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

Paul Backus snarwin at gmail.com
Thu Nov 25 05:02:44 UTC 2021


On Wednesday, 24 November 2021 at 23:50:13 UTC, Dennis wrote:
> Walter describes this existing behavior, as well as a proposed 
> solution to explicitly allow the missing cases, in this 
> bugzilla issue:
> [Issue 22541 - DIP1000: Resolve ambiguity of ref-return-scope 
> parameters](https://issues.dlang.org/show_bug.cgi?id=22541)
>
> What do you think of this proposal?

Not a fan. It's a special case, *and* it's completely invisible 
to anyone who hasn't read the language spec cover-to-cover.

IMO we should only do this if we also apply it to `return ref`, 
and deprecate the `return` attribute in any position other than 
immediately before `ref` or `scope`—i.e., we essentially make 
`return ref` and `return scope` into "compound keywords".

Another thing I'd like to see addressed by this (or any) proposal 
is how it interacts with attribute inference. Do these new 
combinations *only* work when the attributes are explicitly 
given, rather than inferred? If so, that will mean that they 
cannot be used in many cases for generic code—e.g., if my 
template function may call a user-defined copy constructor of 
some generic type `T`, I cannot manually mark that parameter as 
`return scope`, since I do not know in advance whether the copy 
constructor conforms to those attributes.


More information about the Digitalmars-d mailing list