From 6c3360c716bd788b0b398dfc2f5eae66546550d0 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 7 Jul 2011 10:10:56 -0600 Subject: [PATCH] fix formating of duplicated syntax descriptions --- .../scribblings/htdp-langs/advanced.scrbl | 27 +- .../htdp-langs/beginner-abbr.scrbl | 5 +- .../scribblings/htdp-langs/beginner.scrbl | 11 +- .../htdp-langs/intermediate-lambda.scrbl | 9 +- .../scribblings/htdp-langs/intermediate.scrbl | 7 +- collects/scribblings/htdp-langs/prim-ops.rkt | 635 ++++++++++-------- 6 files changed, 379 insertions(+), 315 deletions(-) diff --git a/collects/scribblings/htdp-langs/advanced.scrbl b/collects/scribblings/htdp-langs/advanced.scrbl index d9bfb83da0..bfff957080 100644 --- a/collects/scribblings/htdp-langs/advanced.scrbl +++ b/collects/scribblings/htdp-langs/advanced.scrbl @@ -97,15 +97,13 @@ arguments, and (naturally) function calls can invoke functions of zero arguments @defform[(lambda (variable ...) expression)]{ -Creates a function that takes as many arguments as given @racket[variables]s, +Creates a function that takes as many arguments as given @racket[variable]s, and whose body is @racket[expression].} @defform[(λ (variable ...) expression)]{ The Greek letter @racket[λ] is a synonym for @racket[lambda].} - - @defform/none[(expression expression ...)]{ Calls the function that results from evaluating the first @@ -118,19 +116,6 @@ function call, or from a @racket[lambda] expression. The number of argument @racket[expression]s must be the same as the number of arguments expected by the function.} - - -In Advanced, @racket[define-struct] introduces one additional function: - -@itemize[ - - @item{@racketidfont{set-}@racket[structure-name]@racketidfont{-}@racket[field-name]@racketidfont{!} - : takes an instance of the structure and a value, and changes - the instance's field to the given value.} - -]} - - @; ---------------------------------------------------------------------- @@ -299,7 +284,12 @@ Like @racket[when], but the @racket[body-expression] is evaluated when the @(prim-forms ("advanced") define lambda - define-struct + define-struct + @{In Advanced, @racket[define-struct] introduces one additional function: + @itemize[ + @item{@racketidfont{set-}@racket[_structure-name]@racketidfont{-}@racket[_field-name]@racketidfont{!} + : takes an instance of the structure and a value, and + changes the instance's field to the given value.}]} define-wish cond else @@ -311,7 +301,8 @@ Like @racket[when], but the @racket[body-expression] is evaluated when the check-error check-member-of check-range - require) + require + true false) @; ---------------------------------------- diff --git a/collects/scribblings/htdp-langs/beginner-abbr.scrbl b/collects/scribblings/htdp-langs/beginner-abbr.scrbl index 341404bb15..300ebdc800 100644 --- a/collects/scribblings/htdp-langs/beginner-abbr.scrbl +++ b/collects/scribblings/htdp-langs/beginner-abbr.scrbl @@ -117,7 +117,7 @@ also be written with @racket[unquote-splicing].} @prim-forms[("beginner-abbr") define lambda - define-struct + define-struct [] define-wish cond else @@ -129,7 +129,8 @@ also be written with @racket[unquote-splicing].} check-error check-member-of check-range - require] + require + true false] @; ---------------------------------------- diff --git a/collects/scribblings/htdp-langs/beginner.scrbl b/collects/scribblings/htdp-langs/beginner.scrbl index 2c4668c9e8..e989a85f04 100644 --- a/collects/scribblings/htdp-langs/beginner.scrbl +++ b/collects/scribblings/htdp-langs/beginner.scrbl @@ -36,6 +36,9 @@ @prim-nonterms[("beginner") define define-struct] @prim-variables[("beginner") empty true false] + +@; -------------------------------------------------- + @section[#:tag "beginner-syntax"]{Syntax} @deftogether[( @@ -46,14 +49,13 @@ A quoted @racket[name] is a symbol. A symbol is a value, just like @racket[0] or @racket[empty].} - @(define-forms/normal define) @(define-form/explicit-lambda define lambda) @(prim-forms ("beginner") define lambda - define-struct + define-struct [] define-wish cond else @@ -65,7 +67,10 @@ A quoted @racket[name] is a symbol. A symbol is a value, just like check-error check-member-of check-range - require) + require + true false) + +@; -------------------------------------------------- @section[#:tag "beginner-pre-defined"]{Pre-defined Functions} diff --git a/collects/scribblings/htdp-langs/intermediate-lambda.scrbl b/collects/scribblings/htdp-langs/intermediate-lambda.scrbl index b8f8a72b48..979ba4ad2c 100644 --- a/collects/scribblings/htdp-langs/intermediate-lambda.scrbl +++ b/collects/scribblings/htdp-langs/intermediate-lambda.scrbl @@ -52,7 +52,7 @@ @defform[(lambda (variable variable ...) expression)]{ -Creates a function that takes as many arguments as given @racket[variables]s, +Creates a function that takes as many arguments as given @racket[variable]s, and whose body is @racket[expression].} @defform[(λ (variable variable ...) expression)]{ @@ -94,10 +94,10 @@ the function.} @(define-forms/normal define) -@(prim-forms ("beginner") +@(prim-forms ("intermediate-lam") define lambda - define-struct + define-struct [] define-wish cond else @@ -109,7 +109,8 @@ the function.} check-error check-member-of check-range - require) + require + true false) @section[#:tag "intm-w-lambda-pre-defined"]{Pre-defined Functions} diff --git a/collects/scribblings/htdp-langs/intermediate.scrbl b/collects/scribblings/htdp-langs/intermediate.scrbl index 50b25f5f36..f6d006c662 100644 --- a/collects/scribblings/htdp-langs/intermediate.scrbl +++ b/collects/scribblings/htdp-langs/intermediate.scrbl @@ -69,10 +69,10 @@ @(define-form/explicit-lambda define lambda) @(prim-forms - ("beginner") + ("intermediate") define lambda - define-struct + define-struct [] define-wish cond else @@ -84,7 +84,8 @@ check-error check-member-of check-range - require) + require + true false) diff --git a/collects/scribblings/htdp-langs/prim-ops.rkt b/collects/scribblings/htdp-langs/prim-ops.rkt index c0ab25bf68..d65998efd5 100644 --- a/collects/scribblings/htdp-langs/prim-ops.rkt +++ b/collects/scribblings/htdp-langs/prim-ops.rkt @@ -58,67 +58,70 @@ (define-syntax-rule (prim-variables (section-prefix) empty true false) (make-splice (list + @section[#:tag (string-append section-prefix " Pre-Defined Variables")]{Pre-Defined Variables} -@section[#:tag (string-append section-prefix " Pre-Defined Variables")]{Pre-Defined Variables} -@defthing[empty empty?]{ + @defthing[empty empty?]{ -The empty list.} + The empty list.} -@defthing[true boolean?]{ + @defthing[true boolean?]{ -The true value.} + The true value.} -@defthing[false boolean?]{ + @defthing[false boolean?]{ -The false value.} + The false value.}))) -))) +;; ---------------------------------------- (define-syntax-rule (define-forms/normal define) + (gen-define-forms/normal #'define @racket[define])) -(make-splice - (list -@defform*[[(define (... (name variable variable ...)) expression)]]{ +(define (gen-define-forms/normal define-id define-elem) + ;; Since `define' has a source location different from the use site, + ;; use the `#:id [spec-id bind-id]' form in `defform*': + (list + @defform*[#:id [define define-id] + [(define (name variable variable ...) expression)]]{ -Defines a function named @racket[name]. The @racket[expression] is the body -of the function. When the function is called, -the values of the arguments are inserted into the body in place of the -@racket[variable]s. The function returns the value of that new expression. + Defines a function named @racket[name]. The @racket[expression] is the body + of the function. When the function is called, + the values of the arguments are inserted into the body in place of the + @racket[variable]s. The function returns the value of that new expression. -The function name's cannot be the same as that of another function or -variable.} + The function name's cannot be the same as that of another function or + variable.} -@defform/none[#:literals (define) (define name expression)]{ + @defform/none[(@#,define-elem name expression)]{ -Defines a variable called @racket[name] with the the value of -@racket[expression]. The variable name's cannot be the same as that of -another function or variable, and @racket[name] itself must not appear in -@racket[expression].} + Defines a variable called @racket[name] with the the value of + @racket[expression]. The variable name's cannot be the same as that of + another function or variable, and @racket[name] itself must not appear in + @racket[expression].})) -))) +;; ---------------------------------------- (define-syntax-rule (define-form/explicit-lambda define lambda) + (gen-define-form/explicit-lambda @racket[define] + #'lambda @racket[lambda])) -(make-splice - (list - -@defform/none[#:literals (define lambda) - (... (define name (lambda (variable variable ...) expression)))]{ +(define (gen-define-form/explicit-lambda define-elem lambda-id lambda-elem) + (list + @defform/none[(#,define-elem name (#,lambda-elem (variable variable ...) expression))]{ -An alternate way on defining functions. The @racket[name] is the name of -the function, which cannot be the same as that of another function or -variable. + An alternate way on defining functions. The @racket[name] is the name of + the function, which cannot be the same as that of another function or + variable. -@defidform/inline[lambda] cannot be used outside of this alternate syntax. -} -))) + A @defidform/inline[#,lambda-id] cannot be used outside of this alternate syntax.})) +;; ---------------------------------------- (define-syntax-rule (prim-forms (section-prefix) define lambda - define-struct + define-struct [ds-extra ...] define-wish cond else @@ -130,210 +133,241 @@ variable. check-error check-member-of check-range - require) - (make-splice - (list + require + true + false) + (gen-prim-forms #'define-struct @racket[define-struct] (list ds-extra ...) + #'cond @racket[cond] + #'else @racket[else] + #'if @racket[if] + #'or @racket[or] + #'and @racket[and] + #'check-expect @racket[check-expect] + #'check-within @racket[check-within] + #'check-error @racket[check-error] + #'check-member-of @racket[check-member-of] + #'check-range @racket[check-range] + #'require @racket[require] + @racket[true] @racket[false])) +(define (gen-prim-forms define-struct-id define-struct-elem ds-extras + cond-id cond-elem + else-id else-elem + if-id if-elem + and-id and-elem + or-id or-elem + check-expect-id check-expect-elem + check-within-id check-within-elem + check-error-id check-error-elem + check-member-of-id check-member-of-elem + check-range-id check-range-elem + require-id require-elem + true-elem false-elem) + (list + @; ---------------------------------------------------------------------- + @defform*[#:id [define-struct define-struct-id] + [(define-struct structure-name (field-name ...))]]{ -@; ---------------------------------------------------------------------- + Defines a new structure called @racket[field-name]. The structure's fields are + named by the @racket[field-name]s. After the @define-struct-elem, the following new + functions are available: + @itemize[ -@defform*[[(... (define-struct structure-name (field-name ...)))]]{ + @item{@racketidfont{make-}@racket[structure-name] : takes in a number of + arguments equal to the number of fields in the structure, + and creates a new instance of that structure.} -Defines a new structure called @racket[field-name]. The structure's fields are -named by the @racket[field-name]s. After the @racket[define-struct], the following new -functions are available: + @item{@racket[structure-name]@racketidfont{-}@racket[field-name] : takes in an + instance of the structure and returns the value in the field named by + @racket[field-name].} -@itemize[ + @item{@racket[structure-name]@racketidfont{?} : takes in any value, and returns + @true-elem if the value is an instance of the structure.} + ] - @item{@racketidfont{make-}@racket[structure-name] : takes in a number of - arguments equal to the number of fields in the structure, - and creates a new instance of that structure.} + The name of the new functions introduced by @define-struct-elem + must not be the same as that of other functions or variables, + otherwise @define-struct-elem reports an error. - @item{@racket[structure-name]@racketidfont{-}@racket[field-name] : takes in an - instance of the structure and returns the value in the field named by - @racket[field-name].} + @ds-extras} - @item{@racket[structure-name]@racketidfont{?} : takes in any value, and returns - @racket[true] if the value is an instance of the structure.} + #| -] - -The name of the new functions introduced by @racket[define-struct] must not be the same as that of other functions or -variables, otherwise @racket[define-struct] reports an error.} - -#| - -@defform*[[(define-wish name)]]{ + @defform*[[(define-wish name)]]{ -Defines a function called @racket[name] that we wish exists but have not -implemented yet. The wished-for function can be called with one argument, and -are reported in the test report for the current program. + Defines a function called @racket[name] that we wish exists but have not + implemented yet. The wished-for function can be called with one argument, and + are reported in the test report for the current program. -The name of the function cannot be the same as another function or variable.} + The name of the function cannot be the same as another function or variable.} -@defform/none[#:literals (define-wish) - (define-wish name expression)]{ -Similar to the above form, defines a wished-for function named @racket[name]. If the -wished-for function is called with one value, it returns the values of @racket[expression]. } -|# + @defform/none[#:literals (define-wish) + (define-wish name expression)]{ + Similar to the above form, defines a wished-for function named @racket[name]. If the + wished-for function is called with one value, it returns the values of @racket[expression]. } + |# -@; ---------------------------------------------------------------------- + @; ---------------------------------------------------------------------- + + @defform/none[(name expression expression ...)]{ + + Calls the function named @racket[name]. The value of the call is the + value of @racket[name]'s body when every one of the function's + variables are replaced by the values of the corresponding + @racket[expression]s. + + The function named @racket[name] must defined before it can be called. The + number of argument @racket[expression]s must be the same as the number of arguments + expected by the function.} + + @; ---------------------------------------------------------------------- + + @defform*[#:id [cond cond-id] + #:literals (else) + [(cond [question-expression answer-expression] ...) + (#,cond-elem [question-expression answer-expression] + ... + [#,else-elem answer-expression])]]{ + + Chooses a clause base on a condition by finding the first + @racket[question-expression] that evaluates to @true-elem, then + evaluates the corresponding @racket[answer-expression]. + + If none of the @racket[question-expression]s evaluates to @true-elem, + @cond-elem's value is the @racket[answer-expression] of the + @else-elem clause. If there is no @else-elem, @cond-elem reports + an error. If the result of a @racket[question-expression] is neither + @true-elem nor @false-elem, @cond-elem also reports an error. + + An @defidform/inline[#,else-id] cannot be used outside of @|cond-elem|.} + + @; ---------------------------------------------------------------------- + + @defform*[#:id [if if-id] + [(if test-expression then-expression else-expression)]]{ + + When the value of the @racket[test-expression] is @true-elem, + @if-elem evaluates the @racket[then-expression]. When the test is + @false-elem, @if-elem evaluates the @racket[else-expression]. + + If the @racket[test-expression] is neither @true-elem nor + @false-elem, @if-elem reports an error.} + + @; ---------------------------------------------------------------------- + + @defform*[#:id [and and-id] + [(and expression expression expression ...)]]{ + + Evaluates to @true-elem if all the @racket[expression]s are + @|true-elem|. If any @racket[expression] is false, the @and-elem + expression immediately evaluates to @false-elem (and the expressions to the + right of that expression are not evaluated.) + + If any of the expressions evaluate to a value other than @true-elem or + @false-elem, @and-elem reports an error.} + + @; ---------------------------------------------------------------------- -@defform*[[(... (name expression expression ...))]]{ + @defform*[#:id [or or-id] + [(or expression expression expression ...)]]{ -Calls the function named @racket[name]. The value of the call is the value of -@racket[name]'s body when every one of the function's variables are -replaced by the values of the corresponding @racket[expression]s. + Evaluates to @true-elem as soon as one of the + @racket[expression]s is @true-elem (and the expressions to the right of that + expression are not evaluated.) If all of the @racket[expression]s are false, + the @or-elem expression evaluates to @racket[false]. -The function named @racket[name] must defined before it can be called. The -number of argument @racket[expression]s must be the same as the number of arguments -expected by the function.} + If any of the expressions evaluate to a value other than @true-elem or + @false-elem, @or-elem reports an error.} + + @; ---------------------------------------------------------------------- + + @defform*[#:id [check-expect check-expect-id] + [(check-expect expression expected-expression)]]{ + + Checks that the first @racket[expression] evaluates to the same value as the + @racket[expected-expression].} -@; ---------------------------------------------------------------------- + @defform*[#:id [check-within check-within-id] + [(check-within expression expected-expression delta-expression)]]{ + + Checks that the first @racket[expression] evaluates to a value within + @racket[delta-expression] of the @racket[expected-expression]. If + @racket[delta-expression] is not a number, @check-within-elem reports an + error.} -@defform*[#:literals (cond else) - [(... (cond [question-expression answer-expression] ...)) - (... (cond [question-expression answer-expression] ... [else answer-expression]))]]{ + @defform*[#:id [check-error check-error-id] + [(check-error expression expression) + (#,check-error-elem expression)]]{ -Chooses a clause base on a condition. @racket[cond] finds the first -@racket[question-expression] which evaluates to @racket[true], then it evaluates -the corresponding @racket[answer-expression]. - -If none of the @racket[question-expression]s evaluates to @racket[true], -@racket[cond]'s value is the @racket[answer-expression] of the -@racket[else] clause. If there is no @racket[else], @racket[cond] reports -an error. If the result of a @racket[question-expression] is neither -@racket[true] nor @racket[false], @racket[cond] also reports an error. + Checks that the first @racket[expression] reports an error, + where the error messages matches the string produced by the second + @racket[expression], if it is present.} -@defidform/inline[else] cannot be used outside of @racket[cond]. -} + @defform*[#:id [check-member-of check-member-of-id] + [(check-member-of expression expression expression ...)]]{ + + Checks that the first @racket[expression] produces the same value + as one of the following @racket[expression]s.} -@; ---------------------------------------------------------------------- + @defform*[#:id [check-range check-range-id] + [(check-range expression expression expression)]]{ + + Checks that the first @racket[expression] produces a number in + between the numbers produced by the second and third + @racket[expression]s, inclusive.} + + @; ---------------------------------------------------------------------- + + @defform*[#:id [require require-id] + [(require string)]]{ + + Makes the definitions of the module specified by @racket[string] + available in the current module (i.e., the current file), where + @racket[string] refers to a file relative to the current file. + + The @racket[string] is constrained in several ways to avoid + problems with different path conventions on different platforms: a + @litchar{/} is a directory separator, @litchar{.} always means the + current directory, @litchar{..} always means the parent directory, + path elements can use only @litchar{a} through @litchar{z} + (uppercase or lowercase), @litchar{0} through @litchar{9}, + @litchar{-}, @litchar{_}, and @litchar{.}, and the string cannot be + empty or contain a leading or trailing @litchar{/}.} -@defform*[[(if test-expression then-expression else-expression)]]{ + @defform/none[(#,require-elem module-name)]{ -When the value of the @racket[test-expression] is @racket[true], -@racket[if] evaluates the @racket[then-expression]. When the test is -@racket[false], @racket[if] evaluates the @racket[else-expression]. + Accesses a file in an installed library. The library name is an + identifier with the same constraints as for a relative-path string + (though without the quotes), with the additional constraint that it + must not contain a @litchar{.}.} -If the @racket[test-expression] is neither @racket[true] nor -@racket[false], @racket[if] reports an error.} + @defform/none[(#,require-elem (lib string string ...))]{ -@; ---------------------------------------------------------------------- + Accesses a file in an installed library, making its definitions + available in the current module (i.e., the current file). The first + @racket[string] names the library file, and the remaining + @racket[string]s name the collection (and sub-collection, and so on) + where the file is installed. Each string is constrained in the same + way as for the @racket[(#,require-elem string)] form.} -@defform*[[(... (and expression expression expression ...))]]{ + @defform/none[#:literals (planet) + (#,require-elem (planet string (string string number number)))]{ -@racket[and] evaluates to @racket[true] if all the @racket[expression]s are -@racket[true]. If any @racket[expression] is false, the @racket[and] -expression immediately evaluates to @racket[false] (the expressions to the -right of that expression are not evaluated.) - -If any of the expressions evaluate to a value other than @racket[true] or -@racket[false], it is an error.} - -@; ---------------------------------------------------------------------- - - -@defform*[[(... (or expression expression expression ...))]]{ - -@racket[or] evaluates to @racket[true] as soon as one of the -@racket[expression]s is @racket[true] (the expressions to the right of that -expression are not evaluated.) If all the @racket[expression] are false, -@racket[or] is @racket[false]. - -If any of the expressions evaluate to a value other than @racket[true] or -@racket[false], @racket[or] reports an error.} - -@; ---------------------------------------------------------------------- - - -@defform*[[(check-expect expression expected-expression)]]{ - -Checks that the first @racket[expression] evaluates to the same value as the -@racket[expected-expression].} - -@defform*[[(check-within expression expected-expression delta-expression)]]{ - -Checks that the first @racket[expression] evaluates to a value within -@racket[delta-expression] of the @racket[expected-expression]. If -@racket[delta-expression] is not a number, @racket[check-within] report an -error.} - -@defform*[[(check-error expression expression) - (check-error expression)]]{ - -Checks that the first @racket[expression] reports an error, -where the error messages matches the string produced by the second -@racket[expression], if it is present.} - -@defform*[[(... (check-member-of expression expression expression ...))]]{ - -Checks that the first @racket[expression] produces the same value as one of -the following @racket[expression]s.} - -@defform*[[(check-range expression expression expression)]]{ - -Checks that the first @racket[expression] produces a number in between the numbers -produced by the second and third @racket[expression]s, inclusive.} - - -@; ---------------------------------------------------------------------- - - -@defform*[[(require string)]]{ - -Makes the definitions of the module specified by @racket[string] -available in the current module (i.e., the current file), where @racket[string] -refers to a file relative to the current file. - -The @racket[string] is constrained in several ways to avoid problems -with different path conventions on different platforms: a @litchar{/} -is a directory separator, @litchar{.} always means the current -directory, @litchar{..} always means the parent directory, path -elements can use only @litchar{a} through @litchar{z} (uppercase or -lowercase), @litchar{0} through @litchar{9}, @litchar{-}, @litchar{_}, -and @litchar{.}, and the string cannot be empty or contain a leading -or trailing @litchar{/}.} - -@defform/none[#:literals (require) - (require module-name)]{ - -Accesses a file in an installed library. The library name is an identifier -with the same constraints as for a relative-path string (though without the -quotes), with the additional constraint that it must not contain a -@litchar{.}.} - -@defform/none[#:literals (require lib) - (... (require (lib string string ...)))]{ - -Accesses a file in an installed library, making its definitions -available in the current module (i.e., the current file). The first -@racket[string] names the library file, and the remaining -@racket[string]s name the collection (and sub-collection, and so on) -where the file is installed. Each string is constrained in the same -way as for the @racket[(require string)] form.} - - -@defform/none[#:literals (require planet) - (require (planet string (string string number number)))]{ - - -Accesses a library that is distributed on the internet via the PLaneT -server, making it definitions available in the current module (i.e., -current file).} - -))) + Accesses a library that is distributed on the internet via the + @|PLaneT| server, making it definitions available in the current module + (i.e., current file).})) +;; ---------------------------------------- (define-syntax-rule (intermediate-forms lambda @@ -346,119 +380,150 @@ current file).} let* let time) + (gen-intermediate-forms #'lambda @racket[lambda] + #'quote @racket[quote] + #'quasiquote @racket[quasiquote] + #'unquote @racket[unquote] + #'unquote-splicing @racket[unquote-splicing] + #'local @racket[local] + #'letrec @racket[letrec] + #'let* @racket[let*] + #'let @racket[let] + #'time @racket[time])) - (make-splice - (list +(define (gen-intermediate-forms lambda-id lambda-elem + quote-id quote-elem + quasiquote-id quasiquote-elem + unquote-id unquote-elem + unquote-splicing-id unquote-splicing-elem + local-id local-elem + letrec-id letrec-elem + let*-id let*-elem + let-id let-elem + time-id time-elem) + (list + @deftogether[( + @defform/none[(unsyntax @elem{@racketvalfont{'}@racket[name]})] + @defform/none[(unsyntax @elem{@racketvalfont{'}@racket[part]})] + @defform[#:id [quote quote-id] (quote name)] + @defform/none[(#,quote-elem part)] + )]{ -@deftogether[( -@defform/none[(unsyntax @elem{@racketvalfont{'}@racket[name]})] -@defform/none[(unsyntax @elem{@racketvalfont{'}@racket[part]})] -@defform[(quote name)] -@defform/none[(quote part)] -)]{ + A quoted name is a symbol. A quote part is an abbreviation for a nested lists. -A quoted name is a symbol. A quote part is an abbreviation for a nested lists. - -Normally, this quotation is written with a @litchar{'}, like -@racket['(apple banana)], but it can also be written with @racket[quote], like -@racket[(@#,racket[quote] (apple banana))].} + Normally, this quotation is written with a @litchar{'}, like + @racket['(apple banana)], but it can also be written with + @quote-elem, like @racket[(@#,quote-elem (apple banana))].} -@deftogether[( -@defform/none[(unsyntax @elem{@racketvalfont{`}@racket[name]})] -@defform/none[(unsyntax @elem{@racketvalfont{`}@racket[part]})] -@defform[(quasiquote name)] -@defform/none[(quasiquote part)] -)]{ + @deftogether[( + @defform/none[(unsyntax @elem{@racketvalfont{`}@racket[name]})] + @defform/none[(unsyntax @elem{@racketvalfont{`}@racket[part]})] + @defform[#:id [quasiquote quasiquote-id] + (quasiquote name)] + @defform/none[(#,quasiquote-elem part)] + )]{ -Like @racket[quote], but also allows escaping to expression ``unquotes.'' + Like @quote-elem, but also allows escaping to expression + ``unquotes.'' -Normally, quasi-quotations are written with a backquote, @litchar{`}, like -@racket[`(apple ,(+ 1 2))], but they can also be written with -@racket[quasiquote], like -@racket[(@#,racket[quasiquote] (apple ,(+ 1 2)))].} + Normally, quasi-quotations are written with a backquote, + @litchar{`}, like @racket[`(apple ,(+ 1 2))], but they can also be + written with @quasiquote-elem, like + @racket[(@quasiquote-elem (apple ,(+ 1 2)))].} -@deftogether[( -@defform/none[(unsyntax @elem{@racketvalfont{,}@racket[expression]})] -@defform[(unquote expression)] -)]{ + @deftogether[( + @defform/none[(unsyntax @elem{@racketvalfont{,}@racket[expression]})] + @defform[#:id [unquote unquote-id] + (unquote expression)] + )]{ -Under a single quasiquote, @racketfont{,}@racket[expression] escapes from -the quote to include an evaluated expression whose result is inserted -into the abbreviated list. + Under a single quasiquote, @racketfont{,}@racket[expression] + escapes from the quote to include an evaluated expression whose + result is inserted into the abbreviated list. -Under multiple quasiquotes, @racketfont{,}@racket[expression] is really -the literal @racketfont{,}@racket[expression], decrementing the quasiquote count -by one for @racket[expression]. + Under multiple quasiquotes, @racketfont{,}@racket[expression] is + really the literal @racketfont{,}@racket[expression], decrementing + the quasiquote count by one for @racket[expression]. -Normally, an unquote is written with @litchar{,}, but it can also be -written with @racket[unquote].} + Normally, an unquote is written with @litchar{,}, but it can also be + written with @|unquote-elem|.} -@deftogether[( -@defform/none[(unsyntax @elem{@racketvalfont[",@"]@racket[expression]})] -@defform[(unquote-splicing expression)] -)]{ + @deftogether[( + @defform/none[(unsyntax @elem{@racketvalfont[",@"]@racket[expression]})] + @defform[#:id [unquote-splicing unquote-splicing-id] + (unquote-splicing expression)] + )]{ -Under a single quasiquote, @racketfont[",@"]@racket[expression] escapes from -the quote to include an evaluated expression whose result is a list to -splice into the abbreviated list. + Under a single quasiquote, @racketfont[",@"]@racket[expression] + escapes from the quote to include an evaluated expression whose + result is a list to splice into the abbreviated list. -Under multiple quasiquotes, a splicing unquote is like an unquote; -that is, it decrements the quasiquote count by one. + Under multiple quasiquotes, a splicing unquote is like an unquote; + that is, it decrements the quasiquote count by one. -Normally, a splicing unquote is written with @litchar{,}, but it can -also be written with @racket[unquote-splicing].} - -@defform[(... (local [definition ...] expression))]{ - -Groups related definitions for use in @racket[expression]. Each -@racket[definition] can be either a variable definition, a function -definition, or a structure definition, using the usual syntax. - -When evaluating @racket[local], each @racket[definition] is evaluated in -order, and finally the body @racket[expression] is evaluated. Only the -expressions within the @racket[local] (including the right-hand-sides of -the @racket[definition]s and the @racket[expression]) may refer to the -names defined by the @racket[definition]s. If a name defined in the -@racket[local] is the same as a top-level binding, the inner one -``shadows'' the outer one. That is, inside the @racket[local], any -references to that name refer to the inner one.} - -@; ---------------------------------------------------------------------- + Normally, a splicing unquote is written with @litchar{,}, but it + can also be written with @|unquote-splicing-elem|.} -@defform[(... (letrec ([name expr-for-let] ...) expression))]{ + @defform[#:id [local local-id] + (local [definition ...] expression)]{ -Like @racket[local], but with a simpler syntax. Each @racket[name] defines -a variables (or a functions) with the value of the corresponding -@racket[expr-for-let]. If @racket[expr-for-let] is a @racket[lambda], -@racket[letrec] defines a function, otherwise it defines a variable.} + Groups related definitions for use in @racket[expression]. Each + @racket[definition] can be either a variable definition, a function + definition, or a structure definition, using the usual syntax. -@defform[(... (let* ([name expr-for-let] ...) expression))]{ + When evaluating @local-elem, each @racket[definition] is evaluated + in order, and finally the body @racket[expression] is + evaluated. Only the expressions within the @local-elem (including + the right-hand-sides of the @racket[definition]s and the + @racket[expression]) may refer to the names defined by the + @racket[definition]s. If a name defined in the @local-elem is the + same as a top-level binding, the inner one ``shadows'' the outer + one. That is, inside the @local-elem, any references to that name + refer to the inner one.} -Like @racket[letrec], but each @racket[name] can only be used in -@racket[expression], and in @racket[expr-for-let]s occuring after that -@racket[name].} + @; ---------------------------------------------------------------------- -@defform[(... (let ([name expr-for-let] ...) expression))]{ + @defform[#:id [letrec letrec-id] + (letrec ([name expr-for-let] ...) expression)]{ -Like @racket[letrec], but the defined @racket[name]s can be used only in -the last @racket[expression], not the @racket[expr-for-let]s next to the -@racket[name]s.} + Like @local-elem, but with a simpler syntax. Each @racket[name] + defines a variable (or a function) with the value of the + corresponding @racket[expr-for-let]. If @racket[expr-for-let] is a + @lambda-elem, @letrec-elem defines a function, otherwise it + defines a variable.} -@; ---------------------------------------------------------------------- + @defform[#:id [let* let*-id] + (let* ([name expr-for-let] ...) expression)]{ + + Like @letrec-elem, but each @racket[name] can only be used in + @racket[expression], and in @racket[expr-for-let]s occuring after + that @racket[name].} -@defform[(time expression)]{ + @defform[#:id [let let-id] + (let ([name expr-for-let] ...) expression)]{ -Measures the time taken to evaluate @racket[expression]. After evaluating -@racket[expression], @racket[time] prints out the time taken by the -evaluation (including real time, time taken by the cpu, and the time spent -collecting free memory). The value of @racket[time] is the same as that of @racket[expression].} -))) + Like @letrec-elem, but the defined @racket[name]s can be used only + in the last @racket[expression], not the @racket[expr-for-let]s + next to the @racket[name]s.} + + @; ---------------------------------------------------------------------- + + @defform[#:id [time time-id] + (time expression)]{ + + Measures the time taken to evaluate @racket[expression]. After + evaluating @racket[expression], @racket[time] prints out the time + taken by the evaluation (including real time, time taken by the + CPU, and the time spent collecting free memory). The value of + @time-elem is the same as that of @racket[expression].})) + +;; ---------------------------------------- (define (prim-ops lib ctx-stx) (let ([ops (map (lambda (cat)