auto classes and finalizers

kris foo at bar.com
Wed Apr 5 22:15:42 PDT 2006


Jarrett Billingsley wrote:
> "Dave" <Dave_member at pathlink.com> wrote in message 
> news:e11vjk$1fou$1 at digitaldaemon.com...
> 
>>Long and short of it is I like Mike's ideas regarding allowing dtors for 
>>only
>>auto classes. In that way, the GC wouldn't have to deal with finalizers at 
>>all,
>>or at least during non-deterministic collections. It would also still 
>>allow D to
>>claim RAII because 'auto' classes are something new for D compared to most 
>>other
>>languages.
> 
> 
> Hmm.  'auto' works well and good for classes whose references are local 
> variables, but .. what about objects whose lifetimes aren't determined by 
> the return of a function?
> 
> I.e. the Node class is used only in LinkedList.  When a LinkedList is 
> killed, all its Nodes must die as well.  Since the Node references are kept 
> in the LinkedList and not as local variables, there's no way to specify 
> 'auto' for them.

Heck, the LinkedList dtor /cannot/ rely on the nodes being valid if they 
are also managed by the GC :)

So, as I understand it, one cannot legitimately execute that example.

[snip]



More information about the Digitalmars-d mailing list