<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Dynamic in C# II: Basics</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx</link><description>Last time , we began to dive into dynamic binding in C# and what happens through the pipeline. This time, we'll take a simple scenario and pick apart the details of what happens under the covers, both during compile time and runtime. We can break down</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Dynamic in C# II: Basics</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9807426</link><pubDate>Sun, 28 Jun 2009 17:24:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9807426</guid><dc:creator>Adil Mughal</dc:creator><description>&lt;p&gt;Excellent! I think I need to go through each post in your blog. Love the stuff. Keep posting.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9807426" width="1" height="1"&gt;</description></item><item><title>C# 4, Dynamic Overloads</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9462665</link><pubDate>Fri, 06 Mar 2009 17:13:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9462665</guid><dc:creator>Mike Taulty's Blog</dc:creator><description>&lt;p&gt;Another experiment with C# 4 and the “dynamic type”. I was playing with this code below and wasn’t 100%&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9462665" width="1" height="1"&gt;</description></item><item><title>Dynamic in C# VII: Phantom Method Semantics</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9252354</link><pubDate>Thu, 25 Dec 2008 06:44:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9252354</guid><dc:creator>Sam Ng's Blog</dc:creator><description>&lt;p&gt;By now, my hope is that you all have a well-rounded view of dynamic. We started this series by introducing&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9252354" width="1" height="1"&gt;</description></item><item><title>DYNAMIC IN C# II: BASICS</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9227604</link><pubDate>Tue, 16 Dec 2008 22:15:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9227604</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You've been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9227604" width="1" height="1"&gt;</description></item><item><title>Dynamic in C# III: A slight twist</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9227596</link><pubDate>Tue, 16 Dec 2008 22:13:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9227596</guid><dc:creator>Sam Ng's Blog</dc:creator><description>&lt;p&gt;Last time we dealt with the basics of dynamic binding . This time, we'll add a small twist. First, lets&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9227596" width="1" height="1"&gt;</description></item><item><title>C# Dynamic - CSharp's new feature of the coming version 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9221695</link><pubDate>Mon, 15 Dec 2008 21:01:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9221695</guid><dc:creator>Journal of Abu Sayed Mohammad Ismail</dc:creator><description>&lt;p&gt;Very good resources for the coming version... Sam Ng Dynamic in C# Part One Dynamic in C# Part Two Chris&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9221695" width="1" height="1"&gt;</description></item><item><title>re: Dynamic in C# II: Basics</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9045402</link><pubDate>Thu, 06 Nov 2008 02:17:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9045402</guid><dc:creator>samng</dc:creator><description>&lt;p&gt;Thats exactly the rationale that we've been using when making these decisions, but yes, I agree with you that this is yet another point in which explicit interface implementations are second-class citizens.&lt;/p&gt;
&lt;p&gt;Though, like you say, theres not much we can really do about this one with the current architecture and framework... :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9045402" width="1" height="1"&gt;</description></item><item><title>re: Dynamic in C# II: Basics</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9041009</link><pubDate>Tue, 04 Nov 2008 22:19:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9041009</guid><dc:creator>int19h</dc:creator><description>&lt;p&gt;&amp;gt; We may make a call and say that if the receiver is dynamic, you cant call explicit methods on it, but if the receiver is static, then you can. &lt;/p&gt;
&lt;p&gt;Given that you seem to be really trying to make runtime resolution as close to compile-time as possible, what you describe seems to be the only sensible approach. It allows for a simple rule of thumb: if receiver is dynamic, overload resolution is exactly the same as if &amp;quot;dynamic&amp;quot; type was replaced by the actual type of the object (and if it's not dynamic, then its declared type is used).&lt;/p&gt;
&lt;p&gt;It's just a pity that, if you go that way, it will mark yet another point on which explicit interface implementations are second-class citizens in C# (another, existing, sore point is that you cannot properly override them with the ability to call base implementation in C#, even though CLR allows for that).&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9041009" width="1" height="1"&gt;</description></item><item><title>re: Dynamic in C# II: Basics</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9040703</link><pubDate>Tue, 04 Nov 2008 21:15:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9040703</guid><dc:creator>samng</dc:creator><description>&lt;p&gt;int19h -&lt;/p&gt;
&lt;p&gt;Great question! This is one issue that we're currently looking into. The consideration is this:&lt;/p&gt;
&lt;p&gt;Explicitily implemented interfaces are (statically) callable only through the interface, and not through the implementing object. &lt;/p&gt;
&lt;p&gt;However, at runtime, there really isn't a notion of interfaces - everything is just a bunch of runtime objects. So from a purely legalistic approach, these guys should never be callable.&lt;/p&gt;
&lt;p&gt;BUT - and this is a big but, and a bit of a spoiler for my next post - dynamic invocations can happen with a STATIC receiver! What happens if that receiver is the correct interface?&lt;/p&gt;
&lt;p&gt;Consider:&lt;/p&gt;
&lt;p&gt;IFoo f = ...;&lt;/p&gt;
&lt;p&gt;dynamic d = ...;&lt;/p&gt;
&lt;p&gt;f.Foo(d);&lt;/p&gt;
&lt;p&gt;Because at compile time, the type of d is dynamic (the second class of dispatches in my post), we cant resolve the call to Foo at compile time, and must do it at runtime. But the receiver is known at compile time to be an explicit interface! That means the runtime binder should dispatch to that interface call, because the call itself was never meant to be dynamic!&lt;/p&gt;
&lt;p&gt;So what do we do? &lt;/p&gt;
&lt;p&gt;We're not sure yet! :) We may make a call and say that if the receiver is dynamic, you cant call explicit methods on it, but if the receiver is static, then you can. I'll definitely let you know more on it when we decide!&lt;/p&gt;
&lt;p&gt;But again, great question!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9040703" width="1" height="1"&gt;</description></item><item><title>re: Dynamic in C# II: Basics</title><link>http://blogs.msdn.com/b/samng/archive/2008/11/02/dynamic-in-c-ii-basics.aspx#9040702</link><pubDate>Tue, 04 Nov 2008 21:15:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9040702</guid><dc:creator>samng</dc:creator><description>&lt;p&gt;int19h -&lt;/p&gt;
&lt;p&gt;Great question! This is one issue that we're currently looking into. The consideration is this:&lt;/p&gt;
&lt;p&gt;Explicitily implemented interfaces are (statically) callable only through the interface, and not through the implementing object. &lt;/p&gt;
&lt;p&gt;However, at runtime, there really isn't a notion of interfaces - everything is just a bunch of runtime objects. So from a purely legalistic approach, these guys should never be callable.&lt;/p&gt;
&lt;p&gt;BUT - and this is a big but, and a bit of a spoiler for my next post - dynamic invocations can happen with a STATIC receiver! What happens if that receiver is the correct interface?&lt;/p&gt;
&lt;p&gt;Consider:&lt;/p&gt;
&lt;p&gt;IFoo f = ...;&lt;/p&gt;
&lt;p&gt;dynamic d = ...;&lt;/p&gt;
&lt;p&gt;f.Foo(d);&lt;/p&gt;
&lt;p&gt;Because at compile time, the type of d is dynamic (the second class of dispatches in my post), we cant resolve the call to Foo at compile time, and must do it at runtime. But the receiver is known at compile time to be an explicit interface! That means the runtime binder should dispatch to that interface call, because the call itself was never meant to be dynamic!&lt;/p&gt;
&lt;p&gt;So what do we do? &lt;/p&gt;
&lt;p&gt;We're not sure yet! :) We may make a call and say that if the receiver is dynamic, you cant call explicit methods on it, but if the receiver is static, then you can. I'll definitely let you know more on it when we decide!&lt;/p&gt;
&lt;p&gt;But again, great question!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9040702" width="1" height="1"&gt;</description></item></channel></rss>