I would think, since output is popped off the stack, that there wouldn't be any need. Am I missing something?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
GC is normally applied to memory allocated on the heap. I'm not familiar with Forth or RPL, but if there is no heap, and everything is stored on a global stack instead, then there's nothing for GC to do.
Yes, you're right. But the stack basedness is just a part of the whole story. For example, the Java bytecode interpreter is stack-based as well (the compiled code works -- for efficiency reasons -- differently). This tells us, that any language can be transformed into a stack language.
What matters are the objects outside of the stack, those who can outlive the current method execution. As long as the language has nothing like
A language lacking dynamic memory allocation is quite limited in its usefulness.