[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua function arguments
- From: David Jeske <jeske@...>
- Date: Sun, 17 May 1998 23:17:13 -0700
On Sun, May 17, 1998 at 12:31:20PM -0300, Roberto Ierusalimschy wrote:
> > I may have asked this before, but is there any way to ask Lua for the
> > number of arguments that a given Lua function expects?
>
> It wouldn't be difficult to implement a built-in function "num_params",
> which returns the number of parameters a function expects. However, it would
> not work neither for C functions nor for vararg functions. So, it doesn't
> seem very useful as a generic facility.
It does seem odd just to throw away this information at compile time
though, given that it is there. Perhaps it would be worthwhile to preserve
this information for functions which make it available. Namely, a lua
function declared with explicit arguments, would have the number of
arguments (and perhaps even their names??) stored, so you could use them
later.
Or perhaps just allowing that information to propogate far enough to be
grabbed by some fallback style function. So normally it would just get
trashed, but if you wanted to do something strange, you could hook the
"define function" fallback, and you would know all the arguments, and
their names.
--
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net