lua-users home
lua-l archive

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

I'm trying to figure out what you're checking (it's late here!) .. a Lua number that has no fractional part (with all the issues that can cause) or a Lua number that can be stored within a C "int" without overflow?

pi==3 would make life so much easier …


On May 28, 2013, at 11:22 PM, Dirk Laurie <> wrote:

> I can't believe the following is the best way of not happily
> accepting pi=3 etc. Too many calls to genuine functions as
> distinct from macros.
> #define reallycheckint(L,index) (\
>  lua_pushinteger(L,luaL_checkint(L,index)),\
>  luaL_argcheck(L,lua_compare(L,index,-1,LUA_OPEQ),index,"expected integer"),\
>  lua_pop(L,1), lua_tointeger(L,index) )
> But every time I try to improve on it I need to store something
> in a C variable.