|
On 2012-11-12 2:38 PM, "Dirk Laurie" <dirk.laurie@gmail.com> wrote:
>
> 2012/11/12 spir <denis.spir@gmail.com>:
>
> > I have no luajit and only one lua, no 5.1 afaik. My exec command for lua
> > code is just lua "%f". /usr/bin/lua is well a symlink (to another symlink, I
> > guess, in etc/alternatives/, don't know more).
> >
> > spir@ospir:~$ which lua
> > /usr/bin/lua
> > spir@ospir:~$ lua -v
> > Lua 5.2.0 Copyright (C) 1994-2011 Lua.org, PUC-Rio
>
> Lua 5.2 has only table.pack and table.unpack.
>
> Lua 5.1 has only unpack. Instead of table.pack(...)
> 5.1 prgrams use {...}. Only difference is that table.pack
> sets a field `n` telling how many things (including nils)
> were packed. You can't get that info from {...}. However,
> programs written for 5.1 do not rely on this feature.
A common idiom is t = {n=select('#', ...), ...}
Though I suspect if you're doing this in a speed-critical section, a dedicated function may be faster, since it only need evaluate ... once (at least a C function could do n = lua_gettop() instead of any counting). But you should probably avoid doing this in a speed-critical section anyway...