Idea: Context sensitive attribute functions.

Dennis dkorpel at gmail.com
Tue Jun 19 21:06:16 UTC 2018


On Tuesday, 19 June 2018 at 19:03:44 UTC, 12345swordy wrote:
> Why not use them if given the opportunity based on its context?

You can do that if you want
```
import std.stdio;
import core.stdc.stdio;

void main() @nogc {
     int a = 8;
     static if (__traits(compiles, new int(0))) {
         writefln("writeln %d", a);
     } else {
         printf("printf %d", a);
     }
}
```


More information about the Digitalmars-d mailing list