lua-users home
lua-l archive

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


On Sat, Jul 7, 2012 at 11:56 AM, dcharno <dcharno@comcast.net> wrote:
> On 07/07/2012 10:06 AM, Alexandre Rion wrote:
>>
>> s=0; k=0
>> grade="Ann 57, Bob 64,Cat 77, Don 62, Eve 51"
>> for n in grade:gmatch("%d+") do s=s+tonumber(n); k=k+1 end
>> print(s/k)
>>
>> It's the same, it is easy, and it is clearer for people to understand your
>> code. ->  + 10.000 points
>
>
> You can already do this in your code if you wish, so what's the point of
> changing the language at this stage?  Will it make Lua noticeable faster or
> smaller?  Doubtful.

Yes. Roberto already explicitly said it would simplify the code
(making Lua smaller) and reduce checks in critical code paths (making
Lua faster). Even if you're already using tonumber(s), the + operator
still has to check to see if the coercion is necessary -- this check
could be removed if it could just error out if lua_type doesn't return
LUA_TNUMBER.

/s/ Adam