lua-users home
lua-l archive

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


On Sun, Apr 18, 2010 at 22:09, Patrick Donnelly <batrick@batbytes.com> wrote:
> On Sun, Apr 18, 2010 at 11:51 PM, Pan Shi Zhu <pan.shizhu@gmail.com> wrote:
>> in C, the lua_tonumber() is an in-place convertion, it changes the
>> value in stack and may cause unwanted behavior when you're iterating a
>> table.
>
> This is not true. lua_tonumber and its variants do not change the
> value of the stack location. It converts the value to a number and
> returns that number.
>
> --
> - Patrick Donnelly
>

Correct, according to the manual, lua_tolstring (and lua_tostring)
perform in-place conversion of numbers, while lua_tonumber and others
do not.

-- 
Sent from my toaster.