--- a/Complex.st Wed Dec 04 14:04:15 2019 +0100
+++ b/Complex.st Wed Dec 04 14:30:06 2019 +0100
@@ -76,50 +76,12 @@
Complex real: 10 imaginary: 5.
Complex abs: 5 arg: (Float pi / 4)
- NOTE (from the original author):
- Although Complex seems similiar to the Smalltalk''s Number class,
- it would not be a good idea to make a Complex to be a subclass of a Number because:
- - Number is subclass of Magnitude and Complex is certainly not a magnitude.
- Complex does not behave very well as a Magnitude. Operations such as
- <
- >
- <=
- >=
- do not make sense in case of complex numbers.
- - Methods in the following Number methods'' categories do not make sense for a Complex numbers
- truncation and round off
- testing
- intervals
- comparing
+ NOTE (from porter):
+ The original author's Complex class did not inherit from Number and had therefore to reimplement
+ a lot of useful code (reading, testing, mathematical functions, etc.)
+ Therefore we chose to place it under the number hierarchy, blocking some of the methods
+ (eg. comparing, floor, ceiling, etc.)
- However the following Number methods'' categories do have sense for a Complex number
- arithmetic (with the exception of operation
- //
- \\
- quo:
- rem:
- mathematical functions
-
- Thus Complex is somewhat similar to a Number but it is not a subclass of it.
- Some operations we would like to inherit (e.g. #abs, #negated, #reciprocal)
- but some of the Number operations do not have sens to inherit or to overload.
- Classes are not always neat mechanism.
-
- !!!!!! We had to COPY the implementation of some methods
- abs
- negated
- reciprocal
- log:
- isZero
- reciprocal
- ...
- methods from the Number class to the Complex class.
- Awful solution. Now I begin to appreciate Self.
-
- NOTE (from porter):
- moved to Number hierarchy.
- Makes live of users much easier (isNumber, reading, etc)
-
[Author:]
Kurt Hebel (hebel@uinova.cerl.uiuc.edu)
minor changes and double dispatching code by cg.