[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua 5.3.0 (work2) now available
- From: Coroutines <coroutines@...>
- Date: Sat, 22 Mar 2014 13:52:55 -0700
On Sat, Mar 22, 2014 at 1:34 PM, Andrew Starks <firstname.lastname@example.org> wrote:
> On Saturday, March 22, 2014, Roberto Ierusalimschy <email@example.com>
>> > >> There is no direct conversion from strings to integers:
>> > >> If a string is provided where an integer is needed,
>> > >> Lua converts the string to a float and then the float to an integer.
>> > Does it mean the following:
>> > assert('100000000000000001'%2 == 0)
>> > It looks unnaturally for a language having 64-bit integers as native
>> > datatype.
>> Coercion from strings to numbers are considered a bad thing, and can
>> (should?) be removed in future versions. It did not seem worth to extend
>> to the new integer stuff something already outdate. (Ideally it should
>> raise an error, but that would create all sorts of incompatibilities.)
>> In other words, it is unnatural, but the whole coercion stuff is
>> -- Roberto
> I'd like to suggest that the timing for changes to coercion is in this
> You introduced int 64 and language support for bits, plus changes to number
> formatting. 5.3 looks to be shaping up to be a "number" release. Eliminating
> string->number fits this.
> There are new operators, which makes this release especially significant,
> already. As is, I believe that these works have will prove to compel people
> to upgrade. Even if someone agrees with the change in coercion, often a
> business case is needed, in order to do the hard work of checking for new
> bugs. Since I believe that you have that here, it may be good to take
> It's easier to take medicine when it's washed down with something you like
> That's my perspective, anyway.
> Thank you for giving us this release!
I actually wish there were a __tonumber metamethod and that the
underlying C for numbers and strings to coerce between them were
exposed through metatables. So if you don't like coercion you could
turn it off with the debug library: debug.getmetatable(0).__tostring =
I would expose more than that, sonny :ppp