Why will the delete keyword be removed?

Vladimir Panteleev vladimir at thecybershadow.net
Wed Jul 14 14:08:40 PDT 2010


On Wed, 14 Jul 2010 22:43:00 +0300, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> You mean class objects, right? I agree. I think it's okay to fill the  
> object with its stateless .init members, which would assuage the issue.

Then that object may be in an invalid state, in cases when valid states  
are created by the constructor.

Also, what about classes which don't have a default constructor?

It is my understanding that you are trying to add something to the  
language which would destroy an object without deallocating it (and  
deprecate everything that involves on-the-spot deallocation), in order to  
allow creating simpler and more efficient garbage collectors. The only  
correct solution seems to be to call the destructor, and mark the object  
instance as invalid. The release version needn't do anything, the debug  
version can stomp on the object's memory to make sure that any code that  
attempts to access the object crashes quickly. (This is practically the  
same as deallocation, as far as the user can see - the difference lies in  
that the GC doesn't do anything immediately.)

-- 
Best regards,
  Vladimir                            mailto:vladimir at thecybershadow.net


More information about the Digitalmars-d mailing list