Destructor semantics

Michel Fortin michel.fortin at michelf.com
Wed Aug 11 12:43:10 PDT 2010


On 2010-08-11 15:09:45 -0400, Jonathan M Davis <jmdavisprog at gmail.com> said:

> On Wednesday, August 11, 2010 11:33:54 Michel Fortin wrote:
>> I'm not too sure that'll work very well. I think a better solution
>> would be to have a way to distinguish between a struct that can be put
>> on the GC heap and one that cannot. A struct that cannot go on the GC
>> heap make it safe to access GC-managed members in its destructor, and
>> thus can have a @safe destructor.
> 
> But couldn't the fact that a struct has a destructor make it so that it 
> can't be
> declared anywhere but on the heap? The destructor itself could be what
> distinguishes them. I don't see a need for any other @attributes or whatnot to
> distinguish them.

Sure, and now you can't use std.containers.Array as a member in a 
Class, neither std.stdio.File, etc. Is there something left classes can 
do?

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list