develooper Front page | perl.perl6.internals | Postings from February 2006

Re: Allowing push/pop across sub calls

Thread Previous | Thread Next
From:
Leopold Toetsch
Date:
February 23, 2006 01:34
Subject:
Re: Allowing push/pop across sub calls
Message ID:
10654adce7ae9ab3ce8f21093e959705@toetsch.at

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


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About