lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, 21 Apr 2010, Matthew Wild wrote:
>
> Lua generally doesn't do coercion as a rule (compared to some languages,
> such as PHP).

Yes.

> It generally only coerces numbers<>strings when doing direct comparisons
> (that otherwise wouldn't make sense) or a function indicates (by using
> tostring/lua_tostring) that it is expecting a string, and the user
> passed a number (or vice-versa).

No.

Lua only coerces strings to numbers if they are arguments of an arithmetic
operator (+-*/%^) and numbers to strings if they are arguments of the
concatenation operator. Comparisons preserve types. Functions may coerce
as they require.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.