<?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>Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx</link><description>I recently was given a piece of C# code with statements like: yield return value; and yield break; This was the beginning of my descent into the loopy world of C# 2.0 iterators. It took me awhile to wrap my head around them, and when I tried to explain</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#197314</link><pubDate>Mon, 26 Jul 2004 22:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197314</guid><dc:creator>Sanin Saracevic</dc:creator><description>This seems like a higher-level construct of a &amp;quot;standard&amp;quot; NT Fiber. Am I missing something?</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#197317</link><pubDate>Mon, 26 Jul 2004 22:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197317</guid><dc:creator>R. Andrew Lamonica</dc:creator><description>Does the method have to return &amp;quot;IEnumerable&amp;quot; or can the &amp;quot;yield return&amp;quot; be used to return other values?  I can see where the lack of an Iterator would make it hard for the runtime to know when to restart at the begining of the function but it might be a fun trick to play with.&lt;br&gt;&lt;br&gt;B.T.W. I could just check this but I don't seem to have a version of .NET that supports this construct.  Is 2.0 Beta available to the public?</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#197329</link><pubDate>Mon, 26 Jul 2004 22:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197329</guid><dc:creator>Nick Parker</dc:creator><description>There is an article in MSDN covering Coroutines in .NET.&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://msdn.microsoft.com/msdnmag/issues/03/09/coroutinesinnet/"&gt;http://msdn.microsoft.com/msdnmag/issues/03/09/coroutinesinnet/&lt;/a&gt;</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#197359</link><pubDate>Mon, 26 Jul 2004 22:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197359</guid><dc:creator>Matt Pietrek</dc:creator><description>Sanin: When I first looked at Iterators, I also noticed the similarity to Win32 Fibers.  However, Fibers aren't used in the C# implementation.&lt;br&gt;&lt;br&gt;Andrew: The Whidbey beta can be downloaded: &lt;a target="_new" href="http://lab.msdn.microsoft.com/vs2005/get/default.aspx#express"&gt;http://lab.msdn.microsoft.com/vs2005/get/default.aspx#express&lt;/a&gt;</description></item><item><title>Implementing Scheme-like streams in C#?</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#197620</link><pubDate>Tue, 27 Jul 2004 00:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197620</guid><dc:creator>David's blog</dc:creator><description /></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#197959</link><pubDate>Tue, 27 Jul 2004 11:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197959</guid><dc:creator>AT</dc:creator><description>An question - Why exceptions try/catch/finaly not allowed with yeild ?&lt;br&gt;&lt;br&gt;&lt;br&gt;See also:&lt;br&gt;Fibers, and other mad stuff that you shouldn’t use&lt;br&gt;&lt;a target="_new" href="http://blogs.msdn.com/greggm/archive/2004/06/07/150298.aspx"&gt;http://blogs.msdn.com/greggm/archive/2004/06/07/150298.aspx&lt;/a&gt;</description></item><item><title>Matt Pietrek on Iterators</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#199642</link><pubDate>Wed, 28 Jul 2004 18:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:199642</guid><dc:creator>Mike Taulty's Weblog</dc:creator><description /></item><item><title>Matt Pietrek on How Iterators Work</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#205977</link><pubDate>Mon, 02 Aug 2004 20:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:205977</guid><dc:creator>.Net Security Blog</dc:creator><description /></item><item><title>C# 2.0 Iterators</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#206095</link><pubDate>Mon, 02 Aug 2004 23:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:206095</guid><dc:creator>Another Tired Idea</dc:creator><description /></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#206097</link><pubDate>Mon, 02 Aug 2004 23:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:206097</guid><dc:creator>Chad Humphries</dc:creator><description>Just thought I'd say thanks for the article.   I really enjoyed it!</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#206163</link><pubDate>Tue, 03 Aug 2004 00:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:206163</guid><dc:creator>drebin</dc:creator><description>Interesting..... but I don't get it. How or why would you ever use something like this???</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#206323</link><pubDate>Tue, 03 Aug 2004 03:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:206323</guid><dc:creator>Amit</dc:creator><description>It seems that from the ILDASM code, the current state is modified _after_ the code in the yield block executes. This means that any construct that will cause the flow of execution to shift before state modification is either not allowed or will cause problems. &lt;br&gt;&lt;br&gt;Isn't it better to modify the state first and then let the yield block execute?&lt;br&gt;</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#206416</link><pubDate>Tue, 03 Aug 2004 05:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:206416</guid><dc:creator>Julian - SerialN6kCom</dc:creator><description>Thanks, for the article.</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#206519</link><pubDate>Tue, 03 Aug 2004 08:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:206519</guid><dc:creator>Timothy</dc:creator><description>Why not use collections?</description></item><item><title>Iterators in C#, Python, and Ruby</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#206670</link><pubDate>Tue, 03 Aug 2004 12:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:206670</guid><dc:creator>Michael Geary</dc:creator><description>It's interesting to compare these new C# iterators with the very similar ones in Python and Ruby. There's less code involved in those languages, making the iterators easier to understand.&lt;br&gt;&lt;br&gt;To see how they compare, I translated some of the sample C# iterator code to Python and Ruby:&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://mg.to/2004/08/03/iterator-cpr"&gt;http://mg.to/2004/08/03/iterator-cpr&lt;/a&gt;</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#207131</link><pubDate>Tue, 03 Aug 2004 19:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:207131</guid><dc:creator>Matt Pietrek</dc:creator><description>Timothy and drebin: The article I linked to in the main text (&lt;a target="_new" href="http://msdn.microsoft.com/msdnmag/issues/04/05/c20/"&gt;http://msdn.microsoft.com/msdnmag/issues/04/05/c20/&lt;/a&gt;) provides a much better &amp;quot;big picture&amp;quot; view of iterators than I did in this entry.&lt;br&gt;&lt;br&gt;My short answer about the usefulness of iterators is that they make it much easier to implement your data as .NET collections that work with &amp;quot;foreach&amp;quot;.  In the past, implementing the code to support enumerating your data could be quite complicated. Iterators also make it very easy to support multiple ways of iterating over your data (e.g., first to last, last to first, every other item, etc...)</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#207765</link><pubDate>Wed, 04 Aug 2004 10:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:207765</guid><dc:creator>Roshan James</dc:creator><description>Here are some potentially relevant writeups - &lt;br&gt;&lt;br&gt;Implementation of Iterators in C#&lt;br&gt;&lt;a target="_new" href="http://pensieve.thinkingms.com/CommentView,guid,fd10bfa8-1aeb-4353-84c8-cd80e418424f.aspx"&gt;http://pensieve.thinkingms.com/CommentView,guid,fd10bfa8-1aeb-4353-84c8-cd80e418424f.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;Implementation of Closures (Anonymous Methods) in C# 2.0&lt;br&gt;&lt;a target="_new" href="http://pensieve.thinkingms.com/CommentView,guid,9fe42970-09e3-44e2-a4d0-32d63139351a.aspx"&gt;http://pensieve.thinkingms.com/CommentView,guid,9fe42970-09e3-44e2-a4d0-32d63139351a.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;These might be relevant too - &lt;br&gt;&lt;br&gt;Iterators in Ruby&lt;br&gt;&lt;a target="_new" href="http://pensieve.thinkingms.com/CommentView,guid,dd0e61ef-6fb1-4156-9d16-81c20a6aa871.aspx"&gt;http://pensieve.thinkingms.com/CommentView,guid,dd0e61ef-6fb1-4156-9d16-81c20a6aa871.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;Warming up to using Iterators&lt;br&gt;&lt;a target="_new" href="http://pensieve.thinkingms.com/CommentView,guid,02da61dd-1e35-4a36-b46b-aa3a605b2ad6.aspx"&gt;http://pensieve.thinkingms.com/CommentView,guid,02da61dd-1e35-4a36-b46b-aa3a605b2ad6.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;The ‘Big Deal’ about Iterators&lt;br&gt;&lt;a target="_new" href="http://pensieve.thinkingms.com/CommentView,guid,d355277d-a942-4a50-aa03-d68413fd459c.aspx"&gt;http://pensieve.thinkingms.com/CommentView,guid,d355277d-a942-4a50-aa03-d68413fd459c.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;CLR 2.0 Closures and Environment classes that capture arity&lt;br&gt;&lt;a target="_new" href="http://pensieve.thinkingms.com/CommentView,guid,92e51a8a-4d8d-4401-beb2-8b68a019d4bb.aspx"&gt;http://pensieve.thinkingms.com/CommentView,guid,92e51a8a-4d8d-4401-beb2-8b68a019d4bb.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Matt, its surprising that a hardcore systems programming person like you is writing about implementation of managed compilers, very nice :)&lt;br&gt;&lt;br&gt;cheers&lt;br&gt;Roshan James</description></item><item><title>re: Fun with Iterators and state machines</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#209146</link><pubDate>Thu, 05 Aug 2004 21:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:209146</guid><dc:creator>Paul Ballard</dc:creator><description>Congratulations, this blog has been featured on TheServerSide.NET</description></item><item><title>Generic algorithms for C# 2.0 using iterators and anonymous methods</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#211949</link><pubDate>Tue, 10 Aug 2004 18:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:211949</guid><dc:creator>Peli's Blog</dc:creator><description /></item><item><title>A look at C# 2.0 Iterators by Matt Pietrek</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#215897</link><pubDate>Tue, 17 Aug 2004 21:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:215897</guid><dc:creator>phool.org</dc:creator><description /></item><item><title>Generic algorithms for C# 2.0 using iterators and anonymous methods</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#216381</link><pubDate>Wed, 18 Aug 2004 10:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:216381</guid><dc:creator>Peli's Blog</dc:creator><description /></item><item><title>浅谈 C# 中的代码协同 (Coroutine) 执行支持</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#218542</link><pubDate>Sun, 22 Aug 2004 18:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:218542</guid><dc:creator>Flier Lu</dc:creator><description>Ping Back来自：blog.csdn.net</description></item><item><title>CCR 101 - Part 9: Iterators &amp;laquo; Iodyne&amp;#8217;s Weblog</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#8727862</link><pubDate>Sun, 13 Jul 2008 13:35:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8727862</guid><dc:creator>CCR 101 - Part 9: Iterators &amp;laquo; Iodyne&amp;#8217;s Weblog</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://iodyne.wordpress.com/2008/07/13/ccr-101-part-9-iterators/"&gt;http://iodyne.wordpress.com/2008/07/13/ccr-101-part-9-iterators/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>   MRM: Microthreading Functions at Adam Frisby</title><link>http://blogs.msdn.com/matt_pietrek/archive/2004/07/26/197242.aspx#9566140</link><pubDate>Fri, 24 Apr 2009 09:14:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9566140</guid><dc:creator>   MRM: Microthreading Functions at Adam Frisby</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.adamfrisby.com/blog/2009/04/mrm-microthreading-functions/"&gt;http://www.adamfrisby.com/blog/2009/04/mrm-microthreading-functions/&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>