Trying to get current function name results in compiler error with __traits

Arun Chandrasekaran aruncxy at gmail.com
Fri Dec 7 02:37:34 UTC 2018


I'm trying to get the current function name and apparently the 
commented line errors out.

What am I doing wrong?

https://run.dlang.io/is/EGsRU2

```
#!/usr/bin/rdmd

void main()
{
     import std.experimental.all;
     void foo() {
         // __traits(identifier, mixin(__FUNCTION__)).writeln; // 
compilation error
         __FUNCTION__.split('.')[$-1].writeln;
     }
     __traits(identifier, mixin(__FUNCTION__)).writeln;
     __FUNCTION__.split('.')[$-1].writeln;
     foo();
}
```



More information about the Digitalmars-d-learn mailing list