From f6b9265f77226eccf8a40138e16723c582228af1 Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Mon, 14 Sep 2009 21:42:59 +0000 Subject: [PATCH] add some examples for the control operators svn: r16013 --- .../scribblings/reference/control-lib.scrbl | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/collects/scribblings/reference/control-lib.scrbl b/collects/scribblings/reference/control-lib.scrbl index 1729afc1ca..6676148825 100644 --- a/collects/scribblings/reference/control-lib.scrbl +++ b/collects/scribblings/reference/control-lib.scrbl @@ -6,6 +6,11 @@ @note-lib-only[scheme/control] +@(define control-eval + (let ([the-eval (make-base-eval)]) + (the-eval '(require scheme/control)) + the-eval)) + The @scheme[scheme/control] library provides various control operators from the research literature on higher-order control operators, plus a few extra convenience forms. These control operators are implemented @@ -27,6 +32,12 @@ That is, @scheme[(abort v ...)] is equivalent to (abort-current-continuation (default-continuation-prompt-tag) (lambda () (values v ...))) +] + +@examples[#:eval control-eval +(prompt + (printf "start here\n") + (printf "answer is ~a\n" (+ 2 (abort 3)))) ]} @; ---------------------------------------------------------------------- @@ -49,7 +60,16 @@ The essential reduction rules are: ] When @scheme[handler-expr] is omitted, @scheme[%] is the same as -@scheme[prompt].} +@scheme[prompt]. + +@examples[#:eval control-eval +(% (+ 2 (fcontrol 5)) + (lambda (v k) + (k v))) +(% (+ 2 (fcontrol 5)) + (lambda (v k) + v)) +]} @; ---------------------------------------------------------------------- @@ -223,3 +243,5 @@ In this library, @scheme[new-prompt] is an alias for @scheme[prompt0-at], and @scheme[cupto] is an alias for @scheme[control0-at]. } + +@close-eval[control-eval]