[Python-Dev] Simple generators, round 2

Tim Peters tim_one@email.msn.com
Tue, 20 Mar 2001 01:31:49 -0500


[Neil Schemenauer]
> I like the frame methods.  However, this may be a good idea since
> Jython may implement things quite differently.

Note that the "compare fringes of two trees" example is a classic not because
it's inherently interesting, but because it distills the essence of a
particular *class* of problem (that's why it's popular with academics).

In Icon you need to create co-expressions to solve this problem, because its
generators aren't explicitly resumable, and Icon has no way to spell "kick a
pair of generators in lockstep".  But explicitly resumable generators are in
fact "good enough" for this classic example, which is usually used to
motivate coroutines.

I expect this relates to the XLST/XSLT/whatever-the-heck-it-was example:  if
Paul thought iterators were the bee's knees there, I *bet* in glorious
ignorance that iterators implemented via Icon-style generators would be the
bee's pajamas.

Of course Christian is right that you have to prevent a suspended frame from
getting activated more than once simultaneously; but that's detectable, and
should be considered a programmer error if it happens.