lua-users home
lua-l archive

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


On 11 May 2010 14:27, Gary Bringhurst <garyb@strata.com> wrote:
Why do you want the runtime to check for the correct number of arguments rather than having your own function check? The language is very flexible and makes it easy to validate both missing and too many arguments if that's important to your usage.

Because, in my use cases at least, most functions take a fixed number of arguments, that is, the number of arguments I specify. In particular, when I write a function with a certain number of arguments, I expect it to be called with that many arguments, not more and (usually) not less. It seems redundant to repeat myself by manually checking it.

And how do you check that not too many arguments are passed? Do I have to add ... to the argument list of every function I write and assert(select('#', ...) == 0)?

Varargs seems to be the special case, not fixed-args.

    henk