Named parameters
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 24 13:11:19 PDT 2015
On Friday, 24 July 2015 at 19:59:17 UTC, Shammah Chancellor wrote:
> On Friday, 24 July 2015 at 19:45:55 UTC, Jonathan M Davis wrote:
>> On Friday, 24 July 2015 at 14:15:11 UTC, Shammah Chancellor
>> wrote:
>>> Since D has optional arguments -- why don't we support named
>>> parameters? There are extremely handy and work beautifully
>>> in languages like C#.
>>
>> We've argued about this several times in the past. We're not
>> adding them. They interact badly with overloading (especially
>> if you try and add more overloads later), and they make it so
>> that the parameter names are part of the API, which means even
>> more bikeshedding and arguments about naming.
>>
>> - Jonathan M Davis
>
> Funny, they work beautifully in C#.
>
> https://msdn.microsoft.com/en-us/library/dd264739.aspx
Well, I don't know how C# dealt with mixing function overloading
with named arguments (I haven't read the article yet), but there
_are_ issues with mixing them, and Walter's sure that they
interact badly enough that he's against adding named arguments to
D, and if anyone wants them, they'll have to convince him
otherwise.
But I for one, hope _very_ much that they never end up in either
D or C++ (which are the two main languages I use). IMHO, they're
hideous, and if you need them, you have too many function
arguments/parameters. And I _hate_ the fact that they make it so
that the function's parameters are part of the API. It just makes
something else that you have to get right up front and can't
change later without breaking someone's code.
But for those who really want to have them, they can always
create them themselves via templates:
http://forum.dlang.org/post/hdxnptcikgojdkmldzrk@forum.dlang.org
- Jonathan M Davis
More information about the Digitalmars-d
mailing list