diff --git a/collects/browser/browser.scrbl b/collects/browser/browser.scrbl index f738552d72..fd1b1deae9 100644 --- a/collects/browser/browser.scrbl +++ b/collects/browser/browser.scrbl @@ -16,8 +16,8 @@ @(define-syntax-rule (def-ext id) (begin - (require (for-label net/sendurl)) - (define id (racket send-url)))) + (require (for-label net/sendurl)) + (define id (racket send-url)))) @(def-ext net-send-url) diff --git a/collects/deinprogramm/scribblings/line3d.scrbl b/collects/deinprogramm/scribblings/line3d.scrbl index d55a2bd9d5..da376790e5 100644 --- a/collects/deinprogramm/scribblings/line3d.scrbl +++ b/collects/deinprogramm/scribblings/line3d.scrbl @@ -47,7 +47,7 @@ Zum Beispiel: (define pos (make-vec3 5 5 3)) (define lookat (make-vec3 0 0 0)) (define camera - (create-camera-matrix pos lookat 70.0 screenWidth screenHeight)) + (create-camera-matrix pos lookat 70.0 screenWidth screenHeight)) (code:comment @#,t{render image}) (render-scene screenWidth screenHeight box camera) ] diff --git a/collects/graphics/scribblings/graphics.scrbl b/collects/graphics/scribblings/graphics.scrbl index e000777126..3a547752a2 100644 --- a/collects/graphics/scribblings/graphics.scrbl +++ b/collects/graphics/scribblings/graphics.scrbl @@ -175,17 +175,17 @@ black white, white black, and is otherwise ill-defined). rgb?) "black"]) void?]{ - + Colors the entire contents of @racket[viewport] with @racket[color].} @defproc[((clear-viewport [viewport viewport?])) void?]{ - + Whitens the entire contents of @racket[viewport].} @defproc[((flip-viewport [viewport viewport?])) void?]{ - + @tech{Inverts} the entire contents of @racket[viewport].} @@ -198,7 +198,7 @@ Copies the content of @racket[source] into @racket[dest].} @subsection{Pixels} -@defproc[((draw-pixel [viewport viewport?]) +@defproc[((draw-pixel [viewport viewport?]) [p posn?] [color (or/c (integer-in 0 299) string? @@ -208,13 +208,13 @@ Copies the content of @racket[source] into @racket[dest].} Colors the pixel in @racket[viewport] at @racket[p].} -@defproc[((clear-pixel [viewport viewport?]) +@defproc[((clear-pixel [viewport viewport?]) [p posn?]) void?]{ Whitens the pixel in @racket[viewport] at @racket[p].} -@defproc[((flip-pixel [viewport viewport?]) +@defproc[((flip-pixel [viewport viewport?]) [p posn?]) void?]{ diff --git a/collects/lazy/lazy.scrbl b/collects/lazy/lazy.scrbl index 169b5c7fd4..c6e1007960 100644 --- a/collects/lazy/lazy.scrbl +++ b/collects/lazy/lazy.scrbl @@ -19,16 +19,16 @@ @(define-syntax-rule (defprocthing* mod id ...) (begin - (deflazy mod defprocthing id) - ...)) + (deflazy mod defprocthing id) + ...)) @(define-syntax-rule (defprocthing id . rest) (defthing id procedure? . rest)) @(define-syntax-rule (defidform* mod id ...) (begin - (deflazy mod defidform id) - ...)) + (deflazy mod defidform id) + ...)) @; ---------------------------------------- diff --git a/collects/mzlib/scribblings/cmdline.scrbl b/collects/mzlib/scribblings/cmdline.scrbl index 18b871be75..b409834278 100644 --- a/collects/mzlib/scribblings/cmdline.scrbl +++ b/collects/mzlib/scribblings/cmdline.scrbl @@ -4,8 +4,8 @@ @(define-syntax-rule (intro id) (begin - (require (for-label racket/cmdline)) - (define id (racket command-line)))) + (require (for-label racket/cmdline)) + (define id (racket command-line)))) @(intro racket-command-line) @mzlib[#:mode title cmdline] diff --git a/collects/mzlib/scribblings/etc.scrbl b/collects/mzlib/scribblings/etc.scrbl index 7770ade777..c80f9afd1e 100644 --- a/collects/mzlib/scribblings/etc.scrbl +++ b/collects/mzlib/scribblings/etc.scrbl @@ -13,12 +13,12 @@ @interaction-eval[#:eval etc-eval (require mzlib/etc)] @(begin - (define-syntax-rule (bind id else-id) - (begin - (require (for-label scheme/base)) - (define id (racket lambda)) - (define else-id (racket else)))) - (bind base-lambda base-else)) + (define-syntax-rule (bind id else-id) + (begin + (require (for-label scheme/base)) + (define id (racket lambda)) + (define else-id (racket else)))) + (bind base-lambda base-else)) @mzlib[#:mode title etc] @@ -77,11 +77,11 @@ syntax transformers that share helper functions, though (define-syntax-set (let-current-continuation let-current-escape-continuation) (define (mk call-id) - (lambda (stx) - (syntax-case stx () - [(_ id body1 body ...) - (with-syntax ([call call-id]) - (syntax (call (lambda (id) body1 body ...))))]))) + (lambda (stx) + (syntax-case stx () + [(_ id body1 body ...) + (with-syntax ([call call-id]) + (syntax (call (lambda (id) body1 body ...))))]))) (define let-current-continuation/proc (mk (quote-syntax call/cc))) (define let-current-escape-continuation/proc @@ -156,12 +156,12 @@ corresponding expression are bound to the multiple variables. @examples[ #:eval etc-eval (let+ ([val (values x y) (values 1 2)]) - (list x y)) + (list x y)) (let ([x 1]) - (let+ ([val x 3] - [val y x]) - y)) + (let+ ([val x 3] + [val y x]) + y)) ]} diff --git a/collects/mzlib/scribblings/kw.scrbl b/collects/mzlib/scribblings/kw.scrbl index 607a3aba20..bdd69d9c7f 100644 --- a/collects/mzlib/scribblings/kw.scrbl +++ b/collects/mzlib/scribblings/kw.scrbl @@ -10,11 +10,11 @@ @interaction-eval[#:eval kw-eval (require mzlib/kw)] @(begin - (define-syntax-rule (bind id) - (begin - (require (for-label scheme/base)) - (define id (racket lambda)))) - (bind base-lambda)) + (define-syntax-rule (bind id) + (begin + (require (for-label scheme/base)) + (define id (racket lambda)))) + (bind base-lambda)) @mzlib[#:mode title kw] diff --git a/collects/mzlib/scribblings/match.scrbl b/collects/mzlib/scribblings/match.scrbl index b957907ab7..ff807948f6 100644 --- a/collects/mzlib/scribblings/match.scrbl +++ b/collects/mzlib/scribblings/match.scrbl @@ -6,8 +6,8 @@ @(begin (define-syntax-rule (bind id) (begin - (require racket/match) - (define id (racket match)))) + (require racket/match) + (define id (racket match)))) (bind racket-match)) @mzlib[#:mode title match] diff --git a/collects/mzlib/scribblings/sandbox.scrbl b/collects/mzlib/scribblings/sandbox.scrbl index ffd3976591..e76550bc5e 100644 --- a/collects/mzlib/scribblings/sandbox.scrbl +++ b/collects/mzlib/scribblings/sandbox.scrbl @@ -4,11 +4,11 @@ (only-in racket/sandbox make-module-evaluator))) @(begin - (define-syntax-rule (bind id) - (begin - (require (for-label racket/sandbox)) - (define id (racket make-evaluator)))) - (bind racket-make-evaluator)) + (define-syntax-rule (bind id) + (begin + (require (for-label racket/sandbox)) + (define id (racket make-evaluator)))) + (bind racket-make-evaluator)) @mzlib[#:mode title sandbox] diff --git a/collects/mzlib/scribblings/sendevent.scrbl b/collects/mzlib/scribblings/sendevent.scrbl index 2f7dcf4150..818453b4c2 100644 --- a/collects/mzlib/scribblings/sendevent.scrbl +++ b/collects/mzlib/scribblings/sendevent.scrbl @@ -3,11 +3,11 @@ (for-label mzlib/sendevent)) @(begin - (define-syntax-rule (bind id) - (begin - (require (for-label scheme/gui/base)) - (define id (racket send-event)))) - (bind mred-send-event)) + (define-syntax-rule (bind id) + (begin + (require (for-label scheme/gui/base)) + (define id (racket send-event)))) + (bind mred-send-event)) @mzlib[#:mode title sendevent] diff --git a/collects/mzlib/scribblings/serialize.scrbl b/collects/mzlib/scribblings/serialize.scrbl index 22c73ed46e..d0a86542b1 100644 --- a/collects/mzlib/scribblings/serialize.scrbl +++ b/collects/mzlib/scribblings/serialize.scrbl @@ -3,12 +3,13 @@ (for-label mzlib/serialize)) @(begin - (define-syntax-rule (bind id id2) - (begin - (require (for-label racket/serialize)) - (define id (racket define-serializable-struct)) - (define id2 (racket define-serializable-struct/versions)))) - (bind racket-define-serializable-struct racket-define-serializable-struct/versions)) + (define-syntax-rule (bind id id2) + (begin + (require (for-label racket/serialize)) + (define id (racket define-serializable-struct)) + (define id2 (racket define-serializable-struct/versions)))) + (bind racket-define-serializable-struct + racket-define-serializable-struct/versions)) @mzlib[#:mode title serialize] diff --git a/collects/mzlib/scribblings/struct.scrbl b/collects/mzlib/scribblings/struct.scrbl index 02d62575cd..1fada9665f 100644 --- a/collects/mzlib/scribblings/struct.scrbl +++ b/collects/mzlib/scribblings/struct.scrbl @@ -51,11 +51,11 @@ property. @examples[ #:eval struct-eval -(define-struct/properties point (x y) - ([prop:custom-write (lambda (p port write?) - (fprintf port "(~a, ~a)" - (point-x p) - (point-y p)))])) +(define-struct/properties point (x y) + ([prop:custom-write (lambda (p port write?) + (fprintf port "(~a, ~a)" + (point-x p) + (point-y p)))])) (display (make-point 1 2)) ]} diff --git a/collects/mzlib/scribblings/transcr.scrbl b/collects/mzlib/scribblings/transcr.scrbl index 30e9085cc6..1d8cd9ef02 100644 --- a/collects/mzlib/scribblings/transcr.scrbl +++ b/collects/mzlib/scribblings/transcr.scrbl @@ -10,13 +10,13 @@ library provides working versions of @racket[transcript-on] and @racket[transcript-off]. @(define-syntax-rule (go) - (begin - (require (for-label mzlib/transcr)) + (begin + (require (for-label mzlib/transcr)) - @deftogether[( - @defproc[(transcript-on [filename any/c]) any] - @defproc[(transcript-off) any] - )]{ + @deftogether[( + @defproc[(transcript-on [filename any/c]) any] + @defproc[(transcript-off) any] + )]{ Starts/stops recording a transcript at @racket[filename].})) @(go) diff --git a/collects/mzlib/scribblings/unit.scrbl b/collects/mzlib/scribblings/unit.scrbl index 5ccf11e6a6..8d71116b07 100644 --- a/collects/mzlib/scribblings/unit.scrbl +++ b/collects/mzlib/scribblings/unit.scrbl @@ -3,16 +3,16 @@ (for-label mzlib/unit)) @(begin - (define-syntax-rule (bind id) - (begin - (require (for-label racket/unit)) - (define id (racket struct)))) - (bind racket-struct) - (define-syntax-rule (bindc id) - (begin - (require (for-label racket/unit)) - (define id (racket struct/ctc)))) - (bindc racket-struct/ctc)) + (define-syntax-rule (bind id) + (begin + (require (for-label racket/unit)) + (define id (racket struct)))) + (bind racket-struct) + (define-syntax-rule (bindc id) + (begin + (require (for-label racket/unit)) + (define id (racket struct/ctc)))) + (bindc racket-struct/ctc)) @mzlib[#:mode title unit] diff --git a/collects/mzscheme/mzscheme.scrbl b/collects/mzscheme/mzscheme.scrbl index c6c22402cd..de77e7553e 100644 --- a/collects/mzscheme/mzscheme.scrbl +++ b/collects/mzscheme/mzscheme.scrbl @@ -22,22 +22,22 @@ base-free-identifier=? base-free-template-identifier=? base-free-transformer-identifier=? base-free-label-identifier=?) (begin - (require (for-label scheme/base)) - (define base-define (racket define)) - (define base-define-syntax (racket define-syntax)) - (define base-define-for-syntax (racket define-for-syntax)) - (define base-define-struct (racket define-struct)) - (define base-if (racket if)) - (define base-cond (racket cond)) - (define base-case (racket case)) - (define base-top-interaction (racket #%top-interaction)) - (define base-open-input-file (racket open-input-file)) - (define base-apply (racket apply)) - (define base-prop:procedure (racket prop:procedure)) - (define base-free-identifier=? (racket free-identifier=?)) - (define base-free-template-identifier=? (racket free-template-identifier=?)) - (define base-free-transformer-identifier=? (racket free-transformer-identifier=?)) - (define base-free-label-identifier=? (racket free-label-identifier=?)))) + (require (for-label scheme/base)) + (define base-define (racket define)) + (define base-define-syntax (racket define-syntax)) + (define base-define-for-syntax (racket define-for-syntax)) + (define base-define-struct (racket define-struct)) + (define base-if (racket if)) + (define base-cond (racket cond)) + (define base-case (racket case)) + (define base-top-interaction (racket #%top-interaction)) + (define base-open-input-file (racket open-input-file)) + (define base-apply (racket apply)) + (define base-prop:procedure (racket prop:procedure)) + (define base-free-identifier=? (racket free-identifier=?)) + (define base-free-template-identifier=? (racket free-template-identifier=?)) + (define base-free-transformer-identifier=? (racket free-transformer-identifier=?)) + (define base-free-label-identifier=? (racket free-label-identifier=?)))) @(def-base base-define base-define-syntax base-define-for-syntax base-define-struct base-if base-cond base-case base-top-interaction base-open-input-file base-apply base-prop:procedure diff --git a/collects/net/scribblings/cookie.scrbl b/collects/net/scribblings/cookie.scrbl index 9f30a58e21..ecd0b22d6f 100644 --- a/collects/net/scribblings/cookie.scrbl +++ b/collects/net/scribblings/cookie.scrbl @@ -110,11 +110,11 @@ Raised for errors when handling cookies.} @subsection{Creating a cookie} @racketblock[ -(let ((c (cookie:add-max-age +(let ([c (cookie:add-max-age (cookie:add-path (set-cookie "foo" "bar") "/servlets") - 3600))) + 3600)]) (print-cookie c)) ] diff --git a/collects/parser-tools/parser-tools.scrbl b/collects/parser-tools/parser-tools.scrbl index dc44b23a17..3e59b88f4c 100644 --- a/collects/parser-tools/parser-tools.scrbl +++ b/collects/parser-tools/parser-tools.scrbl @@ -343,7 +343,7 @@ characters, @racket[char-lower-case?] characters, etc.} @(define-syntax-rule (lex-sre-doc) (... (begin - (require (for-label parser-tools/lex-sre)) + (require (for-label parser-tools/lex-sre)) @defform[(* re ...)]{ @@ -417,7 +417,7 @@ characters.} @(define-syntax-rule (lex-v200-doc) (... (begin - (require (for-label parser-tools/lex-plt-v200)) + (require (for-label parser-tools/lex-plt-v200)) @t{The @racketmodname[parser-tools/lex-plt-v200] module re-exports @racket[*], @racket[+], @racket[?], and @racket[&] from diff --git a/collects/picturing-programs/picturing-programs.scrbl b/collects/picturing-programs/picturing-programs.scrbl index 0e72ebd56b..eb68b9022b 100644 --- a/collects/picturing-programs/picturing-programs.scrbl +++ b/collects/picturing-programs/picturing-programs.scrbl @@ -199,19 +199,19 @@ the bounds of the image, returns a transparent color.} [f (-> natural-number/c natural-number/c color?)]) image?]{ -Builds an image of the specified size and shape by calling the specified function -on the coordinates of each pixel. For example, +Builds an image of the specified size and shape by calling the specified +function on the coordinates of each pixel. For example, @codeblock|{ ; fuzz : image -> image (define (fuzz pic) - (local [; near-pixel : num(x) num(y) -> color - (define (near-pixel x y) - (get-pixel-color (+ x -3 (random 7)) - (+ y -3 (random 7)) - pic))] - (build-image (image-width pic) - (image-height pic) - near-pixel))) + (local [; near-pixel : num(x) num(y) -> color + (define (near-pixel x y) + (get-pixel-color (+ x -3 (random 7)) + (+ y -3 (random 7)) + pic))] + (build-image (image-width pic) + (image-height pic) + near-pixel))) }| produces a fuzzy version of the given picture by replacing each pixel with a randomly chosen pixel near it.} @@ -268,7 +268,7 @@ size and shape. For example, @codeblock|{ ; lose-red : num(x) num(y) color -> color (define (lose-red x y old-color) - (make-color 0 (color-green old-color) (color-blue old-color))) + (make-color 0 (color-green old-color) (color-blue old-color))) (map-image lose-red my-picture)}| produces a copy of @racket[my-picture] with all the red leached out, @@ -286,9 +286,9 @@ Another example: @codeblock|{ ; apply-gradient : num(x) num(y) color -> color (define (apply-gradient x y old-color) - (make-color (min (* 3 x) 255) - 0 - (min (* 3 y) 255))) + (make-color (min (* 3 x) 255) + 0 + (min (* 3 y) 255))) (map-image apply-gradient my-picture)}| produces a picture the size of @racket[my-picture]'s bounding rectangle, @@ -402,12 +402,12 @@ For example, @codeblock|{ ; bad-gradient : num(x) num(y) -> color (define (bad-gradient x y) - (make-color (* 2.5 x) (* 1.6 y) 0)) + (make-color (* 2.5 x) (* 1.6 y) 0)) (build-image 50 30 bad-gradient) ; good-gradient : num(x) num(y) -> color (define (good-gradient x y) - (make-color (real->int (* 2.5 x)) (real->int (* 1.6 y)) 0)) + (make-color (real->int (* 2.5 x)) (real->int (* 1.6 y)) 0)) (build-image 50 30 good-gradient) }| The version using @racket[bad-gradient] crashes because color components must be exact integers. @@ -462,15 +462,15 @@ its output into a string, which is returned. Especially useful for testing: @codeblock|{ ; ask : string -> prints output, waits for text input, returns it (define (ask question) - (begin (display question) - (read))) + (begin (display question) + (read))) ; greet : nothing -> prints output, waits for text input, prints output (define (greet) - (local [(define name (ask "What is your name?"))] - (printf "Hello, ~a!" name))) + (local [(define name (ask "What is your name?"))] + (printf "Hello, ~a!" name))) (check-expect - (with-io-strings "Steve" greet) - "What is your name?Hello, Steve!")}| + (with-io-strings "Steve" greet) + "What is your name?Hello, Steve!")}| } @; @include-section{worlds.scrbl} diff --git a/collects/planet/private/util.scrbl b/collects/planet/private/util.scrbl index 495b82d02d..407ecf3806 100644 --- a/collects/planet/private/util.scrbl +++ b/collects/planet/private/util.scrbl @@ -44,7 +44,7 @@ the resolvers behavior. Returns the path corresponding to the planet package (interpreting the arguments the same way as @racket[planet-module-name-resolver] and @racket[(current-module-name-resolver)]). } - + @defproc[(resolve-planet-path [planet-path any/c]) path?]{ Returns the path where the file named by the require spec @racket[planet-path] is located in the current installation. } @@ -154,7 +154,7 @@ The port on the server the client should connect to if @defparam[DEFAULT-PACKAGE-LANGUAGE vers string?]{ The package language used when communicating with the server to find which package to download. - + Defaults to @racket[(version)]. } @@ -180,7 +180,7 @@ The port on the server the client should connect to if with ``raco planet link''. } - + @defproc[(get-hard-linked-packages) (listof (list/c (and/c path? absolute-path?) string? string? (listof string?) exact-nonnegative-integer? @@ -229,7 +229,6 @@ The @racket[pkg] argument must end with @racket[".plt"]. } - @defproc[(get-package-spec [owner string?] [pkg (and/c string? #rx"[.]plt$")] [maj (or/c #f natural-number/c) #f] @@ -278,13 +277,14 @@ the output file's name. See also @racket[build-scribble-docs?] and @racket[force-package-building?] } - + @defparam[build-scribble-docs? b boolean?]{ - Determines if @racket[make-planet-archive] builds scribble docs (or not). + Determines if @racket[make-planet-archive] builds scribble docs (or not). } @defparam[force-package-building? b boolean?]{ - Determines if @racket[make-planet-archive] is more strict and thus aborts more often. + Determines if @racket[make-planet-archive] is more strict and thus + aborts more often. } @defproc[(download-package [pkg-spec pkg-spec?]) @@ -300,7 +300,7 @@ See also @racket[build-scribble-docs?] and @racket[force-package-building?] a list, then the server is saying that there is no matching package; otherwise the error is some lower-level problem (perhaps no networking, etc.) } - + @defproc[(pkg->download-url [pkg pkg?]) url?]{ Returns the url for a given package. } @@ -412,13 +412,14 @@ produces a list corresponding to its name and version, exactly like @racket[(this-package-version)]. Given any other path, produces @racket[#f]. } - + @defstruct[(exn:fail:planet exn:fail) ([message string?] [continuation-marks continuation-mark-set?])]{ This exception record is used to report planet-specific exceptions. } -@defproc[(pkg? [v any/c]) boolean?]{ - Determines if its argument is a pkg, the representation of an installed package. +@defproc[(pkg? [v any/c]) boolean?]{ + Determines if its argument is a pkg, the representation of an + installed package. } @section[#:tag "version.rkt"]{Package Version} @@ -488,7 +489,7 @@ with Scribble to associate each documented binding with the appropriate package. Returns a symbol representing the require spec for @racket[ver], as a planet package. } - + @section[#:tag "syntax.rkt"]{Macros and Syntax Objects} @defmodule[planet/syntax] diff --git a/collects/plot/plot.scrbl b/collects/plot/plot.scrbl index f79f36abc7..2262d6bf61 100644 --- a/collects/plot/plot.scrbl +++ b/collects/plot/plot.scrbl @@ -181,15 +181,15 @@ function, we could do the following: #:segments [segments 20] #:color [color 'red] #:width [width 1]) - (let* ((dash-size (/ (- x-max x-min) segments)) - (x-lists (build-list + (let* ([dash-size (/ (- x-max x-min) segments)] + [x-lists (build-list (/ segments 2) (lambda (index) (x-values (/ samples segments) (+ x-min (* 2 index dash-size)) (+ x-min (* (add1 (* 2 index)) - dash-size))))))) + dash-size)))))]) (lambda (2dview) (send 2dview set-line-color color) (send 2dview set-line-width width) diff --git a/collects/preprocessor/scribblings/mztext.scrbl b/collects/preprocessor/scribblings/mztext.scrbl index 400314e7da..d444acb1c6 100644 --- a/collects/preprocessor/scribblings/mztext.scrbl +++ b/collects/preprocessor/scribblings/mztext.scrbl @@ -399,7 +399,7 @@ Dispatching-related bindings: @racketblock[ (define (ttref) - (let ((url (get-arg)) (text (get-arg))) + (let ([url (get-arg)] [text (get-arg)]) (list "@tt{" text "}"))) ] diff --git a/collects/rackunit/scribblings/internals.scrbl b/collects/rackunit/scribblings/internals.scrbl index 15d68563f4..4a22aeb102 100644 --- a/collects/rackunit/scribblings/internals.scrbl +++ b/collects/rackunit/scribblings/internals.scrbl @@ -247,8 +247,8 @@ Here's the implementation of @racket[fold-test-results] in terms of kid-seed) (lambda (case name action seed) (case-fn - (run-test-case name action) - seed)) + (run-test-case name action) + seed)) seed test)) ] diff --git a/collects/rackunit/scribblings/quick-start.scrbl b/collects/rackunit/scribblings/quick-start.scrbl index 3ffede3981..bb79433bc8 100644 --- a/collects/rackunit/scribblings/quick-start.scrbl +++ b/collects/rackunit/scribblings/quick-start.scrbl @@ -76,7 +76,7 @@ cases. Here's a simple test case written using the @racketblock[ (test-begin - (let ((lst (list 2 4 6 9))) + (let ([lst (list 2 4 6 9)]) (check = (length lst) 4) (for-each (lambda (elt) @@ -111,7 +111,7 @@ we're testing. We can give a test case a name with the @racketblock[ (test-case "List has length 4 and all elements even" - (let ((lst (list 2 4 6 9))) + (let ([lst (list 2 4 6 9)]) (check = (length lst) 4) (for-each (lambda (elt) @@ -133,7 +133,7 @@ group them into a test suite: (test-case "List has length 4 and all elements even" - (let ((lst (list 2 4 6 9))) + (let ([lst (list 2 4 6 9)]) (check = (length lst) 4) (for-each (lambda (elt) diff --git a/collects/redex/redex.scrbl b/collects/redex/redex.scrbl index 0d2b7b489b..2ff16ed1c8 100644 --- a/collects/redex/redex.scrbl +++ b/collects/redex/redex.scrbl @@ -1127,7 +1127,7 @@ For example, the following defines addition on natural numbers: [(sum z n n)] [(sum (s n_1) n_2 (s n_3)) (sum n_1 n_2 n_3)])] - + The @racket[judgment-holds] form checks whether a relation holds for any assignment of pattern variables in output positions. @examples[ @@ -1199,7 +1199,7 @@ one. (judgment-holds (all-even (z (s (s z)) (s z))))] Redex evaluates premises depth-first, even when it doing so leads to -non-termination. For example, consider the following definitions: +non-termination. For example, consider the following definitions: @interaction[ #:eval redex-eval (define-language vertices @@ -1241,7 +1241,7 @@ the pattern variables in @racket[judgment-id]'s output positions. In its second form, produces a list of terms by instantiating the supplied term template with each satisfying assignment of pattern variables. See @racket[define-judgment-form] for examples. -} +} @defidform[I]{ Recognized specially within @racket[define-judgment-form], the @racket[I] keyword @@ -1294,7 +1294,7 @@ the same inputs, and their results are cached, unless relation is called with the same inputs twice, then its right-hand sides are evaluated only once. } - + @defparam[current-traced-metafunctions traced-metafunctions (or/c 'all (listof symbol?))]{ Controls which metafunctions are currently being traced. If it is @@ -1638,7 +1638,7 @@ term that does not match @racket[pattern].} (printf "~s\n" (term (number ...))) #:attempts 3 #:source R)) - + (redex-check empty-lang number @@ -2284,8 +2284,8 @@ Like @racket[render-metafunction] but for judgment forms. This function sets @racket[dc-for-text-size]. See also @racket[relation->pict]. -} - +} + @defform[(relation->pict relation-name)]{ This produces a pict, but without setting @racket[dc-for-text-size]. It is suitable for use in Slideshow or other libraries that combine @@ -2508,7 +2508,7 @@ metafunction. It defaults to slideshow's @racket[text] function. } @defproc[(arrow->pict [arrow symbol?]) pict?]{ - Returns the pict corresponding to @racket[arrow]. + Returns the pict corresponding to @racket[arrow]. } @defproc[(set-arrow-pict! [arrow symbol?] [proc (-> pict?)]) void?]{ @@ -2660,8 +2660,8 @@ explanation of logical-space): @defform[(with-compound-rewriters ([name-symbol proc] ...) expression)]{ -Shorthand for nested @racket[with-compound-rewriter] expressions.} - +Shorthand for nested @racket[with-compound-rewriter] expressions.} + @defstruct[lw ([e (or/c string? symbol? pict? @@ -2695,8 +2695,8 @@ metafunction application. See @racket[to-lw] for the meanings of the other field lw?]{ Like @racket[make-lw] but specialized for constructing @racket[lw]s that do not represent unquoted expressions or metafunction applications. -} - +} + @defform[(to-lw arg)]{ This form turns its argument into lw structs that diff --git a/collects/scribblings/drracket/keybindings.scrbl b/collects/scribblings/drracket/keybindings.scrbl index b3ff7baa01..29e0c2b8da 100644 --- a/collects/scribblings/drracket/keybindings.scrbl +++ b/collects/scribblings/drracket/keybindings.scrbl @@ -9,9 +9,9 @@ (apply item @index[(map (lambda (x) (format "~a keybinding" x)) keys) key-str] " : " desc))) @(define-syntax-rule (def-mod-beg id) - (begin - (require (for-label racket/base)) - (define id @racket[#%module-begin]))) + (begin + (require (for-label racket/base)) + (define id @racket[#%module-begin]))) @(def-mod-beg mz-mod-begin) @title{Keyboard Shortcuts} diff --git a/collects/scribblings/framework/frame.scrbl b/collects/scribblings/framework/frame.scrbl index 76d0c98763..85c9b1b14b 100644 --- a/collects/scribblings/framework/frame.scrbl +++ b/collects/scribblings/framework/frame.scrbl @@ -36,15 +36,15 @@ @racketblock[ (class ... ... - (define status-panel #f) - (define/override (make-root-area-container cls parent) - (set! status-panel - (super make-root-area-container vertical-panel% parent)) - (let ([root (make-object cls status-panel)]) + (define status-panel #f) + (define/override (make-root-area-container cls parent) + (set! status-panel + (super make-root-area-container vertical-panel% parent)) + (let ([root (make-object cls status-panel)]) - (code:comment "... add other children to status-panel ...") + (code:comment "... add other children to status-panel ...") - root)) + root)) ...)] In this example, status-panel will contain a root panel for the other @@ -186,7 +186,7 @@ See also @racket[frame:setup-size-pref]. } - + @defmethod*[#:mode override (((on-size (width number?) (height number?)) void?))]{ Updates the preferences, according to the width and diff --git a/collects/scribblings/framework/splash.scrbl b/collects/scribblings/framework/splash.scrbl index 482d658efc..9919cdb146 100644 --- a/collects/scribblings/framework/splash.scrbl +++ b/collects/scribblings/framework/splash.scrbl @@ -85,7 +85,7 @@ that number to control the gauge along the bottom of the splash screen. exact-nonnegative-integer? exact-nonnegative-integer? void?)]{ - Returns the callback that is invoked when redrawing the splash screen. + Returns the callback that is invoked when redrawing the splash screen. } @defproc[(set-splash-paint-callback [cb diff --git a/collects/scribblings/gui/snip-class.scrbl b/collects/scribblings/gui/snip-class.scrbl index 7805405798..7df8f280bb 100644 --- a/collects/scribblings/gui/snip-class.scrbl +++ b/collects/scribblings/gui/snip-class.scrbl @@ -247,7 +247,7 @@ more specific equivalence comparison.}} @methspec{See @racket[equal<%>].} @methimpl{Returns @racket[1].}} - + @defmethod[(find-scroll-step [y real?]) exact-nonnegative-integer?]{ diff --git a/collects/scribblings/gui/wxme.scrbl b/collects/scribblings/gui/wxme.scrbl index a53c50065a..a1af9075d1 100644 --- a/collects/scribblings/gui/wxme.scrbl +++ b/collects/scribblings/gui/wxme.scrbl @@ -9,11 +9,11 @@ (except-in wxme/cache-image reader))) @(define-syntax-rule (in mod . content) - (begin - (define-syntax-rule (intro) - (begin (require (for-label mod)) - . content)) - (intro))) + (begin + (define-syntax-rule (intro) + (begin (require (for-label mod)) + . content)) + (intro))) @title{WXME Decoding} diff --git a/collects/scribblings/guide/apply.scrbl b/collects/scribblings/guide/apply.scrbl index bf0543e321..2bfa063a9f 100644 --- a/collects/scribblings/guide/apply.scrbl +++ b/collects/scribblings/guide/apply.scrbl @@ -94,8 +94,8 @@ apply a function like @racket[+] to all of the items in the list: @def+int[ (define (avg lst) (code:comment @#,elem{doesn't always work...}) - (/ (+ (list-ref lst 0) (list-ref lst 1) (list-ref lst 2)) - (length lst))) + (/ (+ (list-ref lst 0) (list-ref lst 1) (list-ref lst 2)) + (length lst))) (avg '(1 2 3)) (avg '(1 2)) ] diff --git a/collects/scribblings/guide/begin.scrbl b/collects/scribblings/guide/begin.scrbl index 55faf31ef5..b0883215cd 100644 --- a/collects/scribblings/guide/begin.scrbl +++ b/collects/scribblings/guide/begin.scrbl @@ -28,9 +28,9 @@ tail position with respect to the @racket[begin] form. (if (zero? height) (void) (begin - (display (make-string height #\*)) - (newline) - (print-triangle (sub1 height))))) + (display (make-string height #\*)) + (newline) + (print-triangle (sub1 height))))) (print-triangle 4) ] @@ -55,10 +55,10 @@ positions, instead of forming an expression, the content of @defexamples[ (let ([curly 0]) - (begin - (define moe (+ 1 curly)) - (define larry (+ 1 moe))) - (list larry curly moe)) + (begin + (define moe (+ 1 curly)) + (define larry (+ 1 moe))) + (list larry curly moe)) ] This splicing behavior is mainly useful for macros, as we discuss @@ -114,13 +114,13 @@ result is @racket[#f]. @defexamples[ (define (enumerate lst) - (if (null? (cdr lst)) - (printf "~a.\n" (car lst)) - (begin - (printf "~a, " (car lst)) - (when (null? (cdr (cdr lst))) - (printf "and ")) - (enumerate (cdr lst))))) + (if (null? (cdr lst)) + (printf "~a.\n" (car lst)) + (begin + (printf "~a, " (car lst)) + (when (null? (cdr (cdr lst))) + (printf "and ")) + (enumerate (cdr lst))))) (enumerate '("Larry" "Curly" "Moe")) ] diff --git a/collects/scribblings/guide/class.scrbl b/collects/scribblings/guide/class.scrbl index becaa931bb..0b77eef3ec 100644 --- a/collects/scribblings/guide/class.scrbl +++ b/collects/scribblings/guide/class.scrbl @@ -742,8 +742,8 @@ applied first. Then the method-implementing mixins can use (class % .... (define/public (get-color) (void)))) (lambda (get-color get-price %) .... - (class % .... - (define/override (get-color) 'black)))) + (class % .... + (define/override (get-color) 'black)))) (list (local-member-name-key get-price) (lambda (get-price get-color %) .... (class % .... @@ -752,7 +752,7 @@ applied first. Then the method-implementing mixins can use (class % .... (inherit get-color) (define/override (get-price) - .... (get-color) ....)))))) + .... (get-color) ....)))))) ] With this trait encoding, @racket[trait-alias] adds a new method with @@ -789,11 +789,11 @@ Using this form in conjunction with trait operators such as (define/public (get-color) 'red))) (define spots+stripes-trait - (trait-sum - (trait-exclude (trait-alias spots-trait + (trait-sum + (trait-exclude (trait-alias spots-trait get-color get-spots-color) - get-color) - (trait-exclude (trait-alias stripes-trait + get-color) + (trait-exclude (trait-alias stripes-trait get-color get-stripes-color) get-color) (trait diff --git a/collects/scribblings/guide/contracts-first-extended-example.scrbl b/collects/scribblings/guide/contracts-first-extended-example.scrbl index 24c6e8971a..d4a88a29a4 100644 --- a/collects/scribblings/guide/contracts-first-extended-example.scrbl +++ b/collects/scribblings/guide/contracts-first-extended-example.scrbl @@ -60,9 +60,9 @@ racket [argmax (->i ([f (-> any/c real?)] [lov (and/c pair? list?)]) () (r (f lov) - (lambda (r) - (define f@r (f r)) - (for/and ((v lov)) (>= f@r (f v))))))]) + (lambda (r) + (define f@r (f r)) + (for/and ([v lov]) (>= f@r (f v))))))]) ] It is a @emph{dependent} contract that names the two arguments and uses the names to impose a predicate on the result. This predicate computes @@ -84,9 +84,8 @@ racket (r (f lov) (lambda (r) (define f@r (f r)) - (and - (memq r lov) - (for/and ((v lov)) (>= f@r (f v)))))))]) + (and (memq r lov) + (for/and ([v lov]) (>= f@r (f v)))))))]) ] The @racket[memq] function ensures that @racket[r] is @emph{intensionally equal} @margin-note*{That is, "pointer equality" for those who prefer to think at @@ -113,14 +112,14 @@ racket (r (f lov) (lambda (r) (define f@r (f r)) - (and (for/and ((v lov)) (>= f@r (f v))) + (and (for/and ([v lov]) (>= f@r (f v))) (eq? (first (memf (lambda (v) (= (f v) f@r)) lov)) r)))))]) ] That is, the @racket[memf] function determines the first element of @racket[lov] whose value under @racket[f] is equal to @racket[r]'s value under @racket[f]. If this element is intensionally equal to @racket[r], - the result of @racket[argmax] is correct. + the result of @racket[argmax] is correct. This second refinement step introduces two problems. First, both conditions recompute the values of @racket[f] for all elements of @racket[lov]. Second, @@ -157,7 +156,7 @@ racket @code:comment{@#,dominates1} (define (dominates-all f@r f lov) - (for/and ((v lov)) (>= (f v) f@r))) + (for/and ([v lov]) (>= (f v) f@r))) @code:comment{@#,first?1} (define (is-first-max? r f@r f lov) @@ -199,7 +198,7 @@ racket @code:comment{@#,dominates2} (define (dominates-all f@r flov) - (for/and ((f@v flov)) (>= f@r f@v))) + (for/and ([f@v flov]) (>= f@r f@v))) @code:comment{@#,first?2} (define (is-first-max? r f@r lov+flov) diff --git a/collects/scribblings/guide/contracts-general-function.scrbl b/collects/scribblings/guide/contracts-general-function.scrbl index f4b4c85ab6..6c39021f00 100644 --- a/collects/scribblings/guide/contracts-general-function.scrbl +++ b/collects/scribblings/guide/contracts-general-function.scrbl @@ -225,7 +225,7 @@ of numbers or a string into a new string: The contract for such a function is formed with the @racket[case->] combinator, which combines as many functional contracts as needed: @racketblock[ -(provide/contract +(provide/contract [report-cost (case-> (integer? integer? . -> . string?) diff --git a/collects/scribblings/guide/contracts-gotchas.scrbl b/collects/scribblings/guide/contracts-gotchas.scrbl index fe3d1420ac..f7521f56b5 100644 --- a/collects/scribblings/guide/contracts-gotchas.scrbl +++ b/collects/scribblings/guide/contracts-gotchas.scrbl @@ -81,26 +81,24 @@ streams like this: @interaction[ #:eval e (define stream/c - (promise/c - (or/c - null? - (cons/c number? stream/c)))) + (promise/c + (or/c null? + (cons/c number? stream/c)))) ] @close-eval[e] - + Unfortunately, this does not work because the value of @racket[stream/c] is needed before it is defined. Put another way, all of the combinators evaluate their arguments eagerly, even thought the values that they accept do not. -Instead, use +Instead, use @racketblock[ (define stream/c - (promise/c - (or/c - null? - (cons/c 1 - (recursive-contract stream/c))))) + (promise/c + (or/c + null? + (cons/c 1 (recursive-contract stream/c))))) ] The use of @racket[recursive-contract] delays the evaluation of the diff --git a/collects/scribblings/guide/contracts-intro.scrbl b/collects/scribblings/guide/contracts-intro.scrbl index 2186603f32..139735da0e 100644 --- a/collects/scribblings/guide/contracts-intro.scrbl +++ b/collects/scribblings/guide/contracts-intro.scrbl @@ -93,16 +93,16 @@ provide/contract'd. This is currently buggy so this discussion is elided. Here's the expansion of the requiring module, just to give an idea: -(module m racket +(module m racket (require mzlib/contract) - (provide/contract [x x-ctc])) + (provide/contract [x x-ctc])) (module n racket (require m) (define (f) ... x ...)) ==> -(module n racket - (require (rename m x x-real)) - (define x (apply-contract x-real x-ctc ...)) - (define (f) ... x ...)) +(module n racket + (require (rename m x x-real)) + (define x (apply-contract x-real x-ctc ...)) + (define (f) ... x ...)) The intention is to only do the work of applying the contract once (per variable reference to a diff --git a/collects/scribblings/guide/for.scrbl b/collects/scribblings/guide/for.scrbl index b30085673e..272915f303 100644 --- a/collects/scribblings/guide/for.scrbl +++ b/collects/scribblings/guide/for.scrbl @@ -261,7 +261,7 @@ resulting iteration can be performed more efficiently than plain @racket[for/vector] or @racket[for*/vector]: @interaction[ -(let ((chapters '("Intro" "Details" "Conclusion"))) +(let ([chapters '("Intro" "Details" "Conclusion")]) (for/vector #:length (length chapters) ([i (in-naturals 1)] [chapter chapters]) (string-append (number->string i) ". " chapter))) diff --git a/collects/scribblings/guide/futures.scrbl b/collects/scribblings/guide/futures.scrbl index 85690f7a61..d3cffaa30d 100644 --- a/collects/scribblings/guide/futures.scrbl +++ b/collects/scribblings/guide/futures.scrbl @@ -64,18 +64,18 @@ Consider the following core of a Mandelbrot-set computation: @racketblock[ (define (mandelbrot iterations x y n) - (let ((ci (- (/ (* 2.0 y) n) 1.0)) - (cr (- (/ (* 2.0 x) n) 1.5))) - (let loop ((i 0) (zr 0.0) (zi 0.0)) + (let ([ci (- (/ (* 2.0 y) n) 1.0)] + [cr (- (/ (* 2.0 x) n) 1.5)]) + (let loop ([i 0] [zr 0.0] [zi 0.0]) (if (> i iterations) i - (let ((zrq (* zr zr)) - (ziq (* zi zi))) + (let ([zrq (* zr zr)] + [ziq (* zi zi)]) (cond - ((> (+ zrq ziq) 4.0) i) - (else (loop (add1 i) - (+ (- zrq ziq) cr) - (+ (* 2.0 zr zi) ci))))))))) + [(> (+ zrq ziq) 4.0) i] + [else (loop (add1 i) + (+ (- zrq ziq) cr) + (+ (* 2.0 zr zi) ci))])))))) ] The expressions @racket[(mandelbrot 10000000 62 500 1000)] and @@ -110,8 +110,8 @@ first the problem: @racketblock[ (define (mandelbrot iterations x y n) - (let ((ci (- (/ (* 2.0 (->fl y)) (->fl n)) 1.0)) - (cr (- (/ (* 2.0 (->fl x)) (->fl n)) 1.5))) + (let ([ci (- (/ (* 2.0 (->fl y)) (->fl n)) 1.0)] + [cr (- (/ (* 2.0 (->fl x)) (->fl n)) 1.5)]) ....)) ] @@ -128,18 +128,18 @@ much less allocation: @racketblock[ (define (mandelbrot iterations x y n) - (let ((ci (fl- (fl/ (* 2.0 (->fl y)) (->fl n)) 1.0)) - (cr (fl- (fl/ (* 2.0 (->fl x)) (->fl n)) 1.5))) - (let loop ((i 0) (zr 0.0) (zi 0.0)) + (let ([ci (fl- (fl/ (* 2.0 (->fl y)) (->fl n)) 1.0)] + [cr (fl- (fl/ (* 2.0 (->fl x)) (->fl n)) 1.5)]) + (let loop ([i 0] [zr 0.0] [zi 0.0]) (if (> i iterations) i - (let ((zrq (fl* zr zr)) - (ziq (fl* zi zi))) + (let ([zrq (fl* zr zr)] + [ziq (fl* zi zi)]) (cond - ((fl> (fl+ zrq ziq) 4.0) i) - (else (loop (add1 i) - (fl+ (fl- zrq ziq) cr) - (fl+ (fl* 2.0 (fl* zr zi)) ci))))))))) + [(fl> (fl+ zrq ziq) 4.0) i] + [else (loop (add1 i) + (fl+ (fl- zrq ziq) cr) + (fl+ (fl* 2.0 (fl* zr zi)) ci))])))))) ] This conversion can speed @racket[mandelbrot] by a factor of 8, even diff --git a/collects/scribblings/guide/proc-macros.scrbl b/collects/scribblings/guide/proc-macros.scrbl index 622421bd1b..b01ba6bb3f 100644 --- a/collects/scribblings/guide/proc-macros.scrbl +++ b/collects/scribblings/guide/proc-macros.scrbl @@ -315,8 +315,8 @@ the source form are identifiers. We could use a (syntax-case stx () [(rotate a c ...) (begin - (check-ids stx #'(a c ...)) - #'(shift-to (c ... a) (a c ...)))])) + (check-ids stx #'(a c ...)) + #'(shift-to (c ... a) (a c ...)))])) ] The @racket[check-ids] function can use the @racket[syntax->list] diff --git a/collects/scribblings/guide/syntax-taints.scrbl b/collects/scribblings/guide/syntax-taints.scrbl index 951dacf665..c18535440c 100644 --- a/collects/scribblings/guide/syntax-taints.scrbl +++ b/collects/scribblings/guide/syntax-taints.scrbl @@ -217,13 +217,13 @@ racket (+ n 17)) (define-syntax (def-go stx) - (syntax-case stx () - [(_ go) - (protect-syntax - #'(define-syntax (go stx) - (syntax-case stx () - [(_ x) - (protect-syntax #'(unchecked-go 8 x))])))])) + (syntax-case stx () + [(_ go) + (protect-syntax + #'(define-syntax (go stx) + (syntax-case stx () + [(_ x) + (protect-syntax #'(unchecked-go 8 x))])))])) ] When @racket[def-go] is used inside another module to defined @@ -247,13 +247,13 @@ racket (lambda (stx) (syntax-arm stx insp)))) (define-syntax (def-go stx) - (syntax-case stx () - [(_ go) - (protect-syntax - #'(define-syntax (go stx) - (syntax-case stx () - [(_ x) - (go-syntax-protect #'(unchecked-go 8 x))])))])) + (syntax-case stx () + [(_ go) + (protect-syntax + #'(define-syntax (go stx) + (syntax-case stx () + [(_ x) + (go-syntax-protect #'(unchecked-go 8 x))])))])) ] @;------------------------------------------------------------------------ diff --git a/collects/scribblings/guide/unit.scrbl b/collects/scribblings/guide/unit.scrbl index 096f22be15..d464aa6862 100644 --- a/collects/scribblings/guide/unit.scrbl +++ b/collects/scribblings/guide/unit.scrbl @@ -313,28 +313,28 @@ racket (define toy-store@-maker (lambda (the-color) - (unit - (import toy-factory^) - (export toy-store^) + (unit + (import toy-factory^) + (export toy-store^) - (define inventory null) + (define inventory null) - (define (store-color) the-color) + (define (store-color) the-color) - (code:comment @#,t{the rest is the same as before}) + (code:comment @#,t{the rest is the same as before}) - (define (maybe-repaint t) - (if (eq? (toy-color t) (store-color)) - t - (repaint t (store-color)))) + (define (maybe-repaint t) + (if (eq? (toy-color t) (store-color)) + t + (repaint t (store-color)))) - (define (stock! n) - (set! inventory - (append inventory - (map maybe-repaint - (build-toys n))))) + (define (stock! n) + (set! inventory + (append inventory + (map maybe-repaint + (build-toys n))))) - (define (get-inventory) inventory)))) + (define (get-inventory) inventory)))) (provide toy-store@-maker) ] diff --git a/collects/scribblings/htdp-langs/advanced.scrbl b/collects/scribblings/htdp-langs/advanced.scrbl index 534bc46751..9140226f78 100644 --- a/collects/scribblings/htdp-langs/advanced.scrbl +++ b/collects/scribblings/htdp-langs/advanced.scrbl @@ -122,7 +122,7 @@ the function.} @defform[(define-datatype dataype-name [variant-name field-name ...] ...)]{ - + A short-hand for defining a group of related structures. The following @racket[define-datatype]: @racketblock[ @@ -237,7 +237,7 @@ of the initial @racket[expression].} @defform[(match expression [pattern expression] ...)]{ - + A @racket[match] form contains one or more clauses that are surrounded by square brackets. Each clause contains a pattern---a description of a value---and an answer @racket[expression]. The initial @racket[expression] is evaluated, diff --git a/collects/scribblings/raco/exe-api.scrbl b/collects/scribblings/raco/exe-api.scrbl index 4fb80755d5..682c358040 100644 --- a/collects/scribblings/raco/exe-api.scrbl +++ b/collects/scribblings/raco/exe-api.scrbl @@ -433,7 +433,7 @@ A unit that imports nothing and exports @racket[compiler:embed^].} @defproc[(find-exe [gracket? boolean?] [variant (or/c 'cgc '3m) (system-type 'gc)]) path?]{ - - Finds the path to the racket (or gracket) executable. + + Finds the path to the racket (or gracket) executable. } diff --git a/collects/scribblings/raco/info.scrbl b/collects/scribblings/raco/info.scrbl index 67bbbce0bb..ad4886cdd3 100644 --- a/collects/scribblings/raco/info.scrbl +++ b/collects/scribblings/raco/info.scrbl @@ -6,11 +6,11 @@ (only-in setup/infotab require))) @(begin - (define-syntax-rule (define-racket-require id) - (begin - (require (for-label (only-in racket require))) - (define id @racket[require]))) - (define-racket-require racket:require)) + (define-syntax-rule (define-racket-require id) + (begin + (require (for-label (only-in racket require))) + (define id @racket[require]))) + (define-racket-require racket:require)) @title[#:tag "info.rkt"]{@filepath{info.rkt} File Format} diff --git a/collects/scribblings/raco/make.scrbl b/collects/scribblings/raco/make.scrbl index 15e3de84d9..3abbaee883 100644 --- a/collects/scribblings/raco/make.scrbl +++ b/collects/scribblings/raco/make.scrbl @@ -384,8 +384,8 @@ result will not call @racket[proc] with @racket['unlock].) (when ok-to-compile? (printf "Do compile here ...\n"))) (lambda () - (when locked? - (lc 'unlock zo-name))))) + (when locked? + (lc 'unlock zo-name))))) ] } diff --git a/collects/scribblings/raco/setup.scrbl b/collects/scribblings/raco/setup.scrbl index c91b9f53fd..ff878e8e37 100644 --- a/collects/scribblings/raco/setup.scrbl +++ b/collects/scribblings/raco/setup.scrbl @@ -27,12 +27,12 @@ racket/future)) @(define-syntax-rule (local-module mod . body) - (begin - (define-syntax-rule (go) - (begin - (require (for-label mod)) - . body)) - (go))) + (begin + (define-syntax-rule (go) + (begin + (require (for-label mod)) + . body)) + (go))) @(define ref-src '(lib "scribblings/reference/reference.scrbl")) diff --git a/collects/scribblings/reference/bytes.scrbl b/collects/scribblings/reference/bytes.scrbl index 8f5376ffa1..a3fae2021c 100644 --- a/collects/scribblings/reference/bytes.scrbl +++ b/collects/scribblings/reference/bytes.scrbl @@ -280,7 +280,8 @@ For communication among @tech{places}, the new byte string is allocated in the the other operations. @examples[ (define b - (bytes->string/utf-8 (bytes #xc3 #xa7 #xc3 #xb0 #xc3 #xb6 #xc2 #xa3))) + (bytes->string/utf-8 + (bytes #xc3 #xa7 #xc3 #xb0 #xc3 #xb6 #xc2 #xa3))) (string->bytes/utf-8 b) (bytes->string/utf-8 (string->bytes/utf-8 b)) @@ -316,7 +317,7 @@ For communication among @tech{places}, the new byte string is allocated in the @examples[ (define b - (bytes->string/latin-1 (bytes #xfe #xd3 #xd1 #xa5))) + (bytes->string/latin-1 (bytes #xfe #xd3 #xd1 #xa5))) (string->bytes/latin-1 b) (bytes->string/latin-1 (string->bytes/latin-1 b)) diff --git a/collects/scribblings/reference/class.scrbl b/collects/scribblings/reference/class.scrbl index 78044c4c24..38083d74a4 100644 --- a/collects/scribblings/reference/class.scrbl +++ b/collects/scribblings/reference/class.scrbl @@ -12,15 +12,15 @@ [(_ s ... s0) (elem (elem ", " (secref s)) ... ", and " (secref s0))])) (define-syntax (defclassforms stx) - (syntax-case stx (*) - [(_ [* (form ...) (also ...)]) - #'(defform* (form ...) - "See " @racket[class*] (sees also ...) "; use" - " outside the body of a " @racket[class*] " form is a syntax error.")] - [(_ [form (also ...)]) - #'(defclassforms [* (form) (also ...)])] - [(_ form ...) - #'(begin (defclassforms form) ...)])) + (syntax-case stx (*) + [(_ [* (form ...) (also ...)]) + #'(defform* (form ...) + "See " @racket[class*] (sees also ...) "; use" + " outside the body of a " @racket[class*] " form is a syntax error.")] + [(_ [form (also ...)]) + #'(defclassforms [* (form) (also ...)])] + [(_ form ...) + #'(begin (defclassforms form) ...)])) (define-syntax (defstarshorthands stx) (syntax-case stx () @@ -292,13 +292,13 @@ interface @racket[(class->interface object%)], and is transparent (lambda kw-formals expr ...+) (case-lambda (formals expr ...+) ...) (#%plain-lambda formals expr ...+) - (let-values (((id) method-procedure) ...) + (let-values ([(id) method-procedure] ...) method-procedure) - (letrec-values (((id) method-procedure) ...) + (letrec-values ([(id) method-procedure] ...) method-procedure) - (let-values (((id) method-procedure) ...+) + (let-values ([(id) method-procedure] ...+) id) - (letrec-values (((id) method-procedure) ...+) + (letrec-values ([(id) method-procedure] ...+) id)])]{ Produces a class value. @@ -1366,11 +1366,11 @@ Produces a @tech{trait} that combines all of the methods of the given @racketblock[ (define t1 - (trait - (define/public (m1) 1))) + (trait + (define/public (m1) 1))) (define t2 - (trait - (define/public (m2) 2))) + (trait + (define/public (m2) 2))) (define t3 (trait-sum t1 t2)) ] @@ -1378,8 +1378,8 @@ creates a trait @racket[t3] that is equivalent to @racketblock[ (trait - (define/public (m1) 1) - (define/public (m2) 2)) + (define/public (m1) 1) + (define/public (m2) 2)) ] but @racket[t1] and @racket[t2] can still be used individually or @@ -1649,12 +1649,12 @@ Also, method contracts for @racket[object/c] follow those for behaves as if its class had been wrapped with the equivalent @racket[class/c] contract. } - + @defproc[(instanceof/c [class-contract contract?]) contract?]{ Produces a contract for an object, where the object is an instance of a class that conforms to @racket[class-contract]. } - + @defform/subs[ #:literals (field -> ->* ->d) diff --git a/collects/scribblings/reference/cont-marks.scrbl b/collects/scribblings/reference/cont-marks.scrbl index 1691e5da22..786fd5132f 100644 --- a/collects/scribblings/reference/cont-marks.scrbl +++ b/collects/scribblings/reference/cont-marks.scrbl @@ -172,18 +172,18 @@ default error display handler (see @secref["errorproc"]).} @examples[ -(define (extract-current-continuation-marks key) - (continuation-mark-set->list - (current-continuation-marks) - key)) +(define (extract-current-continuation-marks key) + (continuation-mark-set->list + (current-continuation-marks) + key)) -(with-continuation-mark 'key 'mark +(with-continuation-mark 'key 'mark (extract-current-continuation-marks 'key)) -(with-continuation-mark 'key1 'mark1 - (with-continuation-mark 'key2 'mark2 - (list - (extract-current-continuation-marks 'key1) +(with-continuation-mark 'key1 'mark1 + (with-continuation-mark 'key2 'mark2 + (list + (extract-current-continuation-marks 'key1) (extract-current-continuation-marks 'key2)))) (with-continuation-mark 'key 'mark1 diff --git a/collects/scribblings/reference/contracts.scrbl b/collects/scribblings/reference/contracts.scrbl index c71b9c3cc2..8a33f1d642 100644 --- a/collects/scribblings/reference/contracts.scrbl +++ b/collects/scribblings/reference/contracts.scrbl @@ -997,7 +997,7 @@ is bound to vectors of two elements, the exported identifier and a syntax object for the expression that produces the contract controlling the export. } - + @subsection{Nested Contract Boundaries} @defmodule*/no-declare[(racket/contract/region)] @declare-exporting-ctc[racket/contract/region] @@ -1091,7 +1091,7 @@ The @racket[define-struct/contract] form only allows a subset of the @subsection{Low-level Contract Boundaries} @declare-exporting-ctc[racket/contract/base] - + @defform*[[(contract contract-expr to-protect-expr positive-blame-expr negative-blame-expr) (contract contract-expr to-protect-expr @@ -1808,7 +1808,7 @@ are below): @; ------------------------------------------------------------------------ @subsection{Utilities for Building New Combinators} - + @defproc[(contract-stronger? [x contract?] [y contract?]) boolean?]{ Returns @racket[#t] if the contract @racket[x] accepts either fewer or the same number of values as @racket[y] does. @@ -1845,7 +1845,7 @@ contract holds.} Produces the first-order test used by @racket[or/c] to match values to higher-order contracts. } - + @section{Contract Utilities} @declare-exporting-ctc[racket/contract/base] diff --git a/collects/scribblings/reference/file-ports.scrbl b/collects/scribblings/reference/file-ports.scrbl index 7b80dcba67..34dfef03a6 100644 --- a/collects/scribblings/reference/file-ports.scrbl +++ b/collects/scribblings/reference/file-ports.scrbl @@ -9,27 +9,27 @@ ;; hacky? (define file-eval - (lambda () - (let ([the-eval (make-base-eval)]) - (the-eval '(require (for-syntax racket/base) - racket/file)) - (the-eval '(define some-file (make-temporary-file))) - (the-eval '(define some-other-file (make-temporary-file))) - the-eval))) + (lambda () + (let ([the-eval (make-base-eval)]) + (the-eval '(require (for-syntax racket/base) + racket/file)) + (the-eval '(define some-file (make-temporary-file))) + (the-eval '(define some-other-file (make-temporary-file))) + the-eval))) (define-syntax file-examples (syntax-rules () [(_ expr ...) (let [(my-eval (file-eval))] - (define (clean) - (my-eval '(for [(i (list some-file some-other-file))] - (when (file-exists? i) - (delete-file i))))) - (clean) - (begin0 - (defexamples #:eval my-eval - expr ...) - (clean)))])) + (define (clean) + (my-eval '(for [(i (list some-file some-other-file))] + (when (file-exists? i) + (delete-file i))))) + (clean) + (begin0 + (defexamples #:eval my-eval + expr ...) + (clean)))])) "") diff --git a/collects/scribblings/reference/fixnums.scrbl b/collects/scribblings/reference/fixnums.scrbl index f72427285c..a8af31cea6 100644 --- a/collects/scribblings/reference/fixnums.scrbl +++ b/collects/scribblings/reference/fixnums.scrbl @@ -196,4 +196,3 @@ For communication among @tech{places}, the new @tech{fxvector} is allocated in the @tech{shared memory space}. @mz-examples[#:eval flfx-eval (make-shared-fxvector 4 3)]} - diff --git a/collects/scribblings/reference/hashes.scrbl b/collects/scribblings/reference/hashes.scrbl index 9266a1d623..15c16379ee 100644 --- a/collects/scribblings/reference/hashes.scrbl +++ b/collects/scribblings/reference/hashes.scrbl @@ -180,7 +180,7 @@ Maps @racket[key] to @racket[v] in @racket[hash], overwriting any existing mapping for @racket[key]. @see-also-caveats[]} - + @defproc[(hash-set*! [hash (and/c hash? (not/c immutable?))] [key any/c] [v any/c] @@ -204,7 +204,7 @@ Functionally extends @racket[hash] by mapping @racket[key] to returning the extended hash table. @see-also-mutable-key-caveat[]} - + @defproc[(hash-set* [hash (and/c hash? immutable?)] [key any/c] [v any/c] @@ -329,25 +329,25 @@ otherwise the traversal skips a deleted key or uses the remapped key's new value. @see-also-concurrency-caveat[]} - + @defproc[(hash-keys [hash hash?]) (listof any/c)]{ Returns a list of the keys of @racket[hash] in an unspecified order. - + See @racket[hash-map] for information about modifying @racket[hash] during @racket[hash-keys]. @see-also-concurrency-caveat[]} @defproc[(hash-values [hash hash?]) (listof any/c)]{ Returns a list of the values of @racket[hash] in an unspecified order. - + See @racket[hash-map] for information about modifying @racket[hash] during @racket[hash-values]. @see-also-concurrency-caveat[]} - + @defproc[(hash->list [hash hash?]) (listof (cons/c any/c any/c))]{ Returns a list of the key--value pairs of @racket[hash] in an unspecified order. - + See @racket[hash-map] for information about modifying @racket[hash] during @racket[hash->list]. @see-also-concurrency-caveat[]} diff --git a/collects/scribblings/reference/logging.scrbl b/collects/scribblings/reference/logging.scrbl index 042b07c087..ea6e7d94e8 100644 --- a/collects/scribblings/reference/logging.scrbl +++ b/collects/scribblings/reference/logging.scrbl @@ -144,8 +144,8 @@ is equivalent to @racketblock[ (let ([l (current-logger)]) (when (log-level? l '@#,racket[_level]) - (log-message l '@#,racket[_level] string-expr - (current-continuation-marks)))) + (log-message l '@#,racket[_level] string-expr + (current-continuation-marks)))) ]} @; ---------------------------------------- diff --git a/collects/scribblings/reference/match.scrbl b/collects/scribblings/reference/match.scrbl index 4b784ae414..b5e653f50b 100644 --- a/collects/scribblings/reference/match.scrbl +++ b/collects/scribblings/reference/match.scrbl @@ -480,9 +480,10 @@ instead of @racket[match].} A @racket[match] pattern form that matches an instance of a structure type named @racket[struct-id], where the field @racket[field] in the instance matches the corresponding @racket[pat]. - - Any field of @racket[struct-id] may be omitted, and such fields can occur in any order. - + + Any field of @racket[struct-id] may be omitted, and such fields can + occur in any order. + @defexamples[ #:eval match-eval (define-struct tree (val left right)) diff --git a/collects/scribblings/reference/module-reflect.scrbl b/collects/scribblings/reference/module-reflect.scrbl index a537bbaa16..0d0e401152 100644 --- a/collects/scribblings/reference/module-reflect.scrbl +++ b/collects/scribblings/reference/module-reflect.scrbl @@ -49,14 +49,14 @@ the grammar for @racket[_module-path] for @racket[require], @racket[#f] otherwise.} -@defparam[current-module-name-resolver proc +@defparam[current-module-name-resolver proc (case-> (resolved-module-path? . -> . any) ((or/c module-path? path?) - (or/c #f resolved-module-path?) - (or/c #f syntax?) + (or/c #f resolved-module-path?) + (or/c #f syntax?) boolean? - . -> . + . -> . resolved-module-path?))]{ A parameter that determines the current @deftech{module name diff --git a/collects/scribblings/reference/parameters.scrbl b/collects/scribblings/reference/parameters.scrbl index f504c9e17d..631ee66e56 100644 --- a/collects/scribblings/reference/parameters.scrbl +++ b/collects/scribblings/reference/parameters.scrbl @@ -44,7 +44,7 @@ new parameter value. A guard procedure can raise an exception to reject a change to the parameter's value. The @racket[guard] is not applied to the initial @racket[v].} -@defform[(parameterize ((parameter-expr value-expr) ...) +@defform[(parameterize ([parameter-expr value-expr] ...) body ...+) #:contracts ([parameter-expr parameter?])]{ diff --git a/collects/scribblings/reference/sequences.scrbl b/collects/scribblings/reference/sequences.scrbl index 5343cc92e3..1a8899ad57 100644 --- a/collects/scribblings/reference/sequences.scrbl +++ b/collects/scribblings/reference/sequences.scrbl @@ -739,8 +739,8 @@ values from the generator. (if (null? x) 0 (begin - (yield (car x)) - (loop (cdr x))))))) + (yield (car x)) + (loop (cdr x))))))) (g) (g) (g) @@ -812,8 +812,8 @@ Produces a @tech{sequence} that encapsulates the @tech{generator} formed by (if (null? x) my-stop-value (begin - (yield (car x)) - (loop (cdr x))))))) + (yield (car x)) + (loop (cdr x))))))) (for/list ([i (in-producer my-generator my-stop-value)]) i)]} diff --git a/collects/scribblings/reference/sets.scrbl b/collects/scribblings/reference/sets.scrbl index 01e6e755fe..d9ea0c639b 100644 --- a/collects/scribblings/reference/sets.scrbl +++ b/collects/scribblings/reference/sets.scrbl @@ -209,7 +209,7 @@ Returns @racket[#t] if @racket[st] compares elements with @racket[eq?], @defproc[(set/c [contract chaperone-contract?] [#:cmp cmp (or/c 'dont-care 'equal 'eqv 'eq) 'dont-care]) contract?]{ Constructs a contract that recognizes sets whose elements match @racket[contract]. - + If @racket[cmp] is @racket['dont-care], then the equality notion of the set is not considered when checking the contract. Otherwise, the contract accepts only sets with the corresponding notion of equality. diff --git a/collects/scribblings/reference/stx-param.scrbl b/collects/scribblings/reference/stx-param.scrbl index 1eff9cd21d..beff503012 100644 --- a/collects/scribblings/reference/stx-param.scrbl +++ b/collects/scribblings/reference/stx-param.scrbl @@ -24,7 +24,7 @@ used as a macro that expands to a use of the target identifier, but @racket[syntax-local-value] of @racket[id] does not produce the target's value.} -@defform[(syntax-parameterize ((id expr) ...) body-expr ...+)]{ +@defform[(syntax-parameterize ([id expr] ...) body-expr ...+)]{ @margin-note/ref{See also @racket[splicing-syntax-parameterize].} diff --git a/collects/scribblings/reference/stx-props.scrbl b/collects/scribblings/reference/stx-props.scrbl index 1081a44bfd..43b1330f32 100644 --- a/collects/scribblings/reference/stx-props.scrbl +++ b/collects/scribblings/reference/stx-props.scrbl @@ -139,7 +139,7 @@ For example, the expression expands to @racketblock[ -(let ((or-part x)) (if or-part or-part (or y))) +(let ([or-part x]) (if or-part or-part (or y))) ] which, in turn, expands to diff --git a/collects/scribblings/reference/syntax-model.scrbl b/collects/scribblings/reference/syntax-model.scrbl index 245cadd6da..24f768dba4 100644 --- a/collects/scribblings/reference/syntax-model.scrbl +++ b/collects/scribblings/reference/syntax-model.scrbl @@ -210,9 +210,9 @@ the binding (according to @racket[free-identifier=?]) matters.} (if expr expr expr) (begin expr ...+) (begin0 expr expr ...) - (let-values (((id ...) expr) ...) + (let-values ([(id ...) expr] ...) expr ...+) - (letrec-values (((id ...) expr) ...) + (letrec-values ([(id ...) expr] ...) expr ...+) (set! id expr) (@#,racket[quote] datum) @@ -756,21 +756,21 @@ bucket-2 (syntax-rules () [(def-and-use) (begin - (code:comment @#,t{Initial reference to @racket[even] precedes definition:}) - (define (odd x) (if (zero? x) #f (even (sub1 x)))) - (define (even x) (if (zero? x) #t (odd (sub1 x)))) - (odd 17))])) + (code:comment @#,t{Initial reference to @racket[even] precedes definition:}) + (define (odd x) (if (zero? x) #f (even (sub1 x)))) + (define (even x) (if (zero? x) #t (odd (sub1 x)))) + (odd 17))])) (defs-and-uses/fail) - + (define-syntax defs-and-uses (syntax-rules () [(def-and-use) (begin - (code:comment @#,t{Declare before definition via no-values @racket[define-syntaxes]:}) - (define-syntaxes (odd even) (values)) - (define (odd x) (if (zero? x) #f (even (sub1 x)))) - (define (even x) (if (zero? x) #t (odd (sub1 x)))) - (odd 17))])) + (code:comment @#,t{Declare before definition via no-values @racket[define-syntaxes]:}) + (define-syntaxes (odd even) (values)) + (define (odd x) (if (zero? x) #f (even (sub1 x)))) + (define (even x) (if (zero? x) #t (odd (sub1 x)))) + (odd 17))])) (defs-and-uses) ] diff --git a/collects/scribblings/reference/syntax-util.scrbl b/collects/scribblings/reference/syntax-util.scrbl index 797ba73458..97aac08343 100644 --- a/collects/scribblings/reference/syntax-util.scrbl +++ b/collects/scribblings/reference/syntax-util.scrbl @@ -109,7 +109,7 @@ is prefixed with the special form name as described under @examples[#:eval the-eval (wrong-syntax #'here "expected ~s" 'there) -(parameterize ((current-syntax-context #'(look over here))) +(parameterize ([current-syntax-context #'(look over here)]) (wrong-syntax #'here "expected ~s" 'there)) ] @@ -117,7 +117,7 @@ A macro using @racket[wrong-syntax] might set the syntax context at the very beginning of its transformation as follows: @RACKETBLOCK[ (define-syntax (my-macro stx) - (parameterize ((current-syntax-context stx)) + (parameterize ([current-syntax-context stx]) (syntax-case stx () ___))) ] diff --git a/collects/scribblings/reference/syntax.scrbl b/collects/scribblings/reference/syntax.scrbl index 9d1adcf568..c22dd13626 100644 --- a/collects/scribblings/reference/syntax.scrbl +++ b/collects/scribblings/reference/syntax.scrbl @@ -905,18 +905,18 @@ follows. chickens)) (module nest2 racket - (define-for-syntax eggs 2) - (provide (for-syntax eggs))) + (define-for-syntax eggs 2) + (provide (for-syntax eggs))) (require (for-meta 2 racket/base) (for-syntax 'nest2)) (define-syntax (test stx) - (define-syntax (show-eggs stx) - (printf "Eggs are ~a\n" eggs) - #'0) - (begin - (show-eggs) - #'0)) - (test) + (define-syntax (show-eggs stx) + (printf "Eggs are ~a\n" eggs) + #'0) + (begin + (show-eggs) + #'0)) + (test) ]} @specsubform[#:literals (for-syntax) @@ -2144,8 +2144,8 @@ be defined by the same @racket[define-for-syntax] form. @defexamples[#:eval (syntax-eval) (define-for-syntax helper 2) (define-syntax (make-two syntax-object) - (printf "helper is ~a\n" helper) - #'2) + (printf "helper is ~a\n" helper) + #'2) (make-two) (code:comment @#,t{`helper' is not bound in the runtime phase}) helper diff --git a/collects/scribblings/reference/time.scrbl b/collects/scribblings/reference/time.scrbl index 48e026322e..7deeda36eb 100644 --- a/collects/scribblings/reference/time.scrbl +++ b/collects/scribblings/reference/time.scrbl @@ -144,7 +144,7 @@ result is the result of @racket[expr].} @note-lib-only[racket/date] @defproc[(current-date) date?]{ - + An abbreviation for @racket[(seconds->date (current-seconds))].} @defproc[(date->string [date date?] [time? any/c #f]) string?]{ diff --git a/collects/scribblings/reference/vectors.scrbl b/collects/scribblings/reference/vectors.scrbl index f646661fda..6dae2282a4 100644 --- a/collects/scribblings/reference/vectors.scrbl +++ b/collects/scribblings/reference/vectors.scrbl @@ -67,7 +67,7 @@ slot is position @racket[0], and the last slot is one less than void?]{ Updates the slot @racket[pos] of @racket[vec] to contain @racket[v].} - + @defproc[(vector->list [vec vector?]) list?]{ Returns a list with the same length and elements as @racket[vec].} diff --git a/collects/scribblings/scribble/eval.scrbl b/collects/scribblings/scribble/eval.scrbl index 9874bca78d..a0ed01f50c 100644 --- a/collects/scribblings/scribble/eval.scrbl +++ b/collects/scribblings/scribble/eval.scrbl @@ -36,7 +36,7 @@ As an example, (: my-sqr (Real -> Real)) (define (my-sqr x) - (* x x)) + (* x x)) (my-sqr 42)] }| uses an evaluator whose language is @racketmodname[typed/racket/base]. diff --git a/collects/scribblings/scribble/jfp.scrbl b/collects/scribblings/scribble/jfp.scrbl index ec94a5bce7..24eca1c97b 100644 --- a/collects/scribblings/scribble/jfp.scrbl +++ b/collects/scribblings/scribble/jfp.scrbl @@ -3,8 +3,8 @@ @(define-syntax-rule (def base-author) (begin - (require (for-label scribble/base)) - (define base-author @racket[author]))) + (require (for-label scribble/base)) + (define base-author @racket[author]))) @(def base-author) @title{JFP Paper Format} diff --git a/collects/scribblings/scribble/lncs.scrbl b/collects/scribblings/scribble/lncs.scrbl index 5bb45d3802..f7a899c8fa 100644 --- a/collects/scribblings/scribble/lncs.scrbl +++ b/collects/scribblings/scribble/lncs.scrbl @@ -4,8 +4,8 @@ @(define-syntax-rule (def base-author) (begin - (require (for-label scribble/base)) - (define base-author @racket[author]))) + (require (for-label scribble/base)) + (define base-author @racket[author]))) @(def base-author) @title{LNCS Paper Format} @@ -47,7 +47,7 @@ arguments to @racket[institutes]. #:contracts ([pre-content-expr pre-content?])]{ The @racket[pre-content-expr]s are used as the institutions of the authors. - + } @defidform[institute]{For use only in @racket[institutes].} diff --git a/collects/scribblings/scribble/manual.scrbl b/collects/scribblings/scribble/manual.scrbl index d7bcf7ceb6..b95527b029 100644 --- a/collects/scribblings/scribble/manual.scrbl +++ b/collects/scribblings/scribble/manual.scrbl @@ -477,7 +477,7 @@ and one that combines several modules) via your own @defform/subs[(declare-exporting mod-path ... maybe-sources) ([maybe-sources code:blank (code:line #:use-sources (mod-path ...))])]{ - + Associates the @racket[mod-path]s to all bindings defined within the enclosing section, except as overridden by other @racket[declare-exporting] declarations in nested sub-sections. The diff --git a/collects/scribblings/scribble/renderer.scrbl b/collects/scribblings/scribble/renderer.scrbl index e0b66a66e3..932530c1cb 100644 --- a/collects/scribblings/scribble/renderer.scrbl +++ b/collects/scribblings/scribble/renderer.scrbl @@ -16,9 +16,9 @@ @(begin (define-syntax-rule (def-render-mixin id) - (begin - (require (for-label scribble/html-render)) - (define id @racket[render-mixin]))) + (begin + (require (for-label scribble/html-render)) + (define id @racket[render-mixin]))) (def-render-mixin html:render-mixin)) @title[#:tag "renderer"]{Renderers} diff --git a/collects/scribblings/scribble/srcdoc.scrbl b/collects/scribblings/scribble/srcdoc.scrbl index 88b3b4991d..58bbe29b6a 100644 --- a/collects/scribblings/scribble/srcdoc.scrbl +++ b/collects/scribblings/scribble/srcdoc.scrbl @@ -77,7 +77,7 @@ documentation expressions.} (code:line keyword contract-expr)] [optional contract-expr (code:line keyword contract-expr)])]{ - + When used in @racket[provide/doc], exports @racket[id] with the contract described by @racket[contract] just like using @racket[provide/contract]. @@ -109,7 +109,7 @@ form.} (->i (arg ...) () res) (->i (arg ...) () #:pre (pre-id ...) condition [name res]) (->i (arg ...) () #:rest rest res) - + (->d (arg ...) () (values [id result] ...)) (->d (arg ...) () #:pre-cond expr (values [id result] ...)) (->d (arg ...) () [id result]) @@ -117,9 +117,9 @@ form.} (->d (arg ...) () #:rest id rest [id result])])]{ Like @racket[proc-doc], but supporting contract forms that embed -argument names. Only a subset of @racket[->i] and @racket[->d] forms are currently -supported.} - +argument names. Only a subset of @racket[->i] and @racket[->d] forms are +currently supported.} + @defform[(thing-doc id contract-expr dec-expr)]{ Like @racket[proc-doc], but for an export of an arbitrary value.} diff --git a/collects/scribblings/scribble/xref.scrbl b/collects/scribblings/scribble/xref.scrbl index 752be73449..34202d934d 100644 --- a/collects/scribblings/scribble/xref.scrbl +++ b/collects/scribblings/scribble/xref.scrbl @@ -161,7 +161,6 @@ locations, instead of copying to the directory of @racket[dest].} Transfers cross-reference information to @racket[ci], which is the initially collected information from @racket[renderer].} - @defproc[(xref-index [xref xref?]) (listof entry?)]{ diff --git a/collects/scribblings/slideshow/slides.scrbl b/collects/scribblings/slideshow/slides.scrbl index 3113b6ef52..4dd6c4787d 100644 --- a/collects/scribblings/slideshow/slides.scrbl +++ b/collects/scribblings/slideshow/slides.scrbl @@ -328,7 +328,7 @@ but not hollow (using @racket[disk], not @racket[circle]). @defthing[o-bullet pict?]{ A hollow bullet used by default by @racket[subitem]. - + It's implementation is: @racketblock[(baseless (cc-superimpose diff --git a/collects/scribblings/tools/tools.scrbl b/collects/scribblings/tools/tools.scrbl index bf34cfee28..e14afc0656 100644 --- a/collects/scribblings/tools/tools.scrbl +++ b/collects/scribblings/tools/tools.scrbl @@ -640,7 +640,7 @@ Check Syntax is a part of the DrRacket collection, but is implemented via the to } @definterface[syncheck-annotations<%> ()]{ - + Classes implementing this interface are accceptors of information about a traversal of syntax objects. See @racket[make-traversal]. @@ -682,7 +682,7 @@ Check Syntax is a part of the DrRacket collection, but is implemented via the to Called to indicate that there is a @racket[require] at the location from @racket[start] to @racket[end], and that it corresponds to @racket[file]. Check Syntax adds a popup menu. } - + @defmethod[(syncheck:add-docs-menu [source-obj (not/c #f)] [start exact-nonnegative-integer?] [end exact-nonnegative-integer?] diff --git a/collects/scribblings/tools/unit.scrbl b/collects/scribblings/tools/unit.scrbl index 36226053de..db332576b1 100644 --- a/collects/scribblings/tools/unit.scrbl +++ b/collects/scribblings/tools/unit.scrbl @@ -150,12 +150,12 @@ Calls the definitions text's @defmethod[#:mode public-final (remove-bkg-running-color [id symbol?]) void?]{ - + Removes the color and label added with @racket[id]. - + See also @method[drracket:unit:tab<%> add-bkg-running-color]. } - + } @@ -599,7 +599,7 @@ Returns the currently active tab. } @defmethod[(get-tab-count) exact-positive-integer?]{ - Returns the number of open tabs in the frame. + Returns the number of open tabs in the frame. } @defmethod[(open-in-new-tab [filename (or/c path-string? #f)]) void?]{ diff --git a/collects/stepper/scribblings/stepper.scrbl b/collects/stepper/scribblings/stepper.scrbl index 937b29e812..ab949f10e4 100644 --- a/collects/stepper/scribblings/stepper.scrbl +++ b/collects/stepper/scribblings/stepper.scrbl @@ -72,25 +72,25 @@ language [*]: (define-values (f) (with-continuation-mark "#" (#%plain-lambda () (#%plain-app "#")) - (#%plain-app + (#%plain-app call-with-values - (#%plain-lambda () + (#%plain-lambda () (with-continuation-mark "#" - (#%plain-lambda () (#%plain-app + (#%plain-lambda () (#%plain-app "#" (#%plain-lambda () beginner:+))) (#%plain-app "#" - (#%plain-lambda (x) - (begin - (let-values (((arg0-1643 arg1-1644 arg2-1645) + (#%plain-lambda (x) + (begin + (let-values ([(arg0-1643 arg1-1644 arg2-1645) (#%plain-app values "#<*unevaluated-struct*>" "#<*unevaluated-struct*>" - "#<*unevaluated-struct*>"))) + "#<*unevaluated-struct*>")]) (with-continuation-mark "#" - (#%plain-lambda () + (#%plain-lambda () (#%plain-app "#" (#%plain-lambda () beginner:+) @@ -161,12 +161,12 @@ language [*]: #f (#%plain-lambda () (#%plain-app list f)))))))) -(let-values (((done-already?) (quote #f))) - (#%app dynamic-wind void +(let-values ([(done-already?) (quote #f)]) + (#%app dynamic-wind void (lambda () (#%app dynamic-require (quote (quote #%htdp)) (quote #f))) - (lambda () (if done-already? + (lambda () (if done-already? (#%app void) - (let-values () + (let-values () (set! done-already? (quote #t)) (#%app test*) (#%app current-namespace diff --git a/collects/syntax/scribblings/kerncase.scrbl b/collects/syntax/scribblings/kerncase.scrbl index d2ce8b1d82..dda0933326 100644 --- a/collects/syntax/scribblings/kerncase.scrbl +++ b/collects/syntax/scribblings/kerncase.scrbl @@ -2,9 +2,9 @@ @(require "common.rkt" (for-label syntax/kerncase)) @(define-syntax-rule (intro id) - (begin - (require (for-label mzscheme)) - (define id (racket if)))) + (begin + (require (for-label mzscheme)) + (define id (racket if)))) @(intro mzscheme-if) @; ---------------------------------------------------------------------- diff --git a/collects/syntax/scribblings/keyword.scrbl b/collects/syntax/scribblings/keyword.scrbl index cb198f6559..6f4f300868 100644 --- a/collects/syntax/scribblings/keyword.scrbl +++ b/collects/syntax/scribblings/keyword.scrbl @@ -11,8 +11,8 @@ @(begin (define the-eval - (parameterize ((sandbox-output 'string) - (sandbox-error-output 'string)) + (parameterize ([sandbox-output 'string] + [sandbox-error-output 'string]) (make-evaluator 'racket/base #:requires '(syntax/keyword)))) ;;(void (the-eval '(error-print-source-location #f))) (define-syntax-rule (myexamples e ...) diff --git a/collects/syntax/scribblings/module-reader.scrbl b/collects/syntax/scribblings/module-reader.scrbl index af5db2afb8..c998a519d5 100644 --- a/collects/syntax/scribblings/module-reader.scrbl +++ b/collects/syntax/scribblings/module-reader.scrbl @@ -6,11 +6,11 @@ read-syntax-inside read-inside))) @(begin - (define-syntax-rule (define-mb name) - (begin - (require (for-label scheme/base)) - (define name @racket[#%module-begin]))) - (define-mb scheme-#%module-begin)) + (define-syntax-rule (define-mb name) + (begin + (require (for-label scheme/base)) + (define name @racket[#%module-begin]))) + (define-mb scheme-#%module-begin)) @(define guide-doc '(lib "scribblings/guide/guide.scrbl")) diff --git a/collects/syntax/scribblings/parse/ex-exprc.scrbl b/collects/syntax/scribblings/parse/ex-exprc.scrbl index 4a8fba6395..241b49408e 100644 --- a/collects/syntax/scribblings/parse/ex-exprc.scrbl +++ b/collects/syntax/scribblings/parse/ex-exprc.scrbl @@ -23,11 +23,11 @@ the parameter expressions. [(_ ((p v:expr) ...) body:expr) #:declare p (expr/c #'parameter? #:name "parameter argument") - #'(parameterize ((p.c v) ...) body)])) -(myparameterize ((current-input-port - (open-input-string "(1 2 3)"))) + #'(parameterize ([p.c v] ...) body)])) +(myparameterize ([current-input-port + (open-input-string "(1 2 3)")]) (read)) -(myparameterize (('whoops 'something)) +(myparameterize (['whoops 'something]) 'whatever) ] diff --git a/collects/teachpack/2htdp/scribblings/image.scrbl b/collects/teachpack/2htdp/scribblings/image.scrbl index 8ead596572..5c8ccb4aff 100644 --- a/collects/teachpack/2htdp/scribblings/image.scrbl +++ b/collects/teachpack/2htdp/scribblings/image.scrbl @@ -197,9 +197,9 @@ Unlike @racket[scene+curve], if the line passes outside of @racket[image], the i (beside empty-image (rectangle 10 10 "solid" "red")))] } - + @section{Polygons} - + @defproc*[([(triangle [side-length (and/c real? (not/c negative?))] [mode mode?] [color image-color?]) @@ -423,8 +423,7 @@ They all construct a triangle oriented as follows: (triangle/saa 200 90 40 "solid" "aquamarine") (triangle/saa 40 130 40 "solid" "lightseagreen")] } - - + @defproc*[([(square [side-len (and/c real? (not/c negative?))] [mode mode?] @@ -540,7 +539,7 @@ other. The top and bottom pair of angles is @racket[angle] and the left and righ [outline-mode (or/c 'outline "outline")] [pen-or-color (or/c pen? image-color?)]) image?])]{ - + Constructs a star-like polygon where the star is specified by two radii and a number of points. The first radius determines where the points begin, the second determines where they end, and the @racket[point-count] argument determines how many points the star has. @@ -569,7 +568,7 @@ the @racket[point-count] argument determines how many points the star has. (regular-polygon 20 8 "solid" "red")] } - + @defproc*[([(polygon [vertices (listof real-valued-posn?)] [mode mode?] [color image-color?]) @@ -656,8 +655,7 @@ the @racket[point-count] argument determines how many points the star has. (rectangle 30 30 "solid" "seagreen") (rectangle 40 40 "solid" "silver") (rectangle 50 50 "solid" "seagreen"))] - - + } @defproc[(overlay/offset [i1 image?] [x real?] [y real?] [i2 image?]) image?]{ @@ -776,8 +774,7 @@ the @racket[point-count] argument determines how many points the star has. (rectangle 40 40 50 "seagreen") (rectangle 30 30 50 "seagreen") (rectangle 20 20 50 "seagreen"))] - - + } @@ -868,8 +865,7 @@ the @racket[point-count] argument determines how many points the star has. (ellipse 20 50 "solid" "darkgray") (ellipse 20 30 "solid" "dimgray") (ellipse 20 10 "solid" "black"))] - - + } @defproc[(beside/align [y-place y-place?] [i1 image?] [i2 image?] [is image?] ...) image?]{ @@ -883,18 +879,17 @@ the @racket[point-count] argument determines how many points the star has. (ellipse 20 50 "solid" "mediumslateblue") (ellipse 20 30 "solid" "slateblue") (ellipse 20 10 "solid" "navy")) - + (beside/align "top" (ellipse 20 70 "solid" "mediumorchid") (ellipse 20 50 "solid" "darkorchid") (ellipse 20 30 "solid" "purple") (ellipse 20 10 "solid" "indigo")) - + (beside/align "baseline" (text "ijy" 18 "black") (text "ijy" 24 "black"))] - - + } @@ -906,8 +901,7 @@ the @racket[point-count] argument determines how many points the star has. (ellipse 50 20 "solid" "darkgray") (ellipse 30 20 "solid" "dimgray") (ellipse 10 20 "solid" "black"))] - - + } @defproc[(above/align [x-place x-place?] [i1 image?] [i2 image?] [is image?] ...) image?]{ @@ -921,14 +915,13 @@ the @racket[point-count] argument determines how many points the star has. (ellipse 50 20 "solid" "goldenrod") (ellipse 30 20 "solid" "darkgoldenrod") (ellipse 10 20 "solid" "sienna")) - + (above/align "left" (ellipse 70 20 "solid" "yellowgreen") (ellipse 50 20 "solid" "olivedrab") (ellipse 30 20 "solid" "darkolivegreen") (ellipse 10 20 "solid" "darkgreen"))] - - + } @section{Placing Images & Scenes} @@ -937,11 +930,11 @@ Placing images into scenes is particularly useful when building worlds and universes using @racket[2htdp/universe]. @defproc*[([(empty-scene [width (and/c real? (not/c negative?))] - [height (and/c real? (not/c negative?))]) - image?] + [height (and/c real? (not/c negative?))]) + image?] [(empty-scene [width (and/c real? (not/c negative?))] [height (and/c real? (not/c negative?))] - [color image-color?]) + [color image-color?]) image?])]{ Creates an empty scene, i.e., a white rectangle with a black outline. @@ -1071,14 +1064,14 @@ the parts that fit onto @racket[scene]. 20 10 0 1/2 20 90 0 1/2 "white") - + (scene+curve (rectangle 100 100 "solid" "black") -20 -20 0 1 120 120 0 1 "red")] } - + @section{Rotating, Scaling, Flipping, Cropping, and Framing Images} @defproc[(rotate [angle angle?] [image image?]) image?]{ @@ -1200,11 +1193,12 @@ more expensive than with the other shapes. @defform/subs[(bitmap bitmap-spec) ([bitmap-spec rel-string id])]{ - - Loads the bitmap specified by @racket[bitmap-spec]. If @racket[bitmap-spec] is a string, it is treated as a - relative path. If it is an identifier, it is treated like a require spec and used to refer to a file - in a collection. - + + Loads the bitmap specified by @racket[bitmap-spec]. If + @racket[bitmap-spec] is a string, it is treated as a relative path. + If it is an identifier, it is treated like a require spec and used to + refer to a file in a collection. + @image-examples[(bitmap icons/stop-16x16.png) (bitmap icons/b-run.png)] } @@ -1216,7 +1210,7 @@ more expensive than with the other shapes. you may find it simpler to download the image once with a browser and then paste it into your program or download it and use @racket[bitmap]. } - + @defproc[(image->color-list [image image?]) (listof color?)]{ Returns a list of colors that correspond to the colors in the image, reading from left to right, top to bottom. @@ -1271,7 +1265,7 @@ more expensive than with the other shapes. @defproc[(image-width [i image?]) (and/c integer? (not/c negative?) exact?)]{ Returns the width of @racket[i]. - + @image-examples[(image-width (ellipse 30 40 "solid" "orange")) (image-width (circle 30 "solid" "orange")) (image-width (beside (circle 20 "solid" "orange") @@ -1356,7 +1350,7 @@ This section lists predicates for the basic structures provided by the image lib The complete list of colors is available in the documentation for @racket[color-database<%>]. - + } @defstruct[color ([red (and/c natural-number/c (<=/c 255))] @@ -1433,7 +1427,7 @@ Using @racket["pinhole"] or @racket['pinhole] is only allowed when all of the im } @defproc[(step-count? [x any/c]) boolean?]{ - Determines if @racket[x] is an integer greater than or equal to @racket[1]. + Determines if @racket[x] is an integer greater than or equal to @racket[1]. } @defproc[(real-valued-posn? [x any/c]) boolean?]{ @@ -1530,7 +1524,7 @@ then the scene argument's pinhole is preserved. @image-examples[(pinhole-y (center-pinhole (rectangle 10 10 "solid" "red")))] } @defproc[(clear-pinhole [image image?]) image?]{ - Removes a pinhole from @racket[image] (if the image has a pinhole). + Removes a pinhole from @racket[image] (if the image has a pinhole). } @defproc[(overlay/pinhole [i1 image?] [i2 image?] [is image?] ...) image?]{ diff --git a/collects/teachpack/2htdp/scribblings/port.scrbl b/collects/teachpack/2htdp/scribblings/port.scrbl index 7eccb74ecf..4e06303821 100644 --- a/collects/teachpack/2htdp/scribblings/port.scrbl +++ b/collects/teachpack/2htdp/scribblings/port.scrbl @@ -197,35 +197,35 @@ The other big change concerns key event handling and mouse event @port[ @racketblock[ (define (change w a-key-event) - (cond - [(key=? a-key-event 'left) - (world-go w -DELTA)] - [(key=? a-key-event 'right) - (world-go w +DELTA)] - [(char? a-key-event) - w] - [(key=? a-key-event 'up) - (world-go w -DELTA)] - [(key=? a-key-event 'down) - (world-go w +DELTA)] - [else - w]))] + (cond + [(key=? a-key-event 'left) + (world-go w -DELTA)] + [(key=? a-key-event 'right) + (world-go w +DELTA)] + [(char? a-key-event) + w] + [(key=? a-key-event 'up) + (world-go w -DELTA)] + [(key=? a-key-event 'down) + (world-go w +DELTA)] + [else + w]))] @; --------------------------------- @racketblock[ (define (change w a-key-event) - (cond - [(key=? a-key-event "left") - (world-go w -DELTA)] - [(key=? a-key-event "right") - (world-go w +DELTA)] - [(= (string-length a-key-event) 1) - w] - [(key=? a-key-event "up") - (world-go w -DELTA)] - [(key=? a-key-event "down") - (world-go w +DELTA)] - [else - w])) + (cond + [(key=? a-key-event "left") + (world-go w -DELTA)] + [(key=? a-key-event "right") + (world-go w +DELTA)] + [(= (string-length a-key-event) 1) + w] + [(key=? a-key-event "up") + (world-go w -DELTA)] + [(key=? a-key-event "down") + (world-go w +DELTA)] + [else + w])) ]] Note how the @racket[char?] clause changed. Since all chars are now represented as strings containing one ``letter'', the program on the right diff --git a/collects/teachpack/htdp/scribblings/arrow-gui.scrbl b/collects/teachpack/htdp/scribblings/arrow-gui.scrbl index 8d69ea5c19..9ba01f8b8d 100644 --- a/collects/teachpack/htdp/scribblings/arrow-gui.scrbl +++ b/collects/teachpack/htdp/scribblings/arrow-gui.scrbl @@ -27,18 +27,17 @@ Example: @(begin #reader scribble/comment-reader (racketblock -;; Advanced +;; Advanced (define (make-model dir) - (lambda (b e) - (begin - (view dir) - (printf "~a ~n" (control))))) + (lambda (b e) + (begin + (view dir) + (printf "~a ~n" (control))))) -(connect - (make-model "left") - (make-model "right") - (make-model "up") - (make-model "down")) +(connect (make-model "left") + (make-model "right") + (make-model "up") + (make-model "down")) )) Now click on the four arrows. The message field contains the current direction, the print-out the prior contents of the message field. diff --git a/collects/teachpack/htdp/scribblings/gui.scrbl b/collects/teachpack/htdp/scribblings/gui.scrbl index ab9db7985b..5e547c8fce 100644 --- a/collects/teachpack/htdp/scribblings/gui.scrbl +++ b/collects/teachpack/htdp/scribblings/gui.scrbl @@ -82,11 +82,11 @@ Example 2: ;; set up window with three "lines": ;; a text field, a message, and two buttons ;; fill in text and click OKAY -(define w - (create-window - (list - (list text1) - (list msg1) - (list (make-button "OKAY" respond) - (make-button "QUIT" (lambda (e) (hide-window w))))))) +(define w + (create-window + (list + (list text1) + (list msg1) + (list (make-button "OKAY" respond) + (make-button "QUIT" (lambda (e) (hide-window w))))))) )) diff --git a/collects/test-engine/test-engine.scrbl b/collects/test-engine/test-engine.scrbl index 055ccd750b..fb4f9eca5b 100644 --- a/collects/test-engine/test-engine.scrbl +++ b/collects/test-engine/test-engine.scrbl @@ -53,9 +53,9 @@ Accepts at least two value-producing expressions. Structurally compares the firs value to each value subsequent value specified. It is an error to produce a function value.} - + @defform[(check-range (test number/c) (min number/c) (max number/c))]{ - + Accepts three number-producing expressions. Performs the following comparison: min <= test <= max.} diff --git a/collects/unstable/automata/scribblings/re.scrbl b/collects/unstable/automata/scribblings/re.scrbl index 2415b3bbf6..73f5f087cc 100644 --- a/collects/unstable/automata/scribblings/re.scrbl +++ b/collects/unstable/automata/scribblings/re.scrbl @@ -33,23 +33,28 @@ This module provides a macro for regular expression compilation. (dseq pat re-pat) pat])]{ Compiles a regular expression over match patterns to a @racket[machine]. - - The interpretation of the pattern language is mostly intuitive. The pattern language may be extended - with @racket[define-re-transformer]. @racket[dseq] allows bindings of the @racket[match] pattern to be - used in the rest of the regular expression. (Thus, they are not @emph{really} regular expressions.) - @racket[unquote] escapes to Racket to evaluate an expression that evaluates to a regular expression (this happens - once, at compile time.) @racket[rec] binds a Racket identifier to a delayed version of the inner expression; even - if the expression is initially accepting, this delayed version is never accepting. - - The compiler will use an NFA, provided @racket[complement] and @racket[dseq] are not used. Otherwise, - many NFAs connected with the machine simulation functions from @racketmodname[unstable/automata/machine] are used. + + The interpretation of the pattern language is mostly intuitive. The + pattern language may be extended with @racket[define-re-transformer]. + @racket[dseq] allows bindings of the @racket[match] pattern to be used + in the rest of the regular expression. (Thus, they are not + @emph{really} regular expressions.) @racket[unquote] escapes to Racket + to evaluate an expression that evaluates to a regular expression (this + happens once, at compile time.) @racket[rec] binds a Racket identifier + to a delayed version of the inner expression; even if the expression is + initially accepting, this delayed version is never accepting. + + The compiler will use an NFA, provided @racket[complement] and + @racket[dseq] are not used. Otherwise, many NFAs connected with the + machine simulation functions from + @racketmodname[unstable/automata/machine] are used. } - + @(define-syntax-rule (defidforms (id ...) . dat) (deftogether ((defidform id) ...) . dat)) - + @defidforms[(complement seq union star epsilon nullset dseq rec)]{ - Bindings for use in @racket[re]. + Bindings for use in @racket[re]. } @defform[(define-re-transformer id expr)]{ @@ -127,9 +132,9 @@ This module provides a few transformers that extend the syntax of regular expres [(list "B")]) (define-re-transformer my-opt - (syntax-rules () - [(_ pat) - (union epsilon pat)])) + (syntax-rules () + [(_ pat) + (union epsilon pat)])) (test-re (my-opt "A") [(list) diff --git a/collects/unstable/scribblings/generics.scrbl b/collects/unstable/scribblings/generics.scrbl index fb9c8113bf..a0e48eb3f2 100644 --- a/collects/unstable/scribblings/generics.scrbl +++ b/collects/unstable/scribblings/generics.scrbl @@ -23,19 +23,27 @@ [prop:name identifier?] [name? identifier?] [method identifier?])]{ - -Defines @racket[name] as a transformer binding for the static information about a new generic group. -Defines @racket[prop:name] as a structure -type property. Structure types implementing this generic group should have this property where the value is a vector -with one element per @racket[method] where each value is -either @racket[#f] or a procedure with the same arity as specified by @racket[kw-formals*]. -(@racket[kw-formals*] is similar to the @racket[kw-formals] used by @racket[lambda], except no expression is given for optional arguments.) -The arity of each method is checked by the guard on the structure type property. +Defines @racket[name] as a transformer binding for the static +information about a new generic group. -Defines @racket[name?] as a predicate identifying instances of structure types that implement this generic group. +Defines @racket[prop:name] as a structure type property. Structure +types implementing this generic group should have this property where +the value is a vector with one element per @racket[method] where each +value is either @racket[#f] or a procedure with the same arity as +specified by @racket[kw-formals*]. (@racket[kw-formals*] is similar to +the @racket[kw-formals] used by @racket[lambda], except no expression is +given for optional arguments.) The arity of each method is checked by +the guard on the structure type property. -Defines each @racket[method] as a generic procedure that calls the corresponding method on values where @racket[name?] is true. Each method must have a required by-position argument that is @racket[free-identifier=?] to @racket[name]. This argument is used in the generic definition to locate the specialization. +Defines @racket[name?] as a predicate identifying instances of structure +types that implement this generic group. + +Defines each @racket[method] as a generic procedure that calls the +corresponding method on values where @racket[name?] is true. Each method +must have a required by-position argument that is +@racket[free-identifier=?] to @racket[name]. This argument is used in +the generic definition to locate the specialization. } @@ -56,36 +64,43 @@ where @racket[_prop:name] and @racket[_name?] are created with the lexical context of @racket[name]. } - + @defform[(define-methods name definition ...) #:contracts ([name identifier?])]{ -@racket[name] must be a transformer binding for the static information about a new generic group. - -Expands to a value usable as the property value for the structure type property of the @racket[name] generic group. - -If the @racket[definition]s define the methods of @racket[name], then they are used in the property value. +@racket[name] must be a transformer binding for the static information +about a new generic group. -If any method of @racket[name] is not defined, then @racket[#f] is used to signify that the structure type does not implement the particular method. +Expands to a value usable as the property value for the structure type +property of the @racket[name] generic group. + +If the @racket[definition]s define the methods of @racket[name], then +they are used in the property value. + +If any method of @racket[name] is not defined, then @racket[#f] is used +to signify that the structure type does not implement the particular +method. Allows @racket[define/generic] to appear in @racket[definition ...]. } - + @defform[(define/generic local-name method-name) #:contracts ([local-name identifier?] [method-name identifier?])]{ - -When used inside @racket[define-methods], binds @racket[local-name] to the generic for @racket[method-name]. This is useful for method specializations to use the generic methods on other values. - + +When used inside @racket[define-methods], binds @racket[local-name] to +the generic for @racket[method-name]. This is useful for method +specializations to use the generic methods on other values. + Syntactically an error when used outside @racket[define-methods]. } - + @; Examples -@(require scribble/eval) +@(require scribble/eval) @(define (new-evaluator) (let* ([e (make-base-eval)]) (e '(require (for-syntax racket/base) diff --git a/collects/unstable/scribblings/markparam.scrbl b/collects/unstable/scribblings/markparam.scrbl index e96bf7a40a..433128f925 100644 --- a/collects/unstable/scribblings/markparam.scrbl +++ b/collects/unstable/scribblings/markparam.scrbl @@ -29,9 +29,18 @@ This library provides a simplified version of parameters that are backed by cont [none-v [any/c #f]] [tag continuation-prompt-tag? default-continuation-prompt-tag]) (listof vector?)]{ - Returns the values of the @racket[mps] up to @racket[tag]. The length of each vector in the result list is the same as the length of @racket[mps], and a value in a particular vector position is the value for the corresponding mark parameter in @racket[mps]. Values for multiple mark parameter appear in a single vector only when the mark parameters are for the same continuation frame in the current continuation. The @racket[none-v] argument is used for vector elements to indicate the lack of a value. - } - + Returns the values of the @racket[mps] up to @racket[tag]. The length + of each vector in the result list is the same as the length of + @racket[mps], and a value in a particular vector position is the value + for the corresponding mark parameter in @racket[mps]. Values for + multiple mark parameter appear in a single vector only when the mark + parameters are for the same continuation frame in the current + continuation. The @racket[none-v] argument is used for vector elements + to indicate the lack of a value. +} + @defform[(mark-parameterize ([mp expr] ...) body-expr ...)]{ - Parameterizes @racket[(begin body-expr ...)] by associating each @racket[mp] with the evaluation of @racket[expr] in the parameterization of the entire expression. - } + Parameterizes @racket[(begin body-expr ...)] by associating each + @racket[mp] with the evaluation of @racket[expr] in the + parameterization of the entire expression. +} diff --git a/collects/unstable/scribblings/wrapc.scrbl b/collects/unstable/scribblings/wrapc.scrbl index 99cdcd7200..137e57a989 100644 --- a/collects/unstable/scribblings/wrapc.scrbl +++ b/collects/unstable/scribblings/wrapc.scrbl @@ -40,16 +40,16 @@ The other arguments have the same meaning as for @racket[expr/c]. @examples[#:eval the-eval (define-syntax (myparameterize1 stx) (syntax-case stx () - [(_ ((p v)) body) + [(_ ([p v]) body) (with-syntax ([cp (wrap-expr/c #'parameter? #'p #:name "the parameter argument" #:context stx)]) - #'(parameterize ((cp v)) body))])) -(myparameterize1 ((current-input-port - (open-input-string "(1 2 3)"))) + #'(parameterize ([cp v]) body))])) +(myparameterize1 ([current-input-port + (open-input-string "(1 2 3)")]) (read)) -(myparameterize1 (('whoops 'something)) +(myparameterize1 (['whoops 'something]) 'whatever) (module mod racket diff --git a/collects/web-server/scribblings/closure.scrbl b/collects/web-server/scribblings/closure.scrbl index b5175b0757..96ae17eab1 100644 --- a/collects/web-server/scribblings/closure.scrbl +++ b/collects/web-server/scribblings/closure.scrbl @@ -7,20 +7,21 @@ web-server/lang/serial-lambda web-server/private/define-closure)) - -The defunctionalization process of the Web Language (see @secref["stateless" #:doc '(lib "web-server/scribblings/web-server.scrbl")]) +The defunctionalization process of the Web Language (see +@secref["stateless" #:doc '(lib "web-server/scribblings/web-server.scrbl")]) requires an explicit representation of closures that is serializable. @defmodule[web-server/lang/serial-lambda]{ - + @defform[(serial-lambda formals body ...)]{ - Returns @racket[(lambda formals body ...)], except it is serializable. + Returns @racket[(lambda formals body ...)], except it is serializable. } - + @defform[(serial-case-lambda [formals body ...] ...)]{ - Returns @racket[(case-lambda [formals body ...] ...)], except it is serializable. + Returns @racket[(case-lambda [formals body ...] ...)], except it is + serializable. } - + } @section[#:style 'hidden]{Definition Syntax} diff --git a/collects/web-server/scribblings/contracts.scrbl b/collects/web-server/scribblings/contracts.scrbl index b83bdef33f..f4c9f187b7 100644 --- a/collects/web-server/scribblings/contracts.scrbl +++ b/collects/web-server/scribblings/contracts.scrbl @@ -7,7 +7,7 @@ web-server/servlet)) @defmodule[web-server/servlet/servlet-structs]{ - + Servlets communicate to the Web Server by returning HTTP responses. In order to accommodate lightweight programs (and backwards compatibility), the Web Server provides an indirection from application-specific response formats and the internal diff --git a/collects/web-server/scribblings/dispatch-servlets.scrbl b/collects/web-server/scribblings/dispatch-servlets.scrbl index 3543b0124c..a184c0f168 100644 --- a/collects/web-server/scribblings/dispatch-servlets.scrbl +++ b/collects/web-server/scribblings/dispatch-servlets.scrbl @@ -17,14 +17,15 @@ @defproc[(make-cached-url->servlet [url->path url->path/c] - [path->serlvet path->servlet/c]) + [path->serlvet path->servlet/c]) (values (-> void) url->servlet/c)]{ - The first return value flushes the cache. - The second is a procedure that uses @racket[url->path] to resolve the URL to a path, then uses @racket[path->servlet] to resolve - that path to a servlet, caching the results in an internal table. + The first return value flushes the cache. The second is a procedure + that uses @racket[url->path] to resolve the URL to a path, then uses + @racket[path->servlet] to resolve that path to a servlet, caching the + results in an internal table. } - + @defproc[(make [url->servlet url->servlet/c] [#:responders-servlet-loading responders-servlet-loading @@ -35,11 +36,14 @@ (url? exn? . -> . can-be-response?) servlet-error-responder]) dispatcher/c]{ - This dispatcher runs racket servlets, using @racket[url->servlet] to resolve URLs to the underlying servlets. - If servlets have errors loading, then @racket[responders-servlet-loading] is used. Other errors are handled with - @racket[responders-servlet]. If a servlet raises calls @racket[next-dispatcher], then the signal is propagated by this dispatcher. + This dispatcher runs racket servlets, using @racket[url->servlet] to + resolve URLs to the underlying servlets. If servlets have errors + loading, then @racket[responders-servlet-loading] is used. Other errors + are handled with @racket[responders-servlet]. If a servlet raises calls + @racket[next-dispatcher], then the signal is propagated by this + dispatcher. } - + } @include-section["servlet-setup.scrbl"] @@ -48,18 +52,18 @@ @section{Internal Servlet Representation} -@defmodule[web-server/private/servlet]{ - @defstruct[servlet ([custodian custodian?] - [namespace namespace?] - [manager manager?] - [directory path-string?] - [handler (request? . -> . can-be-response?)]) - #:mutable]{ - Instances of this structure hold the necessary parts of a servlet: - the @racket[custodian] responsible for the servlet's resources, - the @racket[namespace] the servlet is executed within, - the @racket[manager] responsible for the servlet's continuations, - the current @racket[directory] of the servlet, - and the @racket[handler] for all requests to the servlet. - } +@defmodule[web-server/private/servlet]{ + @defstruct[servlet ([custodian custodian?] + [namespace namespace?] + [manager manager?] + [directory path-string?] + [handler (request? . -> . can-be-response?)]) + #:mutable]{ + Instances of this structure hold the necessary parts of a servlet: + the @racket[custodian] responsible for the servlet's resources, + the @racket[namespace] the servlet is executed within, + the @racket[manager] responsible for the servlet's continuations, + the current @racket[directory] of the servlet, + and the @racket[handler] for all requests to the servlet. + } } diff --git a/collects/web-server/scribblings/dispatchers.scrbl b/collects/web-server/scribblings/dispatchers.scrbl index 2cef0a3ff9..8fe2931aad 100644 --- a/collects/web-server/scribblings/dispatchers.scrbl +++ b/collects/web-server/scribblings/dispatchers.scrbl @@ -98,16 +98,18 @@ URLs to paths on the filesystem. This is primarily useful for dispatchers that allow path information after the name of a service to be used for data, but where the service is represented by a file. The most prominent example is obviously servlets.} - + @defproc[(filter-url->path [regex regexp?] [url->path url->path/c]) url->path/c]{ - Runs the underlying @racket[url->path] but will only return if the path, when considered as a string, - matches the @racket[regex]. This is useful to disallow strange files, like GIFs, from being considered - servlets when using the servlet dispatchers. It will return a @racket[exn:fail:filesystem:exists?] exception if - the path does not match. + Runs the underlying @racket[url->path] but will only return if the + path, when considered as a string, matches the @racket[regex]. This is + useful to disallow strange files, like GIFs, from being considered + servlets when using the servlet dispatchers. It will return a + @racket[exn:fail:filesystem:exists?] exception if the path does not + match. } - + } @; ------------------------------------------------------------ @@ -249,35 +251,37 @@ a URL that refreshes the password file, servlet cache, etc.} web-server/configuration/responders)) @defthing[denied?/c contract?]{ - Equivalent to @racket[(request? . -> . (or/c false/c string?))]. - The return is the authentication realm as a string if the request is not authorized and - @racket[#f] if the request @emph{is} authorized. -} - + Equivalent to @racket[(request? . -> . (or/c false/c string?))]. The + return is the authentication realm as a string if the request is not + authorized and @racket[#f] if the request @emph{is} authorized. +} + @defproc[(make [denied? denied?/c] [#:authentication-responder authentication-responder (url? header? . -> . response?) (gen-authentication-responder "forbidden.html")]) dispatcher/c]{ - A dispatcher that checks if the request is denied based on @racket[denied?]. If so, then - @racket[authentication-responder] is called with a @racket[header] that - requests credentials. If not, then @racket[next-dispatcher] is - invoked. + A dispatcher that checks if the request is denied based on + @racket[denied?]. If so, then @racket[authentication-responder] is + called with a @racket[header] that requests credentials. If not, then + @racket[next-dispatcher] is invoked. } - + @defthing[authorized?/c contract?]{ - Equivalent to @racket[(string? (or/c false/c bytes?) (or/c false/c bytes?) . -> . (or/c false/c string?))]. - The input is the URI as a string and the username and passwords as bytes. - The return is the authentication realm as a string if the user is not authorized and - @racket[#f] if the request @emph{is} authorized. -} - + Equivalent to + @racket[(string? (or/c false/c bytes?) (or/c false/c bytes?) . -> . (or/c false/c string?))]. + The input is the URI as a string and the username and passwords as + bytes. The return is the authentication realm as a string if the user + is not authorized and @racket[#f] if the request @emph{is} authorized. +} + @defproc[(make-basic-denied?/path [password-file path-string?]) (values (-> void) authorized?/c)]{ - Creates an authorization procedure based on the given password file. The first returned value - is a procedure that refreshes the password cache used by the authorization procedure. + Creates an authorization procedure based on the given password + file. The first returned value is a procedure that refreshes the + password cache used by the authorization procedure. @racket[password-file] is parsed as: @racketblock[(list ([domain : string?] @@ -361,14 +365,14 @@ a URL that refreshes the password file, servlet cache, etc.} If @racket[over-limit] is @racket['kill-old], then the oldest request handler is killed---prioritizing new connections over old. (This setting is a little dangerous because requests might never finish if there is constant load.) }} - + @(require (for-label web-server/web-server web-server/http (prefix-in limit: web-server/dispatchers/limit) (prefix-in filter: web-server/dispatchers/dispatch-filter) (prefix-in sequencer: web-server/dispatchers/dispatch-sequencer))) - + Consider this example: @racketmod[ racket diff --git a/collects/web-server/scribblings/formlets.scrbl b/collects/web-server/scribblings/formlets.scrbl index c9fdb22173..5b418316bb 100644 --- a/collects/web-server/scribblings/formlets.scrbl +++ b/collects/web-server/scribblings/formlets.scrbl @@ -23,9 +23,8 @@ Suppose we want to create an abstraction of entering a date in an HTML form. The @racketblock[ (define date-formlet (formlet - (div - "Month:" ,{input-int . => . month} - "Day:" ,{input-int . => . day}) + (div "Month:" ,{input-int . => . month} + "Day:" ,{input-int . => . day}) (list month day))) ] @@ -203,7 +202,7 @@ types. Refer to @secref["input-formlets"] for example low-level formlets using t (values xexpr-forest/c ((listof binding?) . -> . (values (coerce-contract 'formlet/c content) ...)) integer?))]. - + A @tech{formlet}'s internal representation is a function from an initial input number to an @xexpr forest rendering, a processing function, and the next allowable input number. @@ -233,38 +232,41 @@ types. Refer to @secref["input-formlets"] for example low-level formlets using t @defproc[(xml-forest [r xexpr-forest/c]) (formlet/c procedure?)]{ - Constructs a @tech{formlet} with the rendering @racket[r] and the identity procedure as the processing step. + Constructs a @tech{formlet} with the rendering @racket[r] and the + identity procedure as the processing step. } @defproc[(xml [r xexpr/c]) (formlet/c procedure?)]{ - Equivalent to @racket[(xml-forest (list r))]. + Equivalent to @racket[(xml-forest (list r))]. } - + @defproc[(text [r string?]) (formlet/c procedure?)]{ - Equivalent to @racket[(xml r)]. + Equivalent to @racket[(xml r)]. } - + @defproc[(tag-xexpr [tag symbol?] [attrs (listof (list/c symbol? string?))] [inner (formlet/c any/c)]) (formlet/c any/c)]{ - Constructs a @tech{formlet} with the rendering @racket[(list (list* tag attrs inner-rendering))] where @racket[inner-rendering] is - the rendering of @racket[inner] and the processing stage identical to @racket[inner]. + Constructs a @tech{formlet} with the rendering @racket[(list (list* + tag attrs inner-rendering))] where @racket[inner-rendering] is the + rendering of @racket[inner] and the processing stage identical to + @racket[inner]. } @defproc[(formlet-display [f (formlet/c any/c)]) xexpr-forest/c]{ - Renders @racket[f]. + Renders @racket[f]. } - + @defproc[(formlet-process [f (formlet/c any/c ...)] [r request?]) (values any/c ...)]{ - Runs the processing stage of @racket[f] on the bindings in @racket[r]. + Runs the processing stage of @racket[f] on the bindings in @racket[r]. } - + } @section[#:tag "input-formlets"]{Predefined Formlets} @@ -273,81 +275,90 @@ types. Refer to @secref["input-formlets"] for example low-level formlets using t @defmodule[web-server/formlets/input]{ These @tech{formlet}s are the main combinators for form input. - + @defproc[(make-input [render (string? . -> . xexpr/c)]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} is rendered with @racket[render], which is passed the input name, and results in the - extracted @racket[binding]. -} - + This @tech{formlet} is rendered with @racket[render], which is passed + the input name, and results in the extracted @racket[binding]. +} + @defproc[(make-input* [render (string? . -> . xexpr/c)]) (formlet/c (listof binding?))]{ - This @tech{formlet} is rendered with @racket[render], which is passed the input name, and results in all the - @racket[binding]s that use the name. + This @tech{formlet} is rendered with @racket[render], which is passed + the input name, and results in all the @racket[binding]s that use the + name. } - + @defproc[(text-input [#:value value (or/c false/c bytes?) #f] [#:size size (or/c false/c exact-nonnegative-integer?) #f] [#:max-length max-length (or/c false/c exact-nonnegative-integer?) #f] [#:read-only? read-only? boolean? #f] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using an INPUT element with the TEXT type and the attributes given in the arguments. + This @tech{formlet} renders using an INPUT element with the TEXT type + and the attributes given in the arguments. } - + @defproc[(password-input [#:value value (or/c false/c bytes?) #f] [#:size size (or/c false/c exact-nonnegative-integer?) #f] [#:max-length max-length (or/c false/c exact-nonnegative-integer?) #f] [#:read-only? read-only? boolean? #f] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using an INPUT element with the PASSWORD type and the attributes given in the arguments. + This @tech{formlet} renders using an INPUT element with the PASSWORD + type and the attributes given in the arguments. } - + @defproc[(textarea-input [#:value value (or/c false/c bytes?) #f] [#:rows rows (or/c false/c number?) #f] [#:cols cols (or/c false/c number?) #f] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using an TEXTAREA element with attributes given in the arguments. + This @tech{formlet} renders using an TEXTAREA element with attributes + given in the arguments. } - + @defproc[(checkbox [value bytes?] [checked? boolean?] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using an INPUT element with the CHECKBOX type and the attributes given in the arguments. + This @tech{formlet} renders using an INPUT element with the CHECKBOX + type and the attributes given in the arguments. } - + @defproc[(radio [value bytes?] [checked? boolean?] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ This @tech{formlet} renders using an INPUT element with the RADIO type and the attributes given in the arguments. } - -@defproc[(submit [value bytes?] + +@defproc[(submit [value bytes?] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using an INPUT element with the SUBMIT type and the attributes given in the arguments. + This @tech{formlet} renders using an INPUT element with the SUBMIT + type and the attributes given in the arguments. } - + @defproc[(reset [value bytes?] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using an INPUT element with the RESET type and the attributes given in the arguments. + This @tech{formlet} renders using an INPUT element with the RESET type + and the attributes given in the arguments. } @defproc[(file-upload [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using an INPUT element with the FILE type and the attributes given in the arguments. + This @tech{formlet} renders using an INPUT element with the FILE type + and the attributes given in the arguments. } - + @defproc[(hidden [value bytes?] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using an INPUT element with HIDDEN type and the attributes given in the arguments. + This @tech{formlet} renders using an INPUT element with HIDDEN type + and the attributes given in the arguments. } - + @defproc[(img [alt bytes?] [src bytes?] [#:height height (or/c false/c exact-nonnegative-integer?) #f] @@ -356,25 +367,32 @@ These @tech{formlet}s are the main combinators for form input. [#:width width (or/c false/c exact-nonnegative-integer?) #f] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using an IMG element with the attributes given in the arguments. + This @tech{formlet} renders using an IMG element with the attributes + given in the arguments. } - + @defproc[(button [type bytes?] [button-text bytes?] [#:disabled disabled boolean? #f] [#:value value (or/c false/c bytes?) #f] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{ - This @tech{formlet} renders using a BUTTON element with the attributes given in the arguments. @racket[button-text] is the text that will appear on the button when rendered. -} - + This @tech{formlet} renders using a BUTTON element with the attributes + given in the arguments. @racket[button-text] is the text that will + appear on the button when rendered. +} + @defproc[(multiselect-input [l sequence?] [#:attributes attrs (listof (list/c symbol? string?)) empty] [#:multiple? multiple? boolean? #t] [#:selected? selected? (any/c . -> . boolean?) (λ (x) #f)] [#:display display (any/c . -> . xexpr/c) (λ (x) x)]) (formlet/c list?)]{ - This @tech{formlet} renders using an SELECT element with the attributes given with an OPTION for each element of the sequence. If @racket[multiple?] is @racket[#t], then multiple options may be selected. An element is selected if @racket[selected?] returns @racket[#t]. Elements are displayed with @racket[display]. + This @tech{formlet} renders using an SELECT element with the + attributes given with an OPTION for each element of the sequence. If + @racket[multiple?] is @racket[#t], then multiple options may be + selected. An element is selected if @racket[selected?] returns + @racket[#t]. Elements are displayed with @racket[display]. } @defproc[(select-input [l sequence?] @@ -382,51 +400,62 @@ These @tech{formlet}s are the main combinators for form input. [#:selected? selected? (any/c . -> . boolean?) (λ (x) #f)] [#:display display (any/c . -> . xexpr/c) (λ (x) x)]) (formlet/c any/c)]{ - This @tech{formlet} renders using an SELECT element with the attributes given with an OPTION for each element of the sequence. An element is selected if @racket[selected?] returns @racket[#t]. Elements are displayed with @racket[display]. + This @tech{formlet} renders using an SELECT element with the + attributes given with an OPTION for each element of the sequence. An + element is selected if @racket[selected?] returns + @racket[#t]. Elements are displayed with @racket[display]. } - + @defproc[(required [f (formlet/c (or/c false/c binding?))]) (formlet/c bytes?)]{ - Constructs a @tech{formlet} that extracts the @racket[binding:form-value] from the binding produced by @racket[f], or errors. + Constructs a @tech{formlet} that extracts the + @racket[binding:form-value] from the binding produced by @racket[f], + or errors. } @defproc[(default [def bytes?] [f (formlet/c (or/c false/c binding?))]) (formlet/c bytes?)]{ - Constructs a @tech{formlet} that extracts the @racket[binding:form-value] from the binding produced by @racket[f], or returns @racket[def]. + Constructs a @tech{formlet} that extracts the + @racket[binding:form-value] from the binding produced by @racket[f], + or returns @racket[def]. } - + @defproc[(to-string [f (formlet/c bytes?)]) (formlet/c string?)]{ - Converts @racket[f]'s output to a string. Equivalent to @racket[(cross (pure bytes->string/utf-8) f)]. -} - + Converts @racket[f]'s output to a string. Equivalent to + @racket[(cross (pure bytes->string/utf-8) f)]. +} + @defproc[(to-number [f (formlet/c string?)]) (formlet/c number?)]{ - Converts @racket[f]'s output to a number. Equivalent to @racket[(cross (pure string->number) f)]. -} + Converts @racket[f]'s output to a number. Equivalent to @racket[(cross + (pure string->number) f)]. +} @defproc[(to-symbol [f (formlet/c string?)]) (formlet/c symbol?)]{ - Converts @racket[f]'s output to a symbol. Equivalent to @racket[(cross (pure string->symbol) f)]. -} + Converts @racket[f]'s output to a symbol. Equivalent to + @racket[(cross (pure string->symbol) f)]. +} @defproc[(to-boolean [f (formlet/c bytes?)]) (formlet/c boolean?)]{ - Converts @racket[f]'s output to a boolean, if it is equal to @racket[#"on"]. + Converts @racket[f]'s output to a boolean, if it is equal to + @racket[#"on"]. } - + @defthing[input-string (formlet/c string?)]{ - Equivalent to @racket[(to-string (required (text-input)))]. + Equivalent to @racket[(to-string (required (text-input)))]. } @defthing[input-int (formlet/c integer?)]{ - Equivalent to @racket[(to-number input-string)]. + Equivalent to @racket[(to-number input-string)]. } @defthing[input-symbol (formlet/c symbol?)]{ - Equivalent to @racket[(to-symbol input-string)]. + Equivalent to @racket[(to-symbol input-string)]. } } @@ -446,16 +475,18 @@ A few utilities are provided for using @tech{formlet}s in Web applications. `(html (head (title "Form Entry")) (body ,form-xexpr)))]) (values any/c ...)]{ - Uses @racket[send/suspend] and @racket[response/xexpr] to send @racket[f]'s rendering (wrapped in a FORM tag whose action is - the continuation URL (wrapped again by @racket[wrapper])) to the client. - When the form is submitted, the request is passed to the - processing stage of @racket[f]. + Uses @racket[send/suspend] and @racket[response/xexpr] to send + @racket[f]'s rendering (wrapped in a FORM tag whose action is the + continuation URL (wrapped again by @racket[wrapper])) to the client. + When the form is submitted, the request is passed to the processing + stage of @racket[f]. } - + @defproc[(embed-formlet [embed/url ((request? . -> . any) . -> . string?)] [f (formlet/c any/c ...)]) xexpr/c]{ - Like @racket[send/formlet], but for use with @racket[send/suspend/dispatch]. + Like @racket[send/formlet], but for use with + @racket[send/suspend/dispatch]. } } diff --git a/collects/web-server/scribblings/http.scrbl b/collects/web-server/scribblings/http.scrbl index 1d7778b52a..299441b7e0 100644 --- a/collects/web-server/scribblings/http.scrbl +++ b/collects/web-server/scribblings/http.scrbl @@ -69,12 +69,12 @@ The @web-server implements many HTTP libraries that are provided by this module. You are @bold{unlikely to need to construct} a request struct. } - + @defproc[(request-bindings/raw [r request?]) (listof binding?)]{ Forces @racket[(request-bindings/raw-promise r)]. } - + Here is an example typical of what you will find in many applications: @racketblock[ (define (get-number req) @@ -181,12 +181,12 @@ Here is an example typical of what you will find in many applications: (λ (op) (write-bytes #"Moved" op))) ] } - + @defproc[(response/full [code number?] [message bytes?] [seconds number?] [mime bytes?] [headers (listof header?)] [body (listof bytes?)]) response?]{ A constructor for responses where @racket[body] is the response body. - + Example: @racketblock[ (response/full @@ -261,7 +261,7 @@ transmission that the server @bold{will not catch}.} @warning{When using cookies, make sure you follow the advice of the @link["http://cookies.lcs.mit.edu/"]{MIT Cookie Eaters}, or you will be susceptible to dangerous attacks.} -} +} @; ------------------------------------------------------------ @section[#:tag "cookie-parse"]{Extracting Cookies} @@ -277,9 +277,10 @@ transmission that the server @bold{will not catch}.} [value string?] [domain (or/c false/c valid-domain?)] [path (or/c false/c string?)])]{ - - While server cookies are represented with @racket[cookie?]s, cookies that come from the client are represented - with a @racket[client-cookie] structure. + + While server cookies are represented with @racket[cookie?]s, cookies + that come from the client are represented with a + @racket[client-cookie] structure. } @defproc[(request-cookies [req request?]) @@ -364,7 +365,7 @@ An implementation of HTTP Basic Authentication. Returns a pair of the username and password from the authentication header in @racket[req] if they are present, or @racket[#f]. } - + Example: @racketmod[ web-server/insta @@ -408,32 +409,36 @@ An implementation of HTTP Digest Authentication. (or/c false/c (listof (cons/c symbol? string?)))]{ Returns the Digest credentials from @racket[req] (if they appear) as an association list. } - + @defthing[username*realm->password/c contract?]{ - Used to look up the password for a user is a realm. - - Equivalent to @racket[(string? string? . -> . string?)]. + Used to look up the password for a user is a realm. + + Equivalent to @racket[(string? string? . -> . string?)]. } @defthing[username*realm->digest-HA1/c contract?]{ Used to compute the user's secret hash. - + Equivalent to @racket[(string? string? . -> . bytes?)]. -} - +} + @defproc[(password->digest-HA1 [lookup-password username*realm->password/c]) username*realm->digest-HA1/c]{ - Uses @racket[lookup-password] to find the password, then computes the secret hash of it. -} - + Uses @racket[lookup-password] to find the password, then computes the + secret hash of it. +} + @defproc[(make-check-digest-credentials [lookup-HA1 username*realm->digest-HA1/c]) (string? (listof (cons/c symbol? string?)) . -> . boolean?)]{ - Constructs a function that checks whether particular Digest credentials (the second argument of the returned function) - are correct given the HTTP method provided as the first argument and the secret hash computed by @racket[lookup-HA1]. - - This is will result in an exception if the Digest credentials are missing portions. -} - + Constructs a function that checks whether particular Digest credentials + (the second argument of the returned function) are correct given the + HTTP method provided as the first argument and the secret hash computed + by @racket[lookup-HA1]. + + This is will result in an exception if the Digest credentials are + missing portions. +} + Example: @racketmod[ web-server/insta @@ -471,7 +476,7 @@ web-server/insta xml)) @defmodule[web-server/http/xexpr]{ - + @defproc[(response/xexpr [xexpr xexpr/c] [#:code code number? 200] [#:message message bytes? #"Okay"] diff --git a/collects/web-server/scribblings/lang-api.scrbl b/collects/web-server/scribblings/lang-api.scrbl index 0724cfc4e9..5717c4fccd 100644 --- a/collects/web-server/scribblings/lang-api.scrbl +++ b/collects/web-server/scribblings/lang-api.scrbl @@ -45,9 +45,9 @@ An example @racket['stateless] servlet module: (provide interface-version stuffer start) (define interface-version 'stateless) (define stuffer - (stuffer-chain - serialize-stuffer - (md5-stuffer (build-path (find-system-path 'home-dir) ".urls")))) + (stuffer-chain + serialize-stuffer + (md5-stuffer (build-path (find-system-path 'home-dir) ".urls")))) (define (start req) (response/xexpr `(html (body (h2 "Look ma, no state!"))))) diff --git a/collects/web-server/scribblings/managers.scrbl b/collects/web-server/scribblings/managers.scrbl index 1ae24cff92..482f8f56ce 100644 --- a/collects/web-server/scribblings/managers.scrbl +++ b/collects/web-server/scribblings/managers.scrbl @@ -68,7 +68,7 @@ the users and implementers of managers. This exception should be thrown by a manager when a continuation is looked up that does not exist. } - + } @; ------------------------------------------------------------ diff --git a/collects/web-server/scribblings/namespace.scrbl b/collects/web-server/scribblings/namespace.scrbl index 303fcd7170..18b7ef752e 100644 --- a/collects/web-server/scribblings/namespace.scrbl +++ b/collects/web-server/scribblings/namespace.scrbl @@ -21,10 +21,11 @@ of @racketmodname[web-server/dispatchers/dispatch-servlets]. @defproc[(make-make-servlet-namespace (#:to-be-copied-module-specs to-be-copied-module-specs (listof module-path?))) make-servlet-namespace/c]{ -This function creates a function that when called will construct a new @racket[namespace] that -has all the modules from @racket[to-be-copied-module-specs] and @racket[additional-specs], as well -as @racket[racket] and @racket[mred], provided they are already attached -to the @racket[(current-namespace)] of the call-site. +This function creates a function that when called will construct a new +@racket[namespace] that has all the modules from +@racket[to-be-copied-module-specs] and @racket[additional-specs], as +well as @racket[racket] and @racket[mred], provided they are already +attached to the @racket[(current-namespace)] of the call-site. Example: @racketblock[ @@ -32,19 +33,22 @@ Example: #:to-be-copied-module-specs `((lib "database.rkt" "my-module"))) ] } - + } @section{Why this is useful} -A different namespace is needed for each servlet, so that if servlet A and servlet B both use -a stateful module C, they will be isolated from one another. We see the @web-server as -an operating system for servlets, so we inherit the isolation requirement on operating systems. +A different namespace is needed for each servlet, so that if servlet A +and servlet B both use a stateful module C, they will be isolated from +one another. We see the @web-server as an operating system for servlets, +so we inherit the isolation requirement on operating systems. -However, there are some modules which must be shared. If they were not, then structures cannot -be passed from the @web-server to the servlets, because Racket's structures are generative. +However, there are some modules which must be shared. If they were not, +then structures cannot be passed from the @web-server to the servlets, +because Racket's structures are generative. -Since, on occasion, a user will actually wanted servlets A and B to interact through module C. -A custom @racket[make-servlet-namespace] can be created, through this procedure, that attaches -module C to all servlet namespaces. Through other means (see @secref["dispatchers"]) different sets -of servlets can share different sets of modules. +Since, on occasion, a user will actually wanted servlets A and B to +interact through module C. A custom @racket[make-servlet-namespace] can +be created, through this procedure, that attaches module C to all +servlet namespaces. Through other means (see @secref["dispatchers"]) +different sets of servlets can share different sets of modules. diff --git a/collects/web-server/scribblings/native.scrbl b/collects/web-server/scribblings/native.scrbl index fab7fca102..c21493645f 100644 --- a/collects/web-server/scribblings/native.scrbl +++ b/collects/web-server/scribblings/native.scrbl @@ -9,18 +9,23 @@ @defmodule[web-server/lang/native]{ -It is sometimes inconvenient to use @racket[serial->native] and @racket[native->serial] throughout your program. -This module provides a macro for creating wrappers. +It is sometimes inconvenient to use @racket[serial->native] and +@racket[native->serial] throughout your program. This module provides a +macro for creating wrappers. + +@defform[#:literals (ho) + (define-native (native arg-spec ...) original) + #:contracts ([arg-spec ho] [arg-spec _])]{ + Builds an interface around @racket[original] named @racket[native] such + that calls to @racket[native] are wrapped in @racket[serial->native] + and all arguments marked with @racket[ho] in @racket[arg-spec] are + assumed to procedures and are wrapped in @racket[native->serial]. -@defform[#:literals (ho) (define-native (native arg-spec ...) original) #:contracts ([arg-spec ho] [arg-spec _])]{ - Builds an interface around @racket[original] named @racket[native] such that calls to @racket[native] are wrapped in @racket[serial->native] - and all arguments marked with @racket[ho] in @racket[arg-spec] are assumed to procedures and are wrapped in @racket[native->serial]. - For example, @racketblock[ (define-native (build-list/native _ ho) build-list) ] - + is equivalent to @racketblock[ (define (build-list/native fst snd) @@ -32,5 +37,5 @@ This module provides a macro for creating wrappers. (apply snd args)))))) ] } - + } diff --git a/collects/web-server/scribblings/page.scrbl b/collects/web-server/scribblings/page.scrbl index 5197e7e8c7..24c0f8e70d 100644 --- a/collects/web-server/scribblings/page.scrbl +++ b/collects/web-server/scribblings/page.scrbl @@ -39,33 +39,59 @@ A simple example: "You clicked!"))]) "Click me")))))] -Similarly, many Web applications make use almost exclusively of functions that are arguments to @racket[embed/url] and immediately invoke @racket[send/suspend/dispatch]. +Similarly, many Web applications make use almost exclusively of +functions that are arguments to @racket[embed/url] and immediately +invoke @racket[send/suspend/dispatch]. @deftogether[[@defform[(lambda/page formals e ...)] @defform[(define/page (id . formals) e ...)]]]{ -The @racket[lambda/page] and @racket[define/page] automate this by expanding to functions that accept a request as the first argument (followed by any arguments specified in @racket[formals]) and immediately wrap their body in @racket[page]. This functions also cooperate with @racket[get-binding] by binding the request to the @racket[current-request] parameter. + The @racket[lambda/page] and @racket[define/page] automate this by + expanding to functions that accept a request as the first argument + (followed by any arguments specified in @racket[formals]) and + immediately wrap their body in @racket[page]. This functions also + cooperate with @racket[get-binding] by binding the request to the + @racket[current-request] parameter. } - -The binding interface of @racketmodname[web-server/http] is powerful, but subtle to use conveniently due to its protection against hostile clients. + +The binding interface of @racketmodname[web-server/http] is powerful, +but subtle to use conveniently due to its protection against hostile +clients. @deftogether[[ @defparam[current-request req request?] @defthing[binding-id/c contract?] @defthing[binding-format/c contract?] -@defproc[(get-binding [id binding-id/c] [req request? (current-request)] [#:format format binding-format/c 'string]) +@defproc[(get-binding [id binding-id/c] + [req request? (current-request)] + [#:format format binding-format/c 'string]) (or/c false/c string? bytes? binding?)] -@defproc[(get-bindings [id binding-id/c] [req request? (current-request)] [#:format format binding-format/c 'string]) +@defproc[(get-bindings [id binding-id/c] + [req request? (current-request)] + [#:format format binding-format/c 'string]) (listof (or/c string? bytes? binding?))] ]]{ - - The @racket[get-binding](s) interface attempts to resolve this by providing a powerful interface with convenient defaults. - - @racket[get-binding] extracts the first binding of a form input from a request, while @racket[get-bindings] extracts them all. - - They accept a form identifier (@racket[id]) as either a byte string, a string, or a symbol. In each case, the user input is compared in a case-sensitive way with the form input. - - They accept an optional request argument (@racket[req]) that defaults to the value of the @racket[current-request] parameter used by @racket[lambda/page] and @racket[define/page]. - - Finally, they accept an optional keyword argument (@racket[format]) that specifies the desired return format. The default, @racket['string], produces a UTF-8 string (or @racket[#f] if the byte string cannot be converted to UTF-8.) The @racket['bytes] format always produces the raw byte string. The @racket['file] format produces the file upload content (or @racket[#f] if the form input was not an uploaded file.) The @racket['binding] format produces the binding object. - + + The @racket[get-binding](s) interface attempts to resolve this by + providing a powerful interface with convenient defaults. + + @racket[get-binding] extracts the first binding of a form input from a + request, while @racket[get-bindings] extracts them all. + + They accept a form identifier (@racket[id]) as either a byte string, a + string, or a symbol. In each case, the user input is compared in a + case-sensitive way with the form input. + + They accept an optional request argument (@racket[req]) that defaults + to the value of the @racket[current-request] parameter used by + @racket[lambda/page] and @racket[define/page]. + + Finally, they accept an optional keyword argument (@racket[format]) + that specifies the desired return format. The default, + @racket['string], produces a UTF-8 string (or @racket[#f] if the byte + string cannot be converted to UTF-8.) The @racket['bytes] format + always produces the raw byte string. The @racket['file] format + produces the file upload content (or @racket[#f] if the form input was + not an uploaded file.) The @racket['binding] format produces the + binding object. + } diff --git a/collects/web-server/scribblings/responders.scrbl b/collects/web-server/scribblings/responders.scrbl index e32ddee1bd..7976d07b41 100644 --- a/collects/web-server/scribblings/responders.scrbl +++ b/collects/web-server/scribblings/responders.scrbl @@ -8,70 +8,88 @@ @defmodule[web-server/configuration/responders]{ -This module provides some functions that help constructing HTTP responders. -These functions are used by the default dispatcher constructor (see @secref["web-server-unit"]) to -turn the paths given in the @racket[configuration-table] into responders for the associated circumstance. +This module provides some functions that help constructing HTTP +responders. These functions are used by the default dispatcher +constructor (see @secref["web-server-unit"]) to turn the paths given in +the @racket[configuration-table] into responders for the associated +circumstance. -@defproc[(file-response (http-code natural-number/c) (short-version string?) (text-file string?) (header header?) ...) +@defproc[(file-response [http-code natural-number/c] + [short-version string?] + [text-file string?] + [header header?] ...) response?]{ - Generates a @racket[response?] with the given @racket[http-code] and @racket[short-version] -as the corresponding fields; with the content of the @racket[text-file] as the body; and, with -the @racket[header]s as, you guessed it, headers. + Generates a @racket[response?] with the given @racket[http-code] and + @racket[short-version] as the corresponding fields; with the content of + the @racket[text-file] as the body; and, with the @racket[header]s as, + you guessed it, headers. -This does not cause redirects to a well-known URL, such as @filepath{conf/not-found.html}, but rather use the contents -of @filepath{not-found.html} (for example) as its contents. Therefore, any relative URLs in @racket[text-file] are relative -to whatever URL @racket[file-response] is used to respond @emph{to}. Thus, you should probably use absolute URLs in these files. +This does not cause redirects to a well-known URL, such as +@filepath{conf/not-found.html}, but rather use the contents of +@filepath{not-found.html} (for example) as its contents. Therefore, any +relative URLs in @racket[text-file] are relative to whatever URL +@racket[file-response] is used to respond @emph{to}. Thus, you should +probably use absolute URLs in these files. } -@defproc[(servlet-loading-responder (url url?) (exn exn?)) +@defproc[(servlet-loading-responder [url url?] [exn exn?]) response?]{ - Gives @racket[exn] to the @racket[current-error-handler] and response with a stack trace and a "Servlet didn't load" message. + Gives @racket[exn] to the @racket[current-error-handler] and response + with a stack trace and a "Servlet didn't load" message. } -@defproc[(gen-servlet-not-found (file path-string?)) +@defproc[(gen-servlet-not-found [file path-string?]) ((url url?) . -> . response?)]{ - Returns a function that generates a standard "Servlet not found." error with content from @racket[file]. + Returns a function that generates a standard "Servlet not found." error + with content from @racket[file]. } -@defproc[(servlet-error-responder (url url?) (exn exn?)) +@defproc[(servlet-error-responder [url url?] [exn exn?]) response?]{ - Gives @racket[exn] to the @racket[current-error-handler] and response with a stack trace and a "Servlet error" message. + Gives @racket[exn] to the @racket[current-error-handler] and response + with a stack trace and a "Servlet error" message. } - -@defproc[(gen-servlet-responder (file path-string?)) + +@defproc[(gen-servlet-responder [file path-string?]) ((url url?) (exn any/c) . -> . response?)]{ - Prints the @racket[exn] to standard output and responds with a "Servlet error." message with content from @racket[file]. + Prints the @racket[exn] to standard output and responds with a "Servlet + error." message with content from @racket[file]. } -@defproc[(gen-servlets-refreshed (file path-string?)) +@defproc[(gen-servlets-refreshed [file path-string?]) (-> response?)]{ - Returns a function that generates a standard "Servlet cache refreshed." message with content from @racket[file]. + Returns a function that generates a standard "Servlet cache refreshed." + message with content from @racket[file]. } -@defproc[(gen-passwords-refreshed (file path-string?)) +@defproc[(gen-passwords-refreshed [file path-string?]) (-> response?)]{ - Returns a function that generates a standard "Passwords refreshed." message with content from @racket[file]. + Returns a function that generates a standard "Passwords refreshed." + message with content from @racket[file]. } -@defproc[(gen-authentication-responder (file path-string?)) +@defproc[(gen-authentication-responder [file path-string?]) ((url url?) (header header?) . -> . response?)]{ - Returns a function that generates an authentication failure error with content from @racket[file] and -@racket[header] as the HTTP header. + Returns a function that generates an authentication failure error with + content from @racket[file] and @racket[header] as the HTTP header. } -@defproc[(gen-protocol-responder (file path-string?)) +@defproc[(gen-protocol-responder [file path-string?]) ((url url?) . -> . response?)]{ - Returns a function that generates a "Malformed request" error with content from @racket[file]. + Returns a function that generates a "Malformed request" error with + content from @racket[file]. } -@defproc[(gen-file-not-found-responder (file path-string?)) +@defproc[(gen-file-not-found-responder [file path-string?]) ((req request?) . -> . response?)]{ - Returns a function that generates a standard "File not found" error with content from @racket[file]. + Returns a function that generates a standard "File not found" error + with content from @racket[file]. } -@defproc[(gen-collect-garbage-responder (file path-string?)) +@defproc[(gen-collect-garbage-responder [file path-string?]) (-> response?)]{ - Returns a function that generates a standard "Garbage collection run" message with content from @racket[file]. + Returns a function that generates a standard "Garbage collection run" + message with content from @racket[file]. } } diff --git a/collects/web-server/scribblings/servlet-env-int.scrbl b/collects/web-server/scribblings/servlet-env-int.scrbl index 55109d3f23..352d57018f 100644 --- a/collects/web-server/scribblings/servlet-env-int.scrbl +++ b/collects/web-server/scribblings/servlet-env-int.scrbl @@ -43,7 +43,7 @@ These functions optimize the construction of dispatchers and launching of server The servlet is run in the @racket[(current-namespace)]. } - + @defproc[(serve/launch/wait [make-dispatcher (semaphore? . -> . dispatcher/c)] [#:connection-close? connection-close? boolean? #f] diff --git a/collects/web-server/scribblings/servlet-env.scrbl b/collects/web-server/scribblings/servlet-env.scrbl index 971708a473..2710b99a3b 100644 --- a/collects/web-server/scribblings/servlet-env.scrbl +++ b/collects/web-server/scribblings/servlet-env.scrbl @@ -33,7 +33,7 @@ racket (response/xexpr `(html (head (title "Hello world!")) (body (p "Hey out there!"))))) - + (serve/servlet start) ] diff --git a/collects/web-server/scribblings/soft.scrbl b/collects/web-server/scribblings/soft.scrbl index 29d656be3c..c2b3443503 100644 --- a/collects/web-server/scribblings/soft.scrbl +++ b/collects/web-server/scribblings/soft.scrbl @@ -20,12 +20,15 @@ and increasing the size of the serialization. This module provides support for t soft-state?]{ Creates a piece of soft state that is computed by @racket[thnk]. This value is serializable. } - + @defproc[(soft-state-ref [ss soft-state?]) any/c]{ - Extracts the value associated with @racket[ss]. If the value is not available (perhaps because of garbage collection, deserialization in an uninitialized process, etc), then the thunk associated with @racket[ss] is invoked and the value is cached. + Extracts the value associated with @racket[ss]. If the value is not + available (perhaps because of garbage collection, deserialization in an + uninitialized process, etc), then the thunk associated with @racket[ss] + is invoked and the value is cached. } - + @defform[(soft-state expr ...)]{ Equivalent to @racket[(make-soft-state (lambda () expr ...))]. } diff --git a/collects/web-server/scribblings/stateless-usage.scrbl b/collects/web-server/scribblings/stateless-usage.scrbl index 3b4c397c82..2b0bf59ce2 100644 --- a/collects/web-server/scribblings/stateless-usage.scrbl +++ b/collects/web-server/scribblings/stateless-usage.scrbl @@ -5,11 +5,12 @@ web-server/lang/web)) @title[#:tag "considerations"]{Usage Considerations} - -A stateless servlet has the following process performed on it automatically: + +A stateless servlet has the following process performed on it +automatically: @itemize[ - @item{All uses of @racket[letrec] are removed and replaced with equivalent uses of - @racket[let] and imperative features.} + @item{All uses of @racket[letrec] are removed and replaced with + equivalent uses of @racket[let] and imperative features.} @item{The program is converted into @link["http://en.wikipedia.org/wiki/Administrative_normal_form"]{ANF} (Administrative Normal Form), making all continuations explicit.} @item{All continuations and continuations marks are recorded in the @@ -22,41 +23,47 @@ A stateless servlet has the following process performed on it automatically: @racket[lambda].} ] -This process allows the continuations captured by your servlet to be serialized. -This means they may be stored on the client's browser or the server's disk. +This process allows the continuations captured by your servlet to be +serialized. This means they may be stored on the client's browser or +the server's disk. -This means your servlet has no cost to the server other than execution. This is -very attractive if you've used Racket servlets and had memory problems. +This means your servlet has no cost to the server other than +execution. This is very attractive if you've used Racket servlets and +had memory problems. -This means your server can restart in the middle of a long running Web interaction -without the URLs that have been shared with the client expiring. This is -very attractive if you've used Racket servlets and had session timeout problems. +This means your server can restart in the middle of a long running Web +interaction without the URLs that have been shared with the client +expiring. This is very attractive if you've used Racket servlets and +had session timeout problems. -This process is defined on all of Racket and occurs after macro-expansion, -so you are free to use all interesting features of Racket. However, there -are some considerations you must make. +This process is defined on all of Racket and occurs after +macro-expansion, so you are free to use all interesting features of +Racket. However, there are some considerations you must make. -First, this process drastically changes the structure of your program. It -will create an immense number of lambdas and structures your program -did not normally contain. The performance implication of this has not been -studied with Racket. +First, this process drastically changes the structure of your program. +It will create an immense number of lambdas and structures your program +did not normally contain. The performance implication of this has not +been studied with Racket. -Second, the defunctionalization process is sensitive to the syntactic structure -of your program. Therefore, if you change your program in a trivial way, for example, -changing a constant, then all serialized continuations will be obsolete and will -error when deserialization is attempted. This is a feature, not a bug! It is a small -price to pay for protection from the sorts of errors that would occur if your program +Second, the defunctionalization process is sensitive to the syntactic +structure of your program. Therefore, if you change your program in a +trivial way, for example, changing a constant, then all serialized +continuations will be obsolete and will error when deserialization is +attempted. This is a feature, not a bug! It is a small price to pay for +protection from the sorts of errors that would occur if your program were changed in a meaningful way. -Third, the values in the lexical scope of your continuations must be serializable -for the continuations itself to be serializable. This means that you must use -@racket[define-serializable-struct] rather than @racket[define-struct], and take -care to use modules that do the same. Similarly, you may not use @racket[parameterize], -because parameterizations are not serializable. +Third, the values in the lexical scope of your continuations must be +serializable for the continuations itself to be serializable. This means +that you must use @racket[define-serializable-struct] rather than +@racket[define-struct], and take care to use modules that do the same. +Similarly, you may not use @racket[parameterize], because +parameterizations are not serializable. -Fourth, and related, this process only runs on your code, not on the code you -@racket[require]. Thus, your continuations---to be serializable---must not -be in the context of another module. For example, the following will fail with an @as-index{"unsafe context"} +Fourth, and related, this process only runs on your code, not on the +code you @racket[require]. Thus, your continuations---to be +serializable---must not be in the context of another module. For +example, the following will fail with an @as-index{"unsafe context"} exception: @racketblock[ diff --git a/collects/web-server/scribblings/stuffers.scrbl b/collects/web-server/scribblings/stuffers.scrbl index fbfb844c19..41e8a10354 100644 --- a/collects/web-server/scribblings/stuffers.scrbl +++ b/collects/web-server/scribblings/stuffers.scrbl @@ -26,7 +26,7 @@ You can supply your own (built with these functions) when you write a stateless @section{Basic Combinators} @defmodule[web-server/stuffers/stuffer]{ - + @defstruct[stuffer ([in (any/c . -> . any/c)] [out (any/c . -> . any/c)])]{ @@ -35,9 +35,9 @@ You can supply your own (built with these functions) when you write a stateless @racketblock[ (out (in x)) = x (in (out x)) = x - ] + ] } - + @defproc[(stuffer/c [dom any/c] [rng any/c]) contract?]{ Constructs a contract for a @tech{stuffer} where @racket[in] has @@ -52,24 +52,26 @@ You can supply your own (built with these functions) when you write a stateless @defproc[(stuffer-compose [g (stuffer/c any/c any/c)] [f (stuffer/c any/c any/c)]) (stuffer/c any/c any/c)]{ - Composes @racket[f] and @racket[g], i.e., applies @racket[f] then @racket[g] for @racket[in] - and @racket[g] then @racket[f] for @racket[out]. + Composes @racket[f] and @racket[g], i.e., applies @racket[f] then + @racket[g] for @racket[in] and @racket[g] then @racket[f] for + @racket[out]. } - + @defproc[(stuffer-sequence [f (stuffer/c any/c any/c)] [g (stuffer/c any/c any/c)]) (stuffer/c any/c any/c)]{ @racket[stuffer-compose] with arguments swapped. } - + @defproc[(stuffer-if [c (bytes? . -> . boolean?)] [f (stuffer/c bytes? bytes?)]) (stuffer/c bytes? bytes?)]{ - Creates a @tech{stuffer} that stuffs with @racket[f] if @racket[c] is true on the input - to @racket[in]. Similarly, applies @racket[f] during @racket[out] if it was applied during - @racket[in] (which is recorded by prepending a byte.) + Creates a @tech{stuffer} that stuffs with @racket[f] if @racket[c] is + true on the input to @racket[in]. Similarly, applies @racket[f] during + @racket[out] if it was applied during @racket[in] (which is recorded by + prepending a byte.) } - + @defproc[(stuffer-chain [x (or/c stuffer? (bytes? . -> . boolean?))] ...) stuffer?]{ @@ -83,11 +85,12 @@ You can supply your own (built with these functions) when you write a stateless @(require (for-label racket/serialize web-server/private/util)) @defmodule[web-server/stuffers/serialize]{ - + @defthing[serialize-stuffer (stuffer/c serializable? bytes?)]{ - A @tech{stuffer} that uses @racket[serialize] and @racket[write/bytes] and @racket[deserialize] and @racket[read/bytes]. + A @tech{stuffer} that uses @racket[serialize] and @racket[write/bytes] + and @racket[deserialize] and @racket[read/bytes]. } - + } @section{Base64 Encoding} @@ -108,20 +111,22 @@ You can supply your own (built with these functions) when you write a stateless @(require (for-label file/gzip file/gunzip web-server/private/gzip)) @defmodule[web-server/stuffers/gzip]{ -@defthing[gzip-stuffer (stuffer/c bytes? bytes?)]{ +@defthing[gzip-stuffer (stuffer/c bytes? bytes?)]{ A @tech{stuffer} that uses @racket[gzip/bytes] and @racket[gunzip/bytes]. - - @warning{You should compose this with @racket[base64-stuffer] to get URL-safe bytes.} + + @warning{You should compose this with @racket[base64-stuffer] to get + URL-safe bytes.} } - + } @section{Key/Value Storage} -The @racketmodname[web-server/stuffers/hash] @tech{stuffers} rely on a key/value store. +The @racketmodname[web-server/stuffers/hash] @tech{stuffers} rely on a +key/value store. @defmodule[web-server/stuffers/store]{ - + @defstruct[store ([write (bytes? bytes? . -> . void)] [read (bytes? . -> . bytes?)])]{ The following should hold: @@ -129,7 +134,7 @@ The @racketmodname[web-server/stuffers/hash] @tech{stuffers} rely on a key/value (begin (write k v) (read k)) = v ] } - + @defproc[(dir-store [root path-string?]) store?]{ A store that stores key @racket[key]'s value in a file located at @@ -147,68 +152,81 @@ The @racketmodname[web-server/stuffers/hash] @tech{stuffers} rely on a key/value @(require (for-label file/md5)) @defmodule[web-server/stuffers/hash]{ - + @defthing[hash-fun/c contract?]{ Equivalent to @racket[(bytes? . -> . bytes?)]. } - + @defproc[(hash-stuffer [H hash-fun/c] [store store?]) (stuffer/c bytes? bytes?)]{ - A content-addressed storage @tech{stuffer} that stores input bytes, @racket[input], in @racket[store] with the key @racket[(H input)] - and returns the key. Similarly, on @racket[out] the original bytes are looked up. + A content-addressed storage @tech{stuffer} that stores input bytes, + @racket[input], in @racket[store] with the key @racket[(H input)] and + returns the key. Similarly, on @racket[out] the original bytes are + looked up. } - + @defproc[(md5-stuffer [root path-string?]) (stuffer/c bytes? bytes?)]{ Equivalent to @racket[(hash-stuffer md5 (dir-store root))] } - + } @section{HMAC-SHA1 Signing} @defmodule[web-server/stuffers/hmac-sha1]{ - + @defproc[(HMAC-SHA1 [kb bytes?] [db bytes?]) bytes?]{ - Performs a HMAC-SHA1 calculation on @racket[db] using @racket[kb] as the key. The result is guaranteed to be 20 bytes. - (You could curry this to use it with @racket[hash-stuffer], but there is little value in doing so over @racket[md5].) - + Performs a HMAC-SHA1 calculation on @racket[db] using @racket[kb] as + the key. The result is guaranteed to be 20 bytes. (You could curry + this to use it with @racket[hash-stuffer], but there is little value + in doing so over @racket[md5].) } - + @defproc[(HMAC-SHA1-stuffer [kb bytes?]) (stuffer/c bytes? bytes?)]{ - A @tech{stuffer} that signs input using @racket[HMAC-SHA1] with @racket[kb] as the key. The result of the @tech{stuffer} is - the hash prepended to the input data. When the @tech{stuffer} is run in reverse, it checks if the first 20 bytes are the correct - has for the rest of the data. - - @warning{You should compose this with @racket[base64-stuffer] to get URL-safe bytes.} + A @tech{stuffer} that signs input using @racket[HMAC-SHA1] with + @racket[kb] as the key. The result of the @tech{stuffer} is the hash + prepended to the input data. When the @tech{stuffer} is run in + reverse, it checks if the first 20 bytes are the correct has for the + rest of the data. - @warning{Without explicit provision, it is possible for users to modify the continuations they are sent through the other @tech{stuffers}. - This @tech{stuffer} allows the servlet to certify that stuffed data was truly generated by the servlet. Therefore, you @bold{should} use this - if you are not using the @racket[hash-stuffer]s.} - - @warning{This @tech{stuffer} does @bold{not} encrypt the data in anyway, so users can still observe the stuffed values.} + @warning{You should compose this with @racket[base64-stuffer] to get + URL-safe bytes.} + + @warning{Without explicit provision, it is possible for users to + modify the continuations they are sent through the other + @tech{stuffers}. This @tech{stuffer} allows the servlet to certify + that stuffed data was truly generated by the servlet. Therefore, you + @bold{should} use this if you are not using the + @racket[hash-stuffer]s.} + + @warning{This @tech{stuffer} does @bold{not} encrypt the data in + anyway, so users can still observe the stuffed values.} } - + } @section{Helpers} @defmodule[web-server/lang/stuff-url]{ - + @defproc[(is-url-too-big? [v bytes?]) boolean?]{ - Determines if stuffing @racket[v] into the current servlet's URL would result in a URL that is too big for Internet Explorer. - (@link["http://www.boutell.com/newfaq/misc/urllength.html"]{IE only supports URLs up to 2048 characters.}) + Determines if stuffing @racket[v] into the current servlet's URL would + result in a URL that is too big for Internet Explorer. + (@link["http://www.boutell.com/newfaq/misc/urllength.html"]{IE only + supports URLs up to 2048 characters.}) } - + @defproc[(make-default-stuffer [root path-string?]) (stuffer/c serializable? bytes?)]{ - Constructs a @tech{stuffer} that serializes, then if the URL is too big, compresses (and base64-encodes), if the URL is still too big - then it stores it in an MD5-indexed database rooted at @racket[root]. - + Constructs a @tech{stuffer} that serializes, then if the URL is too + big, compresses (and base64-encodes), if the URL is still too big then + it stores it in an MD5-indexed database rooted at @racket[root]. + Equivalent to: @racketblock[ (stuffer-chain diff --git a/collects/web-server/scribblings/templates.scrbl b/collects/web-server/scribblings/templates.scrbl index 264b638c61..d52568ad97 100644 --- a/collects/web-server/scribblings/templates.scrbl +++ b/collects/web-server/scribblings/templates.scrbl @@ -293,16 +293,16 @@ the template to be unescaped, then create a @racket[cdata] structure: Expands into @racketblock[ (for/list ([x xs]) - (begin/text e ...)) + (begin/text e ...)) ] - + Template Example: @verbatim[#:indent 2]|{ @in[c clients]{ @(car c), @(cdr c) } }| - + Racket Example: @racketblock[ (in c clients "" (car c) ", " (cdr c) "") diff --git a/collects/web-server/scribblings/test.scrbl b/collects/web-server/scribblings/test.scrbl index 0375b75c3a..5c5bfde213 100644 --- a/collects/web-server/scribblings/test.scrbl +++ b/collects/web-server/scribblings/test.scrbl @@ -35,8 +35,11 @@ This function accepts a servlet function and provides a function that accepts a @item{The optional @racket[#:raw?] keyword controls whether an X-expression or a byte string is returned as a result.} ] } - -This facility is designed to be used in concert with a technique of extracting continuation URLs and relevant values; @racketmodname[xml/path] is one way to do this. Here is an extended example that tests an Add-Two-Numbers.com: + +This facility is designed to be used in concert with a technique of +extracting continuation URLs and relevant values; +@racketmodname[xml/path] is one way to do this. Here is an extended +example that tests an Add-Two-Numbers.com: @(require (for-label xml/path rackunit racket/list diff --git a/collects/web-server/scribblings/tutorial/continue.scrbl b/collects/web-server/scribblings/tutorial/continue.scrbl index 2e6fe285e5..b6f96a7a0f 100644 --- a/collects/web-server/scribblings/tutorial/continue.scrbl +++ b/collects/web-server/scribblings/tutorial/continue.scrbl @@ -95,17 +95,22 @@ represented as an X-expression in Racket, by using @racketblock[ (define xexpr/c - (flat-rec-contract - xexpr - (or/c string? - (or/c (cons/c symbol? (listof xexpr)) - (cons/c symbol? - (cons/c (listof (list/c symbol? string?)) - (listof xexpr)))))))] + (flat-rec-contract + xexpr + (or/c string? + (or/c (cons/c symbol? (listof xexpr)) + (cons/c symbol? + (cons/c (listof (list/c symbol? string?)) + (listof xexpr)))))))] For example: -The HTML @tt{hello} is represented as @racket["hello"]. Strings are automatically escaped when output. This guarantees valid HTML. Therefore, the value @racket["Unfinished tag"] is rendered as @tt{<b>Unfinished tag} not @tt{Unfinished tag}. Similarly, @racket["Finished tag"] is rendered as @tt{<i>Finished tag</i>} not @tt{Finished tag}. +The HTML @tt{hello} is represented as @racket["hello"]. Strings are +automatically escaped when output. This guarantees valid HTML. +Therefore, the value @racket["Unfinished tag"] is rendered as +@tt{<b>Unfinished tag} not @tt{Unfinished tag}. Similarly, +@racket["Finished tag"] is rendered as +@tt{<i>Finished tag</i>} not @tt{Finished tag}. @tt{

This is an example

} is @@ -400,10 +405,10 @@ web-server/insta (local [(define (response-generator embed/url) (response/xexpr `(html (head (title "Counting example")) - (body + (body (a ((href ,(embed/url next-number-handler))) ,(number->string n)))))) - + (define (next-number-handler request) (show-counter (+ n 1) request))] diff --git a/collects/web-server/scribblings/web-cells.scrbl b/collects/web-server/scribblings/web-cells.scrbl index c70c2bc281..8c4bcc7c42 100644 --- a/collects/web-server/scribblings/web-cells.scrbl +++ b/collects/web-server/scribblings/web-cells.scrbl @@ -51,19 +51,19 @@ transformations of the program into continuation or store passing style. web-server/insta (define (start initial-request) - (define counter1 (make-counter)) - (define counter2 (make-counter)) - (define include1 (include-counter counter1)) - (define include2 (include-counter counter2)) - (send/suspend/dispatch - (lambda (embed/url) - (response/xexpr - `(html - (body (h2 "Double Counters") - (div (h3 "First") - ,(include1 embed/url)) - (div (h3 "Second") - ,(include2 embed/url)))))))) + (define counter1 (make-counter)) + (define counter2 (make-counter)) + (define include1 (include-counter counter1)) + (define include2 (include-counter counter2)) + (send/suspend/dispatch + (lambda (embed/url) + (response/xexpr + `(html + (body (h2 "Double Counters") + (div (h3 "First") + ,(include1 embed/url)) + (div (h3 "Second") + ,(include2 embed/url)))))))) (define (make-counter) (make-web-cell 0)) diff --git a/collects/web-server/scribblings/web.scrbl b/collects/web-server/scribblings/web.scrbl index d94f166d7e..982c3ff86c 100644 --- a/collects/web-server/scribblings/web.scrbl +++ b/collects/web-server/scribblings/web.scrbl @@ -211,7 +211,8 @@ functions of interest for the servlet developer. Checks if @racket[u] is a URL that refers to a continuation, if so returns the instance id, continuation id, and nonce. } - -@defthing[servlet-prompt continuation-prompt-tag?]{The tag used for Web interaction continuation capture.} + +@defthing[servlet-prompt continuation-prompt-tag?]{ + The tag used for Web interaction continuation capture.} } diff --git a/collects/xml/xml.scrbl b/collects/xml/xml.scrbl index b4747cbe81..a61c9dc7b6 100644 --- a/collects/xml/xml.scrbl +++ b/collects/xml/xml.scrbl @@ -39,7 +39,7 @@ It does not interpret namespaces either. [offset exact-nonnegative-integer?])]{ Represents a location in an input stream.} - + @defthing[location/c contract?]{ Equivalent to @racket[(or/c location? symbol? false/c)]. } @@ -47,7 +47,8 @@ Represents a location in an input stream.} @defstruct[source ([start location/c] [stop location/c])]{ -Represents a source location. Other structure types extend @racket[source]. +Represents a source location. Other structure types extend +@racket[source]. When XML is generated from an input stream by @racket[read-xml], locations are represented by @racket[location] instances. When XML @@ -67,7 +68,7 @@ Represents an externally defined DTD.} [inlined false/c])]{ Represents a document type.} - + @defstruct[comment ([text string?])]{ Represents a comment.} @@ -76,7 +77,7 @@ Represents a comment.} [instruction string?])]{ Represents a processing instruction.} - + @defthing[misc/c contract?]{ Equivalent to @racket[(or/c comment? p-i?)] } @@ -91,7 +92,7 @@ Represents a document prolog. [element element?] [misc (listof misc/c)])]{ Represents a document.} - + @defstruct[(element source) ([name symbol?] [attributes (listof attribute?)] [content (listof content/c)])]{ @@ -174,9 +175,10 @@ and a @racket[_misc] is an instance of the @racket[comment] or @racket[p-i] structure types.} @defthing[xexpr/c contract?]{ - A contract that is like @racket[xexpr?] except produces a better error message when the value is not an @tech{X-expression}. -} - + A contract that is like @racket[xexpr?] except produces a better error + message when the value is not an @tech{X-expression}. +} + @; ---------------------------------------------------------------------- @section{Reading and Writing XML} @@ -266,7 +268,7 @@ XML document.} non-XML objects, such as other structs, in the content of the converted XML and leave them in place in the resulting ``@tech{X-expression}''. } - + @defproc[(xml->xexpr [content content/c]) xexpr/c]{ Converts document content into an @tech{X-expression}, using