C# 4.0 is to introduce the static type “dynamic” (and other things)

At Microsoft’s Professional Developer Conference (PDC) yesterday, Anders Hejlsberg unveiled plans for C# version 4.

One of the key changes is the introduction of a new type called “dynamic”. By declaring a variable of type dynamic, the compiler makes no attempt to resolve any of its members at compile time, instead performing late-binding checks at run time. This feature enables C# to use the DLR, and to use DLR-based Python and Ruby libraries.

Another key change, is the inclusion of named and optional parameters. Default values can now be specified for a method’s parameters, and parameters can be specified in any order in a call by using the parameter := value convention to name the parameters. This, combined with dynamic types, suddenly makes COM invocation a lot simpler. For example, the current mess of “ref missing” parameters will just go away.

There are various other additions, such as covariance and contravariance for generics (which I do not yet fully understand). You can read more details of the changes by downloading the document “New features in C# 4.0

If you are eager to try out an early CTP of VS2010, with .NET 4  and C# 4, you can download the 7.5Gb virtual PC image from here.