I don't want to seem I turned the rant mode, on, but:
Last statement makes so little sense as saying the "expected" thing is that
4 sqrt
should return a tuple #(2.0 -2.0) because it happened before we had computers....
The "Principle of Least Surprise" should be taken in the context of the Smalltalk language history.�� For an argument based in mathematical package, if you open a "R" (a statistical package based in ATT's S language) repl and do the similar call you get:
> sqrt(-2)
[1] NaN
Warning message:
In sqrt(-2) : NaNs produced
Specific mathematical packages like Maxima, Scilab and Octave have flags to control the behaviour for this case.
HTH
��
Em 12/08/2009 12:11, Ken.Dickey < Ken.Dickey@whidbey.com > escreveu:
KenD> > Currently:
> >
> > -1 asComplex isNumber --> true
> > ?1 asComplex isNumber -> true
> > -1 asComplex < 1 asComplex --> error
> >
> > -4 sqrt --> error
Igor Stasenko >
> 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
So you prefer (1 asFraction / 2) -> 1/2 , where (1/2) gives an error because 1
and 2 are not fractions?
(-1 s qrt) is the definition of 1i .
Other dynamic languages I use [Scheme, Lisp] which define complex numbers all
give square roots of negative numbers.
I am trying to approach the Principle of Least Surprise here. Computers are
very bad at math, but we have learned painfully to work around this. I
would like pre-computer high school math to "just work". IEEE Floats only
guarantee the wrong answer fast, IMHO.
I would like square roots of negative numbers to work like they did before I
got a computer! 8^) 8^O 8^{
Cheers,
-KenD
_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project