[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: list iteration for statement
- From: Edgar Toernig <froese@...>
- Date: Tue, 12 Jun 2001 05:45:23 +0200
[nil terminates a list]
John Belmonte wrote:
>
> Independent of that issue however, is the issue of whether it's useful to
> have nil in a list.
Ignoring the nil vs false issue at the moment I think it's strange to
have lists with 'missing' elements. It's more a (numerical) indexed
array.
> Certainly Lua is already making use of this ability,
> such as for function arguments. Take the call foo(nil, "a", 2). If foo is
> implemented in C or in Lua with a vararg, the arguments are represented in
> list form.
In C? C always gets the raw arguments. And a vararg Lua function may
still get the 'n' field. It's not redundant. Try
print(getn{nil,0,nil})
There _is_ a difference between tables with and without the 'n'. You may
call them arrays (with 'n') and lists (without 'n'). And the semantics of
getn for lists is arbitrary. Both definitions have pros and cons. May be
one more reason for a 'next' tag method instead of a special for-loop...
Ciao, ET.