inout and function/delegate parameters

Steven Schveighoffer schveiguy at yahoo.com
Fri Mar 9 16:53:18 PST 2012


On Fri, 09 Mar 2012 19:44:20 -0500, Stewart Gordon <smjg_1998 at yahoo.com>  
wrote:

> On 19/02/2012 14:27, Stewart Gordon wrote:
> <snip>
>> int opApply(int delegate(ref inout(T)) dg) inout;
>>
>> But then I realised a potential ambiguity:
>> (a) the constancy is passed through to the delegate
>> (b) the delegate has an inout parameter in its own right
> <snip>
>
> Thinking about it, if we go with (a), then (b) can be achieved by  
> defining an alias of the delegate type.  Just one problem I can see:  
> since a signature that uses (b) can't be represented in code without an  
> alias, how would compiler messages, .stringof and TypeInfo notate the  
> type?
>
> But if we go with (b), then there doesn't seem to be a way to achieve  
> (a) without inventing new syntax.

As I recently mentioned in the bug report, (b) must be the case without  
any additional syntax, because otherwise you have two types with identical  
syntax, but different underlying types.

In order to do (a), we need new syntax.  That's not a good thing, but not  
the end of the world.

-Steve


More information about the Digitalmars-d mailing list