Template accepting code blocks as a parameter.
Andrew Fedoniouk
news at terrainformatica.com
Tue Feb 28 13:37:24 PST 2006
Let's say I'll be able to define mixin template which
is able to accept block of code (aka closure) as a parameter.
So if I declare something like this:
template on_scope_exit(B: void delegate() )
{
auto ScopeGuard sc#__LINE__ = new ScopeGuard(B);
}
then I would like to be able to write something like this
mixin on_scope_exit! { delete foo; }
Which will expand to something like this at the point of mixin:
auto ScopeGuard sc1234 = new ScopeGuard( { delete foo; } );
This is just a rough idea.
Having this will allow to define onScope*** in the way that task needs
and I beleive it will be useful in other places too.
Andrew
http://terrainformatica.com
More information about the Digitalmars-d
mailing list