Pretty please: Named arguments

Don nospam at nospam.com
Tue Mar 1 01:10:12 PST 2011


Steven Schveighoffer wrote:
> On Mon, 28 Feb 2011 16:38:34 -0500, Don <nospam at 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");

> 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.


More information about the Digitalmars-d mailing list