On Wed, 7 Sep 2011, commits(a)source.squeak.org wrote:
> Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
> http://source.squeak.org/trunk/Kernel-nice.614.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-nice.614
> Author: nice
> Time: 7 September 2011, 7:10:52.779 pm
> UUID: 8b421fd9-75f4-2e44-bef4-9bbf5cd3b57a
> Ancestors: Kernel-nice.613
>
> Let (ScaledDecimal newFromNumber: 0.0 scale: 2) print itself.
>
> While at it, review ScaledDecimal comment and indicate that the fraction inst var can be an Integer eventually.
>
> =============== Diff against Kernel-nice.613 ===============
>
> Item was added:
> + ----- Method: Integer>>printTruncatedOn:showingDecimalPlaces: (in category 'printing') -----
> + printTruncatedOn: aStream showingDecimalPlaces: placesDesired
> + "Print a representation of the receiver on aStream in decimal notation with prescribed number of places after decimal separator.
> + Print as if the receiver was truncated to requested precision."
> +
> + self printOn: aStream.
> + placesDesired > 0
> + ifTrue:
> + [aStream nextPut: $..
> + aStream nextPutAll: (String new: placesDesired withAll: (Character digitValue: 0))]!
Wouldn't
aStream
nextPut: $.;
next: placesDesired put: $0
be better here? I mean $0 is the character we want to see and not
something language specific (especially after using $. for the decimal
separator). Also creating a string seems to be overkill for most cases.
I'm just nitpicking, but couldn't stand to ask. :)
Levente
snip
Changes to Trunk (http://source.squeak.org/trunk.html) in the last 24 hours:
http://lists.squeakfoundation.org/pipermail/packages/2011-September/004945.…
Name: Kernel-nice.614
Ancestors: Kernel-nice.613
Let (ScaledDecimal newFromNumber: 0.0 scale: 2) print itself.
While at it, review ScaledDecimal comment and indicate that the fraction inst var can be an Integer eventually.
=============================================
http://lists.squeakfoundation.org/pipermail/packages/2011-September/004946.…
Name: Kernel-nice.615
Ancestors: Kernel-nice.614
Integer shall understand #numerator and #denominator to be polymorphic to Fraction.
Integer shall be polymorphic to Fraction because Fraction with denominator = 1 don't preserve their class across arithmetic operations.
=============================================
http://lists.squeakfoundation.org/pipermail/packages/2011-September/004947.…
Name: Kernel-nice.616
Ancestors: Kernel-nice.615
Form a Fraction explicitely rather than sending asFraction when coercing an Integer is required.
This way, Integer>>#isFraction and Integer>>#asFraction can be modified.
=============================================
http://lists.squeakfoundation.org/pipermail/packages/2011-September/004948.…
Name: Kernel-nice.617
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.
=============================================
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.617.mcz
==================== 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@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') -----
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!
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.616.mcz
==================== Summary ====================
Name: Kernel-nice.616
Author: nice
Time: 7 September 2011, 10:07:42.842 pm
UUID: 7aedbc4c-8362-48cb-bfbe-7b28ef66837c
Ancestors: Kernel-nice.615
Form a Fraction explicitely rather than sending asFraction when coercing an Integer is required.
This way, Integer>>#isFraction and Integer>>#asFraction can be modified.
=============== Diff against Kernel-nice.615 ===============
Item was changed:
----- Method: Fraction>>adaptToInteger:andSend: (in category 'converting') -----
adaptToInteger: rcvr andSend: selector
"If I am involved in arithmetic with an Integer, convert it to a Fraction."
+ ^ (Fraction numerator: rcvr denominator: 1) perform: selector with: self!
- ^ rcvr asFraction perform: selector with: self!
Item was changed:
----- Method: Integer>>adaptToFraction:andSend: (in category 'converting') -----
adaptToFraction: rcvr andSend: selector
"If I am involved in arithmetic with a Fraction, convert me to a Fraction."
+ ^ rcvr perform: selector with: (Fraction numerator: self denominator: 1)!
- ^ rcvr perform: selector with: self asFraction!
On 7 September 2011 20:54, <commits(a)source.squeak.org> wrote:
> Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
> http://source.squeak.org/trunk/Kernel-nice.615.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-nice.615
> Author: nice
> Time: 7 September 2011, 9:54:15.365 pm
> UUID: 4e49e25c-85dc-444c-bdd5-5e4bb9d05b6e
> Ancestors: Kernel-nice.614
>
> Integer shall understand #numerator and #denominator to be polymorphic to Fraction.
> Integer shall be polymorphic to Fraction because Fraction with denominator = 1 don't preserve their class across arithmetic operations.
>
> =============== Diff against Kernel-nice.614 ===============
Great stuff! Thanks, Nicolas!
frank
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.615.mcz
==================== Summary ====================
Name: Kernel-nice.615
Author: nice
Time: 7 September 2011, 9:54:15.365 pm
UUID: 4e49e25c-85dc-444c-bdd5-5e4bb9d05b6e
Ancestors: Kernel-nice.614
Integer shall understand #numerator and #denominator to be polymorphic to Fraction.
Integer shall be polymorphic to Fraction because Fraction with denominator = 1 don't preserve their class across arithmetic operations.
=============== Diff against Kernel-nice.614 ===============
Item was added:
+ ----- Method: Integer>>denominator (in category 'accessing') -----
+ denominator
+ "Let an Integer be polymorphic to a Fraction. See #isFraction."
+ ^1!
Item was added:
+ ----- Method: Integer>>numerator (in category 'accessing') -----
+ numerator
+ "Let an Integer be polymorphic to a Fraction. See #isFraction."
+ ^self!
Evaluate the following:
0s0 "=> 0s0"
ScaledDecimal newFromNumber: 0 scale: 0 "=> 0s0"
0.0s0 "=> 0s0"
ScaledDecimal newFromNumber: 0.0 scale: 0 "=> MNU: SmallInteger
doesn't understand printTruncatedOn:showingDecimalPlaces:"
The MNU happens because in ScaledDecimal class >> #newFromNumber:scale: we say
"..." aNumber asFraction "..."
and when aNumber = 0.0, aNumber asFraction = 0, which is a
SmallInteger and not a Fraction.
(Recorded as http://bugs.squeak.org/view.php?id=7667)
frank
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.614.mcz
==================== Summary ====================
Name: Kernel-nice.614
Author: nice
Time: 7 September 2011, 7:10:52.779 pm
UUID: 8b421fd9-75f4-2e44-bef4-9bbf5cd3b57a
Ancestors: Kernel-nice.613
Let (ScaledDecimal newFromNumber: 0.0 scale: 2) print itself.
While at it, review ScaledDecimal comment and indicate that the fraction inst var can be an Integer eventually.
=============== Diff against Kernel-nice.613 ===============
Item was added:
+ ----- Method: Integer>>printTruncatedOn:showingDecimalPlaces: (in category 'printing') -----
+ printTruncatedOn: aStream showingDecimalPlaces: placesDesired
+ "Print a representation of the receiver on aStream in decimal notation with prescribed number of places after decimal separator.
+ Print as if the receiver was truncated to requested precision."
+
+ self printOn: aStream.
+ placesDesired > 0
+ ifTrue:
+ [aStream nextPut: $..
+ aStream nextPutAll: (String new: placesDesired withAll: (Character digitValue: 0))]!
Item was changed:
Number subclass: #ScaledDecimal
instanceVariableNames: 'fraction scale'
classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Numbers'!
+ !ScaledDecimal commentStamp: 'nice 9/7/2011 19:09' prior: 0!
- !ScaledDecimal commentStamp: '<historical>' prior: 0!
ScaledDecimal provides a numeric representation of fixed point decimal numbers able to accurately represent decimal fractions. It supports unbounded precision, with no limit to the number of digits before and after the decimal point.
ScaledDecimal complies with the ANSI protocols:
Object
number
ScaledDecimal
????
#todo. "finish protocol list."
Implementation Notes:
+ In order to fullfil exact arithmetic requirements, ScaledDecimal is implemented using a Fraction (or an Integer if fraction part is zero) in the fraction instance variable, and a positive Integer number of digits after the decimal point in the scale instance variable.
- I implemented ScaledDecimal with the decimal fraction stored in instance variables numerator and denominator, and the number of digits after the decimal point in fractionalDigit as a positive Integer. I implemented operations by first coercing the aurguments to fractions, doing the operations, then coercing the result to the proper numeric representation when necessary and scale. This is because I assume the Fraction class is more likely to implement them correctly.
+ A scaled decimal will perform arithmetic by coercing the arguments to fractions, and perform the operations with exact arithmetic.
+
+ Note that the denominator needs not being a power of two. If denominator has other prime factors than 2 and 5, then it cannot be printed in decimal form with a finite number of digits. Instead, the printed representation will be truncated to the number of digits prescribed in scale. But beware, the number still has hidden precision.
+
+ Example:
+ | x |
+ x := 1 / 3.0s2.
+ ^{ x printString -> 'truncated print'.
+ 3 * x -> 'but full precision'}
- Richard A. Harmon
!
Attending: Chris Muller, Bert Freudenberg, Colin Putney, Randal
Schwartz, Jecel Assumpacao Jr., Chris Cunnington
* Bert and Chris C. returned from ESUG. Quality of attendance was
expressed as one of several highlights.
* The future of SqueakSource was also discussed. The plan is to
employ an updated SqueakSource running on GemStone in the near
future athttp://ss3.gemstone.com <http://ss3.gemstone.com/>with
the mirror in Chile remaining unchanged. The squeaksource code
repository is important to the Smalltalk community as a whole, and
so it is very nice that GemStone has taken on this responsibility.
* Bert has a change set that can make a trunk image work on iPad
like the Etoys image works on the iPad and he is considering
merging those changes into the trunk
image.http://etoys.squeak.org/experimental/ipad/