lua-users home
lua-l archive

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

>   last night i read the 5.1src and found a strange code in ltable.c, please
> note the lines i marked RED: there are 2 cast for "k" and "n", first cast
> "n" from lua_Number to int and result is saved in "k", but soon it then cast
> "k" back to lua_Number to adopt to the function luai_numeq as its first
> argument. i don't known why it's neccesary:(

To check whether that lua_Number fits in an integer. luai_numeq is
a macro that expands likes this:  

     if (cast_num(k) == nvalue(key)) /* index is int? */

-- Roberto