lua-users home
lua-l archive

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


On Dec 20, 2001 at 01:24 -0600, Roberto Ierusalimschy wrote:
> On Thu, 20 Dec 2001, Thatcher Ulrich wrote:
> 
> > A couple of questions: I notice the VM is now stackless for
> > Lua-calls-to-Lua, and there's an explicit CallInfo stack.  But there
> > doesn't seem to be any sign of lua_resume(), lua_sleep()/yield() etc.
> > Is that planned, and just not implemented yet?
> 
> It is planned, but we still have to work out some details. One
> particular concern is the use of longjmp/setjmp in a "regular" mechanism
> (as opposed to error handling).

A better alternative, that I thought about for the patch, but decided
would cause too many changes: add an OP_YIELD opcode.  With the
stackless changes, an OP_YIELD opcode could set a flag and return from
luaV_execute, leaving the lua_State in a resumable state.  No need for
longjmp/setjmp.

> > Also, whatever happened to non-recursive tailcalls?  In 4.0 with the
> > sleep/yield patch they worked nicely because of OP_TAILCALL.  Are you
> > thinking about implementing that?  I guess it could be implemented
> > without OP_TAILCALL by peeking at the opcode following an OP_CALL, and
> > if it's OP_RETURN then just reuse the current stack frame instead of
> > making a new one.
> 
> Our concern here is error messages. A OP_TAILCALL leaves no trace of the
> calling function, and that may be quite confusing in error messages.

FWIW, I personally have no problem with tail recursion not showing up
in a stack trace.  Iterative loops don't show up on a stack trace
either.

-- 
Thatcher Ulrich <tu@tulrich.com>
http://tulrich.com