[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: equals metamethod and hash functions
- From: Rici Lake <lua@...>
- Date: Wed, 8 Jun 2005 18:22:07 -0500
On 8-Jun-05, at 6:05 PM, Dave Dodge wrote:
On Tue, Jun 07, 2005 at 06:27:35PM -0400, Paul Chiusano wrote:
In order for this to work, I need equal objects (according to __eq)
to hash to the same location in the table.
If these objects are strictly tables, tostring() might be sufficient
for this already.
If the objects are all unique, you can just use them as keys. No
I think the issue here is that he wants to create equivalence classes
By the way, it would be a Really Bad Idea to use tostring(t) instead of
just using t. tostring(t) is not going to keep t from being garbage
collected, and if it were, some other object might end up with the same
tostring() value. At any rate, it is completely unnecessary, since in
Lua a key can be any Lua value aside from nil and NaN.