Lots of documentation formatting.

Started as fixing misindented definitions, then more indentations, then
a bunch of similar things (square brackets, huge spaces at end-of-lines,
etc).
This commit is contained in:
Eli Barzilay 2011-08-15 07:50:04 -04:00
parent d3d9514b1c
commit d61eb53686
113 changed files with 1081 additions and 923 deletions

View File

@ -16,8 +16,8 @@
@(define-syntax-rule (def-ext id) @(define-syntax-rule (def-ext id)
(begin (begin
(require (for-label net/sendurl)) (require (for-label net/sendurl))
(define id (racket send-url)))) (define id (racket send-url))))
@(def-ext net-send-url) @(def-ext net-send-url)

View File

@ -47,7 +47,7 @@ Zum Beispiel:
(define pos (make-vec3 5 5 3)) (define pos (make-vec3 5 5 3))
(define lookat (make-vec3 0 0 0)) (define lookat (make-vec3 0 0 0))
(define camera (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}) (code:comment @#,t{render image})
(render-scene screenWidth screenHeight box camera) (render-scene screenWidth screenHeight box camera)
] ]

View File

@ -175,17 +175,17 @@ black white, white black, and is otherwise ill-defined).
rgb?) rgb?)
"black"]) "black"])
void?]{ void?]{
Colors the entire contents of @racket[viewport] with @racket[color].} Colors the entire contents of @racket[viewport] with @racket[color].}
@defproc[((clear-viewport [viewport viewport?])) @defproc[((clear-viewport [viewport viewport?]))
void?]{ void?]{
Whitens the entire contents of @racket[viewport].} Whitens the entire contents of @racket[viewport].}
@defproc[((flip-viewport [viewport viewport?])) @defproc[((flip-viewport [viewport viewport?]))
void?]{ void?]{
@tech{Inverts} the entire contents of @racket[viewport].} @tech{Inverts} the entire contents of @racket[viewport].}
@ -198,7 +198,7 @@ Copies the content of @racket[source] into @racket[dest].}
@subsection{Pixels} @subsection{Pixels}
@defproc[((draw-pixel [viewport viewport?]) @defproc[((draw-pixel [viewport viewport?])
[p posn?] [p posn?]
[color (or/c (integer-in 0 299) [color (or/c (integer-in 0 299)
string? string?
@ -208,13 +208,13 @@ Copies the content of @racket[source] into @racket[dest].}
Colors the pixel in @racket[viewport] at @racket[p].} Colors the pixel in @racket[viewport] at @racket[p].}
@defproc[((clear-pixel [viewport viewport?]) @defproc[((clear-pixel [viewport viewport?])
[p posn?]) [p posn?])
void?]{ void?]{
Whitens the pixel in @racket[viewport] at @racket[p].} Whitens the pixel in @racket[viewport] at @racket[p].}
@defproc[((flip-pixel [viewport viewport?]) @defproc[((flip-pixel [viewport viewport?])
[p posn?]) [p posn?])
void?]{ void?]{

View File

@ -19,16 +19,16 @@
@(define-syntax-rule (defprocthing* mod id ...) @(define-syntax-rule (defprocthing* mod id ...)
(begin (begin
(deflazy mod defprocthing id) (deflazy mod defprocthing id)
...)) ...))
@(define-syntax-rule (defprocthing id . rest) @(define-syntax-rule (defprocthing id . rest)
(defthing id procedure? . rest)) (defthing id procedure? . rest))
@(define-syntax-rule (defidform* mod id ...) @(define-syntax-rule (defidform* mod id ...)
(begin (begin
(deflazy mod defidform id) (deflazy mod defidform id)
...)) ...))
@; ---------------------------------------- @; ----------------------------------------

View File

@ -4,8 +4,8 @@
@(define-syntax-rule (intro id) @(define-syntax-rule (intro id)
(begin (begin
(require (for-label racket/cmdline)) (require (for-label racket/cmdline))
(define id (racket command-line)))) (define id (racket command-line))))
@(intro racket-command-line) @(intro racket-command-line)
@mzlib[#:mode title cmdline] @mzlib[#:mode title cmdline]

View File

@ -13,12 +13,12 @@
@interaction-eval[#:eval etc-eval (require mzlib/etc)] @interaction-eval[#:eval etc-eval (require mzlib/etc)]
@(begin @(begin
(define-syntax-rule (bind id else-id) (define-syntax-rule (bind id else-id)
(begin (begin
(require (for-label scheme/base)) (require (for-label scheme/base))
(define id (racket lambda)) (define id (racket lambda))
(define else-id (racket else)))) (define else-id (racket else))))
(bind base-lambda base-else)) (bind base-lambda base-else))
@mzlib[#:mode title etc] @mzlib[#:mode title etc]
@ -77,11 +77,11 @@ syntax transformers that share helper functions, though
(define-syntax-set (let-current-continuation (define-syntax-set (let-current-continuation
let-current-escape-continuation) let-current-escape-continuation)
(define (mk call-id) (define (mk call-id)
(lambda (stx) (lambda (stx)
(syntax-case stx () (syntax-case stx ()
[(_ id body1 body ...) [(_ id body1 body ...)
(with-syntax ([call call-id]) (with-syntax ([call call-id])
(syntax (call (lambda (id) body1 body ...))))]))) (syntax (call (lambda (id) body1 body ...))))])))
(define let-current-continuation/proc (define let-current-continuation/proc
(mk (quote-syntax call/cc))) (mk (quote-syntax call/cc)))
(define let-current-escape-continuation/proc (define let-current-escape-continuation/proc
@ -156,12 +156,12 @@ corresponding expression are bound to the multiple variables.
@examples[ @examples[
#:eval etc-eval #:eval etc-eval
(let+ ([val (values x y) (values 1 2)]) (let+ ([val (values x y) (values 1 2)])
(list x y)) (list x y))
(let ([x 1]) (let ([x 1])
(let+ ([val x 3] (let+ ([val x 3]
[val y x]) [val y x])
y)) y))
]} ]}

View File

@ -10,11 +10,11 @@
@interaction-eval[#:eval kw-eval (require mzlib/kw)] @interaction-eval[#:eval kw-eval (require mzlib/kw)]
@(begin @(begin
(define-syntax-rule (bind id) (define-syntax-rule (bind id)
(begin (begin
(require (for-label scheme/base)) (require (for-label scheme/base))
(define id (racket lambda)))) (define id (racket lambda))))
(bind base-lambda)) (bind base-lambda))
@mzlib[#:mode title kw] @mzlib[#:mode title kw]

View File

@ -6,8 +6,8 @@
@(begin @(begin
(define-syntax-rule (bind id) (define-syntax-rule (bind id)
(begin (begin
(require racket/match) (require racket/match)
(define id (racket match)))) (define id (racket match))))
(bind racket-match)) (bind racket-match))
@mzlib[#:mode title match] @mzlib[#:mode title match]

View File

@ -4,11 +4,11 @@
(only-in racket/sandbox make-module-evaluator))) (only-in racket/sandbox make-module-evaluator)))
@(begin @(begin
(define-syntax-rule (bind id) (define-syntax-rule (bind id)
(begin (begin
(require (for-label racket/sandbox)) (require (for-label racket/sandbox))
(define id (racket make-evaluator)))) (define id (racket make-evaluator))))
(bind racket-make-evaluator)) (bind racket-make-evaluator))
@mzlib[#:mode title sandbox] @mzlib[#:mode title sandbox]

View File

@ -3,11 +3,11 @@
(for-label mzlib/sendevent)) (for-label mzlib/sendevent))
@(begin @(begin
(define-syntax-rule (bind id) (define-syntax-rule (bind id)
(begin (begin
(require (for-label scheme/gui/base)) (require (for-label scheme/gui/base))
(define id (racket send-event)))) (define id (racket send-event))))
(bind mred-send-event)) (bind mred-send-event))
@mzlib[#:mode title sendevent] @mzlib[#:mode title sendevent]

View File

@ -3,12 +3,13 @@
(for-label mzlib/serialize)) (for-label mzlib/serialize))
@(begin @(begin
(define-syntax-rule (bind id id2) (define-syntax-rule (bind id id2)
(begin (begin
(require (for-label racket/serialize)) (require (for-label racket/serialize))
(define id (racket define-serializable-struct)) (define id (racket define-serializable-struct))
(define id2 (racket define-serializable-struct/versions)))) (define id2 (racket define-serializable-struct/versions))))
(bind racket-define-serializable-struct racket-define-serializable-struct/versions)) (bind racket-define-serializable-struct
racket-define-serializable-struct/versions))
@mzlib[#:mode title serialize] @mzlib[#:mode title serialize]

View File

@ -51,11 +51,11 @@ property.
@examples[ @examples[
#:eval struct-eval #:eval struct-eval
(define-struct/properties point (x y) (define-struct/properties point (x y)
([prop:custom-write (lambda (p port write?) ([prop:custom-write (lambda (p port write?)
(fprintf port "(~a, ~a)" (fprintf port "(~a, ~a)"
(point-x p) (point-x p)
(point-y p)))])) (point-y p)))]))
(display (make-point 1 2)) (display (make-point 1 2))
]} ]}

View File

@ -10,13 +10,13 @@ library provides working versions of @racket[transcript-on] and
@racket[transcript-off]. @racket[transcript-off].
@(define-syntax-rule (go) @(define-syntax-rule (go)
(begin (begin
(require (for-label mzlib/transcr)) (require (for-label mzlib/transcr))
@deftogether[( @deftogether[(
@defproc[(transcript-on [filename any/c]) any] @defproc[(transcript-on [filename any/c]) any]
@defproc[(transcript-off) any] @defproc[(transcript-off) any]
)]{ )]{
Starts/stops recording a transcript at @racket[filename].})) Starts/stops recording a transcript at @racket[filename].}))
@(go) @(go)

View File

@ -3,16 +3,16 @@
(for-label mzlib/unit)) (for-label mzlib/unit))
@(begin @(begin
(define-syntax-rule (bind id) (define-syntax-rule (bind id)
(begin (begin
(require (for-label racket/unit)) (require (for-label racket/unit))
(define id (racket struct)))) (define id (racket struct))))
(bind racket-struct) (bind racket-struct)
(define-syntax-rule (bindc id) (define-syntax-rule (bindc id)
(begin (begin
(require (for-label racket/unit)) (require (for-label racket/unit))
(define id (racket struct/ctc)))) (define id (racket struct/ctc))))
(bindc racket-struct/ctc)) (bindc racket-struct/ctc))
@mzlib[#:mode title unit] @mzlib[#:mode title unit]

View File

@ -22,22 +22,22 @@
base-free-identifier=? base-free-template-identifier=? base-free-identifier=? base-free-template-identifier=?
base-free-transformer-identifier=? base-free-label-identifier=?) base-free-transformer-identifier=? base-free-label-identifier=?)
(begin (begin
(require (for-label scheme/base)) (require (for-label scheme/base))
(define base-define (racket define)) (define base-define (racket define))
(define base-define-syntax (racket define-syntax)) (define base-define-syntax (racket define-syntax))
(define base-define-for-syntax (racket define-for-syntax)) (define base-define-for-syntax (racket define-for-syntax))
(define base-define-struct (racket define-struct)) (define base-define-struct (racket define-struct))
(define base-if (racket if)) (define base-if (racket if))
(define base-cond (racket cond)) (define base-cond (racket cond))
(define base-case (racket case)) (define base-case (racket case))
(define base-top-interaction (racket #%top-interaction)) (define base-top-interaction (racket #%top-interaction))
(define base-open-input-file (racket open-input-file)) (define base-open-input-file (racket open-input-file))
(define base-apply (racket apply)) (define base-apply (racket apply))
(define base-prop:procedure (racket prop:procedure)) (define base-prop:procedure (racket prop:procedure))
(define base-free-identifier=? (racket free-identifier=?)) (define base-free-identifier=? (racket free-identifier=?))
(define base-free-template-identifier=? (racket free-template-identifier=?)) (define base-free-template-identifier=? (racket free-template-identifier=?))
(define base-free-transformer-identifier=? (racket free-transformer-identifier=?)) (define base-free-transformer-identifier=? (racket free-transformer-identifier=?))
(define base-free-label-identifier=? (racket free-label-identifier=?)))) (define base-free-label-identifier=? (racket free-label-identifier=?))))
@(def-base base-define base-define-syntax base-define-for-syntax base-define-struct @(def-base base-define base-define-syntax base-define-for-syntax base-define-struct
base-if base-cond base-case base-top-interaction base-if base-cond base-case base-top-interaction
base-open-input-file base-apply base-prop:procedure base-open-input-file base-apply base-prop:procedure

View File

@ -110,11 +110,11 @@ Raised for errors when handling cookies.}
@subsection{Creating a cookie} @subsection{Creating a cookie}
@racketblock[ @racketblock[
(let ((c (cookie:add-max-age (let ([c (cookie:add-max-age
(cookie:add-path (cookie:add-path
(set-cookie "foo" "bar") (set-cookie "foo" "bar")
"/servlets") "/servlets")
3600))) 3600)])
(print-cookie c)) (print-cookie c))
] ]

View File

@ -343,7 +343,7 @@ characters, @racket[char-lower-case?] characters, etc.}
@(define-syntax-rule (lex-sre-doc) @(define-syntax-rule (lex-sre-doc)
(... (...
(begin (begin
(require (for-label parser-tools/lex-sre)) (require (for-label parser-tools/lex-sre))
@defform[(* re ...)]{ @defform[(* re ...)]{
@ -417,7 +417,7 @@ characters.}
@(define-syntax-rule (lex-v200-doc) @(define-syntax-rule (lex-v200-doc)
(... (...
(begin (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 @t{The @racketmodname[parser-tools/lex-plt-v200] module re-exports
@racket[*], @racket[+], @racket[?], and @racket[&] from @racket[*], @racket[+], @racket[?], and @racket[&] from

View File

@ -199,19 +199,19 @@ the bounds of the image, returns a transparent color.}
[f (-> natural-number/c natural-number/c color?)]) [f (-> natural-number/c natural-number/c color?)])
image?]{ image?]{
Builds an image of the specified size and shape by calling the specified function Builds an image of the specified size and shape by calling the specified
on the coordinates of each pixel. For example, function on the coordinates of each pixel. For example,
@codeblock|{ @codeblock|{
; fuzz : image -> image ; fuzz : image -> image
(define (fuzz pic) (define (fuzz pic)
(local [; near-pixel : num(x) num(y) -> color (local [; near-pixel : num(x) num(y) -> color
(define (near-pixel x y) (define (near-pixel x y)
(get-pixel-color (+ x -3 (random 7)) (get-pixel-color (+ x -3 (random 7))
(+ y -3 (random 7)) (+ y -3 (random 7))
pic))] pic))]
(build-image (image-width pic) (build-image (image-width pic)
(image-height pic) (image-height pic)
near-pixel))) near-pixel)))
}| }|
produces a fuzzy version of the given picture by replacing each pixel with a produces a fuzzy version of the given picture by replacing each pixel with a
randomly chosen pixel near it.} randomly chosen pixel near it.}
@ -268,7 +268,7 @@ size and shape. For example,
@codeblock|{ @codeblock|{
; lose-red : num(x) num(y) color -> color ; lose-red : num(x) num(y) color -> color
(define (lose-red x y old-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)}| (map-image lose-red my-picture)}|
produces a copy of @racket[my-picture] with all the red leached out, produces a copy of @racket[my-picture] with all the red leached out,
@ -286,9 +286,9 @@ Another example:
@codeblock|{ @codeblock|{
; apply-gradient : num(x) num(y) color -> color ; apply-gradient : num(x) num(y) color -> color
(define (apply-gradient x y old-color) (define (apply-gradient x y old-color)
(make-color (min (* 3 x) 255) (make-color (min (* 3 x) 255)
0 0
(min (* 3 y) 255))) (min (* 3 y) 255)))
(map-image apply-gradient my-picture)}| (map-image apply-gradient my-picture)}|
produces a picture the size of @racket[my-picture]'s bounding rectangle, produces a picture the size of @racket[my-picture]'s bounding rectangle,
@ -402,12 +402,12 @@ For example,
@codeblock|{ @codeblock|{
; bad-gradient : num(x) num(y) -> color ; bad-gradient : num(x) num(y) -> color
(define (bad-gradient x y) (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) (build-image 50 30 bad-gradient)
; good-gradient : num(x) num(y) -> color ; good-gradient : num(x) num(y) -> color
(define (good-gradient x y) (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) (build-image 50 30 good-gradient)
}| }|
The version using @racket[bad-gradient] crashes because color components must be exact integers. 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|{ @codeblock|{
; ask : string -> prints output, waits for text input, returns it ; ask : string -> prints output, waits for text input, returns it
(define (ask question) (define (ask question)
(begin (display question) (begin (display question)
(read))) (read)))
; greet : nothing -> prints output, waits for text input, prints output ; greet : nothing -> prints output, waits for text input, prints output
(define (greet) (define (greet)
(local [(define name (ask "What is your name?"))] (local [(define name (ask "What is your name?"))]
(printf "Hello, ~a!" name))) (printf "Hello, ~a!" name)))
(check-expect (check-expect
(with-io-strings "Steve" greet) (with-io-strings "Steve" greet)
"What is your name?Hello, Steve!")}| "What is your name?Hello, Steve!")}|
} }
@; @include-section{worlds.scrbl} @; @include-section{worlds.scrbl}

View File

@ -44,7 +44,7 @@ the resolvers behavior.
Returns the path corresponding to the planet package (interpreting the arguments 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)]). the same way as @racket[planet-module-name-resolver] and @racket[(current-module-name-resolver)]).
} }
@defproc[(resolve-planet-path [planet-path any/c]) path?]{ @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. 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?]{ @defparam[DEFAULT-PACKAGE-LANGUAGE vers string?]{
The package language used when communicating with the server to find The package language used when communicating with the server to find
which package to download. which package to download.
Defaults to @racket[(version)]. Defaults to @racket[(version)].
} }
@ -180,7 +180,7 @@ The port on the server the client should connect to if
with ``raco planet link''. with ``raco planet link''.
} }
@defproc[(get-hard-linked-packages) @defproc[(get-hard-linked-packages)
(listof (list/c (and/c path? absolute-path?) string? string? (listof string?) (listof (list/c (and/c path? absolute-path?) string? string? (listof string?)
exact-nonnegative-integer? exact-nonnegative-integer?
@ -229,7 +229,6 @@ The @racket[pkg] argument must end with @racket[".plt"].
} }
@defproc[(get-package-spec [owner string?] @defproc[(get-package-spec [owner string?]
[pkg (and/c string? #rx"[.]plt$")] [pkg (and/c string? #rx"[.]plt$")]
[maj (or/c #f natural-number/c) #f] [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?] See also @racket[build-scribble-docs?] and @racket[force-package-building?]
} }
@defparam[build-scribble-docs? b boolean?]{ @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?]{ @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?]) @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; 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.) otherwise the error is some lower-level problem (perhaps no networking, etc.)
} }
@defproc[(pkg->download-url [pkg pkg?]) url?]{ @defproc[(pkg->download-url [pkg pkg?]) url?]{
Returns the url for a given package. 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]. @racket[(this-package-version)]. Given any other path, produces @racket[#f].
} }
@defstruct[(exn:fail:planet exn:fail) ([message string?] [continuation-marks continuation-mark-set?])]{ @defstruct[(exn:fail:planet exn:fail) ([message string?] [continuation-marks continuation-mark-set?])]{
This exception record is used to report planet-specific exceptions. This exception record is used to report planet-specific exceptions.
} }
@defproc[(pkg? [v any/c]) boolean?]{ @defproc[(pkg? [v any/c]) boolean?]{
Determines if its argument is a pkg, the representation of an installed package. Determines if its argument is a pkg, the representation of an
installed package.
} }
@section[#:tag "version.rkt"]{Package Version} @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], Returns a symbol representing the require spec for @racket[ver],
as a planet package. as a planet package.
} }
@section[#:tag "syntax.rkt"]{Macros and Syntax Objects} @section[#:tag "syntax.rkt"]{Macros and Syntax Objects}
@defmodule[planet/syntax] @defmodule[planet/syntax]

View File

@ -181,15 +181,15 @@ function, we could do the following:
#:segments [segments 20] #:segments [segments 20]
#:color [color 'red] #:color [color 'red]
#:width [width 1]) #:width [width 1])
(let* ((dash-size (/ (- x-max x-min) segments)) (let* ([dash-size (/ (- x-max x-min) segments)]
(x-lists (build-list [x-lists (build-list
(/ segments 2) (/ segments 2)
(lambda (index) (lambda (index)
(x-values (x-values
(/ samples segments) (/ samples segments)
(+ x-min (* 2 index dash-size)) (+ x-min (* 2 index dash-size))
(+ x-min (* (add1 (* 2 index)) (+ x-min (* (add1 (* 2 index))
dash-size))))))) dash-size)))))])
(lambda (2dview) (lambda (2dview)
(send 2dview set-line-color color) (send 2dview set-line-color color)
(send 2dview set-line-width width) (send 2dview set-line-width width)

View File

@ -399,7 +399,7 @@ Dispatching-related bindings:
@racketblock[ @racketblock[
(define (ttref) (define (ttref)
(let ((url (get-arg)) (text (get-arg))) (let ([url (get-arg)] [text (get-arg)])
(list "<a href=\"" url "\">@tt{" text "}</a>"))) (list "<a href=\"" url "\">@tt{" text "}</a>")))
] ]

View File

@ -247,8 +247,8 @@ Here's the implementation of @racket[fold-test-results] in terms of
kid-seed) kid-seed)
(lambda (case name action seed) (lambda (case name action seed)
(case-fn (case-fn
(run-test-case name action) (run-test-case name action)
seed)) seed))
seed seed
test)) test))
] ]

View File

@ -76,7 +76,7 @@ cases. Here's a simple test case written using the
@racketblock[ @racketblock[
(test-begin (test-begin
(let ((lst (list 2 4 6 9))) (let ([lst (list 2 4 6 9)])
(check = (length lst) 4) (check = (length lst) 4)
(for-each (for-each
(lambda (elt) (lambda (elt)
@ -111,7 +111,7 @@ we're testing. We can give a test case a name with the
@racketblock[ @racketblock[
(test-case (test-case
"List has length 4 and all elements even" "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) (check = (length lst) 4)
(for-each (for-each
(lambda (elt) (lambda (elt)
@ -133,7 +133,7 @@ group them into a test suite:
(test-case (test-case
"List has length 4 and all elements even" "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) (check = (length lst) 4)
(for-each (for-each
(lambda (elt) (lambda (elt)

View File

@ -1127,7 +1127,7 @@ For example, the following defines addition on natural numbers:
[(sum z n n)] [(sum z n n)]
[(sum (s n_1) n_2 (s n_3)) [(sum (s n_1) n_2 (s n_3))
(sum n_1 n_2 n_3)])] (sum n_1 n_2 n_3)])]
The @racket[judgment-holds] form checks whether a relation holds for any The @racket[judgment-holds] form checks whether a relation holds for any
assignment of pattern variables in output positions. assignment of pattern variables in output positions.
@examples[ @examples[
@ -1199,7 +1199,7 @@ one.
(judgment-holds (all-even (z (s (s z)) (s z))))] (judgment-holds (all-even (z (s (s z)) (s z))))]
Redex evaluates premises depth-first, even when it doing so leads to 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[ @interaction[
#:eval redex-eval #:eval redex-eval
(define-language vertices (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 form, produces a list of terms by instantiating the supplied term template with
each satisfying assignment of pattern variables. each satisfying assignment of pattern variables.
See @racket[define-judgment-form] for examples. See @racket[define-judgment-form] for examples.
} }
@defidform[I]{ @defidform[I]{
Recognized specially within @racket[define-judgment-form], the @racket[I] keyword 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 relation is called with the same inputs twice, then its right-hand
sides are evaluated only once. sides are evaluated only once.
} }
@defparam[current-traced-metafunctions traced-metafunctions (or/c 'all (listof symbol?))]{ @defparam[current-traced-metafunctions traced-metafunctions (or/c 'all (listof symbol?))]{
Controls which metafunctions are currently being traced. If it is 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 ...))) (printf "~s\n" (term (number ...)))
#:attempts 3 #:attempts 3
#:source R)) #:source R))
(redex-check (redex-check
empty-lang empty-lang
number number
@ -2284,8 +2284,8 @@ Like @racket[render-metafunction] but for judgment forms.
This function sets @racket[dc-for-text-size]. See also This function sets @racket[dc-for-text-size]. See also
@racket[relation->pict]. @racket[relation->pict].
} }
@defform[(relation->pict relation-name)]{ @defform[(relation->pict relation-name)]{
This produces a pict, but without setting @racket[dc-for-text-size]. This produces a pict, but without setting @racket[dc-for-text-size].
It is suitable for use in Slideshow or other libraries that combine 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?]{ @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?]{ @defproc[(set-arrow-pict! [arrow symbol?] [proc (-> pict?)]) void?]{
@ -2660,8 +2660,8 @@ explanation of logical-space):
@defform[(with-compound-rewriters ([name-symbol proc] ...) @defform[(with-compound-rewriters ([name-symbol proc] ...)
expression)]{ expression)]{
Shorthand for nested @racket[with-compound-rewriter] expressions.} Shorthand for nested @racket[with-compound-rewriter] expressions.}
@defstruct[lw ([e (or/c string? @defstruct[lw ([e (or/c string?
symbol? symbol?
pict? pict?
@ -2695,8 +2695,8 @@ metafunction application. See @racket[to-lw] for the meanings of the other field
lw?]{ lw?]{
Like @racket[make-lw] but specialized for constructing @racket[lw]s that Like @racket[make-lw] but specialized for constructing @racket[lw]s that
do not represent unquoted expressions or metafunction applications. do not represent unquoted expressions or metafunction applications.
} }
@defform[(to-lw arg)]{ @defform[(to-lw arg)]{
This form turns its argument into lw structs that This form turns its argument into lw structs that

View File

@ -9,9 +9,9 @@
(apply item @index[(map (lambda (x) (format "~a keybinding" x)) keys) key-str] " : " desc))) (apply item @index[(map (lambda (x) (format "~a keybinding" x)) keys) key-str] " : " desc)))
@(define-syntax-rule (def-mod-beg id) @(define-syntax-rule (def-mod-beg id)
(begin (begin
(require (for-label racket/base)) (require (for-label racket/base))
(define id @racket[#%module-begin]))) (define id @racket[#%module-begin])))
@(def-mod-beg mz-mod-begin) @(def-mod-beg mz-mod-begin)
@title{Keyboard Shortcuts} @title{Keyboard Shortcuts}

View File

@ -36,15 +36,15 @@
@racketblock[ @racketblock[
(class ... (class ...
... ...
(define status-panel #f) (define status-panel #f)
(define/override (make-root-area-container cls parent) (define/override (make-root-area-container cls parent)
(set! status-panel (set! status-panel
(super make-root-area-container vertical-panel% parent)) (super make-root-area-container vertical-panel% parent))
(let ([root (make-object cls status-panel)]) (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 In this example, status-panel will contain a root panel for the other
@ -186,7 +186,7 @@
See also @racket[frame:setup-size-pref]. See also @racket[frame:setup-size-pref].
} }
@defmethod*[#:mode override (((on-size (width number?) (height number?)) void?))]{ @defmethod*[#:mode override (((on-size (width number?) (height number?)) void?))]{
Updates the preferences, according to the width and Updates the preferences, according to the width and

View File

@ -85,7 +85,7 @@ that number to control the gauge along the bottom of the splash screen.
exact-nonnegative-integer? exact-nonnegative-integer?
exact-nonnegative-integer? exact-nonnegative-integer?
void?)]{ 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 @defproc[(set-splash-paint-callback
[cb [cb

View File

@ -247,7 +247,7 @@ more specific equivalence comparison.}}
@methspec{See @racket[equal<%>].} @methspec{See @racket[equal<%>].}
@methimpl{Returns @racket[1].}} @methimpl{Returns @racket[1].}}
@defmethod[(find-scroll-step [y real?]) @defmethod[(find-scroll-step [y real?])
exact-nonnegative-integer?]{ exact-nonnegative-integer?]{

View File

@ -9,11 +9,11 @@
(except-in wxme/cache-image reader))) (except-in wxme/cache-image reader)))
@(define-syntax-rule (in mod . content) @(define-syntax-rule (in mod . content)
(begin (begin
(define-syntax-rule (intro) (define-syntax-rule (intro)
(begin (require (for-label mod)) (begin (require (for-label mod))
. content)) . content))
(intro))) (intro)))
@title{WXME Decoding} @title{WXME Decoding}

View File

@ -94,8 +94,8 @@ apply a function like @racket[+] to all of the items in the list:
@def+int[ @def+int[
(define (avg lst) (code:comment @#,elem{doesn't always work...}) (define (avg lst) (code:comment @#,elem{doesn't always work...})
(/ (+ (list-ref lst 0) (list-ref lst 1) (list-ref lst 2)) (/ (+ (list-ref lst 0) (list-ref lst 1) (list-ref lst 2))
(length lst))) (length lst)))
(avg '(1 2 3)) (avg '(1 2 3))
(avg '(1 2)) (avg '(1 2))
] ]

View File

@ -28,9 +28,9 @@ tail position with respect to the @racket[begin] form.
(if (zero? height) (if (zero? height)
(void) (void)
(begin (begin
(display (make-string height #\*)) (display (make-string height #\*))
(newline) (newline)
(print-triangle (sub1 height))))) (print-triangle (sub1 height)))))
(print-triangle 4) (print-triangle 4)
] ]
@ -55,10 +55,10 @@ positions, instead of forming an expression, the content of
@defexamples[ @defexamples[
(let ([curly 0]) (let ([curly 0])
(begin (begin
(define moe (+ 1 curly)) (define moe (+ 1 curly))
(define larry (+ 1 moe))) (define larry (+ 1 moe)))
(list larry curly moe)) (list larry curly moe))
] ]
This splicing behavior is mainly useful for macros, as we discuss This splicing behavior is mainly useful for macros, as we discuss
@ -114,13 +114,13 @@ result is @racket[#f].
@defexamples[ @defexamples[
(define (enumerate lst) (define (enumerate lst)
(if (null? (cdr lst)) (if (null? (cdr lst))
(printf "~a.\n" (car lst)) (printf "~a.\n" (car lst))
(begin (begin
(printf "~a, " (car lst)) (printf "~a, " (car lst))
(when (null? (cdr (cdr lst))) (when (null? (cdr (cdr lst)))
(printf "and ")) (printf "and "))
(enumerate (cdr lst))))) (enumerate (cdr lst)))))
(enumerate '("Larry" "Curly" "Moe")) (enumerate '("Larry" "Curly" "Moe"))
] ]

View File

@ -742,8 +742,8 @@ applied first. Then the method-implementing mixins can use
(class % .... (class % ....
(define/public (get-color) (void)))) (define/public (get-color) (void))))
(lambda (get-color get-price %) .... (lambda (get-color get-price %) ....
(class % .... (class % ....
(define/override (get-color) 'black)))) (define/override (get-color) 'black))))
(list (local-member-name-key get-price) (list (local-member-name-key get-price)
(lambda (get-price get-color %) .... (lambda (get-price get-color %) ....
(class % .... (class % ....
@ -752,7 +752,7 @@ applied first. Then the method-implementing mixins can use
(class % .... (class % ....
(inherit get-color) (inherit get-color)
(define/override (get-price) (define/override (get-price)
.... (get-color) ....)))))) .... (get-color) ....))))))
] ]
With this trait encoding, @racket[trait-alias] adds a new method with 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/public (get-color) 'red)))
(define spots+stripes-trait (define spots+stripes-trait
(trait-sum (trait-sum
(trait-exclude (trait-alias spots-trait (trait-exclude (trait-alias spots-trait
get-color get-spots-color) get-color get-spots-color)
get-color) get-color)
(trait-exclude (trait-alias stripes-trait (trait-exclude (trait-alias stripes-trait
get-color get-stripes-color) get-color get-stripes-color)
get-color) get-color)
(trait (trait

View File

@ -60,9 +60,9 @@ racket
[argmax [argmax
(->i ([f (-> any/c real?)] [lov (and/c pair? list?)]) () (->i ([f (-> any/c real?)] [lov (and/c pair? list?)]) ()
(r (f lov) (r (f lov)
(lambda (r) (lambda (r)
(define f@r (f r)) (define f@r (f r))
(for/and ((v lov)) (>= f@r (f v))))))]) (for/and ([v lov]) (>= f@r (f v))))))])
] ]
It is a @emph{dependent} contract that names the two arguments and uses 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 the names to impose a predicate on the result. This predicate computes
@ -84,9 +84,8 @@ racket
(r (f lov) (r (f lov)
(lambda (r) (lambda (r)
(define f@r (f r)) (define f@r (f r))
(and (and (memq r lov)
(memq r lov) (for/and ([v lov]) (>= f@r (f v)))))))])
(for/and ((v lov)) (>= f@r (f v)))))))])
] ]
The @racket[memq] function ensures that @racket[r] is @emph{intensionally equal} 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 @margin-note*{That is, "pointer equality" for those who prefer to think at
@ -113,14 +112,14 @@ racket
(r (f lov) (r (f lov)
(lambda (r) (lambda (r)
(define f@r (f 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)) (eq? (first (memf (lambda (v) (= (f v) f@r)) lov))
r)))))]) r)))))])
] ]
That is, the @racket[memf] function determines the first element of 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 @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], 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 This second refinement step introduces two problems. First, both conditions
recompute the values of @racket[f] for all elements of @racket[lov]. Second, recompute the values of @racket[f] for all elements of @racket[lov]. Second,
@ -157,7 +156,7 @@ racket
@code:comment{@#,dominates1} @code:comment{@#,dominates1}
(define (dominates-all f@r f lov) (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} @code:comment{@#,first?1}
(define (is-first-max? r f@r f lov) (define (is-first-max? r f@r f lov)
@ -199,7 +198,7 @@ racket
@code:comment{@#,dominates2} @code:comment{@#,dominates2}
(define (dominates-all f@r flov) (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} @code:comment{@#,first?2}
(define (is-first-max? r f@r lov+flov) (define (is-first-max? r f@r lov+flov)

View File

@ -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->] The contract for such a function is formed with the @racket[case->]
combinator, which combines as many functional contracts as needed: combinator, which combines as many functional contracts as needed:
@racketblock[ @racketblock[
(provide/contract (provide/contract
[report-cost [report-cost
(case-> (case->
(integer? integer? . -> . string?) (integer? integer? . -> . string?)

View File

@ -81,26 +81,24 @@ streams like this:
@interaction[ @interaction[
#:eval e #:eval e
(define stream/c (define stream/c
(promise/c (promise/c
(or/c (or/c null?
null? (cons/c number? stream/c))))
(cons/c number? stream/c))))
] ]
@close-eval[e] @close-eval[e]
Unfortunately, this does not work because the value of Unfortunately, this does not work because the value of
@racket[stream/c] is needed before it is defined. Put another way, all @racket[stream/c] is needed before it is defined. Put another way, all
of the combinators evaluate their arguments eagerly, even thought the of the combinators evaluate their arguments eagerly, even thought the
values that they accept do not. values that they accept do not.
Instead, use Instead, use
@racketblock[ @racketblock[
(define stream/c (define stream/c
(promise/c (promise/c
(or/c (or/c
null? null?
(cons/c 1 (cons/c 1 (recursive-contract stream/c)))))
(recursive-contract stream/c)))))
] ]
The use of @racket[recursive-contract] delays the evaluation of the The use of @racket[recursive-contract] delays the evaluation of the

View File

@ -93,16 +93,16 @@ provide/contract'd. This is currently buggy so this
discussion is elided. Here's the expansion of discussion is elided. Here's the expansion of
the requiring module, just to give an idea: the requiring module, just to give an idea:
(module m racket (module m racket
(require mzlib/contract) (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 m) (define (f) ... x ...))
==> ==>
(module n racket (module n racket
(require (rename m x x-real)) (require (rename m x x-real))
(define x (apply-contract x-real x-ctc ...)) (define x (apply-contract x-real x-ctc ...))
(define (f) ... x ...)) (define (f) ... x ...))
The intention is to only do the work of applying the The intention is to only do the work of applying the
contract once (per variable reference to a contract once (per variable reference to a

View File

@ -261,7 +261,7 @@ resulting iteration can be performed more efficiently than plain
@racket[for/vector] or @racket[for*/vector]: @racket[for/vector] or @racket[for*/vector]:
@interaction[ @interaction[
(let ((chapters '("Intro" "Details" "Conclusion"))) (let ([chapters '("Intro" "Details" "Conclusion")])
(for/vector #:length (length chapters) ([i (in-naturals 1)] (for/vector #:length (length chapters) ([i (in-naturals 1)]
[chapter chapters]) [chapter chapters])
(string-append (number->string i) ". " chapter))) (string-append (number->string i) ". " chapter)))

View File

@ -64,18 +64,18 @@ Consider the following core of a Mandelbrot-set computation:
@racketblock[ @racketblock[
(define (mandelbrot iterations x y n) (define (mandelbrot iterations x y n)
(let ((ci (- (/ (* 2.0 y) n) 1.0)) (let ([ci (- (/ (* 2.0 y) n) 1.0)]
(cr (- (/ (* 2.0 x) n) 1.5))) [cr (- (/ (* 2.0 x) n) 1.5)])
(let loop ((i 0) (zr 0.0) (zi 0.0)) (let loop ([i 0] [zr 0.0] [zi 0.0])
(if (> i iterations) (if (> i iterations)
i i
(let ((zrq (* zr zr)) (let ([zrq (* zr zr)]
(ziq (* zi zi))) [ziq (* zi zi)])
(cond (cond
((> (+ zrq ziq) 4.0) i) [(> (+ zrq ziq) 4.0) i]
(else (loop (add1 i) [else (loop (add1 i)
(+ (- zrq ziq) cr) (+ (- zrq ziq) cr)
(+ (* 2.0 zr zi) ci))))))))) (+ (* 2.0 zr zi) ci))]))))))
] ]
The expressions @racket[(mandelbrot 10000000 62 500 1000)] and The expressions @racket[(mandelbrot 10000000 62 500 1000)] and
@ -110,8 +110,8 @@ first the problem:
@racketblock[ @racketblock[
(define (mandelbrot iterations x y n) (define (mandelbrot iterations x y n)
(let ((ci (- (/ (* 2.0 (->fl y)) (->fl n)) 1.0)) (let ([ci (- (/ (* 2.0 (->fl y)) (->fl n)) 1.0)]
(cr (- (/ (* 2.0 (->fl x)) (->fl n)) 1.5))) [cr (- (/ (* 2.0 (->fl x)) (->fl n)) 1.5)])
....)) ....))
] ]
@ -128,18 +128,18 @@ much less allocation:
@racketblock[ @racketblock[
(define (mandelbrot iterations x y n) (define (mandelbrot iterations x y n)
(let ((ci (fl- (fl/ (* 2.0 (->fl y)) (->fl n)) 1.0)) (let ([ci (fl- (fl/ (* 2.0 (->fl y)) (->fl n)) 1.0)]
(cr (fl- (fl/ (* 2.0 (->fl x)) (->fl n)) 1.5))) [cr (fl- (fl/ (* 2.0 (->fl x)) (->fl n)) 1.5)])
(let loop ((i 0) (zr 0.0) (zi 0.0)) (let loop ([i 0] [zr 0.0] [zi 0.0])
(if (> i iterations) (if (> i iterations)
i i
(let ((zrq (fl* zr zr)) (let ([zrq (fl* zr zr)]
(ziq (fl* zi zi))) [ziq (fl* zi zi)])
(cond (cond
((fl> (fl+ zrq ziq) 4.0) i) [(fl> (fl+ zrq ziq) 4.0) i]
(else (loop (add1 i) [else (loop (add1 i)
(fl+ (fl- zrq ziq) cr) (fl+ (fl- zrq ziq) cr)
(fl+ (fl* 2.0 (fl* zr zi)) ci))))))))) (fl+ (fl* 2.0 (fl* zr zi)) ci))]))))))
] ]
This conversion can speed @racket[mandelbrot] by a factor of 8, even This conversion can speed @racket[mandelbrot] by a factor of 8, even

View File

@ -315,8 +315,8 @@ the source form are identifiers. We could use a
(syntax-case stx () (syntax-case stx ()
[(rotate a c ...) [(rotate a c ...)
(begin (begin
(check-ids stx #'(a c ...)) (check-ids stx #'(a c ...))
#'(shift-to (c ... a) (a c ...)))])) #'(shift-to (c ... a) (a c ...)))]))
] ]
The @racket[check-ids] function can use the @racket[syntax->list] The @racket[check-ids] function can use the @racket[syntax->list]

View File

@ -217,13 +217,13 @@ racket
(+ n 17)) (+ n 17))
(define-syntax (def-go stx) (define-syntax (def-go stx)
(syntax-case stx () (syntax-case stx ()
[(_ go) [(_ go)
(protect-syntax (protect-syntax
#'(define-syntax (go stx) #'(define-syntax (go stx)
(syntax-case stx () (syntax-case stx ()
[(_ x) [(_ x)
(protect-syntax #'(unchecked-go 8 x))])))])) (protect-syntax #'(unchecked-go 8 x))])))]))
] ]
When @racket[def-go] is used inside another module to defined When @racket[def-go] is used inside another module to defined
@ -247,13 +247,13 @@ racket
(lambda (stx) (syntax-arm stx insp)))) (lambda (stx) (syntax-arm stx insp))))
(define-syntax (def-go stx) (define-syntax (def-go stx)
(syntax-case stx () (syntax-case stx ()
[(_ go) [(_ go)
(protect-syntax (protect-syntax
#'(define-syntax (go stx) #'(define-syntax (go stx)
(syntax-case stx () (syntax-case stx ()
[(_ x) [(_ x)
(go-syntax-protect #'(unchecked-go 8 x))])))])) (go-syntax-protect #'(unchecked-go 8 x))])))]))
] ]
@;------------------------------------------------------------------------ @;------------------------------------------------------------------------

View File

@ -313,28 +313,28 @@ racket
(define toy-store@-maker (define toy-store@-maker
(lambda (the-color) (lambda (the-color)
(unit (unit
(import toy-factory^) (import toy-factory^)
(export toy-store^) (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) (define (maybe-repaint t)
(if (eq? (toy-color t) (store-color)) (if (eq? (toy-color t) (store-color))
t t
(repaint t (store-color)))) (repaint t (store-color))))
(define (stock! n) (define (stock! n)
(set! inventory (set! inventory
(append inventory (append inventory
(map maybe-repaint (map maybe-repaint
(build-toys n))))) (build-toys n)))))
(define (get-inventory) inventory)))) (define (get-inventory) inventory))))
(provide toy-store@-maker) (provide toy-store@-maker)
] ]

View File

@ -122,7 +122,7 @@ the function.}
@defform[(define-datatype dataype-name [variant-name field-name ...] ...)]{ @defform[(define-datatype dataype-name [variant-name field-name ...] ...)]{
A short-hand for defining a group of related structures. The following @racket[define-datatype]: A short-hand for defining a group of related structures. The following @racket[define-datatype]:
@racketblock[ @racketblock[
@ -237,7 +237,7 @@ of the initial @racket[expression].}
@defform[(match expression [pattern expression] ...)]{ @defform[(match expression [pattern expression] ...)]{
A @racket[match] form contains one or more clauses that are surrounded by 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 square brackets. Each clause contains a pattern---a description of a value---and
an answer @racket[expression]. The initial @racket[expression] is evaluated, an answer @racket[expression]. The initial @racket[expression] is evaluated,

View File

@ -433,7 +433,7 @@ A unit that imports nothing and exports @racket[compiler:embed^].}
@defproc[(find-exe [gracket? boolean?] @defproc[(find-exe [gracket? boolean?]
[variant (or/c 'cgc '3m) (system-type 'gc)]) [variant (or/c 'cgc '3m) (system-type 'gc)])
path?]{ path?]{
Finds the path to the racket (or gracket) executable. Finds the path to the racket (or gracket) executable.
} }

View File

@ -6,11 +6,11 @@
(only-in setup/infotab require))) (only-in setup/infotab require)))
@(begin @(begin
(define-syntax-rule (define-racket-require id) (define-syntax-rule (define-racket-require id)
(begin (begin
(require (for-label (only-in racket require))) (require (for-label (only-in racket require)))
(define id @racket[require]))) (define id @racket[require])))
(define-racket-require racket:require)) (define-racket-require racket:require))
@title[#:tag "info.rkt"]{@filepath{info.rkt} File Format} @title[#:tag "info.rkt"]{@filepath{info.rkt} File Format}

View File

@ -384,8 +384,8 @@ result will not call @racket[proc] with @racket['unlock].)
(when ok-to-compile? (when ok-to-compile?
(printf "Do compile here ...\n"))) (printf "Do compile here ...\n")))
(lambda () (lambda ()
(when locked? (when locked?
(lc 'unlock zo-name))))) (lc 'unlock zo-name)))))
] ]
} }

View File

@ -27,12 +27,12 @@
racket/future)) racket/future))
@(define-syntax-rule (local-module mod . body) @(define-syntax-rule (local-module mod . body)
(begin (begin
(define-syntax-rule (go) (define-syntax-rule (go)
(begin (begin
(require (for-label mod)) (require (for-label mod))
. body)) . body))
(go))) (go)))
@(define ref-src @(define ref-src
'(lib "scribblings/reference/reference.scrbl")) '(lib "scribblings/reference/reference.scrbl"))

View File

@ -280,7 +280,8 @@ For communication among @tech{places}, the new byte string is allocated in the
the other operations. the other operations.
@examples[ @examples[
(define b (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) (string->bytes/utf-8 b)
(bytes->string/utf-8 (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[ @examples[
(define b (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) (string->bytes/latin-1 b)
(bytes->string/latin-1 (string->bytes/latin-1 b)) (bytes->string/latin-1 (string->bytes/latin-1 b))

View File

@ -12,15 +12,15 @@
[(_ s ... s0) (elem (elem ", " (secref s)) ... ", and " (secref s0))])) [(_ s ... s0) (elem (elem ", " (secref s)) ... ", and " (secref s0))]))
(define-syntax (defclassforms stx) (define-syntax (defclassforms stx)
(syntax-case stx (*) (syntax-case stx (*)
[(_ [* (form ...) (also ...)]) [(_ [* (form ...) (also ...)])
#'(defform* (form ...) #'(defform* (form ...)
"See " @racket[class*] (sees also ...) "; use" "See " @racket[class*] (sees also ...) "; use"
" outside the body of a " @racket[class*] " form is a syntax error.")] " outside the body of a " @racket[class*] " form is a syntax error.")]
[(_ [form (also ...)]) [(_ [form (also ...)])
#'(defclassforms [* (form) (also ...)])] #'(defclassforms [* (form) (also ...)])]
[(_ form ...) [(_ form ...)
#'(begin (defclassforms form) ...)])) #'(begin (defclassforms form) ...)]))
(define-syntax (defstarshorthands stx) (define-syntax (defstarshorthands stx)
(syntax-case stx () (syntax-case stx ()
@ -292,13 +292,13 @@ interface @racket[(class->interface object%)], and is transparent
(lambda kw-formals expr ...+) (lambda kw-formals expr ...+)
(case-lambda (formals expr ...+) ...) (case-lambda (formals expr ...+) ...)
(#%plain-lambda formals expr ...+) (#%plain-lambda formals expr ...+)
(let-values (((id) method-procedure) ...) (let-values ([(id) method-procedure] ...)
method-procedure) method-procedure)
(letrec-values (((id) method-procedure) ...) (letrec-values ([(id) method-procedure] ...)
method-procedure) method-procedure)
(let-values (((id) method-procedure) ...+) (let-values ([(id) method-procedure] ...+)
id) id)
(letrec-values (((id) method-procedure) ...+) (letrec-values ([(id) method-procedure] ...+)
id)])]{ id)])]{
Produces a class value. Produces a class value.
@ -1366,11 +1366,11 @@ Produces a @tech{trait} that combines all of the methods of the given
@racketblock[ @racketblock[
(define t1 (define t1
(trait (trait
(define/public (m1) 1))) (define/public (m1) 1)))
(define t2 (define t2
(trait (trait
(define/public (m2) 2))) (define/public (m2) 2)))
(define t3 (trait-sum t1 t2)) (define t3 (trait-sum t1 t2))
] ]
@ -1378,8 +1378,8 @@ creates a trait @racket[t3] that is equivalent to
@racketblock[ @racketblock[
(trait (trait
(define/public (m1) 1) (define/public (m1) 1)
(define/public (m2) 2)) (define/public (m2) 2))
] ]
but @racket[t1] and @racket[t2] can still be used individually or 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 behaves as if its class had been wrapped with the equivalent
@racket[class/c] contract. @racket[class/c] contract.
} }
@defproc[(instanceof/c [class-contract contract?]) contract?]{ @defproc[(instanceof/c [class-contract contract?]) contract?]{
Produces a contract for an object, where the object is an Produces a contract for an object, where the object is an
instance of a class that conforms to @racket[class-contract]. instance of a class that conforms to @racket[class-contract].
} }
@defform/subs[ @defform/subs[
#:literals (field -> ->* ->d) #:literals (field -> ->* ->d)

View File

@ -172,18 +172,18 @@ default error display handler (see
@secref["errorproc"]).} @secref["errorproc"]).}
@examples[ @examples[
(define (extract-current-continuation-marks key) (define (extract-current-continuation-marks key)
(continuation-mark-set->list (continuation-mark-set->list
(current-continuation-marks) (current-continuation-marks)
key)) key))
(with-continuation-mark 'key 'mark (with-continuation-mark 'key 'mark
(extract-current-continuation-marks 'key)) (extract-current-continuation-marks 'key))
(with-continuation-mark 'key1 'mark1 (with-continuation-mark 'key1 'mark1
(with-continuation-mark 'key2 'mark2 (with-continuation-mark 'key2 'mark2
(list (list
(extract-current-continuation-marks 'key1) (extract-current-continuation-marks 'key1)
(extract-current-continuation-marks 'key2)))) (extract-current-continuation-marks 'key2))))
(with-continuation-mark 'key 'mark1 (with-continuation-mark 'key 'mark1

View File

@ -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 syntax object for the expression that produces the contract controlling
the export. the export.
} }
@subsection{Nested Contract Boundaries} @subsection{Nested Contract Boundaries}
@defmodule*/no-declare[(racket/contract/region)] @defmodule*/no-declare[(racket/contract/region)]
@declare-exporting-ctc[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} @subsection{Low-level Contract Boundaries}
@declare-exporting-ctc[racket/contract/base] @declare-exporting-ctc[racket/contract/base]
@defform*[[(contract contract-expr to-protect-expr @defform*[[(contract contract-expr to-protect-expr
positive-blame-expr negative-blame-expr) positive-blame-expr negative-blame-expr)
(contract contract-expr to-protect-expr (contract contract-expr to-protect-expr
@ -1808,7 +1808,7 @@ are below):
@; ------------------------------------------------------------------------ @; ------------------------------------------------------------------------
@subsection{Utilities for Building New Combinators} @subsection{Utilities for Building New Combinators}
@defproc[(contract-stronger? [x contract?] [y contract?]) boolean?]{ @defproc[(contract-stronger? [x contract?] [y contract?]) boolean?]{
Returns @racket[#t] if the contract @racket[x] accepts either fewer Returns @racket[#t] if the contract @racket[x] accepts either fewer
or the same number of values as @racket[y] does. 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 Produces the first-order test used by @racket[or/c] to match values to
higher-order contracts. higher-order contracts.
} }
@section{Contract Utilities} @section{Contract Utilities}
@declare-exporting-ctc[racket/contract/base] @declare-exporting-ctc[racket/contract/base]

View File

@ -9,27 +9,27 @@
;; hacky? ;; hacky?
(define file-eval (define file-eval
(lambda () (lambda ()
(let ([the-eval (make-base-eval)]) (let ([the-eval (make-base-eval)])
(the-eval '(require (for-syntax racket/base) (the-eval '(require (for-syntax racket/base)
racket/file)) racket/file))
(the-eval '(define some-file (make-temporary-file))) (the-eval '(define some-file (make-temporary-file)))
(the-eval '(define some-other-file (make-temporary-file))) (the-eval '(define some-other-file (make-temporary-file)))
the-eval))) the-eval)))
(define-syntax file-examples (define-syntax file-examples
(syntax-rules () (syntax-rules ()
[(_ expr ...) [(_ expr ...)
(let [(my-eval (file-eval))] (let [(my-eval (file-eval))]
(define (clean) (define (clean)
(my-eval '(for [(i (list some-file some-other-file))] (my-eval '(for [(i (list some-file some-other-file))]
(when (file-exists? i) (when (file-exists? i)
(delete-file i))))) (delete-file i)))))
(clean) (clean)
(begin0 (begin0
(defexamples #:eval my-eval (defexamples #:eval my-eval
expr ...) expr ...)
(clean)))])) (clean)))]))
"") "")

View File

@ -196,4 +196,3 @@ For communication among @tech{places}, the new @tech{fxvector} is
allocated in the @tech{shared memory space}. allocated in the @tech{shared memory space}.
@mz-examples[#:eval flfx-eval (make-shared-fxvector 4 3)]} @mz-examples[#:eval flfx-eval (make-shared-fxvector 4 3)]}

View File

@ -180,7 +180,7 @@ Maps @racket[key] to @racket[v] in @racket[hash], overwriting
any existing mapping for @racket[key]. any existing mapping for @racket[key].
@see-also-caveats[]} @see-also-caveats[]}
@defproc[(hash-set*! [hash (and/c hash? (not/c immutable?))] @defproc[(hash-set*! [hash (and/c hash? (not/c immutable?))]
[key any/c] [key any/c]
[v any/c] [v any/c]
@ -204,7 +204,7 @@ Functionally extends @racket[hash] by mapping @racket[key] to
returning the extended hash table. returning the extended hash table.
@see-also-mutable-key-caveat[]} @see-also-mutable-key-caveat[]}
@defproc[(hash-set* [hash (and/c hash? immutable?)] @defproc[(hash-set* [hash (and/c hash? immutable?)]
[key any/c] [key any/c]
[v any/c] [v any/c]
@ -329,25 +329,25 @@ otherwise the traversal skips a deleted key or uses the remapped key's
new value. new value.
@see-also-concurrency-caveat[]} @see-also-concurrency-caveat[]}
@defproc[(hash-keys [hash hash?]) @defproc[(hash-keys [hash hash?])
(listof any/c)]{ (listof any/c)]{
Returns a list of the keys of @racket[hash] in an unspecified order. Returns a list of the keys of @racket[hash] in an unspecified order.
See @racket[hash-map] for information about modifying @racket[hash] See @racket[hash-map] for information about modifying @racket[hash]
during @racket[hash-keys]. @see-also-concurrency-caveat[]} during @racket[hash-keys]. @see-also-concurrency-caveat[]}
@defproc[(hash-values [hash hash?]) @defproc[(hash-values [hash hash?])
(listof any/c)]{ (listof any/c)]{
Returns a list of the values of @racket[hash] in an unspecified order. Returns a list of the values of @racket[hash] in an unspecified order.
See @racket[hash-map] for information about modifying @racket[hash] See @racket[hash-map] for information about modifying @racket[hash]
during @racket[hash-values]. @see-also-concurrency-caveat[]} during @racket[hash-values]. @see-also-concurrency-caveat[]}
@defproc[(hash->list [hash hash?]) @defproc[(hash->list [hash hash?])
(listof (cons/c any/c any/c))]{ (listof (cons/c any/c any/c))]{
Returns a list of the key--value pairs of @racket[hash] in an unspecified order. 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] See @racket[hash-map] for information about modifying @racket[hash]
during @racket[hash->list]. @see-also-concurrency-caveat[]} during @racket[hash->list]. @see-also-concurrency-caveat[]}

View File

@ -144,8 +144,8 @@ is equivalent to
@racketblock[ @racketblock[
(let ([l (current-logger)]) (let ([l (current-logger)])
(when (log-level? l '@#,racket[_level]) (when (log-level? l '@#,racket[_level])
(log-message l '@#,racket[_level] string-expr (log-message l '@#,racket[_level] string-expr
(current-continuation-marks)))) (current-continuation-marks))))
]} ]}
@; ---------------------------------------- @; ----------------------------------------

View File

@ -480,9 +480,10 @@ instead of @racket[match].}
A @racket[match] pattern form that matches an instance of a structure A @racket[match] pattern form that matches an instance of a structure
type named @racket[struct-id], where the field @racket[field] in the type named @racket[struct-id], where the field @racket[field] in the
instance matches the corresponding @racket[pat]. 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[ @defexamples[
#:eval match-eval #:eval match-eval
(define-struct tree (val left right)) (define-struct tree (val left right))

View File

@ -49,14 +49,14 @@ the grammar for @racket[_module-path] for @racket[require],
@racket[#f] otherwise.} @racket[#f] otherwise.}
@defparam[current-module-name-resolver proc @defparam[current-module-name-resolver proc
(case-> (case->
(resolved-module-path? . -> . any) (resolved-module-path? . -> . any)
((or/c module-path? path?) ((or/c module-path? path?)
(or/c #f resolved-module-path?) (or/c #f resolved-module-path?)
(or/c #f syntax?) (or/c #f syntax?)
boolean? boolean?
. -> . . -> .
resolved-module-path?))]{ resolved-module-path?))]{
A parameter that determines the current @deftech{module name A parameter that determines the current @deftech{module name

View File

@ -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 reject a change to the parameter's value. The @racket[guard] is not
applied to the initial @racket[v].} applied to the initial @racket[v].}
@defform[(parameterize ((parameter-expr value-expr) ...) @defform[(parameterize ([parameter-expr value-expr] ...)
body ...+) body ...+)
#:contracts #:contracts
([parameter-expr parameter?])]{ ([parameter-expr parameter?])]{

View File

@ -739,8 +739,8 @@ values from the generator.
(if (null? x) (if (null? x)
0 0
(begin (begin
(yield (car x)) (yield (car x))
(loop (cdr x))))))) (loop (cdr x)))))))
(g) (g)
(g) (g)
(g) (g)
@ -812,8 +812,8 @@ Produces a @tech{sequence} that encapsulates the @tech{generator} formed by
(if (null? x) (if (null? x)
my-stop-value my-stop-value
(begin (begin
(yield (car x)) (yield (car x))
(loop (cdr x))))))) (loop (cdr x)))))))
(for/list ([i (in-producer my-generator my-stop-value)]) (for/list ([i (in-producer my-generator my-stop-value)])
i)]} i)]}

View File

@ -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?]{ @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]. 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 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 when checking the contract. Otherwise, the contract accepts only sets with the corresponding
notion of equality. notion of equality.

View File

@ -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 @racket[syntax-local-value] of @racket[id] does not produce
the target's value.} 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].} @margin-note/ref{See also @racket[splicing-syntax-parameterize].}

View File

@ -139,7 +139,7 @@ For example, the expression
expands to expands to
@racketblock[ @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 which, in turn, expands to

View File

@ -210,9 +210,9 @@ the binding (according to @racket[free-identifier=?]) matters.}
(if expr expr expr) (if expr expr expr)
(begin expr ...+) (begin expr ...+)
(begin0 expr expr ...) (begin0 expr expr ...)
(let-values (((id ...) expr) ...) (let-values ([(id ...) expr] ...)
expr ...+) expr ...+)
(letrec-values (((id ...) expr) ...) (letrec-values ([(id ...) expr] ...)
expr ...+) expr ...+)
(set! id expr) (set! id expr)
(@#,racket[quote] datum) (@#,racket[quote] datum)
@ -756,21 +756,21 @@ bucket-2
(syntax-rules () (syntax-rules ()
[(def-and-use) [(def-and-use)
(begin (begin
(code:comment @#,t{Initial reference to @racket[even] precedes definition:}) (code:comment @#,t{Initial reference to @racket[even] precedes definition:})
(define (odd x) (if (zero? x) #f (even (sub1 x)))) (define (odd x) (if (zero? x) #f (even (sub1 x))))
(define (even x) (if (zero? x) #t (odd (sub1 x)))) (define (even x) (if (zero? x) #t (odd (sub1 x))))
(odd 17))])) (odd 17))]))
(defs-and-uses/fail) (defs-and-uses/fail)
(define-syntax defs-and-uses (define-syntax defs-and-uses
(syntax-rules () (syntax-rules ()
[(def-and-use) [(def-and-use)
(begin (begin
(code:comment @#,t{Declare before definition via no-values @racket[define-syntaxes]:}) (code:comment @#,t{Declare before definition via no-values @racket[define-syntaxes]:})
(define-syntaxes (odd even) (values)) (define-syntaxes (odd even) (values))
(define (odd x) (if (zero? x) #f (even (sub1 x)))) (define (odd x) (if (zero? x) #f (even (sub1 x))))
(define (even x) (if (zero? x) #t (odd (sub1 x)))) (define (even x) (if (zero? x) #t (odd (sub1 x))))
(odd 17))])) (odd 17))]))
(defs-and-uses) (defs-and-uses)
] ]

View File

@ -109,7 +109,7 @@ is prefixed with the special form name as described under
@examples[#:eval the-eval @examples[#:eval the-eval
(wrong-syntax #'here "expected ~s" 'there) (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)) (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: beginning of its transformation as follows:
@RACKETBLOCK[ @RACKETBLOCK[
(define-syntax (my-macro stx) (define-syntax (my-macro stx)
(parameterize ((current-syntax-context stx)) (parameterize ([current-syntax-context stx])
(syntax-case stx () (syntax-case stx ()
___))) ___)))
] ]

View File

@ -905,18 +905,18 @@ follows.
chickens)) chickens))
(module nest2 racket (module nest2 racket
(define-for-syntax eggs 2) (define-for-syntax eggs 2)
(provide (for-syntax eggs))) (provide (for-syntax eggs)))
(require (for-meta 2 racket/base) (require (for-meta 2 racket/base)
(for-syntax 'nest2)) (for-syntax 'nest2))
(define-syntax (test stx) (define-syntax (test stx)
(define-syntax (show-eggs stx) (define-syntax (show-eggs stx)
(printf "Eggs are ~a\n" eggs) (printf "Eggs are ~a\n" eggs)
#'0) #'0)
(begin (begin
(show-eggs) (show-eggs)
#'0)) #'0))
(test) (test)
]} ]}
@specsubform[#:literals (for-syntax) @specsubform[#:literals (for-syntax)
@ -2144,8 +2144,8 @@ be defined by the same @racket[define-for-syntax] form.
@defexamples[#:eval (syntax-eval) @defexamples[#:eval (syntax-eval)
(define-for-syntax helper 2) (define-for-syntax helper 2)
(define-syntax (make-two syntax-object) (define-syntax (make-two syntax-object)
(printf "helper is ~a\n" helper) (printf "helper is ~a\n" helper)
#'2) #'2)
(make-two) (make-two)
(code:comment @#,t{`helper' is not bound in the runtime phase}) (code:comment @#,t{`helper' is not bound in the runtime phase})
helper helper

View File

@ -144,7 +144,7 @@ result is the result of @racket[expr].}
@note-lib-only[racket/date] @note-lib-only[racket/date]
@defproc[(current-date) date?]{ @defproc[(current-date) date?]{
An abbreviation for @racket[(seconds->date (current-seconds))].} An abbreviation for @racket[(seconds->date (current-seconds))].}
@defproc[(date->string [date date?] [time? any/c #f]) string?]{ @defproc[(date->string [date date?] [time? any/c #f]) string?]{

View File

@ -67,7 +67,7 @@ slot is position @racket[0], and the last slot is one less than
void?]{ void?]{
Updates the slot @racket[pos] of @racket[vec] to contain @racket[v].} Updates the slot @racket[pos] of @racket[vec] to contain @racket[v].}
@defproc[(vector->list [vec vector?]) list?]{ @defproc[(vector->list [vec vector?]) list?]{
Returns a list with the same length and elements as @racket[vec].} Returns a list with the same length and elements as @racket[vec].}

View File

@ -36,7 +36,7 @@ As an example,
(: my-sqr (Real -> Real)) (: my-sqr (Real -> Real))
(define (my-sqr x) (define (my-sqr x)
(* x x)) (* x x))
(my-sqr 42)] (my-sqr 42)]
}| }|
uses an evaluator whose language is @racketmodname[typed/racket/base]. uses an evaluator whose language is @racketmodname[typed/racket/base].

View File

@ -3,8 +3,8 @@
@(define-syntax-rule (def base-author) @(define-syntax-rule (def base-author)
(begin (begin
(require (for-label scribble/base)) (require (for-label scribble/base))
(define base-author @racket[author]))) (define base-author @racket[author])))
@(def base-author) @(def base-author)
@title{JFP Paper Format} @title{JFP Paper Format}

View File

@ -4,8 +4,8 @@
@(define-syntax-rule (def base-author) @(define-syntax-rule (def base-author)
(begin (begin
(require (for-label scribble/base)) (require (for-label scribble/base))
(define base-author @racket[author]))) (define base-author @racket[author])))
@(def base-author) @(def base-author)
@title{LNCS Paper Format} @title{LNCS Paper Format}
@ -47,7 +47,7 @@ arguments to @racket[institutes].
#:contracts ([pre-content-expr pre-content?])]{ #:contracts ([pre-content-expr pre-content?])]{
The @racket[pre-content-expr]s are used as the institutions of the authors. The @racket[pre-content-expr]s are used as the institutions of the authors.
} }
@defidform[institute]{For use only in @racket[institutes].} @defidform[institute]{For use only in @racket[institutes].}

View File

@ -477,7 +477,7 @@ and one that combines several modules) via your own
@defform/subs[(declare-exporting mod-path ... maybe-sources) @defform/subs[(declare-exporting mod-path ... maybe-sources)
([maybe-sources code:blank ([maybe-sources code:blank
(code:line #:use-sources (mod-path ...))])]{ (code:line #:use-sources (mod-path ...))])]{
Associates the @racket[mod-path]s to all bindings defined within the Associates the @racket[mod-path]s to all bindings defined within the
enclosing section, except as overridden by other enclosing section, except as overridden by other
@racket[declare-exporting] declarations in nested sub-sections. The @racket[declare-exporting] declarations in nested sub-sections. The

View File

@ -16,9 +16,9 @@
@(begin @(begin
(define-syntax-rule (def-render-mixin id) (define-syntax-rule (def-render-mixin id)
(begin (begin
(require (for-label scribble/html-render)) (require (for-label scribble/html-render))
(define id @racket[render-mixin]))) (define id @racket[render-mixin])))
(def-render-mixin html:render-mixin)) (def-render-mixin html:render-mixin))
@title[#:tag "renderer"]{Renderers} @title[#:tag "renderer"]{Renderers}

View File

@ -77,7 +77,7 @@ documentation expressions.}
(code:line keyword contract-expr)] (code:line keyword contract-expr)]
[optional contract-expr [optional contract-expr
(code:line keyword contract-expr)])]{ (code:line keyword contract-expr)])]{
When used in @racket[provide/doc], exports @racket[id] with the When used in @racket[provide/doc], exports @racket[id] with the
contract described by @racket[contract] contract described by @racket[contract]
just like using @racket[provide/contract]. just like using @racket[provide/contract].
@ -109,7 +109,7 @@ form.}
(->i (arg ...) () res) (->i (arg ...) () res)
(->i (arg ...) () #:pre (pre-id ...) condition [name res]) (->i (arg ...) () #:pre (pre-id ...) condition [name res])
(->i (arg ...) () #:rest rest res) (->i (arg ...) () #:rest rest res)
(->d (arg ...) () (values [id result] ...)) (->d (arg ...) () (values [id result] ...))
(->d (arg ...) () #:pre-cond expr (values [id result] ...)) (->d (arg ...) () #:pre-cond expr (values [id result] ...))
(->d (arg ...) () [id result]) (->d (arg ...) () [id result])
@ -117,9 +117,9 @@ form.}
(->d (arg ...) () #:rest id rest [id result])])]{ (->d (arg ...) () #:rest id rest [id result])])]{
Like @racket[proc-doc], but supporting contract forms that embed Like @racket[proc-doc], but supporting contract forms that embed
argument names. Only a subset of @racket[->i] and @racket[->d] forms are currently argument names. Only a subset of @racket[->i] and @racket[->d] forms are
supported.} currently supported.}
@defform[(thing-doc id contract-expr dec-expr)]{ @defform[(thing-doc id contract-expr dec-expr)]{
Like @racket[proc-doc], but for an export of an arbitrary value.} Like @racket[proc-doc], but for an export of an arbitrary value.}

View File

@ -161,7 +161,6 @@ locations, instead of copying to the directory of @racket[dest].}
Transfers cross-reference information to @racket[ci], which is the Transfers cross-reference information to @racket[ci], which is the
initially collected information from @racket[renderer].} initially collected information from @racket[renderer].}
@defproc[(xref-index [xref xref?]) (listof entry?)]{ @defproc[(xref-index [xref xref?]) (listof entry?)]{

View File

@ -328,7 +328,7 @@ but not hollow (using @racket[disk], not @racket[circle]).
@defthing[o-bullet pict?]{ @defthing[o-bullet pict?]{
A hollow bullet used by default by @racket[subitem]. A hollow bullet used by default by @racket[subitem].
It's implementation is: It's implementation is:
@racketblock[(baseless @racketblock[(baseless
(cc-superimpose (cc-superimpose

View File

@ -640,7 +640,7 @@ Check Syntax is a part of the DrRacket collection, but is implemented via the to
} }
@definterface[syncheck-annotations<%> ()]{ @definterface[syncheck-annotations<%> ()]{
Classes implementing this interface are Classes implementing this interface are
accceptors of information about a traversal accceptors of information about a traversal
of syntax objects. See @racket[make-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], 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. and that it corresponds to @racket[file]. Check Syntax adds a popup menu.
} }
@defmethod[(syncheck:add-docs-menu [source-obj (not/c #f)] @defmethod[(syncheck:add-docs-menu [source-obj (not/c #f)]
[start exact-nonnegative-integer?] [start exact-nonnegative-integer?]
[end exact-nonnegative-integer?] [end exact-nonnegative-integer?]

View File

@ -150,12 +150,12 @@ Calls the definitions text's
@defmethod[#:mode public-final @defmethod[#:mode public-final
(remove-bkg-running-color [id symbol?]) (remove-bkg-running-color [id symbol?])
void?]{ void?]{
Removes the color and label added with @racket[id]. Removes the color and label added with @racket[id].
See also @method[drracket:unit:tab<%> add-bkg-running-color]. 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?]{ @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?]{ @defmethod[(open-in-new-tab [filename (or/c path-string? #f)]) void?]{

View File

@ -72,25 +72,25 @@ language [*]:
(define-values (f) (define-values (f)
(with-continuation-mark "#<debug-key-struct>" (with-continuation-mark "#<debug-key-struct>"
(#%plain-lambda () (#%plain-app "#<procedure:...rivate/marks.rkt:70:2>")) (#%plain-lambda () (#%plain-app "#<procedure:...rivate/marks.rkt:70:2>"))
(#%plain-app (#%plain-app
call-with-values call-with-values
(#%plain-lambda () (#%plain-lambda ()
(with-continuation-mark "#<debug-key-struct>" (with-continuation-mark "#<debug-key-struct>"
(#%plain-lambda () (#%plain-app (#%plain-lambda () (#%plain-app
"#<procedure:...rivate/marks.rkt:70:2>" "#<procedure:...rivate/marks.rkt:70:2>"
(#%plain-lambda () beginner:+))) (#%plain-lambda () beginner:+)))
(#%plain-app (#%plain-app
"#<procedure:closure-storing-proc>" "#<procedure:closure-storing-proc>"
(#%plain-lambda (x) (#%plain-lambda (x)
(begin (begin
(let-values (((arg0-1643 arg1-1644 arg2-1645) (let-values ([(arg0-1643 arg1-1644 arg2-1645)
(#%plain-app (#%plain-app
values values
"#<*unevaluated-struct*>" "#<*unevaluated-struct*>"
"#<*unevaluated-struct*>" "#<*unevaluated-struct*>"
"#<*unevaluated-struct*>"))) "#<*unevaluated-struct*>")])
(with-continuation-mark "#<debug-key-struct>" (with-continuation-mark "#<debug-key-struct>"
(#%plain-lambda () (#%plain-lambda ()
(#%plain-app (#%plain-app
"#<procedure:...rivate/marks.rkt:70:2>" "#<procedure:...rivate/marks.rkt:70:2>"
(#%plain-lambda () beginner:+) (#%plain-lambda () beginner:+)
@ -161,12 +161,12 @@ language [*]:
#f #f
(#%plain-lambda () (#%plain-app list f)))))))) (#%plain-lambda () (#%plain-app list f))))))))
(let-values (((done-already?) (quote #f))) (let-values ([(done-already?) (quote #f)])
(#%app dynamic-wind void (#%app dynamic-wind void
(lambda () (#%app dynamic-require (quote (quote #%htdp)) (quote #f))) (lambda () (#%app dynamic-require (quote (quote #%htdp)) (quote #f)))
(lambda () (if done-already? (lambda () (if done-already?
(#%app void) (#%app void)
(let-values () (let-values ()
(set! done-already? (quote #t)) (set! done-already? (quote #t))
(#%app test*) (#%app test*)
(#%app current-namespace (#%app current-namespace

View File

@ -2,9 +2,9 @@
@(require "common.rkt" (for-label syntax/kerncase)) @(require "common.rkt" (for-label syntax/kerncase))
@(define-syntax-rule (intro id) @(define-syntax-rule (intro id)
(begin (begin
(require (for-label mzscheme)) (require (for-label mzscheme))
(define id (racket if)))) (define id (racket if))))
@(intro mzscheme-if) @(intro mzscheme-if)
@; ---------------------------------------------------------------------- @; ----------------------------------------------------------------------

View File

@ -11,8 +11,8 @@
@(begin @(begin
(define the-eval (define the-eval
(parameterize ((sandbox-output 'string) (parameterize ([sandbox-output 'string]
(sandbox-error-output 'string)) [sandbox-error-output 'string])
(make-evaluator 'racket/base #:requires '(syntax/keyword)))) (make-evaluator 'racket/base #:requires '(syntax/keyword))))
;;(void (the-eval '(error-print-source-location #f))) ;;(void (the-eval '(error-print-source-location #f)))
(define-syntax-rule (myexamples e ...) (define-syntax-rule (myexamples e ...)

View File

@ -6,11 +6,11 @@
read-syntax-inside read-inside))) read-syntax-inside read-inside)))
@(begin @(begin
(define-syntax-rule (define-mb name) (define-syntax-rule (define-mb name)
(begin (begin
(require (for-label scheme/base)) (require (for-label scheme/base))
(define name @racket[#%module-begin]))) (define name @racket[#%module-begin])))
(define-mb scheme-#%module-begin)) (define-mb scheme-#%module-begin))
@(define guide-doc '(lib "scribblings/guide/guide.scrbl")) @(define guide-doc '(lib "scribblings/guide/guide.scrbl"))

View File

@ -23,11 +23,11 @@ the parameter expressions.
[(_ ((p v:expr) ...) body:expr) [(_ ((p v:expr) ...) body:expr)
#:declare p (expr/c #'parameter? #:declare p (expr/c #'parameter?
#:name "parameter argument") #:name "parameter argument")
#'(parameterize ((p.c v) ...) body)])) #'(parameterize ([p.c v] ...) body)]))
(myparameterize ((current-input-port (myparameterize ([current-input-port
(open-input-string "(1 2 3)"))) (open-input-string "(1 2 3)")])
(read)) (read))
(myparameterize (('whoops 'something)) (myparameterize (['whoops 'something])
'whatever) 'whatever)
] ]

View File

@ -197,9 +197,9 @@ Unlike @racket[scene+curve], if the line passes outside of @racket[image], the i
(beside empty-image (beside empty-image
(rectangle 10 10 "solid" "red")))] (rectangle 10 10 "solid" "red")))]
} }
@section{Polygons} @section{Polygons}
@defproc*[([(triangle [side-length (and/c real? (not/c negative?))] @defproc*[([(triangle [side-length (and/c real? (not/c negative?))]
[mode mode?] [mode mode?]
[color image-color?]) [color image-color?])
@ -423,8 +423,7 @@ They all construct a triangle oriented as follows:
(triangle/saa 200 90 40 "solid" "aquamarine") (triangle/saa 200 90 40 "solid" "aquamarine")
(triangle/saa 40 130 40 "solid" "lightseagreen")] (triangle/saa 40 130 40 "solid" "lightseagreen")]
} }
@defproc*[([(square [side-len (and/c real? (not/c negative?))] @defproc*[([(square [side-len (and/c real? (not/c negative?))]
[mode mode?] [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")] [outline-mode (or/c 'outline "outline")]
[pen-or-color (or/c pen? image-color?)]) [pen-or-color (or/c pen? image-color?)])
image?])]{ image?])]{
Constructs a star-like polygon where the star is specified by two radii and a number of points. 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 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. 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")] (regular-polygon 20 8 "solid" "red")]
} }
@defproc*[([(polygon [vertices (listof real-valued-posn?)] @defproc*[([(polygon [vertices (listof real-valued-posn?)]
[mode mode?] [mode mode?]
[color image-color?]) [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 30 30 "solid" "seagreen")
(rectangle 40 40 "solid" "silver") (rectangle 40 40 "solid" "silver")
(rectangle 50 50 "solid" "seagreen"))] (rectangle 50 50 "solid" "seagreen"))]
} }
@defproc[(overlay/offset [i1 image?] [x real?] [y real?] [i2 image?]) image?]{ @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 40 40 50 "seagreen")
(rectangle 30 30 50 "seagreen") (rectangle 30 30 50 "seagreen")
(rectangle 20 20 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 50 "solid" "darkgray")
(ellipse 20 30 "solid" "dimgray") (ellipse 20 30 "solid" "dimgray")
(ellipse 20 10 "solid" "black"))] (ellipse 20 10 "solid" "black"))]
} }
@defproc[(beside/align [y-place y-place?] [i1 image?] [i2 image?] [is image?] ...) image?]{ @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 50 "solid" "mediumslateblue")
(ellipse 20 30 "solid" "slateblue") (ellipse 20 30 "solid" "slateblue")
(ellipse 20 10 "solid" "navy")) (ellipse 20 10 "solid" "navy"))
(beside/align "top" (beside/align "top"
(ellipse 20 70 "solid" "mediumorchid") (ellipse 20 70 "solid" "mediumorchid")
(ellipse 20 50 "solid" "darkorchid") (ellipse 20 50 "solid" "darkorchid")
(ellipse 20 30 "solid" "purple") (ellipse 20 30 "solid" "purple")
(ellipse 20 10 "solid" "indigo")) (ellipse 20 10 "solid" "indigo"))
(beside/align "baseline" (beside/align "baseline"
(text "ijy" 18 "black") (text "ijy" 18 "black")
(text "ijy" 24 "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 50 20 "solid" "darkgray")
(ellipse 30 20 "solid" "dimgray") (ellipse 30 20 "solid" "dimgray")
(ellipse 10 20 "solid" "black"))] (ellipse 10 20 "solid" "black"))]
} }
@defproc[(above/align [x-place x-place?] [i1 image?] [i2 image?] [is image?] ...) image?]{ @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 50 20 "solid" "goldenrod")
(ellipse 30 20 "solid" "darkgoldenrod") (ellipse 30 20 "solid" "darkgoldenrod")
(ellipse 10 20 "solid" "sienna")) (ellipse 10 20 "solid" "sienna"))
(above/align "left" (above/align "left"
(ellipse 70 20 "solid" "yellowgreen") (ellipse 70 20 "solid" "yellowgreen")
(ellipse 50 20 "solid" "olivedrab") (ellipse 50 20 "solid" "olivedrab")
(ellipse 30 20 "solid" "darkolivegreen") (ellipse 30 20 "solid" "darkolivegreen")
(ellipse 10 20 "solid" "darkgreen"))] (ellipse 10 20 "solid" "darkgreen"))]
} }
@section{Placing Images & Scenes} @section{Placing Images & Scenes}
@ -937,11 +930,11 @@ Placing images into scenes is particularly useful when building worlds
and universes using @racket[2htdp/universe]. and universes using @racket[2htdp/universe].
@defproc*[([(empty-scene [width (and/c real? (not/c negative?))] @defproc*[([(empty-scene [width (and/c real? (not/c negative?))]
[height (and/c real? (not/c negative?))]) [height (and/c real? (not/c negative?))])
image?] image?]
[(empty-scene [width (and/c real? (not/c negative?))] [(empty-scene [width (and/c real? (not/c negative?))]
[height (and/c real? (not/c negative?))] [height (and/c real? (not/c negative?))]
[color image-color?]) [color image-color?])
image?])]{ image?])]{
Creates an empty scene, i.e., a white rectangle with a black outline. 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 10 0 1/2
20 90 0 1/2 20 90 0 1/2
"white") "white")
(scene+curve (rectangle 100 100 "solid" "black") (scene+curve (rectangle 100 100 "solid" "black")
-20 -20 0 1 -20 -20 0 1
120 120 0 1 120 120 0 1
"red")] "red")]
} }
@section{Rotating, Scaling, Flipping, Cropping, and Framing Images} @section{Rotating, Scaling, Flipping, Cropping, and Framing Images}
@defproc[(rotate [angle angle?] [image image?]) image?]{ @defproc[(rotate [angle angle?] [image image?]) image?]{
@ -1200,11 +1193,12 @@ more expensive than with the other shapes.
@defform/subs[(bitmap bitmap-spec) @defform/subs[(bitmap bitmap-spec)
([bitmap-spec rel-string ([bitmap-spec rel-string
id])]{ id])]{
Loads the bitmap specified by @racket[bitmap-spec]. If @racket[bitmap-spec] is a string, it is treated as a Loads the bitmap specified by @racket[bitmap-spec]. If
relative path. If it is an identifier, it is treated like a require spec and used to refer to a file @racket[bitmap-spec] is a string, it is treated as a relative path.
in a collection. 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) @image-examples[(bitmap icons/stop-16x16.png)
(bitmap icons/b-run.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 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]. and then paste it into your program or download it and use @racket[bitmap].
} }
@defproc[(image->color-list [image image?]) (listof color?)]{ @defproc[(image->color-list [image image?]) (listof color?)]{
Returns a list of colors that correspond to the colors in the Returns a list of colors that correspond to the colors in the
image, reading from left to right, top to bottom. 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?)]{ @defproc[(image-width [i image?]) (and/c integer? (not/c negative?) exact?)]{
Returns the width of @racket[i]. Returns the width of @racket[i].
@image-examples[(image-width (ellipse 30 40 "solid" "orange")) @image-examples[(image-width (ellipse 30 40 "solid" "orange"))
(image-width (circle 30 "solid" "orange")) (image-width (circle 30 "solid" "orange"))
(image-width (beside (circle 20 "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 The complete list of colors is available in the documentation for
@racket[color-database<%>]. @racket[color-database<%>].
} }
@defstruct[color ([red (and/c natural-number/c (<=/c 255))] @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?]{ @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?]{ @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")))] @image-examples[(pinhole-y (center-pinhole (rectangle 10 10 "solid" "red")))]
} }
@defproc[(clear-pinhole [image image?]) image?]{ @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?]{ @defproc[(overlay/pinhole [i1 image?] [i2 image?] [is image?] ...) image?]{

View File

@ -197,35 +197,35 @@ The other big change concerns key event handling and mouse event
@port[ @port[
@racketblock[ @racketblock[
(define (change w a-key-event) (define (change w a-key-event)
(cond (cond
[(key=? a-key-event 'left) [(key=? a-key-event 'left)
(world-go w -DELTA)] (world-go w -DELTA)]
[(key=? a-key-event 'right) [(key=? a-key-event 'right)
(world-go w +DELTA)] (world-go w +DELTA)]
[(char? a-key-event) [(char? a-key-event)
w] w]
[(key=? a-key-event 'up) [(key=? a-key-event 'up)
(world-go w -DELTA)] (world-go w -DELTA)]
[(key=? a-key-event 'down) [(key=? a-key-event 'down)
(world-go w +DELTA)] (world-go w +DELTA)]
[else [else
w]))] w]))]
@; --------------------------------- @; ---------------------------------
@racketblock[ @racketblock[
(define (change w a-key-event) (define (change w a-key-event)
(cond (cond
[(key=? a-key-event "left") [(key=? a-key-event "left")
(world-go w -DELTA)] (world-go w -DELTA)]
[(key=? a-key-event "right") [(key=? a-key-event "right")
(world-go w +DELTA)] (world-go w +DELTA)]
[(= (string-length a-key-event) 1) [(= (string-length a-key-event) 1)
w] w]
[(key=? a-key-event "up") [(key=? a-key-event "up")
(world-go w -DELTA)] (world-go w -DELTA)]
[(key=? a-key-event "down") [(key=? a-key-event "down")
(world-go w +DELTA)] (world-go w +DELTA)]
[else [else
w])) w]))
]] ]]
Note how the @racket[char?] clause changed. Since all chars are now Note how the @racket[char?] clause changed. Since all chars are now
represented as strings containing one ``letter'', the program on the right represented as strings containing one ``letter'', the program on the right

View File

@ -27,18 +27,17 @@ Example:
@(begin @(begin
#reader scribble/comment-reader #reader scribble/comment-reader
(racketblock (racketblock
;; Advanced ;; Advanced
(define (make-model dir) (define (make-model dir)
(lambda (b e) (lambda (b e)
(begin (begin
(view dir) (view dir)
(printf "~a ~n" (control))))) (printf "~a ~n" (control)))))
(connect (connect (make-model "left")
(make-model "left") (make-model "right")
(make-model "right") (make-model "up")
(make-model "up") (make-model "down"))
(make-model "down"))
)) ))
Now click on the four arrows. The message field contains the current Now click on the four arrows. The message field contains the current
direction, the print-out the prior contents of the message field. direction, the print-out the prior contents of the message field.

View File

@ -82,11 +82,11 @@ Example 2:
;; set up window with three "lines": ;; set up window with three "lines":
;; a text field, a message, and two buttons ;; a text field, a message, and two buttons
;; fill in text and click OKAY ;; fill in text and click OKAY
(define w (define w
(create-window (create-window
(list (list
(list text1) (list text1)
(list msg1) (list msg1)
(list (make-button "OKAY" respond) (list (make-button "OKAY" respond)
(make-button "QUIT" (lambda (e) (hide-window w))))))) (make-button "QUIT" (lambda (e) (hide-window w)))))))
)) ))

View File

@ -53,9 +53,9 @@ Accepts at least two value-producing expressions. Structurally compares the firs
value to each value subsequent value specified. value to each value subsequent value specified.
It is an error to produce a function value.} It is an error to produce a function value.}
@defform[(check-range (test number/c) (min number/c) (max number/c))]{ @defform[(check-range (test number/c) (min number/c) (max number/c))]{
Accepts three number-producing expressions. Performs the following comparison: Accepts three number-producing expressions. Performs the following comparison:
min <= test <= max.} min <= test <= max.}

View File

@ -33,23 +33,28 @@ This module provides a macro for regular expression compilation.
(dseq pat re-pat) (dseq pat re-pat)
pat])]{ pat])]{
Compiles a regular expression over match patterns to a @racket[machine]. 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 The interpretation of the pattern language is mostly intuitive. The
with @racket[define-re-transformer]. @racket[dseq] allows bindings of the @racket[match] pattern to be pattern language may be extended with @racket[define-re-transformer].
used in the rest of the regular expression. (Thus, they are not @emph{really} regular expressions.) @racket[dseq] allows bindings of the @racket[match] pattern to be used
@racket[unquote] escapes to Racket to evaluate an expression that evaluates to a regular expression (this happens in the rest of the regular expression. (Thus, they are not
once, at compile time.) @racket[rec] binds a Racket identifier to a delayed version of the inner expression; even @emph{really} regular expressions.) @racket[unquote] escapes to Racket
if the expression is initially accepting, this delayed version is never accepting. to evaluate an expression that evaluates to a regular expression (this
happens once, at compile time.) @racket[rec] binds a Racket identifier
The compiler will use an NFA, provided @racket[complement] and @racket[dseq] are not used. Otherwise, to a delayed version of the inner expression; even if the expression is
many NFAs connected with the machine simulation functions from @racketmodname[unstable/automata/machine] are used. 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) @(define-syntax-rule (defidforms (id ...) . dat)
(deftogether ((defidform id) ...) . dat)) (deftogether ((defidform id) ...) . dat))
@defidforms[(complement seq union star epsilon nullset dseq rec)]{ @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)]{ @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")]) [(list "B")])
(define-re-transformer my-opt (define-re-transformer my-opt
(syntax-rules () (syntax-rules ()
[(_ pat) [(_ pat)
(union epsilon pat)])) (union epsilon pat)]))
(test-re (my-opt "A") (test-re (my-opt "A")
[(list) [(list)

View File

@ -23,19 +23,27 @@
[prop:name identifier?] [prop:name identifier?]
[name? identifier?] [name? identifier?]
[method 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 Defines @racket[name] as a transformer binding for the static
type property. Structure types implementing this generic group should have this property where the value is a vector information about a new generic group.
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 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]. context of @racket[name].
} }
@defform[(define-methods name definition ...) @defform[(define-methods name definition ...)
#:contracts #:contracts
([name identifier?])]{ ([name identifier?])]{
@racket[name] must be a transformer binding for the static information about a new generic group. @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.
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 ...]. Allows @racket[define/generic] to appear in @racket[definition ...].
} }
@defform[(define/generic local-name method-name) @defform[(define/generic local-name method-name)
#:contracts #:contracts
([local-name identifier?] ([local-name identifier?]
[method-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]. Syntactically an error when used outside @racket[define-methods].
} }
@; Examples @; Examples
@(require scribble/eval) @(require scribble/eval)
@(define (new-evaluator) @(define (new-evaluator)
(let* ([e (make-base-eval)]) (let* ([e (make-base-eval)])
(e '(require (for-syntax racket/base) (e '(require (for-syntax racket/base)

View File

@ -29,9 +29,18 @@ This library provides a simplified version of parameters that are backed by cont
[none-v [any/c #f]] [none-v [any/c #f]]
[tag continuation-prompt-tag? default-continuation-prompt-tag]) [tag continuation-prompt-tag? default-continuation-prompt-tag])
(listof vector?)]{ (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 ...)]{ @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.
}

View File

@ -40,16 +40,16 @@ The other arguments have the same meaning as for @racket[expr/c].
@examples[#:eval the-eval @examples[#:eval the-eval
(define-syntax (myparameterize1 stx) (define-syntax (myparameterize1 stx)
(syntax-case stx () (syntax-case stx ()
[(_ ((p v)) body) [(_ ([p v]) body)
(with-syntax ([cp (wrap-expr/c (with-syntax ([cp (wrap-expr/c
#'parameter? #'p #'parameter? #'p
#:name "the parameter argument" #:name "the parameter argument"
#:context stx)]) #:context stx)])
#'(parameterize ((cp v)) body))])) #'(parameterize ([cp v]) body))]))
(myparameterize1 ((current-input-port (myparameterize1 ([current-input-port
(open-input-string "(1 2 3)"))) (open-input-string "(1 2 3)")])
(read)) (read))
(myparameterize1 (('whoops 'something)) (myparameterize1 (['whoops 'something])
'whatever) 'whatever)
(module mod racket (module mod racket

View File

@ -7,20 +7,21 @@
web-server/lang/serial-lambda web-server/lang/serial-lambda
web-server/private/define-closure)) web-server/private/define-closure))
The defunctionalization process of the Web Language (see
The defunctionalization process of the Web Language (see @secref["stateless" #:doc '(lib "web-server/scribblings/web-server.scrbl")]) @secref["stateless" #:doc '(lib "web-server/scribblings/web-server.scrbl")])
requires an explicit representation of closures that is serializable. requires an explicit representation of closures that is serializable.
@defmodule[web-server/lang/serial-lambda]{ @defmodule[web-server/lang/serial-lambda]{
@defform[(serial-lambda formals body ...)]{ @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 ...] ...)]{ @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} @section[#:style 'hidden]{Definition Syntax}

View File

@ -7,7 +7,7 @@
web-server/servlet)) web-server/servlet))
@defmodule[web-server/servlet/servlet-structs]{ @defmodule[web-server/servlet/servlet-structs]{
Servlets communicate to the Web Server by returning HTTP responses. In order to Servlets communicate to the Web Server by returning HTTP responses. In order to
accommodate lightweight programs (and backwards compatibility), the Web Server accommodate lightweight programs (and backwards compatibility), the Web Server
provides an indirection from application-specific response formats and the internal provides an indirection from application-specific response formats and the internal

View File

@ -17,14 +17,15 @@
@defproc[(make-cached-url->servlet @defproc[(make-cached-url->servlet
[url->path url->path/c] [url->path url->path/c]
[path->serlvet path->servlet/c]) [path->serlvet path->servlet/c])
(values (-> void) (values (-> void)
url->servlet/c)]{ url->servlet/c)]{
The first return value flushes the cache. The first return value flushes the cache. The second is a procedure
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 uses @racket[url->path] to resolve the URL to a path, then uses
that path to a servlet, caching the results in an internal table. @racket[path->servlet] to resolve that path to a servlet, caching the
results in an internal table.
} }
@defproc[(make [url->servlet url->servlet/c] @defproc[(make [url->servlet url->servlet/c]
[#:responders-servlet-loading [#:responders-servlet-loading
responders-servlet-loading responders-servlet-loading
@ -35,11 +36,14 @@
(url? exn? . -> . can-be-response?) (url? exn? . -> . can-be-response?)
servlet-error-responder]) servlet-error-responder])
dispatcher/c]{ dispatcher/c]{
This dispatcher runs racket servlets, using @racket[url->servlet] to resolve URLs to the underlying servlets. This dispatcher runs racket servlets, using @racket[url->servlet] to
If servlets have errors loading, then @racket[responders-servlet-loading] is used. Other errors are handled with resolve URLs to the underlying servlets. If servlets have errors
@racket[responders-servlet]. If a servlet raises calls @racket[next-dispatcher], then the signal is propagated by this dispatcher. 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"] @include-section["servlet-setup.scrbl"]
@ -48,18 +52,18 @@
@section{Internal Servlet Representation} @section{Internal Servlet Representation}
@defmodule[web-server/private/servlet]{ @defmodule[web-server/private/servlet]{
@defstruct[servlet ([custodian custodian?] @defstruct[servlet ([custodian custodian?]
[namespace namespace?] [namespace namespace?]
[manager manager?] [manager manager?]
[directory path-string?] [directory path-string?]
[handler (request? . -> . can-be-response?)]) [handler (request? . -> . can-be-response?)])
#:mutable]{ #:mutable]{
Instances of this structure hold the necessary parts of a servlet: Instances of this structure hold the necessary parts of a servlet:
the @racket[custodian] responsible for the servlet's resources, the @racket[custodian] responsible for the servlet's resources,
the @racket[namespace] the servlet is executed within, the @racket[namespace] the servlet is executed within,
the @racket[manager] responsible for the servlet's continuations, the @racket[manager] responsible for the servlet's continuations,
the current @racket[directory] of the servlet, the current @racket[directory] of the servlet,
and the @racket[handler] for all requests to the servlet. and the @racket[handler] for all requests to the servlet.
} }
} }

View File

@ -98,16 +98,18 @@ URLs to paths on the filesystem.
This is primarily useful for dispatchers that allow path information after 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 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.} by a file. The most prominent example is obviously servlets.}
@defproc[(filter-url->path [regex regexp?] @defproc[(filter-url->path [regex regexp?]
[url->path url->path/c]) [url->path url->path/c])
url->path/c]{ url->path/c]{
Runs the underlying @racket[url->path] but will only return if the path, when considered as a string, Runs the underlying @racket[url->path] but will only return if the
matches the @racket[regex]. This is useful to disallow strange files, like GIFs, from being considered path, when considered as a string, matches the @racket[regex]. This is
servlets when using the servlet dispatchers. It will return a @racket[exn:fail:filesystem:exists?] exception if useful to disallow strange files, like GIFs, from being considered
the path does not match. 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)) web-server/configuration/responders))
@defthing[denied?/c contract?]{ @defthing[denied?/c contract?]{
Equivalent to @racket[(request? . -> . (or/c false/c string?))]. Equivalent to @racket[(request? . -> . (or/c false/c string?))]. The
The return is the authentication realm as a string if the request is not authorized and return is the authentication realm as a string if the request is not
@racket[#f] if the request @emph{is} authorized. authorized and @racket[#f] if the request @emph{is} authorized.
} }
@defproc[(make [denied? denied?/c] @defproc[(make [denied? denied?/c]
[#:authentication-responder [#:authentication-responder
authentication-responder authentication-responder
(url? header? . -> . response?) (url? header? . -> . response?)
(gen-authentication-responder "forbidden.html")]) (gen-authentication-responder "forbidden.html")])
dispatcher/c]{ dispatcher/c]{
A dispatcher that checks if the request is denied based on @racket[denied?]. If so, then A dispatcher that checks if the request is denied based on
@racket[authentication-responder] is called with a @racket[header] that @racket[denied?]. If so, then @racket[authentication-responder] is
requests credentials. If not, then @racket[next-dispatcher] is called with a @racket[header] that requests credentials. If not, then
invoked. @racket[next-dispatcher] is invoked.
} }
@defthing[authorized?/c contract?]{ @defthing[authorized?/c contract?]{
Equivalent to @racket[(string? (or/c false/c bytes?) (or/c false/c bytes?) . -> . (or/c false/c string?))]. Equivalent to
The input is the URI as a string and the username and passwords as bytes. @racket[(string? (or/c false/c bytes?) (or/c false/c bytes?) . -> . (or/c false/c string?))].
The return is the authentication realm as a string if the user is not authorized and The input is the URI as a string and the username and passwords as
@racket[#f] if the request @emph{is} authorized. 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?]) @defproc[(make-basic-denied?/path [password-file path-string?])
(values (-> void) (values (-> void)
authorized?/c)]{ authorized?/c)]{
Creates an authorization procedure based on the given password file. The first returned value Creates an authorization procedure based on the given password
is a procedure that refreshes the password cache used by the authorization procedure. file. The first returned value is a procedure that refreshes the
password cache used by the authorization procedure.
@racket[password-file] is parsed as: @racket[password-file] is parsed as:
@racketblock[(list ([domain : string?] @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. 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.) (This setting is a little dangerous because requests might never finish if there is constant load.)
}} }}
@(require (for-label @(require (for-label
web-server/web-server web-server/web-server
web-server/http web-server/http
(prefix-in limit: web-server/dispatchers/limit) (prefix-in limit: web-server/dispatchers/limit)
(prefix-in filter: web-server/dispatchers/dispatch-filter) (prefix-in filter: web-server/dispatchers/dispatch-filter)
(prefix-in sequencer: web-server/dispatchers/dispatch-sequencer))) (prefix-in sequencer: web-server/dispatchers/dispatch-sequencer)))
Consider this example: Consider this example:
@racketmod[ @racketmod[
racket racket

View File

@ -23,9 +23,8 @@ Suppose we want to create an abstraction of entering a date in an HTML form. The
@racketblock[ @racketblock[
(define date-formlet (define date-formlet
(formlet (formlet
(div (div "Month:" ,{input-int . => . month}
"Month:" ,{input-int . => . month} "Day:" ,{input-int . => . day})
"Day:" ,{input-int . => . day})
(list month 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 (values xexpr-forest/c
((listof binding?) . -> . (values (coerce-contract 'formlet/c content) ...)) ((listof binding?) . -> . (values (coerce-contract 'formlet/c content) ...))
integer?))]. integer?))].
A @tech{formlet}'s internal representation is a function from an initial input number 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 to an @xexpr forest rendering, a processing function, and the next allowable
input number. 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]) @defproc[(xml-forest [r xexpr-forest/c])
(formlet/c procedure?)]{ (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]) @defproc[(xml [r xexpr/c])
(formlet/c procedure?)]{ (formlet/c procedure?)]{
Equivalent to @racket[(xml-forest (list r))]. Equivalent to @racket[(xml-forest (list r))].
} }
@defproc[(text [r string?]) @defproc[(text [r string?])
(formlet/c procedure?)]{ (formlet/c procedure?)]{
Equivalent to @racket[(xml r)]. Equivalent to @racket[(xml r)].
} }
@defproc[(tag-xexpr [tag symbol?] @defproc[(tag-xexpr [tag symbol?]
[attrs (listof (list/c symbol? string?))] [attrs (listof (list/c symbol? string?))]
[inner (formlet/c any/c)]) [inner (formlet/c any/c)])
(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 Constructs a @tech{formlet} with the rendering @racket[(list (list*
the rendering of @racket[inner] and the processing stage identical to @racket[inner]. 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)]) @defproc[(formlet-display [f (formlet/c any/c)])
xexpr-forest/c]{ xexpr-forest/c]{
Renders @racket[f]. Renders @racket[f].
} }
@defproc[(formlet-process [f (formlet/c any/c ...)] @defproc[(formlet-process [f (formlet/c any/c ...)]
[r request?]) [r request?])
(values any/c ...)]{ (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} @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]{ @defmodule[web-server/formlets/input]{
These @tech{formlet}s are the main combinators for form input. These @tech{formlet}s are the main combinators for form input.
@defproc[(make-input [render (string? . -> . xexpr/c)]) @defproc[(make-input [render (string? . -> . xexpr/c)])
(formlet/c (or/c false/c binding?))]{ (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 This @tech{formlet} is rendered with @racket[render], which is passed
extracted @racket[binding]. the input name, and results in the extracted @racket[binding].
} }
@defproc[(make-input* [render (string? . -> . xexpr/c)]) @defproc[(make-input* [render (string? . -> . xexpr/c)])
(formlet/c (listof binding?))]{ (formlet/c (listof binding?))]{
This @tech{formlet} is rendered with @racket[render], which is passed the input name, and results in all the This @tech{formlet} is rendered with @racket[render], which is passed
@racket[binding]s that use the name. 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] @defproc[(text-input [#:value value (or/c false/c bytes?) #f]
[#:size size (or/c false/c exact-nonnegative-integer?) #f] [#:size size (or/c false/c exact-nonnegative-integer?) #f]
[#:max-length max-length (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] [#:read-only? read-only? boolean? #f]
[#:attributes attrs (listof (list/c symbol? string?)) empty]) [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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] @defproc[(password-input [#:value value (or/c false/c bytes?) #f]
[#:size size (or/c false/c exact-nonnegative-integer?) #f] [#:size size (or/c false/c exact-nonnegative-integer?) #f]
[#:max-length max-length (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] [#:read-only? read-only? boolean? #f]
[#:attributes attrs (listof (list/c symbol? string?)) empty]) [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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] @defproc[(textarea-input [#:value value (or/c false/c bytes?) #f]
[#:rows rows (or/c false/c number?) #f] [#:rows rows (or/c false/c number?) #f]
[#:cols cols (or/c false/c number?) #f] [#:cols cols (or/c false/c number?) #f]
[#:attributes attrs (listof (list/c symbol? string?)) empty]) [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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?] @defproc[(checkbox [value bytes?]
[checked? boolean?] [checked? boolean?]
[#:attributes attrs (listof (list/c symbol? string?)) empty]) [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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?] @defproc[(radio [value bytes?]
[checked? boolean?] [checked? boolean?]
[#:attributes attrs (listof (list/c symbol? string?)) empty]) [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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. 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]) [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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?] @defproc[(reset [value bytes?]
[#:attributes attrs (listof (list/c symbol? string?)) empty]) [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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]) @defproc[(file-upload [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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]) @defproc[(hidden [value bytes?] [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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?] @defproc[(img [alt bytes?]
[src bytes?] [src bytes?]
[#:height height (or/c false/c exact-nonnegative-integer?) #f] [#: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] [#:width width (or/c false/c exact-nonnegative-integer?) #f]
[#:attributes attrs (listof (list/c symbol? string?)) empty]) [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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?] @defproc[(button [type bytes?]
[button-text bytes?] [button-text bytes?]
[#:disabled disabled boolean? #f] [#:disabled disabled boolean? #f]
[#:value value (or/c false/c bytes?) #f] [#:value value (or/c false/c bytes?) #f]
[#:attributes attrs (listof (list/c symbol? string?)) empty]) [#:attributes attrs (listof (list/c symbol? string?)) empty])
(formlet/c (or/c false/c binding?))]{ (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?] @defproc[(multiselect-input [l sequence?]
[#:attributes attrs (listof (list/c symbol? string?)) empty] [#:attributes attrs (listof (list/c symbol? string?)) empty]
[#:multiple? multiple? boolean? #t] [#:multiple? multiple? boolean? #t]
[#:selected? selected? (any/c . -> . boolean?) (λ (x) #f)] [#:selected? selected? (any/c . -> . boolean?) (λ (x) #f)]
[#:display display (any/c . -> . xexpr/c) (λ (x) x)]) [#:display display (any/c . -> . xexpr/c) (λ (x) x)])
(formlet/c list?)]{ (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?] @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)] [#:selected? selected? (any/c . -> . boolean?) (λ (x) #f)]
[#:display display (any/c . -> . xexpr/c) (λ (x) x)]) [#:display display (any/c . -> . xexpr/c) (λ (x) x)])
(formlet/c any/c)]{ (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?))]) @defproc[(required [f (formlet/c (or/c false/c binding?))])
(formlet/c bytes?)]{ (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 @defproc[(default
[def bytes?] [def bytes?]
[f (formlet/c (or/c false/c binding?))]) [f (formlet/c (or/c false/c binding?))])
(formlet/c bytes?)]{ (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?)]) @defproc[(to-string [f (formlet/c bytes?)])
(formlet/c string?)]{ (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?)]) @defproc[(to-number [f (formlet/c string?)])
(formlet/c number?)]{ (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?)]) @defproc[(to-symbol [f (formlet/c string?)])
(formlet/c symbol?)]{ (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?)]) @defproc[(to-boolean [f (formlet/c bytes?)])
(formlet/c boolean?)]{ (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?)]{ @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?)]{ @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?)]{ @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")) `(html (head (title "Form Entry"))
(body ,form-xexpr)))]) (body ,form-xexpr)))])
(values any/c ...)]{ (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 Uses @racket[send/suspend] and @racket[response/xexpr] to send
the continuation URL (wrapped again by @racket[wrapper])) to the client. @racket[f]'s rendering (wrapped in a FORM tag whose action is the
When the form is submitted, the request is passed to the continuation URL (wrapped again by @racket[wrapper])) to the client.
processing stage of @racket[f]. When the form is submitted, the request is passed to the processing
stage of @racket[f].
} }
@defproc[(embed-formlet [embed/url ((request? . -> . any) . -> . string?)] @defproc[(embed-formlet [embed/url ((request? . -> . any) . -> . string?)]
[f (formlet/c any/c ...)]) [f (formlet/c any/c ...)])
xexpr/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].
} }
} }

View File

@ -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. You are @bold{unlikely to need to construct} a request struct.
} }
@defproc[(request-bindings/raw [r request?]) @defproc[(request-bindings/raw [r request?])
(listof binding?)]{ (listof binding?)]{
Forces @racket[(request-bindings/raw-promise r)]. Forces @racket[(request-bindings/raw-promise r)].
} }
Here is an example typical of what you will find in many applications: Here is an example typical of what you will find in many applications:
@racketblock[ @racketblock[
(define (get-number req) (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))) (λ (op) (write-bytes #"Moved" op)))
] ]
} }
@defproc[(response/full [code number?] [message bytes?] [seconds number?] [mime bytes?] @defproc[(response/full [code number?] [message bytes?] [seconds number?] [mime bytes?]
[headers (listof header?)] [body (listof bytes?)]) [headers (listof header?)] [body (listof bytes?)])
response?]{ response?]{
A constructor for responses where @racket[body] is the response body. A constructor for responses where @racket[body] is the response body.
Example: Example:
@racketblock[ @racketblock[
(response/full (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}, @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.} or you will be susceptible to dangerous attacks.}
} }
@; ------------------------------------------------------------ @; ------------------------------------------------------------
@section[#:tag "cookie-parse"]{Extracting Cookies} @section[#:tag "cookie-parse"]{Extracting Cookies}
@ -277,9 +277,10 @@ transmission that the server @bold{will not catch}.}
[value string?] [value string?]
[domain (or/c false/c valid-domain?)] [domain (or/c false/c valid-domain?)]
[path (or/c false/c string?)])]{ [path (or/c false/c string?)])]{
While server cookies are represented with @racket[cookie?]s, cookies that come from the client are represented While server cookies are represented with @racket[cookie?]s, cookies
with a @racket[client-cookie] structure. that come from the client are represented with a
@racket[client-cookie] structure.
} }
@defproc[(request-cookies [req request?]) @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 Returns a pair of the username and password from the authentication
header in @racket[req] if they are present, or @racket[#f]. header in @racket[req] if they are present, or @racket[#f].
} }
Example: Example:
@racketmod[ @racketmod[
web-server/insta web-server/insta
@ -408,32 +409,36 @@ An implementation of HTTP Digest Authentication.
(or/c false/c (listof (cons/c symbol? string?)))]{ (or/c false/c (listof (cons/c symbol? string?)))]{
Returns the Digest credentials from @racket[req] (if they appear) as an association list. Returns the Digest credentials from @racket[req] (if they appear) as an association list.
} }
@defthing[username*realm->password/c contract?]{ @defthing[username*realm->password/c contract?]{
Used to look up the password for a user is a realm. Used to look up the password for a user is a realm.
Equivalent to @racket[(string? string? . -> . string?)]. Equivalent to @racket[(string? string? . -> . string?)].
} }
@defthing[username*realm->digest-HA1/c contract?]{ @defthing[username*realm->digest-HA1/c contract?]{
Used to compute the user's secret hash. Used to compute the user's secret hash.
Equivalent to @racket[(string? string? . -> . bytes?)]. Equivalent to @racket[(string? string? . -> . bytes?)].
} }
@defproc[(password->digest-HA1 [lookup-password username*realm->password/c]) @defproc[(password->digest-HA1 [lookup-password username*realm->password/c])
username*realm->digest-HA1/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]) @defproc[(make-check-digest-credentials [lookup-HA1 username*realm->digest-HA1/c])
(string? (listof (cons/c symbol? string?)) . -> . boolean?)]{ (string? (listof (cons/c symbol? string?)) . -> . boolean?)]{
Constructs a function that checks whether particular Digest credentials (the second argument of the returned function) Constructs a function that checks whether particular Digest credentials
are correct given the HTTP method provided as the first argument and the secret hash computed by @racket[lookup-HA1]. (the second argument of the returned function) are correct given the
HTTP method provided as the first argument and the secret hash computed
This is will result in an exception if the Digest credentials are missing portions. by @racket[lookup-HA1].
}
This is will result in an exception if the Digest credentials are
missing portions.
}
Example: Example:
@racketmod[ @racketmod[
web-server/insta web-server/insta
@ -471,7 +476,7 @@ web-server/insta
xml)) xml))
@defmodule[web-server/http/xexpr]{ @defmodule[web-server/http/xexpr]{
@defproc[(response/xexpr [xexpr xexpr/c] @defproc[(response/xexpr [xexpr xexpr/c]
[#:code code number? 200] [#:code code number? 200]
[#:message message bytes? #"Okay"] [#:message message bytes? #"Okay"]

View File

@ -45,9 +45,9 @@ An example @racket['stateless] servlet module:
(provide interface-version stuffer start) (provide interface-version stuffer start)
(define interface-version 'stateless) (define interface-version 'stateless)
(define stuffer (define stuffer
(stuffer-chain (stuffer-chain
serialize-stuffer serialize-stuffer
(md5-stuffer (build-path (find-system-path 'home-dir) ".urls")))) (md5-stuffer (build-path (find-system-path 'home-dir) ".urls"))))
(define (start req) (define (start req)
(response/xexpr (response/xexpr
`(html (body (h2 "Look ma, no state!"))))) `(html (body (h2 "Look ma, no state!")))))

View File

@ -68,7 +68,7 @@ the users and implementers of managers.
This exception should be thrown by a manager when a continuation is This exception should be thrown by a manager when a continuation is
looked up that does not exist. looked up that does not exist.
} }
} }
@; ------------------------------------------------------------ @; ------------------------------------------------------------

View File

@ -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?))) @defproc[(make-make-servlet-namespace (#:to-be-copied-module-specs to-be-copied-module-specs (listof module-path?)))
make-servlet-namespace/c]{ make-servlet-namespace/c]{
This function creates a function that when called will construct a new @racket[namespace] that This function creates a function that when called will construct a new
has all the modules from @racket[to-be-copied-module-specs] and @racket[additional-specs], as well @racket[namespace] that has all the modules from
as @racket[racket] and @racket[mred], provided they are already attached @racket[to-be-copied-module-specs] and @racket[additional-specs], as
to the @racket[(current-namespace)] of the call-site. well as @racket[racket] and @racket[mred], provided they are already
attached to the @racket[(current-namespace)] of the call-site.
Example: Example:
@racketblock[ @racketblock[
@ -32,19 +33,22 @@ Example:
#:to-be-copied-module-specs `((lib "database.rkt" "my-module"))) #:to-be-copied-module-specs `((lib "database.rkt" "my-module")))
] ]
} }
} }
@section{Why this is useful} @section{Why this is useful}
A different namespace is needed for each servlet, so that if servlet A and servlet B both use A different namespace is needed for each servlet, so that if servlet A
a stateful module C, they will be isolated from one another. We see the @web-server as and servlet B both use a stateful module C, they will be isolated from
an operating system for servlets, so we inherit the isolation requirement on operating systems. 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 However, there are some modules which must be shared. If they were not,
be passed from the @web-server to the servlets, because Racket's structures are generative. 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. Since, on occasion, a user will actually wanted servlets A and B to
A custom @racket[make-servlet-namespace] can be created, through this procedure, that attaches interact through module C. A custom @racket[make-servlet-namespace] can
module C to all servlet namespaces. Through other means (see @secref["dispatchers"]) different sets be created, through this procedure, that attaches module C to all
of servlets can share different sets of modules. servlet namespaces. Through other means (see @secref["dispatchers"])
different sets of servlets can share different sets of modules.

View File

@ -9,18 +9,23 @@
@defmodule[web-server/lang/native]{ @defmodule[web-server/lang/native]{
It is sometimes inconvenient to use @racket[serial->native] and @racket[native->serial] throughout your program. It is sometimes inconvenient to use @racket[serial->native] and
This module provides a macro for creating wrappers. @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, For example,
@racketblock[ @racketblock[
(define-native (build-list/native _ ho) build-list) (define-native (build-list/native _ ho) build-list)
] ]
is equivalent to is equivalent to
@racketblock[ @racketblock[
(define (build-list/native fst snd) (define (build-list/native fst snd)
@ -32,5 +37,5 @@ This module provides a macro for creating wrappers.
(apply snd args)))))) (apply snd args))))))
] ]
} }
} }

Some files were not shown because too many files have changed in this diff Show More