<?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>generic method substitutions and unification</title><link>http://blogs.msdn.com/samng/archive/2008/02/13/generic-method-substitutions-and-unification.aspx</link><description>It's been a while since I've last written - my apologies. We've been hard at work figuring out what the next release of C# will look like, and I'm happy to say that I'm very excited about what we're working on. Great minds are at work figuring out things</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: generic method substitutions and unification</title><link>http://blogs.msdn.com/samng/archive/2008/02/13/generic-method-substitutions-and-unification.aspx#7679666</link><pubDate>Wed, 13 Feb 2008 22:40:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7679666</guid><dc:creator>Thomas Danecker</dc:creator><description>&lt;p&gt;Thanks for the greate post!&lt;/p&gt;
&lt;p&gt;I just want to add that that's a typical multiple-inheritance problem. IMO, whenever there's an ambiguity, the compiler should treat it as invalid code. This way, you'll also eliminate the possible ambiguity of the writer's intention when you read his code. The CLI spec does a good job here.&lt;/p&gt;
&lt;p&gt;We've always the possibility to explicitly implement the methods and create a new method with clear definitions of our intentions when we run into such problems.&lt;/p&gt;
&lt;p&gt;Keep blogging!&lt;/p&gt;
&lt;p&gt;Thomas&lt;/p&gt;</description></item><item><title>re: generic method substitutions and unification</title><link>http://blogs.msdn.com/samng/archive/2008/02/13/generic-method-substitutions-and-unification.aspx#7798699</link><pubDate>Tue, 19 Feb 2008 21:06:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7798699</guid><dc:creator>samng</dc:creator><description>&lt;p&gt;Hi Thomas,&lt;/p&gt;
&lt;p&gt;The problem with treating all ambiguity as invalid code however, is that there are many cases where ambiguity is hard to avoid, and yet we want some tie-breaking rule to allow us to write seemingly unambiguous code, and yet have it work in a consistent manner. For instance, the overload resolution rules are a fairly complex set of rules that define exactly how to deal with ambiguities, so that we dont have to have different method names for every overload that we'd like to have.&lt;/p&gt;
&lt;p&gt;While I agree that its often nice to name methods clearly, sometimes its unavoidable to have overloads (overloaded operators for example). Dont get me wrong - I'm definitely in the camp that prefers methods named descriptively and without abbreviations, but there are definitely times where simply overloading the parameters is descriptive enough.&lt;/p&gt;
&lt;p&gt;Thanks for your comments! &lt;/p&gt;
&lt;p&gt;- Sam&lt;/p&gt;
</description></item><item><title>re: generic method substitutions and unification</title><link>http://blogs.msdn.com/samng/archive/2008/02/13/generic-method-substitutions-and-unification.aspx#7903906</link><pubDate>Tue, 26 Feb 2008 16:32:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7903906</guid><dc:creator>fjeannin</dc:creator><description>&lt;p&gt;To me, this similar (in a more sophisticated way) to the inconsistency you can create with the 'new' keyword:&lt;/p&gt;
&lt;p&gt;//Illegal in C#, will not compile&lt;/p&gt;
&lt;p&gt;class Z{&lt;/p&gt;
&lt;p&gt;private void Display(){ Console.WriteLine(&amp;quot;private Display&amp;quot;); }&lt;/p&gt;
&lt;p&gt;public void Display(){ Console.WriteLine(&amp;quot;public Display&amp;quot;); }&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;--------------------------------------------&lt;/p&gt;
&lt;p&gt;//Will compile just fine and produce an equivalent result to the illegal bit above&lt;/p&gt;
&lt;p&gt;class Program {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;static void Main(string[] args) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B b = new B();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;b.Display();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;class A {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void Display() {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(&amp;quot;from A&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;class B : A {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new void Display() {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(&amp;quot;from B&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;</description></item><item><title>re: generic method substitutions and unification</title><link>http://blogs.msdn.com/samng/archive/2008/02/13/generic-method-substitutions-and-unification.aspx#7931647</link><pubDate>Thu, 28 Feb 2008 11:43:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7931647</guid><dc:creator>Kirill Osenkov</dc:creator><description>&lt;p&gt;Hi Sam,&lt;/p&gt;
&lt;p&gt;Nikov's real name is Vladimir Reshetnikov and yes, he is amazing at finding such things. You can read more at&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://nikov-thoughts.blogspot.com/"&gt;http://nikov-thoughts.blogspot.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kirill&lt;/p&gt;</description></item><item><title>re: generic method substitutions and unification</title><link>http://blogs.msdn.com/samng/archive/2008/02/13/generic-method-substitutions-and-unification.aspx#8018899</link><pubDate>Tue, 04 Mar 2008 07:37:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8018899</guid><dc:creator>samng</dc:creator><description>&lt;p&gt;Hi fjeannin,&lt;/p&gt;
&lt;p&gt;You're absolutely right about the scenario you described. That is exactly the purpose of the &amp;quot;new&amp;quot; keyword when specifying methods on derived classes. The behavior that you're contrasting this to is different. Consider the following example:&lt;/p&gt;
&lt;p&gt;using System;&lt;/p&gt;
&lt;p&gt;class A&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public void Foo()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(&amp;quot;A&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;class B : A&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public new void Foo()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(&amp;quot;B&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;static void Main(string[] args)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B b = new B();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A a = b;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a.Foo();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;b.Foo();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;This program prints out &amp;quot;A&amp;quot; followed by &amp;quot;B&amp;quot;. This is exactly what the new keyword is for - to specify that whatever type the reference is that you're using, thats the method that will get called. Notice that if the methods were declared virtual and override respectively, we would produce &amp;quot;B&amp;quot; followed by &amp;quot;B&amp;quot; instead.&lt;/p&gt;
</description></item><item><title>Community Convergence XLI</title><link>http://blogs.msdn.com/samng/archive/2008/02/13/generic-method-substitutions-and-unification.aspx#8161022</link><pubDate>Wed, 12 Mar 2008 00:41:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8161022</guid><dc:creator>Charlie Calvert's Community Blog</dc:creator><description>&lt;p&gt;Welcome to the forty-first Community Convergence. The big news this week is that we have moved Future&lt;/p&gt;
</description></item></channel></rss>