[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Different tonumber() behavior between 5.2 and 5.3
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sat, 29 Apr 2017 15:48:24 -0300
> Is there a reason 5.3 lost this flexibility?
Automatic coercion from numbers to strings is already considered bad
by many people. Lua usually avoids this coercion when it can lead to
confusion (e.g., 10 == "10"). In this case, as your example shows,
it sounds quite weird:
> tonumber(100, 4) --> 16
100 is already a number! "Converting" it to a number should not change
its value.
-- Roberto