Pretty please: Named arguments
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Tue Mar 1 04:40:53 PST 2011
On Tue, 01 Mar 2011 07:26:28 -0500, Nick Sabalausky wrote:
> "Lars T. Kyllingstad" <public at kyllingen.NOSPAMnet> wrote in message
> news:ikimed$2vba$5 at digitalmars.com...
>> On Tue, 01 Mar 2011 12:20:22 +0100, spir wrote:
>>
>>> On 02/28/2011 11:13 PM, Steven Schveighoffer wrote:
>>>>> But I still don't see the need for this feature. Aren't people using
>>>>> IDEs where the function signature (with parameter names) pops up
>>>>> when you're entering the function, and when you move the mouse over
>>>>> the function call?
>>>
>>> You are wrong Don, this is not an argument. The feature is *not* for
>>> writing code, but for reading it (first your own code). Obviously, if
>>> you can write parameter names, this means you know them somehow, lol!
>>> The names provide highly valuable info at /reading/ time.
>>>
>>>> Dunno, vim doesn't do that for me currently. Also, if reviewing code
>>>> on github, there is no ide.
>>>
>>> Geany does it, but only for currently open files. Meaning, to have it
>>> work when programming in D, I should have the whole stdlib open in
>>> geany tabs... Anyway, as said above, this feature is 'orthogonal' to
>>> the question discussed in this thread.
>>>
>>> I'm fed up with people opposing to features very relevant for code
>>> clarity, which they are not forced to use, and can hardly bother when
>>> reading code themselves. Is the second statement below really that
>>> hard to read?
>>> p = new Point([1,2,3], [3,2,1]);
>>> p = new Point(color:[1,2,3], pos:[3,2,1]);
>>
>> Are the following really that hard to read?
>>
>> p = new Point(/* color */ [1,2,3], /* pos */ [3,2,1]);
>>
>> p = new Point(
>> [1, 2, 3], // color
>> [3, 2, 1], // pos
>> );
>>
>> -Lars
>
> class Point {
> this(int[3] pos, int[3] color) {...}
> }
>
> p = new Point(/* color */ [1,2,3], /* pos */ [3,2,1]);
>
> Big Fail.
Yeah, I'm aware of that. I was merely opposing the "code clarity"
argument by saying that we already have a feature for clarifying code:
comments.
Note that I'm not against named parameters per se, and I understand their
benefits. I just think that, at this late point in D2's development, the
cost of adding them outweighs the benefits. I mean, have you looked at
the spec for D2 lately? It's starting to look like the OOXML spec!
-Lars
More information about the Digitalmars-d
mailing list