« Return to Thread: Stack vs Heap allocation

Re: Stack vs Heap allocation

by Edsko de Vries :: Rate this Message:

Reply to Author | View in Thread

Hi,

> > > (...(((1+2)+3)+4) ... + 10000000)
> > > which requires stack in proportion to the number of nested parentheses
> >
> > Ah, that makes! So does it make sense to talk about "tail recursive
> > thunks"? Or does the evaluation of thunks always take stack space
> > proportional to the "nesting level"?
>
> The key reason why nested additions take stack space, is because (+) on
> Integers is *strict* in both arguments.  If it were somehow non-strict
> instead, then the unevaluated parts of the number would be heap-allocated
> rather than stack-allocated.

I don't understand. Could you elaborate?

Thanks,

Edsko
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

 « Return to Thread: Stack vs Heap allocation

LightInTheBox - Buy quality products at wholesale price