develooper Front page | perl.perl6.language | Postings from November 2010

Re: Ruby Fibers (was: threads?)

Thread Previous | Thread Next
From:
Mark J. Reed
Date:
November 7, 2010 12:13
Subject:
Re: Ruby Fibers (was: threads?)
Message ID:
AANLkTimm-3406XTRQi3w6CpXkjV2Gv8gA_TjBSwKqb4M@mail.gmail.com
On Fri, Oct 15, 2010 at 10:22 AM, B. Estrade <estrabd@gmail.com> wrote:
> Pardon my ignorance, but are continuations the same thing as
> co-routines, or is it more primitive than that?

Continuations are not the same thing as coroutines, although they can
be used to implement coroutines - in fact, continuations can be used
to implement any sort of flow control whatsoever, because they are a
way of generalizing flow control.  Goto's, function calls, coroutines,
setjmp/longjmp, loops, exception throwing and catching - these and
more can all be regarded as special cases of continuation
manipulation.

A continuation is just a snapshot of a point in a program's run, which
can then be 'called' later to return control to that point.  The
entire execution context is preserved, so you can call the same
continuation multiple times, re-enter a function that has already
returned, etc.   But state changes are not undone, so the program can
still behave differently after the continuation is called.

-- 
Mark J. Reed <markjreed@gmail.com>

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