On Mon, Jul 7, 2008 at 2:21 PM, Michael Feathers
<[EMAIL PROTECTED]> wrote:
> Thanks. Here's a newb question: what does strictness really get me in this
> code?
A bit of speed and memory improvements, I suspect. The type
(Double,Double) has three boxes, one for the tuple and one for each
double. The type Complex, which is defined as
data Complex a = !a :+ !a
has one box (after -funbox-strict-fields has done its work), the one
for the type as a whole. So it will end up using less memory, and
there will be fewer jumps to evaluate one (a jump is made for each
box).
> BTW, I only noticed the Complex type late. I looked at it and noticed that
> all I'd be using is the constructor and add. Didn't seem worth the change.
You would also be using the multiply and magnitude functions! And you
would gain code readability, since you could define:
mandel c z = z^2 + c
trajectory c = iterate (mandel c) 0
Which is basically the mathematical definition right there in front of
you, instead of splayed out all over the place.
Luke
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe