DIP 1019--Named Arguments Lite--Final Review

bachmeier no at spam.net
Fri Aug 23 17:16:16 UTC 2019


On Friday, 23 August 2019 at 16:47:14 UTC, H. S. Teoh wrote:
>> I'm personally not a fan of those argument lists the size of 
>> the Magna
>> Cartas like you see in Python libraries:
>> https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.lines.Line2D.html#matplotlib.lines.Line2D
>> I don't see it as a loss that this DIP doesn't enable those in 
>> D. If
>> your function takes more than 6 arguments you should really 
>> consider
>> creating a struct with configuration data.
> [...]
>
> But this DIP neither enables nor disables inordinately long 
> parameter lists: the language already allows them!  The only 
> thing worse than an overly-long parameter list is one in which 
> you cannot (easily) tell which argument corresponds with which 
> parameter, and that's something this DIP would fix (by letting 
> you name the arguments so that they are self-documenting).  So 
> your argument doesn't really detract from this DIP.

Hopefully we don't make changes to the language in order to 
reduce the cost of bad programming practice. There's a real cost 
to encouraging long parameter lists, because while the "usual" 
case isn't so bad:

foo(x: 4, y: 8)

the case where you specify nine parameters is quite ugly, 
spilling onto multiple lines and making it hard to read. IMO, 
it's okay to make language design decisions assuming existing 
data structures (structs in this case) will be used when they're 
appropriate.


More information about the Digitalmars-d mailing list