| Thread overview | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 08, 2014 DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
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 Re: DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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 Re: DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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 Re: DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
Posted in reply to deadalnix | 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 Re: DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
Posted in reply to John Colvin | 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 Re: DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
Posted in reply to deadalnix | 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 Re: DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
Posted in reply to deadalnix | 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 Re: DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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 Re: DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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 Re: DIP69: problem with scope grammar - need a new keyword | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | 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'.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply