DIP69: problem with scope grammar - need a new keyword

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 8 12:14:08 PST 2014


On 12/8/2014 11:57 AM, deadalnix wrote:
> On Monday, 8 December 2014 at 10:37:29 UTC, Walter Bright wrote:
>> On 12/8/2014 1:52 AM, deadalnix wrote:
>>> On Monday, 8 December 2014 at 09:46:03 UTC, Walter Bright wrote:
>>>> I thought I could make this work, but it's a problem. There are two meanings
>>>> for scope when attached to a function:
>>>>
>>>>    T func() scope;   // the 'this' pointer is 'scope'
>>>>    scope T func();   // the function returns a 'scope' T
>>>>
>>>> I have some ideas, but don't particularly like any of them. But I don't want
>>>> to bias things, so what ideas do you guys have?
>>>
>>> I'm arguing for ages that qualifier before the return type qualify the return
>>> type, and the one after the implicit argument. I stand by this.
>>
>> Another problem with that is:
>>
>>   void func(scope T delegate() dg);
>
> Nop. I actually made a proposal that was more complete and
> handled such case.
>
> qualifier on the left qualify the return type. qualifier in
> between return type and function/delegate qualify both the symbol
> and the context (it implicit parameter) and qualifier on the
> right qualify only the context.

This would be inconsistent with the rest of the types, where qualifier on the 
left affects the symbol.

But I like the idea of:

    T scope delegate() dg;

as meaning the scope affects the return type. Is that what you meant?


More information about the Digitalmars-d mailing list