C# "dynamic," Part III

Here are a few good resources that you ought to look at for information about dynamic from PDC:

Anders Hejlsberg's talk, "The Future of C#" - Among other things, this talk is a great introduction to dynamic. I recommend it highly! There are some good demos, and Anders' presentation is very compelling. I especially like the parts where people applaud.

Jim Hugunin's talk, "Deep Dive: Dynamic Languages in Microsoft .NET" - Jim is the DLR's architect. There are some details about implementing your own dynamic objects, which I touched on only superficially yesterday. He also talks about the way that C# (or any language) generates dynamic call sites and what they do at runtime.

Mads Torgerson's white paper, "New features in C# 4.0" - Some more information, this time written by the language PM. Mads is the guy who'll ultimately write and edit the updated language spec, which doesn't yet exist.

If you watch these presentations, and you start to play around with the PDC 2008 CTP, you may notice something strange. A few things just won't work. For instance, when you try to get an indexer on a dynamic (d[0]) or perform a binary operation with a dynamic ("Hello from C# " + d), the compiler is going to tell you you can't do that. And in Jim's talk, he implements IDynamicObject with a great helper class called DynamicObject where you only need to override some virtual methods. But the PDC bits don't have that type.

It may be obvious, but the thing that's going on here is that the CTP build for PDC was snapped sometime in the summer, and some of the presenters are using a newer, more complete build. We've done a lot of work since the CTP was snapped, and I regret that you can't see it all first hand right now, but I hope you'll understand that this is the nature of a CTP. I'll try to be clear when I post about what will work for you, and what won't.

For instance, Part II in this series (the implementation of IDynamicObject) will work for you! I don't think Part I will, though (it uses indexers).

If you're wondering what does work for dynamic C# in the CTP build, here's the short story: (a) dynamic method calls, (b) dynamic property gets/sets, and (c) dynamic conversion sites.

Previous posts in this series: C# "dynamic"; C# "dynamic," Part II