C# Dynamic – C# 4.0/2010 New Feature
I watched the video about the new Dynamic feature coming in .Net 4.0. Its an interview with Sam Ng and Chris Burrows who are the compiler developers who actually helped design and implement the feature.
They almost lost me when they said it was for interop & COM (features I hope to avoid), but they brought me back when they mentioned it would be helpful with the HTML DOM and Office (features that keep sucking me back in).
They talked about the DLR (dynamic language runtime) which helps with dynamic expressions. Lots of mentions of interop with IronPython & Ruby so we’ll see if this makes those guys happy or is just a red herring.
There’s going to be a dynamic type: its syntactic sugar for object type (I’m in favor of anything sweet). Dynamic type will help the compiler optimize, but the syntax will be the same as usual. This is primarily for COM Interop, Dynamic C#/Reflection, and Office API’s.
Dynamic will allow for working with dynamic objects without all that nasty casting, but you need to know method names in that case, so it sounds like you wont get intellisense :(, and late bound type errors aren’t pretty either. While getting the same error at runtime as you would at compile time sounds good, the bad part is that you’ll get an error at runtime. More debugging…
Another use case is using a dynamic object (essentially an object type) as a parameter and the proper overload being determined at runtime. Oh joy, imagine all the possibilities. Now test them all…
On the other hand, if you really need to do this, it sounds like dynamic will help make things easier without much trouble for the developer. I’m all for that.
I bet one day I’ll use this. I hope I won’t build something embarrassing or that I regret. At least I feel smarter listening to these guys talk.
No comments yet.