[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: naming: Why luaL_testudata but lua(L)_to*?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sat, 16 Sep 2017 07:01:19 +0200
2017-09-15 20:38 GMT+02:00 nobody <firstname.lastname@example.org>:
> 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".