On Mon, 2002-07-22 at 09:36, [EMAIL PROTECTED] wrote:
> > Now, I ask for PMC programmers to take care implementing this! Notice
> > that, for example in arrays, arrays with the same length but different
> > elements should return different hash codes (or try). But for the same
> > elements MUST return the same hash code.
> 
> Um... not necessarily. Bordering on the 'not at all'. Perl 6 will
> apparently allow one to have things other than strings as keys to
> hashes. If I have:
> 
>    $a = [ 1, 2, 3 ];
>    $b = [ 1, 2, 3 ];
> 
>    %foo{$a} = 'A';
>    %foo{$b} = 'B';
> 
> Then I want C< (%foo{$a} == 'A') && %foo{$b} == 'B' > to be true.
> 
> Hmm... actually, that doesn't require a hashing algorithm which
> returns distinct values for $a and $b does it...
> 
> Actually there's a whole can of worms here. Assuming I've just run
> the above code. I want to be able to do C< $b[0] = 3 > and still be
> able to lookup %foo{$b}, which implies that C<hash> should be based
> on some invariant of the PMC that's independent of its content. 

We can, or we can't. This is not really a question of Perl 6 and how it
will behave. This is a question of having real PMC's as keys. I don't
know how it will work on Perl 6, but on my project, with a specification
language over parrot, I must ensure the construction of a hash (or
formally, a finite mapping) to map elements on elements. And, (as there
are not references), after assigning f{ [a,b,c] } = X, there will be no
way to change the key directly (only removing and re-inserting).

That's why I posted some days ago a RFC based on Hash'es versus Finite
Mapping (where nobody answered me). I think we should maintain the
behaviour of PerlHash, but get another PMC to implement finite mapping.
The only problem is that I need some quick way to distingue PMC's, or I
will end-up comparing all key elements.

Thanks

Alberto
-- 
Alberto Manuel B. Simoes
Departamento de Informática - Universidade do Minho
http://alfarrabio.di.uminho.pt/~albie - http://numexp.sf.net

Reply via email to