A nice way to step into 2012
Jacob Carlborg
doob at me.com
Wed Dec 28 09:02:43 PST 2011
On 2011-12-28 14:18, Marco Leise wrote:
> Am 28.12.2011, 01:22 Uhr, schrieb Jonathan M Davis <jmdavisProg at gmx.com>:
>
>> On Tuesday, December 27, 2011 18:43:14 Andrej Mitrovic wrote:
>>> Wouldn't it be great if Santa were to give us named arguments this
>>> year too?
>>> :)
>>
>> Only if he hates me. But I guess that I'm in the minority around here
>> in that
>> I hate the idea of named arguments.
>>
>> - Jonathan M Davis
>
> Despite that feature being optional to use, I could understand you if
> you think it only makes sense on obscure 'true'/'false' flags and prefer
> named enums there. Then there would be two ways to do the same thing,
> which annoys language purists like me ^^.
>
> (…, overwrite = true); vs. (…, CreateMode.overwrite);
>
> But named parameters can do more, like skipping some optional parameters
> and using others.
>
> int foo(int a = 0, int b = 1, int c = 2) {}
> foo(c = 3);
That's where they are really useful. When C# got named arguments and
optional arguments it became a lot easier to use COM functions:
http://msdn.microsoft.com/en-us/library/dd264739.aspx
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list