Shouldn't 2 hash = 2.0 hash? [LONG]

Jan Theodore Galkowski algebraist at salonmember.com
Thu Dec 2 18:06:39 UTC 1999



On Wed, 1 Dec 1999 17:35:30    agree wrote:


[snip]


>... is just wrong, unless one
>> is trying to imitate FORTRAN's mixed mode.
>
>I think any reasonable reading of the Number hierarchy suggests precisely that: Smalltalk numbers with their automated coercions expressly contemplate that numbers shall be converted as necessary.  Whether this is good or bad is not an issue on which I am prepared to pass, but there is no doubt that the auto-conversions is at present a Smalltalk feature.
>
>Indeed, its far worse than you may have imagined.  "=" is so overloaded as to give meaning to expressions such as:
>
>'1.0' + 0 = 1	which is true, and
>'1.0' = 1		which is false.
> > So, like Dave, I see the hash behavior of
>> really not being pertinent.
>
>I disagree.  A number of Smalltalk classes depend upon the '='/hash property.  Either '=' should be defined to be identity with the default hash, or it should be redefined so as to assure the '='/hash concordance.
>
>One serious aesthetic difficulty, of course, with algebraist's alternative definition of equality for floats is that it is not an equivalence relationship, because it is not transitive.  It would be a travesty to use the '=' sign with such a relation, better to use withinEps:of: or something like that.

[snip]

"withinEps:of:" would get around it, but I
also was second guessing my own suggestion.
For, unless one starts hacking with "=="'s
definition, with the definition of "=" for
flonums I and others proposed, one could
never calculate a value for machine epsilon
using Squeak.  For that is done with an
iteration of testing "1 = (1 + candidate_eps)"
and choosing machine epsilon as the value
of "candidate_eps" just before it turns
true.  Being able to calculate such a 
thing is important for numerical portability,
and numerical algorithms calculate "nearness"
to things like convergence by differencing
flonums and comparing against various 
multiples of this machine epsilon.

Sorry, I don't mean to be pedantic here:  I
just wanted a complete record of the
matter for the archive.

I don't have the st experience to understand
the situation with hash, apart from it being
a quick preconditioning rejector of 
possibilities of equality.

So, the matter is, indeed, more complicated
than it first seemed, and the withinEps:of: 
is a better idea, with the first keyword
tagging a positive integral multiple of Eps,
and there being a currentEps message which
sets the current machine epsilon.

  --Jan Galkowski


---
___________________________________________
demiourgos at smalltalk.org        squeak.org/
home.stny.rr.com/algebraist/ 
www.smalltalk.org/ jtgalkowski at alum.mit.edu




Get your FREE, private e-mail account at http://www.salonmember.com.





More information about the Squeak-dev mailing list