4 ms·
Any functional programming language shall have TCO since statements are forbidden (everything is a function).
by CodeArtisan 5y ago
Any functional programming language shall have TCO since statements are forbidden (everything is a function).
- lmm 5y agoOr you could avoid (semantically) having a stack at all, as Haskell does.
- bjoli 5y agoI don't see how that could be done... Is it a result of laziness?
- jlouis 5y agoYou 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.
- bjoli 5y agoGuie 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.