Discussion Thread: DIP 1030--Named Arguments--Final Review

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri May 15 19:37:05 UTC 2020


On Wednesday, May 13, 2020 1:55:20 PM MDT Jonathan Marler via Digitalmars-d 
wrote:
> On Wednesday, 13 May 2020 at 19:48:58 UTC, Panke wrote:
> > On Wednesday, 13 May 2020 at 19:44:32 UTC, Jonathan Marler
> >
> > wrote:
> >> I found a way:
> >>
> >> void copy(string, string destination)
> >> {
> >>
> >>     alias source = _param_0;
> >>
> >> }
> >>
> >> I didn't realize you could do this till now but this allows
> >> functions to "opt-out" of using named parameters.  We may want
> >> to consider using this pattern throughout phobos/druntime when
> >> we want want to prevent parameter names from being apart of
> >> the API.
> >
> > Makes the documentation worse though.
>
> If it makes the documentation worse then it means the parameter
> names were helpful to the API, in which case you wouldn't do
> this.  The "copy" function isn't a good example because the
> "source" and "destination" parameter names are actually helpful
> to include.

Just because having the parameter names in the documentation helps make the
documentation clearer doesn't mean that it's desirable to actually have the
parameter names be part of the API. Personally, I think that the
documentation is much clearer and cleaner if the parameter names are in it,
but I have zero interest in parameters names actually being part of the API
where they then will cause code breakage if changed and risk causing even
more bike-shedding arguments. I hate the whole idea of this DIP (and that of
any other DIP that adds named arguments), but since Walter now seems to be
on board wtih the idea, and I know that Atila has been for years, I expect
that I'm out of luck, and I'm going to be stuck with some version of them in
the language. If it weren't for how it affected the documentation, I almost
certainly would stop naming any parameters on public functions and would use
a "trick" like this one, though of course, that wouldn't fix it so that I
wouldn't have to put up with named arguments in code just make it so that I
wouldn't have to deal with how changing parameter names would break the code
of anyone using any libraries I write.

- Jonathan M Davis





More information about the Digitalmars-d mailing list