DIP1000: Walter's proposal to resolve ambiguity of ref-return-scope parameters
Paul Backus
snarwin at gmail.com
Thu Nov 25 19:35:53 UTC 2021
On Thursday, 25 November 2021 at 16:11:39 UTC, Dennis wrote:
> On Thursday, 25 November 2021 at 15:57:13 UTC, WebFreak001
> wrote:
>> with `return ref` and `return scope`, will there also be a
>> `return this` for the case like the opIndex functions
>> returning something with the lifetime of the containing
>> struct? I don't quite get how it's otherwise fixing it.
>
> `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 {
>
> }
> }
> ```
Seems like we may be reaching the point where it's worth it to
make the `this` parameter explicit, like it is in Python and Rust:
```d
struct S {
ref int opIndex(return ref scope this) {
// ...
}
}
```
More information about the Digitalmars-d
mailing list