lua-users home
lua-l archive

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

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 conversion necessary.

I think the issue here is that he wants to create equivalence classes of objects.

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.