[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Different shades of false
- From: Tobias Käs <tobias.kaes@...>
- Date: Thu, 02 Mar 2006 21:00:51 +0100
Dolan, Ryanne Thomas (UMR-Student) wrote:
Exactly. The only problem with nil/false is that people use these values incorrectly. nil is by no means synonomous with false, so it makes sense that nil ~= false. Being false and not defined are two very different states.
And the proposal that all types should have true/false values seems strange to me, as anything with true/false evaluations is by definition a boolean, which Lua of course already has. Would it make sense at all if "" == 0?
You are contradicting yourself here ;-)
At one point you say nil ~= false because they have different meanings.
At the other point you argue "" == 0 incase 'if' treats them the same.
If you stand by the first argument, you would consequently have to say
"" ~= 0
If you stand by the second argument, you would have to say nil == false
As already has been pointed out, nil and false being different has some
advantages for tables.
So if you say "undefined" evaluates to "false" in the context of an 'if'
(even though they are not the same), you could as well say "empty"
should evaluate to "false" in the same context.
Since the ambiguity already exists it wouldn't make things much more
worse I guess ;-)
Though in the end it probably is just a matter of taste which you prefer.
So long as you take the convention that nil means something like "undefined" then everything makes sense the way it is.