Return by 'ref' problems...

Timon Gehr timon.gehr at gmx.ch
Fri May 4 07:57:14 PDT 2012


On 05/04/2012 04:53 PM, Jakob Ovrum wrote:
> On Friday, 4 May 2012 at 14:34:20 UTC, Timon Gehr wrote:
>> It is an attribute:
>>
>> int x;
>> ref {
>>     int foo(){ return x; }
>>     int bar(){ return x; }
>> }
>>
>> ref:
>>
>> int qux(){ return x; }
>>
>> static assert(typeof(&qux).stringof == "int function() ref");
>
> Thanks, this is news to me! I never noticed that ref was actually a
> function attribute.
>
> The following are legal declaration statements:
>
> extern(C) void function() foo;
> pure void function() bar; // not just linkage attributes
>
> So I think it's a plain bug that this isn't:
>
> ref void function() foo;
>
>

What would be the meaning of

void foo(ref void function() fn) { }

?


More information about the Digitalmars-d mailing list