Named Arguments Status Update - Empty Tuple Value

Timon Gehr timon.gehr at gmx.ch
Tue Jan 9 13:25:49 UTC 2024


On 1/9/24 00:52, Walter Bright wrote:
> 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.
> 

I fully agree with your analysis above. This should error.


More information about the Digitalmars-d mailing list