[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Abusing Lua iterators for fun and profit
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 5 Feb 2015 18:47:35 -0200
> [...]
> It's (in my opinion) cleaner and easier to read. Now my question: can I
> rely upon this behavior of io.lines() and string.gmatch() to only return a
> single function? I tested it on Lua 5.1, 5.2, 5.3 and LuaJIT, and in each
> case, only a function was returned. Am I relying upon an implementation
> detail? Should I use the first version, where I pass in the state and value
> each time, to be "safe"?
>
> -spc
I guess the best solution is not to use lines/gmatch at all, but
read/match (or find). See [1] for something similar.
[1] http://www.lua.org/pil/7.1.html
-- Roberto