<?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 and Expression Trees</title><link>http://blogs.msdn.com/vbteam/archive/2007/09/11/lambda-expressions-and-expression-trees.aspx</link><description>Hi there! My name is Tim, and I'm the dev lead for the VB compiler team. Recently Amanda convinced me to blog on the VB team blog rather then my own blog for a variety of reasons, and so here I am. My current plan is that I'll post VB related postings</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>MSDN Blog Postings  &amp;raquo; Lambda Expressions and Expression Trees</title><link>http://blogs.msdn.com/vbteam/archive/2007/09/11/lambda-expressions-and-expression-trees.aspx#4875001</link><pubDate>Wed, 12 Sep 2007 07:45:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4875001</guid><dc:creator>MSDN Blog Postings  » Lambda Expressions and Expression Trees</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://msdnrss.thecoderblogs.com/2007/09/12/lambda-expressions-and-expression-trees/"&gt;http://msdnrss.thecoderblogs.com/2007/09/12/lambda-expressions-and-expression-trees/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Lambda Expressions and Expression Trees</title><link>http://blogs.msdn.com/vbteam/archive/2007/09/11/lambda-expressions-and-expression-trees.aspx#4920113</link><pubDate>Sat, 15 Sep 2007 03:00:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4920113</guid><dc:creator>Fduch</dc:creator><description>&lt;p&gt;Please! &lt;/p&gt;
&lt;p&gt;Fix the bug with VB lambda expressions in Beta 2.&lt;/p&gt;
&lt;p&gt;These same line of code comile to very different IL and return different results in VB and C#. &lt;/p&gt;
&lt;p&gt;I don't understab why, but VB compiler generates closures for this code and returns wrong results.&lt;/p&gt;
&lt;p&gt;C#&lt;/p&gt;
&lt;p&gt;delegate TReturn SelfApplicable0&amp;lt;TReturn&amp;gt;(SelfApplicable0&amp;lt;TReturn&amp;gt; self);&lt;/p&gt;
&lt;p&gt;SelfApplicable0&amp;lt;Func&amp;lt;Func&amp;lt;Func&amp;lt;int, int&amp;gt;, Func&amp;lt;int, int&amp;gt;&amp;gt;, Func&amp;lt;int, int&amp;gt;&amp;gt;&amp;gt; YC = y =&amp;gt; f =&amp;gt; x =&amp;gt; f(y(y)(f))(x);&lt;/p&gt;
&lt;p&gt;VB&lt;/p&gt;
&lt;p&gt;Delegate Function SelfApplicable0(Of TReturn)(ByVal self As SelfApplicable0(Of TReturn)) As TReturn&lt;/p&gt;
&lt;p&gt;Dim YC As SelfApplicable0(Of Func(Of Func(Of Func(Of Integer, Integer), Func(Of Integer, Integer)), Func(Of Integer, Integer))) = Function(y) Function(f) Function(x) f(y(y)(f))(x)&lt;/p&gt;
</description></item><item><title>re: Lambda Expressions and Expression Trees</title><link>http://blogs.msdn.com/vbteam/archive/2007/09/11/lambda-expressions-and-expression-trees.aspx#4999403</link><pubDate>Wed, 19 Sep 2007 20:56:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4999403</guid><dc:creator>VBTeam</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;Thanks for posting this suggestion. &amp;nbsp;The behavior is actually by design, and not a bug at all. &amp;nbsp;If you run the code you'll notice the output is exactly the same as C#.&lt;/p&gt;
&lt;p&gt;VB's closures are the same as C#'s display classes. In the C# example, there is a nesting level of 2 display classes. In VB, we have a nesting level of 3 closures. C# chose to optimize one level of display classes away by creating a static function for lambdas that don't lift variables. VB chose not to do this optimization because these classes would then not be hostable in the SQL CLR.&lt;/p&gt;
&lt;p&gt;Hope that helps,&lt;/p&gt;
&lt;p&gt;Jonathan Aneja&lt;/p&gt;
&lt;p&gt;PM, VB Team&lt;/p&gt;
</description></item><item><title>VB 2008 Language Deep Dive - Presentation Materials (Jonathan Aneja)</title><link>http://blogs.msdn.com/vbteam/archive/2007/09/11/lambda-expressions-and-expression-trees.aspx#8883457</link><pubDate>Thu, 21 Aug 2008 08:09:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8883457</guid><dc:creator>The Visual Basic Team</dc:creator><description>&lt;p&gt;Last week I got the chance to visit the Toronto .NET User Group and give a talk on all the great new&lt;/p&gt;
</description></item></channel></rss>