# HG changeset patch # User jbe # Date 1409091664 -7200 # Node ID 37c2841c6e8c106f36504901b9b07b4ccf41ac8c # Parent 92ce3958aca7cbf64882a0bb6747086baaf53798 Added warning regarding nested/repeated loops to README diff -r 92ce3958aca7 -r 37c2841c6e8c README --- a/README Wed Aug 27 00:10:47 2014 +0200 +++ b/README Wed Aug 27 00:21:04 2014 +0200 @@ -1,7 +1,7 @@ seqlua: Extension for handling sequential data in Lua ===================================================== -This package is an extension for the Lua programming language (version 5.2) +This package is an experimental extension for the Lua 5.2 programming language which: * allows ``ipairs(seq)`` to accept either tables or functions (i.e function @@ -101,11 +101,23 @@ macros to iterate over values in the same manner as a generic loop statement with ``ipairs`` would do. -Note that this extension doesn't aim to supersede Lua's concept of iterator -functions. While metamethods (see section "Respected metamethods" below) may be -used to customize iteration behavior on values, this extension isn't thought to -replace the common practice to use function closures as iterators. Consider the -following example: +Note that in case of repeated or nested loops, using function iterators may not +be feasible: + + function print_list_twice(seq) + for i = 1, 2 do + for i, v in ipairs(seq) do + print(v) + end + end + end + print_list_twice(io.stdin:lines()) -- won't work as expected + +Also note that this extension doesn't aim to supersede Lua's concept of +iterator functions. While metamethods (see section "Respected metamethods" +below) may be used to customize iteration behavior on values, this extension +isn't thought to replace the common practice to use function closures as +iterators. Consider the following example: local result = sql_query("SELECT * FROM actor ORDER BY birthdate") write_lines(result:get_column_entries("name"))