Mixin Template: cannot mixin scope(exit)?

1100110 0b1100110 at gmail.com
Sun Jan 13 21:35:24 PST 2013


Ok,  I wish to create a standard timing system so that I can measure 
~how long each function takes to execute.

I wish to be able to place at the start of a function
version(Time) mixin TimeExecution("funcName");

mixin template TimeExecution(T) if(isSomeString!T) {
     import std.stdio, std.datetime, std.conv;

     auto sw = StopWatch(AutoStart.yes);
     //	Error: Declaration expected, not '('
     scope(exit) writeln(T, ": ", to!Duration(sw.peek));
}


Why do I receive the Error when the scope statement is included?
Is this an error, or what is the rationale behind the decision?

Thank you.


More information about the Digitalmars-d-learn mailing list