[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Coroutines & C boundaries
- From: David Given <dg@...>
- Date: Thu, 16 Feb 2006 11:27:20 +0000
On Thursday 16 February 2006 00:53, Mike Pall wrote:
[...]
> Try print(debug.traceback()) immediately before the yield and
> ye shall see.
I'm slightly embarrassed to admit I didn't think about that.
[...]
> No. luaV_execute() is called from two places.
> You want the other one. It's called resume(). :-)
I found that, but I'm never calling it, and it doesn't change nCcalls unless
cleaning up after an error, so it shouldn't have been relevant.
[...]
> Your problem:
>
> -> lua_resume
> --> resume
> ---> luaV_execute
> ----> luaD_precall
> -----> luaB_pcall or a C function which calls back into Lua <-- !!
The problem was that my coroutine top-level function runs everything inside a
pcall, so it can trap errors. And pcall, despite being a pure Lua function,
apparently counts as a C call and you can't yield across it. Ack.
It might be worth emphasising this in the manual; I would never have thought
of this --- pcall looks like pure Lua, and therefore I assumed that you could
yield across it.
Now it's all working, and the R is back into my RAD. Thanks for all the help,
everyone!
--
+- David Given --McQ-+ "There is // One art // No more // No less // To
| dg@cowlark.com | do // All things // With art // Lessness." --- Piet
| (dg@tao-group.com) | Hein
+- www.cowlark.com --+
Attachment:
pgpXakToeMpoJ.pgp
Description: PGP signature