[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re: 3 q's: lua_sethook in coroutines :: co-routine return values :: nice variable dumper
- From: Peter Bradshaw <flatfeetpete@...>
- Date: Mon, 28 Jun 2004 11:42:53 -0700
Thanks very much for the reply, the co-routine thing was confusing me a little.
And thanks for the pointer about the hooks the list archive was very
useful, I hadn't noticed the search (Doh!).
As for the hooks and debuging I need to do something a little nicer
anyway, I may pump out UDP or similar to a listener app. I don't know.
Thanks again.
Pete
On Fri, 25 Jun 2004 03:39:07 +0200, Mike Pall <mikelu-0406@mike.de> wrote:
>
> Hi,
>
> 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:
>
> function f(a,b,c)
> coroutine.yield(a,b,c)
> end
>
> t=coroutine.create(f)
> 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.
>
> Bye,
> Mike
>