[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: What does metamethod equality mean? (long) (Was: Re: Need for help)
- From: "Peter Hill" <corwin@...>
- Date: Mon, 24 Feb 2003 12:32:27 +0800
Peter Hill:
> Which makes me wonder... if table key comparison was extended to include
> an "eq" metamethod would there be any remaining need for a "reference
> equivalence" test? It is not that unreasonable that two "__eq" values
> might key the same for a table...
Rici Lake:
> If you think about that for a minute, you will see how difficult
> implementation would be. To make tables work, you need a hash function,
> and writing hash functions to correspond with random __eq methods is
> non-trivial. Otherwise, you would be reduced to a linear search of tables
> for key equality on every lookup.
I see your point. You'd have to supply a "__hash" metamethod that covered
your concept of equality.
Hmm, maybe that might be handy... use normal (object reference) hashing &
equality *unless* the object has a "__hash" metamethod!
*cheers*
Peter Hill.
Ki: Contractors... high-paid leeches stealing our work.
Fooker: If you think of them as disposable employees, you'll feel much
better...