Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
call/cc in lisp
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Masoud Pirnazar  
View profile  
 More options Sep 21 2001, 8:34 pm
Newsgroups: comp.lang.lisp
From: "Masoud Pirnazar" <amp.xnos...@apptek.com>
Date: 22 Sep 2001 00:34:51 GMT
Local: Fri, Sep 21 2001 8:34 pm
Subject: call/cc in lisp
is there an equivalent of the scheme call/cc (continuations) for lisp?
(maybe some libraries that provide similar functionality?)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Sep 21 2001, 11:55 pm
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: Sat, 22 Sep 2001 03:54:30 GMT
Local: Fri, Sep 21 2001 11:54 pm
Subject: Re: call/cc in lisp

"Masoud Pirnazar" <amp.xnos...@apptek.com> writes:
> is there an equivalent of the scheme call/cc (continuations) for lisp?
> (maybe some libraries that provide similar functionality?)

No.  CATCH and THROW are the closest you'll get.  Lisp continuations have
dynamic, not indefinite extent.  And they are not reentrant.

A compatibility library for this would be extremely hard to arrange because
it would probably involves transforming ALL relevant code to use Continuation
Passing Style (CPS) in order that continuations would become manifestly
manipulable objects.  Further, in the process of doing this, you'd have to
develop a model of what happened to special variables and UNWIND-PROTECT
and other dynamic effects.  Even Scheme does not have a good theory of
how call/cc and unwind-protect interact--they just hide it by not offering
unwind-protect and claiming that it is left as an exercise to the user.
The truth is that unwind-protect is a mess in the presence of call/cc.
And given the choice between the two, I'd pick unwind-protect any day.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruce Hoult  
View profile  
 More options Sep 22 2001, 2:58 am
Newsgroups: comp.lang.lisp
From: Bruce Hoult <br...@hoult.org>
Date: Sat, 22 Sep 2001 18:58:33 +1200
Local: Sat, Sep 22 2001 2:58 am
Subject: Re: call/cc in lisp
In article <sfwwv2rubgp....@world.std.com>, Kent M Pitman

All the above about Common Lisp also applies to Dylan, which is in most
other semantic respects closer to Scheme than to CL (plus CLOS, of
course).

Dylan unifies the concepts of conditions and restarts -- both have
calling semantics -- and uses macros to build the high level exception
handling facilities on top of conditions/restarts, lexical closures, and
escape functions (one-shot continuations that are valid only until the
creating environment exits).

The other main use for continuations is to build co-routines.  Dylan
intends you to use the OS's (or runtime library's) threads package for
that.  I guess this is probably also the case in Common Lisp.

-- Bruce


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Per Bothner  
View profile  
 More options Sep 23 2001, 11:40 am
Newsgroups: comp.lang.lisp
From: Per Bothner <p...@bothner.com>
Date: Sun, 23 Sep 2001 08:33:09 -0700
Local: Sun, Sep 23 2001 11:33 am
Subject: Re: call/cc in lisp

Kent M Pitman wrote:
> Even Scheme does not have a good theory of
> how call/cc and unwind-protect interact--they just hide it by not offering
> unwind-protect and claiming that it is left as an exercise to the user.

R5RS has 'dynamic-wind' which is a generalizationm of unwind-protect.
(It takes an extra parameter whiich is a function called when the
body is re-entered.)  However, there does appears to be some problems
with dynamic-wind, and I understand the definition in R5RS is bad.
(I don't know the specifics.)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
"Frank Goenninger"  
View profile  
 More options Sep 23 2001, 2:25 pm
Newsgroups: comp.lang.lisp
From: frank_goennin...@goenninger.com ("Frank Goenninger")
Date: 23 Sep 2001 20:25:19 +0200
Local: Sun, Sep 23 2001 2:25 pm
Subject: Re: call/cc in lisp

Hi Masoud!

"Masoud Pirnazar" <amp.xnos...@apptek.com> writes:
> is there an equivalent of the scheme call/cc (continuations) for lisp?
> (maybe some libraries that provide similar functionality?)

AFAIK the closest thing to what you are looking for (with an
explanation of limitations and differences) is given in "On Lisp",
by Paul Graham, published by Prentice-Hall, Inc. under
ISBN 0-13-030552-9. See chapter 20, Continuations.

It might be difficult to get hold of a copy of this book, though.
It was out of print.

HTH.

Frank


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Sletten  
View profile  
 More options Sep 23 2001, 3:33 pm
Newsgroups: comp.lang.lisp
From: David Sletten <slytob...@home.com>
Date: Sun, 23 Sep 2001 19:33:15 GMT
Local: Sun, Sep 23 2001 3:33 pm
Subject: Re: call/cc in lisp

Masoud Pirnazar wrote:
> is there an equivalent of the scheme call/cc (continuations) for lisp?
> (maybe some libraries that provide similar functionality?)

Peter Norvig discusses the issue in chapters 22, 23 of PAIP

David Sletten


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Sep 23 2001, 3:35 pm
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: Sun, 23 Sep 2001 19:34:56 GMT
Local: Sun, Sep 23 2001 3:34 pm
Subject: Re: call/cc in lisp

Per Bothner <p...@bothner.com> writes:
> Kent M Pitman wrote:

> > Even Scheme does not have a good theory of
> > how call/cc and unwind-protect interact--they just hide it by not offering
> > unwind-protect and claiming that it is left as an exercise to the user.

> R5RS has 'dynamic-wind' which is a generalizationm of unwind-protect.
> (It takes an extra parameter whiich is a function called when the
> body is re-entered.)  However, there does appears to be some problems
> with dynamic-wind, and I understand the definition in R5RS is bad.
> (I don't know the specifics.)

There was recent discussion of dynamic-wind, and I'm convinced there are
some problems with it, but those problems are orthogonal to the issue at
hand.

dynamic-wind serves a completely different need than unwind-protect.

Pushed over the edge by having to speak on this complicated issue for the
n-millionth time, I've added my position on this to my personal faq
so that I can just allude to it in the future.

 http://world.std.com/~pitman/pfaq/unwind-protect-vs-continuations.html

By the way, the world.std.com server is performing VERY badly of late, so
if you pull this up, be very patient.  (sigh)

Also, I dashed the article out rather hastily and did not really
proofread it well.  It may contain typos, etc.  I'll fix them later
when I have more time.  Running spellcheck on stuff containing code is
more tedious than I can bear right now.  I just wanted to get the
basic framework laid out for now.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Sep 23 2001, 3:39 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Sun, 23 Sep 2001 19:38:34 GMT
Local: Sun, Sep 23 2001 3:38 pm
Subject: Re: call/cc in lisp
* Per Bothner <p...@bothner.com>

> R5RS has 'dynamic-wind' which is a generalizationm of unwind-protect.

  Kent Pitman has shown that the two mechanisms are orhogonal.  I do not
  buy the line that dynamic-wind can implement unwind-protect properly.
  Could you show us how it can?

///
--
  Why did that stupid George W. Bush turn to Christian fundamentalism to
  fight Islamic fundamentalism?  Why use terms like "crusade", which only
  invokes fear of a repetition of that disgraceful period of Christianity
  with its _sustained_ terrorist attacks on Islam?  He is _such_ an idiot.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob Warnock  
View profile  
 More options Sep 23 2001, 9:37 pm
Newsgroups: comp.lang.lisp
Followup-To: comp.lang.lisp
From: r...@rigden.engr.sgi.com (Rob Warnock)
Date: 24 Sep 2001 01:37:37 GMT
Local: Sun, Sep 23 2001 9:37 pm
Subject: Re: call/cc in lisp
Erik Naggum  <e...@naggum.net> wrote:
+---------------
| * Per Bothner <p...@bothner.com>
| > R5RS has 'dynamic-wind' which is a generalizationm of unwind-protect.
|
|   Kent Pitman has shown that the two mechanisms are orhogonal.  I do not
|   buy the line that dynamic-wind can implement unwind-protect properly.
|   Could you show us how it can?
+---------------

Indeed, the last time this came up (back in May?), I believe I showed
in <URL:news:9e00uc$915mi$1@fido.engr.sgi.com> that R5RS "dynamic-wind"
specifically *lacks* the ability to emulate UNWIND-PROTECT, since in CL
the cleanup form is allowed to THROW (provided it's to a context further
up the stack than the target of the current non-local exit, see CLHS 5.2
and 5.3->THROW), whereas in R5RS the "after" form is not:

        6.4 Control features
        ...
        (dynamic-wind before thunk after)
        ...
        The effect of using a captured continuation to enter or exit the
        dynamic extent of a call to "before" or "after" is undefined.

But even more important was the observation that:

    ...there is no guarantee anywhere in R5RS that "signalling an error"
    interacts in any way with dynamic-wind!! At most an implementation
    is required to "detect and report" certain errors, but it's not
    required to do this by calling a continuation captured with call/cc
    in the top-level REPL (albeit that's one "obvious" implementation),
    and thus it's not required to execute any "after" thunks in any
    active dynamic-winds.

    This means that R5RS call/cc + dynamic-wind are inadequate to
    implement a portable exception-handling system.

Q.E.D.

-Rob

-----
Rob Warnock, 30-3-510           <r...@sgi.com>
SGI Network Engineering         <http://reality.sgi.com/rpw3/>
1600 Amphitheatre Pkwy.         Phone: 650-933-1673
Mountain View, CA  94043        PP-ASEL-IA

[Note: aaanal...@sgi.com and zedwa...@sgi.com aren't for humans ]  


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »