lua-users home
lua-l archive

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



On Thu, Jun 23, 2016 at 07:33 Viacheslav Usov <via.usov@gmail.com> wrote:
On Thu, Jun 23, 2016 at 2:08 PM, Andrew Starks <andrew@starksfam.org> wrote:

Using them as intended, to provide a variable number of arguments to a function, requires no change in the documentation.

The documentation today, even if we consider the latest edition of PiL as part of it, suggests very clearly that {...} is the way to handle variadic arguments. Is that what your "as intended" means?

Cheers,
V.


I think that I was speaking conceptually. That is, if I'm processing an arbitrary set of arguments, I'm doing so for a particular reason and I can choose to handle them in a clear way.

opt1, opt2, opt3 = ...

Or if I'm handling arguments in a printf -like function, maybe:

fargs, nargs = {...}, select('#', ...)

...if that is clearer

Once you start using varargs as a way to pass around data structures, you cease to use the language feature in the way it was intended and you'll start to wish for things that aren't relevant to the design. You'll start to care about limits and speed in a way that works against the language and you'll ask for things that will reinforce the point of view that perhaps they shouldn't be there at all.

Accepting them as they are for what they are is not technically interesting but is probably healthier.

-Andrew