lua-users home
lua-l archive

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


Hi,

Rici Lake wrote:
> There is an undocumented feature where:
>   unpack(tab, start, -1)
> is the same as
>   unpack(tab, start, #tab)

This is used internally to mark the default case:
if no range is given, the whole table is unpacked.

Trivial patch:

--- lua-5.1-alpha/src/lbaselib.c        2005-08-26 19:36:32 +0200
+++ lua-5.1-alpha-cumulative/src/lbaselib.c  2005-10-19 15:00:26 +0200
@@ -330,7 +330,7 @@
   int e = luaL_optint(L, 3, -1);
   int n;
   luaL_checktype(L, 1, LUA_TTABLE);
-  if (e == -1)
+  if (e == -1 && lua_isnoneornil(L, 3))
     e = luaL_getn(L, 1);
   n = e - i + 1;  /* number of elements */
   if (n <= 0) return 0;  /* empty range */

Bye,
     Mike