This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Re: equality questions

3 replies
Jesper Nordenberg
Joined: 2008-12-27,
User offline. Last seen 42 years 45 weeks ago.

martin odersky wrote:
> Are there alternatives? The most obvious generalization is to make ==
> a multi-method.
> That's similar to the current scheme, except that we should avoid any
> leakage into equals. We have to make sure that equals only ever calls
> equals, never ==.

Why? Why can't == be used in equals if a hash code function that is consistent with it is also used?

/Jesper Nordenberg

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Re: equality questions

On Wed, Sep 23, 2009 at 10:53 AM, Jesper Nordenberg wrote:
> martin odersky wrote:
>> Are there alternatives? The most obvious generalization is to make ==
>> a multi-method.
>> That's similar to the current scheme, except that we should avoid any
>> leakage into equals. We have to make sure that equals only ever calls
>> equals, never ==.
>
> Why? Why can't == be used in equals if a hash code function that is consistent with it is also used?
>
That would work of course. But remember we are dealing with boxed
numbers here and the hashCode
for them is imposed on us.

Cheers

Jesper Nordenberg
Joined: 2008-12-27,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: equality questions
odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Re: equality questions

On Wed, Sep 23, 2009 at 11:31 AM, Jesper Nordenberg wrote:

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland