[nem-en] Re: tuples as keys in Hashtable

Michal Moskal michal.moskal at gmail.com
Mon Jun 11 12:26:32 CEST 2007


On 6/8/07, Radu Grigore <radugrigore at gmail.com> wrote:
> On 6/7/07, Michal Moskal <michal.moskal at gmail.com> wrote:
> > I'll try modifying tuples to support IEqutable, which should make
> > hashtabling them several times faster, but still about 4 times slower
> > than your two level hashtable (which is in fact 70 times faster than
> > hashtabling the tuples).
>
> I wrote the `nested hashtables' solution in a (dumb) generic way and
> hit something that might be a bug in the type inference. See the
> attached file.

This is a case, which our type inference cannot handle. The only way
the compiler could deduce correct type for c.K(1).K is by looking at
all the classes which contains the field/method K, which we never do.

Basically you need to use type constraints in such cases, the minimal
type constraints that work in this case are:

def c : Cache[_, Cache[_, CacheVal [_]]] = Cache()

Hope this helps,
   Michał


More information about the devel-en mailing list