Perhaps #isNumber should answer false.  I would be very careful about 
advertising an order that might not behave as people expect.

The example of

   -1 asComplex < 1 asComplex

is simple enough, but anything that invokes dictionary ordering (or whatever 
other definition is used) will get tricky with questions of floating point 
precision.

Also, Float has much more in common with Number than would Complex.  A float 
can be approximated by a fraction; a Complex in general cannot.  That alone 
might be justification for treating complex numbers as something different.  
Take the real or imaginary part or the modulus, and you have a number again.

Bill



-----Original Message-----
From: pharo-project-boun...@lists.gforge.inria.fr 
[mailto:pharo-project-boun...@lists.gforge.inria.fr] On Behalf Of Ken.Dickey
Sent: Tuesday, August 11, 2009 9:46 PM
To: Pharo-project@lists.gforge.inria.fr
Subject: Re: [Pharo-project] Complex neurotic

> AFAIK, one has to be careful ordering complex numbers:

I am aware of this.  There are a large number of ways to define #< for complex 
numbers -- and a large number of problems with each of them.

What I object to are bad behaviors for things which are perfectly well defined.

Currently:

-1 asComplex isNumber --> true
 1 asComplex isNumber -> true
-1 asComplex < 1 asComplex --> error

-4 sqrt --> error
-3 ln -> NaN

> If in doubt, I would #shouldNotImplement #< until we can get a 
> conclusive answer.

An answer to what?  I wrote the test cases first and then did code to make the 
tests pass.

I am certainly open to alternate definitions, but I think if an object answers 
true to isNumber it should behave as a number.

What would you expect of the following?

-1 asFloat < 1 asFloat.
-1 asNumber < 1 asNumber.
-1 asFraction < 1 asFraction.
-1 asComplex < 1 asComplex.


One can add checks and make off-axis complex numbers fail (why?), but why cause 
the last case above to fail?

Smalltalk is known for reasonable behaviors.  E.g in Java (1/2) + (1/3) + 1/6) 
can yield zero (integer division truncates).  I much prefer to get an exact 1.

Why should I expect complex numbers to be unreasonable?

$0.02,
-KenD

_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to