which fix is the best for Complex?
Adrian Lienhard
adi at netstyle.ch
Sun Jun 11 13:23:29 UTC 2006
you may want to have a look at the TraitsExample package in the
Traits repository on SqueakSource (http://www.squeaksource.com/
Traits.html).
It contains an implementation of Complex using a trait.
Adrian
On Jun 10, 2006, at 22:04 , Matej Kosik wrote:
> Thomas Koenig wrote:
>> Steph, I recommend harvesting Nicolas cellier' fixes. Certainly in
>> preference to mine (to in elegant) and even in preference to
>> (isNumber
>> ignores issues discussed in Complex class comments.) Nicolas
>> appears to have
>> spent the time working with Complex. Tom
>>
>
> Hello,
>
> Once upon a time the `Complex' class was in a separate package called
> `Algebraic'. Its intention was to brings things like complex numbers,
> matrices, polynoms and such to the image. Since it was rather
> incomplete, I deleted it. Later someone put these classes into the
> core
> image.
>
> The problem with the Complex class (and I thought that it was obvious)
> is, that it cannot be implemented correctly without traits. Complex
> certainly is a number (roughly) (you can do arithmetic with it, it
> plays
> well with other numbers etc). The problem is, that it is not a
> magnitude
> (they cannot be sensibly totally ordered).
>
> Other things are problematic. If `Complex' is a `Number' then methods:
>
> to:
> to:by:
> to:by:do:
> to:do:
> even
> odd
> isDivisibleBy:
> negative
> positive
> sign
> strictlyPositive
> ceiling
> detentBy: detent atMultiplesOf: grid snap: snap
> floor
> fractionPart
> integerPart
> reduce
> roundTo:
> roundUpTo:
> rounded
> truncateTo:
> truncated
>
> do not have sense.
>
> Finer classification would be more appropriate, but the whole stuff
> would be a bit more complicated. I am not sure if it could be done
> without traits (I guess).
> --
> Matej Kosik
>
More information about the Squeak-dev
mailing list
|