develooper Front page | perl.perl6.internals | Postings from November 2004

Re: Continuations, basic blocks, loops and register allocation

Thread Previous | Thread Next
From:
Leopold Toetsch
Date:
November 16, 2004 09:35
Subject:
Re: Continuations, basic blocks, loops and register allocation
Message ID:
419A3997.7060309@toetsch.at
Matt Fowles wrote:
> I disagree with that analysis.  Let us consider the actual effect of
> such an implementation.
> 
> First iteration
> 
> i = 0;
> foo(); #at this point a continuation created capturing i=0, promoted
> by Jens and stuff happens
> #eventually it is invoked, restoring i=0
> i++; #i = 1
> foo(); #at this point a NEW return continuation is created capturing

That would work if there is a one to one representation of the invoation 
of foo() an it's continuation. But no one guarantees that.

By repeatedly invocing the continuation you alway get to the opcode 
after invoke, and registers would be restored to some earlier state.

> ...  If foo's algorithm had an error and did not use the new
> return continuation to recreate its internal continuation each time,
> then you would be correct.  But that would be a bug in the
> implementation of foo.

Why? If foo's implementation is changed internally to double it's work 
per call, it could indicate that progress by returning twice through the 
same continuation.

E.g.

   unless done
      (done, result) = foo()
      s .= result

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