2009/8/12 Ken.Dickey <[email protected]>:
>> 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

and it should.
Not many people using a complex numbers. And -4 is an integer number,
not complex number (i hope this non-objectionable?). And sqrt function
is not defined for real/integer numbers < 0 ,and should lead to error,
period.
If you change this behavior, some of code will fail to work correctly
, definitely.
But you are free to use something like:
-4 asComplex sqrt

> -3 ln -> NaN
>
same as above, use it as:
-3 asComplex ln.

>> 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.
>

i personally, don't see any reason why bother defining an ordering
operator for non-scalar value(s).
Complex numbers is not scalars and ordering operator having a little
sense on vectors (however you can find its defined in Point protocol).
I really wonder, where #<, #> could be used for Point(s), or vectors
in general? And there always will be questions how to define them.
As for complex numbers, i wonder , what is correct answer in
comparison between real number and any complex number (and moreover,
what is the mathematical meaning of such comparison?), because if you
introducing it, you can expect someone to compare occasionally:

(a * x) < (b * x)
where a,b,x could be either complex or real numbers, and #* behavior
could turn the complex number to real for one side, but not for
another one.


>
> 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?
>

They shoudn't, just keep real numbers be reasonable in parallel :)

> $0.02,
> -KenD
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



-- 
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to