Destructor nonsense on dlang.org

Alex Rønne Petersen alex at lycus.org
Thu May 24 09:10:31 PDT 2012


On 24-05-2012 18:06, Andrei Alexandrescu wrote:
> On 5/24/12 9:57 AM, Alex Rønne Petersen wrote:
>> On 24-05-2012 16:54, Andrei Alexandrescu wrote:
>>> On 5/24/12 9:28 AM, Alex Rønne Petersen wrote:
>>>> The GC should (and probably does) assume at shutdown that all objects
>>>> are unreferenced, and therefore reclaim and finalize them.
>>>
>>> They may refer to one another.
>>>
>>> Andrei
>>>
>>
>> Doesn't matter: Nothing is guaranteed about order of finalization (and
>> this is reasonable). Thus, the finalizers can be run in any arbitrary
>> order. The important point here is that they are run *at all*.
>
> It does matter because a destructor may use an object that has just been
> destroyed.
>
> Andrei
>

No, the docs specifically state that this is invalid (and it currently 
throws InvalidMemoryOperationError in most cases).

Whether it *should* be allowed is arguable, but it isn't currently, both 
in docs and impl.

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d mailing list