[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Trailing nils in an argument list
- From: David Kastrup <dak@...>
- Date: Sun, 09 Jan 2011 16:57:13 +0100
Dirk Laurie <firstname.lastname@example.org> writes:
> On Sun, Jan 09, 2011 at 04:51:00PM +0200, David Kastrup wrote:
>> Dirk Laurie <email@example.com> writes:
>> > 6. insert(a,b) does not do the same as insert(a,b,nil). This
>> > behaviour would not be possible for a function of three arguments
>> > written in Lua itself.
>> function arity(...)
>> return select('#',...)
>> 2 3
> By 'a function of three arguments' I mean a function starting with e.g.
> function f(a,b,c)
A "function of three arguments" receives three arguments by demand and
coercion. It is somewhat silly to complain that it can't distinguish
getting a different number.
I don't see that a function starting with e.g.
can't be used as a function of two _or_ three arguments perfectly well.
You could try arguing that f in this case does not raise an error when
called with 4 arguments. But neither does insert, or any Lua function.
Spurious arguments are always allowed and ignored.