lua-users home
lua-l archive

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


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
>