lua-users home
lua-l archive

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


On Sun, 2005-01-23 at 04:53, Mike Pall wrote:
> Hi,
> 
> John Skaller wrote:
> > There's also a solution for Python (Stackless Python),
> > maybe it is worth looking at that (since it's also 
> > a bytecode interpreter).
> 
> Stackless Python does stack ripping for many core functions 

What's stack ripping?

> plus C stack copying 

It uses continuation passing AFAIK..  of course if you call
a C function which calls a callback, you have a stack
whether you like it or not. So even if you can 'resume/yield'
out of a callback, you'd have to get back in to return
to the caller...

> (a bit more portable than C stack switching, but slower). Ruby does
> stack copying, too.

Neither copying nor switching works properly in C++
due to exception handling stuff :(

> Alas, stack copying is problematic for Lua since we cannot assume an even
> C stack base for the caller of lua_resume(). 

Right.

> This could be solved by
> hardwiring a scheduler into the core. But I do not think this is the way
> to go for Lua.

This is probably right. However note that
the bytecode interpreter does actually schedule
execution of bytecodes.

If you re-enter it recursively (using loadfile or whatever),
you're screwed. But this can be fixed with a mechanical
transform to CPS (Continuation Passing Style) ..
pass the bytecode return address as an argument
instead of pushing it onto the stack.

This will change the C API though .. hmmm.. sorry just
rambling .. :)

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net