lua-users home
lua-l archive

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

Thanks for your reply.

I conclude from it that I can safely use "int" for all those variables in C-modules having to do with indices, either on the stack on or in tables.

Hans van der Meer

On 19 jun 2009, at 15:41, Roberto Ierusalimschy wrote:

Please allow me to pose the following suggestion to the developers of
Lua 5.2.
It concerns the parametrization of the type used for indexing.

In the Lua Reference manual I find defined:
typedef ptrdiff_t lua_Integer;
typedef double lua_Number;

However there is no corresponding typedef for indices. For example in
"void lua_rawgeti (lua_State *L, int index, int n)" one find the int. It
is also used to access the lua stack.

I would plea for using a typedef here too. Especially because int is
notouriously "vague" and its size can vary from system to system. It
does not matter too much what representation is chosen, as long as it is
adaptable in luaconf.h

lua_Integer and lua_Number are parameterised because they represent
user's values. The other 'ints' in the API are strongly related to the
internal implementation of Lua. To parameterise them would mean to
parameterise the entire source code. I think this would be a nightmare.

-- Roberto