Attributes on Enum Members: Call for use cases.

Timon Gehr timon.gehr at gmx.ch
Thu Nov 30 08:34:12 UTC 2017


On 29.11.2017 20:49, Steven Schveighoffer wrote:
> 
> 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)
> ...

Your suggestion is missing the parameter name.

>  ...
>>
>> auto weird(){
>>      int x;
>>      void foo(@x int y){}
>>      return &foo;
>> }
>>
>> pragma(msg, typeof(weird())); // ?
> 
> void delegate(int)
> 
> -Steve

Just noticed this:

auto weird(){
      int x=3;
      int foo(int y=x){ return y; }
      return &foo;
}
pragma(msg, typeof(weird)); // int delegate(int y = x)

I.e., we have "Voldemort initializers".


More information about the Digitalmars-d mailing list