[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Improved ipairs for Lua 5.2/5.3
- From: Jan Behrens <jbe-lua-l@...>
- Date: Mon, 25 Aug 2014 16:25:27 +0200
Hello,
After some more work on my proposal[1] to improve ipairs in Lua, I
can finally present a completed extension library[2] that can be used
with either Lua 5.2 or Lua 5.3.0-alpha.
I removed the capability for supporting iterator triplets as input to
ipairs due to certain problems[3] and also to simplify the library.
The library consists now of approx. 200 lines of code, extending Lua in
the following manner:
* allow ipairs(seq) to accept either tables or functions (i.e function
iterators) as an argument,
* add a new function string.concat(separator, seq) that concats either
table entries or function return values,
* provide auxiliary C functions and macros to simplify iterating over
both tables and iterator functions with a generic statement.
The README file[4] of the project contains detailed information on
the new (modified) behavior of ipairs (and the motivations behind it).
The project's homepage is:
http://www.public-software-group.org/seqlua
Kind Regards
Jan Behrens
[1] http://lua-users.org/lists/lua-l/2014-08/msg00500.html
[2] http://www.public-software-group.org/seqlua
[3] the triplet func,nil,nil would require creating a closure,
since func would still need to be invoked as func(nil,prev_value)
[4] http://www.public-software-group.org/mercurial/seqlua/raw-file/tip/README