Jump to page: 1 2 3
Thread overview
DIP69: problem with scope grammar - need a new keyword
Dec 08, 2014
Walter Bright
Dec 08, 2014
deadalnix
Dec 08, 2014
John Colvin
Dec 08, 2014
Daniel N
Dec 08, 2014
Walter Bright
Dec 08, 2014
Marc Schütz
Dec 08, 2014
Walter Bright
Dec 08, 2014
Walter Bright
Dec 08, 2014
Marc Schütz
Dec 08, 2014
Walter Bright
Dec 08, 2014
H. S. Teoh
Dec 08, 2014
deadalnix
Dec 08, 2014
Walter Bright
Dec 08, 2014
deadalnix
Dec 08, 2014
Paolo Invernizzi
Dec 09, 2014
ketmar
Dec 08, 2014
Dicebot
Dec 08, 2014
Walter Bright
Dec 08, 2014
Mathias LANG
Dec 08, 2014
Rikki Cattermole
Dec 08, 2014
John Colvin
Dec 08, 2014
bearophile
Dec 09, 2014
ketmar
Dec 09, 2014
Manu
December 08, 2014
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?
December 08, 2014
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.
December 08, 2014
On 8/12/2014 10:45 p.m., 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'

T func() scope(this);

or:

T func(scope(this), ARGS);

It is theoretically the first argument after all.

>      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?

December 08, 2014
On Monday, 8 December 2014 at 09:52:02 UTC, 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.

Agreed.
December 08, 2014
On Monday, 8 December 2014 at 10:19:03 UTC, John Colvin wrote:
> On Monday, 8 December 2014 at 09:52:02 UTC, deadalnix wrote:
>> 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.
>
> Agreed.

FWIW: I'm in the same camp.
December 08, 2014
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.

The trouble with that is, for example, __traits(getFuncAttributes, ...) which will return "scope" for both cases.
December 08, 2014
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);
December 08, 2014
On Monday, 8 December 2014 at 10:34:42 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.
>
> The trouble with that is, for example, __traits(getFuncAttributes, ...) which will return "scope" for both cases.

Why would it? A qualifier/stc for the implicit `this` parameter is not a function attribute.
December 08, 2014
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);

Playing the devil's advocate:

    void func(scope(T delegate()) dg);
    void func(scope(T) delegate() dg);
December 08, 2014
On 12/8/2014 2:44 AM, "Marc Schütz" <schuetzm@gmx.net>" wrote:
> On Monday, 8 December 2014 at 10:37:29 UTC, Walter Bright wrote:
>> Another problem with that is:
>>
>>   void func(scope T delegate() dg);
>
> Playing the devil's advocate:
>
>      void func(scope(T delegate()) dg);
>      void func(scope(T) delegate() dg);

Note that:

    void func(ref T delegate() dg);

has the same problem. The only way to make dg return a 'ref T' is to use an alias:

    alias ref T delegate() dg_t;
    void func(dg_t dg);

or put 'ref' as a postfix:

     void func(T delegate() ref dg);

But if the latter solution is used for 'scope', then it interferes with 'scope this'.
« First   ‹ Prev
1 2 3