Fraction hackers...

Bert Freudenberg bert at isgnw.CS.Uni-Magdeburg.De
Fri Sep 10 07:22:57 UTC 1999


On Thu, 9 Sep 1999, Florin Mateoc wrote:

> This obviously works for #= 

It does not because it breaks the symmetry of #=

	'0.5' = 0.5	"false"
	0.5 = '0.5'	"false"
	'(1/2)' = 0.5	"false"
	(1/2) = '0.5'	"true"

You have to leave the #isNumber check in there.

> but maybe there are better solutions, maybe we want it to break
> instead when we compare apples with oranges.

In Smalltalk we need to be able to compare apples with oranges. If not,
something will break, like when having a Set of apples and oranges. 
That's why every implementor of #= must check the class of the argument.

> And while we are talking about Fraction, I would suggest the following
> implementation for #reduced that complements the new #= implementation
> [...]
> The proposed implementation does not create a new Fraction object, it
> modifies self instead. 

Sounds reasonable, but I'd rather rename that method to #reduce then.

  /bert





More information about the Squeak-dev mailing list