[D-runtime] Precise garbage collection

Michel Fortin michel.fortin at michelf.ca
Wed Aug 7 18:05:01 PDT 2013


Le 7-août-2013 à 16:42, Rainer Schuetze <r.sagitario at gmx.de> a écrit :

> I'm also hoping for a comment on the ambiguity of TypeInfo_Class. If implementing TypeInfo_Reference, what would TypeInfo_Reference.toString return? "C ref" as in Michel Fortin's implementation of tail const references? ;-)

Funny problem. But there's no ambiguity really because you can't create using "new" a memory block that'll only contain a reference to an object. You can thus be sure that if the root type of a memory block is a TypeInfo_Class it truly is an object of that class; and if a *variable* has TypeInfo_Class then it's a reference.

Even my const(Object)ref patch did not change that. Try "new (C ref)()" or "new (const(C)ref)()" and you'll get a new object and not a pointer to a reference to the object. The "ref" part here was purely a syntactic mean to change the head-constness of the object type.

(Side note: Internally in the compiler there was a reference type created in some cases but it was mostly an implementation detail to facilitate propagating and checking for const. Most of the compiler code did not touch it, and that type was only used when the head-constness was different from the tail-constness anyway.)

-- 
Michel Fortin
michelfortin at aranatha.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: poissoonnnn.bmp
Type: image/bmp
Size: 20848 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/d-runtime/attachments/20130807/1476b923/attachment-0001.bin>
-------------- next part --------------

-- 
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca



More information about the D-runtime mailing list