lua-users home
lua-l archive

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

2017-09-15 20:38 GMT+02:00 nobody <>:

> 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".