[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: printf and/or %n
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 6 Nov 2012 09:53:51 +0200
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.