On Feb 23, 2006, at 5:06, Patrick R. Michaud wrote:
PGE does not expect that a sub will restore the state of the user
stack, but it does expect that *coroutines* get their own copy of
the user stack, and that calling/returning from a coroutine will
not affect the current user stack. This expectation comes from
two sources-- first, it's claimed at the bottom of page 165 in
"Perl 6 and Parrot Essentials", and the docs/pmc/subs.pmc file
says that coroutines get a COW copy of the user stack.
Moving the user stack from context (which is distinct for a coroutine)
to the interpreter needs definitely more code:
a) create or copy user stack on coroutine creation, store it in the
coro structure
b) swap user stacks on yield/reinvocation
As I said, I'll be the first to admit that my understanding of
how the user stack is supposed to work may be incorrect.
Well, there are two issues involved with the user stack:
* do we really need it / want it / keep it [1]
* if so, how are the semantics across sub calls or for coros
[1] the stacks are rather inefficient and big structures:
one stack entry occupies 12 words (96 bytes on 32-bit)
using a local ResizableIntegerArray is by far more efficient
leo