DIP 1019--Named Arguments Lite--Final Review

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Aug 23 16:47:14 UTC 2019


On Fri, Aug 23, 2019 at 04:19:51PM +0000, Dennis via Digitalmars-d wrote:
> On Friday, 23 August 2019 at 15:01:20 UTC, Andrei Alexandrescu wrote:
> > Large parameter lists of which most have reasonable defaults is a
> > marquee use case of named arguments. A proposal that works itself
> > out of that opportunity cannot and should not be acceptable.

Exactly the same objections I have against this DIP.  OT1H it's trying
to get named arguments into the language, but OTOH it takes out what I
would consider to be two of the most important reasons to *have* named
arguments: skipping default parameters, and out-of-order argument
passing.  Therefore, it essentially nullifies its own raison d'etre.


> 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.

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.


T

-- 
If you're not part of the solution, you're part of the precipitate.


More information about the Digitalmars-d mailing list