lua-users home
lua-l archive

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

On Sat, Aug 10, 2013 at 6:16 AM, John Hind <> wrote:
> I like this a lot.
> One possible extension is to follow the lead of luaL_checkudata surfacing
> this test in Lua. So if a type is defined using a userdata with a metatable
> stored under a type name in the registry (as the C API encourages):
> type(x, "mytype")
> checks if type is a userdata or table with a metatable equal to the table
> stored in the registry under the key "mytype".
> This allows for the test to work even if a "type" metavalue is not defined.


Thanks man!

I love your idea. It's actually the problem that I set out to solve,
before I learned I would need the C-API to solve it.

I have to admit that I don't spend any work-time in the C-API (my
colleague does that). When I have time, I like to study and practice
it, however, so I'm going to take this on as my next challenge.

Feel free to modify and extend as you see fit!

Also, I didn't mention that the inspiration for this was from Philipp
Janda and his contribution to a (very long) discussion on type. He had
many other ideas, but the one that I lifted was the concept of using
2...n arguments to type for comparison.

- Andrew