[squeak-dev] The Trunk: Kernel-nice.617.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Sep 7 20:37:28 UTC 2011

Nicolas Cellier uploaded a new version of Kernel to project The Trunk:

==================== Summary ====================

Name: Kernel-nice.617
Author: nice
Time: 7 September 2011, 10:36:43.543 pm
UUID: 709886c8-65a6-4ca8-8c60-96002f0cc739
Ancestors: Kernel-nice.616

Consider an Integer as a special kind of Fraction (from behavioral POV, not from hierarchical POV), ans as such answer true to #isFraction and answer self to #asFraction.

This is a logical consequence of having Fraction with a unit denominator automatically reduced to Integer.

Two pre-requisites to this change are:
- letting Integer be polymorphic with Fraction by responding to #numerator and #denominator
- and don't letting senders of #asFraction rely on the class of the result being a Fraction (which was the case of some coercion message only).
These requirements should be fullfiled by update-nice.196.mcm.

A side effect of this change is to speed up a bit mixed arithmetic like (1/2)+1, but not 1+(1/2).

A second side effect is that (1 at 2) asNonFractionalPoint will now convert coordinates to floating point.

There is no other sender of #isFraction or #asFraction affected by the change in the trunk image.

=============== Diff against Kernel-nice.616 ===============

Item was changed:
  ----- Method: Integer>>asFraction (in category 'converting') -----
+ 	"Answer a Fraction that represents the value of the receiver.
+ 	Since an Integer already behaves as a special kind of Fraction, no conversion is required, see #isFraction."
- 	"Answer a Fraction that represents the value of the receiver."
+ 	^self!
- 	^Fraction numerator: self denominator: 1!

Item was added:
+ ----- Method: Integer>>isFraction (in category 'testing') -----
+ isFraction
+ 	"Each Integer is considered as a special kind of Fraction with self as numerator and a unit denominator.
+ 	Rationale: A Fraction with a unit denominator will be automatically reduced to an Integer.
+ 	Hence Integer has to be polymorphic to Fraction."
+ 	^true!

More information about the Squeak-dev mailing list