mixins: Shouldn't this work?

mike vertex at gmx.at
Wed Jan 3 15:20:41 PST 2007


Hi!

I've got this idea:

' import std.stdio;
'
' debug
' {
'     void trace(char[] T)()
'     {
'         scope (failure) writefln("Trace: ", T);
'     }
' }
' else
' {
'     void trace(char[] T)()
'     {
'     }
' }
'
' float foo(float x, float y)
' {
'     mixin trace!("foo");
'     return x / y;
' }
'
' void bar()
' {
'     writefln("result: ", foo(0., 0.));
' }

As far as I understand it, the "scope (failure) ..." would be mixed into  
foo's scope, so as soon as foo throws, the trace message should be  
displayed.

' mixin trace!("msg");

is much nicer than

' debug scope (failure) writefln("msg");

Oh, and congrats on 1.0! :)
Hope D gets picked up by lots of people now!

-mike

-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list