On Tue, 01 Mar 2011 04:10:12 -0500, Don <nos...@nospam.com> wrote:

Steven Schveighoffer wrote:
On Mon, 28 Feb 2011 16:38:34 -0500, Don <nos...@nospam.com> wrote:

spir wrote:
 Just don't use them!

You don't have that option. At least, if you're a library developer, you don't. (I'm a bit sick of people saying "you don't have to use it if you don't want to" in language design. If it is in the language, you don't have a choice. You will encounter it).
encounter *reading* it or encounter *using it*? You shouldn't ever have to use named parameters if you don't want to. Just like you can specify all defaulted parameters, or specify all template args when calling templated functions. I could live without named parameters (obviously!), but I certainly think reading a call with named parameters can be much easier with the parameter names than without, and I don't think you could ever say the opposite (that name-less parameters would be clearer).

For sure they can be clearer with nameless parameters!

printf(formatstr: "Hello World!\n");

This is not less clear than printf("Hello World!\n"); It's as clear. More verbose, yes, but clear.

Just like foo!int(1) is as clear as, but more verbose than, foo(1).

In essense, the parameter names are ALREADY an essential part of the API. If we didn't name the parameters (entirely possible with .di files!), how shitty would programming be?

The names are for humans to read. They are documentation. That's a big difference.

And they continue to be documentation, I'm documenting what my argument names are at the call site so I don't have to go back to the function definition to determine what each parameter is via position.

Regarding your objection in another post, I see your point that you don't want to break existing code by changing a parameter name. A way to look at this is, you must choose good parameter names on the first try. Another way to look at it is, I'm documenting my function call -- I want to be notified by the compiler when the parameter names changed because I want to reassure myself that the call is still valid. My point is, the function author should choose good names, but if he must make a change, then fear of breaking calls should not dissuade him. We routinely change the names of functions or deprecate them, this is taken in stride by the users of the library, I don't see how changing parameter names is any different.

-Steve

Reply via email to