Named Arguments Status Update

Paul Backus snarwin at gmail.com
Fri Jan 5 16:42:14 UTC 2024


On Friday, 5 January 2024 at 09:48:53 UTC, 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`?

The analogous case for array initializers is currently an error:

```d
alias AliasSeq(T...) = T;

void main()
{
     int[2] a = [1: AliasSeq!(), 1, 2];
     // Error: cannot implicitly convert expression `()` of type 
`()` to `int`
}
```

Whatever we decide here, these two cases should probably work the 
same way.


More information about the Digitalmars-d mailing list