lua-users home
lua-l archive

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


Sean Conner <sean@conman.org> wrote:

>  Why not the following?
> 
> 	function foo(...)
> 	  for i = 1 , #... do
> 	    print("the answer is",...[i])
> 	  end
> 	end

This is exactly the syntax I was going to use for vargs in my Lua fork
actually. Instead of adding the vargs to a table, however, I would be
using my Index data type.

I think this syntax makes the general use-cases for vargs easy to use...
length and element access both nice and simple and easily understandable.

As you stated, if the vargs are needed in a table simply using "..." in
a table constructor could also be used. 

~Paige