lua-users home
lua-l archive

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


Em qui, 2020-04-23 às 22:14 +0100, Dibyendu Majumdar escreveu:
> On Thu, 23 Apr 2020 at 02:30, Hisham <h@hisham.hm> wrote:
> > For example, with `uname -n` set below 10000, this script crashes
> > on
> > Lua < 5.4, and works in Lua 5.4:
> > 
> > local lfs = require("lfs")
> > for t = 1, 10000 do
> >    local i = 0
> >    for e in lfs.dir("/usr/lib") do
> >       i = i + 1
> >       if i == 100 then
> >          break
> >       end
> >    end
> > end
> > 
> 
> Out of interest, how would you have written this in older versions of
> Lua?

IIRC, the most most direct workaround was to manually call
collectgarbage in order to run the iterator's __gc metamethod. The
performance is not ideal though.

-- Hugo
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org