[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: nil isn't as unique in Lua 4.1
- From: "Eric Ries" <eries@...>
- Date: Fri, 11 Jan 2002 10:09:09 -0800
Maybe I am just dense, but why does this require that "not nil" and "not
false" be the same thing? If you're trying to use a non-nil value to cache a
"false" response, why not just make up your own value and then test for it
explicitly? It seems to me that the road to simplicity lies in having only
one value that the boolean operators understand as "nil/false"
> -----Original Message-----
> From: email@example.com
> [mailto:firstname.lastname@example.org]On Behalf Of John Mckenna
> Sent: Friday, January 11, 2002 2:36 AM
> To: Multiple recipients of list
> Subject: RE: nil isn't as unique in Lua 4.1
> >I look at lexically scoped and eventtable and I think "WOW, that's
> >great. That will fix a whole bunch of nasty things in my code." I look
> >at false and I thing "What for?". I guess false just isn't that useful
> >for me. I just hope you don't go and add 0, "0" and "" to the list of
> >false values.
> The problem that false is there to solve is that nil is currently trying
> to be two very different things - "false" and "doesn't exist".
> Let's say you have a very lengthy computation that returns either "true"
> or "false". Since it takes such a long time to compute, you decide to
> cache the results in a table. Look up the parameter in the table - if
> you get nil, then either you've already done the calculation and the
> answer was "false", or you haven't done the calculation yet.
> Or maybe you're implementing an object system with inheritance. If a
> field isn't in the child's member table, then look it up in the parent.
> How do you store "false"?
> Or there's Markus Huber's example: you want default values for function
> parameters. If the function gets nil for that parameter, then it can't
> tell if the parameter was missing, or if the caller is trying to pass
> Introducing a real false value means that nil can be "doesn't exist",
> and nothing else. It eliminates a lot of ambiguity.
> -Virus scanned and cleared ok