[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: That're not coroutines
- From: Julian Squires <tek@...>
- Date: Fri, 7 Jun 2002 17:47:42 -0230
On Fri, Jun 07, 2002 at 09:48:32PM +0200, Edgar Toernig wrote:
> The "coroutines" in Lua5 just implement regular subroutines
> with preserved state. But the symmetry of "calling each other"
> does not work. In fact, something like a "yield" is a
> higher level concept that has nothing to do with basic
> coroutines but seems to be the only way in Lua5's coroutines
> to leave one.
They could very easily be used to implement Sather-style iterators,
which are restricted forms of coroutines.
Perhaps it would be better to name them something like that?
(then again, the name iterator isn't really sufficiently general, I
I personally don't have any problem with the name (as that's the
terminology used around sather and clu), but I don't have a problem with
the name changing, either. But having the feature is great!
It allows easy creation of safe iterators in lua, so various horrible
things like fencepost errors can be more easily avoided.
|/| Julian Squires <firstname.lastname@example.org>