Eric Sven Ristad <ristad / mnemonic.com> writes:

| On a related note, I'm continually surprised at how nice the yield
| statement is.
| 
| [...]
|
| In Ruby, you get the best of both worlds because (1) the block you
| pass to the iterator enjoys the environment in which the iterator is
| called, rather than the environment of the iterator itself and (2)
| the iterator enjoys its own environment.  This simple feature makes
| writing iterators at least 10 times easier than in C and similar
| languages.

The sad thing is what a shock this is to those of us who took the
Pascal/C model of execution for granted for so long.  I remember being
incredibly confused by coroutines when I read about them in Knuth,
which are the same kind of idea.

CLU and Sather have the same kind of iterator support.  It's great.

-- 
http://www.dfan.org