I have a question based on SmallTalk and C++. In one of the programming languages books, there is a question like:Does an object in Smalltalk require its own private stack? What about in C++? Could you please explain those questions above if you know the answers?Thanks.
Objects in smalltalk and c++
c++;object oriented;stack;smalltalk
In no language does each object require its own stack. Not in Smalltalk. Not in C++. Not in any other language in common use.The only notable exception to this would be thread objects, or objects that otherwise embody concurrency context. Each thread of execution requires its own call stack. That is true independent of the language used--Smalltalk, C++, Python, or whathaveyou. NB Some languages or environments attempt to achieve concurrency (the effect of multi-threading) without per-thread stacks in order to reduce overhead. Such green threads or greenlets are quite useful and increasingly common. Concurrency in go, for example, is centered around this idea. But even if green threads are called threads, they behave closer to coroutines than true threads. Those that are stackless are simulating multi-threaded concurrency, not implementing it fully.