[squeakdev] The Trunk: Kernelnice.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:
http://source.squeak.org/trunk/Kernelnice.617.mcz
==================== Summary ====================
Name: Kernelnice.617
Author: nice
Time: 7 September 2011, 10:36:43.543 pm
UUID: 709886c865a64ca88c6096002f0cc739
Ancestors: Kernelnice.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 prerequisites 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 updatenice.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 Kernelnice.616 ===============
Item was changed:
 Method: Integer>>asFraction (in category 'converting') 
asFraction
+ "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 Squeakdev
mailing list
