lua-users home
lua-l archive

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


> Is there any way to determine how many arguments an arbitrary function 
> expects?

No.

First of all, an arbitrary function might be:

1) a CFunction
2) a Lua vararg function
3) an ordinary Lua function.

Only in the last case is the concept of "expected arguments" even
close to defined.

In all cases, the functions will accept any number of arguments,
in some sense, although it may be that not all of them will affect
the computation.

Even in the case of an ordinary Lua function, there is no guarantee
that all arguments supplied will be examined, although since Lua is
not a lazy language, all of them will have been evaluated prior to
the call happening.