lua-users home
lua-l archive

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


In my Lua application I have userdata objects with value semantics (position coordinates) that I sometimes want to use as table keys. I.e., I want table lookup based on equality rather than identity.

Currently, my best idea for doing this is to have a function key() in the userdata that returns a string representation of the data and use that string as the table key. This has the disadvantage of 1) not being very elegant and 2) creating a lot of unnecessary strings.

Is there a better way of doing this?

// Niklas