Document the default prompt tag in TR

Note: this isn't the ideal location for this in the long
run because it isn't a special form. When we have more
bindings like this, we should move them to a new manual
section.

original commit: ffde8ec486abec4741e4d0299f841dcbfe65a3f2
This commit is contained in:
Asumu Takikawa 2012-12-03 11:58:46 -05:00
parent d5a89d5cff
commit 24842684da

View File

@ -13,17 +13,25 @@
(examples #:eval the-top-eval . args))
@(define-syntax-rule (def-racket for-id for*-id with-handlers-id mod-beg-id lambda-id λ-id define-id)
@(define-syntax-rule (def-racket for-id for*-id with-handlers-id
default-continuation-prompt-tag-id
mod-beg-id lambda-id λ-id define-id)
(begin
(require (for-label (only-in racket/base for for* with-handlers #%module-begin lambda λ define)))
(require (for-label (only-in racket/base for for* with-handlers
default-continuation-prompt-tag
#%module-begin lambda λ define)))
(define for-id (racket for))
(define for*-id (racket for*))
(define mod-beg-id (racket #%module-begin))
(define with-handlers-id (racket with-handlers))
(define default-continuation-prompt-tag-id
(racket default-continuation-prompt-tag))
(define lambda-id (racket lambda))
(define λ-id (racket λ))
(define define-id (racket define))))
@(def-racket for-id for*-id with-handlers-id mod-beg-id lambda-id λ-id define-id)
@(def-racket for-id for*-id with-handlers-id
default-continuation-prompt-tag-id
mod-beg-id lambda-id λ-id define-id)
@title[#:tag "special-forms"]{Special Form Reference}
@ -436,6 +444,33 @@ Note that unlike @|define-id|, @racket[define] does not bind functions with keyw
to static information about those functions.
}
@defproc[(default-continuation-prompt-tag) (-> (Prompt-Tagof Any (Any -> Any)))]{
Identical to @|default-continuation-prompt-tag-id|, but additionally protects
the resulting prompt tag with a contract that wraps
higher-order values, such as functions, that are communicated with that
prompt tag. If the wrapped value is used in untyped code, a contract error
will be raised.
@ex[
(module typed typed/racket
(provide do-abort)
(: do-abort (-> Void))
(define (do-abort)
(abort-current-continuation
(code:comment "typed, and thus contracted, prompt tag")
(default-continuation-prompt-tag)
(λ: ([x : Integer]) (+ 1 x)))))
(module untyped racket
(require 'typed)
(call-with-continuation-prompt
(λ () (do-abort))
(default-continuation-prompt-tag)
(code:comment "the function cannot be passed an argument")
(λ (f) (f 3))))
(require 'untyped)
]
}
@defform[(#%module-begin form ...)]{
Legal only in a @rtech{module begin context}.