[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua function arguments
- From: David Jeske <jeske@...>
- Date: Thu, 14 May 1998 11:20:17 -0700
On Thu, May 14, 1998 at 06:41:49AM -0300, Luiz Henrique de Figueiredo wrote:
> >From firstname.lastname@example.org Thu May 14 02:43:03 1998
> >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?
> no. the number of arguments that a function expects is not a notion in Lua.
> what do you need this for?
> there are ways to fake this, however.
> you can create a table with the number of args plus the functions itself,
> and use tag methods to aloow the function to be called directly and at the
> same time check the number or do whatever you want to do:
> function f(x,y) ... end
> f(a,b,c) -- this gives an error
> f(a,b) -- this is ok. the tag method uses 'call'.
> something like this.
Too bad there is no "define function" fallback. If there was, and it gave
the argument information, you could do away with the step:
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + email@example.com