Comment by lmm

5 years ago

Or you could avoid (semantically) having a stack at all, as Haskell does.

I don't see how that could be done... Is it a result of laziness?

  • You just push the stack into the heap, and don't have a specific area which is the stack area. It's pretty common as a technique if you have something such as call-with-current-continuation.

    The "stack" is still there in this case, but spread out over multiple heap blocks.

    • Guie Scheme does something similar then. It expands the call stack so that you can't have a stack overflow. Pretty neat since it allows you to write recursive functions without accumulators.

      I suspect something like that is a bigger deal in eagerly evaluated languages.