Home > Archive > Scheme > February 2007 > Most common ways to utlize continuations?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Most common ways to utlize continuations?
|
|
|
| Hi folks,
What are some of the most common ways to utilize continuations?
Regards,
Griff
| |
| Lauri Alanko 2007-01-24, 8:16 am |
| In article <1169590309.371312.105450@k78g2000cwa.googlegroups.com>,
Griff <grettke@gmail.com> wrote:
> What are some of the most common ways to utilize continuations?
Exceptions, non-local exits, threading, nondeterminism and synchronous
interfaces to asynchronous processes.
Lauri
| |
| Greg Woodhouse 2007-01-24, 7:10 pm |
|
On Jan 23, 2:11 pm, "Griff" <gret...@gmail.com> wrote:
> Hi folks,
>
> What are some of the most common ways to utilize continuations?
>
> Regards,
>
> Griff
Remember that a continuation captures the state of a computation in
progress, so if you need to "pick up here you left off" then a
continuation is a way to do it. Many Scheme implementations support
exceptions (I don't recall the SRFI number), so you don't necessarily
need to use call-with-current-continuation (or just call/cc) for simple
exceptions, but you could do it. Continuations can be used for
elaborate things like backtracking, too.
| |
| joe nada 2007-01-25, 4:15 am |
| In <ep7gfi$81b$1@oravannahka.helsinki.fi> Lauri Alanko wrote:
> In article <1169590309.371312.105450@k78g2000cwa.googlegroups.com>,
> Griff <grettke@gmail.com> wrote:
>
> Exceptions, non-local exits, threading, nondeterminism and synchronous
> interfaces to asynchronous processes.
>
>
> Lauri
>
If this isn't enough - and if sounds non-practical - I'd like to add
that once I read a paper about aa guy who used continuations to
prototype fast C algorithms (C with gotos, but proven correct).
Cheers.
Joe Nada
| |
| Abdulaziz Ghuloum 2007-01-25, 4:15 am |
|
On Jan 25, 1:07 am, joe nada <j...@nada.com> wrote:
> In <ep7gfi$81...@oravannahka.helsinki.fi> Lauri Alanko wrote:
>
>
>
> that once I read a paper about aa guy who used continuations to
> prototype fast C algorithms (C with gotos, but proven correct).
Pointers?
Aziz,,,
| |
| Anton van Straaten 2007-01-25, 8:08 am |
| joe nada wrote:
> In <ep7gfi$81b$1@oravannahka.helsinki.fi> Lauri Alanko wrote:
>
> If this isn't enough - and if sounds non-practical - I'd like to add
> that once I read a paper about aa guy who used continuations to
> prototype fast C algorithms (C with gotos, but proven correct).
You might be thinking of Dan Friedman's "The Role of the Study of
Programming Languages in the Education of a Programmer":
http://www.cs.indiana.edu/~dfried/dfried/mex.pdf
Also, one practical place that continuations have been used to good
effect is in many kinds of web applications -- not just in Scheme, but
in languages like Lisp, Smalltalk, Java, and Javascript, where in some
cases people have gone to quite a lot of trouble to implement (a.k.a.
fake) continuations in order to enjoy their benefits.
Anton
| |
| Adrian 2007-01-25, 7:09 pm |
| But are they *good* uses of continuations, or just a hack to emulate
something better provided by a language abstraction?
I know you can do allot of funky stuff with continuations, but I just
don't know if such uses are workarounds for missing language features,
or alternatively, if they are actually a *more* elegant solution to
such problems. I've been wanting to ask this for a long time, but was
worried that it may be a naive question.
On Jan 24, 8:38 pm, Lauri Alanko <l...@iki.fi> wrote:
> In article <1169590309.371312.105...@k78g2000cwa.googlegroups.com>,
>
> Griff <gret...@gmail.com> wrote:
> interfaces to asynchronous processes.
>
> Lauri
| |
| Jens Axel Søgaard 2007-01-25, 7:09 pm |
| Griff skrev:
> Hi folks,
>
> What are some of the most common ways to utilize continuations?
Make a cup of coffee.
Read Daniel P. Friedman.
"Applications of Continuations: Invited Tutorial"
<http://www.cs.indiana.edu/hyplan/dfried/appcont.pdf>
Name this context c.
Make a cup of coffee.
Pick a paper at <http://library.readscheme.org/page6.html>
Read the paper, if stuck backtrack to c.
Backtrack to c.
--
Jens Axel Søgaard
| |
| Chung-chieh Shan 2007-01-26, 4:13 am |
| Adrian <borg@swirve.com> wrote in article <1169759853.046235.251900@m58g2000cwm.googlegroups.com> in comp.lang.scheme:
> But are they *good* uses of continuations, or just a hack to emulate
> something better provided by a language abstraction?
Continuations let you build the abstractions without relying on the
language to provide it.
| |
| Andrew Reilly 2007-01-26, 8:07 am |
| On Fri, 26 Jan 2007 05:30:36 +0000, Chung-chieh Shan wrote:
> Adrian <borg@swirve.com> wrote in article <1169759853.046235.251900@m58g2000cwm.googlegroups.com> in comp.lang.scheme:
>
> Continuations let you build the abstractions without relying on the
> language to provide it.
OK, but if I could elaborate on what I think that the OP might have been
getting at: does anyone, in practice, do that sort of
abstraction-building in an application-specific sort of way, and *not*
just come up with something like the generally accepted/standard control
constructs? (repeat/until, while, loop, goto, for, yield, try/catch,
state-machine, etc)
Cheers,
--
Andrew (pre newbie-stage scheme acolyte)
| |
| joe nada 2007-02-02, 4:10 am |
| In <45b92e2d$0$884$edfadb0f@dread12.news.tele.dk> Jens_Axel_Søgaard
wrote:
> http://library.readscheme.org/page6.html
I just looked at what seems a very interesting, real-world use for
continuations:
Continuations from Generalized Stack Inspection
Greg Pettyjohn, John Clements, Joe Marshall, Shriram Krishnamurthi,
Matthias Felleisen
ACM SIGPLAN International Conference on Functional Programming, 2005
Abstract
Implementing first-class continuations can pose a challenge if the
target machine makes no provisions for accessing and re-installing the
run-time stack. In this paper, we present a novel translation that
overcomes this problem. In the first half of the paper, we introduce a
theoretical model that shows how to eliminate the capture and the use of
first-class continuations in the presence of a generalized stack
inspection mechanism. The second half of the paper explains how to
translate this model into practice in two different contexts. First, we
reformulate the servlet interaction language in the PLT Web server,
which heavily relies on first-class continuations. Using our technique,
servlet programs can be run directly under the control of non-
cooperative web servers such as Apache. Second, we show how to use our
new technique to copy and reconstitute the stack on MSIL.Net using
exception handlers. This establishes that Scheme's first-class
continuations can exist on non-cooperative virtual machines.
http://www.cs.brown.edu/~sk/Publica...hed/pcmkf-cont-
from-gen-stack-insp/
Cheers,
JN
| |
| joe nada 2007-02-02, 4:10 am |
| In <1169711921.317705.215520@v45g2000cwv.googlegroups.com> Abdulaziz
Ghuloum wrote:
> Pointers?
>
> Aziz,,,
>
It was the one Van Straaten posted.
JN.
| |
| Nathan Thern 2007-02-07, 7:09 pm |
| Griff wrote:
> Hi folks,
>
> What are some of the most common ways to utilize continuations?
>
> Regards,
>
> Griff
>
In LispMe, which is a full-featured R4RS scheme for palm pilot, map
comes as a library function which only takes 2 arguments (a function and
a single list). Needing the more general map which takes a function of N
args and N lists, I wrote and tested several R4RS compliant map's of my
own. The fastest was definitely the one that used continuations to
iterate. Of course, that's just the case for one implementation on some
unusual hardware.
Here is my LispMe version of map...the funny formating is because of the
narrow screen on the palm pilot.
(define (map f l1 . l2)
(if (null? l1) l1
(let ((lol (cons l1 l2))
(cars ())
(cdrs ())
(rslts ()))
(let ((k (call/cc
(lambda (k2) k2))))
(if (null? lol)
(begin
(set! rslts (cons (apply
f (reverse cars))
rslts))
(if (null? (car cdrs))
(reverse rslts)
(begin (set! lol
(reverse cdrs))
(set! cars ())
(set! cdrs ())
(k k))))
(begin
(set! cars (cons
(caar lol) cars))
(set! cdrs (cons
(cdar lol) cdrs))
(set! lol (cdr lol))
(k k)))))))
Nate T
|
|
|
|
|