More radical ideas about gc and reference counting

monarch_dodra via Digitalmars-d digitalmars-d at puremagic.com
Fri May 2 13:59:44 PDT 2014


On Friday, 2 May 2014 at 16:20:47 UTC, Andrei Alexandrescu wrote:
> On 5/2/14, 9:04 AM, fra wrote:
>> On Wednesday, 30 April 2014 at 20:21:33 UTC, Andrei 
>> Alexandrescu wrote:
>>> I think there's no need to argue that in this community. The 
>>> GC never
>>> guarantees calling destructors even today, so this decision 
>>> would be
>>> just a point in the definition space (albeit an extreme one).
>>
>> I think I (we) need a bit of clarification.
>> Docs in http://dlang.org/class.html#destructors states that: 
>> "The
>> garbage collector calls the destructor function when the 
>> object is
>> deleted."
>> As far as I understand, this means that destructors are always 
>> called
>> when an instance is collected. Is this right?
>> Doesn't this mean that destructors are guaranteed to run for
>> unreferenced objects if we force the GC to do a full collect 
>> cycle?
>
> False pointers make it seem like unreferenced objects are in 
> fact referenced, so fewer destructors will run than there 
> should. -- Andrei

Yeah, you have to read the "fine print": "collection implies 
destruction" *but* "no guarantees the collection will actually 
ever happen".


More information about the Digitalmars-d mailing list