Eliminate class allocators and deallocators?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Oct 7 05:46:06 PDT 2009
Kagamin wrote:
> I don't see any problem with dispose() method (except that it doesn't
> nullifies the pointer, which can be a performance issue for some GC
> implementations). If you plan to go C# way, it's reasonable to adopt
> its techniques of destruction. Moreover C# and C++ approaches are
> compatible. If the programmer doesn't guarantee ownership of the
> object, it's just unreasonable to call delete, here adding the
> dispose() method to the Object and using it for destruction will
> help.
>
> Your proposal is indeed better than the scheme above and it's not a
> pain to implement and use destruct+free function, but delete and
> dispose are already well-known idioms, as you were already told
> about.
You're right. It would be great to dispose of the delete keyword and
define a member function and/or a free function that invokes the
destructor and obliterates the object with its .init bits.
At any rate: deletion + memory reclamation must go. If you want to do
manual memory management, malloc/free are yours. D's native GC heap is
not the right place.
Andrei
More information about the Digitalmars-d
mailing list