Attributes on Enum Members: Call for use cases.

Timon Gehr timon.gehr at gmx.ch
Wed Nov 29 19:01:29 UTC 2017


On 29.11.2017 19:18, Steven Schveighoffer wrote:
> On 11/29/17 12:20 PM, Timon Gehr wrote:
>>
>> I don't understand what you mean. Function types _contain_ parameter 
>> declarations. (Including attributes and default initializers.)
> 
> I too, am confused. I thought you meant that the types of the parameters 
> would have attributes that might conflict/merge with the attributes 
> declared on the parameters.
> 
> So maybe a snippet of code to further explain your concern?
> 
> -Steve

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)?
pragam(msg, typeof(&bar)); // int function(@attribute2 int x)?

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

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

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

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


More information about the Digitalmars-d mailing list