[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: hash metamethod?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sun, 1 Feb 2009 17:42:04 -0200
> Languages like Ruby, Python, etc. allow you to define hash functions that
> apply to your objects. You define a hash function and a comparison
> function, and this lets user-defined types be keys in hash tables based on
> their values.
In Lua, any value can be used as a table key. But for objects, this means
that their address is used rather than the contents. Is that the issue?
If so, can't it be addressed by calling new/put/get functions that compute
new keys for objects based on whatever is needed by the app? And of course
use a table as the underlying container.