Pretty please: Named arguments

Bruno Medeiros brunodomedeiros+spam at com.gmail
Wed Mar 23 09:12:38 PDT 2011


On 09/03/2011 17:20, Steven Schveighoffer wrote:
> 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.
>

Now that is an argument. Although I still don't agree: it really 
shouldn't take that long to setup an IDE (if Netbeans and/or its PHP 
plugin are crappy, don't use that to blame all IDEs :P ). But in any 
case this is kinda besides the point, because setting up an IDE is a 
one-time affair (reviewing code is many-times).

For small changes, yeah, it might be overkill to fire up an IDE. However 
I think the ideal solution in this issue is to bring a bit more IDE 
functionality to the web. There are already some projects loosely 
related to this underway, for example Orion 
(http://adtmag.com/articles/2011/03/21/eclipse-orion-hub.aspx ) from the 
Eclipse Foundation, of which Github is one of the involved parties.

But for bigger changes (in fact even for smaller ones as well) it might 
be worthwhile to use an IDE tool, because it can offer a lot of help in 
navigation and other stuff related to reviewing the code. I mean, the 
named arguments only address a very limited problem in reviewing code: 
it only tells you which parameter corresponds each argument. But what if 
you need to read the function's documentation to know or remind yourself 
what the function does, if the arguments have correct values, respect 
the contract, etc.? You'll likely need to open the function declaration 
in any case, in one way or another.


-- 
Bruno Medeiros - Software Engineer


More information about the Digitalmars-d mailing list