OSNews article about C++09 degenerates into C++ vs. D discussion

Sean Kelly sean at f4.ca
Tue Nov 21 09:07:36 PST 2006


Mike Capp wrote:
> Sean Kelly wrote:
> 
>> A lot of this can be handled by "scope."  Though I grant that using
>> objects for the rest and relying on the GC for clean-up is possibly not
>> ideal for resources that must be cleaned up in a timely manner.
> 
> Indeed. Long, long ago I suggested disallowing destructors for classes not
> declared 'scope' (or 'auto', as it was then), on the grounds that if you need
> stuff done there you really don't want to rely on the GC to do it.
> 
> It was a bit of a Devil's Advocate thing, but the response was surprisingly
> positive, and (as I recall) nobody came up with a counterexample where a dtor was
> needed but timeliness wasn't.

I've actually got a test build of Ares (not sure if it's in SVN) that 
hooks the GC collection process so the user can be notified when an 
object is being cleaned up and can optionally prevent the object's dtor 
from being run.  The intent is to allow the user to detect "leaks" of 
resources intended to have deterministic scope and to allow the dtors of 
such objects to perform activities normally not allowed in GCed objects. 
  I haven't used the feature much yet in testing, but it seems a good 
compromise between the current D behavior and your suggestion.


Sean



More information about the Digitalmars-d mailing list