<?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>Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx</link><description>I've returned from a brief vacation, visiting friends on the island of Maui. I'd never been to that part of the world before. Turns out, it's a small island in the middle of the Pacific Ocean, entirely made out of volcanoes. Weird! But delightful. 
</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx#9922525</link><pubDate>Sat, 14 Nov 2009 19:59:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9922525</guid><dc:creator>Sanil</dc:creator><description>&lt;p&gt;Hi Eric!&lt;/p&gt;
&lt;p&gt;Just a humble request, can you read my post &lt;a rel="nofollow" target="_new" href="http://www.thewiredguy.com/wordpress/?p=62"&gt;http://www.thewiredguy.com/wordpress/?p=62&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;and validate my approach (and point out any pitfalls) to LINQ problem you mentioned in your previous blog post :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9922525" width="1" height="1"&gt;</description></item><item><title>re: Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx#9921754</link><pubDate>Fri, 13 Nov 2009 04:44:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9921754</guid><dc:creator>configurator</dc:creator><description>&lt;p&gt;&amp;quot;No, and no. -- Eric&amp;quot;&lt;/p&gt;
&lt;p&gt;I think the story would be even more interesting if a manager suddenly popped out from behind a bush and gave her the fish.&lt;/p&gt;
&lt;p&gt;By the way, are all Maui names as short as your friends'? That would be quite confusing whenever in a group of about eight or more people.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9921754" width="1" height="1"&gt;</description></item><item><title>re: Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx#9919157</link><pubDate>Sun, 08 Nov 2009 01:19:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9919157</guid><dc:creator>Mark</dc:creator><description>&lt;p&gt;Gabe: Mahalo&lt;/p&gt;
&lt;p&gt;          &amp;nbsp;                                                                                                vv&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9919157" width="1" height="1"&gt;</description></item><item><title>re: Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx#9918662</link><pubDate>Fri, 06 Nov 2009 16:28:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918662</guid><dc:creator>mike</dc:creator><description>&lt;P&gt;I find it kind of amazing that you have such in-depth knowledge about Hannah Montana and her alter ego. I didn't know that, and we have a subteen female child in the house. &lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;I don't. I looked it up on wikipedia. -- Eric&lt;/P&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918662" width="1" height="1"&gt;</description></item><item><title>re: Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx#9918610</link><pubDate>Fri, 06 Nov 2009 15:01:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918610</guid><dc:creator>Niall Connaughton</dc:creator><description>&lt;P&gt;In regards to your first comment on configurator's post, it always felt to me that having the loop variable for a foreach declared in the outer declaration space leads to unintuitive behaviour of closures inside the foreach. ie: it felt intuitive to me to have a fresh new delegate for each loop, with a fresh new "m" as you say.&lt;/P&gt;
&lt;P&gt;Does the current behaviour exist due to the C# specification mandating it be so before closures existed in C#? Or is this desired behaviour and I'm missing some understanding of why declaring the variable in the outer scope is better?&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;The former. It is undesirable behaviour and we are considering taking the breaking change. I've been meaning to blog about this for a while. -- Eric&lt;/P&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918610" width="1" height="1"&gt;</description></item><item><title>re: Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx#9918513</link><pubDate>Fri, 06 Nov 2009 11:05:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918513</guid><dc:creator>AnnoyedFromMidwest</dc:creator><description>&lt;P&gt;Did the manager turn up and did the customer get the fish without the chips?&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;No, and no. -- Eric&lt;/P&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918513" width="1" height="1"&gt;</description></item><item><title>re: Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx#9918414</link><pubDate>Fri, 06 Nov 2009 06:45:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918414</guid><dc:creator>Gabe</dc:creator><description>&lt;P&gt;Thank you for spelling the okina (the glottal stop in Hawaiian words) as an ANSI-standard apostrophe rather than some obscure Unicode character that only exists in exotic Unicode fonts.&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;That wasn't deliberate; I had no idea it was anything other than an apostrophe. -- Eric&lt;/P&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918414" width="1" height="1"&gt;</description></item><item><title>re: Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx#9918279</link><pubDate>Thu, 05 Nov 2009 22:25:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918279</guid><dc:creator>configurator</dc:creator><description>&lt;P&gt;Two quick questions.&lt;/P&gt;
&lt;P&gt;1. Is the code&lt;/P&gt;
&lt;P&gt;int m;&lt;BR&gt;while(e.MoveNext()) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;m = e.Current;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.Write(m);&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;And the code&lt;/P&gt;
&lt;P&gt;while (e.MoveNext()) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;int m = e.Current;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.Write(m);&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;Equivalent, or is there any difference, besides having the variable unnecessarily in the outer declaration space?&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;Those are equivalent, but if instead of Console.Write(m), that was M(()=&amp;gt;m), then there would be a difference. The first program would call M with the same delegate over and over, a delegate closed over the single outer variable m. The second program would call M with a fresh new delegate each time, each one bound to a fresh new "m". -- Eric&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;is the variable in the second example reallocated in each iteration, or does the CLR know to do the "smart thing" and allocate it only once?&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;In the straightforward non-closure case, the jitter generates code which re-uses the same stack slot or register in both scenarios. In the closure case, things get much more complicated because we must allocate closure classes; since the variables can survive beyond the loop body if the delegate survives, then the storage cannot be re-used in the second case. -- Eric&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;2. Why m = (int)(int)e.Current(); and not m = e.Current; ?&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;I was being uber-picky. The spec states that the code generation for a foreach loop is to determine the loop variable type V, and the type of the collection elements, T, and then do casts (V)(T)e.Current;&amp;nbsp;The cast to T is actually redundant, though the cast to V is a true cast that can produce failures. -- Eric&lt;/P&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918279" width="1" height="1"&gt;</description></item><item><title>re: Simple names are not so simple, Part Two, plus, volcanoes and fried foods</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx#9918195</link><pubDate>Thu, 05 Nov 2009 19:53:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918195</guid><dc:creator>Rob</dc:creator><description>&lt;P&gt;It physically pains me to be pointing this out, but it's Miley Cyrus, not Stewart.&lt;/P&gt;
&lt;P&gt;OW.&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;I hate to be contradictory, but no, it is in fact&amp;nbsp;&lt;STRONG&gt;Miley&lt;/STRONG&gt; &lt;STRONG&gt;Stewart&lt;/STRONG&gt; who is the secret identity of Hannah Montana.&amp;nbsp;Miley Stewart/Hannah Montana are&amp;nbsp;&lt;STRONG&gt;played by an actress &lt;/STRONG&gt;named &lt;STRONG&gt;Miley&lt;/STRONG&gt; &lt;STRONG&gt;Cyrus&lt;/STRONG&gt;. OW OW OW. -- Eric&lt;/P&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918195" width="1" height="1"&gt;</description></item></channel></rss>