[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5.3: wrong coercion?
- From: Coda Highland <chighland@...>
- Date: Fri, 16 Jan 2015 15:04:27 -0800
On Fri, Jan 16, 2015 at 2:29 PM, Lorenzo Donati
> On 16/01/2015 22:38, Roberto Ierusalimschy wrote:
>>> Is there a reason why the coercion first recognizes the string as
>>> representing an int and then "throws away" that info and converts it
>>> unconditionally into a float?
>> We want a fast track for integers, so the first check is simply whether
>> both operands are integers. After that check, it is too cumbersome to
>> recheck whether the strings are "integers" and then also do an integer
>> -- Roberto
> Thanks for the clarification!
> I'm not really sure, maybe I just must get used to it, but the whole
> string->number automatic coercion thing seems to have become a bit
> overcomplicated. I only relied a few times on this behavior before (pre
> 5.3), so I wouldn't miss it should you remove it from the language and raise
> an error whenever a string is used where a number is expected. As it stands
> now the feature seems to me a bit counterintuitive or at least too
> convoluted and perhaps can cause more harm than good. Just a gut feeling,
> though. (my 2c)
> -- Lorenzo
Isn't there a #define you can set now to disable string-to-number coercions?