lua-users home
lua-l archive

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

On Thu, Oct 8, 2015 at 1:48 PM, Soni L. <> wrote:
> On 08/10/15 02:21 PM, Patrick Donnelly wrote:
>> On Thu, Oct 8, 2015 at 7:55 AM, Soni L. <> 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
>> Lua 5.3.1  Copyright (C) 1994-2015, 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
>> stack traceback:
>>          [C]: in ?
>>          stdin:1: in main chunk
>>          [C]: in ?
> I said lua_load.
> load() uses lua_call internally (not lua_callk)

The documentations says:

"To avoid this kind of problem, Lua raises an error whenever it tries
to yield across an API call, except for three functions:
lua_yieldk,lua_callk, and lua_pcallk. All those functions receive a
continuation function (as a parameter named k) to continue execution
after a yield."

[I'm not going to check if lua_load will throw an error if you try to
yield across it.] The documentation requires that a yieldable API must
also receive a continuation function. lua_load has no argument for a
continuation function.

Patrick Donnelly