[MANUAL]: Discrepancy in documentation of lua_type

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[MANUAL]: Discrepancy in documentation of lua_type

Dirk Laurie-2
The sequence of types in the manual does not correspond to the values
0,1,2,... as defined in lua.h.

Reply | Threaded
Open this post in threaded view
|

Re: [MANUAL]: Discrepancy in documentation of lua_type

Luiz Henrique de Figueiredo
> The sequence of types in the manual does not correspond to the values
> 0,1,2,... as defined in lua.h.

You're supposed to use the symbolic constants LUA_TNIL, LUA_TNUMBER,
etc., not the actual values.

Reply | Threaded
Open this post in threaded view
|

Re: [MANUAL]: Discrepancy in documentation of lua_type

Dirk Laurie-2
2018-03-06 12:43 GMT+02:00 Luiz Henrique de Figueiredo <[hidden email]>:
>> The sequence of types in the manual does not correspond to the values
>> 0,1,2,... as defined in lua.h.
>
> You're supposed to use the symbolic constants LUA_TNIL, LUA_TNUMBER,
> etc., not the actual values.

I realize that. Also that I am supposed to use luaL_typename when
printing out a type value. And that there is LUA_NUMTAGS to tell me
where to stop in a `for`.

I also know that it is a bit of a tradition to require Bourbakian
hairsplitting ability for determining what the manual says and what it
does not. Also that what it should say is neither here nor there.

Moreover, when someone else criticizes the manual for being
insufficiently informative, I usually take the point of view that. to
the careful reader. it is informative enough.

BUT ...

Why, if we are supposed to use symbolic constants, is LUA_TNIL (0)
explicitly mentioned as the first? And given that it is, can the
reader then be blamed for expecting the rest to follow consecutively?

Reply | Threaded
Open this post in threaded view
|

Re: [MANUAL]: Discrepancy in documentation of lua_type

Luiz Henrique de Figueiredo
> Why, if we are supposed to use symbolic constants, is LUA_TNIL (0)
> explicitly mentioned as the first? And given that it is, can the
> reader then be blamed for expecting the rest to follow consecutively?

You have a point there, yes.

Reply | Threaded
Open this post in threaded view
|

Re: [MANUAL]: Discrepancy in documentation of lua_type

Viacheslav Usov
In reply to this post by Dirk Laurie-2
On Tue, Mar 6, 2018 at 1:25 PM, Dirk Laurie <[hidden email]> 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.