Guide corrections
This commit is contained in:
parent
85790b6611
commit
bedd7b1671
|
@ -41,7 +41,7 @@
|
|||
(namespace-require '(for-syntax racket/base))
|
||||
|
||||
(define (literal-string style s)
|
||||
(let ([m (regexp-match #rx"^(.*)( +)(.*)$" s)])
|
||||
(let ([m (regexp-match #rx"^(.*)( +|^ )(.*)$" s)])
|
||||
(if m
|
||||
(make-element #f (list (literal-string style (cadr m))
|
||||
(hspace (string-length (caddr m)))
|
||||
|
|
|
@ -47,12 +47,10 @@ y)]. The environment of @racket[(+ x y)] includes bindings for
|
|||
@racketmodname[racket].
|
||||
|
||||
A module-level @racket[define] can bind only identifiers that are not
|
||||
already bound within the module. For example, @racket[(define cons 1)]
|
||||
is a syntax error in a @racketmodname[racket] module, since @racket[cons]
|
||||
is provided by @racketmodname[racket]. A local @racket[define] or other
|
||||
binding forms, however, can give a new local binding for an identifier
|
||||
that already has a binding; such a binding @defterm{shadows} the
|
||||
existing binding.
|
||||
already defined or @racket[require]s into the module. A local
|
||||
@racket[define] or other binding forms, however, can give a new local
|
||||
binding for an identifier that already has a binding; such a binding
|
||||
@deftech{shadows} the existing binding.
|
||||
|
||||
@defexamples[
|
||||
(define f
|
||||
|
@ -63,6 +61,14 @@ existing binding.
|
|||
(f list)
|
||||
]
|
||||
|
||||
Similarly, a module-level @racket[define] can @tech{shadow} a binding
|
||||
from the module's language. For example, @racket[(define cons 1)] in a
|
||||
@racketmodname[racket] module shadows the @racket[cons] that is
|
||||
provided by @racketmodname[racket]. Intentionally shadowing a language
|
||||
binding is rarely a good idea---especially for widely used bindings
|
||||
like @racket[cons]---but shadowing relieves a programmer from having
|
||||
to avoid every obscure binding that is provided by a language.
|
||||
|
||||
Even identifiers like @racket[define] and @racket[lambda] get their
|
||||
meanings from bindings, though they have @defterm{transformer}
|
||||
bindings (which means that they indicate syntactic forms) instead of
|
||||
|
@ -76,5 +82,5 @@ define
|
|||
(eval:alts (let ([@#,racketidfont{define} 5]) @#,racketidfont{define}) (let ([define 5]) define))
|
||||
]
|
||||
|
||||
Shadowing standard bindings in this way is rarely a good idea, but the
|
||||
Again, shadowing standard bindings in this way is rarely a good idea, but the
|
||||
possibility is an inherent part of Racket's flexibility.
|
||||
|
|
|
@ -49,10 +49,14 @@ For example, the @filepath{cake.rkt} example of the
|
|||
(provide print-cake)
|
||||
|
||||
(define (print-cake n)
|
||||
(printf " ~a \n" (make-string n #\.))
|
||||
(printf " .-~a-.\n" (make-string n #\|))
|
||||
(printf " | ~a |\n" (make-string n #\space))
|
||||
(printf "---~a---\n" (make-string n #\-))))
|
||||
(show " ~a " n #\.)
|
||||
(show " .-~a-. " n #\|)
|
||||
(show " | ~a | " n #\space)
|
||||
(show "---~a---" n #\-))
|
||||
|
||||
(define (show fmt n ch)
|
||||
(printf fmt (make-string n ch))
|
||||
(newline)))
|
||||
]
|
||||
|
||||
Furthermore, this @racket[module] form can be evaluated in a
|
||||
|
|
Loading…
Reference in New Issue
Block a user