A ton of @scheme*' ->
@racket*' and related updates.
Also, updates some of the mzlib files to point at `racket/*' libraries rather than to `scheme/*' ones.
This commit is contained in:
parent
f6be5447dd
commit
ac26fe7554
|
@ -13,14 +13,14 @@ by Peter Naur.
|
|||
@section{Including Algol 60 Programs}
|
||||
|
||||
Although Algol 60 is mainly provided as a DrRacket language,
|
||||
@scheme[include-algol] supports limited use of Algol 60 programs in
|
||||
@racket[include-algol] supports limited use of Algol 60 programs in
|
||||
larger programs.
|
||||
|
||||
@defmodule[algol60/algol60]
|
||||
|
||||
@defform[(include-algol path-string)]{
|
||||
|
||||
Includes the Algol 60 program indicated by @scheme[path-string] as an
|
||||
Includes the Algol 60 program indicated by @racket[path-string] as an
|
||||
expression in a Racket program. The included Algol 60 program is
|
||||
closed (i.e., it doesn't see any bindings in the included context),
|
||||
and the result is always @|void-const|.}
|
||||
|
@ -28,7 +28,7 @@ and the result is always @|void-const|.}
|
|||
|
||||
@section{Language}
|
||||
|
||||
The DrRacket and @scheme[include-algol] implementation departs from
|
||||
The DrRacket and @racket[include-algol] implementation departs from
|
||||
the Algol 60 specification in the following minor ways:
|
||||
|
||||
@(itemize (item "Strings are not permitted to contain nested quotes.")
|
||||
|
|
|
@ -77,7 +77,7 @@ return values are ignored.
|
|||
|
||||
If the html file is being accessed as a @litchar{file:} url, the
|
||||
@racket[current-load-relative-directory] parameter is set to the
|
||||
directory during the evaluation of the mzracket code (in both
|
||||
directory during the evaluation of the mzscheme code (in both
|
||||
examples). The Racket code is executed through @racket[eval].
|
||||
|
||||
The @litchar{MZSCHEME} forms are disabled unless the web page is a
|
||||
|
|
|
@ -35,13 +35,12 @@
|
|||
(elem "conversions: (obvious and precise)"))
|
||||
@(define goesto 'rarr)
|
||||
|
||||
|
||||
|
||||
@title{@scheme[c-lambda]: C FFI via @exec{raco ctool}}
|
||||
@title{@racket[c-lambda]: C FFI via @exec{raco ctool}}
|
||||
|
||||
@defmodule[compiler/cffi]{
|
||||
|
||||
The @schememodname[compiler/cffi] module relies on a C compiler to
|
||||
The @racketmodname[compiler/cffi] module relies on a C compiler to
|
||||
statically construct an interface to C code through directives
|
||||
embedded in a Racket program. The library implements a subset of
|
||||
@as-index{Gambit-C}'s foreign-function interface @cite["Feeley98"].}
|
||||
|
|
|
@ -10,89 +10,89 @@
|
|||
|
||||
@defmodule[config]{
|
||||
|
||||
The @schememodname[config] library specifies the location of
|
||||
The @racketmodname[config] library specifies the location of
|
||||
directories (such as the main documentation directory) and also
|
||||
directory search paths (such as a list of directories to search for
|
||||
documentation).}
|
||||
|
||||
|
||||
@bold{Note:} Instead of @scheme[require]ing
|
||||
@schememodname[config] directly, use the
|
||||
@schememodname[setup/dirs] library, which combines information from
|
||||
@schememodname[config] and other sources.
|
||||
@bold{Note:} Instead of @racket[require]ing
|
||||
@racketmodname[config] directly, use the
|
||||
@racketmodname[setup/dirs] library, which combines information from
|
||||
@racketmodname[config] and other sources.
|
||||
|
||||
The @schememodname[config] module must export the following
|
||||
values. In all cases where a @scheme[delay]ed value is expected for an
|
||||
exported identifier, the value can be a @scheme[delay]ed @scheme[#f]
|
||||
The @racketmodname[config] module must export the following
|
||||
values. In all cases where a @racket[delay]ed value is expected for an
|
||||
exported identifier, the value can be a @racket[delay]ed @racket[#f]
|
||||
to indicate the default.
|
||||
|
||||
@defthing[doc-dir (promise/c (or/c path? string? bytes? false/c))]{
|
||||
|
||||
A @scheme[delay]ed path, string, or byte string for the main
|
||||
A @racket[delay]ed path, string, or byte string for the main
|
||||
documentation directory. It defaults to a @filepath{doc} sibling
|
||||
directory of the main collection directory.}
|
||||
|
||||
@defthing[lib-dir (promise/c (or/c path? string? bytes? false/c))]{
|
||||
|
||||
A @scheme[delay]ed path, string, or byte string for the main directory
|
||||
A @racket[delay]ed path, string, or byte string for the main directory
|
||||
containing C libraries and build information; it defaults to a
|
||||
@filepath{lib} sibling directory of the main collection directory.}
|
||||
|
||||
@defthing[dll-dir (promise/c (or/c path? string? bytes? false/c))]{
|
||||
|
||||
A @scheme[delay]ed path, string, or byte string for a directory
|
||||
A @racket[delay]ed path, string, or byte string for a directory
|
||||
containing Unix shared libraries for the main executable; it defaults
|
||||
to the main C-library directory}
|
||||
|
||||
@defthing[include-dir (promise/c (or/c path? string? bytes? false/c))]{
|
||||
|
||||
A @scheme[delay]ed path, string, or byte string for the main directory
|
||||
A @racket[delay]ed path, string, or byte string for the main directory
|
||||
containing C header files; it defaults to an @filepath{include}
|
||||
sibling directory of the main collection directory.}
|
||||
|
||||
@defthing[bin-dir (promise/c (or/c path? string? bytes? false/c))]{
|
||||
|
||||
A @scheme[delay]ed path, string, or byte string for the main directory
|
||||
A @racket[delay]ed path, string, or byte string for the main directory
|
||||
containing executables; it defaults to a @filepath{bin} sibling
|
||||
directory of the main collection directory.}
|
||||
|
||||
@defthing[doc-search-dirs (promise/c (or/c path? string? bytes? false/c))]{
|
||||
|
||||
A @scheme[delay]ed path, string, byte string, or @scheme[#f]
|
||||
representing the search path for documentation; each @scheme[#f] in
|
||||
A @racket[delay]ed path, string, byte string, or @racket[#f]
|
||||
representing the search path for documentation; each @racket[#f] in
|
||||
the list, if any, is replaced with the default search path, which is
|
||||
the user- and version-specific @filepath{doc} directory followed by
|
||||
the main documentation directory.}
|
||||
|
||||
@defthing[lib-search-dirs (promise/c (or/c path? string? bytes? false/c))]{
|
||||
|
||||
Like @scheme[doc-search-dirs], but for directories containing C
|
||||
Like @racket[doc-search-dirs], but for directories containing C
|
||||
libraries and other build information}
|
||||
|
||||
@defthing[include-search-dirs(promise/c (or/c path? string? bytes? false/c))]{
|
||||
|
||||
Like @scheme[doc-search-dirs], but for directories containing C header
|
||||
Like @racket[doc-search-dirs], but for directories containing C header
|
||||
files}
|
||||
|
||||
@defthing[absolute-installation? boolean?]{
|
||||
|
||||
A (simple, non-@scheme[delay]ed) boolean that is @scheme[#t] if the
|
||||
installation uses absolute path names, @scheme[#f] otherwise.}
|
||||
A (simple, non-@racket[delay]ed) boolean that is @racket[#t] if the
|
||||
installation uses absolute path names, @racket[#f] otherwise.}
|
||||
|
||||
@defthing[cgc-suffix (promise/c (or/c string? false/c))]{
|
||||
|
||||
A @scheme[delay]ed string used as the suffix (before the actual
|
||||
A @racket[delay]ed string used as the suffix (before the actual
|
||||
suffix, such as @filepath{.exe}) for a @filepath{CGC} executable. Use
|
||||
Windows-style casing, and the string will be downcased as appropriate
|
||||
(e.g., for a Unix binary name). A @scheme[#f] value means that if the
|
||||
(e.g., for a Unix binary name). A @racket[#f] value means that if the
|
||||
@exec{mzscheme} binary identifies itself as CGC, then the suffix is
|
||||
@scheme[""], otherwise it is @scheme["CGC"].}
|
||||
@racket[""], otherwise it is @racket["CGC"].}
|
||||
|
||||
@defthing[3m-suffix (promise/c (or/c string? false/c))]{
|
||||
|
||||
Analogous to @scheme[cgc-suffix], but for 3m. A @scheme[#f] value
|
||||
Analogous to @racket[cgc-suffix], but for 3m. A @racket[#f] value
|
||||
means that if the @filepath{mzscheme} binary identifies itself as CGC,
|
||||
then the suffix is @scheme["3m"], otherwise it is @scheme[""].}
|
||||
then the suffix is @racket["3m"], otherwise it is @racket[""].}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
|
@ -108,17 +108,17 @@ normally takes precedence over the main collection directory).
|
|||
|
||||
@defmodule[setup/configtab]{
|
||||
|
||||
The @schememodname[setup/configtab] library defines a language module
|
||||
that can be used to implement @schememodname[config].}
|
||||
The @racketmodname[setup/configtab] library defines a language module
|
||||
that can be used to implement @racketmodname[config].}
|
||||
|
||||
When @schememodname[setup/configtab] is used as a language module, the
|
||||
When @racketmodname[setup/configtab] is used as a language module, the
|
||||
module body must consist of a sequence of
|
||||
|
||||
@schemeblock[(define _id _val)]
|
||||
@racketblock[(define _id _val)]
|
||||
|
||||
declarations, where each @scheme[_id] is one of the names that the
|
||||
@schememodname[config] library must export, and @scheme[_val] is
|
||||
declarations, where each @racket[_id] is one of the names that the
|
||||
@racketmodname[config] library must export, and @racket[_val] is
|
||||
an expression for the value (which will be automatically wrapped with
|
||||
@scheme[delay] when needed). If a required export has no corresponding
|
||||
@scheme[define], a definition with @scheme[#f] is inserted
|
||||
@racket[delay] when needed). If a required export has no corresponding
|
||||
@racket[define], a definition with @racket[#f] is inserted
|
||||
automatically.
|
||||
|
|
|
@ -109,7 +109,7 @@ The following BNF describes the syntax of Datalog.
|
|||
(nonterm "constant"))
|
||||
(list (nonterm "constant")
|
||||
(nonterm "IDENTIFIER")
|
||||
(nonterm "STRING"))
|
||||
(nonterm "STRING"))
|
||||
]
|
||||
|
||||
The effect of running a Datalog program is to modify the database as directed
|
||||
|
@ -143,7 +143,7 @@ All identifiers in @racketmodname[racket/base] are available for use as predicat
|
|||
|
||||
The following is a program:
|
||||
@racketmod[datalog/sexp
|
||||
|
||||
|
||||
(! (edge a b))
|
||||
(! (edge b c))
|
||||
(! (edge c d))
|
||||
|
|
|
@ -16,22 +16,22 @@ The Datalog database can be directly used by Racket programs through this API.
|
|||
|
||||
@examples[#:eval the-eval
|
||||
(define family (make-theory))
|
||||
|
||||
|
||||
(datalog family
|
||||
(! (parent joseph2 joseph1))
|
||||
(! (parent joseph2 lucy))
|
||||
(! (parent joseph3 joseph2)))
|
||||
|
||||
|
||||
(datalog family
|
||||
(? (parent X joseph2)))
|
||||
|
||||
|
||||
(datalog family
|
||||
(? (parent joseph2 X)))
|
||||
|
||||
|
||||
(datalog family
|
||||
(? (parent joseph2 X))
|
||||
(? (parent X joseph2)))
|
||||
|
||||
|
||||
(datalog family
|
||||
(! (:- (ancestor A B)
|
||||
(parent A B)))
|
||||
|
@ -46,7 +46,7 @@ The Datalog database can be directly used by Racket programs through this API.
|
|||
(let ([x 'joseph2])
|
||||
(datalog family
|
||||
(? (parent x X))))
|
||||
|
||||
|
||||
(datalog family
|
||||
(? (add1 1 :- X)))]
|
||||
|
||||
|
@ -57,11 +57,11 @@ The Datalog database can be directly used by Racket programs through this API.
|
|||
@defform[(datalog thy-expr
|
||||
stmt ...)
|
||||
#:contracts ([thy-expr theory/c])]{ Executes the statements on the theory given by @racket[thy-expr]. Returns the answers to the final query as a list of substitution dictionaries or returns @racket[empty]. }
|
||||
|
||||
|
||||
@defform[(datalog! thy-expr
|
||||
stmt ...)
|
||||
#:contracts ([thy-expr theory/c])]{ Executes the statements on the theory given by @racket[thy-expr]. Prints the answers to every query in the list of statements. Returns @racket[(void)]. }
|
||||
|
||||
|
||||
Statements are either assertions, retractions, or queries.
|
||||
|
||||
@defform[(! clause)]{ Asserts the clause. }
|
||||
|
@ -70,7 +70,7 @@ Statements are either assertions, retractions, or queries.
|
|||
@defform[(:- literal question ...)]{ A conditional clause. }
|
||||
|
||||
@defform[(? question)]{ Queries the literal and prints the result literals. }
|
||||
|
||||
|
||||
Questions are either literals or external queries.
|
||||
Literals are represented as @racket[identifier] or @racket[(identifier term ...)].
|
||||
External queries are represented as @racket[(identifier term ... :- term ...)], where @racket[identifier] is bound to a procedure that when given the first set of terms as arguments returns the second set of terms as values.
|
||||
|
|
|
@ -9,8 +9,8 @@ Abstraktion - fortgeschritten} that goes with the German textbook
|
|||
@italic{Die Macht der Abstraktion}.
|
||||
|
||||
@declare-exporting[deinprogramm/DMdA-advanced]
|
||||
|
||||
@schemegrammar*-DMdA[
|
||||
|
||||
@racketgrammar*-DMdA[
|
||||
#:literals (define-record-procedures-2 set!)
|
||||
(
|
||||
(define-record-procedures-2 id id id (field-spec ...))
|
||||
|
@ -23,11 +23,11 @@ Abstraktion - fortgeschritten} that goes with the German textbook
|
|||
string
|
||||
character
|
||||
(quoted ...)
|
||||
@#,elem{@schemevalfont{'}@scheme[quoted]}]
|
||||
@#,elem{@racketvalfont{'}@racket[quoted]}]
|
||||
)
|
||||
(
|
||||
(set! id expr)
|
||||
(code:line @#,elem{@schemevalfont{'}@scheme[quoted]} (code:comment @#,seclink["advanced-quote"]{Quote-Literal}))
|
||||
(code:line @#,elem{@racketvalfont{'}@racket[quoted]} (code:comment @#,seclink["advanced-quote"]{Quote-Literal}))
|
||||
)
|
||||
]
|
||||
|
||||
|
@ -38,10 +38,10 @@ Abstraktion - fortgeschritten} that goes with the German textbook
|
|||
@section[#:tag "advanced-quote"]{Quote-Literal}
|
||||
|
||||
@deftogether[(
|
||||
@defform/none[(unsyntax @elem{@schemevalfont{'}@scheme[quoted]})]
|
||||
@defform/none[(unsyntax @elem{@racketvalfont{'}@racket[quoted]})]
|
||||
@defform[(quote quoted)]
|
||||
)]{
|
||||
Der Wert eines Quote-Literals hat die gleiche externe Repräsentation wie @scheme[quoted].
|
||||
Der Wert eines Quote-Literals hat die gleiche externe Repräsentation wie @racket[quoted].
|
||||
}
|
||||
|
||||
@section[#:tag "advanced-signatures"]{Signaturen}
|
||||
|
|
|
@ -12,7 +12,7 @@ Abstraktion mit Zuweisungen} to go with the German textbook
|
|||
|
||||
@declare-exporting[deinprogramm/DMdA-assignments]
|
||||
|
||||
@schemegrammar*-DMdA[
|
||||
@racketgrammar*-DMdA[
|
||||
#:literals (define-record-procedures-2 define-record-procedures-parametric-2 set!)
|
||||
(
|
||||
(define-record-procedures-2 id id id (field-spec ...))
|
||||
|
@ -30,48 +30,48 @@ Abstraktion mit Zuweisungen} to go with the German textbook
|
|||
|
||||
@prim-ops['(lib "DMdA-assignments.rkt" "deinprogramm") #'here]
|
||||
|
||||
@section{@scheme[define-record-procedures-2]}
|
||||
@section{@racket[define-record-procedures-2]}
|
||||
|
||||
@declare-exporting[deinprogramm/DMdA]
|
||||
|
||||
@defform[(define-record-procedures-2 t c p (field-spec ...))]{
|
||||
Die @scheme[define-record-procedures-2]-Form ist eine Definition für
|
||||
einen neuen Record-Typ. Dabei ist @scheme[t] der Name der Record-Signatur,
|
||||
@scheme[c] der Name des Konstruktors, @scheme[p] der Name des
|
||||
Prädikats. Jedes @scheme[field-spec] kann entweder der Name eines Selektors
|
||||
oder ein Paar @scheme[(id id)] aus dem Namen eines Selektors und dem Namen eines
|
||||
Die @racket[define-record-procedures-2]-Form ist eine Definition für
|
||||
einen neuen Record-Typ. Dabei ist @racket[t] der Name der Record-Signatur,
|
||||
@racket[c] der Name des Konstruktors, @racket[p] der Name des
|
||||
Prädikats. Jedes @racket[field-spec] kann entweder der Name eines Selektors
|
||||
oder ein Paar @racket[(id id)] aus dem Namen eines Selektors und dem Namen eines
|
||||
Mutators sein.
|
||||
}
|
||||
|
||||
@section{@scheme[define-record-procedures-parametric-2]}
|
||||
@section{@racket[define-record-procedures-parametric-2]}
|
||||
|
||||
@declare-exporting[deinprogramm/DMdA]
|
||||
|
||||
@defform[(define-record-procedures-parametric-2 t cc c p (field-spec1 ...))]{
|
||||
Diese Form ist wie @scheme[define-record-procedures-2], nur parametrisch
|
||||
wie @scheme[define-record-procedures-parametric]. Außerdem
|
||||
Diese Form ist wie @racket[define-record-procedures-2], nur parametrisch
|
||||
wie @racket[define-record-procedures-parametric]. Außerdem
|
||||
werden die Signaturen für die Feldinhalte, anders als bei
|
||||
@scheme[define-record-procedures-parametric], sofort bei der
|
||||
@racket[define-record-procedures-parametric], sofort bei der
|
||||
Konstruktion überprüft und nicht erst beim Aufruf eines Selektors.
|
||||
}
|
||||
|
||||
@section{@scheme[begin]}
|
||||
@section{@racket[begin]}
|
||||
|
||||
@declare-exporting[deinprogramm/DMdA]
|
||||
|
||||
@defform[(begin expr expr ...)]{
|
||||
Bei der Auswertung eines @scheme[begin]-Ausdrucks werden nacheinander
|
||||
Bei der Auswertung eines @racket[begin]-Ausdrucks werden nacheinander
|
||||
die Operanden ausgewertet. Der Wert des letzten Ausdrucks wird der
|
||||
Wert des @scheme[begin]-Ausdrucks.
|
||||
Wert des @racket[begin]-Ausdrucks.
|
||||
}
|
||||
|
||||
@section{@scheme[set!]}
|
||||
@section{@racket[set!]}
|
||||
|
||||
@declare-exporting[deinprogramm/DMdA]
|
||||
|
||||
@defform[(set! id expr)]{
|
||||
Ein @scheme[set!]-Ausdruck ist eine Zuweisung, und ändert den Inhalt
|
||||
der Zelle, die an @scheme[id] gebunden ist, auf den Wert von @scheme[expr].
|
||||
Ein @racket[set!]-Ausdruck ist eine Zuweisung, und ändert den Inhalt
|
||||
der Zelle, die an @racket[id] gebunden ist, auf den Wert von @racket[expr].
|
||||
}
|
||||
|
||||
@section[#:tag "assignments-signatures"]{Signaturen}
|
||||
|
@ -80,21 +80,21 @@ der Zelle, die an @scheme[id] gebunden ist, auf den Wert von @scheme[expr].
|
|||
|
||||
@defidform[unspecific]{
|
||||
Signatur für unspezifische Werte, die unwichtig sind - typischerweise für die
|
||||
Rückgabewerte von Operationen, die nur Seiteneffekte haben wie @scheme[set!]
|
||||
oder @scheme[write-string].
|
||||
Rückgabewerte von Operationen, die nur Seiteneffekte haben wie @racket[set!]
|
||||
oder @racket[write-string].
|
||||
}
|
||||
|
||||
@section[#:tag "advanced-definitions"]{Definitionen}
|
||||
@declare-exporting[deinprogramm/DMdA-deflam]
|
||||
|
||||
@defform[(define id expr)]{Diese Form ist wie in den unteren
|
||||
Sprachebenen, mit dem Unterschied, dass an @scheme[id] mit
|
||||
@scheme[set!] zugewiesen werden kann.}
|
||||
Sprachebenen, mit dem Unterschied, dass an @racket[id] mit
|
||||
@racket[set!] zugewiesen werden kann.}
|
||||
|
||||
@section[#:tag "advanced-lambda"]{@scheme[lambda]}
|
||||
@section[#:tag "advanced-lambda"]{@racket[lambda]}
|
||||
@declare-exporting[deinprogramm/DMdA-deflam]
|
||||
|
||||
@defform[(lambda (id id ... . id) expr)]{Bei @scheme[lambda] ist in
|
||||
@defform[(lambda (id id ... . id) expr)]{Bei @racket[lambda] ist in
|
||||
dieser Sprachebene in einer Form zulässig, die es erlaubt, eine
|
||||
Prozedur mit einer variablen Anzahl von Paramern zu erzeugen: Alle
|
||||
Parameter vor dem Punkt funktionieren wie gewohnt und werden jeweils
|
||||
|
|
|
@ -11,7 +11,7 @@ Macht der Abstraktion}.
|
|||
|
||||
@declare-exporting[deinprogramm/DMdA-beginner #:use-sources (deinprogramm/DMdA deinprogramm/define-record-procedures)]
|
||||
|
||||
@schemegrammar*-DMdA[
|
||||
@racketgrammar*-DMdA[
|
||||
#:literals ()
|
||||
() () ()
|
||||
]
|
||||
|
@ -25,27 +25,27 @@ Macht der Abstraktion}.
|
|||
@section{Definitionen}
|
||||
|
||||
@defform[(define id expr)]{
|
||||
Diese Form ist eine Definition, und bindet @scheme[id] als
|
||||
globalen Namen an den Wert von @scheme[exp].}
|
||||
Diese Form ist eine Definition, und bindet @racket[id] als
|
||||
globalen Namen an den Wert von @racket[exp].}
|
||||
|
||||
@section{Record-Typ-Definitionen}
|
||||
|
||||
@defform[(define-record-procedures t c p (s1 ...))]{
|
||||
|
||||
Die @scheme[define-record-procedures]-Form ist eine Definition
|
||||
für einen neuen Record-Typ. Dabei ist @scheme[t] der Name der Record-Signatur,
|
||||
@scheme[c] der Name des Konstruktors, @scheme[p]
|
||||
der Name des Prädikats, und die @scheme[si] sind die
|
||||
Die @racket[define-record-procedures]-Form ist eine Definition
|
||||
für einen neuen Record-Typ. Dabei ist @racket[t] der Name der Record-Signatur,
|
||||
@racket[c] der Name des Konstruktors, @racket[p]
|
||||
der Name des Prädikats, und die @racket[si] sind die
|
||||
Namen der Selektoren.}
|
||||
|
||||
@section[#:tag "application"]{Prozedurapplikation}
|
||||
|
||||
@defform/none[(expr expr ...)]{
|
||||
Dies ist eine Prozeduranwendung oder Applikation.
|
||||
Alle @scheme[expr]s werden ausgewertet:
|
||||
Alle @racket[expr]s werden ausgewertet:
|
||||
Der Operator (also der erste Ausdruck) muß eine
|
||||
Prozedur ergeben, die genauso viele Argumente
|
||||
akzeptieren kann, wie es Operanden, also weitere @scheme[expr]s gibt.
|
||||
akzeptieren kann, wie es Operanden, also weitere @racket[expr]s gibt.
|
||||
Die Anwendung wird dann ausgewertet, indem der Rumpf
|
||||
der Applikation ausgewertet wird, nachdem die Parameter
|
||||
der Prozedur durch die Argumente, also die Werte der
|
||||
|
@ -53,15 +53,15 @@ Operanden ersetzt wurden.}
|
|||
|
||||
@; @defform[(#%app id expr expr ...)]{
|
||||
@;
|
||||
@; Eine Prozedurapplikation kann auch mit @scheme[#%app] geschrieben
|
||||
@; Eine Prozedurapplikation kann auch mit @racket[#%app] geschrieben
|
||||
@; werden, aber das macht eigentlich niemand.}
|
||||
|
||||
@section{@scheme[#t] and @scheme[#f]}
|
||||
@section{@racket[#t] and @racket[#f]}
|
||||
|
||||
@as-index{@litchar{#t}} ist das Literal für den booleschen Wert "wahr",
|
||||
@as-index{@litchar{#f}} das Literal für den booleschen Wert "falsch".
|
||||
|
||||
@section{@scheme[lambda]}
|
||||
@section{@racket[lambda]}
|
||||
|
||||
@defform[(lambda (id ...) expr)]{
|
||||
Ein Lambda-Ausdruck ergibt bei der Auswertung eine neue Prozedur.}
|
||||
|
@ -70,69 +70,69 @@ Ein Lambda-Ausdruck ergibt bei der Auswertung eine neue Prozedur.}
|
|||
|
||||
@defform/none[id]{
|
||||
Eine Variable bezieht sich auf die, von innen nach
|
||||
außen suchend, nächstgelegene Bindung durch @scheme[lambda], @scheme[let], @scheme[letrec], oder
|
||||
@scheme[let*]. Falls es keine solche lokale Bindung gibt, muß es eine
|
||||
außen suchend, nächstgelegene Bindung durch @racket[lambda], @racket[let], @racket[letrec], oder
|
||||
@racket[let*]. Falls es keine solche lokale Bindung gibt, muß es eine
|
||||
Definition oder eine eingebaute Bindung mit dem entsprechenden Namen
|
||||
geben. Die Auswertung des Namens ergibt dann den entsprechenden
|
||||
Wert. }
|
||||
|
||||
@section{@scheme[cond]}
|
||||
@section{@racket[cond]}
|
||||
|
||||
@defform[(cond (expr expr) ... (expr expr))]{
|
||||
Ein @scheme[cond]-Ausdruck bildet eine Verzweigung, die aus mehreren
|
||||
Ein @racket[cond]-Ausdruck bildet eine Verzweigung, die aus mehreren
|
||||
Zweigen besteht. Jeder Zweig besteht
|
||||
aus einem Test und einem Ausdruck. Bei der Auswertung werden die
|
||||
Zweige nacheinander abgearbeitet. Dabei wird jeweils zunächst der Test
|
||||
ausgewertet, der jeweils einen booleschen Wert ergeben müssen. Beim
|
||||
ersten Test, der @scheme[#t] ergibt, wird der Wert des Ausdrucks des Zweigs zum
|
||||
Wert der gesamten Verzweigung. Wenn kein Test @scheme[#t] ergibt, wird das
|
||||
ersten Test, der @racket[#t] ergibt, wird der Wert des Ausdrucks des Zweigs zum
|
||||
Wert der gesamten Verzweigung. Wenn kein Test @racket[#t] ergibt, wird das
|
||||
Programm mit einer Fehlermeldung abgebrochen.
|
||||
}
|
||||
|
||||
@defform/none[#:literals (cond else)
|
||||
(cond (expr expr) ... (else expr))]{
|
||||
Die Form des cond-Ausdrucks ist ähnlich zur vorigen, mit der
|
||||
Ausnahme, daß in dem Fall, in dem kein Test @scheme[#t] ergibt, der Wert des
|
||||
letzten Ausdruck zum Wert der @scheme[cond]-Form wird.
|
||||
Ausnahme, daß in dem Fall, in dem kein Test @racket[#t] ergibt, der Wert des
|
||||
letzten Ausdruck zum Wert der @racket[cond]-Form wird.
|
||||
}
|
||||
|
||||
@defidform[else]{
|
||||
|
||||
Das Schlüsselwort @scheme[else] kann nur in @scheme[cond] benutzt werden.}
|
||||
Das Schlüsselwort @racket[else] kann nur in @racket[cond] benutzt werden.}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@section{@scheme[if]}
|
||||
@section{@racket[if]}
|
||||
|
||||
@defform[(if expr expr expr)]{
|
||||
Eine @scheme[if]-Form ist eine binäre Verzweigung. Bei der Auswertung wird
|
||||
Eine @racket[if]-Form ist eine binäre Verzweigung. Bei der Auswertung wird
|
||||
zunächst der erste Operand ausgewertet (der Test), der einen
|
||||
booleschen Wert ergeben muß. Ergibt er @scheme[#t], wird der Wert des zweiten
|
||||
Operanden (die Konsequente) zum Wert der @scheme[if]-Form, bei @scheme[#f] der Wert des
|
||||
booleschen Wert ergeben muß. Ergibt er @racket[#t], wird der Wert des zweiten
|
||||
Operanden (die Konsequente) zum Wert der @racket[if]-Form, bei @racket[#f] der Wert des
|
||||
dritten Operanden (die Alternative).
|
||||
}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@section{@scheme[and]}
|
||||
@section{@racket[and]}
|
||||
|
||||
@defform[(and expr ...)]{
|
||||
Bei der Auswertung eines @scheme[and]-Ausdrucks werden nacheinander die
|
||||
Bei der Auswertung eines @racket[and]-Ausdrucks werden nacheinander die
|
||||
Operanden (die boolesche Werte ergeben müssen) ausgewertet. Ergibt
|
||||
einer @scheme[#f], ergibt auch der and-Ausdruck @scheme[#f]; wenn alle
|
||||
Operanden @scheme[#t] ergeben, ergibt auch der @scheme[and]-Ausdruck
|
||||
@scheme[#t].
|
||||
einer @racket[#f], ergibt auch der and-Ausdruck @racket[#f]; wenn alle
|
||||
Operanden @racket[#t] ergeben, ergibt auch der @racket[and]-Ausdruck
|
||||
@racket[#t].
|
||||
}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@section{@scheme[or]}
|
||||
@section{@racket[or]}
|
||||
|
||||
@defform[(or expr ...)]{
|
||||
Bei der Auswertung eines @scheme[or]-Ausdrucks werden nacheinander die
|
||||
Bei der Auswertung eines @racket[or]-Ausdrucks werden nacheinander die
|
||||
Operanden (die boolesche Werte ergeben müssen) ausgewertet. Ergibt
|
||||
einer @scheme[#t], ergibt auch der or-Ausdruck @scheme[#t]; wenn alle Operanden @scheme[#f]
|
||||
ergeben, ergibt auch der @scheme[or]-Ausdruck @scheme[#f].
|
||||
einer @racket[#t], ergibt auch der or-Ausdruck @racket[#t]; wenn alle Operanden @racket[#f]
|
||||
ergeben, ergibt auch der @racket[or]-Ausdruck @racket[#f].
|
||||
}
|
||||
|
||||
@section{Signaturen}
|
||||
|
@ -141,14 +141,14 @@ Signaturen können statt der Verträge aus dem Buch geschrieben werden:
|
|||
Während Verträge reine Kommentare sind, überprüft DrRacket Signaturen
|
||||
und meldet etwaige Verletzungen.
|
||||
|
||||
@subsection{@scheme[signature]}
|
||||
@subsection{@racket[signature]}
|
||||
@defform[(signature sig)]{
|
||||
Diese Form liefert die Signatur mit der Notation @scheme[sig].
|
||||
Diese Form liefert die Signatur mit der Notation @racket[sig].
|
||||
}
|
||||
|
||||
@subsection{Signaturdeklaration}
|
||||
@defform[(: id sig)]{
|
||||
Diese Form erklärt @scheme[sig] zur gültigen Signatur für @scheme[id].
|
||||
Diese Form erklärt @racket[sig] zur gültigen Signatur für @racket[id].
|
||||
}
|
||||
|
||||
@subsection{Eingebaute Signaturen}
|
||||
|
@ -202,33 +202,33 @@ Signatur für Signaturen.}
|
|||
@defidform[property]{
|
||||
Signatur für Eigenschaften.}
|
||||
|
||||
@subsection{@scheme[predicate]}
|
||||
@subsection{@racket[predicate]}
|
||||
@defform[(predicate expr)]{
|
||||
Bei dieser Signatur muß @scheme[expr] als Wert ein Prädikat haben, also
|
||||
eine Prozedur, die einen beliebigen Wert akzeptiert und entweder @scheme[#t]
|
||||
oder @scheme[#f] zurückgibt.
|
||||
Bei dieser Signatur muß @racket[expr] als Wert ein Prädikat haben, also
|
||||
eine Prozedur, die einen beliebigen Wert akzeptiert und entweder @racket[#t]
|
||||
oder @racket[#f] zurückgibt.
|
||||
Die Signatur ist dann für einen Wert gültig, wenn das Prädikat, darauf angewendet,
|
||||
@scheme[#t] ergibt.
|
||||
@racket[#t] ergibt.
|
||||
}
|
||||
|
||||
@subsection{@scheme[one-of]}
|
||||
@subsection{@racket[one-of]}
|
||||
@defform[(one-of expr ...)]{
|
||||
Diese Signatur ist für einen Wert gültig, wenn er gleich dem Wert eines
|
||||
der @scheme[expr] ist.
|
||||
der @racket[expr] ist.
|
||||
}
|
||||
|
||||
@subsection{@scheme[mixed]}
|
||||
@subsection{@racket[mixed]}
|
||||
@defform[(mixed sig ...)]{
|
||||
Diese Signatur ist für einen Wert gültig, wenn er für eine der Signaturen
|
||||
@scheme[sig] gültig ist.
|
||||
@racket[sig] gültig ist.
|
||||
}
|
||||
|
||||
@subsection[#:tag "proc-signature"]{Prozedur-Signatur}
|
||||
@defidform[->]{
|
||||
@defform/none[(sig ... -> sig)]{
|
||||
Diese Signatur ist dann für einen Wert gültig, wenn dieser eine
|
||||
Prozedur ist. Er erklärt außerdem, daß die Signaturen vor dem @scheme[->]
|
||||
für die Argumente der Prozedur gelten und die Signatur nach dem @scheme[->]
|
||||
Prozedur ist. Er erklärt außerdem, daß die Signaturen vor dem @racket[->]
|
||||
für die Argumente der Prozedur gelten und die Signatur nach dem @racket[->]
|
||||
für den Rückgabewert.
|
||||
}}
|
||||
}
|
||||
|
@ -241,80 +241,80 @@ für den Rückgabewert.
|
|||
Dies ist eine Signaturvariable: sie steht für eine Signatur, die für jeden Wert gültig ist.
|
||||
}
|
||||
|
||||
@subsection{@scheme[combined]}
|
||||
@subsection{@racket[combined]}
|
||||
@defform[(combined sig ...)]{
|
||||
Diese Signatur ist für einen Wert gültig, wenn sie für alle der Signaturen
|
||||
@scheme[sig] gültig ist.
|
||||
@racket[sig] gültig ist.
|
||||
}
|
||||
|
||||
@section{Testfälle}
|
||||
|
||||
@defform[(check-expect expr expr)]{
|
||||
|
||||
Dieser Testfall überprüft, ob der erste @scheme[expr] den gleichen
|
||||
Wert hat wie der zweite @scheme[expr], wobei das zweite @scheme[expr]
|
||||
Dieser Testfall überprüft, ob der erste @racket[expr] den gleichen
|
||||
Wert hat wie der zweite @racket[expr], wobei das zweite @racket[expr]
|
||||
meist ein Literal ist.}
|
||||
|
||||
@defform[(check-within expr expr expr)]{
|
||||
|
||||
Wie @scheme[check-expect], aber mit einem weiteren Ausdruck,
|
||||
der als Wert eine Zahl @scheme[_delta] hat. Der Testfall überprüft, daß jede Zahl im Resultat
|
||||
des ersten @scheme[expr] maximal um @scheme[_delta]
|
||||
von der entsprechenden Zahl im zweiten @scheme[expr] abweicht.}
|
||||
Wie @racket[check-expect], aber mit einem weiteren Ausdruck,
|
||||
der als Wert eine Zahl @racket[_delta] hat. Der Testfall überprüft, daß jede Zahl im Resultat
|
||||
des ersten @racket[expr] maximal um @racket[_delta]
|
||||
von der entsprechenden Zahl im zweiten @racket[expr] abweicht.}
|
||||
|
||||
@defform[(check-member-of expr expr ...)]{
|
||||
|
||||
Ähnlich wie @scheme[check-expect]: Der Testfall überprüft, daß das Resultat
|
||||
Ähnlich wie @racket[check-expect]: Der Testfall überprüft, daß das Resultat
|
||||
des ersten Operanden gleich dem Wert eines der folgenden Operanden ist.}
|
||||
|
||||
@defform[(check-range expr expr expr)]{
|
||||
|
||||
Ähnlich wie @scheme[check-expect]: Alle drei Operanden müssen
|
||||
Ähnlich wie @racket[check-expect]: Alle drei Operanden müssen
|
||||
Zahlen sein. Der Testfall überprüft, ob die erste Zahl zwischen der
|
||||
zweiten und der dritten liegt (inklusive).}
|
||||
|
||||
@defform[(check-error expr expr)]{
|
||||
|
||||
Dieser Testfall überprüft, ob der erste @scheme[expr] einen Fehler produziert,
|
||||
Dieser Testfall überprüft, ob der erste @racket[expr] einen Fehler produziert,
|
||||
wobei die Fehlermeldung der Zeichenkette entspricht, die der Wert des zweiten
|
||||
@scheme[expr] ist.}
|
||||
@racket[expr] ist.}
|
||||
|
||||
@defform[(check-property expr)]{
|
||||
|
||||
Dieser Testfall überprüft experimentell, ob die @tech{Eigenschaft}
|
||||
@scheme[expr] erfüllt ist. Dazu werden zufällige Werte für die mit
|
||||
@scheme[for-all] quantifizierten Variablen eingesetzt: Damit wird
|
||||
@racket[expr] erfüllt ist. Dazu werden zufällige Werte für die mit
|
||||
@racket[for-all] quantifizierten Variablen eingesetzt: Damit wird
|
||||
überprüft, ob die Bedingung gilt.
|
||||
|
||||
@emph{Wichtig:} @scheme[check-property] funktioniert nur für
|
||||
@emph{Wichtig:} @racket[check-property] funktioniert nur für
|
||||
Eigenschaften, bei denen aus den Signaturen sinnvoll Werte generiert
|
||||
werden können. Dies ist für die meisten eingebauten Signaturen der
|
||||
Fall, aber nicht für Signaturvariablen und Signaturen, die mit @scheme[predicate]
|
||||
erzeugt wurden. In diesen Fällen erzeugt @scheme[check-property] eine Fehlermeldung.
|
||||
Fall, aber nicht für Signaturvariablen und Signaturen, die mit @racket[predicate]
|
||||
erzeugt wurden. In diesen Fällen erzeugt @racket[check-property] eine Fehlermeldung.
|
||||
}
|
||||
|
||||
@section{Parametrische Record-Typ-Definitionen}
|
||||
|
||||
@defform[(define-record-procedures-parametric t cc c p (s1 ...))]{
|
||||
|
||||
Die @scheme[define-record-procedures-parametric] ist wie
|
||||
@scheme[define-record-procedures]. Zusäzlich wird der Bezeichner
|
||||
@scheme[cc] an einen Signaturkonstruktor gebunden: Dieser akzeptiert
|
||||
Die @racket[define-record-procedures-parametric] ist wie
|
||||
@racket[define-record-procedures]. Zusäzlich wird der Bezeichner
|
||||
@racket[cc] an einen Signaturkonstruktor gebunden: Dieser akzeptiert
|
||||
für jedes Feld eine Feld-Signatur und liefert eine Signatur, die nur
|
||||
Records des Record-Typs @scheme[t] erfüllen, bei dem die Feldinhalte
|
||||
Records des Record-Typs @racket[t] erfüllen, bei dem die Feldinhalte
|
||||
die Feld-Signaturen erfüllen.
|
||||
|
||||
Beispiel:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define-record-procedures-parametric pare pare-of
|
||||
make-pare pare?
|
||||
(pare-one pare-two))
|
||||
]
|
||||
|
||||
Dann ist @scheme[(pare-of integer string)] die Signatur für
|
||||
@scheme[pare]-Records, bei dem die Feldinhalte die Signaturen
|
||||
@scheme[integer] bzw. @scheme[string] erfüllen müssen.
|
||||
Dann ist @racket[(pare-of integer string)] die Signatur für
|
||||
@racket[pare]-Records, bei dem die Feldinhalte die Signaturen
|
||||
@racket[integer] bzw. @racket[string] erfüllen müssen.
|
||||
|
||||
Die Signaturen für die Feldinhalte werden erst überprüft, wenn ein
|
||||
Selektor aufgerufen wird.
|
||||
|
@ -322,15 +322,15 @@ Selektor aufgerufen wird.
|
|||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@; @section{@scheme[require]}
|
||||
@; @section{@racket[require]}
|
||||
@;
|
||||
@; @defform[(require string)]{
|
||||
@;
|
||||
@; Diese Form macht die Definitionen des durch @scheme[string] spezifizierten Moduls
|
||||
@; verfügbar. Dabei bezieht sich @scheme[string] auf eine Datei relativ zu der Datei,
|
||||
@; in der die @scheme[require]-Form steht.
|
||||
@; Diese Form macht die Definitionen des durch @racket[string] spezifizierten Moduls
|
||||
@; verfügbar. Dabei bezieht sich @racket[string] auf eine Datei relativ zu der Datei,
|
||||
@; in der die @racket[require]-Form steht.
|
||||
@;
|
||||
@; Dabei ist @scheme[string] leicht eingeschränkt, um Portabilitätsprobleme zu vermeiden:
|
||||
@; Dabei ist @racket[string] leicht eingeschränkt, um Portabilitätsprobleme zu vermeiden:
|
||||
@; @litchar{/} ist der Separator für Unterverzeichnisse,, @litchar{.} bedeutet das aktuelle
|
||||
@; Verzeichnis, @litchar{..} meint das übergeordnete Verzeichnis, Pfadelemente
|
||||
@; können nur @litchar{a} bis @litchar{z} (groß oder klein),
|
||||
|
@ -342,7 +342,7 @@ Selektor aufgerufen wird.
|
|||
@; @defform/none[#:literals (require)
|
||||
@; (require module-id)]{
|
||||
@;
|
||||
@; Diese Form macht eine eingebaute Library mit dem Namen @scheme[module-id] verfügbar.}
|
||||
@; Diese Form macht eine eingebaute Library mit dem Namen @racket[module-id] verfügbar.}
|
||||
@;
|
||||
@; @defform/none[#:literals (require lib)
|
||||
@; (require (lib string string ...))]{
|
||||
|
@ -350,10 +350,10 @@ Selektor aufgerufen wird.
|
|||
@; Diese Form macht die Definitionen eines Moduls in einer installierten Bibliothek
|
||||
@; verfügbar.
|
||||
@; Der erste
|
||||
@; @scheme[string] ist der Name der Datei des Moduls, und die restlichen
|
||||
@; @scheme[string]s bezeichnen die Collection (und Sub-Collection undsoweiter),
|
||||
@; in der die Datei installiert ist. Jede @scheme[string] ist ebenso eingeschränkt
|
||||
@; wie bei @scheme[(require string)].}
|
||||
@; @racket[string] ist der Name der Datei des Moduls, und die restlichen
|
||||
@; @racket[string]s bezeichnen die Collection (und Sub-Collection undsoweiter),
|
||||
@; in der die Datei installiert ist. Jede @racket[string] ist ebenso eingeschränkt
|
||||
@; wie bei @racket[(require string)].}
|
||||
@;
|
||||
@;
|
||||
@; @defform/none[#:literals (require planet)
|
||||
|
@ -371,7 +371,7 @@ Scheme-Ausdruck, die experimentell überprüft werden kann. Der
|
|||
einfachste Fall einer Eigenschaft ist ein boolescher Ausdruck. Die
|
||||
folgende Eigenschaft gilt immer:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(= 1 1)
|
||||
]
|
||||
|
||||
|
@ -379,17 +379,17 @@ Es ist auch möglich, in einer Eigenschaft Variablen zu verwenden, für
|
|||
die verschiedene Werte eingesetzt werden. Dafür müssen die Variablen
|
||||
gebunden und @deftech{quantifiziert} werden, d.h. es muß festgelegt
|
||||
werden, welche Signatur die Werte der Variable erfüllen sollen.
|
||||
Eigenschaften mit Variablen werden mit der @scheme[for-all]-Form erzeugt:
|
||||
Eigenschaften mit Variablen werden mit der @racket[for-all]-Form erzeugt:
|
||||
|
||||
@defform[(for-all ((id sig) ...) expr)]{
|
||||
Dies bindet die Variablen @scheme[id] in der Eigenschaft
|
||||
@scheme[expr]. Zu jeder Variable gehört eine Signatur
|
||||
@scheme[sig], der von den Werten der Variable erfüllt werden
|
||||
Dies bindet die Variablen @racket[id] in der Eigenschaft
|
||||
@racket[expr]. Zu jeder Variable gehört eine Signatur
|
||||
@racket[sig], der von den Werten der Variable erfüllt werden
|
||||
muß.
|
||||
|
||||
Beispiel:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(for-all ((x integer))
|
||||
(= x (/ (* x 2) 2)))
|
||||
]
|
||||
|
@ -397,40 +397,40 @@ Beispiel:
|
|||
|
||||
@defform[(expect expr expr)]{
|
||||
|
||||
Ein @scheme[expect]-Ausdruck ergibt eine Eigenschaft, die dann gilt,
|
||||
wenn die Werte von @scheme[expr] und @scheme[expr] gleich sind, im
|
||||
gleichen Sinne wie bei @scheme[check-expect].}
|
||||
Ein @racket[expect]-Ausdruck ergibt eine Eigenschaft, die dann gilt,
|
||||
wenn die Werte von @racket[expr] und @racket[expr] gleich sind, im
|
||||
gleichen Sinne wie bei @racket[check-expect].}
|
||||
|
||||
|
||||
@defform[(expect-within expr expr expr)]{
|
||||
|
||||
Wie @scheme[expect], aber entsprechend @scheme[check-within] mit einem
|
||||
weiteren Ausdruck, der als Wert eine Zahl @scheme[_delta] hat. Die
|
||||
Wie @racket[expect], aber entsprechend @racket[check-within] mit einem
|
||||
weiteren Ausdruck, der als Wert eine Zahl @racket[_delta] hat. Die
|
||||
resultierende Eigenschaft gilt, wenn jede Zahl im Resultat des ersten
|
||||
@scheme[expr] maximal um @scheme[_delta] von der entsprechenden Zahl
|
||||
im zweiten @scheme[expr] abweicht.}
|
||||
@racket[expr] maximal um @racket[_delta] von der entsprechenden Zahl
|
||||
im zweiten @racket[expr] abweicht.}
|
||||
|
||||
@defform[(expect-member-of expr expr ...)]{
|
||||
|
||||
Wie @scheme[expect], aber entsprechend @scheme[check-member-of] mit
|
||||
Wie @racket[expect], aber entsprechend @racket[check-member-of] mit
|
||||
weiteren Ausdrücken, die mit dem ersten verglichen werden. Die
|
||||
resultierende Eigenschaft gilt, wenn das erste Argument gleich
|
||||
einem der anderen Argumente ist.}
|
||||
|
||||
@defform[(expect-range expr expr expr)]{
|
||||
|
||||
Wie @scheme[expect], aber entsprechend @scheme[check-range]: Die
|
||||
Wie @racket[expect], aber entsprechend @racket[check-range]: Die
|
||||
Argumente müssen Zahlen sein. Die Eigenschaft gilt, wenn die erste Zahl
|
||||
zwischen der zweiten und dritten Zahl liegt (inklusive).}
|
||||
|
||||
|
||||
@defform[(==> expr expr)]{
|
||||
Der erste Operand ist ein boolescher Ausdruck, der zweite Operand eine
|
||||
Eigenschaft: @scheme[(==> c p)] legt fest, daß die Eigenschaft
|
||||
@scheme[p] nur erfüllt sein muß, wenn @scheme[c] (die
|
||||
@emph{Bedingung}) @scheme[#t] ergibt, also erfüllt ist.}
|
||||
Eigenschaft: @racket[(==> c p)] legt fest, daß die Eigenschaft
|
||||
@racket[p] nur erfüllt sein muß, wenn @racket[c] (die
|
||||
@emph{Bedingung}) @racket[#t] ergibt, also erfüllt ist.}
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(for-all ((x integer))
|
||||
(==> (even? x)
|
||||
(= x (* 2 (/ x 2)))))
|
||||
|
|
|
@ -23,7 +23,7 @@ Macht der Abstraktion}}.
|
|||
|
||||
@defmodule[deinprogramm/DMdA-beginner]
|
||||
|
||||
Das Modul @schememodname[deinprogramm/DMdA-beginner] implementiert die
|
||||
Das Modul @racketmodname[deinprogramm/DMdA-beginner] implementiert die
|
||||
Anfängersprache für @|DMdA|; siehe @DMdA-ref["DMdA-beginner"].
|
||||
|
||||
@; ------------------------------------------------------------
|
||||
|
@ -31,7 +31,7 @@ Anfängersprache für @|DMdA|; siehe @DMdA-ref["DMdA-beginner"].
|
|||
|
||||
@defmodule[deinprogramm/DMdA-vanilla]
|
||||
|
||||
Das Modul @schememodname[deinprogramm/DMdA-vanilla] implementiert die
|
||||
Das Modul @racketmodname[deinprogramm/DMdA-vanilla] implementiert die
|
||||
Standardsprache für @|DMdA|; siehe @DMdA-ref["DMdA-vanilla"].
|
||||
|
||||
@; ------------------------------------------------------------
|
||||
|
@ -39,7 +39,7 @@ Standardsprache für @|DMdA|; siehe @DMdA-ref["DMdA-vanilla"].
|
|||
|
||||
@defmodule[deinprogramm/DMdA-assignments]
|
||||
|
||||
Das Modul @schememodname[deinprogramm/DMdA-assignments] implementiert
|
||||
Das Modul @racketmodname[deinprogramm/DMdA-assignments] implementiert
|
||||
die Sprachebene für @|DMdA| mit Zuweisungen und Mutationen; siehe
|
||||
@DMdA-ref["DMdA-assignments"].
|
||||
|
||||
|
@ -48,6 +48,6 @@ die Sprachebene für @|DMdA| mit Zuweisungen und Mutationen; siehe
|
|||
|
||||
@defmodule[deinprogramm/DMdA-advanced]
|
||||
|
||||
Das Modul @schememodname[deinprogramm/DMdA-advanced] implementiert
|
||||
Das Modul @racketmodname[deinprogramm/DMdA-advanced] implementiert
|
||||
die fortgeschrittene Sprachebene für @|DMdA|; siehe
|
||||
@DMdA-ref["DMdA-advanced"].
|
||||
|
|
|
@ -11,7 +11,7 @@ Abstraktion}.
|
|||
|
||||
@declare-exporting[deinprogramm/DMdA-vanilla #:use-sources (deinprogramm/DMdA)]
|
||||
|
||||
@schemegrammar*-DMdA[
|
||||
@racketgrammar*-DMdA[
|
||||
#:literals ()
|
||||
() () ()
|
||||
]
|
||||
|
@ -22,55 +22,55 @@ Abstraktion}.
|
|||
|
||||
@section[#:tag "signatures-vanilla"]{Signaturen}
|
||||
|
||||
@subsection{@scheme[list-of]}
|
||||
@subsection{@racket[list-of]}
|
||||
@defform[(list-of sig)]{
|
||||
Diese Signatur ist dann für einen Wert gültig, wenn dieser eine Liste ist,
|
||||
für dessen Elemente @scheme[sig] gültig ist.
|
||||
für dessen Elemente @racket[sig] gültig ist.
|
||||
}
|
||||
|
||||
@section{@scheme[let], @scheme[letrec] und @scheme[let*]}
|
||||
@section{@racket[let], @racket[letrec] und @racket[let*]}
|
||||
|
||||
@defform[(let ((id expr) ...) expr)]{
|
||||
|
||||
Bei einem @scheme[let]-Ausdruck werden zunächst die @scheme[expr]s aus
|
||||
den @scheme[(id expr)]-Paaren ausgewertet. Ihre Werte werden dann im
|
||||
Rumpf-@scheme[expr] für die Namen @scheme[id] eingesetzt. Dabei können
|
||||
Bei einem @racket[let]-Ausdruck werden zunächst die @racket[expr]s aus
|
||||
den @racket[(id expr)]-Paaren ausgewertet. Ihre Werte werden dann im
|
||||
Rumpf-@racket[expr] für die Namen @racket[id] eingesetzt. Dabei können
|
||||
sich die Ausdrücke nicht auf die Namen beziehen.
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define a 3)
|
||||
(let ((a 16)
|
||||
(b a))
|
||||
(+ b a))
|
||||
=> 19]
|
||||
|
||||
Das Vorkommen von @scheme[a] in der Bindung von @scheme[b] bezieht
|
||||
sich also auf das @scheme[a] aus der Definition, nicht das @scheme[a]
|
||||
aus dem @scheme[let]-Ausdruck.
|
||||
Das Vorkommen von @racket[a] in der Bindung von @racket[b] bezieht
|
||||
sich also auf das @racket[a] aus der Definition, nicht das @racket[a]
|
||||
aus dem @racket[let]-Ausdruck.
|
||||
}
|
||||
|
||||
@defform[(letrec ((id expr) ...) expr)]{
|
||||
Ein @scheme[letrec]-Ausdruck ist
|
||||
ähnlich zum entsprechenden @scheme[let]-Ausdruck, mit dem Unterschied, daß sich
|
||||
die @scheme[expr]s aus den Bindungen auf die gebundenen Namen beziehen
|
||||
Ein @racket[letrec]-Ausdruck ist
|
||||
ähnlich zum entsprechenden @racket[let]-Ausdruck, mit dem Unterschied, daß sich
|
||||
die @racket[expr]s aus den Bindungen auf die gebundenen Namen beziehen
|
||||
dürfen.}
|
||||
|
||||
@defform[(let* ((id expr) ...) expr)]{
|
||||
Ein @scheme[let*]-Ausdruck ist ähnlich zum entsprechenden
|
||||
@scheme[let]-Ausdruck, mit dem Unterschied, daß sich die @scheme[expr]s
|
||||
Ein @racket[let*]-Ausdruck ist ähnlich zum entsprechenden
|
||||
@racket[let]-Ausdruck, mit dem Unterschied, daß sich die @racket[expr]s
|
||||
aus den Bindungen auf die Namen beziehen dürfen, die jeweils vor dem
|
||||
@scheme[expr] gebunden wurden. Beispiel:
|
||||
@racket[expr] gebunden wurden. Beispiel:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define a 3)
|
||||
(let* ((a 16)
|
||||
(b a))
|
||||
(+ b a))
|
||||
=> 32]
|
||||
|
||||
Das Vorkommen von @scheme[a] in der Bindung von @scheme[b] bezieht
|
||||
sich also auf das @scheme[a] aus dem @scheme[let*]-Ausdruck, nicht das
|
||||
@scheme[a] aus der globalen Definition.
|
||||
Das Vorkommen von @racket[a] in der Bindung von @racket[b] bezieht
|
||||
sich also auf das @racket[a] aus dem @racket[let*]-Ausdruck, nicht das
|
||||
@racket[a] aus der globalen Definition.
|
||||
}
|
||||
|
||||
@section[#:tag "vanilla-prim-op"]{Primitive Operationen}
|
||||
|
|
|
@ -20,37 +20,37 @@ Zusätzliche Prozeduren erlauben die Komposition von Bildern.
|
|||
@section{Bilder}
|
||||
|
||||
@defthing[image signature]{
|
||||
Ein @deftech{Bild} (Name: @scheme[image]) ist die Repräsentation eines Bildes.
|
||||
Ein @deftech{Bild} (Name: @racket[image]) ist die Repräsentation eines Bildes.
|
||||
}
|
||||
|
||||
@defthing[empty-image image]{
|
||||
Ein leeres Bild mit Breite und Höhe 0.
|
||||
}
|
||||
|
||||
@defthing[image? (any -> boolean?)]{Der Aufruf @scheme[(image? x)] stellt fest, ob @scheme[x] ein Bild ist.}
|
||||
@defthing[image? (any -> boolean?)]{Der Aufruf @racket[(image? x)] stellt fest, ob @racket[x] ein Bild ist.}
|
||||
|
||||
@;-----------------------------------------------------------------------------
|
||||
@section[#:tag "modes-colors"]{Modi und Farben}
|
||||
|
||||
@defthing[mode signature]{
|
||||
@scheme[(one-of "solid" "outline")]
|
||||
@racket[(one-of "solid" "outline")]
|
||||
|
||||
Ein Modus (Name: @scheme[mode]) legt fest, ob die Darstellung einer Form diese füllt
|
||||
Ein Modus (Name: @racket[mode]) legt fest, ob die Darstellung einer Form diese füllt
|
||||
oder nur einen Umriss zeichnet.}
|
||||
|
||||
@defthing[octet signature]{
|
||||
@scheme[(combined natural (predicate (lambda (n) (<= n 255))))]
|
||||
@racket[(combined natural (predicate (lambda (n) (<= n 255))))]
|
||||
|
||||
Ein Oktet (Name: @scheme[octet]) ist eine natürliche Zahl zwischen 0 und 255.}
|
||||
Ein Oktet (Name: @racket[octet]) ist eine natürliche Zahl zwischen 0 und 255.}
|
||||
|
||||
@defthing[rgb-color signature]{
|
||||
Eine @deftech{RGB-Farbe} ist eine Farbe (Name: @scheme[color], die vom
|
||||
Record-Konstruktor @scheme[make-color] zurückgegeben wird:
|
||||
Eine @deftech{RGB-Farbe} ist eine Farbe (Name: @racket[color], die vom
|
||||
Record-Konstruktor @racket[make-color] zurückgegeben wird:
|
||||
}
|
||||
|
||||
@defthing[make-color (octet octet octet -> rgb-color)]{
|
||||
Eine @tech{RGB-Farbe} beschreibt eine Farbe mit den roten, blauen und grünen Anteilen,
|
||||
also z.B. @scheme[(make-color 100 200 30)].}
|
||||
also z.B. @racket[(make-color 100 200 30)].}
|
||||
|
||||
@defthing[color-red (color -> octet)]{
|
||||
liefert den Rot-Anteil einer RGB-Farbe.}
|
||||
|
@ -63,22 +63,22 @@ also z.B. @scheme[(make-color 100 200 30)].}
|
|||
stellt fest, ob ein Objekt eine @tech{RGB-Farbe} ist.}
|
||||
|
||||
@defthing[image-color signature]{
|
||||
@scheme[(mixed string rgb-color)]
|
||||
@racket[(mixed string rgb-color)]
|
||||
|
||||
Eine @deftech{Farbe} (Name: @scheme[image-color]) ist eine Zeichenkette aus einer Farbbezeichnung
|
||||
(z.B. @scheme["blue"]) oder eine @tech{RGB-Farbe}.}
|
||||
Eine @deftech{Farbe} (Name: @racket[image-color]) ist eine Zeichenkette aus einer Farbbezeichnung
|
||||
(z.B. @racket["blue"]) oder eine @tech{RGB-Farbe}.}
|
||||
|
||||
@defthing[image-color? (any -> boolean?)]{ stellt fest, ob ein Objekt
|
||||
eine @tech{Farbe} ist.}
|
||||
|
||||
@defthing[alpha-rgb-color signature]{
|
||||
Eine @deftech{Alpha/RGB-Farbe} ist eine Farbe (Name: @scheme[color], die vom
|
||||
Record-Konstruktor @scheme[make-alpha-color] zurückgegeben wird:
|
||||
Eine @deftech{Alpha/RGB-Farbe} ist eine Farbe (Name: @racket[color], die vom
|
||||
Record-Konstruktor @racket[make-alpha-color] zurückgegeben wird:
|
||||
}
|
||||
|
||||
@defthing[make-alpha-color (octet octet octet octet -> alpha-color)]{
|
||||
Eine @tech{Alpha/RGB-Farbe} beschreibt eine Farbe mit den Alpha-, roten,
|
||||
blaue und grünen Anteilen, also z.B. @scheme[(make-color 50 100 200
|
||||
blaue und grünen Anteilen, also z.B. @racket[(make-color 50 100 200
|
||||
30)]. Der Alpha-Anteil beschreibt, wie durchsichtig die Farbe ist.}
|
||||
|
||||
@defthing[alpha-color-red (color -> octet)]{
|
||||
|
@ -101,37 +101,37 @@ stellt fest, ob ein Objekt eine @tech{Alpha/RGB-Farbe} ist.}
|
|||
Die folgenden Prozeduren erzeugen Bilder mit einfachen geometrischen Formen:
|
||||
|
||||
@defthing[rectangle (natural natural mode image-color -> image)]{
|
||||
Der Aufruf @scheme[(rectangle w h m c)]
|
||||
erzeugt ein Rechteck mit Breite @scheme[w] und Höhe @scheme[h], gefüllt mit Modus
|
||||
@scheme[m] und in Farbe @scheme[c].}
|
||||
Der Aufruf @racket[(rectangle w h m c)]
|
||||
erzeugt ein Rechteck mit Breite @racket[w] und Höhe @racket[h], gefüllt mit Modus
|
||||
@racket[m] und in Farbe @racket[c].}
|
||||
|
||||
@defthing[circle (natural mode image-color -> image)]{
|
||||
Der Aufruf @scheme[(circle r m c)]
|
||||
erzeugt einen Kreis oder eine Scheibe mit Radius @scheme[r], gefüllt mit Modus
|
||||
@scheme[m] und in Farbe @scheme[c].}
|
||||
Der Aufruf @racket[(circle r m c)]
|
||||
erzeugt einen Kreis oder eine Scheibe mit Radius @racket[r], gefüllt mit Modus
|
||||
@racket[m] und in Farbe @racket[c].}
|
||||
|
||||
@defthing[ellipse (natural natural mode image-color -> image)]{
|
||||
Der Aufruf @scheme[(ellipse w h m c)]
|
||||
erzeugt eine Ellipse mit Breite @scheme[w] und Höhe @scheme[h], gefüllt mit Modus
|
||||
@scheme[m] und in Farbe @scheme[c].}
|
||||
Der Aufruf @racket[(ellipse w h m c)]
|
||||
erzeugt eine Ellipse mit Breite @racket[w] und Höhe @racket[h], gefüllt mit Modus
|
||||
@racket[m] und in Farbe @racket[c].}
|
||||
|
||||
@defthing[triangle (integer mode image-color -> image)]{
|
||||
Der Aufruf @scheme[(triangle s m c)]
|
||||
Der Aufruf @racket[(triangle s m c)]
|
||||
erzeugt ein nach oben zeigendes gleichseitiges Dreieck, wobei
|
||||
@scheme[s] die Seitenlänge angibt, gefüllt mit Modus
|
||||
@scheme[m] und in Farbe @scheme[c].}
|
||||
@racket[s] die Seitenlänge angibt, gefüllt mit Modus
|
||||
@racket[m] und in Farbe @racket[c].}
|
||||
|
||||
@defthing[line (natural natural number number number number image-color -> image)]{
|
||||
Der Aufruf @scheme[(line w h sx sy ex ey c)]
|
||||
erzeugt ein Bild mit einer farbigen Strecke, wobei @scheme[w] die Breite und @scheme[h] die Höhe des Bilds,
|
||||
sowie @scheme[sx] die X- und @scheme[sx] die Y-Koordinate des Anfangspunkts und
|
||||
@scheme[ex] die X- und @scheme[ey] die Y-Koordinate des Endpunkts angeben, gefüllt mit Modus
|
||||
@scheme[m] und in Farbe @scheme[c].}
|
||||
Der Aufruf @racket[(line w h sx sy ex ey c)]
|
||||
erzeugt ein Bild mit einer farbigen Strecke, wobei @racket[w] die Breite und @racket[h] die Höhe des Bilds,
|
||||
sowie @racket[sx] die X- und @racket[sx] die Y-Koordinate des Anfangspunkts und
|
||||
@racket[ex] die X- und @racket[ey] die Y-Koordinate des Endpunkts angeben, gefüllt mit Modus
|
||||
@racket[m] und in Farbe @racket[c].}
|
||||
|
||||
@defthing[text (string natural image-color -> image)]{
|
||||
Der Aufruf @scheme[(text s f c)]
|
||||
erzeugt ein Bild mit Text @scheme[s],
|
||||
wobei die Buchstaben die Größe @scheme[f] haben, in Farbe @scheme[c]}
|
||||
Der Aufruf @racket[(text s f c)]
|
||||
erzeugt ein Bild mit Text @racket[s],
|
||||
wobei die Buchstaben die Größe @racket[f] haben, in Farbe @racket[c]}
|
||||
|
||||
Außerdem können beliebige Bitmap-Bilder in ein Scheme-Programm
|
||||
eingeklebt werden.
|
||||
|
@ -143,18 +143,18 @@ Zwei Eigenschaften von Bildern sind für ihre Manipulation nützlich,
|
|||
nämlich Breite und Höhe:
|
||||
|
||||
@defthing[image-width (image -> natural)]{
|
||||
liefert die Breite von @scheme[i] in Pixeln.}
|
||||
liefert die Breite von @racket[i] in Pixeln.}
|
||||
|
||||
@defthing[image-height (image -> natural)]{
|
||||
liefert die Höhe von @scheme[i] in Pixeln.}
|
||||
liefert die Höhe von @racket[i] in Pixeln.}
|
||||
|
||||
@defthing[image-inside? (image image -> boolean)]{
|
||||
Der Aufruf @scheme[(image-inside? i1 i2)] stellt fest, ob das Bild
|
||||
@scheme[i2] im Bild @scheme[i1] enthalten ist.}
|
||||
Der Aufruf @racket[(image-inside? i1 i2)] stellt fest, ob das Bild
|
||||
@racket[i2] im Bild @racket[i1] enthalten ist.}
|
||||
|
||||
@defthing[find-image (image image -> posn)]{
|
||||
Der Aufruf @scheme[(find-image i1 i2)] findet die Position von @scheme[i2]
|
||||
im Bild @scheme[i1] (in dem es vorkommen muss).}
|
||||
Der Aufruf @racket[(find-image i1 i2)] findet die Position von @racket[i2]
|
||||
im Bild @racket[i1] (in dem es vorkommen muss).}
|
||||
|
||||
@;-----------------------------------------------------------------------------
|
||||
@section[#:tag "composition"]{Bilder zusammensetzen}
|
||||
|
@ -162,87 +162,87 @@ im Bild @scheme[i1] (in dem es vorkommen muss).}
|
|||
The nächste Gruppe von Prozeduren baut aus Bildern neue Bilder:
|
||||
|
||||
@defthing[h-place signature]{
|
||||
@scheme[(mixed integer (one-of "left" "right" "center"))]
|
||||
@racket[(mixed integer (one-of "left" "right" "center"))]
|
||||
|
||||
Eine @deftech{horizontale Positionsangabe} (Name: @scheme[h-place])
|
||||
Eine @deftech{horizontale Positionsangabe} (Name: @racket[h-place])
|
||||
gibt an, wie zwei Bilder horizontal zueinander positioniert werden
|
||||
|
||||
Im ersten Fall, wenn es sich um eine Zahl @scheme[x] handelt, wird das
|
||||
zweite Bild @scheme[x] Pixel vom linken Rand auf das erste gelegt.
|
||||
Im ersten Fall, wenn es sich um eine Zahl @racket[x] handelt, wird das
|
||||
zweite Bild @racket[x] Pixel vom linken Rand auf das erste gelegt.
|
||||
Die drei Fälle mit Zeichenketten sagen, daß die Bilder am linken Rand
|
||||
bzw. am rechten Rand bündig plaziert werden, bzw. das zweite Bild
|
||||
horizontal in die Mitte des ersten gesetzt wird.}
|
||||
|
||||
@defthing[v-place signature]{
|
||||
@scheme[(mixed integer (one-of "top" "bottom" "center"))]
|
||||
@racket[(mixed integer (one-of "top" "bottom" "center"))]
|
||||
|
||||
Eine @deftech{vertikale Positionsangabe} (Name: @scheme[v-place])
|
||||
Eine @deftech{vertikale Positionsangabe} (Name: @racket[v-place])
|
||||
gibt an, wie zwei Bilder vertikal zueinander positioniert werden
|
||||
|
||||
Im ersten Fall, wenn es sich um eine Zahl @scheme[y] handelt, wird das
|
||||
zweite Bild @scheme[y] Pixel vom oberen Rand auf das erste gelegt.
|
||||
Im ersten Fall, wenn es sich um eine Zahl @racket[y] handelt, wird das
|
||||
zweite Bild @racket[y] Pixel vom oberen Rand auf das erste gelegt.
|
||||
Die drei Fälle mit Zeichenketten sagen, daß die Bilder am oberen Rand
|
||||
bzw. am unteren Rand bündig plaziert werden, bzw. das zweite Bild
|
||||
vertikal in die Mitte des ersten gesetzt wird.
|
||||
}
|
||||
|
||||
@defthing[h-mode signature]{
|
||||
@scheme[(one-of "left" "right" "center")]
|
||||
Eine @deftech{horizontale Justierungsangabe} (Name: @scheme[h-mode])
|
||||
@racket[(one-of "left" "right" "center")]
|
||||
Eine @deftech{horizontale Justierungsangabe} (Name: @racket[h-mode])
|
||||
gibt an, ob zwei Bilder, die übereinander angeordnet werden, entlang der linken
|
||||
Kante, der rechten Kante oder der Mitte angeordnet werden.
|
||||
}
|
||||
|
||||
@defthing[v-mode signature]{
|
||||
@scheme[(one-of "top" "bottom" "center")]
|
||||
@racket[(one-of "top" "bottom" "center")]
|
||||
|
||||
Eine @deftech{vertikale Justierungsangabe} (Name: @scheme[V-mode])
|
||||
Eine @deftech{vertikale Justierungsangabe} (Name: @racket[V-mode])
|
||||
gibt an, ob zwei Bilder, die nebenander angeordnet werden, entlang der
|
||||
oberen Kante, der untern Kante oder der Mitte angeordnet werden.}
|
||||
|
||||
@defthing[overlay (image image h-place v-place -> image)]{
|
||||
Der Aufruf @scheme[(overlay img other h v)]
|
||||
legt zweite Bild @scheme[other] auf das erste @scheme[img]. Die beiden anderen Argumente geben an, wie
|
||||
Der Aufruf @racket[(overlay img other h v)]
|
||||
legt zweite Bild @racket[other] auf das erste @racket[img]. Die beiden anderen Argumente geben an, wie
|
||||
die beiden Bilder zueinander positioniert werden.}
|
||||
|
||||
@defthing[beside (image image v-mode -> image)]{
|
||||
Der Aufruf @scheme[(beside img other v)]
|
||||
ordnet die beiden Bilder entsprechend des @scheme[v]-Arguments
|
||||
Der Aufruf @racket[(beside img other v)]
|
||||
ordnet die beiden Bilder entsprechend des @racket[v]-Arguments
|
||||
nebeneinander an.}
|
||||
|
||||
@defthing[above (image image h-mode -> image)]{
|
||||
Der Aufruf @scheme[(img other h -> image)]
|
||||
ordnet die beiden Bilder entsprechend des @scheme[h]-Arguments
|
||||
Der Aufruf @racket[(img other h -> image)]
|
||||
ordnet die beiden Bilder entsprechend des @racket[h]-Arguments
|
||||
übereinander an.}
|
||||
|
||||
@defthing[clip (image natural natural natural natural -> image)]{
|
||||
Der Aufruf @scheme[(clip img x y w h)]
|
||||
liefert das Teilrechteck des Bildes @scheme[img]
|
||||
bei (@scheme[x], @scheme[y]), Breite @scheme[w] und Höhe @scheme[h].}
|
||||
Der Aufruf @racket[(clip img x y w h)]
|
||||
liefert das Teilrechteck des Bildes @racket[img]
|
||||
bei (@racket[x], @racket[y]), Breite @racket[w] und Höhe @racket[h].}
|
||||
|
||||
@defthing[pad (image natural natural natural natural -> image)]{
|
||||
Der Aufruf @scheme[(pad img l r t b)]
|
||||
fügt an den Seiten von @scheme[img] noch transparenten Leerraum an:
|
||||
@scheme[l] Pixel links, @scheme[r] Pixel rechts, @scheme[t] Pixel oben und
|
||||
@scheme[b] Pixel unten.}
|
||||
Der Aufruf @racket[(pad img l r t b)]
|
||||
fügt an den Seiten von @racket[img] noch transparenten Leerraum an:
|
||||
@racket[l] Pixel links, @racket[r] Pixel rechts, @racket[t] Pixel oben und
|
||||
@racket[b] Pixel unten.}
|
||||
|
||||
|
||||
@;-----------------------------------------------------------------------------
|
||||
@section[#:tag "from-pixels"]{Bilder aus Pixeln konstruieren}
|
||||
|
||||
@defthing[color-list->image ((list-of color) natural natural -> image)]{
|
||||
Der Aufruf @scheme[(color-list->image lis w h)] stellt ein Bild mit
|
||||
Breite @scheme[w] und Höhe @scheme[h] her, in dem die Pixel die
|
||||
Farben aus der Liste @scheme[lis] (welche die Länge @scheme[(* w h)]
|
||||
Der Aufruf @racket[(color-list->image lis w h)] stellt ein Bild mit
|
||||
Breite @racket[w] und Höhe @racket[h] her, in dem die Pixel die
|
||||
Farben aus der Liste @racket[lis] (welche die Länge @racket[(* w h)]
|
||||
haben muß) haben.}
|
||||
|
||||
@defthing[image->color-list (image -> (list-of rgb-color))]{
|
||||
Diese Prozedur liefert eine Liste der RGB-Farben der Pixel eines Bildes.}
|
||||
|
||||
@defthing[alpha-color-list->image ((list-of alpha-rgb-color) natural natural -> image)]{
|
||||
Der Aufruf @scheme[(color-list->image lis w h)] stellt ein Bild mit
|
||||
Breite @scheme[w] und Höhe @scheme[h] her, in dem die Pixel die
|
||||
Farben aus der Liste @scheme[lis] (welche die Länge @scheme[(* w h)]
|
||||
Der Aufruf @racket[(color-list->image lis w h)] stellt ein Bild mit
|
||||
Breite @racket[w] und Höhe @racket[h] her, in dem die Pixel die
|
||||
Farben aus der Liste @racket[lis] (welche die Länge @racket[(* w h)]
|
||||
haben muß) haben.}
|
||||
|
||||
@defthing[image->alpha-color-list (image -> (list-of rgb-color))]{
|
||||
|
|
|
@ -37,10 +37,10 @@ die möglichen Werte also in feste Kategorien sortiert werden können,
|
|||
steht im Rumpf eine Verzweigung. Die Anzahl der Zweige entspricht
|
||||
der Anzahl der Kategorien.
|
||||
|
||||
Die Schablone für eine Prozedur @scheme[proc], deren Argument zu einer Sorte gehört,
|
||||
Die Schablone für eine Prozedur @racket[proc], deren Argument zu einer Sorte gehört,
|
||||
die @italic{n} Kategorien hat, sieht folgendermaßen aus:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: proc (sig -> ...))
|
||||
(define proc
|
||||
(lambda (a)
|
||||
|
@ -49,16 +49,16 @@ die @italic{n} Kategorien hat, sieht folgendermaßen aus:
|
|||
...
|
||||
(#,(elem (scheme test) (subscript "n")) ...))))
|
||||
]
|
||||
Dabei ist @scheme[sig] die Signatur, den die Elemente der Sorte erfüllen müssen.
|
||||
Dabei ist @racket[sig] die Signatur, den die Elemente der Sorte erfüllen müssen.
|
||||
Die @elem[(scheme test) (subscript "i")] müssen Tests sein, welche die einzelnen Kategorien
|
||||
erkennen. Sie sollten alle Kategorien abdecken.
|
||||
Der letzte Zweig kann auch ein @scheme[else]-Zweig sein, falls
|
||||
klar ist, daß @scheme[a] zum letzten Fall gehört, wenn alle vorherigen
|
||||
@elem[(scheme test) (subscript "i")] @scheme[#f] ergeben haben.
|
||||
Der letzte Zweig kann auch ein @racket[else]-Zweig sein, falls
|
||||
klar ist, daß @racket[a] zum letzten Fall gehört, wenn alle vorherigen
|
||||
@elem[(scheme test) (subscript "i")] @racket[#f] ergeben haben.
|
||||
Anschließend werden die Zweige vervollständigt.
|
||||
|
||||
Bei Fallunterscheidungen mit zwei Kategorien kann auch @scheme[if]
|
||||
statt @scheme[cond] verwendet werden.
|
||||
Bei Fallunterscheidungen mit zwei Kategorien kann auch @racket[if]
|
||||
statt @racket[cond] verwendet werden.
|
||||
|
||||
@section{zusammengesetzte Daten}
|
||||
Wenn bei der Datenanalyse zusammengesetzte Daten vorkommen, stellen
|
||||
|
@ -66,23 +66,23 @@ Sie zunächst fest, welche Komponenten zu welchen Sorten gehören.
|
|||
Schreiben Sie dann eine Datendefinition, die mit folgenden Worten
|
||||
anfängt:
|
||||
|
||||
@schemeblock[
|
||||
(code:comment @#,t{Ein @scheme[x] besteht aus / hat:})
|
||||
(code:comment @#,t{- @scheme[#,(elem (scheme Feld) (subscript "1"))] @scheme[(#,(elem (scheme sig) (subscript "1")))]})
|
||||
@racketblock[
|
||||
(code:comment @#,t{Ein @racket[x] besteht aus / hat:})
|
||||
(code:comment @#,t{- @racket[#,(elem (scheme Feld) (subscript "1"))] @racket[(#,(elem (scheme sig) (subscript "1")))]})
|
||||
(code:comment @#,t{...})
|
||||
(code:comment @#,t{- @scheme[#,(elem (scheme Feld) (subscript "n"))] @scheme[(#,(elem (scheme sig) (subscript "n")))]})
|
||||
(code:comment @#,t{- @racket[#,(elem (scheme Feld) (subscript "n"))] @racket[(#,(elem (scheme sig) (subscript "n")))]})
|
||||
]
|
||||
|
||||
Dabei ist @scheme[x] ein umgangssprachlicher Name für die Sorte
|
||||
Dabei ist @racket[x] ein umgangssprachlicher Name für die Sorte
|
||||
(``Schokokeks''), die @elem[(scheme Feld) (subscript "i")] sind
|
||||
umgangssprachliche Namen und kurze Beschreibungen der Komponenten
|
||||
und die @elem[(scheme sig) (subscript "i")] die dazugehörigen Signaturen.
|
||||
|
||||
Übersetzen Sie die Datendefinition in eine Record-Definition, indem Sie
|
||||
auch Namen für die Record-Signatur @scheme[sig], Konstruktor @scheme[constr],
|
||||
Prädikat @scheme[pred?] und die Selektoren @elem[(scheme select) (subscript "i")]
|
||||
auch Namen für die Record-Signatur @racket[sig], Konstruktor @racket[constr],
|
||||
Prädikat @racket[pred?] und die Selektoren @elem[(scheme select) (subscript "i")]
|
||||
wählen:
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define-record-procedures sig
|
||||
constr pred?
|
||||
(#,(elem (scheme select) (subscript "1")) ... #,(elem (scheme select) (subscript "n"))))
|
||||
|
@ -91,13 +91,13 @@ wählen:
|
|||
Schreiben Sie außerdem eine Signatur für den Konstruktor der
|
||||
Form:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: constr (#,(elem (scheme sig) (subscript "1")) ... #,(elem (scheme sig) (subscript "n")) -> sig))
|
||||
]
|
||||
|
||||
Ggf. schreiben Sie außerdem Signaturen für das Prädikat und die Selektoren:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: pred? (any -> boolean))
|
||||
(: #,(elem (scheme select) (subscript "1")) (sig -> #,(elem (scheme sig) (subscript "1"))))
|
||||
...
|
||||
|
@ -109,8 +109,8 @@ Wenn ein Argument einer Prozedur zusammengesetzt ist, stellen Sie
|
|||
zunächst fest, von welchen Komponenten des Records das Ergebnis der
|
||||
Prozeduren abhängt.
|
||||
|
||||
Schreiben Sie dann für jede Komponente @scheme[(select a)] in die
|
||||
Schablone, wobei @scheme[select] der Selektor der Komponente und @scheme[a] der Name
|
||||
Schreiben Sie dann für jede Komponente @racket[(select a)] in die
|
||||
Schablone, wobei @racket[select] der Selektor der Komponente und @racket[a] der Name
|
||||
des Parameters der Prozedur ist.
|
||||
|
||||
Vervollständigen Sie die Schablone, indem Sie einen Ausdruck
|
||||
|
@ -124,23 +124,23 @@ enthält einen Aufruf des Konstruktors des zugehörigen Record-Typs.
|
|||
Wenn bei der Datenanalyse gemischte Daten auftauchen, schreiben Sie
|
||||
eine Datendefinition der Form:
|
||||
|
||||
@schemeblock[
|
||||
(code:comment @#,t{Ein @scheme[x] ist eins der Folgenden:})
|
||||
@racketblock[
|
||||
(code:comment @#,t{Ein @racket[x] ist eins der Folgenden:})
|
||||
(code:comment @#,t{- @elem[(scheme Sorte) (subscript "1")] (@elem[(scheme sig) (subscript "1")])})
|
||||
(code:comment @#,t{...})
|
||||
(code:comment @#,t{- @elem[(scheme Sorte) (subscript "n")] (@elem[(scheme sig) (subscript "n")])})
|
||||
(code:comment @#,t{Name: @scheme[sig]})
|
||||
(code:comment @#,t{Name: @racket[sig]})
|
||||
]
|
||||
|
||||
Dabei sind die @elem[(scheme Sorte) (subscript "i")] umgangssprachliche Namen
|
||||
für die möglichen Sorten, die ein Wert aus diesen gemischten Daten
|
||||
annehmen kann. Die @elem[(scheme sig) (subscript "i")] sind die zu den Sorten
|
||||
gehörenden Signaturen. Der Name @scheme[sig] ist für die Verwendung als
|
||||
gehörenden Signaturen. Der Name @racket[sig] ist für die Verwendung als
|
||||
Signatur.
|
||||
|
||||
Aus der Datendefinition entsteht eine Signaturdefinition folgender Form:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define sig
|
||||
(signature
|
||||
(mixed #,(elem (scheme sig) (subscript "1"))
|
||||
|
@ -153,7 +153,7 @@ Wenn die Prädikate für die einzelnen Sorten @elem[(scheme pred?)
|
|||
Schablone für eine Prozedur, die gemischte Daten konsumiert, die
|
||||
folgende Form:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: proc (sig -> ...))
|
||||
|
||||
(define proc
|
||||
|
@ -172,7 +172,7 @@ Konstruktionsanleitungen der einzelnen Sorten ausgefüllt.
|
|||
Eine Prozedur, die eine Liste konsumiert, hat die folgende
|
||||
Schablone:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: proc ((list-of elem) -> ...))
|
||||
|
||||
(define proc
|
||||
|
@ -184,18 +184,18 @@ Schablone:
|
|||
... (proc (rest lis)) ...))))
|
||||
]
|
||||
|
||||
Dabei ist @scheme[elem] die Signatur für die Elemente der Liste. Dies
|
||||
kann eine Signaturvariable (@scheme[%a], @scheme[%b], ...) sein, falls
|
||||
Dabei ist @racket[elem] die Signatur für die Elemente der Liste. Dies
|
||||
kann eine Signaturvariable (@racket[%a], @racket[%b], ...) sein, falls
|
||||
die Prozedur unabhängig von der Signatur der Listenelemente ist.
|
||||
|
||||
Füllen Sie in der Schablone zuerst den @scheme[empty?]-Zweig aus.
|
||||
Füllen Sie in der Schablone zuerst den @racket[empty?]-Zweig aus.
|
||||
Vervollständigen Sie dann den anderen Zweig unter der Annahme, daß
|
||||
der rekursive Aufruf @scheme[(proc (rest lis))] das gewünschte
|
||||
der rekursive Aufruf @racket[(proc (rest lis))] das gewünschte
|
||||
Ergebnis für den Rest der Liste liefert.
|
||||
|
||||
Beispiel:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: list-sum ((list-of number) -> number))
|
||||
|
||||
(define list-sum
|
||||
|
@ -212,7 +212,7 @@ Beispiel:
|
|||
Eine Prozedur, die natürliche Zahlen konsumiert, hat die folgende
|
||||
Schablone:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: proc (natural -> ...))
|
||||
|
||||
(define proc
|
||||
|
@ -224,12 +224,12 @@ Schablone:
|
|||
|
||||
Füllen Sie in der Schablone zuerst den 0-Zweig aus. Vervollständigen
|
||||
Sie dann den anderen Zweig unter der Annahme, daß der rekursive Aufruf
|
||||
@scheme[(proc (- n 1))] das gewünschte Ergebnis für @scheme[n]-1
|
||||
@racket[(proc (- n 1))] das gewünschte Ergebnis für @racket[n]-1
|
||||
liefert.
|
||||
|
||||
Beispiel:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: factorial (natural -> natural))
|
||||
|
||||
(define factorial
|
||||
|
@ -244,7 +244,7 @@ Beispiel:
|
|||
Eine Prozedur mit Akkumulator, die Listen konsumiert, hat die
|
||||
folgende Schablone:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: proc ((list-of elem) -> ...))
|
||||
|
||||
(define proc
|
||||
|
@ -262,17 +262,17 @@ folgende Schablone:
|
|||
(... (first lis) ... acc ...))))))
|
||||
]
|
||||
|
||||
Hier ist @scheme[proc] der Name der zu definierenden Prozedur und
|
||||
@scheme[proc-helper] der Name der Hilfsprozedur mit Akkumulator. Der
|
||||
Anfangswert für den Akkumulator ist der Wert von @scheme[z]. Die Signatur @scheme[sig]
|
||||
Hier ist @racket[proc] der Name der zu definierenden Prozedur und
|
||||
@racket[proc-helper] der Name der Hilfsprozedur mit Akkumulator. Der
|
||||
Anfangswert für den Akkumulator ist der Wert von @racket[z]. Die Signatur @racket[sig]
|
||||
ist die Signatur für den Akkumulator. Der
|
||||
Ausdruck @scheme[(... (first lis) ... acc ...)]
|
||||
macht aus dem alten Zwischenergebnis @scheme[acc] das neue
|
||||
Ausdruck @racket[(... (first lis) ... acc ...)]
|
||||
macht aus dem alten Zwischenergebnis @racket[acc] das neue
|
||||
Zwischenergebnis.
|
||||
|
||||
Beispiel:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: invert ((list-of %a) -> (list-of %a)))
|
||||
|
||||
(define invert
|
||||
|
@ -293,7 +293,7 @@ Beispiel:
|
|||
Eine Prozedur mit Akkumulator, die natürliche Zahlen konsumiert, hat die
|
||||
folgende Schablone:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: proc (natural -> ...))
|
||||
|
||||
(define proc
|
||||
|
@ -307,13 +307,13 @@ folgende Schablone:
|
|||
(proc-helper (- n 1) (... acc ...)))))
|
||||
]
|
||||
|
||||
Dabei ist @scheme[z] das gewünschte Ergebnis für @scheme[n] = 0. Der
|
||||
Ausdruck @scheme[(... acc ...)] muß den neuen Wert für den
|
||||
Dabei ist @racket[z] das gewünschte Ergebnis für @racket[n] = 0. Der
|
||||
Ausdruck @racket[(... acc ...)] muß den neuen Wert für den
|
||||
Akkumulator berechnen.
|
||||
|
||||
Beispiel:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: ! (natural -> natural))
|
||||
|
||||
(define !
|
||||
|
@ -332,24 +332,24 @@ Falls ein Wert Zustand enthalten soll, schreiben Sie eine
|
|||
Datendefinition wie bei zusammengesetzten Daten.
|
||||
|
||||
Schreiben Sie dann eine Record-Definition mit
|
||||
@scheme[define-record-procedures-2] und legen Sie dabei fest, welche
|
||||
@racket[define-record-procedures-2] und legen Sie dabei fest, welche
|
||||
Bestandteile veränderbar sein sollen. Geben Sie Mutatoren für die
|
||||
betroffenen Felder an. Wenn der Selektor für das Feld @scheme[select]
|
||||
heißt, sollte der Mutator i.d.R. @scheme[set-select!] heißen. Die Form
|
||||
sieht folgendermaßen aus, wobei an der Stelle @scheme[k] ein
|
||||
betroffenen Felder an. Wenn der Selektor für das Feld @racket[select]
|
||||
heißt, sollte der Mutator i.d.R. @racket[set-select!] heißen. Die Form
|
||||
sieht folgendermaßen aus, wobei an der Stelle @racket[k] ein
|
||||
veränderbares Feld steht:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define-record-procedures-2 sig
|
||||
constr pred?
|
||||
(#,(elem (scheme select) (subscript "1")) ... (#,(elem (scheme s) (subscript "k")) #,(elem (scheme mutate) (subscript "k"))) ... #,(elem (scheme s) (subscript "n"))))
|
||||
]
|
||||
|
||||
In der Schablone für Prozeduren, die den Zustand eines
|
||||
Record-Arguments @scheme[r] ändern, benutzen Sie den dazugehörigen Mutator
|
||||
@elem[(scheme mutate) (subscript "k")] Wenn @scheme[a] der Ausdruck für den neuen Wert der Komponente ist,
|
||||
sieht der Aufruf folgendermaßen aus: @scheme[(#,(elem (scheme mutate) (subscript "k")) r a)].
|
||||
Record-Arguments @racket[r] ändern, benutzen Sie den dazugehörigen Mutator
|
||||
@elem[(scheme mutate) (subscript "k")] Wenn @racket[a] der Ausdruck für den neuen Wert der Komponente ist,
|
||||
sieht der Aufruf folgendermaßen aus: @racket[(#,(elem (scheme mutate) (subscript "k")) r a)].
|
||||
|
||||
Um mehrere Komponenten in einer Prozedur zu verändern, oder um einen
|
||||
sinnvollen Rückgabewert nach einer Mutation zu liefern, benutzen Sie
|
||||
@scheme[begin].
|
||||
@racket[begin].
|
||||
|
|
|
@ -22,21 +22,21 @@ Dieses teachpack definiert Prozeduren für lineare Algebra und 3D-Rendering:
|
|||
@declare-exporting[teachpack/deinprogramm/line3d]
|
||||
|
||||
@defthing[render-scene (natural natural (list-of line3d) matrix4x4 -> image)]{
|
||||
Der Aufruf @scheme[(render-scene width height scene camera-matrix)]erzeugt die Szene
|
||||
in ein Bild mit Breite @scheme[width] und Höhe @scheme[height]. Position,
|
||||
Orientierung und Projektion werden durch die @scheme[camera-matrix] festgelegt.
|
||||
Der Aufruf @racket[(render-scene width height scene camera-matrix)]erzeugt die Szene
|
||||
in ein Bild mit Breite @racket[width] und Höhe @racket[height]. Position,
|
||||
Orientierung und Projektion werden durch die @racket[camera-matrix] festgelegt.
|
||||
}
|
||||
|
||||
@defthing[create-camera-matrix (vec3 vec3 number natural natural -> matrix4x4)]{
|
||||
Der Aufruf @scheme[(create-camera-matrix position lookat vertical-fov width height)]
|
||||
erzeugt eine 4x4 Matrix. Diese kodiert eine Kamera an der Position @scheme[position], die
|
||||
auf die Position @scheme[lookat] schaut.
|
||||
@scheme[vertical-fov] bezeichnet das @deftech{vertikale Feld} der Szene.
|
||||
Der Aufruf @racket[(create-camera-matrix position lookat vertical-fov width height)]
|
||||
erzeugt eine 4x4 Matrix. Diese kodiert eine Kamera an der Position @racket[position], die
|
||||
auf die Position @racket[lookat] schaut.
|
||||
@racket[vertical-fov] bezeichnet das @deftech{vertikale Feld} der Szene.
|
||||
}
|
||||
|
||||
Zum Beispiel:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(code:comment @#,t{scene-data (simple box example)})
|
||||
(define box
|
||||
(create-box 1.0 1.0 1.0 "brown"))
|
||||
|
@ -56,156 +56,156 @@ Zum Beispiel:
|
|||
@section[#:tag "3Dvectors"]{3D-Vektoren}
|
||||
|
||||
@defthing[vec3 signature]{
|
||||
Ein @deftech{3D-Vektor} (Name: @scheme[vec3]) ist ein Record, der durch den Aufruf @scheme[make-vec3] erstellt wird.
|
||||
Ein @deftech{3D-Vektor} (Name: @racket[vec3]) ist ein Record, der durch den Aufruf @racket[make-vec3] erstellt wird.
|
||||
}
|
||||
|
||||
@defthing[make-vec3 (number number number -> vec3)]{
|
||||
@scheme[(make-vec3 x y z)] erstellt einen Vektor (x,y,z).
|
||||
@racket[(make-vec3 x y z)] erstellt einen Vektor (x,y,z).
|
||||
}
|
||||
|
||||
@defthing[add-vec3 (vec3 vec3 -> vec3)]{
|
||||
@scheme[(add-vec3 a b)] gibt die Summe von @scheme[a] und @scheme[b] zurück.
|
||||
@racket[(add-vec3 a b)] gibt die Summe von @racket[a] und @racket[b] zurück.
|
||||
}
|
||||
|
||||
@defthing[sub-vec3 (vec3 vec3 -> vec3)]{
|
||||
@scheme[(sub-vec3 a b)] gibt die Differenz zwischen @scheme[a] und @scheme[b] zurück.
|
||||
@racket[(sub-vec3 a b)] gibt die Differenz zwischen @racket[a] und @racket[b] zurück.
|
||||
}
|
||||
|
||||
@defthing[mult-vec3 (vec3 number -> vec3)]{
|
||||
@scheme[(mult-vec3 a s)] gibt den das Produkt von @scheme[a] und @scheme[s] zurück.
|
||||
@racket[(mult-vec3 a s)] gibt den das Produkt von @racket[a] und @racket[s] zurück.
|
||||
}
|
||||
|
||||
@defthing[div-vec3 (vec3 number -> vec3)]{
|
||||
@scheme[(div-vec3 a s)] gibt den das Produkt von @scheme[a] und dem Kehrwert von @scheme[s] zurück.
|
||||
@racket[(div-vec3 a s)] gibt den das Produkt von @racket[a] und dem Kehrwert von @racket[s] zurück.
|
||||
}
|
||||
|
||||
@defthing[dotproduct-vec3 (vec3 vec3 -> number)]{
|
||||
@scheme[(dotproduct-vec3 a b)] gibt das Produkt von @scheme[a] und @scheme[b] zurück.
|
||||
@racket[(dotproduct-vec3 a b)] gibt das Produkt von @racket[a] und @racket[b] zurück.
|
||||
}
|
||||
|
||||
@defthing[normQuad-vec3 (vec3 -> number)]{
|
||||
@scheme[(normQuad-vec3 a)] gibt die quadrierte Norm/Länge |@scheme[a]|² eines Vektors @scheme[a] zurück (Quadrat der Euklidischen Norm.)
|
||||
@racket[(normQuad-vec3 a)] gibt die quadrierte Norm/Länge |@racket[a]|² eines Vektors @racket[a] zurück (Quadrat der Euklidischen Norm.)
|
||||
}
|
||||
|
||||
@defthing[norm-vec3 (vec3 -> number)]{
|
||||
@scheme[(norm-vec3 a)] gibt die Norm/Länge |@scheme[a]| eines Vektors a zurück (Euklidische Norm.)
|
||||
@racket[(norm-vec3 a)] gibt die Norm/Länge |@racket[a]| eines Vektors a zurück (Euklidische Norm.)
|
||||
}
|
||||
|
||||
@defthing[normalize-vec3 (vec3 -> vec3)]{
|
||||
@scheme[(normalize-vec3 a)] normalisiert @scheme[a].
|
||||
@racket[(normalize-vec3 a)] normalisiert @racket[a].
|
||||
}
|
||||
|
||||
@defthing[crossproduct-vec3 (vec3 vec3-> vec3)]{
|
||||
@scheme[(crossproduct-vec3 a b)] gibt das Kreuzprodukt von @scheme[a]
|
||||
und @scheme[b] zurück (einen Vektor der senkrecht auf @scheme[a] und @scheme[b] steht).
|
||||
@racket[(crossproduct-vec3 a b)] gibt das Kreuzprodukt von @racket[a]
|
||||
und @racket[b] zurück (einen Vektor der senkrecht auf @racket[a] und @racket[b] steht).
|
||||
}
|
||||
|
||||
@;-------------------------------------------------------------------------------------
|
||||
@section[#:tag "4Dvectors"]{4D-Vektoren}
|
||||
|
||||
@defthing[vec4 signature]{
|
||||
Ein @deftech{4D-Vektor} @scheme[vec4] ist ein 4D-Vektor. Folgende Prozeduren werden bereitgestellt:
|
||||
Ein @deftech{4D-Vektor} @racket[vec4] ist ein 4D-Vektor. Folgende Prozeduren werden bereitgestellt:
|
||||
}
|
||||
|
||||
@defthing[make-vec4 (number number number number -> vec4)]{
|
||||
@scheme[(make-vec4 a b c d)] erzeugt einen Vektor aus @scheme[a], @scheme[b], @scheme[c] und @scheme[d].
|
||||
@racket[(make-vec4 a b c d)] erzeugt einen Vektor aus @racket[a], @racket[b], @racket[c] und @racket[d].
|
||||
}
|
||||
|
||||
@defthing[add-vec4 (vec4 vec4 -> vec4)]{
|
||||
@scheme[(add-vec4 a b)] gibt die Summe von @scheme[a] und @scheme[b] zurück.
|
||||
@racket[(add-vec4 a b)] gibt die Summe von @racket[a] und @racket[b] zurück.
|
||||
}
|
||||
|
||||
@defthing[sub-vec4 (vec4 vec4 -> vec4)]{
|
||||
@scheme[(sub-vec4 a b)] gibt die Differenz zwischen @scheme[a] und @scheme[b] zurück.
|
||||
@racket[(sub-vec4 a b)] gibt die Differenz zwischen @racket[a] und @racket[b] zurück.
|
||||
}
|
||||
|
||||
@defthing[mult-vec4 (vec4 number -> vec4)]{
|
||||
@scheme[(mult-vec4 a s)] gibt den das Produkt von @scheme[a] und @scheme[s] zurück.
|
||||
@racket[(mult-vec4 a s)] gibt den das Produkt von @racket[a] und @racket[s] zurück.
|
||||
}
|
||||
|
||||
@defthing[div-vec4 (vec4 number -> vec4)]{
|
||||
@scheme[(div-vec4 a s)] gibt den das Produkt von @scheme[a] und dem Kehrwert von @scheme[s] zurück.
|
||||
@racket[(div-vec4 a s)] gibt den das Produkt von @racket[a] und dem Kehrwert von @racket[s] zurück.
|
||||
}
|
||||
|
||||
@defthing[dotproduct-vec4 (vec3 vec4 -> number)]{
|
||||
@scheme[(dotproduct-vec4 a b)] gibt die quadrierte Norm/Länge |@scheme[a]|² eines Vektors @scheme[a] zurück (Quadrat der Euklidischen Norm.)
|
||||
@racket[(dotproduct-vec4 a b)] gibt die quadrierte Norm/Länge |@racket[a]|² eines Vektors @racket[a] zurück (Quadrat der Euklidischen Norm.)
|
||||
}
|
||||
|
||||
@defthing[normQuad-vec4 (vec4 -> number)]{
|
||||
@scheme[(normQuad-vec4 a)] gibt die quadrierte Norm/Länge |@scheme[a]|² eines Vektors @scheme[a] zurück (Quadrat der Euklidischen Norm.)
|
||||
@racket[(normQuad-vec4 a)] gibt die quadrierte Norm/Länge |@racket[a]|² eines Vektors @racket[a] zurück (Quadrat der Euklidischen Norm.)
|
||||
}
|
||||
|
||||
@defthing[norm-vec4 (vec4 -> number)]{
|
||||
@scheme[(norm-vec4 a)] gibt die Norm/Länge |a| eines Vektors a zurück (Euklidische Norm)
|
||||
@racket[(norm-vec4 a)] gibt die Norm/Länge |a| eines Vektors a zurück (Euklidische Norm)
|
||||
}
|
||||
|
||||
@defthing[normalize-vec4 (vec4 -> vec4)]{
|
||||
@scheme[(normalize-vec4 a)] normalisiert @scheme[a].
|
||||
@racket[(normalize-vec4 a)] normalisiert @racket[a].
|
||||
}
|
||||
|
||||
@defthing[expand-vec3 (vec3 number -> vec4)]{
|
||||
@scheme[(expand-vec3 a s)] gibt den 4D-Vektor mit @scheme[s] als letze Komponente zurück (erweitert @scheme[a] mit @scheme[s]).
|
||||
@racket[(expand-vec3 a s)] gibt den 4D-Vektor mit @racket[s] als letze Komponente zurück (erweitert @racket[a] mit @racket[s]).
|
||||
}
|
||||
|
||||
@;-------------------------------------------------------------------------------------
|
||||
@section[#:tag "4x4matrix"]{4x4 Matrizen}
|
||||
|
||||
@defthing[matrix4x4 signature]{
|
||||
Eine @deftech{Matrix} @scheme[matrix4x4] ist ein Record, der durch den Aufruf @scheme[make-matrix4x4] erstellt wird.
|
||||
Eine @deftech{Matrix} @racket[matrix4x4] ist ein Record, der durch den Aufruf @racket[make-matrix4x4] erstellt wird.
|
||||
}
|
||||
|
||||
@defthing[make-matrix4x4 (vec4 vec4 vec4 vec4 -> matrix4x4)]{
|
||||
@scheme[(make-matrix4x4 a b c d)] erstellt eine Matrix aus @scheme[a], @scheme[b], @scheme[c] und @scheme[d].
|
||||
@racket[(make-matrix4x4 a b c d)] erstellt eine Matrix aus @racket[a], @racket[b], @racket[c] und @racket[d].
|
||||
}
|
||||
|
||||
@defthing[create-matrix4x4 (vec3 vec3 vec3 vec3 -> matrix4x4)]{
|
||||
@scheme[(create-matrix4x4 a b c d)] erweitert jeden Vektor in einen 4D-Vektor und kombiniert diese zu
|
||||
einer Matrix @scheme[a], @scheme[b], @scheme[c] und @scheme[d], wobei
|
||||
@scheme[a], @scheme[b], @scheme[c] mit 0 und @scheme[d] mit 1 erweitert wird, um eine homogene Matrix zu erzeugen.
|
||||
@racket[(create-matrix4x4 a b c d)] erweitert jeden Vektor in einen 4D-Vektor und kombiniert diese zu
|
||||
einer Matrix @racket[a], @racket[b], @racket[c] und @racket[d], wobei
|
||||
@racket[a], @racket[b], @racket[c] mit 0 und @racket[d] mit 1 erweitert wird, um eine homogene Matrix zu erzeugen.
|
||||
}
|
||||
|
||||
@defthing[transpose-matrix4x4 (matrix4x4 -> matrix4x)]{
|
||||
@scheme[(transpose-matrix4x4 m)] erstellt die transponierte Matrix @scheme[m]^@scheme[T].
|
||||
@racket[(transpose-matrix4x4 m)] erstellt die transponierte Matrix @racket[m]^@racket[T].
|
||||
}
|
||||
|
||||
@defthing[multiply-matrix-vec4 (matrix vec4 -> vec4)]{
|
||||
@scheme[(multiply-matrix-vec4 m v)] gibt die Matrix @scheme[m]@scheme[v] zurück. Die @scheme[w]-Komponente ist nicht normalisiert.
|
||||
@racket[(multiply-matrix-vec4 m v)] gibt die Matrix @racket[m]@racket[v] zurück. Die @racket[w]-Komponente ist nicht normalisiert.
|
||||
}
|
||||
|
||||
@defthing[transform-vec3 (matrix4x4 vec3 -> vec3)]{
|
||||
@scheme[(transform-vec3 m v)] erweitert @scheme[v] mit 1, multipliziert @scheme[m] mit @scheme[v] und dividiert das Ergebnis mit @scheme[w].
|
||||
@racket[(transform-vec3 m v)] erweitert @racket[v] mit 1, multipliziert @racket[m] mit @racket[v] und dividiert das Ergebnis mit @racket[w].
|
||||
}
|
||||
|
||||
@defthing[multiply-matrix (matrix4x4 matrix4x4 -> matrix4x4)]{
|
||||
@scheme[(multiply-matrix a b)] gibt die Matrix @scheme[a]*@scheme[b] zurück.
|
||||
@racket[(multiply-matrix a b)] gibt die Matrix @racket[a]*@racket[b] zurück.
|
||||
}
|
||||
|
||||
@defthing[create-translation-matrix (vec3 -> matrix4x4)]{
|
||||
@scheme[(create-translation-matrix v)] gibt die Translations-Matrix zurück.
|
||||
@racket[(create-translation-matrix v)] gibt die Translations-Matrix zurück.
|
||||
}
|
||||
|
||||
@defthing[create-rotation-x-matrix (number -> matrix4x4)]{
|
||||
@scheme[(create-rotation-x-matrix a)] gibt eine Rotations-Matrix zurück die um die X-Achse mit dem Winkel @scheme[a] rotiert.
|
||||
@racket[(create-rotation-x-matrix a)] gibt eine Rotations-Matrix zurück die um die X-Achse mit dem Winkel @racket[a] rotiert.
|
||||
}
|
||||
|
||||
@defthing[create-rotation-y-matrix (number -> matrix4x4)]{
|
||||
@scheme[(create-rotation-y-matrix a)] gibt eine Rotations-Matrix zurück die um die Y-Achse mit dem Winkel @scheme[a] rotiert.
|
||||
@racket[(create-rotation-y-matrix a)] gibt eine Rotations-Matrix zurück die um die Y-Achse mit dem Winkel @racket[a] rotiert.
|
||||
}
|
||||
|
||||
@defthing[create-rotation-z-matrix (number -> matrix4x4)]{
|
||||
@scheme[(create-rotation-z-matrix a)] gibt eine Rotations-Matrix zurück die um die Z-Achse mit dem Winkel @scheme[a] rotiert.
|
||||
@racket[(create-rotation-z-matrix a)] gibt eine Rotations-Matrix zurück die um die Z-Achse mit dem Winkel @racket[a] rotiert.
|
||||
}
|
||||
|
||||
@defthing[create-lookat-matrix (vec3 vec3 vec3 -> matrix4x4)]{
|
||||
@scheme[(create-lookat-matrix pos lookat up)] gibt eine Kameramatrix. Ursprungspunkt ist @scheme[pos], die Z-Achse zeigt auf @scheme[lookat].
|
||||
@racket[(create-lookat-matrix pos lookat up)] gibt eine Kameramatrix. Ursprungspunkt ist @racket[pos], die Z-Achse zeigt auf @racket[lookat].
|
||||
}
|
||||
|
||||
@defthing[create-projection-matrix (number -> matrix4x4)]{
|
||||
@scheme[(create-projection-matrix vertical-fov/2)] erzeugt eine Projektions-Matrix. @scheme[vertical-fov]/2 gibt den vertikalen Winkel der Ansicht dividiert durch 2 an.
|
||||
@racket[(create-projection-matrix vertical-fov/2)] erzeugt eine Projektions-Matrix. @racket[vertical-fov]/2 gibt den vertikalen Winkel der Ansicht dividiert durch 2 an.
|
||||
}
|
||||
|
||||
@defthing[create-viewport-matrix (natural natural -> matrix4x4)]{
|
||||
@scheme[(create-viewport-matrix width height)] gibt einen Ausschnitt an.
|
||||
@racket[(create-viewport-matrix width height)] gibt einen Ausschnitt an.
|
||||
}
|
||||
|
||||
@;-------------------------------------------------------------------------------------
|
||||
|
@ -213,12 +213,12 @@ und @scheme[b] zurück (einen Vektor der senkrecht auf @scheme[a] und @scheme[b]
|
|||
|
||||
|
||||
@defthing[line3d signature]{
|
||||
Eine @deftech{3d-Linie} @scheme[line3d] ist ein Record, der durch den Aufruf @scheme[make-line3d] erstellt wird und eine farbige Linie zwischen zwei Punkten
|
||||
Eine @deftech{3d-Linie} @racket[line3d] ist ein Record, der durch den Aufruf @racket[make-line3d] erstellt wird und eine farbige Linie zwischen zwei Punkten
|
||||
im 3-dimensionalen Raum darstellt.
|
||||
}
|
||||
|
||||
@defthing[make-line3d (vec3 vec3 color -> line3d)]{
|
||||
@scheme[(make-line3d a b col)] erstellt eine 3D-Linie zwischen Punkt @scheme[a] und Punkt @scheme[b] mit der Farbe @scheme[col].
|
||||
@racket[(make-line3d a b col)] erstellt eine 3D-Linie zwischen Punkt @racket[a] und Punkt @racket[b] mit der Farbe @racket[col].
|
||||
}
|
||||
|
||||
@defthing[line3d-a (line3d -> vec3)]{
|
||||
|
@ -231,10 +231,10 @@ und @scheme[b] zurück (einen Vektor der senkrecht auf @scheme[a] und @scheme[b]
|
|||
extrahiert die Farbe einer 3D-Linie.}
|
||||
|
||||
@defthing[create-box (number number number color -> (list-of line3d))]{
|
||||
@scheme[(create-box width height depth color)] erstellt eine Box am Punkt (0,0,0) in den angebenen Ausmaßen.
|
||||
@racket[(create-box width height depth color)] erstellt eine Box am Punkt (0,0,0) in den angebenen Ausmaßen.
|
||||
}
|
||||
|
||||
@defthing[transform-primitive-list ((list-of line3d) matrix4x4 -> (list-of line3d))]{
|
||||
@scheme[(transform-primitive-list scene transformationr)] wendet @scheme[transformation] auf alle Punkte der Linien in @scheme[scene] an und gibt
|
||||
@racket[(transform-primitive-list scene transformationr)] wendet @racket[transformation] auf alle Punkte der Linien in @racket[scene] an und gibt
|
||||
diese zurück.
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ Rechner.
|
|||
|
||||
@defthing[play-sound-file (string -> unspecific)]{
|
||||
Der Aufruf
|
||||
@scheme[(play-sound-file f)] spielt die Audio-Datei mit dem Namen
|
||||
@scheme[f] ab.}
|
||||
@racket[(play-sound-file f)] spielt die Audio-Datei mit dem Namen
|
||||
@racket[f] ab.}
|
||||
|
||||
@defthing[background-play-sound-file (string -> unspecific)]{
|
||||
Der Aufruf
|
||||
@scheme[(background-play-sound-file f)] spielt die Audio-Datei mit dem Namen
|
||||
@scheme[f] im Hintergrund ab, also ohne dass das Scheme-Programm anhält.}
|
||||
@racket[(background-play-sound-file f)] spielt die Audio-Datei mit dem Namen
|
||||
@racket[f] im Hintergrund ab, also ohne dass das Scheme-Programm anhält.}
|
||||
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
(for-label deinprogramm/DMdA-beginner))
|
||||
|
||||
(provide prim-nonterms
|
||||
schemegrammar*-DMdA)
|
||||
racketgrammar*-DMdA)
|
||||
|
||||
(define ex-str "Dies ist eine Zeichenkette, die \" enthält.")
|
||||
|
||||
(define-syntax-rule (schemegrammar*-DMdA
|
||||
(define-syntax-rule (racketgrammar*-DMdA
|
||||
#:literals (lit ...)
|
||||
(def-rule ...)
|
||||
(prod ...)
|
||||
(def-rule ...)
|
||||
(prod ...)
|
||||
(expr-rule ...))
|
||||
(schemegrammar*
|
||||
(racketgrammar*
|
||||
#:literals (define define-record-procedures lambda cond if and or let letrec let* begin
|
||||
#;require lib planet
|
||||
check-expect check-within check-error
|
||||
|
@ -24,7 +24,7 @@
|
|||
(... [program (code:line def-or-expr ...)])
|
||||
[def-or-expr definition
|
||||
expr
|
||||
test-case
|
||||
test-case
|
||||
#;library-require]
|
||||
[definition @#,scheme[(define id expr)]
|
||||
@#,scheme[(define-record-procedures id id id (id (... ...)))]
|
||||
|
@ -80,7 +80,7 @@
|
|||
(make-splice
|
||||
(list
|
||||
|
||||
@t{Ein @scheme[_id] ist eine Folge von Zeichen, die weder Leerzeichen
|
||||
@t{Ein @racket[_id] ist eine Folge von Zeichen, die weder Leerzeichen
|
||||
noch eins der folgenden Zeichen enthält:}
|
||||
|
||||
@t{@hspace[2] @litchar{"} @litchar{,} @litchar{'} @litchar{`}
|
||||
|
@ -88,10 +88,10 @@ noch eins der folgenden Zeichen enthält:}
|
|||
@litchar["{"] @litchar["}"] @litchar{|} @litchar{;}
|
||||
@litchar{#}}
|
||||
|
||||
@t{Ein @scheme[_number] ist eine Zahl wie z.B. @scheme[123], @scheme[3/2] oder
|
||||
@scheme[5.5].}
|
||||
@t{Ein @racket[_number] ist eine Zahl wie z.B. @racket[123], @racket[3/2] oder
|
||||
@racket[5.5].}
|
||||
|
||||
@t{Ein @scheme[_string] ist eine Zeichenkette, und durch ein Paar von @litchar{"} umschlossen.
|
||||
So sind z.B. @scheme["abcdef"],
|
||||
@scheme["This is a string"] und @scheme[#,ex-str] Zeichenketten.}
|
||||
@t{Ein @racket[_string] ist eine Zeichenkette, und durch ein Paar von @litchar{"} umschlossen.
|
||||
So sind z.B. @racket["abcdef"],
|
||||
@racket["This is a string"] und @racket[#,ex-str] Zeichenketten.}
|
||||
)))
|
||||
|
|
|
@ -20,9 +20,9 @@ Zeichnen wird dabei durch das Bewegen einer virtuellen Schildkröte
|
|||
Befehle bewegt werden:
|
||||
|
||||
@itemize[
|
||||
@item{@scheme[(move n)] Bewegt die Schildkröte um @scheme[n] Pixel ohne zu zeichnen.}
|
||||
@item{@scheme[(draw n)] Bewegt die Schildkröte um @scheme[n] Pixel und zeichnet dabei.}
|
||||
@item{@scheme[(turn n)] Dreht die Schildkröte um n Grad im Uhrzeigersinn.}
|
||||
@item{@racket[(move n)] Bewegt die Schildkröte um @racket[n] Pixel ohne zu zeichnen.}
|
||||
@item{@racket[(draw n)] Bewegt die Schildkröte um @racket[n] Pixel und zeichnet dabei.}
|
||||
@item{@racket[(turn n)] Dreht die Schildkröte um n Grad im Uhrzeigersinn.}
|
||||
]
|
||||
|
||||
Wir stellen jetzt ein Teachpack für DrRacket vor, mit dessen Hilfe
|
||||
|
@ -32,9 +32,9 @@ solche Turtle-Grafiken erstellt werden können.
|
|||
|
||||
Unser Ziel ist es, in diesem Tutorial ein Quadrat mithilfe der
|
||||
Prozeduren des Teachpacks zu zeichnen. Aus diesem Grund müssen wir
|
||||
zunächst mit der Prozedur @scheme[draw] eine Linie nach rechts malen. Die
|
||||
zunächst mit der Prozedur @racket[draw] eine Linie nach rechts malen. Die
|
||||
initiale Ausgansposition der Turtle ist in der Bildmitte mit Blick
|
||||
nach rechts. Mit @scheme[(draw 20)] bewegen wir die Turtle dann 20 Pixel nach
|
||||
nach rechts. Mit @racket[(draw 20)] bewegen wir die Turtle dann 20 Pixel nach
|
||||
rechts und zeichnen dabei. Um das resultierende Bild zu sehen ist,
|
||||
müssen wir die Turtle mittels der Prozedur run laufen lassen. Die
|
||||
restlichen Parameter für run sind die Höhe und die Breite des Bildes
|
||||
|
@ -42,7 +42,7 @@ sowie die Farbe, in der gezeichnet werden soll. Geben Sie also
|
|||
folgenden Befehl in die REPL ein, um Ihre erste Turtle-Grafik zu
|
||||
erstellen:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(run (draw 20) 100 100 "red")
|
||||
]
|
||||
|
||||
|
@ -53,14 +53,14 @@ Sie erhalten dann eine Ausgabe wie die folgende:
|
|||
Nun vervollständigen wir die Linie zu einem rechten Winkel: wir drehen
|
||||
die Turtle um 90° nach rechts und zeichnen dann eine Line der Länge 20
|
||||
Pixel nach unten. Zum Drehen einer Turtle verwenden wir die Prozedur
|
||||
@scheme[turn].
|
||||
@racket[turn].
|
||||
|
||||
Da wir ein Quadrat aus zwei rechten Winkeln zusammensetzen können,
|
||||
abstrahieren wir über das Zeichnen des rechten Winkels. Dazu schreiben
|
||||
wir eine Prozedur @scheme[right-angle] die als Parameter eine Turtle
|
||||
wir eine Prozedur @racket[right-angle] die als Parameter eine Turtle
|
||||
erhält:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: right-angle (turtle -> turtle))
|
||||
(define right-angle
|
||||
(lambda (t1)
|
||||
|
@ -78,7 +78,7 @@ Um das Quadrat komplett zu zeichnen, sollen nun zwei rechte Winkel
|
|||
verwendet werden. Wir zeichnen also einen rechten Winkel, drehen uns
|
||||
um 90° nach rechts, und zeichnen einen zweiten rechten Winkel.
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(: square (turtle -> turtle))
|
||||
(define square
|
||||
(lambda (t1)
|
||||
|
@ -95,27 +95,27 @@ So sieht das Ergebnis aus:
|
|||
@subsection{Verbesserungen}
|
||||
|
||||
An dem Beispiel ist leicht zu sehen, dass es zum Zeichnen mit Hilfe
|
||||
von Turtle-Grafik oft erforderlich ist, Zwischenwerte wie @scheme[t1],
|
||||
@scheme[t2] etc., an die nächste Prozedur weiterzureichen, die Werte
|
||||
von Turtle-Grafik oft erforderlich ist, Zwischenwerte wie @racket[t1],
|
||||
@racket[t2] etc., an die nächste Prozedur weiterzureichen, die Werte
|
||||
ansonsten aber nicht weiterverwendet werden. Beispielsweise werden in
|
||||
der obigen Definition von square die Variablen @scheme[t1], ...,
|
||||
@scheme[t4] nur gebraucht, um die Prozeduren @scheme[right-angle],
|
||||
@scheme[(turn -90)] und @scheme[right-angle] hintereinander
|
||||
der obigen Definition von square die Variablen @racket[t1], ...,
|
||||
@racket[t4] nur gebraucht, um die Prozeduren @racket[right-angle],
|
||||
@racket[(turn -90)] und @racket[right-angle] hintereinander
|
||||
auszuführen.
|
||||
|
||||
Um solche Fälle einfach programmieren zu können, enthält das
|
||||
Turtle-Teachpack die Prozedur @scheme[sequence]. Damit können wir eine
|
||||
zu @scheme[right-angle] äquivalente Version wesentlicher einfacher
|
||||
Turtle-Teachpack die Prozedur @racket[sequence]. Damit können wir eine
|
||||
zu @racket[right-angle] äquivalente Version wesentlicher einfacher
|
||||
aufschreiben:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define right-angle2
|
||||
(sequence (draw 20) (turn -90) (draw 20)))
|
||||
]
|
||||
|
||||
Ebenso wie @scheme[right-angle] können wir square leichter schreiben als:
|
||||
Ebenso wie @racket[right-angle] können wir square leichter schreiben als:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define square2
|
||||
(sequence right-angle (turn -90) right-angle))
|
||||
]
|
||||
|
@ -135,7 +135,7 @@ so ändert dies die Farbe mit der gezeichnet wird.
|
|||
|
||||
Folgender Code
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define square3
|
||||
(sequence right-angle (turn -90) (set-color "blue") right-angle))
|
||||
]
|
||||
|
@ -173,6 +173,6 @@ der gezeichnet wird.
|
|||
|
||||
@defthing[sequence ((turtle -> turtle) ... -> (turtle -> turtle))]{
|
||||
Diese Prozedur nimmt eine beliebige Anzahl von Turtle-Veränderungen
|
||||
(d.h. Prozeduren mit Signatur @scheme[turtle -> turtle]) und erstellt
|
||||
(d.h. Prozeduren mit Signatur @racket[turtle -> turtle]) und erstellt
|
||||
eine neue Prozedur, die die Veränderungen der Reihe nach von links
|
||||
nach rechts abarbeitet.}
|
||||
|
|
|
@ -19,60 +19,60 @@ Es enthält alle Prozeduren aus dem
|
|||
@declare-exporting[teachpack/deinprogramm/world #:use-sources (deinprogramm/world)]
|
||||
|
||||
@defthing[world signature]{
|
||||
Eine @deftech{Welt} (Name: @scheme[world]) ist die Repräsentation des Zustands,
|
||||
Eine @deftech{Welt} (Name: @racket[world]) ist die Repräsentation des Zustands,
|
||||
der durch die Animation abgebildet wird.
|
||||
}
|
||||
|
||||
@defthing[mouse-event-kind signature]{
|
||||
@scheme[(one-of "enter" "leave" "motion" "left-down" "left-up" "middle-down" "middle-up" "right-down" "right-up")]
|
||||
@racket[(one-of "enter" "leave" "motion" "left-down" "left-up" "middle-down" "middle-up" "right-down" "right-up")]
|
||||
|
||||
Eine @deftech{Mausereignis-Art} (Name: @scheme[mouse-event-kind])
|
||||
Eine @deftech{Mausereignis-Art} (Name: @racket[mouse-event-kind])
|
||||
bezeichnet die Art eines Maus-Ereignisses:
|
||||
|
||||
@scheme["enter"] bedeutet, daß der Mauszeiger gerade
|
||||
in das Fenster hinein bewegt wurde. @scheme["leave"] bedeutet, daß der
|
||||
@racket["enter"] bedeutet, daß der Mauszeiger gerade
|
||||
in das Fenster hinein bewegt wurde. @racket["leave"] bedeutet, daß der
|
||||
Mauszeiger gerade aus dem Fenster heraus bewegt wurde.
|
||||
@scheme["motion"] bedeutet, daß der Mauszeiger innerhalb des
|
||||
@racket["motion"] bedeutet, daß der Mauszeiger innerhalb des
|
||||
Fensters bewegt wurde. Die anderen Zeichenketten bedeuten, daß der
|
||||
entsprechende Mausknopf gedrückt oder losgelassen wurde.}
|
||||
|
||||
@defthing[big-bang (natural natural number world -> (one-of #t))]{
|
||||
Der Aufruf @scheme[(big-bang w h n w)]
|
||||
erzeugt eine Leinwand mit Breite @scheme[w] und Höhe
|
||||
@scheme[h], startet die Uhr, die alle @scheme[n] Sekunden
|
||||
tickt, und macht @scheme[w] zur ersten Welt.}
|
||||
Der Aufruf @racket[(big-bang w h n w)]
|
||||
erzeugt eine Leinwand mit Breite @racket[w] und Höhe
|
||||
@racket[h], startet die Uhr, die alle @racket[n] Sekunden
|
||||
tickt, und macht @racket[w] zur ersten Welt.}
|
||||
|
||||
@defthing[on-tick-event ((world -> world) -> (one-of #t))]{
|
||||
Der Aufruf @scheme[(on-tick-event tock)]
|
||||
meldet @scheme[tock]
|
||||
Der Aufruf @racket[(on-tick-event tock)]
|
||||
meldet @racket[tock]
|
||||
als Prozedur an, die bei jedem Uhren-Tick aufgerufen wird, um aus
|
||||
der alten Welt eine neue zu machen.}
|
||||
|
||||
@defthing[on-key-event ((world string -> world) -> (one-of #t))]{
|
||||
Der Aufruf @scheme[(on-key-event change)]
|
||||
meldet @scheme[change]
|
||||
Der Aufruf @racket[(on-key-event change)]
|
||||
meldet @racket[change]
|
||||
als Prozedur an, die bei jedem Tastendruck aufgerufen wird, um aus
|
||||
der alten Welt eine neue zu machen. Dabei wird als Argument eine
|
||||
Zeichenkette übergeben, welche die Taste darstellt, also
|
||||
@scheme["a"] für die A-Taste etc., sowie @scheme["up"],
|
||||
@scheme["down"], @scheme["left"], und @scheme["right"]
|
||||
für die entsprechenden Pfeiltasten und @scheme["wheel-up"] für die
|
||||
Bewegung des Mausrads nach oben und @scheme["wheel-down"] für die
|
||||
@racket["a"] für die A-Taste etc., sowie @racket["up"],
|
||||
@racket["down"], @racket["left"], und @racket["right"]
|
||||
für die entsprechenden Pfeiltasten und @racket["wheel-up"] für die
|
||||
Bewegung des Mausrads nach oben und @racket["wheel-down"] für die
|
||||
Bewegung des Mausrads nach unten.}
|
||||
|
||||
@defthing[on-mouse-event ((world natural natural mouse-event-kind -> world) -> (one-of #t))]{
|
||||
Der Aufruf @scheme[(on-mouse-event change)]
|
||||
meldet @scheme[change]
|
||||
Der Aufruf @racket[(on-mouse-event change)]
|
||||
meldet @racket[change]
|
||||
als Prozedur an, die bei jedem Mausereignis aufgerufen wird, um aus
|
||||
der alten Welt eine neue zu machen. Die @scheme[change]-Prozedur
|
||||
wird als @scheme[(change w x y k)] aufgerufen. Dabei ist @scheme[w]
|
||||
die alte Welt, @scheme[x] und @scheme[y] die Koordinaten des
|
||||
Mauszeigers, und @scheme[k] die Art des Mausereignisses.}
|
||||
der alten Welt eine neue zu machen. Die @racket[change]-Prozedur
|
||||
wird als @racket[(change w x y k)] aufgerufen. Dabei ist @racket[w]
|
||||
die alte Welt, @racket[x] und @racket[y] die Koordinaten des
|
||||
Mauszeigers, und @racket[k] die Art des Mausereignisses.}
|
||||
|
||||
@defthing[on-redraw ((world -> image) -> (one-of #t))]{
|
||||
Der Aufruf @scheme[(world->image world->image)]
|
||||
Der Aufruf @racket[(world->image world->image)]
|
||||
meldet die
|
||||
Prozedur @scheme[world->image] an, die aus einer Welt
|
||||
Prozedur @racket[world->image] an, die aus einer Welt
|
||||
ein Bild macht, das auf der Leinwand dargestellt wird.}
|
||||
|
||||
@defthing[end-of-time (string -> world)]{
|
||||
|
|
|
@ -88,5 +88,5 @@
|
|||
#`(provide/doc
|
||||
(thing-doc id
|
||||
contract?
|
||||
((reconstitute (schemeblock #,ctc) provide?)))))
|
||||
((reconstitute (racketblock #,ctc) provide?)))))
|
||||
'()))))]))
|
||||
|
|
|
@ -96,7 +96,7 @@ all of the names in the tools library, for use defining keybindings
|
|||
|
||||
See @racket[read-language] for more details on how language's specify how to opt out.
|
||||
DrRacket will invoke the @tt{get-info} proc from @racket[read-language] with
|
||||
@indexed-scheme['drscheme:opt-out-toolbar-buttons]. If the result is a list of symbols, the
|
||||
@indexed-racket['drscheme:opt-out-toolbar-buttons]. If the result is a list of symbols, the
|
||||
listed symbols are opted out. If the result is @racket[#f], all buttons are opted
|
||||
out. The default is the empty list, meaning that all opt-out buttons appear.
|
||||
})
|
||||
|
@ -425,7 +425,7 @@ all of the names in the tools library, for use defining keybindings
|
|||
|
||||
It looks for both stack trace information in the continuation
|
||||
marks both via the
|
||||
@schememodname[errortrace/errortrace-key]
|
||||
@racketmodname[errortrace/errortrace-key]
|
||||
module and via
|
||||
@racket[continuation-mark-set->context].
|
||||
|
||||
|
@ -1139,9 +1139,8 @@ all of the names in the tools library, for use defining keybindings
|
|||
is initialized to.
|
||||
If unsure of a default, the currently set language
|
||||
in the user's preferences can be obtained via:
|
||||
@schemeblock[
|
||||
(preferences:get (drracket:language-configuration:get-settings-preferences-symbol))
|
||||
]
|
||||
@racketblock[
|
||||
(preferences:get (drracket:language-configuration:get-settings-preferences-symbol))]
|
||||
|
||||
The @racket[parent] argument is used as the parent
|
||||
to the dialog.
|
||||
|
|
|
@ -32,9 +32,9 @@ platform-specific C compiler and linker.
|
|||
any/c]{
|
||||
|
||||
Compiles the given input file (C source) to the given output file (a
|
||||
compiled-object file). The @scheme[quiet?] argument indicates whether
|
||||
compiled-object file). The @racket[quiet?] argument indicates whether
|
||||
command should be echoed to the current output port. The
|
||||
@scheme[include-dirs] argument is a list of directories to search for
|
||||
@racket[include-dirs] argument is a list of directories to search for
|
||||
include files; the Racket installation's @filepath{include}
|
||||
directories are added automatically.}
|
||||
|
||||
|
@ -53,7 +53,7 @@ The default is set by searching for an executable using the
|
|||
defined (and the latter takes precedence). On Windows, the search
|
||||
looks for @filepath{cl.exe}, then @filepath{gcc.exe}, then
|
||||
@filepath{bcc32.exe} (Borland). On Unix, it looks for
|
||||
@filepath{gcc}, then @filepath{cc}. A @scheme[#f] value indicates that
|
||||
@filepath{gcc}, then @filepath{cc}. A @racket[#f] value indicates that
|
||||
no compiler could be found.}
|
||||
|
||||
@defparam[current-extension-compiler-flags
|
||||
|
@ -62,14 +62,14 @@ no compiler could be found.}
|
|||
(-> (or/c null? (listof string?)))))]{
|
||||
|
||||
A parameter that determines strings passed to the compiler as flags.
|
||||
See also @scheme[expand-for-compile-variant].
|
||||
See also @racket[expand-for-compile-variant].
|
||||
|
||||
On Windows, the default is @scheme[(list "/c" "/O2" "/MT"
|
||||
_3m-flag-thunk)] for @filepath{cl.exe}, or @scheme[(list "-c" "-O2"
|
||||
On Windows, the default is @racket[(list "/c" "/O2" "/MT"
|
||||
_3m-flag-thunk)] for @filepath{cl.exe}, or @racket[(list "-c" "-O2"
|
||||
"-fPIC" _3m-flag-thunk)] for @filepath{gcc.exe} and
|
||||
@filepath{bcc32.exe}, where @scheme[_3m-flag-thunk] returns
|
||||
@scheme[(list "-DMZ_PRECISE_GC")] for the 3m variant and null for the
|
||||
CGC variant. On Unix, the default is usually @scheme[(list "-c"
|
||||
@filepath{bcc32.exe}, where @racket[_3m-flag-thunk] returns
|
||||
@racket[(list "-DMZ_PRECISE_GC")] for the 3m variant and null for the
|
||||
CGC variant. On Unix, the default is usually @racket[(list "-c"
|
||||
"-O2" "-fPIC" _3m-flag-thunk)]. If the @envvar{CFLAGS} or
|
||||
@envvar{MZSCHEME_DYNEXT_COMPILER_FLAGS} environment variable is
|
||||
defined (the latter takes precedence), then its value is parsed as a
|
||||
|
@ -84,10 +84,10 @@ A parameter the processes include-path inputs to the compiler; the
|
|||
parameter values takes an include directory path and returns a list of
|
||||
strings for the command line.
|
||||
|
||||
On Windows, the default converts @scheme["dir"] to @scheme[(list
|
||||
"/Idir")] for @filepath{cl.exe}, @scheme[(list "-Idir")] for
|
||||
On Windows, the default converts @racket["dir"] to @racket[(list
|
||||
"/Idir")] for @filepath{cl.exe}, @racket[(list "-Idir")] for
|
||||
@filepath{gcc.exe} and @filepath{bcc32.exe}. On Unix, the default
|
||||
converts @scheme["dir"] to @scheme[(list "-Idir")]. If the
|
||||
converts @racket["dir"] to @racket[(list "-Idir")]. If the
|
||||
@envvar{CFLAGS} environment variable is defined, then its value is
|
||||
parsed as a list of flags that is appended before the defaults.}
|
||||
|
||||
|
@ -98,7 +98,7 @@ parsed as a list of flags that is appended before the defaults.}
|
|||
|
||||
A parameter that processes inputs to the compiler; the parameter's
|
||||
values takes an input file path and returns a list of strings for the
|
||||
command line. The default is @scheme[list].}
|
||||
command line. The default is @racket[list].}
|
||||
|
||||
|
||||
@defparam[current-make-compile-output-strings
|
||||
|
@ -109,10 +109,10 @@ A parameter that processes outputs specified for the compiler; the
|
|||
parameter's value takes an output file path and returns a list of
|
||||
strings for the command line.
|
||||
|
||||
On Windows, the default converts @scheme["file"] to @scheme[(list
|
||||
"/Fofile")] for @filepath{cl.exe}, or to @scheme[(list "-o" "file")]
|
||||
On Windows, the default converts @racket["file"] to @racket[(list
|
||||
"/Fofile")] for @filepath{cl.exe}, or to @racket[(list "-o" "file")]
|
||||
for @filepath{gcc.exe} and @filepath{bcc32.exe}. On Unix, the
|
||||
default converts @scheme["file"] to @scheme[(list "-o" "file")].}
|
||||
default converts @racket["file"] to @racket[(list "-o" "file")].}
|
||||
|
||||
|
||||
@defparam[current-extension-preprocess-flags
|
||||
|
@ -121,11 +121,11 @@ default converts @scheme["file"] to @scheme[(list "-o" "file")].}
|
|||
|
||||
A parameters that specifies flags to the compiler preprocessor,
|
||||
instead of to the compiler proper; use these flags for preprocessing
|
||||
instead of @scheme[current-extension-compiler-flags].
|
||||
instead of @racket[current-extension-compiler-flags].
|
||||
|
||||
The defaults are similar to @scheme[current-extension-compiler-flags],
|
||||
but with @scheme["/E"] (Windows @filepath{cl.exe}) or @scheme["-E"]
|
||||
and without non-@scheme["-D"] flags.}
|
||||
The defaults are similar to @racket[current-extension-compiler-flags],
|
||||
but with @racket["/E"] (Windows @filepath{cl.exe}) or @racket["-E"]
|
||||
and without non-@racket["-D"] flags.}
|
||||
|
||||
|
||||
@defparam[compile-variant
|
||||
|
@ -133,7 +133,7 @@ and without non-@scheme["-D"] flags.}
|
|||
(one-of/c 'normal 'cgc '3m)]{
|
||||
|
||||
A parameter that indicates the target for compilation, where
|
||||
@scheme['normal] is an alias for the result of @scheme[(system-type
|
||||
@racket['normal] is an alias for the result of @racket[(system-type
|
||||
'gc)]}
|
||||
|
||||
|
||||
|
@ -146,16 +146,16 @@ particular known compiler. The acceptable names are
|
|||
platforms-specific:
|
||||
|
||||
@itemize[
|
||||
@item{Unix: @scheme['cc] or @scheme['gcc]}
|
||||
@item{Windows: @scheme['gcc], @scheme['msvc], or @scheme['borland]}
|
||||
@item{MacOS: @scheme['cw]}
|
||||
@item{Unix: @racket['cc] or @racket['gcc]}
|
||||
@item{Windows: @racket['gcc], @racket['msvc], or @racket['borland]}
|
||||
@item{MacOS: @racket['cw]}
|
||||
]}
|
||||
|
||||
|
||||
@defproc[(get-standard-compilers) (listof symbol?)]{
|
||||
|
||||
Returns a list of standard compiler names for the current platform. See
|
||||
@scheme[use-standard-compiler].}
|
||||
@racket[use-standard-compiler].}
|
||||
|
||||
|
||||
@defproc[(expand-for-compile-variant (l (listof (or/c path-string? (-> (listof string?)))))) any]{
|
||||
|
@ -172,7 +172,7 @@ depending on the current compile variant.}
|
|||
|
||||
@defsignature[dynext:compile^ ()]
|
||||
|
||||
Includes everything exported by the @schememodname[dynext/compile] module.
|
||||
Includes everything exported by the @racketmodname[dynext/compile] module.
|
||||
|
||||
@subsection[#:tag "compile-unit"]{Unit}
|
||||
|
||||
|
@ -180,7 +180,7 @@ Includes everything exported by the @schememodname[dynext/compile] module.
|
|||
|
||||
@defthing[dynext:compile@ unit?]{
|
||||
|
||||
Imports nothing, exports @scheme[dynext:compile^].}
|
||||
Imports nothing, exports @racket[dynext:compile^].}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
|
@ -191,11 +191,11 @@ Imports nothing, exports @scheme[dynext:compile^].}
|
|||
@defproc[(link-extension (quiet? any/c) (input-files (listof path-string?)) (output-file path-string?)) any]{
|
||||
|
||||
Links object files to create an extension (normally of a form that can
|
||||
be loaded with @scheme[load-extension]).
|
||||
be loaded with @racket[load-extension]).
|
||||
|
||||
The @scheme[quiet?] argument indicates whether command should be
|
||||
echoed to the current output port. The @scheme[input-files] argument
|
||||
is list of compiled object filenames, and @scheme[output-file] is the
|
||||
The @racket[quiet?] argument indicates whether command should be
|
||||
echoed to the current output port. The @racket[input-files] argument
|
||||
is list of compiled object filenames, and @racket[output-file] is the
|
||||
destination extension filename.}
|
||||
|
||||
|
||||
|
@ -214,7 +214,7 @@ The default is set by searching for an executable using the
|
|||
@filepath{cl.exe}, then @filepath{ld.exe} (gcc), then
|
||||
@filepath{ilink32.exe} (Borland). On Cygwin, Solaris, FreeBSD 2.x,
|
||||
or HP/UX, it looks for @filepath{ld}. On other Unix variants, it
|
||||
looks for @filepath{cc}. @scheme[#f] indicates that no linker could be
|
||||
looks for @filepath{cc}. @racket[#f] indicates that no linker could be
|
||||
found.}
|
||||
|
||||
@defparam[current-extension-linker-flags
|
||||
|
@ -222,10 +222,10 @@ found.}
|
|||
(listof (or/c path-string? (-> (listof string?))))]{
|
||||
|
||||
A parameter that determines flags provided to the linker. See also
|
||||
@scheme[expand-for-link-variant].
|
||||
@racket[expand-for-link-variant].
|
||||
|
||||
On Windows, default is @scheme[(list "/LD")] for @filepath{cl.exe},
|
||||
@scheme[(list "--dll")] for @filepath{ld.exe}, and @scheme[(list
|
||||
On Windows, default is @racket[(list "/LD")] for @filepath{cl.exe},
|
||||
@racket[(list "--dll")] for @filepath{ld.exe}, and @racket[(list
|
||||
"/Tpd" "/c")] for @filepath{ilink32.exe}. On Unix, the default
|
||||
varies greatly among platforms. If the @envvar{LDFLAGS} or
|
||||
@envvar{MZSCHEME_DYNEXT_LINKER_FLAGS} (the latter takes precedence)
|
||||
|
@ -238,7 +238,7 @@ strings that is appended before the defaults.}
|
|||
|
||||
A parameter that processes linker input arguments; the parameter value
|
||||
takes an input file path and returns a list of strings for the command
|
||||
line. The default is @scheme[list].}
|
||||
line. The default is @racket[list].}
|
||||
|
||||
@defparam[current-make-link-output-strings
|
||||
proc
|
||||
|
@ -248,28 +248,28 @@ A parameter that processes linker output arguments; the parameter
|
|||
value takes an output file path and returns a list of strings for the
|
||||
command line.
|
||||
|
||||
On Windows, the default converts @scheme["file"] to @scheme[(list
|
||||
"/Fefile")] for @filepath{cl.exe}, something like @scheme[(list "-e"
|
||||
On Windows, the default converts @racket["file"] to @racket[(list
|
||||
"/Fefile")] for @filepath{cl.exe}, something like @racket[(list "-e"
|
||||
"_dll_entry@12" "-o" "file")] for @filepath{ld.exe}, and something
|
||||
complex for @filepath{ilink32.exe}. On Unix, the default converts
|
||||
@scheme["file"] to @scheme[(list "-o" "file")].}
|
||||
@racket["file"] to @racket[(list "-o" "file")].}
|
||||
|
||||
@defparam[current-standard-link-libraries
|
||||
libs
|
||||
(listof (or/c path-string? (-> (listof string?))))]{
|
||||
|
||||
A parameter that determines libraries supplied to the linker, in
|
||||
addition to other inputs. See also @scheme[expand-for-link-variant].
|
||||
addition to other inputs. See also @racket[expand-for-link-variant].
|
||||
|
||||
For most platforms, the default is
|
||||
|
||||
@schemeblock[(list (build-path (collection-path "mzscheme" "lib")
|
||||
@racketblock[(list (build-path (collection-path "mzscheme" "lib")
|
||||
(system-library-subpath)
|
||||
(_mzdyn-thunk)))]
|
||||
|
||||
where @scheme[_mzdyn-thunk] produces @scheme[(list "mzdyn.o")] for the
|
||||
@scheme['cgc] variant and @scheme[(list "mzdyn3m.o")] for the
|
||||
@scheme['3m] variant. See also @scheme[current-use-mzdyn]).}
|
||||
where @racket[_mzdyn-thunk] produces @racket[(list "mzdyn.o")] for the
|
||||
@racket['cgc] variant and @racket[(list "mzdyn3m.o")] for the
|
||||
@racket['3m] variant. See also @racket[current-use-mzdyn]).}
|
||||
|
||||
@defparam[current-use-mzdyn
|
||||
use-mzdyn?
|
||||
|
@ -277,15 +277,15 @@ where @scheme[_mzdyn-thunk] produces @scheme[(list "mzdyn.o")] for the
|
|||
|
||||
A parameter that determines whether the default standard link
|
||||
libraries include the @filepath{mzdyn} library which allows the
|
||||
resulting file to be loaded via @scheme[load-extension]. Defaults to
|
||||
@scheme[#t].}
|
||||
resulting file to be loaded via @racket[load-extension]. Defaults to
|
||||
@racket[#t].}
|
||||
|
||||
@defparam[link-variant
|
||||
variant-symbol
|
||||
(one-of/c 'normal 'cgc '3m)]{
|
||||
|
||||
A parameter that indicates the target for linking, where
|
||||
@scheme['normal] is an alias for the result of @scheme[(system-type
|
||||
@racket['normal] is an alias for the result of @racket[(system-type
|
||||
'gc)].}
|
||||
|
||||
|
||||
|
@ -303,7 +303,7 @@ particular known linker.}
|
|||
(-> (listof string?))))))
|
||||
any]{
|
||||
|
||||
The same as @scheme[expand-for-compile-variant].}
|
||||
The same as @racket[expand-for-compile-variant].}
|
||||
|
||||
|
||||
@subsection[#:tag "link-sig"]{Signature}
|
||||
|
@ -312,7 +312,7 @@ The same as @scheme[expand-for-compile-variant].}
|
|||
|
||||
@defsignature[dynext:link^ ()]
|
||||
|
||||
Includes everything exported by the @schememodname[dynext/link] module.
|
||||
Includes everything exported by the @racketmodname[dynext/link] module.
|
||||
|
||||
@subsection[#:tag "link-unit"]{Unit}
|
||||
|
||||
|
@ -320,7 +320,7 @@ Includes everything exported by the @schememodname[dynext/link] module.
|
|||
|
||||
@defthing[dynext:link@ unit?]{
|
||||
|
||||
Imports nothing, exports @scheme[dynext:link^].}
|
||||
Imports nothing, exports @racket[dynext:link^].}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
|
@ -330,63 +330,63 @@ Imports nothing, exports @scheme[dynext:link^].}
|
|||
|
||||
@defproc[(append-zo-suffix (s (or/c string? path?))) path?]{
|
||||
|
||||
Appends the @filepath{.zo} file suffix to @scheme[s], returning a
|
||||
Appends the @filepath{.zo} file suffix to @racket[s], returning a
|
||||
path. The existing suffix, if any, is preserved and converted as with
|
||||
@scheme[path-add-suffix].}
|
||||
@racket[path-add-suffix].}
|
||||
|
||||
@defproc[(append-object-suffix (s path-string?)) path?]{
|
||||
|
||||
Appends the platform-standard compiled object file suffix to
|
||||
@scheme[s], returning a path.}
|
||||
@racket[s], returning a path.}
|
||||
|
||||
@defproc[(append-c-suffix (s path-string?)) path?]{
|
||||
|
||||
Appends the platform-standard C source-file suffix to @scheme[s],
|
||||
Appends the platform-standard C source-file suffix to @racket[s],
|
||||
returning a path.}
|
||||
|
||||
@defproc[(append-constant-pool-suffix (s (or/c string? path?))) path?]{
|
||||
|
||||
Appends the constant-pool file suffix @filepath{.kp} to @scheme[s],
|
||||
Appends the constant-pool file suffix @filepath{.kp} to @racket[s],
|
||||
returning a path.}
|
||||
|
||||
@defproc[(append-extension-suffix (s (or/c string? path?))) path?]{
|
||||
|
||||
Appends the platform-standard dynamic-extension file suffix to
|
||||
@scheme[s], returning a path.}
|
||||
@racket[s], returning a path.}
|
||||
|
||||
@defproc[(extract-base-filename/ss (s path-string?)
|
||||
(program any/c #f))
|
||||
(or/c path? false/c)]{
|
||||
|
||||
Strips the Racket file suffix from @scheme[s] and returns a stripped
|
||||
path. Unlike the other functions below, when @scheme[program] is not
|
||||
@scheme[#f], then any suffix (including no suffix) is allowed. If
|
||||
@scheme[s] is not a Racket file and @scheme[program] is @scheme[#f],
|
||||
@scheme[#f] is returned.}
|
||||
Strips the Racket file suffix from @racket[s] and returns a stripped
|
||||
path. Unlike the other functions below, when @racket[program] is not
|
||||
@racket[#f], then any suffix (including no suffix) is allowed. If
|
||||
@racket[s] is not a Racket file and @racket[program] is @racket[#f],
|
||||
@racket[#f] is returned.}
|
||||
|
||||
@defproc[(extract-base-filename/c (s path-string?)
|
||||
(program any/c #f))
|
||||
(or/c path? false/c)]{
|
||||
|
||||
Strips the Racket file suffix from @scheme[s] and
|
||||
returns a stripped path. If @scheme[s] is not a Racket file name and
|
||||
@scheme[program] is a symbol, and error is signaled. If @scheme[s] is
|
||||
not a Racket file and @scheme[program] is @scheme[#f], @scheme[#f] is
|
||||
Strips the Racket file suffix from @racket[s] and
|
||||
returns a stripped path. If @racket[s] is not a Racket file name and
|
||||
@racket[program] is a symbol, and error is signaled. If @racket[s] is
|
||||
not a Racket file and @racket[program] is @racket[#f], @racket[#f] is
|
||||
returned.}
|
||||
|
||||
@defproc[(extract-base-filename/kp (s path-string?) (program any/c #f)) (or/c path? false/c)]{
|
||||
|
||||
Same as @scheme[extract-base-filename/c], but for constant-pool
|
||||
Same as @racket[extract-base-filename/c], but for constant-pool
|
||||
files.}
|
||||
|
||||
@defproc[(extract-base-filename/o (s path-string?) (program any/c #f)) (or/c path? false/c)]{
|
||||
|
||||
Same as @scheme[extract-base-filename/c], but for compiled-object
|
||||
Same as @racket[extract-base-filename/c], but for compiled-object
|
||||
files.}
|
||||
|
||||
@defproc[(extract-base-filename/ext (s path-string?) (program any/c #f)) (or/c path? false/c)]{
|
||||
|
||||
Same as @scheme[extract-base-filename/c], but for extension files.}
|
||||
Same as @racket[extract-base-filename/c], but for extension files.}
|
||||
|
||||
|
||||
@subsection[#:tag "file-sig"]{Signature}
|
||||
|
@ -395,7 +395,7 @@ Same as @scheme[extract-base-filename/c], but for extension files.}
|
|||
|
||||
@defsignature[dynext:file^ ()]
|
||||
|
||||
Includes everything exported by the @schememodname[dynext/file] module.
|
||||
Includes everything exported by the @racketmodname[dynext/file] module.
|
||||
|
||||
@subsection[#:tag "file-unit"]{Unit}
|
||||
|
||||
|
@ -403,5 +403,5 @@ Includes everything exported by the @schememodname[dynext/file] module.
|
|||
|
||||
@defthing[dynext:file@ unit?]{
|
||||
|
||||
Imports nothing, exports @scheme[dynext:file^].}
|
||||
Imports nothing, exports @racket[dynext:file^].}
|
||||
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
|
||||
@defclass/title[aligned-pasteboard% pasteboard% (alignment-parent<%>)]{
|
||||
|
||||
Acts as the top of an @scheme[alignment<%>] tree.}
|
||||
Acts as the top of an @racket[alignment<%>] tree.}
|
||||
|
|
|
@ -16,7 +16,7 @@ Tells the alignment that its sizes should be calculated.}
|
|||
[width (and/c real? (not/c negative?))]
|
||||
[height (and/c real? (not/c negative?))]) void?]{
|
||||
Tells itself to align its children on the pasteboard
|
||||
in the given rectangle defined by @scheme[width], @scheme[height] and a top
|
||||
in the given rectangle defined by @racket[width], @racket[height] and a top
|
||||
left corner point given as offsets into the pasteboards top
|
||||
left corner.}
|
||||
|
||||
|
@ -30,7 +30,7 @@ The minimum height this alignment must be.}
|
|||
|
||||
@defmethod*[([(stretchable-width) boolean?]
|
||||
[(stretchable-width [value boolean?]) void?])]{
|
||||
|
||||
|
||||
Gets/sets the property of stretchability in the x dimension.}
|
||||
|
||||
@defmethod*[([(stretchable-height) boolean?]
|
||||
|
|
|
@ -8,11 +8,11 @@ A clickable button with a bitmap label.
|
|||
@defconstructor[([images (cons/c path-string? path-string?)]
|
||||
[callback ((is-a?/c button-snip%) (is-a?/c event%) . -> . void?)])]{
|
||||
|
||||
The @scheme[images] argument is a pair filenames to be load as the
|
||||
The @racket[images] argument is a pair filenames to be load as the
|
||||
button-label image, where the first is the image for when the button
|
||||
is at rest, and the second is the image for the button while its
|
||||
pressed.
|
||||
|
||||
The @scheme[callback] is called when the button is clicked.}
|
||||
The @racket[callback] is called when the button is clicked.}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ Gets/sets the previous item in the list.}
|
|||
|
||||
@defmethod[(for-each [f ((is-a?/c dllist<%>) . -> . void?)]) void?]{
|
||||
|
||||
Applies @scheme[f] to every element of the dllist.}
|
||||
Applies @racket[f] to every element of the dllist.}
|
||||
|
||||
@defmethod[(map-to-list [f ((is-a?/c dllist<%>) . -> . any/c)])
|
||||
(listof any/c)]{
|
||||
|
||||
Creates a Scheme list by applying @scheme[f] to every element
|
||||
Creates a Scheme list by applying @racket[f] to every element
|
||||
of @this-obj[].}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ A clickable button with a bitmap label.
|
|||
@defconstructor[([images (cons/c path-string? path-string?)]
|
||||
[callback ((is-a?/c button-snip%) (is-a?/c event%) . -> . void?)])]{
|
||||
|
||||
The @scheme[images] argument is a pair filenames to be load as the
|
||||
The @racket[images] argument is a pair filenames to be load as the
|
||||
button-label image, where the first is the image for when the button
|
||||
is at rest, and the second is the image for the button while its
|
||||
pressed.
|
||||
|
||||
The @scheme[callback] is called when the button is clicked.}
|
||||
The @racket[callback] is called when the button is clicked.}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#lang scribble/doc
|
||||
@(require "common.rkt" (for-label framework))
|
||||
|
||||
@title{@bold{Embedded GUI}: Widgets within @scheme[editor<%>]}
|
||||
@title{@bold{Embedded GUI}: Widgets within @racket[editor<%>]}
|
||||
|
||||
@author["Mike T. McHenry"]
|
||||
|
||||
@defmodule[embedded-gui]
|
||||
|
||||
The @schememodname[embedded-gui] library provides a class hierarchy
|
||||
for creating graphical boxes within @scheme[editor<%>] objects with
|
||||
geometry management that mirrors that of @scheme[vertical-panel%] and
|
||||
@scheme[horizontal-panel%].
|
||||
The @racketmodname[embedded-gui] library provides a class hierarchy
|
||||
for creating graphical boxes within @racket[editor<%>] objects with
|
||||
geometry management that mirrors that of @racket[vertical-panel%] and
|
||||
@racket[horizontal-panel%].
|
||||
|
||||
@table-of-contents[]
|
||||
|
||||
|
@ -24,10 +24,10 @@ geometry management that mirrors that of @scheme[vertical-panel%] and
|
|||
|
||||
@defmixin[stretchable-editor-snip-mixin (editor-snip%) (stretchable-snip<%>)]{
|
||||
|
||||
Extends an editor snip the @scheme[stretchable-snip<%>] interface,
|
||||
Extends an editor snip the @racket[stretchable-snip<%>] interface,
|
||||
which allows it to be stretched to fit an
|
||||
@scheme[alignment-parent<%>]'s allotted width. Stretchable snips are
|
||||
useful as the snip of a @scheme[snip-wrapper%] }
|
||||
@racket[alignment-parent<%>]'s allotted width. Stretchable snips are
|
||||
useful as the snip of a @racket[snip-wrapper%] }
|
||||
|
||||
|
||||
@defclass[stretchable-editor-snip% editor-snip% (stretchable-editor-snip-mixin editor-snip%)]{
|
||||
|
@ -41,11 +41,11 @@ geometry management that mirrors that of @scheme[vertical-panel%] and
|
|||
@defproc[(fixed-width-label-snip [possible-labels (listof string?)])
|
||||
(subclass?/c snip%)]{
|
||||
|
||||
Returns a subclass of @scheme[snip%] that takes a single
|
||||
Returns a subclass of @racket[snip%] that takes a single
|
||||
initialization argument. The argument provided when instantiating the
|
||||
class must be a member of @scheme[possible-labels]; the given label
|
||||
class must be a member of @racket[possible-labels]; the given label
|
||||
is displayed by the snip, but the snip is sized to match the longest
|
||||
of the labels in @scheme[possible-labels].
|
||||
of the labels in @racket[possible-labels].
|
||||
|
||||
In other words, the resulting class helps align multiple GUI elements
|
||||
t hat are labeled from a particular set of strings.}
|
||||
|
@ -53,11 +53,11 @@ t hat are labeled from a particular set of strings.}
|
|||
|
||||
@definterface[tabbable-text<%> ()]{
|
||||
|
||||
An interface for tabbing between embedded @scheme[text%]s.
|
||||
An interface for tabbing between embedded @racket[text%]s.
|
||||
|
||||
@defmethod[(set-caret-owner) void?]{
|
||||
|
||||
Moves the caret into the @scheme[tabbable-text<%>].}
|
||||
Moves the caret into the @racket[tabbable-text<%>].}
|
||||
|
||||
@defmethod[(set-ahead) void?]{
|
||||
|
||||
|
@ -70,15 +70,15 @@ t hat are labeled from a particular set of strings.}
|
|||
|
||||
@defmixin[tabbable-text-mixin (editor:keymap<%>) (tabbable-text<%>)]{
|
||||
|
||||
Adds the @scheme[tabbable-text<%>] interface to an
|
||||
@scheme[editor:text%] class, where instantiation installs key
|
||||
Adds the @racket[tabbable-text<%>] interface to an
|
||||
@racket[editor:text%] class, where instantiation installs key
|
||||
bindings to tab ahead and backward}
|
||||
|
||||
|
||||
@defproc[(set-tabbing [a-text (is-a?/c tabbable-text<%>)] ...)
|
||||
void?]{
|
||||
|
||||
Sets the tabbing order of @scheme[tabbable-text<%>]s by setting each
|
||||
Sets the tabbing order of @racket[tabbable-text<%>]s by setting each
|
||||
text's @method[tabbable-text<%> set-ahead] and
|
||||
@method[tabbable-text<%> set-back] thunks to point to its neighbor in
|
||||
the argument list.}
|
||||
|
@ -86,13 +86,13 @@ the argument list.}
|
|||
|
||||
@defmixin[grey-editor-snip-mixin (editor-snip%) ()]{
|
||||
|
||||
Gives an @scheme[editor-snip%] a colored background indicating that
|
||||
Gives an @racket[editor-snip%] a colored background indicating that
|
||||
is disabled. The editor is not disabled by the mixin however, and
|
||||
must be locked separately.}
|
||||
|
||||
@defmixin[grey-editor-mixin (editor<%>) ()]{
|
||||
|
||||
Gives an @scheme[editor<%>] a colored background indicating that is
|
||||
Gives an @racket[editor<%>] a colored background indicating that is
|
||||
disabled. The editor is not disabled by the mixin however, and must be
|
||||
locked separately.}
|
||||
|
||||
|
@ -105,8 +105,8 @@ the argument list.}
|
|||
|
||||
@defmixin[cue-text-mixin (text%) ()]{
|
||||
|
||||
Gives a @scheme[text%] an instantiation argument of a string that is
|
||||
displayed in the @scheme[text%] initially in grey; the text
|
||||
Gives a @racket[text%] an instantiation argument of a string that is
|
||||
displayed in the @racket[text%] initially in grey; the text
|
||||
disappears when the text gets focus. This technique is useful for
|
||||
labeling texts without needing to take up space.}
|
||||
|
||||
|
|
|
@ -8,4 +8,4 @@ A static text label.
|
|||
@defconstructor[([parent (is-a?/c alignment-parent<%>)]
|
||||
[label string?])]{
|
||||
|
||||
Creates a static control that displays @scheme[label].}}
|
||||
Creates a static control that displays @racket[label].}}
|
||||
|
|
|
@ -8,6 +8,6 @@ A button with a text label.
|
|||
@defconstructor[([label string?]
|
||||
[callback ((is-a?/c text-button-snip%) (is-a?/c event%) . -> . void?)])]{
|
||||
|
||||
The @scheme[callback] is called when the button is clicked.}
|
||||
The @racket[callback] is called when the button is clicked.}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@defclass/title[embedded-toggle-button% snip-wrapper% (alignment<%>)]{
|
||||
|
||||
A @scheme[check-box%]-like control that a user can toggle between
|
||||
A @racket[check-box%]-like control that a user can toggle between
|
||||
checked and unchecked states.
|
||||
|
||||
@defconstructor[([images-off (cons/c path-string? path-string?)]
|
||||
|
@ -12,17 +12,17 @@ checked and unchecked states.
|
|||
[turn-off ((is-a?/c toggle-button-snip%) (is-a?/c event%) . -> . void?)]
|
||||
[state (symbols 'on 'off) 'on])]{
|
||||
|
||||
The @scheme[images-off] argument is a pair filenames to be load as the
|
||||
The @racket[images-off] argument is a pair filenames to be load as the
|
||||
button-label image, where the first is the image for when the button
|
||||
is at rest, and the second is the image for the button while its
|
||||
pressed---in both cases when the button is not checked by the
|
||||
user. The @scheme[images-on] argument similarly determines the images
|
||||
user. The @racket[images-on] argument similarly determines the images
|
||||
for then the button is checked.
|
||||
|
||||
The @scheme[turn-on] and @scheme[turn-off] callbacks are invoked when
|
||||
The @racket[turn-on] and @racket[turn-off] callbacks are invoked when
|
||||
the button changes to checked or unchecked, respectively.
|
||||
|
||||
The @scheme[state] argument determines whether the button is initially
|
||||
The @racket[state] argument determines whether the button is initially
|
||||
checked.}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
[after (or/c (is-a?/c alignment<%>) false/c) #f])]{
|
||||
|
||||
Inserts a new horizontal-alignment container into
|
||||
@scheme[parent]---optionally after a given container also in
|
||||
@scheme[parent]. The new container can be initially shown or hidden.}}
|
||||
@racket[parent]---optionally after a given container also in
|
||||
@racket[parent]. The new container can be initially shown or hidden.}}
|
||||
|
|
|
@ -28,8 +28,8 @@ The pasteboard that contains the snip.}
|
|||
[snip (is-a?/c snip%)])
|
||||
any/c]{
|
||||
|
||||
Applies @scheme[f] to all snips in the parent of @scheme[snip],
|
||||
starting with @scheme[snip].}
|
||||
Applies @racket[f] to all snips in the parent of @racket[snip],
|
||||
starting with @racket[snip].}
|
||||
|
||||
@defproc[(for-each-snip [f ((is-a?/c snip%) . -> . any/c)]
|
||||
[first-snip (is-a?/c snip%)]
|
||||
|
@ -37,9 +37,9 @@ starting with @scheme[snip].}
|
|||
void?]{
|
||||
|
||||
Applies the function to each snip in the parent of
|
||||
@scheme[first-snip], starting with @scheme[first-snip]. If
|
||||
@scheme[more] lists are supplied, they are used for extra arguments to
|
||||
@scheme[f], just like extra lists provided to @scheme[for-each].}
|
||||
@racket[first-snip], starting with @racket[first-snip]. If
|
||||
@racket[more] lists are supplied, they are used for extra arguments to
|
||||
@racket[f], just like extra lists provided to @racket[for-each].}
|
||||
|
||||
@defproc[(map-snip [f ((is-a?/c snip%) . -> . any/c)]
|
||||
[first-snip (is-a?/c snip%)]
|
||||
|
@ -47,10 +47,10 @@ Applies the function to each snip in the parent of
|
|||
void?]{
|
||||
|
||||
Applies the function to each snip in the parent of
|
||||
@scheme[first-snip], starting with @scheme[first-snip], and
|
||||
accumulates the results into a list. If @scheme[more] lists are
|
||||
supplied, they are used for extra arguments to @scheme[f], just like
|
||||
extra lists provided to @scheme[map].}
|
||||
@racket[first-snip], starting with @racket[first-snip], and
|
||||
accumulates the results into a list. If @racket[more] lists are
|
||||
supplied, they are used for extra arguments to @racket[f], just like
|
||||
extra lists provided to @racket[map].}
|
||||
|
||||
|
||||
@defproc[(stretchable-width? [snip (is-a?/c snip%)]) boolean?]{
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
@defclass/title[snip-wrapper% dllist<%> (alignment<%>)]{
|
||||
|
||||
Adapts an arbitrary @scheme[snip<%>] to work in an alignment
|
||||
Adapts an arbitrary @racket[snip<%>] to work in an alignment
|
||||
container.
|
||||
|
||||
@defconstructor[([parent (is-a?/c alignment-parent<%>)]
|
||||
[snip (is-a?/c snip%)])]{
|
||||
|
||||
Adds @scheme[snip] to @scheme[parent].}}
|
||||
Adds @racket[snip] to @racket[parent].}}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
@definterface/title[stretchable-snip<%> ()]{
|
||||
|
||||
Must be implemented by any snip class whose objects will be
|
||||
stretchable when inserted into an @scheme[aligned-pasteboard<%>]
|
||||
within a @scheme[snip-wrapper%].
|
||||
stretchable when inserted into an @racket[aligned-pasteboard<%>]
|
||||
within a @racket[snip-wrapper%].
|
||||
|
||||
@defmethod[(get-aligned-min-width) (and/c real? (not/c negative?))]{
|
||||
|
||||
|
|
|
@ -8,6 +8,6 @@ A button with a text label.
|
|||
@defconstructor[([label string?]
|
||||
[callback ((is-a?/c text-button-snip%) (is-a?/c event%) . -> . void)])]{
|
||||
|
||||
The @scheme[callback] is called when the button is clicked.}
|
||||
The @racket[callback] is called when the button is clicked.}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@defclass/title[toggle-button-snip% snip% ()]{
|
||||
|
||||
A @scheme[check-box%]-like control that a user can toggle between
|
||||
A @racket[check-box%]-like control that a user can toggle between
|
||||
checked and unchecked states.
|
||||
|
||||
@defconstructor[([images-off (cons/c path-string? path-string?)]
|
||||
|
@ -12,17 +12,17 @@ checked and unchecked states.
|
|||
[turn-off ((is-a?/c toggle-button-snip%) (is-a?/c event%) . -> . void?)]
|
||||
[state (symbols 'on 'off) 'on])]{
|
||||
|
||||
The @scheme[images-off] argument is a pair filenames to be load as the
|
||||
The @racket[images-off] argument is a pair filenames to be load as the
|
||||
button-label image, where the first is the image for when the button
|
||||
is at rest, and the second is the image for the button while its
|
||||
pressed---in both cases when the button is not checked by the
|
||||
user. The @scheme[images-on] argument similarly determines the images
|
||||
user. The @racket[images-on] argument similarly determines the images
|
||||
for then the button is checked.
|
||||
|
||||
The @scheme[turn-on] and @scheme[turn-off] callbacks are invoked when
|
||||
The @racket[turn-on] and @racket[turn-off] callbacks are invoked when
|
||||
the button changes to checked or unchecked, respectively.
|
||||
|
||||
The @scheme[state] argument determines whether the button is initially
|
||||
The @racket[state] argument determines whether the button is initially
|
||||
checked.}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
[after (or/c (is-a?/c alignment<%>) false/c) #f])]{
|
||||
|
||||
Inserts a new vertical-alignment container into
|
||||
@scheme[parent]---optionally after a given container also in
|
||||
@scheme[parent]. The new container can be initially shown or hidden.}}
|
||||
@racket[parent]---optionally after a given container also in
|
||||
@racket[parent]. The new container can be initially shown or hidden.}}
|
||||
|
|
|
@ -37,14 +37,14 @@
|
|||
|
||||
The @italic{Essentials of Programming Languages} language in DrRacket
|
||||
provides a subset of functions and syntactic forms of
|
||||
@schememodname[mzscheme]---mostly the ones that correspond to
|
||||
@scheme[r5rs] forms. See below for a complete list. The
|
||||
@racketmodname[mzscheme]---mostly the ones that correspond to
|
||||
@racket[r5rs] forms. See below for a complete list. The
|
||||
language is intended for use with the textbook @cite["EoPL"].
|
||||
|
||||
@defmodulelang[eopl #:use-sources (eopl/eopl)]
|
||||
|
||||
The following bindings are re-@scheme[provide]d from
|
||||
@schememodname[mzscheme]:
|
||||
The following bindings are re-@racket[provide]d from
|
||||
@racketmodname[mzscheme]:
|
||||
|
||||
@reprovide[
|
||||
make-parameter
|
||||
|
@ -111,22 +111,22 @@ The following bindings are re-@scheme[provide]d from
|
|||
(variant-id (field-id predicate-expr) ...)
|
||||
...)]{
|
||||
|
||||
Defines the datatype @scheme[id] and a function
|
||||
@scheme[predicate-id] that returns @scheme[#t] for instances of the
|
||||
datatype, and @scheme[#f] for any other value.
|
||||
Defines the datatype @racket[id] and a function
|
||||
@racket[predicate-id] that returns @racket[#t] for instances of the
|
||||
datatype, and @racket[#f] for any other value.
|
||||
|
||||
Each @scheme[variant-id] is defined as a constructor function that
|
||||
Each @racket[variant-id] is defined as a constructor function that
|
||||
creates an instance of the datatype; the constructor takes as many
|
||||
arguments as the variant's @scheme[field-id]s, and each argument is
|
||||
arguments as the variant's @racket[field-id]s, and each argument is
|
||||
checked by applying the function produced by the variant's
|
||||
@scheme[predicate-expr].
|
||||
@racket[predicate-expr].
|
||||
|
||||
In DrScheme v209 and older, when constructor-based printing was
|
||||
used, variant instances were printed with a @scheme[make-] prefix
|
||||
used, variant instances were printed with a @racket[make-] prefix
|
||||
before the variant name. Thus, for compatibility, in addition to
|
||||
@scheme[variant-id], @scheme[make-variant-id] is also defined for
|
||||
each @scheme[variant-id] (to the same constructor as
|
||||
@scheme[variant-id]).}
|
||||
@racket[variant-id], @racket[make-variant-id] is also defined for
|
||||
each @racket[variant-id] (to the same constructor as
|
||||
@racket[variant-id]).}
|
||||
|
||||
@defform*[#:literals (else)
|
||||
[(cases datatype-id expr
|
||||
|
@ -137,9 +137,9 @@ The following bindings are re-@scheme[provide]d from
|
|||
...
|
||||
(else result-expr ...))]]{
|
||||
|
||||
Branches on the datatype instance produced by @scheme[expr], which
|
||||
must be an instance of the specified @scheme[datatype-id] that is
|
||||
defined with @scheme[define-datatype].}
|
||||
Branches on the datatype instance produced by @racket[expr], which
|
||||
must be an instance of the specified @racket[datatype-id] that is
|
||||
defined with @racket[define-datatype].}
|
||||
|
||||
@deftogether[(
|
||||
@defidform[sllgen:make-string-scanner]
|
||||
|
@ -167,7 +167,7 @@ The following bindings are re-@scheme[provide]d from
|
|||
@defproc[(eopl:printf (form string?) (v any/c) ...) void?]
|
||||
@defproc[(eopl:pretty-print (v any/c) (port output-port? (current-output-port))) void?])]{
|
||||
|
||||
Same as @schememodname[scheme/base]'s @scheme[printf] and @scheme[pretty-print].}
|
||||
Same as @racketmodname[scheme/base]'s @racket[printf] and @racket[pretty-print].}
|
||||
|
||||
@deftogether[(
|
||||
@defproc[((list-of (pred (any/c . -> . any)) ...+) (x any/c)) boolean?]
|
||||
|
@ -182,7 +182,7 @@ The following bindings are re-@scheme[provide]d from
|
|||
|
||||
@defform[(time expr)]{
|
||||
|
||||
Evaluates @scheme[expr], and prints timing information before returning the
|
||||
Evaluates @racket[expr], and prints timing information before returning the
|
||||
result.}
|
||||
|
||||
@defproc[(collect-garbage) void?]{
|
||||
|
@ -193,19 +193,19 @@ The following bindings are re-@scheme[provide]d from
|
|||
@defform[(trace id ...)]
|
||||
@defform[(untrace id ...)])]{
|
||||
|
||||
For debugging: @scheme[trace] redefines each @scheme[id] at the top
|
||||
For debugging: @racket[trace] redefines each @racket[id] at the top
|
||||
level (bound to a procedure) so that it prints arguments on entry
|
||||
and results on exit. The @scheme[untrace] form reverses the action
|
||||
of @scheme[trace] for the given @scheme[id]s.
|
||||
and results on exit. The @racket[untrace] form reverses the action
|
||||
of @racket[trace] for the given @racket[id]s.
|
||||
|
||||
Tracing a function causes tail-calls in the original function to
|
||||
become non-tail calls.}
|
||||
|
||||
@defform[(provide provide-spec ...)]{
|
||||
|
||||
Useful only with a module that uses @schememodname[eopl] as a
|
||||
Useful only with a module that uses @racketmodname[eopl] as a
|
||||
language: exports identifiers from the module. See @mzscheme-provide
|
||||
from @schememodname[mzscheme] for more information.}
|
||||
from @racketmodname[mzscheme] for more information.}
|
||||
|
||||
@defthing[eopl:error-stop (-> any/c)]{
|
||||
|
||||
|
@ -213,15 +213,15 @@ The following bindings are re-@scheme[provide]d from
|
|||
mutate this variable to install an exception-handling
|
||||
thunk. Typically, the handler thunk escapes through a continuation.
|
||||
|
||||
The @schememodname[eopl] library sets this variable to
|
||||
@scheme[#f] in the current namespace when it executes.}
|
||||
The @racketmodname[eopl] library sets this variable to
|
||||
@racket[#f] in the current namespace when it executes.}
|
||||
|
||||
@defproc[(install-eopl-exception-handler) void?]{
|
||||
|
||||
Sets an exception handler to one that checks
|
||||
@scheme[eopl:error-stop].
|
||||
@racket[eopl:error-stop].
|
||||
|
||||
The @schememodname[eopl] library calls this function when it
|
||||
The @racketmodname[eopl] library calls this function when it
|
||||
executes.}
|
||||
|
||||
@(bibliography
|
||||
|
|
|
@ -28,12 +28,12 @@ Then,
|
|||
|
||||
@itemize[
|
||||
@item{If your program has a module file @nonterm{prog}, run it with
|
||||
|
||||
|
||||
@commandline{racket -l errortrace -t @nonterm{prog}}}
|
||||
|
||||
@item{If you program is a non-module top-level sequence of
|
||||
definitions and expressions, you can instead add
|
||||
@schemeblock[(require errortrace)]
|
||||
@racketblock[(require errortrace)]
|
||||
to the beginning of the program or start Racket with the @Flag{l} option before the
|
||||
arguments to load your program:
|
||||
@commandline{racket -l errortrace ...}}
|
||||
|
@ -44,17 +44,17 @@ Then,
|
|||
@commandline{racket -i -l errortrace}}
|
||||
]
|
||||
|
||||
After starting @schememodname[errortrace] in one of these ways, when an
|
||||
After starting @racketmodname[errortrace] in one of these ways, when an
|
||||
exception occurs, the exception handler something like a stack trace
|
||||
with most recent contexts first.
|
||||
|
||||
The @schememodname[errortrace] module is strange: Don't import it
|
||||
into another module. Instead, the @schememodname[errortrace]
|
||||
The @racketmodname[errortrace] module is strange: Don't import it
|
||||
into another module. Instead, the @racketmodname[errortrace]
|
||||
module is meant to be invoked from the top-level, so that it can install
|
||||
an evaluation handler, exception handler, etc.
|
||||
|
||||
To reuse parts of the code of @schememodname[errortrace], import
|
||||
@schememodname[errortrace/errortrace-lib]. That library contains all
|
||||
To reuse parts of the code of @racketmodname[errortrace], import
|
||||
@racketmodname[errortrace/errortrace-lib]. That library contains all
|
||||
of the bindings described here, but does not set the compilation
|
||||
handler or the error display handler.
|
||||
|
||||
|
@ -63,21 +63,21 @@ handler or the error display handler.
|
|||
@section[#:tag "installing-errortrace"]{Installing Errortrace}
|
||||
|
||||
Invoking the
|
||||
@schememodname[errortrace] module sets the compilation
|
||||
@racketmodname[errortrace] module sets the compilation
|
||||
handler to instrument Racket source code. It also sets the error
|
||||
display handler to report source information for an exception, and it
|
||||
sets the @scheme[use-compiled-file-paths] parameter to trigger the use
|
||||
sets the @racket[use-compiled-file-paths] parameter to trigger the use
|
||||
of Errortrace-specific @filepath{.zo} files.
|
||||
|
||||
NOTE: @schememodname[errortrace] has no effect on code
|
||||
NOTE: @racketmodname[errortrace] has no effect on code
|
||||
loaded as compiled byte code (i.e., from a @filepath{.zo} file) or
|
||||
native code (i.e., from a @filepath{.dll}, @filepath{.so} or
|
||||
@filepath{.dylib} file). You can use the @DFlag{mode errortrace} flag
|
||||
to @exec{setup-plt} to create @filepath{.zo} files with
|
||||
Errortrace information.
|
||||
|
||||
Explicitly requiring @schememodname[errortrace] within a module is
|
||||
generally a bad idea, since @schememodname[errortrace] sets various
|
||||
Explicitly requiring @racketmodname[errortrace] within a module is
|
||||
generally a bad idea, since @racketmodname[errortrace] sets various
|
||||
parameters.
|
||||
|
||||
@; ---------------------------------------------
|
||||
|
@ -86,24 +86,24 @@ parameters.
|
|||
@defmodule[errortrace #:use-sources (errortrace/errortrace-lib)]
|
||||
|
||||
See @secref["quick-instructions"] for information on starting with
|
||||
@schememodname[errortrace]. This chapter provides information on the
|
||||
configuration of @schememodname[errortrace] after it is loaded and
|
||||
@racketmodname[errortrace]. This chapter provides information on the
|
||||
configuration of @racketmodname[errortrace] after it is loaded and
|
||||
installed.
|
||||
|
||||
Don't import @schememodname[errortrace] into another module and expect
|
||||
it to work on that module. Instead, the @schememodname[errortrace]
|
||||
Don't import @racketmodname[errortrace] into another module and expect
|
||||
it to work on that module. Instead, the @racketmodname[errortrace]
|
||||
module is meant to be invoked from the top-level (as described in
|
||||
@secref["quick-instructions"]) so it can install handlers. The
|
||||
functions documented in this chapter then can be used at the
|
||||
top-level. The functions also can be accessed by importing
|
||||
@schememodname[errortrace/errortrace-lib], which does not install any
|
||||
@racketmodname[errortrace/errortrace-lib], which does not install any
|
||||
handlers.
|
||||
|
||||
As a language name, @schememodname[errortrace] chains to another
|
||||
language that is specified immediately after @schememodname[at-exp],
|
||||
As a language name, @racketmodname[errortrace] chains to another
|
||||
language that is specified immediately after @racketmodname[at-exp],
|
||||
but instruments the module for debugging in the same way as if
|
||||
@schememodname[errortrace] is required before loading the module from
|
||||
source. Using the @schememodname[errortrace] meta-language is one way
|
||||
@racketmodname[errortrace] is required before loading the module from
|
||||
source. Using the @racketmodname[errortrace] meta-language is one way
|
||||
to ensure that debugging instrumentation is present when the module is
|
||||
compiled.}
|
||||
|
||||
|
@ -111,32 +111,32 @@ compiled.}
|
|||
|
||||
@subsection[#:tag "instrumentation-and-profiling"]{Instrumentation and Profiling}
|
||||
|
||||
By default, @schememodname[errortrace] only instruments for
|
||||
By default, @racketmodname[errortrace] only instruments for
|
||||
stack-trace-on-exception. Profiling and coverage need to be enabled
|
||||
separately.
|
||||
|
||||
@defboolparam[instrumenting-enabled on?]{
|
||||
|
||||
A parameter that determines whether tracing instrumentation is
|
||||
enabled, @scheme[#t] by default. Affects only the way that source code is
|
||||
enabled, @racket[#t] by default. Affects only the way that source code is
|
||||
compiled, not the way that exception information is reported. The
|
||||
instrumentation for storing exception information slows most programs
|
||||
by a factor of 2 or 3.}
|
||||
|
||||
@defboolparam[profiling-enabled on?]{
|
||||
|
||||
Errortrace's profiling instrumentation is @scheme[#f] by default. To use it,
|
||||
you also need to ensure that @scheme[instrumenting-enabled] is on.
|
||||
Errortrace's profiling instrumentation is @racket[#f] by default. To use it,
|
||||
you also need to ensure that @racket[instrumenting-enabled] is on.
|
||||
|
||||
Also, profiling only records information about the time taken on the thread
|
||||
that compiled the code (more precisely, the thread that instruments the code via
|
||||
the @scheme[errortrace-compile-handler]).
|
||||
the @racket[errortrace-compile-handler]).
|
||||
}
|
||||
|
||||
@defboolparam[profiling-record-enabled on?]{
|
||||
|
||||
Enables/disables the recording of profiling info for the instrumented code.
|
||||
The default is @scheme[#t].
|
||||
The default is @racket[#t].
|
||||
|
||||
Profiling information is accumulated in a hash table. If a procedure
|
||||
is redefined, new profiling information is accumulated for the new
|
||||
|
@ -148,15 +148,15 @@ exception-information instrumentation.
|
|||
}
|
||||
|
||||
@defproc[(output-profile-results [paths? any/c] [sort-time? any/c]) void?]{
|
||||
|
||||
Gets the current profile results using @scheme[get-profile-results] and
|
||||
|
||||
Gets the current profile results using @racket[get-profile-results] and
|
||||
displays them. It optionally shows paths information (if it is recorded),
|
||||
and sorts by either time or call counts.}
|
||||
|
||||
@defproc[(get-profile-results [thd thread? (current-thread)]) list?]{
|
||||
|
||||
Returns a list of lists that contain all profiling information accumulated
|
||||
so far (for the thread @scheme[thd]):
|
||||
so far (for the thread @racket[thd]):
|
||||
|
||||
@itemize[
|
||||
@item{the number of times a procedure was called.}
|
||||
|
@ -166,23 +166,23 @@ so far (for the thread @scheme[thd]):
|
|||
within the procedure, but not including time consumed by a
|
||||
tail-call from the procedure).}
|
||||
|
||||
@item{an inferred name (or @scheme[#f]) for the procedure.}
|
||||
@item{an inferred name (or @racket[#f]) for the procedure.}
|
||||
|
||||
@item{the procedure's source in the form of a syntax object (which might,
|
||||
in turn, provide a source location file and position).}
|
||||
|
||||
@item{optionally, a list of unique call paths (i.e. stack traces)
|
||||
recorded if @scheme[profile-paths-enabled] is set to @scheme[#t].
|
||||
recorded if @racket[profile-paths-enabled] is set to @racket[#t].
|
||||
Each call path is a pair of
|
||||
@itemize[
|
||||
@item{a count (the number of times the path occurred), and}
|
||||
|
||||
|
||||
@item{a list containing two-element lists. Each two-element list
|
||||
contains
|
||||
@itemize[
|
||||
@item{the calling procedure's name or source expression,
|
||||
and}
|
||||
@item{the calling procedure's source file or @scheme[#f].}]
|
||||
@item{the calling procedure's source file or @racket[#f].}]
|
||||
}
|
||||
]
|
||||
Collecting this information is relatively expensive.}
|
||||
|
@ -191,7 +191,7 @@ so far (for the thread @scheme[thd]):
|
|||
@defboolparam[profile-paths-enabled on?]{
|
||||
|
||||
Enables/disables collecting path information for profiling. The default is
|
||||
@scheme[#f], but setting the parameter to @scheme[#t] immediately affects
|
||||
@racket[#f], but setting the parameter to @racket[#t] immediately affects
|
||||
all procedures instrumented for profiling information.}
|
||||
|
||||
@defproc[(clear-profile-results) void?]{
|
||||
|
@ -211,13 +211,13 @@ annotations that the profiler uses, so only function bodies are
|
|||
counted. To see the difference between the two approaches, try this
|
||||
program:
|
||||
|
||||
@schemeblock[(define (foo x) (if x 1 2))
|
||||
@racketblock[(define (foo x) (if x 1 2))
|
||||
(equal? (foo #t) 1)]
|
||||
|
||||
The first approach will produce exact results, but it is more
|
||||
expensive; use it when you want to know how covered your code is (when
|
||||
the expected counts are small). The second approach produces coarser
|
||||
results (which, in the above case, will miss the @scheme[2] expression),
|
||||
results (which, in the above case, will miss the @racket[2] expression),
|
||||
but is less expensive; use it when you want to use the counts for
|
||||
profiling (when the expected counts are large).
|
||||
|
||||
|
@ -227,19 +227,19 @@ profiling (when the expected counts are large).
|
|||
|
||||
Parameters that determine if the first (exact coverage) or second
|
||||
(profiler-based coverage) are enabled. Remember that setting
|
||||
@scheme[instrumenting-enabled] to @scheme[#f] also disables both.}
|
||||
@racket[instrumenting-enabled] to @racket[#f] also disables both.}
|
||||
|
||||
@defproc[(get-coverage) (listof (cons/c syntax? boolean?))]{
|
||||
|
||||
Returns a list of pairs, one for each instrumented expression. The
|
||||
first element of the pair is a @scheme[syntax?] object (usually containing
|
||||
first element of the pair is a @racket[syntax?] object (usually containing
|
||||
source location information) for the original expression, and the
|
||||
second element of the pair indicates if the code has been executed.
|
||||
This list is snapshot of the current state of the computation.}
|
||||
|
||||
@defproc[(get-execute-counts) (list (cons/c syntax? number?))])]{
|
||||
Returns a list of pairs, one for each instrumented expression. The
|
||||
first element of the pair is a @scheme[syntax?] object (usually containing
|
||||
first element of the pair is a @racket[syntax?] object (usually containing
|
||||
source location information) for the original expression, and the
|
||||
second element of the pair is the number of times that the
|
||||
expression has been evaluated.
|
||||
|
@ -255,16 +255,16 @@ This list is snapshot of the current state of the computation.}
|
|||
[display-string (or/c string? #t #f) "^.,"])
|
||||
void?])]{
|
||||
|
||||
Writes the named file to the @scheme[current-output-port], inserting an
|
||||
Writes the named file to the @racket[current-output-port], inserting an
|
||||
additional line between each source line to reflect execution counts
|
||||
(as reported by @scheme[get-coverage-counts] or @scheme[get-execute-counts]).
|
||||
The optional @scheme[display-string] is used for the annotation: the first
|
||||
(as reported by @racket[get-coverage-counts] or @racket[get-execute-counts]).
|
||||
The optional @racket[display-string] is used for the annotation: the first
|
||||
character is used for expressions that were visited 0 times, the
|
||||
second character for 1 time, ..., and the last character for
|
||||
expressions that were visited more times. It can also be
|
||||
@scheme[#f] for a minimal display, @scheme["#."], or, in
|
||||
the case of @scheme[annotate-executed-file],
|
||||
@scheme[#t] for a maximal display, @scheme["0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"].
|
||||
@racket[#f] for a minimal display, @racket["#."], or, in
|
||||
the case of @racket[annotate-executed-file],
|
||||
@racket[#t] for a maximal display, @racket["0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"].
|
||||
}
|
||||
|
||||
@defparam[test-coverage-info ht hasheq?]{
|
||||
|
@ -275,17 +275,17 @@ the case of @scheme[annotate-executed-file],
|
|||
|
||||
@subsection[#:tag "other-errortrace-bindings"]{Other Errortrace Bindings}
|
||||
|
||||
The @schememodname[errortrace] module also exports:
|
||||
The @racketmodname[errortrace] module also exports:
|
||||
|
||||
@defproc[(print-error-trace [output-port output-port?] [exn exn?]) void?]{
|
||||
|
||||
The @scheme[print-error-trace] procedure takes a port and exception and
|
||||
The @racket[print-error-trace] procedure takes a port and exception and
|
||||
prints the Errortrace-collected debugging information contained in the
|
||||
exception. It is used by the exception handler installed by
|
||||
Errortrace.}
|
||||
|
||||
@defparam[error-context-display-depth d integer?]{The
|
||||
@scheme[error-context-display-depth] parameter controls how much context
|
||||
@racket[error-context-display-depth] parameter controls how much context
|
||||
Errortrace's exception handler displays. The default value is 10,000.}
|
||||
|
||||
|
||||
|
@ -295,8 +295,8 @@ Errortrace's exception handler displays. The default value is 10,000.}
|
|||
|
||||
@defmodule[errortrace/errortrace-lib]{
|
||||
|
||||
The @schememodname[errortrace/errortrace-lib] module exports all of the
|
||||
exports of @schememodname[errortrace], plus a few more. It does
|
||||
The @racketmodname[errortrace/errortrace-lib] module exports all of the
|
||||
exports of @racketmodname[errortrace], plus a few more. It does
|
||||
not install any handlers.}
|
||||
|
||||
The additional exports are as follows:
|
||||
|
@ -304,29 +304,29 @@ The additional exports are as follows:
|
|||
@defproc[(errortrace-compile-handler (stx any/c) (immediate-eval? any/c))
|
||||
compiled-expression?]{
|
||||
|
||||
Compiles @scheme[stx] using the compilation handler that was active
|
||||
when the @schememodname[errortrace/errortrace-lib] module was
|
||||
Compiles @racket[stx] using the compilation handler that was active
|
||||
when the @racketmodname[errortrace/errortrace-lib] module was
|
||||
executed, but first instruments the code for Errortrace information.
|
||||
The code is instrumented only if
|
||||
@schemeblock[(namespace-module-registry (current-namespace))]
|
||||
@racketblock[(namespace-module-registry (current-namespace))]
|
||||
is the same as when the
|
||||
@schememodname[errortrace/errortrace-lib] module was executed. This
|
||||
@racketmodname[errortrace/errortrace-lib] module was executed. This
|
||||
procedure is suitable for use as a compilation handler via
|
||||
@scheme[current-compile].}
|
||||
@racket[current-compile].}
|
||||
|
||||
@defproc[(make-errortrace-compile-handler)
|
||||
(-> any/c any/c compiled-expression)]{
|
||||
|
||||
Produces a compile handler that is like
|
||||
@scheme[errortrace-compile-handler], except that the code that
|
||||
@racket[errortrace-compile-handler], except that the code that
|
||||
it produces is instrumented if the value of
|
||||
@schemeblock[(namespace-module-registry (current-namespace))]
|
||||
@racketblock[(namespace-module-registry (current-namespace))]
|
||||
is the same as when the original thunk is invoked.
|
||||
|
||||
In addition, when the thunk is invoked, it uses
|
||||
@scheme[namespace-attach-module] to attach the
|
||||
@schememodname[errortrace/errortrace-key] module and the
|
||||
@schememodname['#%kernel] module to the @scheme[current-namespace].
|
||||
@racket[namespace-attach-module] to attach the
|
||||
@racketmodname[errortrace/errortrace-key] module and the
|
||||
@racketmodname['#%kernel] module to the @racket[current-namespace].
|
||||
}
|
||||
|
||||
@defproc[(errortrace-error-display-handler (string string?) (exn exn?)) void?]{
|
||||
|
@ -337,18 +337,18 @@ for use as an error display handler.}
|
|||
@defproc[(errortrace-annotate (stx any/c)) any/c]{
|
||||
|
||||
Macro-expands and instruments the given top-level form. If the form is
|
||||
a module named @schemeidfont{errortrace-key}, no instrumentation is
|
||||
a module named @racketidfont{errortrace-key}, no instrumentation is
|
||||
applied. This annotation function is used by
|
||||
@scheme[errortrace-compile-handler].}
|
||||
@racket[errortrace-compile-handler].}
|
||||
|
||||
@defproc[(annotate-top [stx any/c][phase-level exact-integer?]) any/c]{
|
||||
|
||||
Like @scheme[errortrace-annotate], but given an explicit phase level
|
||||
for @scheme[stx]; @scheme[(namespace-base-phase)] is typically the
|
||||
right value for the @scheme[phase-level] argument.
|
||||
Like @racket[errortrace-annotate], but given an explicit phase level
|
||||
for @racket[stx]; @racket[(namespace-base-phase)] is typically the
|
||||
right value for the @racket[phase-level] argument.
|
||||
|
||||
Unlike @scheme[errortrace-annotate], there no special case for
|
||||
a module named @scheme[errortrace-key]. Also, if @scheme[stx] is a module
|
||||
Unlike @racket[errortrace-annotate], there no special case for
|
||||
a module named @racket[errortrace-key]. Also, if @racket[stx] is a module
|
||||
declaration, it is not enriched with imports to explicitly load
|
||||
Errortrace run-time support.}
|
||||
|
||||
|
@ -356,19 +356,19 @@ Errortrace run-time support.}
|
|||
|
||||
@section[#:tag "stacktrace"]{Re-using Errortrace Stack Tracing}
|
||||
|
||||
@(define-syntax-rule (schemein id) (sigelem stacktrace-imports^ id))
|
||||
@(define-syntax-rule (schemeout id) (sigelem stacktrace^ id))
|
||||
@(define-syntax-rule (racketin id) (sigelem stacktrace-imports^ id))
|
||||
@(define-syntax-rule (racketout id) (sigelem stacktrace^ id))
|
||||
|
||||
@defmodule[errortrace/stacktrace]{
|
||||
The errortrace collection also includes a
|
||||
@schememodname[errortrace/stacktrace] library. It exports
|
||||
the @scheme[stacktrace@] unit, its import signature
|
||||
@scheme[stacktrace-imports^], and its export signature
|
||||
@scheme[stacktrace^].}
|
||||
@racketmodname[errortrace/stacktrace] library. It exports
|
||||
the @racket[stacktrace@] unit, its import signature
|
||||
@racket[stacktrace-imports^], and its export signature
|
||||
@racket[stacktrace^].}
|
||||
|
||||
@defthing[stacktrace@ unit?]{
|
||||
|
||||
Imports @scheme[stacktrace-imports^] and exports @scheme[stacktrace^].}
|
||||
Imports @racket[stacktrace-imports^] and exports @racket[stacktrace^].}
|
||||
|
||||
|
||||
@defsignature[stacktrace^ ()]{
|
||||
|
@ -378,11 +378,11 @@ Imports @scheme[stacktrace-imports^] and exports @scheme[stacktrace^].}
|
|||
@defproc[(annotate-top (stx syntax?) (phase-level exact-integer?)) syntax?])]{
|
||||
|
||||
Annotate expressions with errortrace information. The
|
||||
@schemeout[annotate-top] function should be called with a top-level
|
||||
expression, and @schemeout[annotate] should be called with a nested
|
||||
expression (e.g., by @schemein[initialize-profile-point]). The
|
||||
@scheme[phase-level] argument indicates the phase level of the
|
||||
expression, typically @scheme[(namespace-base-phase)] for a top-level
|
||||
@racketout[annotate-top] function should be called with a top-level
|
||||
expression, and @racketout[annotate] should be called with a nested
|
||||
expression (e.g., by @racketin[initialize-profile-point]). The
|
||||
@racket[phase-level] argument indicates the phase level of the
|
||||
expression, typically @racket[(namespace-base-phase)] for a top-level
|
||||
expression.}
|
||||
|
||||
@deftogether[(
|
||||
|
@ -390,17 +390,17 @@ expression.}
|
|||
@defproc[(st-mark-source (st-mark st-mark?)) syntax?]
|
||||
@defproc[(st-mark-bindings (st-mark st-mark?)) list?])]{
|
||||
|
||||
The @schemeout[st-mark-source] and @schemeout[st-mark-bindings]
|
||||
The @racketout[st-mark-source] and @racketout[st-mark-bindings]
|
||||
functions extract information from a particular kind of value.
|
||||
The value must be created by @schemeout[make-st-mark]
|
||||
(the shape of the value is guaranteed to be writable and not to be @scheme[#f], but otherwise unspecified).
|
||||
The @scheme[make-st-mark] function returns @scheme[#f] when there is
|
||||
The value must be created by @racketout[make-st-mark]
|
||||
(the shape of the value is guaranteed to be writable and not to be @racket[#f], but otherwise unspecified).
|
||||
The @racket[make-st-mark] function returns @racket[#f] when there is
|
||||
no source location information in the syntax object.
|
||||
The @schemeout[st-mark-source] extracts the value originally provided to
|
||||
the expression-maker, and @schemeout[st-mark-bindings] returns local
|
||||
The @racketout[st-mark-source] extracts the value originally provided to
|
||||
the expression-maker, and @racketout[st-mark-bindings] returns local
|
||||
binding information (if available) as a list of two element (syntax?
|
||||
any/c) lists. The @schemeout[st-mark-bindings] function is currently
|
||||
hardwired to return @scheme[null]. }
|
||||
any/c) lists. The @racketout[st-mark-bindings] function is currently
|
||||
hardwired to return @racket[null]. }
|
||||
|
||||
}
|
||||
|
||||
|
@ -408,8 +408,8 @@ hardwired to return @scheme[null]. }
|
|||
|
||||
@defproc[(with-mark (source-stx any/c) (dest-stx any/c)) any/c]{
|
||||
|
||||
Called by @schemeout[annotate] and @schemeout[annotate-top] to wrap
|
||||
expressions with @scheme[with-continuation-mark]. The first argument
|
||||
Called by @racketout[annotate] and @racketout[annotate-top] to wrap
|
||||
expressions with @racket[with-continuation-mark]. The first argument
|
||||
is the source expression and the second argument is the expression to
|
||||
be wrapped.}
|
||||
|
||||
|
@ -418,24 +418,24 @@ be wrapped.}
|
|||
Determines if the test coverage annotation is inserted into the code.
|
||||
This parameter controls how compilation happens---it does not affect the
|
||||
dynamic behavior of the already compiled code. If the parameter is set,
|
||||
code generated by @schemein[test-covered] are inserted into the code (and
|
||||
@schemein[initialize-test-coverage-point] is called during compilation).
|
||||
If not, no calls to @scheme[test-covered] code are inserted.}
|
||||
code generated by @racketin[test-covered] are inserted into the code (and
|
||||
@racketin[initialize-test-coverage-point] is called during compilation).
|
||||
If not, no calls to @racket[test-covered] code are inserted.}
|
||||
|
||||
@defproc[(test-covered (stx any/c)) (or/c syntax? (-> void?) #f)]{
|
||||
This is called during compilation of the program with an expression for
|
||||
each point in the program that was passed to
|
||||
@schemein[initialize-test-coverage-point].
|
||||
@racketin[initialize-test-coverage-point].
|
||||
|
||||
If the result is @scheme[#f], this program point is not instrumented. If
|
||||
If the result is @racket[#f], this program point is not instrumented. If
|
||||
the result is syntax, it is inserted into the code, and if it is a
|
||||
thunk, the thunk is inserted into the code in an application (using the
|
||||
thunk directly, as a 3D value). In either case, the syntax or the thunk
|
||||
should register that the relevant point was covered.
|
||||
|
||||
Note: using a thunk tends to be slow. Current uses in the Racket code
|
||||
will create a mutable pair in @scheme[initialize-test-coverage-point],
|
||||
and @scheme[test-covered] returns syntax that will set its mcar. (This
|
||||
will create a mutable pair in @racket[initialize-test-coverage-point],
|
||||
and @racket[test-covered] returns syntax that will set its mcar. (This
|
||||
makes the resulting overhead about 3 times smaller.)}
|
||||
|
||||
@defproc[(initialize-test-coverage-point (stx any/c)) void?]{
|
||||
|
@ -452,7 +452,7 @@ Only used for profiling paths.}
|
|||
|
||||
Determines if profiling information is currently collected (affects
|
||||
the behavior of compiling the code---does not affect running code).
|
||||
If this always returns @scheme[#f], the other profiling functions are
|
||||
If this always returns @racket[#f], the other profiling functions are
|
||||
never called.}
|
||||
|
||||
@defproc[(initialize-profile-point (key any/c)
|
||||
|
@ -470,8 +470,8 @@ this expression.}
|
|||
|
||||
Called when some profiled code is about to be executed. If the
|
||||
result is a number, it is expected to be the current number of
|
||||
milliseconds. @scheme[key] is unique to this fragment of code---it is
|
||||
the same key passed to @schemein[initialize-profile-point] for this code
|
||||
milliseconds. @racket[key] is unique to this fragment of code---it is
|
||||
the same key passed to @racketin[initialize-profile-point] for this code
|
||||
fragment.}
|
||||
|
||||
@defproc[(register-profile-done (key any/c)
|
||||
|
@ -480,19 +480,19 @@ fragment.}
|
|||
|
||||
This function is called when some profiled code is finished executing.
|
||||
|
||||
Note that @schemein[register-profile-start] and
|
||||
@schemein[register-profile-done] can be called in a nested manner; in
|
||||
this case, the result of @schemein[register-profile-start] should be
|
||||
@scheme[#f].}
|
||||
Note that @racketin[register-profile-start] and
|
||||
@racketin[register-profile-done] can be called in a nested manner; in
|
||||
this case, the result of @racketin[register-profile-start] should be
|
||||
@racket[#f].}
|
||||
|
||||
}
|
||||
|
||||
@section{Errortrace Key}
|
||||
@defmodule[errortrace/errortrace-key]
|
||||
|
||||
This module depends only on @schememodname['#%kernel].
|
||||
This module depends only on @racketmodname['#%kernel].
|
||||
|
||||
@defthing[errortrace-key symbol?]{
|
||||
A key used by errortrace via @scheme[with-continuation-mark] to
|
||||
A key used by errortrace via @racket[with-continuation-mark] to
|
||||
record stack information.
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
@defmodule[file/convertible]
|
||||
|
||||
The @schememodname[file/convertible] library provides a protocol to
|
||||
The @racketmodname[file/convertible] library provides a protocol to
|
||||
mediate between providers of data in different possible formats and
|
||||
consumers of the formats. For example, a datatype that implements
|
||||
@racket[prop:convertible] might be able to convert itself to a GIF or
|
||||
|
@ -19,13 +19,13 @@ should be considered standard:
|
|||
@itemlist[
|
||||
#:style 'compact
|
||||
|
||||
@item{@scheme['text] --- a string for human-readable text}
|
||||
@item{@scheme['gif-bytes] --- a byte string containing a GIF image encoding}
|
||||
@item{@scheme['png-bytes] --- a byte string containing a PNG image encoding}
|
||||
@item{@scheme['ps-bytes] --- a byte string containing a PostScript document}
|
||||
@item{@scheme['eps-bytes] --- a byte string containing an Encapsulated PostScript document}
|
||||
@item{@scheme['pdf-bytes] --- a byte string containing a PDF document}
|
||||
@item{@scheme['pdf-bytes+bounds] --- a list containing a byte string and four numbers;
|
||||
@item{@racket['text] --- a string for human-readable text}
|
||||
@item{@racket['gif-bytes] --- a byte string containing a GIF image encoding}
|
||||
@item{@racket['png-bytes] --- a byte string containing a PNG image encoding}
|
||||
@item{@racket['ps-bytes] --- a byte string containing a PostScript document}
|
||||
@item{@racket['eps-bytes] --- a byte string containing an Encapsulated PostScript document}
|
||||
@item{@racket['pdf-bytes] --- a byte string containing a PDF document}
|
||||
@item{@racket['pdf-bytes+bounds] --- a list containing a byte string and four numbers;
|
||||
the byte string contains a PDF document and the four numbers are sizing information for the PDF document,
|
||||
namely the width, height, ascent and descent in that order}
|
||||
]
|
||||
|
|
|
@ -7,29 +7,29 @@
|
|||
|
||||
@defmodule[file/gif]
|
||||
|
||||
The @schememodname[file/gif] library provides functions for
|
||||
The @racketmodname[file/gif] library provides functions for
|
||||
writing GIF files to a stream, including GIF files with multiple
|
||||
images and controls (such as animated GIFs).
|
||||
|
||||
A GIF stream is created by @scheme[gif-start], and then individual
|
||||
images are written with @scheme[gif-add-image]. Optionally,
|
||||
@scheme[gif-add-control] inserts instructions for rendering the
|
||||
images. The @scheme[gif-end] function ends the GIF stream.
|
||||
A GIF stream is created by @racket[gif-start], and then individual
|
||||
images are written with @racket[gif-add-image]. Optionally,
|
||||
@racket[gif-add-control] inserts instructions for rendering the
|
||||
images. The @racket[gif-end] function ends the GIF stream.
|
||||
|
||||
A GIF stream can be in any one of the following states:
|
||||
|
||||
@itemize[
|
||||
|
||||
@item{@scheme['init] : no images or controls have been added to the
|
||||
@item{@racket['init] : no images or controls have been added to the
|
||||
stream}
|
||||
|
||||
@item{@scheme['image-or-control] : another image or control can be
|
||||
@item{@racket['image-or-control] : another image or control can be
|
||||
written}
|
||||
|
||||
@item{@scheme['image] : another image can be written (but not a
|
||||
@item{@racket['image] : another image can be written (but not a
|
||||
control, since a control was written)}
|
||||
|
||||
@item{@scheme['done] : nothing more can be added}
|
||||
@item{@racket['done] : nothing more can be added}
|
||||
|
||||
]
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@title[#:tag "gunzip"]{@exec{gzip} Decompression}
|
||||
|
||||
@defmodule[file/gunzip]{The @schememodname[file/gunzip] library provides
|
||||
@defmodule[file/gunzip]{The @racketmodname[file/gunzip] library provides
|
||||
utilities to decompress archive files in @exec{gzip} format, or simply
|
||||
to deccompress data using the @exec{pkzip} ``inflate'' method.}
|
||||
|
||||
|
@ -14,36 +14,36 @@ to deccompress data using the @exec{pkzip} ``inflate'' method.}
|
|||
void?]{
|
||||
|
||||
Extracts data that was compressed using the @exec{gzip} utility (or
|
||||
@scheme[gzip] function), writing the uncompressed data directly to a
|
||||
file. The @scheme[file] argument is the name of the file containing
|
||||
@racket[gzip] function), writing the uncompressed data directly to a
|
||||
file. The @racket[file] argument is the name of the file containing
|
||||
compressed data. The default output file name is the original name of
|
||||
the compressed file as stored in @scheme[file]. If a file by this name
|
||||
the compressed file as stored in @racket[file]. If a file by this name
|
||||
exists, it will be overwritten. If no original name is stored in the
|
||||
source file, @scheme["unzipped"] is used as the default output file
|
||||
source file, @racket["unzipped"] is used as the default output file
|
||||
name.
|
||||
|
||||
The @scheme[output-name-filter] procedure is applied to two
|
||||
The @racket[output-name-filter] procedure is applied to two
|
||||
arguments---the default destination file name and a boolean that is
|
||||
@scheme[#t] if this name was read from @scheme[file]---before the
|
||||
@racket[#t] if this name was read from @racket[file]---before the
|
||||
destination file is created. The return value of the file is used as
|
||||
the actual destination file name (to be opened with the
|
||||
@scheme['truncate] flag of @scheme[open-output-file]).
|
||||
@racket['truncate] flag of @racket[open-output-file]).
|
||||
|
||||
If the compressed data turns out to be corrupted, the
|
||||
@scheme[exn:fail] exception is raised.}
|
||||
@racket[exn:fail] exception is raised.}
|
||||
|
||||
|
||||
@defproc[(gunzip-through-ports [in input-port?]
|
||||
[out output-port?])
|
||||
void?]{
|
||||
|
||||
Reads the port @scheme[in] for compressed data that was created using
|
||||
Reads the port @racket[in] for compressed data that was created using
|
||||
the @exec{gzip} utility, writing the uncompressed data to the port
|
||||
@scheme[out].
|
||||
@racket[out].
|
||||
|
||||
If the compressed data turns out to be corrupted, the
|
||||
@scheme[exn:fail] exception is raised. The unzipping process may peek
|
||||
further into @scheme[in] than needed to decompress the data, but it
|
||||
@racket[exn:fail] exception is raised. The unzipping process may peek
|
||||
further into @racket[in] than needed to decompress the data, but it
|
||||
will not consume the unneeded bytes.}
|
||||
|
||||
|
||||
|
@ -51,12 +51,12 @@ will not consume the unneeded bytes.}
|
|||
[out output-port?])
|
||||
void?]{
|
||||
|
||||
Reads @exec{pkzip}-format ``deflated'' data from the port @scheme[in]
|
||||
Reads @exec{pkzip}-format ``deflated'' data from the port @racket[in]
|
||||
and writes the uncompressed (``inflated'') data to the port
|
||||
@scheme[out]. The data in a file created by @exec{gzip} uses this
|
||||
@racket[out]. The data in a file created by @exec{gzip} uses this
|
||||
format (preceded with some header information).
|
||||
|
||||
If the compressed data turns out to be corrupted, the
|
||||
@scheme[exn:fail] exception is raised. The inflate process may peek
|
||||
further into @scheme[in] than needed to decompress the data, but it
|
||||
@racket[exn:fail] exception is raised. The inflate process may peek
|
||||
further into @racket[in] than needed to decompress the data, but it
|
||||
will not consume the unneeded bytes.}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@title[#:tag "gzip"]{@exec{gzip} Compression and File Creation}
|
||||
|
||||
@defmodule[file/gzip]{The @schememodname[file/gzip] library provides
|
||||
@defmodule[file/gzip]{The @racketmodname[file/gzip] library provides
|
||||
utilities to create archive files in @exec{gzip} format, or simply to
|
||||
compress data using the @exec{pkzip} ``deflate'' method.}
|
||||
|
||||
|
@ -12,9 +12,9 @@ compress data using the @exec{pkzip} ``deflate'' method.}
|
|||
void?]{
|
||||
|
||||
Compresses data to the same format as the @exec{gzip} utility, writing
|
||||
the compressed data directly to a file. The @scheme[in-file] argument
|
||||
the compressed data directly to a file. The @racket[in-file] argument
|
||||
is the name of the file to compress. If the file named by
|
||||
@scheme[out-file] exists, it will be overwritten.}
|
||||
@racket[out-file] exists, it will be overwritten.}
|
||||
|
||||
|
||||
@defproc[(gzip-through-ports [in input-port?]
|
||||
|
@ -23,13 +23,13 @@ is the name of the file to compress. If the file named by
|
|||
[timestamp exact-integer?])
|
||||
void?]{
|
||||
|
||||
Reads the port @scheme[in] for data and compresses it to @scheme[out],
|
||||
Reads the port @racket[in] for data and compresses it to @racket[out],
|
||||
outputting the same format as the @exec{gzip} utility. The
|
||||
@scheme[orig-filename] string is embedded in this output;
|
||||
@scheme[orig-filename] can be @scheme[#f] to omit the filename from
|
||||
the compressed stream. The @scheme[timestamp] number is also embedded
|
||||
@racket[orig-filename] string is embedded in this output;
|
||||
@racket[orig-filename] can be @racket[#f] to omit the filename from
|
||||
the compressed stream. The @racket[timestamp] number is also embedded
|
||||
in the output stream, as the modification date of the original file
|
||||
(in Unix seconds, as @scheme[file-or-directory-modify-seconds] would
|
||||
(in Unix seconds, as @racket[file-or-directory-modify-seconds] would
|
||||
report on Unix).}
|
||||
|
||||
|
||||
|
@ -39,11 +39,11 @@ report on Unix).}
|
|||
exact-nonnegative-integer?
|
||||
exact-nonnegative-integer?)]{
|
||||
|
||||
Writes @exec{pkzip}-format ``deflated'' data to the port @scheme[out],
|
||||
compressing data from the port @scheme[in]. The data in a file
|
||||
Writes @exec{pkzip}-format ``deflated'' data to the port @racket[out],
|
||||
compressing data from the port @racket[in]. The data in a file
|
||||
created by @exec{gzip} uses this format (preceded with header
|
||||
information).
|
||||
|
||||
The result is three values: the number of bytes read from @scheme[in],
|
||||
the number of bytes written to @scheme[out], and a cyclic redundancy
|
||||
The result is three values: the number of bytes read from @racket[in],
|
||||
the number of bytes written to @racket[out], and a cyclic redundancy
|
||||
check (CRC) value for the input.}
|
||||
|
|
|
@ -13,10 +13,10 @@ See @racketmodname[openssl/sha1] for a faster implementation.
|
|||
@defproc[(sha1 [in input-port]) string?]{
|
||||
|
||||
Returns a 40-character string that represents the SHA-1 hash (in
|
||||
hexadecimal notation) of the content from @scheme[in], consuming all
|
||||
of the input from @scheme[in] until an end-of-file.
|
||||
hexadecimal notation) of the content from @racket[in], consuming all
|
||||
of the input from @racket[in] until an end-of-file.
|
||||
|
||||
The @scheme[sha1] function composes @scheme[bytes->hex-string] with
|
||||
The @racket[sha1] function composes @racket[bytes->hex-string] with
|
||||
@racket[sha1-bytes].
|
||||
|
||||
@examples[
|
||||
|
@ -27,7 +27,7 @@ The @scheme[sha1] function composes @scheme[bytes->hex-string] with
|
|||
@defproc[(sha1-bytes [in input-port]) bytes?]{
|
||||
|
||||
Returns a 20-byte byte string that represents the SHA-1 hash of the
|
||||
content from @scheme[in], consuming all of the input from @scheme[in]
|
||||
content from @racket[in], consuming all of the input from @racket[in]
|
||||
until an end-of-file.
|
||||
|
||||
@examples[
|
||||
|
@ -38,5 +38,5 @@ until an end-of-file.
|
|||
@defproc[(bytes->hex-string [bstr bytes?]) string?]{
|
||||
|
||||
Converts the given byte string to a string representation, where each
|
||||
byte in @scheme[bstr] is converted to its two-digit hexadecimal
|
||||
byte in @racket[bstr] is converted to its two-digit hexadecimal
|
||||
representation in the resulting string.}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@title[#:tag "tar"]{@exec{tar} File Creation}
|
||||
|
||||
@defmodule[file/tar]{The @schememodname[file/tar] library provides
|
||||
@defmodule[file/tar]{The @racketmodname[file/tar] library provides
|
||||
utilities to create archive files in USTAR format, like the archive
|
||||
that the Unix utility @exec{pax} generates. The USTAR format imposes
|
||||
limits on path lengths. The resulting archives contain only
|
||||
|
@ -14,26 +14,26 @@ is always ``root.''}
|
|||
@defproc[(tar [tar-file path-string?][path path-string?] ...)
|
||||
exact-nonnegative-integer?]{
|
||||
|
||||
Creates @scheme[tar-file], which holds the complete content of all
|
||||
@scheme[path]s. The given @scheme[path]s are all expected to be
|
||||
Creates @racket[tar-file], which holds the complete content of all
|
||||
@racket[path]s. The given @racket[path]s are all expected to be
|
||||
relative path names of existing directories and files (i.e., relative
|
||||
to the current directory). If a nested path is provided as a
|
||||
@scheme[path], its ancestor directories are also added to the
|
||||
@racket[path], its ancestor directories are also added to the
|
||||
resulting tar file, up to the current directory (using
|
||||
@scheme[pathlist-closure]).}
|
||||
@racket[pathlist-closure]).}
|
||||
|
||||
@defproc[(tar->output [paths (listof path?)]
|
||||
[out output-port? (current-output-port)])
|
||||
exact-nonnegative-integer?]{
|
||||
|
||||
Packages each of the given @scheme[paths] in a @exec{tar} format
|
||||
archive that is written directly to the @scheme[out]. The specified
|
||||
@scheme[paths] are included as-is; if a directory is specified, its
|
||||
Packages each of the given @racket[paths] in a @exec{tar} format
|
||||
archive that is written directly to the @racket[out]. The specified
|
||||
@racket[paths] are included as-is; if a directory is specified, its
|
||||
content is not automatically added, and nested directories are added
|
||||
without parent directories.}
|
||||
|
||||
@defproc[(tar-gzip [tar-file path-string?] [paths path-string?] ...)
|
||||
void?]{
|
||||
|
||||
Like @scheme[tar], but compresses the resulting file with @scheme[gzip].
|
||||
Like @racket[tar], but compresses the resulting file with @racket[gzip].
|
||||
}
|
||||
|
|
|
@ -3,24 +3,24 @@
|
|||
|
||||
@title[#:tag "zip"]{@exec{zip} File Creation}
|
||||
|
||||
@defmodule[file/zip]{The @schememodname[file/zip] library provides
|
||||
@defmodule[file/zip]{The @racketmodname[file/zip] library provides
|
||||
utilities to create @exec{zip} archive files, which are compatible
|
||||
with both Windows and Unix (including Mac OS X) unpacking. The actual
|
||||
compression is implemented by @scheme[deflate].}
|
||||
compression is implemented by @racket[deflate].}
|
||||
|
||||
@defproc[(zip [zip-file path-string?][path path-string?] ...)
|
||||
void?]{
|
||||
|
||||
Creates @scheme[zip-file], which holds the complete content of all
|
||||
@scheme[path]s. The given @scheme[path]s are all expected to be
|
||||
Creates @racket[zip-file], which holds the complete content of all
|
||||
@racket[path]s. The given @racket[path]s are all expected to be
|
||||
relative path names of existing directories and files (i.e., relative
|
||||
to the current directory). If a nested path is provided as a
|
||||
@scheme[path], its ancestor directories are also added to the
|
||||
@racket[path], its ancestor directories are also added to the
|
||||
resulting zip file, up to the current directory (using
|
||||
@scheme[pathlist-closure]). Files are packaged as usual for
|
||||
@racket[pathlist-closure]). Files are packaged as usual for
|
||||
@exec{zip} files, including permission bits for both Windows and Unix
|
||||
(including Mac OS X). The permission bits are determined by
|
||||
@scheme[file-or-directory-permissions], which does not preserve the
|
||||
@racket[file-or-directory-permissions], which does not preserve the
|
||||
distinction between owner/group/other permissions. Also, symbolic
|
||||
links are always followed.}
|
||||
|
||||
|
@ -29,16 +29,16 @@ links are always followed.}
|
|||
[out output-port? (current-output-port)])
|
||||
void?]{
|
||||
|
||||
Zips each of the given @scheme[paths], and packages it as a zip
|
||||
``file'' that is written directly to @scheme[out]. Unlike
|
||||
@scheme[zip], the specified @scheme[paths] are included as-is; if a
|
||||
Zips each of the given @racket[paths], and packages it as a zip
|
||||
``file'' that is written directly to @racket[out]. Unlike
|
||||
@racket[zip], the specified @racket[paths] are included as-is; if a
|
||||
directory is specified, its content is not automatically added, and
|
||||
nested directories are added without parent directories.}
|
||||
|
||||
|
||||
@defboolparam[zip-verbose on?]{
|
||||
|
||||
A parameter that controls output during a @scheme[zip]
|
||||
operation. Setting this parameter to a true value causes @scheme[zip]
|
||||
to display to @scheme[(current-error-port)] the filename that is
|
||||
A parameter that controls output during a @racket[zip]
|
||||
operation. Setting this parameter to a true value causes @racket[zip]
|
||||
to display to @racket[(current-error-port)] the filename that is
|
||||
currently being compressed.}
|
||||
|
|
|
@ -39,9 +39,7 @@
|
|||
;; quote-literal-label: string -> string
|
||||
(define (quote-literal-label a-str)
|
||||
(trim-string (regexp-replace* #rx"(&)" a-str "\\1\\1")
|
||||
maximum-string-label-length))
|
||||
|
||||
|
||||
maximum-string-label-length))
|
||||
|
||||
;; selected-text-color : color
|
||||
(define selected-text-color (send the-color-database find-color "black"))
|
||||
|
@ -302,7 +300,7 @@
|
|||
(λ (str)
|
||||
((string-length str) . <= . size)))])
|
||||
@{Constructs a string whose size is less
|
||||
than @scheme[size] by trimming the @scheme[str]
|
||||
than @racket[size] by trimming the @racket[str]
|
||||
and inserting an ellispses into it.})
|
||||
|
||||
(proc-doc
|
||||
|
@ -334,12 +332,12 @@
|
|||
gui-utils:cancel-on-right?
|
||||
(-> boolean?)
|
||||
()
|
||||
@{Returns @scheme[#t] if cancel should be on the right-hand side (or below)
|
||||
in a dialog and @scheme[#f] otherwise.
|
||||
@{Returns @racket[#t] if cancel should be on the right-hand side (or below)
|
||||
in a dialog and @racket[#f] otherwise.
|
||||
|
||||
Just returns what @scheme[system-position-ok-before-cancel?] does.
|
||||
Just returns what @racket[system-position-ok-before-cancel?] does.
|
||||
|
||||
See also @scheme[gui-utils:ok/cancel-buttons].})
|
||||
See also @racket[gui-utils:ok/cancel-buttons].})
|
||||
(proc-doc/names
|
||||
gui-utils:ok/cancel-buttons
|
||||
(->* ((is-a?/c area-container<%>)
|
||||
|
@ -365,12 +363,12 @@
|
|||
The first result is be the OK button and the second is
|
||||
the cancel button.
|
||||
|
||||
By default, the confirmation action button has the @scheme['(border)] style,
|
||||
By default, the confirmation action button has the @racket['(border)] style,
|
||||
meaning that hitting return in the dialog will trigger the confirmation action.
|
||||
The @racket[confirm-style] argument can override this behavior, tho.
|
||||
See @racket[button%] for the precise list of allowed styles.
|
||||
|
||||
See also @scheme[gui-utils:cancel-on-right?].})
|
||||
See also @racket[gui-utils:cancel-on-right?].})
|
||||
|
||||
(proc-doc/names
|
||||
gui-utils:next-untitled-name
|
||||
|
@ -390,13 +388,13 @@
|
|||
|
||||
The first case in the case lambda
|
||||
returns the current delay in seconds before a watch cursor is shown,
|
||||
when either @scheme[gui-utils:local-busy-cursor] or
|
||||
@scheme[gui-utils:show-busy-cursor] is called.
|
||||
when either @racket[gui-utils:local-busy-cursor] or
|
||||
@racket[gui-utils:show-busy-cursor] is called.
|
||||
|
||||
The second case in the case lambda
|
||||
Sets the delay, in seconds, before a watch cursor is shown, when
|
||||
either @scheme[gui-utils:local-busy-cursor] or
|
||||
@scheme[gui-utils:show-busy-cursor] is called.})
|
||||
either @racket[gui-utils:local-busy-cursor] or
|
||||
@racket[gui-utils:show-busy-cursor] is called.})
|
||||
(proc-doc/names
|
||||
gui-utils:show-busy-cursor
|
||||
(->* ((-> any/c))
|
||||
|
@ -404,12 +402,12 @@
|
|||
any/c)
|
||||
((thunk)
|
||||
((delay (gui-utils:cursor-delay))))
|
||||
@{Evaluates @scheme[(thunk)] with a watch cursor. The argument
|
||||
@scheme[delay] specifies the amount of time before the watch cursor is
|
||||
opened. Use @scheme[gui-utils:cursor-delay] to set this value
|
||||
@{Evaluates @racket[(thunk)] with a watch cursor. The argument
|
||||
@racket[delay] specifies the amount of time before the watch cursor is
|
||||
opened. Use @racket[gui-utils:cursor-delay] to set this value
|
||||
to all calls.
|
||||
|
||||
This function returns the result of @scheme[thunk].})
|
||||
This function returns the result of @racket[thunk].})
|
||||
(proc-doc/names
|
||||
gui-utils:delay-action
|
||||
(real?
|
||||
|
@ -424,7 +422,7 @@
|
|||
to appear after 2 seconds and the action may or may not take more than
|
||||
two seconds, use this pattern:
|
||||
|
||||
@schemeblock[(let ([close-down
|
||||
@racketblock[(let ([close-down
|
||||
(gui-utils:delay-action
|
||||
2
|
||||
(λ () .. init watch cursor ...)
|
||||
|
@ -432,11 +430,11 @@
|
|||
;; .. do action ...
|
||||
(close-down))]
|
||||
|
||||
Creates a thread that waits @scheme[delay-time]. After @scheme[delay-time]
|
||||
Creates a thread that waits @racket[delay-time]. After @racket[delay-time]
|
||||
has elapsed, if the result thunk has @italic{not} been called, call
|
||||
@scheme[open]. Then, when the result thunk is called, call
|
||||
@scheme[close]. The function @scheme[close] will only be called if
|
||||
@scheme[open] has been called.})
|
||||
@racket[open]. Then, when the result thunk is called, call
|
||||
@racket[close]. The function @racket[close] will only be called if
|
||||
@racket[open] has been called.})
|
||||
|
||||
(proc-doc/names
|
||||
gui-utils:local-busy-cursor
|
||||
|
@ -447,13 +445,13 @@
|
|||
any/c)
|
||||
((window thunk)
|
||||
((delay (gui-utils:cursor-delay))))
|
||||
@{Evaluates @scheme[(thunk)] with a watch cursor in @scheme[window]. If
|
||||
@scheme[window] is @scheme[#f], the watch cursor is turned on globally.
|
||||
The argument @scheme[delay] specifies the amount of time before the watch
|
||||
cursor is opened. Use @scheme[gui-utils:cursor-delay]
|
||||
@{Evaluates @racket[(thunk)] with a watch cursor in @racket[window]. If
|
||||
@racket[window] is @racket[#f], the watch cursor is turned on globally.
|
||||
The argument @racket[delay] specifies the amount of time before the watch
|
||||
cursor is opened. Use @racket[gui-utils:cursor-delay]
|
||||
to set this value for all uses of this function.
|
||||
|
||||
The result of this function is the result of @scheme[thunk].})
|
||||
The result of this function is the result of @racket[thunk].})
|
||||
|
||||
(proc-doc/names
|
||||
gui-utils:unsaved-warning
|
||||
|
@ -473,17 +471,17 @@
|
|||
|
||||
@{This displays a dialog that warns the user of a unsaved file.
|
||||
|
||||
The string, @scheme[action], indicates what action is about to
|
||||
The string, @racket[action], indicates what action is about to
|
||||
take place, without saving. For example, if the application
|
||||
is about to close a file, a good action is @scheme["Close" "Anyway"].
|
||||
is about to close a file, a good action is @racket["Close" "Anyway"].
|
||||
The result symbol indicates the user's choice. If
|
||||
@scheme[can-save-now?] is @scheme[#f], this function does not
|
||||
@racket[can-save-now?] is @racket[#f], this function does not
|
||||
give the user the ``Save'' option and thus will not return
|
||||
@scheme['save].
|
||||
@racket['save].
|
||||
|
||||
If @scheme[cancel?] is @scheme[#t] there is a cancel button
|
||||
in the dialog and the result may be @scheme['cancel]. If it
|
||||
is @scheme[#f], then there is no cancel button, and @scheme['cancel]
|
||||
If @racket[cancel?] is @racket[#t] there is a cancel button
|
||||
in the dialog and the result may be @racket['cancel]. If it
|
||||
is @racket[#f], then there is no cancel button, and @racket['cancel]
|
||||
will not be the result of the function.
|
||||
|
||||
})
|
||||
|
@ -514,30 +512,30 @@
|
|||
dialog opens a message box asking the user to actually choose one of the
|
||||
two options.
|
||||
|
||||
The dialog will contain the string @scheme[message] and two buttons,
|
||||
labeled with the @scheme[true-choice] and the @scheme[false-choice]. If the
|
||||
user clicks on @scheme[true-choice] @scheme[#t] is returned. If the user
|
||||
clicks on @scheme[false-choice], @scheme[#f] is returned.
|
||||
The dialog will contain the string @racket[message] and two buttons,
|
||||
labeled with the @racket[true-choice] and the @racket[false-choice]. If the
|
||||
user clicks on @racket[true-choice] @racket[#t] is returned. If the user
|
||||
clicks on @racket[false-choice], @racket[#f] is returned.
|
||||
|
||||
The argument @scheme[default-result] determines how closing the window is
|
||||
treated. If the argument is @scheme['disallow-close], closing the window
|
||||
The argument @racket[default-result] determines how closing the window is
|
||||
treated. If the argument is @racket['disallow-close], closing the window
|
||||
is not allowed. If it is anything else, that value is returned when
|
||||
the user closes the window.
|
||||
|
||||
If @scheme[gui-utils:cancel-on-right?]
|
||||
returns @scheme[#t], the false choice is on the right.
|
||||
If @racket[gui-utils:cancel-on-right?]
|
||||
returns @racket[#t], the false choice is on the right.
|
||||
Otherwise, the true choice is on the right.
|
||||
|
||||
The @scheme[style] parameter is (eventually) passed to
|
||||
@scheme[message]
|
||||
The @racket[style] parameter is (eventually) passed to
|
||||
@racket[message]
|
||||
as an icon in the dialog.
|
||||
|
||||
If @scheme[checkbox-proc] is given, it should be a procedure that behaves
|
||||
If @racket[checkbox-proc] is given, it should be a procedure that behaves
|
||||
like a parameter for getting/setting a boolean value. The intention for
|
||||
this value is that it can be used to disable the dialog. When it is
|
||||
given, a checkbox will appear with a @scheme[checkbox-label] label
|
||||
(defaults to the @scheme[dont-ask-again] string constant), and that
|
||||
checkbox value will be sent to the @scheme[checkbox-proc] when the dialog
|
||||
given, a checkbox will appear with a @racket[checkbox-label] label
|
||||
(defaults to the @racket[dont-ask-again] string constant), and that
|
||||
checkbox value will be sent to the @racket[checkbox-proc] when the dialog
|
||||
is closed. Note that the dialog will always pop-up --- it is the
|
||||
caller's responsibility to avoid the dialog if not needed.})
|
||||
|
||||
|
@ -550,13 +548,13 @@
|
|||
((white-on-black? #f)))
|
||||
@{This delta is designed for use with
|
||||
@method[text set-clickback].
|
||||
Use it as one of the @scheme[style-delta%] argument to
|
||||
Use it as one of the @racket[style-delta%] argument to
|
||||
@method[text% set-clickback].
|
||||
|
||||
If @scheme[white-on-black?] is true, the function returns
|
||||
If @racket[white-on-black?] is true, the function returns
|
||||
a delta suitable for use on a black background.
|
||||
|
||||
See also @scheme[gui-utils:get-clickback-delta].})
|
||||
See also @racket[gui-utils:get-clickback-delta].})
|
||||
|
||||
(proc-doc/names
|
||||
gui-utils:get-clickback-delta
|
||||
|
@ -569,8 +567,8 @@
|
|||
Use the result of this function as the style
|
||||
for the region text where the clickback is set.
|
||||
|
||||
If @scheme[white-on-black?] is true, the function returns
|
||||
If @racket[white-on-black?] is true, the function returns
|
||||
a delta suitable for use on a black background.
|
||||
|
||||
See also
|
||||
@scheme[gui-utils:get-clicked-clickback-delta].}))
|
||||
@racket[gui-utils:get-clicked-clickback-delta].}))
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -155,7 +155,7 @@
|
|||
[(an-item? x)
|
||||
(pop-out
|
||||
`@defmethod[(,(an-item->get-item-name x)) (or/c false/c (is-a?/c menu-item%))]{
|
||||
This method returns the @scheme[menu-item%] object corresponding
|
||||
This method returns the @racket[menu-item%] object corresponding
|
||||
to this menu item, if it has been created (as controlled by
|
||||
@method[frame:standard-menus<%> ,(an-item->create-menu-item-name x)]).})
|
||||
|
||||
|
@ -163,8 +163,8 @@
|
|||
`@defmethod[(,(an-item->create-menu-item-name x)) boolean?]{
|
||||
The result of this method determines if the corresponding
|
||||
menu item is created. Override it to control the creation of the menu item.
|
||||
|
||||
Defaults to @scheme[,(an-item-create x)].})
|
||||
|
||||
Defaults to @racket[,(an-item-create x)].})
|
||||
|
||||
(match (an-item-proc x)
|
||||
[`(λ (,item-name ,evt-name) ,bodies ...)
|
||||
|
@ -173,7 +173,7 @@
|
|||
[,item-name (is-a?/c menu-item%)]
|
||||
[,evt-name (is-a?/c control-event%)])
|
||||
void?]{
|
||||
Defaults to @schemeblock[,(if (= 1 (length bodies))
|
||||
Defaults to @racketblock[,(if (= 1 (length bodies))
|
||||
(car bodies)
|
||||
`(begin ,@bodies))] })])
|
||||
|
||||
|
@ -182,21 +182,21 @@
|
|||
(pop-out
|
||||
`@defmethod[(,(an-item->on-demand-name x) [,item-name (is-a?/c menu-item%)]) void?]{
|
||||
The menu item's on-demand proc calls this method.
|
||||
|
||||
Defaults to @schemeblock[,body]})])
|
||||
|
||||
Defaults to @racketblock[,body]})])
|
||||
|
||||
(pop-out
|
||||
`@defmethod[(,(an-item->string-name x)) string?]{
|
||||
The result of this method is used as the name of the @scheme[menu-item%].
|
||||
|
||||
Defaults to @scheme[,(an-item-menu-string x)].})
|
||||
`@defmethod[(,(an-item->string-name x)) string?]{
|
||||
The result of this method is used as the name of the @racket[menu-item%].
|
||||
|
||||
Defaults to @racket[,(an-item-menu-string x)].})
|
||||
|
||||
(pop-out
|
||||
`@defmethod[(,(an-item->help-string-name x)) string?]{
|
||||
The result of this method is used as the help string
|
||||
when the @scheme[menu-item%] object is created.
|
||||
|
||||
Defaults to @scheme[,(an-item-help-string x)].})]))
|
||||
when the @racket[menu-item%] object is created.
|
||||
|
||||
Defaults to @racket[,(an-item-help-string x)].})]))
|
||||
|
||||
items)
|
||||
(display docs-footer-text port))
|
||||
|
@ -282,6 +282,7 @@
|
|||
;; THIS FILE IS GENERATED. DO NOT EDIT.
|
||||
|
||||
@definterface[frame:standard-menus<%> (frame:basic<%>)]{
|
||||
|
||||
|
||||
|
||||
--
|
||||
)
|
||||
|
|
|
@ -155,7 +155,7 @@
|
|||
The result of this method is used as the class for creating
|
||||
the menu items in this frame.
|
||||
|
||||
Defaultly returns @scheme[menu:can-restore-menu-item].}))
|
||||
Defaultly returns @racket[menu:can-restore-menu-item].}))
|
||||
(make-generic-method
|
||||
'get-checkable-menu-item% '(λ () menu:can-restore-checkable-menu-item%)
|
||||
(list
|
||||
|
@ -163,7 +163,7 @@
|
|||
The result of this method is used as the class for creating
|
||||
checkable menu items in this class.
|
||||
|
||||
Defaultly returns @scheme[menu:can-restore-checkable-menu-item].}))
|
||||
Defaultly returns @racket[menu:can-restore-checkable-menu-item].}))
|
||||
|
||||
(make-generic-method
|
||||
'get-file-menu
|
||||
|
|
|
@ -854,7 +854,7 @@
|
|||
(λ (c) (eq? c btn))))))
|
||||
void?)
|
||||
(button)
|
||||
@{Simulates pushing @scheme[button]. If a string is supplied, the
|
||||
@{Simulates pushing @racket[button]. If a string is supplied, the
|
||||
primitive searches for a button labelled with that string in the
|
||||
active frame. Otherwise, it pushes the button argument.})
|
||||
|
||||
|
@ -862,52 +862,52 @@
|
|||
test:set-radio-box!
|
||||
(-> (or/c string? regexp? (is-a?/c radio-box%)) (or/c string? number?) void?)
|
||||
(radio-box state)
|
||||
@{Sets the radio-box to the label matching @scheme[state]. If @scheme[state] is a
|
||||
@{Sets the radio-box to the label matching @racket[state]. If @racket[state] is a
|
||||
string, this function finds the choice with that label.
|
||||
If it is a regexp, this function finds the first choice whose label matches the regexp.
|
||||
If it is a number, it uses the number as an index into the
|
||||
state. If the number is out of range or if the label isn't
|
||||
in the radio box, an exception is raised.
|
||||
|
||||
If @scheme[radio-box] is a string, this function searches for a
|
||||
@scheme[radio-box%] object with a label matching that string,
|
||||
otherwise it uses @scheme[radio-box] itself.})
|
||||
If @racket[radio-box] is a string, this function searches for a
|
||||
@racket[radio-box%] object with a label matching that string,
|
||||
otherwise it uses @racket[radio-box] itself.})
|
||||
|
||||
(proc-doc/names
|
||||
test:set-radio-box-item!
|
||||
(-> (or/c string? regexp?) void?)
|
||||
(entry)
|
||||
@{Finds a @scheme[radio-box%] that has a label matching @scheme[entry]
|
||||
and sets the radio-box to @scheme[entry].})
|
||||
@{Finds a @racket[radio-box%] that has a label matching @racket[entry]
|
||||
and sets the radio-box to @racket[entry].})
|
||||
|
||||
(proc-doc/names
|
||||
test:set-check-box!
|
||||
(-> (or/c string? (is-a?/c check-box%)) boolean? void?)
|
||||
(check-box state)
|
||||
@{Clears the @scheme[check-box%] item if @scheme[state] is @scheme[#f], and sets it
|
||||
@{Clears the @racket[check-box%] item if @racket[state] is @racket[#f], and sets it
|
||||
otherwise.
|
||||
|
||||
If @scheme[check-box] is a string,
|
||||
this function searches for a @scheme[check-box%] with a label matching that string,
|
||||
otherwise it uses @scheme[check-box] itself.})
|
||||
If @racket[check-box] is a string,
|
||||
this function searches for a @racket[check-box%] with a label matching that string,
|
||||
otherwise it uses @racket[check-box] itself.})
|
||||
|
||||
(proc-doc/names
|
||||
test:set-choice!
|
||||
(-> (or/c string? (is-a?/c choice%)) (or/c string? (and/c number? exact? integer? positive?))
|
||||
void?)
|
||||
(choice str)
|
||||
@{Selects @scheme[choice]'s item @scheme[str]. If @scheme[choice] is a string,
|
||||
this function searches for a @scheme[choice%] with a label matching
|
||||
that string, otherwise it uses @scheme[choice] itself.})
|
||||
@{Selects @racket[choice]'s item @racket[str]. If @racket[choice] is a string,
|
||||
this function searches for a @racket[choice%] with a label matching
|
||||
that string, otherwise it uses @racket[choice] itself.})
|
||||
|
||||
(proc-doc/names
|
||||
test:set-list-box!
|
||||
(-> (or/c string? (is-a?/c list-box%)) (or/c string? (and/c number? exact? integer? positive?))
|
||||
void?)
|
||||
(choice str)
|
||||
@{Selects @scheme[list-box]'s item @scheme[str]. If @scheme[list-box] is a string,
|
||||
this function searches for a @scheme[list-box%] with a label matching
|
||||
that string, otherwise it uses @scheme[list-box] itself.})
|
||||
@{Selects @racket[list-box]'s item @racket[str]. If @racket[list-box] is a string,
|
||||
this function searches for a @racket[list-box%] with a label matching
|
||||
that string, otherwise it uses @racket[list-box] itself.})
|
||||
|
||||
(proc-doc/names
|
||||
test:keystroke
|
||||
|
@ -916,19 +916,19 @@
|
|||
void?)
|
||||
((key)
|
||||
((modifier-list null)))
|
||||
@{This function simulates a user pressing a key. The argument, @scheme[key],
|
||||
@{This function simulates a user pressing a key. The argument, @racket[key],
|
||||
is just like the argument to the
|
||||
@method[key-event% get-key-code]
|
||||
method of the @scheme[key-event%] class.
|
||||
method of the @racket[key-event%] class.
|
||||
|
||||
@italic{Note:}
|
||||
To send the ``Enter'' key, use @scheme[#\return],
|
||||
not @scheme[#\newline].
|
||||
To send the ``Enter'' key, use @racket[#\return],
|
||||
not @racket[#\newline].
|
||||
|
||||
The @scheme['shift] or @scheme['noshift] modifier is implicitly set from @scheme[key],
|
||||
but is overridden by the argument list. The @scheme['shift] modifier is
|
||||
The @racket['shift] or @racket['noshift] modifier is implicitly set from @racket[key],
|
||||
but is overridden by the argument list. The @racket['shift] modifier is
|
||||
set for any capitol alpha-numeric letters and any of the following characters:
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
#\? #\: #\~ #\\ #\|
|
||||
#\< #\> #\{ #\} #\[ #\] #\( #\)
|
||||
#\! #\@ #\# #\$ #\% #\^ #\& #\* #\_ #\+
|
||||
|
@ -940,7 +940,7 @@
|
|||
test:menu-select
|
||||
(string? string? . -> . void?)
|
||||
(menu item)
|
||||
@{Selects the menu-item named @scheme[item] in the menu named @scheme[menu].
|
||||
@{Selects the menu-item named @racket[item] in the menu named @racket[menu].
|
||||
|
||||
@italic{Note:}
|
||||
The string for the menu item does not include its keyboard equivalent.
|
||||
|
@ -958,17 +958,17 @@
|
|||
((button x y)
|
||||
((modifiers null)))
|
||||
@{Simulates a mouse click at the coordinate (x,y) in the currently
|
||||
focused @scheme[window], assuming that it supports the
|
||||
focused @racket[window], assuming that it supports the
|
||||
@method[canvas<%> on-event] method.
|
||||
Use @scheme[test:button-push] to click on a button.
|
||||
Use @racket[test:button-push] to click on a button.
|
||||
|
||||
On the Macintosh, @scheme['right] corresponds to holding down the command
|
||||
modifier key while clicking and @scheme['middle] cannot be generated.
|
||||
On the Macintosh, @racket['right] corresponds to holding down the command
|
||||
modifier key while clicking and @racket['middle] cannot be generated.
|
||||
|
||||
Under Windows, @scheme['middle] can only be generated if the user has a
|
||||
Under Windows, @racket['middle] can only be generated if the user has a
|
||||
three button mouse.
|
||||
|
||||
The modifiers later in the list @scheme[modifiers] take precedence over
|
||||
The modifiers later in the list @racket[modifiers] take precedence over
|
||||
ones that appear earlier.})
|
||||
|
||||
(proc-doc/names
|
||||
|
@ -979,7 +979,7 @@
|
|||
((msec) ())
|
||||
@{See also @secref{test:actions-completeness}.
|
||||
The first case in the case-lambda sets
|
||||
the run interval to @scheme[msec] milliseconds and the second
|
||||
the run interval to @racket[msec] milliseconds and the second
|
||||
returns the current setting.})
|
||||
|
||||
(parameter-doc
|
||||
|
@ -991,7 +991,7 @@
|
|||
(see also @secref[#:doc '(lib "scribblings/gui/gui.scrbl") "eventspaceinfo"])
|
||||
are considered when finding the frontmost frame.
|
||||
The first case
|
||||
sets the parameter to @scheme[func]. The procedure @scheme[func] will be
|
||||
sets the parameter to @racket[func]. The procedure @racket[func] will be
|
||||
invoked with no arguments to determine the eventspaces to consider
|
||||
when finding the frontmost frame for simulated user events.
|
||||
The second case
|
||||
|
@ -1011,8 +1011,8 @@
|
|||
(-> (is-a?/c top-level-window<%>) void?)
|
||||
(tlw)
|
||||
@{Use this function to simulate clicking on the close box of a frame.
|
||||
Closes @scheme[tlw] with this expression:
|
||||
@schemeblock[
|
||||
Closes @racket[tlw] with this expression:
|
||||
@racketblock[
|
||||
(when (send tlw can-close?)
|
||||
(send tlw on-close)
|
||||
(send tlw show #f))]})
|
||||
|
@ -1021,10 +1021,10 @@
|
|||
test:top-level-focus-window-has?
|
||||
(-> (-> (is-a?/c area<%>) boolean?) boolean?)
|
||||
(test)
|
||||
@{Calls @scheme[test] for each child of the top-level-focus-frame
|
||||
and returns @scheme[#t] if @scheme[test] ever does, otherwise
|
||||
returns @scheme[#f]. If there
|
||||
is no top-level-focus-window, returns @scheme[#f].})
|
||||
@{Calls @racket[test] for each child of the top-level-focus-frame
|
||||
and returns @racket[#t] if @racket[test] ever does, otherwise
|
||||
returns @racket[#f]. If there
|
||||
is no top-level-focus-window, returns @racket[#f].})
|
||||
|
||||
|
||||
(proc-doc
|
||||
|
@ -1041,6 +1041,4 @@
|
|||
test:run-one
|
||||
(-> (-> void?) void?)
|
||||
(f)
|
||||
@{Runs the function @scheme[f] as if it was a simulated event.}))
|
||||
|
||||
|
||||
@{Runs the function @racket[f] as if it was a simulated event.}))
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
|
||||
@author["Greg Cooper"]
|
||||
|
||||
The @schememodname[frtime] language supports declarative construction of
|
||||
The @racketmodname[frtime] language supports declarative construction of
|
||||
reactive systems in a syntax very similar to that of Racket. To
|
||||
interact with FrTime, select @onscreen{FrTime} from the @onscreen{Choose Language} menu.
|
||||
You can also make FrTime the language for a module:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(module <module-name> frtime
|
||||
<module-body>)]
|
||||
|
||||
|
@ -31,45 +31,45 @@ You can also make FrTime the language for a module:
|
|||
|
||||
@defthing[undefined any/c]{stands for an undefined value.}
|
||||
|
||||
@defproc[(undefined? [val any/c]) boolean?]{return @scheme[#t] iff
|
||||
@scheme[val] is @scheme[undefined].}
|
||||
@defproc[(undefined? [val any/c]) boolean?]{return @racket[#t] iff
|
||||
@racket[val] is @racket[undefined].}
|
||||
|
||||
@defproc[(behavior? [val any/c]) boolean?]{returns @scheme[#t] iff
|
||||
@scheme[val] is a behavior (a time-varying value whose current value can be
|
||||
@defproc[(behavior? [val any/c]) boolean?]{returns @racket[#t] iff
|
||||
@racket[val] is a behavior (a time-varying value whose current value can be
|
||||
projected at any time).}
|
||||
|
||||
@defproc[(event? [val any/c]) boolean?]{returns @scheme[#t] iff
|
||||
@scheme[val] is an event (a time-varying stream of values that can occur
|
||||
@defproc[(event? [val any/c]) boolean?]{returns @racket[#t] iff
|
||||
@racket[val] is an event (a time-varying stream of values that can occur
|
||||
at arbitrary times).}
|
||||
|
||||
@defproc[(signal? [val any/c]) boolean?]{returns @scheme[#t] iff val
|
||||
is a signal. @scheme[(signal? v)] is equivalent to @scheme[(or
|
||||
@defproc[(signal? [val any/c]) boolean?]{returns @racket[#t] iff val
|
||||
is a signal. @racket[(signal? v)] is equivalent to @racket[(or
|
||||
(behavior? v) (event? v))].}
|
||||
|
||||
@defthing[seconds behavior?]{updates approximately once per second
|
||||
with the value of @scheme[(current-seconds)].}
|
||||
with the value of @racket[(current-seconds)].}
|
||||
|
||||
@defthing[milliseconds behavior?]{updates frequently with the value of
|
||||
@scheme[(current-inexact-milliseconds)].}
|
||||
@racket[(current-inexact-milliseconds)].}
|
||||
|
||||
@defthing[never-e event?]{is an event that never occurs.}
|
||||
|
||||
@section{Defining Custom Input Signals}
|
||||
|
||||
@defproc[(new-cell [init-expr signal? undefined]) signal? ]{returns a
|
||||
signal whose values initially track that of @scheme[init-expr], but
|
||||
that may be rewired to a different signal by @scheme[set-cell!].}
|
||||
signal whose values initially track that of @racket[init-expr], but
|
||||
that may be rewired to a different signal by @racket[set-cell!].}
|
||||
|
||||
@defproc[(set-cell! [cell signal?] [val signal?]) void?]{rewires
|
||||
@scheme[cell] (which must have been created by @scheme[new-cell]) to
|
||||
take on the value(s) of @scheme[val].}
|
||||
@racket[cell] (which must have been created by @racket[new-cell]) to
|
||||
take on the value(s) of @racket[val].}
|
||||
|
||||
@defproc[(event-receiver) event?]{returns an event stream that can be
|
||||
triggered imperatively by @scheme[send-event].}
|
||||
triggered imperatively by @racket[send-event].}
|
||||
|
||||
@defproc[(send-event [rcvr event?] [val any/c]) void?]{emits
|
||||
@scheme[val] on @scheme[rcvr] (which must have been created by
|
||||
@scheme[event-receiver]).}
|
||||
@racket[val] on @racket[rcvr] (which must have been created by
|
||||
@racket[event-receiver]).}
|
||||
|
||||
@section{Signal-Processing Procedures}
|
||||
|
||||
|
@ -77,32 +77,32 @@ triggered imperatively by @scheme[send-event].}
|
|||
a behavior or constant.}
|
||||
|
||||
@defproc[(delay-by [val behavior?] [duration number?])
|
||||
behavior?]{delays @scheme[val] by @scheme[duration] milliseconds.}
|
||||
behavior?]{delays @racket[val] by @racket[duration] milliseconds.}
|
||||
|
||||
@defproc[(integral [val (or/c number? behavior?)]) behavior?]{computes
|
||||
a numeric approximation of the integral of @scheme[val] with respect
|
||||
a numeric approximation of the integral of @racket[val] with respect
|
||||
to time (measured in milliseconds).}
|
||||
|
||||
@defproc[(derivative [val behavior?]) behavior?]{computes a numeric
|
||||
approximation of the derivative of @scheme[val] with respect to time.}
|
||||
approximation of the derivative of @racket[val] with respect to time.}
|
||||
|
||||
@deftogether[(
|
||||
@defproc[(map-e [proc (-> any/c any)] [ev event?]) event?]
|
||||
@defproc[([ev event?] . ==> . [proc (-> any/c any)]) event?]
|
||||
)]{returns an event stream that fires whenever @scheme[ev] fires, whose
|
||||
values are transformed by application of @scheme[proc].}
|
||||
)]{returns an event stream that fires whenever @racket[ev] fires, whose
|
||||
values are transformed by application of @racket[proc].}
|
||||
|
||||
@deftogether[(
|
||||
@defproc[(filter-e [pred (-> any/c boolean?)] [ev event?]) event?]
|
||||
@defproc[([ev event?] . =#> . [pred (-> any/c boolean?)]) event?])]{
|
||||
returns an event stream that passes through only the values from
|
||||
@scheme[ev] for which @scheme[pred] returns @scheme[#t].}
|
||||
@racket[ev] for which @racket[pred] returns @racket[#t].}
|
||||
|
||||
@defproc[(merge-e [ev event?] ...) event?]{merges all of the input
|
||||
event sources into a single event source.}
|
||||
|
||||
@defproc[(once-e [ev event?]) event?]{returns an event source that
|
||||
carries only the first occurrence of @scheme[ev]. (The rest are
|
||||
carries only the first occurrence of @racket[ev]. (The rest are
|
||||
filtered out.)}
|
||||
|
||||
@defproc[(changes [val behavior?]) event?]{returns an event source
|
||||
|
@ -110,12 +110,12 @@ that occurs each time the argument behavior changes. The value of the
|
|||
occurrence is the behavior's new value.}
|
||||
|
||||
@defproc[(hold [ev event?] [init any/c undefined]) behavior?]{
|
||||
constructs a behavior that starts out as @scheme[init] and then
|
||||
takes on the last value produced by @scheme[ev]}
|
||||
constructs a behavior that starts out as @racket[init] and then
|
||||
takes on the last value produced by @racket[ev]}
|
||||
|
||||
@defproc[(switch [ev event?] [init behavior? undefined])
|
||||
behavior?]{returns a behavior that starts as @scheme[init]. Each time
|
||||
@scheme[ev] yields a (potentially time-varying) value, the behavior
|
||||
behavior?]{returns a behavior that starts as @racket[init]. Each time
|
||||
@racket[ev] yields a (potentially time-varying) value, the behavior
|
||||
switches to that value.}
|
||||
|
||||
@defproc[(accum-e [ev event?] [init any/c]) event?]{constructs an event source
|
||||
|
@ -123,34 +123,34 @@ by accumulating changes (carried by the given event source) over an
|
|||
initial value.}
|
||||
|
||||
@defproc[(accum-b [ev event?] [init any/c]) behavior?]{combines functionality
|
||||
from @scheme[accum-e] and @scheme[hold] to construct a behavior.
|
||||
@scheme[(accum-b ev init)] is equivalent to @scheme[(hold init
|
||||
from @racket[accum-e] and @racket[hold] to construct a behavior.
|
||||
@racket[(accum-b ev init)] is equivalent to @racket[(hold init
|
||||
(accum-e ev init))].}
|
||||
|
||||
@defproc[(collect-e [ev event?] [init any/c] [proc (-> any/c any/c
|
||||
any)]) event?]{is similar to @scheme[accum-e], except the transformer
|
||||
any)]) event?]{is similar to @racket[accum-e], except the transformer
|
||||
function is fixed and is applied to the event occurrence and the
|
||||
current accumulator (in that order).}
|
||||
|
||||
@defproc[(collect-b [ev event?] [init any/c] [proc (-> any/c any/c any)]) behavior?]{is similar to
|
||||
@scheme[collect-e] in the same way as @scheme[accum-b] is similar to
|
||||
@scheme[accum-e].}
|
||||
@racket[collect-e] in the same way as @racket[accum-b] is similar to
|
||||
@racket[accum-e].}
|
||||
|
||||
@defproc[(when-e [val behavior?]) event?]{returns an event stream that
|
||||
carries an occurrence each time @scheme[val] changes from @scheme[#f] to
|
||||
carries an occurrence each time @racket[val] changes from @racket[#f] to
|
||||
anything else.}
|
||||
|
||||
@defproc[(lift-strict [proc (-> [arg any/c] ... any)] [val any/c] ...)
|
||||
any]{provides a mechanism for applying ordinary Scheme primitives to
|
||||
behaviors. If any of the @scheme[val]s are behaviors, returns a
|
||||
behavior whose current value is always equal to @scheme[(proc
|
||||
behaviors. If any of the @racket[val]s are behaviors, returns a
|
||||
behavior whose current value is always equal to @racket[(proc
|
||||
(value-now arg) ...)]. In FrTime, many Racket primitives are
|
||||
implicitly lifted.}
|
||||
|
||||
The following forms allow importation of lifted procedures that aren't
|
||||
included in the basic FrTime language.
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(require (lifted module-spec proc-name ...) ...)
|
||||
(require (lifted:nonstrict module-spec proc-name ...) ...)
|
||||
]
|
||||
|
@ -182,9 +182,9 @@ included in the basic FrTime language.
|
|||
[stretchable-width any/c #t]
|
||||
[stretchable-height any/c #t]
|
||||
[shown any/c #f])]{
|
||||
The constructor arguments are as in @scheme[frame%], except that @scheme[shown]
|
||||
@scheme[label], @scheme[enabled], @scheme[stretchable-width], and
|
||||
@scheme[stretchable-height] may be time-varying.}
|
||||
The constructor arguments are as in @racket[frame%], except that @racket[shown]
|
||||
@racket[label], @racket[enabled], @racket[stretchable-width], and
|
||||
@racket[stretchable-height] may be time-varying.}
|
||||
}
|
||||
|
||||
@defclass[ft-message% message% (control<%>)]{
|
||||
|
@ -194,7 +194,7 @@ The constructor arguments are as in @scheme[frame%], except that @scheme[shown]
|
|||
[parent (or/c (is-a?/c frame%) (is-a?/c dialog%)
|
||||
(is-a?/c panel%) (is-a?/c pane%))]
|
||||
[style (listof (one-of/c 'deleted)) null]
|
||||
[font (is-a?/c font%) @scheme[normal-control-font]]
|
||||
[font (is-a?/c font%) @racket[normal-control-font]]
|
||||
[enabled (or/c any/c behavior?) #t]
|
||||
[vert-margin (integer-in 0 1000) 2]
|
||||
[horiz-margin (integer-in 0 1000) 2]
|
||||
|
@ -202,9 +202,9 @@ The constructor arguments are as in @scheme[frame%], except that @scheme[shown]
|
|||
[min-height (integer-in 0 10000) _graphical-minimum-height]
|
||||
[stretchable-width any/c #f]
|
||||
[stretchable-height any/c #f])]{The constructor
|
||||
arguments are the same as in @scheme[message%], except that
|
||||
@scheme[label], @scheme[enabled], @scheme[stretchable-width], and
|
||||
@scheme[stretchable-height] may be time-varying.}}
|
||||
arguments are the same as in @racket[message%], except that
|
||||
@racket[label], @racket[enabled], @racket[stretchable-width], and
|
||||
@racket[stretchable-height] may be time-varying.}}
|
||||
|
||||
@defclass[ft-button% button% (control<%>)]{
|
||||
|
||||
|
@ -212,7 +212,7 @@ arguments are the same as in @scheme[message%], except that
|
|||
[parent (or/c (is-a?/c frame%) (is-a?/c dialog%)
|
||||
(is-a?/c panel%) (is-a?/c pane%))]
|
||||
[style (one-of/c 'border 'deleted) null]
|
||||
[font (is-a?/c font%) @scheme[normal-control-font]]
|
||||
[font (is-a?/c font%) @racket[normal-control-font]]
|
||||
[enabled any/c #t]
|
||||
[vert-margin (integer-in 0 1000) 2]
|
||||
[horiz-margin (integer-in 0 1000) 2]
|
||||
|
@ -220,9 +220,9 @@ arguments are the same as in @scheme[message%], except that
|
|||
[min-height (integer-in 0 10000) _graphical-minimum-height]
|
||||
[stretchable-width any/c #f]
|
||||
[stretchable-height any/c #f])]{The constructor
|
||||
arguments are the same as in @scheme[message%], except that
|
||||
@scheme[label], @scheme[enabled], @scheme[stretchable-width], and
|
||||
@scheme[stretchable-height] may be time-varying.}
|
||||
arguments are the same as in @racket[message%], except that
|
||||
@racket[label], @racket[enabled], @racket[stretchable-width], and
|
||||
@racket[stretchable-height] may be time-varying.}
|
||||
|
||||
@defmethod[(get-value-e) event?]{returns an event stream that yields a
|
||||
value whenever the user clicks the button.}
|
||||
|
@ -235,7 +235,7 @@ value whenever the user clicks the button.}
|
|||
(is-a?/c panel%) (is-a?/c pane%))]
|
||||
[style (listof (one-of/c 'deleted)) null]
|
||||
[value any/c #f]
|
||||
[font (is-a?/c font%) @scheme[normal-control-font]]
|
||||
[font (is-a?/c font%) @racket[normal-control-font]]
|
||||
[enabled any/c #t]
|
||||
[vert-margin (integer-in 0 1000) 2]
|
||||
[horiz-margin (integer-in 0 1000) 2]
|
||||
|
@ -244,10 +244,10 @@ value whenever the user clicks the button.}
|
|||
[stretchable-width any/c #f]
|
||||
[stretchable-height any/c #f]
|
||||
[value-set event? never-e])]{The constructor arguments
|
||||
are the same as in @scheme[check-box%], except that @scheme[label],
|
||||
@scheme[enabled], @scheme[stretchable-width], and
|
||||
@scheme[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @scheme[value-set] sets the check box's state to that of the event value.}
|
||||
are the same as in @racket[check-box%], except that @racket[label],
|
||||
@racket[enabled], @racket[stretchable-width], and
|
||||
@racket[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @racket[value-set] sets the check box's state to that of the event value.}
|
||||
|
||||
@defmethod[(get-value-b) behavior?]{returns a value that always reflects
|
||||
the current state of the check box.}
|
||||
|
@ -274,10 +274,10 @@ the current state of the check box.}
|
|||
[stretchable-width any/c (memq 'horizontal style)]
|
||||
[stretchable-height any/c (memq 'vertical style)]
|
||||
[value-set event? never-e])]{The constructor arguments
|
||||
are the same as in @scheme[check-box%], except that @scheme[label],
|
||||
@scheme[enabled], @scheme[stretchable-width], and
|
||||
@scheme[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @scheme[value-set] sets the slider's state to that of the event value.}
|
||||
are the same as in @racket[check-box%], except that @racket[label],
|
||||
@racket[enabled], @racket[stretchable-width], and
|
||||
@racket[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @racket[value-set] sets the slider's state to that of the event value.}
|
||||
|
||||
@defmethod[(get-value-b) behavior?]{returns a value that always reflects
|
||||
the current state of the slider.}
|
||||
|
@ -293,7 +293,7 @@ the current state of the slider.}
|
|||
'vertical-label 'horizontal-label
|
||||
'deleted))
|
||||
'(single)]
|
||||
[font (is-a?/c font%) @scheme[normal-control-font]]
|
||||
[font (is-a?/c font%) @racket[normal-control-font]]
|
||||
[enabled any/c #t]
|
||||
[vert-margin (integer-in 0 1000) 2]
|
||||
[horiz-margin (integer-in 0 1000) 2]
|
||||
|
@ -302,10 +302,10 @@ the current state of the slider.}
|
|||
[stretchable-width any/c #t]
|
||||
[stretchable-height any/c (memq 'multiple style)]
|
||||
[value-set event? never-e])]{The
|
||||
constructor arguments are the same as in @scheme[check-box%], except
|
||||
that @scheme[label], @scheme[enabled], @scheme[stretchable-width], and
|
||||
@scheme[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @scheme[value-set] sets the text field's state to that of the event
|
||||
constructor arguments are the same as in @racket[check-box%], except
|
||||
that @racket[label], @racket[enabled], @racket[stretchable-width], and
|
||||
@racket[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @racket[value-set] sets the text field's state to that of the event
|
||||
value.}
|
||||
|
||||
@defmethod[(get-value-b) behavior?]{returns a value that always reflects
|
||||
|
@ -332,10 +332,10 @@ the current state of the text field.}
|
|||
[stretchable-width any/c #f]
|
||||
[stretchable-height any/c #f]
|
||||
[value-set event? never-e])]{The
|
||||
constructor arguments are the same as in @scheme[check-box%], except
|
||||
that @scheme[label], @scheme[enabled], @scheme[stretchable-width], and
|
||||
@scheme[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @scheme[value-set] sets the text field's state to that of the event
|
||||
constructor arguments are the same as in @racket[check-box%], except
|
||||
that @racket[label], @racket[enabled], @racket[stretchable-width], and
|
||||
@racket[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @racket[value-set] sets the text field's state to that of the event
|
||||
value.}
|
||||
@defmethod[(get-selection-b) behavior?]{returns a value that always reflects
|
||||
the currently selected element in the radio box.}
|
||||
|
@ -350,7 +350,7 @@ the currently selected element in the radio box.}
|
|||
'deleted))
|
||||
null]
|
||||
[selection exact-nonnegative-integer? 0]
|
||||
[font (is-a?/c font%) @scheme[normal-control-font]]
|
||||
[font (is-a?/c font%) @racket[normal-control-font]]
|
||||
[enabled any/c #t]
|
||||
[vert-margin (integer-in 0 1000) 2]
|
||||
[horiz-margin (integer-in 0 1000) 2]
|
||||
|
@ -359,10 +359,10 @@ the currently selected element in the radio box.}
|
|||
[stretchable-width any/c #f]
|
||||
[stretchable-height any/c #f]
|
||||
[value-set event? never-e])]{The
|
||||
constructor arguments are the same as in @scheme[check-box%], except
|
||||
that @scheme[label], @scheme[enabled], @scheme[stretchable-width], and
|
||||
@scheme[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @scheme[value-set] sets the text field's state to that of the event
|
||||
constructor arguments are the same as in @racket[check-box%], except
|
||||
that @racket[label], @racket[enabled], @racket[stretchable-width], and
|
||||
@racket[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @racket[value-set] sets the text field's state to that of the event
|
||||
value.}
|
||||
@defmethod[(get-selection-b) behavior?]{returns a value that always reflects
|
||||
the currently selected element in the choice control.}
|
||||
|
@ -378,8 +378,8 @@ the currently selected element in the choice control.}
|
|||
'deleted))
|
||||
'(single)]
|
||||
[selection (or/c exact-nonnegative-integer? false/c) #f]
|
||||
[font (is-a?/c font%) @scheme[view-control-font]]
|
||||
[label-font (is-a?/c font%) @scheme[normal-control-font]]
|
||||
[font (is-a?/c font%) @racket[view-control-font]]
|
||||
[label-font (is-a?/c font%) @racket[normal-control-font]]
|
||||
[enabled any/c #t]
|
||||
[vert-margin (integer-in 0 1000) 2]
|
||||
[horiz-margin (integer-in 0 1000) 2]
|
||||
|
@ -388,10 +388,10 @@ the currently selected element in the choice control.}
|
|||
[stretchable-width any/c #t]
|
||||
[stretchable-height any/c #t]
|
||||
[value-set event? never-e])]{The
|
||||
constructor arguments are the same as in @scheme[check-box%], except
|
||||
that @scheme[label], @scheme[enabled], @scheme[stretchable-width], and
|
||||
@scheme[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @scheme[value-set] sets the text field's state to that of the event
|
||||
constructor arguments are the same as in @racket[check-box%], except
|
||||
that @racket[label], @racket[enabled], @racket[stretchable-width], and
|
||||
@racket[stretchable-height] may be time-varying. Also, any occurrence
|
||||
on @racket[value-set] sets the text field's state to that of the event
|
||||
value.}
|
||||
@defmethod[(get-selection-b) behavior?]{returns a value that always reflects
|
||||
the primary selection in the list box.}
|
||||
|
@ -407,34 +407,34 @@ To run the following animation/GUI demos, simply set the language
|
|||
level to FrTime, open the corresponding file, and Execute. See the
|
||||
demo source code for more information.
|
||||
|
||||
@scheme[orbit-mouse.rkt] : A collection of balls that move in circles
|
||||
@filepath{orbit-mouse.rkt} : A collection of balls that move in circles
|
||||
around the mouse pointer.
|
||||
|
||||
@scheme[piston.rkt] : Simulation of a piston/cylinder.
|
||||
@filepath{piston.rkt} : Simulation of a piston/cylinder.
|
||||
|
||||
@scheme[rotation.rkt] : Balls moving in circles.
|
||||
@filepath{rotation.rkt} : Balls moving in circles.
|
||||
|
||||
@scheme[delay-mouse.rkt] : A trail of balls following the mouse.
|
||||
@filepath{delay-mouse.rkt} : A trail of balls following the mouse.
|
||||
|
||||
@scheme[ball-on-string.rkt] : A ball chasing the mouse.
|
||||
@filepath{ball-on-string.rkt} : A ball chasing the mouse.
|
||||
|
||||
@scheme[pong.rkt] : A simple pong/air-hockey game. The left paddle moves with
|
||||
@filepath{pong.rkt} : A simple pong/air-hockey game. The left paddle moves with
|
||||
numeric keypad; the right paddle moves with the mouse. The 'r' key
|
||||
resets the score.
|
||||
|
||||
@scheme[pizza.rkt] : A simple "pizza ordering" user interface based on an HtDP
|
||||
@filepath{pizza.rkt} : A simple "pizza ordering" user interface based on an HtDP
|
||||
exercise.
|
||||
|
||||
@scheme[calculator.rkt] : A simple calculator interface, also based on an HtDP
|
||||
@filepath{calculator.rkt} : A simple calculator interface, also based on an HtDP
|
||||
exercise except that the result updates continuously as the arguments
|
||||
and operator change.
|
||||
|
||||
The next three animation examples are courtesy of Robb Cutler:
|
||||
|
||||
@scheme[analog-clock.rkt] : An animated real-time clock. A slider adjusts the
|
||||
@filepath{analog-clock.rkt} : An animated real-time clock. A slider adjusts the
|
||||
radius of the face. Click and drag to move the face around.
|
||||
|
||||
@scheme[growing-points.rkt] : A field of points that grow as the mouse
|
||||
@filepath{growing-points.rkt} : A field of points that grow as the mouse
|
||||
approaches.
|
||||
|
||||
@scheme[needles.rkt] : A field of needles that point at the mouse.
|
||||
@filepath{needles.rkt} : A field of needles that point at the mouse.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
@title{@bold{Cards}: Virtual Playing Cards Library}
|
||||
|
||||
@defmodule[games/cards]{The @schememodname[games/cards]
|
||||
@defmodule[games/cards]{The @racketmodname[games/cards]
|
||||
module provides a toolbox for creating cards games.}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
@ -16,10 +16,10 @@ module provides a toolbox for creating cards games.}
|
|||
[h exact-nonnegative-integer? 3])
|
||||
table<%>]{
|
||||
|
||||
Returns a table. The table is named by @scheme[title], and it is
|
||||
@scheme[w] cards wide and @scheme[h] cards high (assuming a standard
|
||||
Returns a table. The table is named by @racket[title], and it is
|
||||
@racket[w] cards wide and @racket[h] cards high (assuming a standard
|
||||
card of 71 by 96 pixels). The table is not initially shown;
|
||||
@scheme[(send table show #t)] shows it.}
|
||||
@racket[(send table show #t)] shows it.}
|
||||
|
||||
@defproc[(make-deck)
|
||||
(listof card<%>)]{
|
||||
|
@ -43,12 +43,12 @@ the same size.}
|
|||
@defproc[(shuffle-list [lst list?] [n exact-nonnegative-integer?])
|
||||
list?]{
|
||||
|
||||
Shuffles the given @scheme[lst] @scheme[n] times, returning the new
|
||||
Shuffles the given @racket[lst] @racket[n] times, returning the new
|
||||
list. Shuffling simulates an actual shuffle: the list is split into
|
||||
halves which are merged back together by repeatedly pulling the top
|
||||
card off one of the halves, randomly selecting one half or the
|
||||
other. According to some mathematical theorem, 7 is a large enough
|
||||
@scheme[n] to get a perfect shuffle.}
|
||||
@racket[n] to get a perfect shuffle.}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
@section{Regions and Buttons}
|
||||
|
@ -61,22 +61,22 @@ other. According to some mathematical theorem, 7 is a large enough
|
|||
[(callback #:mutable) (or/c ((listof (is-a?/c card<%>)) . -> . any)
|
||||
false/c)])]{
|
||||
|
||||
The @scheme[x], @scheme[y], @scheme[w], and @scheme[h] fields
|
||||
The @racket[x], @racket[y], @racket[w], and @racket[h] fields
|
||||
determine the region's location on the table.
|
||||
|
||||
When @scheme[label] is a string, it is drawn in the region in 12-pixel
|
||||
When @racket[label] is a string, it is drawn in the region in 12-pixel
|
||||
text, centered horizontally and 5 pixels down from the region's top
|
||||
outline. If label is @scheme[#f], no label or box is drawn for the
|
||||
outline. If label is @racket[#f], no label or box is drawn for the
|
||||
region.
|
||||
|
||||
The @scheme[callback] procedure takes a list of cards that were
|
||||
dragged to the region; if callback is @scheme[#f], the region is not
|
||||
The @racket[callback] procedure takes a list of cards that were
|
||||
dragged to the region; if callback is @racket[#f], the region is not
|
||||
active (i.e., dragging cards to the region doesn't highlight the
|
||||
region box). The region remains hilited until the callback returns.
|
||||
|
||||
The only available mutator on the structure is
|
||||
@scheme[set-region-callback!]. The structure created by
|
||||
@scheme[make-region] actually has extra hidden fields.}
|
||||
@racket[set-region-callback!]. The structure created by
|
||||
@racket[make-region] actually has extra hidden fields.}
|
||||
|
||||
@defproc[(make-button-region [x real?]
|
||||
[y real?]
|
||||
|
@ -87,7 +87,7 @@ The only available mutator on the structure is
|
|||
false/c)])
|
||||
region?]{
|
||||
|
||||
Returns a region like one made by @scheme[make-region], but the is
|
||||
Returns a region like one made by @racket[make-region], but the is
|
||||
drawn slightly differently and it reacts differently to cards and the
|
||||
mouse. The label is drawn in the middle of the box instead of at the
|
||||
top, and the callback is called with no arguments when the user
|
||||
|
@ -102,13 +102,13 @@ Returns a region like one made by @scheme[make-region], but the is
|
|||
region?]{
|
||||
|
||||
Returns a region that does not respond to mouse clicks, but which has
|
||||
a general paint callback. The @scheme[paint-callback] function is
|
||||
a general paint callback. The @racket[paint-callback] function is
|
||||
called with a drawing context, x and y offsets, and the width and
|
||||
height (which are always @scheme[w] and @scheme[h]). The x and y
|
||||
offsets can be different than the supplied @scheme[x] and @scheme[y]
|
||||
height (which are always @racket[w] and @racket[h]). The x and y
|
||||
offsets can be different than the supplied @racket[x] and @racket[y]
|
||||
when part of the table is drawn offscreen. Regions are painted in the
|
||||
order that they are added to a table, and all regions are painted
|
||||
before any card. The @scheme[paint-callback] procedure should not
|
||||
before any card. The @racket[paint-callback] procedure should not
|
||||
assume a particular state for the drawing context (i.e.,current brush
|
||||
or pen), and it should restore any modified drawing context state
|
||||
before returning.}
|
||||
|
@ -123,7 +123,7 @@ Returns a region like one made by @scheme[make-region], but the is
|
|||
(un)hilited as the user drags a set of cards to the region. The
|
||||
callback is provided two arguments: a boolean indicating whether the
|
||||
region is hilited, and the list of cards being dragged. Like
|
||||
region-callback, the default is @scheme[#f], which indicates that the
|
||||
region-callback, the default is @racket[#f], which indicates that the
|
||||
region has no interactive callback (but does not affect whether the
|
||||
region is hilited as cards are dragged). The final unhilite (when
|
||||
cards are potentially delivered) does not trigger this callback.}
|
||||
|
@ -133,22 +133,22 @@ Returns a region like one made by @scheme[make-region], but the is
|
|||
(boolean? (listof (is-a?/c card<%>)) . -> . any)]{
|
||||
|
||||
Gets the current callback that is installed via
|
||||
@scheme[set-region-interaction-callback!].}
|
||||
@racket[set-region-interaction-callback!].}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
@section{Table Methods}
|
||||
|
||||
@definterface[table<%> (frame%)]{
|
||||
|
||||
Create an instance with @scheme[make-table].
|
||||
Create an instance with @racket[make-table].
|
||||
|
||||
@defmethod[(add-card [card (is-a?/c card<%>)]
|
||||
[x real?]
|
||||
[y real?])
|
||||
void?]{
|
||||
|
||||
Adds @scheme[card] to the table with its top-left corner at
|
||||
(@scheme[x], @scheme[y]) in table pixels.}
|
||||
Adds @racket[card] to the table with its top-left corner at
|
||||
(@racket[x], @racket[y]) in table pixels.}
|
||||
|
||||
@defmethod[(add-cards [cards (listof (is-a?/c card<%>))]
|
||||
[x real?]
|
||||
|
@ -158,39 +158,39 @@ Create an instance with @scheme[make-table].
|
|||
(lambda (i) (values 0 0))])
|
||||
void?]{
|
||||
|
||||
Adds a list of cards at (@scheme[x], @scheme[y]). The optional
|
||||
@scheme[offset-proc] procedure is called with an index @scheme[_i]
|
||||
(counting from 0) and should return two values: @scheme[_dx] and
|
||||
@scheme[_dy]; the @scheme[_i]th card is the placed at @scheme[(+ x
|
||||
+dx)] and @scheme[(+ y _dy)]. The cards are added in order on top of
|
||||
Adds a list of cards at (@racket[x], @racket[y]). The optional
|
||||
@racket[offset-proc] procedure is called with an index @racket[_i]
|
||||
(counting from 0) and should return two values: @racket[_dx] and
|
||||
@racket[_dy]; the @racket[_i]th card is the placed at @racket[(+ x
|
||||
+dx)] and @racket[(+ y _dy)]. The cards are added in order on top of
|
||||
cards already one the table such that the first card in
|
||||
@scheme[cards] is topmost.}
|
||||
@racket[cards] is topmost.}
|
||||
|
||||
@defmethod[(add-cards-to-region [cards (listof (is-a?/c card<%>))]
|
||||
[region? r])
|
||||
void?]{
|
||||
|
||||
Adds @scheme[cards] to fill the region @scheme[r], fanning them out
|
||||
bottom-right to top-left, assuming that all cards in @scheme[cards]
|
||||
have the same width and height. The region @scheme[r] does not have
|
||||
Adds @racket[cards] to fill the region @racket[r], fanning them out
|
||||
bottom-right to top-left, assuming that all cards in @racket[cards]
|
||||
have the same width and height. The region @racket[r] does not have
|
||||
to be added to the table.}
|
||||
|
||||
@defmethod[(remove-card [card (is-a?/c card<%>)])
|
||||
void?]{
|
||||
|
||||
Removes @scheme[card] from the table.}
|
||||
Removes @racket[card] from the table.}
|
||||
|
||||
@defmethod[(remove-cards [cards (listof (is-a?/c card<%>))])
|
||||
void?]{
|
||||
|
||||
Removes @scheme[cards] from the table.}
|
||||
Removes @racket[cards] from the table.}
|
||||
|
||||
@defmethod[(move-card [card (is-a?/c card<%>)]
|
||||
[x real?]
|
||||
[y real?])
|
||||
void?]{
|
||||
|
||||
Moves @scheme[card], which must be on the same already. The movement
|
||||
Moves @racket[card], which must be on the same already. The movement
|
||||
of the cards is animated. If the cards are in snap-back-after-move
|
||||
mode and a drag is active, snapping back will use the new location.}
|
||||
|
||||
|
@ -211,23 +211,23 @@ Removes @scheme[card] from the table.}
|
|||
void?]{
|
||||
|
||||
Like @method[table<%> add-cards-to-region], but moves cards that are
|
||||
already on the table like @scheme[move-card]. All of the cards are
|
||||
already on the table like @racket[move-card]. All of the cards are
|
||||
moved at once.}
|
||||
|
||||
|
||||
@defmethod*[([(flip-card [card (is-a?/c card<%>)]) void?]
|
||||
[(flip-cards [cards (listof (is-a?/c card<%>))]) void?])]{
|
||||
|
||||
Flips @scheme[card] or all @scheme[cards] over (at once) with
|
||||
Flips @racket[card] or all @racket[cards] over (at once) with
|
||||
animation.}
|
||||
|
||||
@defmethod*[([(card-face-up [card (is-a?/c card<%>)]) void?]
|
||||
[(cards-face-up [cards (listof (is-a?/c card<%>))]) void?]
|
||||
[(card-face-down [card (is-a?/c card<%>)]) void?]
|
||||
[(cards-face-down [cards (listof (is-a?/c card<%>))]) void?])]{
|
||||
|
||||
Like @method[table<%> flip-cards], but only for @scheme[card] or
|
||||
elements of @scheme[cards] that are currently face down/up.}
|
||||
|
||||
Like @method[table<%> flip-cards], but only for @racket[card] or
|
||||
elements of @racket[cards] that are currently face down/up.}
|
||||
|
||||
@defmethod*[([(rotate-card [card (is-a?/c card<%>)]
|
||||
[mode (or/c 'cw 'ccw 0 90 -90 180 -180 270 -270 360)])
|
||||
|
@ -236,23 +236,23 @@ Removes @scheme[card] from the table.}
|
|||
[mode (or/c 'cw 'ccw 0 90 -90 180 -180 270 -270 360)])
|
||||
void?])]{
|
||||
|
||||
Rotates @scheme[card] or all @scheme[cards] (at once, currently
|
||||
Rotates @racket[card] or all @racket[cards] (at once, currently
|
||||
without animation, but animation may be added in the future).
|
||||
The center of each card is kept in place, except that the card is
|
||||
moved as necessary to keep it on the table. See @xmethod[card<%>
|
||||
rotate] for information on @scheme[mode].}
|
||||
rotate] for information on @racket[mode].}
|
||||
|
||||
@defmethod*[([(card-to-front [card (is-a?/c card<%>)]) void?]
|
||||
[(card-to-back [card (is-a?/c card<%>)]) void?])]{
|
||||
|
||||
Moves @scheme[card] before/behind of all other cards.}
|
||||
Moves @racket[card] before/behind of all other cards.}
|
||||
|
||||
@defmethod[(stack-cards [cards (listof (is-a?/c card<%>))]) void?]{
|
||||
|
||||
The first card in @scheme[cards] is not moved; the second card is
|
||||
The first card in @racket[cards] is not moved; the second card is
|
||||
moved to follow immediately behind the first one, then
|
||||
@method[table<%> stack-cards] is called on @scheme[(cdr cards)]. If
|
||||
@scheme[cards] is empty or contains only one card, no action is
|
||||
@method[table<%> stack-cards] is called on @racket[(cdr cards)]. If
|
||||
@racket[cards] is empty or contains only one card, no action is
|
||||
taken.}
|
||||
|
||||
@defmethod[(card-location [card (is-a?/c card<%>)])
|
||||
|
@ -276,17 +276,17 @@ Removes @scheme[card] from the table.}
|
|||
|
||||
Starts/ends a sequence of card or region changes that won't be
|
||||
animated or updated until the end of the sequence. Sequences can be
|
||||
nested via matching @schemeidfont{begin-}/@schemeidfont{end-} pairs.}
|
||||
|
||||
nested via matching @racketidfont{begin-}/@racketidfont{end-} pairs.}
|
||||
|
||||
@defmethod[(add-region [r region?]) void]{
|
||||
|
||||
Adds the region @scheme[r] to the table; regions are drawn in the
|
||||
Adds the region @racket[r] to the table; regions are drawn in the
|
||||
order that they are added to the table, and when a region added later
|
||||
is hilighted, it can obscure regions added earlier.}
|
||||
|
||||
@defmethod[(remove-region [r region?]) void]{
|
||||
|
||||
Removes the region @scheme[r] from the table.}
|
||||
Removes the region @racket[r] from the table.}
|
||||
|
||||
@defmethod*[([(hilite-region [r region?]) void?]
|
||||
[(unhilite-region [r region?]) void?])]{
|
||||
|
@ -298,36 +298,36 @@ Removes @scheme[card] from the table.}
|
|||
void?]{
|
||||
|
||||
Sets the way that a mouse click is handled for a particular button
|
||||
indicated by @scheme[which]. The @scheme[action] argument must be one
|
||||
indicated by @racket[which]. The @racket[action] argument must be one
|
||||
of the following:
|
||||
|
||||
@itemize[
|
||||
|
||||
@item{@scheme['drag/one] --- drag only the clicked-on card.}
|
||||
@item{@racket['drag/one] --- drag only the clicked-on card.}
|
||||
|
||||
@item{@scheme['drag-raise/one] --- like drag/one, but raise the
|
||||
@item{@racket['drag-raise/one] --- like drag/one, but raise the
|
||||
card to the top on a click.}
|
||||
|
||||
@item{@scheme['drag/above] --- drag the card along with any card
|
||||
@item{@racket['drag/above] --- drag the card along with any card
|
||||
on top of the card (i.e., more towards the front and
|
||||
overlapping with the card). The on-top-of relation
|
||||
is closed transitively.}
|
||||
|
||||
@item{@scheme['drag-raise/above] --- like @scheme['drag/above],
|
||||
@item{@racket['drag-raise/above] --- like @racket['drag/above],
|
||||
but raises.}
|
||||
|
||||
@item{@scheme['drag-below] --- drag the card along with any card
|
||||
@item{@racket['drag-below] --- drag the card along with any card
|
||||
underneath the card (i.e., more towards the back and
|
||||
overlapping with the card). The underneath relation
|
||||
is closed transitively.}
|
||||
|
||||
@item{@scheme['drag-raise/below] --- like @scheme['drag/below],
|
||||
@item{@racket['drag-raise/below] --- like @racket['drag/below],
|
||||
but raises.}
|
||||
]
|
||||
|
||||
The initial settings are: @scheme['drag-raise/above] for
|
||||
@scheme['left], @scheme['drag/one] for @scheme['middle], and
|
||||
@scheme['drag/below] for @scheme['right].}
|
||||
The initial settings are: @racket['drag-raise/above] for
|
||||
@racket['left], @racket['drag/one] for @racket['middle], and
|
||||
@racket['drag/below] for @racket['right].}
|
||||
|
||||
@defmethod[(set-double-click-action
|
||||
[proc ((is-a?/c card<%>) . -> . any)])
|
||||
|
@ -374,10 +374,10 @@ Removes @scheme[card] from the table.}
|
|||
|
||||
Adds a @onscreen{Help} button to the given pane, where clicking the
|
||||
button opens a new window to display @filepath{doc.txt} from the given
|
||||
collection. The @scheme[str] argument is used for the help window
|
||||
title. If @scheme[tt?] is true, then @filepath{doc.txt} is displayed
|
||||
verbatim, otherwise it is formatted as for @scheme[show-help] from
|
||||
@schememodname[games/show-help].}
|
||||
collection. The @racket[str] argument is used for the help window
|
||||
title. If @racket[tt?] is true, then @filepath{doc.txt} is displayed
|
||||
verbatim, otherwise it is formatted as for @racket[show-help] from
|
||||
@racketmodname[games/show-help].}
|
||||
|
||||
@defmethod[(add-scribble-button [pane (is-a?/c area-container<%>)]
|
||||
[mod-path module-path?]
|
||||
|
@ -386,7 +386,7 @@ Removes @scheme[card] from the table.}
|
|||
|
||||
Adds a @onscreen{Help} button to the given pane, where clicking the
|
||||
button opens Scribble-based documentation, as with
|
||||
@scheme[show-scribbling] from @schememodname[games/show-scribbling].}
|
||||
@racket[show-scribbling] from @racketmodname[games/show-scribbling].}
|
||||
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,7 @@ Removes @scheme[card] from the table.}
|
|||
|
||||
@definterface[card<%> ()]{
|
||||
|
||||
Create instances with @scheme[make-deck] or @scheme[make-card].
|
||||
Create instances with @racket[make-deck] or @racket[make-card].
|
||||
|
||||
@defmethod[(card-width) exact-nonnegative-integer?]{
|
||||
|
||||
|
@ -422,62 +422,62 @@ Create instances with @scheme[make-deck] or @scheme[make-card].
|
|||
|
||||
@defmethod[(face-down?) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if the card is currently face down.}
|
||||
Returns @racket[#t] if the card is currently face down.}
|
||||
|
||||
@defmethod[(rotate [mode (or/c 'cw 'ccw 0 90 -90 180 -180 270 -270 360)]) void?]{
|
||||
|
||||
Rotates the card. Unlike using the @xmethod[table<%> rotate-card] method,
|
||||
the card's top-left position is kept in place.
|
||||
|
||||
If @scheme[mode] is @scheme['cw], the card is
|
||||
rotated clockwise; if @scheme[mode] is @scheme['ccw], the card is
|
||||
rotated counter-clockwise; if @scheme[mode] is one of the allowed
|
||||
If @racket[mode] is @racket['cw], the card is
|
||||
rotated clockwise; if @racket[mode] is @racket['ccw], the card is
|
||||
rotated counter-clockwise; if @racket[mode] is one of the allowed
|
||||
numbers, the card is rotated the corresponding amount in degrees
|
||||
counter-clockwise.}
|
||||
|
||||
@defmethod[(orientation) (or/c 0 90 180 270)]{
|
||||
|
||||
Returns the orientation of the card, where @scheme[0] corresponds to
|
||||
its initial state, @scheme[90] is rotated 90 degrees counter-clockwise, and so on.}
|
||||
Returns the orientation of the card, where @racket[0] corresponds to
|
||||
its initial state, @racket[90] is rotated 90 degrees counter-clockwise, and so on.}
|
||||
|
||||
@defmethod[(get-suit-id) any/c]{
|
||||
|
||||
Normally returns @scheme[1], @scheme[2], @scheme[3], or @scheme[4]
|
||||
Normally returns @racket[1], @racket[2], @racket[3], or @racket[4]
|
||||
(see @method[card<%> get-suit] for corresponding suit names), but the
|
||||
result can be anything for a card created by @scheme[make-card].}
|
||||
result can be anything for a card created by @racket[make-card].}
|
||||
|
||||
@defmethod[(get-suit) symbol?]{
|
||||
|
||||
Returns @scheme['clubs], @scheme['diamonds], @scheme['hearts],
|
||||
@scheme['spades], or @scheme['unknown], depending on whether
|
||||
@method[card<%> get-suit-id] returns @scheme[1], @scheme[2],
|
||||
@scheme[3], @scheme[4], or something else.}
|
||||
Returns @racket['clubs], @racket['diamonds], @racket['hearts],
|
||||
@racket['spades], or @racket['unknown], depending on whether
|
||||
@method[card<%> get-suit-id] returns @racket[1], @racket[2],
|
||||
@racket[3], @racket[4], or something else.}
|
||||
|
||||
@defmethod[(get-value) any/c]{
|
||||
|
||||
Normally returns @scheme[1] (Ace), @scheme[2], ... @scheme[10],
|
||||
@scheme[11] (Jack), @scheme[12] (Queen), or @scheme[13] (King), but
|
||||
the result can be anything for a card created by @scheme[make-card].}
|
||||
Normally returns @racket[1] (Ace), @racket[2], ... @racket[10],
|
||||
@racket[11] (Jack), @racket[12] (Queen), or @racket[13] (King), but
|
||||
the result can be anything for a card created by @racket[make-card].}
|
||||
|
||||
@defmethod*[([(user-can-flip) boolean?]
|
||||
[(user-can-flip [can? any/c]) void?])]{
|
||||
|
||||
Gets/sets whether the user can flip the card interactively, usually
|
||||
by double-clicking it. Initially @scheme[#t].}
|
||||
by double-clicking it. Initially @racket[#t].}
|
||||
|
||||
@defmethod*[([(user-can-move) boolean?]
|
||||
[(user-can-move [can? any/c]) void?])]{
|
||||
|
||||
Gets/sets whether the user can move the card interactively, usually
|
||||
by dragging it. Disabling moves has the side-effect of disabling
|
||||
raises and double-clicks. Initially @scheme[#t].}
|
||||
raises and double-clicks. Initially @racket[#t].}
|
||||
|
||||
@defmethod*[([(snap-back-after-move) boolean?]
|
||||
[(snap-back-after-move [on? any/c]) void?])]{
|
||||
|
||||
Assuming user can move the card interactively, gets/sets whether the
|
||||
card stays where the user dragged it or snaps back to its original
|
||||
place. Initially @scheme[#f].
|
||||
place. Initially @racket[#f].
|
||||
|
||||
A region's @italic{interactive} callback can disable snap-back for a
|
||||
card so that the card can be delivered to the region. (A region's
|
||||
|
@ -487,18 +487,18 @@ Create instances with @scheme[make-deck] or @scheme[make-card].
|
|||
[(stay-in-region [r (or/c region? false/c)]) void?])]{
|
||||
|
||||
|
||||
Gets/sets a constraining region @scheme[r]. If @scheme[r] is not
|
||||
@scheme[#f], the user cannot move the card out of @scheme[r].
|
||||
Initially @scheme[#f].}
|
||||
Gets/sets a constraining region @racket[r]. If @racket[r] is not
|
||||
@racket[#f], the user cannot move the card out of @racket[r].
|
||||
Initially @racket[#f].}
|
||||
|
||||
@defmethod*[([(home-region) (or/c region? false/c)]
|
||||
[(home-region [r (or/c region? false/c)]) void?])]{
|
||||
|
||||
Gets/sets a home region @scheme[r]. If @scheme[r] is not @scheme[#f],
|
||||
Gets/sets a home region @racket[r]. If @racket[r] is not @racket[#f],
|
||||
then the user can move the card freely within the region, but it
|
||||
snaps back if moved completely out of the region. If moved partly out
|
||||
of the region, the card is moved enough to get completely back
|
||||
in. Initially @scheme[#f].
|
||||
in. Initially @racket[#f].
|
||||
|
||||
A region's @italic{interactive} callback can disable snap-back for a
|
||||
card so that the card can be delivered to the region. (A region's
|
||||
|
|
|
@ -42,7 +42,7 @@ the Chat Noir game in a
|
|||
@section{Overview}
|
||||
|
||||
Chat Noir is implemented using @link["http://www.htdp.org/"]{HtDP}'s universe
|
||||
library: @schememodname[2htdp/universe]
|
||||
library: @racketmodname[2htdp/universe]
|
||||
(although it only uses the ``world'' portions of that library).
|
||||
The program is divided up into
|
||||
six parts: the world data definition, an implementation of breadth-first search,
|
||||
|
@ -65,7 +65,7 @@ and some code that builds an initial world and starts the game.
|
|||
<go>]
|
||||
|
||||
Each section also comes with a series of test cases that are collected into the
|
||||
@scheme[<tests>]
|
||||
@racket[<tests>]
|
||||
chunk at the end of the program.
|
||||
|
||||
@chunk[<tests>
|
||||
|
@ -77,8 +77,8 @@ chunk at the end of the program.
|
|||
<drawing-tests>
|
||||
<input-tests>]
|
||||
|
||||
Each test case uses either @scheme[test], a simple form that accepts two
|
||||
arguments and compares them with @scheme[equal?], or @scheme[test/set]
|
||||
Each test case uses either @racket[test], a simple form that accepts two
|
||||
arguments and compares them with @racket[equal?], or @racket[test/set]
|
||||
which accepts two lists and compares them as if they were sets.
|
||||
|
||||
In general, most of the test cases are left to the end of the document, organized
|
||||
|
@ -98,7 +98,7 @@ construct empty worlds and test cases for them.
|
|||
@chunk[<world-tests>
|
||||
<empty-world-test> <empty-board-test> <blocked-cells-tests>]
|
||||
|
||||
The main structure definition is the @scheme[world] struct.
|
||||
The main structure definition is the @racket[world] struct.
|
||||
|
||||
@chunk[<world-struct>
|
||||
(define-struct/contract world ([board (listof cell?)]
|
||||
|
@ -121,50 +121,50 @@ It consists of a structure with six fields:
|
|||
@tt{cell}s, one for each circle on the game.
|
||||
}
|
||||
|
||||
@item{@tt{cat}: a @scheme[posn] indicating the position of the cat
|
||||
(interpreting the @scheme[posn] in the way that they are interpreted
|
||||
@item{@tt{cat}: a @racket[posn] indicating the position of the cat
|
||||
(interpreting the @racket[posn] in the way that they are interpreted
|
||||
for the @tt{board} field),}
|
||||
|
||||
@item{@tt{state}: the state of the game, which can be one of
|
||||
@itemize[
|
||||
@item{@scheme['playing], indicating that the game is still going; this is the
|
||||
@item{@racket['playing], indicating that the game is still going; this is the
|
||||
initial state.}
|
||||
@item{@scheme['cat-won], indicating that the game is over and the
|
||||
@item{@racket['cat-won], indicating that the game is over and the
|
||||
cat won, or}
|
||||
@item{@scheme['cat-lost], indicating that the game is over and the
|
||||
@item{@racket['cat-lost], indicating that the game is over and the
|
||||
cat lost.}]}
|
||||
|
||||
@item{@tt{size}: an odd natural number indicating the size of the board}
|
||||
|
||||
@item{@tt{mouse-posn}: a @scheme[posn] for the location of the
|
||||
mouse (or @scheme[#f] if the mouse is not in the window), and}
|
||||
@item{@tt{mouse-posn}: a @racket[posn] for the location of the
|
||||
mouse (or @racket[#f] if the mouse is not in the window), and}
|
||||
|
||||
@item{@tt{h-down?}: a boolean indicating if the @tt{h} key is being
|
||||
pushed down.}
|
||||
]
|
||||
|
||||
A @scheme[cell] is a structure with two fields:
|
||||
A @racket[cell] is a structure with two fields:
|
||||
|
||||
@chunk[<cell-struct>
|
||||
(define-struct/contract cell ([p posn?]
|
||||
[blocked? boolean?])
|
||||
#:transparent)]
|
||||
|
||||
|
||||
The coordinates of
|
||||
the @scheme[posn] in the first field
|
||||
the @racket[posn] in the first field
|
||||
indicate a position on the hexagonal grid.
|
||||
This program reprsents the hexagon grid as a series of rows that
|
||||
are offset from each other by 1/2 the size of the each cell.
|
||||
The @tt{y} field
|
||||
of the @scheme[posn] refers to the row of the cell, and the @tt{x}
|
||||
of the @racket[posn] refers to the row of the cell, and the @tt{x}
|
||||
coordinate the position in the row. This means that, for example,
|
||||
@scheme[(make-posn 1 0)] is centered above @scheme[(make-posn 1 0)]
|
||||
and @scheme[(make-posn 1 1)].
|
||||
@racket[(make-posn 1 0)] is centered above @racket[(make-posn 1 0)]
|
||||
and @racket[(make-posn 1 1)].
|
||||
|
||||
The boolean in the @tt{blocked?} field indicates if the cell has been
|
||||
clicked on, thus blocking the cat from stepping there.
|
||||
|
||||
The @scheme[empty-board] function builds a list of @scheme[cell]s
|
||||
The @racket[empty-board] function builds a list of @racket[cell]s
|
||||
that correspond to an empty board. For example, here's what an empty
|
||||
7x7 board looks like, as a list of cells.
|
||||
|
||||
|
@ -189,7 +189,7 @@ their left-most cells.
|
|||
And here is how that board looks as a list of cells.
|
||||
|
||||
@chunk[<empty-board-test>
|
||||
|
||||
|
||||
(test (empty-board 3)
|
||||
(list
|
||||
(make-cell (make-posn 0 1) #f)
|
||||
|
@ -200,13 +200,13 @@ And here is how that board looks as a list of cells.
|
|||
(make-cell (make-posn 2 1) #f)
|
||||
(make-cell (make-posn 2 2) #f)))]
|
||||
|
||||
The @scheme[empty-board] function consists
|
||||
of two (nested) calls to @scheme[build-list]
|
||||
The @racket[empty-board] function consists
|
||||
of two (nested) calls to @racket[build-list]
|
||||
that build a list of lists of cells, one for
|
||||
each pair of coordinates between @scheme[0]
|
||||
and @scheme[board-size]. Then, @scheme[append]
|
||||
each pair of coordinates between @racket[0]
|
||||
and @racket[board-size]. Then, @racket[append]
|
||||
flattens the nested lists and the
|
||||
@scheme[filter] expression removes the corners.
|
||||
@racket[filter] expression removes the corners.
|
||||
|
||||
@chunk[<empty-board>
|
||||
(define/contract (empty-board board-size)
|
||||
|
@ -237,13 +237,13 @@ flattens the nested lists and the
|
|||
Building an empty world is simply
|
||||
a matter of building an empty board, finding
|
||||
the initial position of the cat and filling
|
||||
in all of the fields of the @scheme[world] struct.
|
||||
For example, this is the empty world of size @scheme[3].
|
||||
It puts the cat at @scheme[(make-posn 1 1)],
|
||||
sets the state to @scheme['playing], records the
|
||||
size @scheme[3], and sets the current mouse position
|
||||
to @scheme[#f] and the state of the ``h'' key to
|
||||
@scheme[#f].
|
||||
in all of the fields of the @racket[world] struct.
|
||||
For example, this is the empty world of size @racket[3].
|
||||
It puts the cat at @racket[(make-posn 1 1)],
|
||||
sets the state to @racket['playing], records the
|
||||
size @racket[3], and sets the current mouse position
|
||||
to @racket[#f] and the state of the ``h'' key to
|
||||
@racket[#f].
|
||||
|
||||
@chunk[<empty-world-test>
|
||||
|
||||
|
@ -256,7 +256,7 @@ to @scheme[#f] and the state of the ``h'' key to
|
|||
#f))]
|
||||
|
||||
|
||||
The @scheme[empty-world] function
|
||||
The @racket[empty-world] function
|
||||
generalizes the example by computing the
|
||||
cats initial position as the center spot on the board.
|
||||
|
||||
|
@ -273,16 +273,16 @@ cats initial position as the center spot on the board.
|
|||
#f
|
||||
#f))]
|
||||
|
||||
The @scheme[add-n-random-blocked-cells] function accepts a list of cells
|
||||
and returns a new list of cells where @scheme[n] of the unblocked cells
|
||||
in @scheme[all-cells] are now blocked.
|
||||
The @racket[add-n-random-blocked-cells] function accepts a list of cells
|
||||
and returns a new list of cells where @racket[n] of the unblocked cells
|
||||
in @racket[all-cells] are now blocked.
|
||||
|
||||
If @scheme[n] is zero, of course, no more cells should be blocked,
|
||||
so the result is just @scheme[all-cells]. Otherwise,
|
||||
the function computes @scheme[unblocked-cells], a list of all
|
||||
If @racket[n] is zero, of course, no more cells should be blocked,
|
||||
so the result is just @racket[all-cells]. Otherwise,
|
||||
the function computes @racket[unblocked-cells], a list of all
|
||||
of the unblocked cells (except the cat's initial location),
|
||||
and then randomly picks a cell from it,
|
||||
calling @scheme[block-cell] to actually block that cell.
|
||||
calling @racket[block-cell] to actually block that cell.
|
||||
|
||||
@chunk[<blocked-cells>
|
||||
(define/contract (add-n-random-blocked-cells n all-cells board-size)
|
||||
|
@ -309,9 +309,9 @@ calling @scheme[block-cell] to actually block that cell.
|
|||
board-size))]))]
|
||||
|
||||
|
||||
The @scheme[block-cell] function accepts a @scheme[posn]
|
||||
and a list of @scheme[cell] structs and updates the
|
||||
relevant cell, setting its @tt{blocked?} field to @scheme[#t].
|
||||
The @racket[block-cell] function accepts a @racket[posn]
|
||||
and a list of @racket[cell] structs and updates the
|
||||
relevant cell, setting its @tt{blocked?} field to @racket[#t].
|
||||
|
||||
@chunk[<block-cell>
|
||||
(define/contract (block-cell to-block board)
|
||||
|
@ -325,7 +325,7 @@ relevant cell, setting its @tt{blocked?} field to @scheme[#t].
|
|||
|
||||
The cat's move decision is based on a breadth-first search of a graph.
|
||||
The graph's nodes are the cells on the board plus a special
|
||||
node called @scheme['boundary] that is adjacent to every cell
|
||||
node called @racket['boundary] that is adjacent to every cell
|
||||
on the boundary of the graph. In addition to the boundary edges,
|
||||
there are edges
|
||||
between each pair of adjacent cells, unless one of the cells is
|
||||
|
@ -343,21 +343,21 @@ details of how the graph connectivity is computed from the board to the next sec
|
|||
<lookup-in-table-tests>
|
||||
<build-bfs-table-tests>]
|
||||
|
||||
The breadth-first function constructs a @scheme[distance-map],
|
||||
which is a list of @scheme[dist-cell] structs:
|
||||
The breadth-first function constructs a @racket[distance-map],
|
||||
which is a list of @racket[dist-cell] structs:
|
||||
|
||||
@chunk[<dist-cell-data-definition>
|
||||
(define-struct/contract dist-cell ([p (or/c 'boundary posn?)]
|
||||
[n natural-number/c])
|
||||
#:transparent)]
|
||||
|
||||
Each @tt{p} field in the @scheme[dist-cell] is a position on the board
|
||||
Each @tt{p} field in the @racket[dist-cell] is a position on the board
|
||||
and the @tt{n} field is a natural number, indicating
|
||||
the distance of the shortest path from the node to some fixed point on
|
||||
the board.
|
||||
|
||||
The function @scheme[lookup-in-table] returns the distance from the fixed
|
||||
point to the given posn, returning @scheme['∞] if the posn is not in the
|
||||
The function @racket[lookup-in-table] returns the distance from the fixed
|
||||
point to the given posn, returning @racket['∞] if the posn is not in the
|
||||
table.
|
||||
|
||||
@chunk[<lookup-in-table>
|
||||
|
@ -372,7 +372,7 @@ table.
|
|||
[else
|
||||
(lookup-in-table (rest t) p)])]))]
|
||||
|
||||
The @scheme[build-bfs-table] accepts a world and a cell
|
||||
The @racket[build-bfs-table] accepts a world and a cell
|
||||
(indicating the fixed point)
|
||||
and returns a distance map encoding the distance to that cell.
|
||||
For example, here is the distance map for the distance to the boundary.
|
||||
|
@ -397,15 +397,15 @@ The boundary is zero steps away; each of the cells that are on the boundary
|
|||
are one step away and the center is two steps away.
|
||||
|
||||
The core of the breadth-first search is this function,
|
||||
@scheme[bst]. It accepts a queue of the pending nodes to visit
|
||||
and a @scheme[dist-table] that records the same information as a
|
||||
@scheme[distance-map], but in an immutable hash-table. The
|
||||
@scheme[dist-map] is an accumulator, recording the distances
|
||||
@racket[bst]. It accepts a queue of the pending nodes to visit
|
||||
and a @racket[dist-table] that records the same information as a
|
||||
@racket[distance-map], but in an immutable hash-table. The
|
||||
@racket[dist-map] is an accumulator, recording the distances
|
||||
to all of the nodes that have already been visited in the graph,
|
||||
and is used here to speed up the compuation. The queue is
|
||||
represented as a list of vectors of length two. Each element
|
||||
in the queue contains a @scheme[posn], or the symbol @scheme['boundary]
|
||||
and that @scheme[posn]'s distance.
|
||||
in the queue contains a @racket[posn], or the symbol @racket['boundary]
|
||||
and that @racket[posn]'s distance.
|
||||
|
||||
@chunk[<bfs>
|
||||
|
||||
|
@ -430,23 +430,23 @@ and that @scheme[posn]'s distance.
|
|||
(neighbors/w p)))
|
||||
(hash-set dist-table p dist))]))]))]
|
||||
|
||||
If the @scheme[queue] is empty, then the accumulator contains
|
||||
If the @racket[queue] is empty, then the accumulator contains
|
||||
bindings for all of the (reachable) nodes in the graph, so
|
||||
we just return it. If it isn't empty, then we extract
|
||||
the first element from the queue and name its consituents
|
||||
@scheme[p] and @scheme[dist].
|
||||
@racket[p] and @racket[dist].
|
||||
Next we check to see if the node at the head of the queue
|
||||
is in @scheme[dist-table]. If it is, we just move on to the
|
||||
next element in the queue. If that node is not in the @scheme[dist-table],
|
||||
then we add all of the neighbors to the queue, in the @scheme[append]
|
||||
expression, and update the @scheme[dist-table] with the distance to
|
||||
is in @racket[dist-table]. If it is, we just move on to the
|
||||
next element in the queue. If that node is not in the @racket[dist-table],
|
||||
then we add all of the neighbors to the queue, in the @racket[append]
|
||||
expression, and update the @racket[dist-table] with the distance to
|
||||
this node. Because we always add the new children to the end of the queue
|
||||
and always look at the front of the queue, we are guaranteed that
|
||||
the first time we see a node, it will be with the shortest distance.
|
||||
|
||||
The @scheme[build-bfs-table] function packages up @scheme[bfs]
|
||||
function. It accepts a @scheme[world] and an initial position
|
||||
and returns a @scheme[distance-table].
|
||||
The @racket[build-bfs-table] function packages up @racket[bfs]
|
||||
function. It accepts a @racket[world] and an initial position
|
||||
and returns a @racket[distance-table].
|
||||
|
||||
@chunk[<build-bfs-table>
|
||||
|
||||
|
@ -461,16 +461,16 @@ and returns a @scheme[distance-table].
|
|||
(make-immutable-hash '()))
|
||||
make-dist-cell))]
|
||||
|
||||
As you can see, the first thing it does is bind the free variable in @scheme[bfs]
|
||||
to the result of calling the @scheme[neighbors] function (defined in the chunk
|
||||
@scheme[<neighbors>]) and then it has the @scheme[<bfs>] chunk. In the body
|
||||
it calls the @scheme[bfs] function
|
||||
As you can see, the first thing it does is bind the free variable in @racket[bfs]
|
||||
to the result of calling the @racket[neighbors] function (defined in the chunk
|
||||
@racket[<neighbors>]) and then it has the @racket[<bfs>] chunk. In the body
|
||||
it calls the @racket[bfs] function
|
||||
and then transforms the result, using
|
||||
@scheme[hash-map], into a list of @scheme[cell]s.
|
||||
@racket[hash-map], into a list of @racket[cell]s.
|
||||
|
||||
@section{Board to Graph}
|
||||
|
||||
As far as the @scheme[build-bfs-table] function goes,
|
||||
As far as the @racket[build-bfs-table] function goes,
|
||||
all of the information specific to Chat Noir is
|
||||
encoded in the neighbors function.
|
||||
It accepts a world and returns a function
|
||||
|
@ -491,11 +491,11 @@ it is implemented.
|
|||
<adjacent-tests>
|
||||
<neighbors-tests>]
|
||||
|
||||
The neighbors functions accepts a @scheme[world] and then
|
||||
returns a function that computes the neighbors of a @scheme[posn]
|
||||
and of the @scheme['boundary].
|
||||
The neighbors functions accepts a @racket[world] and then
|
||||
returns a function that computes the neighbors of a @racket[posn]
|
||||
and of the @racket['boundary].
|
||||
|
||||
For example, @scheme[(make-posn 1 0)] has four
|
||||
For example, @racket[(make-posn 1 0)] has four
|
||||
neighbors:
|
||||
|
||||
@chunk[<neighbors-tests>
|
||||
|
@ -505,7 +505,7 @@ neighbors:
|
|||
(make-posn 0 1)
|
||||
(make-posn 1 1)))]
|
||||
|
||||
and @scheme[(make-posn 0 1)] has four neighbors:
|
||||
and @racket[(make-posn 0 1)] has four neighbors:
|
||||
|
||||
@chunk[<neighbors-tests>
|
||||
(test ((neighbors (empty-world 7)) (make-posn 0 1))
|
||||
|
@ -527,7 +527,7 @@ Also, there are 6 neighbors of the boundary in the 3x3 board:
|
|||
(make-posn 2 1)
|
||||
(make-posn 2 2)))]
|
||||
|
||||
This is the neighbors function. After it accepts the @scheme[world],
|
||||
This is the neighbors function. After it accepts the @racket[world],
|
||||
it builds a list of the blocked cells in the world and a
|
||||
list of the cells that are on the boundary (and not blocked). Then it
|
||||
returns a function that is specialized to those values.
|
||||
|
@ -554,17 +554,17 @@ returns a function that is specialized to those values.
|
|||
(world-size w)
|
||||
p)))]
|
||||
|
||||
The @scheme[neighbors-blocked/boundary] function is given next.
|
||||
If @scheme[p] is blocked, it returns the empty list. If it is
|
||||
on the boundary, the function simply returns @scheme[boundary-cells].
|
||||
Otherwise, @scheme[neighbors-blocked/boundary] calls
|
||||
@scheme[adjacent] to compute the posns that are adjacent to @scheme[p],
|
||||
filtering out the blocked @scheme[posn]s and binds that to @scheme[adjacent-posns].
|
||||
It then filters out the @scheme[posn]s that would be outside of the board.
|
||||
If those two lists are the same, then @scheme[p] is not on the boundary,
|
||||
so we just return @scheme[in-bounds]. If the lists are different, then
|
||||
we know that @scheme[p] must have been on the boundary, so we add
|
||||
@scheme['boundary] to the result list.
|
||||
The @racket[neighbors-blocked/boundary] function is given next.
|
||||
If @racket[p] is blocked, it returns the empty list. If it is
|
||||
on the boundary, the function simply returns @racket[boundary-cells].
|
||||
Otherwise, @racket[neighbors-blocked/boundary] calls
|
||||
@racket[adjacent] to compute the posns that are adjacent to @racket[p],
|
||||
filtering out the blocked @racket[posn]s and binds that to @racket[adjacent-posns].
|
||||
It then filters out the @racket[posn]s that would be outside of the board.
|
||||
If those two lists are the same, then @racket[p] is not on the boundary,
|
||||
so we just return @racket[in-bounds]. If the lists are different, then
|
||||
we know that @racket[p] must have been on the boundary, so we add
|
||||
@racket['boundary] to the result list.
|
||||
|
||||
@chunk[<neighbors-blocked/boundary>
|
||||
(define/contract (neighbors-blocked/boundary blocked
|
||||
|
@ -598,17 +598,17 @@ we know that @scheme[p] must have been on the boundary, so we add
|
|||
|
||||
|
||||
There are the three functions that build the basic graph structure
|
||||
from a board as used by @scheme[neighbors].
|
||||
from a board as used by @racket[neighbors].
|
||||
|
||||
The first function is @scheme[adjacent]. It consumes a
|
||||
@scheme[posn] and returns six @scheme[posn]s that
|
||||
The first function is @racket[adjacent]. It consumes a
|
||||
@racket[posn] and returns six @racket[posn]s that
|
||||
indicate what the neighbors are, without consideration
|
||||
of the size of the board (or the missing corner pieces).
|
||||
|
||||
For example, these are the @scheme[posn]s that are adjacent
|
||||
to @scheme[(make-posn 0 1)]; note that the first and the third
|
||||
For example, these are the @racket[posn]s that are adjacent
|
||||
to @racket[(make-posn 0 1)]; note that the first and the third
|
||||
are not on the board and do not show up in
|
||||
@scheme[neighbors] function example above.
|
||||
@racket[neighbors] function example above.
|
||||
|
||||
@chunk[<adjacent-tests>
|
||||
(test (adjacent (make-posn 0 1))
|
||||
|
@ -620,7 +620,7 @@ are not on the board and do not show up in
|
|||
(make-posn 1 2)))]
|
||||
|
||||
The adjacent function has two main cases; first when the
|
||||
@scheme[y] coordinate of the @scheme[posn] is even and
|
||||
@racket[y] coordinate of the @racket[posn] is even and
|
||||
second when it is odd. In each case, it is just a matter
|
||||
of looking at the board and calculating coordinate offsets.
|
||||
|
||||
|
@ -647,10 +647,10 @@ of looking at the board and calculating coordinate offsets.
|
|||
(make-posn x (+ y 1))
|
||||
(make-posn (+ x 1) (+ y 1)))])))]
|
||||
|
||||
The @scheme[on-boundary?] function returns @scheme[#t] when
|
||||
The @racket[on-boundary?] function returns @racket[#t] when
|
||||
the posn would be on the boundary of a board of size
|
||||
@scheme[board-size]. Note that this function does not
|
||||
have to special case the missing @scheme[posn]s from the corners.
|
||||
@racket[board-size]. Note that this function does not
|
||||
have to special case the missing @racket[posn]s from the corners.
|
||||
|
||||
@chunk[<on-boundary?>
|
||||
(define/contract (on-boundary? p board-size)
|
||||
|
@ -661,10 +661,10 @@ have to special case the missing @scheme[posn]s from the corners.
|
|||
(= (posn-x p) (- board-size 1))
|
||||
(= (posn-y p) (- board-size 1))))]
|
||||
|
||||
The @scheme[in-bounds?] function returns @scheme[#t]
|
||||
when the @scheme[posn] is actually on the board, meaning
|
||||
that the coordinates of the @scheme[posn] are within the
|
||||
board's size, and that the @scheme[posn] is not one
|
||||
The @racket[in-bounds?] function returns @racket[#t]
|
||||
when the @racket[posn] is actually on the board, meaning
|
||||
that the coordinates of the @racket[posn] are within the
|
||||
board's size, and that the @racket[posn] is not one
|
||||
of the two corners that have been removed.
|
||||
|
||||
@chunk[<in-bounds?>
|
||||
|
@ -689,12 +689,12 @@ determines where the shortest paths from the cat's current position to the bound
|
|||
<on-cats-path?-tests>
|
||||
<+/f-tests>]
|
||||
|
||||
The function @scheme[on-cats-path?] accepts a world and returns a predicate
|
||||
on the @scheme[posn]s in the world. The predicate indicates if the given
|
||||
@scheme[posn] is on the shortest path.
|
||||
The function @racket[on-cats-path?] accepts a world and returns a predicate
|
||||
on the @racket[posn]s in the world. The predicate indicates if the given
|
||||
@racket[posn] is on the shortest path.
|
||||
|
||||
For example, in a world of size @scheme[7] with the cat at
|
||||
@scheme[(make-posn 2 2)], the circles with white centers
|
||||
For example, in a world of size @racket[7] with the cat at
|
||||
@racket[(make-posn 2 2)], the circles with white centers
|
||||
are on the shortest path to the boundary:
|
||||
|
||||
@image["chat-noir/cat-distance-example.png"]
|
||||
|
@ -723,7 +723,7 @@ the cat to the boundary.
|
|||
|
||||
The code is essentially that, plus two other special cases. Specifically if the
|
||||
``h'' key is not pressed down, then we just consider no cells to be on that shortest
|
||||
path. And if the distance to the cat is @scheme['∞], then again no nodes are on the
|
||||
path. And if the distance to the cat is @racket['∞], then again no nodes are on the
|
||||
path. The second situation happens when the cat is completely boxed in and has
|
||||
lost the game.
|
||||
|
||||
|
@ -748,8 +748,8 @@ lost the game.
|
|||
[else
|
||||
(lambda (p) #f)]))]
|
||||
|
||||
Finally, the helper function @scheme[+/f] is just like @scheme[+], except that
|
||||
it returns @scheme['∞] if either argument is @scheme['∞].
|
||||
Finally, the helper function @racket[+/f] is just like @racket[+], except that
|
||||
it returns @racket['∞] if either argument is @racket['∞].
|
||||
|
||||
@chunk[<+/f>
|
||||
(define (+/f x y)
|
||||
|
@ -762,15 +762,15 @@ it returns @scheme['∞] if either argument is @scheme['∞].
|
|||
@section{Drawing the Cat}
|
||||
|
||||
This code is three large, similar constants,
|
||||
bundled up into the @scheme[cat] function.
|
||||
The @scheme[thinking-cat] is the one that
|
||||
bundled up into the @racket[cat] function.
|
||||
The @racket[thinking-cat] is the one that
|
||||
is visible when the game is being played. It
|
||||
differs from the others in that it does not
|
||||
have a mouth. The @scheme[mad-cat] is the one
|
||||
have a mouth. The @racket[mad-cat] is the one
|
||||
that you see when the cat loses. It differs
|
||||
from the others in that its pinks turn pink.
|
||||
Finally, the @scheme[happy-cat] shows up when
|
||||
the cat wins and it is just like the @scheme[thinking-cat]
|
||||
Finally, the @racket[happy-cat] shows up when
|
||||
the cat wins and it is just like the @racket[thinking-cat]
|
||||
except it has a smile.
|
||||
|
||||
@chunk[<drawing-the-cat>
|
||||
|
@ -880,9 +880,9 @@ of the circles that are drawn on the board,
|
|||
plus the radius of an invisible circle
|
||||
that, if they were drawn on top of
|
||||
the circles, would touch
|
||||
each other. Accordingly, @scheme[circle-spacing]
|
||||
each other. Accordingly, @racket[circle-spacing]
|
||||
is used when computing the positions of the circles,
|
||||
but the circles are drawn using @scheme[circle-radius].
|
||||
but the circles are drawn using @racket[circle-radius].
|
||||
|
||||
@chunk[<constants>
|
||||
(define circle-radius 20)
|
||||
|
@ -896,7 +896,7 @@ The other four constants specify the colors of the circles.
|
|||
(define blocked-color 'black)
|
||||
(define under-mouse-color 'black)]
|
||||
|
||||
The main function for drawing a world is @scheme[render-world].
|
||||
The main function for drawing a world is @racket[render-world].
|
||||
It is a fairly straightforward composition of helper functions.
|
||||
First, it builds the image of a board, and then puts the cat on it.
|
||||
Lastly, since the whiskers of the cat might now hang off of the edge
|
||||
|
@ -921,7 +921,7 @@ and that the pinhole is always in the upper-left corner of the window.
|
|||
|
||||
Trimming the cat's whiskers amounts to removing any extra
|
||||
space in the image that appears to the left or above the pinhole.
|
||||
For example, the @scheme[rectangle] function returns
|
||||
For example, the @racket[rectangle] function returns
|
||||
an image with a pinhole in the middle. So trimming 5x5
|
||||
rectangle results in a 3x3 rectangle with the pinhole
|
||||
at (0,0).
|
||||
|
@ -930,7 +930,7 @@ at (0,0).
|
|||
(test (chop-whiskers (rectangle 5 5 'solid 'black))
|
||||
(put-pinhole (rectangle 3 3 'solid 'black) 0 0))]
|
||||
|
||||
The function uses @scheme[shrink] to remove all of the material above
|
||||
The function uses @racket[shrink] to remove all of the material above
|
||||
and to the left of the pinhole.
|
||||
|
||||
@chunk[<chop-whiskers>
|
||||
|
@ -942,9 +942,9 @@ and to the left of the pinhole.
|
|||
(- (image-width img) (pinhole-x img) 1)
|
||||
(- (image-height img) (pinhole-y img) 1)))]
|
||||
|
||||
The @scheme[render-board] function uses @scheme[for/fold] to iterate
|
||||
over all of the @scheme[cell]s in @scheme[cs]. It starts with
|
||||
an empty rectangle and, one by one, puts the cells on @scheme[image].
|
||||
The @racket[render-board] function uses @racket[for/fold] to iterate
|
||||
over all of the @racket[cell]s in @racket[cs]. It starts with
|
||||
an empty rectangle and, one by one, puts the cells on @racket[image].
|
||||
|
||||
@chunk[<render-board>
|
||||
;; render-board : board number (posn -> boolean) posn-or-#f -> image
|
||||
|
@ -965,7 +965,7 @@ an empty rectangle and, one by one, puts the cells on @scheme[image].
|
|||
(and (posn? mouse)
|
||||
(equal? mouse (cell-p c)))))))]
|
||||
|
||||
The @scheme[render-cell] function accepts a @scheme[cell],
|
||||
The @racket[render-cell] function accepts a @racket[cell],
|
||||
a boolean indicating if the cell is on the shortest path between
|
||||
the cat and the boundary, and a second boolean indicating
|
||||
if the cell is underneath the mouse. It returns an image
|
||||
|
@ -998,7 +998,7 @@ results in the cell being placed in the right place.
|
|||
(- x)
|
||||
(- y))))]
|
||||
|
||||
The @scheme[world-width] function computes the width of the rendered world,
|
||||
The @racket[world-width] function computes the width of the rendered world,
|
||||
given the world's size by finding the center of the rightmost posn,
|
||||
and then adding an additional radius.
|
||||
|
||||
|
@ -1009,7 +1009,7 @@ and then adding an additional radius.
|
|||
(make-posn (- board-size 1) (- board-size 2))])
|
||||
(+ (cell-center-x rightmost-posn) circle-radius)))]
|
||||
|
||||
Similarly, the @scheme[world-height] function computest the
|
||||
Similarly, the @racket[world-height] function computest the
|
||||
height of the rendered world, given the world's size.
|
||||
|
||||
@chunk[<world-height>
|
||||
|
@ -1020,12 +1020,12 @@ height of the rendered world, given the world's size.
|
|||
(ceiling (+ (cell-center-y bottommost-posn)
|
||||
circle-radius))))]
|
||||
|
||||
The @scheme[cell-center-x] function returns the
|
||||
The @racket[cell-center-x] function returns the
|
||||
@tt{x} coordinate of the center of the cell specified
|
||||
by @scheme[p].
|
||||
by @racket[p].
|
||||
|
||||
For example, the first cell in
|
||||
the third row (counting from @scheme[0]) is
|
||||
the third row (counting from @racket[0]) is
|
||||
flush with the edge of the screen, so its
|
||||
center is just the radius of the circle that
|
||||
is drawn.
|
||||
|
@ -1037,20 +1037,20 @@ is drawn.
|
|||
|
||||
The first cell in the second row, in contrast
|
||||
is offset from the third row by
|
||||
@scheme[circle-spacing].
|
||||
@racket[circle-spacing].
|
||||
|
||||
@chunk[<cell-center-x-tests>
|
||||
(test (cell-center-x (make-posn 0 1))
|
||||
(+ circle-spacing circle-radius))]
|
||||
|
||||
|
||||
The definition of @scheme[cell-center-x]
|
||||
multiplies the @scheme[x] coordinate of
|
||||
@scheme[p] by twice @scheme[circle-spacing]
|
||||
and then adds @scheme[circle-radius] to move
|
||||
The definition of @racket[cell-center-x]
|
||||
multiplies the @racket[x] coordinate of
|
||||
@racket[p] by twice @racket[circle-spacing]
|
||||
and then adds @racket[circle-radius] to move
|
||||
over for the first circle. In addition
|
||||
if the @scheme[y] coordinate is odd, then
|
||||
it adds @scheme[circle-spacing], shifting
|
||||
if the @racket[y] coordinate is odd, then
|
||||
it adds @racket[circle-spacing], shifting
|
||||
the entire line over.
|
||||
|
||||
@chunk[<cell-center-x>
|
||||
|
@ -1064,9 +1064,9 @@ the entire line over.
|
|||
circle-spacing
|
||||
0))))]
|
||||
|
||||
The @scheme[cell-center-y] function computes the
|
||||
@scheme[y] coordinate of a cell's location on
|
||||
the screen. For example, the @scheme[y]
|
||||
The @racket[cell-center-y] function computes the
|
||||
@racket[y] coordinate of a cell's location on
|
||||
the screen. For example, the @racket[y]
|
||||
coordinate of the first row is
|
||||
the radius of a circle, ensuring that
|
||||
the first row is flush against the top of
|
||||
|
@ -1076,10 +1076,10 @@ the screen.
|
|||
(test (cell-center-y (make-posn 1 0))
|
||||
circle-radius)]
|
||||
|
||||
Because the grid is hexagonal, the @scheme[y] coordinates
|
||||
of the rows do not have the same spacing as the @scheme[x]
|
||||
Because the grid is hexagonal, the @racket[y] coordinates
|
||||
of the rows do not have the same spacing as the @racket[x]
|
||||
coordinates. In particular, they are off by
|
||||
@tt{sin(pi/3)}. We approximate that by @scheme[866/1000]
|
||||
@tt{sin(pi/3)}. We approximate that by @racket[866/1000]
|
||||
in order to keep the computations and test cases simple
|
||||
and using exact numbers.
|
||||
A more precise approximation would be
|
||||
|
@ -1123,7 +1123,7 @@ plus various helper functions.
|
|||
<update-world-posn-tests>
|
||||
<clack-tests>]
|
||||
|
||||
The @scheme[change] function handles keyboard input. If the input is @litchar{n} and the
|
||||
The @racket[change] function handles keyboard input. If the input is @litchar{n} and the
|
||||
game is over, then restart the game. If the input is @litchar{h} then turn on the help
|
||||
and otherwise do nothing.
|
||||
|
||||
|
@ -1144,7 +1144,7 @@ and otherwise do nothing.
|
|||
#t)]
|
||||
[else w]))]
|
||||
|
||||
The @scheme[release] function adjusts the world for a key release event.
|
||||
The @racket[release] function adjusts the world for a key release event.
|
||||
|
||||
@chunk[<release>
|
||||
;; release : world key-event -> world
|
||||
|
@ -1159,15 +1159,15 @@ The @scheme[release] function adjusts the world for a key release event.
|
|||
(world-h-down? w))))]
|
||||
|
||||
|
||||
The @scheme[clack] function handles mouse input. It has three tasks and each corresponds
|
||||
The @racket[clack] function handles mouse input. It has three tasks and each corresponds
|
||||
to a helper function:
|
||||
@itemize[
|
||||
@item{block the clicked cell (@scheme[block-cell/world]),}
|
||||
@item{move the cat (@scheme[move-cat]), and}
|
||||
@item{update the black dot as the mouse moves around (@scheme[update-world-posn]).}]
|
||||
The helper functions are combined in the body of @scheme[clack],
|
||||
@item{block the clicked cell (@racket[block-cell/world]),}
|
||||
@item{move the cat (@racket[move-cat]), and}
|
||||
@item{update the black dot as the mouse moves around (@racket[update-world-posn]).}]
|
||||
The helper functions are combined in the body of @racket[clack],
|
||||
first checking to see if the mouse event corresponds to a
|
||||
player's move (via the @scheme[player-moved?] function.
|
||||
player's move (via the @racket[player-moved?] function.
|
||||
|
||||
@chunk[<clack>
|
||||
(define/contract (clack world x y evt)
|
||||
|
@ -1187,12 +1187,12 @@ player's move (via the @scheme[player-moved?] function.
|
|||
(not (equal? evt "leave"))
|
||||
(make-posn x y)))))]
|
||||
|
||||
The @scheme[player-moved?] predicate returns
|
||||
a @scheme[posn] indicating where the player chose
|
||||
The @racket[player-moved?] predicate returns
|
||||
a @racket[posn] indicating where the player chose
|
||||
to move when the mouse event corresponds to a player move,
|
||||
and returns @scheme[#f]. It first checks to see if the
|
||||
and returns @racket[#f]. It first checks to see if the
|
||||
mouse event is a button up event and that the game
|
||||
is not over, and then it just calls @scheme[circle-at-point].
|
||||
is not over, and then it just calls @racket[circle-at-point].
|
||||
|
||||
@chunk[<player-moved?>
|
||||
(define/contract (player-moved? world x y evt)
|
||||
|
@ -1202,11 +1202,11 @@ is not over, and then it just calls @scheme[circle-at-point].
|
|||
(equal? 'playing (world-state world))
|
||||
(circle-at-point (world-board world) x y)))]
|
||||
|
||||
The @scheme[circle-at-point] function returns a @scheme[posn] when
|
||||
the coordinate (@scheme[x],@scheme[y]) is inside an unblocked circle
|
||||
The @racket[circle-at-point] function returns a @racket[posn] when
|
||||
the coordinate (@racket[x],@racket[y]) is inside an unblocked circle
|
||||
on the given board. Instead of computing the nearest
|
||||
circle to the coordinates, it simply iterates over the cells on the
|
||||
board and returns the @scheme[posn] of the matching cell.
|
||||
board and returns the @racket[posn] of the matching cell.
|
||||
|
||||
@chunk[<circle-at-point>
|
||||
(define/contract (circle-at-point board x y)
|
||||
|
@ -1219,9 +1219,9 @@ board and returns the @scheme[posn] of the matching cell.
|
|||
board))]
|
||||
|
||||
|
||||
The @scheme[point-in-this-circle?] function returns @scheme[#t]
|
||||
when the point (@scheme[x],@scheme[y]) on the screen
|
||||
falls within the circle located at the @scheme[posn] @scheme[p].
|
||||
The @racket[point-in-this-circle?] function returns @racket[#t]
|
||||
when the point (@racket[x],@racket[y]) on the screen
|
||||
falls within the circle located at the @racket[posn] @racket[p].
|
||||
|
||||
This is precise about checking the circles. For example,
|
||||
a point that is (14,14) away from the center of a circle
|
||||
|
@ -1245,15 +1245,15 @@ since it crosses the boundary away from a circle of radius
|
|||
(+ (cell-center-y (make-posn 1 0)) 15))
|
||||
#f)]
|
||||
|
||||
The implementation of @scheme[point-in-this-circle?] uses
|
||||
The implementation of @racket[point-in-this-circle?] uses
|
||||
complex numbers to represent both points on the screen
|
||||
and directional vectors. In particular, the
|
||||
variable @scheme[center] is a complex number whose
|
||||
variable @racket[center] is a complex number whose
|
||||
real part is the @tt{x} coordinate of the center of
|
||||
the cell at @scheme[p], and its imaginary part is
|
||||
@tt{y} coordinate. Similarly, @scheme[mp] is bound
|
||||
the cell at @racket[p], and its imaginary part is
|
||||
@tt{y} coordinate. Similarly, @racket[mp] is bound
|
||||
to a complex number corresponding to the position of
|
||||
the mouse, at (@scheme[x], @scheme[y]). Then, the
|
||||
the mouse, at (@racket[x], @racket[y]). Then, the
|
||||
function computes the vector between the two points
|
||||
by subtracting the complex numbers from each
|
||||
other and extracting the magnitude from that vector.
|
||||
|
@ -1268,9 +1268,9 @@ other and extracting the magnitude from that vector.
|
|||
(<= (magnitude (- center mp))
|
||||
circle-radius)))]
|
||||
|
||||
In the event that @scheme[player-moved?] returns a @scheme[posn],
|
||||
the @scheme[clack] function blocks the clicked on cell using
|
||||
@scheme[block-cell/world], which simply calls @scheme[block-cell].
|
||||
In the event that @racket[player-moved?] returns a @racket[posn],
|
||||
the @racket[clack] function blocks the clicked on cell using
|
||||
@racket[block-cell/world], which simply calls @racket[block-cell].
|
||||
|
||||
@chunk[<block-cell/world>
|
||||
(define/contract (block-cell/world to-block w)
|
||||
|
@ -1282,12 +1282,12 @@ the @scheme[clack] function blocks the clicked on cell using
|
|||
(world-mouse-posn w)
|
||||
(world-h-down? w)))]
|
||||
|
||||
The @scheme[move-cat] function uses calls @scheme[build-bfs-table]
|
||||
The @racket[move-cat] function uses calls @racket[build-bfs-table]
|
||||
to find the shortest distance from all of the cells to the boundary,
|
||||
and then uses @scheme[find-best-positions] to compute the
|
||||
and then uses @racket[find-best-positions] to compute the
|
||||
list of neighbors of the cat that have the shortest distance
|
||||
to the boundary. If that list is empty, then @scheme[next-cat-position]
|
||||
is @scheme[#f], and otherwise, it is a random element from that list.
|
||||
to the boundary. If that list is empty, then @racket[next-cat-position]
|
||||
is @racket[#f], and otherwise, it is a random element from that list.
|
||||
|
||||
@chunk[<move-cat>
|
||||
(define/contract (move-cat world)
|
||||
|
@ -1308,7 +1308,7 @@ is @scheme[#f], and otherwise, it is a random element from that list.
|
|||
|
||||
<moved-cat-world>))]
|
||||
|
||||
Once @scheme[next-cat-position] has been computed, it is used to update
|
||||
Once @racket[next-cat-position] has been computed, it is used to update
|
||||
the @tt{cat} and @tt{state} fields of the world, recording the cat's new
|
||||
position and whether or not the cat won.
|
||||
|
||||
|
@ -1329,13 +1329,13 @@ position and whether or not the cat won.
|
|||
(world-h-down? world))]
|
||||
|
||||
|
||||
The @scheme[find-best-positions] function accepts
|
||||
two parallel lists, one of @scheme[posn]s, and one
|
||||
of scores for those @scheme[posn]s, and it
|
||||
returns either a non-empty list of @scheme[posn]s
|
||||
The @racket[find-best-positions] function accepts
|
||||
two parallel lists, one of @racket[posn]s, and one
|
||||
of scores for those @racket[posn]s, and it
|
||||
returns either a non-empty list of @racket[posn]s
|
||||
that have tied for the best score, or it
|
||||
returns @scheme[#f], if the best score is
|
||||
@scheme['∞].
|
||||
returns @racket[#f], if the best score is
|
||||
@racket['∞].
|
||||
|
||||
@chunk[<find-best-positions>
|
||||
(define/contract (find-best-positions posns scores)
|
||||
|
@ -1358,8 +1358,8 @@ returns @scheme[#f], if the best score is
|
|||
(map list scores posns)))])))]
|
||||
|
||||
This is a helper function that behaves like
|
||||
@scheme[<=], but is extended to deal properly with
|
||||
@scheme['∞].
|
||||
@racket[<=], but is extended to deal properly with
|
||||
@racket['∞].
|
||||
|
||||
@chunk[<lt/f>
|
||||
(define/contract (<=/f a b)
|
||||
|
@ -1372,13 +1372,13 @@ This is a helper function that behaves like
|
|||
[else (<= a b)]))]
|
||||
|
||||
|
||||
Finally, to complete the mouse event handling, the @scheme[update-world-posn]
|
||||
function is called from @scheme[clack]. It updates the @tt{mouse-down}
|
||||
field of the @scheme[world]. If the @scheme[p] argument is a @scheme[posn],
|
||||
Finally, to complete the mouse event handling, the @racket[update-world-posn]
|
||||
function is called from @racket[clack]. It updates the @tt{mouse-down}
|
||||
field of the @racket[world]. If the @racket[p] argument is a @racket[posn],
|
||||
it corresponds to the location of the mouse, in graphical coordinates.
|
||||
So, the function converts it to a cell position on the board and uses that.
|
||||
Otherwise, when @scheme[p] is @scheme[#f], the @tt{mouse-down} field
|
||||
is just updated to @scheme[#f].
|
||||
Otherwise, when @racket[p] is @racket[#f], the @tt{mouse-down} field
|
||||
is just updated to @racket[#f].
|
||||
|
||||
@chunk[<update-world-posn>
|
||||
(define/contract (update-world-posn w p)
|
||||
|
@ -1415,11 +1415,11 @@ This section consists of some infrastructure for
|
|||
maintaining tests, plus a pile of additional tests
|
||||
for the other functions in this document.
|
||||
|
||||
The @scheme[test] and @scheme[test/set] macros
|
||||
The @racket[test] and @racket[test/set] macros
|
||||
package up their arguments into thunks and then
|
||||
simply call @scheme[test/proc], supplying
|
||||
simply call @racket[test/proc], supplying
|
||||
information about the source location of the test
|
||||
case. The @scheme[test/proc] function runs the tests
|
||||
case. The @racket[test/proc] function runs the tests
|
||||
and reports the results.
|
||||
|
||||
@chunk[<test-infrastructure>
|
||||
|
@ -2391,7 +2391,7 @@ First, here is a function to compute state of the world at the start of a game.
|
|||
#f))]
|
||||
|
||||
Finally, we can define and provide a function to start the game
|
||||
by calling @scheme[big-bang] with the appropriate arguments.
|
||||
by calling @racket[big-bang] with the appropriate arguments.
|
||||
|
||||
@chunk[<go>
|
||||
(provide main)
|
||||
|
|
|
@ -21,81 +21,81 @@
|
|||
[move (any/c gl-vector? . -> . any) void]
|
||||
[who string? "this game"])]{
|
||||
|
||||
The @scheme[min-x], @scheme[max-x], @scheme[min-y], and @scheme[max-y]
|
||||
The @racket[min-x], @racket[max-x], @racket[min-y], and @racket[max-y]
|
||||
arguments specify the dimensions of the board plane to be visible in
|
||||
the window by default.
|
||||
|
||||
The @scheme[lift] argument specifies how many units a piece moves
|
||||
The @racket[lift] argument specifies how many units a piece moves
|
||||
vertically when the user clicks on it.
|
||||
|
||||
The @scheme[move] function is called when a piece is moved to a space
|
||||
The @racket[move] function is called when a piece is moved to a space
|
||||
(possibly it's current space), when a space is clicked on, and when a
|
||||
space is dragged to another space. The @scheme[move] function is
|
||||
space is dragged to another space. The @racket[move] function is
|
||||
given the information of the piece or space selected and the
|
||||
coordinates to which it is moved.
|
||||
|
||||
The @scheme[who] argument is used for reporting an error to the user
|
||||
The @racket[who] argument is used for reporting an error to the user
|
||||
when GL is unavailable at run time.}
|
||||
|
||||
|
||||
@defmethod[(add-space [draw (-> any)] [info any/c]) void?]{
|
||||
|
||||
Adds a space to the board. The @scheme[draw] thunk should draw the
|
||||
space (using GL commands) when called. The @scheme[info] value is
|
||||
given to the @scheme[_move] function (supplied to the constructor)
|
||||
Adds a space to the board. The @racket[draw] thunk should draw the
|
||||
space (using GL commands) when called. The @racket[info] value is
|
||||
given to the @racket[_move] function (supplied to the constructor)
|
||||
when the space is selected.}
|
||||
|
||||
|
||||
@defmethod[(add-piece [x real?][y real?][z real?]
|
||||
[draw ([shadow? boolean?] . -> . any)] [info any/c]) void?]{
|
||||
|
||||
Adds a piece to the board. The @scheme[draw] thunk should draw the
|
||||
piece (using GL commands) when called. The @scheme[info] argument is
|
||||
given to the @scheme[_move] function (supplied to the constructor)
|
||||
when the piece is moved. The piece is translated by @scheme[x],
|
||||
@scheme[y], and @scheme[z] before drawing.}
|
||||
Adds a piece to the board. The @racket[draw] thunk should draw the
|
||||
piece (using GL commands) when called. The @racket[info] argument is
|
||||
given to the @racket[_move] function (supplied to the constructor)
|
||||
when the piece is moved. The piece is translated by @racket[x],
|
||||
@racket[y], and @racket[z] before drawing.}
|
||||
|
||||
|
||||
@defmethod[(remove-piece [info any/c]) void?]{
|
||||
|
||||
Removes all pieces previously added with representative @scheme[info].}
|
||||
Removes all pieces previously added with representative @racket[info].}
|
||||
|
||||
|
||||
@defmethod[(add-heads-up [w real?] [h real?] [draw (-> any)] [info any/c]) void?]{
|
||||
|
||||
Add a ``heads-up'' display element whose size is @scheme[w] by
|
||||
@scheme[h] units with the given @scheme[draw] thunk and @scheme[info]
|
||||
Add a ``heads-up'' display element whose size is @racket[w] by
|
||||
@racket[h] units with the given @racket[draw] thunk and @racket[info]
|
||||
reprsentative.}
|
||||
|
||||
|
||||
@defmethod[(remove-heads-up [info any/c]) void?]{
|
||||
|
||||
Removes all ``heads-up'' displays elements previous added with
|
||||
representative @scheme[info].}
|
||||
representative @racket[info].}
|
||||
|
||||
|
||||
@defmethod[(set-space-draw [info any/c] [draw (-> any)]) void?]{
|
||||
|
||||
Sets the drawing function of all spaces added with
|
||||
representative @scheme[info].}
|
||||
representative @racket[info].}
|
||||
|
||||
|
||||
@defmethod[(set-piece-draw [info any/c]
|
||||
[draw ([shadow? boolean?] . -> . any)]) void?]{
|
||||
|
||||
Sets the drawing function of all pieces added with
|
||||
representative @scheme[info].}
|
||||
representative @racket[info].}
|
||||
|
||||
|
||||
@defmethod[(enable-piece [info any/c][can-move? any/c]) void?]{
|
||||
|
||||
Enables or disables moving of all pieces added with
|
||||
representative @scheme[info].}
|
||||
representative @racket[info].}
|
||||
|
||||
|
||||
@defmethod[(enabled? [info any/c]) boolean?]{
|
||||
|
||||
reports whether the first piece with representative @scheme[info] is enabled.}
|
||||
reports whether the first piece with representative @racket[info] is enabled.}
|
||||
|
||||
|
||||
|
||||
|
@ -105,7 +105,7 @@ reports whether the first piece with representative @scheme[info] is enabled.}
|
|||
[(get-heads-up) list?])]{
|
||||
|
||||
Returns values for various kinds of content currently on the
|
||||
board. The result corresponds to @scheme[_info] values given to
|
||||
@scheme[add-piece], etc.}
|
||||
board. The result corresponds to @racket[_info] values given to
|
||||
@racket[add-piece], etc.}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
@gametitle["Checkers" "checkers" "Board Game"]
|
||||
|
||||
This simple checkers game (with no AI player) is intended as a
|
||||
demonstration use of the @schememodname[games/gl-board-game] library.
|
||||
demonstration use of the @racketmodname[games/gl-board-game] library.
|
||||
|
|
|
@ -22,33 +22,33 @@ installed as sub-collections of the @filepath{games} collection (see
|
|||
|
||||
The game-starting console inspects the sub-collections of the
|
||||
@filepath{games} collection. If a sub-collection has an
|
||||
@filepath{info.rkt} module (see @schememodname[setup/infotab]), the
|
||||
@filepath{info.rkt} module (see @racketmodname[setup/infotab]), the
|
||||
following fields of the collection's @filepath{info.rkt} file are used:
|
||||
|
||||
@itemize[
|
||||
|
||||
@item{@schemeidfont{game} [required] : used as a module name in the
|
||||
@item{@racketidfont{game} [required] : used as a module name in the
|
||||
sub-collection to load for the game; the module must provide a
|
||||
@schemeidfont["game@"] unit (see @schememodname[scheme/unit]) with
|
||||
@racketidfont["game@"] unit (see @racketmodname[scheme/unit]) with
|
||||
no particular exports; the unit is invoked with no imports to
|
||||
start the game.}
|
||||
|
||||
@item{@schemeidfont{name} [defaults to the collection name] : used to
|
||||
@item{@racketidfont{name} [defaults to the collection name] : used to
|
||||
label the game-starting button in the game console.}
|
||||
|
||||
@item{@schemeidfont{game-icon} [defaults to collection name with
|
||||
@item{@racketidfont{game-icon} [defaults to collection name with
|
||||
@filepath{.png}] : used as a path to a bitmap file that is used for
|
||||
the game button's label; this image should be 32 by 32 pixels and
|
||||
have a mask.}
|
||||
|
||||
@item{@schemeidfont{game-set} [defaults to @scheme["Other Games"]] :
|
||||
@item{@racketidfont{game-set} [defaults to @racket["Other Games"]] :
|
||||
a label used to group games that declare themselves to be in the
|
||||
same set.}
|
||||
|
||||
]
|
||||
|
||||
To implement card games, see @schememodname[games/cards]. Card games
|
||||
typically belong in the @scheme["Cards"] game set.
|
||||
To implement card games, see @racketmodname[games/cards]. Card games
|
||||
typically belong in the @racket["Cards"] game set.
|
||||
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
@ -62,8 +62,8 @@ typically belong in the @scheme["Cards"] game set.
|
|||
(-> void?)]{
|
||||
|
||||
Returns a thunk for opening a Scribbled section in the user's HTML
|
||||
browser. The @scheme[mod-path] is the document's main source module,
|
||||
and @scheme[section-tag] specifies the section in the document.}
|
||||
browser. The @racket[mod-path] is the document's main source module,
|
||||
and @racket[section-tag] specifies the section in the document.}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
|
@ -81,11 +81,11 @@ text. Multiple invocations of the thunk bring the same window to the
|
|||
foreground (until the user closes the window).
|
||||
|
||||
The help window displays @filepath{doc.txt} from the collection
|
||||
specified by @scheme[coll-path].
|
||||
specified by @racket[coll-path].
|
||||
|
||||
The @scheme[frame-title] argument is used for the help window title.
|
||||
The @racket[frame-title] argument is used for the help window title.
|
||||
|
||||
If @scheme[verbatim?] is true, then @filepath{doc.txt} is displayed
|
||||
If @racket[verbatim?] is true, then @filepath{doc.txt} is displayed
|
||||
verbatim, otherwise it is formatted as follows:
|
||||
|
||||
@itemize[
|
||||
|
|
|
@ -112,12 +112,12 @@ The fern functions below demonstrate more advanced use of
|
|||
@defproc[(save-turtle-bitmap [name (or/c path-string? output-port?)]
|
||||
[kind (or/c 'png 'jpeg 'xbm 'xpm 'bmp)])
|
||||
void?]{
|
||||
Saves the current state of the turtles window in an image file.
|
||||
Saves the current state of the turtles window in an image file.
|
||||
}
|
||||
|
||||
|
||||
@defthing[turtle-window-size exact-positive-integer?]{
|
||||
The size of the turtles window.
|
||||
}
|
||||
The size of the turtles window.
|
||||
}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
|
@ -215,7 +215,7 @@ Calls @racket[lorenze] with good initial values.}
|
|||
}
|
||||
|
||||
@defthing[peano-size exact-nonnegative-integer?]{
|
||||
One size to use with @racket[peano].
|
||||
One size to use with @racket[peano].
|
||||
}
|
||||
|
||||
@defthing[fern-size exact-nonnegative-integer?]{
|
||||
|
|
|
@ -26,9 +26,9 @@ initial turtle and the direction in radians (where @racket[0] is to
|
|||
the right).}
|
||||
|
||||
@defproc[(turtles? [v any/c]) boolean?]{
|
||||
Determines if @racket[v] is a turtles drawing.
|
||||
Determines if @racket[v] is a turtles drawing.
|
||||
}
|
||||
|
||||
|
||||
@defproc[(move [n real?] [turtles turtles?]) turtles?]{
|
||||
|
||||
Moves the turtle @racket[n] pixels, returning a new turtles window.}
|
||||
|
@ -108,7 +108,7 @@ same direction as the original turtle.}
|
|||
[radius real?]
|
||||
[turtles turtles?])
|
||||
turtles?]{
|
||||
|
||||
|
||||
Draws a regular poly centered at the turtle with @racket[sides] sides
|
||||
and with radius @racket[radius].}
|
||||
|
||||
|
|
|
@ -62,14 +62,14 @@ provides several functions:
|
|||
|
||||
The library re-exports the following identifiers from test-engine/scheme-tests:
|
||||
|
||||
@scheme[build-test-engine]
|
||||
@scheme[builder]
|
||||
@scheme[display-results]
|
||||
@scheme[error-handler]
|
||||
@scheme[exn:fail:wish]
|
||||
@scheme[generate-report]
|
||||
@scheme[get-test-engine]
|
||||
@scheme[reset-tests]
|
||||
@scheme[run-tests]
|
||||
@scheme[scheme-test-data]
|
||||
@scheme[signature-test-info%]
|
||||
@racket[build-test-engine]
|
||||
@racket[builder]
|
||||
@racket[display-results]
|
||||
@racket[error-handler]
|
||||
@racket[exn:fail:wish]
|
||||
@racket[generate-report]
|
||||
@racket[get-test-engine]
|
||||
@racket[reset-tests]
|
||||
@racket[run-tests]
|
||||
@racket[scheme-test-data]
|
||||
@racket[signature-test-info%]
|
||||
|
|
|
@ -40,7 +40,7 @@ Reads HTML from a port, producing an @xexpr compatible with the
|
|||
other elements. For example, the top-level @racket["<html>"]
|
||||
element may only contain a @racket["<body>"] and @racket["<head>"]
|
||||
element. Defaults to @racket[#f].
|
||||
}
|
||||
}
|
||||
|
||||
@section{Example}
|
||||
@(require (only-in (for-label racket)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
@defmodule[lang/htdp-beginner]
|
||||
|
||||
The @schememodname[lang/htdp-beginner] module provides the Beginning
|
||||
The @racketmodname[lang/htdp-beginner] module provides the Beginning
|
||||
Student language for @|htdp|; see @htdp-ref["beginner"].
|
||||
|
||||
@; ------------------------------------------------------------
|
||||
|
@ -27,7 +27,7 @@ Student language for @|htdp|; see @htdp-ref["beginner"].
|
|||
|
||||
@defmodule[lang/htdp-beginner-abbr]
|
||||
|
||||
The @schememodname[lang/htdp-beginner-abbr] module provides the
|
||||
The @racketmodname[lang/htdp-beginner-abbr] module provides the
|
||||
Beginning Student with Abbreviations language for @|htdp|; see
|
||||
@htdp-ref["beginner-abbr"].
|
||||
|
||||
|
@ -36,7 +36,7 @@ Beginning Student with Abbreviations language for @|htdp|; see
|
|||
|
||||
@defmodule[lang/htdp-intermediate]
|
||||
|
||||
The @schememodname[lang/htdp-intermediate] module provides the
|
||||
The @racketmodname[lang/htdp-intermediate] module provides the
|
||||
Intermediate Student language for @|htdp|; see
|
||||
@htdp-ref["intermediate"].
|
||||
|
||||
|
@ -45,7 +45,7 @@ Intermediate Student language for @|htdp|; see
|
|||
|
||||
@defmodule[lang/htdp-intermediate-lambda]
|
||||
|
||||
The @schememodname[lang/htdp-intermediate-lambda] module provides the
|
||||
The @racketmodname[lang/htdp-intermediate-lambda] module provides the
|
||||
Intermediate Student with Lambda language for @|htdp|; see
|
||||
@htdp-ref["intermediate-lam"].
|
||||
|
||||
|
@ -54,7 +54,7 @@ Intermediate Student with Lambda language for @|htdp|; see
|
|||
|
||||
@defmodule[lang/htdp-advanced]
|
||||
|
||||
The @schememodname[lang/htdp-advanced] module provides the Advanced
|
||||
The @racketmodname[lang/htdp-advanced] module provides the Advanced
|
||||
Student language for @|htdp|; see @htdp-ref["advanced"].
|
||||
|
||||
@; ------------------------------------------------------------
|
||||
|
@ -62,17 +62,17 @@ Student language for @|htdp|; see @htdp-ref["advanced"].
|
|||
|
||||
@defmodule[lang/plt-pretty-big-text]
|
||||
|
||||
The @schememodname[lang/plt-pretty-big-text] module is similar to the
|
||||
The @racketmodname[lang/plt-pretty-big-text] module is similar to the
|
||||
@italic{HtDP} Advanced Student language, but with more of Racket's
|
||||
libraries in legacy form. It provides the bindings of
|
||||
@schememodname[mzscheme],
|
||||
@schememodname[mzlib/etc], @schememodname[mzlib/file],
|
||||
@schememodname[mzlib/list], @schememodname[mzlib/class],
|
||||
@schememodname[mzlib/unit], @schememodname[mzlib/include],
|
||||
@schememodname[mzlib/defmacro], @schememodname[mzlib/pretty],
|
||||
@schememodname[mzlib/string], @schememodname[mzlib/thread],
|
||||
@schememodname[mzlib/math], @schememodname[mzlib/match],
|
||||
@schememodname[mzlib/shared], and @schememodname[lang/posn].
|
||||
@racketmodname[mzscheme],
|
||||
@racketmodname[mzlib/etc], @racketmodname[mzlib/file],
|
||||
@racketmodname[mzlib/list], @racketmodname[mzlib/class],
|
||||
@racketmodname[mzlib/unit], @racketmodname[mzlib/include],
|
||||
@racketmodname[mzlib/defmacro], @racketmodname[mzlib/pretty],
|
||||
@racketmodname[mzlib/string], @racketmodname[mzlib/thread],
|
||||
@racketmodname[mzlib/math], @racketmodname[mzlib/match],
|
||||
@racketmodname[mzlib/shared], and @racketmodname[lang/posn].
|
||||
|
||||
@; ------------------------------------------------------------
|
||||
|
||||
|
@ -80,21 +80,21 @@ libraries in legacy form. It provides the bindings of
|
|||
|
||||
@defmodule[lang/plt-pretty-big]
|
||||
|
||||
The @schememodname[lang/plt-pretty-big] module extends
|
||||
@scheme[lang/plt-pretty-big-text] with @schememodname[scheme/gui/base]
|
||||
and @schememodname[lang/imageeq]. This language corresponds to the
|
||||
The @racketmodname[lang/plt-pretty-big] module extends
|
||||
@racket[lang/plt-pretty-big-text] with @racketmodname[scheme/gui/base]
|
||||
and @racketmodname[lang/imageeq]. This language corresponds to the
|
||||
@onscreen{Pretty Big} legacy language in DrRacket.
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@section{@scheme[posn]s in @italic{HtDP} Languages}
|
||||
@section{@racket[posn]s in @italic{HtDP} Languages}
|
||||
|
||||
@defmodule[lang/posn]
|
||||
|
||||
@defstruct[posn ([x any/c] [y any/c])]{
|
||||
|
||||
The @scheme[posn] structure type that is also provided by
|
||||
@scheme[lang/htdp-beginner].}
|
||||
The @racket[posn] structure type that is also provided by
|
||||
@racket[lang/htdp-beginner].}
|
||||
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
@ -108,7 +108,7 @@ The @scheme[posn] structure type that is also provided by
|
|||
boolean?]{
|
||||
|
||||
The image-comparison operator that is also provided by
|
||||
@scheme[lang/htdp-beginner].}
|
||||
@racket[lang/htdp-beginner].}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
|
@ -116,7 +116,7 @@ The image-comparison operator that is also provided by
|
|||
|
||||
@defmodule[lang/prim]
|
||||
|
||||
The @schememodname[lang/prim] module several syntactic forms for
|
||||
The @racketmodname[lang/prim] module several syntactic forms for
|
||||
use by the implementors of teachpacks, when the teachpack is to be
|
||||
used with the @|htdp| Beginner Student
|
||||
languages. In Beginner Student, primitive names (for built-in
|
||||
|
@ -125,49 +125,49 @@ they can be syntactically restricted to application positions.
|
|||
|
||||
@defform[(define-primitive id proc-id)]{
|
||||
|
||||
Defines @scheme[id] to be a primitive operator whose implementation
|
||||
is @scheme[proc-id], and that takes no procedures as
|
||||
arguments. Normally, @scheme[id] is exported from the teachpack and
|
||||
@scheme[proc-id] is not.}
|
||||
Defines @racket[id] to be a primitive operator whose implementation
|
||||
is @racket[proc-id], and that takes no procedures as
|
||||
arguments. Normally, @racket[id] is exported from the teachpack and
|
||||
@racket[proc-id] is not.}
|
||||
|
||||
@defform[(provide-primitive id)]{
|
||||
|
||||
Like @scheme[define-primitive], but the existing function @scheme[id] is
|
||||
exported as the primitive operator named @scheme[id]. An alternative
|
||||
to @scheme[define-primitive].}
|
||||
Like @racket[define-primitive], but the existing function @racket[id] is
|
||||
exported as the primitive operator named @racket[id]. An alternative
|
||||
to @racket[define-primitive].}
|
||||
|
||||
@defform[(provide-primitives id ...)]{
|
||||
|
||||
Multiple-identifier version of @scheme[provide-primitive].}
|
||||
Multiple-identifier version of @racket[provide-primitive].}
|
||||
|
||||
@defform[(define-higher-order-primitive id proc-id (arg ...))]{
|
||||
|
||||
Defines @scheme[id] to be a primitive operator whose implementation is
|
||||
@scheme[proc-id]. Normally, @scheme[id] is exported from the teachpack and
|
||||
@scheme[proc-id] is not.
|
||||
Defines @racket[id] to be a primitive operator whose implementation is
|
||||
@racket[proc-id]. Normally, @racket[id] is exported from the teachpack and
|
||||
@racket[proc-id] is not.
|
||||
|
||||
For each non-procedure argument, the corresponding @scheme[arg] should be
|
||||
an underscore. For each procedure argument, the corresponding @scheme[arg]
|
||||
For each non-procedure argument, the corresponding @racket[arg] should be
|
||||
an underscore. For each procedure argument, the corresponding @racket[arg]
|
||||
should be the usual name of the procedure.
|
||||
|
||||
@as-examples[
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define-higher-order-primitive convert-gui convert-gui/proc (f2c))
|
||||
]]
|
||||
}
|
||||
|
||||
@defform[(provide-higher-order-primitive id (arg ...))]{
|
||||
|
||||
Like @scheme[define-higher-order-primitive], but the existing function
|
||||
@scheme[id] is exported as the primitive operator named
|
||||
@scheme[id]. An alternative to @scheme[define-higher-order-primitive].}
|
||||
Like @racket[define-higher-order-primitive], but the existing function
|
||||
@racket[id] is exported as the primitive operator named
|
||||
@racket[id]. An alternative to @racket[define-higher-order-primitive].}
|
||||
|
||||
@defform[(first-order->higher-order expr)]{
|
||||
|
||||
If @scheme[expr] is an identifier for a first-order function (either a
|
||||
If @racket[expr] is an identifier for a first-order function (either a
|
||||
primitive or a function defined within Beginner Student), produces the
|
||||
function as a value; otherwise, the form is equivalent to
|
||||
@scheme[expr].
|
||||
@racket[expr].
|
||||
|
||||
This form is mainly useful for implementing syntactic forms that, like
|
||||
the application of a higher-order primitive, allow first-order bindings
|
||||
|
|
|
@ -42,22 +42,22 @@
|
|||
|
||||
Lazy Racket is available as both a language level and a module that
|
||||
can be used to write lazy code. To write lazy code, simply use
|
||||
@schememodname[lazy] as your module's language:
|
||||
@racketmodname[lazy] as your module's language:
|
||||
|
||||
@schememod[
|
||||
@racketmod[
|
||||
lazy
|
||||
... @#,elem{lazy code here}...]
|
||||
|
||||
Function applications are delayed, and promises are automatically
|
||||
forced. The language provides bindings that are equivalent to most of
|
||||
the @schememodname[mzscheme] and @schememodname[scheme/list]
|
||||
the @racketmodname[mzscheme] and @racketmodname[scheme/list]
|
||||
libraries. Primitives are strict in the expected places; struct
|
||||
constructors are lazy; @scheme[if], @scheme[and], @scheme[or] @|etc|
|
||||
constructors are lazy; @racket[if], @racket[and], @racket[or] @|etc|
|
||||
are plain (lazy) functions. Strict functionality is provided as-is:
|
||||
@scheme[begin], I/O, mutation, parameterization, etc. To have your
|
||||
code make sense, you should chain side effects in @scheme[begin]s,
|
||||
@racket[begin], I/O, mutation, parameterization, etc. To have your
|
||||
code make sense, you should chain side effects in @racket[begin]s,
|
||||
which will sequence things properly. (Note: This is similar to
|
||||
threading monads through your code---only use @scheme[begin] where
|
||||
threading monads through your code---only use @racket[begin] where
|
||||
order matters.)
|
||||
|
||||
Mixing lazy and strict code is simple: you just write the lazy code in
|
||||
|
@ -67,11 +67,11 @@ as strict, and on the strict side you only need to force (possibly
|
|||
recursively) through promises.
|
||||
|
||||
A few side-effect bindings are provided as-is. For example,
|
||||
@scheme[read] and @scheme[printf] do the obvious thing---but note that
|
||||
@racket[read] and @racket[printf] do the obvious thing---but note that
|
||||
the language is a call-by-need, and you need to be aware when promises
|
||||
are forced. There are also bindings for @scheme[begin] (delays a
|
||||
computation that forces all sub-expressions), @scheme[when],
|
||||
@scheme[unless], etc. There are, however, less reliable and might
|
||||
are forced. There are also bindings for @racket[begin] (delays a
|
||||
computation that forces all sub-expressions), @racket[when],
|
||||
@racket[unless], etc. There are, however, less reliable and might
|
||||
change (or be dropped) in the future.
|
||||
|
||||
There are a few additional bindings, the important ones are special
|
||||
|
@ -133,30 +133,30 @@ input arguments in order.}
|
|||
|
||||
@defmodule[lazy/force]
|
||||
|
||||
The bindings of @schememodname[lazy/force] are re-provided by
|
||||
@schememodname[lazy].
|
||||
The bindings of @racketmodname[lazy/force] are re-provided by
|
||||
@racketmodname[lazy].
|
||||
|
||||
@defproc[(! [expr any/c]) any/c]{
|
||||
|
||||
Evaluates @scheme[expr] strictly. The result is always forced, over
|
||||
Evaluates @racket[expr] strictly. The result is always forced, over
|
||||
and over until it gets a non-promise value.}
|
||||
|
||||
|
||||
@defproc[(!![expr any/c]) any/c]{
|
||||
@defproc[(!! [expr any/c]) any/c]{
|
||||
|
||||
Similar to @scheme[!], but recursively forces a structure (e.g:
|
||||
Similar to @racket[!], but recursively forces a structure (e.g:
|
||||
lists).}
|
||||
|
||||
|
||||
@defproc[(!list [expr (or/c promise? list?)]) list?]{
|
||||
|
||||
Forces the @scheme[expr] which is expected to be a list, and forces
|
||||
the @scheme[cdr]s recursively to expose a proper list structure.}
|
||||
Forces the @racket[expr] which is expected to be a list, and forces
|
||||
the @racket[cdr]s recursively to expose a proper list structure.}
|
||||
|
||||
|
||||
@defproc[(!!list [expr (or/c promise? list?)]) list?]{
|
||||
|
||||
Similar to @scheme[!list] but also forces (using @scheme[!]) the
|
||||
Similar to @racket[!list] but also forces (using @racket[!]) the
|
||||
elements of the list.}
|
||||
|
||||
|
||||
|
@ -166,7 +166,7 @@ elements of the list.}
|
|||
|
||||
To avoid dealing with multiple values, they are treated as a single
|
||||
tuple in the lazy language. This is implemented as a
|
||||
@scheme[multiple-values] struct, with a @scheme[values] slot.
|
||||
@racket[multiple-values] struct, with a @racket[values] slot.
|
||||
|
||||
@defproc[(split-values [x multiple-values?]) any]{
|
||||
|
||||
|
@ -176,12 +176,12 @@ in the future.)}
|
|||
|
||||
@defproc[(!values [expr (or/c promise? multiple-values?)]) any]{
|
||||
|
||||
Forces @scheme[expr] and uses @scheme[split-values] on the result.}
|
||||
Forces @racket[expr] and uses @racket[split-values] on the result.}
|
||||
|
||||
|
||||
@defproc[(!!values [expr (or/c promise? multiple-values?)]) any]{
|
||||
|
||||
Similar to @scheme[!values], but forces each of the values
|
||||
Similar to @racket[!values], but forces each of the values
|
||||
recursively.}
|
||||
|
||||
;}
|
||||
|
|
|
@ -52,7 +52,7 @@ stepping through the expansion.
|
|||
|
||||
@defmodule[macro-debugger/expand]
|
||||
|
||||
This module provides @scheme[expand]-like procedures that allow the
|
||||
This module provides @racket[expand]-like procedures that allow the
|
||||
user to specify macros whose expansions should be hidden.
|
||||
|
||||
Warning: because of limitations in the way macro expansion is
|
||||
|
@ -62,8 +62,8 @@ result as the original syntax.
|
|||
@defproc[(expand-only [stx any/c] [transparent-macros (listof identifier?)])
|
||||
syntax?]{
|
||||
|
||||
Expands the given syntax @scheme[stx], but only shows the expansion
|
||||
of macros whose names occur in @scheme[transparent-macros].
|
||||
Expands the given syntax @racket[stx], but only shows the expansion
|
||||
of macros whose names occur in @racket[transparent-macros].
|
||||
|
||||
@(examples #:eval the-eval
|
||||
(syntax->datum
|
||||
|
@ -75,7 +75,7 @@ result as the original syntax.
|
|||
@defproc[(expand/hide [stx any/c] [hidden-macros (listof identifier?)])
|
||||
syntax?]{
|
||||
|
||||
Expands the given syntax @scheme[stx], but hides the expansion of macros in the
|
||||
Expands the given syntax @racket[stx], but hides the expansion of macros in the
|
||||
given identifier list (conceptually, the complement of expand-only).
|
||||
|
||||
@(examples #:eval the-eval
|
||||
|
@ -87,8 +87,8 @@ result as the original syntax.
|
|||
@defproc[(expand/show-predicate [stx any/c] [show? (-> identifier? boolean?)])
|
||||
syntax?]{
|
||||
|
||||
Expands the given syntax @scheme[stx], but only shows the expansion of macros
|
||||
whose names satisfy the predicate @scheme[show?].
|
||||
Expands the given syntax @racket[stx], but only shows the expansion of macros
|
||||
whose names satisfy the predicate @racket[show?].
|
||||
|
||||
@(examples #:eval the-eval
|
||||
(syntax->datum
|
||||
|
@ -116,12 +116,12 @@ the macro's context. The remark is only displayed if the macro that
|
|||
emits it is considered transparent by the hiding policy.
|
||||
|
||||
By default, syntax objects in remarks have the transformer's mark
|
||||
applied (using @scheme[syntax-local-introduce]) so that their
|
||||
applied (using @racket[syntax-local-introduce]) so that their
|
||||
appearance in the macro stepper matches their appearance after the
|
||||
transformer returns. Unmarking is suppressed if @scheme[unmark?] is
|
||||
@scheme[#f].
|
||||
transformer returns. Unmarking is suppressed if @racket[unmark?] is
|
||||
@racket[#f].
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(define-syntax (mymac stx)
|
||||
(syntax-case stx ()
|
||||
[(_ x y)
|
||||
|
@ -141,9 +141,9 @@ transformer returns. Unmarking is suppressed if @scheme[unmark?] is
|
|||
void?]{
|
||||
|
||||
Emits an event that simulates a local expansion step from
|
||||
@scheme[before] to @scheme[after].
|
||||
@racket[before] to @racket[after].
|
||||
|
||||
The @scheme[id] argument acts as the step's ``macro'' for the purposes
|
||||
The @racket[id] argument acts as the step's ``macro'' for the purposes
|
||||
of macro hiding.
|
||||
}
|
||||
|
||||
|
@ -178,8 +178,8 @@ of macro hiding.
|
|||
(symbol? -> void?)]{
|
||||
|
||||
Returns a procedure that can be called on the symbol
|
||||
@scheme['next] to print the next step or on the symbol
|
||||
@scheme['all] to print out all remaining steps.
|
||||
@racket['next] to print the next step or on the symbol
|
||||
@racket['all] to print out all remaining steps.
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,7 +197,7 @@ of macro hiding.
|
|||
@defproc[(browse-syntaxes [stxs (listof syntax?)])
|
||||
void?]{
|
||||
|
||||
Like @scheme[browse-syntax], but shows multiple syntax objects in
|
||||
Like @racket[browse-syntax], but shows multiple syntax objects in
|
||||
the same frame. The coloring partitions are shared between the two,
|
||||
showing the relationships between subterms in different syntax
|
||||
objects.
|
||||
|
@ -270,7 +270,7 @@ syntax may be original, or it may be produced by the expansion of a
|
|||
nonhygienic macro.
|
||||
|
||||
Note: even terms that have the same marks might not be
|
||||
@scheme[bound-identifier=?] to each other, because they might occur in
|
||||
@racket[bound-identifier=?] to each other, because they might occur in
|
||||
different environments.
|
||||
|
||||
@;@example[(bound-identifier=? (let ([x 1]) #'x) #'x)]
|
||||
|
@ -284,8 +284,8 @@ selected term are highlighted in yellow.
|
|||
|
||||
The available secondary partitionings are:
|
||||
@itemize[
|
||||
@item{@scheme[bound-identifier=?]}
|
||||
@item{@scheme[free-identifier=?]}
|
||||
@item{@racket[bound-identifier=?]}
|
||||
@item{@racket[free-identifier=?]}
|
||||
]
|
||||
|
||||
@subsection{Properties}
|
||||
|
@ -298,12 +298,12 @@ selected syntax object. The properties pane has two tabbed pages:
|
|||
|
||||
If the selection is an identifier, shows the binding information
|
||||
associated with the syntax object. For more information, see
|
||||
@scheme[identifier-binding], etc.
|
||||
@racket[identifier-binding], etc.
|
||||
}
|
||||
@item{@bold{Syntax Object}:
|
||||
|
||||
Displays source location information and other properties (see
|
||||
@scheme[syntax-property]) carried by the syntax object.
|
||||
@racket[syntax-property]) carried by the syntax object.
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
@title{@bold{Make}: Dependency Manager}
|
||||
|
||||
The @schememodname[make] library provides a Racket version of the
|
||||
The @racketmodname[make] library provides a Racket version of the
|
||||
popular @exec{make} utility. Its syntax is intended to imitate the
|
||||
syntax of @exec{make}, only in Racket.
|
||||
|
||||
|
@ -24,7 +24,7 @@ dependency tracking, just use @exec{raco make} as described in
|
|||
@|raco-manual|.}
|
||||
|
||||
If you are already familiar with @exec{make}, skip to the precise
|
||||
details of the @schememodname[make] library in @secref["make"]. This
|
||||
details of the @racketmodname[make] library in @secref["make"]. This
|
||||
section contains a brief overview of @exec{make} for everyone
|
||||
else.
|
||||
|
||||
|
@ -69,13 +69,13 @@ files to determine when a certain step is necessary. The @exec{make}
|
|||
utility uses existing programs to build your project --- each rule has
|
||||
a shell command line.
|
||||
|
||||
The @schememodname[make] library provides similar functionality,
|
||||
The @racketmodname[make] library provides similar functionality,
|
||||
except that the description is in Racket, and the steps that are
|
||||
needed to build target files are implemented as Racket functions.
|
||||
|
||||
Here's a Racket program that is equivalent to the above:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(require make)
|
||||
|
||||
(define (make-output in out)
|
||||
|
@ -93,14 +93,14 @@ Here's a Racket program that is equivalent to the above:
|
|||
]
|
||||
|
||||
If you were to fill in the ellipses above with calls to
|
||||
@scheme[system], you'd have the exact same functionality as the
|
||||
@racket[system], you'd have the exact same functionality as the
|
||||
original @filepath{Makefile}. In addition, you can use
|
||||
@scheme[make/proc] to abstract over the various lines. For example,
|
||||
@racket[make/proc] to abstract over the various lines. For example,
|
||||
the @filepath{a.output}, @filepath{b.output}, and @filepath{c.output}
|
||||
lines are very similar so you can write the code that generates those
|
||||
lines:
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(require make)
|
||||
|
||||
(define (make-output in out)
|
||||
|
@ -138,7 +138,7 @@ lines:
|
|||
|
||||
Expands to
|
||||
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
(make/proc
|
||||
(list (list target-expr (list depend-expr ...)
|
||||
(lambda () command-expr ...))
|
||||
|
@ -154,17 +154,17 @@ Expands to
|
|||
[argv (or/c string? (vectorof string?) (listof string?))])
|
||||
void?]
|
||||
|
||||
Performs a make according to @scheme[spec] and using @scheme[argv] as
|
||||
Performs a make according to @racket[spec] and using @racket[argv] as
|
||||
command-line arguments selecting one or more targets.
|
||||
|
||||
Each element of the @scheme[spec] list is a target. A target element
|
||||
Each element of the @racket[spec] list is a target. A target element
|
||||
that starts with a list of strings is the same as multiple elements,
|
||||
one for each string. The second element of each target is a list of
|
||||
dependencies, and the third element (if any) of a target is the
|
||||
optional command thunk.
|
||||
|
||||
To make a target, @scheme[make/proc] is first called recursively on
|
||||
each of the target's dependencies. If a target is not in @scheme[spec]
|
||||
To make a target, @racket[make/proc] is first called recursively on
|
||||
each of the target's dependencies. If a target is not in @racket[spec]
|
||||
and it exists as a file, then the target is considered made. If a
|
||||
target's modification date is older than any of its dependencies'
|
||||
modification dates, the corresponding command thunk is called. If the
|
||||
|
@ -172,36 +172,36 @@ dependency has no command thunk then no action is taken; such a target
|
|||
is useful for triggering the make of other targets (i.e., the
|
||||
dependencies).
|
||||
|
||||
While running a command thunk, @scheme[make/proc] catches exceptions
|
||||
and wraps them in an @scheme[exn:fail:make] structure, the raises the
|
||||
While running a command thunk, @racket[make/proc] catches exceptions
|
||||
and wraps them in an @racket[exn:fail:make] structure, the raises the
|
||||
resulting structure.}
|
||||
|
||||
@defstruct[(exn:fail:make exn:fail)
|
||||
([targets (listof path-string?)]
|
||||
[orig-exn any/c])]{
|
||||
|
||||
The @scheme[targets] field is a list of strings naming the
|
||||
target(s), and the @scheme[orig-exn] field is the original raised
|
||||
The @racket[targets] field is a list of strings naming the
|
||||
target(s), and the @racket[orig-exn] field is the original raised
|
||||
value.}
|
||||
|
||||
|
||||
@defboolparam[make-print-checking on?]{
|
||||
|
||||
A parameter that controls whether @scheme[make/proc] prints a message
|
||||
when making a target. The default is @scheme[#t].}
|
||||
A parameter that controls whether @racket[make/proc] prints a message
|
||||
when making a target. The default is @racket[#t].}
|
||||
|
||||
|
||||
@defboolparam[make-print-dep-no-line on?]{
|
||||
|
||||
A parameter that controls whether @scheme[make/proc] prints
|
||||
A parameter that controls whether @racket[make/proc] prints
|
||||
``checking...'' lines for dependencies that have no target in the
|
||||
given k@scheme[_spec]. The default is @scheme[#f].}
|
||||
given k@racket[_spec]. The default is @racket[#f].}
|
||||
|
||||
|
||||
@defboolparam[make-print-reasons on?]{
|
||||
|
||||
A parameter that controls whether @scheme[make/proc] prints the reason
|
||||
that a command thunk is called. The default is @scheme[#t].}
|
||||
A parameter that controls whether @racket[make/proc] prints the reason
|
||||
that a command thunk is called. The default is @racket[#t].}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
|
@ -211,7 +211,7 @@ that a command thunk is called. The default is @scheme[#t].}
|
|||
|
||||
@defsignature[make^ ()]{
|
||||
|
||||
Includes all of the names provided by @schememodname[make].}
|
||||
Includes all of the names provided by @racketmodname[make].}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
|
@ -221,7 +221,7 @@ Includes all of the names provided by @schememodname[make].}
|
|||
|
||||
@defthing[make@ unit?]{
|
||||
|
||||
A unit that imports nothing and exports @scheme[make^].}
|
||||
A unit that imports nothing and exports @racket[make^].}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
|
@ -229,19 +229,19 @@ A unit that imports nothing and exports @scheme[make^].}
|
|||
|
||||
@defmodule[make/setup-extension]
|
||||
|
||||
The @schememodname[make/setup-extension] library helps compile C code
|
||||
The @racketmodname[make/setup-extension] library helps compile C code
|
||||
via Setup PLT's ``pre-install'' phase (triggered by a
|
||||
@schemeidfont{pre-install-collection} item in @filepath{info.rkt}; see
|
||||
@racketidfont{pre-install-collection} item in @filepath{info.rkt}; see
|
||||
also @secref[#:doc '(lib "scribblings/raco/raco.scrbl")
|
||||
"setup-info"]).
|
||||
|
||||
The @scheme[pre-install] function takes a number of arguments that
|
||||
The @racket[pre-install] function takes a number of arguments that
|
||||
describe how the C code is compiled---mainly the libraries that it
|
||||
depends on. It then drives a C compiler via the
|
||||
@schememodname[dynext/compile] and @schememodname[dynext/link]
|
||||
@racketmodname[dynext/compile] and @racketmodname[dynext/link]
|
||||
functions.
|
||||
|
||||
Many issues can complicate C compilation, and the @scheme[pre-install]
|
||||
Many issues can complicate C compilation, and the @racket[pre-install]
|
||||
function helps with a few:
|
||||
|
||||
@itemize[
|
||||
|
@ -263,9 +263,9 @@ issues manually, however. For example, an old @filepath{readline}
|
|||
installer used to pick whether to link to @filepath{libcurses} or
|
||||
@filepath{libncurses} heuristically by inspecting
|
||||
@filepath{/usr/lib}. More generally, the ``last chance'' argument to
|
||||
@scheme[pre-install] allows an installer to patch compiler and linker
|
||||
options (see @schememodname[dynext/compile] and
|
||||
@schememodname[dynext/link]) before the C code is compiled or linked.
|
||||
@racket[pre-install] allows an installer to patch compiler and linker
|
||||
options (see @racketmodname[dynext/compile] and
|
||||
@racketmodname[dynext/link]) before the C code is compiled or linked.
|
||||
|
||||
@defproc[(pre-install
|
||||
[plthome-dir path-string?]
|
||||
|
@ -286,75 +286,75 @@ The arguments are as follows:
|
|||
|
||||
@itemize[
|
||||
|
||||
@item{@scheme[plthome-dir] --- the directory provided to a `pre-installer'
|
||||
@item{@racket[plthome-dir] --- the directory provided to a `pre-installer'
|
||||
function.}
|
||||
|
||||
@item{@scheme[collection-dir] --- a directory to use as the current directory
|
||||
@item{@racket[collection-dir] --- a directory to use as the current directory
|
||||
while building.}
|
||||
|
||||
@item{@scheme[c-file] --- the name of the source file (relative to
|
||||
@scheme[collection-dir]). The output file will be the same, except
|
||||
with a @filepath{.c} suffix replaced with @scheme[(system-type
|
||||
'so-suffix)], and the path changed to @scheme[(build-path
|
||||
@item{@racket[c-file] --- the name of the source file (relative to
|
||||
@racket[collection-dir]). The output file will be the same, except
|
||||
with a @filepath{.c} suffix replaced with @racket[(system-type
|
||||
'so-suffix)], and the path changed to @racket[(build-path
|
||||
"compiled" "native" (system-library-subpath))].
|
||||
|
||||
If @scheme[(build-path "precompiled" "native"
|
||||
If @racket[(build-path "precompiled" "native"
|
||||
(system-library-subpath) (path-replace-suffix c-file (system-type
|
||||
'so-suffix)))] exists, then @scheme[c-file] is not used at all,
|
||||
'so-suffix)))] exists, then @racket[c-file] is not used at all,
|
||||
and the file in the @filepath{precompiled} directory is simply
|
||||
copied.}
|
||||
|
||||
@item{@scheme[default-lib-dir] --- a default directory for finding
|
||||
@item{@racket[default-lib-dir] --- a default directory for finding
|
||||
supporting libraries, often a subdirectory of
|
||||
@filepath{collection-dir}. The user can supplement this path by
|
||||
setting the @indexed-envvar{PLT_EXTENSION_LIB_PATHS} environment
|
||||
variable, which applies to all extensions manged by
|
||||
@scheme[pre-install].}
|
||||
@racket[pre-install].}
|
||||
|
||||
@item{@scheme[include-subdirs] --- a list of relative paths in which
|
||||
@item{@racket[include-subdirs] --- a list of relative paths in which
|
||||
@tt{#include} files will be found; the path will be determined
|
||||
through a search, in case it's not in a standard place like
|
||||
@filepath{/usr/include}.
|
||||
|
||||
For example, the list used to be @scheme['("openssl")] for the
|
||||
For example, the list used to be @racket['("openssl")] for the
|
||||
@filepath{openssl} collection, because the source uses
|
||||
@tt{#include <openssl/ssl.h>} and @tt{#include <openssl/err.h>}.}
|
||||
|
||||
@item{@scheme[find-unix-libs] --- like @scheme[include-subdirs], but
|
||||
@item{@racket[find-unix-libs] --- like @racket[include-subdirs], but
|
||||
a list of library bases. Leave off the @filepath{lib} prefix and
|
||||
any suffix (such as @filepath{.a} or @filepath{.so}). For
|
||||
@filepath{openssl}, the list used to be @scheme['("ssl"
|
||||
@filepath{openssl}, the list used to be @racket['("ssl"
|
||||
"crypto")]. Each name will essentially get a @tt{-l} prefix for
|
||||
the linker command line.}
|
||||
|
||||
@item{@scheme[find-windows-libs] --- like @scheme[find-unix-libs],
|
||||
@item{@racket[find-windows-libs] --- like @racket[find-unix-libs],
|
||||
but for Windows. The library name will be suffixed with
|
||||
@filepath{.lib} and supplied directly to the linker.}
|
||||
|
||||
@item{@scheme[unix-libs] --- like @scheme[find-unix-libs], except
|
||||
@item{@racket[unix-libs] --- like @racket[find-unix-libs], except
|
||||
that the installer makes no attempt to find the libraries in a
|
||||
non-standard place. For example, the @filepath{readline} installer
|
||||
used to supply @scheme['("curses")].}
|
||||
used to supply @racket['("curses")].}
|
||||
|
||||
@item{@scheme[windows-libs] --- like @scheme[unix-libs], but for
|
||||
@item{@racket[windows-libs] --- like @racket[unix-libs], but for
|
||||
Windows. For example, the @filepath{openssl} installer used to
|
||||
supply @scheme['("wsock32")].}
|
||||
supply @racket['("wsock32")].}
|
||||
|
||||
@item{@scheme[extra-depends] --- a list of relative paths to treat as
|
||||
@item{@racket[extra-depends] --- a list of relative paths to treat as
|
||||
dependencies for compiling @filepath{file.c}. Often this list will
|
||||
include @filepath{file.c} with the @filepath{.c} suffix replaced by
|
||||
@filepath{.rkt}. For example, the "openssl" installer supplies
|
||||
@scheme['("mzssl.rkt")] to ensure that the stub module
|
||||
@racket['("mzssl.rkt")] to ensure that the stub module
|
||||
@filepath{mzssl.rkt} is never used when the true extension can be
|
||||
built.}
|
||||
|
||||
@item{@scheme[last-chance-k] --- a procedure of one argument, which
|
||||
@item{@racket[last-chance-k] --- a procedure of one argument, which
|
||||
is a thunk. This procedure should invoke the thunk to make the
|
||||
file, but it may add parameterizations before the final build. For
|
||||
example, the @filepath{readline} installer used to add an
|
||||
AIX-specific compile flag in this step when compiling on AIX.}
|
||||
|
||||
@item{@scheme[3m-too?]--- a boolean. If true, when the 3m variant is
|
||||
@item{@racket[3m-too?]--- a boolean. If true, when the 3m variant is
|
||||
installed, use the equivalent to @exec{raco ctool --xform} to transform
|
||||
the source file and then compile and link for 3m. Otherwise, the
|
||||
extension is built only for CGC when the CGC variant is installed.}
|
||||
|
@ -372,10 +372,10 @@ The arguments are as follows:
|
|||
[argv (or/c string? (vectorof string?))])
|
||||
void?]{
|
||||
|
||||
Builds bytecode files for each file in @scheme[collection-files],
|
||||
Builds bytecode files for each file in @racket[collection-files],
|
||||
writing each to a @filepath{compiled} subdirectory and automatically
|
||||
managing dependencies. Supply @scheme['#("zo")] as @scheme[argv] to
|
||||
compile all files. The @scheme[collection-name] argument is used only
|
||||
managing dependencies. Supply @racket['#("zo")] as @racket[argv] to
|
||||
compile all files. The @racket[collection-name] argument is used only
|
||||
for printing status information.
|
||||
|
||||
Compilation is performed as with @exec{raco make} (see
|
||||
|
@ -387,7 +387,7 @@ Compilation is performed as with @exec{raco make} (see
|
|||
|
||||
@defsignature[make:collection^ ()]{
|
||||
|
||||
Provides @schemeidfont{make-collection}.}
|
||||
Provides @racketidfont{make-collection}.}
|
||||
|
||||
@subsection{Unit}
|
||||
|
||||
|
@ -395,5 +395,5 @@ Provides @schemeidfont{make-collection}.}
|
|||
|
||||
@defthing[make:collection@ unit?]{
|
||||
|
||||
Imports @scheme[make^], @scheme[dynext:file^], and @scheme[compiler^],
|
||||
and exports @scheme[make:collection^].}
|
||||
Imports @racket[make^], @racket[dynext:file^], and @racket[compiler^],
|
||||
and exports @racket[make:collection^].}
|
||||
|
|
|
@ -25,8 +25,8 @@ fit the widths of all of its children.
|
|||
[(realign)
|
||||
void?])]{
|
||||
|
||||
Realigns the children inside the @scheme[aligned-pasteboard<%>] to
|
||||
either a given @scheme[width] and @scheme[height] or the previously
|
||||
Realigns the children inside the @racket[aligned-pasteboard<%>] to
|
||||
either a given @racket[width] and @racket[height] or the previously
|
||||
alloted width and height.}
|
||||
|
||||
@defmethod[(set-aligned-min-sizes)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@definterface/title[aligned-pasteboard-parent<%> ()]{
|
||||
|
||||
This interface must be implemented by any class who's editor
|
||||
is an @scheme[aligned-pasteboard<%>].
|
||||
is an @racket[aligned-pasteboard<%>].
|
||||
|
||||
@defmethod[(set-aligned-min-sizes)
|
||||
void?]{}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
@title[#:style 'toc]{Aligned Pasteboard}
|
||||
|
||||
The aligned-pasteboard library provides classes derived from
|
||||
@scheme[pasteboard%] with geometry management that mirrors that of
|
||||
@scheme[vertical-panel%] and @scheme[horizontal-panel%].
|
||||
@racket[pasteboard%] with geometry management that mirrors that of
|
||||
@racket[vertical-panel%] and @racket[horizontal-panel%].
|
||||
|
||||
@defmodule[mrlib/aligned-pasteboard]
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@defclass/title[horizontal-pasteboard% pasteboard% (aligned-pasteboard<%>)]{
|
||||
|
||||
@defconstructor/auto-super[()]{
|
||||
Passes all arguments to @scheme[super-init].
|
||||
Passes all arguments to @racket[super-init].
|
||||
}
|
||||
|
||||
@defmethod[#:mode override
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
This interface must be implemented by any snip class who's
|
||||
objects will be stretchable when inserted into an
|
||||
@scheme[aligned-pasteboard<%>].
|
||||
@racket[aligned-pasteboard<%>].
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@defclass/title[vertical-pasteboard% pasteboard% (aligned-pasteboard<%>)]{
|
||||
|
||||
@defconstructor/auto-super[()]{
|
||||
Passes all arguments to @scheme[super-init].
|
||||
Passes all arguments to @racket[super-init].
|
||||
}
|
||||
|
||||
@defmethod[#:mode override
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
(is-a?/c bitmap%)]{
|
||||
|
||||
Constructs a bitmap label suitable for use a button that contains the
|
||||
image specified by @scheme[img] followed by the text in @scheme[str].}
|
||||
image specified by @racket[img] followed by the text in @racket[str].}
|
||||
|
||||
|
||||
@defproc[((bitmap-label-maker [str string?]
|
||||
|
@ -19,5 +19,5 @@ image specified by @scheme[img] followed by the text in @scheme[str].}
|
|||
[future-parent (is-a?/c area-container<%>)])
|
||||
(is-a?/c bitmap%)]{
|
||||
|
||||
And older variant of @scheme[make-bitmap-label] that obtains a
|
||||
font to use from a container @scheme[future-parent].}
|
||||
And older variant of @racket[make-bitmap-label] that obtains a
|
||||
font to use from a container @racket[future-parent].}
|
||||
|
|
|
@ -5,21 +5,21 @@
|
|||
|
||||
@defmodule[mrlib/cache-image-snip]{
|
||||
|
||||
The @schememodname[mrlib/cache-image-snip] library provides the core
|
||||
The @racketmodname[mrlib/cache-image-snip] library provides the core
|
||||
data structure for DrRacket's @filepath{image.rkt} teachpack. Images in
|
||||
the @filepath{image.rkt} teachpack are instances of the
|
||||
@scheme[cache-image-snip%] class.}
|
||||
@racket[cache-image-snip%] class.}
|
||||
|
||||
The library also defines a new type, @scheme[argb], that represents a
|
||||
The library also defines a new type, @racket[argb], that represents a
|
||||
bitmap, but with alpha values. It has a maker, two selectors, and a
|
||||
predicate.
|
||||
|
||||
|
||||
@defclass[cache-image-snip% image-snip% ()]{
|
||||
|
||||
The @scheme[cache-image-snip%] class is a subclass of
|
||||
@scheme[image-snip%] simply so that its instances can be compared with
|
||||
@scheme[image-snip%] using @scheme[equal?]. All @scheme[image-snip%]
|
||||
The @racket[cache-image-snip%] class is a subclass of
|
||||
@racket[image-snip%] simply so that its instances can be compared with
|
||||
@racket[image-snip%] using @racket[equal?]. All @racket[image-snip%]
|
||||
functionality is overridden or ignored.
|
||||
|
||||
@defmethod[#:mode overrride
|
||||
|
@ -28,7 +28,7 @@ functionality is overridden or ignored.
|
|||
boolean?]{
|
||||
|
||||
Calls the @method[cache-image-snip% other-equal-to?] method of
|
||||
@scheme[snip] if it is also a @scheme[cache-image-snip%] instance,
|
||||
@racket[snip] if it is also a @racket[cache-image-snip%] instance,
|
||||
otherwise calls the @method[cache-image-snip% other-equal-to?] of
|
||||
@this-obj[].}
|
||||
|
||||
|
@ -52,7 +52,7 @@ otherwise calls the @method[cache-image-snip% other-equal-to?] of
|
|||
@defmethod[(get-argb/no-compute)
|
||||
(or/c false/c argb?)]{
|
||||
|
||||
Returns a pixel array for this image or @scheme[#f] if it has not
|
||||
Returns a pixel array for this image or @racket[#f] if it has not
|
||||
been computed yet.
|
||||
|
||||
|
||||
|
@ -64,8 +64,8 @@ otherwise calls the @method[cache-image-snip% other-equal-to?] of
|
|||
Builds (if not yet built) a bitmap corresponding to
|
||||
this snip and returns it.
|
||||
|
||||
If the width or the height of the snip is @scheme[0],
|
||||
this method return @scheme[#f].
|
||||
If the width or the height of the snip is @racket[0],
|
||||
this method return @racket[#f].
|
||||
}
|
||||
|
||||
@defmethod[(get-dc-proc)
|
||||
|
@ -119,20 +119,20 @@ This snipclass is used for saved cache image snips.}
|
|||
|
||||
@defproc[(argb-vector [argb argb?]) (vectorof (integer-in 0 255))]{
|
||||
|
||||
Extracts the vector from @scheme[argb].}
|
||||
Extracts the vector from @racket[argb].}
|
||||
|
||||
@defproc[(argb-width [argb argb?]) exact-nonnegative-integer?]{
|
||||
|
||||
Extracts the width from @scheme[argb].}
|
||||
Extracts the width from @racket[argb].}
|
||||
|
||||
@defproc[(argb-height [argb argb?]) exact-nonnegative-integer?]{
|
||||
|
||||
Extracts the height from @scheme[argb].}
|
||||
Extracts the height from @racket[argb].}
|
||||
|
||||
|
||||
@defproc[(argb? [v any/c]) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if @scheme[v] is an argb, @scheme[#f] otherwise.}
|
||||
Returns @racket[#t] if @racket[v] is an argb, @racket[#f] otherwise.}
|
||||
|
||||
|
||||
@defproc[(overlay-bitmap [dest argb?]
|
||||
|
@ -142,8 +142,8 @@ Returns @scheme[#t] if @scheme[v] is an argb, @scheme[#f] otherwise.}
|
|||
[mask (is-a?/c bitmap%)])
|
||||
void?]{
|
||||
|
||||
Changes @scheme[argb], overlaying @scheme[img] with masking based on
|
||||
@scheme[mask] at @math{(@scheme[dx], @scheme[dy])} from the top-left.}
|
||||
Changes @racket[argb], overlaying @racket[img] with masking based on
|
||||
@racket[mask] at @math{(@racket[dx], @racket[dy])} from the top-left.}
|
||||
|
||||
|
||||
@defproc[(build-bitmap [draw ((is-a?/c dc<%>) . -> . any)]
|
||||
|
@ -151,34 +151,34 @@ Changes @scheme[argb], overlaying @scheme[img] with masking based on
|
|||
[height (integer-in 1 10000)])
|
||||
(is-a?/c bitmap%)]{
|
||||
|
||||
Builds a bitmap of size @scheme[width] by @scheme[height], using the
|
||||
procedure @scheme[draw] to render the bitmap content into the given
|
||||
@scheme[dc<%>].}
|
||||
Builds a bitmap of size @racket[width] by @racket[height], using the
|
||||
procedure @racket[draw] to render the bitmap content into the given
|
||||
@racket[dc<%>].}
|
||||
|
||||
|
||||
@defproc[(flatten-bitmap [bitmap (is-a?/c bitmap%)]) (is-a?/c bitmap%)]{
|
||||
|
||||
Builds a new bitmap that flattens the original @scheme[bitmap]
|
||||
Builds a new bitmap that flattens the original @racket[bitmap]
|
||||
with its mask (as determined by @xmethod[bitmap%
|
||||
get-loaded-mask]), producing a bitmap that has no mask, and looks
|
||||
the way that bitmap would draw (when drawn with the mask) onto a
|
||||
white background.}
|
||||
|
||||
|
||||
|
||||
@defproc[(argb->cache-image-snip [argb argb?][dx real?][dy real?])
|
||||
(is-a?/c cache-image-snip%)]{
|
||||
|
||||
Builds a new @scheme[cache-image-snip%] based on the contents of
|
||||
@scheme[argb], using @scheme[dx] and @scheme[dy] as the pinhole.}
|
||||
Builds a new @racket[cache-image-snip%] based on the contents of
|
||||
@racket[argb], using @racket[dx] and @racket[dy] as the pinhole.}
|
||||
|
||||
|
||||
@defproc[(argb->bitmap [argb argb?]) (or/c false/c (is-a?/c bitmap%))]{
|
||||
|
||||
Builds a bitmap that draws the same way as @scheme[argb]; the alpha
|
||||
Builds a bitmap that draws the same way as @racket[argb]; the alpha
|
||||
pixels are put into the bitmap's @method[bitmap% get-loaded-mask]
|
||||
bitmap.
|
||||
|
||||
If the width or height of @scheme[argb] is @scheme[0],
|
||||
this returns @scheme[#f].
|
||||
If the width or height of @racket[argb] is @racket[0],
|
||||
this returns @racket[#f].
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
@title{Close Icon}
|
||||
|
||||
@defmodule[mrlib/close-icon]{The @scheme[close-icon%] class
|
||||
@defmodule[mrlib/close-icon]{The @racket[close-icon%] class
|
||||
provides a clickable close button icon.}
|
||||
|
||||
@defclass[close-icon% canvas% ()]{
|
||||
|
@ -14,8 +14,8 @@ provides a clickable close button icon.}
|
|||
[bg-color (or/c #f string (is-a?/c color%))]
|
||||
[horizontal-pad positive-integer? 4]
|
||||
[vertical-pad positive-integer? 4])]{
|
||||
The @scheme[callback] is called when the close icon is clicked.
|
||||
|
||||
If @scheme[bg-color] is specified, it is used as the background color of the icon.
|
||||
The @racket[callback] is called when the close icon is clicked.
|
||||
|
||||
If @racket[bg-color] is specified, it is used as the background color of the icon.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
[filename path-string])
|
||||
void?]{
|
||||
|
||||
Writes the given @scheme[bitmap] to @scheme[filename] as a GIF image,
|
||||
where @scheme[bitmap] is either an instance of @scheme[bitmap%] or a
|
||||
Writes the given @racket[bitmap] to @racket[filename] as a GIF image,
|
||||
where @racket[bitmap] is either an instance of @racket[bitmap%] or a
|
||||
thunk (to be called just once) that generates such an object. If the
|
||||
bitmap uses more than 256 colors, it is automatically quantized using
|
||||
a simple algorithm; see @scheme[quantize]. If the bitmap has a mask
|
||||
a simple algorithm; see @racket[quantize]. If the bitmap has a mask
|
||||
bitmap via @method[bitmap% get-loaded-mask], it is used to determine
|
||||
transparent pixels in the generated GIF image.}
|
||||
|
||||
|
@ -30,28 +30,28 @@ transparent pixels in the generated GIF image.}
|
|||
[#:last-frame-delay last-frame-delay (or/c (integer-in 0 #xFFFFFFFF) false/c) #f])
|
||||
void?]{
|
||||
|
||||
Writes the bitmaps in @scheme[bitmaps] to @scheme[filename] as an
|
||||
animated GIF. The @scheme[bitmaps] list can contain a mixture of
|
||||
@scheme[bitmap%] objects and thunks (each called just once) that
|
||||
produce @scheme[bitmap%] objects. The @scheme[delay-csec] argument is
|
||||
Writes the bitmaps in @racket[bitmaps] to @racket[filename] as an
|
||||
animated GIF. The @racket[bitmaps] list can contain a mixture of
|
||||
@racket[bitmap%] objects and thunks (each called just once) that
|
||||
produce @racket[bitmap%] objects. The @racket[delay-csec] argument is
|
||||
the amount of time in 1/100s of a second to wait between transitions.
|
||||
If @scheme[loop?] is a true value, then the GIF is marked as a looping
|
||||
If @racket[loop?] is a true value, then the GIF is marked as a looping
|
||||
animation.
|
||||
|
||||
If @scheme[one-at-a-time?] is @scheme[#f], then the content of all
|
||||
If @racket[one-at-a-time?] is @racket[#f], then the content of all
|
||||
images is collected and quantized at once, to produce a single
|
||||
colortable; a drawback to this approach is that it uses more memory,
|
||||
and it allows less color variation among animation frames. Even when
|
||||
@scheme[one-at-a-time?] is @scheme[#f], the result of each thunk in
|
||||
@scheme[bitmaps] is converted to a byte-string one at a time.
|
||||
@racket[one-at-a-time?] is @racket[#f], the result of each thunk in
|
||||
@racket[bitmaps] is converted to a byte-string one at a time.
|
||||
|
||||
If @scheme[one-at-a-time?] is true, then the bitmaps are quantized and
|
||||
If @racket[one-at-a-time?] is true, then the bitmaps are quantized and
|
||||
written to the file one at a time; that is, for each thunk in
|
||||
@scheme[bitmaps], its result is written and discarded before another
|
||||
@racket[bitmaps], its result is written and discarded before another
|
||||
thunk is called. A drawback to this approach is that a separate
|
||||
colortable is written for each frame in the animation, which can make
|
||||
the resulting file large.
|
||||
|
||||
If @scheme[last-frame-delay] is not false, a delay of
|
||||
@scheme[last-frame-delay] (in 1/100s of a second) is added to the last
|
||||
frame. This extra delay is useful when @scheme[loop?] is true.}
|
||||
If @racket[last-frame-delay] is not false, a delay of
|
||||
@racket[last-frame-delay] (in 1/100s of a second) is added to the last
|
||||
frame. This extra delay is useful when @racket[loop?] is true.}
|
||||
|
|
|
@ -70,8 +70,8 @@ different nodes.
|
|||
graph pasteboard, and is expected to draw the edges between the
|
||||
snips. The argments are a subset of those passed to
|
||||
@method[editor<%> on-paint] and it is only called when the
|
||||
@scheme[before?] argument to @method[editor<%> on-paint]
|
||||
is @scheme[#t].
|
||||
@racket[before?] argument to @method[editor<%> on-paint]
|
||||
is @racket[#t].
|
||||
}
|
||||
|
||||
@defmethod[(draw-single-edge [dc (is-a?/c dc<%>)]
|
||||
|
@ -88,25 +88,25 @@ different nodes.
|
|||
This method is called to draw each edge in the graph, except
|
||||
for the edges that connect a node to itself.
|
||||
|
||||
The @scheme[dc], @scheme[dx], and @scheme[dy] arguments are
|
||||
The @racket[dc], @racket[dx], and @racket[dy] arguments are
|
||||
the same as in @method[editor<%> on-paint].
|
||||
|
||||
The
|
||||
@scheme[from-x], @scheme[from-y], @scheme[to-x], and
|
||||
@scheme[to-y] arguments specify points on the source and
|
||||
@racket[from-x], @racket[from-y], @racket[to-x], and
|
||||
@racket[to-y] arguments specify points on the source and
|
||||
destination snip's bounding box where a straight line
|
||||
between the centers of the snip would intersect.
|
||||
|
||||
The @scheme[arrow-point-ok?] function returns @scheme[#t]
|
||||
The @racket[arrow-point-ok?] function returns @racket[#t]
|
||||
when the point specified by its arguments is inside the
|
||||
smallest rectangle that covers both the source and
|
||||
destination snips, but is outside of both of the rectangles
|
||||
that surround the source and destination snips themselves.
|
||||
|
||||
This default implementation uses @scheme[update-polygon] to compute
|
||||
This default implementation uses @racket[update-polygon] to compute
|
||||
the arrowheads and otherwise draws a straight line between the two
|
||||
points and then the arrowheads, unless the arrowhead points
|
||||
are not ok according to @scheme[arrow-point-ok?], in which case
|
||||
are not ok according to @racket[arrow-point-ok?], in which case
|
||||
it just draws the line.
|
||||
}
|
||||
|
||||
|
@ -116,8 +116,8 @@ it just draws the line.
|
|||
[point3 (is-a?/c point%)]
|
||||
[point4 (is-a?/c point%)]) void?]{
|
||||
|
||||
Updates the arguments @scheme[point1], @scheme[point2], @scheme[point3], @scheme[point4] with the coordinates
|
||||
of an arrowhead for a line that connects (@scheme[from-x],@scheme[from-y]) to (@scheme[to-x],@scheme[to-y]).
|
||||
Updates the arguments @racket[point1], @racket[point2], @racket[point3], @racket[point4] with the coordinates
|
||||
of an arrowhead for a line that connects (@racket[from-x],@racket[from-y]) to (@racket[to-x],@racket[to-y]).
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
[edge-label-font (or/c #f (is-a?/c font%)) #f]
|
||||
[cache-arrow-drawing? any])]{
|
||||
|
||||
If @scheme[edge-labels?] is @scheme[#f], no edge labels are
|
||||
If @racket[edge-labels?] is @racket[#f], no edge labels are
|
||||
drawn. Otherwise, they are.
|
||||
|
||||
If @scheme[edge-label-font] is supplied, it is used when drawing the
|
||||
If @racket[edge-label-font] is supplied, it is used when drawing the
|
||||
labels on the edges. Otherwise, the font is not set before drawing
|
||||
the labels, defaulting to the @scheme[dc<%>] object's font.
|
||||
the labels, defaulting to the @racket[dc<%>] object's font.
|
||||
|
||||
If @racket[cache-arrow-drawing?] is @racket[#f], then the arrows in the snip
|
||||
are not cached in a bitmap (to speed up drawing when the mouse moves around).
|
||||
|
@ -21,4 +21,4 @@ Otherwise, they are.
|
|||
}
|
||||
|
||||
This mixin overrides many methods to draw lines between
|
||||
@scheme[graph-snip<%>] that it contains.}
|
||||
@racket[graph-snip<%>] that it contains.}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
void?]{
|
||||
|
||||
Adds a child of this snip. Instead of calling this method,
|
||||
consider using the @scheme[add-links] function.
|
||||
consider using the @racket[add-links] function.
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
|||
void?])]{
|
||||
|
||||
Adds a parent of this snip. Instead of calling this
|
||||
method, consider using the @scheme[add-links] function.
|
||||
method, consider using the @racket[add-links] function.
|
||||
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
|||
(listof snip%)]{
|
||||
|
||||
returns a list of snips that implement
|
||||
@scheme[graph-snip<%>]. Each of these snips will have a line
|
||||
@racket[graph-snip<%>]. Each of these snips will have a line
|
||||
drawn from it, pointing at this snip.
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ drawn from it, pointing at this snip.
|
|||
@defmethod[(get-parents)
|
||||
(listof graph-snip<%>)]{
|
||||
|
||||
Returns a list of snips that implement @scheme[graph-snip<%>]. Each
|
||||
Returns a list of snips that implement @racket[graph-snip<%>]. Each
|
||||
of these snips will have a line drawn to it, starting from
|
||||
this snip.
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ this snip.
|
|||
Removes a child snip from this snip. Be sure to remove
|
||||
this snip as a parent from the argument, too.
|
||||
Instead of calling this method, consider using the
|
||||
@scheme[remove-links] function.
|
||||
@racket[remove-links] function.
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ this snip.
|
|||
Removes a parent snip from this snip. Be sure to remove this
|
||||
snip as a child from the argument, too.
|
||||
Instead of calling this method, consider using the
|
||||
@scheme[remove-links] function.
|
||||
@racket[remove-links] function.
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,8 +70,8 @@ this snip.
|
|||
[label (or/c false/c string/)])
|
||||
void?]{
|
||||
|
||||
Changes the label on the edge going to the @scheme[parent] to be
|
||||
@scheme[label]. Ignored if no such egde exists.
|
||||
Changes the label on the edge going to the @racket[parent] to be
|
||||
@racket[label]. Ignored if no such egde exists.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
@title[#:style 'toc]{Graphs}
|
||||
|
||||
@defmodule[mrlib/graph]{The @schememodname[mrlib/graph] library
|
||||
provides a graph drawing toolkit built out of @scheme[pasteboard%]s.}
|
||||
@defmodule[mrlib/graph]{The @racketmodname[mrlib/graph] library
|
||||
provides a graph drawing toolkit built out of @racket[pasteboard%]s.}
|
||||
|
||||
@local-table-of-contents[]
|
||||
|
||||
|
@ -42,20 +42,20 @@ provides a graph drawing toolkit built out of @scheme[pasteboard%]s.}
|
|||
|
||||
Connects a parent snip to a child snip within a pasteboard.
|
||||
|
||||
The default @scheme[dark-pen]/@scheme[dark-brush] and
|
||||
@scheme[light-pen]/@scheme[light-brush] are blue and purple,
|
||||
respectively. The @scheme[dark-pen] and @scheme[dark-brush] are used
|
||||
The default @racket[dark-pen]/@racket[dark-brush] and
|
||||
@racket[light-pen]/@racket[light-brush] are blue and purple,
|
||||
respectively. The @racket[dark-pen] and @racket[dark-brush] are used
|
||||
when the mouse cursor is over the snip (or a child or parent), and the
|
||||
@scheme[light-pen] and @scheme[light-brush] are used when the mouse
|
||||
@racket[light-pen] and @racket[light-brush] are used when the mouse
|
||||
cursor is not over the snip. The brush is used to draw inside the
|
||||
arrow head and the pen is used to draw the border of the arrowhead and
|
||||
the line connecting the two snips.
|
||||
|
||||
if @scheme[label] is provided and not @scheme[#f], it is used as a
|
||||
if @racket[label] is provided and not @racket[#f], it is used as a
|
||||
label on the edge.
|
||||
|
||||
When @scheme[dx] and @scheme[dy] are provided, the are offsets for the
|
||||
head and the tail of the arrow. Otherwise, @scheme[0] offsets are
|
||||
When @racket[dx] and @racket[dy] are provided, the are offsets for the
|
||||
head and the tail of the arrow. Otherwise, @racket[0] offsets are
|
||||
used.}
|
||||
|
||||
@defproc[(add-links/text-colors [parent (is-a?/c graph-snip<%>)]
|
||||
|
@ -71,8 +71,8 @@ used.}
|
|||
[label (or/c string? false/c)])
|
||||
void?]{
|
||||
|
||||
Like @scheme[add-links], but with extra @scheme[dark-text] and
|
||||
@scheme[light-text] arguments to set the colors of the label.}
|
||||
Like @racket[add-links], but with extra @racket[dark-text] and
|
||||
@racket[light-text] arguments to set the colors of the label.}
|
||||
|
||||
@defproc[(remove-links [parent (is-a?/c graph-snip<%>)]
|
||||
[child (is-a?/c graph-snip<%>)])
|
||||
|
@ -85,6 +85,6 @@ Disconnects a parent snip from a child snip within a pasteboard.}
|
|||
[label (or/c string? false/c)])
|
||||
void?]{
|
||||
|
||||
Changes the label on the edge going from @scheme[child] to
|
||||
@scheme[parent] to be @scheme[label]. If there is no existing edge
|
||||
Changes the label on the edge going from @racket[child] to
|
||||
@racket[parent] to be @racket[label]. If there is no existing edge
|
||||
between the two nodes, then nothing happens.}
|
||||
|
|
|
@ -32,7 +32,7 @@ Like @xmethod[hierarchical-list% new-list].}
|
|||
|
||||
@defmethod[(delete-item [i (is-a?/c hierarchical-list-item<%>)]) void?]{
|
||||
|
||||
Deletes immediate item or sub-list @scheme[i] from the sub-list.}
|
||||
Deletes immediate item or sub-list @racket[i] from the sub-list.}
|
||||
|
||||
|
||||
@defmethod[(get-items) (listof (is-a?/c hierarchical-list-item<%>))]{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
@defmodule[mrlib/hierlist]
|
||||
|
||||
A @scheme[hierarchical-list%] control is a list of items, some of
|
||||
A @racket[hierarchical-list%] control is a list of items, some of
|
||||
which can themselves be hierarchical lists. Each such sub-list has an
|
||||
arrow that the user can click to hide or show the sub-list's items.
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Reports whether the item is selected.}
|
|||
[(click-select [on? any/c]) void?])]{
|
||||
|
||||
Calls @method[hierarchical-list% select] or @method[hierarchical-list%
|
||||
click-select]. The @scheme[on?] argument can be @scheme[#f] only if
|
||||
click-select]. The @racket[on?] argument can be @racket[#f] only if
|
||||
@xmethod[hierarchical-list% allow-deselect] allows it.}
|
||||
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ Creates a hierarchical-list control.
|
|||
|
||||
Creates the control.
|
||||
|
||||
If the style @scheme['transparent] is passed, then the
|
||||
If the style @racket['transparent] is passed, then the
|
||||
@method[editor-snip% use-style-background] method will be
|
||||
called with @scheme[#t] when editor snips are created as part of
|
||||
called with @racket[#t] when editor snips are created as part of
|
||||
the hierarchical list, ensuring that the entire control is
|
||||
transparent.
|
||||
|
||||
|
@ -39,11 +39,11 @@ Returns the currently selected item, if any.}
|
|||
(is-a?/c hierarchical-list-item<%>)]{
|
||||
|
||||
Creates and returns a new (empty) item in the list. See
|
||||
@scheme[hierarchical-list-item<%>] for methods to fill in the item's
|
||||
@racket[hierarchical-list-item<%>] for methods to fill in the item's
|
||||
label.
|
||||
|
||||
The @scheme[mixin] argument is applied to a class implementing
|
||||
@scheme[hierarchical-list-item<%>], and the resulting class is
|
||||
The @racket[mixin] argument is applied to a class implementing
|
||||
@racket[hierarchical-list-item<%>], and the resulting class is
|
||||
instantiated as the list item.}
|
||||
|
||||
|
||||
|
@ -62,17 +62,17 @@ list is empty.}
|
|||
(is-a?/c hierarchical-list-compound-item<%>)]{
|
||||
|
||||
Creates and returns a new (empty) sub-list in the list. See
|
||||
@scheme[hierarchical-list-compound-item<%>] for methods to fill in the
|
||||
@racket[hierarchical-list-compound-item<%>] for methods to fill in the
|
||||
item's label and content.
|
||||
|
||||
The @scheme[mixin] argument is applied to a class implementing
|
||||
@scheme[hierarchical-list-compound-item<%>], and the resulting class
|
||||
The @racket[mixin] argument is applied to a class implementing
|
||||
@racket[hierarchical-list-compound-item<%>], and the resulting class
|
||||
is instantiated as the sub-list.}
|
||||
|
||||
|
||||
@defmethod[(delete-item [i (is-a?/c hierarchical-list-item<%>)]) void?]{
|
||||
|
||||
Deletes immediate item or sub-list @scheme[i] from the list.}
|
||||
Deletes immediate item or sub-list @racket[i] from the list.}
|
||||
|
||||
|
||||
@defmethod[(get-items) (listof (is-a?/c hierarchical-list-item<%>))]{
|
||||
|
@ -89,7 +89,7 @@ selection.}
|
|||
|
||||
@defmethod[(on-select [i (or/c (is-a?/c hierarchical-list-item<%>) false/c)]) any]{
|
||||
|
||||
Called for new select of @scheme[i], where @scheme[i] is @scheme[#f]
|
||||
Called for new select of @racket[i], where @racket[i] is @racket[#f]
|
||||
if no item is now selected.}
|
||||
|
||||
|
||||
|
@ -103,17 +103,17 @@ set-allow-selection].}
|
|||
|
||||
@defmethod[(on-double-select [i (is-a?/c hierarchical-list-item<%>)]) any]{
|
||||
|
||||
Called for a double-click on @scheme[i].}
|
||||
Called for a double-click on @racket[i].}
|
||||
|
||||
|
||||
@defmethod[(on-item-opened [i (is-a?/c hierarchical-list-compound-item<%>)]) any]{
|
||||
|
||||
Called when the arrow for @scheme[i] is turned down.}
|
||||
Called when the arrow for @racket[i] is turned down.}
|
||||
|
||||
|
||||
@defmethod[(on-item-closed [i (is-a?/c hierarchical-list-compound-item<%>)]) any]{
|
||||
|
||||
Called when the arrow for @scheme[i] is turned up.}
|
||||
Called when the arrow for @racket[i] is turned up.}
|
||||
|
||||
|
||||
@defmethod[(sort [less-than-proc ((is-a?/c hierarchical-list-item<%>)
|
||||
|
@ -122,8 +122,8 @@ Called when the arrow for @scheme[i] is turned up.}
|
|||
[recur? any/c #t])
|
||||
void?]{
|
||||
|
||||
Sorts items in the list by calling @scheme[less-than-proc] on pairs of
|
||||
items. If @scheme[recur?] is true, items in sub-lists are sorted
|
||||
Sorts items in the list by calling @racket[less-than-proc] on pairs of
|
||||
items. If @racket[recur?] is true, items in sub-lists are sorted
|
||||
recursively.}
|
||||
|
||||
|
||||
|
@ -131,7 +131,7 @@ recursively.}
|
|||
boolean?]{
|
||||
|
||||
Like @xmethod[editor<%> can-do-edit-operation?]. The default
|
||||
implementation always returns @scheme[#f].}
|
||||
implementation always returns @racket[#f].}
|
||||
|
||||
|
||||
@defmethod[(do-edit-operation [op symbol?] [recursive? any/c #t])
|
||||
|
@ -161,7 +161,7 @@ Moves the selection, scrolls as necessary to show it, and calls
|
|||
@method[hierarchical-list% on-select-always].
|
||||
|
||||
The @method[hierarchical-list% allow-deselect] method controls whether
|
||||
@scheme[i] is allowed to be @scheme[#f] to deselect the currently
|
||||
@racket[i] is allowed to be @racket[#f] to deselect the currently
|
||||
selected item.}
|
||||
|
||||
|
||||
|
@ -199,7 +199,7 @@ This is initially disabled, by default.}
|
|||
|
||||
|
||||
Gets/sets whether the @method[hierarchical-list% on-select] can be
|
||||
called with a @scheme[#f] argument to deselect the current item
|
||||
called with a @racket[#f] argument to deselect the current item
|
||||
(leaving none selected).
|
||||
|
||||
The initial mode does not allow deselection.}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#lang scribble/doc
|
||||
@(require "../common.rkt" (for-label mrlib/hierlist))
|
||||
|
||||
@title{Snips in a @scheme[hierarchical-list%] Instance}
|
||||
@title{Snips in a @racket[hierarchical-list%] Instance}
|
||||
|
||||
The @xmethod[text% find-snip] method of the editor in a
|
||||
@scheme[hierarchical-list%] return instances of
|
||||
@scheme[hierarchical-item-snip%] and @scheme[hierarchical-list-snip%].
|
||||
@racket[hierarchical-list%] return instances of
|
||||
@racket[hierarchical-item-snip%] and @racket[hierarchical-list-snip%].
|
||||
|
||||
@defclass[hierarchical-item-snip% editor-snip% ()]{
|
||||
|
||||
@defmethod[(get-item) (is-a?/c hierarchical-list-item<%>)]{
|
||||
|
||||
Returns the @scheme[hierarchical-list-item<%>] corresponding to the
|
||||
Returns the @racket[hierarchical-list-item<%>] corresponding to the
|
||||
snip.}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ The @xmethod[text% find-snip] method of the editor in a
|
|||
|
||||
@defmethod[(get-item) (is-a?/c hierarchical-list-compound-item<%>)]{
|
||||
|
||||
Returns the @scheme[hierarchical-list-compound-item<%>] corresponding to the
|
||||
Returns the @racket[hierarchical-list-compound-item<%>] corresponding to the
|
||||
snip.}
|
||||
|
||||
@defmethod[(get-content-buffer) (is-a?/c text%)]{
|
||||
|
|
|
@ -18,7 +18,7 @@ up an image.
|
|||
void?]{
|
||||
Draws @racket[image] in @racket[dc] at the position (@racket[dx],@racket[dy]).
|
||||
}
|
||||
|
||||
|
||||
@defproc[(image? [v any/c]) boolean?]{
|
||||
Recognizes the images that library handles.
|
||||
}
|
||||
|
|
|
@ -4,28 +4,28 @@
|
|||
|
||||
@title{Include Bitmap}
|
||||
|
||||
@defmodule[mrlib/include-bitmap]{The @scheme[include-bitmap] form
|
||||
@defmodule[mrlib/include-bitmap]{The @racket[include-bitmap] form
|
||||
takes a filename containing a bitmap and ``inlines'' the bitmap into
|
||||
the program.}
|
||||
|
||||
Historically, the advantage of inlining the bitmap is that a
|
||||
stand-alone executable can be created that contains the bitmap and
|
||||
does not refer to the original image file. The
|
||||
@scheme[define-runtime-path] form, however, now provides a better
|
||||
@racket[define-runtime-path] form, however, now provides a better
|
||||
alternative.
|
||||
|
||||
@defform*[[(include-bitmap path-spec)
|
||||
(include-bitmap path-spec type-expr)]]{
|
||||
|
||||
|
||||
The @scheme[path-spec] is the same as for @scheme[include] form. The
|
||||
@scheme[type-expr] should produce @scheme['unknown],
|
||||
@scheme['unknown/mask], etc., as for @scheme[bitmap%], and the default
|
||||
is @scheme['unknown/mask].}
|
||||
The @racket[path-spec] is the same as for @racket[include] form. The
|
||||
@racket[type-expr] should produce @racket['unknown],
|
||||
@racket['unknown/mask], etc., as for @racket[bitmap%], and the default
|
||||
is @racket['unknown/mask].}
|
||||
|
||||
|
||||
@defform*[[(include-bitmap/relative-to source path-spec)
|
||||
(include-bitmap/relative-to source path-spec [type-expr])]]{
|
||||
|
||||
Analogous to @scheme[include-at/relative-to], though only a source is
|
||||
Analogous to @racket[include-at/relative-to], though only a source is
|
||||
needed (no context).}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
@defproc[(set-interactive-display-handler [port output-port?]) void?]{
|
||||
|
||||
Sets @scheme[port]'s display handler (via
|
||||
@scheme[port-display-handler]) so that when it encounters these
|
||||
Sets @racket[port]'s display handler (via
|
||||
@racket[port-display-handler]) so that when it encounters these
|
||||
values:
|
||||
|
||||
@itemize[
|
||||
|
@ -20,21 +20,21 @@ values:
|
|||
|
||||
]
|
||||
|
||||
it uses @scheme[write-special] to send snips to the port,
|
||||
it uses @racket[write-special] to send snips to the port,
|
||||
instead of those values. Otherwise, it behaves like the
|
||||
default handler.
|
||||
|
||||
To show values embedded in lists and other compound object, it uses
|
||||
@scheme[pretty-print].}
|
||||
@racket[pretty-print].}
|
||||
|
||||
|
||||
@defproc[(set-interactive-write-handler [port output-port?]) void?]{
|
||||
|
||||
Like @scheme[set-interactive-display-handler], but sets the
|
||||
@scheme[port-write-handler].}
|
||||
Like @racket[set-interactive-display-handler], but sets the
|
||||
@racket[port-write-handler].}
|
||||
|
||||
|
||||
@defproc[(set-interactive-print-handler [port output-port?]) void?]{
|
||||
|
||||
Like @scheme[set-interactive-display-handler], but sets the
|
||||
@scheme[port-print-handler].}
|
||||
Like @racket[set-interactive-display-handler], but sets the
|
||||
@racket[port-print-handler].}
|
||||
|
|
|
@ -71,7 +71,7 @@ saying that there is no file name until the file is saved.}
|
|||
the label is determined by
|
||||
the @method[name-message% set-message].
|
||||
}
|
||||
|
||||
|
||||
@defmethod[(get-background-color) (or/c #f (is-a/c color%) string?)]{
|
||||
|
||||
The result of this method is used for the background color
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
@defclass[path-dialog% dialog% ()]{
|
||||
|
||||
The @scheme[path-dialog%] class implements a platform-independent
|
||||
The @racket[path-dialog%] class implements a platform-independent
|
||||
file/directory dialog. The dialog is similar in functionality to the
|
||||
@scheme[get-file], @scheme[put-file], @scheme[get-directory], and
|
||||
@scheme[get-file-list] procedures, but considerable extra functionality
|
||||
is available through the @scheme[path-dialog%] class.
|
||||
@racket[get-file], @racket[put-file], @racket[get-directory], and
|
||||
@racket[get-file-list] procedures, but considerable extra functionality
|
||||
is available through the @racket[path-dialog%] class.
|
||||
|
||||
|
||||
@defconstructor[([label (or/c label-string? false/c) #f]
|
||||
|
@ -34,79 +34,79 @@ is available through the @scheme[path-dialog%] class.
|
|||
[ok? (or/c (path? . -> . any) false/c) #f]
|
||||
[guard (or/c (path? . -> . any) false/c) #f])]{
|
||||
|
||||
The @scheme[label] argument is the dialog's title string. If
|
||||
@scheme[label] is @scheme[#f], the default is based on other field
|
||||
The @racket[label] argument is the dialog's title string. If
|
||||
@racket[label] is @racket[#f], the default is based on other field
|
||||
values.
|
||||
|
||||
The @scheme[message] argument is a prompt message to show at the top
|
||||
of the dialog. If it is @scheme[#f], no prompt line.
|
||||
The @racket[message] argument is a prompt message to show at the top
|
||||
of the dialog. If it is @racket[#f], no prompt line.
|
||||
|
||||
The @scheme[parent] argument is the parent frame or dialog, if any,
|
||||
The @racket[parent] argument is the parent frame or dialog, if any,
|
||||
for this dialog.
|
||||
|
||||
The @scheme[directory] argument specifies the dialog's initial
|
||||
directory. If it is @scheme[#f], the initial directory is the last
|
||||
The @racket[directory] argument specifies the dialog's initial
|
||||
directory. If it is @racket[#f], the initial directory is the last
|
||||
directory that was used by the user (or the current directory on first
|
||||
use).
|
||||
|
||||
The @scheme[filename] argument provides an initial filename text, if
|
||||
The @racket[filename] argument provides an initial filename text, if
|
||||
any.
|
||||
|
||||
If @scheme[put?] is true, the dialog operates in choose-file-to-write
|
||||
If @racket[put?] is true, the dialog operates in choose-file-to-write
|
||||
mode (and warn the user if choosing an existing name).
|
||||
|
||||
If @scheme[dir?] is true, the dialog operates in directory-choice
|
||||
If @racket[dir?] is true, the dialog operates in directory-choice
|
||||
mode.
|
||||
|
||||
If @scheme[existing?] is true, the use must choose an existing file.
|
||||
If @racket[existing?] is true, the use must choose an existing file.
|
||||
|
||||
If @scheme[new?] is true, the user must choose a non-existant
|
||||
path. Providing both @scheme[new?] and @scheme[existing?] as true
|
||||
If @racket[new?] is true, the user must choose a non-existant
|
||||
path. Providing both @racket[new?] and @racket[existing?] as true
|
||||
triggers an exception.
|
||||
|
||||
If @scheme[multi?] is true, the dialog allows selection of multiple
|
||||
If @racket[multi?] is true, the dialog allows selection of multiple
|
||||
paths.
|
||||
|
||||
If @scheme[can-mkdir?] is true, the dialog includes a button for the
|
||||
If @racket[can-mkdir?] is true, the dialog includes a button for the
|
||||
user to create a new directory.
|
||||
|
||||
The @scheme[filters] argument is one of:
|
||||
The @racket[filters] argument is one of:
|
||||
|
||||
@itemize[
|
||||
|
||||
@item{@scheme[(list (list _filter-name _filter-glob) ...)] --- a
|
||||
list of pattern names (e.g., @scheme["Scheme Files"]) and glob
|
||||
patterns (e.g., @scheme["*.rkt;*.scrbl"]). Any list, including an
|
||||
@item{@racket[(list (list _filter-name _filter-glob) ...)] --- a
|
||||
list of pattern names (e.g., @racket["Scheme Files"]) and glob
|
||||
patterns (e.g., @racket["*.rkt;*.scrbl"]). Any list, including an
|
||||
empty list, enables a filter box for the user to enter glob
|
||||
patterns, and the given list of choices is available in a
|
||||
combo-box drop-down menu. Glob patterns are the usual Unix ones
|
||||
(see @scheme[glob->regexp]), and a semicolon can be used to allow
|
||||
(see @racket[glob->regexp]), and a semicolon can be used to allow
|
||||
multiple patterns.}
|
||||
|
||||
@item{@scheme[#f] --- no patterns and no filter input box.}
|
||||
@item{@racket[#f] --- no patterns and no filter input box.}
|
||||
|
||||
@item{@scheme[#t] --- use a generic @scheme["All"] filter, which is
|
||||
@scheme["*.*"] on Windows and @scheme["*"] on other
|
||||
@item{@racket[#t] --- use a generic @racket["All"] filter, which is
|
||||
@racket["*.*"] on Windows and @racket["*"] on other
|
||||
platforms.}
|
||||
|
||||
]
|
||||
|
||||
The @scheme[show-file?] predicate is used to filter file paths that
|
||||
The @racket[show-file?] predicate is used to filter file paths that
|
||||
are shown in the dialog. The predicate is applied to the file name as
|
||||
a string while the current-directory parameter is set. This predicate
|
||||
is intended to be a lightweight filter for choosing which names to
|
||||
display.
|
||||
|
||||
The @scheme[show-dir?] predicate is similar, but for directories
|
||||
The @racket[show-dir?] predicate is similar, but for directories
|
||||
instead of files.
|
||||
|
||||
The @scheme[ok?] predicate is used in a similar fashion to the
|
||||
@scheme[show-file?] and @scheme[show-dir?] predicate, but it is used
|
||||
The @racket[ok?] predicate is used in a similar fashion to the
|
||||
@racket[show-file?] and @racket[show-dir?] predicate, but it is used
|
||||
to determine whether the @onscreen{OK} button should be enabled when a
|
||||
file or directory is selected (so it need not be as lightweight as the
|
||||
other predicates).
|
||||
|
||||
The @scheme[guard] procedure is a generic verifier for the dialog's
|
||||
The @racket[guard] procedure is a generic verifier for the dialog's
|
||||
final result, as produced by the @method[path-dialog% run] method. It
|
||||
receives the result that is about to be returned (which can be a list
|
||||
in a multi-selection dialog), and can return a different value (any
|
||||
|
@ -119,9 +119,9 @@ message.}
|
|||
|
||||
@defmethod[(run) any/c]{
|
||||
|
||||
Shows the dialog and returns the selected result. If a @scheme[guard]
|
||||
Shows the dialog and returns the selected result. If a @racket[guard]
|
||||
procedure is not supplied when the dialog is created, then the result
|
||||
is either a path or a list of paths (and the latter only when
|
||||
@scheme[_multi?] is true when the dialog is created). If a
|
||||
@scheme[_guard] procedure is supplied, its result determines the result
|
||||
@racket[_multi?] is true when the dialog is created). If a
|
||||
@racket[_guard] procedure is supplied, its result determines the result
|
||||
of this method.}}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@title{Plot}
|
||||
|
||||
@defmodule[mrlib/plot]{The @schememodname[mrlib/plot] library provides
|
||||
@defmodule[mrlib/plot]{The @racketmodname[mrlib/plot] library provides
|
||||
a simple tool for plotting data values to a device context.}
|
||||
|
||||
@defstruct[data-set ([points (listof (is-a?/c point%))]
|
||||
|
@ -14,9 +14,9 @@ a simple tool for plotting data values to a device context.}
|
|||
[min-y real?]
|
||||
[max-y real?])]{
|
||||
|
||||
The @scheme[points] field contains the data values to plot, and
|
||||
@scheme[connected?] indicates whether the points are connected by a
|
||||
line. The @scheme[pen] field provides a pen for plotting
|
||||
The @racket[points] field contains the data values to plot, and
|
||||
@racket[connected?] indicates whether the points are connected by a
|
||||
line. The @racket[pen] field provides a pen for plotting
|
||||
points/lines. The remaining fields determine the plotting area within
|
||||
a drawing context.}
|
||||
|
||||
|
@ -30,9 +30,9 @@ a drawing context.}
|
|||
[x-axis-label string?]
|
||||
[y-axis-label string?])]{
|
||||
|
||||
Configures a plot. The @scheme[grid?] field determines whether to draw
|
||||
a grid at axis markings, and the @scheme[x-axis-marking] and
|
||||
@scheme[y-axis-marking] lists supply locations for marks on each
|
||||
Configures a plot. The @racket[grid?] field determines whether to draw
|
||||
a grid at axis markings, and the @racket[x-axis-marking] and
|
||||
@racket[y-axis-marking] lists supply locations for marks on each
|
||||
axis. The other fields are self-explanatory.}
|
||||
|
||||
@defproc[(plot [dc (is-a?/c dc<%>)]
|
||||
|
@ -40,6 +40,6 @@ axis. The other fields are self-explanatory.}
|
|||
[setup plot-setup?])
|
||||
void?]{
|
||||
|
||||
Draws the @scheme[data-set]s in @scheme[data] into the given
|
||||
@scheme[dc]. Uses drawing-context coordinates in @scheme[data-set]s
|
||||
Draws the @racket[data-set]s in @racket[data] into the given
|
||||
@racket[dc]. Uses drawing-context coordinates in @racket[data-set]s
|
||||
that will accommodate all of the data sets.}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
@defclass[switchable-button% canvas% ()]{
|
||||
|
||||
A @scheme[switchable-button%] control displays
|
||||
A @racket[switchable-button%] control displays
|
||||
and icon and a string label. It toggles between
|
||||
display of just the icon and a display with the
|
||||
label and the icon side-by-side.
|
||||
|
@ -17,15 +17,15 @@
|
|||
[bitmap (is-a?/c bitmap%)]
|
||||
[alternate-bitmap (is-a?/c bitmap%) bitmap]
|
||||
[vertical-tight? boolean? #f])]{
|
||||
The @scheme[callback] is called when the button
|
||||
is pressed. The @scheme[string] and @scheme[bitmap] are
|
||||
The @racket[callback] is called when the button
|
||||
is pressed. The @racket[string] and @racket[bitmap] are
|
||||
used as discussed above.
|
||||
|
||||
If @scheme[alternate-bitmap] is supplied, then it is used
|
||||
If @racket[alternate-bitmap] is supplied, then it is used
|
||||
when the button is switched to the view that just shows the bitmap.
|
||||
If it is not supplied, both modes show the same bitmap.
|
||||
|
||||
If the @scheme[vertical-tight?] argument is @scheme[#t], then the button takes up
|
||||
If the @racket[vertical-tight?] argument is @racket[#t], then the button takes up
|
||||
as little as possible vertical space.
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
DrRacket uses with its @tt{control-\} (or @tt{command-\}) strings to
|
||||
their corresponding unicode characters. For example, it contains
|
||||
this mapping:
|
||||
@schemeblock[
|
||||
@racketblock[
|
||||
("alpha" "α")
|
||||
]
|
||||
as well as many more.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@title[#:tag "activex" #:style 'toc]{ActiveX and DHTML}
|
||||
|
||||
A MysterX application consists of one or more browsers, which are
|
||||
instances of the class @scheme[mx-browser%].
|
||||
instances of the class @racket[mx-browser%].
|
||||
|
||||
@local-table-of-contents[]
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
(listof (any-of/c 'iconize 'maximize 'no-system-menu
|
||||
'no-thick-border 'scrollbars))])]{
|
||||
|
||||
Creates an instance of a MysterX browser. The @scheme[label]
|
||||
Creates an instance of a MysterX browser. The @racket[label]
|
||||
argument is a string for the document caption, with default . The
|
||||
@scheme[width], @scheme[height], @scheme[x], and @scheme[y] give the
|
||||
@racket[width], @racket[height], @racket[x], and @racket[y] give the
|
||||
size and placement of the browser window on the desktop, with
|
||||
defaults provided by Windows. When @scheme[style-options] includes
|
||||
@scheme['scrollbars], the vertical scrollbar is disabled if
|
||||
defaults provided by Windows. When @racket[style-options] includes
|
||||
@racket['scrollbars], the vertical scrollbar is disabled if
|
||||
scrolling is unnecessary, and the horizontal scrollbar disappears if
|
||||
scrolling is unnecessary.
|
||||
|
||||
|
@ -39,12 +39,12 @@
|
|||
|
||||
@defmethod[(show [show? any/c]) void?]{
|
||||
|
||||
If @scheme[show?] is @scheme[#f], the browser window is hidden.
|
||||
If @racket[show?] is @racket[#f], the browser window is hidden.
|
||||
Otherwise, the window is shown.}
|
||||
|
||||
@defmethod[(navigate [url string?]) string?]{
|
||||
|
||||
Navigates the browser to the URL given by @scheme[url].
|
||||
Navigates the browser to the URL given by @racket[url].
|
||||
Any DHTML changes to the page associated with the URL
|
||||
are not shown. Returns a string that is the actual URL
|
||||
navigated to.}
|
||||
|
@ -52,13 +52,13 @@
|
|||
@defmethod[(navigate/status [url string?])
|
||||
(list/c string? (or/c false/c integer? (one-of/c 'no-status)))]{
|
||||
|
||||
Navigates the browser to the URL given by @scheme[url].
|
||||
Navigates the browser to the URL given by @racket[url].
|
||||
Any DHTML changes to the page associated with the URL
|
||||
are not shown. Returns a list, whose first element string that
|
||||
is the actual URL navigated to, and whose second element is
|
||||
a status code, one of: @scheme[#f], indicating no status could be
|
||||
obtained; a number, such as @scheme[200] or @scheme[404], indicating the
|
||||
http status; or @scheme['no-status], indicating that @scheme[url] does not
|
||||
a status code, one of: @racket[#f], indicating no status could be
|
||||
obtained; a number, such as @racket[200] or @racket[404], indicating the
|
||||
http status; or @racket['no-status], indicating that @racket[url] does not
|
||||
denote a URL with the ``http'' scheme.}
|
||||
|
||||
@defmethod[(go-back) string?]{
|
||||
|
@ -77,8 +77,8 @@
|
|||
|
||||
@defmethod[(refresh) boolean?]{
|
||||
|
||||
Refreshes the document in the browser. Returns @scheme[#t]
|
||||
if the refresh is successful, @scheme[#f] otherwise.}
|
||||
Refreshes the document in the browser. Returns @racket[#t]
|
||||
if the refresh is successful, @racket[#f] otherwise.}
|
||||
|
||||
@defmethod[(iconize) void?]{
|
||||
|
||||
|
@ -96,8 +96,8 @@
|
|||
[f ((is-a?/c mx-event<%>) . -> . any)])
|
||||
void?]{
|
||||
|
||||
Registers an event handler for the HTML element @scheme[elem].
|
||||
The result of @scheme[f] is discarded.}
|
||||
Registers an event handler for the HTML element @racket[elem].
|
||||
The result of @racket[f] is discarded.}
|
||||
|
||||
@defmethod[(unregister-event-handler [elem (is-a?/c mx-element%)]) void?]{
|
||||
|
||||
|
@ -121,7 +121,7 @@
|
|||
@defproc[(block-while-browsers) void?]{
|
||||
|
||||
Blocks until all browser windows have been closed or hidden, using
|
||||
the show method of @scheme[mx-browser%]. This is useful when a
|
||||
the show method of @racket[mx-browser%]. This is useful when a
|
||||
MysterX program file is run as a script, to prevent @exec{mzscheme}
|
||||
or @exec{mred} from closing prematurely.}
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
(listof string?)]{
|
||||
|
||||
Returns a list of strings naming the events supported by
|
||||
@scheme[obj/type].
|
||||
@racket[obj/type].
|
||||
|
||||
If calling this procedure results in an error indicating that the
|
||||
COM object's coclass is ambiguous, try using either
|
||||
@scheme[set-coclass!] or @scheme[set-coclass-from-progid!], then
|
||||
retry @scheme[com-events].}
|
||||
@racket[set-coclass!] or @racket[set-coclass-from-progid!], then
|
||||
retry @racket[com-events].}
|
||||
|
||||
|
||||
@defproc[(com-event-type [obj/type (or/c com-object? com-type?)]
|
||||
|
@ -27,11 +27,11 @@
|
|||
(listof string?)]{
|
||||
|
||||
Returns the type of an event handler for the
|
||||
event @scheme[ev] generated by the particular
|
||||
COM object/type @scheme[obj/type]. The return type of
|
||||
event @racket[ev] generated by the particular
|
||||
COM object/type @racket[obj/type]. The return type of
|
||||
all COM event handlers is void.
|
||||
|
||||
See also @scheme[com-events] for dealing with a COM
|
||||
See also @racket[com-events] for dealing with a COM
|
||||
object that has an ambiguous class.}
|
||||
|
||||
@defproc[(com-register-event-handler
|
||||
|
@ -40,17 +40,17 @@
|
|||
[f (any/c . -> . any)])
|
||||
void?]{
|
||||
|
||||
Registers @scheme[f] as event handler for the event @scheme[ev] when
|
||||
generated by @scheme[obj]. The type of argument supplied to
|
||||
@scheme[f] depends on the event; the result of @scheme[f] is always
|
||||
Registers @racket[f] as event handler for the event @racket[ev] when
|
||||
generated by @racket[obj]. The type of argument supplied to
|
||||
@racket[f] depends on the event; the result of @racket[f] is always
|
||||
discarded.
|
||||
|
||||
See also @scheme[com-events] for dealing with a COM
|
||||
See also @racket[com-events] for dealing with a COM
|
||||
object that has an ambiguous class.}
|
||||
|
||||
@defproc[(com-unregister-event-handler [obj com-object?]
|
||||
[ev string?])
|
||||
void?]{
|
||||
|
||||
Unregisters any event handler for the event @scheme[ev] that is
|
||||
generated by the COM object @scheme[obj].}
|
||||
Unregisters any event handler for the event @racket[ev] that is
|
||||
generated by the COM object @racket[obj].}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
@title[#:tag "com-types"]{COM Types}
|
||||
|
||||
In the result of a function like @scheme[com-method-type], a type
|
||||
@indexed-scheme['mx-any] standards for a character, real number,
|
||||
string, boolean, COM currency (as in @scheme[com-currency?]), COM date
|
||||
(as in @scheme[com-date?]), COM scode value (as in
|
||||
@scheme[com-scode?]), COM IUnknown value (as in
|
||||
@scheme[com-iunknown?], or COM object (as in @scheme[com-object?]).}
|
||||
In the result of a function like @racket[com-method-type], a type
|
||||
@indexed-racket['mx-any] standards for a character, real number,
|
||||
string, boolean, COM currency (as in @racket[com-currency?]), COM date
|
||||
(as in @racket[com-date?]), COM scode value (as in
|
||||
@racket[com-scode?]), COM IUnknown value (as in
|
||||
@racket[com-iunknown?], or COM object (as in @racket[com-object?]).}
|
||||
|
||||
@defproc[(com-object-type [obj com-object?]) com-type?]{
|
||||
|
||||
|
@ -16,43 +16,43 @@ string, boolean, COM currency (as in @scheme[com-currency?]), COM date
|
|||
|
||||
@defproc[(com-is-a? [obj com-object?] [type com-type?]) boolean?]{
|
||||
|
||||
Return @scheme[#t] if @scheme[obj] is of the
|
||||
type @scheme[type].}
|
||||
Return @racket[#t] if @racket[obj] is of the
|
||||
type @racket[type].}
|
||||
|
||||
@defproc[(com-currency? [v any/c]) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if @scheme[v] is a COM currency value,
|
||||
@scheme[#f] otherwise.}
|
||||
Returns @racket[#t] if @racket[v] is a COM currency value,
|
||||
@racket[#f] otherwise.}
|
||||
|
||||
@defproc[(com-currency->number [curr com-currency?]) real?]{
|
||||
|
||||
Returns a number for @scheme[curr].}
|
||||
Returns a number for @racket[curr].}
|
||||
|
||||
@defproc[(number->com-currency [n real?]) com-currency?]{
|
||||
|
||||
Converts a number to a COM currency value. A currency value is
|
||||
repsented with a 64-bit two's-complement integer, though @scheme[n]
|
||||
may contain decimal digits. If @scheme[n] is too large, an
|
||||
repsented with a 64-bit two's-complement integer, though @racket[n]
|
||||
may contain decimal digits. If @racket[n] is too large, an
|
||||
exception is raised.}
|
||||
|
||||
@defproc[(com-date? [v any/c]) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if @scheme[v] is a COM date value, @scheme[#f]
|
||||
Returns @racket[#t] if @racket[v] is a COM date value, @racket[#f]
|
||||
otherwise.}
|
||||
|
||||
@defproc[(com-date->date [d com-date?]) date?]{
|
||||
|
||||
Converts a COM date to an instance of the @scheme[date] structure
|
||||
type. In the result, the @scheme[dst?] field is always @scheme[#f],
|
||||
and the @scheme[time-zone-offset] field is @scheme[0].}
|
||||
Converts a COM date to an instance of the @racket[date] structure
|
||||
type. In the result, the @racket[dst?] field is always @racket[#f],
|
||||
and the @racket[time-zone-offset] field is @racket[0].}
|
||||
|
||||
@defproc[(date->com-date [d date?]) com-date?]{
|
||||
|
||||
Converts a @scheme[date] instance to a COM date value.}
|
||||
Converts a @racket[date] instance to a COM date value.}
|
||||
|
||||
@defproc[(com-scode? [v any/c]) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if @scheme[v] is a COM scode value, @scheme[#f]
|
||||
Returns @racket[#t] if @racket[v] is a COM scode value, @racket[#f]
|
||||
otherwise.}
|
||||
|
||||
@defproc[(com-scode->number [sc com-scode?]) integer?]{
|
||||
|
@ -67,10 +67,10 @@ string, boolean, COM currency (as in @scheme[com-currency?]), COM date
|
|||
|
||||
@defproc[(com-iunknown? [v any/c]) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if @scheme[v] is a COM IUnknown value,
|
||||
@scheme[#f] otherwise.}
|
||||
Returns @racket[#t] if @racket[v] is a COM IUnknown value,
|
||||
@racket[#f] otherwise.}
|
||||
|
||||
@defthing[com-omit any/c]{
|
||||
|
||||
Used with @scheme[com-invoke] to represent an argument that is not
|
||||
Used with @racket[com-invoke] to represent an argument that is not
|
||||
provided.}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
@title[#:tag "remote"]{Remote COM servers (DCOM)}
|
||||
|
||||
For the MysterX procedures @scheme[cocreate-instance-from-coclass] and
|
||||
@scheme[cocreate-instance-from-progid], the optional @scheme[_where]
|
||||
argument can be @scheme['remote]. In that case, the server instance
|
||||
For the MysterX procedures @racket[cocreate-instance-from-coclass] and
|
||||
@racket[cocreate-instance-from-progid], the optional @racket[_where]
|
||||
argument can be @racket['remote]. In that case, the server instance
|
||||
is run at the location given by the Registry key
|
||||
|
||||
@centerline{@tt{HKEY_CLASSES_ROOT\AppID\@nonterm{CLSID}\RemoteServerName}}
|
||||
|
|
|
@ -37,9 +37,9 @@
|
|||
[size (one-of/c 'pixels 'percent) 'pixels])
|
||||
com-object?]{
|
||||
|
||||
Inserts a COM object with class @scheme[coclass] at the beginning of
|
||||
the document. The optional @scheme[size] argument gives an
|
||||
interpretation for the width and height, where @scheme['percent]
|
||||
Inserts a COM object with class @racket[coclass] at the beginning of
|
||||
the document. The optional @racket[size] argument gives an
|
||||
interpretation for the width and height, where @racket['percent]
|
||||
indicates that the width and height are a fixed percentage of the
|
||||
document window size.}
|
||||
|
||||
|
@ -83,13 +83,13 @@
|
|||
(is-a?/c mx-element%)]{
|
||||
|
||||
Returns an object that encapsulates an HTML element, where
|
||||
@scheme[tag] names an HTML tag, and @scheme[id] names the @scheme["id"]
|
||||
attribute of the HTML element. The @scheme[index] is a nonnegative
|
||||
@racket[tag] names an HTML tag, and @racket[id] names the @racket["id"]
|
||||
attribute of the HTML element. The @racket[index] is a nonnegative
|
||||
integer indicating the zero-based index of the element among all
|
||||
elements with the same @scheme[tag] and @scheme[id]. The ordering
|
||||
elements with the same @racket[tag] and @racket[id]. The ordering
|
||||
of elements is defined by Internet Explorer. The requested element
|
||||
must be within the document's @scheme["body"] tags or the
|
||||
@scheme["body"] element itself.}
|
||||
must be within the document's @racket["body"] tags or the
|
||||
@racket["body"] element itself.}
|
||||
|
||||
@defmethod[(find-element-by-id-or-name
|
||||
[id string?]
|
||||
|
@ -97,19 +97,19 @@
|
|||
(is-a?/c mx-element%)]{
|
||||
|
||||
Returns an object that encapsulates an HTML element, where
|
||||
@scheme[id] names either the @scheme["id"] or @scheme["name"]
|
||||
attribute of the HTML element. The @scheme[index] is a nonnegative
|
||||
@racket[id] names either the @racket["id"] or @racket["name"]
|
||||
attribute of the HTML element. The @racket[index] is a nonnegative
|
||||
integer indicating the zero-based index of the element among all
|
||||
elements with the same @scheme["id"] or @scheme["name"]. The ordering
|
||||
elements with the same @racket["id"] or @racket["name"]. The ordering
|
||||
of elements is defined by Internet Explorer. The requested element
|
||||
must be within the document's @scheme["body"] tags or the
|
||||
@scheme["body"] element itself.}
|
||||
must be within the document's @racket["body"] tags or the
|
||||
@racket["body"] element itself.}
|
||||
|
||||
@defmethod[(elements-with-tag [tag string?])
|
||||
(listof (is-a?/c mx-element%))]{
|
||||
|
||||
Returns a list of elements with the HTML tag given by @scheme[tag].
|
||||
The requested elements must be within the document's @scheme["body"]
|
||||
tags or the @scheme["body"] element itself.}
|
||||
Returns a list of elements with the HTML tag given by @racket[tag].
|
||||
The requested elements must be within the document's @racket["body"]
|
||||
tags or the @racket["body"] element itself.}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
(to-flow spacer)
|
||||
(to-flow (scheme 'option0))
|
||||
(to-flow spacer)
|
||||
(make-flow (list (schemeblock0 contract0))))
|
||||
(make-flow (list (racketblock0 contract0))))
|
||||
(list (to-flow spacer)
|
||||
(to-flow spacer)
|
||||
(to-flow spacer)
|
||||
(to-flow (scheme 'option))
|
||||
(to-flow spacer)
|
||||
(make-flow (list (schemeblock0 contract))))
|
||||
(make-flow (list (racketblock0 contract))))
|
||||
...)
|
||||
...))))
|
||||
|
||||
|
@ -107,30 +107,30 @@
|
|||
@defmethod[(insert-html [html string?])
|
||||
void?]{
|
||||
|
||||
Places the HTML given by the string @scheme[html] before the element.}
|
||||
Places the HTML given by the string @racket[html] before the element.}
|
||||
|
||||
@defmethod[(append-html [html string?])
|
||||
void?]{
|
||||
|
||||
Places the HTML given by the string @scheme[html] after the element.}
|
||||
Places the HTML given by the string @racket[html] after the element.}
|
||||
|
||||
@defmethod[(replace-html [html string?])
|
||||
void?]{
|
||||
|
||||
Replaces the HTML in the element with the string @scheme[html]. You
|
||||
Replaces the HTML in the element with the string @racket[html]. You
|
||||
must use the @method[mx-document<%> find-element] or
|
||||
@method[mx-document<%> find-element-by-id-or-name] methods of
|
||||
@scheme[mx-document<%>] to retrieve the updated element.}
|
||||
@racket[mx-document<%>] to retrieve the updated element.}
|
||||
|
||||
@defmethod[(insert-text [txt string?])
|
||||
void?]{
|
||||
|
||||
Places the text given by the string @scheme[txt] before the HTML element.}
|
||||
Places the text given by the string @racket[txt] before the HTML element.}
|
||||
|
||||
@defmethod[(append-text [txt string?])
|
||||
void?]{
|
||||
|
||||
Places the text given by the string @scheme[txt] after the HTML element.}
|
||||
Places the text given by the string @racket[txt] after the HTML element.}
|
||||
|
||||
@defmethod[(insert-object-from-coclass [coclass string?]
|
||||
[width exact-integer?]
|
||||
|
@ -138,7 +138,7 @@
|
|||
[size (one-of/c 'pixels 'percent) 'pixels])
|
||||
void?]{
|
||||
|
||||
Composes @scheme[coclass->html] with @method[mx-element% insert-html].}
|
||||
Composes @racket[coclass->html] with @method[mx-element% insert-html].}
|
||||
|
||||
@defmethod[(insert-object-from-progid [coclass string?]
|
||||
[width exact-integer?]
|
||||
|
@ -146,7 +146,7 @@
|
|||
[size (one-of/c 'pixels 'percent) 'pixels])
|
||||
void?]{
|
||||
|
||||
Composes @scheme[progid->html] with @method[mx-element% insert-html].}
|
||||
Composes @racket[progid->html] with @method[mx-element% insert-html].}
|
||||
|
||||
@defmethod[(append-object-from-coclass [coclass string?]
|
||||
[width exact-integer?]
|
||||
|
@ -154,7 +154,7 @@
|
|||
[size (one-of/c 'pixels 'percent) 'pixels])
|
||||
void?]{
|
||||
|
||||
Composes @scheme[coclass->html] with @method[mx-element% append-html].}
|
||||
Composes @racket[coclass->html] with @method[mx-element% append-html].}
|
||||
|
||||
@defmethod[(append-object-from-progid [coclass string?]
|
||||
[width exact-integer?]
|
||||
|
@ -162,7 +162,7 @@
|
|||
[size (one-of/c 'pixels 'percent) 'pixels])
|
||||
void?]{
|
||||
|
||||
Composes @scheme[progid->html] with @method[mx-element% append-html].}
|
||||
Composes @racket[progid->html] with @method[mx-element% append-html].}
|
||||
|
||||
@defmethod[(focus)
|
||||
void?]{
|
||||
|
@ -173,7 +173,7 @@
|
|||
@defmethod[(selection)
|
||||
string?]{
|
||||
|
||||
If the element has the @scheme["select"] tag, returns a string
|
||||
If the element has the @racket["select"] tag, returns a string
|
||||
indicating the value of the current selection. Otherwise, an
|
||||
exception s raised. The value of the selection may be different
|
||||
from the string visible in the dropdown list.}
|
||||
|
@ -181,23 +181,23 @@
|
|||
@defmethod[(set-selection! [val string?])
|
||||
void?]{
|
||||
|
||||
If the element has the @scheme["select"] tag, sets the selection to
|
||||
the entry with the value @scheme[val], a string. Otherwise, an
|
||||
If the element has the @racket["select"] tag, sets the selection to
|
||||
the entry with the value @racket[val], a string. Otherwise, an
|
||||
exception is raised. The value of the selection may be different
|
||||
from the string visible in the dropdown list.}
|
||||
|
||||
@defmethod[(attribute [attr string?])
|
||||
(or/c string? real? boolean?)]{
|
||||
|
||||
Retrieves the attribute named by the string @scheme[attr]. The return
|
||||
Retrieves the attribute named by the string @racket[attr]. The return
|
||||
value has a type that depends on the attribute.}
|
||||
|
||||
@defmethod[(set-attribute! [attr string?]
|
||||
[val (or/c string? real? boolean?)])
|
||||
void?]{
|
||||
|
||||
Sets the attribute named by the string @scheme[attr]. The new
|
||||
value @scheme[val] has a type that depends on the attribute.}
|
||||
Sets the attribute named by the string @racket[attr]. The new
|
||||
value @racket[val] has a type that depends on the attribute.}
|
||||
|
||||
@defmethod[(click)
|
||||
void?]{
|
||||
|
@ -246,7 +246,7 @@
|
|||
|
||||
Gets or sets the element's CSS @tt{background-color}, @tt{background-image},
|
||||
@tt{background-repeat}, @tt{background-attachment}, and @tt{background-position}
|
||||
using the string @scheme[b].}
|
||||
using the string @racket[b].}
|
||||
|
||||
|
||||
@defmethods[background-image
|
||||
|
|
|
@ -22,32 +22,32 @@
|
|||
[(dblclick?) boolean?]
|
||||
[(error?) boolean?])]{
|
||||
|
||||
Exactly one of these methods returns @scheme[#t] to indicate the type
|
||||
of a given event, and the others return @scheme[#f] for the event.}
|
||||
Exactly one of these methods returns @racket[#t] to indicate the type
|
||||
of a given event, and the others return @racket[#f] for the event.}
|
||||
|
||||
@defmethod[(alt-key) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if the Alt key was pressed when the
|
||||
event was generated, @scheme[#f] otherwise.}
|
||||
Returns @racket[#t] if the Alt key was pressed when the
|
||||
event was generated, @racket[#f] otherwise.}
|
||||
|
||||
@defmethod[(ctrl-key) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if the Ctrl key was pressed when the
|
||||
event was generated, @scheme[#f] otherwise. }
|
||||
Returns @racket[#t] if the Ctrl key was pressed when the
|
||||
event was generated, @racket[#f] otherwise. }
|
||||
|
||||
@defmethod[(from-tag) string?]{
|
||||
|
||||
Returns a string indicating the tag of the HTML element where the
|
||||
mouse is being moved from. The return value is valid only for
|
||||
events for which @method[mx-event<%> mouseover?] or @method[mx-event<%>
|
||||
mouseout?] produces @scheme[#t].}
|
||||
mouseout?] produces @racket[#t].}
|
||||
|
||||
@defmethod[(from-id) string?]{
|
||||
|
||||
Returns a string indicating the identifier of the HTML element where
|
||||
the mouse is being moved from. Return value is valid only for
|
||||
events for which @method[mx-event<%> mouseover?] or @method[mx-event<%>
|
||||
mouseout?] produces @scheme[#t].}
|
||||
mouseout?] produces @racket[#t].}
|
||||
|
||||
@defmethod[(id) string?]{
|
||||
|
||||
|
@ -59,12 +59,12 @@
|
|||
Returns a number indicating the keycode for the key that generated
|
||||
the event. Return value is valid only for events for which
|
||||
@method[mx-event<%> keypress?], @method[mx-event<%> keydown?], or
|
||||
@method[mx-event<%> keyup?] produces @scheme[#t].}
|
||||
@method[mx-event<%> keyup?] produces @racket[#t].}
|
||||
|
||||
@defmethod[(shift-key) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if the Shift key was pressed when the
|
||||
event was generated, @scheme[#f] otherwise.}
|
||||
Returns @racket[#t] if the Shift key was pressed when the
|
||||
event was generated, @racket[#f] otherwise.}
|
||||
|
||||
@defmethod[(tag) string?]{
|
||||
|
||||
|
@ -76,14 +76,14 @@
|
|||
Returns a string indicating the tag of the target HTML element where
|
||||
the mouse is being moved to. Return value is valid only for events
|
||||
for which @method[mx-event<%> mouseover?] or @method[mx-event<%>
|
||||
mouseout?] produces @scheme[#t].}
|
||||
mouseout?] produces @racket[#t].}
|
||||
|
||||
@defmethod[(to-id) boolean?]{
|
||||
|
||||
Returns a string indicating the identifier of the target HTML
|
||||
element where the mouse is being moved from. Return value is valid
|
||||
only for events for which @method[mx-event<%> mouseover?] or
|
||||
@method[mx-event<%> mouseout?] produces @scheme[#t].}
|
||||
@method[mx-event<%> mouseout?] produces @racket[#t].}
|
||||
|
||||
@defmethod[(x) exact-integer?]{
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user