From: see.signature
Subject: continuations and cl
Date: 
Message-ID: <slrn8afqp5.n8.anyone@Flex111.dNWL.WAU.NL>
Hi Lipsers,

when reading "On Lips" by P. Graham, i was wondering about the
implementation of a scheme like call-with-current-continuation
(call/cc) in common lisp.  Graham gives some macros which implement a
restricted form of call/cc.  Now i have a couple of questions:

1) Are there cl implemetations which directly support call/cc?

2) Graham states that call/cc can be supported in cl by making use of a
code walker which transforms a program in CPS style.  Is there such a
code walker in cl publicly availiable?

3) Are there thechnical (implementation) reasons why cl does not
directly support call/cc?

4) Scheme implemetations with c runtime support often rely on the c
runtime to implement call/cc.  Would something like this be possible in
cl also?


thanks,

Marc


-- 
------------------------------------------------------------------------------
email: marc dot hoffmann at users dot whh dot wau dot nl
------------------------------------------------------------------------------

From: Stig Hemmer
Subject: Re: continuations and cl
Date: 
Message-ID: <ekv7lg7czsx.fsf@verden.pvv.ntnu.no>
······@No-Such-Domain.anywhere (see.signature) writes:
> when reading "On Lips" by P. Graham, i was wondering about the
> implementation of a scheme like call-with-current-continuation
> (call/cc) in common lisp.  Graham gives some macros which implement a
> restricted form of call/cc.  Now i have a couple of questions:

which I'll ignore since other people have answered them.

Graham uses these continuations to implement a Prolog compiler.

Personally, I prefer the Prolog implementations in Peter Norvigs book
"Paradigms of AI Programming: Case Studies in Common Lisp" (PAIP),
none of which uses continuations but rather uses more Prolog-specific
data structures.

Both the interpreter and compiler in PAIP are (IMHO) much easier to
read than Grahams.  The compiler produces fairly human-readable Lisp
output, which looks to my untrained eye as if it should compile well.
Grahams produces a human-unreadable mess in CPS which I doubt compiles
well at all.  (Mind you, these are severly uneducated guesses)

Anyway, take a look at PAIP, for this and other reasons.  The book is
a treasure chest of Lisp lore.

Stig Hemmer,
Jack of a Few Trades.
From: Fernando D. Mato Mira
Subject: Re: continuations and cl
Date: 
Message-ID: <38A81313.3E7F815C@iname.com>
"see.signature" wrote:

> 4) Scheme implemetations with c runtime support often rely on the c
> runtime to implement call/cc.

Yeah. And they also rely on malloc to allocate objects. Give me a break (or a
setjump).


--
Fernando D. Mato Mira
Real-Time SW Eng & Networking
Advanced Systems Engineering Division
CSEM
Jaquet-Droz 1                   email: matomira AT acm DOT org
CH-2007 Neuchatel                 tel:       +41 (32) 720-5157
Switzerland                       FAX:       +41 (32) 720-5720

www.csem.ch      www.vrai.com     ligwww.epfl.ch/matomira.html
From: Joe Marshall
Subject: Re: continuations and cl
Date: 
Message-ID: <yAVp4.30191$vi4.77173@dfw-read.news.verio.net>
see.signature <······@No-Such-Domain.anywhere> wrote in message
·························@Flex111.dNWL.WAU.NL...
> Hi Lipsers,
>
> when reading "On Lips" by P. Graham, i was wondering about the
> implementation of a scheme like call-with-current-continuation
> (call/cc) in common lisp.  Graham gives some macros which implement a
> restricted form of call/cc.  Now i have a couple of questions:
>
> 1) Are there cl implemetations which directly support call/cc?

I would be surprised to see a compliant CL implementation that
directly supported call-with-current-continuation.

> 2) Graham states that call/cc can be supported in cl by making use of a
> code walker which transforms a program in CPS style.  Is there such a
> code walker in cl publicly availiable?

Check out what Graham says a bit more closely.  If you do a CPS conversion,
you can support a general call-with-current-continuation, however, you have
to convert *all* the code, including library functions, third-party code,
etc.
to make it work.  It wouldn't be practical.

> 3) Are there thechnical (implementation) reasons why cl does not
> directly support call/cc?

call-with-current-continuation is hard to implement efficiently.  The
primary use of
call-with-current-continuation is to model complicated control flow, and CL
already has a rich set of control flow constructs: catch/throw, signal,
condition-bind, block/return-from, go, etc.  Most common lisps have ways
of doing multitasking and co-routines as well.

> 4) Scheme implemetations with c runtime support often rely on the c
> runtime to implement call/cc.  Would something like this be possible in
> cl also?

Scheme implementations that rely on setjmp for
call-with-current-continuation
don't implement full continuations.  You could use catch and throw in CL to
get the same sort of functionality.

Why do you want call-with-current-continuation in CL?
From: see.signature
Subject: Re: continuations and cl
Date: 
Message-ID: <slrn8agdmf.1q0.anyone@Flex111.dNWL.WAU.NL>
On Mon, 14 Feb 2000 10:56:13 -0500, Joe Marshall
<·········@alum.mit.edu> wrote:
>
>Why do you want call-with-current-continuation in CL?
>

I was asking out of curiosity.  I first started learning scheme and
thought it was very handy to have call/cc and was then surprised that
cl does not have it.  In different lisp books "sort of" call/cc
solutions are described ( On Lips, Artificial Intelligence Programming
by Charniak, Riebeck, McDermott...).  So I was wondering why call/cc is
not implemented.  I can imagine certain implementation reasons, but i
don't know a lot about these subjects.

yours sincerely, 

Marc


-- 
------------------------------------------------------------------------------
email: marc dot hoffmann at users dot whh dot wau dot nl
------------------------------------------------------------------------------
From: Erik Naggum
Subject: Re: continuations and cl
Date: 
Message-ID: <3159560513225052@naggum.no>
* Marc Hoffman
| So I was wondering why call/cc is not implemented.

  because the Common Lisp crowd doesn't want you to implement manually all
  the control flow mechanisms that CALL/CC is used to implement, and that
  is because there is no desire to pare the language down to "essentials"
  or Scheme's ascetic/anorectic notions of "elegance".

  I think CALL/CC is on par with giving people access to the basic building
  blocks of a function call, without actual support for function calls.
  sure, you _can_ do a lot of nifty stuff with those building blocks, but
  _should_ you?  "because I can" is seldom a good answer.

#:Erik
From: Barry Margolin
Subject: Re: continuations and cl
Date: 
Message-ID: <T3Xp4.17$EI5.2005@burlma1-snr2>
In article <·····················@Flex111.dNWL.WAU.NL>,
see.signature <see.signature> wrote:
>I was asking out of curiosity.  I first started learning scheme and
>thought it was very handy to have call/cc and was then surprised that
>cl does not have it.  In different lisp books "sort of" call/cc
>solutions are described ( On Lips, Artificial Intelligence Programming
>by Charniak, Riebeck, McDermott...).  So I was wondering why call/cc is
>not implemented.  I can imagine certain implementation reasons, but i
>don't know a lot about these subjects.

Common Lisp and Scheme were designed for different purposes.  Scheme is
intended to be a small, elegant language; it provides a few primitive
features out of which more complex features can be implemented.  CL
provides many advanced features directly, and often doesn't provide direct
access to the low-level facilities.  CL gives more lattitude to the
implementor to provide these advanced features in optimal ways, rather than
requiring implementation techniques based on specific low-level features.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Marco Antoniotti
Subject: Re: continuations and cl
Date: 
Message-ID: <lw1z6e98zw.fsf@parades.rm.cnr.it>
Barry Margolin <······@bbnplanet.com> writes:

> In article <·····················@Flex111.dNWL.WAU.NL>,
> see.signature <see.signature> wrote:
> >I was asking out of curiosity.  I first started learning scheme and
> >thought it was very handy to have call/cc and was then surprised that
> >cl does not have it.  In different lisp books "sort of" call/cc
> >solutions are described ( On Lips, Artificial Intelligence Programming
> >by Charniak, Riebeck, McDermott...).  So I was wondering why call/cc is
> >not implemented.  I can imagine certain implementation reasons, but i
> >don't know a lot about these subjects.
> 
> Common Lisp and Scheme were designed for different purposes.  Scheme is
> intended to be a small, elegant language; it provides a few primitive
> features out of which more complex features can be implemented.
                       ^                     ^
                all the missing     (defstruct, multidimensional arrays,etc)

I guess the insertions are necessary. :)

Cheers

-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa
From: Joe Marshall
Subject: Re: continuations and cl
Date: 
Message-ID: <YFWp4.30217$vi4.77877@dfw-read.news.verio.net>
see.signature <······@No-Such-Domain.anywhere> wrote in message
··························@Flex111.dNWL.WAU.NL...
> On Mon, 14 Feb 2000 10:56:13 -0500, Joe Marshall
> <·········@alum.mit.edu> wrote:
> >
> >Why do you want call-with-current-continuation in CL?
> >
>
> I was asking out of curiosity.  I first started learning scheme and
> thought it was very handy to have call/cc and was then surprised that
> cl does not have it.  In different lisp books "sort of" call/cc
> solutions are described ( On Lips, Artificial Intelligence Programming
> by Charniak, Riebeck, McDermott...).  So I was wondering why call/cc is
> not implemented.  I can imagine certain implementation reasons, but i
> don't know a lot about these subjects.

Implementing call-with-current-continuation basically involves copying
the stack.  (Or doing away with the stack altogether and keeping
activation records in the heap.)  While it's true that
call-with-current-continuation
is handy, and you can use it to implement all the control flow constructs
in CommonLisp, there are more efficient implementation techniques
that rely on the fact that Common Lisp continuations are upward-only
and (mostly) non-reentrant.

There were some interesting papers on efficient implementation of
call-with-current-continuation in Lisp.  Stallman wrote something about
`phantom stacks' and Steele wrote about `macaroni stacks' (a pun on
InterLisp's spaghetti stacks).
From: Andrew Cooke
Subject: Re: continuations and cl
Date: 
Message-ID: <88b351$p2$1@nnrp1.deja.com>
In article <····················@Flex111.dNWL.WAU.NL>,
  see.signature wrote:
> Hi Lipsers,
>
> when reading "On Lips" by P. Graham, i was wondering about the
> implementation of a scheme like call-with-current-continuation
> (call/cc) in common lisp.  Graham gives some macros which implement a
> restricted form of call/cc.  Now i have a couple of questions:

You may be interested in Norvig's book, which gives a Prolog compiler
that doesn't use continuations.

While I enjoyed Graham's book I found that section much harder to
understand than Norvig's approach (but then I'm a newbie).

Andrew

PS Thanks for asking those questions - I was curious too.


Sent via Deja.com http://www.deja.com/
Before you buy.