[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: sunday afternoon whishlist
- From: "Juris Kalnins" <juris@...>
- Date: Tue, 11 May 2010 17:08:40 +0300
On Tue, 11 May 2010 16:53:58 +0300, HyperHacker <hyperhacker@gmail.com>
wrote:
You mean select('#', ...)?
Yes. consider also:
local f = function(x, y, z, ...) print(select('#', x, y, z, ...)) end
f()
f(1,2,3,4,5,6,7,8)
outputs:
3
8
So, basically, the simplest way to write function that can test if some of
it's
arguments were not supplied is:
function (...)
local x, y, z = ...
if select('#', ...) < 3 then
. . .
Which is almost OK, but looks funny (like C code from the K&R age)
and needs to call global "select" function.
The way vararg currently works, "#..."
wouldn't syntactically make sense, though I agree the way it currently
works is awkward and as I understand it's being changed in 5.2.
That's good news.