Updated teachpack documentation for the new vocabulary.

This commit is contained in:
Guillaume Marceau 2011-07-02 19:09:19 -04:00
parent ca2de63f9e
commit eedab060ba
29 changed files with 102 additions and 107 deletions

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require "common.rkt" (for-label lang/htdp-beginner)) @(require "common.rkt" (for-label lang/htdp-beginner))
@title{@italic{How to Design Programs} Languages} @title[#:tag "top"]{@italic{How to Design Programs} Languages}
The languages documented in this manual are provided by DrRacket to be The languages documented in this manual are provided by DrRacket to be
used with the @italic{@link["http://www.htdp.org/"]{How to Design used with the @italic{@link["http://www.htdp.org/"]{How to Design

View File

@ -40,14 +40,14 @@
character] character]
] ]
@prim-nonterms[("intermediate-w-lambda") define define-struct] @prim-nonterms[("intm-w-lambda") define define-struct]
@prim-variables[("intermedia-w-lambda") empty true false] @prim-variables[("intm-w-lambda") empty true false]
@; ---------------------------------------------------------------------- @; ----------------------------------------------------------------------
@section[#:tag "intermediate-lambda-syntax"]{Syntax for Intermediate with Lambda} @section[#:tag "intm-w-lambda-syntax"]{Syntax for Intermediate with Lambda}
@defform[(lambda (variable variable ...) expression)]{ @defform[(lambda (variable variable ...) expression)]{
@ -90,7 +90,7 @@ the function.}
@; ---------------------------------------------------------------------- @; ----------------------------------------------------------------------
@section[#:tag "intermediate-lambda-common-syntax"]{Common Syntax} @section[#:tag "intm-w-lambda-common-syntax"]{Common Syntax}
@(define-forms/normal define) @(define-forms/normal define)
@ -111,7 +111,7 @@ the function.}
check-range check-range
require) require)
@section[#:tag "intermediate-lambda-pre-defined"]{Pre-defined Functions} @section[#:tag "intm-w-lambda-pre-defined"]{Pre-defined Functions}
@prim-op-defns['(lib "htdp-intermediate-lambda.ss" "lang") #'here '()] @prim-op-defns['(lib "htdp-intermediate-lambda.ss" "lang") #'here '()]

View File

@ -3,12 +3,12 @@
(for-label racket/base) (for-label racket/base)
) )
@title[#:style '(toc)]{Error Message Composition Guidelines for *SL} @title[#:tag "error-guidelines"]{Error Message Composition Guidelines for *SL}
These guidelines distill our current thoughts on writing good error messages These guidelines distill our current thoughts on writing good error messages for
for novices, as informed by our research. Please apply these to all code you novices, as informed by our research. Please apply these to all code you write
write, including libraries and Teachpacks. Inform Kathi, Shriram, and that's intended for beginners, including libraries and Teachpacks. It will
Guillaume of any cases that appear awkward under these guidelines. ensure your error messages harmonizes with those of the teaching languages.
@section{General Guidelines} @section{General Guidelines}
@ -21,32 +21,27 @@ if only because they have no reason to doubt the authoritative voice of the
tool.} tool.}
@item{Be concise and clear. Students give up reading error messages if the text is @item{Be concise and clear. Students give up reading error messages if the text is
too long, uses obscure words, or employs difficult grammar. too long, uses obscure words, or employs difficult grammar.}]
}]
@section{Message Structure and Form} @section{Message Structure and Form}
@itemize[ @itemize[
@item{Start the message with the name of the construct whose constraint is being @item{Start the message with the name of the construct whose constraint is being
violated, followed by a colon. violated, followed by a colon.}
}
@item{State the constraint that was violated (``expected a...''), then contrast with what @item{State the constraint that was violated (``expected a...''), then contrast with what
was found. For example, @emph{``this function expects two arguments, but found only was found. For example, @emph{``this function expects two arguments, but found only
one.''} If needed, explain how what was found failed to satisfy the constraint. one.''} If needed, explain how what was found failed to satisfy the constraint.
Write somewhat anthropomorphically with an objective voice that is neither Write somewhat anthropomorphically with an objective voice that is neither
friendly nor antagonistic. friendly nor antagonistic.}
}
@item{If an expression contains multiple errors, report the leftmost error first: @item{If an expression contains multiple errors, report the leftmost error first:
e.g., the error in (define 1 2 3) is @emph{``expected the variable name, but found a e.g., the error in (define 1 2 3) is @emph{``expected the variable name, but found a
number''}, not @emph{``expected 2 parts after define, but found 3''}. Before raising an number''}, not @emph{``expected 2 parts after define, but found 3''}. Before raising an
error about a sub-part, call @racket[local-syntax-expand] on all sub-expressions to error about a sub-part, call @racket[local-syntax-expand] on all sub-expressions to
the left to trigger their errors. the left to trigger their errors.}
}
@item{State the number of parts instead of saying ``found too many parts.'' Write the @item{State the number of parts instead of saying ``found too many parts.'' Write the
code necessary to make plurals agree. code necessary to make plurals agree.}]
}]
@section{Vocabulary} @section{Vocabulary}
@ -59,19 +54,16 @@ top level, structure name, type name, field name, binding.}}
@itemize[ @itemize[
@item{Use binding for the square-braced pair in a let and other similar binding @item{Use binding for the square-braced pair in a let and other similar binding
forms. forms.}
}
@item{Use argument for actual arguments and variable for formal arguments and in @item{Use argument for actual arguments and variable for formal arguments and in
the body of the definition. the body of the definition.}
}
@item{Use part when speaking about an s-expression that is not an expression, @item{Use part when speaking about an s-expression that is not an expression,
either because it is malformed, because it occurs in a non-expression position, either because it is malformed, because it occurs in a non-expression position,
or because it is a valid piece of syntax for a macro invocation. A well-formed or because it is a valid piece of syntax for a macro invocation. A well-formed
and well-placed call to a function, primitive, or macro is not a part, it is and well-placed call to a function, primitive, or macro is not a part, it is
an expression. an expression. }]
}]
@subsection{Prohibited Words} @subsection{Prohibited Words}
@ -107,19 +99,16 @@ variable but found a cond''}]
@subsection{General Vocabulary Guidelines} @subsection{General Vocabulary Guidelines}
@itemize[ @itemize[
@item{Avoid modifiers that are not necessary to disambiguate. Write variable @item{Avoid modifiers that are not necessary to disambiguate. Write variable
instead of ``local variable'', ``defined variable'', or ``input variable''. Write instead of ``local variable'', ``defined variable'', or ``input variable''. Write
clause instead of ``question-answer clause''. If they appear necessary for clause instead of ``question-answer clause''. If they appear necessary for
disambiguation, try to find some other way to achieve this (and drop the disambiguation, try to find some other way to achieve this (and drop the
modifier). modifier).}
}
@item{When introducing macros with sub-parts, reuse existing vocabulary words, such @item{When introducing macros with sub-parts, reuse existing vocabulary words, such
as clause or binding (if appropriate), or just part, instead of defining as clause or binding (if appropriate), or just part, instead of defining
new terms. new terms.}
}
@item{Use name only when describing the syntax of a definition form. For example, @item{Use name only when describing the syntax of a definition form. For example,
the define form in BSL should say ``expected at least one variable after the the define form in BSL should say ``expected at least one variable after the
@ -130,18 +119,27 @@ distinction when they learn about lambdathe first is the lambda implicit in the
definition, the second is the variable introduced by the definition that can definition, the second is the variable introduced by the definition that can
appear as the first argument to set!, the third is the particular sequence of appear as the first argument to set!, the third is the particular sequence of
lettersbut BSL should avoid this complexity, and ASLs error messages should lettersbut BSL should avoid this complexity, and ASLs error messages should
maintain consistency with BSL.] maintain consistency with BSL.]}
}
@item{Avoid introducing technical vocabulary, even if well-known to a mathematician. @item{Avoid introducing technical vocabulary, even if well-known to a mathematician.}]
}]
@section{Punctuation} @section{Punctuation}
@itemize[
@item{Do not use any punctuation beyond those of the normal English language. Do not
write <> around type names, and do not write ` around keywords.}]
@section{Runtime Behavior}
@itemize[ @itemize[
@item{Do not use any punctuation beyond those of the normal English language. Do not @item{When specifying a function's behavior, say ``the function takes ... and returns ...''}
write <> around type names, and do not write ` around keywords.
}] @item{When describing a contract violation, say ``the function expects ... but received ...''}
@item{As much as possible, identify expressions to the value they evaluate to,
e.g. ``the value of @tt{(f x)} is 5''. If it is necessary to explicate
evaluation times, the context discusses mutable state or order of evaluation,
then say that the expressions ``evaluate to'' a value. Function calls are a
special case of expression. Prefer ``the function call returns'', instead of
``it evaluates to'', except when trying to draw attention to you evaluation of
the arguments.}]

View File

@ -7,8 +7,8 @@
@defmodule[#:require-form beginner-require htdp/arrow-gui] @defmodule[#:require-form beginner-require htdp/arrow-gui]
The teachpack provides operations for creating and manipulating an arrow The teachpack provides functions for creating and manipulating an arrow
GUI. We recommend using the @seclink["world"]{world teachpack} instead. GUI. We recommend using @racketmodname[2htdp/universe] instead.
@deftech{modelT} @racket[(-> button% event% true)] @deftech{modelT} @racket[(-> button% event% true)]

View File

@ -8,9 +8,7 @@
@;declare-exporting[teachpack/htdp/arrow] @;declare-exporting[teachpack/htdp/arrow]
@defmodule[#:require-form beginner-require htdp/arrow] @defmodule[#:require-form beginner-require htdp/arrow]
The teachpack implements a controller for moving shapes across a canvass. A The teachpack implements a controller for moving shapes across a canvass.
shape is a class of data for which @racket[move] and @racket[draw]
operations can be drawn.
@defproc[(control-left-right @defproc[(control-left-right
[shape Shape] [shape Shape]

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/convert)) (for-label racket teachpack/htdp/convert))
@teachpack["convert"]{Converting Temperatures} @teachpack["convert"]{Converting Temperatures}

View File

@ -1,16 +1,16 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label (except-in scheme/base file-size) (for-label (except-in racket/base file-size)
teachpack/htdp/dir teachpack/htdp/dir
scheme/contract)) racket/contract))
@teachpack["dir"]{Working with Files and Directories} @teachpack["dir"]{Working with Files and Directories}
@;declare-exporting[teachpack/htdp/dir] @;declare-exporting[teachpack/htdp/dir]
@defmodule[#:require-form beginner-require htdp/dir] @defmodule[#:require-form beginner-require htdp/dir]
The teachpack provides structures and operations for working with files and The teachpack provides structures and functions for working with files and
directories: directories:
@defstruct[dir ([name symbol?][dirs (listof dir?)][files (listof file?)])]{} @defstruct[dir ([name symbol?][dirs (listof dir?)][files (listof file?)])]{}

View File

@ -1,22 +1,22 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/docs)) (for-label racket teachpack/htdp/docs))
@teachpack["docs"]{Manipulating Simple HTML Documents} @teachpack["docs"]{Manipulating Simple HTML Documents}
@;declare-exporting[teachpack/htdp/docs] @;declare-exporting[teachpack/htdp/docs]
@defmodule[#:require-form beginner-require htdp/docs] @defmodule[#:require-form beginner-require htdp/docs]
The teachpack provides three operations for creating simple ``HTML'' documents: The teachpack provides three functions for creating simple ``HTML'' documents:
@deftech{Annotation} An @tech{Annotation} is a symbol that starts with ``<'' @deftech{Annotation} An @tech{Annotation} is a symbol that starts with ``<''
and ends in ``>''. An end annotation is one that starts with ``</''. and ends in ``>''. An end annotation is one that starts with ``</''.
@defproc[(atom? [x any/c]) boolean?]{Determines whether or not a Scheme value @defproc[(atom? [x any/c]) boolean?]{Determines whether or not a value
is a number, a symbol, or a string.} is a number, a symbol, or a string.}
@defproc[(annotation? [x any/c]) boolean?]{Determines whether or not a Scheme @defproc[(annotation? [x any/c]) boolean?]{Determines whether or not a
symbol is a document annotation.} symbol is a document annotation.}
@defproc[(end-annotation [x (unsyntax @tech{Annotation})]) (unsyntax @tech{Annotation})]{Consumes an annotation @defproc[(end-annotation [x (unsyntax @tech{Annotation})]) (unsyntax @tech{Annotation})]{Consumes an annotation

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/draw)) (for-label racket teachpack/htdp/draw))
@teachpack["draw"]{Simple Drawing} @teachpack["draw"]{Simple Drawing}
@ -58,8 +58,8 @@ Draws @racket[s] at @racket[p].}
@defproc[(sleep-for-a-while [s number?]) true]{ @defproc[(sleep-for-a-while [s number?]) true]{
Suspends evaluation for @racket[s] seconds.} Suspends evaluation for @racket[s] seconds.}
The teachpack also provides @racket[clear-] operations for each The teachpack also provides @racket[clear-] functions for each
@racket[draw-] operation: @racket[draw-] function:
@defproc[(clear-circle [p posn?] [r number?] [c (unsyntax @tech{DrawColor})]) @defproc[(clear-circle [p posn?] [r number?] [c (unsyntax @tech{DrawColor})])
true]{ true]{

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/elevator)) (for-label racket teachpack/htdp/elevator))
@teachpack["elevator"]{Controlling an Elevator} @teachpack["elevator"]{Controlling an Elevator}

View File

@ -1,14 +1,14 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/graphing)) (for-label racket teachpack/htdp/graphing))
@teachpack["graphing"]{Graphing Functions} @teachpack["graphing"]{Graphing Functions}
@;declare-exporting[teachpack/htdp/graphing] @;declare-exporting[teachpack/htdp/graphing]
@defmodule[#:require-form beginner-require htdp/graphing #:use-sources (htdp/draw)] @defmodule[#:require-form beginner-require htdp/graphing #:use-sources (htdp/draw)]
The teachpack provides two operations for graphing functions in the regular The teachpack provides two functions for graphing functions in the regular
(upper right) quadrant of the Cartesian plane (between 0 and 10 in both (upper right) quadrant of the Cartesian plane (between 0 and 10 in both
directions): directions):

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/guess-gui)) (for-label racket teachpack/htdp/guess-gui))
@teachpack["guess-gui"]{Guess GUI} @teachpack["guess-gui"]{Guess GUI}

View File

@ -1,17 +1,17 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/guess)) (for-label racket teachpack/htdp/guess))
@teachpack["guess"]{Guessing Numbers} @teachpack["guess"]{Guessing Numbers}
@;declare-exporting[teachpack/htdp/guess] @;declare-exporting[teachpack/htdp/guess]
@defmodule[#:require-form beginner-require htdp/guess] @defmodule[#:require-form beginner-require htdp/guess]
The teachpack provides operations to play a guess-the-number game. Each The teachpack provides functions to play a guess-the-number game. Each
operation display a GUI in which a player can choose specific values for function display a GUI in which a player can choose specific values for
some number of digits and then check the guess. The more advanced some number of digits and then check the guess. The more advanced
operations ask students to implement more of the game. functions ask students to implement more of the game.
@defproc[(guess-with-gui [check-guess (-> number? number? symbol?)]) true]{ @defproc[(guess-with-gui [check-guess (-> number? number? symbol?)]) true]{
The @racket[check-guess] function consumes two numbers: @racket[guess], which The @racket[check-guess] function consumes two numbers: @racket[guess], which

View File

@ -1,16 +1,15 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/gui)) (for-label racket teachpack/htdp/gui))
@teachpack["gui"]{Simple Graphical User Interfaces} @teachpack["gui"]{Simple Graphical User Interfaces}
@;declare-exporting[teachpack/htdp/gui] @;declare-exporting[teachpack/htdp/gui]
@defmodule[#:require-form beginner-require htdp/gui] @defmodule[#:require-form beginner-require htdp/gui]
The teachpack provides operations for creating and manipulating graphical The teachpack provides functions for creating and manipulating graphical
user interfaces. We recommend using the @seclink["world"]{world teachpack} user interfaces. We recommend using @racketmodname[2htdp/universe] instead.
instead.
@deftech{Window} A @tech{Window} is a data representation of a visible @deftech{Window} A @tech{Window} is a data representation of a visible
window on your computer screen. window on your computer screen.

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/hangman)) (for-label racket teachpack/htdp/hangman))
@teachpack["hangman-play"]{Playing Hangman} @teachpack["hangman-play"]{Playing Hangman}

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/hangman)) (for-label racket teachpack/htdp/hangman))
@teachpack["hangman"]{Hangman} @teachpack["hangman"]{Hangman}

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual @(require scribble/manual
(for-label scheme)) (for-label racket))
@title[#:style '(toc) #:tag "htdp"]{HtDP Teachpacks} @title[#:style '(toc) #:tag "htdp"]{HtDP Teachpacks}
@ -32,6 +32,6 @@
@;-- what do those do? -- @;-- what do those do? --
@;include-section["Simplified Scheme Web Servlets"] @;include-section["Simplified Racket Web Servlets"]
@;include-section["Scheme Web Servlets"] @;include-section["Racket Web Servlets"]

View File

@ -1,14 +1,14 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" (for-label scheme teachpack/htdp/image)) @(require scribble/manual "shared.rkt" (for-label racket teachpack/htdp/image))
@teachpack["image"]{Manipulating Images} @teachpack["image"]{Manipulating Images}
@defmodule[#:require-form beginner-require htdp/image] @defmodule[#:require-form beginner-require htdp/image]
The teachpack provides primitives for constructing and manipulating The teachpack provides functions for constructing and manipulating
images. Basic, colored images are created as outlines or solid images. Basic, colored images are created as outlines or solid
shapes. Additional primitives allow for the composition of images. shapes. Additional functions allow for the composition of images.
@;----------------------------------------------------------------------------- @;-----------------------------------------------------------------------------
@section{Images} @section{Images}
@ -47,7 +47,7 @@ A @tech{Color} is a color-symbol (e.g., @racket['blue]) or a color-string
@section[#:tag "creational"]{Creating Basic Shapes} @section[#:tag "creational"]{Creating Basic Shapes}
In DrRacket, you can insert images from your file system. Use PNG images In DrRacket, you can insert images from your file system. Use PNG images
instead whenever possible for insertions. In addition, you can create basic whenever possible. In addition, you can create basic
shapes with the following functions. shapes with the following functions.
@defproc[(rectangle [w (and/c number? (or/c zero? positive?))] [h (and/c number? (or/c zero? positive?))] [m (unsyntax @tech{Mode})] [c (unsyntax @tech{Color})]) image?]{ @defproc[(rectangle [w (and/c number? (or/c zero? positive?))] [h (and/c number? (or/c zero? positive?))] [m (unsyntax @tech{Mode})] [c (unsyntax @tech{Color})]) image?]{
@ -104,9 +104,9 @@ basic properties of images.
@defproc[(image-height [i image?]) integer?]{ @defproc[(image-height [i image?]) integer?]{
Obtain @racket[i]'s height in pixels} Obtain @racket[i]'s height in pixels}
For the composition of images, you must know about @emph{pinholes}. Each For the composition of images, you must know about @emph{pinholes}. Every
image, including primitive ones, come with a pinhole. For images created image come with a pinhole. For images created
with the above primitives, the pinhole is at the center of the shape except with the above functions, the pinhole is at the center of the shape except
for those created from @racket[line] and @racket[text]. for those created from @racket[line] and @racket[text].
The @racket[text] function puts the pinhole at the upper left corner of The @racket[text] function puts the pinhole at the upper left corner of
the image, and @racket[line] puts the pinhole at the beginning of the line the image, and @racket[line] puts the pinhole at the beginning of the line

View File

@ -1,6 +1,6 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" (for-label scheme teachpack/htdp/lkup-gui)) @(require scribble/manual "shared.rkt" (for-label racket teachpack/htdp/lkup-gui))
@teachpack["lkup-gui"]{Lookup GUI} @teachpack["lkup-gui"]{Lookup GUI}

View File

@ -1,6 +1,6 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" (for-label scheme teachpack/htdp/master)) @(require scribble/manual "shared.rkt" (for-label racket teachpack/htdp/master))
@teachpack["master-play"]{Playing MasterMind} @teachpack["master-play"]{Playing MasterMind}

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/master)) (for-label racket teachpack/htdp/master))
@teachpack["master"]{MasterMinding} @teachpack["master"]{MasterMinding}

View File

@ -3,22 +3,22 @@
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/matrix lang/posn)) (for-label scheme teachpack/htdp/matrix lang/posn))
@teachpack["matrix"]{Matrix Operations} @teachpack["matrix"]{Matrix Functions}
@;declare-exporting[teachpack/htdp/matrix] @;declare-exporting[teachpack/htdp/matrix]
@defmodule[#:require-form beginner-require htdp/matrix] @defmodule[#:require-form beginner-require htdp/matrix]
The experimental teachpack supports matrices and matrix operations. A The experimental teachpack supports matrices and matrix functions. A
matrix is just a rectangle of 'objects'. It is displayed as an image, just matrix is just a rectangle of 'objects'. It is displayed as an image, just
like the images from @secref["image"]. Matrices are images and, indeed, like the images from @secref["image"]. Matrices are images and, indeed,
scenes in the sense of the @secref["world"]. scenes in the sense of the @secref["world"].
@emph{No educational materials involving matrices exist.} @emph{No educational materials involving matrices exist.}
The operations access a matrix in the usual (school-mathematics) manner: The functions access a matrix in the usual (school-mathematics) manner:
row first, column second. row first, column second.
The operations aren't tuned for efficiency so don't expect to build The functions aren't tuned for efficiency so don't expect to build
programs that process lots of data. programs that process lots of data.
@deftech{Rectangle} @deftech{Rectangle}

View File

@ -1,8 +1,8 @@
{ (define LIBNAME "Scheme Web Servlets") { (define LIBNAME "Racket Web Servlets")
(include "head.tinc") } (include "head.tinc") }
<p>The teachpack <code>servlet.ss</code> provides structures and <p>The teachpack <code>servlet.ss</code> provides structures and
functions for building Web servlets in Scheme. The data definitions functions for building Web servlets in Racket. The data definitions
represent HTTP requests and Web page responses using these two structures:</p> represent HTTP requests and Web page responses using these two structures:</p>
<pre> <pre>

View File

@ -1,7 +1,7 @@
{ (define LIBNAME "Simplified Scheme Web Servlets") { (define LIBNAME "Simplified Racket Web Servlets")
(include "head.tinc") } (include "head.tinc") }
<p>This teachpack provides a simplified API for PLT Scheme servlets. The <p>This teachpack provides a simplified API for Racket servlets. The
teachpack does not require any understanding of HTML and higher-order teachpack does not require any understanding of HTML and higher-order
functions. It uses structures and lists, and is therefore well-suited for functions. It uses structures and lists, and is therefore well-suited for
use with an HtDP course. use with an HtDP course.
@ -134,7 +134,7 @@ ________________________________________________________________________________
<p>The following example illustrates how the library enables programs to <p>The following example illustrates how the library enables programs to
interact with the consumer. In particular, note the properly recursive interact with the consumer. In particular, note the properly recursive
calls to <code>login</code> in <code>inform-error</code>. Also note how the calls to <code>login</code> in <code>inform-error</code>. Also note how the
primitives <code>make-password</code> and <code>make-number</code> deliver functions <code>make-password</code> and <code>make-number</code> return
strings and numbers, respectively. strings and numbers, respectively.
<pre> <pre>

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
(require scribble/manual) (require scribble/manual)

View File

@ -1,14 +1,14 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual "shared.rkt" @(require scribble/manual "shared.rkt"
(for-label scheme teachpack/htdp/show-queen)) (for-label racket teachpack/htdp/show-queen))
@teachpack["show-queen"]{Queens} @teachpack["show-queen"]{Queens}
@;declare-exporting[teachpack/htdp/show-queen] @;declare-exporting[teachpack/htdp/show-queen]
@defmodule[#:require-form beginner-require htdp/show-queen] @defmodule[#:require-form beginner-require htdp/show-queen]
The teachpack provides the operation @racket[show-queen], which implements The teachpack provides the function @racket[show-queen], which implements
a GUI for exploring the n-queens problem. a GUI for exploring the n-queens problem.
@defproc[(show-queen [board (list-of (list-of boolean?))]) true]{The @defproc[(show-queen [board (list-of (list-of boolean?))]) true]{The

View File

@ -4,7 +4,7 @@
(only-in scribble/core make-nested-flow make-style) (only-in scribble/core make-nested-flow make-style)
"shared.rkt" "shared.rkt"
scribble/struct scribble/struct
(for-label scheme (for-label racket
teachpack/htdp/image teachpack/htdp/image
teachpack/htdp/world)) teachpack/htdp/world))
@ -32,7 +32,7 @@ to Design Programs, Second Edition: Prologue}. As of August 2008, we also
have a series of projects available as a small booklet on have a series of projects available as a small booklet on
@link["http://world.cs.brown.edu/"]{How to Design Worlds}. @link["http://world.cs.brown.edu/"]{How to Design Worlds}.
The purpose of this documentation is to give experienced Schemers a concise The purpose of this documentation is to give experienced Racketers a concise
overview for using the library and for incorporating it elsewhere. The last overview for using the library and for incorporating it elsewhere. The last
section presents @secref["example"] for an extremely simple domain and is section presents @secref["example"] for an extremely simple domain and is
suited for a novice who knows how to design conditional functions for suited for a novice who knows how to design conditional functions for
@ -59,7 +59,7 @@ second one generalizes the first by adding interactive GUI features.
true]{ true]{
creates and shows a canvas of width @racket[w] and height @racket[h] , creates and shows a canvas of width @racket[w] and height @racket[h] ,
starts a clock, making it tick every @racket[r] (usually fractional) starts a clock, making it tick every @racket[r] (usually fractional)
seconds. Every time the clock ticks, drscheme applies @racket[create-image] to seconds. Every time the clock ticks, @racket[run-simulation] applies @racket[create-image] to
the number of ticks passed since this function call. The results of the number of ticks passed since this function call. The results of
these applications are displayed in the canvas. these applications are displayed in the canvas.
} }
@ -122,7 +122,7 @@ The following picture provides an intuitive overview of the workings of
generation of images from the animation, including an animated GIF image. } generation of images from the animation, including an animated GIF image. }
@defproc[(on-tick-event [tock (-> (unsyntax @tech{World}) (unsyntax @tech{World}))]) true]{ @defproc[(on-tick-event [tock (-> (unsyntax @tech{World}) (unsyntax @tech{World}))]) true]{
Tell DrRacket to call @racket[tock] on the current world every time the Tells @racket[big-bang] to call @racket[tock] on the current world every time the
clock ticks. The result of the call becomes the current world.} clock ticks. The result of the call becomes the current world.}
@deftech{KeyEvent} @racket[(or/c char? symbol?)] @deftech{KeyEvent} @racket[(or/c char? symbol?)]
@ -141,7 +141,7 @@ A @tech{KeyEvent} represents key board events, e.g., keys pressed or
compares two @tech{KeyEvent} for equality} compares two @tech{KeyEvent} for equality}
@defproc[(on-key-event [change (-> (unsyntax @tech{World}) key-event? (unsyntax @tech{World}))]) true]{ @defproc[(on-key-event [change (-> (unsyntax @tech{World}) key-event? (unsyntax @tech{World}))]) true]{
Tell DrRacket to call @racket[change] on the current world and a Tells @racket[big-bang] to call @racket[change] on the current world and a
@tech{KeyEvent} for every keystroke the user of the computer makes. The result @tech{KeyEvent} for every keystroke the user of the computer makes. The result
of the call becomes the current world. of the call becomes the current world.
@ -167,17 +167,17 @@ A @tech{KeyEvent} represents key board events, e.g., keys pressed or
computer's user. computer's user.
@defproc[(on-mouse-event [clack (-> (unsyntax @tech{World}) natural-number/c natural-number/c (unsyntax @tech{MouseEvent}) (unsyntax @tech{World}))]) true]{ @defproc[(on-mouse-event [clack (-> (unsyntax @tech{World}) natural-number/c natural-number/c (unsyntax @tech{MouseEvent}) (unsyntax @tech{World}))]) true]{
Tell DrRacket to call @racket[clack] on the current world, the current Tells @racket[big-bang] to call @racket[clack] on the current world, the current
@racket[x] and @racket[y] coordinates of the mouse, and a @racket[x] and @racket[y] coordinates of the mouse, and a
@tech{MouseEvent} for every action of the mouse by the user of the @tech{MouseEvent} for every action of the mouse by the user of the
computer. The result of the call becomes the current world.} computer. The result of the call becomes the current world.}
@defproc[(on-redraw [to-scene (-> (unsyntax @tech{World}) (unsyntax @tech{Scene}))]) true]{ Tell DrRacket to call @racket[to-scene] @defproc[(on-redraw [to-scene (-> (unsyntax @tech{World}) (unsyntax @tech{Scene}))]) true]{ Tells @racket[big-bang] to call @racket[to-scene]
whenever the canvas must be redrawn. The canvas is usually re-drawn after a tick event, a keyboard whenever the canvas must be redrawn. The canvas is usually re-drawn after a tick event, a keyboard
event, or a mouse event has occurred. The generated scene is displayed in the world's canvas.} event, or a mouse event has occurred. The generated scene is displayed in the world's canvas.}
@defproc[(stop-when [last-world? (-> (unsyntax @tech{World}) boolean?)]) true]{ @defproc[(stop-when [last-world? (-> (unsyntax @tech{World}) boolean?)]) true]{
Tell DrRacket to call @racket[last-world?] whenever the canvas is Tells @racket[big-bang] to call @racket[last-world?] whenever the canvas is
drawn. If this call produces @racket[true], the clock is stopped; no more drawn. If this call produces @racket[true], the clock is stopped; no more
tick events, @tech{KeyEvent}s, or @tech{MouseEvent}s are forwarded to tick events, @tech{KeyEvent}s, or @tech{MouseEvent}s are forwarded to
the respective handlers. As a result, the canvas isn't updated either.} the respective handlers. As a result, the canvas isn't updated either.}
@ -259,7 +259,7 @@ Simulating any dynamic behavior via a program demands two different
definition makes it easy for readers to map data to information in the definition makes it easy for readers to map data to information in the
real world and vice versa. For all others aspects of the world, we use real world and vice versa. For all others aspects of the world, we use
global constants, including graphical or visual constants that are used in global constants, including graphical or visual constants that are used in
conjunction with the rendering operations. conjunction with the rendering functions.
Second, we must translate the "world" actions---the arrows in the above Second, we must translate the "world" actions---the arrows in the above
diagram---into interactions with the computer that the world teachpack can diagram---into interactions with the computer that the world teachpack can
@ -485,5 +485,5 @@ which function takes care of tick events, key events, and redraws:
(on-redraw render) (on-redraw render)
)) ))
Now it's time for you to collect the pieces and run them in DrRacket to see Now it's time for you to collect the pieces and run them in @racket[big-bang] to see
whether it all works. whether it all works.

View File

@ -1,3 +1,3 @@
#lang scheme #lang racket
(require htdp/testing) (require htdp/testing)
(provide (all-from-out htdp/testing)) (provide (all-from-out htdp/testing))

View File

@ -3,7 +3,7 @@
@(require scribble/manual @(require scribble/manual
(for-label scheme/base)) (for-label scheme/base))
@title[#:style '(toc)]{@italic{How to Design Programs} Teachpacks} @title[#:style '(toc) #:tag "top"]{@italic{How to Design Programs} Teachpacks}
Teaching languages are small subsets of a full programming language. While Teaching languages are small subsets of a full programming language. While
such restrictions simplify error diagnosis and the construction of tools, such restrictions simplify error diagnosis and the construction of tools,