lua-users home
lua-l archive

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


On Tue, Mar 6, 2018 at 1:25 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:

> Why, if we are supposed to use symbolic constants, is LUA_TNIL (0) explicitly mentioned as the first?

Looking at the of manual v.4.0, where lua_gettype() was first documented (shortly after it had been introduced, the one with modern numeric, rather than string, types), the types were enumerated as follows:

LUA_TNIL, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_TFUNCTION, LUA_TUSERDATA

At that time, these were defined as follows:

#define LUA_TUSERDATA 0
#define LUA_TNIL 1
#define LUA_TNUMBER 2
#define LUA_TSTRING 3
#define LUA_TTABLE 4
#define LUA_TFUNCTION 5

With the exception of LUA_TUSERDATA, the order is straight-forward. The additions of more types later must have made ordering them more challenging.

Cheers,
V.