Another space leak questionth
Srineet
srineet@veritas.com
Sun, 1 Jul 2001 21:33:34 +0530
Hi,
I have been having a problem for some time, maybe this is a simple
obvious question, but I would like your help on this. I give only what I
think is the crux of the problem, just to keep this mail short and avoid
unnecessary details.
Consider,
step (n, x:xs) = step (n+x, xs)
main' = step (1, repeat 1)
I think, if you evaluate main', you'd run out of heap space (couldn't
totally verify because my hugs crashed on my windows machine!).
Now have another step'
step' n (x:xs) | n == 0 = 0
| otherwise = step' (n+x) xs
main'' = step' 1 (repeat 1)
Now main'' continues forever, but doesn't cause hugs to run out of
heap.What' the reason that, while both main' and main'' run forever, the
first causes hugs to run out of heap while second doesn't.
Thanks, bye.
- Srineet.