DIP 1030-- Named Arguments--Formal Assessment

zoujiaqing zoujiaqing at gmail.com
Mon Dec 7 12:13:35 UTC 2020


On Thursday, 17 September 2020 at 12:58:06 UTC, Mike Parker wrote:
> DIP 1030, "Named Arguments", has been accepted.
>
> During the assessment, Walter and Atila had a discussion 
> regarding this particular criticism:
>
> https://forum.dlang.org/post/mailman.1117.1581368593.31109.digitalmars-d@puremagic.com
>
> "Named arguments breaks this very important pattern:
>
> auto wrapper(alias origFun)(Parameters!origFun args)
> {
>   // special sauce
>   return origFun(args);
> }"
>
> They say that, though it's true that `Parameters!func` will not 
> work in a wrapper, it "doesn't really work now"---default 
> arguments and storage classes must be accounted for. This can 
> be done with string mixins, or using a technique referred to by 
> Jean-Louis Leroy as "refraction", both of which are clumsy.
>
> So they decided that a new `std.traits` template and a 
> corresponding `__traits` option are needed which expand into 
> the exact function signature of another function.
>
> They also acknowledge that when an API's parameter names 
> change, code depending on the old parameter names will break. 
> Struct literals have the same problem and no one complains (the 
> same is true for C99). And in any case, when such a change 
> occurs, it's a hard failure as any code using named arguments 
> with the old parameter names will fail to compile, making it 
> easy to see how to resolve the issue. Given this, they find the 
> benefits of the feature outweigh the potential for such 
> breakage.

Very practical features, similar to trailing closures, are 
expected.


More information about the Digitalmars-d-announce mailing list