lua-users home
lua-l archive

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


On Thu, Nov 15, 2018 at 1:32 AM Dibyendu Majumdar wrote:
>          for j = 1, 1e4 do

That's why I had to change the limit to 10000 in the type annotated version.

 
In Lua 5.3, in numeric "for"-loop, if both "initial value" and "step" are integers, then loop variable will have only integer values, even if "limit" is float.
 
for j = 1, math.pi, 2 do
   print(j, math.type(j))
end
 
So, when parsing "for j = 1, 1e4 do", Ravi should conclude that "j" is integer, similar to how Lua 5.3 deduces type of loop variable.
This way there would be no reason to replace 1e4 with 10000