On 02/24/2013 08:19 PM, Timon Gehr wrote:
On 02/24/2013 05:04 PM, jerro wrote:
This code currently compiles:

int bar();
@bar() void foo(){}

But this gives an error, as expected:

int bar();
@bar() void foo(){}
pragma(msg, __traits(getAttributes, foo));

I would expect the first example to give an error too. Is the current
behavior deliberate or is it a DMD bug?

Bug.

Actually the documentation does not treat this at all. However, it is not the behaviour discussed on the newsgroup.

Note that it introduces a funny little macro system into the language.

Eg. this:

import std.stdio;
int x;
@(write(x++),writeln()) void foo(){}

void main(){
    __traits(getAttributes, foo);
    __traits(getAttributes, foo)[0];
    __traits(getAttributes, foo)[0];
}

Outputs:

0
12

Reply via email to