lua-users home
lua-l archive

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


David Jones wrote:
>
> On Sep 28, 2004, at 21:07, Roberto Ierusalimschy wrote:
>
> >>   #define abs_index(L, i) \
> >> 	((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
> >> 	lua_gettop(L) + (i) + 1)
> >>
> >>  How about including it into the lauxlib.h or maybe lua.h?
> >
> > The problem is that it uses `i' several times. For a generic,
> > "official" macro, this is not too polite.
>
> How about a function then?  The functionality is useful.  I agree that 
> you wouldn't want to bless macros like this.

Why not switch the implementations?  lua_absindex is the low-level
function and lua_gettop is #defined as lua_absindex(L, -1).

Ciao, ET.