lua-users home
lua-l archive

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


> Wow, just found by chance that this IS in the standard distribution,
> just not public ;-)  [..snip snip..]
>
> [lauxlib.c]
> /* convert a stack index to positive */
> #define abs_index(L, i)  ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) :
>      \ lua_gettop(L) + (i) + 1)

Note that this is not safe (see previous mail.)  I think it would have been
phrased differently if it was public.  To be on the safe side, make it a
function.  If call speed is a concern then you could declare it as inline in
C++, or in C you could declare and define it as static in some header and
rely on the compiler to inline it (or give it a hint.)

--
Wim