lua-users home
lua-l archive

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


On Tue, Nov 6, 2012 at 9:50 AM, spir <denis.spir@gmail.com> wrote:
> printf = function (fmt, ...)
>    local strings = {}
>    for i,elt in ipairs(arg) do
>       strings[i] = tostring(elt)
>    end
>    write(format(fmt, unpack(strings)))
> end

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.

steve d.