Re: Coroutines and FFI

  • From: Coda Highland <chighland@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 25 Mar 2015 12:18:54 -0700

On Wed, Mar 25, 2015 at 12:14 PM, Soni L. <fakedme+lj@xxxxxxxxx> wrote:
>
>
> On 25/03/15 04:04 PM, Coda Highland wrote:
>>
>> On Wed, Mar 25, 2015 at 8:29 AM, Soni L. <fakedme+lj@xxxxxxxxx> wrote:
>>>
>>> Why can't I pass coroutines thru the FFI as lua_State*s?
>>
>> Simply put, the FFI is not intended to interact with Lua at all.
>> Accessing the Lua state while an FFI call is on the stack is undefined
>> behavior and is very likely to blow up in your face.
>>
>> (Accessing a DIFFERENT global Lua state via FFI is perfectly safe, as
>> the LuaJIT interpreter is reentrant.)
>>
>> /s/ Adam
>>
> So... I can't have custom userdata? :/
>
> Hmm... What about adding custom userdata creation to the FFI? (for both
> heavy and light userdatum)
>

Seems like a faintly bad idea. It seems like a much better idea to
just work straight with cdata.

/s/ Adam

Other related posts: