You are looking at historical revision 28915 of this page. It may differ significantly from its current revision.
continuations
This module provides some syntactic sugar to Marc Feeley's continuation interface. In this interface, continuations are a datatype separate from procedures. Hence it provides a continuation? predicate. I've stripped the prefix from the procedures continuation-capture and continuation-graft and renamed continuation-return throw. This latter procedure is accompanied in this module by a macro named catch, so that the usual catch-throw-semantics of other languages is available. For example, a typical use pattern of this module is as follows
(catch k
...
(if ...
(throw k val)
...))
But note, that in this pattern, k is a Scheme object of type continuation, and like every Scheme object it has indefinite extent, hence can be exported, saved in other data-structures etc. So this pattern is much more powerful than the corresponding pattern in other languages.
Two other procedures are provided as well, continuation->procedure, which does what the name says, and continuations, which provides offline documentation to the module. Like in modules written in the design-by-contract style, the call (continuations) lists the exported symbols, and (continuations sym) provides documentation of the exported symbol sym.
The routines
continuations
[procedure] (continuations [sym])documentation procedure
continuation?
[procedure] (continuation? xpr)type predicate
continuation->procedure
[procedure] (continuation->procedure cont)transforms a continuation into a procedure
capture
[procedure] (capture proc)The same as call/cc but with a different datatype: Captures the current continuation as a continuation datatype (contrary to a procedure datatype in call/cc) and calls proc with that continuation as its only argument.
graft
[procedure] (graft cont thunk)tail-calls thunk with the implicit continuation cont.
throw
[procedure] (throw cont . vals)throws the values vals to the continuation cont.
catch
[syntax] (catch cont xpr . xprs)The same as let/cc of miscmacros but with a different datatype: Binds the cont variable to the current continuation as a continuation and executes the body xpr . xprs in this context.
Requirements
none
Last update
May 25, 2013
Author
License
Copyright (c) 2013, Juergen Lorenz All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Version History
- 1.0
- initial import