DIP 1019--Named Arguments Lite--Final Review

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Aug 26 21:48:42 UTC 2019


On Monday, August 26, 2019 8:18:21 AM MDT Kagamin via Digitalmars-d wrote:
> On Saturday, 24 August 2019 at 01:09:48 UTC, Jonathan M Davis
>
> wrote:
> > Personally, I'm against named arguments in general. They make
> > the parameter names part of the API, which adds another set of
> > names that you have to get right up front and which will be
> > bike-shedded to death.
>
> Errors in function names happen too.

My point is that adding named arguments results in even more bikeshedding
over names. We already have more than enough trouble with that over function
names and type names in APIs. I don't want parameter names to be added to
that. I don't want to have to care about how good the parameter names are or
have to worry about breaking anyone's code when changing a parameter name.
And since parameter names have never actually been part of the API in D,
existing parameter names were not selected with the idea that they would be
used by anyone other than the function itself. For instance, if we had named
arguments, all of a sudden, we'd have issues with whether range-based used
range, r, or some other name entirely for the range that they're consuming
or wrapping. Phobos is not at all consistent about that - and it hasn't
needed to be. If we added named arguments, that sort of thing would then
matter. I don't want to have to deal with any of that.

> > The _only_ use case IMHO where they add any real value is when
> > you have a long parameter list where most of the parameters
> > having default arguments.
>
> Another use case is replacing the Flag thing. When a function has
> only one parameter and it's has primitive type, names argument
> will have merit.

Honestly, I don't think that Flag is worth much. In most cases, a simple
bool would do the job just fine. You already have to know what the parameter
is for to use the function anyway. In general, it seems to me like Flag is
an excuse for people to think that they don't need to actually read the
documentation. And the cases where you really get value out of an enum are
generally the cases where you need more than just true and false. I know
that some folks like Flag, but in general, I think that it's an unnecessary
complication.

- Jonathan M Davis





More information about the Digitalmars-d mailing list