[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: list iteration for statement
- From: "John Belmonte" <jvb@...>
- Date: Mon, 11 Jun 2001 15:31:27 +0900
David Jeske wrote:
> Yes, but that problem should be fixed for other reasons. IMO "false"
> should be a distinct value from "nil" which can be set and stored in a
> location. Booleans should evaluate to false, not "nil", and "nil"
> (empty) should be treated as false in boolean comparisons.
> For one reason why, read the section of my table inheritence technical
> note about weaknesses due to Lua (IMO mistakenly) overloading nil with
> both false and empty data.
The issue of nil as false has been well-discussed, and the Lua authors
already admit this weakness in the paper "The Evolution of an Extension
Language: A History of Lua".
Independent of that issue however, is the issue of whether it's useful to
have nil in a list. 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. The nil here could mean "use the default value," "create the
necessary object," etc. Because nil is used for false, this technique can
only be used for "non-bool" arguments. If the nil for false issue was
corrected, this technique would still be useful... in fact be more useful.
Are there any other common uses of nil in a list?