DIP 1030--Named Arguments--Community Review Round 1 Discussion
Adam D. Ruppe
destructionator at gmail.com
Tue Feb 11 14:51:25 UTC 2020
On Tuesday, 11 February 2020 at 14:22:30 UTC, Steven
Schveighoffer wrote:
> Manu's example doesn't work, but this would (and I use this all
> the time):
>
> auto wrapper(alias originalFunction, T...)(T args) if (...) //
Yeah, I use that a lot too.
> What if fn has 10 different overloads?
static foreach(overload; __traits(getOverloads, item, fun))
static if(is(typeof(overload) Params == __parameters))
auto wrap(Params p) {
return overload(p);
}
Which has advantages over the T... in terms of error messages and
future reflection. Also works in interfaces and similar.
So I agree with you that the names in variadics would be super
cool for lots of reasons. I'm meh on if it is *required* but I
certainly do prefer it.
Just still knowing these techniques are useful anyway so I take
any chance to educate :)
More information about the Digitalmars-d
mailing list