naming: Why luaL_testudata but lua(L)_to*?

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

naming: Why luaL_testudata but lua(L)_to*?

nobody
Hey *,

why is it that all error-throwing getters are called lua(L)_check*,
almost all getters that signal errors by their return value are called
lua(L)_to*, but it's luaL_testudata and not luaL_toudata?

Is there a deeper reason or is it just accidental?

-- nobody

Reply | Threaded
Open this post in threaded view
|

Re: naming: Why luaL_testudata but lua(L)_to*?

Dirk Laurie-2
2017-09-15 20:38 GMT+02:00 nobody <[hidden email]>:

> why is it that all error-throwing getters are called lua(L)_check*,
> almost all getters that signal errors by their return value are called
> lua(L)_to*, but it's luaL_testudata and not luaL_toudata?
>
> Is there a deeper reason or is it just accidental?

Userdata is a single type only at the Lua type level.

At the C level it is many types, each of which has a unique name,
and the API requires you to specify the name whenever you access
the userdata so that it can check the subtype.

This is an extra operation not performed for other types, and
I suppose that is why it is a "test" and not just a "to".