> >Now, on which stack is s supposed to live in an instance of C? It > >can't be allocated on the constructor's function stack, because it > >would be destroyed as soon as the constructor is left. Instead, the > >lifespan of s must be as long as that of the instance of C. One > >efficient way to achieve this is to allocate it directly within the > >memory for the C object. > > There is only one stack (from a thread of execution point of view), a > function uses part of the stack that (if the code generator does it's job) > the caller is not affected by. But, that't not to say a function can't > push something on the stack that the caller could pop. I believe in .NET > this is illegal.
Yeah, I formulated imprecisely, I wrote stack, when I meant stack frame. And you are right, one might be able to manage memory allocated on the stack by shifting it between stack frames, although this would be complicated and not very efficient and isn't done in .NET. Fabian =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com