first draft Reducing the legal permutations of ref-return-scope
Dennis
dkorpel at gmail.com
Tue May 13 09:27:26 UTC 2025
On Tuesday, 13 May 2025 at 04:23:05 UTC, Walter Bright wrote:
> https://github.com/WalterBright/documents/blob/master/ReturnRefScope.md
I like the idea.
> The trouble is it's forgettable which order means what
From what I've heard, what's most confusing is that order matters
at all. Usually attributes are order independent: there's no
difference between `const private @safe` and `private @safe
const`. So `scope return` being subtly different than `return
scope` is very surprising.
> scope return was given special meaning
*`return scope` was given special meaning
> For a parameter to be returning a ref, return ref will be
> required
What about the implicit `ref this` parameter?
```D
struct S
{
int* f() return; // doesn't comply with DIP text
int* g() return ref; // syntax error currently
}
```
Also what about variations on `return scope`?
```D
int* f(return scope int* p); // recommended
int* g(return int* p); // currently allowed
int* h(scope return int* p); // currently allowed
```
More information about the dip.development
mailing list