On 11/29/17 2:01 PM, Timon Gehr wrote:

OK, now I get what you are saying. In the same vein, I tested applying attributes to functions themselves:

@("a") int fun() { return 0; }
pragma(msg, typeof(&fun)); // int function()

@("b") int gun() { return 1; }
pragma(msg, typeof(&gun)); // int function()

void main()
{
  auto f = &fun;
  f = &gun; // works
}

Given that, it seems attributes play no part in the type itself, they are just metadata in the compiler.

I would say:


struct attribute1{}
struct attribute2{}

int foo(@attribute1 int x){ return x; }
int bar(@attribute2 int y){ return y; }

pragma(msg, typeof(&foo)); // int function(@attribute1 int x)?

int function(int)

pragam(msg, typeof(&bar)); // int function(@attribute2 int x)?

same


auto apply(F,A)(F fun,A arg){
     pragma(msg, F); // ? (instantiations below)

same

     return fun(arg);
}

void main(){
     apply(&foo,1); // one instantiation
     apply(&bar,1); // second instantiation, or same instance?

same instance

}

auto weird(){
     int x;
     void foo(@x int y){}
     return &foo;
}

pragma(msg, typeof(weird())); // ?

void delegate(int)

-Steve

Reply via email to