unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Zefram <zefram@fysh.org>
To: 21894@debbugs.gnu.org
Subject: bug#21894: escape continuation doc wrong about reinvokability
Date: Thu, 12 Nov 2015 23:27:42 +0000	[thread overview]
Message-ID: <20151112232742.GA19689@fysh.org> (raw)

The manual says

#                  Escape continuations are delimited continuations whose
# only use is to make a non-local exit--i.e., to escape from the current
# continuation.  Such continuations are invoked only once, and for this
# reason they are sometimes called "one-shot continuations".

O RLY?

scheme@(guile-user)> (use-modules (ice-9 control))
scheme@(guile-user)> (define cc #f)
scheme@(guile-user)> (list 'a (let/ec e (list 'b (e (call-with-current-continuation (lambda (c) (set! cc c) 0))))))
$1 = (a 0)
scheme@(guile-user)> (cc 1)
$2 = (a 1)
scheme@(guile-user)> (cc 2)
$3 = (a 2)

Clearly I have invoked this escape continuation, successfully, more
than once.  The semantics here are perfectly sensible, it's just
the documentation that's off the mark, because it ignores how escape
continuations interact with other kinds of continuation.  I suggest
changing "Such continuations are invoked only once" sentence to something
like

    Such continuations can only be invoked from within the dynamic
    extent of the call to which they will jump.  Because the jump
    ends that extent, if escape continuations are the only kind of
    continuations being used it is only possible to invoke an escape
    continuation at most once.  For this reason they are sometimes
    called "one-shot continuations", but that is a misnomer when other
    kinds of continuations are also in use.  Most kinds can reinstate a
    dynamic extent that has been exited, and if the extent of an escape
    continuation is reinstated then it can be invoked again to exit that
    extent again.  Conversely, an escape continuation cannot be invoked
    from a separate thread that has its own dynamic state not including
    the continuation's extent, even if the continuation's extent is
    still in progress in its original thread and the continuation has
    never been invoked.

-zefram





             reply	other threads:[~2015-11-12 23:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 23:27 Zefram [this message]
2016-06-24 16:20 ` bug#21894: escape continuation doc wrong about reinvokability 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=20151112232742.GA19689@fysh.org \
    --to=zefram@fysh.org \
    --cc=21894@debbugs.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).