lua-users home
lua-l archive

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


Renato Maia wrote:
[snip]
For an example, take a look at:
 http://sano.luaforge.net/documentation/HashMap.html

Thanks for the pointer!

Yes, besides the probable performance and complexity overhead in the majority of uses of Lua tables where such thing is not needed, such feature is only one possible solution for this problem of using complex objects as a key of a map, not necessarily the best one. So maybe it is better to let the programmer implement the best solution himself (or use a third-party library) when necessary.

I had such a suspect. Thank you for confirming that!

Have you searched the list archives for '__hash'?

Well, I have a local backup of old list archives (I'm on a low bandwidth connection and not always online). I searched for "hash" and the number of hits were overwhelming - the most talking about the "hash part of a table", so probably I gave up too early and missed something.


I'm discovering day by day that I have to unlearn so much! :-)

I don't know what you mean by "unlearn", but it is always nice to learn new ways of solving old problems.
I agree!
By "unlearn" I mean that you always must remember not to "fight the language" and since my "coding habits" in Java are rather sticky, I sometimes face the question "I did this thing in Java this way, why in Lua it looks so different? What is the rationale for the different approach?" This helps me to understand things better (sort of "comparative programming style analysis" :-) )


In your example, consider using
internalized tuples[1], for example:

I will ponder on this. Thanks!

--
Renato Maia
--
Lorenzo