DIP1000: 'return scope' ambiguity and why you can't make opIndex work
Dennis
dkorpel at gmail.com
Sat Jun 19 14:54:22 UTC 2021
On Saturday, 19 June 2021 at 14:39:01 UTC, Dukc wrote:
> No thanks. The compiler still has ambiguity between
>
> ```d
> ref float opIndex(return(scope) ref __this, size_t i);
> return(scope) ref float opIndex(ref __this, size_t i);
> ```
> It's simpler and better if `return` attribute outside the
> parameter list always binds to `this`.
There is no ambiguity, `return` and `scope` outside the parameter
list *always* bind to `this`, whether you put them on the left or
right.
```D
scope int* f(); // Error: function `onlineapp.f` functions cannot
be `scope`
int* g() scope; // Error: function `onlineapp.g` functions cannot
be `scope`
```
(Nice error message btw)
More information about the Digitalmars-d
mailing list