Pretty please: Named arguments
Steven Schveighoffer
schveiguy at yahoo.com
Wed Mar 9 09:20:33 PST 2011
On Wed, 09 Mar 2011 09:02:14 -0500, Bruno Medeiros
<brunodomedeiros+spam at com.gmail> wrote:
> Although in the particular cased of named arguments, I still don't feel
> it is worthwhile. Not unless it could be done in a very orthogonal way
> (both in semantics and syntax), and even so it should likely be very low
> priority (as in, not any time soon...).
It's one of those things where, in some cases, not having named arguments
makes code unreadable. But having named arguments does not make *all*
code more readable. In many many cases, code is readable just fine
without using the named arguments.
But those cases where it does help, it's essential. Like Don's CreateFont
example (actually almost any GUI function).
We might do something like require explicit comments for confusing
functions like:
foo(
null, // paramA
null, // paramB
null, // paramC
);
during the review process. It would at least document properly what is
happening.
I see not too much value in the "skip default parameter" prospect, most
code can do fine without that via overloading. But the documentation and
compiler verification of parameter names is what I see as the killer
feature here.
>>> B) If the pull request is large, it should be near effortless to put
>>> those changes in the IDE and review them there.
>>
>> Again, don't have one.
>>
>> -Steve
>
> Just because you don't have or don't use an IDE, that is not an argument
> against doing B).
It absolutely is. I use NetBeans for doing php development. It took me
hours and hours to set it up properly, install the right add-ons, etc.
I'm not about to do that for something like descent or DDT so I can
properly read code, I'm way more likely to just go look up the function
signature myself for the few times I need it.
Just having the named arguments idea makes so much more sense than having
to load a specialized (and I might add, way overkill for just reviewing
code in both size and complexity) tool.
It's not one of those "absolutely have to have it" features, it's a
nice-to-have. I certainly can and have lived without it, and there are
certainly ways to compensate for not having it.
It's kind of like arrays in D. Every time I have to use another language,
I miss D's array syntax features. All the same functionality is there, it
just takes more effort to do the same thing. That little effort is not
terrible, but I much prefer not having to do it.
-Steve
More information about the Digitalmars-d
mailing list