Named Parameters (Was: A nice way to step into 2012)

Don nospam at nospam.com
Thu Dec 29 01:48:13 PST 2011


On 29.12.2011 09:39, Derek wrote:
> On Thu, 29 Dec 2011 19:08:36 +1100, Don <nospam at nospam.com> wrote:
>
>> On 29.12.2011 04:48, David Nadlinger wrote:
>>> On 12/29/11 3:46 AM, Timon Gehr wrote:
>>>> My point is, without named arguments you can improve the names at any
>>>> time. With named arguments, you are stuck and have to get it right
>>>> upfront.
>>>
>>> My point is, without positional arguments you can improve the ordering
>>> at any time. With positional arguments, you are stuck and have to get it
>>> right upfront.
>>>
>>> David
>>
>> That's rubbish! Unless you plan to disallow positional arguments...
>
> Maybe you missed the point?
>
> I see the point in David's response as being that regardless of whether
> we have positional or named parameters, once exposed, they are pretty
> well set in concrete. I think that no one is suggesting that position
> parameters are to be replaced by named ones. The upshot of the idea
> would be that a API user would be free to choose between whatever *they*
> felt was appropriate.

I'm not aware of any languages where positional arguments are not 
supported. The restrictions imposed by named arguments are a pure 
superset of the restrictions imposed by positional arguments.

David's post implies that they are two independent approaches.

It's pretty obvious what happens when you have named arguments: if you 
make a poor choice in naming an argument, you generally shouldn't fix 
it. Documentation suffers.
Named arguments WILL reduce code quality in some cases.

There are definitely cases where named arguments are beneficial, though 
I suspect that most of them involve poorly designed functions. (The 
Windows CreateFont() function is my favourite example).

As an always-on feature, I can see as more downsides than upsides.
OTOH if it were an opt-in feature (for the library writer), I'd be 
completely in favour.


More information about the Digitalmars-d mailing list