DIP 1030--Named Arguments--Community Review Round 1 Discussion

Steven Schveighoffer schveiguy at gmail.com
Tue Feb 11 14:22:30 UTC 2020


On 2/11/20 8:56 AM, Adam D. Ruppe wrote:
> On Tuesday, 11 February 2020 at 09:02:03 UTC, Timon Gehr wrote:
>> What if fn is a template?
> 
> Then, as I'm sure you already know, it won't work. It needs an 
> instantiation to wrap in this style. Same with Manu's code though so 
> we've lost nothing.

Manu's example doesn't work, but this would (and I use this all the time):

auto wrapper(alias originalFunction, T...)(T args) if (...) // makes 
sure we can call the function
{
     return originalFunction(args);
}

> Can be slightly annoying with stuff like `to!int`, you'd have to 
> `wrap!(to!it)...`
> 
> A generic forwarder would be variadic and thus this DIP doesn't apply to 
> it regardless. (Though, in a previous review on github for this I 
> proposed a way to handle that - make a variadic template with named 
> params form an anonymous struct that the receiving template can process. 
> Similar to Python's kwargs I'm told. Got pushback and I decided to table 
> it, even though it would provide a lot of cool flexibility so hoping we 
> can come back to it later.)

What if fn has 10 different overloads? You have to provide all of them. 
Where as a template forwarder as above just works.

I think we need to solve this problem in a "just works" way before 
having named parameters.

-Steve


More information about the Digitalmars-d mailing list