What class should include "5 kilograms"?

Augustin Mrazik amr at aitecon.sk
Thu Nov 12 23:41:23 UTC 1998


> I would say that all dimensioned numbers belong in 
> DimensionedNumber (which is probably an immediate 
> subclass of Number) or its subclasses. 

In my opinion physical units are Magnitudes (since they are ordered) but
they are not special Numbers. When having different kinds of units,
result of operation on units can be viewed as conversion from one unit
to another (if the argument is another unit). Numbers are just neutral
units from the point of view of * and / operations: multiplication and
division by a number is not a conversion and division by the same unit
gives just the number.

Hence I think that Units sit at the same level as Numbers. 

In a units package which we have implemented a time ago (I have
mentioned it in this list but then it has shown to be too proprietary
for reuse in Squeak), we have had also another two abstract subclasses
of Unit: BasicUnits (e.g. Lenght, Weight) and DerivedUnits (such as
speed, acceleration). Meters and Inches were just different
representations of the same unit.

BTW, Date and Time in Smalltalk are ment primarily as a particular
moment on the time axis (a date, starting with January 1-st of a certain
year, or time/moment within the particular day), although there is
certain arithmetics implemented there. The Duration (e.g. in seconds) is
a different thing - this is what we need for speed (seconds, hours) or
age (years). Here we need the full arithmetics as for any other unit
(compatible with Numbers). Conversion of Duration from/to Time and Date
would be reasonable, of course (maybe even adding real arithmetics to
Time and to Date - result would be aDuration).

With adding Units to Magnitude, I think it would be reasonable to
include ArithmeticObjects (abstract) as subclass of Magnitude and to put
Number and Units as its subclasses. This would really express the
situation: magnitudes on which also arithmetic operations are defined.
And Numbers would be special Units without dimension (or without 'unit'?
;-). 

So long we have had only Numbers (from all possible arithmetic objects),
we did not really need this class and Number had been immediate subclass
of Magnitude.


Augustin Mrazik





More information about the Squeak-dev mailing list