D classes inherane. How it works.

BCS ao at pathlink.com
Tue Apr 8 22:56:57 PDT 2008


Reply to Robert,

> BCS wrote:
> 
>> that only works in most cases where the object only owns memory
>> resources. If it owns files, mutexes, database connections, stock
>> options or Corvettes, your sunk.
>> 
> Really? I have yet to write a finalize() method in Java. IMO, using
> close() methods for non-memory resources and letting the GC clean up
> the memory makes for less cognitive load than worrying about the order
> of destruction, etc., etc.
> 

My comment was in light of "let the GC handle it". Your suggestion amounts 
to manual memory management (s/memory/resource/). That is fine but to make 
it work you need to keep track of lifetimes which isn't letting the GC do 
it. Personally I'd think the way to handle this kind of thing would be to 
try really hard to make order of destruction irrelevant and let the GC call 
~this().





More information about the Digitalmars-d mailing list