Idea: Context sensitive attribute functions.
Dennis
dkorpel at gmail.com
Tue Jun 19 21:11:10 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
Although it doesn't seem to work in attribute interference of
templates.
```
void main() @nogc {
example();
}
void example()() {
int a = 8;
static if (__traits(compiles, new int(0))) {
writefln("writeln %d", a);
} else {
printf("printf %d", a);
}
}
```
onlineapp.d(5): Error: @nogc function D main cannot call
non- at nogc function onlineapp.example!().example
Maybe there's some workaround?
More information about the Digitalmars-d
mailing list