[<<][compsci][>>][..]
Sat Sep 21 23:57:45 EDT 2013

Iterator Blocks

The task/SM translation I was thinking about is the same as "iterator
blocks" mention here [1]:

  Iterator blocks allow to have both advantages at the same time:

  - Their code looks pretty much the same as with internal iteration

  - The compiler transforms this code into a class/object/type
    implementing the interface of an external iterator

  - The generated iterator object can often be implemented very
    efficiently via a simple FSM

This[2] aso mentions "yield" in C# being converted to a state machine.
Another one[3].  Looks like the C# semantics is same/similar to
python's: only yield in main method.

So looking again at python generators: a 'def' creates a generator
when the body has a yield operation in it.  A yield operation in a
called function doesn't work as expected: control nesting can't be
implemented in function calls: all control nesting needs to be local
in the definition.


[1] http://michaelwoerister.github.io/2013/07/26/Iterator-Blocks.html
[2] http://www.marshut.com/nxyuu/the-future-of-iterators-in-rust.html
[3] http://blogs.msdn.com/b/shawnhar/archive/2010/10/01/iterator-state-machines.aspx





[Reply][About]
[<<][compsci][>>][..]