lua-users home
lua-l archive

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


Why not have lua_type return an enumeration of the types?  This will
eliminate the "dirty trick" (which everyone will certainly do instead of
messing with string compares).  If it's believed that strings are really
necessary for some reason, an additional function could be added to convert
the type enum to a string.

Also a doc suggestion... I think the readability of the manual would be
improved if the deprecated/renamed items were listed separately at the end
of the manual.

Regards,
-John


>From the 4.0b manual
 >>>>>
const char *lua_type        (lua_State *L, int index);

lua_type returns one of the following strings, describing the type of the
given object: "nil", "number", "string", "table", "function", "userdata"; or
"NO VALUE", if the index is non-valid (that is, if that stack position is
``empty'').

(Very dirty trick: some type names start with the same letter (Number-Nil);
others have the second letter in common (nUmber-fUnction). However, you can
use the emph{third} letter as a unique scalar identification for each type.)
<<<<<