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

Jon Degenhardt jond at noreply.com
Sun Feb 9 04:10:30 UTC 2020


On Sunday, 9 February 2020 at 02:40:30 UTC, Steven Schveighoffer 
wrote:
> On 2/8/20 8:47 PM, Jon Degenhardt wrote:
>> On Sunday, 9 February 2020 at 01:07:03 UTC, Adam D. Ruppe 
>> wrote:
>>> On Sunday, 9 February 2020 at 00:56:15 UTC, Jon Degenhardt 
>>> wrote:
>>>> (Specifically, that a parameter name cannot be changed 
>>>> without risk of breaking existing callers.)
>
> [...snip...]
>
> If you name your parameters something unintuitive, like "a". 
> Likely nobody is going to use them via named parameters.
>
> For example, if you have;
>
> Date makeDate(int year, int month, int day)
>
> What would be the reason to change these? Likely you already 
> picked those names.
>
> But if you named them:
>
> Date makeDate(int a, int b, int c)

Well, I personally wouldn't recommend this as a general remedy. 
Parameter names help to document the implementation. In many 
environments it's important that developers other than the 
original author be able to read, debug, enhance, or take over 
code. Having good parameter and variable names is helpful from 
this perspective. Naming conventions are a common element of 
coding standards for this reason.

In general, what I typically try to do (and recommend) is taking 
a good shot at creating meaningful names, but not spend excessive 
amounts of time on it. And, depending the situation, look at 
improving the names over time (and other elements of the code as 
well).

> I don't think there's going to be a lot of problems here. Take 
> a look at the history of phobos and see if you can find places 
> where someone changed an appropriate parameter name to another 
> appropriate name. Chances are it's close to never.

For Phobos this would be my expectation as well. I'm admittedly 
thinking of project environments with meaningful size teams more 
than the standard library of a major programming language. 
Environments where there is a fair bit of code in earlier stages 
of development and subject to more evolution.




More information about the Digitalmars-d mailing list