|
On 11/07/16 11:52 PM, Soni L. wrote:
(Empty reply so someone sees this. The table vs array threads kill all other threads :/)On 11/07/16 11:38 PM, Sean Conner wrote:It was thus said that the Great Soni L. once stated: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'tthat 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?Previous discussions on __key:http://lua-users.org/cgi-bin/namazu.cgi?query=__key&idxname=lua-l&max=20&result=normal&sort=date%3AearlyInteresting. Such a shame previous threads didn't go very far. However, the use-case I proposed is different, as it's about compatibility/interoperability with Lua types (number, string, boolean, etc).And just because ... __hash:http://lua-users.org/cgi-bin/namazu.cgi?query=__hash&idxname=lua-l&max=20&result=normal&sort=date%3Aearly-spc (Wow ... that __hash one goes way back to 2003 I see ... )
-- Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.