Binding rvalues to ref parameters redux

Nicholas Wilson iamthewilsonator at hotmail.com
Tue Apr 2 23:40:42 UTC 2019


On Monday, 1 April 2019 at 16:43:15 UTC, bitwise wrote:
> On Thursday, 28 March 2019 at 16:07:17 UTC, Nicholas Wilson 
> wrote:
>>
>>> It seems like a waste to have a keyword that's just an alias 
>>> for two others (in = const scope), so why not put 'in' to 
>>> better use, like to qualify a ref parameter as accepting 
>>> rvalues, or to outright replace 'ref' for rvalue-ref 
>>> accepting parameters?
>>
>> Code breakage.
>
> In this case, I think it's worth it.
>
> Dlang's documentation has warned against using 'in' for YEARS:
> https://dlang.org/spec/function.html#param-storage

Try 10 months:
https://github.com/dlang/dlang.org/commit/93411bed24382a08212648c273183d0725cf5dfor
and 15 months for
https://github.com/dlang/dlang.org/commit/71ad1b38d5b5d0a25e383c1dce27e90ed6698f71

> Any code using 'in' right now deserves to break. (but actually, 
> that may not be necessary)

That change is still within our 2 year deprecation period and I 
think it was not a good move.

> So finally, I would suggest that rvalues only bind to 'in ref'.

This comes down to an opt in vs opt out, 'in ref' (leaving aside 
the issues with const) mean that bindings and code must be 
updated to allow use, whereas rvalues not binding to 'out ref' 
allows immediate use. I'm for opt out.



More information about the Digitalmars-d mailing list