After LuaConf 2016, more specifically the Lua stored procedures talk, I
kept thinking about something... They had to modify the Lua VM just so
they can decay userdata into keys when indexing, everything else could
be done with a substitution layer on top of Lua.
So, can we get a __key metamethod *for userdata only* that takes an
userdatum and returns a value to be used for table indexing?
For t[k] and t[k] = v this is pretty simple to understand, but Lua isn't
that simple:
- How should rawget() and rawset() work?
- Should there be a way to invoke __index and __newindex without
invoking __key? (rawkeyset() and rawkeyget()?)
- Should there be a way to invoke __key without indexing? (getkey()?)
(for use with rawset/rawget)
- Or is this the wrong way to go about it?