unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andreas Rottmann <a.rottmann@gmx.at>
To: David Kastrup <dak@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: Non-stack-copying call-with-current-continuation?
Date: Sat, 03 Mar 2012 06:03:34 +0100	[thread overview]
Message-ID: <87y5riwa1l.fsf@rotty.yi.org> (raw)
In-Reply-To: <87ehtbe6vx.fsf@fencepost.gnu.org> (David Kastrup's message of "Fri, 02 Mar 2012 09:36:50 +0100")

David Kastrup <dak@gnu.org> writes:

> Noah Lavine <noah.b.lavine@gmail.com> writes:
>
>> Hello,
>>
>>> Sure, but things like gensym and make-prompt-tag (and (list '()) for
>>> creating an eq?-unique object) are artificial hygiene coming at a cost
>>> in symbol table and symbol generation time rather than "lexical"
>>> hygiene.  They need _extra_ work, whereas the
>>> call-with-current-continuation approach needed _less_ work.  Basically I
>>> want something like call-with-single-continuation that will only allow
>>> one return (and any dynwind out counts and should work if it is the
>>> first, so it is not exactly equivalent to using
>>> with-continuation-barrier) and come without the stack-copying cost of
>>> call-with-current-continuation.
>>
>> I agree that it's not pretty. We have hygienic macros so we don't have
>> to use gensym, after all. But I don't know of a better way.
>
> Well, to wrap this up: the manual (not current) states
>
>     It is traditional in Scheme to implement exception systems using
>     `call-with-current-continuation'.  Continuations (*note
>     Continuations::) are such a powerful concept that any other control
>     mechanism -- including `catch' and `throw' -- can be implemented in
>     terms of them.
>
> [...]
>
>        The more targeted mechanism provided by `catch' and `throw' does not
>     need to save and restore the C stack because the `throw' always jumps
>     to a location higher up the stack of the code that executes the
>     `throw'.  Therefore Guile implements the `catch' and `throw' primitives
>     independently of `call-with-current-continuation', in a way that takes
>     advantage of this _upwards only_ nature of exceptions.
>
>
> I think that using something like "call-with-single-continuation" as the
> underlying primitive would make Guile quite more similar to
> "traditional" systems in the code base.  It would also provide a
> minimally-invasive tool for tuning existing code based on
> call-with-current-continuation in case that the stack copying semantics
> are _not_ required.  Definitely more Schemeish than stuff like, uh,
> prompts?
>
Just to throw my two cents in: Racket (and probably other Schemes)
provide this primitive under the name call-with-escape-continuation
(call/ec):

http://docs.racket-lang.org/reference/cont.html?q=call/ec#%28def._%28%28quote._~23~25kernel%29._call-with-escape-continuation%29%29

Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.yi.org/>



  reply	other threads:[~2012-03-03  5:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-02  0:00 Non-stack-copying call-with-current-continuation? David Kastrup
2012-03-02  0:20 ` Noah Lavine
2012-03-02  0:42   ` David Kastrup
2012-03-02  1:01     ` Noah Lavine
2012-03-02  1:35       ` David Kastrup
2012-03-02  1:49         ` Noah Lavine
2012-03-02  8:36           ` David Kastrup
2012-03-03  5:03             ` Andreas Rottmann [this message]
2012-03-03  5:04             ` Andreas Rottmann
2012-03-03 17:48         ` Andy Wingo
2012-03-04 12:01           ` David Kastrup
2012-03-04 12:15             ` Andy Wingo
2012-03-04 13:59               ` David Kastrup
2012-03-04 18:42                 ` Andy Wingo
2012-03-04 18:45                 ` Mark H Weaver
2012-03-04 23:13                   ` David Kastrup
2012-03-05  0:35                     ` Mark H Weaver
2012-03-05  1:44                       ` David Kastrup
2012-03-02  1:18 ` Nala Ginrut
2012-03-02  1:25   ` Noah Lavine
2012-03-03 17:41 ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y5riwa1l.fsf@rotty.yi.org \
    --to=a.rottmann@gmx.at \
    --cc=dak@gnu.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).