That works, thanks very much!

On Dec 21, 2025 at 23:09:53, Max Chernoff <[email protected]> wrote:

> Hi David,
>
> On Sun, 2025-12-21 at 17:21 -0800, David Chiang wrote:
>
> Is this the intended behavior,
>
>
> I wouldn't say that it's intended, but it's definitely expected. You can
> replicate fairly similar errors with just TeX code. Although I can't
> replicate your error with only 10 000 loops, I needed 100 000 instead:
>
>    \directlua{
>        for i = 1, 100000 do
>            tex.runtoks(function () end)
>        end
>    }
>    \end
>
> and is there a way to pop from the stack to avoid the overflow?
>
>
> Probably the easiest solution in this case is to insert an \expandafter
> every time that you call tex.runtoks:
>
>    \directlua{
>        local expandafter = token.create("expandafter")
>
>        for i = 1, 100000 do
>            tex.runtoks(function ()
>                token.put_next(expandafter)
>            end)
>        end
>    }
>    \end
>
> There's also a coroutine trick that you can use
>
>    https://tug.org/TUGboat/tb39-1/tb121hagen-exec.pdf
>
> although you'll need probably need to modify that code a little bit to
> work with the latest LuaTeX.
>
> Probably a better solution is to not call tex.runtoks a hundred thousand
> times since I can't really think of a scenario where that makes
> sense---it usually makes more sense to just use tex.runtoks only a few
> dozen times, even if that means that you need to include way more code
> in each call.
>
> Thanks,
> -- Max
>
_______________________________________________
dev-luatex mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to