lua-users home
lua-l archive

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


Testing cosmopolitan (https://github.com/jart/cosmopolitan) with building several Lua versions (5.1.5, 5.2.4, 5.3.6, 5.4.4) I ended up needing to adjust the stack size at compile time (https://github.com/jart/cosmopolitan/issues/601) and discovered that different versions of Lua need different stack sizes to run the small test shown bellow, Lua-5.3.6 is the one that needs more stack space and Lua-5.4.4 the less.

What's the main change that reduced the stack size needs in Lua-5.4.4 ?

====

local nrep = 10
if #arg > 0 then nrep = tonumber(arg[1]) end
print("string.rep", nrep)
-- deep nest of gsubs
function rev (s)
  return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end)
end

local x = string.rep('012345', nrep)
print(rev(rev(x)) == x)

====