John Macdonald wrote:

The most common (and what people sometimes believe the
*only* usage) is as a generator - a coroutime which creates a
sequence of values as its "chunk" and always returns control
to its caller. (This retains part of the subordinate aspect
of a subroutine. While it has the ability to resume operation
from where it left off and so doesn't terminate as soon as it
has a partial result to pass on, it has the subordinate trait
of not caring who called it and not trying to exert any control
over which coroutine is next given control after completing a
"chunk").


[Rest of lengthy, but good explanation of coroutines omitted]

Question:

Do we not get all of this loveliness from lazy lists and the given/take syntax? Seems like that makes a pretty straightforward generator, and even wraps it into a nice, complete object that people can play with.

Now, I'm all in favor of TMTOWTDI, but in this case, if there are no other decent uses of co-routines, I don't see the need for AWTDI. Given/Take _does_ create a coroutine.


If there are good uses for coroutines that given/take does not address, I'll gladly change my opinion. But I'd like to see some examples.
FWIW, I believe that Patrick's example of the PGE returning matches could be written with given/take (if it was being written in P6).


-- Rod Adams

Reply via email to