[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: 3 q's: lua_sethook in coroutines :: co-routine return values :: nice variable dumper
- From: Mike Pall <mikelu-0406@...>
- Date: Fri, 25 Jun 2004 03:39:07 +0200
Peter Bradshaw wrote:
> 1. lua_sethook and coroutines
Hooks are set per-thread and not globally. This has been mentioned in
another list thread recently and Roberto indicated that it may be more
reasonable to have global hooks. I don't know whether this will be
changed in 5.1 (but I would like to see this, too).
In the meantime you have to wrap the coroutine.create/wrap functions with
your own functions and set the hook of the new thread. Dito if you are
calling lua_newthread() from C.
> 2. co-routine return values.
Here is simple example:
print(coroutine.resume(t, 1, 2, 3)) ---> a=1, b=2, c=3
1, 2, 3 <--- coroutine.yield(a, b, c)
==> true 1 2 3
coroutine.resume() calls the coroutine with error catching turned on
(similar to what pcall() does), so you get an additional first return
value that indicates success or failure of the coroutine call.
> 3. nice variable dumper.
Someone else will have to answer this one.