From 76754c5443c83d76aea86d18279e25997626342f Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 24 Apr 2010 06:52:21 -0600 Subject: [PATCH 01/15] set-subset? to subset? --- collects/racket/set.rkt | 8 ++++---- collects/scribblings/reference/sets.scrbl | 8 ++++---- collects/tests/mzscheme/set.ss | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/collects/racket/set.rkt b/collects/racket/set.rkt index 3dc363eb81..2d007c66c7 100644 --- a/collects/racket/set.rkt +++ b/collects/racket/set.rkt @@ -6,7 +6,7 @@ set-empty? set-count set-member? set-add set-remove set-union set-intersect set-subtract - set-subset? + subset? set-map set-for-each (rename-out [*in-set in-set]) for/set for/seteq for/seteqv @@ -164,9 +164,9 @@ (for/fold ([set set]) ([set2 (in-list sets)]) (set-subtract set set2))])) -(define (set-subset? set1 set2) - (unless (set? set1) (raise-type-error 'set-subset? "set" 0 set1 set2)) - (unless (set? set2) (raise-type-error 'set-subset? "set" 1 set1 set2)) +(define (subset? set2 set1) + (unless (set? set2) (raise-type-error 'subset? "set" 0 set2 set1)) + (unless (set? set1) (raise-type-error 'subset? "set" 0 set2 set1)) (let ([ht1 (set-ht set1)] [ht2 (set-ht set2)]) (unless (and (eq? (hash-eq? ht1) (hash-eq? ht2)) diff --git a/collects/scribblings/reference/sets.scrbl b/collects/scribblings/reference/sets.scrbl index a61ff00c9f..358ca31364 100644 --- a/collects/scribblings/reference/sets.scrbl +++ b/collects/scribblings/reference/sets.scrbl @@ -103,13 +103,13 @@ runs in time proportional to the total size of all given @scheme[set]s except the first one.} -@defproc[(set-subset? [set set?] [set2 set?]) boolean?]{ +@defproc[(subset? [set set?] [set2 set?]) boolean?]{ -Returns @scheme[#t] if every member of @scheme[set2] is in -@scheme[set], @scheme[#f] otherwise. The @scheme[set] and +Returns @scheme[#t] if every member of @scheme[set] is in +@scheme[set2], @scheme[#f] otherwise. The @scheme[set] and @scheme[set2] must use the same equivalence predicate (@scheme[equal?], @scheme[eq?], or @scheme[eqv?]). This operation -runs in time proportional to the size of @scheme[set2].} +runs in time proportional to the size of @scheme[set].} @defproc[(set-map [set set?] diff --git a/collects/tests/mzscheme/set.ss b/collects/tests/mzscheme/set.ss index 9632b1fb3f..1089b48cb2 100644 --- a/collects/tests/mzscheme/set.ss +++ b/collects/tests/mzscheme/set.ss @@ -50,10 +50,10 @@ (test #t set-member? (set-remove s 5) 3) (test #f set-member? (set-remove s 3) 3) - (test #t set-subset? s (set 1 3)) - (test #t set-subset? s (set 1 2 3)) - (test #f set-subset? s (set 1 4)) - (test #t set-subset? s (set)) + (test #t subset? (set 1 3) s) + (test #t subset? (set 1 2 3) s) + (test #f subset? (set 1 4) s) + (test #t subset? (set) s) (test 3 set-count (set-union s)) (test 6 set-count (set-union s (set 3 4 5 6))) From b0deb8affb817f971dafa8b8bcf658cd1ed4d878 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 24 Apr 2010 06:52:49 -0600 Subject: [PATCH 02/15] more doc and scribble repairs --- collects/scribble/racket.ss | 8 +- collects/scribblings/reference/struct.scrbl | 378 ++++++++++---------- 2 files changed, 196 insertions(+), 190 deletions(-) diff --git a/collects/scribble/racket.ss b/collects/scribble/racket.ss index ab3a05ca64..397f359984 100644 --- a/collects/scribble/racket.ss +++ b/collects/scribble/racket.ss @@ -663,6 +663,11 @@ paren-color)) (set! src-col (+ src-col 3)) ((loop init-line! quote-depth qq?) (graph-defn-r (syntax-e c))))] + [(and (keyword? (syntax-e c)) qq?) + (advance c init-line!) + (let ([quote-depth (to-quoted "`" qq? quote-depth out color? inc-src-col)]) + (typeset-atom c out color? quote-depth qq?) + (set! src-col (+ src-col (or (syntax-span c) 1))))] [else (advance c init-line!) (typeset-atom c out color? quote-depth qq?) @@ -701,7 +706,8 @@ (graph-defn? s) (graph-reference? s) (struct-proxy? s) - (and qq? (identifier? c))) + (and qq? (or (identifier? c) + (keyword? (syntax-e c))))) (gen-typeset c multi-line? prefix1 prefix suffix color? qq?) (typeset-atom c (letrec ([mk diff --git a/collects/scribblings/reference/struct.scrbl b/collects/scribblings/reference/struct.scrbl index b5dc9e4a06..1d9ec7c195 100644 --- a/collects/scribblings/reference/struct.scrbl +++ b/collects/scribblings/reference/struct.scrbl @@ -6,7 +6,7 @@ @title[#:tag "structures" #:style 'toc]{Structures} -@guideintro["define-struct"]{structure types via @scheme[define-struct]} +@guideintro["define-struct"]{structure types via @racket[struct]} A @deftech{structure type} is a record datatype composing a number of @idefterm{fields}. A @deftech{structure}, an instance of a structure @@ -15,8 +15,8 @@ the structure type. A structure instance is created with a type-specific @tech{constructor} procedure, and its field values are accessed and changed with type-specific @tech{accessor} and @tech{mutator} procedures. In addition, each structure type has a -@tech{predicate} procedure that answers @scheme[#t] for instances of -the structure type and @scheme[#f] for any other value. +@tech{predicate} procedure that answers @racket[#t] for instances of +the structure type and @racket[#f] for any other value. A structure type's fields are essentially unnamed, though names are supported for error-reporting purposes. The constructor procedure @@ -49,7 +49,7 @@ accessed with subtype-specific selectors. Subtype-specific @tech{accessors} and @tech{mutators} for the first @math{m} fields do not exist. -The @scheme[define-struct] form and @scheme[make-struct-type] +The @racket[struct] form and @racket[make-struct-type] procedure typically create a new structure type, but they can also access @deftech{prefab} (i.e., previously fabricated) structure types that are globally shared, and whose instances can be parsed and @@ -65,15 +65,15 @@ field), and field mutability. @refalso["serialization"]{reading and writing structures} @index['("structures" "equality")]{Two} structure values are -@scheme[eqv?] if and only if they are @scheme[eq?]. Two structure -values are @scheme[equal?] if they are @scheme[eq?]. By default, two -structure values are also @scheme[equal?] if they are instances of the +@racket[eqv?] if and only if they are @racket[eq?]. Two structure +values are @racket[equal?] if they are @racket[eq?]. By default, two +structure values are also @racket[equal?] if they are instances of the same structure type, no fields are opaque, and the results of applying -@scheme[struct->vector] to the structs are -@scheme[equal?]. (Consequently, @scheme[equal?] testing for +@racket[struct->vector] to the structs are +@racket[equal?]. (Consequently, @racket[equal?] testing for structures may depend on the current inspector.) A structure type can -override the default @scheme[equal?] definition through the -@scheme[prop:equal+hash] property. +override the default @racket[equal?] definition through the +@racket[prop:equal+hash] property. @local-table-of-contents[] @@ -107,74 +107,74 @@ override the default @scheme[equal?] definition through the struct-accessor-procedure? struct-mutator-procedure?)]{ -Creates a new structure type, unless @scheme[inspector] is -@scheme['prefab], in which case @scheme[make-struct-type] accesses a -@techlink{prefab} structure type. The @scheme[name] argument is used -as the type name. If @scheme[super-type] is not @scheme[#f], the +Creates a new structure type, unless @racket[inspector] is +@racket['prefab], in which case @racket[make-struct-type] accesses a +@techlink{prefab} structure type. The @racket[name] argument is used +as the type name. If @racket[super-type] is not @racket[#f], the resulting type is a subtype of the corresponding structure type. The resulting structure type has -@math{@scheme[init-field-cnt]+@scheme[auto-field-cnt]} fields (in -addition to any fields from @scheme[super-type]), but only -@scheme[init-field-cnt] constructor arguments (in addition to any -constructor arguments from @scheme[super-type]). The remaining fields -are initialized with @scheme[auto-v]. The total field count (including -@scheme[super-type] fields) must be no more than 32768. +@math{@racket[init-field-cnt]+@racket[auto-field-cnt]} fields (in +addition to any fields from @racket[super-type]), but only +@racket[init-field-cnt] constructor arguments (in addition to any +constructor arguments from @racket[super-type]). The remaining fields +are initialized with @racket[auto-v]. The total field count (including +@racket[super-type] fields) must be no more than 32768. -The @scheme[props] argument is a list of pairs, where the @scheme[car] +The @racket[props] argument is a list of pairs, where the @racket[car] of each pair is a structure type property descriptor, and the -@scheme[cdr] is an arbitrary value. A property can be specified -multiple times in in @scheme[props] (including properties that are +@racket[cdr] is an arbitrary value. A property can be specified +multiple times in in @racket[props] (including properties that are automatically added by properties that are directly included in -@scheme[props]) only if the associated values are @scheme[eq?], +@racket[props]) only if the associated values are @racket[eq?], otherwise the @exnraise[exn:fail:contract]. See @secref["structprops"] -for more information about properties. When @scheme[inspector] is -@scheme['prefab], then @scheme[props] must be @scheme[null]. +for more information about properties. When @racket[inspector] is +@racket['prefab], then @racket[props] must be @racket[null]. -The @scheme[inspector] argument normally controls access to reflective +The @racket[inspector] argument normally controls access to reflective information about the structure type and its instances; see -@secref["inspectors"] for more information. If @scheme[inspector] is -@scheme['prefab], then the resulting @tech{prefab} structure type and +@secref["inspectors"] for more information. If @racket[inspector] is +@racket['prefab], then the resulting @tech{prefab} structure type and its instances are always transparent. -If @scheme[proc-spec] is an integer or procedure, instances of the -structure type act as procedures. See @scheme[prop:procedure] for -further information. Providing a non-@scheme[#f] value for -@scheme[proc-spec] is the same as pairing the value with -@scheme[prop:procedure] at the end of @scheme[props], plus including -@scheme[proc-spec] in @scheme[immutables] when @scheme[proc-spec] is +If @racket[proc-spec] is an integer or procedure, instances of the +structure type act as procedures. See @racket[prop:procedure] for +further information. Providing a non-@racket[#f] value for +@racket[proc-spec] is the same as pairing the value with +@racket[prop:procedure] at the end of @racket[props], plus including +@racket[proc-spec] in @racket[immutables] when @racket[proc-spec] is an integer. -The @scheme[immutables] argument provides a list of field +The @racket[immutables] argument provides a list of field positions. Each element in the list must be unique, otherwise @exnraise[exn:fail:contract]. Each element must also fall in the range -@scheme[0] (inclusive) to @scheme[init-field-cnt] (exclusive), otherwise +@racket[0] (inclusive) to @racket[init-field-cnt] (exclusive), otherwise @exnraise[exn:fail:contract]. -The @scheme[guard] argument is either a procedure of @math{n+1} -arguments or @scheme[#f], where @math{n} is the number of arguments +The @racket[guard] argument is either a procedure of @math{n+1} +arguments or @racket[#f], where @math{n} is the number of arguments for the new structure type's constructor (i.e., -@scheme[init-field-cnt] plus constructor arguments implied by -@scheme[super-type], if any). If @scheme[guard] is a procedure, then +@racket[init-field-cnt] plus constructor arguments implied by +@racket[super-type], if any). If @racket[guard] is a procedure, then the procedure is called whenever an instance of the type is constructed, or whenever an instance of a subtype is created. The -arguments to @scheme[guard] are the values provided for the +arguments to @racket[guard] are the values provided for the structure's first @math{n} fields, followed by the name of the -instantiated structure type (which is @scheme[name], unless a subtype -is instantiated). The @scheme[guard] result must be @math{n} values, +instantiated structure type (which is @racket[name], unless a subtype +is instantiated). The @racket[guard] result must be @math{n} values, which become the actual values for the structure's fields. The -@scheme[guard] can raise an exception to prevent creation of a +@racket[guard] can raise an exception to prevent creation of a structure with the given field values. If a structure subtype has its own guard, the subtype guard is applied first, and the first @math{n} values produced by the subtype's guard procedure become the first -@math{n} arguments to @scheme[guard]. When @scheme[inspector] is -@scheme['prefab], then @scheme[guard] must be @scheme[#f]. +@math{n} arguments to @racket[guard]. When @racket[inspector] is +@racket['prefab], then @racket[guard] must be @racket[#f]. -If @scheme[constructor-name] is not @scheme[#f], it is used as the +If @racket[constructor-name] is not @racket[#f], it is used as the name of the generated @tech{constructor} procedure as returned by -@scheme[object-name] or in the printed form of the constructor value. +@racket[object-name] or in the printed form of the constructor value. -The result of @scheme[make-struct-type] is five values: +The result of @racket[make-struct-type] is five values: @itemize[ @@ -186,7 +186,7 @@ The result of @scheme[make-struct-type] is five values: @item{an @tech{accessor} procedure, which consumes a structure and a field index between @math{0} (inclusive) and - @math{@scheme[init-field-cnt]+@scheme[auto-field-cnt]} (exclusive), + @math{@racket[init-field-cnt]+@racket[auto-field-cnt]} (exclusive), and} @item{a @tech{mutator} procedure, which consumes a structure, a field @@ -249,14 +249,14 @@ The result of @scheme[make-struct-type] is five values: (symbol->string (format "field~a" field-pos))]) procedure?]{ -Returns a field accessor that is equivalent to @scheme[(lambda (s) -(accessor-proc s field-pos))]. The @scheme[accessor-proc] must be -an @tech{accessor} returned by @scheme[make-struct-type]. The name of the +Returns a field accessor that is equivalent to @racket[(lambda (s) +(accessor-proc s field-pos))]. The @racket[accessor-proc] must be +an @tech{accessor} returned by @racket[make-struct-type]. The name of the resulting procedure for debugging purposes is derived from -@scheme[field-name] and the name of @scheme[accessor-proc]'s -structure type if @scheme[field-name] is a symbol. +@racket[field-name] and the name of @racket[accessor-proc]'s +structure type if @racket[field-name] is a symbol. -For examples, see @scheme[make-struct-type].} +For examples, see @racket[make-struct-type].} @defproc[(make-struct-field-mutator [mutator-proc struct-mutator-procedure?] [field-pos exact-nonnegative-integer?] @@ -264,14 +264,14 @@ For examples, see @scheme[make-struct-type].} (symbol->string (format "field~a" field-pos))]) procedure?]{ -Returns a field mutator that is equivalent to @scheme[(lambda (s v) -(mutator-proc s field-pos v))]. The @scheme[mutator-proc] must be -a @tech{mutator} returned by @scheme[make-struct-type]. The name of the +Returns a field mutator that is equivalent to @racket[(lambda (s v) +(mutator-proc s field-pos v))]. The @racket[mutator-proc] must be +a @tech{mutator} returned by @racket[make-struct-type]. The name of the resulting procedure for debugging purposes is derived from -@scheme[field-name] and the name of @scheme[mutator-proc]'s -structure type if @scheme[field-name] is a symbol. +@racket[field-name] and the name of @racket[mutator-proc]'s +structure type if @racket[field-name] is a symbol. -For examples, see @scheme[make-struct-type].} +For examples, see @racket[make-struct-type].} @;------------------------------------------------------------------------ @@ -281,9 +281,9 @@ A @deftech{structure type property} allows per-type information to be associated with a structure type (as opposed to per-instance information associated with a structure value). A property value is associated with a structure type through the - @scheme[make-struct-type] procedure (see - @secref["creatingmorestructs"]) or through the @scheme[#:property] - option of @scheme[define-struct]. Subtypes inherit the property + @racket[make-struct-type] procedure (see + @secref["creatingmorestructs"]) or through the @racket[#:property] + option of @racket[struct]. Subtypes inherit the property values of their parent types, and subtypes can override an inherited property value with a new value. @@ -301,12 +301,12 @@ Creates a new structure type property and returns three values: @itemize[ @item{a @deftech{structure type property descriptor}, for use with - @scheme[make-struct-type] and @scheme[define-struct];} + @racket[make-struct-type] and @racket[struct];} @item{a @deftech{property predicate} procedure, which takes an - arbitrary value and returns @scheme[#t] if the value is a + arbitrary value and returns @racket[#t] if the value is a descriptor or instance of a structure type that has a value for - the property, @scheme[#f] otherwise;} + the property, @racket[#f] otherwise;} @item{an @deftech{property accessor} procedure, which returns the value associated with the structure type given its descriptor or @@ -316,30 +316,30 @@ Creates a new structure type property and returns three values: ] -If the optional @scheme[guard] is supplied as a procedure, it is -called by @scheme[make-struct-type] before attaching the property to a -new structure type. The @scheme[guard] must accept two arguments: -a value for the property supplied to @scheme[make-struct-type], and a +If the optional @racket[guard] is supplied as a procedure, it is +called by @racket[make-struct-type] before attaching the property to a +new structure type. The @racket[guard] must accept two arguments: +a value for the property supplied to @racket[make-struct-type], and a list containing information about the new structure type. The list -contains the values that @scheme[struct-type-info] would return for +contains the values that @racket[struct-type-info] would return for the new structure type if it skipped the immediate current-inspector control check (but not the check for exposing an ancestor structure type, if any; see @secref["inspectors"]). -The result of calling @scheme[guard] is associated with the property +The result of calling @racket[guard] is associated with the property in the target structure type, instead of the value supplied to -@scheme[make-struct-type]. To reject a property association (e.g., -because the value supplied to @scheme[make-struct-type] is -inappropriate for the property), the @scheme[guard] can raise an -exception. Such an exception prevents @scheme[make-struct-type] from +@racket[make-struct-type]. To reject a property association (e.g., +because the value supplied to @racket[make-struct-type] is +inappropriate for the property), the @racket[guard] can raise an +exception. Such an exception prevents @racket[make-struct-type] from returning a structure type descriptor. -The optional @scheme[supers] argument is a list of properties that are +The optional @racket[supers] argument is a list of properties that are automatically associated with some structure type when the newly created property is associated to the structure type. Each property in -@scheme[supers] is paired with a procedure that receives the value +@racket[supers] is paired with a procedure that receives the value supplied for the new property (after it is processed by -@scheme[guard]) and returns a value for the associated property (which +@racket[guard]) and returns a value for the associated property (which is then sent to that property's guard, of any). @examples[ @@ -371,119 +371,119 @@ is then sent to that property's guard, of any). @defproc[(struct-type-property? [v any/c]) boolean?]{ -Returns @scheme[#t] if @scheme[v] is a @tech{structure type property -descriptor} value, @scheme[#f] otherwise.} +Returns @racket[#t] if @racket[v] is a @tech{structure type property +descriptor} value, @racket[#f] otherwise.} @defproc[(struct-type-property-accessor-procedure? [v any/c]) boolean?]{ -Returns @scheme[#t] if @scheme[v] is an accessor procedure produced -by @scheme[make-struct-type-property], @scheme[#f] otherwise.} +Returns @racket[#t] if @racket[v] is an accessor procedure produced +by @racket[make-struct-type-property], @racket[#f] otherwise.} @;------------------------------------------------------------------------ @section[#:tag "struct-copy"]{Copying and Updating Structures} @defform[(struct-copy id struct-expr [field-id expr] ...)]{ -Creates a new instance of the structure type @scheme[id] with the same -field values as the structure produced by @scheme[struct-expr], except -that the value of each supplied @scheme[field-id] is instead -determined by the corresponding @scheme[expr]. +Creates a new instance of the structure type @racket[id] with the same +field values as the structure produced by @racket[struct-expr], except +that the value of each supplied @racket[field-id] is instead +determined by the corresponding @racket[expr]. -The @scheme[id] must have a @tech{transformer binding} that +The @racket[id] must have a @tech{transformer binding} that encapsulates information about a structure type (i.e., like the -initial identifier bound by @scheme[define-struct]), and the binding +initial identifier bound by @racket[struct]), and the binding must supply a constructor, a predicate, and all field accessors. -Each @scheme[field-id] is combined with @scheme[id] to form -@scheme[id]@schemeidfont{-}@scheme[field-id] (using the lexical -context of @scheme[field-id]), which must be one of the accessor -bindings in @scheme[id]. The accessor bindings determined by different -@scheme[field-id]s must be distinct. The order of the -@scheme[field-id]s need not match the order of the corresponding +Each @racket[field-id] is combined with @racket[id] to form +@racket[id]@racketidfont{-}@racket[field-id] (using the lexical +context of @racket[field-id]), which must be one of the accessor +bindings in @racket[id]. The accessor bindings determined by different +@racket[field-id]s must be distinct. The order of the +@racket[field-id]s need not match the order of the corresponding fields in the structure type. -The @scheme[struct-expr] is evaluated first. The result must be an -instance of the @scheme[id] structure type, otherwise the -@exnraise[exn:fail:contract]. Next, the field @scheme[expr]s are +The @racket[struct-expr] is evaluated first. The result must be an +instance of the @racket[id] structure type, otherwise the +@exnraise[exn:fail:contract]. Next, the field @racket[expr]s are evaluated in order (even if the fields that correspond to the -@scheme[field-id]s are in a different order). Finally, the new +@racket[field-id]s are in a different order). Finally, the new structure instance is created. -The result of @scheme[struct-expr] can be an instance of a sub-type of -@scheme[id], but the resulting copy is an immediate instance of -@scheme[id] (not the sub-type).} +The result of @racket[struct-expr] can be an instance of a sub-type of +@racket[id], but the resulting copy is an immediate instance of +@racket[id] (not the sub-type).} @;------------------------------------------------------------------------ @section[#:tag "structutils"]{Structure Utilities} @defproc[(struct->vector [v any/c] [opaque-v any/c '...]) vector?]{ -Creates a vector representing @scheme[v]. The first slot of the +Creates a vector representing @racket[v]. The first slot of the result vector contains a symbol whose printed name has the form -@schemeidfont{struct:}@scheme[_id]. Each remaining slot contains -either the value of a field in @scheme[v], if it is accessible via the -current inspector, or @scheme[opaque-v] for a field that is not -accessible. A single @scheme[opaque-v] value is used in the vector for +@racketidfont{struct:}@racket[_id]. Each remaining slot contains +either the value of a field in @racket[v], if it is accessible via the +current inspector, or @racket[opaque-v] for a field that is not +accessible. A single @racket[opaque-v] value is used in the vector for contiguous inaccessible fields. (Consequently, the size of the vector -does not match the size of the @scheme[struct] if more than one field +does not match the size of the @racket[struct] if more than one field is inaccessible.)} -@defproc[(struct? [v any/c]) any]{ Returns @scheme[#t] if - @scheme[struct-info] exposes any structure types of @scheme[v] with - the current inspector, @scheme[#f] otherwise. +@defproc[(struct? [v any/c]) any]{ Returns @racket[#t] if + @racket[struct-info] exposes any structure types of @racket[v] with + the current inspector, @racket[#f] otherwise. - Typically, when @scheme[(struct? v)] is true, then - @scheme[(struct->vector v)] exposes at least one field value. It is - possible, however, for the only visible types of @scheme[v] to + Typically, when @racket[(struct? v)] is true, then + @racket[(struct->vector v)] exposes at least one field value. It is + possible, however, for the only visible types of @racket[v] to contribute zero fields.} -@defproc[(struct-type? [v any/c]) boolean?]{Returns @scheme[#t] if - @scheme[v] is a structure type descriptor value, @scheme[#f] +@defproc[(struct-type? [v any/c]) boolean?]{Returns @racket[#t] if + @racket[v] is a structure type descriptor value, @racket[#f] otherwise.} @defproc[(struct-constructor-procedure? [v any/c]) boolean?]{Returns - @scheme[#t] if @scheme[v] is a constructor procedure generated by - @scheme[define-struct] or @scheme[make-struct-type], @scheme[#f] + @racket[#t] if @racket[v] is a constructor procedure generated by + @racket[struct] or @racket[make-struct-type], @racket[#f] otherwise.} @defproc[(struct-predicate-procedure? [v any/c]) boolean?]{Returns - @scheme[#t] if @scheme[v] is a predicate procedure generated by - @scheme[define-struct] or @scheme[make-struct-type], @scheme[#f] + @racket[#t] if @racket[v] is a predicate procedure generated by + @racket[struct] or @racket[make-struct-type], @racket[#f] otherwise.} @defproc[(struct-accessor-procedure? [v any/c]) boolean?]{Returns - @scheme[#t] if @scheme[v] is an accessor procedure generated by - @scheme[define-struct], @scheme[make-struct-type], or - @scheme[make-struct-field-accessor], @scheme[#f] otherwise.} + @racket[#t] if @racket[v] is an accessor procedure generated by + @racket[struct], @racket[make-struct-type], or + @racket[make-struct-field-accessor], @racket[#f] otherwise.} @defproc[(struct-mutator-procedure? [v any/c]) boolean?]{Returns - @scheme[#t] if @scheme[v] is a mutator procedure generated by - @scheme[define-struct], @scheme[make-struct-type], or - @scheme[make-struct-field-mutator], @scheme[#f] otherwise.} + @racket[#t] if @racket[v] is a mutator procedure generated by + @racket[struct], @racket[make-struct-type], or + @racket[make-struct-field-mutator], @racket[#f] otherwise.} @defproc[(prefab-struct-key [v any/c]) (or/c #f symbol? list?)]{ -Returns @scheme[#f] if @scheme[v] is not an instance of a +Returns @racket[#f] if @racket[v] is not an instance of a @tech{prefab} structure type. Otherwise, the result is the shorted key -that could be used with @scheme[make-prefab-struct] to create an instance +that could be used with @racket[make-prefab-struct] to create an instance of the structure type. @examples[ (prefab-struct-key #s(cat "Garfield")) -(define-struct cat (name) #:prefab) -(define-struct (cute-cat cat) (shipping-dest) #:prefab) -(make-cute-cat "Nermel" "Abu Dhabi") -(prefab-struct-key (make-cute-cat "Nermel" "Abu Dhabi")) +(struct cat (name) #:prefab) +(struct cute-cat cat (shipping-dest) #:prefab) +(cute-cat "Nermel" "Abu Dhabi") +(prefab-struct-key (cute-cat "Nermel" "Abu Dhabi")) ]} @defproc[(make-prefab-struct [key (or/c symbol? list?)] [v any/c] ...) struct?]{ Creates an instance of a @tech{prefab} structure type, using the -@scheme[v]s as field values. The @scheme[key] and the number of -@scheme[v]s determine the @tech{prefab} structure type. +@racket[v]s as field values. The @racket[key] and the number of +@racket[v]s determine the @tech{prefab} structure type. -A @scheme[key] identifies a structure type based on a list with the +A @racket[key] identifies a structure type based on a list with the following items: @itemize[ @@ -502,7 +502,7 @@ following items: @item{A vector of exact, nonnegative integers that indicate mutable non-automatic fields in the structure type, counting from - @scheme[0] and not including fields from the supertype (if + @racket[0] and not including fields from the supertype (if any).} @item{Nothing else, if the structure type has no @@ -511,17 +511,17 @@ following items: ] -An empty vector and an auto-field list that starts with @scheme[0] can +An empty vector and an auto-field list that starts with @racket[0] can be omitted. Furthermore, the first integer (which indicates the number of non-automatic fields) can be omitted, since it can be inferred from -the number of supplied @scheme[v]s. Finally, a single symbol can be +the number of supplied @racket[v]s. Finally, a single symbol can be used instead of a list that contains only a symbol (in the case that the structure type has no supertype, no automatic fields, and no mutable fields). The total field count must be no more than 32768. If the number of -fields indicated by @scheme[key] is inconsistent with the number of -supplied @scheme[v]s, the @exnraise[exn:fail:contract]. +fields indicated by @racket[key] is inconsistent with the number of +supplied @racket[v]s, the @exnraise[exn:fail:contract]. @examples[ (make-prefab-struct 'clown "Binky" "pie") @@ -536,29 +536,29 @@ supplied @scheme[v]s, the @exnraise[exn:fail:contract]. struct-type?]{ Returns a @tech{structure type descriptor} for the @tech{prefab} -structure type specified by the combination of @scheme[key] and -@scheme[field-count].} +structure type specified by the combination of @racket[key] and +@racket[field-count].} @;------------------------------------------------------------------------ @section[#:tag "structinfo"]{Structure Type Transformer Binding} -The @scheme[define-struct] form binds the name of a structure type as +The @racket[struct] form binds the name of a structure type as a @tech{transformer binding} that records the other identifiers bound to the structure type, the constructor procedure, the predicate procedure, and the field accessor and mutator procedures. This information can be used during the expansion of other expressions via -@scheme[syntax-local-value]. +@racket[syntax-local-value]. -For example, the @scheme[define-struct] variant for subtypes uses the -base type name @scheme[_t] to find the variable -@schemeidfont{struct:}@scheme[_t] containing the base type's descriptor; it +For example, the @racket[struct] variant for subtypes uses the +base type name @racket[_t] to find the variable +@racketidfont{struct:}@racket[_t] containing the base type's descriptor; it also folds the field accessor and mutator information for the base type into the information for the subtype. As another example, the -@scheme[match] form uses a type name to find the predicates and field -accessors for the structure type. The @scheme[struct] form in an -imported signature for @scheme[unit] causes the @scheme[unit] +@racket[match] form uses a type name to find the predicates and field +accessors for the structure type. The @racket[struct] form in an +imported signature for @racket[unit] causes the @racket[unit] transformer to generate information about imported structure types, so -that @scheme[match] and subtyping @scheme[define-struct] forms work +that @racket[match] and subtyping @racket[struct] forms work within the unit. The expansion-time information for a structure type can be represented @@ -568,17 +568,17 @@ encapsulated procedure must return): @itemize[ @item{an identifier that is bound to the structure type's descriptor, - or @scheme[#f] it none is known;} + or @racket[#f] it none is known;} @item{an identifier that is bound to the structure type's constructor, - or @scheme[#f] it none is known;} + or @racket[#f] it none is known;} @item{an identifier that is bound to the structure type's predicate, - or @scheme[#f] it none is known;} + or @racket[#f] it none is known;} @item{a list of identifiers bound to the field accessors of the - structure type, optionally with @scheme[#f] as the list's last - element. A @scheme[#f] as the last element indicates that the + structure type, optionally with @racket[#f] as the list's last + element. A @racket[#f] as the last element indicates that the structure type may have additional fields, otherwise the list is a reliable indicator of the number of fields in the structure type. Furthermore, the accessors are listed in reverse order for the @@ -586,44 +586,44 @@ encapsulated procedure must return): sharing in the lists for a subtype and its base type.)} @item{a list of identifiers bound to the field mutators of - the structure type, or @scheme[#f] for each field that has no known - mutator, and optionally with an extra @scheme[#f] as the list's last - element (if the accessor list has such a @scheme[#f]). The list's - order and the meaning of a final @scheme[#f] are the same as for the + the structure type, or @racket[#f] for each field that has no known + mutator, and optionally with an extra @racket[#f] as the list's last + element (if the accessor list has such a @racket[#f]). The list's + order and the meaning of a final @racket[#f] are the same as for the accessor identifiers, and the length of the mutator list is the same as the accessor list's length.} @item{an identifier that determines a super-type for the structure - type, @scheme[#f] if the super-type (if any) is unknown, or - @scheme[#t] if there is no super-type. If a super-type is specified, + type, @racket[#f] if the super-type (if any) is unknown, or + @racket[#t] if there is no super-type. If a super-type is specified, the identifier is also bound to structure-type expansion-time information.} ] Instead of this direct representation, the representation can be a -structure created by @scheme[make-struct-info] (or an instance of a -subtype of @scheme[struct:struct-info]), which encapsulates a +structure created by @racket[make-struct-info] (or an instance of a +subtype of @racket[struct:struct-info]), which encapsulates a procedure that takes no arguments and returns a list of six elements. Alternately, the representation can be a structure whose -type has the @scheme[prop:struct-info] @tech{structure type property}. +type has the @racket[prop:struct-info] @tech{structure type property}. Finally, the representation can be an instance of a structure type -derived from @scheme[struct:struct-info] or with the -@scheme[prop:struct-info] property that also implements -@scheme[prop:procedure], and where the instance is further is wrapped -by @scheme[make-set!-transformer]. +derived from @racket[struct:struct-info] or with the +@racket[prop:struct-info] property that also implements +@racket[prop:procedure], and where the instance is further is wrapped +by @racket[make-set!-transformer]. -Use @scheme[struct-info?] to recognize all allowed forms of the -information, and use @scheme[extract-struct-info] to obtain a list +Use @racket[struct-info?] to recognize all allowed forms of the +information, and use @racket[extract-struct-info] to obtain a list from any representation. The implementor of a syntactic form can expect users of the form to know what kind of information is available about a structure type. For -example, the @scheme[match] implementation works with structure +example, the @racket[match] implementation works with structure information containing an incomplete set of accessor bindings, because the user is assumed to know what information is available in the -context of the @scheme[match] expression. In particular, the -@scheme[match] expression can appear in a @scheme[unit] form with an +context of the @racket[match] expression. In particular, the +@racket[match] expression can appear in a @racket[unit] form with an imported structure type, in which case the user is expected to know the set of fields that are listed in the signature for the structure type. @@ -632,17 +632,17 @@ type. @defproc[(struct-info? [v any/c]) boolean?]{ -Returns @scheme[#t] if @scheme[v] is either a six-element list with +Returns @racket[#t] if @racket[v] is either a six-element list with the correct shape for representing structure-type information, a -procedure encapsulated by @scheme[make-struct-info], a structure with -the @scheme[prop:struct-info] property, or a structure type derived -from @scheme[struct:struct-info] or with @scheme[prop:struct-info] and -wrapped with @scheme[make-set!-transformer].} +procedure encapsulated by @racket[make-struct-info], a structure with +the @racket[prop:struct-info] property, or a structure type derived +from @racket[struct:struct-info] or with @racket[prop:struct-info] and +wrapped with @racket[make-set!-transformer].} @defproc[(checked-struct-info? [v any/c]) boolean?]{ -Returns @scheme[#t] if @scheme[v] is a procedure encapsulated by -@scheme[make-struct-info] and produced by @scheme[define-struct], but +Returns @racket[#t] if @racket[v] is a procedure encapsulated by +@racket[make-struct-info] and produced by @racket[struct], but only when no parent type is specified or the parent type is also specified through a transformer binding to such a value.} @@ -656,20 +656,20 @@ form.} (and/c struct-info? list?)]{ Extracts the list form of the structure type information represented -by @scheme[v].} +by @racket[v].} @defthing[struct:struct-info struct-type?]{ The @tech{structure type descriptor} for the structure type returned -by @scheme[make-struct-info]. This @tech{structure type descriptor} is +by @racket[make-struct-info]. This @tech{structure type descriptor} is mostly useful for creating structure subtypes. The structure type includes a guard that checks an instance's first field in the same way -as @scheme[make-struct-info].} +as @racket[make-struct-info].} @defthing[prop:struct-info struct-type-property?]{ The @tech{structure type property} for creating new structure types -like @scheme[struct:struct-info]. The property value must a procedure +like @racket[struct:struct-info]. The property value must a procedure of one argument that takes an instance structure and returns structure-type information in list form.} From 22470e414713ab34f653fb96f062338abfb3d334 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 24 Apr 2010 07:17:53 -0600 Subject: [PATCH 03/15] racket-tool -> raco --- collects/compiler/commands/c-ext.ss | 2 +- collects/compiler/commands/decompile.ss | 2 +- collects/compiler/commands/exe-dir.ss | 2 +- collects/compiler/commands/exe.ss | 2 +- collects/compiler/commands/expand.ss | 2 +- collects/compiler/commands/info.ss | 2 +- collects/compiler/commands/make.ss | 2 +- collects/compiler/commands/pack.ss | 2 +- collects/help/help.ss | 4 +++- collects/help/info.ss | 2 +- collects/help/installer.ss | 2 +- collects/meta/dist-specs.ss | 4 ++-- collects/planet/info.ss | 2 +- collects/planet/planet.ss | 2 +- collects/{tool => raco}/all-tools.ss | 6 +++--- collects/{tool => raco}/command-name.ss | 0 collects/{tool => raco}/info.ss | 2 +- collects/{tool => raco}/main.lch | 0 collects/{tool => raco}/main.ss | 4 ++-- collects/{tool/tool.ss => raco/raco.ss} | 6 +++--- collects/scribble/info.ss | 2 +- collects/scribble/run.ss | 2 +- collects/setup/info.ss | 2 +- collects/setup/setup-cmdline.ss | 6 +++--- src/Makefile.in | 2 +- 25 files changed, 33 insertions(+), 31 deletions(-) rename collects/{tool => raco}/all-tools.ss (85%) rename collects/{tool => raco}/command-name.ss (100%) rename collects/{tool => raco}/info.ss (69%) rename collects/{tool => raco}/main.lch (100%) rename collects/{tool => raco}/main.ss (85%) rename collects/{tool/tool.ss => raco/raco.ss} (92%) diff --git a/collects/compiler/commands/c-ext.ss b/collects/compiler/commands/c-ext.ss index 44456ab4f9..22bc5db193 100644 --- a/collects/compiler/commands/c-ext.ss +++ b/collects/compiler/commands/c-ext.ss @@ -7,7 +7,7 @@ (require (prefix-in compiler:option: "../option.ss") "../compiler.ss" - tool/command-name + raco/command-name mzlib/cmdline dynext/file dynext/compile diff --git a/collects/compiler/commands/decompile.ss b/collects/compiler/commands/decompile.ss index 8b16b48434..0bc201d044 100644 --- a/collects/compiler/commands/decompile.ss +++ b/collects/compiler/commands/decompile.ss @@ -1,6 +1,6 @@ #lang scheme/base (require scheme/cmdline - tool/command-name + raco/command-name compiler/zo-parse compiler/decompile scheme/pretty) diff --git a/collects/compiler/commands/exe-dir.ss b/collects/compiler/commands/exe-dir.ss index 95f28d1aee..dae09d1438 100644 --- a/collects/compiler/commands/exe-dir.ss +++ b/collects/compiler/commands/exe-dir.ss @@ -1,6 +1,6 @@ #lang scheme/base (require scheme/cmdline - tool/command-name + raco/command-name compiler/distribute) (define verbose (make-parameter #f)) diff --git a/collects/compiler/commands/exe.ss b/collects/compiler/commands/exe.ss index 762df0ff2b..59a956f60f 100644 --- a/collects/compiler/commands/exe.ss +++ b/collects/compiler/commands/exe.ss @@ -1,6 +1,6 @@ #lang scheme/base (require scheme/cmdline - tool/command-name + raco/command-name compiler/private/embed dynext/file) diff --git a/collects/compiler/commands/expand.ss b/collects/compiler/commands/expand.ss index ed742087c1..181b79b1c3 100644 --- a/collects/compiler/commands/expand.ss +++ b/collects/compiler/commands/expand.ss @@ -1,6 +1,6 @@ #lang scheme/base (require scheme/cmdline - tool/command-name + raco/command-name scheme/pretty) (define source-files diff --git a/collects/compiler/commands/info.ss b/collects/compiler/commands/info.ss index a2fef6dcbd..732470021c 100644 --- a/collects/compiler/commands/info.ss +++ b/collects/compiler/commands/info.ss @@ -1,6 +1,6 @@ #lang setup/infotab -(define racket-tools +(define raco-commands '(("make" compiler/commands/make "compile source to bytecode" 100) ("exe" compiler/commands/exe "create executable" 20) ("pack" compiler/commands/pack "pack files/collections into a .plt archive" 10) diff --git a/collects/compiler/commands/make.ss b/collects/compiler/commands/make.ss index 61336ce1e4..20b8ea9c5f 100644 --- a/collects/compiler/commands/make.ss +++ b/collects/compiler/commands/make.ss @@ -1,6 +1,6 @@ #lang scheme/base (require scheme/cmdline - tool/command-name + raco/command-name compiler/cm "../compiler.ss" dynext/file) diff --git a/collects/compiler/commands/pack.ss b/collects/compiler/commands/pack.ss index add2f667b1..852ee99d74 100644 --- a/collects/compiler/commands/pack.ss +++ b/collects/compiler/commands/pack.ss @@ -1,6 +1,6 @@ #lang scheme/base (require scheme/cmdline - tool/command-name + raco/command-name setup/pack setup/getinfo compiler/distribute) diff --git a/collects/help/help.ss b/collects/help/help.ss index 340a7a7c20..039a343837 100644 --- a/collects/help/help.ss +++ b/collects/help/help.ss @@ -1,10 +1,12 @@ #lang scheme/base -(require "search.ss" scheme/cmdline scheme/list scheme/string) +(require "search.ss" scheme/cmdline scheme/list scheme/string + raco/command-name) ;; Minimal command-line arguments, the query string can contain all ;; kinds of magic. (command-line + #:program (short-program+command-name) #:handlers (lambda (_ . ts) (if (null? ts) diff --git a/collects/help/info.ss b/collects/help/info.ss index 8d3e9814ac..d2f4cd6ae0 100644 --- a/collects/help/info.ss +++ b/collects/help/info.ss @@ -1,4 +1,4 @@ #lang setup/infotab (define post-install-collection "installer.ss") -(define racket-tools '(("docs" help/help "search and view documentation" 100))) +(define raco-commands '(("docs" help/help "search and view documentation" 100))) diff --git a/collects/help/installer.ss b/collects/help/installer.ss index cd1f5959ed..9507d8646a 100644 --- a/collects/help/installer.ss +++ b/collects/help/installer.ss @@ -27,7 +27,7 @@ (parameterize ([current-launcher-variant variant]) (mk-launcher '("-l-" "help/help") (mk-path "plt-help") ;; change to "Racket Docs" - `([exe-name . "plt-help"] ;; get rid of this (in favor of 'racket-tool docs') + `([exe-name . "plt-help"] ;; get rid of this (in favor of 'raco docs') [relative? . #t] [framework-root . #f] [dll-dir . #f] diff --git a/collects/meta/dist-specs.ss b/collects/meta/dist-specs.ss index d1079e3539..6dd42893ab 100644 --- a/collects/meta/dist-specs.ss +++ b/collects/meta/dist-specs.ss @@ -431,8 +431,8 @@ platform-dependent := ; hook for package rules mz-extras :+= (- (package: "setup-plt" #:collection "setup/") (cond (not dr) => (srcfile: "plt-installer{|-sig|-unit}.ss"))) -;; -------------------- racket-tool -mz-extras :+= (package: "tool") +;; -------------------- raco +mz-extras :+= (package: "raco") ;; -------------------- launcher mz-extras :+= (- (collects: "launcher") diff --git a/collects/planet/info.ss b/collects/planet/info.ss index b39b69aa6a..b27175645e 100644 --- a/collects/planet/info.ss +++ b/collects/planet/info.ss @@ -5,4 +5,4 @@ (define mzscheme-launcher-libraries '("planet.ss")) (define scribblings '(("planet.scrbl" (multi-page) (tool)))) -(define racket-tools '(("planet" planet/planet "manage Planet package installations" 80))) +(define raco-commands '(("planet" planet/planet "manage Planet package installations" 80))) diff --git a/collects/planet/planet.ss b/collects/planet/planet.ss index c1b84adfe6..2536551d89 100644 --- a/collects/planet/planet.ss +++ b/collects/planet/planet.ss @@ -11,7 +11,7 @@ PLANNED FEATURES: (only mzlib/list sort) net/url mzlib/match - tool/command-name + raco/command-name "config.ss" "private/planet-shared.ss" diff --git a/collects/tool/all-tools.ss b/collects/raco/all-tools.ss similarity index 85% rename from collects/tool/all-tools.ss rename to collects/raco/all-tools.ss index d47ac7632e..b877f3ee71 100644 --- a/collects/tool/all-tools.ss +++ b/collects/raco/all-tools.ss @@ -4,11 +4,11 @@ (provide all-tools) (define (all-tools) - (let* ([dirs (find-relevant-directories '(racket-tools))] + (let* ([dirs (find-relevant-directories '(raco-commands))] [tools (make-hash)]) (for ([i (in-list (map get-info/full dirs))] [d (in-list dirs)]) - (let ([entries (let ([l (i 'racket-tools (lambda () null))]) + (let ([entries (let ([l (i 'raco-commands (lambda () null))]) (if (list? l) l (list l)))]) @@ -33,7 +33,7 @@ [else (fprintf (current-error-port) - "warning: ~s provided bad `racket-tools' spec: ~e" + "warning: ~s provided bad `raco-commands' spec: ~e" d entry)])))) tools)) diff --git a/collects/tool/command-name.ss b/collects/raco/command-name.ss similarity index 100% rename from collects/tool/command-name.ss rename to collects/raco/command-name.ss diff --git a/collects/tool/info.ss b/collects/raco/info.ss similarity index 69% rename from collects/tool/info.ss rename to collects/raco/info.ss index d3177af88f..62887e73b9 100644 --- a/collects/tool/info.ss +++ b/collects/raco/info.ss @@ -3,4 +3,4 @@ (define compile-omit-paths '("main.ss")) (define racket-launcher-libraries '("main.ss")) -(define racket-launcher-names '("racket-tool")) +(define racket-launcher-names '("raco")) diff --git a/collects/tool/main.lch b/collects/raco/main.lch similarity index 100% rename from collects/tool/main.lch rename to collects/raco/main.lch diff --git a/collects/tool/main.ss b/collects/raco/main.ss similarity index 85% rename from collects/tool/main.ss rename to collects/raco/main.ss index 6a95d0e59c..335ed7c379 100644 --- a/collects/tool/main.ss +++ b/collects/raco/main.ss @@ -1,5 +1,5 @@ -;; Because `racket-tool setup' is used to rebuild .zos, check for "setup" +;; Because `raco setup' is used to rebuild .zos, check for "setup" ;; directly. ;; Note that this file is listed in "info.ss" so that it never gets a @@ -19,4 +19,4 @@ (cdr (vector->list cmdline)))]) (dynamic-require 'setup/main #f)) - (dynamic-require 'tool/tool #f)))) + (dynamic-require 'raco/raco #f)))) diff --git a/collects/tool/tool.ss b/collects/raco/raco.ss similarity index 92% rename from collects/tool/tool.ss rename to collects/raco/raco.ss index dca3d2c8d6..9d29d1dcb8 100644 --- a/collects/tool/tool.ss +++ b/collects/raco/raco.ss @@ -54,7 +54,7 @@ (find-system-path 'run-file) (car cmdline)) #f])]) - (fprintf (current-error-port) "Usage: racket-tool