Simple implementation of __FUNCTION

Philippe Sigaud philippe.sigaud at gmail.com
Fri Nov 2 14:34:15 PDT 2012


By changing this to a standard function:

const(char[]) __FUNCTION() @property
{
   return "__traits(identifier, __traits(parent, {}))";
}


... the calling syntax is slightly easier on the eye:

void main()
{
    writefln( "File: %s, Func: %s, Line: %d", __FILE__,
mixin(__FUNCTION), __LINE__ );

    //throw new Exception( "Error: Function " ~ mixin(__FUNCTION) );
}

That is, mixin(__FUNCTION) instead of mixin(__FUNCTION!())


Is there any downside to this?


More information about the Digitalmars-d mailing list