One programmer's expectation is another's broken code, so "surprise" is not a good standard.  Perserving long-standing behavior is.  Your multiplication example is esaily handled by double-dispatch, and that would not violate "no implicit coercion" because one of the participants is already complex. 
 


From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of csrabak@bol.com.br
Sent: Saturday, August 15, 2009 12:18 PM
To: Pharo-project@lists.gforge.inria.fr
Subject: Re: [Pharo-project] Complex number support discussion

It helps to undestand your suggestion.

It does not help to make it Smalltalk friendly, my meaning of that being the "principle of least surprise".

If complex math is to be allowed a natural consequence is that a lot of functions would return complex answers for real arguments.

How would then have Pharo Smalltalk behave in a case of computing a reactance: X = j�L?

anInductance being Number and complexFrequency obviously being Complex:

aReactance := anInductance * complexFrequency

Em 15/08/2009 13:55, Schwab,Wilhelm K < bschwab@anest.ufl.edu > escreveu:


Nothing tricky: just that methods answering complex results should be defined only by things tha are already complex.  -1 sqrt blows up; -1 asComplex answers i.  There would be no imlicit conversion between real and complex, allowing the base system to perform as it does now and still allowing all the complex number crunching anyone wants to do. Does that help?
Bill