edits to 'quick', mostly from Eli
svn: r8354
This commit is contained in:
parent
74062d996f
commit
6a2512e0a3
|
@ -42,9 +42,10 @@ start DrScheme.
|
||||||
@; ----------------------------------------------------------------------
|
@; ----------------------------------------------------------------------
|
||||||
@section{Set...}
|
@section{Set...}
|
||||||
|
|
||||||
To draw pictures, we must first load the picture library. Copy the
|
To draw pictures, we must first load the picture library, which is
|
||||||
following into the @defterm{definitions area}, which is the top text
|
part of a slide-creation library. Copy the following into the
|
||||||
area that you see in DrScheme:
|
@defterm{definitions area}, which is the top text area that you see in
|
||||||
|
DrScheme:
|
||||||
|
|
||||||
@schememod[slideshow]
|
@schememod[slideshow]
|
||||||
|
|
||||||
|
@ -59,9 +60,9 @@ Language..."] menu item before clicking @onscreen{Run}.
|
||||||
@section{Go!}
|
@section{Go!}
|
||||||
|
|
||||||
When you type an expression after the @onscreen{>} in the interactions
|
When you type an expression after the @onscreen{>} in the interactions
|
||||||
window and hit Enter, DrScheme evaluates the expression and prints its result. An
|
window and hit Enter, DrScheme evaluates the expression and prints its
|
||||||
expression can be just a value, such as the number @scheme[5] or the
|
result. An expression can be just a value, such as the number
|
||||||
string @scheme["art gallery"]:
|
@scheme[5] or the string @scheme["art gallery"]:
|
||||||
|
|
||||||
@mr-interaction[5 "art gallery"]
|
@mr-interaction[5 "art gallery"]
|
||||||
|
|
||||||
|
@ -97,14 +98,19 @@ The hyphen in the name @scheme[hc-append] is just a part of the
|
||||||
identifier; it's not @schemeidfont{hc} minus
|
identifier; it's not @schemeidfont{hc} minus
|
||||||
@schemeidfont{append}. The function name starts with @scheme[h]
|
@schemeidfont{append}. The function name starts with @scheme[h]
|
||||||
because it combines pictures horizontally, and the next letter is
|
because it combines pictures horizontally, and the next letter is
|
||||||
@scheme[c] because the pictures are centered vertically. If you wonder
|
@scheme[c] because the pictures are centered vertically.
|
||||||
what other functions exist (perhaps a way to stack pictures vertically
|
|
||||||
and left-aligned), move the text caret to the name @scheme[hc-append]
|
If you wonder what other functions exist---perhaps a way to stack
|
||||||
and press the F1 key in DrScheme. A Help Desk window will appear, and
|
pictures vertically and left-aligned?---move the text caret to the
|
||||||
it will give you a link to the documentation for
|
name @scheme[hc-append] and press the F1 key in DrScheme. A browser
|
||||||
|
window will open, and it will give you a link to the documentation for
|
||||||
@scheme[hc-append]. Click the link, and you'll see lots of other
|
@scheme[hc-append]. Click the link, and you'll see lots of other
|
||||||
functions.
|
functions.
|
||||||
|
|
||||||
|
If you're reading this in HTML form, you can also just click on
|
||||||
|
@scheme[hc-append] or any other imported identifier that is used in
|
||||||
|
this tutorial.
|
||||||
|
|
||||||
@; ----------------------------------------------------------------------
|
@; ----------------------------------------------------------------------
|
||||||
@section{Definitions}
|
@section{Definitions}
|
||||||
|
|
||||||
|
@ -135,10 +141,10 @@ area. In practice, though, the definitions area is where your program
|
||||||
lives---it's the file that you save---while the interaction area is
|
lives---it's the file that you save---while the interaction area is
|
||||||
for transient explorations and debugging tasks.
|
for transient explorations and debugging tasks.
|
||||||
|
|
||||||
Let's add a function definition to the program. A function
|
Let's add a function definition to the program. A function definition
|
||||||
definition uses @scheme[define], just like our shape definitions, but with
|
uses @scheme[define], just like our shape definitions, but with an
|
||||||
an open parenthesis before the function name, and names for the
|
open parenthesis before the function name, and names for the function
|
||||||
function arguments before the matching close parenthesis:
|
arguments before the matching close parenthesis:
|
||||||
|
|
||||||
@mr-schemeblock+eval[
|
@mr-schemeblock+eval[
|
||||||
(define (square n)
|
(define (square n)
|
||||||
|
@ -242,9 +248,9 @@ the function, and the expression after the argument names is the
|
||||||
function body. Using the word ``lambda'' instead of ``function'' or
|
function body. Using the word ``lambda'' instead of ``function'' or
|
||||||
``procedure'' is part of Scheme's history and culture.
|
``procedure'' is part of Scheme's history and culture.
|
||||||
|
|
||||||
A function @scheme[define] is really a shorthand for a simple
|
A @scheme[define] form for a function is really a shorthand for a
|
||||||
@scheme[define] using @scheme[lambda] as the value. For example, the
|
simple @scheme[define] using @scheme[lambda] as the value. For
|
||||||
@scheme[series] definition could be written as
|
example, the @scheme[series] definition could be written as
|
||||||
|
|
||||||
@schemeblock[
|
@schemeblock[
|
||||||
(define series
|
(define series
|
||||||
|
@ -407,7 +413,8 @@ Modules are named and distributed in various ways:
|
||||||
@schemeblock[(provide rainbow square)]
|
@schemeblock[(provide rainbow square)]
|
||||||
|
|
||||||
then you can open a new tab or window in DrScheme, type the new
|
then you can open a new tab or window in DrScheme, type the new
|
||||||
program @filepath{use.ss} in the same directory as @filepath{quick.ss}:
|
program @filepath{use.ss} in the same directory as
|
||||||
|
@filepath{quick.ss}:
|
||||||
|
|
||||||
@schememod[
|
@schememod[
|
||||||
scheme
|
scheme
|
||||||
|
@ -415,9 +422,9 @@ Modules are named and distributed in various ways:
|
||||||
(rainbow square)
|
(rainbow square)
|
||||||
]
|
]
|
||||||
|
|
||||||
and when you run this later program, a rainbow list of squares
|
and when you run @filepath{use.ss}, a rainbow list of squares
|
||||||
is the output. Note that @filepath{use.ss} is written using the
|
is the output. Note that @filepath{use.ss} is written using
|
||||||
initial import @schememodname[scheme], which does not
|
the initial import @schememodname[scheme], which does not
|
||||||
supply any picture-making functions itself---but does provide
|
supply any picture-making functions itself---but does provide
|
||||||
@scheme[require] and the function-calling syntax.}
|
@scheme[require] and the function-calling syntax.}
|
||||||
|
|
||||||
|
@ -451,10 +458,10 @@ creating pictures; the bit between the opening parenthesis with
|
||||||
This helps explain what we meant in the previous section when we said
|
This helps explain what we meant in the previous section when we said
|
||||||
that @schememodname[scheme] provides @scheme[require] and the
|
that @schememodname[scheme] provides @scheme[require] and the
|
||||||
function-calling syntax. Libraries are not restricted to exporting
|
function-calling syntax. Libraries are not restricted to exporting
|
||||||
values, such as functions; they can also define new syntax. In this
|
values, such as functions; they can also define new syntactic
|
||||||
sense, Scheme isn't exactly language at all; it's more of an idea for
|
forms. In this sense, Scheme isn't exactly a language at all; it's
|
||||||
how to structure a language so that you can extend it or create
|
more of an idea for how to structure a language so that you can extend
|
||||||
entirely new languages.
|
it or create entirely new languages.
|
||||||
|
|
||||||
One way to introduce a new syntactic form is through
|
One way to introduce a new syntactic form is through
|
||||||
@scheme[define-syntax] with @scheme[syntax-rules]:
|
@scheme[define-syntax] with @scheme[syntax-rules]:
|
||||||
|
@ -479,7 +486,7 @@ is @scheme[(hc-append 10 expr (code expr))]. In particular,
|
||||||
|
|
||||||
Of course, the sword of syntactic extension cuts both ways: inventing
|
Of course, the sword of syntactic extension cuts both ways: inventing
|
||||||
a new language can make it easier to say what you want, but harder for
|
a new language can make it easier to say what you want, but harder for
|
||||||
others to understand. As it happens, the developers of Scheme are
|
others to understand. As it happens, the developers of PLT Scheme are
|
||||||
constantly giving talks and writing papers that involve Scheme code,
|
constantly giving talks and writing papers that involve Scheme code,
|
||||||
and it's worthwhile for everyone who works on those products to know
|
and it's worthwhile for everyone who works on those products to know
|
||||||
about @scheme[code].
|
about @scheme[code].
|
||||||
|
@ -519,7 +526,7 @@ classes. By convention, the classes are given names that end with
|
||||||
|
|
||||||
@mr-interaction-eval[(send f show #f)]
|
@mr-interaction-eval[(send f show #f)]
|
||||||
|
|
||||||
The @scheme[new] form creates an instances of a class, where
|
The @scheme[new] form creates an instance of a class, where
|
||||||
initialization arguments like @scheme[label] and @scheme[width] are
|
initialization arguments like @scheme[label] and @scheme[width] are
|
||||||
provided by name. The @scheme[send] form calls a method of the object,
|
provided by name. The @scheme[send] form calls a method of the object,
|
||||||
such as @scheme[show], with arguments after the method name; the
|
such as @scheme[show], with arguments after the method name; the
|
||||||
|
@ -544,7 +551,13 @@ picture into a canvas:
|
||||||
(add-drawing (colorize (filled-flash 50 30) "yellow"))
|
(add-drawing (colorize (filled-flash 50 30) "yellow"))
|
||||||
]
|
]
|
||||||
|
|
||||||
@centerline{@mr-interaction-eval-show[(scale (bitmap (build-path (collection-path "scribblings/quick") "art.png")) 0.5)]}
|
@centerline{
|
||||||
|
@mr-interaction-eval-show[(scale
|
||||||
|
(bitmap
|
||||||
|
(build-path
|
||||||
|
(collection-path "scribblings/quick")
|
||||||
|
"art.png"))
|
||||||
|
0.5)]}
|
||||||
|
|
||||||
Each canvas stretches to fill an equal portion of the frame, because
|
Each canvas stretches to fill an equal portion of the frame, because
|
||||||
that's how a frame manages its children by default.
|
that's how a frame manages its children by default.
|
||||||
|
@ -566,6 +579,10 @@ threads. That is, instead of a ``minimalist'' language---which is the
|
||||||
way that Scheme is often described---PLT Scheme offers a rich language
|
way that Scheme is often described---PLT Scheme offers a rich language
|
||||||
with an extensive set of libraries and tools.
|
with an extensive set of libraries and tools.
|
||||||
|
|
||||||
To start learning about the full PLT Scheme language and tools in
|
To continue touring PLT Scheme, but from a systems-oriented
|
||||||
depth, move on to @other-manual['(lib "guide.scrbl"
|
perspective instead of pictures, your next stop is @other-manual['(lib
|
||||||
|
"scribblings/more/more.scrbl")].
|
||||||
|
|
||||||
|
To instead start learning about the full PLT Scheme language and tools
|
||||||
|
in depth, move on to @other-manual['(lib "guide.scrbl"
|
||||||
"scribblings/guide")].
|
"scribblings/guide")].
|
||||||
|
|
Loading…
Reference in New Issue
Block a user