Message from discussion
Lisp or Scheme?
Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Pascal Costanza <p...@p-cos.net>
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: Lisp or Scheme?
Date: Wed, 23 Aug 2006 23:47:01 +0200
Lines: 67
Message-ID: <4l40mnF6cj6U1@individual.net>
References: <1156030129.169310.43740@b28g2000cwb.googlegroups.com> <4kplhuFd6sueU1@individual.net> <MXQFg.1327$EG2.45@newsfe10.lga> <1156151402.643304.39520@h48g2000cwc.googlegroups.com> <1156367295.052862.180390@p79g2000cwp.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 5hcqBL11CI21kbMRu2Vo+gb6Vw9qIzY7cYNpzNYnrXcvOuzx5a
User-Agent: Thunderbird 1.5.0.5 (Macintosh/20060719)
In-Reply-To: <1156367295.052862.180390@p79g2000cwp.googlegroups.com>
joh wrote:
> I only get to play with the good languages during my hobby time, and
> I've stuck to CL because I just love the feel of the language. Scheme
> seems nice, too, but my heart's already taken.
>
> It's always bothered me though that CL doesn't have continuations. From
> my limited knowledge, that seems like the one deep concept Scheme has
> that CL doesn't. And since Lisp for me is play time, I want access to
> all the toys.
>
> So some questions for the two camps, and especially those with a foot
> in both camps:
>
> 1. How much do Schemers actually use continuations?
>
> 2. I believe there's at least one library that tries to provide
> continuations in CL. How close is it to the "real thing"?
>
> 3. How hard is it to take some continuation-heavy Scheme code and port
> it to CL? Is it usually straightforward to find a CL way to accomplish
> the same things?
It's not true that CL doesn't have continuations at all. First some
terminology:
- There are one-shot and multi-shot continuations. The difference is
that a one-shot continuations is only called once while a multi-shot
continuation is called several times.
- There are escaping and non-escaping continuations. If you grab a
continuation, for example with call/cc, and during the execution of that
call/cc invoke the continuation, this is called an escaping continuation
because the continuation escapes from the current control flow. If the
execution of that call/cc is already over (either normally or via the
invocation of that continuation), and you call that continuation
(possibly a second time), then this is called a non-escaping
continuation because you are actually returning to a point of execution
that was already "escaped."
Scheme supports one-shot and multi-shot escaping and non-escaping
continuations.
Common Lisp provides the pairs catch/throw and block/return-from which
are one-shot escaping continuations. Common Lisp doesn't support
multi-shot or non-escaping continuations.
It seems to me that in a lot of cases, Scheme's continuations are only
invoked once if at all and are invoked during the extent of the
respective call/cc, so are effectively used as one-shot escaping
continuations. In those cases it is relatively straightforward to
translate the code to Common Lisp, just replace them with the
appropriate constructs (typically block/return-from).
Only if they are used as multi-shot and/or as non-escaping
continuations, then you need to worry more about them. For example, when
continuations are used to simulate threads, or when they are used as
building blocks for web applications, then they are used as non-escaping
continuations.
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/