lua-users home
lua-l archive

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


On Thu, Nov 08, 2012 at 11:42:19AM +0100, joao lobato wrote:
> On 11/8/12, Enrique Garcia Cota <kikito@gmail.com> wrote:
> >> How about simply having nested datastructures? Yes, it takes a few
> > lookups instead of 1. But on the other hand you create less garbage to be
> > collected when concating.
> >
> > That is what I usually do when I have this problem.
> >
> 
> The problem here is that hashing does not take table contents in
> consideration. I wonder if it would make sense to have __eq influence
> table hashing.

You'd need something like __key in additional to __eq, in order to choose
the bucket.

__eq works if you're using a tree data structure, though. That's probably
how functional languages do it, as they don't really have arrays, but lists
and trees.

> That way it would be possible to simply store the values in a table has
> key to another table. That would (imho) be the cleanest approach, in
> accordance to the "table has the basic data structure" mantra. (Mantras
> are a good thing :-) ).
> 
> Makes you miss Lisp's eq, eql, equal and equalp.