commit 6229f725df48903f245d8f107085f342f769f15d parent a847663f2d41c29da2ce4cf74479b5a93356c46c Author: Danny Yoo <dyoo@cs.wpi.edu> Date: Wed, 15 Jun 2011 15:34:39 -0400 added example of making an evaluator for interaction original commit: e35e005a1c833bdc70a76bf1ffe2e6720b881675 Diffstat:
| M | collects/scribblings/scribble/eval.scrbl | | | 18 | ++++++++++++++++++ |
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/collects/scribblings/scribble/eval.scrbl b/collects/scribblings/scribble/eval.scrbl @@ -25,6 +25,24 @@ set to @racket['string]. If @racket[eval] is not provided, an evaluator is created using @racket[make-base-eval]. See also @racket[make-eval-factory]. +As an example, +@codeblock|{ +#lang scribble/manual +@(require racket/sandbox + scribble/eval) +@(define my-evaluator + (parameterize ([sandbox-output 'string] + [sandbox-error-output 'string]) + (make-evaluator 'typed/racket/base))) +@interaction[#:eval my-evaluator + + (: my-sqr (Real -> Real)) + (define (my-sqr x) + (* x x)) + (my-sqr 42)] +}| +uses an evaluator whose language is @racketmodname[typed/racket/base]. + If the value of @racket[current-print] in the sandbox is changed from its default value, or if @racket[print-as-expression] in the sandbox is set to @racket[#f], then each evaluation result is formatted to a