Message-ID: <3272BF85.2697@ptc.com>
Date: Sat, 26 Oct 1996 21:48:53 -0400
From: Paul Licameli <licameli@ptc.com>
Organization: Parametric Technology Corporation
X-Mailer: Mozilla 3.0 (X11; I; HP-UX A.09.07 9000/777)
MIME-Version: 1.0
Newsgroups: comp.lang.scheme
Subject: Re: call/cc
References: <325B5B15.167E@ilf.uio.no> <53lhkp$3k4@decius.ultra.net> <53v29g$a9i@decius.ultra.net>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: south.ptc.com
Lines: 26
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!csulb.edu!news.sgi.com!news.mathworks.com!howland.erols.net!netcom.com!news3.noc.netcom.net!noc.netcom.net!news.ptc.com!

> >Dan Vigeland <dan.vigeland@ilf.uio.no> wrote:
> >>
> >> I am looking for a call-with-current-continuatin (call/cc among friends)
> >> eqvivalent in any other languages. Has anybody heard about such?

Check out Standard ML of New Jersey, an implementation of the Standard
ML language that compiles everything into continuation-passing style.

http://cm.bell-labs.com/cm/cs/what/smlnj/index.html

SML/NJ has callcc and throw as non-standard extensions, which do allow
a continuation to escape its context as a first-class value.

"throw" is needed because continuations belong to their own type
distinct from functions.

Types:
callcc:  ('a cont -> 'a) -> 'a
throw: 'a cont -> 'a -> 'b

(The latter never returns, so its return type 'b is unconstrained;
it unifies with any type.)

Usage: (where "fn" is SML for "lambda")

callcc(fn escape => (
    ...
    throw escape answer;
    ...
))

The expression either "falls off the end" with a value of type 'a,
or throws a value of the same type to its continuation, for a quick
exit.
