Discussion Thread: DIP 1032--Function pointers and Delegate Parameters...--Community Review Round 1

Timon Gehr timon.gehr at gmx.ch
Sun Apr 5 22:08:45 UTC 2020


On 04.04.20 09:15, Walter Bright wrote:
>> P.S. What about delegate types defined inside functions? Would they 
>> also inherit the functions attributes? @safe pure nothrow void foo() { 
>> alias D = void delegate(); D d; }
> 
> I should think so,

No, please.

> otherwise how could the function call it?

Easy:

void foo()pure{
     alias D = int delegate();
     enum D d = ()=>2;
     enum x = d();
}

Also, there is no need to call it:

auto foo()pure{
     alias D = int delegate();
     D d = ()=>2;
     return d;
}


More information about the Digitalmars-d mailing list