<?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>Lambda Expressions vs. Anonymous Methods, Part Two</title><link>http://blogs.msdn.com/ericlippert/archive/2007/01/11/lambda-expressions-vs-anonymous-methods-part-two.aspx</link><description>We interrupt the discussion of how the difference between lambda expression and anonymous method convertibility leads to potential performance problems in the compiler to answer a user question. Within hours of yesterday's post readers Raymond Chen and</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Community Convergence XVIII</title><link>http://blogs.msdn.com/ericlippert/archive/2007/01/11/lambda-expressions-vs-anonymous-methods-part-two.aspx#1454473</link><pubDate>Fri, 12 Jan 2007 11:56:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1454473</guid><dc:creator>Charlie Calvert's Community Blog</dc:creator><description>&lt;p&gt;Welcome to the eighteenth issue of Community Convergence. I'm Charlie Calvert, the C# Community PM, and&lt;/p&gt;
</description></item><item><title>Lambda Expressions vs. Anonymous Methods, Part Three</title><link>http://blogs.msdn.com/ericlippert/archive/2007/01/11/lambda-expressions-vs-anonymous-methods-part-two.aspx#1456820</link><pubDate>Fri, 12 Jan 2007 21:05:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1456820</guid><dc:creator>Fabulous Adventures In Coding</dc:creator><description>&lt;p&gt;Last time I said that I would describe a sneaky trick whereby you can get variable type inference out&lt;/p&gt;
</description></item><item><title>re: Lambda Expressions vs. Anonymous Methods, Part Two</title><link>http://blogs.msdn.com/ericlippert/archive/2007/01/11/lambda-expressions-vs-anonymous-methods-part-two.aspx#1456973</link><pubDate>Fri, 12 Jan 2007 22:47:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1456973</guid><dc:creator>Richard Smith</dc:creator><description>&lt;p&gt;You wrote:&lt;/p&gt;
&lt;p&gt;&amp;quot;Delegate types are not even structurally equivalent; you can't even assign a variable of type D1 to a variable of type D2.&amp;quot;&lt;/p&gt;
&lt;p&gt;What's the justification for this? I guess it's to prevent this:&lt;/p&gt;
&lt;p&gt;delegate bool FooTester(Foo foo);&lt;/p&gt;
&lt;p&gt;delegate bool FooFrobber(Foo foo);&lt;/p&gt;
&lt;p&gt;bool IsPrickly(Foo foo) { return true; }&lt;/p&gt;
&lt;p&gt;bool MakePrickly(Foo foo) { foo.prickly = true; return true; }&lt;/p&gt;
&lt;p&gt;FooTester isPrickly = IsPrickly;&lt;/p&gt;
&lt;p&gt;FooFrobber makePrickly = MakePrickly;&lt;/p&gt;
&lt;p&gt;// Whoops, meant to pass in isPrickly, not makePrickly.&lt;/p&gt;
&lt;p&gt;bool allPrickly = fooColl.All(makePrickly);&lt;/p&gt;
&lt;p&gt;But this doesn't really seem to help that much; I'd imagine it's much more common to see either this:&lt;/p&gt;
&lt;p&gt;bool allPrickly = fooColl.All(MakePrickly);&lt;/p&gt;
&lt;p&gt;or this:&lt;/p&gt;
&lt;p&gt;bool allPrickly = fooColl.All(delegate(Foo f) { f.prickly = true; return true; });&lt;/p&gt;
&lt;p&gt;Following that argument through, I would allow conversions between delegate types where one can implicitly convert the argument and return types (with covariant return conversions and contravariant argument conversions permitted). Maybe there is potential for harm here, but I'm not seeing it. More likely I've misunderstood something about C#...&lt;/p&gt;
</description></item><item><title>re: Lambda Expressions vs. Anonymous Methods, Part Two</title><link>http://blogs.msdn.com/ericlippert/archive/2007/01/11/lambda-expressions-vs-anonymous-methods-part-two.aspx#1609916</link><pubDate>Tue, 06 Feb 2007 10:11:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1609916</guid><dc:creator>Cameron Zwarich</dc:creator><description>&lt;p&gt;Why is there such a strong insistence in C# on not identifying structurally equivalent delegate types, especially since the introduction of anonymous types makes a completely nominative type system somewhat impossible? Is it just because you don't want to have massive backwards compatibility problems?&lt;/p&gt;
&lt;p&gt;If you identified structurally equivalent delegate types, then you could allow anonymous delegate types, as C# requires that all structurally equivalent anonymous types in the same method are identified. This would be a pretty reasonable solution to your conundrum, but perhaps I am missing a subtlety here due to a lack of deep experience with the C# type system. And barring such a jarring change to existing C# features, couldn't you just introduce anonymous delegate types regardless, with the usual anonymous type semantics of divining that the programmer intended all structurally equivalent anonymous delegate types in the same method to be identified?&lt;/p&gt;
</description></item><item><title>Learning WPF with BabySmash - Factories, Interfaces, Delegates and Lambdas, oh my!</title><link>http://blogs.msdn.com/ericlippert/archive/2007/01/11/lambda-expressions-vs-anonymous-methods-part-two.aspx#8594187</link><pubDate>Fri, 13 Jun 2008 10:23:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8594187</guid><dc:creator>ASPInsiders</dc:creator><description>&lt;p&gt;NOTE: If you haven't read the first post in this series, I would encourage you do to that first , or&lt;/p&gt;
</description></item><item><title>Learning WPF with BabySmash - Factories, Interfaces, Delegates and Lambdas, oh my!</title><link>http://blogs.msdn.com/ericlippert/archive/2007/01/11/lambda-expressions-vs-anonymous-methods-part-two.aspx#9413723</link><pubDate>Thu, 12 Feb 2009 02:53:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9413723</guid><dc:creator>BabySmash</dc:creator><description>&lt;p&gt;NOTE: If you haven&amp;amp;#39;t read the first post in this series, I would encourage you do to that first&lt;/p&gt;
</description></item></channel></rss>