The whole idea sucks, in spades. Userdata means user data.
Lua is not supposed to know how its implementation details.
The metatable is there to provide an interface. Light userdata
is there when no interface beyond the ability to distinguish between
instances is required.
I don't think you really understand the idea.
Why a lua function need upvalues ? And why there is a type LUA_TPROTO internal ?
We can associate different upvalues with the same proto to build different closures (lua function).
A full userdata is like the value with typed LUA_TPROTO, with an associated integer (like upvalue) would be more flexible.