Named Arguments Status Update - Empty Tuple Value

Walter Bright newshound2 at digitalmars.com
Mon Jan 8 23:52:00 UTC 2024


On 1/5/2024 1:48 AM, Dennis wrote:
> ## Empty tuple value
> 
> ```D
> alias AliasSeq(T...) = T;
> 
> int f(int x, int y) { return 0; }
> 
> int v = f(y: AliasSeq!(), 1, 2);
> ```
> 
> Currently, the named argument y with an empty tuple will collapse into nothing, 
> and `(1, 2)` will be assigned to `(x, y)`.
> - Should this be an error?
> - Should this assign `1` to `y`?

My intuition says that an empty tuple is nothing at all, and should just be 
elided from consideration. Trying to assign nothing to parameter `y` doesn't 
make sense, and it should error.

In fact, trying to assign a tuple to `y` that is anything other than one element 
should be an error.

Timon knows more about tuples than I do, so his input would be most welcome.



More information about the Digitalmars-d mailing list