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

Dukc ajieskola at gmail.com
Fri Nov 26 08:58:21 UTC 2021


On Thursday, 25 November 2021 at 16:11:39 UTC, Dennis wrote:
>
> `return this` in struct member functions is `return ref`. 
> Walter proposes in the bugzilla issue to allow `ref` after the 
> parameter list:
>
> ```D
> struct S {
>     ref int opIndex() return ref scope {
>
>     }
> }
> ```

Perhaps it still makes sense to allow free `return` qualifier 
with member functions? The invisible `this` parameter is 
implicitly `ref`, so that repeating `ref` just for the `return` 
qualifier wouldn't be needed.

We might still require the `return` for the invisible `ref this` 
to be the last qualifier, so no `ref int opIndex() return const 
scope` or anything like that.



More information about the Digitalmars-d mailing list