DIP1000: 'return scope' ambiguity and why you can't make opIndex work

Dukc ajieskola at gmail.com
Fri Jun 18 21:44:39 UTC 2021


On Friday, 18 June 2021 at 15:44:02 UTC, Dennis wrote:
> [snip]

Wow, if nothing else you're doing a great job documenting DIP1000 
with your posts. Thanks!

With regular pointers and `ref` parameters, I think we should 
change the semantics of `scope ref` to be simply same as `ref`, 
i.e. no binding `scope` to the underlying pointer. Other than 
that, the semantics you explained are understandable IMO.

I'd prefer to call the `return scope` storage class just a 
`return` storage class. Your post shows they are the same except 
for the corner cases with `ref scope` I just recommended 
ditching. Do you agree?

Of course, we also need to be able to annotate the `this` pointer 
as return. Simplest answer IMO: have `return` storage class for a 
function declaration to always bind to the `this` argument, 
compiler error if there is none. `return` storage class for the 
returned value makes no sense anyway.


More information about the Digitalmars-d mailing list