

C# finally gets default parameters - RyanMcGreal
http://www.devcurry.com/2009/08/two-new-features-of-c-40.html

======
snprbob86
When C# was first conceived, it was to be the system language of the .NET
platform. It had to, through a pit of success, produce APIs which could be
consumed by any CLS compliant language (any language which compiles to MSIL
and has a some minimum feature set). Microsoft expected (perhaps naively)
developers to use VB.net for application development. Over time, C# has become
the primary language choice of the .NET ecosystem. With that change, C#
started adding a significant number of non-CLS compliant features.

As a static and strongly typed language, overloading is a very clean solution
for implementing default arguments. Haskell, for example, uses the same
mechanism. VB, on the other hand, can use late binding. This is an essential
feature of VB for COM interop.

Optional and named parameters are being added to C# with support for the
"dynamic" type and interop with COM (primarily Office), IronRuby, IronPython,
and the HTML DOM via Silverlight. If C# were to stand on its own, I don't
think they would have ever added this feature.

EDIT: Also, the actual title of this post is "Two New Features of C# 4.0".
Please don't editorialize the headline :-)

~~~
RyanMcGreal
_Please don't editorialize the headline_

Mea culpa. :)

~~~
snprbob86
No worries. The original title was pretty non-descriptive. I'd have gone with:
"Two New Features of C# 4.0 (optional and named parameters)"

------
tokipin
dynamic scripting languages are my friends, but i've been writing a handful of
programs in C#/WPF lately and i really don't have any complaints. having
experience with all sorts of esoteric languages, i was afraid C# would feel
"limited." but that didn't turn out to be the case, probably thanks to the
recently-added lambdas and syntatic sugaries

and in terms of the whole environment, it's like MS is bending over backwards
to make it comfy for the programmer... don't mind if i do

------
Xixi
Wow, I thought these would never come !

Now I just have to wait for C# 4.0 to make it to mono, and for the guys from
Unity to upgrade it (which might take forever, they still use something like
mono 1.2.5 I think). And at last I'll be able to use this...

For those who don't know Unity: <http://unity3d.com/>, it's a very small, yet
very impressive 3D engine that runs in the browser.

------
pmichaud
I'm not comfortable with the direction C# is going. It's trying to be and do
too many things at once, and it's making itself muddy.

~~~
logicalmind
What is interesting is that C# has become the antithesis of Java. Java is now
muddled in the JSR process and takes a long time to develop new features. C#
is driven by MS and features have been evolving at a fast rate.

This is quite different from the beginnings of C# when it was basically a Java
clone.

------
ilitirit
This works in C#:

    
    
       public static void SomeMethod([Optional, DefaultParameterValue(false)] bool param)

------
ludwig
Now they need to add keyword arguments.

~~~
dtf
Seems like they have:

    
    
      name = SomeMethod("Suprotim", age: 20);

