views:

402

answers:

3

I suppose there could be historical reasons for this naming and that other languages have similar feature, but it also seems to me that parameters always had a name in C#. Arguments are the unnamed ones.

+4  A: 

Yes, you're absolutely right (to my mind, anyway). Ironically, although I'm usually picky about these terms, I still use "parameter passing" when I should probably talk about "argument passing". I suppose one could argue that prior to C# 4.0, if you're calling a method you don't care about the parameter names, whereas the names become part of the significant metadata when you can specify them on the arguments as well.

I agree that it makes a difference, and that terminology is important.

"Optional parameters" is definitely okay though - that's adding metadata to the parameter when you couldn't do so before :) (Having said that, it's not going to be optional in terms of the generated IL...)

Would you like me to ask the team for their feedback?

Jon Skeet
Jon, you are fast and omnipresent :)I think that I read some of your blog or answers where you pointed the difference between the two. And I agree that correct terminology is important.As for team feedback I propose that you decide if this is thus important. Regards, Petar
Petar Repac
I think I'll leave this one then - mostly because even if the team changes documentation etc, it's *going* to be referred to as "named parameters" by the world anyway. How many people call "automatic properties" by their real name of "automatically implemented properties"?
Jon Skeet
+7  A: 

Oh, you wanted arguments! Sorry, this is parameters - arguments are two doors down the hall on the left.

Sherm Pendley
A: 

I don't think so. The names are quite definitely the names of parameters, as they are defined and given a specific meaning in the method definition, where they are properly called the parameters to the method. At the call site, arguments can now be tagged with the name of the parameter that they supply a value for.

The new term refers to the perspective of the method caller - which is logical because that's where the feature applies. Previously, callers only had to think of parameters as being "positioned parameters". Now they can optionally treat them as "named parameters" - hence the name.

Daniel Earwicker
And yet Sam Ng, a developer at C# team (http://blogs.msdn.com/samng/archive/2007/11/06/yet-another-compiler-dev.aspx) refers to "named arguments" (http://blogs.msdn.com/samng/archive/2009/02/03/named-arguments-optional-arguments-and-default-values.aspx)
Petar Repac
If you look at http://code.msdn.microsoft.com/csharpfuture/Release/ProjectReleases.aspx?ReleaseId=1686 and open up a document titled "New Features in C# 4.0" you will find a chapter titled "Named and Optional Arguments"
Petar Repac
All Microsoft employees could get the words "Named Arguments" tattooed on their foreheads if they want to, but it won't make any difference to the soundness of my reasoning!
Daniel Earwicker