[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Userdata as keys
- From: Niklas Frykholm <niklas@...>
- Date: Mon, 16 Oct 2006 18:27:09 +0200
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