lua-users home
lua-l archive

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


lhf wrote:

> >Why does lua_typename take a state if the information is static?
>
> Simplify because *all* API functions take a state (except lua_open).
>
It's a strange argument.  Of course you could make lua_open take a state and
ignore it in the same way, but that would be silly because lua_open doesn't
require an existing state.  Likewise for lua_typename.

>
> Unofficially, you call lua_typename with a NULL state.

You have an opportunity to make the unofficial official (by making
lua_typename not take a state).  It's the same argument I used for making
lua_type return an enumeration instead of doing tricks on the type string.

An API function that doesn't require state such as lua_typename not unusual.
Static members are used often in C++ classes, for example.  In the future
there may be other functions added to the Lua API that don't require state.
It would be unfortunate to set a bad precedent.

Regards,
-John