lua-users home
lua-l archive

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



On Nov 8, 2012 8:37 PM, "William Ahern" <william@25thandclement.com> wrote:
>
> 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.

In that case, __le. Thing is, aside from not going offtopic, one wouldnt want to slow down the general case by forcing metamethod lookup on every operation.