[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Launching and controlling multiple lua scripts from Lua
- From: Thijs Schreijer <thijs@...>
- Date: Sat, 1 Feb 2014 09:51:01 +0000
> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] 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 <milind.gupta@gmail.com>
> 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.
>
> http://www.lua.org/manual/5.2/manual.html#4.7 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