lua-users home
lua-l archive

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


> 1)
> Two warning generated by VisualStudio 2010
> lobject.c(463) : warning C4267: '+=' : conversion from 'size_t' to 'int',
> possible loss of data
> lobject.c(478) : warning C4267: '+=' : conversion from 'size_t' to 'int',
> possible loss of data

Thanks.


> 2)
> The bug with wrong S2N conversion has been reported for previous "work
> versions", but still not fixed:
> for i = "2", 3 do print(math.type(i)) end  --> float float
> According to the manual, the value must be integer.

The manual says this about a numerical for:

  The loop starts by evaluating once the three control expressions;
  they must all result in numbers.

So, I would say that |for i = "2", 3| is unspecified in the manual.


> 3)
> The new manual (in the "For Statement" section) says the following:
>    *"You should not change the value of the control variable during the
> loop."*
> Does it mean that the following code may stop working correctly in the
> nearest future?
>    for i = 1, 10 do i = tostring(i); .... end

Yes. Ideally, 'i' should be 'const'. (It would allow a slightly more
efficient implementation.)  It was kept as it is only for compatibility.


> The possibility to assign to a loop variable is so nice, please don't
> remove it from Lua.

Is it too painful to create another variable?

-    for i = 1, 10 do i = tostring(i); .... end
+    for i = 1, 10 do local i = tostring(i); .... end

(The later is even slightly more efficient.)

-- Roberto