[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Yielding across lua_load
- From: "Christian N." <cn00@...>
- Date: Sat, 10 Oct 2015 15:57:03 +0200
On 2015-10-08 19:48 +0200, Soni L. wrote:
On 08/10/15 02:21 PM, Patrick Donnelly wrote:
On Thu, Oct 8, 2015 at 7:55 AM, Soni L. <firstname.lastname@example.org> wrote:
Is it possible to yield across lua_load?
Disclaimer: these emails may be made public at any given time, with or
without reason. If you don't agree with this, DO NOT REPLY.
Lua 5.3.1 Copyright (C) 1994-2015 Lua.org, PUC-Rio
coroutine.wrap(function() assert(load(function() coroutine.yield("a =
1") end)) end)()
stdin:1: stdin:1: attempt to yield across a C-call boundary
[C]: in ?
stdin:1: in main chunk
[C]: in ?
I said lua_load.
load() uses lua_call internally (not lua_callk)
I don't think that would be possible, as yielding would jump outside
lua_load using longjmp, losing any information lua_load has stored on
the C stack (probably even leaking memory). However, using something
like the C++ library Boost.Context or Boost.Coroutine, a workaround
might maybe be possible as these libraries provide a way to sort of save
the C stack.