GC conservatism -- again
Simen kjaeraas
simen.kjaras at gmail.com
Thu Dec 30 15:54:15 PST 2010
Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> I'm thinking of an API that allows people to dynamically add "to do"
> stuff, a la C's atexit(). Yours above is dynamic (because client code
> can append to toFree) but is hand-written by the client.
So like this:
import std.stdio;
void delegate()[] terminators;
void atExit( void delegate() dg ) {
terminators ~= dg;
}
static ~this( ) {
foreach ( t; terminators ) {
t( );
}
}
void main( ) {
atExit( {writeln("OH HAI! I BROKE UR THREAD");} );
}
--
Simen
More information about the Digitalmars-d
mailing list