Mixins for GC-Flexibility?

Russ Lewis spamhole-2001-07-16 at deming-os.org
Mon Nov 20 16:58:37 PST 2006


People, including me, have asked before that Walter add hooks that would 
enable refcounting collectors.  This requires hooks, at least, which are 
called when a reference is first initialized, when it is modified, and 
when it is destroyed.

Walter has responded that it is impractical to add these, one reason 
being the runtime overhead of calling these hooks.  (Sorry, Walter, if 
I've forgotten other reasons.)

What if the compiler inserted a mixin, defined in object.d, to each such 
event?  In the default library, that mixin would be empty, incurring 
zero runtime cost.  In alternate collectors, it could be non-empty, and 
would insert actions without the requirement of calling a library function.

Obviously, this would mean that you would have to make a compile-time 
decision which library you are going to link to, but I would be very 
surprised if we weren't required to do that already.  Ofc, if you really 
valued runtime plugability, then your mixin could call a pluggable function.

Thoughts?



More information about the Digitalmars-d mailing list