Idea: Context sensitive attribute functions.
12345swordy
alexanderheistermann at gmail.com
Wed Jun 20 15:28:29 UTC 2018
On Tuesday, 19 June 2018 at 21:06:16 UTC, Dennis wrote:
> 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);
> }
> }
> ```
No, it is not the same. You are testing one of the rules that is
defined by the attribute, you are not testing the attribute
itself that is derived by the context that you are in. You code
can't take into account of custom attributes.
Alexander
More information about the Digitalmars-d
mailing list