Sign In

Navigation

On This Page

Archive

<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Categories

Blogroll

Contact

Send mail to the author(s) Email Me
MCPD
MCTS

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way


Copyright ©  2010
 Creative Commons License
This work by Jeff Klawiter is, unless explicitly stated in the article,  available under the Creative Commons Attribution 3.0 United States License.

Pick a theme:
# Tuesday, October 28, 2008
by Jeff Klawiter - Tuesday, October 28, 2008 10:23:43 AM (Central Standard Time, UTC-06:00)
All of these new C# 4.0 dynamic features require parts of the DLR. Thus it looks like MS is taking the DLR and making it a first class citizen in the CLR. This also I'm guessing will make IronPython and IronRuby first class citizens as well. A huge win for the dynamic languages community. For C# 4.0 it is bittersweet. It means better interoperability when calling things created in IronRuby or IronPython but there are limitations. Below is an excerpt from the C# 4.0 WhitePaper (available here http://code.msdn.microsoft.com/csharpfuture)

Open issues

There are a few limitations and things that might work differently than you would expect.

·         The DLR allows objects to be created from objects that represent classes. However, the current implementation of C# doesn’t have syntax to support this.

·         Dynamic lookup will not be able to find extension methods. Whether extension methods apply or not depends on the static context of the call (i.e. which using clauses occur), and this context information is not currently kept as part of the payload.

·         Anonymous functions (i.e. lambda expressions) cannot appear as arguments to a dynamic method call. The compiler cannot bind (i.e. “understand”) an anonymous function without knowing what type it is converted to.

One consequence of these limitations is that you cannot easily use LINQ queries over dynamic objects:

dynamic collection = …;

var result = collection.Select(e => e + 5);

If the Select method is an extension method, dynamic lookup will not find it. Even if it is an instance method, the above does not compile, because a lambda expression cannot be passed as an argument to a dynamic operation.

There are no plans to address these limitations in C# 4.0.


To me this is a very huge limitation. I can already see that most of my interop with dynamic languages will probably involve collections of some sort. Also this would come into play with collections from Dynamic COM objects. LINQ is so powerful and easy to use, it may end up being a major annoyance to have to move away from it for dynamic typing. I hope they work on this for C# 4.5


Comments [0] #      C# 4.0  |  kick it on DotNetKicks.com Shout it
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview