Eliminate class allocators and deallocators?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Oct 6 19:36:59 PDT 2009


Leandro Lucarella wrote:
> Andrei Alexandrescu, el  6 de octubre a las 11:01 me escribiste:
>> Hello,
>>
>>
>> D currently allows defining class allocators and deallocators. They
>> have a number of problems that make them unsuitable for D 2.0. The
>> most obvious issue is that D 2.0 will _not_ conflate destruction
>> with deallocation anymore: invoking delete against an object will
>> call ~this() against it but will not recycle its memory.
> 
> I don't think it is a good idea (GC-wise) to say that in the specs.
> I think the GC implementor should be free to decide if a delete really
> free the memory or not. Some collectors can do this very naturally (like
> the current one) and some others don't (like allocators that uses
> pointer-bump allocation). I think the language should divide destruction
> and deallocation, but I don't think is a good idea not to notify the GC at
> all when delete is used. I think the GC should be able to do whatever it
> feels is good for him (so the user should not rely either on the memory
> being actually freed or otherwise).
> 

I agree insofar as a GC could be tipped by the compiler that no live 
reference of the object exists after delete.

Andrei



More information about the Digitalmars-d mailing list