lua-users home
lua-l archive

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

On Tue, Aug 6, 2019 at 3:40 AM Soni "They/Them" L. <> wrote:
Has anyone made yieldable load patches for Lua 5.2 and Lua 5.3?

I know you can run load inside load, so it should be safe to
coroutinize, but perhaps not trivial.

That's not a patch, that's a rewrite. Lua uses a recursive descent parser, a mutually recursive set of routines, with lots of state being kept on the C runtime stack. All that state would have to be stored in userdata objects, and lots of C routine would have to be added to act as continuations. That's a lot of work, and the performance would probably be a lot worse.

The 'easiest' way to implement a 'yieldable' parser would be to replace the current one with a table driven one that uses explicit stacks in stead of recursion, i.e. a full rewrite.