DIP 1016--ref T accepts r-values--Final Review
kinke
noone at nowhere.com
Sat Nov 17 14:49:26 UTC 2018
On Saturday, 17 November 2018 at 13:01:12 UTC, Rubn wrote:
> For this what about if there are multiple parameters? How many
> overloads do you have to define to get this behavior?
I'd assume a single one. It should be analogous to this:
```
void lval_only(uint x, short y) @disable;
void lval_only(int x, int y);
void main()
{
byte y = 1;
lval_only(100_000, y);
}
```
The disabled function is preferred, so this doesn't compile. As
by-value params are to be preferred for rvalue args in overload
resolution, the single overload should do in your example.
---
I'm a huge fan of this DIP and have been wanting this in the
language literally since the day I wrote my first D code,
immediately stumbling into this limitation (but fortunately not
losing much interest due to numerous advantages and syntax
loveliness).
More information about the Digitalmars-d
mailing list