seqlua

diff README @ 54:92ce3958aca7

Reverted last two commits
author jbe
date Wed Aug 27 00:10:47 2014 +0200 (2014-08-27)
parents 664736a8fcbf
children 37c2841c6e8c
line diff
     1.1 --- a/README	Tue Aug 26 23:53:29 2014 +0200
     1.2 +++ b/README	Wed Aug 27 00:10:47 2014 +0200
     1.3 @@ -1,15 +1,11 @@
     1.4  seqlua: Extension for handling sequential data in Lua
     1.5  =====================================================
     1.6  
     1.7 -This package is an experimental extension for the Lua programming language
     1.8 -(version 5.2) which:
     1.9 +This package is an extension for the Lua programming language (version 5.2)
    1.10 +which:
    1.11  
    1.12 -* makes ``ipairs(tbl)`` respect both metamethods ``__index`` and ``__ipairs``
    1.13 -  (where ``__ipairs`` has precedence over ``__index``),
    1.14 -* allows ``ipairs(seq, "call")`` to accept either tables or functions as first
    1.15 -  argument where a function is used as iterator,
    1.16 -* allows ``ipairs(seq, "generator")`` to accept either tables or functions as
    1.17 -  first argument where a function is used as generator for an iterator,
    1.18 +* allows ``ipairs(seq)`` to accept either tables or functions (i.e function
    1.19 +  iterators) as an argument,
    1.20  * adds a new function ``string.concat(separator, seq)`` that concats either
    1.21    table entries or function return values,
    1.22  * provides auxiliary C functions and macros to simplify iterating over both
    1.23 @@ -98,15 +94,8 @@
    1.24  
    1.25  This extension, however, modifies Lua's ``ipairs`` statement in such way that
    1.26  it automatically accepts either a table or an iterator function as argument.
    1.27 -Thus, the function below will accept both (table) sequences and (function)
    1.28 -iterators:
    1.29 -
    1.30 -    function write_lines(lines)
    1.31 -      for i, line in ipairs(lines, "call") do
    1.32 -        io.stdout:write(line)
    1.33 -        io.stdout:write("\n")
    1.34 -      end
    1.35 -    end
    1.36 +Thus, the first of the three ``write_lines`` functions above will accept both
    1.37 +(table) sequences and (function) iterators.
    1.38  
    1.39  In addition to the modification of ``ipairs``, it also provides C functions and
    1.40  macros to iterate over values in the same manner as a generic loop statement
    1.41 @@ -178,7 +167,7 @@
    1.42  
    1.43      t = {"a", "b", "c"}
    1.44  
    1.45 -    for i, v in ipairs(t, "call") do
    1.46 +    for i, v in ipairs(t) do
    1.47        print(i, v)
    1.48      end
    1.49      -- prints:
    1.50 @@ -203,18 +192,7 @@
    1.51        end
    1.52      end
    1.53  
    1.54 -    for i, v in ipairs(alphabet(), "call") do
    1.55 -      print(i, v)
    1.56 -    end
    1.57 -    -- prints:
    1.58 -    --  1   a
    1.59 -    --  2   b
    1.60 -    --  3   c
    1.61 -    --  ...
    1.62 -    --  25  y
    1.63 -    --  26  z
    1.64 -
    1.65 -    for i, v in ipairs(alphabet, "generator") do
    1.66 +    for i, v in ipairs(alphabet()) do
    1.67        print(i, v)
    1.68      end
    1.69      -- prints:
    1.70 @@ -231,7 +209,7 @@
    1.71      function filter(f)
    1.72        return function(seq)
    1.73          return coroutine.wrap(function()
    1.74 -          for i, v in ipairs(seq, "call") do f(v) end
    1.75 +          for i, v in ipairs(seq) do f(v) end
    1.76          end)
    1.77        end
    1.78      end
    1.79 @@ -261,9 +239,9 @@
    1.80  
    1.81  In ``seqlualib.h``, the following macro is defined:
    1.82  
    1.83 -    #define seqlua_iterloop(L, iter, mode, idx) \
    1.84 +    #define seqlua_iterloop(L, iter, idx) \
    1.85        for ( \
    1.86 -        seqlua_iterinit((L), (iter), (mode), (idx)); \
    1.87 +        seqlua_iterinit((L), (iter), (idx)); \
    1.88          seqlua_iternext(iter); \
    1.89        )
    1.90  
    1.91 @@ -271,7 +249,7 @@
    1.92  
    1.93      #define seqlua_iterloopauto(L, iter, idx) \
    1.94        for ( \
    1.95 -        seqlua_iterinit((L), (iter), (mode), (idx)); \
    1.96 +        seqlua_iterinit((L), (iter), (idx)); \
    1.97          seqlua_iternext(iter); \
    1.98          lua_pop((L), 1) \
    1.99        )
   1.100 @@ -281,7 +259,7 @@
   1.101  
   1.102      int printcsv(lua_State *L) {
   1.103        seqlua_Iterator iter;
   1.104 -      seqlua_iterloop(L, &iter, SEQLUA_MODE_CALL, 1) {
   1.105 +      seqlua_iterloop(L, &iter, 1) {
   1.106          if (seqlua_itercount(&iter) > 1) fputs(",", stdout);
   1.107          fputs(luaL_tolstring(L, -1, NULL), stdout);
   1.108          // two values need to be popped (the value pushed by

Impressum / About Us