Passing table values ​​as arguments to a function in Lua 4 without a "call" function

I have a table of values, which can basically have any length:

Points =
{
    "Point #1",
    "Point #5",
    "Point #7",
    "Point #10",
    "Point #5",
    "Point #11",
    "Point #5",
}

I want to pass them as arguments to a function.

addPath(<sPathName>, <sPoint>, <sPoint>, ...)

Now, as a rule, you can use the "call" function. But in the software that I use, this function is not available, not in the area.

How do I get around this problem in Lua 4?

[edit]

Here are the functions that I can use.

+4
source share
1 answer

In newer versions of Lua you use unpackas in addPath(sPathName,unpack(Points)), but Lua 4.0 does not unpack.

C, unpack Lua 5.0 4.0:

static int luaB_unpack (lua_State *L) {
  int n, i;
  luaL_checktype(L, 1, LUA_TTABLE);
  n = lua_getn(L, 1);
  luaL_checkstack(L, n, "table too big to unpack");
  for (i=1; i<=n; i++)  /* push arg[1...n] */
    lua_rawgeti(L, 1, i);
  return n;
}

lbaselib.c, base_funcs:

  {"unpack", luaB_unpack},

C, , , :

function unpack(t)
  return t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10]
end

, 200 . , addPath nil.

, , ( , 250 ):

function unpack(t,i)
        i = i or 1
        if t[i]~=nil then
                return t[i],unpack(t,i+1)
        end
end
+4

All Articles