[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Upcoming changes in Lua 5.4
- From: Paige DePol <lual@...>
- Date: Sat, 20 Jan 2018 03:43:18 -0600
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