Named Arguments Status Update
Dennis
dkorpel at gmail.com
Fri Jan 5 10:53:48 UTC 2024
On Friday, 5 January 2024 at 10:06:15 UTC, Richard (Rikki) Andrew
Cattermole wrote:
> I would error on two fronts:
That's not how value sequences work today.
```D
void f(int, int);
f(AliasSeq!(), 1, 2); // ok, equal to f(1, 2)
```
> Clearly something was amiss when the programmer wrote it.
Consider generic code, where you could have a static array of
generic size that you pass to a function with `.tupleof`. It
should just work with a zero-size `int[0]` without special cases.
> This seems like something that should have already been checked.
The example is a simple case, but the template constraints may be
arbitrarily complex. Consider:
```D
string f(T : string)(T x) { return "x"; }
string f(T )(T y) { return "y"; }
```
Now the original case with `T=int` works fine, but the problem
re-emerges only with `T=string`.
> I would go with z. As it is an aggregate.
Type tuples are not aggregates currently.
> So the current behavior is correct.
Current behavior would name it `x`, not `z`.
>> ## Forwarding?
>
> Language is lacking, until that is resolved named arguments
> shouldn't be trying to shoehorn it in.
Agreed
More information about the Digitalmars-d
mailing list