lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Edgar Toernig <froese@gmx.de> wrote:
> 
> Just for your information.  When Lua 4.0 is out, I will make a
> version of Lua that will contain (beside other stuff) coroutines.
> ...

Looking forward to it :-)

> setjmp/longjmp was mentioned to help with this and some people
> were asking how?  It's possible to implement coroutines with
> the combination of setjmp/longjump and sigaltstack. 

Just for my own amusement, I made a test (not coroutines) using
setjmp/longjmp and Sebastien's lead.  It's not as great as I would
have liked, but if you want a look:

    http://www.alphalink.com.au/~tjaden/dev/multitask.c

If you use a compiler other than gcc or non-x86 hardware you'll need
to port a line of assembler.

> PS: IMHO, coroutines are the most underrated programming technique.
> They are more limited than continuations (Scheme) but normally,
> continuations are only used to implement coroutines ;)  And,
> coroutines are much much lighter.  They cost nothing during normal
> program execution and only as much as a subroutine call to switch
> from one coroutine to another.

Sounds cool.  I searched for "coroutines" on Google and guess whose
page I found :-)  I'm still trying to wrap my head around that `t.c'
example, BTW.

-- 
tjaden@psynet.net - http://www.psynet.net/tjaden/
MAYPOP (MAY pop), n.  A bald tire.  -- Rich Hall, "Sniglets"