DIP 1019--Named Arguments Lite--Final Review

Exil Exil at gmall.com
Sat Aug 24 03:01:17 UTC 2019


>> Furthermore, if this DIP hadn't shot itself in its own foot by 
>> not allowing out-of-order argument passing and skipping 
>> default parameters, then it would have actually made 
>> overly-long parameter lists actually *acceptable*, in the 
>> sense that the function could just supply default values for 
>> most of the parameters, and the caller can just name and pass 
>> the few arguments that it wants to be different from the 
>> defaults, and the rest don't have to be explicitly specified.
>
> It does not always make sense to supply default values for 
> parameters.
>
> e.g createWindow(int width, int height)
>
> What default value do you give them?


See this quite often. Usually values of -1 are used to auto 
calculate based on the contents of the window.

There are a lot of instances default values are used. Named 
parameters are one of the few tools to use to keep those default 
values if you only want to modify one of them and there's 
multiple default value parameters.




More information about the Digitalmars-d mailing list