how dynamic stack approximation works

Malcolm Wallace Malcolm.Wallace at
Tue Feb 24 05:49:32 EST 2009

Peter Hercek <phercek at> wrote:

> >
> I was writing about a way how to maintain the stack as described in 
> point 6 of the page (provided that point is about dynamic stack).

The whole page (including point 6) is about explicitly maintaining a
(simulated) lexical call stack, not the dynamic one.

> As I already said in other emails, I would rather choose dynamic stack
> over lexical one if I was forced to choose only one of them. Actually,
> I  almost do not care about lexical stack and still do not understand
> why  people want it.

In a lazy language, the dynamic stack rarely tells you anything of
interest for debugging.  For the value at the top of the stack, you get
one of many possible _demand_ chains, rather than the creation chain.
The demanding location is pretty-much guaranteed not to be the site of
the bug.

But you can think of the lexical call stack as what _would_ have been
the dynamic call stack, if only the language were completely strict
rather than lazy.  Most people find the latter notion more intuitive for
the purposes of finding program errors.

> Sure, but the plan to maintain an approximate debugging dynamic stack 
> depends on one thing:

There is no need to approximate the dynamic stack.  It is directly
available to the RTS, in full detail.


More information about the Glasgow-haskell-users mailing list