diff --git a/collects/scribble/eval.rkt b/collects/scribble/eval.rkt index 0cc8281567..d0618a438b 100644 --- a/collects/scribble/eval.rkt +++ b/collects/scribble/eval.rkt @@ -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))) diff --git a/collects/scribblings/guide/binding.scrbl b/collects/scribblings/guide/binding.scrbl index 9ed1e18ea7..a138531fde 100644 --- a/collects/scribblings/guide/binding.scrbl +++ b/collects/scribblings/guide/binding.scrbl @@ -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. diff --git a/collects/scribblings/guide/module-syntax.scrbl b/collects/scribblings/guide/module-syntax.scrbl index 7039679537..82cc57d78c 100644 --- a/collects/scribblings/guide/module-syntax.scrbl +++ b/collects/scribblings/guide/module-syntax.scrbl @@ -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