[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_isstring et al and booleans in 5.0w0
- From: Björn De Meyer <bjorn.demeyer@...>
- Date: Mon, 15 Jul 2002 19:12:10 +0200
Roberto Ierusalimschy wrote:
>
> The problem with this conversion is that it is not reversible. Assuming
> the obvious conversion, we have that false(b) -> "false(s)", but
> "false(s)" -> true(b) (any string is non-false). So, we prefer not to
> perform it implicitly.
>
> (Actually, the conversion between numbers and strings is not completely
> reversible, too: "0003" -> 3 -> "3". But most of the time it works as
> we expect.)
AFAIK, PHP "solves" this problem by evaluating the string "0"
as FALSE, together with empty strings. So, in PHP "0" , "" and
0 are converted to FALSE, and "apple" , "1234" and 3421 are
converted to TRUE. If you do that, then strings can be more or
less reversibly transformed into booleans and back.
However, I don't know whether such behaviour would be appropriate
in LUA. It has some nasty side effects...
--
"No one knows true heroes, for they speak not of their greatness." --
Daniel Remar.
Björn De Meyer
bjorn.demeyer@pandora.be