Simple implementation of __FUNCTION
Jonathan M Davis
jmdavisProg at gmx.com
Fri Nov 2 14:59:21 PDT 2012
On Friday, November 02, 2012 22:34:15 Philippe Sigaud wrote:
> 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?
Identifiers starting with __ are reserved for the compiler/language. It should
be __FUNCTION__ if it's built-in, but if it's in the library, I see no reason
to name it in a way that conflicts with Phobos' naming conventions like this.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list