The definition of the Complex type seems a little weak. A few things:

To get the Cartesian components of the value there are two methods ("re" and "im"). In contrast there is just one method "polar" to return the polar components of the value I'm not sure that this asymmetry is a good thing. Contrast with Rat which has both separate accessors and the "nude" method (a name that could possibly be improved to avoid adult-content filters)

The next thing I notice is that the return value of "polar" is defined as a "Seq" (as is the return value of "nude"), with an English-language definition of that the (exactly) two members of the sequence are. Surely it is possible in a perl6 signature to define the return value more formally, something like:

our multi method polar (Complex $nim: --> [ Real $mag where 0..Inf, Real $angle where -π ..^ π ]) is export { ... }

Finally, anyone using complex numbers probably wants a "conjugate" method and/or operator postfix:<*> almost as much as they want unary-minus:

  $mag = sqrt( $z * $z* );


Reply via email to