From 5e4386ba139f02fedbf711973e97dd0328bf57d9 Mon Sep 17 00:00:00 2001 From: Stevie Strickland Date: Fri, 30 Apr 2010 09:51:35 -0400 Subject: [PATCH 1/5] Change legacy commands to correctly use negative blame also for user blame. --- collects/racket/contract/private/legacy.rkt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collects/racket/contract/private/legacy.rkt b/collects/racket/contract/private/legacy.rkt index d912b62e41..86270cdcbd 100644 --- a/collects/racket/contract/private/legacy.rkt +++ b/collects/racket/contract/private/legacy.rkt @@ -22,7 +22,7 @@ (unpack-blame pos) "<>" #t - name) + "<>") x fmt args)) @@ -60,7 +60,7 @@ (unpack-blame (if original? pos neg)) (unpack-blame (if original? neg pos)) original? - name))))) + (unpack-blame (if original? neg pos))))))) (define (legacy-property name) (define-values [ prop pred get ] From 783e309b4d9da9f5f4debf48a02b66b4618c04fc Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 30 Apr 2010 06:21:02 -0600 Subject: [PATCH 2/5] add serializable-struct --- collects/racket/serialize.rkt | 59 ++++++++++++--- .../scribblings/reference/serialization.scrbl | 72 +++++++++++-------- 2 files changed, 94 insertions(+), 37 deletions(-) diff --git a/collects/racket/serialize.rkt b/collects/racket/serialize.rkt index 4849b2beec..f839b30e8f 100644 --- a/collects/racket/serialize.rkt +++ b/collects/racket/serialize.rkt @@ -5,13 +5,15 @@ racket/struct-info)) (provide (all-from-out "private/serialize.ss") + serializable-struct + serializable-struct/versions define-serializable-struct define-serializable-struct/versions) (define-syntax (define-serializable-struct/versions/derived stx) (syntax-case stx () ;; First check `id/sup': - [(_ orig-stx id/sup . _) + [(_ orig-stx make-prefix? id/sup . _) (not (or (identifier? #'id/sup) (syntax-case #'id/sup () [(id sup) (and (identifier? #'id) @@ -22,11 +24,11 @@ ;; Not valid, so let `define-struct/derived' complain: #'(define-struct/derived orig-stx id/sup ())] ;; Check version: - [(_ orig-stx id/sup vers . _) + [(_ orig-stx make-prefix? id/sup vers . _) (not (exact-nonnegative-integer? (syntax-e #'vers))) (raise-syntax-error #f "expected a nonnegative exact integer for a version" #'orig-stx #'vers)] ;; Main case: - [(_ orig-stx id/sup vers (field ...) ([other-vers make-proc-expr cycle-make-proc-expr] ...) + [(_ orig-stx make-prefix? id/sup vers (field ...) ([other-vers make-proc-expr cycle-make-proc-expr] ...) prop ...) (let* ([id (if (identifier? #'id/sup) #'id/sup @@ -35,10 +37,22 @@ #f (extract-struct-info (syntax-local-value (cadr (syntax->list #'id/sup)))))] [fields (syntax->list #'(field ...))] - [maker (datum->syntax id - (string->symbol - (format "make-~a" (syntax-e id))) - id)] + [given-maker (let loop ([props (syntax->list #'(prop ...))]) + (cond + [(null? props) #f] + [(null? (cdr props)) #f] + [(or (eq? (syntax-e (car props)) '#:constructor-name) + (eq? (syntax-e (car props)) '#:extra-constructor-name)) + (and (identifier? (cadr props)) + (cadr props))] + [else (loop (cdr props))]))] + [maker (or given-maker + (if (syntax-e #'make-prefix?) + (datum->syntax id + (string->symbol + (format "make-~a" (syntax-e id))) + id) + id))] [getters (map (lambda (field) (datum->syntax id @@ -103,6 +117,10 @@ id/sup (field ...) prop ... + #,@(if (or given-maker + (syntax-e #'make-prefix?)) + null + (list #'#:constructor-name id)) #:property prop:serializable (make-serialize-info ;; The struct-to-vector function: -------------------- @@ -203,14 +221,37 @@ (define-syntax (define-serializable-struct/versions stx) (syntax-case stx () [(_ . rest) - #`(define-serializable-struct/versions/derived #,stx . rest)])) + #`(define-serializable-struct/versions/derived #,stx #t . rest)])) + + (define-syntax (serializable-struct/versions stx) + (syntax-case stx () + [(_ id super-id . rest) + (and (identifier? #'id) + (identifier? #'super-id)) + #`(define-serializable-struct/versions/derived #,stx #f (id super-id) . rest)] + [(_ id (field ...) . rest) + (identifier? #'id) + #`(define-serializable-struct/versions/derived #,stx #f id (field ...) . rest)])) (define-syntax (define-serializable-struct stx) (syntax-case stx () [(_ id/sup (field ...) prop ...) - #`(define-serializable-struct/versions/derived #,stx + #`(define-serializable-struct/versions/derived #,stx #t id/sup 0 (field ...) () prop ...)] [(_ . rest) #`(define-struct/derived #,stx . rest)])) + (define-syntax (serializable-struct stx) + (syntax-case stx () + [(_ id super-id (field ...) prop ...) + (and (identifier? #'id) + (identifier? #'super-id)) + #`(define-serializable-struct/versions/derived #,stx #f + (id super-id) 0 (field ...) () prop ...)] + [(_ id (field ...) prop ...) + (and (identifier? #'id) + (identifier? #'super-id)) + #`(define-serializable-struct/versions/derived #,stx #f + id 0 (field ...) () prop ...)])) + ) diff --git a/collects/scribblings/reference/serialization.scrbl b/collects/scribblings/reference/serialization.scrbl index e1e32b8944..d17e6d5dd3 100644 --- a/collects/scribblings/reference/serialization.scrbl +++ b/collects/scribblings/reference/serialization.scrbl @@ -33,8 +33,8 @@ The following kinds of values are serializable: @itemize[ - @item{structures created through @scheme[define-serializable-struct] or - @scheme[define-serializable-struct/version], or more generally + @item{structures created through @scheme[serializable-struct] or + @scheme[serializable-struct/versions], or more generally structures with the @scheme[prop:serializable] property (see @scheme[prop:serializable] for more information);} @@ -338,10 +338,10 @@ exception to disallow the @scheme[dynamic-require].} @; ---------------------------------------------------------------------- -@defform[(define-serializable-struct id-maybe-super (field ...) - struct-option ...)]{ +@defform[(serializable-struct id maybe-super (field ...) + struct-option ...)]{ -Like @scheme[define-struct], but instances of the structure type are +Like @scheme[struct], but instances of the structure type are serializable with @scheme[serialize]. This form is allowed only at the top level or in a module's top level (so that deserialization information can be found later). @@ -350,17 +350,16 @@ Serialization only supports cycles involving the created structure type when all fields are mutable (or when the cycle can be broken through some other mutable value). -In addition to the bindings generated by @scheme[define-struct], -@scheme[define-serializable-struct] binds +In addition to the bindings generated by @scheme[struct], +@scheme[serializable-struct] binds @schemeidfont{deserialize-info:}@scheme[_id]@schemeidfont{-v0} to deserialization information. Furthermore, in a module context, it automatically @scheme[provide]s this binding. -The @scheme[define-serializable-struct] form enables the construction -of structure instances from places where -@schemeidfont{make}@scheme[id] is not accessible, since -deserialization must construct instances. Furthermore, -@scheme[define-serializable-struct] provides limited access to field +The @scheme[serializable-struct] form enables the construction of +structure instances from places where @scheme[id] is not accessible, +since deserialization must construct instances. Furthermore, +@scheme[serializable-struct] provides limited access to field mutation, but only for instances generated through the deserialization information bound to @schemeidfont{deserialize-info:}@scheme[_id]@schemeidfont{-v0}. See @@ -368,9 +367,9 @@ information bound to The @scheme[-v0] suffix on the deserialization enables future versioning on the structure type through -@scheme[define-serializable-struct/version]. +@scheme[serializable-struct/version]. -When a supertype is supplied in @scheme[id-maybe-super] is supplied, +When a supertype is supplied in @scheme[maybe-super] is supplied, compile-time information bound to the supertype identifier must include all of the supertype's field accessors. If any field mutator is missing, the structure type will be treated as immutable for the @@ -379,20 +378,28 @@ structure type cannot be handled by the deserializer). @examples[ #:eval ser-eval -(define-serializable-struct point (x y)) -(point-x (deserialize (serialize (make-point 1 2)))) +(serializable-struct point (x y)) +(point-x (deserialize (serialize (point 1 2)))) ]} @; ---------------------------------------------------------------------- -@defform/subs[(define-serializable-struct/versions id-maybe-super vers (field ...) - (other-version-clause ...) - struct-option ...) +@defform[(define-serializable-struct id-maybe-super (field ...) + struct-option ...)]{ + +Like @racket[serializable-struct], but with the supertype syntax and +default constructor name of @racket[define-struct].} + +@; ---------------------------------------------------------------------- + +@defform/subs[(serializable-struct/versions id-maybe-super vers (field ...) + (other-version-clause ...) + struct-option ...) ([other-version-clause (other-vers make-proc-expr cycle-make-proc-expr)])]{ -Like @scheme[define-serializable-struct], but the generated -deserializer binding is +Like @scheme[serializable-struct], but the generated deserializer +binding is @schemeidfont{deserialize-info:}@scheme[_id]@schemeidfont{-v}@scheme[vers]. In addition, @schemeidfont{deserialize-info:}@scheme[_id]@schemeidfont{-v}@scheme[other-vers] @@ -410,35 +417,44 @@ instance of @scheme[id] and copies its field values into @scheme[x]. @examples[ #:eval ser-eval -(define-serializable-struct point (x y) #:mutable #:transparent) -(define ps (serialize (make-point 1 2))) +(serializable-struct point (x y) #:mutable #:transparent) +(define ps (serialize (point 1 2))) (deserialize ps) -(define x (make-point 1 10)) +(define x (point 1 10)) (set-point-x! x x) (define xs (serialize x)) (deserialize xs) -(define-serializable-struct/versions point 1 (x y z) +(serializable-struct/versions point 1 (x y z) ([0 (code:comment @#,t{Constructor for simple v0 instances:}) - (lambda (x y) (make-point x y 0)) + (lambda (x y) (point x y 0)) (code:comment @#,t{Constructor for v0 instance in a cycle:}) (lambda () - (let ([p0 (make-point #f #f 0)]) + (let ([p0 (point #f #f 0)]) (values p0 (lambda (p) (set-point-x! p0 (point-x p)) (set-point-y! p0 (point-y p))))))]) #:mutable #:transparent) -(deserialize (serialize (make-point 4 5 6))) +(deserialize (serialize (point 4 5 6))) (deserialize ps) (deserialize xs) ]} @; ---------------------------------------------------------------------- +@defform[(define-serializable-struct/versions id-maybe-super vers (field ...) + (other-version-clause ...) + struct-option ...)]{ +Like @racket[serializable-struct/versions], but with the supertype syntax and +default constructor name of @racket[define-struct].} +} + +@; ---------------------------------------------------------------------- + @defproc[(make-deserialize-info [make procedure?] [cycle-make (-> (values any/c procedure?))]) any]{ From 162058036ec2fcce1905fdf746b6faa3a0342d34 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 30 Apr 2010 07:39:41 -0600 Subject: [PATCH 3/5] fully rackety guide --- collects/racket/serialize.rkt | 7 +- collects/scribble/eval.rkt | 32 +- collects/scribblings/guide/class.scrbl | 560 +++++++++--------- collects/scribblings/guide/compile.scrbl | 54 +- collects/scribblings/guide/control.scrbl | 88 +-- collects/scribblings/guide/dialects.scrbl | 118 ++-- collects/scribblings/guide/for.scrbl | 196 +++--- collects/scribblings/guide/io.scrbl | 220 ++++--- collects/scribblings/guide/macros.scrbl | 10 +- collects/scribblings/guide/match.scrbl | 48 +- collects/scribblings/guide/namespaces.scrbl | 335 +++++------ collects/scribblings/guide/other.scrbl | 18 +- .../scribblings/guide/pattern-macros.scrbl | 258 ++++---- collects/scribblings/guide/performance.scrbl | 156 ++--- collects/scribblings/guide/proc-macros.scrbl | 254 ++++---- collects/scribblings/guide/regexp.scrbl | 122 ++-- collects/scribblings/guide/running.scrbl | 101 ++-- collects/scribblings/guide/scripts.scrbl | 66 +-- 18 files changed, 1331 insertions(+), 1312 deletions(-) diff --git a/collects/racket/serialize.rkt b/collects/racket/serialize.rkt index f839b30e8f..6ebce11b47 100644 --- a/collects/racket/serialize.rkt +++ b/collects/racket/serialize.rkt @@ -229,9 +229,10 @@ (and (identifier? #'id) (identifier? #'super-id)) #`(define-serializable-struct/versions/derived #,stx #f (id super-id) . rest)] - [(_ id (field ...) . rest) - (identifier? #'id) - #`(define-serializable-struct/versions/derived #,stx #f id (field ...) . rest)])) + [(_ id vers (field ...) . rest) + (and (identifier? #'id) + (number? (syntax-e #'vers))) + #`(define-serializable-struct/versions/derived #,stx #f id vers (field ...) . rest)])) (define-syntax (define-serializable-struct stx) (syntax-case stx () diff --git a/collects/scribble/eval.rkt b/collects/scribble/eval.rkt index f0a8f74578..a1b6dae813 100644 --- a/collects/scribble/eval.rkt +++ b/collects/scribble/eval.rkt @@ -7,7 +7,7 @@ racket/file racket/sandbox racket/promise - mzlib/string + racket/string (for-syntax racket/base)) (provide interaction @@ -97,18 +97,24 @@ (map (lambda (s) (car (format-output s error-color))) - (let sloop ([s (caar val-list+outputs)]) - (if ((string-length s) . > . maxlen) - ;; break the error message into multiple lines: - (let loop ([pos (sub1 maxlen)]) - (cond - [(zero? pos) (cons (substring s 0 maxlen) - (sloop (substring s maxlen)))] - [(char-whitespace? (string-ref s pos)) - (cons (substring s 0 pos) - (sloop (substring s (add1 pos))))] - [else (loop (sub1 pos))])) - (list s)))) + (filter + (lambda (s) (not (equal? s ""))) + (let sloop ([s (caar val-list+outputs)]) + (apply + append + (map (lambda (s) + (if ((string-length s) . > . maxlen) + ;; break the error message into multiple lines: + (let loop ([pos (sub1 maxlen)]) + (cond + [(zero? pos) (cons (substring s 0 maxlen) + (sloop (substring s maxlen)))] + [(char-whitespace? (string-ref s pos)) + (cons (substring s 0 pos) + (sloop (substring s (add1 pos))))] + [else (loop (sub1 pos))])) + (list s))) + (regexp-split #rx"\n" s)))))) ;; Normal result case: (let ([val-list (caar val-list+outputs)]) (if (equal? val-list (list (void))) diff --git a/collects/scribblings/guide/class.scrbl b/collects/scribblings/guide/class.scrbl index 106a98b8bd..fe250667b0 100644 --- a/collects/scribblings/guide/class.scrbl +++ b/collects/scribblings/guide/class.scrbl @@ -1,16 +1,16 @@ #lang scribble/doc @(require scribble/manual scribble/eval - scheme/class + racket/class "guide-utils.ss" - (for-label scheme/class - scheme/trait - scheme/contract)) + (for-label racket/class + racket/trait + racket/contract)) @(define class-eval (let ([e (make-base-eval)]) - (e '(require scheme/class)) + (e '(require racket/class)) e)) @; FIXME: at some point, discuss classes vs. units vs. modules @@ -20,24 +20,24 @@ @margin-note{This chapter is based on a paper @cite["Flatt06"].} -A @scheme[class] expression denotes a first-class value, -just like a @scheme[lambda] expression: +A @racket[class] expression denotes a first-class value, +just like a @racket[lambda] expression: @specform[(class superclass-expr decl-or-expr ...)] -The @scheme[_superclass-expr] determines the superclass for the new -class. Each @scheme[_decl-or-expr] is either a declaration related to +The @racket[_superclass-expr] determines the superclass for the new +class. Each @racket[_decl-or-expr] is either a declaration related to methods, fields, and initialization arguments, or it is an expression that is evaluated each time that the class is instantiated. In other words, instead of a method-like constructor, a class has initialization expressions interleaved with field and method declarations. -By convention, class names end with @schemeidfont{%}. The built-in root class is -@scheme[object%]. The following expression creates a class with -public methods @scheme[get-size], @scheme[grow], and @scheme[eat]: +By convention, class names end with @racketidfont{%}. The built-in root class is +@racket[object%]. The following expression creates a class with +public methods @racket[get-size], @racket[grow], and @racket[eat]: -@schemeblock[ +@racketblock[ (class object% (init size) (code:comment #,(t "initialization argument")) @@ -69,16 +69,16 @@ public methods @scheme[get-size], @scheme[grow], and @scheme[eat]: (define/public (eat other-fish) (grow (send other-fish get-size)))))) -The @scheme[size] initialization argument must be supplied via a named - argument when instantiating the class through the @scheme[new] form: +The @racket[size] initialization argument must be supplied via a named + argument when instantiating the class through the @racket[new] form: -@schemeblock[ +@racketblock[ (new (class object% (init size) ....) [size 10]) ] Of course, we can also name the class and its instance: -@schemeblock[ +@racketblock[ (define fish% (class object% (init size) ....)) (define charlie (new fish% [size 10])) ] @@ -87,26 +87,26 @@ Of course, we can also name the class and its instance: #:eval class-eval (define charlie (new fish% [size 10]))) -In the definition of @scheme[fish%], @scheme[current-size] is a -private field that starts out with the value of the @scheme[size] -initialization argument. Initialization arguments like @scheme[size] +In the definition of @racket[fish%], @racket[current-size] is a +private field that starts out with the value of the @racket[size] +initialization argument. Initialization arguments like @racket[size] are available only during class instantiation, so they cannot be -referenced directly from a method. The @scheme[current-size] field, in +referenced directly from a method. The @racket[current-size] field, in contrast, is available to methods. -The @scheme[(super-new)] expression in @scheme[fish%] invokes the +The @racket[(super-new)] expression in @racket[fish%] invokes the initialization of the superclass. In this case, the superclass is -@scheme[object%], which takes no initialization arguments and performs -no work; @scheme[super-new] must be used, anyway, because a class must +@racket[object%], which takes no initialization arguments and performs +no work; @racket[super-new] must be used, anyway, because a class must always invoke its superclass's initialization. Initialization arguments, field declarations, and expressions such as -@scheme[(super-new)] can appear in any order within a @scheme[class], +@racket[(super-new)] can appear in any order within a @racket[class], and they can be interleaved with method declarations. The relative order of expressions in the class determines the order of evaluation during instantiation. For example, if a field's initial value requires calling a method that works only after superclass initialization, then -the field declaration must be placed after the @scheme[super-new] +the field declaration must be placed after the @racket[super-new] call. Ordering field and initialization declarations in this way helps avoid imperative assignment. The relative order of method declarations makes no difference for evaluation, because methods are fully defined @@ -114,11 +114,11 @@ before a class is instantiated. @section[#:tag "methods"]{Methods} -Each of the three @scheme[define/public] declarations in -@scheme[fish%] introduces a new method. The declaration uses the same -syntax as a Scheme function, but a method is not accessible as an -independent function. A call to the @scheme[grow] method of a -@scheme[fish%] object requires the @scheme[send] form: +Each of the three @racket[define/public] declarations in +@racket[fish%] introduces a new method. The declaration uses the same +syntax as a Racket function, but a method is not accessible as an +independent function. A call to the @racket[grow] method of a +@racket[fish%] object requires the @racket[send] form: @interaction[ #:eval class-eval @@ -126,15 +126,15 @@ independent function. A call to the @scheme[grow] method of a (send charlie get-size) ] -Within @scheme[fish%], self methods can be called like functions, -because the method names are in scope. For example, the @scheme[eat] -method within @scheme[fish%] directly invokes the @scheme[grow] +Within @racket[fish%], self methods can be called like functions, +because the method names are in scope. For example, the @racket[eat] +method within @racket[fish%] directly invokes the @racket[grow] method. Within a class, attempting to use a method name in any way other than a method call results in a syntax error. In some cases, a class must call methods that are supplied by the superclass -but not overridden. In that case, the class can use @scheme[send] -with @scheme[this] to access the method: +but not overridden. In that case, the class can use @racket[send] +with @racket[this] to access the method: @def+int[ #:eval class-eval @@ -144,7 +144,7 @@ with @scheme[this] to access the method: (send this eat fish2)))) ] -Alternately, the class can declare the existence of a method using @scheme[inherit], +Alternately, the class can declare the existence of a method using @racket[inherit], which brings the method name into scope for a direct call: @def+int[ @@ -155,26 +155,26 @@ which brings the method name into scope for a direct call: (eat fish1) (eat fish2)))) ] -With the @scheme[inherit] declaration, if @scheme[fish%] had not -provided an @scheme[eat] method, an error would be signaled in the -evaluation of the @scheme[class] form for @scheme[hungry-fish%]. In -contrast, with @scheme[(send this ....)], an error would not be -signaled until the @scheme[eat-more] method is called and the -@scheme[send] form is evaluated. For this reason, @scheme[inherit] is +With the @racket[inherit] declaration, if @racket[fish%] had not +provided an @racket[eat] method, an error would be signaled in the +evaluation of the @racket[class] form for @racket[hungry-fish%]. In +contrast, with @racket[(send this ....)], an error would not be +signaled until the @racket[eat-more] method is called and the +@racket[send] form is evaluated. For this reason, @racket[inherit] is preferred. -Another drawback of @scheme[send] is that it is less efficient than -@scheme[inherit]. Invocation of a method via @scheme[send] involves +Another drawback of @racket[send] is that it is less efficient than +@racket[inherit]. Invocation of a method via @racket[send] involves finding a method in the target object's class at run time, making -@scheme[send] comparable to an interface-based method call in Java. In -contrast, @scheme[inherit]-based method invocations use an offset +@racket[send] comparable to an interface-based method call in Java. In +contrast, @racket[inherit]-based method invocations use an offset within the class's method table that is computed when the class is created. -To achieve performance similar to @scheme[inherit]-based method calls when +To achieve performance similar to @racket[inherit]-based method calls when invoking a method from outside the method's class, the programmer must use the -@scheme[generic] form, which produces a class- and method-specific -@defterm{generic method} to be invoked with @scheme[send-generic]: +@racket[generic] form, which produces a class- and method-specific +@defterm{generic method} to be invoked with @racket[send-generic]: @def+int[ #:eval class-eval @@ -189,9 +189,9 @@ method name to a location in the class's method table. As illustrated by the last example, sending through a generic method checks that its argument is an instance of the generic's class. -Whether a method is called directly within a @scheme[class], +Whether a method is called directly within a @racket[class], through a generic method, -or through @scheme[send], method overriding works in the usual way: +or through @racket[send], method overriding works in the usual way: @defs+int[ #:eval class-eval @@ -206,27 +206,27 @@ or through @scheme[send], method overriding works in the usual way: (send daisy get-size) ] -The @scheme[grow] method in @scheme[picky-fish%] is declared with -@scheme[define/override] instead of @scheme[define/public], because -@scheme[grow] is meant as an overriding declaration. If @scheme[grow] -had been declared with @scheme[define/public], an error would have -been signaled when evaluating the @scheme[class] expression, because -@scheme[fish%] already supplies @scheme[grow]. +The @racket[grow] method in @racket[picky-fish%] is declared with +@racket[define/override] instead of @racket[define/public], because +@racket[grow] is meant as an overriding declaration. If @racket[grow] +had been declared with @racket[define/public], an error would have +been signaled when evaluating the @racket[class] expression, because +@racket[fish%] already supplies @racket[grow]. -Using @scheme[define/override] also allows the invocation of the -overridden method via a @scheme[super] call. For example, the -@scheme[grow] implementation in @scheme[picky-fish%] uses -@scheme[super] to delegate to the superclass implementation. +Using @racket[define/override] also allows the invocation of the +overridden method via a @racket[super] call. For example, the +@racket[grow] implementation in @racket[picky-fish%] uses +@racket[super] to delegate to the superclass implementation. @section[#:tag "initargs"]{Initialization Arguments} -Since @scheme[picky-fish%] declares no initialization arguments, any -initialization values supplied in @scheme[(new picky-fish% ....)] are -propagated to the superclass initialization, i.e., to @scheme[fish%]. +Since @racket[picky-fish%] declares no initialization arguments, any +initialization values supplied in @racket[(new picky-fish% ....)] are +propagated to the superclass initialization, i.e., to @racket[fish%]. A subclass can supply additional initialization arguments for its -superclass in a @scheme[super-new] call, and such initialization -arguments take precedence over arguments supplied to @scheme[new]. For -example, the following @scheme[size-10-fish%] class always generates +superclass in a @racket[super-new] call, and such initialization +arguments take precedence over arguments supplied to @racket[new]. For +example, the following @racket[size-10-fish%] class always generates fish of size 10: @def+int[ @@ -235,15 +235,15 @@ fish of size 10: (send (new size-10-fish%) get-size) ] -In the case of @scheme[size-10-fish%], supplying a @scheme[size] -initialization argument with @scheme[new] would result in an -initialization error; because the @scheme[size] in @scheme[super-new] -takes precedence, a @scheme[size] supplied to @scheme[new] would have +In the case of @racket[size-10-fish%], supplying a @racket[size] +initialization argument with @racket[new] would result in an +initialization error; because the @racket[size] in @racket[super-new] +takes precedence, a @racket[size] supplied to @racket[new] would have no target declaration. -An initialization argument is optional if the @scheme[class] form -declares a default value. For example, the following @scheme[default-10-fish%] -class accepts a @scheme[size] initialization argument, but its value defaults to +An initialization argument is optional if the @racket[class] form +declares a default value. For example, the following @racket[default-10-fish%] +class accepts a @racket[size] initialization argument, but its value defaults to 10 if no value is supplied on instantiation: @def+int[ @@ -255,24 +255,24 @@ class accepts a @scheme[size] initialization argument, but its value defaults to (new default-10-fish% [size 20]) ] -In this example, the @scheme[super-new] call propagates its own -@scheme[size] value as the @scheme[size] initialization argument to +In this example, the @racket[super-new] call propagates its own +@racket[size] value as the @racket[size] initialization argument to the superclass. @section[#:tag "intnames"]{Internal and External Names} -The two uses of @scheme[size] in @scheme[default-10-fish%] expose the -double life of class-member identifiers. When @scheme[size] is the -first identifier of a bracketed pair in @scheme[new] or -@scheme[super-new], @scheme[size] is an @defterm{external name} that +The two uses of @racket[size] in @racket[default-10-fish%] expose the +double life of class-member identifiers. When @racket[size] is the +first identifier of a bracketed pair in @racket[new] or +@racket[super-new], @racket[size] is an @defterm{external name} that is symbolically matched to an initialization argument in a class. When -@scheme[size] appears as an expression within -@scheme[default-10-fish%], @scheme[size] is an @defterm{internal name} +@racket[size] appears as an expression within +@racket[default-10-fish%], @racket[size] is an @defterm{internal name} that is lexically scoped. Similarly, a call to an inherited -@scheme[eat] method uses @scheme[eat] as an internal name, whereas a -@scheme[send] of @scheme[eat] uses @scheme[eat] as an external name. +@racket[eat] method uses @racket[eat] as an internal name, whereas a +@racket[send] of @racket[eat] uses @racket[eat] as an external name. -The full syntax of the @scheme[class] form allows a programmer to +The full syntax of the @racket[class] form allows a programmer to specify distinct internal and external names for a class member. Since internal names are local, they can be renamed to avoid shadowing or conflicts. Such renaming is not frequently necessary, but workarounds @@ -285,7 +285,7 @@ implements a set of methods with a particular (implied) behavior. This use of interfaces is helpful even without a static type system (which is the main reason that Java has interfaces). -An interface in PLT Scheme is created using the @scheme[interface] +An interface in Racket is created using the @racket[interface] form, which merely declares the method names required to implement the interface. An interface can extend other interfaces, which means that implementations of the interface automatically implement the extended @@ -294,56 +294,56 @@ interfaces. @specform[(interface (superinterface-expr ...) id ...)] To declare that a class implements an interface, the -@scheme[class*] form must be used instead of @scheme[class]: +@racket[class*] form must be used instead of @racket[class]: @specform[(class* superclass-expr (interface-expr ...) decl-or-expr ...)] For example, instead of forcing all fish classes to be derived from -@scheme[fish%], we can define @scheme[fish-interface] and change the -@scheme[fish%] class to declare that it implements -@scheme[fish-interface]: +@racket[fish%], we can define @racket[fish-interface] and change the +@racket[fish%] class to declare that it implements +@racket[fish-interface]: -@schemeblock[ +@racketblock[ (define fish-interface (interface () get-size grow eat)) (define fish% (class* object% (fish-interface) ....)) ] -If the definition of @scheme[fish%] does not include -@scheme[get-size], @scheme[grow], and @scheme[eat] methods, then an -error is signaled in the evaluation of the @scheme[class*] form, -because implementing the @scheme[fish-interface] interface requires +If the definition of @racket[fish%] does not include +@racket[get-size], @racket[grow], and @racket[eat] methods, then an +error is signaled in the evaluation of the @racket[class*] form, +because implementing the @racket[fish-interface] interface requires those methods. -The @scheme[is-a?] predicate accepts either a class or interface as +The @racket[is-a?] predicate accepts either a class or interface as its first argument and an object as its second argument. When given a -class, @scheme[is-a?] checks whether the object is an instance of that -class or a derived class. When given an interface, @scheme[is-a?] +class, @racket[is-a?] checks whether the object is an instance of that +class or a derived class. When given an interface, @racket[is-a?] checks whether the object's class implements the interface. In -addition, the @scheme[implementation?] predicate checks whether a +addition, the @racket[implementation?] predicate checks whether a given class implements a given interface. @section[#:tag "inner"]{Final, Augment, and Inner} -As in Java, a method in a @scheme[class] form can be specified as +As in Java, a method in a @racket[class] form can be specified as @defterm{final}, which means that a subclass cannot override the -method. A final method is declared using @scheme[public-final] or -@scheme[override-final], depending on whether the declaration is for a +method. A final method is declared using @racket[public-final] or +@racket[override-final], depending on whether the declaration is for a new method or an overriding implementation. Between the extremes of allowing arbitrary overriding and disallowing overriding entirely, the class system also supports Beta-style @defterm{augmentable} methods @cite["Goldberg04"]. A method -declared with @scheme[pubment] is like @scheme[public], but the method +declared with @racket[pubment] is like @racket[public], but the method cannot be overridden in subclasses; it can be augmented only. A -@scheme[pubment] method must explicitly invoke an augmentation (if any) -using @scheme[inner]; a subclass augments the method using -@scheme[augment], instead of @scheme[override]. +@racket[pubment] method must explicitly invoke an augmentation (if any) +using @racket[inner]; a subclass augments the method using +@racket[augment], instead of @racket[override]. In general, a method can switch between augment and override modes in -a class derivation. The @scheme[augride] method specification +a class derivation. The @racket[augride] method specification indicates an augmentation to a method where the augmentation is itself overrideable in subclasses (though the superclass's implementation -cannot be overridden). Similarly, @scheme[overment] overrides a method +cannot be overridden). Similarly, @racket[overment] overrides a method and makes the overriding implementation augmentable. @section[#:tag "extnames"]{Controlling the Scope of External Names} @@ -357,39 +357,39 @@ definition refers to an existing binding for an external name, where the member name is bound to a @defterm{member key}; a class ultimately maps member keys to methods, fields, and initialization arguments. -Recall the @scheme[hungry-fish%] @scheme[class] expression: +Recall the @racket[hungry-fish%] @racket[class] expression: -@schemeblock[ +@racketblock[ (define hungry-fish% (class fish% .... (inherit eat) (define/public (eat-more fish1 fish2) (eat fish1) (eat fish2)))) ] -During its evaluation, the @scheme[hungry-fish%] and @scheme[fish%] -classes refer to the same global binding of @scheme[eat]. At run -time, calls to @scheme[eat] in @scheme[hungry-fish%] are matched with -the @scheme[eat] method in @scheme[fish%] through the shared method -key that is bound to @scheme[eat]. +During its evaluation, the @racket[hungry-fish%] and @racket[fish%] +classes refer to the same global binding of @racket[eat]. At run +time, calls to @racket[eat] in @racket[hungry-fish%] are matched with +the @racket[eat] method in @racket[fish%] through the shared method +key that is bound to @racket[eat]. The default binding for an external name is global, but a programmer can introduce an external-name binding with the -@scheme[define-member-name] form. +@racket[define-member-name] form. @specform[(define-member-name id member-key-expr)] -In particular, by using @scheme[(generate-member-key)] as the -@scheme[member-key-expr], an external name can be localized for a +In particular, by using @racket[(generate-member-key)] as the +@racket[member-key-expr], an external name can be localized for a particular scope, because the generated member key is inaccessible -outside the scope. In other words, @scheme[define-member-name] gives +outside the scope. In other words, @racket[define-member-name] gives an external name a kind of package-private scope, but generalized from -packages to arbitrary binding scopes in Scheme. +packages to arbitrary binding scopes in Racket. -For example, the following @scheme[fish%] and @scheme[pond%] classes cooperate -via a @scheme[get-depth] method that is only accessible to the +For example, the following @racket[fish%] and @racket[pond%] classes cooperate +via a @racket[get-depth] method that is only accessible to the cooperating classes: -@schemeblock[ +@racketblock[ (define-values (fish% pond%) (code:comment #,(t "two mutually recursive classes")) (let () ; create a local definition scope (define-member-name get-depth (generate-member-key)) @@ -408,18 +408,18 @@ cooperating classes: (values fish% pond%))) ] -External names are in a namespace that separates them from other Scheme +External names are in a namespace that separates them from other Racket names. This separate namespace is implicitly used for the method name in -@scheme[send], for initialization-argument names in @scheme[new], or for +@racket[send], for initialization-argument names in @racket[new], or for the external name in a member definition. The special form -@scheme[member-name-key] provides access to the binding of an external name -in an arbitrary expression position: @scheme[(member-name-key id)] -produces the member-key binding of @scheme[id] in the current scope. +@racket[member-name-key] provides access to the binding of an external name +in an arbitrary expression position: @racket[(member-name-key id)] +produces the member-key binding of @racket[id] in the current scope. A member-key value is primarily used with a -@scheme[define-member-name] form. Normally, then, -@scheme[(member-name-key id)] captures the method key of @scheme[id] -so that it can be communicated to a use of @scheme[define-member-name] +@racket[define-member-name] form. Normally, then, +@racket[(member-name-key id)] captures the method key of @racket[id] +so that it can be communicated to a use of @racket[define-member-name] in a different scope. This capability turns out to be useful for generalizing mixins, as discussed next. @@ -427,34 +427,34 @@ generalizing mixins, as discussed next. @section{Mixins} -Since @scheme[class] is an expression form instead of a top-level -declaration as in Smalltalk and Java, a @scheme[class] form can be -nested inside any lexical scope, including @scheme[lambda]. The result +Since @racket[class] is an expression form instead of a top-level +declaration as in Smalltalk and Java, a @racket[class] form can be +nested inside any lexical scope, including @racket[lambda]. The result is a @deftech{mixin}, i.e., a class extension that is parameterized with respect to its superclass. -For example, we can parameterize the @scheme[picky-fish%] class over -its superclass to define @scheme[picky-mixin]: +For example, we can parameterize the @racket[picky-fish%] class over +its superclass to define @racket[picky-mixin]: -@schemeblock[ +@racketblock[ (define (picky-mixin %) (class % (super-new) (define/override (grow amt) (super grow (* 3/4 amt))))) (define picky-fish% (picky-mixin fish%)) ] -Many small differences between Smalltalk-style classes and Scheme +Many small differences between Smalltalk-style classes and Racket classes contribute to the effective use of mixins. In particular, the -use of @scheme[define/override] makes explicit that -@scheme[picky-mixin] expects a class with a @scheme[grow] method. If -@scheme[picky-mixin] is applied to a class without a @scheme[grow] -method, an error is signaled as soon as @scheme[picky-mixin] is +use of @racket[define/override] makes explicit that +@racket[picky-mixin] expects a class with a @racket[grow] method. If +@racket[picky-mixin] is applied to a class without a @racket[grow] +method, an error is signaled as soon as @racket[picky-mixin] is applied. -Similarly, a use of @scheme[inherit] enforces a ``method existence'' +Similarly, a use of @racket[inherit] enforces a ``method existence'' requirement when the mixin is applied: -@schemeblock[ +@racketblock[ (define (hungry-mixin %) (class % (super-new) (inherit eat) @@ -466,22 +466,22 @@ requirement when the mixin is applied: The advantage of mixins is that we can easily combine them to create new classes whose implementation sharing does not fit into a single-inheritance hierarchy---without the ambiguities associated with -multiple inheritance. Equipped with @scheme[picky-mixin] and -@scheme[hungry-mixin], creating a class for a hungry, yet picky fish +multiple inheritance. Equipped with @racket[picky-mixin] and +@racket[hungry-mixin], creating a class for a hungry, yet picky fish is straightforward: -@schemeblock[ +@racketblock[ (define picky-hungry-fish% (hungry-mixin (picky-mixin fish%))) ] The use of keyword initialization arguments is critical for the easy -use of mixins. For example, @scheme[picky-mixin] and -@scheme[hungry-mixin] can augment any class with suitable @scheme[eat] -and @scheme[grow] methods, because they do not specify initialization -arguments and add none in their @scheme[super-new] expressions: +use of mixins. For example, @racket[picky-mixin] and +@racket[hungry-mixin] can augment any class with suitable @racket[eat] +and @racket[grow] methods, because they do not specify initialization +arguments and add none in their @racket[super-new] expressions: -@schemeblock[ +@racketblock[ (define person% (class object% (init name age) @@ -494,21 +494,21 @@ arguments and add none in their @scheme[super-new] expressions: Finally, the use of external names for class members (instead of lexically scoped identifiers) makes mixin use convenient. Applying -@scheme[picky-mixin] to @scheme[person%] works because the names -@scheme[eat] and @scheme[grow] match, without any a priori declaration -that @scheme[eat] and @scheme[grow] should be the same method in -@scheme[fish%] and @scheme[person%]. This feature is a potential +@racket[picky-mixin] to @racket[person%] works because the names +@racket[eat] and @racket[grow] match, without any a priori declaration +that @racket[eat] and @racket[grow] should be the same method in +@racket[fish%] and @racket[person%]. This feature is a potential drawback when member names collide accidentally; some accidental collisions can be corrected by limiting the scope external names, as discussed in @secref["extnames"]. @subsection{Mixins and Interfaces} -Using @scheme[implementation?], @scheme[picky-mixin] could require -that its base class implements @scheme[grower-interface], which could -be implemented by both @scheme[fish%] and @scheme[person%]: +Using @racket[implementation?], @racket[picky-mixin] could require +that its base class implements @racket[grower-interface], which could +be implemented by both @racket[fish%] and @racket[person%]: -@schemeblock[ +@racketblock[ (define grower-interface (interface () grow)) (define (picky-mixin %) (unless (implementation? % grower-interface) @@ -518,14 +518,14 @@ be implemented by both @scheme[fish%] and @scheme[person%]: Another use of interfaces with a mixin is to tag classes generated by the mixin, so that instances of the mixin can be recognized. In other -words, @scheme[is-a?] cannot work on a mixin represented as a +words, @racket[is-a?] cannot work on a mixin represented as a function, but it can recognize an interface (somewhat like a @defterm{specialization interface}) that is consistently implemented -by the mixin. For example, classes generated by @scheme[picky-mixin] -could be tagged with @scheme[picky-interface], enabling the -@scheme[is-picky?] predicate: +by the mixin. For example, classes generated by @racket[picky-mixin] +could be tagged with @racket[picky-interface], enabling the +@racket[is-picky?] predicate: -@schemeblock[ +@racketblock[ (define picky-interface (interface ())) (define (picky-mixin %) (unless (implementation? % grower-interface) @@ -535,11 +535,11 @@ could be tagged with @scheme[picky-interface], enabling the (is-a? o picky-interface)) ] -@subsection{The @scheme[mixin] Form} +@subsection{The @racket[mixin] Form} -To codify the @scheme[lambda]-plus-@scheme[class] pattern for +To codify the @racket[lambda]-plus-@racket[class] pattern for implementing mixins, including the use of interfaces for the domain -and range of the mixin, the class system provides a @scheme[mixin] +and range of the mixin, the class system provides a @racket[mixin] macro: @specform[ @@ -547,14 +547,14 @@ macro: decl-or-expr ...) ] -The first set of @scheme[interface-expr]s determines the domain of the +The first set of @racket[interface-expr]s determines the domain of the mixin, and the second set determines the range. That is, the expansion is a function that tests whether a given base class implements the -first sequence of @scheme[interface-expr]s and produces a class that -implements the second sequence of @scheme[interface-expr]s. Other -requirements, such as the presence of @scheme[inherit]ed methods in -the superclass, are then checked for the @scheme[class] expansion of -the @scheme[mixin] form. +first sequence of @racket[interface-expr]s and produces a class that +implements the second sequence of @racket[interface-expr]s. Other +requirements, such as the presence of @racket[inherit]ed methods in +the superclass, are then checked for the @racket[class] expansion of +the @racket[mixin] form. Mixins not only override methods and introduce public methods, they can also augment methods, introduce augment-only methods, add an @@ -565,12 +565,12 @@ the things that a class can do (see @secref["inner"]). @subsection[#:tag "parammixins"]{Parameterized Mixins} As noted in @secref["extnames"], external names can be bound with -@scheme[define-member-name]. This facility allows a mixin to be +@racket[define-member-name]. This facility allows a mixin to be generalized with respect to the methods that it defines and uses. For -example, we can parameterize @scheme[hungry-mixin] with respect to the -external member key for @scheme[eat]: +example, we can parameterize @racket[hungry-mixin] with respect to the +external member key for @racket[eat]: -@schemeblock[ +@racketblock[ (define (make-hungry-mixin eat-method-key) (define-member-name eat eat-method-key) (mixin () () (super-new) @@ -580,18 +580,18 @@ external member key for @scheme[eat]: To obtain a particular hungry-mixin, we must apply this function to a member key that refers to a suitable -@scheme[eat] method, which we can obtain using @scheme[member-name-key]: +@racket[eat] method, which we can obtain using @racket[member-name-key]: -@schemeblock[ +@racketblock[ ((make-hungry-mixin (member-name-key eat)) (class object% .... (define/public (eat x) 'yum))) ] -Above, we apply @scheme[hungry-mixin] to an anonymous class that provides -@scheme[eat], but we can also combine it with a class that provides -@scheme[chomp], instead: +Above, we apply @racket[hungry-mixin] to an anonymous class that provides +@racket[eat], but we can also combine it with a class that provides +@racket[chomp], instead: -@schemeblock[ +@racketblock[ ((make-hungry-mixin (member-name-key chomp)) (class object% .... (define/public (chomp x) 'yum))) ] @@ -603,8 +603,8 @@ Above, we apply @scheme[hungry-mixin] to an anonymous class that provides A @defterm{trait} is similar to a mixin, in that it encapsulates a set of methods to be added to a class. A trait is different from a mixin in that its individual methods can be manipulated with trait operators -such as @scheme[trait-sum] (merge the methods of two traits), @scheme[trait-exclude] -(remove a method from a trait), and @scheme[trait-alias] (add a copy of a +such as @racket[trait-sum] (merge the methods of two traits), @racket[trait-exclude] +(remove a method from a trait), and @racket[trait-alias] (add a copy of a method with a new name; do not redirect any calls to the old name). The practical difference between mixins and traits is that two traits @@ -614,28 +614,28 @@ programmer must explicitly resolve the collision, usually by aliasing methods, excluding methods, and merging a new trait that uses the aliases. -Suppose our @scheme[fish%] programmer wants to define two class -extensions, @scheme[spots] and @scheme[stripes], each of which -includes a @scheme[get-color] method. The fish's spot color should not +Suppose our @racket[fish%] programmer wants to define two class +extensions, @racket[spots] and @racket[stripes], each of which +includes a @racket[get-color] method. The fish's spot color should not override the stripe color nor vice-versa; instead, a -@scheme[spots+stripes-fish%] should combine the two colors, which is -not possible if @scheme[spots] and @scheme[stripes] are implemented as -plain mixins. If, however, @scheme[spots] and @scheme[stripes] are +@racket[spots+stripes-fish%] should combine the two colors, which is +not possible if @racket[spots] and @racket[stripes] are implemented as +plain mixins. If, however, @racket[spots] and @racket[stripes] are implemented as traits, they can be combined. First, we alias -@scheme[get-color] in each trait to a non-conflicting name. Second, -the @scheme[get-color] methods are removed from both and the traits +@racket[get-color] in each trait to a non-conflicting name. Second, +the @racket[get-color] methods are removed from both and the traits with only aliases are merged. Finally, the new trait is used to create -a class that introduces its own @scheme[get-color] method based on the -two aliases, producing the desired @scheme[spots+stripes] extension. +a class that introduces its own @racket[get-color] method based on the +two aliases, producing the desired @racket[spots+stripes] extension. @subsection{Traits as Sets of Mixins} -One natural approach to implementing traits in PLT Scheme is as a set +One natural approach to implementing traits in Racket is as a set of mixins, with one mixin per trait method. For example, we might attempt to define the spots and stripes traits as follows, using association lists to represent sets: -@schemeblock[ +@racketblock[ (define spots-trait (list (cons 'get-color (lambda (%) (class % (super-new) @@ -648,19 +648,19 @@ association lists to represent sets: 'red)))))) ] -A set representation, such as the above, allows @scheme[trait-sum] and -@scheme[trait-exclude] as simple manipulations; unfortunately, it does -not support the @scheme[trait-alias] operator. Although a mixin can be +A set representation, such as the above, allows @racket[trait-sum] and +@racket[trait-exclude] as simple manipulations; unfortunately, it does +not support the @racket[trait-alias] operator. Although a mixin can be duplicated in the association list, the mixin has a fixed method name, -e.g., @scheme[get-color], and mixins do not support a method-rename -operation. To support @scheme[trait-alias], we must parameterize the -mixins over the external method name in the same way that @scheme[eat] +e.g., @racket[get-color], and mixins do not support a method-rename +operation. To support @racket[trait-alias], we must parameterize the +mixins over the external method name in the same way that @racket[eat] was parameterized in @secref["parammixins"]. -To support the @scheme[trait-alias] operation, @scheme[spots-trait] +To support the @racket[trait-alias] operation, @racket[spots-trait] should be represented as: -@schemeblock[ +@racketblock[ (define spots-trait (list (cons (member-name-key get-color) (lambda (get-color-key %) @@ -669,11 +669,11 @@ should be represented as: (define/public (get-color) 'black)))))) ] -When the @scheme[get-color] method in @scheme[spots-trait] is aliased -to @scheme[get-trait-color] and the @scheme[get-color] method is +When the @racket[get-color] method in @racket[spots-trait] is aliased +to @racket[get-trait-color] and the @racket[get-color] method is removed, the resulting trait is the same as -@schemeblock[ +@racketblock[ (list (cons (member-name-key get-trait-color) (lambda (get-color-key %) (define-member-name get-color get-color-key) @@ -681,28 +681,28 @@ removed, the resulting trait is the same as (define/public (get-color) 'black))))) ] -To apply a trait @scheme[_T] to a class @scheme[_C] and obtain a derived -class, we use @scheme[((trait->mixin _T) _C)]. The @scheme[trait->mixin] -function supplies each mixin of @scheme[_T] with the key for the mixin's -method and a partial extension of @scheme[_C]: +To apply a trait @racket[_T] to a class @racket[_C] and obtain a derived +class, we use @racket[((trait->mixin _T) _C)]. The @racket[trait->mixin] +function supplies each mixin of @racket[_T] with the key for the mixin's +method and a partial extension of @racket[_C]: -@schemeblock[ +@racketblock[ (define ((trait->mixin T) C) (foldr (lambda (m %) ((cdr m) (car m) %)) C T)) ] Thus, when the trait above is combined with other traits and then -applied to a class, the use of @scheme[get-color] becomes a reference -to the external name @scheme[get-trait-color]. +applied to a class, the use of @racket[get-color] becomes a reference +to the external name @racket[get-trait-color]. @subsection{Inherit and Super in Traits} -This first implementation of traits supports @scheme[trait-alias], and it +This first implementation of traits supports @racket[trait-alias], and it supports a trait method that calls itself, but it does not support trait methods that call each other. In particular, suppose that a spot-fish's market value depends on the color of its spots: -@schemeblock[ +@racketblock[ (define spots-trait (list (cons (member-name-key get-color) ....) (cons (member-name-key get-price) @@ -712,19 +712,19 @@ This first implementation of traits supports @scheme[trait-alias], and it .... (get-color) ....)))))) ] -In this case, the definition of @scheme[spots-trait] fails, because -@scheme[get-color] is not in scope for the @scheme[get-price] +In this case, the definition of @racket[spots-trait] fails, because +@racket[get-color] is not in scope for the @racket[get-price] mixin. Indeed, depending on the order of mixin application when the -trait is applied to a class, the @scheme[get-color] method may not be -available when @scheme[get-price] mixin is applied to the class. -Therefore adding an @scheme[(inherit get-color)] declaration to the -@scheme[get-price] mixin does not solve the problem. +trait is applied to a class, the @racket[get-color] method may not be +available when @racket[get-price] mixin is applied to the class. +Therefore adding an @racket[(inherit get-color)] declaration to the +@racket[get-price] mixin does not solve the problem. -One solution is to require the use of @scheme[(send this get-color)] in -methods such as @scheme[get-price]. This change works because -@scheme[send] always delays the method lookup until the method call is +One solution is to require the use of @racket[(send this get-color)] in +methods such as @racket[get-price]. This change works because +@racket[send] always delays the method lookup until the method call is evaluated. The delayed lookup is more expensive than a direct call, -however. Worse, it also delays checking whether a @scheme[get-color] method +however. Worse, it also delays checking whether a @racket[get-color] method even exists. A second, effective, and efficient solution is to change the encoding @@ -732,9 +732,9 @@ of traits. Specifically, we represent each method as a pair of mixins: one that introduces the method and one that implements it. When a trait is applied to a class, all of the method-introducing mixins are applied first. Then the method-implementing mixins can use -@scheme[inherit] to directly access any introduced method. +@racket[inherit] to directly access any introduced method. -@schemeblock[ +@racketblock[ (define spots-trait (list (list (local-member-name-key get-color) (lambda (get-color get-price %) .... @@ -754,30 +754,30 @@ applied first. Then the method-implementing mixins can use .... (get-color) ....)))))) ] -With this trait encoding, @scheme[trait-alias] adds a new method with +With this trait encoding, @racket[trait-alias] adds a new method with a new name, but it does not change any references to the old method. -@subsection{The @scheme[trait] Form} +@subsection{The @racket[trait] Form} The general-purpose trait pattern is clearly too complex for a programmer to use directly, but it is easily codified in a -@scheme[trait] macro: +@racket[trait] macro: @specform[ (trait trait-clause ...) ] -The @scheme[id]s in the optional @scheme[inherit] clause are available for direct -reference in the method @scheme[expr]s, and they must be supplied +The @racket[id]s in the optional @racket[inherit] clause are available for direct +reference in the method @racket[expr]s, and they must be supplied either by other traits or the base class to which the trait is ultimately applied. Using this form in conjunction with trait operators such as -@scheme[trait-sum], @scheme[trait-exclude], @scheme[trait-alias], and -@scheme[trait->mixin], we can implement @scheme[spots-trait] and -@scheme[stripes-trait] as desired. +@racket[trait-sum], @racket[trait-exclude], @racket[trait-alias], and +@racket[trait->mixin], we can implement @racket[spots-trait] and +@racket[stripes-trait] as desired. -@schemeblock[ +@racketblock[ (define spots-trait (trait (define/public (get-color) 'black) @@ -804,26 +804,26 @@ Using this form in conjunction with trait operators such as @; ---------------------------------------------------------------------- @; Set up uses of contract forms below -@(class-eval '(require scheme/contract)) +@(class-eval '(require racket/contract)) @section{Class Contracts} As classes are values, they can flow across contract boundaries, and we may wish to protect parts of a given class with contracts. For this, -the @scheme[class/c] form is used. The @scheme[class/c] form has many +the @racket[class/c] form is used. The @racket[class/c] form has many subforms, which describe two types of contracts on fields and methods: those that affect uses via instantiated objects and those that affect subclasses. @subsection{External Class Contracts} -In its simplest form, @scheme[class/c] protects the public fields and methods +In its simplest form, @racket[class/c] protects the public fields and methods of objects instantiated from the contracted class. There is also an -@scheme[object/c] form that can be used to similarly protect the public fields +@racket[object/c] form that can be used to similarly protect the public fields and methods of a particular object. Take the following definition of -@scheme[animal%], which uses a public field for its @scheme[size] attribute: +@racket[animal%], which uses a public field for its @racket[size] attribute: -@schemeblock[ +@racketblock[ (define animal% (class object% (super-new) @@ -831,14 +831,14 @@ and methods of a particular object. Take the following definition of (define/public (eat food) (set! size (+ size (get-field size food))))))] -For any instantiated @scheme[animal%], accessing the @scheme[size] field -should return a positive number. Also, if the @scheme[size] field is set, -it should be assigned a positive number. Finally, the @scheme[eat] method -should receive an argument which is an object with a @scheme[size] field +For any instantiated @racket[animal%], accessing the @racket[size] field +should return a positive number. Also, if the @racket[size] field is set, +it should be assigned a positive number. Finally, the @racket[eat] method +should receive an argument which is an object with a @racket[size] field that contains a positive number. To ensure these conditions, we will define -the @scheme[animal%] class with an appropriate contract: +the @racket[animal%] class with an appropriate contract: -@schemeblock[ +@racketblock[ (define positive/c (and/c number? positive?)) (define edible/c (object/c (field [size positive/c]))) (define/contract animal% @@ -865,10 +865,10 @@ the @scheme[animal%] class with an appropriate contract: (define/public (eat food) (set! size (+ size (get-field size food)))))))] -Here we use @scheme[->m] to describe the behavior of @scheme[eat] since we -do not need to describe any requirements for the @scheme[this] parameter. +Here we use @racket[->m] to describe the behavior of @racket[eat] since we +do not need to describe any requirements for the @racket[this] parameter. Now that we have our contracted class, we can see that the contracts -on both @scheme[size] and @scheme[eat] are enforced: +on both @racket[size] and @racket[eat] are enforced: @interaction[ #:eval class-eval @@ -894,10 +894,10 @@ crosses the contract boundary. Unlike external method contracts, external field contracts are always enforced for clients of subclasses, since fields cannot be overridden or shadowed. -Second, these contracts do not restrict subclasses of @scheme[animal%] +Second, these contracts do not restrict subclasses of @racket[animal%] in any way. Fields and methods that are inherited and used by subclasses are not checked by these contracts, and uses of the superclass's methods -via @scheme[super] are also unchecked. The following example illustrates +via @racket[super] are also unchecked. The following example illustrates both caveats: @def+int[ @@ -915,9 +915,9 @@ both caveats: @subsection{Internal Class Contracts} -Notice that retrieving the @scheme[size] field from the object -@scheme[elephant] blames @scheme[animal%] for the contract violation. -This blame is correct, but unfair to the @scheme[animal%] class, +Notice that retrieving the @racket[size] field from the object +@racket[elephant] blames @racket[animal%] for the contract violation. +This blame is correct, but unfair to the @racket[animal%] class, as we have not yet provided it with a method for protecting itself from subclasses. To this end we add internal class contracts, which provide directives to subclasses for how they may access and override @@ -927,10 +927,10 @@ invariants may be broken internally by subclasses but should be enforced for external uses via instantiated objects. As a simple example of what kinds of protection are available, we provide -an example aimed at the @scheme[animal%] class that uses all the applicable +an example aimed at the @racket[animal%] class that uses all the applicable forms: -@schemeblock[ +@racketblock[ (class/c (field [size positive/c]) (inherit-field [size positive/c]) [eat (->m edible/c void?)] @@ -938,23 +938,23 @@ forms: (super [eat (->m edible/c void?)]) (override [eat (->m edible/c void?)]))] -This class contract not only ensures that objects of class @scheme[animal%] -are protected as before, but also ensure that subclasses of @scheme[animal%] -only store appropriate values within the @scheme[size] field and use -the implementation of @scheme[size] from @scheme[animal%] appropriately. +This class contract not only ensures that objects of class @racket[animal%] +are protected as before, but also ensure that subclasses of @racket[animal%] +only store appropriate values within the @racket[size] field and use +the implementation of @racket[size] from @racket[animal%] appropriately. These contract forms only affect uses within the class hierarchy, and only for method calls that cross the contract boundary. -That means that @scheme[inherit] will only affect subclass uses of a method -until a subclass overrides that method, and that @scheme[override] only +That means that @racket[inherit] will only affect subclass uses of a method +until a subclass overrides that method, and that @racket[override] only affects calls from the superclass into a subclass's overriding implementation -of that method. Since these only affect internal uses, the @scheme[override] +of that method. Since these only affect internal uses, the @racket[override] form does not automatically enter subclasses into obligations when objects of -those classes are used. Also, use of @scheme[override] only makes sense, and +those classes are used. Also, use of @racket[override] only makes sense, and thus can only be used, for methods where no Beta-style augmentation has taken place. The following example shows this difference: -@schemeblock[ +@racketblock[ (define/contract sloppy-eater% (class/c [eat (->m edible/c edible/c)]) (begin @@ -1008,24 +1008,24 @@ place. The following example shows this difference: (send pig gulp (list slop1 slop2 slop3))] In addition to the internal class contract forms shown here, there are -similar forms for Beta-style augmentable methods. The @scheme[inner] +similar forms for Beta-style augmentable methods. The @racket[inner] form describes to the subclass what is expected from augmentations of -a given method. Both @scheme[augment] and @scheme[augride] tell the +a given method. Both @racket[augment] and @racket[augride] tell the subclass that the given method is a method which has been augmented and that any calls to the method in the subclass will dynamically dispatch to the appropriate implementation in the superclass. Such calls will be checked according to the given contract. The two forms -differ in that use of @scheme[augment] signifies that subclasses can -augment the given method, whereas use of @scheme[augride] signifies that +differ in that use of @racket[augment] signifies that subclasses can +augment the given method, whereas use of @racket[augride] signifies that subclasses must override the current augmentation instead. This means that not all forms can be used at the same time. Only one of the -@scheme[override], @scheme[augment], and @scheme[augride] forms can be used +@racket[override], @racket[augment], and @racket[augride] forms can be used for a given method, and none of these forms can be used if the given method -has been finalized. In addition, @scheme[super] can be specified for a given -method only if @scheme[augride] or @scheme[override] can be specified. -Similarly, @scheme[inner] can be specified only if @scheme[augment] or -@scheme[augride] can be specified. +has been finalized. In addition, @racket[super] can be specified for a given +method only if @racket[augride] or @racket[override] can be specified. +Similarly, @racket[inner] can be specified only if @racket[augment] or +@racket[augride] can be specified. @; ---------------------------------------------------------------------- diff --git a/collects/scribblings/guide/compile.scrbl b/collects/scribblings/guide/compile.scrbl index 0950f5d7e8..eb87632864 100644 --- a/collects/scribblings/guide/compile.scrbl +++ b/collects/scribblings/guide/compile.scrbl @@ -4,57 +4,43 @@ @title[#:tag "compile"]{Compilation and Configuration} -So far, we have talked about three main PLT Scheme executables: +So far in this guide, we have mainly discussed DrRacket and +@exec{racket} (and @exec{gracket}). The main additional executable is +@exec{raco}, which is short for ``@bold{Ra}cket @bold{co}mmand.'' The +@exec{raco} program provides a command-line interface to many +additional tools for compiling Racket programs and maintaining a +Racket installation. @itemize[ - @item{DrScheme, which is the development environment.} + @item{@exec{raco make} compiles Racket source to bytecode. - @item{@exec{mzscheme}, which is the console-based virtual machine for - running PLT Scheme programs (and that can be used as a - development environment in interactive mode);} - - @item{@exec{mred}, which is like @exec{mzscheme}, but for GUI - applications.} - -] - -Three more executables help in compiling PLT Scheme programs and in -maintaining a PLT Scheme installation: - -@itemize[ - - @item{@exec{mzc} is a command-line tool for miscellaneous tasks, such - as compiling Scheme source to bytecode, generating executables, and - building distribution packages, and compiling C-implemented - extensions to work with the run-time system. The @exec{mzc} is - described in @other-manual['(lib - "scribblings/mzc/mzc.scrbl")]. - - For example, if you have a program @filepath{take-over-world.ss} and + For example, if you have a program @filepath{take-over-world.rkt} and you'd like to compile it to bytecode, along with all of its dependencies, so that it loads more quickly, then run - @commandline{mzc take-over-the-world.ss}} + @commandline{raco make take-over-the-world.rkt}} - @item{@exec{setup-plt} is a command-line tool for managing a PLT - Scheme installation, including manually installed packages. The - @exec{setup-plt} tool is described in @other-manual['(lib - "scribblings/setup-plt/setup-plt.scrbl")]. + + @item{@exec{raco setup} manages a Racket installation, including + manually installed packages. For example, if you create your own library @techlink{collection} called @filepath{take-over}, and you'd like to build all bytecode and documentation for the collection, then run - @commandline{setup-plt -l take-over}} + @commandline{raco setup -l take-over}} - @item{@exec{planet} is a command-line tool for managing packages that - are normally downloaded automatically, on demand. The @exec{planet} - tool is described in @other-manual['(lib "planet/planet.scrbl")]. + + @item{@exec{raco planet} manages packages that are normally + downloaded automatically, on demand. For example, if you'd like to see a list of @|PLaneT| packages that are currently installed, then run - @commandline{planet show}} + @commandline{raco planet show}} ] + +For more information on @exec{raco}, see @other-manual['(lib +"scribblings/mzc/mzc.scrbl")]. diff --git a/collects/scribblings/guide/control.scrbl b/collects/scribblings/guide/control.scrbl index 4a1e9ad7e4..32d1b85bcc 100644 --- a/collects/scribblings/guide/control.scrbl +++ b/collects/scribblings/guide/control.scrbl @@ -7,7 +7,7 @@ @title[#:tag "control" #:style 'toc]{Exceptions and Control} -Scheme provides an especially rich set of control operations---not +Racket provides an especially rich set of control operations---not only operations for raising and catching exceptions, but also operations for grabbing and restoring portions of a computation. @@ -27,22 +27,22 @@ computation. (car 17) ] -To catch an exception, use the @scheme[with-handlers] form: +To catch an exception, use the @racket[with-handlers] form: @specform[ (with-handlers ([predicate-expr handler-expr] ...) body ...+) ]{} -Each @scheme[_predicate-expr] in a handler determines a kind of -exception that is caught by the @scheme[with-handlers] form, and the +Each @racket[_predicate-expr] in a handler determines a kind of +exception that is caught by the @racket[with-handlers] form, and the value representing the exception is passed to the handler procedure -produced by @scheme[_handler-expr]. The result of the -@scheme[_handler-expr] is the result of the @scheme[with-handlers] +produced by @racket[_handler-expr]. The result of the +@racket[_handler-expr] is the result of the @racket[with-handlers] expression. For example, a divide-by-zero error raises an instance of the -@scheme[exn:fail:contract:divide-by-zero] structure type: +@racket[exn:fail:contract:divide-by-zero] structure type: @interaction[ (with-handlers ([exn:fail:contract:divide-by-zero? @@ -53,9 +53,9 @@ For example, a divide-by-zero error raises an instance of the (car 17)) ] -The @scheme[error] function is one way to raise your own exception. It +The @racket[error] function is one way to raise your own exception. It packages an error message and other information into an -@scheme[exn:fail] structure: +@racket[exn:fail] structure: @interaction[ (error "crash!") @@ -63,11 +63,11 @@ packages an error message and other information into an (error "crash!")) ] -The @scheme[exn:fail:contract:divide-by-zero] and @scheme[exn:fail] -structure types are sub-types of the @scheme[exn] structure +The @racket[exn:fail:contract:divide-by-zero] and @racket[exn:fail] +structure types are sub-types of the @racket[exn] structure type. Exceptions raised by core forms and functions always raise an -instance of @scheme[exn] or one of its sub-types, but an exception -does not have to be represented by a structure. The @scheme[raise] +instance of @racket[exn] or one of its sub-types, but an exception +does not have to be represented by a structure. The @racket[raise] function lets you raise any value as an exception: @interaction[ @@ -78,7 +78,7 @@ function lets you raise any value as an exception: (/ 1 0)) ] -Multiple @scheme[_predicate-expr]s in a @scheme[with-handlers] form +Multiple @racket[_predicate-expr]s in a @racket[with-handlers] form let you handle different kinds of exceptions in different ways. The predicates are tried in order, and if none of them match, then the exception is propagated to enclosing contexts. @@ -95,7 +95,7 @@ exception is propagated to enclosing contexts. (always-fail -3)) ] -Using @scheme[(lambda (v) #t)] as a predicate captures all exceptions, of course: +Using @racket[(lambda (v) #t)] as a predicate captures all exceptions, of course: @interaction[ (with-handlers ([(lambda (v) #t) (lambda (v) 'oops)]) @@ -104,9 +104,9 @@ Using @scheme[(lambda (v) #t)] as a predicate captures all exceptions, of course Capturing all exceptions is usually a bad idea, however. If the user types Ctl-C in a terminal window or clicks the @onscreen{Stop} button -in DrScheme to interrupt a computation, then normally the -@scheme[exn:break] exception should not be caught. To catch only -exceptions that represent errors, use @scheme[exn:fail?] as the +in DrRacket to interrupt a computation, then normally the +@racket[exn:break] exception should not be caught. To catch only +exceptions that represent errors, use @racket[exn:fail?] as the predicate: @interaction[ @@ -134,7 +134,7 @@ the way out if the expression is never caught: But if control escapes ``all the way out,'' why does the @tech{REPL} keep going after an error is printed? You might think that it's because the @tech{REPL} wraps every interaction in a -@scheme[with-handlers] form that catches all exceptions, but that's +@racket[with-handlers] form that catches all exceptions, but that's not quite the reason. The actual reason is that the @tech{REPL} wraps the interaction with a @@ -145,11 +145,11 @@ nearest enclosing prompt. More precisely, each prompt has a @deftech{prompt tag}, and there is a designated @deftech{default prompt tag} that the uncaught-exception handler uses to @tech{abort}. -The @scheme[call-with-continuation-prompt] function installs a prompt +The @racket[call-with-continuation-prompt] function installs a prompt with a given @tech{prompt tag}, and then it evaluates a given thunk -under the prompt. The @scheme[default-continuation-prompt-tag] +under the prompt. The @racket[default-continuation-prompt-tag] function returns the @tech{default prompt tag}. The -@scheme[abort-current-continuation] function escapes to the nearest +@racket[abort-current-continuation] function escapes to the nearest enclosing prompt that has a given @tech{prompt tag}. @interaction[ @@ -165,13 +165,13 @@ enclosing prompt that has a given @tech{prompt tag}. (default-continuation-prompt-tag))) ] -In @scheme[escape] above, the value @scheme[v] is wrapped in a +In @racket[escape] above, the value @racket[v] is wrapped in a procedure that is called after escaping to the enclosing prompt. @tech{Prompts} and @tech{aborts} look very much like exception handling and raising. Indeed, prompts and aborts are essentially a -more primitive form of exceptions, and @scheme[with-handlers] and -@scheme[raise] are implemented in terms of prompts and aborts. The +more primitive form of exceptions, and @racket[with-handlers] and +@racket[raise] are implemented in terms of prompts and aborts. The power of the more primitive forms is related to the word ``continuation'' in the operator names, as we discuss in the next section. @@ -182,7 +182,7 @@ section. A @deftech{continuation} is a value that encapsulates a piece of an -expression context. The @scheme[call-with-composable-continuation] +expression context. The @racket[call-with-composable-continuation] function captures the @deftech{current continuation} starting outside the current function call and running up to the nearest enclosing prompt. (Keep in mind that each @tech{REPL} interaction is implicitly @@ -190,31 +190,31 @@ wrapped in a prompt.) For example, in -@schemeblock[ +@racketblock[ (+ 1 (+ 1 (+ 1 0))) ] -at the point where @scheme[0] is evaluated, the expression context +at the point where @racket[0] is evaluated, the expression context includes three nested addition expressions. We can grab that context by -changing @scheme[0] to grab the continuation before returning 0: +changing @racket[0] to grab the continuation before returning 0: @interaction[ #:eval cc-eval (define saved-k #f) (define (save-it!) (call-with-composable-continuation - (lambda (k) (code:comment @#,t{@scheme[k] is the captured continuation}) + (lambda (k) (code:comment @#,t{@racket[k] is the captured continuation}) (set! saved-k k) 0))) (+ 1 (+ 1 (+ 1 (save-it!)))) ] -The @tech{continuation} saved in @scheme[save-k] encapsulates the -program context @scheme[(+ 1 (+ 1 (+ 1 _?)))], where @scheme[_?] +The @tech{continuation} saved in @racket[save-k] encapsulates the +program context @racket[(+ 1 (+ 1 (+ 1 _?)))], where @racket[_?] represents a place to plug in a result value---because that was the -expression context when @scheme[save-it!] was called. The +expression context when @racket[save-it!] was called. The @tech{continuation} is encapsulated so that it behaves like the -function @scheme[(lambda (v) (+ 1 (+ 1 (+ 1 v))))]: +function @racket[(lambda (v) (+ 1 (+ 1 (+ 1 v))))]: @interaction[ #:eval cc-eval @@ -224,7 +224,7 @@ function @scheme[(lambda (v) (+ 1 (+ 1 (+ 1 v))))]: ] The continuation captured by -@scheme[call-with-composable-continuation] is determined dynamically, +@racket[call-with-composable-continuation] is determined dynamically, not syntactically. For example, with @interaction[ @@ -236,7 +236,7 @@ not syntactically. For example, with (sum 5) ] -the continuation in @scheme[saved-k] becomes @scheme[(lambda (x) (+ 5 +the continuation in @racket[saved-k] becomes @racket[(lambda (x) (+ 5 (+ 4 (+ 3 (+ 2 (+ 1 x))))))]: @interaction[ @@ -245,25 +245,25 @@ the continuation in @scheme[saved-k] becomes @scheme[(lambda (x) (+ 5 (saved-k 10) ] -A more traditional continuation operator in Scheme is -@scheme[call-with-current-continuation], which is often abbreviated -@scheme[call/cc]. It is like -@scheme[call-with-composable-continuation], but applying the captured +A more traditional continuation operator in Racket is +@racket[call-with-current-continuation], which is often abbreviated +@racket[call/cc]. It is like +@racket[call-with-composable-continuation], but applying the captured continuation first @tech{aborts} (to the current @tech{prompt}) before -restoring the saved continuation. In addition, Scheme systems +restoring the saved continuation. In addition, Racket systems traditionally support a single prompt at the program start, instead of allowing new prompts via -@scheme[call-with-continuation-prompt]. Continuations as in PLT Scheme +@racket[call-with-continuation-prompt]. Continuations as in Racket are sometimes called @deftech{delimited continuations}, since a program can introduce new delimiting prompts, and continuations as -captured by @scheme[call-with-composable-continuation] are sometimes +captured by @racket[call-with-composable-continuation] are sometimes called @deftech{composable continuations}, because they do not have a built-in @tech{abort}. For an example of how @tech{continuations} are useful, see @other-manual['(lib "scribblings/more/more.scrbl")]. For specific control operators that have more convenient names than the primitives -described here, see @schememodname[scheme/control]. +described here, see @racketmodname[racket/control]. @; ---------------------------------------------------------------------- diff --git a/collects/scribblings/guide/dialects.scrbl b/collects/scribblings/guide/dialects.scrbl index 0fa499f9a9..7beeb4660e 100644 --- a/collects/scribblings/guide/dialects.scrbl +++ b/collects/scribblings/guide/dialects.scrbl @@ -1,28 +1,26 @@ -#lang scribble/doc +#lang scribble/base @(require scribble/manual "guide-utils.ss") @(define r6rs @elem{R@superscript{6}RS}) @(define r5rs @elem{R@superscript{5}RS}) -@title[#:tag "dialects" #:style 'toc]{Dialects of Scheme} +@title[#:tag "dialects" #:style 'toc]{Dialects of Racket and Scheme} -PLT Scheme is one dialect of the Scheme programming language, and -there are many others. Indeed, ``Scheme'' is perhaps more of an idea -than a specific language. +We use ``Racket'' to refer to a specific dialect of the Lisp language, +and one that is based on the Scheme branch of the Lisp family. +Despite Racket's similarly to Scheme, the @hash-lang[] prefix on +modules is a particular feature of Racket, and programs that start +with @hash-lang[] are unlikely to run in other implementations of +Scheme. At the same time, programs that do not start with @hash-lang[] +do not work with the default mode of most Racket tools. -The @hash-lang[] prefix on modules is a particular feature of PLT -Scheme, and programs that start with @hash-lang[] are unlikely to run -in other implementations of Scheme. At the same time, programs that do -not start with @hash-lang[] (or another PLT Scheme module form) do not -work with the default mode of most PLT Scheme tools. - -``PLT Scheme'' is not, however, the only dialect of Scheme that is supported -by PLT Scheme tools. On the contrary, PLT Scheme tools are designed to -support multiple dialects of Scheme and even multiple languages, which -allows the PLT Scheme tool suite to serve multiple communities. PLT -Scheme also gives programmers and researchers the tools they need to -explore and create new languages. +``Racket'' is not, however, the only dialect of Lisp that is supported +by Racket tools. On the contrary, Racket tools are designed to support +multiple dialects of Lisp and even multiple languages, which allows +the Racket tool suite to serve multiple communities. Racket also gives +programmers and researchers the tools they need to explore and create +new languages. @local-table-of-contents[] @@ -39,10 +37,10 @@ Standard dialects of Scheme include the ones defined by @|r5rs| and Revised@superscript{5} Report on the Algorithmic Language Scheme}, and it is currently the most widely implemented Scheme standard. -PLT Scheme tools in their default modes do not conform to @|r5rs|, -mainly because PLT Scheme tools generally expect modules, and @|r5rs| +Racket tools in their default modes do not conform to @|r5rs|, +mainly because Racket tools generally expect modules, and @|r5rs| does not define a module system. Typical single-file @|r5rs| programs -can be converted to PLT Scheme programs by prefixing them with +can be converted to Racket programs by prefixing them with @scheme[@#,hash-lang[] @#,schememodname[r5rs]], but other Scheme systems do not recognize @scheme[@#,hash-lang[] @#,schememodname[r5rs]]. The @exec{plt-r5rs} executable (see @@ -50,106 +48,106 @@ systems do not recognize @scheme[@#,hash-lang[] conforms to the @|r5rs| standard. Aside from the module system, the syntactic forms and functions of -@|r5rs| and PLT Scheme differ. Only simple @|r5rs| become PLT Scheme -programs when prefixed with @scheme[@#,hash-lang[] scheme], and -relatively few PLT Scheme programs become @|r5rs| programs when a +@|r5rs| and Racket differ. Only simple @|r5rs| become Racket +programs when prefixed with @scheme[@#,hash-lang[] racket], and +relatively few Racket programs become @|r5rs| programs when a @hash-lang[] line is removed. Also, when mixing ``@|r5rs| modules'' -with PLT Scheme modules, beware that @|r5rs| pairs correspond to PLT -Scheme mutable pairs (as constructed with @scheme[mcons]). +with Racket modules, beware that @|r5rs| pairs correspond to +Racket mutable pairs (as constructed with @scheme[mcons]). See @other-manual['(lib "r5rs/r5rs.scrbl")] for more -information about running @|r5rs| programs with PLT Scheme. +information about running @|r5rs| programs with Racket. @subsection{@|r6rs|} ``@|r6rs|'' stands for @link["../r6rs-std/index.html"]{The Revised@superscript{6} Report on the Algorithmic Language Scheme}, -which extends @|r5rs| with a module system that is similar to the PLT -Scheme module system. +which extends @|r5rs| with a module system that is similar to the +Racket module system. When an @|r6rs| library or top-level program is prefixed with @schememetafont{#!}@schememodname[r6rs] (which is valid @|r6rs| -syntax), then it can also be used as a PLT Scheme program. This works -because @schememetafont{#!} in PLT Scheme is treated as a shorthand +syntax), then it can also be used as a Racket program. This works +because @schememetafont{#!} in Racket is treated as a shorthand for @hash-lang[] followed by a space, so @schememetafont{#!}@schememodname[r6rs] selects the @schememodname[r6rs] module language. As with @|r5rs|, however, beware -that the syntactic forms and functions of @|r6rs| differ from PLT -Scheme, and @|r6rs| pairs are mutable pairs. +that the syntactic forms and functions of @|r6rs| differ from +Racket, and @|r6rs| pairs are mutable pairs. See @other-manual['(lib "r6rs/scribblings/r6rs.scrbl")] for more -information about running @|r6rs| programs with PLT Scheme. +information about running @|r6rs| programs with Racket. @; -------------------------------------------------- -@section[#:tag "more-hash-lang"]{More PLT Schemes} +@section[#:tag "more-hash-lang"]{More Rackets} -Like ``Scheme'' itself, even ``PLT Scheme'' is more of an idea about +Like ``Scheme,'' even ``Racket'' is more of an idea about programming languages than a language in the usual sense. Macros can extend a base language (as described in @secref["macros"]), but macros and alternate parsers can construct an entirely new language from the ground up. -The @hash-lang[] line that starts a PLT Scheme module declares the -base language of the module. By ``PLT Scheme,'' we usually mean -@hash-lang[] followed by the base language @schememodname[scheme] or -@schememodname[scheme/base] (of which @schememodname[scheme] is an -extension). The PLT Scheme distribution provides additional languages, +The @hash-lang[] line that starts a Racket module declares the +base language of the module. By ``Racket,'' we usually mean +@hash-lang[] followed by the base language @racketmodname[racket] or +@racketmodname[racket/base] (of which @racketmodname[racket] is an +extension). The Racket distribution provides additional languages, including the following: @itemize[ - @item{@schememodname[typed/scheme] --- like - @schememodname[scheme], but statically typed; see + @item{@racketmodname[typed/scheme] --- like + @racketmodname[racket], but statically typed; see @other-manual['(lib "typed-scheme/scribblings/ts-guide.scrbl")]} - @item{@schememodname[lazy] --- like @schememodname[scheme/base], but + @item{@racketmodname[lazy] --- like @racketmodname[racket/base], but avoids evaluating an expression until its value is needed; see @other-manual['(lib "lazy/lazy.scrbl")]} - @item{@schememodname[frtime] --- changes evaluation in an even more + @item{@racketmodname[frtime] --- changes evaluation in an even more radical way to support reactive programming; see @other-manual['(lib "frtime/scribblings/frtime.scrbl")]} - @item{@schememodname[scribble/doc] --- a language, which looks more - like Latex than Scheme, for writing documentation; see + @item{@racketmodname[scribble/base] --- a language, which looks more + like Latex than Racket, for writing documentation; see @other-manual['(lib "scribblings/scribble/scribble.scrbl")]} ] Each of these languages is used by starting module with the language name after @hash-lang[]. For example, this source of this -document starts with @scheme[@#,hash-lang[] scribble/doc]. +document starts with @racket[@#,hash-lang[] scribble/base]. -PLT Scheme users can define their own languages. A language name maps +Racket users can define their own languages. A language name maps to its implementation through a module path by adding -@schemeidfont{/lang/reader}. For example, the language name -@schememodname[scribble/doc] is expanded to -@scheme[scribble/doc/lang/reader], which is the module that implements +@racketidfont{/lang/reader}. For example, the language name +@racketmodname[scribble/doc] is expanded to +@racket[scribble/doc/lang/reader], which is the module that implements the surface-syntax parser. The parser, in turn, generates a -@scheme[module] form, which determines the base language at the level +@racket[module] form, which determines the base language at the level of syntactic forms an functions. Some language names act as language loaders. For example, -@schememodname[s-exp] as a language uses the usual PLT Scheme parser +@racketmodname[s-exp] as a language uses the usual Racket parser for surface-syntax reading, and then it uses the module path after -@schememodname[s-exp] for the language's syntactic forms. Thus, -@scheme[@#,hash-lang[] @#,schememodname[s-exp] "mylang.ss"] parses -the module body using the normal PLT Scheme reader, by then imports +@racketmodname[s-exp] for the language's syntactic forms. Thus, +@racket[@#,hash-lang[] @#,racketmodname[s-exp] "mylang.rkt"] parses +the module body using the normal Racket reader, by then imports the initial syntax and functions for the module body from -@scheme["mylang.ss"]. Similarly, @scheme[@#,hash-lang[] -@#,schememodname[planet] _planet-path] loads a language via +@racket["mylang.rkt"]. Similarly, @racket[@#,hash-lang[] +@#,racketmodname[planet] _planet-path] loads a language via @seclink["top" #:doc '(lib "planet/planet.scrbl")]{@|PLaneT|}. @; -------------------------------------------------- @section[#:tag "teaching-langs"]{Teaching} -The @|HtDP| textbook relies on pedagogic variants of Scheme that +The @|HtDP| textbook relies on pedagogic variants of Racket that smooth the introduction of programming concepts for new programmers. The languages are documented in @other-manual['(lib "scribblings/htdp-langs/htdp-langs.scrbl")]. The @|HtDP| languages are typically not used with @hash-lang[] -prefixes, but are instead used within DrScheme by selecting the +prefixes, but are instead used within DrRacket by selecting the language from the @onscreen{Choose Language...} dialog. diff --git a/collects/scribblings/guide/for.scrbl b/collects/scribblings/guide/for.scrbl index 049452715b..594faff861 100644 --- a/collects/scribblings/guide/for.scrbl +++ b/collects/scribblings/guide/for.scrbl @@ -5,24 +5,24 @@ @title[#:tag "for"]{Iterations and Comprehensions} -The @scheme[for] family of syntactic forms support iteration over +The @racket[for] family of syntactic forms support iteration over @defterm{sequences}. Lists, vectors, strings, byte strings, input ports, and hash tables can all be used as sequences, and constructors -like @scheme[in-range] offer even more kinds of sequences. +like @racket[in-range] offer even more kinds of sequences. -Variants of @scheme[for] accumulate iteration results in different +Variants of @racket[for] accumulate iteration results in different ways, but they all have the same syntactic shape. Simplifying for -now, the syntax of @scheme[for] is +now, the syntax of @racket[for] is @specform[ (for ([id sequence-expr] ...) body ...+) ]{} -A @scheme[for] loop iterates through the sequence produced by the -@scheme[_sequence-expr]. For each element of the sequence, -@scheme[for] binds the element to @scheme[_id], and then it evaluates -the @scheme[_body]s for side effects. +A @racket[for] loop iterates through the sequence produced by the +@racket[_sequence-expr]. For each element of the sequence, +@racket[for] binds the element to @racket[_id], and then it evaluates +the @racket[_body]s for side effects. @examples[ (for ([i '(1 2 3)]) @@ -31,10 +31,10 @@ the @scheme[_body]s for side effects. (printf "~a..." i)) ] -The @scheme[for/list] variant of @scheme[for] is more Scheme-like. It -accumulates @scheme[_body] results into a list, instead of -evaluating @scheme[_body] only for side effects. In more -technical terms, @scheme[for/list] implements a @defterm{list +The @racket[for/list] variant of @racket[for] is more Racket-like. It +accumulates @racket[_body] results into a list, instead of +evaluating @racket[_body] only for side effects. In more +technical terms, @racket[for/list] implements a @defterm{list comprehension}. @examples[ @@ -44,22 +44,22 @@ comprehension}. i) ] -The full syntax of @scheme[for] accommodates multiple sequences to -iterate in parallel, and the @scheme[for*] variant nests the +The full syntax of @racket[for] accommodates multiple sequences to +iterate in parallel, and the @racket[for*] variant nests the iterations instead of running them in parallel. More variants of -@scheme[for] and @scheme[for*] accumulate @scheme[_body] results +@racket[for] and @racket[for*] accumulate @racket[_body] results in different ways. In all of these variants, predicates that prune iterations can be included along with bindings. -Before details on the variations of @scheme[for], though, it's best to +Before details on the variations of @racket[for], though, it's best to see the kinds of sequence generators that make interesting examples. @section[#:tag "sequences"]{Sequence Constructors} -The @scheme[in-range] function generates a sequence of numbers, given -an optional starting number (which defaults to @scheme[0]), a number +The @racket[in-range] function generates a sequence of numbers, given +an optional starting number (which defaults to @racket[0]), a number before which the sequences ends, and an optional step (which defaults -to @scheme[1]). +to @racket[1]). @examples[ (for ([i (in-range 3)]) @@ -74,10 +74,10 @@ to @scheme[1]). (printf " ~a " i)) ] -The @scheme[in-naturals] function is similar, except that the +The @racket[in-naturals] function is similar, except that the starting number must be an exact non-negative integer (which defaults -to @scheme[0]), the step is always @scheme[1], and there is no upper -limit. A @scheme[for] loop using just @scheme[in-naturals] will never +to @racket[0]), the step is always @racket[1], and there is no upper +limit. A @racket[for] loop using just @racket[in-naturals] will never terminate unless a body expression raises an exception or otherwise escapes. @@ -88,7 +88,7 @@ escapes. (display i))) ] -The @scheme[stop-before] and @scheme[stop-after] functions construct +The @racket[stop-before] and @racket[stop-after] functions construct a new sequence given a sequence and a predicate. The new sequence is like the given sequence, but truncated either immediately before or immediately after the first element for which the predicate returns @@ -100,8 +100,8 @@ true. (display i)) ] -Sequence constructors like @scheme[in-list], @scheme[in-vector] and -@scheme[in-string] simply make explicit the use of a list, vector, or +Sequence constructors like @racket[in-list], @racket[in-vector] and +@racket[in-string] simply make explicit the use of a list, vector, or string as a sequence. Since they raise an exception when given the wrong kind of value, and since they otherwise avoid a run-time dispatch to determine the sequence type, they enable more efficient @@ -116,9 +116,9 @@ code generation; see @secref["for-performance"] for more information. @refdetails["sequences"]{sequences} -@section{@scheme[for] and @scheme[for*]} +@section{@racket[for] and @racket[for*]} -A more complete syntax of @scheme[for] is +A more complete syntax of @racket[for] is @specform/subs[ (for (clause ...) @@ -127,8 +127,8 @@ A more complete syntax of @scheme[for] is (code:line #:when boolean-expr)]) ]{} -When multiple @scheme[[_id _sequence-expr]] clauses are provided -in a @scheme[for] form, the corresponding sequences are traversed in +When multiple @racket[[_id _sequence-expr]] clauses are provided +in a @racket[for] form, the corresponding sequences are traversed in parallel: @interaction[ @@ -137,8 +137,8 @@ parallel: (printf "Chapter ~a. ~a\n" i chapter)) ] -With parallel sequences, the @scheme[for] expression stops iterating -when any sequence ends. This behavior allows @scheme[in-naturals], +With parallel sequences, the @racket[for] expression stops iterating +when any sequence ends. This behavior allows @racket[in-naturals], which creates an infinite sequence of numbers, to be used for indexing: @@ -148,7 +148,7 @@ indexing: (printf "Chapter ~a. ~a\n" i chapter)) ] -The @scheme[for*] form, which has the same syntax as @scheme[for], +The @racket[for*] form, which has the same syntax as @racket[for], nests multiple sequences instead of running them in parallel: @interaction[ @@ -157,12 +157,12 @@ nests multiple sequences instead of running them in parallel: (printf "~a ~a\n" book chapter)) ] -Thus, @scheme[for*] is a shorthand for nested @scheme[for]s in the -same way that @scheme[let*] is a shorthand for nested @scheme[let]s. +Thus, @racket[for*] is a shorthand for nested @racket[for]s in the +same way that @racket[let*] is a shorthand for nested @racket[let]s. -The @scheme[#:when _boolean-expr] form of a @scheme[_clause] is -another shorthand. It allows the @scheme[_body]s to evaluate only -when the @scheme[_boolean-expr] produces a true value: +The @racket[#:when _boolean-expr] form of a @racket[_clause] is +another shorthand. It allows the @racket[_body]s to evaluate only +when the @racket[_boolean-expr] produces a true value: @interaction[ (for* ([book '("Guide" "Reference")] @@ -171,11 +171,11 @@ when the @scheme[_boolean-expr] produces a true value: (printf "~a ~a\n" book chapter)) ] -A @scheme[_boolean-expr] with @scheme[#:when] can refer to any of the -preceding iteration bindings. In a @scheme[for] form, this scoping +A @racket[_boolean-expr] with @racket[#:when] can refer to any of the +preceding iteration bindings. In a @racket[for] form, this scoping makes sense only if the test is nested in the iteration of the -preceding bindings; thus, bindings separated by @scheme[#:when] are -mutually nested, instead of in parallel, even with @scheme[for]. +preceding bindings; thus, bindings separated by @racket[#:when] are +mutually nested, instead of in parallel, even with @racket[for]. @interaction[ (for ([book '("Guide" "Reference" "Notes")] @@ -186,10 +186,10 @@ mutually nested, instead of in parallel, even with @scheme[for]. (printf "~a Chapter ~a. ~a\n" book i chapter)) ] -@section{@scheme[for/list] and @scheme[for*/list]} +@section{@racket[for/list] and @racket[for*/list]} -The @scheme[for/list] form, which has the same syntax as @scheme[for], -evaluates the @scheme[_body]s to obtain values that go into a +The @racket[for/list] form, which has the same syntax as @racket[for], +evaluates the @racket[_body]s to obtain values that go into a newly constructed list: @interaction[ @@ -198,8 +198,8 @@ newly constructed list: (string-append (number->string i) ". " chapter)) ] -A @scheme[#:when] clause in a @scheme[for-list] form prunes the result -list along with evaluations of the @scheme[_body]s: +A @racket[#:when] clause in a @racket[for-list] form prunes the result +list along with evaluations of the @racket[_body]s: @interaction[ (for/list ([i (in-naturals 1)] @@ -208,13 +208,13 @@ list along with evaluations of the @scheme[_body]s: chapter) ] -This pruning behavior of @scheme[#:when] is more useful with -@scheme[for/list] than @scheme[for]. Whereas a plain @scheme[when] -form normally suffices with @scheme[for], a @scheme[when] expression -form in a @scheme[for/list] would cause the result list to contain +This pruning behavior of @racket[#:when] is more useful with +@racket[for/list] than @racket[for]. Whereas a plain @racket[when] +form normally suffices with @racket[for], a @racket[when] expression +form in a @racket[for/list] would cause the result list to contain @|void-const|s instead of omitting list elements. -The @scheme[for*/list] is like @scheme[for*], nesting multiple +The @racket[for*/list] is like @racket[for*], nesting multiple iterations: @interaction[ @@ -223,23 +223,23 @@ iterations: (string-append book " " chapter)) ] -A @scheme[for*/list] form is not quite the same thing as nested -@scheme[for/list] forms. Nested @scheme[for/list]s would produce a +A @racket[for*/list] form is not quite the same thing as nested +@racket[for/list] forms. Nested @racket[for/list]s would produce a list of lists, instead of one flattened list. Much like -@scheme[#:when], then, the nesting of @scheme[for*/list] is more -useful than the nesting of @scheme[for*]. +@racket[#:when], then, the nesting of @racket[for*/list] is more +useful than the nesting of @racket[for*]. -@section{@scheme[for/and] and @scheme[for/or]} +@section{@racket[for/and] and @racket[for/or]} -The @scheme[for/and] form combines iteration results with -@scheme[and], stopping as soon as it encounters @scheme[#f]: +The @racket[for/and] form combines iteration results with +@racket[and], stopping as soon as it encounters @racket[#f]: @interaction[ (for/and ([chapter '("Intro" "Details" "Conclusion")]) (equal? chapter "Intro")) ] -The @scheme[for/or] form combines iteration results with @scheme[or], +The @racket[for/or] form combines iteration results with @racket[or], stopping as soon as it encounters a true value: @interaction[ @@ -247,14 +247,14 @@ stopping as soon as it encounters a true value: (equal? chapter "Intro")) ] -As usual, the @scheme[for*/and] and @scheme[for*/or] forms provide the +As usual, the @racket[for*/and] and @racket[for*/or] forms provide the same facility with nested iterations. -@section{@scheme[for/first] and @scheme[for/last]} +@section{@racket[for/first] and @racket[for/last]} -The @scheme[for/first] form returns the result of the first time that -the @scheme[_body]s are evaluated, skipping further iterations. -This form is most useful with a @scheme[#:when] clause. +The @racket[for/first] form returns the result of the first time that +the @racket[_body]s are evaluated, skipping further iterations. +This form is most useful with a @racket[#:when] clause. @interaction[ (for/first ([chapter '("Intro" "Details" "Conclusion" "Index")] @@ -262,11 +262,11 @@ This form is most useful with a @scheme[#:when] clause. chapter) ] -If the @scheme[_body]s are evaluated zero times, then the result -is @scheme[#f]. +If the @racket[_body]s are evaluated zero times, then the result +is @racket[#f]. -The @scheme[for/last] form runs all iterations, returning the value of -the last iteration (or @scheme[#f] if no iterations are run): +The @racket[for/last] form runs all iterations, returning the value of +the last iteration (or @racket[#f] if no iterations are run): @interaction[ (for/last ([chapter '("Intro" "Details" "Conclusion" "Index")] @@ -274,7 +274,7 @@ the last iteration (or @scheme[#f] if no iterations are run): chapter) ] -As usual, the @scheme[for*/first] and @scheme[for*/last] forms provide +As usual, the @racket[for*/first] and @racket[for*/last] forms provide the same facility with nested iterations: @interaction[ @@ -289,26 +289,26 @@ the same facility with nested iterations: (list book chapter)) ] -@section[#:tag "for/fold"]{@scheme[for/fold] and @scheme[for*/fold]} +@section[#:tag "for/fold"]{@racket[for/fold] and @racket[for*/fold]} -The @scheme[for/fold] form is a very general way to combine iteration +The @racket[for/fold] form is a very general way to combine iteration results. Its syntax is slightly different than the syntax of -@scheme[for], because accumulation variables must be declared at the +@racket[for], because accumulation variables must be declared at the beginning: -@schemeblock[ +@racketblock[ (for/fold ([_accum-id _init-expr] ...) (_clause ...) _body ...+) ] -In the simple case, only one @scheme[[_accum-id _init-expr]] is -provided, and the result of the @scheme[for/fold] is the final value -for @scheme[_accum-id], which starts out with the value of -@scheme[_init-expr]. In the @scheme[_clause]s and -@scheme[_body]s, @scheme[_accum-id] can be referenced to get its -current value, and the last @scheme[_body] provides the value of -@scheme[_accum-id] for the next iteration. +In the simple case, only one @racket[[_accum-id _init-expr]] is +provided, and the result of the @racket[for/fold] is the final value +for @racket[_accum-id], which starts out with the value of +@racket[_init-expr]. In the @racket[_clause]s and +@racket[_body]s, @racket[_accum-id] can be referenced to get its +current value, and the last @racket[_body] provides the value of +@racket[_accum-id] for the next iteration. @examples[ (for/fold ([len 0]) @@ -322,9 +322,9 @@ current value, and the last @scheme[_body] provides the value of chapter) ] -When multiple @scheme[_accum-id]s are specified, then the last -@scheme[_body] must produce multiple values, one for each -@scheme[_accum-id]. The @scheme[for/fold] expression itself produces +When multiple @racket[_accum-id]s are specified, then the last +@racket[_body] must produce multiple values, one for each +@racket[_accum-id]. The @racket[for/fold] expression itself produces multiple values for the results. @examples[ @@ -344,12 +344,12 @@ values, individual iterations of a sequence can produce multiple elements. For example, a hash table as a sequence generates two values for each iteration: a key and a value. -In the same way that @scheme[let-values] binds multiple results to -multiple identifiers, @scheme[for] can bind multiple sequence elements +In the same way that @racket[let-values] binds multiple results to +multiple identifiers, @racket[for] can bind multiple sequence elements to multiple iteration identifiers: -@margin-note{While @scheme[let] must be changed to @scheme[let-values] - to bind multiple identifier, @scheme[for] simply allows a +@margin-note{While @racket[let] must be changed to @racket[let-values] + to bind multiple identifier, @racket[for] simply allows a parenthesized list of identifiers instead of a single identifier in any clause.} @@ -358,8 +358,8 @@ to multiple iteration identifiers: (printf "~a count: ~a\n" k v)) ] -This extension to multiple-value bindings works for all @scheme[for] -variants. For example, @scheme[for*/list] nests iterations, builds a +This extension to multiple-value bindings works for all @racket[for] +variants. For example, @racket[for*/list] nests iterations, builds a list, and also works with multiple-valued sequences: @interaction[ @@ -371,26 +371,26 @@ list, and also works with multiple-valued sequences: @section[#:tag "for-performance"]{Iteration Performance} -Ideally, a @scheme[for] iteration should run as fast as a loop that +Ideally, a @racket[for] iteration should run as fast as a loop that you write by hand as a recursive-function invocation. A hand-written loop, however, is normally specific to a particular kind of data, such as lists. In that case, the hand-written loop uses selectors like -@scheme[car] and @scheme[cdr] directly, instead of handling all forms +@racket[car] and @racket[cdr] directly, instead of handling all forms of sequences and dispatching to an appropriate iterator. -The @scheme[for] forms can provide the performance of hand-written +The @racket[for] forms can provide the performance of hand-written loops when enough information is apparent about the sequences to iterate. Specifically, the clause should have one of the following -@scheme[_fast-clause] forms: +@racket[_fast-clause] forms: -@schemegrammar[ +@racketgrammar[ fast-clause [id fast-seq] [(id) fast-seq] [(id id) fast-indexed-seq] [(id ...) fast-parallel-seq] ] -@schemegrammar[ +@racketgrammar[ #:literals [in-range in-naturals in-list in-vector in-string in-bytes in-value stop-before stop-after] fast-seq (in-range expr expr) (in-range expr expr expr) @@ -405,14 +405,14 @@ fast-seq (in-range expr expr) (stop-after fast-seq predicate-expr) ] -@schemegrammar[ +@racketgrammar[ #:literals [in-indexed stop-before stop-after] fast-indexed-seq (in-indexed fast-seq) (stop-before fast-indexed-seq predicate-expr) (stop-after fast-indexed-seq predicate-expr) ] -@schemegrammar[ +@racketgrammar[ #:literals [in-parallel stop-before stop-after] fast-parallel-seq (in-parallel fast-seq ...) (stop-before fast-parallel-seq predicate-expr) @@ -436,6 +436,6 @@ The grammars above are not complete, because the set of syntactic patterns that provide good performance is extensible, just like the set of sequence values. The documentation for a sequence constructor should indicate the performance benefits of using it directly in -a @scheme[for] @scheme[_clause]. +a @racket[for] @racket[_clause]. @refdetails["for"]{iterations and comprehensions} diff --git a/collects/scribblings/guide/io.scrbl b/collects/scribblings/guide/io.scrbl index 20f2a0802d..978a1e71ae 100644 --- a/collects/scribblings/guide/io.scrbl +++ b/collects/scribblings/guide/io.scrbl @@ -4,22 +4,24 @@ scribble/eval mzlib/process "guide-utils.ss" - (for-label scheme/tcp - scheme/serialize - scheme/port)) + (for-label racket/tcp + racket/serialize + racket/port)) @(define io-eval (make-base-eval)) -@(define (twocolumn a b) +@(define (threecolumn a b c) (make-table #f (list (list (make-flow (list a)) (make-flow (list (make-paragraph (list (hspace 1))))) - (make-flow (list b)))))) + (make-flow (list b)) + (make-flow (list (make-paragraph (list (hspace 1))))) + (make-flow (list c)))))) @(interaction-eval #:eval io-eval (print-hash-table #t)) @title[#:tag "i/o" #:style 'toc]{Input and Output} -A Scheme @deftech{port} represents an input or output stream, such as +A Racket @deftech{port} represents an input or output stream, such as a file, a terminal, a TCP connection, or an in-memory string. More specifically, an @defterm{input port} represents a stream from which a program can read data, and an @defterm{output port} represents a @@ -28,7 +30,7 @@ stream for writing data. @local-table-of-contents[] @;------------------------------------------------------------------------ -@section{Varieties of Ports} +@section[#:tag "ports"]{Varieties of Ports} Various functions create various kinds of ports. Here are a few examples: @@ -36,8 +38,8 @@ examples: @itemize[ @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @item{@bold{Files:} The @scheme[open-output-file] function opens a - file for writing, and @scheme[open-input-file] opens a file for + @item{@bold{Files:} The @racket[open-output-file] function opens a + file for writing, and @racket[open-input-file] opens a file for reading. @(interaction-eval #:eval io-eval (define old-dir (current-directory))) @@ -54,9 +56,9 @@ examples: (close-input-port in) ] -If a file exists already, then @scheme[open-output-file] raises an -exception by default. Supply an option like @scheme[#:exists -'truncate] or @scheme[#:exists 'update] to re-write or update the +If a file exists already, then @racket[open-output-file] raises an +exception by default. Supply an option like @racket[#:exists +'truncate] or @racket[#:exists 'update] to re-write or update the file: @examples[ @@ -66,9 +68,9 @@ file: (close-output-port out) ] -Instead of having to match @scheme[open-input-file] and -@scheme[open-output-file] calls, most Scheme programmers will instead -use @scheme[call-with-output-file], which takes a function to call +Instead of having to match @racket[open-input-file] and +@racket[open-output-file] calls, most Racket programmers will instead +use @racket[call-with-output-file], which takes a function to call with the output port; when the function returns, the port is closed. @examples[ @@ -86,9 +88,9 @@ with the output port; when the function returns, the port is closed. @(interaction-eval #:eval io-eval (current-directory old-dir))} @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @item{@bold{Strings:} The @scheme[open-output-string] function creates - a port that accumulates data into a string, and @scheme[get-output-string] - extracts the accumulated string. The @scheme[open-input-string] function + @item{@bold{Strings:} The @racket[open-output-string] function creates + a port that accumulates data into a string, and @racket[get-output-string] + extracts the accumulated string. The @racket[open-input-string] function creates a port to read from a string. @examples[ @@ -101,10 +103,10 @@ with the output port; when the function returns, the port is closed. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @item{@bold{TCP Connections:} The @scheme[tcp-connect] function + @item{@bold{TCP Connections:} The @racket[tcp-connect] function creates both an input port and an output port for the client side of - a TCP communication. The @scheme[tcp-listen] function creates a - server, which accepts connections via @scheme[tcp-accept]. + a TCP communication. The @racket[tcp-listen] function creates a + server, which accepts connections via @racket[tcp-accept]. @examples[ #:eval io-eval @@ -121,7 +123,7 @@ with the output port; when the function returns, the port is closed. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @item{@bold{Process Pipes:} The @scheme[subprocess] function runs a new + @item{@bold{Process Pipes:} The @racket[subprocess] function runs a new process at the OS level and returns ports that correspond to the subprocess's stdin, stdout, and stderr. (The first three arguments can be certain kinds of existing ports to connect directly to the @@ -143,9 +145,9 @@ with the output port; when the function returns, the port is closed. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @item{@bold{Internal Pipes:} The @scheme[make-pipe] function returns + @item{@bold{Internal Pipes:} The @racket[make-pipe] function returns two ports that are ends of a pipe. This kind of pipe is internal to - Scheme, and not related to OS-level pipes for communicating between + Racket, and not related to OS-level pipes for communicating between different processes. @examples[ @@ -159,14 +161,14 @@ with the output port; when the function returns, the port is closed. ] @;------------------------------------------------------------------------ -@section{Default Ports} +@section[#:tag "default-ports"]{Default Ports} For most simple I/O functions, the target port is an optional argument, and the default is the @defterm{current input port} or @defterm{current output port}. Furthermore, error messages are written to the @defterm{current error port}, which is an output port. The -@scheme[current-input-port], @scheme[current-output-port], and -@scheme[current-error-port] functions return the corresponding current +@racket[current-input-port], @racket[current-output-port], and +@racket[current-error-port] functions return the corresponding current ports. @examples[ @@ -175,7 +177,7 @@ ports. (code:line (display "Hi" (current-output-port)) (code:comment @#,t{the same})) ] -If you start the @exec{mzscheme} program in a terminal, then the +If you start the @exec{racket} program in a terminal, then the current input, output, and error ports are all connected to the terminal. More generally, they are connected to the OS-level stdin, stdout, and stderr. In this guide, the examples show output written to @@ -188,8 +190,10 @@ stdout in purple, and output written to stderr in red italics. (swing-hammer) ] -The current-port functions are actually parameters, which means that -their values can be set with @scheme[parameterize]. +The current-port functions are actually @tech{parameters}, which means +that their values can be set with @racket[parameterize]. + +@margin-note{See @secref["parameterize"] for an introduction to parameters.} @examples[ #:eval io-eval @@ -202,34 +206,47 @@ their values can be set with @scheme[parameterize]. ] @; ---------------------------------------------------------------------- -@section{Reading and Writing Scheme Data} +@section[#:tag "read-write"]{Reading and Writing Racket Data} -As noted throughout @secref["datatypes"], Scheme provides two +As noted throughout @secref["datatypes"], Racket provides three ways to print an instance of a built-in value: @itemize[ - @item{ @scheme[write], which prints a value in the same way that is it - printed for a @tech{REPL} result; and } + @item{@racket[print], which prints a value in the same way that is it + printed for a @tech{REPL} result; and } - @item{@scheme[display], which tends to reduce a value to just its + @item{@racket[write], which prints a value in such a way that + @racket[read] on the output produces the value back; and } + + @item{@racket[display], which tends to reduce a value to just its character or byte content---at least for those datatypes that are primarily about characters or bytes, otherwise it falls - back to the same output as @scheme[write].} + back to the same output as @racket[write].} ] Here are some examples using each: -@twocolumn[ +@threecolumn[ + +@interaction[ +(print 1/2) +(print #\x) +(print "hello") +(print #"goodbye") +(print '|pea pod|) +(print '("i" pod)) +(print write) +] @interaction[ (write 1/2) (write #\x) (write "hello") (write #"goodbye") -(write '|dollar sign|) -(write '("alphabet" soup)) +(write '|pea pod|) +(write '("i" pod)) (write write) ] @@ -238,27 +255,35 @@ Here are some examples using each: (display #\x) (display "hello") (display #"goodbye") -(display '|dollar sign|) -(display '("alphabet" soup)) +(display '|pea pod|) +(display '("i" pod)) (display write) ] ] -The @scheme[printf] function supports simple formatting of data and -text. In the format string supplied to @scheme[printf], @litchar{~a} -@scheme[display]s the next argument, while @litchar{~s} -@scheme[write]s the next argument. +Overall, @racket[print] as corresponds to the expression layer of +Racket syntax, @racket[write] corresponds to the reader layer, and +@racket[display] roughly corresponds to the character layer. + +The @racket[printf] function supports simple formatting of data and +text. In the format string supplied to @racket[printf], @litchar{~a} +@racket[display]s the next argument, @litchar{~s} +@racket[write]s the next argument, and @litchar{~v} +@racket[print]s the next argument. @defexamples[ #:eval io-eval -(define (deliver who what) - (printf "Value for ~a: ~s" who what)) -(deliver "John" "string") +(define (deliver who when what) + (printf "Items ~a for shopper ~s: ~v" who when what)) +(deliver '("list") '("John") '("milk")) ] -An advantage of @scheme[write], as opposed to @scheme[display], is -that many forms of data can be read back in using @scheme[read]. +After using @racket[write], as opposed to @racket[display] or +@racket[print], many forms of data can be read back in using +@racket[read]. The same values @racket[print]ed can also be parsed by +@scheme[read], but the result may have extra quote forms, since a +@racket[print]ed form is meant to be read like an expression. @examples[ #:eval io-eval @@ -269,6 +294,8 @@ that many forms of data can be read back in using @scheme[read]. (read in) (write #hash((a . "apple") (b . "banana")) out) (read in) +(write '("alphabet" soup) out) +(read in) ] @; ---------------------------------------------------------------------- @@ -284,100 +311,99 @@ an output stream, and a copy can be read back in from an input stream: (read in) ] -Other structure types created by @scheme[define-struct], which offer +Other structure types created by @racket[struct], which offer more abstraction than @tech{prefab} structure types, normally -@scheme[write] either using @schemeresultfont{#<....>} notation (for -opaque structure types) or using @schemeresultfont{#(....)} vector +@racket[write] either using @racketresultfont{#<....>} notation (for +opaque structure types) or using @racketresultfont{#(....)} vector notation (for transparent structure types). In neither can can the result be read back in as an instance of the structure type: @interaction[ -(define-struct posn (x y)) -(write (make-posn 1 2)) +(struct posn (x y)) +(write (posn 1 2)) (define-values (in out) (make-pipe)) -(write (make-posn 1 2) out) +(write (posn 1 2) out) (read in) ] @interaction[ -(define-struct posn (x y) #:transparent) -(write (make-posn 1 2)) +(struct posn (x y) #:transparent) +(write (posn 1 2)) (define-values (in out) (make-pipe)) -(write (make-posn 1 2) out) +(write (posn 1 2) out) (define v (read in)) v (posn? v) (vector? v) ] -The @scheme[define-serializable-struct] form defines a structure type -that can be @scheme[serialize]d to a value that can be printed using -@scheme[write] and restored via @scheme[read]. The @scheme[serialize]d -result can be @scheme[deserialize]d to get back an instance of the +The @racket[serializable-struct] form defines a structure type +that can be @racket[serialize]d to a value that can be printed using +@racket[write] and restored via @racket[read]. The @racket[serialize]d +result can be @racket[deserialize]d to get back an instance of the original structure type. The serialization form and functions are -provided by the @schememodname[scheme/serialize] library. +provided by the @racketmodname[racket/serialize] library. @examples[ -(require scheme/serialize) -(define-serializable-struct posn (x y) #:transparent) -(deserialize (serialize (make-posn 1 2))) -(write (serialize (make-posn 1 2))) +(require racket/serialize) +(serializable-struct posn (x y) #:transparent) +(deserialize (serialize (posn 1 2))) +(write (serialize (posn 1 2))) (define-values (in out) (make-pipe)) -(write (serialize (make-posn 1 2)) out) +(write (serialize (posn 1 2)) out) (deserialize (read in)) ] -In addition to the names bound by @scheme[define-struct], -@scheme[define-serializable-struct] binds an identifier with -deserialization information, and it automatically @scheme[provide]s -the deserialization identifier from a module context. This -deserialization identifier is accessed reflectively when a value is -deserialized. +In addition to the names bound by @racket[struct], +@racket[serializable-struct] binds an identifier with deserialization +information, and it automatically @racket[provide]s the +deserialization identifier from a module context. This deserialization +identifier is accessed reflectively when a value is deserialized. @; ---------------------------------------------------------------------- -@section{Bytes, Characters, and Encodings} +@section[#:tag "encodings"]{Bytes, Characters, and Encodings} -Functions like @scheme[read-line], @scheme[read], @scheme[display], -and @scheme[write] all work in terms of @tech{characters} (which +Functions like @racket[read-line], @racket[read], @racket[display], +and @racket[write] all work in terms of @tech{characters} (which correspond to Unicode scalar values). Conceptually, they are -implemented in terms of @scheme[read-char] and @scheme[write-char]. +implemented in terms of @racket[read-char] and @racket[write-char]. More primitively, ports read and write @tech{bytes}, instead of -@tech{characters}. The functions @scheme[read-byte] and -@scheme[write-byte] read and write raw bytes. Other functions, such as -@scheme[read-bytes-line], build on top of byte operations instead of +@tech{characters}. The functions @racket[read-byte] and +@racket[write-byte] read and write raw bytes. Other functions, such as +@racket[read-bytes-line], build on top of byte operations instead of character operations. -In fact, the @scheme[read-char] and @scheme[write-char] functions are -conceptually implemented in terms of @scheme[read-byte] and -@scheme[write-byte]. When a single byte's value is less than 128, then +In fact, the @racket[read-char] and @racket[write-char] functions are +conceptually implemented in terms of @racket[read-byte] and +@racket[write-byte]. When a single byte's value is less than 128, then it corresponds to an ASCII character. Any other byte is treated as part of a UTF-8 sequence, where UTF-8 is a particular standard way of encoding Unicode scalar values in bytes (which has the nice property that ASCII characters are encoded as themselves). Thus, a single -@scheme[read-char] may call @scheme[read-byte] multiple times, and a -single @scheme[write-char] may generate multiple output bytes. +@racket[read-char] may call @racket[read-byte] multiple times, and a +single @racket[write-char] may generate multiple output bytes. -The @scheme[read-char] and @scheme[write-char] operations +The @racket[read-char] and @racket[write-char] operations @emph{always} use a UTF-8 encoding. If you have a text stream that uses a different encoding, or if you want to generate a text stream in -a different encoding, use @scheme[reencode-input-port] or -@scheme[reencode-output-port]. The @scheme[reencode-input-port] +a different encoding, use @racket[reencode-input-port] or +@racket[reencode-output-port]. The @racket[reencode-input-port] function converts an input stream from an encoding that you specify -into a UTF-8 stream; that way, @scheme[read-char] sees UTF-8 +into a UTF-8 stream; that way, @racket[read-char] sees UTF-8 encodings, even though the original used a different encoding. Beware, -however, that @scheme[read-byte] also sees the re-encoded data, +however, that @racket[read-byte] also sees the re-encoded data, instead of the original byte stream. @; ---------------------------------------------------------------------- -@section{I/O Patterns} +@section[#:tag "io-patterns"]{I/O Patterns} @(begin (define port-eval (make-base-eval)) - (interaction-eval #:eval port-eval (require scheme/port))) + (interaction-eval #:eval port-eval (require racket/port))) If you want to process individual lines of a file, then you can use -@scheme[for] with @scheme[in-lines]: +@racket[for] with @racket[in-lines]: @interaction[ (define (upcase-all in) @@ -401,8 +427,8 @@ regular expression (see @secref["regexp"]) to the stream: (has-hello? (open-input-string "goodbye")) ] -If you want to copy one port into another, use @scheme[copy-port] from -@schememodname[scheme/port], which efficiently transfers large blocks +If you want to copy one port into another, use @racket[copy-port] from +@racketmodname[racket/port], which efficiently transfers large blocks when lots of data is available, but also transfers small blocks immediately if that's all that is available: diff --git a/collects/scribblings/guide/macros.scrbl b/collects/scribblings/guide/macros.scrbl index 44e7d6029d..89dd3156c5 100644 --- a/collects/scribblings/guide/macros.scrbl +++ b/collects/scribblings/guide/macros.scrbl @@ -8,14 +8,14 @@ A @deftech{macro} is a syntactic form with an associated @deftech{transformer} that @deftech{expands} the original form into existing forms. To put it another way, a macro is an -extension to the Scheme compiler. Most of the syntactic forms of -@schememodname[scheme/base] and @schememodname[scheme] are +extension to the Racket compiler. Most of the syntactic forms of +@racketmodname[racket/base] and @racketmodname[racket] are actually macros that expand into a small set of core constructs. -Like many languages, Scheme provides pattern-based macros that +Like many languages, Racket provides pattern-based macros that make simple transformations easy to implement and reliable to -use. Scheme also supports arbitrary macro transformers that are -implemented in Scheme---or in a macro-extended variant of Scheme. +use. Racket also supports arbitrary macro transformers that are +implemented in Racket---or in a macro-extended variant of Racket. @local-table-of-contents[] diff --git a/collects/scribblings/guide/match.scrbl b/collects/scribblings/guide/match.scrbl index b0529363f9..426294d992 100644 --- a/collects/scribblings/guide/match.scrbl +++ b/collects/scribblings/guide/match.scrbl @@ -2,16 +2,16 @@ @(require scribble/manual scribble/eval "guide-utils.ss" - (for-label scheme/match)) + (for-label racket/match)) @(begin (define match-eval (make-base-eval)) - (interaction-eval #:eval match-eval (require scheme/match))) + (interaction-eval #:eval match-eval (require racket/match))) @title[#:tag "match"]{Pattern Matching} -The @scheme[match] form supports pattern matching on arbitrary Scheme -values, as opposed to functions like @scheme[regexp-match] that +The @racket[match] form supports pattern matching on arbitrary Racket +values, as opposed to functions like @racket[regexp-match] that compare regular expressions to byte and character sequences (see @secref["regexp"]). @@ -20,15 +20,15 @@ compare regular expressions to byte and character sequences (see [pattern expr ...+] ...) ] -The @scheme[match] form takes the result of @scheme[target-expr] and -tries to match each @scheme[_pattern] in order. As soon as it finds a -match, it evaluates the corresponding @scheme[_expr] sequence to -obtain the result for the @scheme[match] form. If @scheme[_pattern] +The @racket[match] form takes the result of @racket[target-expr] and +tries to match each @racket[_pattern] in order. As soon as it finds a +match, it evaluates the corresponding @racket[_expr] sequence to +obtain the result for the @racket[match] form. If @racket[_pattern] includes @deftech{pattern variables}, they are treated like wildcards, -and each variable is bound in the @scheme[_expr] to the input +and each variable is bound in the @racket[_expr] to the input fragments that it matched. -Most Scheme literal expressions can be used as patterns: +Most Racket literal expressions can be used as patterns: @interaction[ #:eval match-eval @@ -45,7 +45,7 @@ Most Scheme literal expressions can be used as patterns: [#f 'boolean]) ] -Constructors like @scheme[cons], @scheme[list], and @scheme[vector] +Constructors like @racket[cons], @racket[list], and @racket[vector] can be used to create patterns that match pairs, lists, and vectors: @interaction[ @@ -61,16 +61,16 @@ can be used to create patterns that match pairs, lists, and vectors: [(vector 1 2) 'vector]) ] -The @scheme[struct] construct matches an instance of a particular -structure type: +A constructor bound with @scheme[struct] also can be used as a pattern +constructor: @interaction[ #:eval match-eval -(define-struct shoe (size color)) -(define-struct hat (size style)) -(match (make-hat 23 'bowler) - [(struct shoe (10 'white)) "bottom"] - [(struct hat (23 'bowler)) "top"]) +(struct shoe (size color)) +(struct hat (size style)) +(match (hat 23 'bowler) + [(shoe 10 'white) "bottom"] + [(hat 23 'bowler) "top"]) ] Unquoted, non-constructor identifiers in a pattern are @tech{pattern @@ -106,8 +106,8 @@ result expression to a list of matches: [else 'other]) (match '(1 2 3 4) [(list 1 x ... 4) x]) -(match (list (make-hat 23 'bowler) (make-hat 22 'pork-pie)) - [(list (struct hat (sz styl)) ...) (apply + sz)]) +(match (list (hat 23 'bowler) (hat 22 'pork-pie)) + [(list (hat sz styl) ...) (apply + sz)]) ] Ellipses can be nested to match nested repetitions, and in that case, @@ -119,11 +119,11 @@ pattern variables can be bound to lists of lists of matches: [(list (list '! x ...) ...) x]) ] -For information on many more pattern forms, see @schememodname[scheme/match]. +For information on many more pattern forms, see @racketmodname[racket/match]. -Forms like @scheme[match-let] and @scheme[match-lambda] support +Forms like @racket[match-let] and @racket[match-lambda] support patterns in positions that otherwise must be identifiers. For example, -@scheme[match-let] generalizes @scheme[let] to a @as-index{destructing +@racket[match-let] generalizes @racket[let] to a @as-index{destructing bind}: @interaction[ @@ -132,7 +132,7 @@ bind}: (list z y x)) ] -For information on these additional forms, see @schememodname[scheme/match]. +For information on these additional forms, see @racketmodname[racket/match]. @refdetails["match"]{pattern matching} diff --git a/collects/scribblings/guide/namespaces.scrbl b/collects/scribblings/guide/namespaces.scrbl index 16a8c32228..17da05140b 100644 --- a/collects/scribblings/guide/namespaces.scrbl +++ b/collects/scribblings/guide/namespaces.scrbl @@ -1,12 +1,12 @@ #lang scribble/doc @(require scribble/manual scribble/eval - scheme/class + racket/class "guide-utils.ss") @title[#:tag "reflection" #:style 'toc]{Reflection and Dynamic Evaluation} -Scheme is a @italic{dynamic} language. It offers numerous facilities +Racket is a @italic{dynamic} language. It offers numerous facilities for loading, compiling, and even constructing new code at run time. @@ -14,16 +14,16 @@ time. @; ---------------------------------------------------------------------- -@section[#:tag "eval"]{@scheme[eval]} +@section[#:tag "eval"]{@racket[eval]} -The @scheme[eval] function takes a ``quoted'' expression or definition +The @racket[eval] function takes a ``quoted'' expression or definition and evaluates it: @interaction[ (eval '(+ 1 2)) ] -The power of @scheme[eval] that is that an expression can be +The power of @racket[eval] that is that an expression can be constructed dynamically: @interaction[ @@ -36,7 +36,7 @@ constructed dynamically: ] Of course, if we just wanted to evaluate expressions with given values -for @scheme[x] and @scheme[y], we do not need @scheme[eval]. A more +for @racket[x] and @racket[y], we do not need @racket[eval]. A more direct approach is to use first-class functions: @interaction[ @@ -46,25 +46,25 @@ direct approach is to use first-class functions: (apply-formula (lambda (x y) (+ (* x y) y))) ] -However, if expressions like @scheme[(+ x y)] and @scheme[(+ (* x y) +However, if expressions like @racket[(+ x y)] and @racket[(+ (* x y) y)] are read from a file supplied by a user, for example, then -@scheme[eval] might be appropriate. Simialrly, the @tech{REPL} reads -expressions that are typed by a user and uses @scheme[eval] to +@racket[eval] might be appropriate. Simialrly, the @tech{REPL} reads +expressions that are typed by a user and uses @racket[eval] to evaluate them. -Also, @scheme[eval] is often used directly or indirectly on whole +Also, @racket[eval] is often used directly or indirectly on whole modules. For example, a program might load a module on demand using -@scheme[dynamic-require], which is essentially a wrapper around -@scheme[eval] to dynamically load the module code. +@racket[dynamic-require], which is essentially a wrapper around +@racket[eval] to dynamically load the module code. @; ---------------------------------------- @subsection{Local Scopes} -The @scheme[eval] function cannot see local bindings in the context -where it is called. For example, calling @scheme[eval] inside an -unquoted @scheme[let] form to evaluate a formula does not make values -visible for @scheme[x] and @scheme[y]: +The @racket[eval] function cannot see local bindings in the context +where it is called. For example, calling @racket[eval] inside an +unquoted @racket[let] form to evaluate a formula does not make values +visible for @racket[x] and @racket[y]: @interaction[ (define (broken-eval-formula formula) @@ -74,29 +74,29 @@ visible for @scheme[x] and @scheme[y]: (broken-eval-formula '(+ x y)) ] -The @scheme[eval] function cannot see the @scheme[x] and @scheme[y] -bindings precisely because it is a function, and Scheme is a lexically -scoped language. Imagine if @scheme[eval] were implemented as +The @racket[eval] function cannot see the @racket[x] and @racket[y] +bindings precisely because it is a function, and Racket is a lexically +scoped language. Imagine if @racket[eval] were implemented as -@schemeblock[ +@racketblock[ (define (eval x) (eval-expanded (macro-expand x))) ] -then at the point when @scheme[eval-expanded] is called, the most -recent binding of @scheme[x] is to the expression to evaluate, not the -@scheme[let] binding in @scheme[broken-eval-formula]. Lexical scope +then at the point when @racket[eval-expanded] is called, the most +recent binding of @racket[x] is to the expression to evaluate, not the +@racket[let] binding in @racket[broken-eval-formula]. Lexical scope prevents such confusing and fragile behavior, and consequently -prevents @scheme[eval] from seeing local bindings in the context where +prevents @racket[eval] from seeing local bindings in the context where it is called. -You might imagine that even though @scheme[eval] cannot see the local -bindings in @scheme[broken-eval-formula], there must actually be a -data structure mapping @scheme[x] to @scheme[2] and @scheme[y] to -@scheme[3], and you would like a way to get that data structure. In +You might imagine that even though @racket[eval] cannot see the local +bindings in @racket[broken-eval-formula], there must actually be a +data structure mapping @racket[x] to @racket[2] and @racket[y] to +@racket[3], and you would like a way to get that data structure. In fact, no such data structure exists; the compiler is free to replace -every use of @scheme[x] with @scheme[2] at compile time, so that the -local binding of @scheme[x] does not exist in any concrete sense at +every use of @racket[x] with @racket[2] at compile time, so that the +local binding of @racket[x] does not exist in any concrete sense at run-time. Even when variables cannot be eliminated by constant-folding, normally the names of the variables can be eliminated, and the data structures that hold local values do not @@ -106,26 +106,29 @@ resemble a mapping from names to values. @subsection[#:tag "namespaces"]{Namespaces} -Since @scheme[eval] cannot see the bindings from the context where it +Since @racket[eval] cannot see the bindings from the context where it is called, another mechanism is needed to determine dynamically available bindings. A @deftech{namespace} is a first-class value that encapsulates the bindings available for dynamic evaluation. @margin-note{Informally, the term @defterm{namespace} is sometimes used interchangeably with @defterm{environment} or - @defterm{scope}. In PLT Scheme, the term @defterm{namespace} has the + @defterm{scope}. In Racket, the term @defterm{namespace} has the more specific, dynamic meaning given above, and it should not be confused with static lexical concepts.} -Some functions, such as @scheme[eval], accept an optional namespace +Some functions, such as @racket[eval], accept an optional namespace argument. More often, the namespace used by a dynamic operation is the @deftech{current namespace} as determined by the -@scheme[current-namespace] parameter. +@racket[current-namespace] @tech{parameter}. -When @scheme[eval] is used in a @tech{REPL}, the current is the one +@margin-note{See @secref["parameterize"] for an introduction to +parameters.} + +When @racket[eval] is used in a @tech{REPL}, the current is the one that the @tech{REPL} uses for evaluating expressions. That's why the -following interaction successfully accesses @scheme[x] via -@scheme[eval]: +following interaction successfully accesses @racket[x] via +@racket[eval]: @interaction[ (define x 3) @@ -133,34 +136,34 @@ following interaction successfully accesses @scheme[x] via ] In contrast, try the following a simple module and running in directly -in DrScheme's @onscreen{Module} language or supplying the file as a -command-line argument to @exec{mzscheme}: +in DrRacket or supplying the file as a command-line argument to +@exec{racket}: -@schememod[ -scheme +@racketmod[ +racket (eval '(cons 1 2)) ] This fails because the initial current namespace is empty. When you -run @exec{mzscheme} in interactive mode (see +run @exec{racket} in interactive mode (see @secref["start-interactive-mode"]), the initial namespace is -initialized with the exports of the @scheme[scheme] module, but when +initialized with the exports of the @racket[racket] module, but when you run a module directly, the initial namespace starts empty. -In general, it's a bad idea to use @scheme[eval] with whatever +In general, it's a bad idea to use @racket[eval] with whatever namespace happens to be installed. Instead, create a namespace explicitly and install it for the call to eval: -@schememod[ -scheme +@racketmod[ +racket (define ns (make-base-namespace)) (eval '(cons 1 2) ns) (code:comment @#,t{works}) ] -The @scheme[make-base-namespace] function creates a namespace that is -initialized with the exports of @scheme[scheme/base]. The later +The @racket[make-base-namespace] function creates a namespace that is +initialized with the exports of @racket[racket/base]. The later section @secref["mk-namespace"] provides more information on creating and configuring namespaces. @@ -168,40 +171,40 @@ and configuring namespaces. @subsection{Namespaces and Modules} -As with @scheme[let] bindings, lexical scope means that @scheme[eval] -cannot automatically see the definitions of a @scheme[module] in which -it is called. Unlike @scheme[let] bindings, however, Scheme provides a +As with @racket[let] bindings, lexical scope means that @racket[eval] +cannot automatically see the definitions of a @racket[module] in which +it is called. Unlike @racket[let] bindings, however, Racket provides a way to reflect a module into a @tech{namespace}. -The @scheme[module->namespace] function takes a quoted @tech{module +The @racket[module->namespace] function takes a quoted @tech{module path} and produces a namespace for evaluating expressions and -definitions as if they appears in the @scheme[module] body: +definitions as if they appears in the @racket[module] body: @interaction[ -(module m scheme/base +(module m racket/base (define x 11)) (require 'm) (define ns (module->namespace ''m)) (eval 'x ns) ] -@margin-note{The double quoting in @scheme[''m] is because @scheme['m] +@margin-note{The double quoting in @racket[''m] is because @racket['m] is a module path that refers to an interactively declared module, and -so @scheme[''m] is the quoted form of the path.} +so @racket[''m] is the quoted form of the path.} -The @scheme[module->namespace] function is mostly useful from outside +The @racket[module->namespace] function is mostly useful from outside a module, where the module's full name is known. Inside a -@scheme[module] form, however, the full name of a module may not be +@racket[module] form, however, the full name of a module may not be known, because it may depend on where the module source is location when it is eventually loaded. -From within a @scheme[module], use @scheme[define-namespace-anchor] to +From within a @racket[module], use @racket[define-namespace-anchor] to declare a reflection hook on the module, and use -@scheme[namespace-anchor->namespace] to reel in the module's +@racket[namespace-anchor->namespace] to reel in the module's namespace: -@schememod[ -scheme +@racketmod[ +racket (define-namespace-anchor a) (define ns (namespace-anchor->namespace a)) @@ -209,7 +212,7 @@ scheme (define x 1) (define y 2) -(eval '(cons x y) ns) (code:comment @#,t{produces @schemeresult[(1 . 2)]}) +(eval '(cons x y) ns) (code:comment @#,t{produces @racketresult[(1 . 2)]}) ] @@ -222,8 +225,8 @@ A @tech{namespace} encapsulates two pieces of information: @itemize[ @item{A mapping from identifiers to bindings. For example, a - namespace might map the identifier @schemeidfont{lambda} to the - @scheme[lambda] form. An ``empty'' namespace is one that maps + namespace might map the identifier @racketidfont{lambda} to the + @racket[lambda] form. An ``empty'' namespace is one that maps every identifier to an uninitialized top-level variable.} @item{A mapping from module names to module declarations and @@ -232,39 +235,39 @@ A @tech{namespace} encapsulates two pieces of information: ] The first mapping is used for evaluating expressions in a top-level -context, as in @scheme[(eval '(lambda (x) (+ x 1)))]. The second -mapping is used, for example, by @scheme[dynamic-require] to locate a -module. The call @scheme[(eval '(require scheme/base))] normally uses +context, as in @racket[(eval '(lambda (x) (+ x 1)))]. The second +mapping is used, for example, by @racket[dynamic-require] to locate a +module. The call @racket[(eval '(require racket/base))] normally uses both pieces: the identifier mapping determines the binding of -@schemeidfont{require}; if it turns out to mean @scheme[require], then -the module mapping is used to locate the @schememodname[scheme/base] +@racketidfont{require}; if it turns out to mean @racket[require], then +the module mapping is used to locate the @racketmodname[racket/base] module. -From the perspective of the core Scheme run-time system, all +From the perspective of the core Racket run-time system, all evaluation is reflective. Execution starts with an initial namespace that contains a few primitive modules, and that is further populated by loading files and modules as specified on the command line or as -supplied in the @tech{REPL}. Top-level @scheme[require] and -@scheme[define] forms adjusts the identifier mapping, and module -declarations (typically loaded on demand for a @scheme[require] form) +supplied in the @tech{REPL}. Top-level @racket[require] and +@racket[define] forms adjusts the identifier mapping, and module +declarations (typically loaded on demand for a @racket[require] form) adjust the module mapping. @; ---------------------------------------- @subsection{Creating and Installing Namespaces} -The function @scheme[make-empty-namespace] creates a new, empty +The function @racket[make-empty-namespace] creates a new, empty @tech{namespace}. Since the namespace is truly empty, it cannot at first be used to evaluate any top-level expression---not even -@scheme[(require scheme)]. In particular, +@racket[(require racket)]. In particular, -@schemeblock[ +@racketblock[ (parameterize ([current-namespace (make-empty-namespace)]) - (namespace-require 'scheme)) + (namespace-require 'racket)) ] fails, because the namespace does not include the primitive modules on -which @scheme[scheme] is built. +which @racket[racket] is built. To make a namespace useful, some modules much be @deftech{attached} from an existing namespace. Attaching a module adjusts the mapping of @@ -272,47 +275,47 @@ module names to instances by transitively copying entries (the module and all its imports) from an existing namespace's mapping. Normally, instead of just attaching the primitive modules---whose names and organization are subject to change---a higher-level module is -attached, such as @schememodname[scheme] or -@schememodname[scheme/base]. +attached, such as @racketmodname[racket] or +@racketmodname[racket/base]. -The @scheme[make-base-empty-namespace] function provides a namespace -that is empty, except that @schememodname[scheme/base] is +The @racket[make-base-empty-namespace] function provides a namespace +that is empty, except that @racketmodname[racket/base] is attached. The resulting namespace is still ``empty'' in the sense that the identifiers-to-bindings part of the namespace has no mappings; only the module mapping has been populated. Nevertheless, with an initial module mapping, further modules can be loaded. -A namespace created with @scheme[make-base-empty-namespace] is +A namespace created with @racket[make-base-empty-namespace] is suitable for many basic dynamic tasks. For example, suppose that a -@schememodfont{my-dsl} library implements a domain-specific language +@racketmodfont{my-dsl} library implements a domain-specific language in which you want to execute commands from a user-specified file. A -namespace created with @scheme[make-base-empty-namespace] is enough to +namespace created with @racket[make-base-empty-namespace] is enough to get started: -@schemeblock[ +@racketblock[ (define (run-dsl file) (parameterize ([current-namespace (make-base-empty-namespace)]) (namespace-require 'my-dsl) (load file))) ] -Note that the @scheme[parameterize] of @scheme[current-namespace] does -not affect the meaning of identifiers like @scheme[namespace-require] -within the @scheme[parameterize] body. Those identifiers obtain their +Note that the @racket[parameterize] of @racket[current-namespace] does +not affect the meaning of identifiers like @racket[namespace-require] +within the @racket[parameterize] body. Those identifiers obtain their meaning from the enclosing context (probably a module). Only expressions that are dynamic with respect to this code, such as the -content of @scheme[load]ed files, are affected by the -@scheme[parameterize]. +content of @racket[load]ed files, are affected by the +@racket[parameterize]. Another subtle point in the above example is the use of -@scheme[(namespace-require 'my-dsl)] instead of @scheme[(eval -'(require my-dsl))]. The latter would not work, because @scheme[eval] -needs to obtain a meaning for @scheme[require] in the namespace, and +@racket[(namespace-require 'my-dsl)] instead of @racket[(eval +'(require my-dsl))]. The latter would not work, because @racket[eval] +needs to obtain a meaning for @racket[require] in the namespace, and the namespace's identifier mapping is initially empty. The -@scheme[namespace-require] function, in contrast, directly imports the +@racket[namespace-require] function, in contrast, directly imports the given module into the current namespace. Starting with -@scheme[(namespace-require 'scheme/base)] would introduce a binding -for @schemeidfont{require} and make a subsequent @scheme[(eval +@racket[(namespace-require 'racket/base)] would introduce a binding +for @racketidfont{require} and make a subsequent @racket[(eval '(require my-dsl))] work. The above is better, not only because it is more compact, but also because it avoids introducing bindings that are not part of the domain-specific languages. @@ -323,88 +326,88 @@ not part of the domain-specific languages. Modules not attached to a new namespace will be loaded and instantiated afresh if they are demanded by evaluation. For example, -@schememodname[scheme/base] does not include -@schememodname[scheme/class], and loading @schememodname[scheme/class] +@racketmodname[racket/base] does not include +@racketmodname[racket/class], and loading @racketmodname[racket/class] again will create a distinct class datatype: @interaction[ -(require scheme/class) +(require racket/class) (class? object%) (class? (parameterize ([current-namespace (make-base-empty-namespace)]) - (namespace-require 'scheme/class) (code:comment @#,t{loads again}) + (namespace-require 'racket/class) (code:comment @#,t{loads again}) (eval 'object%))) ] For cases when dynamically loaded code needs to share more code and -data with its context, use the @scheme[namespace-attach-module] -function. The first argument to @scheme[namespace-attach-module] is a +data with its context, use the @racket[namespace-attach-module] +function. The first argument to @racket[namespace-attach-module] is a source namespace from which to draw a module instance; in some cases, the current namespace is known to include the module that needs to be shared: @interaction[ -(require scheme/class) +(require racket/class) (class? (let ([ns (make-base-empty-namespace)]) (namespace-attach-module (current-namespace) - 'scheme/class + 'racket/class ns) (parameterize ([current-namespace ns]) - (namespace-require 'scheme/class) (code:comment @#,t{uses attached}) + (namespace-require 'racket/class) (code:comment @#,t{uses attached}) (eval 'object%)))) ] Within a module, however, the combination of -@scheme[define-namespace-anchor] and -@scheme[namespace-anchor->empty-namespace] offers a more reliable +@racket[define-namespace-anchor] and +@racket[namespace-anchor->empty-namespace] offers a more reliable method for obtaining a source namespace: -@schememod[ -scheme/base +@racketmod[ +racket/base -(require scheme/class) +(require racket/class) (define-namespace-anchor a) (define (load-plug-in file) (let ([ns (make-base-empty-namespace)]) (namespace-attach-module (namespace-anchor->empty-namespace a) - 'scheme/class + 'racket/class ns) (parameterize ([current-namespace ns]) (dynamic-require file 'plug-in%)))) ] -The anchor bound by @scheme[namespace-attach-module] connects the +The anchor bound by @racket[namespace-attach-module] connects the run time of a module with the namespace in which a module is loaded (which might differ from the current namespace). In the above example, since the enclosing module requires -@schememodname[scheme/class], the namespace produced by -@scheme[namespace-anchor->empty-namespace] certainly contains an -instance of @schememodname[scheme/class]. Moreover, that instance is +@racketmodname[racket/class], the namespace produced by +@racket[namespace-anchor->empty-namespace] certainly contains an +instance of @racketmodname[racket/class]. Moreover, that instance is the same as the one imported into the module, so the class datatype is shared. @; ---------------------------------------------------------------------- -@section[#:tag "load"]{Scripting Evaluation and Using @scheme[load]} +@section[#:tag "load"]{Scripting Evaluation and Using @racket[load]} -Historically, Scheme and Lisp systems did not offer module +Historically, Lisp implementations did not offer module systems. Instead, large programs were built by essentially scripting the @tech{REPL} to evaluate program fragments in a particular order. While @tech{REPL} scripting turns out to be a bad way to structure programs and libraries, it is still sometimes a useful capability. -@margin-note{Describing a program via @scheme[load] interacts +@margin-note{Describing a program via @racket[load] interacts especially badly with macro-defined language extensions @cite["Flatt02"].} -The @scheme[load] function runs a @tech{REPL} script by -@scheme[read]ing S-expressions from a file, one by one, and passing -them to @scheme[eval]. If a file @filepath{place.scm} contains +The @racket[load] function runs a @tech{REPL} script by +@racket[read]ing S-expressions from a file, one by one, and passing +them to @racket[eval]. If a file @filepath{place.rkts} contains -@schemeblock[ +@racketblock[ (define city "Salt Lake City") (define state "Utah") (printf "~a, ~a\n" city state) @@ -413,86 +416,86 @@ them to @scheme[eval]. If a file @filepath{place.scm} contains then it can be loaded in a @tech{REPL}: @interaction[ -(eval:alts (load "place.scm") (begin (define city "Salt Lake City") +(eval:alts (load "place.rkts") (begin (define city "Salt Lake City") (printf "~a, Utah\n" city))) city ] -Since @scheme[load] uses @scheme[eval], however, a module like the +Since @racket[load] uses @racket[eval], however, a module like the following generally will not work---for the same reasons described in @secref["namespaces"]: -@schememod[ -scheme +@racketmod[ +racket (define there "Utopia") -(load "here.scm") +(load "here.rkts") ] The current namespace for evaluating the content of -@filepath{here.scm} is likely to be empty; in any case, you cannot get -@scheme[there] from @filepath{here.scm}. Also, any definitions in -@filepath{here.scm} will not become visible for use within the module; -after all, the @scheme[load] happens dynamically, while references to +@filepath{here.rkts} is likely to be empty; in any case, you cannot get +@racket[there] from @filepath{here.rkts}. Also, any definitions in +@filepath{here.rkts} will not become visible for use within the module; +after all, the @racket[load] happens dynamically, while references to identifiers within the module are resolved lexically, and therefore statically. -Unlike @scheme[eval], @scheme[load] does not accept a namespace -argument. To supply a namespace to @scheme[load], set the -@scheme[current-namespace] parameter. The following example evaluates -the expressions in @filepath{here.scm} using the bindings of the -@schememodname[scheme/base] module: +Unlike @racket[eval], @racket[load] does not accept a namespace +argument. To supply a namespace to @racket[load], set the +@racket[current-namespace] @tech{parameter}. The following example evaluates +the expressions in @filepath{here.rkts} using the bindings of the +@racketmodname[racket/base] module: -@schememod[ -scheme +@racketmod[ +racket (parameterize ([current-namespace (make-base-namespace)]) - (load "here.scm")) + (load "here.rkts")) ] -You can even use @scheme[namespace-anchor->namespace] to make the +You can even use @racket[namespace-anchor->namespace] to make the bindings of the enclosing module accessible for dynamic evaluation. In -the following example, when @filepath{here.scm} is @scheme[load]ed, it -can refer to @scheme[there] as well as the bindings of -@schememodname[scheme]: +the following example, when @filepath{here.rkts} is @racket[load]ed, it +can refer to @racket[there] as well as the bindings of +@racketmodname[racket]: -@schememod[ -scheme +@racketmod[ +racket (define there "Utopia") (define-namespace-anchor a) (parameterize ([current-namespace (namespace-anchor->namespace a)]) - (load "here.scm")) + (load "here.rkts")) ] -Still, if @filepath{here.scm} defines any identifiers, the definitions +Still, if @filepath{here.rkts} defines any identifiers, the definitions cannot be directly (i.e., statically) referenced by in the enclosing module. -The @schememodname[scheme/load] module language is different from -@schememodname[scheme] or @schememodname[scheme/base]. A module using -@schememodname[scheme/load] treats all of its content as dynamic, -passing each form in the module body to @scheme[eval] (using a -namespace that is initialized with @schememodname[scheme]). As a -result, uses of @scheme[eval] and @scheme[load] in the module body see +The @racketmodname[racket/load] module language is different from +@racketmodname[racket] or @racketmodname[racket/base]. A module using +@racketmodname[racket/load] treats all of its content as dynamic, +passing each form in the module body to @racket[eval] (using a +namespace that is initialized with @racketmodname[racket]). As a +result, uses of @racket[eval] and @racket[load] in the module body see the same dynamic namespace as immediate body forms. For example, if -@filepath{here.scm} contains +@filepath{here.rkts} contains -@schemeblock[ +@racketblock[ (define here "Morporkia") (define (go!) (set! here there)) ] then running -@schememod[ -scheme/load +@racketmod[ +racket/load (define there "Utopia") -(load "here.scm") +(load "here.rkts") (go!) (printf "~a\n" here) @@ -500,12 +503,12 @@ scheme/load prints ``Utopia''. -Drawbacks of using @schememodname[scheme/load] include reduced +Drawbacks of using @racketmodname[racket/load] include reduced error checking, tool support, and performance. For example, with the program -@schememod[ -scheme/load +@racketmod[ +racket/load (define good 5) (printf "running\n") @@ -513,7 +516,7 @@ good bad ] -DrScheme's @onscreen{Check Syntax} tool cannot tell that the second -@scheme[good] is a reference to the first, and the unbound reference -to @scheme[bad] is reported only at run time instead of rejected +DrRacket's @onscreen{Check Syntax} tool cannot tell that the second +@racket[good] is a reference to the first, and the unbound reference +to @racket[bad] is reported only at run time instead of rejected syntactically. diff --git a/collects/scribblings/guide/other.scrbl b/collects/scribblings/guide/other.scrbl index 998a37aaee..cfc3e9f5d7 100644 --- a/collects/scribblings/guide/other.scrbl +++ b/collects/scribblings/guide/other.scrbl @@ -4,22 +4,22 @@ @title{More Libraries} -@other-manual['(lib "scribblings/gui/gui.scrbl")] describes the PLT -Scheme graphics toolbox, whose core is implemented by the @exec{mred} +@other-manual['(lib "scribblings/gui/gui.scrbl")] describes the Racket +graphics toolbox, whose core is implemented by the @exec{gracket} executable. @other-manual['(lib "scribblings/foreign/foreign.scrbl")] describes -tools for using Scheme to access libraries that are normally used by C +tools for using Racket to access libraries that are normally used by C programs. @other-manual['(lib "web-server/scribblings/web-server.scrbl")] -describes the PLT Scheme web server, which supports servlets -implemented in Scheme. +describes the Racket web server, which supports servlets implemented +in Racket. -@link["../index.html"]{PLT Scheme Documentation} lists documentation -for many other installed libraries. Run @exec{plt-help} to find +@link["../index.html"]{Racket Documentation} lists documentation for +many other installed libraries. Run @exec{raco docs} to find documentation for libraries that are installed on your system and specific to your user account. -@link["http://planet.plt-scheme.org/"]{@|PLaneT|} offers even more -downloadable packages contributed by PLT Scheme users. +@link["http://planet.plt-racket.org/"]{@|PLaneT|} offers even more +downloadable packages contributed by Racketeers. diff --git a/collects/scribblings/guide/pattern-macros.scrbl b/collects/scribblings/guide/pattern-macros.scrbl index 908f8b60be..32e9247a11 100644 --- a/collects/scribblings/guide/pattern-macros.scrbl +++ b/collects/scribblings/guide/pattern-macros.scrbl @@ -11,52 +11,52 @@ match parts of the pattern. @; ---------------------------------------- -@section{@scheme[define-syntax-rule]} +@section{@racket[define-syntax-rule]} The simplest way to create a macro is to use -@scheme[define-syntax-rule]: +@racket[define-syntax-rule]: @specform[(define-syntax-rule pattern template)] -As a running example, consider the @scheme[swap] macro, which swaps +As a running example, consider the @racket[swap] macro, which swaps the values stored in two variables. It can be implemented using -@scheme[define-syntax-rule] as follows: +@racket[define-syntax-rule] as follows: -@margin-note{The macro is ``un-Schemely'' in the sense that it +@margin-note{The macro is ``un-Rackety'' in the sense that it involves side effects on variables---but the point of macros is to let you add syntactic forms that some other language designer might not approve.} -@schemeblock[ +@racketblock[ (define-syntax-rule (swap x y) (let ([tmp x]) (set! x y) (set! y tmp))) ] -The @scheme[define-syntax-rule] form binds a macro that matches a +The @racket[define-syntax-rule] form binds a macro that matches a single pattern. The pattern must always start with an open parenthesis -followed by an identifier, which is @scheme[swap] in this case. After +followed by an identifier, which is @racket[swap] in this case. After the initial identifier, other identifiers are @deftech{macro pattern variables} that can match anything in a use of the macro. Thus, this -macro matches the for @scheme[(swap _form_1 _form_2)] for any -@scheme[_form_1] and @scheme[_form_2]. +macro matches the form @racket[(swap _form1 _form2)] for any +@racket[_form_1] and @racket[_form_2]. @margin-note{Macro pattern variables similar to pattern variables for - @scheme[match]. See @secref["match"].} + @racket[match]. See @secref["match"].} -After the pattern in @scheme[define-syntax-rule] is the +After the pattern in @racket[define-syntax-rule] is the @deftech{template}. The template is used in place of a form that matches the pattern, except that each instance of a pattern variable in the template is replaced with the part of the macro use the pattern variable matched. For example, in -@schemeblock[(swap first last)] +@racketblock[(swap first last)] -the pattern variable @scheme[x] matches @scheme[first] and @scheme[y] -matches @scheme[last], so that the expansion is +the pattern variable @racket[x] matches @racket[first] and @racket[y] +matches @racket[last], so that the expansion is -@schemeblock[ +@racketblock[ (let ([tmp first]) (set! first last) (set! last tmp)) @@ -66,20 +66,20 @@ matches @scheme[last], so that the expansion is @section{Lexical Scope} -Suppose that we use the @scheme[swap] macro to swap variables named -@scheme[tmp] and @scheme[other]: +Suppose that we use the @racket[swap] macro to swap variables named +@racket[tmp] and @racket[other]: -@schemeblock[ +@racketblock[ (let ([tmp 5] [other 6]) (swap tmp other) (list tmp other)) ] -The result of the above expression should be @schemeresult[(6 5)]. The -naive expansion of this use of @scheme[swap], however, is +The result of the above expression should be @racketresult[(6 5)]. The +naive expansion of this use of @racket[swap], however, is -@schemeblock[ +@racketblock[ (let ([tmp 5] [other 6]) (let ([tmp tmp]) @@ -88,14 +88,14 @@ naive expansion of this use of @scheme[swap], however, is (list tmp other)) ] -whose result is @schemeresult[(5 6)]. The problem is that the naive -expansion confuses the @scheme[tmp] in the context where @scheme[swap] -is used with the @scheme[tmp] that is in the macro template. +whose result is @racketresult[(5 6)]. The problem is that the naive +expansion confuses the @racket[tmp] in the context where @racket[swap] +is used with the @racket[tmp] that is in the macro template. -Scheme doesn't produce the naive expansion for the above use of -@scheme[swap]. Instead, it produces +Racket doesn't produce the naive expansion for the above use of +@racket[swap]. Instead, it produces -@schemeblock[ +@racketblock[ (let ([tmp 5] [other 6]) (let ([tmp_1 tmp]) @@ -104,10 +104,10 @@ Scheme doesn't produce the naive expansion for the above use of (list tmp other)) ] -with the correct result in @schemeresult[(6 5)]. Similarly, in the +with the correct result in @racketresult[(6 5)]. Similarly, in the example -@schemeblock[ +@racketblock[ (let ([set! 5] [other 6]) (swap set! other) @@ -116,7 +116,7 @@ example the expansion is -@schemeblock[ +@racketblock[ (let ([set!_1 5] [other 6]) (let ([tmp_1 tmp]) @@ -125,23 +125,23 @@ the expansion is (list set!_1 other)) ] -so that the local @scheme[set!] binding doesn't interfere with the +so that the local @racket[set!] binding doesn't interfere with the assignments introduced by the macro template. -In other words, Scheme's pattern-based macros automatically maintain +In other words, Racket's pattern-based macros automatically maintain lexical scope, so macro implementors can reason about variable reference in macros and macro uses in the same way as for functions and function calls. @; ---------------------------------------- -@section{@scheme[define-syntax] and @scheme[syntax-rules]} +@section{@racket[define-syntax] and @racket[syntax-rules]} -The @scheme[define-syntax-rule] form binds a macro that matches a -single pattern, but Scheme's macro system supports transformers that +The @racket[define-syntax-rule] form binds a macro that matches a +single pattern, but Racket's macro system supports transformers that match multiple patterns starting with the same identifier. To write such macros, the programmer much use the more general -@scheme[define-syntax] form along with the @scheme[syntax-rules] +@racket[define-syntax] form along with the @racket[syntax-rules] transformer form: @specform[#:literals (syntax-rules) @@ -150,25 +150,25 @@ transformer form: [pattern template] ...))] -@margin-note{The @scheme[define-syntax-rule] form is itself a macro - that expands into @scheme[define-syntax] with a @scheme[syntax-rules] +@margin-note{The @racket[define-syntax-rule] form is itself a macro + that expands into @racket[define-syntax] with a @racket[syntax-rules] form that contains only one pattern and template.} -For example, suppose we would like a @scheme[rotate] macro that -generalizes @scheme[swap] to work on either two or three identifiers, +For example, suppose we would like a @racket[rotate] macro that +generalizes @racket[swap] to work on either two or three identifiers, so that -@schemeblock[ +@racketblock[ (let ([red 1] [green 2] [blue 3]) (rotate red green) (code:comment @#,t{swaps}) (rotate red green blue) (code:comment @#,t{rotates left}) (list red green blue)) ] -produces @schemeresult[(1 3 2)]. We can implement @scheme[rotate] -using @scheme[syntax-rules]: +produces @racketresult[(1 3 2)]. We can implement @racket[rotate] +using @racket[syntax-rules]: -@schemeblock[ +@racketblock[ (define-syntax rotate (syntax-rules () [(rotate a b) (swap a b)] @@ -177,27 +177,27 @@ using @scheme[syntax-rules]: (swap b c))])) ] -The expression @scheme[(rotate red green)] matches the first pattern -in the @scheme[syntax-rules] form, so it expands to @scheme[(swap red -green)]. The expression @scheme[(rotate a b c)] matches the second -pattern, so it expands to @scheme[(begin (swap red green) (swap green +The expression @racket[(rotate red green)] matches the first pattern +in the @racket[syntax-rules] form, so it expands to @racket[(swap red +green)]. The expression @racket[(rotate a b c)] matches the second +pattern, so it expands to @racket[(begin (swap red green) (swap green blue))]. @; ---------------------------------------- @section{Matching Sequences} -A better @scheme[rotate] macro would allow any number of identifiers, -instead of just two or three. To match a use of @scheme[rotate] with +A better @racket[rotate] macro would allow any number of identifiers, +instead of just two or three. To match a use of @racket[rotate] with any number of identifiers, we need a pattern form that has something -like a Kleene star. In a Scheme macro pattern, a star is written as -@scheme[...]. +like a Kleene star. In a Racket macro pattern, a star is written as +@racket[...]. -To implement @scheme[rotate] with @scheme[...], we need a base case to +To implement @racket[rotate] with @racket[...], we need a base case to handle a single identifier, and an inductive case to handle more than one identifier: -@schemeblock[ +@racketblock[ (define-syntax rotate (syntax-rules () [(rotate a) (void)] @@ -206,19 +206,19 @@ one identifier: (rotate b c ...))])) ] -When a pattern variable like @scheme[c] is followed by @scheme[...] in -a pattern, then it must be followed by @scheme[...] in a template, +When a pattern variable like @racket[c] is followed by @racket[...] in +a pattern, then it must be followed by @racket[...] in a template, too. The pattern variable effectively matches a sequence of zero or more forms, and it is replaced in the template by the same sequence. -Both versions of @scheme[rotate] so far are a bit inefficient, since +Both versions of @racket[rotate] so far are a bit inefficient, since pairwise swapping keeps moving the value from the first variable into every variable in the sequence until it arrives at the last one. A -more efficient @scheme[rotate] would move the first value directly to -the last variable. We can use @scheme[...] patterns to implement the +more efficient @racket[rotate] would move the first value directly to +the last variable. We can use @racket[...] patterns to implement the more efficient variant using a helper macro: -@schemeblock[ +@racketblock[ (define-syntax rotate (syntax-rules () [(rotate a c ...) @@ -232,18 +232,18 @@ more efficient variant using a helper macro: (set! to0 tmp))])) ] -In the @scheme[shift-to] macro, @scheme[...] in the template follows -@scheme[(set! to from)], which causes the @scheme[(set! to from)] +In the @racket[shift-to] macro, @racket[...] in the template follows +@racket[(set! to from)], which causes the @racket[(set! to from)] expression to be duplicated as many times as necessary to use each -identifier matched in the @scheme[to] and @scheme[from] -sequences. (The number of @scheme[to] and @scheme[from] matches must +identifier matched in the @racket[to] and @racket[from] +sequences. (The number of @racket[to] and @racket[from] matches must be the same, otherwise the macro expansion fails with an error.) @; ---------------------------------------- @section{Identifier Macros} -Given our macro definitions, the @scheme[swap] or @scheme[rotate] +Given our macro definitions, the @racket[swap] or @racket[rotate] identifiers must be used after an open parenthesis, otherwise a syntax error is reported: @@ -252,13 +252,13 @@ error is reported: @interaction[(+ swap 3)] An @deftech{identifier macro} works in any expression. For example, we -can define @scheme[clock] as an identifier macro that expands to -@scheme[(get-clock)], so @scheme[(+ clock 3)] would expand to -@scheme[(+ (get-clock) 3)]. An identifier macro also cooperates with -@scheme[set!], and we can define @scheme[clock] so that @scheme[(set! -clock 3)] expands to @scheme[(put-clock! 3)]. +can define @racket[clock] as an identifier macro that expands to +@racket[(get-clock)], so @racket[(+ clock 3)] would expand to +@racket[(+ (get-clock) 3)]. An identifier macro also cooperates with +@racket[set!], and we can define @racket[clock] so that @racket[(set! +clock 3)] expands to @racket[(put-clock! 3)]. -The @scheme[syntax-id-rules] form is like @scheme[syntax-rules], but +The @racket[syntax-id-rules] form is like @racket[syntax-rules], but it creates a transformer that acts as an identifier macro: @specform[#:literals (syntax-id-rules) @@ -267,12 +267,12 @@ it creates a transformer that acts as an identifier macro: [pattern template] ...))] -Unlike a @scheme[syntax-rules] form, the @scheme[_pattern]s are not -required to start with an open parenthesis. Also, @scheme[set!] is -typically used as a literal to match a use of @scheme[set!] in the +Unlike a @racket[syntax-rules] form, the @racket[_pattern]s are not +required to start with an open parenthesis. Also, @racket[set!] is +typically used as a literal to match a use of @racket[set!] in the pattern (as opposed to being a pattern variable. -@schemeblock[ +@racketblock[ (define-syntax clock (syntax-id-rules (set!) [(set! clock e) (put-clock! e)] @@ -280,29 +280,29 @@ pattern (as opposed to being a pattern variable. [clock (get-clock)])) ] -The @scheme[(clock a ...)] pattern is needed because, when an +The @racket[(clock a ...)] pattern is needed because, when an identifier macro is used after an open parenthesis, the macro transformer is given the whole form, like with a non-identifier macro. -Put another way, the @scheme[syntax-rules] form is essentially a -special case of the @scheme[syntax-id-rules] form with errors in the -@scheme[set!] and lone-identifier cases. +Put another way, the @racket[syntax-rules] form is essentially a +special case of the @racket[syntax-id-rules] form with errors in the +@racket[set!] and lone-identifier cases. @; ---------------------------------------- @section{Macro-Generating Macros} -Suppose that we have many identifier like @scheme[clock] that we'd +Suppose that we have many identifier like @racket[clock] that we'd like to redirect to accessor and mutator functions like -@scheme[get-clock] and @scheme[put-clock!]. We'd like to be able to +@racket[get-clock] and @racket[put-clock!]. We'd like to be able to just write -@schemeblock[ +@racketblock[ (define-get/put-id clock get-clock put-clock!) ] -Naturally, we can implement @scheme[define-get/put-id] as a macro: +Naturally, we can implement @racket[define-get/put-id] as a macro: -@schemeblock[ +@racketblock[ (define-syntax-rule (define-get/put-id id get put!) (define-syntax id (syntax-id-rules (set!) @@ -311,25 +311,25 @@ Naturally, we can implement @scheme[define-get/put-id] as a macro: [id (get)]))) ] -The @scheme[define-get/put-id] macro is a @deftech{macro-generating +The @racket[define-get/put-id] macro is a @deftech{macro-generating macro}. The only non-obvious part of its definition is the -@scheme[(... ...)], which ``quotes'' @scheme[...] so that it takes its +@racket[(... ...)], which ``quotes'' @racket[...] so that it takes its usual role in the generated macro, instead of the generating macro. @; ---------------------------------------- @section[#:tag "pattern-macro-example"]{Extended Example: Call-by-Reference Functions} -We can use pattern-matching macros to add a form to Scheme +We can use pattern-matching macros to add a form to Racket for defining first-order @deftech{call-by-reference} functions. When a call-by-reference function body mutates its formal argument, the mutation applies to variables that are supplied as actual arguments in a call to the function. -For example, if @scheme[define-cbr] is like @scheme[define] except +For example, if @racket[define-cbr] is like @racket[define] except that it defines a call-by-reference function, then -@schemeblock[ +@racketblock[ (define-cbr (f a b) (swap a b)) @@ -338,35 +338,35 @@ that it defines a call-by-reference function, then (list x y)) ] -produces @schemeresult[(2 1)]. +produces @racketresult[(2 1)]. We will implement call-by-reference functions by having function calls supply accessor and mutators for the arguments, instead of supplying -argument values directly. In particular, for the function @scheme[f] +argument values directly. In particular, for the function @racket[f] above, we'll generate -@schemeblock[ +@racketblock[ (define (do-f get-a get-b put-a! put-b!) (define-get/put-id a get-a put-a!) (define-get/put-id b get-b put-b!) (swap a b)) ] -and redirect a function call @scheme[(f x y)] to +and redirect a function call @racket[(f x y)] to -@schemeblock[ +@racketblock[ (do-f (lambda () x) (lambda () y) (lambda (v) (set! x v)) (lambda (v) (set! y v))) ] -Clearly, then @scheme[define-cbr] is a macro-generating macro, which -binds @scheme[f] to a macro that expands to a call of @scheme[do-f]. -That is, @scheme[(define-cbr (f a b) (swap ab))] needs to generate the +Clearly, then @racket[define-cbr] is a macro-generating macro, which +binds @racket[f] to a macro that expands to a call of @racket[do-f]. +That is, @racket[(define-cbr (f a b) (swap ab))] needs to generate the definition -@schemeblock[ +@racketblock[ (define-syntax f (syntax-rules () [(id actual ...) @@ -377,13 +377,13 @@ definition ...)])) ] -At the same time, @scheme[define-cbr] needs to define @scheme[do-f] -using the body of @scheme[f], this second part is slightly more -complex, so we defer most it to a @scheme[define-for-cbr] helper -module, which lets us write @scheme[define-cbr] easily enough: +At the same time, @racket[define-cbr] needs to define @racket[do-f] +using the body of @racket[f], this second part is slightly more +complex, so we defer most it to a @racket[define-for-cbr] helper +module, which lets us write @racket[define-cbr] easily enough: -@schemeblock[ +@racketblock[ (define-syntax-rule (define-cbr (id arg ...) body) (begin (define-syntax id @@ -399,34 +399,34 @@ module, which lets us write @scheme[define-cbr] easily enough: body))) ] -Our remaining task is to define @scheme[define-for-cbr] so that it +Our remaining task is to define @racket[define-for-cbr] so that it converts -@schemeblock[ +@racketblock[ (define-for-cbr do-f (a b) () (swap a b)) ] -to the function definition @scheme[do-f] above. Most of the work is -generating a @scheme[define-get/put-id] declaration for each argument, -@scheme[a] ad @scheme[b], and putting them before the body. Normally, -that's an easy task for @scheme[...] in a pattern and template, but +to the function definition @racket[do-f] above. Most of the work is +generating a @racket[define-get/put-id] declaration for each argument, +@racket[a] ad @racket[b], and putting them before the body. Normally, +that's an easy task for @racket[...] in a pattern and template, but this time there's a catch: we need to generate the names -@scheme[get-a] and @scheme[put-a!] as well as @scheme[get-b] and -@scheme[put-b!], and the pattern language provides no way to +@racket[get-a] and @racket[put-a!] as well as @racket[get-b] and +@racket[put-b!], and the pattern language provides no way to synthesize identifiers based on existing identifiers. As it turns out, lexical scope gives us a way around this problem. The -trick is to iterate expansions of @scheme[define-for-cbr] once for -each argument in the function, and that's why @scheme[define-cbr] -starts with an apparently useless @scheme[()] after the argument +trick is to iterate expansions of @racket[define-for-cbr] once for +each argument in the function, and that's why @racket[define-cbr] +starts with an apparently useless @racket[()] after the argument list. We need to keep track of all the arguments seen so far and the -@scheme[get] and @scheme[put] names generated for each, in addition to +@racket[get] and @racket[put] names generated for each, in addition to the arguments left to process. After we've processed all the identifiers, then we have all the names we need. -Here is the definition of @scheme[define-for-cbr]: +Here is the definition of @racket[define-for-cbr]: -@schemeblock[ +@racketblock[ (define-syntax define-for-cbr (syntax-rules () [(define-for-cbr do-f (id0 id ...) @@ -442,7 +442,7 @@ Here is the definition of @scheme[define-for-cbr]: Step-by-step, expansion proceeds as follows: -@schemeblock[ +@racketblock[ (define-for-cbr do-f (a b) () (swap a b)) => (define-for-cbr do-f (b) @@ -455,11 +455,11 @@ Step-by-step, expansion proceeds as follows: (swap a b)) ] -The ``subscripts'' on @scheme[get_1], @scheme[get_2], -@scheme[put_1], and @scheme[put_2] are inserted by the macro -expander to preserve lexical scope, since the @scheme[get] -generated by each iteration of @scheme[define-for-cbr] should not -bind the @scheme[get] generated by a different iteration. In +The ``subscripts'' on @racket[get_1], @racket[get_2], +@racket[put_1], and @racket[put_2] are inserted by the macro +expander to preserve lexical scope, since the @racket[get] +generated by each iteration of @racket[define-for-cbr] should not +bind the @racket[get] generated by a different iteration. In other words, we are essentially tricking the macro expander into generating fresh names for us, but the technique illustrates some of the surprising power of pattern-based macros with automatic @@ -467,17 +467,17 @@ lexical scope. The last expression eventually expands to just -@schemeblock[ +@racketblock[ (define (do-f get_1 get_2 put_1 put_2) (let ([tmp (get_1)]) (put_1 (get_2)) (put_2 tmp))) ] -which implements the call-by-name function @scheme[f]. +which implements the call-by-name function @racket[f]. To summarize, then, we can add call-by-reference functions to -Scheme with just three small pattern-based macros: -@scheme[define-cbr], @scheme[define-for-cbr], and -@scheme[define-get/put-id]. +Racket with just three small pattern-based macros: +@racket[define-cbr], @racket[define-for-cbr], and +@racket[define-get/put-id]. diff --git a/collects/scribblings/guide/performance.scrbl b/collects/scribblings/guide/performance.scrbl index 30866eb5a6..c65a101b71 100644 --- a/collects/scribblings/guide/performance.scrbl +++ b/collects/scribblings/guide/performance.scrbl @@ -1,31 +1,31 @@ #lang scribble/doc @(require scribble/manual "guide-utils.ss" - (for-label scheme/flonum scheme/unsafe/ops)) + (for-label racket/flonum racket/unsafe/ops)) @title[#:tag "performance"]{Performance} Alan Perlis famously quipped ``Lisp programmers know the value of -everything and the cost of nothing.'' A Scheme programmer knows, for -example, that a @scheme[lambda] anywhere in a program produces a value +everything and the cost of nothing.'' A Racket programmer knows, for +example, that a @racket[lambda] anywhere in a program produces a value that is closed over it lexical environment---but how much does allocating that value cost? While most programmers have a reasonable grasp of the cost of various operations and data structures at the -machine level, the gap between the Scheme language model and the +machine level, the gap between the Racket language model and the underlying computing machinery can be quite large. -In this chapter, we narrow the gap by explaining details of the PLT -Scheme compiler and run-time system and how they affect the run-time -and memory performance of Scheme code. +In this chapter, we narrow the gap by explaining details of the +Racket compiler and run-time system and how they affect the run-time +and memory performance of Racket code. @; ---------------------------------------------------------------------- @section[#:tag "JIT"]{The Bytecode and Just-in-Time (JIT) Compilers} -Every definition or expression to be evaluated by Scheme is compiled +Every definition or expression to be evaluated by Racket is compiled to an internal bytecode format. In interactive mode, this compilation -occurs automatically and on-the-fly. Tools like @exec{mzc} and -@exec{setup-plt} marshal compiled bytecode to a file, so that you do +occurs automatically and on-the-fly. Tools like @exec{raco make} and +@exec{raco setup} marshal compiled bytecode to a file, so that you do not have to compile from source every time that you run a program. (Most of the time required to compile a file is actually in macro expansion; generating bytecode from fully expanded code is @@ -34,9 +34,9 @@ generating bytecode files. The bytecode compiler applies all standard optimizations, such as constant propagation, constant folding, inlining, and dead-code -elimination. For example, in an environment where @scheme[+] has its -usual binding, the expression @scheme[(let ([x 1][y (lambda () 4)]) (+ -1 (y)))] is compiled the same as the constant @scheme[5]. +elimination. For example, in an environment where @racket[+] has its +usual binding, the expression @racket[(let ([x 1][y (lambda () 4)]) (+ +1 (y)))] is compiled the same as the constant @racket[5]. On some platforms, bytecode is further compiled to native code via a @deftech{just-in-time} or @deftech{JIT} compiler. The @tech{JIT} @@ -44,13 +44,13 @@ compiler substantially speeds programs that execute tight loops, arithmetic on small integers, and arithmetic on inexact real numbers. Currently, @tech{JIT} compilation is supported for x86, x86_64 (a.k.a. AMD64), and 32-bit PowerPC processors. The @tech{JIT} -compiler can be disabled via the @scheme[eval-jit-enabled] parameter -or the @DFlag{no-jit}/@Flag{j} command-line flag for @exec{mzscheme}. +compiler can be disabled via the @racket[eval-jit-enabled] parameter +or the @DFlag{no-jit}/@Flag{j} command-line flag for @exec{racket}. The @tech{JIT} compiler works incrementally as functions are applied, but the @tech{JIT} compiler makes only limited use of run-time information when compiling procedures, since the code for a given -module body or @scheme[lambda] abstraction is compiled only once. The +module body or @racket[lambda] abstraction is compiled only once. The @tech{JIT}'s granularity of compilation is a single procedure body, not counting the bodies of any lexically nested procedures. The overhead for @tech{JIT} compilation is normally so small that it is @@ -61,33 +61,33 @@ difficult to detect. @section{Modules and Performance} The module system aids optimization by helping to ensure that -identifiers have the usual bindings. That is, the @scheme[+] provided -by @schememodname[scheme/base] can be recognized by the compiler and +identifiers have the usual bindings. That is, the @racket[+] provided +by @racketmodname[racket/base] can be recognized by the compiler and inlined, which is especially important for @tech{JIT}-compiled code. -In contrast, in a traditional interactive Scheme system, the top-level -@scheme[+] binding might be redefined, so the compiler cannot assume a -fixed @scheme[+] binding (unless special flags or declarations +In contrast, in a traditional interactive Racket system, the top-level +@racket[+] binding might be redefined, so the compiler cannot assume a +fixed @racket[+] binding (unless special flags or declarations act as a poor-man's module system to indicate otherwise). -Even in the top-level environment, importing with @scheme[require] -enables some inlining optimizations. Although a @scheme[+] definition -at the top level might shadow an imported @scheme[+], the shadowing +Even in the top-level environment, importing with @racket[require] +enables some inlining optimizations. Although a @racket[+] definition +at the top level might shadow an imported @racket[+], the shadowing definition applies only to expressions evaluated later. Within a module, inlining and constant-propagation optimizations take additional advantage of the fact that definitions within a module -cannot be mutated when no @scheme[set!] is visable at compile +cannot be mutated when no @racket[set!] is visable at compile time. Such optimizations are unavailable in the top-level environment. Although this optimization within modules is important for performance, it hinders some forms of interactive development and -exploration. The @scheme[compile-enforce-module-constants] parameter +exploration. The @racket[compile-enforce-module-constants] parameter disables the @tech{JIT} compiler's assumptions about module definitions when interactive exploration is more important. See @secref["module-set"] for more information. Currently, the compiler does not attempt to inline or propagate -constants across module boundary, except for exports of the built-in -modules (such as the one that originally provides @scheme[+]). +constants across module boundaries, except for exports of the built-in +modules (such as the one that originally provides @racket[+]). The later section @secref["letrec-performance"] provides some additional caveats concerning inlining of module bindings. @@ -100,7 +100,7 @@ When the compiler detects a function call to an immediately visible function, it generates more efficient code than for a generic call, especially for tail calls. For example, given the program -@schemeblock[ +@racketblock[ (letrec ([odd (lambda (x) (if (zero? x) #f @@ -112,23 +112,23 @@ especially for tail calls. For example, given the program (odd 40000000)) ] -the compiler can detect the @scheme[odd]--@scheme[even] loop and +the compiler can detect the @racket[odd]--@racket[even] loop and produce code that runs much faster via loop unrolling and related optimizations. -Within a module form, @scheme[define]d variables are lexically scoped -like @scheme[letrec] bindings, and definitions within a module +Within a module form, @racket[define]d variables are lexically scoped +like @racket[letrec] bindings, and definitions within a module therefore permit call optimizations, so -@schemeblock[ +@racketblock[ (define (odd x) ....) (define (even x) ....) ] -within a module would perform the same as the @scheme[letrec] version. +within a module would perform the same as the @racket[letrec] version. -Primitive operations like @scheme[pair?], @scheme[car], and -@scheme[cdr] are inlined at the machine-code level by the @tech{JIT} +Primitive operations like @racket[pair?], @racket[car], and +@racket[cdr] are inlined at the machine-code level by the @tech{JIT} compiler. See also the later section @secref["fixnums+flonums"] for information about inlined arithmetic operations. @@ -136,11 +136,11 @@ information about inlined arithmetic operations. @section{Mutation and Performance} -Using @scheme[set!] to mutate a variable can lead to bad +Using @racket[set!] to mutate a variable can lead to bad performance. For example, the microbenchmark -@schememod[ -scheme/base +@racketmod[ +racket/base (define (subtract-one x) (set! x (sub1 x)) @@ -155,8 +155,8 @@ scheme/base runs much more slowly than the equivalent -@schememod[ -scheme/base +@racketmod[ +racket/base (define (subtract-one x) (sub1 x)) @@ -168,16 +168,16 @@ scheme/base (loop (subtract-one n))))) ] -In the first variant, a new location is allocated for @scheme[x] on +In the first variant, a new location is allocated for @racket[x] on every iteration, leading to poor performance. A more clever compiler -could unravel the use of @scheme[set!] in the first example, but since +could unravel the use of @racket[set!] in the first example, but since mutation is discouraged (see @secref["using-set!"]), the compiler's effort is spent elsewhere. More significantly, mutation can obscure bindings where inlining and constant-propagation might otherwise apply. For example, in -@schemeblock[ +@racketblock[ (let ([minus1 #f]) (set! minus1 sub1) (let loop ([n 4000000]) @@ -186,14 +186,14 @@ constant-propagation might otherwise apply. For example, in (loop (minus1 n))))) ] -the @scheme[set!] obscures the fact that @scheme[minus1] is just -another name for the built-in @scheme[sub1]. +the @racket[set!] obscures the fact that @racket[minus1] is just +another name for the built-in @racket[sub1]. @; ---------------------------------------------------------------------- -@section[#:tag "letrec-performance"]{@scheme[letrec] Performance} +@section[#:tag "letrec-performance"]{@racket[letrec] Performance} -When @scheme[letrec] is used to bind only procedures and literals, +When @racket[letrec] is used to bind only procedures and literals, then the compiler can treat the bindings in an optimal manner, compiling uses of the bindings efficiently. When other kinds of bindings are mixed with procedures, the compiler may be less able to @@ -201,7 +201,7 @@ determine the control flow. For example, -@schemeblock[ +@racketblock[ (letrec ([loop (lambda (x) (if (zero? x) 'done @@ -213,7 +213,7 @@ For example, likely compiles to less efficient code than -@schemeblock[ +@racketblock[ (letrec ([loop (lambda (x) (if (zero? x) 'done @@ -223,13 +223,13 @@ likely compiles to less efficient code than ] In the first case, the compiler likely does not know that -@scheme[display] does not call @scheme[loop]. If it did, then -@scheme[loop] might refer to @scheme[next] before the binding is +@racket[display] does not call @racket[loop]. If it did, then +@racket[loop] might refer to @racket[next] before the binding is available. -This caveat about @scheme[letrec] also applies to definitions of +This caveat about @racket[letrec] also applies to definitions of functions and constants within modules. A definition sequence in a -module body is analogous to a sequence of @scheme[letrec] bindings, +module body is analogous to a sequence of @racket[letrec] bindings, and non-constant expressions in a module body can interfere with the optimization of references to later bindings. @@ -247,14 +247,14 @@ correspond to 64-bit IEEE floating-point numbers on all platforms. Inlined fixnum and flonum arithmetic operations are among the most important advantages of the @tech{JIT} compiler. For example, when -@scheme[+] is applied to two arguments, the generated machine code +@racket[+] is applied to two arguments, the generated machine code tests whether the two arguments are fixnums, and if so, it uses the machine's instruction to add the numbers (and check for overflow). If -the two numbers are not fixnums, then the next check whether whether +the two numbers are not fixnums, then it checks whether whether both are flonums; in that case, the machine's floating-point operations are used directly. For functions that take any number of -arguments, such as @scheme[+], inlining works for two or more -arguments (except for @scheme[-], whose one-argument case is also +arguments, such as @racket[+], inlining works for two or more +arguments (except for @racket[-], whose one-argument case is also inlined) when the arguments are either all fixnums or all flonums. Flonums are typically @defterm{boxed}, which means that memory is @@ -267,23 +267,23 @@ typically cheap to use. @margin-note{See @secref["effective-futures"] for an example use of @tech{flonum}-specific operations.} -The @schememodname[scheme/flonum] library provides flonum-specific +The @racketmodname[racket/flonum] library provides flonum-specific operations, and combinations of flonum operations allow the @tech{JIT} compiler to generate code that avoids boxing and unboxing intermediate results. Besides results within immediate combinations, -flonum-specific results that are bound with @scheme[let] and consumed +flonum-specific results that are bound with @racket[let] and consumed by a later flonum-specific operation are unboxed within temporary storage. Finally, the compiler can detect some flonum-valued loop accumulators and avoid boxing of the accumulator. The bytecode decompiler (see @secref[#:doc '(lib "scribblings/mzc/mzc.scrbl") "decompile"]) annotates combinations where the JIT can avoid boxes with -@schemeidfont{#%flonum}, @schemeidfont{#%as-flonum}, and -@schemeidfont{#%from-flonum}. +@racketidfont{#%flonum}, @racketidfont{#%as-flonum}, and +@racketidfont{#%from-flonum}. @margin-note{Unboxing of local bindings and accumualtors is not supported by the JIT for PowerPC.} -The @schememodname[scheme/unsafe/ops] library provides unchecked +The @racketmodname[racket/unsafe/ops] library provides unchecked fixnum- and flonum-specific operations. Unchecked flonum-specific operations allow unboxing, and sometimes they allow the compiler to reorder expressions to improve performance. See also @@ -293,10 +293,10 @@ reorder expressions to improve performance. See also @section[#:tag "unchecked-unsafe"]{Unchecked, Unsafe Operations} -The @schememodname[scheme/unsafe/ops] library provides functions that -are like other functions in @schememodname[scheme/base], but they +The @racketmodname[racket/unsafe/ops] library provides functions that +are like other functions in @racketmodname[racket/base], but they assume (instead of checking) that provided arguments are of the right -type. For example, @scheme[unsafe-vector-ref] accesses an element from +type. For example, @racket[unsafe-vector-ref] accesses an element from a vector without checking that its first argument is actually a vector and without checking that the given index is in bounds. For tight loops that use these functions, avoiding checks can sometimes speed @@ -304,20 +304,20 @@ the computation, though the benefits vary for different unchecked functions and different contexts. Beware that, as ``unsafe'' in the library and function names suggest, -misusing the exports of @schememodname[scheme/unsafe/ops] can lead to +misusing the exports of @racketmodname[racket/unsafe/ops] can lead to crashes or memory corruption. @; ---------------------------------------------------------------------- @section[#:tag "gc-perf"]{Memory Management} -PLT Scheme is available in two variants: @deftech{3m} and +The Racket implementation is available in two variants: @deftech{3m} and @deftech{CGC}. The @tech{3m} variant uses a modern, @deftech{generational garbage collector} that makes allocation relatively cheap for short-lived objects. The @tech{CGC} variant uses a @deftech{conservative garbage collector} which facilitates interaction with C code at the expense of both precision and speed for -Scheme memory management. The 3m variant is the standard one. +Racket memory management. The 3m variant is the standard one. Although memory allocation is reasonably cheap, avoiding allocation altogether is normally faster. One particular place where allocation @@ -325,7 +325,7 @@ can be avoided sometimes is in @deftech{closures}, which are the run-time representation of functions that contain free variables. For example, -@schemeblock[ +@racketblock[ (let loop ([n 40000000][prev-thunk (lambda () #f)]) (if (zero? n) (prev-thunk) @@ -333,13 +333,13 @@ For example, (lambda () n)))) ] -allocates a closure on every iteration, since @scheme[(lambda () n)] -effectively saves @scheme[n]. +allocates a closure on every iteration, since @racket[(lambda () n)] +effectively saves @racket[n]. The compiler can eliminate many closures automatically. For example, in -@schemeblock[ +@racketblock[ (let loop ([n 40000000][prev-val #f]) (let ([prev-thunk (lambda () n)]) (if (zero? n) @@ -347,10 +347,10 @@ in (loop (sub1 n) (prev-thunk))))) ] -no closure is ever allocated for @scheme[prev-thunk], because its only +no closure is ever allocated for @racket[prev-thunk], because its only application is visible, and so it is inlined. Similarly, in -@schemeblock[ +@racketblock[ (let n-loop ([n 400000]) (if (zero? n) 'done @@ -360,9 +360,9 @@ application is visible, and so it is inlined. Similarly, in (m-loop (sub1 m)))))) ] -then the expansion of the @scheme[let] form to implement -@scheme[m-loop] involves a closure over @scheme[n], but the compiler -automatically converts the closure to pass itself @scheme[n] as an +then the expansion of the @racket[let] form to implement +@racket[m-loop] involves a closure over @racket[n], but the compiler +automatically converts the closure to pass itself @racket[n] as an argument instead. @; ---------------------------------------------------------------------- diff --git a/collects/scribblings/guide/proc-macros.scrbl b/collects/scribblings/guide/proc-macros.scrbl index a6fb3caf74..ddaec65b03 100644 --- a/collects/scribblings/guide/proc-macros.scrbl +++ b/collects/scribblings/guide/proc-macros.scrbl @@ -4,34 +4,34 @@ "guide-utils.ss") @(define check-eval (make-base-eval)) -@(interaction-eval #:eval check-eval (require (for-syntax scheme/base))) +@(interaction-eval #:eval check-eval (require (for-syntax racket/base))) -@(define-syntax-rule (schemeblock/eval #:eval e body ...) +@(define-syntax-rule (racketblock/eval #:eval e body ...) (begin (interaction-eval #:eval e body) ... - (schemeblock body ...))) + (racketblock body ...))) @title[#:tag "proc-macros" #:style 'toc]{General Macro Transformers} -The @scheme[define-syntax] form creates a @deftech{transformer +The @racket[define-syntax] form creates a @deftech{transformer binding} for an identifier, which is a binding that can be used at compile time while expanding expressions to be evaluated at run time. The compile-time value associated with a transformer binding can be anything; if it is a procedure of one argument, then the binding is used as a macro, and the procedure is the @deftech{macro transformer}. -The @scheme[syntax-rules] and @scheme[syntax-id-rules] forms are +The @racket[syntax-rules] and @racket[syntax-id-rules] forms are macros that expand to procedure forms. For example, if you evaluate a -@scheme[syntax-rules] form directly (instead of placing on the -right-hand of a @scheme[define-syntax] form), the result is a +@racket[syntax-rules] form directly (instead of placing on the +right-hand of a @racket[define-syntax] form), the result is a procedure: @interaction[ (syntax-rules () [(nothing) something]) ] -Instead of using @scheme[syntax-rules], you can write your own macro -transformer procedure directly using @scheme[lambda]. The argument to +Instead of using @racket[syntax-rules], you can write your own macro +transformer procedure directly using @racket[lambda]. The argument to the procedure is a values that represents the source form, and the result of the procedure must be a value that represents the replacement form. @@ -45,37 +45,37 @@ replacement form. The input and output of a macro transformer (i.e., source and replacement forms) are represented as @deftech{syntax objects}. A syntax object contains symbols, lists, and constant values (such as -numbers) that essentially correspond to the @scheme[quote]d form of +numbers) that essentially correspond to the @racket[quote]d form of the expression. For example, a representation of the expression -@scheme[(+ 1 2)] contains the symbol @scheme['+] and the numbers -@scheme[1] and @scheme[2], all in a list. In addition to this quoted +@racket[(+ 1 2)] contains the symbol @racket['+] and the numbers +@racket[1] and @racket[2], all in a list. In addition to this quoted content, a syntax object associates source-location and lexical-binding information with each part of the form. The source-location information is used when reporting syntax errors (for example), and the lexical-biding information allows the macro system to maintain lexical scope. To accommodate this extra information, the -represention of the expression @scheme[(+ 1 2)] is not merely -@scheme['(+ 1 2)], but a packaging of @scheme['(+ 1 2)] into a syntax +represention of the expression @racket[(+ 1 2)] is not merely +@racket['(+ 1 2)], but a packaging of @racket['(+ 1 2)] into a syntax object. -To create a literal syntax object, use the @scheme[syntax] form: +To create a literal syntax object, use the @racket[syntax] form: @interaction[ -(eval:alts (#,(scheme syntax) (+ 1 2)) (syntax (+ 1 2))) +(eval:alts (#,(racket syntax) (+ 1 2)) (syntax (+ 1 2))) ] -In the same way that @litchar{'} abbreviates @scheme[quote], -@litchar{#'} abbreviates @scheme[syntax]: +In the same way that @litchar{'} abbreviates @racket[quote], +@litchar{#'} abbreviates @racket[syntax]: @interaction[ #'(+ 1 2) ] A syntax object that contains just a symbol is an @deftech{identifier -syntax object}. Scheme provides some additional operations specific to -identifier syntax objects, including the @scheme[identifier?] +syntax object}. Racket provides some additional operations specific to +identifier syntax objects, including the @racket[identifier?] operation to detect identifiers. Most notably, -@scheme[free-identifier=?] determines whether two identifiers refer +@racket[free-identifier=?] determines whether two identifiers refer to the same binding: @interaction[ @@ -83,7 +83,7 @@ to the same binding: (identifier? #'(+ 1 2)) (free-identifier=? #'car #'cdr) (free-identifier=? #'car #'car) -(require (only-in scheme/base [car also-car])) +(require (only-in racket/base [car also-car])) (free-identifier=? #'car #'also-car) (free-identifier=? #'car (let ([car 8]) #'car)) @@ -93,13 +93,13 @@ The last example above, in particular, illustrates how syntax objects preserve lexical-context information. To see the lists, symbols, numbers, @|etc| within a syntax object, use -@scheme[syntax->datum]: +@racket[syntax->datum]: @interaction[ (syntax->datum #'(+ 1 2)) ] -The @scheme[syntax-e] function is similar to @scheme[syntax->datum], +The @racket[syntax-e] function is similar to @racket[syntax->datum], but it unwraps a single layer of source-location and lexical-context information, leaving sub-forms that have their own information wrapped as syntax objects: @@ -108,16 +108,16 @@ as syntax objects: (syntax-e #'(+ 1 2)) ] -The @scheme[syntax-e] function always leaves syntax-object wrappers +The @racket[syntax-e] function always leaves syntax-object wrappers around sub-forms that are represented via symbols, numbers, and other literal values. The only time it unwraps extra sub-forms is when -unwrapping a pair, in which case the @scheme[cdr] of the pair may be +unwrapping a pair, in which case the @racket[cdr] of the pair may be recursively unwrapped, depending on how the syntax object was constructed. -The opposite of @scheme[syntax->datum] is, of course, -@scheme[datum->syntax]. In addition to a datum like @scheme['(+ 1 -2)], @scheme[datum->syntax] needs an existing syntax object to donate +The opposite of @racket[syntax->datum] is, of course, +@racket[datum->syntax]. In addition to a datum like @racket['(+ 1 +2)], @racket[datum->syntax] needs an existing syntax object to donate its lexical context, and optionally another syntax object to donate its source location: @@ -127,44 +127,44 @@ its source location: #'srcloc) ] -In the above example, the lexical context of @scheme[#'lex] is used +In the above example, the lexical context of @racket[#'lex] is used for the new syntax object, while the source location of -@scheme[#'srcloc] is used. +@racket[#'srcloc] is used. When the second (i.e., the ``datum'') argument to -@scheme[datum->syntax] includes syntax objects, those syntax objects +@racket[datum->syntax] includes syntax objects, those syntax objects are preserved intact in the result. That is, deconstructing the result -with @scheme[syntax-e] eventually produces the syntax objects that -were given to @scheme[datum->syntax]. +with @racket[syntax-e] eventually produces the syntax objects that +were given to @racket[datum->syntax]. @; ---------------------------------------- -@section[#:tag "syntax-case"]{Mixing Patterns and Expressions: @scheme[syntax-case]} +@section[#:tag "syntax-case"]{Mixing Patterns and Expressions: @racket[syntax-case]} -The procedure generated by @scheme[syntax-rules] internally uses -@scheme[syntax-e] to deconstruct the given syntax object, and it uses -@scheme[datum->syntax] to construct the result. The -@scheme[syntax-rules] form doesn't provide a way to escape from +The procedure generated by @racket[syntax-rules] internally uses +@racket[syntax-e] to deconstruct the given syntax object, and it uses +@racket[datum->syntax] to construct the result. The +@racket[syntax-rules] form doesn't provide a way to escape from pattern-matching and template-construction mode into an arbitrary -Scheme expression. +Racket expression. -The @scheme[syntax-case] form lets you mix pattern matching, template +The @racket[syntax-case] form lets you mix pattern matching, template construction, and arbitrary expressions: @specform[(syntax-case stx-expr (literal-id ...) [pattern expr] ...)] -Unlike @scheme[syntax-rules], the @scheme[syntax-case] form does not -produce a procedure. Instead, it starts with a @scheme[_stx-expr] +Unlike @racket[syntax-rules], the @racket[syntax-case] form does not +produce a procedure. Instead, it starts with a @racket[_stx-expr] expression that determines the syntax object to match against the -@scheme[_pattern]s. Also, each @scheme[syntax-case] clause has a -@scheme[_pattern] and @scheme[_expr], instead of a @scheme[_pattern] -and @scheme[_template]. Within an @scheme[_expr], the @scheme[syntax] +@racket[_pattern]s. Also, each @racket[syntax-case] clause has a +@racket[_pattern] and @racket[_expr], instead of a @racket[_pattern] +and @racket[_template]. Within an @racket[_expr], the @racket[syntax] form---usually abbreviated with @litchar{#'}---shifts into -template-construction mode; if the @scheme[_expr] of a clause starts -with @litchar{#'}, then we have something like a @scheme[syntax-rules] +template-construction mode; if the @racket[_expr] of a clause starts +with @litchar{#'}, then we have something like a @racket[syntax-rules] form: @interaction[ @@ -173,10 +173,10 @@ form: [(op n1 n2) #'(- n1 n2)])) ] -We could write the @scheme[swap] macro using @scheme[syntax-case] -instead of @scheme[define-syntax-rule] or @scheme[syntax-rules]: +We could write the @racket[swap] macro using @racket[syntax-case] +instead of @racket[define-syntax-rule] or @racket[syntax-rules]: -@schemeblock[ +@racketblock[ (define-syntax swap (lambda (stx) (syntax-case stx () @@ -185,15 +185,15 @@ instead of @scheme[define-syntax-rule] or @scheme[syntax-rules]: (set! y tmp))]))) ] -One advantage of using @scheme[syntax-case] is that we can provide -better error reporting for @scheme[swap]. For example, with the -@scheme[define-syntax-rule] definition of @scheme[swap], then -@scheme[(swap x 2)] produces a syntax error in terms of @scheme[set!], -because @scheme[2] is not an identifier. We can refine our -@scheme[syntax-case] implementation of @scheme[swap] to explicitly +One advantage of using @racket[syntax-case] is that we can provide +better error reporting for @racket[swap]. For example, with the +@racket[define-syntax-rule] definition of @racket[swap], then +@racket[(swap x 2)] produces a syntax error in terms of @racket[set!], +because @racket[2] is not an identifier. We can refine our +@racket[syntax-case] implementation of @racket[swap] to explicitly check the sub-forms: -@schemeblock[ +@racketblock[ (define-syntax swap (lambda (stx) (syntax-case stx () @@ -211,29 +211,29 @@ check the sub-forms: #'x)))]))) ] -With this definition, @scheme[(swap x 2)] provides a syntax error -originating from @scheme[swap] instead of @scheme[set!]. +With this definition, @racket[(swap x 2)] provides a syntax error +originating from @racket[swap] instead of @racket[set!]. -In the above definition of @scheme[swap], @scheme[#'x] and -@scheme[#'y] are templates, even though they are not used as the +In the above definition of @racket[swap], @racket[#'x] and +@racket[#'y] are templates, even though they are not used as the result of the macro transformer. This example illustrates how templates can be used to access pieces of the input syntax, in this case for checking the form of the pieces. Also, the match for -@scheme[#'x] or @scheme[#'y] is used in the call to -@scheme[raise-syntax-error], so that the syntax-error message can +@racket[#'x] or @racket[#'y] is used in the call to +@racket[raise-syntax-error], so that the syntax-error message can point directly to the source location of the non-identifier. @; ---------------------------------------- -@section[#:tag "with-syntax"]{@scheme[with-syntax] and @scheme[generate-temporaries]} +@section[#:tag "with-syntax"]{@racket[with-syntax] and @racket[generate-temporaries]} -Since @scheme[syntax-case] lets us compute with arbitrary Scheme +Since @racket[syntax-case] lets us compute with arbitrary Racket expression, we can more simply solve a problem that we had in -writing @scheme[define-for-cbr] (see +writing @racket[define-for-cbr] (see @secref["pattern-macro-example"]), where we needed to generate a -set of names based on a sequence @scheme[id ...]: +set of names based on a sequence @racket[id ...]: -@schemeblock[ +@racketblock[ (define-syntax (define-for-cbr stx) (syntax-case stx () [(_ do-f (id ...) body) @@ -243,17 +243,17 @@ set of names based on a sequence @scheme[id ...]: body) ....])) ] -@margin-note{This example uses @scheme[(define-syntax (_id _arg) _body ...+)], - which is equivalent to @scheme[(define-syntax _id (lambda (_arg) _body ...+))].} +@margin-note{This example uses @racket[(define-syntax (_id _arg) _body ...+)], + which is equivalent to @racket[(define-syntax _id (lambda (_arg) _body ...+))].} -In place of the @scheme[....]s above, we need to bind @scheme[get -...] and @scheme[put ...] to lists of generated identifiers. We -cannot use @scheme[let] to bind @scheme[get] and @scheme[put], +In place of the @racket[....]s above, we need to bind @racket[get +...] and @racket[put ...] to lists of generated identifiers. We +cannot use @racket[let] to bind @racket[get] and @racket[put], because we need bindings that count as pattern variables, instead -of normal local variables. The @scheme[with-syntax] form lets us +of normal local variables. The @racket[with-syntax] form lets us bind pattern variables: -@schemeblock[ +@racketblock[ (define-syntax (define-for-cbr stx) (syntax-case stx () [(_ do-f (id ...) body) @@ -264,14 +264,14 @@ bind pattern variables: body))])) ] -Now we need an expression in place of @scheme[....] that -generates as many identifiers as there are @scheme[id] matches in -the original pattern. Since this is a common task, Scheme -provides a helper function, @scheme[generate-temporaries], that +Now we need an expression in place of @racket[....] that +generates as many identifiers as there are @racket[id] matches in +the original pattern. Since this is a common task, Racket +provides a helper function, @racket[generate-temporaries], that takes a sequece of identifiers and returns a sequence of generated identifiers: -@schemeblock[ +@racketblock[ (define-syntax (define-for-cbr stx) (syntax-case stx () [(_ do-f (id ...) body) @@ -286,9 +286,9 @@ This way of generating identifiers is normally easier to think about than tricking the macro expander into generating names with purely pattern-based macros. -In general, the right-hand side of a @scheme[with-syntax] -binding is a pattern, just like in @scheme[syntax-case]. In fact, -a @scheme[with-syntax] form is just a @scheme[syntax-case] form +In general, the right-hand side of a @racket[with-syntax] +binding is a pattern, just like in @racket[syntax-case]. In fact, +a @racket[with-syntax] form is just a @racket[syntax-case] form turned partially inside-out. @; ---------------------------------------- @@ -297,13 +297,13 @@ turned partially inside-out. As sets of macros get more complicated, you might want to write your own helper functions, like -@scheme[generate-temporaries]. For example, to provide good -syntax-error messsage, @scheme[swap], @scheme[rotate], and -@scheme[define-cbr] all should check that certain sub-forms in +@racket[generate-temporaries]. For example, to provide good +syntax-error messsage, @racket[swap], @racket[rotate], and +@racket[define-cbr] all should check that certain sub-forms in the source form are identifiers. We could use a -@scheme[check-ids] to perform this checking everywhere: +@racket[check-ids] to perform this checking everywhere: -@schemeblock/eval[ +@racketblock/eval[ #:eval check-eval (define-syntax (swap stx) (syntax-case stx () @@ -321,11 +321,11 @@ the source form are identifiers. We could use a #'(shift-to (c ... a) (a c ...)))])) ] -The @scheme[check-ids] function can use the @scheme[syntax->list] +The @racket[check-ids] function can use the @racket[syntax->list] function to convert a syntax-object wrapping a list into a list of syntax objects: -@schemeblock[ +@racketblock[ (define (check-ids stx forms) (for-each (lambda (form) @@ -337,7 +337,7 @@ of syntax objects: (syntax->list forms))) ] -If you define @scheme[swap] and @scheme[check-ids] in this way, +If you define @racket[swap] and @racket[check-ids] in this way, however, it doesn't work: @interaction[ @@ -345,18 +345,18 @@ however, it doesn't work: (let ([a 1] [b 2]) (swap a b)) ] -The problem is that @scheme[check-ids] is defined as a run-time -expression, but @scheme[swap] is trying to use it at compile time. In +The problem is that @racket[check-ids] is defined as a run-time +expression, but @racket[swap] is trying to use it at compile time. In interactive mode, compile time and run time are interleaved, but they are not interleaved within the body of a module, and they are not interleaved or across modules that are compiled ahead-of-time. To help -make all of these modes treat code consistently, Scheme separates the +make all of these modes treat code consistently, Racket separates the binding spaces for different phases. -To define a @scheme[check-ids] function that can be referenced at -compile time, use @scheme[define-for-syntax]: +To define a @racket[check-ids] function that can be referenced at +compile time, use @racket[define-for-syntax]: -@schemeblock/eval[ +@racketblock/eval[ #:eval check-eval (define-for-syntax (check-ids stx forms) (for-each @@ -369,7 +369,7 @@ compile time, use @scheme[define-for-syntax]: (syntax->list forms))) ] -With this for-syntax definition, then @scheme[swap] works: +With this for-syntax definition, then @racket[swap] works: @interaction[ #:eval check-eval @@ -380,11 +380,11 @@ With this for-syntax definition, then @scheme[swap] works: When organizing a program into modules, you may want to put helper functions in one module to be used by macros that reside on other modules. In that case, you can write the helper function using -@scheme[define]: +@racket[define]: -@schememod[#:file +@racketmod[#:file "utils.ss" -scheme +racket (provide check-ids) @@ -400,11 +400,11 @@ scheme ] Then, in the module that implements macros, import the helper function -using @scheme[(require (for-syntax "utils.ss"))] instead of -@scheme[(require "utils.ss")]: +using @racket[(require (for-syntax "utils.ss"))] instead of +@racket[(require "utils.ss")]: -@schememod[ -scheme +@racketmod[ +racket (require (for-syntax "utils.ss")) @@ -420,38 +420,38 @@ scheme Since modules are separately compiled and cannot have circular dependencies, the @filepath["utils.ss"] module's run-time body can be compiled before the compiling the module that implements -@scheme[swap]. Thus, the run-time definitions in -@filepath["utils.ss"] can be used to implement @scheme[swap], as long -as they are explicitly shifted into compile time by @scheme[(require +@racket[swap]. Thus, the run-time definitions in +@filepath["utils.ss"] can be used to implement @racket[swap], as long +as they are explicitly shifted into compile time by @racket[(require (for-syntax ....))]. -The @schememodname[scheme] module provides @scheme[syntax-case], -@scheme[generate-temporaries], @scheme[lambda], @scheme[if], and more +The @racketmodname[racket] module provides @racket[syntax-case], +@racket[generate-temporaries], @racket[lambda], @racket[if], and more for use in both the run-time and compile-time phases. That is why we -can use @scheme[syntax-case] in the @scheme[mzscheme] @tech{REPL} both -directly and in the right-hand side of a @scheme[define-syntax] +can use @racket[syntax-case] in the @exec{racket} @tech{REPL} both +directly and in the right-hand side of a @racket[define-syntax] form. -The @schememodname[scheme/base] module, in contrast, exports those +The @racketmodname[racket/base] module, in contrast, exports those bindings only in the run-time phase. If you change the module above -that defines @scheme[swap] so that it uses the -@schememodname[scheme/base] language instead of -@schememodname[scheme], then it no longer works. Adding -@scheme[(require (for-syntax scheme/base))] imports -@scheme[syntax-case] and more into the compile-time phase, so that the +that defines @racket[swap] so that it uses the +@racketmodname[racket/base] language instead of +@racketmodname[racket], then it no longer works. Adding +@racket[(require (for-syntax racket/base))] imports +@racket[syntax-case] and more into the compile-time phase, so that the module works again. -Suppose that @scheme[define-syntax] is used to define a local macro in -the right-hand side of a @scheme[define-syntax] form. In that case, -the right-hand side of the inner @scheme[define-syntax] is in the +Suppose that @racket[define-syntax] is used to define a local macro in +the right-hand side of a @racket[define-syntax] form. In that case, +the right-hand side of the inner @racket[define-syntax] is in the @deftech{meta-compile phase level}, also known as @deftech{phase level -2}. To import @scheme[syntax-case] into that phase level, you would -have to use @scheme[(require (for-syntax (for-syntax scheme/base)))] -or, equivalently, @scheme[(require (for-meta 2 scheme/base))]. +2}. To import @racket[syntax-case] into that phase level, you would +have to use @racket[(require (for-syntax (for-syntax racket/base)))] +or, equivalently, @racket[(require (for-meta 2 racket/base))]. Negative phase levels also exist. If a macro uses a helper function -that is imported @scheme[for-syntax], and if the helper function -returns syntax-object constants generated by @scheme[syntax], then +that is imported @racket[for-syntax], and if the helper function +returns syntax-object constants generated by @racket[syntax], then identifiers in the syntax will need bindings at @deftech{phase level -1}, also known as the @deftech{template phase level}, to have any binding at the run-time phase level relative to the module that diff --git a/collects/scribblings/guide/regexp.scrbl b/collects/scribblings/guide/regexp.scrbl index 020315eb6f..5f17e308e7 100644 --- a/collects/scribblings/guide/regexp.scrbl +++ b/collects/scribblings/guide/regexp.scrbl @@ -12,7 +12,7 @@ A @deftech{regexp} value encapsulates a pattern that is described by a string or @tech{byte string}. The regexp matcher tries to match this pattern against (a portion of) another string or byte string, which we will call the @deftech{text string}, when you call functions like -@scheme[regexp-match]. The text string is treated as raw text, and +@racket[regexp-match]. The text string is treated as raw text, and not as a pattern. @local-table-of-contents[] @@ -25,30 +25,30 @@ not as a pattern. A string or @tech{byte string} can be used directly as a @tech{regexp} pattern, or it can be prefixed with @litchar{#rx} to form a literal -@tech{regexp} value. For example, @scheme[#rx"abc"] is a string-based -@tech{regexp} value, and @scheme[#rx#"abc"] is a @tech{byte +@tech{regexp} value. For example, @racket[#rx"abc"] is a string-based +@tech{regexp} value, and @racket[#rx#"abc"] is a @tech{byte string}-based @tech{regexp} value. Alternately, a string or byte -string can be prefixed with @litchar{#px}, as in @scheme[#px"abc"], +string can be prefixed with @litchar{#px}, as in @racket[#px"abc"], for a slightly extended syntax of patterns within the string. Most of the characters in a @tech{regexp} pattern are meant to match occurrences of themselves in the @tech{text string}. Thus, the pattern -@scheme[#rx"abc"] matches a string that contains the characters +@racket[#rx"abc"] matches a string that contains the characters @litchar{a}, @litchar{b}, and @litchar{c} in succession. Other characters act as @deftech{metacharacters}, and some character sequences act as @deftech{metasequences}. That is, they specify something other than their literal selves. For example, in the -pattern @scheme[#rx"a.c"], the characters @litchar{a} and @litchar{c} +pattern @racket[#rx"a.c"], the characters @litchar{a} and @litchar{c} stand for themselves, but the @tech{metacharacter} @litchar{.} can -match @emph{any} character. Therefore, the pattern @scheme[#rx"a.c"] +match @emph{any} character. Therefore, the pattern @racket[#rx"a.c"] matches an @litchar{a}, any character, and @litchar{c} in succession. -@margin-note{When we want a literal @litchar{\} inside a Scheme string +@margin-note{When we want a literal @litchar{\} inside a Racket string or regexp literal, we must escape it so that it shows up in the string -at all. Scheme strings use @litchar{\} as the escape character, so we -end up with two @litchar{\}s: one Scheme-string @litchar{\} to escape +at all. Racket strings use @litchar{\} as the escape character, so we +end up with two @litchar{\}s: one Racket-string @litchar{\} to escape the regexp @litchar{\}, which then escapes the @litchar{.}. Another -character that would need escaping inside a Scheme string is +character that would need escaping inside a Racket string is @litchar{"}.} If we needed to match the character @litchar{.} itself, we can escape @@ -56,19 +56,19 @@ it by precede it with a @litchar{\}. The character sequence @litchar{\.} is thus a @tech{metasequence}, since it doesn't match itself but rather just @litchar{.}. So, to match @litchar{a}, @litchar{.}, and @litchar{c} in succession, we use the regexp pattern -@scheme[#rx"a\\.c"]; the double @litchar{\} is an artifact of Scheme +@racket[#rx"a\\.c"]; the double @litchar{\} is an artifact of Racket strings, not the @tech{regexp} pattern itself. -The @scheme[regexp] function takes a string or byte string and -produces a @tech{regexp} value. Use @scheme[regexp] when you construct +The @racket[regexp] function takes a string or byte string and +produces a @tech{regexp} value. Use @racket[regexp] when you construct a pattern to be matched against multiple strings, since a pattern is compiled to a @tech{regexp} value before it can be used in a match. -The @scheme[pregexp] function is like @scheme[regexp], but using the +The @racket[pregexp] function is like @racket[regexp], but using the extended syntax. Regexp values as literals with @litchar{#rx} or @litchar{#px} are compiled once and for all when they are read. -The @scheme[regexp-quote] function takes an arbitrary string and +The @racket[regexp-quote] function takes an arbitrary string and returns a string for a pattern that matches exactly the original string. In particular, characters in the input string that could serve as regexp metacharacters are escaped with a backslash, so that they @@ -79,7 +79,7 @@ safely match only themselves. (regexp-quote "list?") ] -The @scheme[regexp-quote] function is useful when building a composite +The @racket[regexp-quote] function is useful when building a composite @tech{regexp} from a mix of @tech{regexp} strings and verbatim strings. @@ -87,9 +87,9 @@ The @scheme[regexp-quote] function is useful when building a composite @section[#:tag "regexp-match"]{Matching Regexp Patterns} -The @scheme[regexp-match-positions] function takes a @tech{regexp} +The @racket[regexp-match-positions] function takes a @tech{regexp} pattern and a @tech{text string}, and it returns a match if the regexp -matches (some part of) the @tech{text string}, or @scheme[#f] if the regexp +matches (some part of) the @tech{text string}, or @racket[#f] if the regexp did not match the string. A successful match produces a list of @deftech{index pairs}. @@ -98,22 +98,22 @@ did not match the string. A successful match produces a list of (regexp-match-positions #rx"needle" "hay needle stack") ] -In the second example, the integers @scheme[4] and @scheme[10] -identify the substring that was matched. The @scheme[4] is the -starting (inclusive) index, and @scheme[10] the ending (exclusive) +In the second example, the integers @racket[4] and @racket[10] +identify the substring that was matched. The @racket[4] is the +starting (inclusive) index, and @racket[10] the ending (exclusive) index of the matching substring: @interaction[ (substring "hay needle stack" 4 10) ] -In this first example, @scheme[regexp-match-positions]'s return list +In this first example, @racket[regexp-match-positions]'s return list contains only one index pair, and that pair represents the entire substring matched by the regexp. When we discuss @tech{subpatterns} later, we will see how a single match operation can yield a list of @tech{submatch}es. -The @scheme[regexp-match-positions] function takes optional third and +The @racket[regexp-match-positions] function takes optional third and fourth arguments that specify the indices of the @tech{text string} within which the matching should take place. @@ -127,8 +127,8 @@ which the matching should take place. Note that the returned indices are still reckoned relative to the full @tech{text string}. -The @scheme[regexp-match] function is like -@scheme[regexp-match-positions], but instead of returning index pairs, +The @racket[regexp-match] function is like +@racket[regexp-match-positions], but instead of returning index pairs, it returns the matching substrings: @interaction[ @@ -136,7 +136,7 @@ it returns the matching substrings: (regexp-match #rx"needle" "hay needle stack") ] -When @scheme[regexp-match] is used with byte-string regexp, the result +When @racket[regexp-match] is used with byte-string regexp, the result is a matching byte substring: @interaction[ @@ -153,7 +153,7 @@ is a matching byte substring: avoids UTF-8 encodings.} If you have data that is in a port, there's no need to first read it -into a string. Functions like @scheme[regexp-match] can match on the +into a string. Functions like @racket[regexp-match] can match on the port directly: @interaction[ @@ -163,8 +163,8 @@ port directly: (regexp-match #rx#"needle" i) ] -The @scheme[regexp-match?] function is like -@scheme[regexp-match-positions], but simply returns a boolean +The @racket[regexp-match?] function is like +@racket[regexp-match-positions], but simply returns a boolean indicating whether the match succeeded: @interaction[ @@ -172,7 +172,7 @@ indicating whether the match succeeded: (regexp-match? #rx"needle" "hay needle stack") ] -The @scheme[regexp-split] function takes two arguments, a +The @racket[regexp-split] function takes two arguments, a @tech{regexp} pattern and a text string, and it returns a list of substrings of the text string; the pattern identifies the delimiter separating the substrings. @@ -190,32 +190,32 @@ single-character substrings is returned. ] Thus, to identify one-or-more spaces as the delimiter, take care to -use the regexp @scheme[#rx"\u20+"], not @scheme[#rx"\u20*"]. +use the regexp @racket[#rx"\u20+"], not @racket[#rx"\u20*"]. @interaction[ (regexp-split #rx" +" "split pea soup") (regexp-split #rx" *" "split pea soup") ] -The @scheme[regexp-replace] function replaces the matched portion of +The @racket[regexp-replace] function replaces the matched portion of the text string by another string. The first argument is the pattern, the second the text string, and the third is either the string to be inserted or a procedure to convert matches to the insert string. @interaction[ (regexp-replace #rx"te" "liberte" "ty") -(regexp-replace #rx"." "scheme" string-upcase) +(regexp-replace #rx"." "racket" string-upcase) ] If the pattern doesn't occur in the text string, the returned string is identical to the text string. -The @scheme[regexp-replace*] function replaces @emph{all} matches in +The @racket[regexp-replace*] function replaces @emph{all} matches in the text string by the insert string: @interaction[ (regexp-replace* #rx"te" "liberte egalite fraternite" "ty") -(regexp-replace* #rx"[ds]" "drscheme" string-upcase) +(regexp-replace* #rx"[ds]" "drracket" string-upcase) ] @; ---------------------------------------- @@ -285,20 +285,20 @@ A @deftech{character class} matches any one character from a set of characters. A typical format for this is the @deftech{bracketed character class} @litchar{[}...@litchar{]}, which matches any one character from the non-empty sequence of characters enclosed within -the brackets. Thus, @scheme[#rx"p[aeiou]t"] matches @litchar{pat}, +the brackets. Thus, @racket[#rx"p[aeiou]t"] matches @litchar{pat}, @litchar{pet}, @litchar{pit}, @litchar{pot}, @litchar{put}, and nothing else. Inside the brackets, a @litchar{-} between two characters specifies the Unicode range between the characters. For example, -@scheme[#rx"ta[b-dgn-p]"] matches @litchar{tab}, @litchar{tac}, +@racket[#rx"ta[b-dgn-p]"] matches @litchar{tab}, @litchar{tac}, @litchar{tad}, @litchar{tag}, @litchar{tan}, @litchar{tao}, and @litchar{tap}. An initial @litchar{^} after the left bracket inverts the set specified by the rest of the contents; i.e., it specifies the set of characters @emph{other than} those identified in the brackets. For -example, @scheme[#rx"do[^g]"] matches all three-character sequences +example, @racket[#rx"do[^g]"] matches all three-character sequences starting with @litchar{do} except @litchar{dog}. Note that the @tech{metacharacter} @litchar{^} inside brackets means @@ -314,12 +314,12 @@ Bracketed character classes cannot contain other bracketed character classes (although they contain certain other types of character classes; see below). Thus, a @litchar{[} inside a bracketed character class doesn't have to be a metacharacter; it can stand for itself. -For example, @scheme[#rx"[a[b]"] matches @litchar{a}, @litchar{[}, and +For example, @racket[#rx"[a[b]"] matches @litchar{a}, @litchar{[}, and @litchar{b}. Furthermore, since empty bracketed character classes are disallowed, a @litchar{]} immediately occurring after the opening left bracket also -doesn't need to be a metacharacter. For example, @scheme[#rx"[]ab]"] +doesn't need to be a metacharacter. For example, @racket[#rx"[]ab]"] matches @litchar{]}, @litchar{a}, and @litchar{b}. @subsection{Some Frequently Used Character Classes} @@ -333,7 +333,7 @@ bracketed expressions: @litchar{\d} matches a digit @margin-note{Following regexp custom, we identify ``word'' characters as @litchar{[A-Za-z0-9_]}, although these are too restrictive for what -a Schemer might consider a ``word.''} +a Racketr might consider a ``word.''} The upper-case versions of these metasequences stand for the inversions of the corresponding character classes: @litchar{\D} @@ -341,7 +341,7 @@ matches a non-digit, @litchar{\S} a non-whitespace character, and @litchar{\W} a non-``word'' character. Remember to include a double backslash when putting these -metasequences in a Scheme string: +metasequences in a Racket string: @interaction[ (regexp-match #px"\\d\\d" @@ -349,7 +349,7 @@ metasequences in a Scheme string: ] These character classes can be used inside a bracketed expression. For -example, @scheme[#px"[a-z\\d]"] matches a lower-case letter or a +example, @racket[#px"[a-z\\d]"] matches a lower-case letter or a digit. @subsection{POSIX character classes} @@ -389,7 +389,7 @@ supported are ] -For example, the @scheme[#px"[[:alpha:]_]"] matches a letter or +For example, the @racket[#px"[[:alpha:]_]"] matches a letter or underscore. @interaction[ @@ -516,7 +516,7 @@ it is the last submatch that is returned. It is also possible for a quantified subpattern to fail to match, even if the overall pattern matches. In such cases, the failing submatch -is represented by @scheme[#f] +is represented by @racket[#f] @interaction[ (define date-re @@ -531,7 +531,7 @@ is represented by @scheme[#f] @subsection{Backreferences} @tech{Submatch}es can be used in the insert string argument of the -procedures @scheme[regexp-replace] and @scheme[regexp-replace*]. The +procedures @racket[regexp-replace] and @racket[regexp-replace*]. The insert string can use @litchar{\}@math{n} as a @deftech{backreference} to refer back to the @math{n}th submatch, which is the substring that matched the @math{n}th subpattern. A @litchar{\0} refers to the @@ -612,11 +612,11 @@ In the following example, a non-capturing cluster eliminates the cluster identifies the basename. @margin-note{But don't parse paths with regexps. Use functions like - @scheme[split-path], instead.} + @racket[split-path], instead.} @interaction[ (regexp-match #rx"^(?:[a-z]*/)*([a-z]+)$" - "/usr/local/bin/mzscheme") + "/usr/local/bin/racket") ] @subsection[#:tag "regexp-cloister"]{Cloisters} @@ -734,7 +734,7 @@ Consider The regexp consists of two subregexps: @litchar{a*} followed by @litchar{a}. The subregexp @litchar{a*} cannot be allowed to match -all four @litchar{a}'s in the text string @scheme[aaaa], even though +all four @litchar{a}'s in the text string @racket[aaaa], even though @litchar{*} is a greedy quantifier. It may match only the first three, leaving the last one for the second subregexp. This ensures that the full regexp matches successfully. @@ -800,7 +800,7 @@ its subpattern @emph{could} match. "i left my grey socks at the greyhound") ] -The regexp @scheme[#rx"grey(?=hound)"] matches @litchar{grey}, but +The regexp @racket[#rx"grey(?=hound)"] matches @litchar{grey}, but @emph{only} if it is followed by @litchar{hound}. Thus, the first @litchar{grey} in the text string is not matched. @@ -812,7 +812,7 @@ subpattern @emph{could not} possibly match. "the gray greyhound ate the grey socks") ] -The regexp @scheme[#rx"grey(?!hound)"] matches @litchar{grey}, but +The regexp @racket[#rx"grey(?!hound)"] matches @litchar{grey}, but only if it is @emph{not} followed by @litchar{hound}. Thus the @litchar{grey} just before @litchar{socks} is matched. @@ -827,7 +827,7 @@ the text string. "the hound in the picture is not a greyhound") ] -The regexp @scheme[#rx"(?<=grey)hound"] matches @litchar{hound}, but +The regexp @racket[#rx"(?<=grey)hound"] matches @litchar{hound}, but only if it is preceded by @litchar{grey}. Negative lookbehind with @litchar{? } prompt: @verbatim[#:indent 2]{ - Welcome to MzScheme + Welcome to Racket > } @margin-note{For information on GNU Readline support, see -@schememodname[readline].} +@racketmodname[readline].} -To initialize the @tech{REPL}'s environment, @exec{mzscheme} first -requires the @schememodname[scheme/init] module, which provides all of -@scheme[scheme], and also installs @scheme[pretty-print] for display -results. Finally, @exec{mzscheme} loads the file reported by -@scheme[(find-system-path 'init-file)], if it exists, before starting +To initialize the @tech{REPL}'s environment, @exec{racket} first +requires the @racketmodname[racket/init] module, which provides all of +@racket[racket], and also installs @racket[pretty-print] for display +results. Finally, @exec{racket} loads the file reported by +@racket[(find-system-path 'init-file)], if it exists, before starting the @tech{REPL}. If any command-line arguments are provided (other than configuration options), add @Flag{i} or @DFlag{repl} to re-enable the @tech{REPL}. For example, -@commandline{mzscheme -e '(display "hi\n")' -i} +@commandline{racket -e '(display "hi\n")' -i} displays ``hi'' on start-up, but still presents a @tech{REPL}. If module-requiring flags appear before @Flag{i}/@DFlag{repl}, they -cancel the automatic requiring of @schememodname[scheme/init]. This +cancel the automatic requiring of @racketmodname[racket/init]. This behavior can be used to initialize the @tech{REPL}'s environment with a different language. For example, -@commandline{mzscheme -l scheme/base -i} +@commandline{racket -l racket/base -i} starts a @tech{REPL} using a much smaller initial language (that loads much faster). Beware that most modules do not provide the basic syntax -of Scheme, including function-call syntax and @scheme[require]. For +of Racket, including function-call syntax and @racket[require]. For example, -@commandline{mzscheme -l scheme/date -i} +@commandline{racket -l racket/date -i} produces a @tech{REPL} that fails for every expression, because -@schememodname[scheme/date] provides only a few functions, and not the -@scheme[#%top-interaction] and @scheme[#%app] bindings that are needed +@racketmodname[racket/date] provides only a few functions, and not the +@racket[#%top-interaction] and @racket[#%app] bindings that are needed to evaluate top-level function calls in the @tech{REPL}. If a module-requiring flag appears after @Flag{i}/@DFlag{repl} instead of before it, then the module is required after -@schememodname[scheme/init] to augment the initial environment. For +@racketmodname[racket/init] to augment the initial environment. For example, -@commandline{mzscheme -i -l scheme/date} +@commandline{racket -i -l racket/date} -starts a useful @tech{REPL} with @schememodname[scheme/date] available -in addition to the exports of @schememodname[scheme]. +starts a useful @tech{REPL} with @racketmodname[racket/date] available +in addition to the exports of @racketmodname[racket]. @; ---------------------------------------- @subsection[#:tag "start-module-mode"]{Module Mode} -If a file argument is supplied to @exec{mzscheme} before any +If a file argument is supplied to @exec{racket} before any command-line switch (other than configuration options), then the file is required as a module, and (unless @Flag{i}/@DFlag{repl} is specified), no @tech{REPL} is started. For example, -@commandline{mzscheme hello.ss} +@commandline{racket hello.rkt} -requires the @filepath{hello.ss} module and then exits. Any argument +requires the @filepath{hello.rkt} module and then exits. Any argument after the file name, flag or otherwise, is preserved as a command-line argument for use by the required module via -@scheme[current-command-line-arguments]. +@racket[current-command-line-arguments]. If command-line flags are used, then the @Flag{u} or @DFlag{require-script} flag can be used to explicitly require a file as a module. The @Flag{t} or @DFlag{require} flag is similar, except -that additional command-line flags are processed by @exec{mzscheme}, +that additional command-line flags are processed by @exec{racket}, instead of preserved for the required module. For example, -@commandline{mzscheme -t hello.ss -t goodbye.ss} +@commandline{racket -t hello.rkt -t goodbye.rkt} -requires the @filepath{hello.ss} module, then requires the -@filepath{goodbye.ss} module, and then exits. +requires the @filepath{hello.rkt} module, then requires the +@filepath{goodbye.rkt} module, and then exits. The @Flag{l} or @DFlag{lib} flag is similar to @Flag{t}/@DFlag{require}, but it requires a module using a -@scheme[lib] module path instead of a file path. For example, +@racket[lib] module path instead of a file path. For example, -@commandline{mzscheme -l compiler} +@commandline{racket -l raco} -is the same as running the @exec{mzc} executable with no arguments, -since the @scheme[compiler] module is the main @exec{mzc} -module. +is the same as running the @exec{raco} executable with no arguments, +since the @racket[raco] module is the executable's main module. Note that if you wanted to pass command-line flags to -@scheme[compiler] above, you would need to protect the flags with a -@Flag{-}, so that @exec{mzscheme} doesn't try to parse them itself: +@racket[raco] above, you would need to protect the flags with a +@Flag{-}, so that @exec{racket} doesn't try to parse them itself: -@commandline{mzscheme -l compiler -- --make prog.ss} +@commandline{racket -l raco -- --help} @; ---------------------------------------- @subsection[#:tag "start-load-mode"]{Load Mode} -The @Flag{f} or @DFlag{load} flag supports @scheme[load]ing top-level +The @Flag{f} or @DFlag{load} flag supports @racket[load]ing top-level expressions in a file directly, as opposed to expressions within a module file. This evaluation is like starting a @tech{REPL} and typing the expressions directly, except that the results are not printed. For example, -@commandline{mzscheme -f hi.ss} +@commandline{racket -f hi.rkts} -@scheme[load]s @filepath{hi.ss} and exits. Note that load mode is +@racket[load]s @filepath{hi.rkts} and exits. Note that load mode is generally a bad idea, for the reasons explained in @secref["use-module"]; using module mode is typically better. @@ -144,21 +143,21 @@ The @Flag{e} or @DFlag{eval} flag accepts an expression to evaluate directly. Unlike file loading, the result of the expression is printed, as in a @tech{REPL}. For example, -@commandline{mzscheme -e '(current-seconds)'} +@commandline{racket -e '(current-seconds)'} prints the number of seconds since January 1, 1970. For file loading and expression evaluation, the top-level environment is created in the same way for @seclink["start-interactive-mode"]{interactive mode}: -@schememodname[scheme/init] is required unless another module is +@racketmodname[racket/init] is required unless another module is specified first. For example, -@commandline{mzscheme -l scheme/base -e '(current-seconds)'} +@commandline{racket -l racket/base -e '(current-seconds)'} likely runs faster, because it initializes the environment for -evaluation using the smaller @schememodname[scheme/base] language, -instead of @schememodname[scheme/init]. +evaluation using the smaller @racketmodname[racket/base] language, +instead of @racketmodname[racket/init]. @; ---------------------------------------------------------------------- diff --git a/collects/scribblings/guide/scripts.scrbl b/collects/scribblings/guide/scripts.scrbl index 5647b65e65..5687051b19 100644 --- a/collects/scribblings/guide/scripts.scrbl +++ b/collects/scribblings/guide/scripts.scrbl @@ -5,13 +5,13 @@ @title[#:tag "scripts"]{Scripts} -Scheme files can be turned into executable scripts under Unix and Mac +Racket files can be turned into executable scripts under Unix and Mac OS X. Under Windows, a compatibility layer like Cygwin support the same kind of scripts, or scripts can be implemented as batch files. @section{Unix Scripts} -In a Unix environment (including Linux and Mac OS X), a Scheme file can +In a Unix environment (including Linux and Mac OS X), a Racket file can be turned into an executable script using the shell's @as-index{@tt{#!}} convention. The first two characters of the file must be @litchar{#!}; the next character must be either a space or @litchar{/}, and the @@ -19,14 +19,14 @@ remainder of the first line must be a command to execute the script. For some platforms, the total length of the first line is restricted to 32 characters, and sometimes the space is required. -The simplest script format uses an absolute path to a @exec{mzscheme} +The simplest script format uses an absolute path to a @exec{racket} executable followed by a module declaration. For example, if -@exec{mzscheme} is installed in @filepath{/usr/local/bin}, then a file +@exec{racket} is installed in @filepath{/usr/local/bin}, then a file containing the following text acts as a ``hello world'' script: @verbatim[#:indent 2]{ - #! /usr/local/bin/mzscheme - #lang scheme/base + #! /usr/local/bin/racket + #lang racket/base "Hello, world!" } @@ -37,43 +37,43 @@ typing @exec{./hello} at the shell prompt produces the output The above script works because the operating system automatically puts the path to the script as the argument to the program started by the -@tt{#!} line, and because @exec{mzscheme} treats a single non-flag +@tt{#!} line, and because @exec{racket} treats a single non-flag argument as a file containing a module to run. -Instead of specifying a complete path to the @exec{mzscheme} -executable, a popular alternative is to require that @exec{mzscheme} +Instead of specifying a complete path to the @exec{racket} +executable, a popular alternative is to require that @exec{racket} is in the user's command path, and then ``trampoline'' using @exec{/usr/bin/env}: @verbatim[#:indent 2]{ - #! /usr/bin/env mzscheme - #lang scheme/base + #! /usr/bin/env racket + #lang racket/base "Hello, world!" } In either case, command-line arguments to a script are available via -@scheme[current-command-line-arguments]: +@racket[current-command-line-arguments]: @verbatim[#:indent 2]{ - #! /usr/bin/env mzscheme - #lang scheme/base + #! /usr/bin/env racket + #lang racket/base (printf "Given arguments: ~s\n" (current-command-line-arguments)) } If the name of the script is needed, it is available via -@scheme[(find-system-path 'run-file)], instead of via -@scheme[(current-command-line-arguments)]. +@racket[(find-system-path 'run-file)], instead of via +@racket[(current-command-line-arguments)]. Usually, then best way to handle command-line arguments is to parse -them using the @scheme[command-line] form provided by -@schememodname[scheme]. The @scheme[command-line] form extracts -command-line arguments from @scheme[(current-command-line-arguments)] +them using the @racket[command-line] form provided by +@racketmodname[racket]. The @racket[command-line] form extracts +command-line arguments from @racket[(current-command-line-arguments)] by default: @verbatim[#:indent 2]{ - #! /usr/bin/env mzscheme - #lang scheme + #! /usr/bin/env racket + #lang racket (define verbose? (make-parameter #f)) @@ -95,47 +95,47 @@ command-line arguments are allowed by the script. An even more general trampoline uses @exec{/bin/sh} plus some lines that are comments in one language and expressions in the other. This trampoline is more complicated, but it provides more control over -command-line arguments to @exec{mzscheme}: +command-line arguments to @exec{racket}: @verbatim[#:indent 2]|{ #! /bin/sh #| - exec mzscheme -cu "$0" ${1+"$@"} + exec racket -cu "$0" ${1+"$@"} |# - #lang scheme/base + #lang racket/base (printf "This script started slowly, because the use of\n") (printf "bytecode files has been disabled via -c.\n") (printf "Given arguments: ~s\n" (current-command-line-arguments)) }| -Note that @litchar{#!} starts a line comment in Scheme, and +Note that @litchar{#!} starts a line comment in Racket, and @litchar{#|}...@litchar{|#} forms a block comment. Meanwhile, @litchar{#} also starts a shell-script comment, while @exec{exec -mzscheme} aborts the shell script to start @exec{mzscheme}. That way, +racket} aborts the shell script to start @exec{racket}. That way, the script file turns out to be valid input to both @exec{/bin/sh} and -@exec{mzscheme}. +@exec{racket}. @section{Windows Batch Files} -A similar trick can be used to write Scheme code in Windows +A similar trick can be used to write Racket code in Windows @as-index{@tt{.bat}} batch files: @verbatim[#:indent 2]|{ ; @echo off - ; MzScheme.exe "%~f0" %* + ; Racket.exe "%~f0" %* ; exit /b - #lang scheme/base + #lang racket/base "Hello, world!" }| @;{ Original trick from Ben Goetter, who used: - ; @echo off && REM -*- scheme -*- - ; "%MZSCHEME%" "%~f0" %* + ; @echo off && REM -*- racket -*- + ; "%RACKET%" "%~f0" %* ; exit /b - #lang scheme + #lang racket ... it might be worth documenting the Emacs "-*-" convention and a way to From bc5cf30ebe1ba3743f7097d81ebf1297435e0201 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Fri, 30 Apr 2010 10:57:32 -0600 Subject: [PATCH 4/5] Renaming rktunit to racunit --- collects/2htdp/tests/batch-io.rkt | 2 +- collects/2htdp/tests/test-image.rkt | 2 +- collects/meta/dist-specs.rkt | 2 +- collects/meta/drdr/pkgs.bak | 40 +++++++++--------- collects/meta/props | 23 +++++----- .../parser-tools/private-lex/error-tests.rkt | 2 +- collects/{rktunit => racunit}/gui.rkt | 2 +- collects/{rktunit => racunit}/info.rkt | 8 ++-- collects/{rktunit => racunit}/main.rkt | 0 .../{rktunit => racunit}/private/base.rkt | 12 +++--- .../private/check-info.rkt | 2 +- .../{rktunit => racunit}/private/check.rkt | 0 .../{rktunit => racunit}/private/counter.rkt | 0 .../{rktunit => racunit}/private/format.rkt | 0 .../private/gui/cache-box.rkt | 0 .../private/gui/config.rkt | 12 +++--- .../private/gui/controller.rkt | 8 ++-- .../private/gui/drracket-link.rkt | 0 .../private/gui/drracket-ui.rkt | 0 .../{rktunit => racunit}/private/gui/gui.rkt | 8 ++-- .../private/gui/gvector.rkt | 0 .../private/gui/interfaces.rkt | 0 .../private/gui/model.rkt | 0 .../private/gui/model2rml.rkt | 0 .../private/gui/output-icon.png | Bin .../{rktunit => racunit}/private/gui/rml.rkt | 12 +++--- .../{rktunit => racunit}/private/gui/view.rkt | 6 +-- .../private/hash-monad.rkt | 0 .../{rktunit => racunit}/private/location.rkt | 0 .../{rktunit => racunit}/private/monad.rkt | 0 .../private/name-collector.rkt | 0 .../{rktunit => racunit}/private/result.rkt | 8 ++-- .../private/test-case.rkt | 0 .../private/test-suite.rkt | 32 +++++++------- .../{rktunit => racunit}/private/test.rkt | 10 ++--- .../private/text-ui-util.rkt | 0 .../{rktunit => racunit}/private/util.rkt | 0 .../scribblings/acknowledgements.scrbl | 6 +-- .../scribblings/api.scrbl | 6 +-- .../{rktunit => racunit}/scribblings/base.rkt | 12 +++--- .../scribblings/check.scrbl | 4 +- .../scribblings/compound-testing.scrbl | 2 +- .../scribblings/control-flow.scrbl | 2 +- .../scribblings/file-test.rkt | 2 +- .../{rktunit => racunit}/scribblings/file.rkt | 0 .../scribblings/misc.scrbl | 4 +- .../scribblings/overview.scrbl | 4 +- .../scribblings/philosophy.scrbl | 24 +++++------ .../scribblings/quick-start.scrbl | 22 +++++----- .../scribblings/racunit.scrbl} | 4 +- .../scribblings/release-notes.scrbl | 2 +- .../scribblings/running-tests.scrbl | 6 +-- .../{rktunit => racunit}/scribblings/ui.scrbl | 16 +++---- collects/{rktunit => racunit}/text-ui.rkt | 0 collects/{rktunit => racunit}/tool.rkt | 2 +- collects/schemeunit/gui.rkt | 4 +- collects/schemeunit/main.rkt | 4 +- collects/schemeunit/text-ui.rkt | 4 +- .../guide/contracts-examples/1-test.rkt | 2 +- .../guide/contracts-examples/2-test.rkt | 2 +- .../guide/contracts-examples/3-test.rkt | 2 +- .../guide/contracts-examples/5-test.rkt | 2 +- collects/tests/deinprogramm/contract.rkt | 2 +- collects/tests/deinprogramm/image.rkt | 2 +- .../tests/deinprogramm/run-contract-tests.rkt | 2 +- .../tests/deinprogramm/run-image-test.rkt | 2 +- collects/tests/eli-tester.rkt | 2 +- collects/tests/future/future.rkt | 2 +- collects/tests/html/test.rkt | 4 +- collects/tests/info.rkt | 2 +- collects/tests/macro-debugger/all-tests.rkt | 4 +- collects/tests/macro-debugger/gentests.rkt | 2 +- .../tests/macro-debugger/tests/collects.rkt | 4 +- .../tests/macro-debugger/tests/hiding.rkt | 2 +- .../tests/macro-debugger/tests/policy.rkt | 2 +- .../tests/macro-debugger/tests/regression.rkt | 2 +- collects/tests/match/examples.rkt | 2 +- collects/tests/match/match-tests.rkt | 2 +- collects/tests/match/other-plt-tests.rkt | 2 +- collects/tests/match/other-tests.rkt | 2 +- collects/tests/match/plt-match-tests.rkt | 2 +- collects/tests/plai/test-random-mutator.rkt | 2 +- collects/tests/racket/contract-opt-tests.rkt | 4 +- collects/tests/raclog/bible.rkt | 2 +- collects/tests/raclog/england.rkt | 2 +- collects/tests/raclog/games.rkt | 2 +- .../all-racunit-tests.rkt} | 8 ++-- .../tests/{rktunit => racunit}/base-test.rkt | 22 +++++----- .../{rktunit => racunit}/check-info-test.rkt | 12 +++--- .../tests/{rktunit => racunit}/check-test.rkt | 10 ++--- .../{rktunit => racunit}/counter-test.rkt | 8 ++-- .../{rktunit => racunit}/format-test.rkt | 6 +-- .../{rktunit => racunit}/hash-monad-test.rkt | 6 +-- .../{rktunit => racunit}/location-test.rkt | 4 +- .../tests/{rktunit => racunit}/monad-test.rkt | 4 +- .../{rktunit => racunit}/result-test.rkt | 4 +- .../tests/{rktunit => racunit}/run-tests.rkt | 8 ++-- .../standalone-check-test.rkt | 2 +- .../standalone-test-case-test.rkt | 4 +- .../{rktunit => racunit}/test-case-test.rkt | 10 ++--- .../{rktunit => racunit}/test-suite-test.rkt | 4 +- .../tests/{rktunit => racunit}/test-test.rkt | 8 ++-- .../{rktunit => racunit}/text-ui-test.rkt | 16 +++---- .../text-ui-util-test.rkt | 4 +- .../tests/{rktunit => racunit}/util-test.rkt | 6 +-- collects/tests/srfi/1/alist-test.rkt | 2 +- collects/tests/srfi/1/all-1-tests.rkt | 2 +- collects/tests/srfi/1/cons-test.rkt | 2 +- collects/tests/srfi/1/delete-test.rkt | 2 +- collects/tests/srfi/1/filter-test.rkt | 2 +- collects/tests/srfi/1/fold-test.rkt | 2 +- collects/tests/srfi/1/lset-test.rkt | 2 +- collects/tests/srfi/1/misc-test.rkt | 2 +- collects/tests/srfi/1/predicate-test.rkt | 2 +- collects/tests/srfi/1/run-tests.rkt | 4 +- collects/tests/srfi/1/search-test.rkt | 2 +- collects/tests/srfi/1/selector-test.rkt | 2 +- collects/tests/srfi/13/string-test.rkt | 2 +- collects/tests/srfi/14/char-set-test.rkt | 2 +- collects/tests/srfi/19/tests.rkt | 4 +- collects/tests/srfi/2/and-let-test.rkt | 2 +- collects/tests/srfi/26/cut-test.rkt | 2 +- collects/tests/srfi/4/srfi-4-test.rkt | 4 +- collects/tests/srfi/40/all-srfi-40-tests.rkt | 2 +- collects/tests/srfi/40/run-tests.rkt | 4 +- collects/tests/srfi/43/all-srfi-43-tests.rkt | 2 +- collects/tests/srfi/43/constructor-tests.rkt | 2 +- collects/tests/srfi/43/conversion-tests.rkt | 2 +- collects/tests/srfi/43/iteration-tests.rkt | 2 +- collects/tests/srfi/43/mutator-tests.rkt | 2 +- collects/tests/srfi/43/predicate-tests.rkt | 2 +- collects/tests/srfi/43/run-tests.rkt | 4 +- collects/tests/srfi/43/searching-tests.rkt | 2 +- collects/tests/srfi/69/hash-tests.rkt | 2 +- collects/tests/srfi/all-srfi-tests.rkt | 2 +- collects/tests/srfi/run-tests.rkt | 4 +- collects/tests/stxparse/more-tests.rkt | 2 +- collects/tests/stxparse/select.rkt | 2 +- collects/tests/stxparse/stxclass.rkt | 2 +- collects/tests/stxparse/test.rkt | 2 +- collects/tests/typed-scheme/main.rkt | 2 +- .../tests/typed-scheme/succeed/fixnum.rkt | 2 +- .../tests/typed-scheme/succeed/flonum.rkt | 2 +- .../tests/typed-scheme/succeed/flvector.rkt | 2 +- .../typed-scheme/unit-tests/all-tests.rkt | 2 +- .../unit-tests/contract-tests.rkt | 2 +- .../typed-scheme/unit-tests/infer-tests.rkt | 2 +- .../typed-scheme/unit-tests/module-tests.rkt | 2 +- .../unit-tests/parse-type-tests.rkt | 2 +- .../unit-tests/planet-requires.rkt | 8 ++-- .../unit-tests/remove-intersect-tests.rkt | 2 +- .../typed-scheme/unit-tests/subst-tests.rkt | 2 +- .../typed-scheme/unit-tests/subtype-tests.rkt | 2 +- .../typed-scheme/unit-tests/test-utils.rkt | 4 +- .../unit-tests/type-annotation-test.rkt | 2 +- .../unit-tests/type-equal-tests.rkt | 2 +- .../unit-tests/typecheck-tests.rkt | 2 +- .../tests/web-server/all-web-server-tests.rkt | 2 +- .../configuration/all-configuration-tests.rkt | 2 +- .../configuration-table-test.rkt | 2 +- collects/tests/web-server/dispatch-test.rkt | 4 +- .../dispatchers/all-dispatchers-tests.rkt | 2 +- .../dispatchers/dispatch-files-test.rkt | 4 +- .../dispatchers/dispatch-host-test.rkt | 2 +- .../dispatchers/dispatch-lang-test.rkt | 4 +- .../dispatchers/dispatch-passwords-test.rkt | 2 +- .../dispatchers/dispatch-servlets-test.rkt | 2 +- .../dispatchers/filesystem-map-test.rkt | 2 +- .../dispatchers/servlet-test-util.rkt | 2 +- collects/tests/web-server/formlets-test.rkt | 4 +- .../tests/web-server/http/all-http-tests.rkt | 2 +- .../tests/web-server/http/cookies-test.rkt | 4 +- .../web-server/http/digest-auth-test.rkt | 2 +- collects/tests/web-server/lang-test.rkt | 2 +- .../web-server/lang/abort-resume-test.rkt | 4 +- .../tests/web-server/lang/all-lang-tests.rkt | 2 +- .../tests/web-server/lang/anormal-test.rkt | 2 +- collects/tests/web-server/lang/defun-test.rkt | 2 +- .../tests/web-server/lang/file-box-test.rkt | 2 +- .../tests/web-server/lang/labels-test.rkt | 2 +- .../tests/web-server/lang/stuff-url-test.rkt | 2 +- .../tests/web-server/lang/web-param-test.rkt | 2 +- .../managers/all-managers-tests.rkt | 2 +- .../web-server/private/all-private-tests.rkt | 2 +- .../web-server/private/cache-table-test.rkt | 4 +- .../private/connection-manager-test.rkt | 2 +- .../private/define-closure-test.rkt | 2 +- .../tests/web-server/private/gzip-test.rkt | 2 +- .../web-server/private/mime-types-test.rkt | 2 +- .../tests/web-server/private/mod-map-test.rkt | 2 +- .../tests/web-server/private/request-test.rkt | 2 +- .../web-server/private/response-test.rkt | 2 +- .../web-server/private/url-param-test.rkt | 2 +- .../tests/web-server/private/util-test.rkt | 2 +- collects/tests/web-server/run-all-tests.rkt | 2 +- .../tests/web-server/servlet-env-test.rkt | 2 +- .../web-server/servlet/all-servlet-tests.rkt | 2 +- .../web-server/servlet/basic-auth-test.rkt | 2 +- .../web-server/servlet/bindings-test.rkt | 2 +- .../tests/web-server/servlet/helpers-test.rkt | 4 +- .../tests/web-server/servlet/web-test.rkt | 2 +- collects/tests/web-server/stuffers-test.rkt | 4 +- collects/tests/xml/test-clark.rkt | 4 +- collects/tests/xml/test.rkt | 4 +- 204 files changed, 386 insertions(+), 385 deletions(-) rename collects/{rktunit => racunit}/gui.rkt (84%) rename collects/{rktunit => racunit}/info.rkt (54%) rename collects/{rktunit => racunit}/main.rkt (100%) rename collects/{rktunit => racunit}/private/base.rkt (82%) rename collects/{rktunit => racunit}/private/check-info.rkt (97%) rename collects/{rktunit => racunit}/private/check.rkt (100%) rename collects/{rktunit => racunit}/private/counter.rkt (100%) rename collects/{rktunit => racunit}/private/format.rkt (100%) rename collects/{rktunit => racunit}/private/gui/cache-box.rkt (100%) rename collects/{rktunit => racunit}/private/gui/config.rkt (78%) rename collects/{rktunit => racunit}/private/gui/controller.rkt (87%) rename collects/{rktunit => racunit}/private/gui/drracket-link.rkt (100%) rename collects/{rktunit => racunit}/private/gui/drracket-ui.rkt (100%) rename collects/{rktunit => racunit}/private/gui/gui.rkt (95%) rename collects/{rktunit => racunit}/private/gui/gvector.rkt (100%) rename collects/{rktunit => racunit}/private/gui/interfaces.rkt (100%) rename collects/{rktunit => racunit}/private/gui/model.rkt (100%) rename collects/{rktunit => racunit}/private/gui/model2rml.rkt (100%) rename collects/{rktunit => racunit}/private/gui/output-icon.png (100%) rename collects/{rktunit => racunit}/private/gui/rml.rkt (96%) rename collects/{rktunit => racunit}/private/gui/view.rkt (98%) rename collects/{rktunit => racunit}/private/hash-monad.rkt (100%) rename collects/{rktunit => racunit}/private/location.rkt (100%) rename collects/{rktunit => racunit}/private/monad.rkt (100%) rename collects/{rktunit => racunit}/private/name-collector.rkt (100%) rename collects/{rktunit => racunit}/private/result.rkt (96%) rename collects/{rktunit => racunit}/private/test-case.rkt (100%) rename collects/{rktunit => racunit}/private/test-suite.rkt (86%) rename collects/{rktunit => racunit}/private/test.rkt (93%) rename collects/{rktunit => racunit}/private/text-ui-util.rkt (100%) rename collects/{rktunit => racunit}/private/util.rkt (100%) rename collects/{rktunit => racunit}/scribblings/acknowledgements.scrbl (87%) rename collects/{rktunit => racunit}/scribblings/api.scrbl (78%) rename collects/{rktunit => racunit}/scribblings/base.rkt (58%) rename collects/{rktunit => racunit}/scribblings/check.scrbl (99%) rename collects/{rktunit => racunit}/scribblings/compound-testing.scrbl (99%) rename collects/{rktunit => racunit}/scribblings/control-flow.scrbl (96%) rename collects/{rktunit => racunit}/scribblings/file-test.rkt (96%) rename collects/{rktunit => racunit}/scribblings/file.rkt (100%) rename collects/{rktunit => racunit}/scribblings/misc.scrbl (89%) rename collects/{rktunit => racunit}/scribblings/overview.scrbl (84%) rename collects/{rktunit => racunit}/scribblings/philosophy.scrbl (84%) rename collects/{rktunit => racunit}/scribblings/quick-start.scrbl (87%) rename collects/{rktunit/scribblings/rktunit.scrbl => racunit/scribblings/racunit.scrbl} (82%) rename collects/{rktunit => racunit}/scribblings/release-notes.scrbl (95%) rename collects/{rktunit => racunit}/scribblings/running-tests.scrbl (97%) rename collects/{rktunit => racunit}/scribblings/ui.scrbl (75%) rename collects/{rktunit => racunit}/text-ui.rkt (100%) rename collects/{rktunit => racunit}/tool.rkt (97%) rename collects/tests/{rktunit/all-rktunit-tests.rkt => racunit/all-racunit-tests.rkt} (92%) rename collects/tests/{rktunit => racunit}/base-test.rkt (80%) rename collects/tests/{rktunit => racunit}/check-info-test.rkt (91%) rename collects/tests/{rktunit => racunit}/check-test.rkt (98%) rename collects/tests/{rktunit => racunit}/counter-test.rkt (93%) rename collects/tests/{rktunit => racunit}/format-test.rkt (87%) rename collects/tests/{rktunit => racunit}/hash-monad-test.rkt (95%) rename collects/tests/{rktunit => racunit}/location-test.rkt (98%) rename collects/tests/{rktunit => racunit}/monad-test.rkt (98%) rename collects/tests/{rktunit => racunit}/result-test.rkt (95%) rename collects/tests/{rktunit => racunit}/run-tests.rkt (74%) rename collects/tests/{rktunit => racunit}/standalone-check-test.rkt (98%) rename collects/tests/{rktunit => racunit}/standalone-test-case-test.rkt (88%) rename collects/tests/{rktunit => racunit}/test-case-test.rkt (86%) rename collects/tests/{rktunit => racunit}/test-suite-test.rkt (97%) rename collects/tests/{rktunit => racunit}/test-test.rkt (98%) rename collects/tests/{rktunit => racunit}/text-ui-test.rkt (95%) rename collects/tests/{rktunit => racunit}/text-ui-util-test.rkt (96%) rename collects/tests/{rktunit => racunit}/util-test.rkt (94%) diff --git a/collects/2htdp/tests/batch-io.rkt b/collects/2htdp/tests/batch-io.rkt index cbabba4e3c..a44e391b89 100644 --- a/collects/2htdp/tests/batch-io.rkt +++ b/collects/2htdp/tests/batch-io.rkt @@ -1,6 +1,6 @@ #lang scheme/load -(require rktunit) +(require racunit) (require 2htdp/batch-io) (define file "batch-io.txt") diff --git a/collects/2htdp/tests/test-image.rkt b/collects/2htdp/tests/test-image.rkt index b8f8ff5451..e53be1f265 100644 --- a/collects/2htdp/tests/test-image.rkt +++ b/collects/2htdp/tests/test-image.rkt @@ -45,7 +45,7 @@ scheme/math scheme/class scheme/gui/base - rktunit + racunit (prefix-in 1: htdp/image) (only-in lang/htdp-advanced equal~?)) diff --git a/collects/meta/dist-specs.rkt b/collects/meta/dist-specs.rkt index 869ab4223f..90be9f4d58 100644 --- a/collects/meta/dist-specs.rkt +++ b/collects/meta/dist-specs.rkt @@ -662,7 +662,7 @@ mz-extras :+= (- (package: "unstable") ;; -------------------- plai plt-extras :+= (package: "plai/") -plt-extras :+= (package: "rktunit/") +plt-extras :+= (package: "racunit/") plt-extras :+= (package: "schemeunit/") ;; ============================================================================ diff --git a/collects/meta/drdr/pkgs.bak b/collects/meta/drdr/pkgs.bak index 66c34ab0f1..a733b187cd 100644 --- a/collects/meta/drdr/pkgs.bak +++ b/collects/meta/drdr/pkgs.bak @@ -615,26 +615,26 @@ ("schematics" "port.plt" 1 0 #f) ("schematics" "random.plt" 1 0 #f) ("schematics" "sake.plt" 1 0 "4.0") - ("schematics" "rktunit.plt" 3 4 "4.0") - ("schematics" "rktunit.plt" 3 3 "4.0") - ("schematics" "rktunit.plt" 3 2 "4.0") - ("schematics" "rktunit.plt" 3 1 "4.0") - ("schematics" "rktunit.plt" 3 0 "4.0") - ("schematics" "rktunit.plt" 2 11 "4.1.0.3") - ("schematics" "rktunit.plt" 2 10 "369.1") - ("schematics" "rktunit.plt" 2 9 "369.1") - ("schematics" "rktunit.plt" 2 8 "369.1") - ("schematics" "rktunit.plt" 2 7 "369.1") - ("schematics" "rktunit.plt" 2 6 "369.1") - ("schematics" "rktunit.plt" 2 5 "369.1") - ("schematics" "rktunit.plt" 2 4 "369.1") - ("schematics" "rktunit.plt" 2 3 #f) - ("schematics" "rktunit.plt" 2 2 #f) - ("schematics" "rktunit.plt" 2 1 #f) - ("schematics" "rktunit.plt" 2 0 #f) - ("schematics" "rktunit.plt" 1 2 #f) - ("schematics" "rktunit.plt" 1 1 #f) - ("schematics" "rktunit.plt" 1 0 #f) + ("schematics" "racunit.plt" 3 4 "4.0") + ("schematics" "racunit.plt" 3 3 "4.0") + ("schematics" "racunit.plt" 3 2 "4.0") + ("schematics" "racunit.plt" 3 1 "4.0") + ("schematics" "racunit.plt" 3 0 "4.0") + ("schematics" "racunit.plt" 2 11 "4.1.0.3") + ("schematics" "racunit.plt" 2 10 "369.1") + ("schematics" "racunit.plt" 2 9 "369.1") + ("schematics" "racunit.plt" 2 8 "369.1") + ("schematics" "racunit.plt" 2 7 "369.1") + ("schematics" "racunit.plt" 2 6 "369.1") + ("schematics" "racunit.plt" 2 5 "369.1") + ("schematics" "racunit.plt" 2 4 "369.1") + ("schematics" "racunit.plt" 2 3 #f) + ("schematics" "racunit.plt" 2 2 #f) + ("schematics" "racunit.plt" 2 1 #f) + ("schematics" "racunit.plt" 2 0 #f) + ("schematics" "racunit.plt" 1 2 #f) + ("schematics" "racunit.plt" 1 1 #f) + ("schematics" "racunit.plt" 1 0 #f) ("schematics" "si.plt" 1 0 #f) ("schematics" "spgsql.plt" 2 3 "371.3") ("schematics" "spgsql.plt" 2 2 "371.3") diff --git a/collects/meta/props b/collects/meta/props index 5733db644a..58d07ae4da 100644 --- a/collects/meta/props +++ b/collects/meta/props @@ -1126,17 +1126,18 @@ path/s is either such a string or a list of them. "collects/scheme/gui.rkt" drdr:command-line "mred-text -t ~s" "collects/scheme/match" responsible (samth) "collects/scheme/match.rkt" responsible (samth) -"collects/rktunit" responsible (jay noel ryanc) +"collects/racunit" responsible (jay noel ryanc) "collects/schemeunit" responsible (jay) -"collects/rktunit/gui.rkt" responsible (ryanc) drdr:command-line "mred-text -t ~s" -"collects/rktunit/private/gui" responsible (ryanc) -"collects/rktunit/private/gui/config.rkt" drdr:command-line "mred-text -t ~s" -"collects/rktunit/private/gui/controller.rkt" drdr:command-line "mred-text -t ~s" -"collects/rktunit/private/gui/gui.rkt" drdr:command-line "mred-text -t ~s" -"collects/rktunit/private/gui/model2rml.rkt" drdr:command-line "mred-text -t ~s" -"collects/rktunit/private/gui/rml.rkt" drdr:command-line "mred-text -t ~s" -"collects/rktunit/private/gui/view.rkt" drdr:command-line "mred-text -t ~s" -"collects/rktunit/tool.rkt" responsible (ryanc) drdr:command-line "mred-text -t ~s" +"collects/schemeunit/gui.rkt" responsible (jay) drdr:command-line "mred-text -t ~s" +"collects/racunit/gui.rkt" responsible (ryanc) drdr:command-line "mred-text -t ~s" +"collects/racunit/private/gui" responsible (ryanc) +"collects/racunit/private/gui/config.rkt" drdr:command-line "mred-text -t ~s" +"collects/racunit/private/gui/controller.rkt" drdr:command-line "mred-text -t ~s" +"collects/racunit/private/gui/gui.rkt" drdr:command-line "mred-text -t ~s" +"collects/racunit/private/gui/model2rml.rkt" drdr:command-line "mred-text -t ~s" +"collects/racunit/private/gui/rml.rkt" drdr:command-line "mred-text -t ~s" +"collects/racunit/private/gui/view.rkt" drdr:command-line "mred-text -t ~s" +"collects/racunit/tool.rkt" responsible (ryanc) drdr:command-line "mred-text -t ~s" "collects/scribble/run.rkt" drdr:command-line "mzc ~s" "collects/scribble/tools/drscheme-buttons.rkt" drdr:command-line "mred-text ~s" "collects/scribble/tools/private/mk-drs-bitmaps.rkt" drdr:command-line "mred-text ~s" drdr:timeout 240 @@ -1583,7 +1584,7 @@ path/s is either such a string or a list of them. "collects/tests/planet/examples/dummy-module.rkt" drdr:command-line "" "collects/tests/plot/run-tests.rkt" drdr:command-line "mred-text -t ~s" "collects/tests/run-automated-tests.rkt" drdr:command-line "mzc -k ~s" drdr:timeout 600 -"collects/tests/rktunit" responsible (jay noel) +"collects/tests/racunit" responsible (jay noel) "collects/tests/srfi/1/run-tests.rkt" drdr:command-line "mzscheme -f ~s" "collects/tests/srfi/40/run-tests.rkt" drdr:command-line "mzscheme -f ~s" "collects/tests/srfi/43/run-tests.rkt" drdr:command-line "mzscheme -f ~s" diff --git a/collects/parser-tools/private-lex/error-tests.rkt b/collects/parser-tools/private-lex/error-tests.rkt index 88876985aa..92307f8633 100644 --- a/collects/parser-tools/private-lex/error-tests.rkt +++ b/collects/parser-tools/private-lex/error-tests.rkt @@ -1,7 +1,7 @@ #lang scheme/base (require (for-syntax scheme/base) "../lex.ss" - rktunit) + racunit) (define-syntax (catch-syn-error stx) (syntax-case stx () diff --git a/collects/rktunit/gui.rkt b/collects/racunit/gui.rkt similarity index 84% rename from collects/rktunit/gui.rkt rename to collects/racunit/gui.rkt index 0b57fd641e..8daff1a5a4 100644 --- a/collects/rktunit/gui.rkt +++ b/collects/racunit/gui.rkt @@ -6,7 +6,7 @@ (define (test/gui . tests) (apply (make-gui-runner) tests)) -(define test/c (or/c rktunit-test-case? rktunit-test-suite?)) +(define test/c (or/c racunit-test-case? racunit-test-suite?)) (provide/contract [test/gui diff --git a/collects/rktunit/info.rkt b/collects/racunit/info.rkt similarity index 54% rename from collects/rktunit/info.rkt rename to collects/racunit/info.rkt index 3b9fbfce4a..a12d54d758 100644 --- a/collects/rktunit/info.rkt +++ b/collects/racunit/info.rkt @@ -1,13 +1,13 @@ #lang setup/infotab -(define name "RktUnit") +(define name "RacUnit") -(define blurb '((p "RktUnit is a unit testing framework based on the " +(define blurb '((p "RacUnit is a unit testing framework based on the " " Extreme Programming unit test frameworks"))) -(define scribblings '(("scribblings/rktunit.scrbl" (multi-page) (tool)))) +(define scribblings '(("scribblings/racunit.scrbl" (multi-page) (tool)))) (define tools '[("tool.rkt")]) -(define tool-names '["RktUnit DrRacket integration"]) +(define tool-names '["RacUnit DrRacket integration"]) (define homepage "http://schematics.sourceforge.net/") (define url "http://schematics.sourceforge.net/") diff --git a/collects/rktunit/main.rkt b/collects/racunit/main.rkt similarity index 100% rename from collects/rktunit/main.rkt rename to collects/racunit/main.rkt diff --git a/collects/rktunit/private/base.rkt b/collects/racunit/private/base.rkt similarity index 82% rename from collects/rktunit/private/base.rkt rename to collects/racunit/private/base.rkt index bb87c10134..6809635198 100644 --- a/collects/rktunit/private/base.rkt +++ b/collects/racunit/private/base.rkt @@ -4,10 +4,10 @@ ;; struct test : (define-struct test ()) -;; struct (rktunit-test-case test) : (U string #f) thunk -(define-struct (rktunit-test-case test) (name action) #:transparent) -;; struct (rktunit-test-suite test) : string (fdown fup fhere seed -> (listof test-result)) thunk thunk -(define-struct (rktunit-test-suite test) (name tests before after) #:transparent) +;; struct (racunit-test-case test) : (U string #f) thunk +(define-struct (racunit-test-case test) (name action) #:transparent) +;; struct (racunit-test-suite test) : string (fdown fup fhere seed -> (listof test-result)) thunk thunk +(define-struct (racunit-test-suite test) (name tests before after) #:transparent) ;; struct exn:test exn : () ;; @@ -33,10 +33,10 @@ (define-struct (test-success test-result) (result)) (provide/contract - (struct (rktunit-test-case test) + (struct (racunit-test-case test) ((name (or/c string? false/c)) (action (-> any)))) - (struct (rktunit-test-suite test) + (struct (racunit-test-suite test) ((name string?) (tests procedure?) (before (-> any)) diff --git a/collects/rktunit/private/check-info.rkt b/collects/racunit/private/check-info.rkt similarity index 97% rename from collects/rktunit/private/check-info.rkt rename to collects/racunit/private/check-info.rkt index 3b3ec4e1a5..de98d71bf2 100644 --- a/collects/rktunit/private/check-info.rkt +++ b/collects/racunit/private/check-info.rkt @@ -11,7 +11,7 @@ ;; Infrastructure ---------------------------------------------- ;; The continuation mark under which all check-info is keyed -(define check-info-mark (gensym 'rktunit)) +(define check-info-mark (gensym 'racunit)) ;; (continuation-mark-set -> (listof check-info)) (define (check-info-stack marks) diff --git a/collects/rktunit/private/check.rkt b/collects/racunit/private/check.rkt similarity index 100% rename from collects/rktunit/private/check.rkt rename to collects/racunit/private/check.rkt diff --git a/collects/rktunit/private/counter.rkt b/collects/racunit/private/counter.rkt similarity index 100% rename from collects/rktunit/private/counter.rkt rename to collects/racunit/private/counter.rkt diff --git a/collects/rktunit/private/format.rkt b/collects/racunit/private/format.rkt similarity index 100% rename from collects/rktunit/private/format.rkt rename to collects/racunit/private/format.rkt diff --git a/collects/rktunit/private/gui/cache-box.rkt b/collects/racunit/private/gui/cache-box.rkt similarity index 100% rename from collects/rktunit/private/gui/cache-box.rkt rename to collects/racunit/private/gui/cache-box.rkt diff --git a/collects/rktunit/private/gui/config.rkt b/collects/racunit/private/gui/config.rkt similarity index 78% rename from collects/rktunit/private/gui/config.rkt rename to collects/racunit/private/gui/config.rkt index c0123eecab..1d843d9a79 100644 --- a/collects/rktunit/private/gui/config.rkt +++ b/collects/racunit/private/gui/config.rkt @@ -5,20 +5,20 @@ ;; Frame size preferences -(preferences:set-default 'rktunit:frame:width 400 exact-positive-integer?) -(preferences:set-default 'rktunit:frame:height 400 exact-positive-integer?) -(define pref:width (pref:get/set 'rktunit:frame:width)) -(define pref:height (pref:get/set 'rktunit:frame:height)) +(preferences:set-default 'racunit:frame:width 400 exact-positive-integer?) +(preferences:set-default 'racunit:frame:height 400 exact-positive-integer?) +(define pref:width (pref:get/set 'racunit:frame:width)) +(define pref:height (pref:get/set 'racunit:frame:height)) ;; CONSTANTS ;; Some of these are obsolete, given the preferences above. (define DETAILS-CANVAS-INIT-WIDTH 400) -(define FRAME-LABEL "RktUnit") +(define FRAME-LABEL "RacUnit") (define FRAME-INIT-HEIGHT 400) (define TREE-INIT-WIDTH 240) (define TREE-COLORIZE-CASES #t) -(define DIALOG-ERROR-TITLE "RktUnit: Error") +(define DIALOG-ERROR-TITLE "RacUnit: Error") (define STATUS-SUCCESS 'success) (define STATUS-FAILURE 'failure) (define STATUS-ERROR 'error) diff --git a/collects/rktunit/private/gui/controller.rkt b/collects/racunit/private/gui/controller.rkt similarity index 87% rename from collects/rktunit/private/gui/controller.rkt rename to collects/racunit/private/gui/controller.rkt index edcd4be075..46a08349b3 100644 --- a/collects/rktunit/private/gui/controller.rkt +++ b/collects/racunit/private/gui/controller.rkt @@ -25,18 +25,18 @@ ;; create-model : test suite<%>/#f -> result<%> (define/public (create-model test parent) (define result - (cond [(rktunit-test-case? test) + (cond [(racunit-test-case? test) (new case-result% (controller this) (test test) - (name (or (rktunit-test-case-name test) + (name (or (racunit-test-case-name test) "")) (parent parent))] - [(rktunit-test-suite? test) + [(racunit-test-suite? test) (new suite-result% (controller this) (test test) - (name (or (rktunit-test-suite-name test) + (name (or (racunit-test-suite-name test) "")) (parent parent))])) (send/i view view<%> create-view-link result parent) diff --git a/collects/rktunit/private/gui/drracket-link.rkt b/collects/racunit/private/gui/drracket-link.rkt similarity index 100% rename from collects/rktunit/private/gui/drracket-link.rkt rename to collects/racunit/private/gui/drracket-link.rkt diff --git a/collects/rktunit/private/gui/drracket-ui.rkt b/collects/racunit/private/gui/drracket-ui.rkt similarity index 100% rename from collects/rktunit/private/gui/drracket-ui.rkt rename to collects/racunit/private/gui/drracket-ui.rkt diff --git a/collects/rktunit/private/gui/gui.rkt b/collects/racunit/private/gui/gui.rkt similarity index 95% rename from collects/rktunit/private/gui/gui.rkt rename to collects/racunit/private/gui/gui.rkt index 782875f0e1..e5a5c4178c 100644 --- a/collects/rktunit/private/gui/gui.rkt +++ b/collects/racunit/private/gui/gui.rkt @@ -48,8 +48,8 @@ #| (define/public (run) (let ([custodian (make-custodian)] - [before (rktunit-test-suite-before test)] - [after (rktunit-test-suite-after test)]) + [before (racunit-test-suite-before test)] + [after (racunit-test-suite-after test)]) (parameterize [(current-custodian custodian)] (dynamic-wind before @@ -112,8 +112,8 @@ (call-with-continuation-prompt (lambda () (time-apply run-test-case - (list (rktunit-test-case-name test) - (rktunit-test-case-action test)))))]) + (list (racunit-test-case-name test) + (racunit-test-case-action test)))))]) (values (car results) (list cputime realtime gctime)))) (define (make-output-ports) diff --git a/collects/rktunit/private/gui/gvector.rkt b/collects/racunit/private/gui/gvector.rkt similarity index 100% rename from collects/rktunit/private/gui/gvector.rkt rename to collects/racunit/private/gui/gvector.rkt diff --git a/collects/rktunit/private/gui/interfaces.rkt b/collects/racunit/private/gui/interfaces.rkt similarity index 100% rename from collects/rktunit/private/gui/interfaces.rkt rename to collects/racunit/private/gui/interfaces.rkt diff --git a/collects/rktunit/private/gui/model.rkt b/collects/racunit/private/gui/model.rkt similarity index 100% rename from collects/rktunit/private/gui/model.rkt rename to collects/racunit/private/gui/model.rkt diff --git a/collects/rktunit/private/gui/model2rml.rkt b/collects/racunit/private/gui/model2rml.rkt similarity index 100% rename from collects/rktunit/private/gui/model2rml.rkt rename to collects/racunit/private/gui/model2rml.rkt diff --git a/collects/rktunit/private/gui/output-icon.png b/collects/racunit/private/gui/output-icon.png similarity index 100% rename from collects/rktunit/private/gui/output-icon.png rename to collects/racunit/private/gui/output-icon.png diff --git a/collects/rktunit/private/gui/rml.rkt b/collects/racunit/private/gui/rml.rkt similarity index 96% rename from collects/rktunit/private/gui/rml.rkt rename to collects/racunit/private/gui/rml.rkt index 885958b307..1b2b65b875 100644 --- a/collects/rktunit/private/gui/rml.rkt +++ b/collects/racunit/private/gui/rml.rkt @@ -7,7 +7,7 @@ (provide insert-text ext:text% - rktunit-style-map) + racunit-style-map) ;; insert-text : text% string style-delta% -> void (define (insert-text e text style) @@ -20,7 +20,7 @@ (define ext:text-mixin (mixin (text<%>) () - (init-field (style-map rktunit-style-map)) + (init-field (style-map racunit-style-map)) (inherit last-position change-style set-clickback @@ -139,7 +139,7 @@ [error . ,style:red] [value . ,style:darkblue])) -(define rktunit-styles +(define racunit-styles `([test-unexecuted . ,style:gray] [test-success . ,style:green] [test-failure . ,style:red] @@ -181,7 +181,7 @@ (extend-style-map empty-style-map basic-styles)) -;; rktunit-style-map : style-map<%> -(define rktunit-style-map +;; racunit-style-map : style-map<%> +(define racunit-style-map (extend-style-map basic-style-map - rktunit-styles)) + racunit-styles)) diff --git a/collects/rktunit/private/gui/view.rkt b/collects/racunit/private/gui/view.rkt similarity index 98% rename from collects/rktunit/private/gui/view.rkt rename to collects/racunit/private/gui/view.rkt index 0b840db5f5..e3ab4357c3 100644 --- a/collects/rktunit/private/gui/view.rkt +++ b/collects/racunit/private/gui/view.rkt @@ -13,7 +13,7 @@ (provide make-view-frame view%) -(define style-map rktunit-style-map) +(define style-map racunit-style-map) #| @@ -50,7 +50,7 @@ still be there, just not visible? controller) (super-new) - (define editor (new ext:text% (style-map rktunit-style-map))) + (define editor (new ext:text% (style-map racunit-style-map))) (define renderer (new model-renderer% (controller controller) @@ -146,7 +146,7 @@ still be there, just not visible? ;; If the view-link has not been created, ;; yield until it is. (unless (yield) - (error 'rktunit-gui + (error 'racunit-gui "internal error: no progress waiting for view-link")) (do-model-update model)]))) diff --git a/collects/rktunit/private/hash-monad.rkt b/collects/racunit/private/hash-monad.rkt similarity index 100% rename from collects/rktunit/private/hash-monad.rkt rename to collects/racunit/private/hash-monad.rkt diff --git a/collects/rktunit/private/location.rkt b/collects/racunit/private/location.rkt similarity index 100% rename from collects/rktunit/private/location.rkt rename to collects/racunit/private/location.rkt diff --git a/collects/rktunit/private/monad.rkt b/collects/racunit/private/monad.rkt similarity index 100% rename from collects/rktunit/private/monad.rkt rename to collects/racunit/private/monad.rkt diff --git a/collects/rktunit/private/name-collector.rkt b/collects/racunit/private/name-collector.rkt similarity index 100% rename from collects/rktunit/private/name-collector.rkt rename to collects/racunit/private/name-collector.rkt diff --git a/collects/rktunit/private/result.rkt b/collects/racunit/private/result.rkt similarity index 96% rename from collects/rktunit/private/result.rkt rename to collects/racunit/private/result.rkt index 61a553ffa4..208b39d191 100644 --- a/collects/rktunit/private/result.rkt +++ b/collects/racunit/private/result.rkt @@ -51,12 +51,12 @@ ;; data so FP is a bit ugly]. (define (foldts fdown fup fhere seed test) (cond - ((rktunit-test-case? test) + ((racunit-test-case? test) (fhere test - (rktunit-test-case-name test) - (rktunit-test-case-action test) + (racunit-test-case-name test) + (racunit-test-case-action test) seed)) - ((rktunit-test-suite? test) + ((racunit-test-suite? test) (apply-test-suite test fdown fup fhere seed)) (else (raise diff --git a/collects/rktunit/private/test-case.rkt b/collects/racunit/private/test-case.rkt similarity index 100% rename from collects/rktunit/private/test-case.rkt rename to collects/racunit/private/test-case.rkt diff --git a/collects/rktunit/private/test-suite.rkt b/collects/racunit/private/test-suite.rkt similarity index 86% rename from collects/rktunit/private/test-suite.rkt rename to collects/racunit/private/test-suite.rkt index d59ef78e38..4b3aa1d5b1 100644 --- a/collects/rktunit/private/test-suite.rkt +++ b/collects/racunit/private/test-suite.rkt @@ -27,14 +27,14 @@ (define (test-suite-test-case-around fhere) (lambda (thunk) (let* ([name (current-test-name)] - [test (make-rktunit-test-case name thunk)] + [test (make-racunit-test-case name thunk)] [seed (current-seed)]) (current-seed (fhere test name thunk seed))))) (define (test-suite-check-around fhere) (lambda (thunk) (let* ([name #f] - [test (make-rktunit-test-case name thunk)] + [test (make-racunit-test-case name thunk)] [seed (current-seed)]) (current-seed (fhere test name thunk seed))))) @@ -42,12 +42,12 @@ (define delayed-test-case-around (lambda (thunk) (let ([name (current-test-name)]) - (make-rktunit-test-case name thunk)))) + (make-racunit-test-case name thunk)))) (define delayed-check-around (lambda (thunk) (let ([name #f]) - (make-rktunit-test-case name thunk)))) + (make-racunit-test-case name thunk)))) (define-syntax delay-test (syntax-rules () @@ -58,12 +58,12 @@ test test1 ...)])) (define (apply-test-suite suite fdown fup fhere seed) - (let* ([name (rktunit-test-suite-name suite)] - [tests (rktunit-test-suite-tests suite)] - [before (rktunit-test-suite-before suite)] - [after (rktunit-test-suite-after suite)] + (let* ([name (racunit-test-suite-name suite)] + [tests (racunit-test-suite-tests suite)] + [before (racunit-test-suite-before suite)] + [after (racunit-test-suite-after suite)] [kid-seed (fdown suite name before after seed)] - [kid-seed ((rktunit-test-suite-tests suite) fdown fup fhere kid-seed)]) + [kid-seed ((racunit-test-suite-tests suite) fdown fup fhere kid-seed)]) (fup suite name before after seed kid-seed))) ;; test-suite : name [#:before thunk] [#:after thunk] test ... @@ -84,7 +84,7 @@ [the-tests (lambda (fdown fup fhere seed) (define (run/inner x) - (cond [(rktunit-test-suite? x) + (cond [(racunit-test-suite? x) (current-seed (apply-test-suite x fdown fup fhere (current-seed)))] [(list? x) @@ -103,7 +103,7 @@ [(not (string? the-name)) (raise-type-error 'test-suite "test-suite name as string" the-name)] [else - (make-rktunit-test-suite + (make-racunit-test-suite the-name the-tests before-thunk @@ -138,13 +138,13 @@ (for-each (lambda (t) (cond - [(rktunit-test-suite? t) + [(racunit-test-suite? t) (current-seed (apply-test-suite t fdown fup fhere (current-seed)))] - [(rktunit-test-case? t) + [(racunit-test-case? t) (current-seed (fhere t - (rktunit-test-case-name t) - (rktunit-test-case-action t) + (racunit-test-case-name t) + (racunit-test-case-action t) (current-seed)))] [else (raise @@ -158,7 +158,7 @@ ;; ;; Construct a test suite from a list of tests (define (make-test-suite name #:before [before void-thunk] #:after [after void-thunk] tests) - (make-rktunit-test-suite name + (make-racunit-test-suite name (tests->test-suite-action tests) before after)) diff --git a/collects/rktunit/private/test.rkt b/collects/racunit/private/test.rkt similarity index 93% rename from collects/rktunit/private/test.rkt rename to collects/racunit/private/test.rkt index f6ad6fec2d..0fabb9f3a9 100644 --- a/collects/rktunit/private/test.rkt +++ b/collects/racunit/private/test.rkt @@ -15,8 +15,8 @@ (struct-out test-failure) (struct-out test-error) (struct-out test-success) - (struct-out rktunit-test-case) - (struct-out rktunit-test-suite) + (struct-out racunit-test-case) + (struct-out racunit-test-suite) with-check-info with-check-info* @@ -42,9 +42,9 @@ test-suite make-test-suite delay-test - (rename-out [make-rktunit-test-case make-test-case] - [rktunit-test-case? test-case?] - [rktunit-test-suite? test-suite?]) + (rename-out [make-racunit-test-case make-test-case] + [racunit-test-case? test-case?] + [racunit-test-suite? test-suite?]) define-test-suite define/provide-test-suite diff --git a/collects/rktunit/private/text-ui-util.rkt b/collects/racunit/private/text-ui-util.rkt similarity index 100% rename from collects/rktunit/private/text-ui-util.rkt rename to collects/racunit/private/text-ui-util.rkt diff --git a/collects/rktunit/private/util.rkt b/collects/racunit/private/util.rkt similarity index 100% rename from collects/rktunit/private/util.rkt rename to collects/racunit/private/util.rkt diff --git a/collects/rktunit/scribblings/acknowledgements.scrbl b/collects/racunit/scribblings/acknowledgements.scrbl similarity index 87% rename from collects/rktunit/scribblings/acknowledgements.scrbl rename to collects/racunit/scribblings/acknowledgements.scrbl index 147afc0b73..bdab1093a4 100644 --- a/collects/rktunit/scribblings/acknowledgements.scrbl +++ b/collects/racunit/scribblings/acknowledgements.scrbl @@ -3,7 +3,7 @@ @title{Acknowlegements} -The following people have contributed to RktUnit: +The following people have contributed to RacUnit: @itemize[ @item{Robby Findler pushed me to release version 3} @@ -12,7 +12,7 @@ The following people have contributed to RktUnit: suggested renaming @racket[test/text-ui]} @item{Dave Gurnell reported a bug in check-not-exn and - suggested improvements to RktUnit} + suggested improvements to RacUnit} @item{Danny Yoo reported a bug in and provided a fix for trim-current-directory} @@ -30,7 +30,7 @@ The following people have contributed to RktUnit: @item{Jose A. Ortega Ruiz alerted me a problem in the packaging system and helped fix it.} - @item{Sebastian H. Seidel provided help packaging RktUnit + @item{Sebastian H. Seidel provided help packaging RacUnit into a .plt} @item{Don Blaheta provided the method for grabbing line number diff --git a/collects/rktunit/scribblings/api.scrbl b/collects/racunit/scribblings/api.scrbl similarity index 78% rename from collects/rktunit/scribblings/api.scrbl rename to collects/racunit/scribblings/api.scrbl index 33ef4912a8..f99db734c4 100644 --- a/collects/rktunit/scribblings/api.scrbl +++ b/collects/racunit/scribblings/api.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc @(require "base.rkt") -@title[#:tag "api"]{RktUnit API} +@title[#:tag "api"]{RacUnit API} -@defmodule[rktunit - #:use-sources (rktunit)] +@defmodule[racunit + #:use-sources (racunit)] @include-section["overview.scrbl"] @include-section["check.scrbl"] diff --git a/collects/rktunit/scribblings/base.rkt b/collects/racunit/scribblings/base.rkt similarity index 58% rename from collects/rktunit/scribblings/base.rkt rename to collects/racunit/scribblings/base.rkt index 8189c12769..1fc6e255b0 100644 --- a/collects/rktunit/scribblings/base.rkt +++ b/collects/racunit/scribblings/base.rkt @@ -6,15 +6,15 @@ (for-label scheme/base scheme/contract - rktunit - rktunit/text-ui - rktunit/gui)) + racunit + racunit/text-ui + racunit/gui)) (provide (all-from-out scribble/eval scribble/manual) (for-label (all-from-out scheme/base scheme/contract - rktunit - rktunit/text-ui - rktunit/gui))) + racunit + racunit/text-ui + racunit/gui))) diff --git a/collects/rktunit/scribblings/check.scrbl b/collects/racunit/scribblings/check.scrbl similarity index 99% rename from collects/rktunit/scribblings/check.scrbl rename to collects/racunit/scribblings/check.scrbl index 80de0ae33b..d95924c52d 100644 --- a/collects/rktunit/scribblings/check.scrbl +++ b/collects/racunit/scribblings/check.scrbl @@ -3,7 +3,7 @@ @title{Checks} -Checks are the basic building block of RktUnit. A check +Checks are the basic building block of RacUnit. A check checks some condition. If the condition holds the check evaluates to @racket[#t]. If the condition doesn't hold the check raises an instance of @racket[exn:test:check] with @@ -16,7 +16,7 @@ their arguments. You can use check as first class functions, though you will lose precision in the reported source locations if you do so. -The following are the basic checks RktUnit provides. You +The following are the basic checks RacUnit provides. You can create your own checks using @racket[define-check]. @defproc[(check (op (-> any any any)) diff --git a/collects/rktunit/scribblings/compound-testing.scrbl b/collects/racunit/scribblings/compound-testing.scrbl similarity index 99% rename from collects/rktunit/scribblings/compound-testing.scrbl rename to collects/racunit/scribblings/compound-testing.scrbl index 1879fe71ea..8a0fb71e72 100644 --- a/collects/rktunit/scribblings/compound-testing.scrbl +++ b/collects/racunit/scribblings/compound-testing.scrbl @@ -147,7 +147,7 @@ creates test cases within the suite, with the given names and body expressions. As far I know no-one uses this macro, so it might disappear -in future versions of RktUnit.} +in future versions of RacUnit.} } diff --git a/collects/rktunit/scribblings/control-flow.scrbl b/collects/racunit/scribblings/control-flow.scrbl similarity index 96% rename from collects/rktunit/scribblings/control-flow.scrbl rename to collects/racunit/scribblings/control-flow.scrbl index 68f64cab66..59758d4c17 100644 --- a/collects/rktunit/scribblings/control-flow.scrbl +++ b/collects/racunit/scribblings/control-flow.scrbl @@ -48,5 +48,5 @@ file. The after action deletes it. This somewhat curious macro evaluates the given tests in a context where @racket[current-test-case-around] is parameterized to @racket[test-suite-test-case-around]. This -has been useful in testing RktUnit. It might be useful +has been useful in testing RacUnit. It might be useful for you if you create test cases that create test cases.} diff --git a/collects/rktunit/scribblings/file-test.rkt b/collects/racunit/scribblings/file-test.rkt similarity index 96% rename from collects/rktunit/scribblings/file-test.rkt rename to collects/racunit/scribblings/file-test.rkt index 18413644d1..ce3df2728c 100644 --- a/collects/rktunit/scribblings/file-test.rkt +++ b/collects/racunit/scribblings/file-test.rkt @@ -1,6 +1,6 @@ #lang scheme/base -(require rktunit +(require racunit "file.rkt") (check-equal? (my-+ 1 1) 2) diff --git a/collects/rktunit/scribblings/file.rkt b/collects/racunit/scribblings/file.rkt similarity index 100% rename from collects/rktunit/scribblings/file.rkt rename to collects/racunit/scribblings/file.rkt diff --git a/collects/rktunit/scribblings/misc.scrbl b/collects/racunit/scribblings/misc.scrbl similarity index 89% rename from collects/rktunit/scribblings/misc.scrbl rename to collects/racunit/scribblings/misc.scrbl index 264abdf849..64bd792094 100644 --- a/collects/rktunit/scribblings/misc.scrbl +++ b/collects/racunit/scribblings/misc.scrbl @@ -14,8 +14,8 @@ Note that @racket[require/expose] can be a bit fragile, especially when mixed with compiled code. Use at your own risk! } -This example gets @racket[make-failure-test], which is defined in a RktUnit test: +This example gets @racket[make-failure-test], which is defined in a RacUnit test: @racketblock[ -(require/expose rktunit/private/check-test (make-failure-test)) +(require/expose racunit/private/check-test (make-failure-test)) ] diff --git a/collects/rktunit/scribblings/overview.scrbl b/collects/racunit/scribblings/overview.scrbl similarity index 84% rename from collects/rktunit/scribblings/overview.scrbl rename to collects/racunit/scribblings/overview.scrbl index 3d1efa629a..8645271c63 100644 --- a/collects/rktunit/scribblings/overview.scrbl +++ b/collects/racunit/scribblings/overview.scrbl @@ -1,9 +1,9 @@ #lang scribble/doc @(require "base.rkt") -@title{Overview of RktUnit} +@title{Overview of RacUnit} -There are three basic data types in RktUnit: +There are three basic data types in RacUnit: @itemize[ diff --git a/collects/rktunit/scribblings/philosophy.scrbl b/collects/racunit/scribblings/philosophy.scrbl similarity index 84% rename from collects/rktunit/scribblings/philosophy.scrbl rename to collects/racunit/scribblings/philosophy.scrbl index 359e90ed96..bf776e6d4b 100644 --- a/collects/rktunit/scribblings/philosophy.scrbl +++ b/collects/racunit/scribblings/philosophy.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc @(require "base.rkt") -@title[#:tag "philosophy"]{The Philosophy of RktUnit} +@title[#:tag "philosophy"]{The Philosophy of RacUnit} -RktUnit is designed to allow tests to evolve in step with -the evolution of the program under testing. RktUnit +RacUnit is designed to allow tests to evolve in step with +the evolution of the program under testing. RacUnit scales from the unstructed checks suitable for simple programs to the complex structure necessary for large projects. @@ -25,9 +25,9 @@ checking are of the form: (equal? (length '(a b)) 2) ] -RktUnit directly supports this style of testing. A check +RacUnit directly supports this style of testing. A check on its own is a valid test. So the above examples may be -written in RktUnit as: +written in RacUnit as: @racketblock[ (check-equal? (length null) 0) @@ -35,7 +35,7 @@ written in RktUnit as: (check-equal? (length '(a b)) 2) ] -Simple programs now get all the benefits of RktUnit with +Simple programs now get all the benefits of RacUnit with very little overhead. There are limitations to this style of testing that more @@ -45,7 +45,7 @@ it does not make sense to evaluate some expressions if earlier ones have failed. This type of program needs a way to group expressions so that a failure in one group causes evaluation of that group to stop and immediately proceed to -the next group. In RktUnit all that is required is to +the next group. In RacUnit all that is required is to wrap a @racket[test-begin] expression around a group of expressions: @@ -62,7 +62,7 @@ be evaluated. Notice that all the previous tests written in the simple style are still valid. Introducing grouping is a local -change only. This is a key feature of RktUnit's support +change only. This is a key feature of RacUnit's support for the evolution of the program. The programmer may wish to name a group of tests. This is @@ -79,7 +79,7 @@ Most programs will stick with this style. However, programmers writing very complex programs may wish to maintain separate groups of tests for different parts of the program, or run their tests in different ways to the normal -RktUnit manner (for example, test results may be logged +RacUnit manner (for example, test results may be logged for the purpose of improving software quality, or they may be displayed on a website to indicate service quality). For these programmers it is necessary to delay the execution of @@ -104,15 +104,15 @@ outside the suite continue to evaluate as before. @section{Historical Context} Most testing frameworks, including earlier versions of -RktUnit, support only the final form of testing. This is +RacUnit, support only the final form of testing. This is likely due to the influence of the SUnit testing framework, -which is the ancestor of RktUnit and the most widely used +which is the ancestor of RacUnit and the most widely used frameworks in Java, .Net, Python, and Ruby, and many other languages. That this is insufficient for all users is apparent if one considers the proliferation of ``simpler'' testing frameworks in Racket such as SRFI-78, or the practice of beginner programmers. Unfortunately these simpler methods are inadequate for testing larger -systems. To the best of my knowledge RktUnit is the only +systems. To the best of my knowledge RacUnit is the only testing framework that makes a conscious effort to support the testing style of all levels of programmer. diff --git a/collects/rktunit/scribblings/quick-start.scrbl b/collects/racunit/scribblings/quick-start.scrbl similarity index 87% rename from collects/rktunit/scribblings/quick-start.scrbl rename to collects/racunit/scribblings/quick-start.scrbl index 2e0bea8cf6..af4dc31e7c 100644 --- a/collects/rktunit/scribblings/quick-start.scrbl +++ b/collects/racunit/scribblings/quick-start.scrbl @@ -1,7 +1,7 @@ #lang scribble/doc @(require "base.rkt") -@title[#:tag "quick-start"]{Quick Start Guide for RktUnit} +@title[#:tag "quick-start"]{Quick Start Guide for RacUnit} Suppose we have code contained in @tt{file.rkt}, which implements buggy versions of @racket[+] and @racket[-] @@ -24,15 +24,15 @@ racket/base my-*) ] -We want to test this code with RktUnit. We start by +We want to test this code with RacUnit. We start by creating a file called @tt{file-test.rkt} to contain our tests. At the top of @tt{file-test.rkt} we import -RktUnit and @tt{file.rkt}: +RacUnit and @tt{file.rkt}: @racketmod[ racket/base -(require rktunit +(require racunit "file.rkt") ] @@ -43,7 +43,7 @@ Now we add some tests to check our library: (check-equal? (my-* 1 2) 2 "Simple multiplication") ] -This is all it takes to define tests in RktUnit. Now +This is all it takes to define tests in RacUnit. Now evaluate this file and see if the library is correct. Here's the result I get: @@ -63,13 +63,13 @@ expected: 2 The first @racket[#t] indicates the first test passed. The second test failed, as shown by the message. -Requiring RktUnit and writing checks is all you need to +Requiring RacUnit and writing checks is all you need to get started testing, but let's take a little bit more time to look at some features beyond the essentials. Let's say we want to check that a number of properties hold. How do we do this? So far we've only seen checks of a -single expression. In RktUnit a check is always a single +single expression. In RacUnit a check is always a single expression, but we can group checks into units called test cases. Here's a simple test case written using the @racket[test-begin] form: @@ -91,7 +91,7 @@ Evalute this and you should see an error message like: A test ... has a FAILURE name: check-pred -location: (# 14 6 252 22) +location: (# 14 6 252 22) expression: (check-pred even? elt) params: (# 9) -------------------- @@ -147,13 +147,13 @@ tests, allowing you to choose how you run your tests. You might, for example, print the results to the screen or log them to a file. -Let's run our tests, using RktUnit's simple textual user +Let's run our tests, using RacUnit's simple textual user interface (there are fancier interfaces available but this will do for our example). In @tt{file-test.rkt} add the following lines: @racketblock[ - (require rktunit/text-ui) + (require racunit/text-ui) (run-tests file-tests) ] @@ -161,6 +161,6 @@ following lines: Now evaluate the file and you should see similar output again. -These are the basics of RktUnit. Refer to the +These are the basics of RacUnit. Refer to the documentation below for more advanced topics, such as defining your own checks. Have fun! diff --git a/collects/rktunit/scribblings/rktunit.scrbl b/collects/racunit/scribblings/racunit.scrbl similarity index 82% rename from collects/rktunit/scribblings/rktunit.scrbl rename to collects/racunit/scribblings/racunit.scrbl index 0bb06f1332..aa98ed24b1 100644 --- a/collects/rktunit/scribblings/rktunit.scrbl +++ b/collects/racunit/scribblings/racunit.scrbl @@ -1,12 +1,12 @@ #lang scribble/doc @(require "base.rkt") -@title{@bold{RktUnit}: Unit Testing for Racket} +@title{@bold{RacUnit}: Unit Testing for Racket} @author[(author+email "Noel Welsh" "noelwelsh@gmail.com") (author+email "Ryan Culpepper" "ryan_sml@yahoo.com")] -RktUnit is a unit-testing framework for Racket. It +RacUnit is a unit-testing framework for Racket. It is designed to handle the needs of all Racket programmers, from novices to experts. diff --git a/collects/rktunit/scribblings/release-notes.scrbl b/collects/racunit/scribblings/release-notes.scrbl similarity index 95% rename from collects/rktunit/scribblings/release-notes.scrbl rename to collects/racunit/scribblings/release-notes.scrbl index af5b2d5b40..2015dc4822 100644 --- a/collects/rktunit/scribblings/release-notes.scrbl +++ b/collects/racunit/scribblings/release-notes.scrbl @@ -12,7 +12,7 @@ There are also miscellaneous Scribble fixes. @section{Version 3} -This version of RktUnit is largely backwards compatible +This version of RacUnit is largely backwards compatible with version 2 but there are significant changes to the underlying model, justifying incrementing the major version number. These changes are best explained in diff --git a/collects/rktunit/scribblings/running-tests.scrbl b/collects/racunit/scribblings/running-tests.scrbl similarity index 97% rename from collects/rktunit/scribblings/running-tests.scrbl rename to collects/racunit/scribblings/running-tests.scrbl index d8d895abd6..efe32c6da9 100644 --- a/collects/rktunit/scribblings/running-tests.scrbl +++ b/collects/racunit/scribblings/running-tests.scrbl @@ -3,14 +3,14 @@ @title[#:tag "running"]{Programmatically Running Tests and Inspecting Results} -RktUnit provides an API for running tests, from which +RacUnit provides an API for running tests, from which custom UIs can be created. @section{Result Types} @defstruct[(exn:test exn) ()]{ -The base structure for RktUnit exceptions. You should +The base structure for RacUnit exceptions. You should never catch instances of this type, only the subtypes documented below.} @@ -187,7 +187,7 @@ recorded, and so on. To do so the functions that run the test cases need to know what type the test case has, and hence is is necessary to provide this information. -If you've made it this far you truly are a master RktUnit +If you've made it this far you truly are a master RacUnit hacker. As a bonus prize we'll just mention that the code in hash-monad.rkt and monad.rkt might be of interest for constructing user interfaces. The API is still in flux, so diff --git a/collects/rktunit/scribblings/ui.scrbl b/collects/racunit/scribblings/ui.scrbl similarity index 75% rename from collects/rktunit/scribblings/ui.scrbl rename to collects/racunit/scribblings/ui.scrbl index e070e66872..460965d870 100644 --- a/collects/rktunit/scribblings/ui.scrbl +++ b/collects/racunit/scribblings/ui.scrbl @@ -3,13 +3,13 @@ @title[#:tag "ui"]{User Interfaces} -RktUnit provides a textual and a graphical user interface +RacUnit provides a textual and a graphical user interface @section{Textual User Interface} -@defmodule[rktunit/text-ui] +@defmodule[racunit/text-ui] -The textual UI is in the @racketmodname[rktunit/text-ui] module. +The textual UI is in the @racketmodname[racunit/text-ui] module. It is run via the @racket[run-tests] function. @defproc[(run-tests (test (or/c test-case? test-suite?)) @@ -33,15 +33,15 @@ information. @section{Graphical User Interface} -@defmodule[rktunit/gui] +@defmodule[racunit/gui] -RktUnit also provides a GUI test runner, available from the -@racketmodname[rktunit/gui] module. +RacUnit also provides a GUI test runner, available from the +@racketmodname[racunit/gui] module. @defproc[(test/gui [test (or/c test-case? test-suite?)] ...) any]{ -Creates a new RktUnit GUI window and runs each @racket[test]. The +Creates a new RacUnit GUI window and runs each @racket[test]. The GUI is updated as tests complete. } @@ -49,7 +49,7 @@ GUI is updated as tests complete. @defproc[(make-gui-runner) (-> (or/c test-case? test-suite?) ... any)]{ -Creates a new RktUnit GUI window and returns a procedure that, when +Creates a new RacUnit GUI window and returns a procedure that, when applied, runs the given tests and displays the results in the GUI. } diff --git a/collects/rktunit/text-ui.rkt b/collects/racunit/text-ui.rkt similarity index 100% rename from collects/rktunit/text-ui.rkt rename to collects/racunit/text-ui.rkt diff --git a/collects/rktunit/tool.rkt b/collects/racunit/tool.rkt similarity index 97% rename from collects/rktunit/tool.rkt rename to collects/racunit/tool.rkt index a48f63747e..d725be0ee8 100644 --- a/collects/rktunit/tool.rkt +++ b/collects/racunit/tool.rkt @@ -11,7 +11,7 @@ ;; CONSTANTS (define BACKTRACE-NO-MESSAGE "No message.") -(define LINK-MODULE-SPEC 'rktunit/private/gui/drracket-link) +(define LINK-MODULE-SPEC 'racunit/private/gui/drracket-link) (define-namespace-anchor drracket-ns-anchor) diff --git a/collects/schemeunit/gui.rkt b/collects/schemeunit/gui.rkt index 5b3a672d92..bd856a0e35 100644 --- a/collects/schemeunit/gui.rkt +++ b/collects/schemeunit/gui.rkt @@ -1,3 +1,3 @@ #lang racket -(require rktunit/gui) -(provide (all-from-out rktunit/gui)) \ No newline at end of file +(require racunit/gui) +(provide (all-from-out racunit/gui)) diff --git a/collects/schemeunit/main.rkt b/collects/schemeunit/main.rkt index 969fa1a9be..89c8f2ce32 100644 --- a/collects/schemeunit/main.rkt +++ b/collects/schemeunit/main.rkt @@ -1,3 +1,3 @@ #lang racket -(require rktunit) -(provide (all-from-out rktunit)) \ No newline at end of file +(require racunit) +(provide (all-from-out racunit)) diff --git a/collects/schemeunit/text-ui.rkt b/collects/schemeunit/text-ui.rkt index 1ede14a3b2..619faa294a 100644 --- a/collects/schemeunit/text-ui.rkt +++ b/collects/schemeunit/text-ui.rkt @@ -1,3 +1,3 @@ #lang racket -(require rktunit/text-ui) -(provide (all-from-out rktunit/text-ui)) \ No newline at end of file +(require racunit/text-ui) +(provide (all-from-out racunit/text-ui)) diff --git a/collects/scribblings/guide/contracts-examples/1-test.rkt b/collects/scribblings/guide/contracts-examples/1-test.rkt index 05d48e3df2..8e1fe62059 100644 --- a/collects/scribblings/guide/contracts-examples/1-test.rkt +++ b/collects/scribblings/guide/contracts-examples/1-test.rkt @@ -1,5 +1,5 @@ #lang scheme -(require rktunit rktunit/text-ui "1.ss" "1b.ss") +(require racunit racunit/text-ui "1.ss" "1b.ss") (add (make-basic-customer 'mf "matthias" "brookstone")) (add (make-basic-customer 'rf "robby" "beverly hills park")) diff --git a/collects/scribblings/guide/contracts-examples/2-test.rkt b/collects/scribblings/guide/contracts-examples/2-test.rkt index b4e34f6d82..68b5379e97 100644 --- a/collects/scribblings/guide/contracts-examples/2-test.rkt +++ b/collects/scribblings/guide/contracts-examples/2-test.rkt @@ -1,5 +1,5 @@ #lang scheme -(require rktunit rktunit/text-ui "2.ss") +(require racunit racunit/text-ui "2.ss") (define s0 (initialize (flat-contract integer?) =)) (define s2 (push (push s0 2) 1)) diff --git a/collects/scribblings/guide/contracts-examples/3-test.rkt b/collects/scribblings/guide/contracts-examples/3-test.rkt index 6c19e34d87..65752e94fe 100644 --- a/collects/scribblings/guide/contracts-examples/3-test.rkt +++ b/collects/scribblings/guide/contracts-examples/3-test.rkt @@ -1,5 +1,5 @@ #lang scheme -(require rktunit rktunit/text-ui "3.ss") +(require racunit racunit/text-ui "3.ss") (define d0 (initialize (flat-contract integer?) =)) (define d (put (put (put d0 'a 2) 'b 2) 'c 1)) diff --git a/collects/scribblings/guide/contracts-examples/5-test.rkt b/collects/scribblings/guide/contracts-examples/5-test.rkt index 90e36a8fe1..8498c7696a 100644 --- a/collects/scribblings/guide/contracts-examples/5-test.rkt +++ b/collects/scribblings/guide/contracts-examples/5-test.rkt @@ -1,5 +1,5 @@ #lang scheme -(require rktunit rktunit/text-ui "5.ss") +(require racunit racunit/text-ui "5.ss") (define s (put (put (initialize (flat-contract integer?) =) 2) 1)) diff --git a/collects/tests/deinprogramm/contract.rkt b/collects/tests/deinprogramm/contract.rkt index e763ce6222..95519fba1b 100644 --- a/collects/tests/deinprogramm/contract.rkt +++ b/collects/tests/deinprogramm/contract.rkt @@ -2,7 +2,7 @@ (provide all-contract-tests) -(require rktunit +(require racunit deinprogramm/define-record-procedures deinprogramm/contract/contract deinprogramm/contract/contract-syntax) diff --git a/collects/tests/deinprogramm/image.rkt b/collects/tests/deinprogramm/image.rkt index 13a6753ae4..86cd7cea68 100644 --- a/collects/tests/deinprogramm/image.rkt +++ b/collects/tests/deinprogramm/image.rkt @@ -2,7 +2,7 @@ (provide all-image-tests) -(require rktunit +(require racunit deinprogramm/image (only-in lang/private/imageeq image=?) mred diff --git a/collects/tests/deinprogramm/run-contract-tests.rkt b/collects/tests/deinprogramm/run-contract-tests.rkt index c4700c10da..bae75000fc 100644 --- a/collects/tests/deinprogramm/run-contract-tests.rkt +++ b/collects/tests/deinprogramm/run-contract-tests.rkt @@ -1,6 +1,6 @@ #lang scheme/base -(require rktunit/text-ui) +(require racunit/text-ui) (require tests/deinprogramm/contract) (run-tests all-contract-tests) diff --git a/collects/tests/deinprogramm/run-image-test.rkt b/collects/tests/deinprogramm/run-image-test.rkt index 333e7095f8..d2d75a6c7d 100644 --- a/collects/tests/deinprogramm/run-image-test.rkt +++ b/collects/tests/deinprogramm/run-image-test.rkt @@ -1,6 +1,6 @@ #lang scheme/base -(require rktunit/text-ui) +(require racunit/text-ui) (require tests/deinprogramm/image) (run-tests all-image-tests) diff --git a/collects/tests/eli-tester.rkt b/collects/tests/eli-tester.rkt index b8483977e4..6bb114b90c 100644 --- a/collects/tests/eli-tester.rkt +++ b/collects/tests/eli-tester.rkt @@ -216,7 +216,7 @@ => '(#"1 test passed\n" #"2 tests passed\n") ) -;; RktUnit stuff +;; RacUnit stuff ;; (examples that should fail modified to ones that shouldn't) #| diff --git a/collects/tests/future/future.rkt b/collects/tests/future/future.rkt index 3157c7dd6d..aabc41015d 100644 --- a/collects/tests/future/future.rkt +++ b/collects/tests/future/future.rkt @@ -1,7 +1,7 @@ #lang scheme/base (require scheme/future - rktunit) + racunit) #|Need to add expressions which raise exceptions inside a future thunk which can be caught at the touch site diff --git a/collects/tests/html/test.rkt b/collects/tests/html/test.rkt index 0d6f444c41..4981462c61 100644 --- a/collects/tests/html/test.rkt +++ b/collects/tests/html/test.rkt @@ -1,6 +1,6 @@ #lang racket -(require rktunit - rktunit/text-ui +(require racunit + racunit/text-ui net/url (prefix-in h: html) (prefix-in x: xml)) diff --git a/collects/tests/info.rkt b/collects/tests/info.rkt index a9c9912080..a7377f7216 100644 --- a/collects/tests/info.rkt +++ b/collects/tests/info.rkt @@ -21,7 +21,7 @@ "plot" "profj" "r6rs" - "rktunit" + "racunit" "srfi" "srpersist" "stepper" diff --git a/collects/tests/macro-debugger/all-tests.rkt b/collects/tests/macro-debugger/all-tests.rkt index 0d2ece8a7b..577eb8d5e7 100644 --- a/collects/tests/macro-debugger/all-tests.rkt +++ b/collects/tests/macro-debugger/all-tests.rkt @@ -1,6 +1,6 @@ #lang scheme/base -(require rktunit - rktunit/gui) +(require racunit + racunit/gui) (require macro-debugger/model/debug "gentest-framework.ss" "gentests.ss" diff --git a/collects/tests/macro-debugger/gentests.rkt b/collects/tests/macro-debugger/gentests.rkt index bcf9c2f47c..55c6e24d2a 100644 --- a/collects/tests/macro-debugger/gentests.rkt +++ b/collects/tests/macro-debugger/gentests.rkt @@ -1,5 +1,5 @@ #lang scheme/base -(require rktunit) +(require racunit) (require macro-debugger/model/debug macro-debugger/model/stx-util "gentest-framework.ss" diff --git a/collects/tests/macro-debugger/tests/collects.rkt b/collects/tests/macro-debugger/tests/collects.rkt index ee70b2650a..fff6426ea2 100644 --- a/collects/tests/macro-debugger/tests/collects.rkt +++ b/collects/tests/macro-debugger/tests/collects.rkt @@ -1,6 +1,6 @@ #lang scheme/base -(require rktunit - rktunit/gui) +(require racunit + racunit/gui) (require macro-debugger/model/debug scheme/path scheme/gui) diff --git a/collects/tests/macro-debugger/tests/hiding.rkt b/collects/tests/macro-debugger/tests/hiding.rkt index b3f4a54a54..941c093320 100644 --- a/collects/tests/macro-debugger/tests/hiding.rkt +++ b/collects/tests/macro-debugger/tests/hiding.rkt @@ -1,5 +1,5 @@ #lang scheme/base -(require rktunit) +(require racunit) (require macro-debugger/model/debug "../test-setup.ss") (provide specialized-hiding-tests) diff --git a/collects/tests/macro-debugger/tests/policy.rkt b/collects/tests/macro-debugger/tests/policy.rkt index 57f6cab63c..757de46997 100644 --- a/collects/tests/macro-debugger/tests/policy.rkt +++ b/collects/tests/macro-debugger/tests/policy.rkt @@ -1,5 +1,5 @@ #lang scheme/base -(require rktunit) +(require racunit) (require macro-debugger/model/debug "../test-setup.ss") (provide policy-tests) diff --git a/collects/tests/macro-debugger/tests/regression.rkt b/collects/tests/macro-debugger/tests/regression.rkt index fb0f9d9004..c4c92366b3 100644 --- a/collects/tests/macro-debugger/tests/regression.rkt +++ b/collects/tests/macro-debugger/tests/regression.rkt @@ -1,5 +1,5 @@ #lang scheme/base -(require rktunit) +(require racunit) (require macro-debugger/model/debug macro-debugger/model/steps "../test-setup.ss") diff --git a/collects/tests/match/examples.rkt b/collects/tests/match/examples.rkt index 753011c9d6..f8ce7d8c07 100644 --- a/collects/tests/match/examples.rkt +++ b/collects/tests/match/examples.rkt @@ -6,7 +6,7 @@ (for-syntax scheme/base) (prefix-in m: mzlib/match) (only-in srfi/13 string-contains) - rktunit) + racunit) (define-syntax (comp stx) (syntax-case stx () diff --git a/collects/tests/match/match-tests.rkt b/collects/tests/match/match-tests.rkt index a575fb631f..67ac65e00b 100644 --- a/collects/tests/match/match-tests.rkt +++ b/collects/tests/match/match-tests.rkt @@ -1,5 +1,5 @@ (module match-tests mzscheme - (require mzlib/match rktunit) + (require mzlib/match racunit) (provide match-tests) diff --git a/collects/tests/match/other-plt-tests.rkt b/collects/tests/match/other-plt-tests.rkt index 9026ce05f8..1407614be4 100644 --- a/collects/tests/match/other-plt-tests.rkt +++ b/collects/tests/match/other-plt-tests.rkt @@ -1,6 +1,6 @@ (module other-plt-tests mzscheme - (require rktunit net/uri-codec mzlib/pregexp mzlib/plt-match + (require racunit net/uri-codec mzlib/pregexp mzlib/plt-match mzlib/list mzlib/etc) (define-struct shape (color)) diff --git a/collects/tests/match/other-tests.rkt b/collects/tests/match/other-tests.rkt index 27db39ff3a..174b957ccb 100644 --- a/collects/tests/match/other-tests.rkt +++ b/collects/tests/match/other-tests.rkt @@ -1,5 +1,5 @@ (module other-tests mzscheme - (require mzlib/match rktunit) + (require mzlib/match racunit) (provide other-tests) diff --git a/collects/tests/match/plt-match-tests.rkt b/collects/tests/match/plt-match-tests.rkt index c1eb29f9f4..e707ada4ec 100644 --- a/collects/tests/match/plt-match-tests.rkt +++ b/collects/tests/match/plt-match-tests.rkt @@ -2,7 +2,7 @@ (require (for-syntax scheme/base) "match-tests.ss" "other-plt-tests.ss" "other-tests.ss" "examples.ss" - rktunit rktunit/text-ui) + racunit racunit/text-ui) (require mzlib/plt-match) diff --git a/collects/tests/plai/test-random-mutator.rkt b/collects/tests/plai/test-random-mutator.rkt index f5fb8059bc..988d3603d3 100644 --- a/collects/tests/plai/test-random-mutator.rkt +++ b/collects/tests/plai/test-random-mutator.rkt @@ -1,5 +1,5 @@ #lang scheme -(require rktunit +(require racunit plai/random-mutator scheme/runtime-path ;; test find-heap-values and save-random-mutator via the contract'd diff --git a/collects/tests/racket/contract-opt-tests.rkt b/collects/tests/racket/contract-opt-tests.rkt index cdc45afb8f..892e90b0ac 100644 --- a/collects/tests/racket/contract-opt-tests.rkt +++ b/collects/tests/racket/contract-opt-tests.rkt @@ -1,7 +1,7 @@ (module contract-opt-tests mzscheme (require mzlib/contract - rktunit - rktunit/text-ui) + racunit + racunit/text-ui) (define (exn:fail:contract-violation? exn) (if (regexp-match #rx"broke" (exn-message exn)) #t #f)) diff --git a/collects/tests/raclog/bible.rkt b/collects/tests/raclog/bible.rkt index b5ad0ba087..c971222e51 100644 --- a/collects/tests/raclog/bible.rkt +++ b/collects/tests/raclog/bible.rkt @@ -1,7 +1,7 @@ #lang racket (require raclog - rktunit) + racunit) ;The following is the "Biblical" database from "The Art of ;Prolog", Sterling & Shapiro, ch. 1. diff --git a/collects/tests/raclog/england.rkt b/collects/tests/raclog/england.rkt index 0480262a5c..3babf4bbff 100644 --- a/collects/tests/raclog/england.rkt +++ b/collects/tests/raclog/england.rkt @@ -1,7 +1,7 @@ #lang racket (require raclog - rktunit) + racunit) ;The following is a simple database about a certain family in England. ;Should be a piece of cake, but given here so that you can hone diff --git a/collects/tests/raclog/games.rkt b/collects/tests/raclog/games.rkt index 179b53745a..989448057a 100644 --- a/collects/tests/raclog/games.rkt +++ b/collects/tests/raclog/games.rkt @@ -2,7 +2,7 @@ (require raclog "./puzzle.rkt" - rktunit) + racunit) ;;This example is from Sterling & Shapiro, p. 214. ;; diff --git a/collects/tests/rktunit/all-rktunit-tests.rkt b/collects/tests/racunit/all-racunit-tests.rkt similarity index 92% rename from collects/tests/rktunit/all-rktunit-tests.rkt rename to collects/tests/racunit/all-racunit-tests.rkt index baf8d3cb82..2151ae40a8 100644 --- a/collects/tests/rktunit/all-rktunit-tests.rkt +++ b/collects/tests/racunit/all-racunit-tests.rkt @@ -1,6 +1,6 @@ #lang racket/base -(require rktunit +(require racunit "check-test.rkt" "check-info-test.rkt" "format-test.rkt" @@ -17,12 +17,12 @@ "counter-test.rkt" "text-ui-util-test.rkt") -(provide all-rktunit-tests +(provide all-racunit-tests failure-tests) -(define all-rktunit-tests +(define all-racunit-tests (test-suite - "All RktUnit Tests" + "All RacUnit Tests" check-tests base-tests check-info-tests diff --git a/collects/tests/rktunit/base-test.rkt b/collects/tests/racunit/base-test.rkt similarity index 80% rename from collects/tests/rktunit/base-test.rkt rename to collects/tests/racunit/base-test.rkt index 3c81db7019..fe7b256add 100644 --- a/collects/tests/rktunit/base-test.rkt +++ b/collects/tests/racunit/base-test.rkt @@ -28,8 +28,8 @@ #lang racket/base -(require rktunit - rktunit/private/base) +(require racunit + racunit/private/base) (provide base-tests) @@ -37,45 +37,45 @@ (test-suite "All tests for base" (test-case - "rktunit-test-case structure has a contract on name" + "racunit-test-case structure has a contract on name" (check-exn exn:fail? (lambda () - (make-rktunit-test-case + (make-racunit-test-case 'foo (lambda () #t))))) (test-case - "rktunit-test-case structure has a contract on action" + "racunit-test-case structure has a contract on action" (check-exn exn:fail? (lambda () - (make-rktunit-test-case + (make-racunit-test-case "Name" #f)))) (test-case - "rktunit-test-suite has a contract on its fields" + "racunit-test-suite has a contract on its fields" (check-exn exn:fail? (lambda () - (make-rktunit-test-suite + (make-racunit-test-suite #f (list) (lambda () 3) (lambda () 2)))) (check-exn exn:fail? (lambda () - (make-rktunit-test-suite + (make-racunit-test-suite "Name" #f (lambda () 3) (lambda () 2)))) (check-exn exn:fail? (lambda () - (make-rktunit-test-suite + (make-racunit-test-suite "Name" (list) #f (lambda () 2)))) (check-exn exn:fail? (lambda () - (make-rktunit-test-suite + (make-racunit-test-suite "Name" (list) (lambda () 3) diff --git a/collects/tests/rktunit/check-info-test.rkt b/collects/tests/racunit/check-info-test.rkt similarity index 91% rename from collects/tests/rktunit/check-info-test.rkt rename to collects/tests/racunit/check-info-test.rkt index 6cb5a6d3ca..9b0ff44d9b 100644 --- a/collects/tests/rktunit/check-info-test.rkt +++ b/collects/tests/racunit/check-info-test.rkt @@ -4,20 +4,20 @@ ;;; ;;; Copyright (C) 2003 by Noel Welsh. ;;; -;;; This file is part of RktUnit. +;;; This file is part of RacUnit. -;;; RktUnit is free software; you can redistribute it and/or +;;; RacUnit is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public ;;; License as published by the Free Software Foundation; either ;;; version 2.1 of the License, or (at your option) any later version. -;;; RktUnitis distributed in the hope that it will be useful, +;;; RacUnitis distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; You should have received a copy of the GNU Lesser General Public -;;; License along with RktUnit; if not, write to the Free Software +;;; License along with RacUnit; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ;;; Author: Noel Welsh @@ -27,8 +27,8 @@ #lang racket/base -(require rktunit - rktunit/private/check-info) +(require racunit + racunit/private/check-info) (provide check-info-tests) diff --git a/collects/tests/rktunit/check-test.rkt b/collects/tests/racunit/check-test.rkt similarity index 98% rename from collects/tests/rktunit/check-test.rkt rename to collects/tests/racunit/check-test.rkt index fd2029c670..1ca69fc04a 100644 --- a/collects/tests/rktunit/check-test.rkt +++ b/collects/tests/racunit/check-test.rkt @@ -30,10 +30,10 @@ (require racket/runtime-path srfi/1 - rktunit - rktunit/private/check - rktunit/private/result - rktunit/private/test-suite) + racunit + racunit/private/check + racunit/private/result + racunit/private/test-suite) (provide check-tests) @@ -288,7 +288,7 @@ (cns (current-namespace))) (parameterize ((current-namespace destns)) (namespace-require '(for-syntax racket/base)) - (namespace-require 'rktunit/private/check) + (namespace-require 'racunit/private/check) ;; First check that the right check macro got ;; used: ie that it didn't just compile the thing ;; as an application. diff --git a/collects/tests/rktunit/counter-test.rkt b/collects/tests/racunit/counter-test.rkt similarity index 93% rename from collects/tests/rktunit/counter-test.rkt rename to collects/tests/racunit/counter-test.rkt index 516a3911df..2d32f79838 100644 --- a/collects/tests/rktunit/counter-test.rkt +++ b/collects/tests/racunit/counter-test.rkt @@ -28,10 +28,10 @@ #lang racket/base (require racket/match - rktunit - rktunit/private/counter - rktunit/private/monad - rktunit/private/hash-monad) + racunit + racunit/private/counter + racunit/private/monad + racunit/private/hash-monad) (provide counter-tests) diff --git a/collects/tests/rktunit/format-test.rkt b/collects/tests/racunit/format-test.rkt similarity index 87% rename from collects/tests/rktunit/format-test.rkt rename to collects/tests/racunit/format-test.rkt index 9ac98b13c1..6adc10a8b9 100644 --- a/collects/tests/rktunit/format-test.rkt +++ b/collects/tests/racunit/format-test.rkt @@ -1,8 +1,8 @@ #lang racket/base -(require rktunit - rktunit/private/check-info - rktunit/private/format) +(require racunit + racunit/private/check-info + racunit/private/format) (provide format-tests) diff --git a/collects/tests/rktunit/hash-monad-test.rkt b/collects/tests/racunit/hash-monad-test.rkt similarity index 95% rename from collects/tests/rktunit/hash-monad-test.rkt rename to collects/tests/racunit/hash-monad-test.rkt index cb9eecc1a1..63268021cd 100644 --- a/collects/tests/rktunit/hash-monad-test.rkt +++ b/collects/tests/racunit/hash-monad-test.rkt @@ -28,9 +28,9 @@ #lang racket/base -(require rktunit - rktunit/private/monad - rktunit/private/hash-monad) +(require racunit + racunit/private/monad + racunit/private/hash-monad) (provide hash-monad-tests) diff --git a/collects/tests/rktunit/location-test.rkt b/collects/tests/racunit/location-test.rkt similarity index 98% rename from collects/tests/rktunit/location-test.rkt rename to collects/tests/racunit/location-test.rkt index 22ebbc2500..35740c696b 100644 --- a/collects/tests/rktunit/location-test.rkt +++ b/collects/tests/racunit/location-test.rkt @@ -27,8 +27,8 @@ ;; Commentary: #lang racket/base -(require rktunit - rktunit/private/location) +(require racunit + racunit/private/location) (provide location-tests) diff --git a/collects/tests/rktunit/monad-test.rkt b/collects/tests/racunit/monad-test.rkt similarity index 98% rename from collects/tests/rktunit/monad-test.rkt rename to collects/tests/racunit/monad-test.rkt index 7aeaa5b959..0672e878c6 100644 --- a/collects/tests/rktunit/monad-test.rkt +++ b/collects/tests/racunit/monad-test.rkt @@ -29,8 +29,8 @@ #lang racket/base -(require rktunit - rktunit/private/monad) +(require racunit + racunit/private/monad) (provide monad-tests) diff --git a/collects/tests/rktunit/result-test.rkt b/collects/tests/racunit/result-test.rkt similarity index 95% rename from collects/tests/rktunit/result-test.rkt rename to collects/tests/racunit/result-test.rkt index a8534c1630..a633fb40d9 100644 --- a/collects/tests/rktunit/result-test.rkt +++ b/collects/tests/racunit/result-test.rkt @@ -1,7 +1,7 @@ #lang racket/base -(require rktunit - rktunit/private/result) +(require racunit + racunit/private/result) (provide result-tests) diff --git a/collects/tests/rktunit/run-tests.rkt b/collects/tests/racunit/run-tests.rkt similarity index 74% rename from collects/tests/rktunit/run-tests.rkt rename to collects/tests/racunit/run-tests.rkt index 66f89fd7e6..45c8ccc74e 100644 --- a/collects/tests/rktunit/run-tests.rkt +++ b/collects/tests/racunit/run-tests.rkt @@ -1,10 +1,10 @@ #lang racket/base -(require rktunit - rktunit/text-ui - "all-rktunit-tests.rkt") +(require racunit + racunit/text-ui + "all-racunit-tests.rkt") -(run-tests all-rktunit-tests) +(run-tests all-racunit-tests) ;; These tests should all error, so we switch the meaning of correct and incorrect. If the error display changes significantly, DrDr will catch it (parameterize ([current-error-port (current-output-port)] diff --git a/collects/tests/rktunit/standalone-check-test.rkt b/collects/tests/racunit/standalone-check-test.rkt similarity index 98% rename from collects/tests/rktunit/standalone-check-test.rkt rename to collects/tests/racunit/standalone-check-test.rkt index 9c6615a2d2..454bfe9bf9 100644 --- a/collects/tests/rktunit/standalone-check-test.rkt +++ b/collects/tests/racunit/standalone-check-test.rkt @@ -31,7 +31,7 @@ #lang racket/base -(require rktunit/private/check) +(require racunit/private/check) ;; This check should succeed (check = 1 1 0.0) diff --git a/collects/tests/rktunit/standalone-test-case-test.rkt b/collects/tests/racunit/standalone-test-case-test.rkt similarity index 88% rename from collects/tests/rktunit/standalone-test-case-test.rkt rename to collects/tests/racunit/standalone-test-case-test.rkt index 816f082682..018bd46ece 100644 --- a/collects/tests/rktunit/standalone-test-case-test.rkt +++ b/collects/tests/racunit/standalone-test-case-test.rkt @@ -4,8 +4,8 @@ #lang racket/base -(require rktunit/private/check - rktunit/private/test-case) +(require racunit/private/check + racunit/private/test-case) ;; These tests should succeeds (test-begin (check-eq? 1 1)) diff --git a/collects/tests/rktunit/test-case-test.rkt b/collects/tests/racunit/test-case-test.rkt similarity index 86% rename from collects/tests/rktunit/test-case-test.rkt rename to collects/tests/racunit/test-case-test.rkt index 66fed4c00b..07ca05fd6e 100644 --- a/collects/tests/rktunit/test-case-test.rkt +++ b/collects/tests/racunit/test-case-test.rkt @@ -1,10 +1,10 @@ #lang racket/base -(require rktunit/private/base - rktunit/private/check - rktunit/private/test-case - rktunit/private/test-suite - rktunit/private/result) +(require racunit/private/base + racunit/private/check + racunit/private/test-case + racunit/private/test-suite + racunit/private/result) (provide test-case-tests) diff --git a/collects/tests/rktunit/test-suite-test.rkt b/collects/tests/racunit/test-suite-test.rkt similarity index 97% rename from collects/tests/rktunit/test-suite-test.rkt rename to collects/tests/racunit/test-suite-test.rkt index de7dd5511a..0d1ed9d446 100644 --- a/collects/tests/rktunit/test-suite-test.rkt +++ b/collects/tests/racunit/test-suite-test.rkt @@ -1,7 +1,7 @@ #lang racket/base -(require rktunit - rktunit/private/check) +(require racunit + racunit/private/check) (define run? #f) diff --git a/collects/tests/rktunit/test-test.rkt b/collects/tests/racunit/test-test.rkt similarity index 98% rename from collects/tests/rktunit/test-test.rkt rename to collects/tests/racunit/test-test.rkt index f83dd15589..148a6856bc 100644 --- a/collects/tests/rktunit/test-test.rkt +++ b/collects/tests/racunit/test-test.rkt @@ -4,9 +4,9 @@ racket/runtime-path srfi/1 srfi/13 - rktunit - rktunit/private/util - rktunit/private/location) + racunit + racunit/private/util + racunit/private/location) (provide test-tests) @@ -43,7 +43,7 @@ (let ((destns (make-base-namespace)) (cns (current-namespace))) (parameterize ((current-namespace destns)) - (namespace-require 'rktunit) + (namespace-require 'racunit) (check-exn (lambda (e) (check-pred exn:fail:syntax? e) (check string-contains (exn-message e) msg)) diff --git a/collects/tests/rktunit/text-ui-test.rkt b/collects/tests/racunit/text-ui-test.rkt similarity index 95% rename from collects/tests/rktunit/text-ui-test.rkt rename to collects/tests/racunit/text-ui-test.rkt index 1d9a0d95a3..d8766dd859 100644 --- a/collects/tests/rktunit/text-ui-test.rkt +++ b/collects/tests/racunit/text-ui-test.rkt @@ -33,8 +33,8 @@ racket/port srfi/1 srfi/13 - rktunit - rktunit/text-ui) + racunit + racunit/text-ui) (provide text-ui-tests) @@ -119,9 +119,9 @@ (with-all-output-to-string (failing-binary-test/complex-params)))]) (check string-contains op - "(`(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) - `(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) - `(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))"))) + "`((0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) + (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) + (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))"))) (test-case "Non-binary check output is pretty printed" @@ -129,9 +129,9 @@ (with-all-output-to-string (failing-test/complex-params)))]) (check string-contains op - "(`(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) - `(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) - `(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))"))) + "`((0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) + (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) + (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))"))) (test-case "Location trimmed when file is under current directory" diff --git a/collects/tests/rktunit/text-ui-util-test.rkt b/collects/tests/racunit/text-ui-util-test.rkt similarity index 96% rename from collects/tests/rktunit/text-ui-util-test.rkt rename to collects/tests/racunit/text-ui-util-test.rkt index 2cb1362eb8..931845fd6b 100644 --- a/collects/tests/rktunit/text-ui-util-test.rkt +++ b/collects/tests/racunit/text-ui-util-test.rkt @@ -27,8 +27,8 @@ ;; Commentary: #lang racket/base -(require rktunit - rktunit/private/text-ui-util) +(require racunit + racunit/private/text-ui-util) (provide text-ui-util-tests) diff --git a/collects/tests/rktunit/util-test.rkt b/collects/tests/racunit/util-test.rkt similarity index 94% rename from collects/tests/rktunit/util-test.rkt rename to collects/tests/racunit/util-test.rkt index b1c534592b..bc054ccb13 100644 --- a/collects/tests/rktunit/util-test.rkt +++ b/collects/tests/racunit/util-test.rkt @@ -1,7 +1,7 @@ #lang racket/base -(require rktunit - rktunit/private/util) +(require racunit + racunit/private/util) (provide util-tests) @@ -21,7 +21,7 @@ (check-true (procedure? make-failure-test)) (check-equal? (make-arity-at-least 2) (procedure-arity make-failure-test)) - (check-pred rktunit-test-case? + (check-pred racunit-test-case? (delay-test (make-failure-test "foo" string?))))) (test-case diff --git a/collects/tests/srfi/1/alist-test.rkt b/collects/tests/srfi/1/alist-test.rkt index 6d6277e4bb..bf9fb7aaca 100644 --- a/collects/tests/srfi/1/alist-test.rkt +++ b/collects/tests/srfi/1/alist-test.rkt @@ -33,7 +33,7 @@ ;; stone@math.grin.edu (module alist-test mzscheme - (require rktunit) + (require racunit) (require (all-except srfi/1/alist assoc) (rename srfi/1/alist s:assoc assoc)) diff --git a/collects/tests/srfi/1/all-1-tests.rkt b/collects/tests/srfi/1/all-1-tests.rkt index 6c5b992850..509b3357f4 100644 --- a/collects/tests/srfi/1/all-1-tests.rkt +++ b/collects/tests/srfi/1/all-1-tests.rkt @@ -1,6 +1,6 @@ (module all-1-tests mzscheme - (require rktunit) + (require racunit) (require "alist-test.ss" "cons-test.ss" "delete-test.ss" diff --git a/collects/tests/srfi/1/cons-test.rkt b/collects/tests/srfi/1/cons-test.rkt index d24a275e3e..9ae15fec74 100644 --- a/collects/tests/srfi/1/cons-test.rkt +++ b/collects/tests/srfi/1/cons-test.rkt @@ -34,7 +34,7 @@ (module cons-test mzscheme - (require rktunit) + (require racunit) (require srfi/1/cons) (provide cons-tests) diff --git a/collects/tests/srfi/1/delete-test.rkt b/collects/tests/srfi/1/delete-test.rkt index c721dc88fa..afc6e59a23 100644 --- a/collects/tests/srfi/1/delete-test.rkt +++ b/collects/tests/srfi/1/delete-test.rkt @@ -34,7 +34,7 @@ (module delete-test mzscheme - (require rktunit) + (require racunit) (require (all-except srfi/1/delete member)) (provide delete-tests) diff --git a/collects/tests/srfi/1/filter-test.rkt b/collects/tests/srfi/1/filter-test.rkt index ab7a7d3d92..452b875096 100644 --- a/collects/tests/srfi/1/filter-test.rkt +++ b/collects/tests/srfi/1/filter-test.rkt @@ -34,7 +34,7 @@ (module filter-test mzscheme - (require rktunit) + (require racunit) (require (all-except srfi/1/filter member)) (provide filter-tests) diff --git a/collects/tests/srfi/1/fold-test.rkt b/collects/tests/srfi/1/fold-test.rkt index 582ece5217..bf174570b7 100644 --- a/collects/tests/srfi/1/fold-test.rkt +++ b/collects/tests/srfi/1/fold-test.rkt @@ -34,7 +34,7 @@ (module fold-test mzscheme - (require rktunit) + (require racunit) (require (all-except srfi/1/fold map for-each) (rename srfi/1/fold s:map map) (rename srfi/1/fold s:for-each for-each)) diff --git a/collects/tests/srfi/1/lset-test.rkt b/collects/tests/srfi/1/lset-test.rkt index 6acd3fc9d1..6f1a014386 100644 --- a/collects/tests/srfi/1/lset-test.rkt +++ b/collects/tests/srfi/1/lset-test.rkt @@ -34,7 +34,7 @@ (module lset-test mzscheme - (require rktunit) + (require racunit) (require srfi/1/lset) (provide lset-tests) diff --git a/collects/tests/srfi/1/misc-test.rkt b/collects/tests/srfi/1/misc-test.rkt index 989715be06..66ca346e70 100644 --- a/collects/tests/srfi/1/misc-test.rkt +++ b/collects/tests/srfi/1/misc-test.rkt @@ -34,7 +34,7 @@ (module misc-test mzscheme - (require rktunit) + (require racunit) (require (all-except srfi/1/misc append! reverse!) (rename srfi/1/misc s:append! append!) (rename srfi/1/misc s:reverse! reverse!)) diff --git a/collects/tests/srfi/1/predicate-test.rkt b/collects/tests/srfi/1/predicate-test.rkt index e62d66b5f5..72337f658b 100644 --- a/collects/tests/srfi/1/predicate-test.rkt +++ b/collects/tests/srfi/1/predicate-test.rkt @@ -34,7 +34,7 @@ (module predicate-test mzscheme - (require rktunit) + (require racunit) (require srfi/1/predicate srfi/1/cons) diff --git a/collects/tests/srfi/1/run-tests.rkt b/collects/tests/srfi/1/run-tests.rkt index 5f16086162..a5e4d5169d 100644 --- a/collects/tests/srfi/1/run-tests.rkt +++ b/collects/tests/srfi/1/run-tests.rkt @@ -1,5 +1,5 @@ -(require rktunit) -(require rktunit/text-ui) +(require racunit) +(require racunit/text-ui) (require "all-1-tests.ss") (run-tests all-1-tests) diff --git a/collects/tests/srfi/1/search-test.rkt b/collects/tests/srfi/1/search-test.rkt index 12ab23f04c..a5af271f30 100644 --- a/collects/tests/srfi/1/search-test.rkt +++ b/collects/tests/srfi/1/search-test.rkt @@ -35,7 +35,7 @@ (module search-test mzscheme - (require rktunit) + (require racunit) (require (all-except srfi/1/search member)) (provide search-tests) diff --git a/collects/tests/srfi/1/selector-test.rkt b/collects/tests/srfi/1/selector-test.rkt index 76803dc9ad..a9d05e107b 100644 --- a/collects/tests/srfi/1/selector-test.rkt +++ b/collects/tests/srfi/1/selector-test.rkt @@ -35,7 +35,7 @@ (module selector-test mzscheme - (require rktunit) + (require racunit) (require srfi/1/selector) (provide selector-tests) diff --git a/collects/tests/srfi/13/string-test.rkt b/collects/tests/srfi/13/string-test.rkt index 073ba14ff3..3bf0d94e36 100644 --- a/collects/tests/srfi/13/string-test.rkt +++ b/collects/tests/srfi/13/string-test.rkt @@ -27,7 +27,7 @@ (module string-test mzscheme ;; Noel's Test Framework: (get your copy @ schematics.sourceforge.net) - (require rktunit) + (require racunit) (require srfi/13/string srfi/14/char-set ) diff --git a/collects/tests/srfi/14/char-set-test.rkt b/collects/tests/srfi/14/char-set-test.rkt index 67d8b0fff2..861f777caf 100644 --- a/collects/tests/srfi/14/char-set-test.rkt +++ b/collects/tests/srfi/14/char-set-test.rkt @@ -27,7 +27,7 @@ (module char-set-test mzscheme - (require rktunit) + (require racunit) (require srfi/14/char-set) (provide char-set-tests) diff --git a/collects/tests/srfi/19/tests.rkt b/collects/tests/srfi/19/tests.rkt index 1851ecb8a7..1e3ddf8767 100644 --- a/collects/tests/srfi/19/tests.rkt +++ b/collects/tests/srfi/19/tests.rkt @@ -10,8 +10,8 @@ (require scheme/serialize srfi/19/time) -(require rktunit - rktunit/text-ui) +(require racunit + racunit/text-ui) (define-check (check-comparisons comparison times expected) (for ([time0 (in-list times)] diff --git a/collects/tests/srfi/2/and-let-test.rkt b/collects/tests/srfi/2/and-let-test.rkt index 03ad164fc4..ecc9c711c2 100644 --- a/collects/tests/srfi/2/and-let-test.rkt +++ b/collects/tests/srfi/2/and-let-test.rkt @@ -26,7 +26,7 @@ ;; Commentary: (module and-let-test mzscheme - (require rktunit) + (require racunit) (require srfi/2/and-let) (provide and-let*-tests) diff --git a/collects/tests/srfi/26/cut-test.rkt b/collects/tests/srfi/26/cut-test.rkt index 8f2ffb84c4..c482795886 100644 --- a/collects/tests/srfi/26/cut-test.rkt +++ b/collects/tests/srfi/26/cut-test.rkt @@ -23,7 +23,7 @@ ; $Id: cut-test.ss,v 1.1 2002/06/20 15:40:52 noel Exp $ (module cut-test mzscheme - (require rktunit) + (require racunit) (require srfi/26/cut) (provide cut-tests) diff --git a/collects/tests/srfi/4/srfi-4-test.rkt b/collects/tests/srfi/4/srfi-4-test.rkt index 7aa4225ffb..5e2b4311b3 100644 --- a/collects/tests/srfi/4/srfi-4-test.rkt +++ b/collects/tests/srfi/4/srfi-4-test.rkt @@ -1,7 +1,7 @@ (module srfi-4-test mzscheme - (require rktunit) - (require rktunit/text-ui + (require racunit) + (require racunit/text-ui srfi/4) (provide srfi-4-tests) diff --git a/collects/tests/srfi/40/all-srfi-40-tests.rkt b/collects/tests/srfi/40/all-srfi-40-tests.rkt index 8f069f96f0..2e24ecd136 100644 --- a/collects/tests/srfi/40/all-srfi-40-tests.rkt +++ b/collects/tests/srfi/40/all-srfi-40-tests.rkt @@ -1,5 +1,5 @@ (module all-srfi-40-tests mzscheme - (require rktunit) + (require racunit) (require srfi/40) (provide all-srfi-40-tests) diff --git a/collects/tests/srfi/40/run-tests.rkt b/collects/tests/srfi/40/run-tests.rkt index a9b0fada83..abea2dceec 100644 --- a/collects/tests/srfi/40/run-tests.rkt +++ b/collects/tests/srfi/40/run-tests.rkt @@ -1,5 +1,5 @@ -(require rktunit) -(require rktunit/text-ui) +(require racunit) +(require racunit/text-ui) (require "all-srfi-40-tests.ss") (run-tests all-srfi-40-tests) diff --git a/collects/tests/srfi/43/all-srfi-43-tests.rkt b/collects/tests/srfi/43/all-srfi-43-tests.rkt index c4620fc684..eacd083544 100644 --- a/collects/tests/srfi/43/all-srfi-43-tests.rkt +++ b/collects/tests/srfi/43/all-srfi-43-tests.rkt @@ -1,5 +1,5 @@ (module all-srfi-43-tests mzscheme - (require rktunit) + (require racunit) (require "constructor-tests.ss" "predicate-tests.ss" "iteration-tests.ss" diff --git a/collects/tests/srfi/43/constructor-tests.rkt b/collects/tests/srfi/43/constructor-tests.rkt index c2457f093c..2a2b1d595d 100644 --- a/collects/tests/srfi/43/constructor-tests.rkt +++ b/collects/tests/srfi/43/constructor-tests.rkt @@ -1,6 +1,6 @@ (module constructor-tests mzscheme - (require rktunit) + (require racunit) (require srfi/43/vector-lib) (provide constructor-tests) diff --git a/collects/tests/srfi/43/conversion-tests.rkt b/collects/tests/srfi/43/conversion-tests.rkt index 26617e5430..c0aac37f3e 100644 --- a/collects/tests/srfi/43/conversion-tests.rkt +++ b/collects/tests/srfi/43/conversion-tests.rkt @@ -1,6 +1,6 @@ (module conversion-tests mzscheme - (require rktunit) + (require racunit) (require srfi/43/vector-lib) (provide conversion-tests) diff --git a/collects/tests/srfi/43/iteration-tests.rkt b/collects/tests/srfi/43/iteration-tests.rkt index a3ce6e6579..d2d09c28bf 100644 --- a/collects/tests/srfi/43/iteration-tests.rkt +++ b/collects/tests/srfi/43/iteration-tests.rkt @@ -1,6 +1,6 @@ (module iteration-tests mzscheme - (require rktunit) + (require racunit) (require srfi/43/vector-lib) (provide iteration-tests) diff --git a/collects/tests/srfi/43/mutator-tests.rkt b/collects/tests/srfi/43/mutator-tests.rkt index 79f1813918..d5c750add4 100644 --- a/collects/tests/srfi/43/mutator-tests.rkt +++ b/collects/tests/srfi/43/mutator-tests.rkt @@ -1,6 +1,6 @@ (module mutator-tests mzscheme - (require rktunit) + (require racunit) (require srfi/43/vector-lib) (provide mutator-tests) diff --git a/collects/tests/srfi/43/predicate-tests.rkt b/collects/tests/srfi/43/predicate-tests.rkt index a98b03d4eb..412b9f29fa 100644 --- a/collects/tests/srfi/43/predicate-tests.rkt +++ b/collects/tests/srfi/43/predicate-tests.rkt @@ -1,6 +1,6 @@ (module predicate-tests mzscheme - (require rktunit) + (require racunit) (require srfi/43/vector-lib) (provide predicate-tests) diff --git a/collects/tests/srfi/43/run-tests.rkt b/collects/tests/srfi/43/run-tests.rkt index 18e001b1fe..9891ab3900 100644 --- a/collects/tests/srfi/43/run-tests.rkt +++ b/collects/tests/srfi/43/run-tests.rkt @@ -1,5 +1,5 @@ -(require rktunit) -(require rktunit/text-ui) +(require racunit) +(require racunit/text-ui) (require "all-srfi-43-tests.ss") (run-tests all-srfi-43-tests) diff --git a/collects/tests/srfi/43/searching-tests.rkt b/collects/tests/srfi/43/searching-tests.rkt index e8c6ffcc06..96093804e7 100644 --- a/collects/tests/srfi/43/searching-tests.rkt +++ b/collects/tests/srfi/43/searching-tests.rkt @@ -1,6 +1,6 @@ (module searching-tests mzscheme - (require rktunit) + (require racunit) (require srfi/43/vector-lib) (provide searching-tests) diff --git a/collects/tests/srfi/69/hash-tests.rkt b/collects/tests/srfi/69/hash-tests.rkt index 433c1e3817..797aca6485 100644 --- a/collects/tests/srfi/69/hash-tests.rkt +++ b/collects/tests/srfi/69/hash-tests.rkt @@ -1,6 +1,6 @@ (module hash-tests mzscheme - (require rktunit) + (require racunit) (require srfi/1/list (prefix h: srfi/69)) diff --git a/collects/tests/srfi/all-srfi-tests.rkt b/collects/tests/srfi/all-srfi-tests.rkt index 4626cd8dd3..ab589733dc 100644 --- a/collects/tests/srfi/all-srfi-tests.rkt +++ b/collects/tests/srfi/all-srfi-tests.rkt @@ -1,6 +1,6 @@ (module all-srfi-tests mzscheme - (require rktunit) + (require racunit) (require "1/all-1-tests.ss" "2/and-let-test.ss" "4/srfi-4-test.ss" diff --git a/collects/tests/srfi/run-tests.rkt b/collects/tests/srfi/run-tests.rkt index b4ebddcd28..050d4e6850 100644 --- a/collects/tests/srfi/run-tests.rkt +++ b/collects/tests/srfi/run-tests.rkt @@ -1,7 +1,7 @@ #lang scheme/base -(require rktunit) -(require rktunit/text-ui) +(require racunit) +(require racunit/text-ui) (require "all-srfi-tests.ss") (run-tests all-srfi-tests) diff --git a/collects/tests/stxparse/more-tests.rkt b/collects/tests/stxparse/more-tests.rkt index 46fbbd80a3..5bba8a038a 100644 --- a/collects/tests/stxparse/more-tests.rkt +++ b/collects/tests/stxparse/more-tests.rkt @@ -1,6 +1,6 @@ #lang scheme (require syntax/parse - rktunit) + racunit) (require (for-syntax syntax/parse)) (define-syntax (convert-syntax-error stx) diff --git a/collects/tests/stxparse/select.rkt b/collects/tests/stxparse/select.rkt index 7ff85f6bec..df03b2b468 100644 --- a/collects/tests/stxparse/select.rkt +++ b/collects/tests/stxparse/select.rkt @@ -1,5 +1,5 @@ #lang scheme -(require rktunit +(require racunit syntax/parse) (require (for-syntax syntax/parse)) (provide (all-defined-out)) diff --git a/collects/tests/stxparse/stxclass.rkt b/collects/tests/stxparse/stxclass.rkt index 2d06baf0a3..0b6a32df13 100644 --- a/collects/tests/stxparse/stxclass.rkt +++ b/collects/tests/stxparse/stxclass.rkt @@ -1,6 +1,6 @@ #lang scheme/base -(require rktunit +(require racunit syntax/parse (for-syntax scheme/base syntax/parse)) diff --git a/collects/tests/stxparse/test.rkt b/collects/tests/stxparse/test.rkt index 62d41a7fe9..c2663108cd 100644 --- a/collects/tests/stxparse/test.rkt +++ b/collects/tests/stxparse/test.rkt @@ -2,7 +2,7 @@ (require syntax/parse syntax/private/stxparse/rep-attrs syntax/private/stxparse/runtime) -(require rktunit) +(require racunit) ;; tok = test pattern ok (define-syntax tok diff --git a/collects/tests/typed-scheme/main.rkt b/collects/tests/typed-scheme/main.rkt index 048b2d4195..6315119172 100644 --- a/collects/tests/typed-scheme/main.rkt +++ b/collects/tests/typed-scheme/main.rkt @@ -2,7 +2,7 @@ (provide go go/text) -(require rktunit rktunit/text-ui +(require racunit racunit/text-ui mzlib/etc scheme/port compiler/compiler scheme/match diff --git a/collects/tests/typed-scheme/succeed/fixnum.rkt b/collects/tests/typed-scheme/succeed/fixnum.rkt index 640cdf1cfa..27e50ba56d 100644 --- a/collects/tests/typed-scheme/succeed/fixnum.rkt +++ b/collects/tests/typed-scheme/succeed/fixnum.rkt @@ -10,7 +10,7 @@ ;; really badly wrong. (: check (All (a) ((a a -> Boolean) a a -> Boolean))) -;; Simple check function as RktUnit doesn't work in Typed Scheme (yet) +;; Simple check function as RacUnit doesn't work in Typed Scheme (yet) (define (check f a b) (if (f a b) #t diff --git a/collects/tests/typed-scheme/succeed/flonum.rkt b/collects/tests/typed-scheme/succeed/flonum.rkt index bacb377500..0c709e64de 100644 --- a/collects/tests/typed-scheme/succeed/flonum.rkt +++ b/collects/tests/typed-scheme/succeed/flonum.rkt @@ -5,7 +5,7 @@ scheme/unsafe/ops) (: check (All (a) ((a a -> Boolean) a a -> Boolean))) -;; Simple check function as RktUnit doesn't work in Typed Scheme (yet) +;; Simple check function as RacUnit doesn't work in Typed Scheme (yet) (define (check f a b) (if (f a b) #t diff --git a/collects/tests/typed-scheme/succeed/flvector.rkt b/collects/tests/typed-scheme/succeed/flvector.rkt index 066d2068c1..255776edf9 100644 --- a/collects/tests/typed-scheme/succeed/flvector.rkt +++ b/collects/tests/typed-scheme/succeed/flvector.rkt @@ -11,7 +11,7 @@ ;; really badly wrong. (: check (All (a) ((a a -> Boolean) a a -> Boolean))) -;; Simple check function as RktUnit doesn't work in Typed Scheme (yet) +;; Simple check function as RacUnit doesn't work in Typed Scheme (yet) (define (check f a b) (if (f a b) #t diff --git a/collects/tests/typed-scheme/unit-tests/all-tests.rkt b/collects/tests/typed-scheme/unit-tests/all-tests.rkt index 7d6b9f542f..27fb506979 100644 --- a/collects/tests/typed-scheme/unit-tests/all-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/all-tests.rkt @@ -12,7 +12,7 @@ "subst-tests.ss" ;; pass "infer-tests.ss" ;; pass "contract-tests.ss" - (r:infer infer infer-dummy) rktunit) + (r:infer infer infer-dummy) racunit) (provide unit-tests) diff --git a/collects/tests/typed-scheme/unit-tests/contract-tests.rkt b/collects/tests/typed-scheme/unit-tests/contract-tests.rkt index 2da932c628..d83173fc8b 100644 --- a/collects/tests/typed-scheme/unit-tests/contract-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/contract-tests.rkt @@ -7,7 +7,7 @@ (rep type-rep filter-rep object-rep) (types utils union convenience) (utils tc-utils) - rktunit) + racunit) (define-syntax-rule (t e) (test-not-exn (format "~a" e) (lambda () (type->contract e (lambda _ (error "type could not be converted to contract")))))) diff --git a/collects/tests/typed-scheme/unit-tests/infer-tests.rkt b/collects/tests/typed-scheme/unit-tests/infer-tests.rkt index 4418c8f51e..011e66ae71 100644 --- a/collects/tests/typed-scheme/unit-tests/infer-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/infer-tests.rkt @@ -3,7 +3,7 @@ (require (rep type-rep) (r:infer infer) (types convenience union utils abbrev) - rktunit) + racunit) diff --git a/collects/tests/typed-scheme/unit-tests/module-tests.rkt b/collects/tests/typed-scheme/unit-tests/module-tests.rkt index 188bf916bd..f4b00aef77 100644 --- a/collects/tests/typed-scheme/unit-tests/module-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/module-tests.rkt @@ -1,5 +1,5 @@ #lang scheme -(require "test-utils.ss" rktunit) +(require "test-utils.ss" racunit) (provide module-tests) diff --git a/collects/tests/typed-scheme/unit-tests/parse-type-tests.rkt b/collects/tests/typed-scheme/unit-tests/parse-type-tests.rkt index 8f04fa8258..5252e603b2 100644 --- a/collects/tests/typed-scheme/unit-tests/parse-type-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/parse-type-tests.rkt @@ -8,7 +8,7 @@ (private base-types-new base-types-extra colon) (for-template (private base-types-new base-types-extra base-env colon)) (private parse-type) - rktunit) + racunit) (provide parse-type-tests) diff --git a/collects/tests/typed-scheme/unit-tests/planet-requires.rkt b/collects/tests/typed-scheme/unit-tests/planet-requires.rkt index 1a7db776e2..1ec61ab5f0 100644 --- a/collects/tests/typed-scheme/unit-tests/planet-requires.rkt +++ b/collects/tests/typed-scheme/unit-tests/planet-requires.rkt @@ -30,12 +30,12 @@ (splice-requires (map mk (syntax->list #'(files ...)))))])))) -(provide rktunit) +(provide racunit) ;; why is this neccessary? (provide planet/multiple) -(define-module rktunit - (planet/multiple ("schematics" "rktunit.plt" 2 11) +(define-module racunit + (planet/multiple ("schematics" "racunit.plt" 2 11) "test.ss" ;"graphical-ui.ss" "text-ui.ss" @@ -44,4 +44,4 @@ #; (planet/multiple ("cce" "fasttest.plt" 1 2) "random.ss" - "rktunit.ss")) + "racunit.ss")) diff --git a/collects/tests/typed-scheme/unit-tests/remove-intersect-tests.rkt b/collects/tests/typed-scheme/unit-tests/remove-intersect-tests.rkt index 46d0910d1c..a0cb778a3e 100644 --- a/collects/tests/typed-scheme/unit-tests/remove-intersect-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/remove-intersect-tests.rkt @@ -3,7 +3,7 @@ (rep type-rep) (r:infer infer infer-dummy) (types convenience subtype union remove-intersect) - rktunit) + racunit) (define-syntax (over-tests stx) (syntax-case stx () diff --git a/collects/tests/typed-scheme/unit-tests/subst-tests.rkt b/collects/tests/typed-scheme/unit-tests/subst-tests.rkt index 546c4eef08..61ee5c02f5 100644 --- a/collects/tests/typed-scheme/unit-tests/subst-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/subst-tests.rkt @@ -3,7 +3,7 @@ (require "test-utils.ss" (for-syntax scheme/base) (rep type-rep) (types utils abbrev) - rktunit) + racunit) (define-syntax-rule (s img var tgt result) (test-eq? "test" (substitute img 'var tgt) result)) diff --git a/collects/tests/typed-scheme/unit-tests/subtype-tests.rkt b/collects/tests/typed-scheme/unit-tests/subtype-tests.rkt index 9f5fe6c943..b43e4c0285 100644 --- a/collects/tests/typed-scheme/unit-tests/subtype-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/subtype-tests.rkt @@ -5,7 +5,7 @@ (rep type-rep) (env init-envs type-environments) (r:infer infer infer-dummy) - rktunit + racunit (for-syntax scheme/base)) (provide subtype-tests) diff --git a/collects/tests/typed-scheme/unit-tests/test-utils.rkt b/collects/tests/typed-scheme/unit-tests/test-utils.rkt index bcce8ab843..d4ad6aedc0 100644 --- a/collects/tests/typed-scheme/unit-tests/test-utils.rkt +++ b/collects/tests/typed-scheme/unit-tests/test-utils.rkt @@ -7,7 +7,7 @@ typed-scheme/utils/utils (for-syntax scheme/base) (types comparison utils) - rktunit rktunit/text-ui) + racunit racunit/text-ui) (provide private typecheck (rename-out [infer r:infer]) utils env rep types) @@ -20,7 +20,7 @@ (run-tests (mk-suite ts))) (define (test/gui suite) - (((dynamic-require 'rktunit/private/gui/gui 'make-gui-runner)) + (((dynamic-require 'racunit/private/gui/gui 'make-gui-runner)) suite)) (define (run/gui . ts) diff --git a/collects/tests/typed-scheme/unit-tests/type-annotation-test.rkt b/collects/tests/typed-scheme/unit-tests/type-annotation-test.rkt index 8479820a8f..8e73752988 100644 --- a/collects/tests/typed-scheme/unit-tests/type-annotation-test.rkt +++ b/collects/tests/typed-scheme/unit-tests/type-annotation-test.rkt @@ -6,7 +6,7 @@ (env type-environments type-name-env init-envs) (utils tc-utils) (rep type-rep) - rktunit) + racunit) (provide type-annotation-tests) diff --git a/collects/tests/typed-scheme/unit-tests/type-equal-tests.rkt b/collects/tests/typed-scheme/unit-tests/type-equal-tests.rkt index 1fcd1f759d..f66af265d9 100644 --- a/collects/tests/typed-scheme/unit-tests/type-equal-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/type-equal-tests.rkt @@ -3,7 +3,7 @@ (require "test-utils.ss" (for-syntax scheme/base) (rep type-rep) (types comparison abbrev union) - rktunit) + racunit) (provide type-equal-tests) diff --git a/collects/tests/typed-scheme/unit-tests/typecheck-tests.rkt b/collects/tests/typed-scheme/unit-tests/typecheck-tests.rkt index be6a31f2ab..ca86558640 100644 --- a/collects/tests/typed-scheme/unit-tests/typecheck-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/typecheck-tests.rkt @@ -17,7 +17,7 @@ (utils tc-utils utils) unstable/mutated-vars (env type-name-env type-environments init-envs) - rktunit + racunit syntax/parse (for-syntax (utils tc-utils) (typecheck typechecker) diff --git a/collects/tests/web-server/all-web-server-tests.rkt b/collects/tests/web-server/all-web-server-tests.rkt index 65b4b07ccd..8b90ea90f2 100644 --- a/collects/tests/web-server/all-web-server-tests.rkt +++ b/collects/tests/web-server/all-web-server-tests.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit "configuration/all-configuration-tests.rkt" "dispatchers/all-dispatchers-tests.rkt" "lang/all-lang-tests.rkt" diff --git a/collects/tests/web-server/configuration/all-configuration-tests.rkt b/collects/tests/web-server/configuration/all-configuration-tests.rkt index 41c99ecc30..bd7703f4c7 100644 --- a/collects/tests/web-server/configuration/all-configuration-tests.rkt +++ b/collects/tests/web-server/configuration/all-configuration-tests.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit "configuration-table-test.rkt") (provide all-configuration-tests) diff --git a/collects/tests/web-server/configuration/configuration-table-test.rkt b/collects/tests/web-server/configuration/configuration-table-test.rkt index d67e440b4d..cd602c87ad 100644 --- a/collects/tests/web-server/configuration/configuration-table-test.rkt +++ b/collects/tests/web-server/configuration/configuration-table-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit (only-in mzlib/file make-temporary-file) web-server/configuration/configuration-table) diff --git a/collects/tests/web-server/dispatch-test.rkt b/collects/tests/web-server/dispatch-test.rkt index d91d90af25..3ed75947eb 100644 --- a/collects/tests/web-server/dispatch-test.rkt +++ b/collects/tests/web-server/dispatch-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit web-server/http web-server/dispatchers/dispatch net/url @@ -458,5 +458,5 @@ #;(test-serve/dispatch) -(require rktunit/text-ui) +(require racunit/text-ui) (run-tests all-dispatch-tests) diff --git a/collects/tests/web-server/dispatchers/all-dispatchers-tests.rkt b/collects/tests/web-server/dispatchers/all-dispatchers-tests.rkt index 00083f7917..4f5c36e0e2 100644 --- a/collects/tests/web-server/dispatchers/all-dispatchers-tests.rkt +++ b/collects/tests/web-server/dispatchers/all-dispatchers-tests.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit "dispatch-passwords-test.rkt" "dispatch-files-test.rkt" "dispatch-servlets-test.rkt" diff --git a/collects/tests/web-server/dispatchers/dispatch-files-test.rkt b/collects/tests/web-server/dispatchers/dispatch-files-test.rkt index 78b5ccf047..4fb373a65b 100644 --- a/collects/tests/web-server/dispatchers/dispatch-files-test.rkt +++ b/collects/tests/web-server/dispatchers/dispatch-files-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit (only-in mzlib/file file-name-from-path make-temporary-file) @@ -120,5 +120,5 @@ exn:dispatcher? (lambda () (collect (dispatch #f a-dir) (req #t #"HEAD" empty)))))) -#;(require (planet schematics/rktunit:3/text-ui)) +#;(require (planet schematics/racunit:3/text-ui)) #;(run-tests dispatch-files-tests) diff --git a/collects/tests/web-server/dispatchers/dispatch-host-test.rkt b/collects/tests/web-server/dispatchers/dispatch-host-test.rkt index 3143d201e0..c79d6a4e9a 100644 --- a/collects/tests/web-server/dispatchers/dispatch-host-test.rkt +++ b/collects/tests/web-server/dispatchers/dispatch-host-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit (only-in mzlib/file make-temporary-file) net/url diff --git a/collects/tests/web-server/dispatchers/dispatch-lang-test.rkt b/collects/tests/web-server/dispatchers/dispatch-lang-test.rkt index 7036604798..b473e4591e 100644 --- a/collects/tests/web-server/dispatchers/dispatch-lang-test.rkt +++ b/collects/tests/web-server/dispatchers/dispatch-lang-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit mzlib/etc mzlib/list web-server/dispatchers/dispatch @@ -164,6 +164,6 @@ )) #| -(require rktunit/text-ui) +(require racunit/text-ui) (run-tests dispatch-lang-tests) |# diff --git a/collects/tests/web-server/dispatchers/dispatch-passwords-test.rkt b/collects/tests/web-server/dispatchers/dispatch-passwords-test.rkt index 869c4bbb30..33347211b7 100644 --- a/collects/tests/web-server/dispatchers/dispatch-passwords-test.rkt +++ b/collects/tests/web-server/dispatchers/dispatch-passwords-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit (only-in mzlib/file make-temporary-file) net/url diff --git a/collects/tests/web-server/dispatchers/dispatch-servlets-test.rkt b/collects/tests/web-server/dispatchers/dispatch-servlets-test.rkt index f8bfb708c9..949019e14d 100644 --- a/collects/tests/web-server/dispatchers/dispatch-servlets-test.rkt +++ b/collects/tests/web-server/dispatchers/dispatch-servlets-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit mzlib/etc mzlib/list web-server/http diff --git a/collects/tests/web-server/dispatchers/filesystem-map-test.rkt b/collects/tests/web-server/dispatchers/filesystem-map-test.rkt index 8e3944fe77..061f706222 100644 --- a/collects/tests/web-server/dispatchers/filesystem-map-test.rkt +++ b/collects/tests/web-server/dispatchers/filesystem-map-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit net/url web-server/private/util web-server/dispatchers/filesystem-map) diff --git a/collects/tests/web-server/dispatchers/servlet-test-util.rkt b/collects/tests/web-server/dispatchers/servlet-test-util.rkt index 3a8891151e..3ac0782dbf 100644 --- a/collects/tests/web-server/dispatchers/servlet-test-util.rkt +++ b/collects/tests/web-server/dispatchers/servlet-test-util.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit mzlib/list web-server/http "../util.rkt") diff --git a/collects/tests/web-server/formlets-test.rkt b/collects/tests/web-server/formlets-test.rkt index 895e44d95e..be71f9bd58 100644 --- a/collects/tests/web-server/formlets-test.rkt +++ b/collects/tests/web-server/formlets-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit net/url web-server/http web-server/formlets @@ -370,5 +370,5 @@ )) -(require rktunit/text-ui) +(require racunit/text-ui) (run-tests all-formlets-tests) diff --git a/collects/tests/web-server/http/all-http-tests.rkt b/collects/tests/web-server/http/all-http-tests.rkt index 906b334a1f..a722c882ab 100644 --- a/collects/tests/web-server/http/all-http-tests.rkt +++ b/collects/tests/web-server/http/all-http-tests.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit "cookies-test.rkt" "digest-auth-test.rkt") (provide all-http-tests) diff --git a/collects/tests/web-server/http/cookies-test.rkt b/collects/tests/web-server/http/cookies-test.rkt index c1f56f8227..6ed78bfe6d 100644 --- a/collects/tests/web-server/http/cookies-test.rkt +++ b/collects/tests/web-server/http/cookies-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit net/url web-server/http/request-structs web-server/http/response-structs @@ -141,5 +141,5 @@ ))) -#;(require rktunit/text-ui) +#;(require racunit/text-ui) #;(run-tests cookies-tests) diff --git a/collects/tests/web-server/http/digest-auth-test.rkt b/collects/tests/web-server/http/digest-auth-test.rkt index bb31d356f4..1bc7263f9b 100644 --- a/collects/tests/web-server/http/digest-auth-test.rkt +++ b/collects/tests/web-server/http/digest-auth-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit web-server/http net/url) (provide digest-auth-tests) diff --git a/collects/tests/web-server/lang-test.rkt b/collects/tests/web-server/lang-test.rkt index 98107a4d96..3da169df89 100644 --- a/collects/tests/web-server/lang-test.rkt +++ b/collects/tests/web-server/lang-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit "util.rkt") (provide lang-tests) diff --git a/collects/tests/web-server/lang/abort-resume-test.rkt b/collects/tests/web-server/lang/abort-resume-test.rkt index b8305fed4c..f166cab69f 100644 --- a/collects/tests/web-server/lang/abort-resume-test.rkt +++ b/collects/tests/web-server/lang/abort-resume-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit web-server/lang/abort-resume) (require/expose web-server/lang/abort-resume (web-prompt)) (provide abort-resume-tests) @@ -306,6 +306,6 @@ )) #| -(require rktunit/text-ui) +(require racunit/text-ui) (run-tests abort-resume-tests) |# diff --git a/collects/tests/web-server/lang/all-lang-tests.rkt b/collects/tests/web-server/lang/all-lang-tests.rkt index e4830190cf..ba06886206 100644 --- a/collects/tests/web-server/lang/all-lang-tests.rkt +++ b/collects/tests/web-server/lang/all-lang-tests.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit "abort-resume-test.rkt" "anormal-test.rkt" "defun-test.rkt" diff --git a/collects/tests/web-server/lang/anormal-test.rkt b/collects/tests/web-server/lang/anormal-test.rkt index 430c7099bb..cacede5139 100644 --- a/collects/tests/web-server/lang/anormal-test.rkt +++ b/collects/tests/web-server/lang/anormal-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit web-server/lang/anormal web-server/lang/util) (provide anormal-tests) diff --git a/collects/tests/web-server/lang/defun-test.rkt b/collects/tests/web-server/lang/defun-test.rkt index de10e08029..93abc043ec 100644 --- a/collects/tests/web-server/lang/defun-test.rkt +++ b/collects/tests/web-server/lang/defun-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit web-server/lang/defun web-server/lang/util) (provide defun-tests) diff --git a/collects/tests/web-server/lang/file-box-test.rkt b/collects/tests/web-server/lang/file-box-test.rkt index 144287593b..5388373a08 100644 --- a/collects/tests/web-server/lang/file-box-test.rkt +++ b/collects/tests/web-server/lang/file-box-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit web-server/lang/file-box (only-in mzlib/file make-temporary-file)) (provide file-box-tests) diff --git a/collects/tests/web-server/lang/labels-test.rkt b/collects/tests/web-server/lang/labels-test.rkt index 042b9bac1f..74aae31f54 100644 --- a/collects/tests/web-server/lang/labels-test.rkt +++ b/collects/tests/web-server/lang/labels-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit web-server/lang/labels) (provide labels-tests) diff --git a/collects/tests/web-server/lang/stuff-url-test.rkt b/collects/tests/web-server/lang/stuff-url-test.rkt index fa25f1a6ff..adbade62bc 100644 --- a/collects/tests/web-server/lang/stuff-url-test.rkt +++ b/collects/tests/web-server/lang/stuff-url-test.rkt @@ -1,7 +1,7 @@ #lang racket/base (require web-server/lang/stuff-url web-server/stuffers - rktunit + racunit net/url mzlib/serialize "../util.rkt") diff --git a/collects/tests/web-server/lang/web-param-test.rkt b/collects/tests/web-server/lang/web-param-test.rkt index 2c9f0f06a6..011a5033c0 100644 --- a/collects/tests/web-server/lang/web-param-test.rkt +++ b/collects/tests/web-server/lang/web-param-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit "../util.rkt") (provide web-param-tests) diff --git a/collects/tests/web-server/managers/all-managers-tests.rkt b/collects/tests/web-server/managers/all-managers-tests.rkt index 739cab4bf4..c587719b5f 100644 --- a/collects/tests/web-server/managers/all-managers-tests.rkt +++ b/collects/tests/web-server/managers/all-managers-tests.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit) +(require racunit) (provide all-managers-tests) (define all-managers-tests diff --git a/collects/tests/web-server/private/all-private-tests.rkt b/collects/tests/web-server/private/all-private-tests.rkt index adae03de54..d483c50c3c 100644 --- a/collects/tests/web-server/private/all-private-tests.rkt +++ b/collects/tests/web-server/private/all-private-tests.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit "request-test.rkt" "cache-table-test.rkt" "response-test.rkt" diff --git a/collects/tests/web-server/private/cache-table-test.rkt b/collects/tests/web-server/private/cache-table-test.rkt index 48028c50dc..9777f18d4d 100644 --- a/collects/tests/web-server/private/cache-table-test.rkt +++ b/collects/tests/web-server/private/cache-table-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit web-server/private/cache-table) (provide cache-table-tests) @@ -37,6 +37,6 @@ (cache-table-lookup! ct 'foo (lambda () #f))))))) #| -(require (planet schematics/rktunit:3/text-ui)) +(require (planet schematics/racunit:3/text-ui)) (run-tests cache-table-tests) |# diff --git a/collects/tests/web-server/private/connection-manager-test.rkt b/collects/tests/web-server/private/connection-manager-test.rkt index 72950e37b9..b0dbb90f35 100644 --- a/collects/tests/web-server/private/connection-manager-test.rkt +++ b/collects/tests/web-server/private/connection-manager-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit web-server/private/connection-manager) (provide connection-manager-tests) diff --git a/collects/tests/web-server/private/define-closure-test.rkt b/collects/tests/web-server/private/define-closure-test.rkt index 7e35dd3f78..a764b78fdd 100644 --- a/collects/tests/web-server/private/define-closure-test.rkt +++ b/collects/tests/web-server/private/define-closure-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit mzlib/serialize mzlib/match web-server/private/define-closure) diff --git a/collects/tests/web-server/private/gzip-test.rkt b/collects/tests/web-server/private/gzip-test.rkt index 32c5b6d06c..3746170516 100644 --- a/collects/tests/web-server/private/gzip-test.rkt +++ b/collects/tests/web-server/private/gzip-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit web-server/private/gzip) (provide gzip-tests) diff --git a/collects/tests/web-server/private/mime-types-test.rkt b/collects/tests/web-server/private/mime-types-test.rkt index 78942cce7d..ca31d96b83 100644 --- a/collects/tests/web-server/private/mime-types-test.rkt +++ b/collects/tests/web-server/private/mime-types-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit (only-in mzlib/file make-temporary-file) web-server/http web-server/private/mime-types) diff --git a/collects/tests/web-server/private/mod-map-test.rkt b/collects/tests/web-server/private/mod-map-test.rkt index df290694f4..7a15c4235a 100644 --- a/collects/tests/web-server/private/mod-map-test.rkt +++ b/collects/tests/web-server/private/mod-map-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit web-server/private/mod-map mzlib/serialize "../util.rkt") diff --git a/collects/tests/web-server/private/request-test.rkt b/collects/tests/web-server/private/request-test.rkt index 85adc37e5d..840e53b463 100644 --- a/collects/tests/web-server/private/request-test.rkt +++ b/collects/tests/web-server/private/request-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit web-server/private/connection-manager web-server/private/timer web-server/http/request diff --git a/collects/tests/web-server/private/response-test.rkt b/collects/tests/web-server/private/response-test.rkt index 95a1303b1d..19e5a7d015 100644 --- a/collects/tests/web-server/private/response-test.rkt +++ b/collects/tests/web-server/private/response-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit xml/xml (only-in mzlib/file make-temporary-file) diff --git a/collects/tests/web-server/private/url-param-test.rkt b/collects/tests/web-server/private/url-param-test.rkt index 9370012973..baaa7e0c9a 100644 --- a/collects/tests/web-server/private/url-param-test.rkt +++ b/collects/tests/web-server/private/url-param-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit net/url web-server/private/url-param) (provide url-param-tests) diff --git a/collects/tests/web-server/private/util-test.rkt b/collects/tests/web-server/private/util-test.rkt index a0a977a385..ad6903a60a 100644 --- a/collects/tests/web-server/private/util-test.rkt +++ b/collects/tests/web-server/private/util-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit net/url xml/xml mzlib/contract diff --git a/collects/tests/web-server/run-all-tests.rkt b/collects/tests/web-server/run-all-tests.rkt index 484934b0d4..c643297e7e 100644 --- a/collects/tests/web-server/run-all-tests.rkt +++ b/collects/tests/web-server/run-all-tests.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit/text-ui +(require racunit/text-ui "all-web-server-tests.rkt") (run-tests all-web-server-tests) diff --git a/collects/tests/web-server/servlet-env-test.rkt b/collects/tests/web-server/servlet-env-test.rkt index 867dfebbf1..4d20cd5786 100644 --- a/collects/tests/web-server/servlet-env-test.rkt +++ b/collects/tests/web-server/servlet-env-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit mzlib/etc mzlib/list mzlib/pretty diff --git a/collects/tests/web-server/servlet/all-servlet-tests.rkt b/collects/tests/web-server/servlet/all-servlet-tests.rkt index cfc7e907b3..677eb4b3db 100644 --- a/collects/tests/web-server/servlet/all-servlet-tests.rkt +++ b/collects/tests/web-server/servlet/all-servlet-tests.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit "bindings-test.rkt" "basic-auth-test.rkt" "helpers-test.rkt" diff --git a/collects/tests/web-server/servlet/basic-auth-test.rkt b/collects/tests/web-server/servlet/basic-auth-test.rkt index c6e0d85ba8..2f41b84962 100644 --- a/collects/tests/web-server/servlet/basic-auth-test.rkt +++ b/collects/tests/web-server/servlet/basic-auth-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit web-server/http net/url) (provide basic-auth-tests) diff --git a/collects/tests/web-server/servlet/bindings-test.rkt b/collects/tests/web-server/servlet/bindings-test.rkt index 0757517fd8..77be8cc969 100644 --- a/collects/tests/web-server/servlet/bindings-test.rkt +++ b/collects/tests/web-server/servlet/bindings-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit mzlib/list net/url web-server/http diff --git a/collects/tests/web-server/servlet/helpers-test.rkt b/collects/tests/web-server/servlet/helpers-test.rkt index 312b7cc1c6..78688c6303 100644 --- a/collects/tests/web-server/servlet/helpers-test.rkt +++ b/collects/tests/web-server/servlet/helpers-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit web-server/servlet) (provide helpers-tests) @@ -53,5 +53,5 @@ (test-case "temporarily" (check-true (redirection-status? temporarily))) (test-case "see-other" (check-true (redirection-status? see-other)))))) -;(require (planet schematics/rktunit:3/text-ui)) +;(require (planet schematics/racunit:3/text-ui)) ;(run-tests helpers-tests) diff --git a/collects/tests/web-server/servlet/web-test.rkt b/collects/tests/web-server/servlet/web-test.rkt index be5fe60d7f..bbee9492d2 100644 --- a/collects/tests/web-server/servlet/web-test.rkt +++ b/collects/tests/web-server/servlet/web-test.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require rktunit +(require racunit net/url web-server/servlet/web) (require/expose web-server/servlet/web diff --git a/collects/tests/web-server/stuffers-test.rkt b/collects/tests/web-server/stuffers-test.rkt index 7baae5d620..a34a738d40 100644 --- a/collects/tests/web-server/stuffers-test.rkt +++ b/collects/tests/web-server/stuffers-test.rkt @@ -1,5 +1,5 @@ #lang racket -(require rktunit +(require racunit web-server/stuffers web-server/private/servlet web-server/http @@ -127,6 +127,6 @@ (check-not-false (is-url-too-big? (make-bytes 3000 65))))))))) #| -(require (planet schematics/rktunit:3/text-ui)) +(require (planet schematics/racunit:3/text-ui)) (run-tests all-stuffers-tests) |# diff --git a/collects/tests/xml/test-clark.rkt b/collects/tests/xml/test-clark.rkt index 1b94b46cac..ecad0fc909 100644 --- a/collects/tests/xml/test-clark.rkt +++ b/collects/tests/xml/test-clark.rkt @@ -1,6 +1,6 @@ #lang racket -(require rktunit - rktunit/text-ui +(require racunit + racunit/text-ui xml racket/runtime-path) diff --git a/collects/tests/xml/test.rkt b/collects/tests/xml/test.rkt index 3862212969..d2b0c26dda 100644 --- a/collects/tests/xml/test.rkt +++ b/collects/tests/xml/test.rkt @@ -1,6 +1,6 @@ #lang racket -(require rktunit - rktunit/text-ui +(require racunit + racunit/text-ui xml xml/plist mzlib/etc From e3a9aa8162d2ad0b8fd5f9fb300372c9c1c2c182 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Fri, 30 Apr 2010 11:07:02 -0600 Subject: [PATCH 5/5] Fixing test of pprint --- collects/tests/racunit/text-ui-test.rkt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/collects/tests/racunit/text-ui-test.rkt b/collects/tests/racunit/text-ui-test.rkt index d8766dd859..11ed11fd4d 100644 --- a/collects/tests/racunit/text-ui-test.rkt +++ b/collects/tests/racunit/text-ui-test.rkt @@ -120,8 +120,8 @@ (check string-contains op "`((0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) - (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) - (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))"))) + (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) + (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))"))) (test-case "Non-binary check output is pretty printed" @@ -130,8 +130,8 @@ (check string-contains op "`((0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) - (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) - (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))"))) + (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) + (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))"))) (test-case "Location trimmed when file is under current directory"