[Haskell-cafe] Haskell maximum stack depth

Derek Elkins derek.a.elkins at gmail.com
Mon Jan 28 18:34:27 EST 2008


On Mon, 2008-01-28 at 14:39 -0500, istarex wrote:
> On Jan 28, 2008 1:07 PM, Neil Mitchell <ndmitchell at gmail.com> wrote:
> 
> > To answer the question if Haskell has a "stack depth restriction ...
> > like Java" the answer is no. It has a stack depth restriction, but its
> > absolutely nothing like Java in the way it uses the stack, so you
> > can't compare them.
> Fair enough.
> 
> > My guess is that Istarex's inner thought might have been along the
> > lines of "in Java if I do too much recursion I get a stack overflow,
> > but Haskell only has recursion, does that mean I get into stack
> > overflows all the time?". I could of course be entirely wrong ;-)
> Well, it wasn't quite that simplistic :-).  I was considering a
> specifically non-tail recursive solution to a problem, and I was
> wondering if Haskell has an artificial recursion depth limit.  I
> didn't stop to consider laziness, and I now realize there's a whole
> dimension of this question that I didn't consider.  Thanks for the
> input guys.

You may want to look at
http://www.haskell.org/haskellwiki/Stack_overflow

While perhaps for a simple throw-away program it may be beneficial to
write code that allocates unnecessary stack, I personally consider
unnecessary stack use a bug.  A stack overflow, to me, is always
indicative of a bug.



More information about the Haskell-Cafe mailing list