lua-users home
lua-l archive

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

> -----Original Message-----
> From: [] On
> Behalf Of Andrew Starks
> Sent: vrijdag 31 januari 2014 23:59
> To: Lua mailing list
> Subject: Re: Launching and controlling multiple lua scripts from Lua
> On Fri, Jan 31, 2014 at 3:11 PM, Milind Gupta <>
> wrote:
> I get an error saying I cannot yield across C-call boundary. That is
> probably because the script I execute is loaded with loadstring. I even
> tried making modules of the scripts and requiring them. That also did not
> work.
> So we can't use coroutines across modules? Any way we can do this?
> This is not a problem, but it must be accounted for. In short, because C
> only has a single stack, it cannot continue from a call into lua, which
> could then yield into another state and then call into C, because it will
> lose C context.
> Therefore, you need to create a continuation function, which splits your C
> function in two and requires you to package your state variables in a
> context object. I'm probably botching this, but essentially, I think that's
> correct.
> is your friend, but this sort
> of thing all but requires Programming In Lua, 3rd Edition. 5.1 cannot do
> this without the help of... copas? I can't remember. 

Isn't that the coxpcall module?

> LuaJIT can do this, but
> I believe that it is different than in Lua 5.2 (don't know for sure).
> --Andrew