Draft of missing functions in Complex (st?phane ducasse)

Martin Snelgrove snelgar at dissonance.com
Mon Oct 3 20:16:21 UTC 2005


The short answer to the question below is that I'm new to Smalltalk,  
let alone the Squeak project, so don't know how things are done.
Here's my attempt to do as suggested: I have attached a file "snelgar. 
1.cs" that looks to have in it:

     1) Complex methods for arcCos, arcSin, arcTan closeTo: ln and sqrt
         a) note that I added a definition for "closeTo:", largely  
copied from that for Float. It's handy for testing.
     2) ComplexTest methods for testArcCos, testArcSin, testArcTan,  
testLn and testSqrt.
         a) I also hacked testEquality, see below
     3) "=" in Float and Integer. That's because in 3.8 as shipped,  
the following non-intuitive behaviour occurs:
                     3 = (3 + 0 i)  -> false
                     (3 + 0 i) = 3  -> true
     this messed up my testing, and was sure to mess up actual  
application of Complex.
          a) the main hazard here is that Complex numbers fail  
"isNumber", which I gather was a strategic
          implementation choice because ">" is odd to define for  
Complex. Me, I would have expected Complex
          to be a Number, and overridden  a > b to be an error if  
imaginary ~= 0, else (a real) > b real

I ran the ComplexTest, FloatTest and IntegerTest suites, and they pass.

There's also a bunch of mysterious looking stuff in the cs file that  
I don't understand (e.g. MCMockClassD methodsFor:).
I don't dare touch it.

Guidance welcome; I've been wandering randomly around the Swiki and  
the squeak.org site, but haven't found anything
that teaches me best practices for contributing code.

     regards
         ws

>
>
> why don't you send a cs and some tests to back up your implementation.
>
>
> Stef
>
>
> On 30 sept. 05, at 08:03, Martin Snelgrove wrote:
>
>
>> The documentation for Kernel-Numbers/Complex says that arcSin,
>> arcCos and arcTan are missing. "sqrt" is
>> also handy for implementing some of these.
>


-------------- next part --------------
Skipped content of type multipart/mixed


More information about the Squeak-dev mailing list