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

Meta jared771 at gmail.com
Thu Feb 20 15:21:51 UTC 2020


On Wednesday, 19 February 2020 at 19:13:01 UTC, Jonathan M Davis 
wrote:
> On Wednesday, February 19, 2020 8:31:00 AM MST Yuxuan Shui via 
> Digitalmars-d wrote:
>> On Friday, 7 February 2020 at 03:33:26 UTC, Jonathan M Davis
>>
>> wrote:
>> > but for the most part, they're useful because a function has 
>> > way too many parameters, in which case, the function should 
>> > have been designed differently.
>>
>> Named parameters are not just for when there are too many 
>> parameters.
>>
>> Easy example:
>>
>>      dup2(a, b);
>>
>> vs
>>
>>      dup2(src: a, dst: b);
>
> Named arguments are completely unnecessary in such a situation. 
> The list of arguments is short enough that it's trivial to know 
> which is which and what they're for.

This is off the mark. Named arguments are very useful even in 
this case (maybe *especially* in this case, when you have to rely 
on the convention that src always comes first and dst always 
comes second). I've been using Groovy a lot at work lately, which 
has support for named arguments (and interpolated strings, by the 
way), and it allows for writing some very clear and readable code.



More information about the Digitalmars-d mailing list