lua-users home
lua-l archive

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


> It looks - from your explanation - that using 'userstate' and
> 'hooks' are the prefered way in adding functionality - like the
> one I'm asking - to the LUA VM. Is that correct?

Yes. Aside from the line "if (L->nCcalls > 0) return" you'll be
working through the API and can thus assume upwards
compatibility. To add some user state to the lua state structure,
define the LUA_USERSTATE macro to have something
prepended (placed below the lua state pointer): you want
the yield timing to be done on a per-VM-instance basis, so
having some storage to go with a lua state is handy.

> > Also, coroutines cannot be used from within a resume.

> I'm kind of curious about the 'coroutines cannot be used from
> within a resume'. Maybe I'm just lucky, but the following 
> example works as 'expected' in my test:

My mistake. You're right, they work. I'm doing some further
stuff that breaks them, and erroneously assumed it was due to
the hook yielding.

Albert-Jan