DIP1000: Walter's proposal to resolve ambiguity of ref-return-scope parameters

Paul Backus snarwin at gmail.com
Fri Nov 26 15:04:00 UTC 2021


On Friday, 26 November 2021 at 10:32:54 UTC, ShadoLight wrote:
> On Friday, 26 November 2021 at 02:03:41 UTC, Paul Backus wrote:
>>
>> * Allow `return ref` and `return scope`.
>> * Forbid the `return` storage class from appearing in any 
>> other context.
>>
>
> As an occasional D(hobby) user but long-time lurker on this 
> forum... it has been noticeable t me that D is gradually 
> approaching C++ in complexity!
>
> Something like this, as you hinted,...
>
>> ```d
>> struct S {
>>     ref int opIndex(return ref scope this) {
>>         // ...
>>     }
>> }
>> ```
>
> ... are inevitably going to be confusing to newbies.
>
> Personally what I think would help is to somehow 'link' those 
> keywords together that is a single entity i.e. in your example 
> `return ref` and `return scope` becomes `return-ref` and 
> `return-scope`.

Yes, I also think this would be ideal. Someone in a previous 
thread proposed the syntax `return(ref)` and `return(scope)`, 
which would make this possible without introducing new keywords.

However, given the stance Walter and the rest of the core team 
have towards breaking changes, I don't think it's likely they'd 
accept a proposal like this, which makes no concession at all to 
existing usage.


More information about the Digitalmars-d mailing list