lua-users home
lua-l archive

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


2009/2/1 Joshua Haberman <joshua@reverberate.org>:
> 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 any case, like I said I'm mainly wondering if anyone has a PowerPatch,
> I'm not going to argue that it should go into the main Lua (though I
> wouldn't mind that either :)

You don't need a power-patch, with the help of existing metamethods,
you can implement your own hashing algorithm. Here is an example:

http://lua-users.org/wiki/ComparisonByValue