Yieldable load

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Yieldable load

Soni "They/Them" L.
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.

Reply | Threaded
Open this post in threaded view
|

Re: Yieldable load

Gé Weijers

On Tue, Aug 6, 2019 at 3:40 AM Soni "They/Them" L. <[hidden email]> 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.


--
--