lua-users home
lua-l archive

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


On 06/11/2012 09:08, spir wrote:
Watch out for that old-fashioned Lua 5.0 'arg' - LuaJIT does not like
it!  Besides you will not be able to process any nils in the argument.
Lua 5.2's table.pack() does the right thing, otherwise use the trick
in my example.

Thank you, again, Steve. I was aware there was some trap with arg, but did not
remember what, or if it was important or not here. I'll have a look at "Lua
5.2's table.pack()". I guess you'd write maybe:
    args = pack(...)
to get a regular table from the tuple (or whatever internal representation the
rest arg list has)? If yes (or close), i'll use that because it's clear for me,
unlike the select(#, ...) syntax.

For people not aware of the latest lua-nnovations (like myself), I found good info on the topic (and much more) in:
* the Lua inofficial FAQ: http://www.luafaq.org/
* esp a note about unpack: http://www.luafaq.org/#T8.1.3
* and the new pack: http://www.luafaq.org/#T8.2.10

However, unlike what's mentionned there, and in the official list of incompatibilities between 5.1 & 5.2, and while I run Lua 5.2, unpack works by me without 'table' prefix (was not aware the func has moved in the 'table' table anyway):
   print(unpack{1,2,3}) --> 1	2	3

Denis