Collection squared but what about fractions.
John M McIntosh
johnmci at smalltalkconsulting.com
Tue Jun 5 21:06:27 UTC 2001
>
>As the original author... If you implement the latter, then any
>mathematical entity you want to put in your collections will need to
>implement squared. Not a big deal, but its nice to just be able to
>implement */+-raisedTo: and have just about every other derived
>function work. Why is squared taking so long (don't have a current
>Squeak image)? I'm betting it avoids the reduction test?
Well Number>>squared is implemented.
But my point is that if you create a Numeric based object Foo, and a
specialized squared method for performance, then stick that into a
collection and square the collection then your work isn't used. The
pattern being used in math in collections is aways foo operator, but
in squared we've used foo otheroperator.
Andreas pointed out a way to ensure the fraction logic gets used, and
it' has some merit because it also considers the generate case of
someone doing object * object. But it doesn't solve the general case
above. However I'll tidy up Andreas suggestion and submit it.
--
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
===========================================================================
More information about the Squeak-dev
mailing list
|