[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: tonumber(), toboolean()???
- From: Chris Marrin <chris@...>
- Date: Mon, 20 Feb 2006 15:54:13 -0800
Lua has a very nice tostring() function, which can use a "__tostring"
metamethod to give string conversion support to any user defined type.
And tonumber() exists in 5.1, but its implementation does not include a
"__tonumber" metamethod call. It simply converts a number or string to a
number. Everything else returns nil. So, the first question is, why not
make the implementation of tonumber() parallel to that of tostring()?
And the related question is, why not have a toboolean() as well, with
the same sort of __toboolean metamethod?
--
chris marrin ,""$,
chris@marrin.com b` $ ,,.
mP b' , 1$'
,.` ,b` ,` :$$'
,|` mP ,` ,mm
,b" b" ,` ,mm m$$ ,m ,`P$$
m$` ,b` .` ,mm ,'|$P ,|"1$` ,b$P ,` :$1
b$` ,$: :,`` |$$ ,` $$` ,|` ,$$,,`"$$ .` :$|
b$| _m$`,:` :$1 ,` ,$Pm|` ` :$$,..;"' |$:
P$b, _;b$$b$1" |$$ ,` ,$$" ``' $$
```"```'" `"` `""` ""` ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'