[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Procedure proposal: call-with-escape-procedure
From: |
Martin Grabmueller |
Subject: |
Re: Procedure proposal: call-with-escape-procedure |
Date: |
Mon, 5 Mar 2001 15:18:17 +0100 (MET) |
> From: Marius Vollmer <address@hidden>
> Date: 03 Mar 2001 17:44:53 +0100
>
> Martin, could you try to summarize what other Scheme implementations
> do? Call/ec (which is actually called
> call-with-escaping-continuation, I think) should not really be
> uncommon.
[I noticed (too late, of course) that I should've either written
call-with-escape-procedure or call/ep]
Okay, here we go:
The following implementations do not seem to have something like
call/ec (at least I didn't find anything in the online documentation):
- Gambit
- Elk
- Kawa
- MIT Scheme
- RScheme
- Scheme 48 (broken links, so couldn't get any documentation)
- SIOD
- Twobit/Larceny
The following implementations implement something like call/ec, with a
slight favor of call/ec, and two other idioms.
MzScheme:
[http://www.cs.rice.edu/CS/PLT/packages/doc/mzscheme/node86.htm]
In addition to regular call/cc, MzScheme provides
call-with-escape-continuation (or call/ec) and let/ec. A continuation
obtained from call/ec can only be used to escape back to the
continuation; i.e., an escape continuation is only valid when the
current continuation is an extension of the escape continuation. The
application of call/ec's argument is not a tail call.
Escape continuations are provided for two reasons: 1) they are
significantly cheaper than full continuations; and 2) full
continuations are not allowed to cross certain boundaries (e.g., error
handling) that escape continuations can safely cross.
Bigloo:
[http://kaolin.unice.fr/~serrano/bigloo/Doc/bigloo.html#SEC36]
bigloo syntax: bind-exit escape body
This form provides an escape operator facility. bind-exit
evaluates the body, which may refer to the variable escape which
will denote an "escape function" of one argument: when called,
this escape function will return from the bind-exit form with the
given argument as the value of the bind-exit form. The escape can
only be used while in the dynamic extent of the form. Bindings
introduced by bind-exit are immutable.
(bind-exit (exit)
(for-each (lambda (x)
(if (negative? x)
(exit x)))
'(54 0 37 -3 245 19))
#t) => -3
Chez Scheme:
[http://www.scheme.com/csug/control.html#g1805]
call/1cc obtains its continuation and passes it to procedure, which
must accept one argument. The continuation itself is represented by a
procedure. This procedure normally takes one argument but may take an
arbitrary number of arguments depending upon whether the context of
the call to call/1cc expects multiple return values or not. When this
procedure is applied to a value or values, it returns the values to
the continuation of the call/1cc application.
The continuation obtained by call/1cc is a "one-shot continuation." It
is an error to return to a one-shot continuation, either by invoking
the continuation or returning normally from procedure more than
once. A one-shot continuation is "promoted" into a normal (multishot)
continuation, however, if it is still active when a normal
continuation is obtained by call/cc. After a one-shot continuation is
promoted into a multishot continuation, it behaves exactly as if it
had been obtained via call/cc. This allows call/cc and call/1cc to be
used together transparently in many applications.
Pocket Scheme:
[http://www.mazama.net/scheme/pscmref.htm]
In addition to the conventional Scheme reentrant continuations, Pocket
Scheme also supports a cheaper, weaker flavor of continuation, the
escape continuations of Rice University's MZScheme implementation. An
escape continuation (also known as a "weak" continuation) is valid
only for the duration of its dynamic extent, and can be used only to
escape to the context of its creation. Escape continuations are much
cheaper to create than regular reentrant continuations. To bind an
escape continuation, use the call-with-escape-continuation function
(abbreviated call/ec) in just the fashion that you would use call/cc.
Seems like there's no consensus here -- but that's no surprise, is it?
Regards,
'martin
- Procedure proposal: call-with-escape-procedure, Martin Grabmueller, 2001/03/02
- Re: Procedure proposal: call-with-escape-procedure, Marius Vollmer, 2001/03/03
- Re: Procedure proposal: call-with-escape-procedure, Marius Vollmer, 2001/03/03
- Re: Procedure proposal: call-with-escape-procedure,
Martin Grabmueller <=
- Re: Procedure proposal: call-with-escape-procedure, Marius Vollmer, 2001/03/05
- Re: Procedure proposal: call-with-escape-procedure, Marius Vollmer, 2001/03/05
- Re: Procedure proposal: call-with-escape-procedure, Martin Grabmueller, 2001/03/06
- Re: Procedure proposal: call-with-escape-procedure, Marius Vollmer, 2001/03/06
- Re: Procedure proposal: call-with-escape-procedure, Martin Grabmueller, 2001/03/06
- Re: Procedure proposal: call-with-escape-procedure, Marius Vollmer, 2001/03/06
- Re: Procedure proposal: call-with-escape-procedure, Miroslav Silovic, 2001/03/06
- Re: Procedure proposal: call-with-escape-procedure, Marius Vollmer, 2001/03/06
- Re: Procedure proposal: call-with-escape-procedure, Miroslav Silovic, 2001/03/07
- Re: Procedure proposal: call-with-escape-procedure, Marius Vollmer, 2001/03/07