Proposal: ClassInfo hasFinalizer field

dsimcha dsimcha at yahoo.com
Sat Jun 4 21:28:58 PDT 2011


On 6/4/2011 11:45 PM, Walter Bright wrote:
>
> One issue is that if someone derives from a class and adds a finalizer.

One issue I did forget, though, is that these "empty" finalizers do 
deallocate the object's monitor.  (For those not familiar with these 
details, D classes contain a hidden monitor field that is null 
initially.  When you do synchronized(someClass), the monitor is lazily 
initialized.)  I guess we could get around this by setting the finalize 
bit in the monitor initialization code rather than upfront, for classes 
that don't do any other finalization.  This would almost always be more 
efficient than the status quo since very few classes use monitors.


More information about the Digitalmars-d mailing list