[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Coroutines in Lua 5, and reloading scripts
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sat, 24 May 2003 10:52:11 -0300
> But then, the driver script uses pcall() to safely call the command
> function. For some commands this worked, but when I tried to use
> GetLine() in one of the commands, pcall came up with an error: "attempt
> to yield across metamethod/C-call boundary". I can get around it by not
> using pcall (just calling the command directly) but if I do then I run
> the risk of crashing the bot with a bad command function.
"resume" (both coroutine.resume/lua_resume) runs in protected mode, so
you do not need an extra pcall to protect a coroutine. Any error inside
a coroutine returns to the corresponding resume with an error code.
> 3) lua_closethread() doesn't seem to be implemented (at least, I couldn't
> see it - maybe I'm looking in the wrong place)
This is an error in the manual. There is no lua_closethread. Coroutines
are collected (and "closed") like any other object, through garbage
collection.
-- Roberto