diff --git a/collects/big/define-struct.ss b/collects/big/define-struct.ss index 83c65f3715..772957beac 100644 --- a/collects/big/define-struct.ss +++ b/collects/big/define-struct.ss @@ -379,7 +379,7 @@ (c (quote-syntax #,make-)) (c (quote-syntax #,?)) (list-immutable - #,@(map protect sels) + #,@(map protect (reverse sels)) #,@(if super-info (map protect (list-ref super-info 3)) (if super-expr diff --git a/collects/big/lang.ss b/collects/big/lang.ss index a0c7bf130b..fe1883b3d2 100644 --- a/collects/big/lang.ss +++ b/collects/big/lang.ss @@ -1,16 +1,20 @@ (module lang mzscheme (require "define-struct.ss" - "new-lambda.ss") + "new-lambda.ss" + (lib "contract.ss") + (lib "for.ss")) - (provide (all-from-except mzscheme #%datum lambda define #%app define-struct) + (provide (all-from (lib "contract.ss")) + (all-from (lib "for.ss")) + (all-from-except mzscheme #%datum lambda define #%app define-struct) (rename new-datum #%datum) (rename new-lambda lambda) (rename new-define define) (rename new-app #%app) + (rename #%app #%plain-app) + (rename lambda #%plain-lambda) make-keyword-procedure keyword-apply procedure-keywords (rename define-struct* define-struct) struct-field-index)) - - diff --git a/collects/big/new-lambda.ss b/collects/big/new-lambda.ss index 4322e61ede..05218094f7 100644 --- a/collects/big/new-lambda.ss +++ b/collects/big/new-lambda.ss @@ -488,8 +488,8 @@ ;; cannot be used to compute the default). (define-syntax let-maybe (syntax-rules (required) - [(_ () () () () () () body) - (let () body)] + [(_ () () () () () () . body) + (let () . body)] [(_ ([id ignore #:plain] . more) kw-args kw-arg?s opt-args opt-arg?s (req-id . req-ids) . body) (let ([id req-id]) (let-maybe more kw-args kw-arg?s opt-args opt-arg?s req-ids . body))] diff --git a/collects/compiler/compiler-unit.ss b/collects/compiler/compiler-unit.ss index bf85e01dd2..5d2f70a1b3 100644 --- a/collects/compiler/compiler-unit.ss +++ b/collects/compiler/compiler-unit.ss @@ -220,9 +220,15 @@ (lambda () (parameterize ([current-load-relative-directory dir]) ;; Compile the collection files via make-collection - (let ([sses (filter - extract-base-filename/ss - (directory-list))]) + (let ([sses (append + ;; Find all .ss/.scm files: + (filter + extract-base-filename/ss + (directory-list)) + ;; Add specified doc sources: + (map car (info + 'scribblings + (lambda () null))))]) (let ([filtered-sses (remove* (map string->path diff --git a/collects/compiler/embed-unit.ss b/collects/compiler/embed-unit.ss index 4746cbac59..6c1cc67eeb 100644 --- a/collects/compiler/embed-unit.ss +++ b/collects/compiler/embed-unit.ss @@ -402,9 +402,9 @@ null null) (unbox codes)))] [code - (let-values ([(imports fs-imports ft-imports) (module-compiled-imports code)]) + (let-values ([(imports fs-imports ft-imports fl-imports) (module-compiled-imports code)]) (let ([all-file-imports (filter (lambda (x) (not (symbol? x))) - (append imports fs-imports ft-imports))] + (append imports fs-imports ft-imports fl-imports))] [extra-paths (get-extra-imports filename code)]) (let ([sub-files (map (lambda (i) (normalize (resolve-module-path-index i filename))) all-file-imports)] diff --git a/collects/drscheme/private/module-overview.ss b/collects/drscheme/private/module-overview.ss index 6c5c34c55f..32841df9c3 100644 --- a/collects/drscheme/private/module-overview.ss +++ b/collects/drscheme/private/module-overview.ss @@ -941,7 +941,7 @@ (unless (hash-table-get visited-hash-table module-name (λ () #f)) (async-channel-put progress-channel (format adding-file module-name)) (hash-table-put! visited-hash-table module-name #t) - (let-values ([(imports fs-imports ft-imports) (module-compiled-imports module-code)]) + (let-values ([(imports fs-imports ft-imports fl-imports) (module-compiled-imports module-code)]) (let ([requires (extract-filenames imports module-name)] [syntax-requires (extract-filenames fs-imports module-name)] [template-requires (extract-filenames ft-imports module-name)]) diff --git a/collects/errortrace/stacktrace.ss b/collects/errortrace/stacktrace.ss index e5bc0d5b49..7c798b5993 100644 --- a/collects/errortrace/stacktrace.ss +++ b/collects/errortrace/stacktrace.ss @@ -420,8 +420,11 @@ [(require i ...) expr] [(require-for-syntax i ...) expr] [(require-for-template i ...) expr] + [(require-for-label i ...) expr] ;; No error possible (and no way to wrap) [(provide i ...) expr] + [(provide-for-syntax i ...) expr] + [(provide-for-label i ...) expr] ;; No error possible [(quote _) diff --git a/collects/macro-debugger/model/deriv-parser.ss b/collects/macro-debugger/model/deriv-parser.ss index f374d359c2..3019dcc0e0 100644 --- a/collects/macro-debugger/model/deriv-parser.ss +++ b/collects/macro-debugger/model/deriv-parser.ss @@ -57,8 +57,8 @@ ;; Entry point (productions (Expansion - [(EE/Lifts) $1] - [(EE/Lifts/Interrupted) $1])) + [(start EE/Lifts) $2] + [(start EE/Lifts/Interrupted) $2])) (productions/I @@ -106,7 +106,10 @@ ;; Evaluation (Eval - [() #f]) + (#:no-wrap) + [() #f] + [(start (? EE) (? Eval)) #f] + [(start (? CheckImmediateMacro) (? Eval)) #f]) ;; Expansion of an expression to primitive form ;; CheckImmediateMacro Answer = Derivation (I) @@ -150,18 +153,19 @@ (#:no-wrap) (#:skipped null) [() null] - [((? LocalAction) (? LocalActions)) (cons $1 $2)]) + [((? LocalAction) (? LocalActions)) (cons $1 $2)] + [((? NotReallyLocalAction) (? LocalActions)) $2]) (LocalAction (#:no-wrap) - [(enter-local local-pre (? EE) local-post exit-local) - (make-local-expansion $1 $5 $2 $4 #f $3)] - [(enter-local phase-up local-pre (? EE) local-post exit-local) - (make-local-expansion $1 $6 $3 $5 #t $4)] - [(enter-local/expr local-pre (? EE) local-post exit-local/expr) - (make-local-expansion/expr $1 (car $5) $2 $4 #f (cdr $5) $3)] - [(enter-local/expr local-pre phase-up (? EE) local-post exit-local/expr) - (make-local-expansion/expr $1 (car $6) $3 $5 #t (cdr $6) $4)] + [(enter-local local-pre start (? EE) local-post exit-local) + (make-local-expansion $1 $6 $2 $5 #f $4)] + [(enter-local phase-up local-pre start (? EE) local-post exit-local) + (make-local-expansion $1 $7 $3 $6 #t $5)] + [(enter-local/expr local-pre start (? EE) local-post exit-local/expr) + (make-local-expansion/expr $1 (car $6) $2 $5 #f (cdr $6) $4)] + [(enter-local/expr local-pre phase-up start (? EE) local-post exit-local/expr) + (make-local-expansion/expr $1 (car $7) $3 $6 #t (cdr $7) $5)] [(lift) (make-local-lift (cdr $1) (car $1))] [(lift-statement) @@ -169,6 +173,17 @@ [(phase-up (? EE/LetLifts)) (make-local-bind $2)]) + (NotReallyLocalAction + (#:no-wrap) + ;; called 'expand' (not 'local-expand') within transformer + [(start (? EE)) + (make-local-expansion (lift/deriv-e1 $2) + (lift/deriv-e2 $2) + (lift/deriv-e1 $2) + (lift/deriv-e2 $2) + #f + $2)]) + ;; Multiple calls to local-expand ;; EEs Answer = (listof Derivation) (EEs @@ -245,8 +260,8 @@ (#:args e1 e2 rs) ;; Multiple forms after language ;; #%module-begin tagging done automatically - [(prim-module ! (? EE 'body)) - (make-p:module e1 e2 rs #f $3)] + [(prim-module ! (? Eval) (? EE 'body)) + (make-p:module e1 e2 rs #f $4)] ;; One form after language ... macro that expands into #%module-begin [(prim-module NoError next @@ -287,14 +302,14 @@ (ModulePass1/Prim [(enter-prim prim-define-values ! exit-prim) (make-p:define-values $1 $4 null #f)] - [(enter-prim prim-define-syntaxes ! phase-up (? EE/LetLifts) exit-prim) - (make-p:define-syntaxes $1 $6 null $5)] - [(enter-prim prim-require ! exit-prim) - (make-p:require $1 $4 null)] - [(enter-prim prim-require-for-syntax ! exit-prim) - (make-p:require-for-syntax $1 $4 null)] - [(enter-prim prim-require-for-template ! exit-prim) - (make-p:require-for-template $1 $4 null)] + [(enter-prim prim-define-syntaxes ! phase-up (? EE/LetLifts) (? Eval) exit-prim) + (make-p:define-syntaxes $1 $7 null $5)] + [(enter-prim prim-require ! (? Eval) exit-prim) + (make-p:require $1 $5 null)] + [(enter-prim prim-require-for-syntax ! (? Eval) exit-prim) + (make-p:require-for-syntax $1 $5 null)] + [(enter-prim prim-require-for-template ! (? Eval) exit-prim) + (make-p:require-for-template $1 $5 null)] [(enter-prim prim-provide ! exit-prim) (make-p:provide $1 $4 null)] [() @@ -324,7 +339,7 @@ ;; Definitions (PrimDefineSyntaxes (#:args e1 e2 rs) - [(prim-define-syntaxes ! (? EE/LetLifts)) + [(prim-define-syntaxes ! (? EE/LetLifts) (? Eval)) (make-p:define-syntaxes e1 e2 rs $3)]) (PrimDefineValues @@ -439,15 +454,18 @@ (PrimRequire (#:args e1 e2 rs) - [(prim-require !) (make-p:require e1 e2 rs)]) + [(prim-require ! (? Eval)) + (make-p:require e1 e2 rs)]) (PrimRequireForSyntax (#:args e1 e2 rs) - [(prim-require-for-syntax !) (make-p:require-for-syntax e1 e2 rs)]) + [(prim-require-for-syntax ! (? Eval)) + (make-p:require-for-syntax e1 e2 rs)]) (PrimRequireForTemplate (#:args e1 e2 rs) - [(prim-require-for-template !) (make-p:require-for-template e1 e2 rs)]) + [(prim-require-for-template ! (? Eval)) + (make-p:require-for-template e1 e2 rs)]) (PrimProvide (#:args e1 e2 rs) @@ -500,7 +518,7 @@ ;; BindSyntaxes Answer = Derivation (BindSyntaxes - [(phase-up (? EE/LetLifts) ! Eval) $2]) + [(phase-up (? EE/LetLifts) ! (? Eval)) $2]) ;; NextBindSyntaxess Answer = (list-of Derivation) (NextBindSyntaxess diff --git a/collects/macro-debugger/model/deriv-tokens.ss b/collects/macro-debugger/model/deriv-tokens.ss index a1a6ca95c4..cc5fa2fc2a 100644 --- a/collects/macro-debugger/model/deriv-tokens.ss +++ b/collects/macro-debugger/model/deriv-tokens.ss @@ -5,7 +5,8 @@ (provide (all-defined)) (define-tokens basic-tokens - (visit ; syntax + (start ; . + visit ; syntax resolve ; identifier next ; . next-group ; . @@ -138,6 +139,7 @@ (138 . prim-expression) (139 . ,token-enter-local/expr) (140 . ,token-exit-local/expr) + (141 . ,token-start) )) (define (tokenize sig-n val pos) diff --git a/collects/mzlib/class.ss b/collects/mzlib/class.ss index ecf8218682..536df91025 100644 --- a/collects/mzlib/class.ss +++ b/collects/mzlib/class.ss @@ -37,7 +37,7 @@ private public override augment pubment overment augride public-final override-final augment-final - field init init-field + field init init-field init-rest rename-super rename-inner inherit inherit/super inherit/inner inherit-field this super inner super-make-object super-instantiate super-new diff --git a/collects/mzlib/cm.ss b/collects/mzlib/cm.ss index 11a1a31340..3ee4c4e642 100644 --- a/collects/mzlib/cm.ss +++ b/collects/mzlib/cm.ss @@ -25,12 +25,12 @@ (x (apply max x)))) (define (get-deps code path) - (let-values ([(imports fs-imports ft-imports) (module-compiled-imports code)]) + (let-values ([(imports fs-imports ft-imports fl-imports) (module-compiled-imports code)]) (map path->bytes (map (lambda (x) (resolve-module-path-index x path)) ;; Filter symbols: - (let loop ([l (append imports fs-imports ft-imports)]) + (let loop ([l (append imports fs-imports ft-imports fl-imports)]) (cond [(null? l) null] [(symbol? (car l)) (loop (cdr l))] diff --git a/collects/mzlib/for.ss b/collects/mzlib/for.ss index ec9a8f6e4f..2d242d44be 100644 --- a/collects/mzlib/for.ss +++ b/collects/mzlib/for.ss @@ -29,6 +29,7 @@ stop-after (rename *in-indexed in-indexed) + sequence? sequence-generate define-sequence-syntax diff --git a/collects/mzlib/private/class-internal.ss b/collects/mzlib/private/class-internal.ss index 665ec3b9a6..0dca841f2f 100644 --- a/collects/mzlib/private/class-internal.ss +++ b/collects/mzlib/private/class-internal.ss @@ -42,7 +42,8 @@ public-final override-final augment-final rename-super rename-inner inherit inherit-field inherit/super inherit/inner - inspect) + inspect + init-rest) (define-syntax provide-class-define-like-keyword (syntax-rules () diff --git a/collects/scribble/base-render.ss b/collects/scribble/base-render.ss index 397c85497d..e918f79df9 100644 --- a/collects/scribble/base-render.ss +++ b/collects/scribble/base-render.ss @@ -11,7 +11,7 @@ (class object% (init-field dest-dir) - + (define/public (get-dest-directory) dest-dir) @@ -42,210 +42,334 @@ [else (cons (car content) (strip-aux (cdr content)))])) + ;; ---------------------------------------- + ;; marshal info + + (define/public (get-serialize-version) + 1) + + (define/public (serialize-info ri) + (parameterize ([current-serialize-resolve-info ri]) + (serialize (collect-info-ht (resolve-info-ci ri))))) + + (define/public (deserialize-info v ci) + (let ([ht (deserialize v)] + [in-ht (collect-info-ext-ht ci)]) + (hash-table-for-each ht (lambda (k v) + (hash-table-put! in-ht k v))))) + (define/public (get-defined ci) + (hash-table-map (collect-info-ht ci) (lambda (k v) k))) + + (define/public (get-undefined ri) + (hash-table-map (resolve-info-undef ri) (lambda (k v) k))) + ;; ---------------------------------------- ;; global-info collection - (define/public (save-info fn info) - (let ([s (serialize info)]) - (with-output-to-file fn - (lambda () - (write s)) - 'truncate/replace))) - - (define/public (load-info fn info) - (let ([ht (deserialize (with-input-from-file fn read))]) - (hash-table-for-each ht (lambda (k v) - (hash-table-put! info k v)))) - info) - (define/public (collect ds fns) - (let ([ht (make-hash-table 'equal)]) - (map (lambda (d) - (collect-part d #f ht null)) - ds) - ht)) + (let ([ci (make-collect-info (make-hash-table 'equal) + (make-hash-table 'equal) + (make-hash-table) + (make-hash-table) + "")]) + (start-collect ds fns ci) + ci)) - (define/public (collect-part d parent ht number) - (let ([p-ht (make-hash-table 'equal)]) + (define/public (start-collect ds fns ci) + (map (lambda (d) + (collect-part d #f ci null)) + ds)) + + (define/public (collect-part d parent ci number) + (let ([p-ci (make-collect-info (make-hash-table 'equal) + (collect-info-ext-ht ci) + (collect-info-parts ci) + (collect-info-tags ci) + (if (part-tag-prefix d) + (string-append (collect-info-gen-prefix ci) + (part-tag-prefix d) + ":") + (collect-info-gen-prefix ci)))]) (when (part-title-content d) - (collect-content (part-title-content d) p-ht)) - (collect-part-tags d p-ht number) - (collect-content (part-to-collect d) p-ht) - (collect-flow (part-flow d) p-ht) + (collect-content (part-title-content d) p-ci)) + (collect-part-tags d p-ci number) + (collect-content (part-to-collect d) p-ci) + (collect-flow (part-flow d) p-ci) (let loop ([parts (part-parts d)] [pos 1]) (unless (null? parts) (let ([s (car parts)]) - (collect-part s d p-ht + (collect-part s d p-ci (cons (if (unnumbered-part? s) #f pos) number)) (loop (cdr parts) (if (unnumbered-part? s) pos (add1 pos)))))) - (set-part-collected-info! d (make-collected-info - number - parent - p-ht)) - (hash-table-for-each p-ht - (lambda (k v) - (hash-table-put! ht k v))))) + (hash-table-put! (collect-info-parts ci) + d + (make-collected-info + number + parent + (collect-info-ht p-ci))) + (let ([prefix (part-tag-prefix d)]) + (hash-table-for-each (collect-info-ht p-ci) + (lambda (k v) + (when (cadr k) + (hash-table-put! (collect-info-ht ci) + (if prefix + (convert-key prefix k) + k) + v))))))) - (define/public (collect-part-tags d ht number) + (define/private (convert-key prefix k) + (case (car k) + [(part tech) + (if (string? (cadr k)) + (list (car k) + (string-append prefix + ":" + (cadr k))) + k)] + [(index-entry) + (let ([v (convert-key prefix (cadr k))]) + (if (eq? v (cadr k)) + k + (list 'index-entry v)))] + [else k])) + + (define/public (collect-part-tags d ci number) (for-each (lambda (t) - (hash-table-put! ht `(part ,t) (list (part-title-content d) number))) + (hash-table-put! (collect-info-ht ci) + (generate-tag t ci) + (list (or (part-title-content d) '("???")) + number))) (part-tags d))) - (define/public (collect-content c ht) + (define/public (collect-content c ci) (for-each (lambda (i) - (collect-element i ht)) + (collect-element i ci)) c)) - (define/public (collect-paragraph p ht) - (collect-content (paragraph-content p) ht)) + (define/public (collect-paragraph p ci) + (collect-content (paragraph-content p) ci)) - (define/public (collect-flow p ht) + (define/public (collect-flow p ci) (for-each (lambda (p) - (collect-flow-element p ht)) + (collect-flow-element p ci)) (flow-paragraphs p))) - (define/public (collect-flow-element p ht) + (define/public (collect-flow-element p ci) (cond - [(table? p) (collect-table p ht)] - [(itemization? p) (collect-itemization p ht)] - [(blockquote? p) (collect-blockquote p ht)] + [(table? p) (collect-table p ci)] + [(itemization? p) (collect-itemization p ci)] + [(blockquote? p) (collect-blockquote p ci)] [(delayed-flow-element? p) (void)] - [else (collect-paragraph p ht)])) + [else (collect-paragraph p ci)])) - (define/public (collect-table i ht) + (define/public (collect-table i ci) (for-each (lambda (d) (when (flow? d) - (collect-flow d ht))) + (collect-flow d ci))) (apply append (table-flowss i)))) - (define/public (collect-itemization i ht) - (for-each (lambda (d) (collect-flow d ht)) + (define/public (collect-itemization i ci) + (for-each (lambda (d) (collect-flow d ci)) (itemization-flows i))) - (define/public (collect-blockquote i ht) - (for-each (lambda (d) (collect-flow-element d ht)) + (define/public (collect-blockquote i ci) + (for-each (lambda (d) (collect-flow-element d ci)) (blockquote-paragraphs i))) - (define/public (collect-element i ht) + (define/public (collect-element i ci) (when (target-element? i) - (collect-target-element i ht)) + (collect-target-element i ci)) (when (index-element? i) - (collect-index-element i ht)) + (collect-index-element i ci)) + (when (collect-element? i) + ((collect-element-collect i) ci)) (when (element? i) (for-each (lambda (e) - (collect-element e ht)) + (collect-element e ci)) (element-content i)))) - (define/public (collect-target-element i ht) - (hash-table-put! ht (target-element-tag i) (list i))) + (define/public (collect-target-element i ci) + (collect-put! ci + (generate-tag (target-element-tag i) ci) + (list i))) - (define/public (collect-index-element i ht) - (hash-table-put! ht `(index-entry ,(index-element-tag i)) - (list (index-element-plain-seq i) - (index-element-entry-seq i)))) + (define/public (collect-index-element i ci) + (collect-put! ci + `(index-entry ,(generate-tag (index-element-tag i) ci)) + (list (index-element-plain-seq i) + (index-element-entry-seq i)))) - (define/public (lookup part ht key) - (let ([v (hash-table-get (if part - (collected-info-info (part-collected-info part)) - ht) - key - #f)]) - (or v - (and part - (lookup (collected-info-parent - (part-collected-info part)) - ht - key))))) + ;; ---------------------------------------- + ;; global-info resolution + + (define/public (resolve ds fns ci) + (let ([ri (make-resolve-info ci + (make-hash-table) + (make-hash-table 'equal))]) + (start-resolve ds fns ri) + ri)) + + (define/public (start-resolve ds fns ri) + (map (lambda (d) + (resolve-part d ri)) + ds)) + + (define/public (resolve-part d ri) + (when (part-title-content d) + (resolve-content (part-title-content d) d ri)) + (resolve-flow (part-flow d) d ri) + (for-each (lambda (p) + (resolve-part p ri)) + (part-parts d))) + + (define/public (resolve-content c d ri) + (for-each (lambda (i) + (resolve-element i d ri)) + c)) + + (define/public (resolve-paragraph p d ri) + (resolve-content (paragraph-content p) d ri)) + + (define/public (resolve-flow p d ri) + (for-each (lambda (p) + (resolve-flow-element p d ri)) + (flow-paragraphs p))) + + (define/public (resolve-flow-element p d ri) + (cond + [(table? p) (resolve-table p d ri)] + [(itemization? p) (resolve-itemization p d ri)] + [(blockquote? p) (resolve-blockquote p d ri)] + [(delayed-flow-element? p) + (let ([v ((delayed-flow-element-resolve p) this d ri)]) + (hash-table-put! (resolve-info-delays ri) p v) + (resolve-flow-element v d ri))] + [else (resolve-paragraph p d ri)])) + + (define/public (resolve-table i d ri) + (for-each (lambda (f) (when (flow? f) + (resolve-flow f d ri))) + (apply append (table-flowss i)))) + + (define/public (resolve-itemization i d ri) + (for-each (lambda (f) (resolve-flow f d ri)) + (itemization-flows i))) + + (define/public (resolve-blockquote i d ri) + (for-each (lambda (f) (resolve-flow-element f d ri)) + (blockquote-paragraphs i))) + + (define/public (resolve-element i d ri) + (cond + [(delayed-element? i) + (resolve-content (or (hash-table-get (resolve-info-delays ri) + i + #f) + (let ([v ((delayed-element-resolve i) this d ri)]) + (hash-table-put! (resolve-info-delays ri) + i + v) + v)) + d ri)] + [(element? i) + (cond + [(link-element? i) + (let-values ([(dest ext?) (resolve-get/where d ri (link-element-tag i))]) + (when ext? + (hash-table-put! (resolve-info-undef ri) + (tag-key (link-element-tag i) ri) + #t)))]) + (for-each (lambda (e) + (resolve-element e d ri)) + (element-content i))])) ;; ---------------------------------------- ;; render methods - (define/public (render ds fns ht) + (define/public (render ds fns ri) (map (lambda (d fn) (printf " [Output to ~a]\n" fn) (with-output-to-file fn (lambda () - (render-one d ht fn)) + (render-one d ri fn)) 'truncate/replace)) - ds fns)) - (define/public (render-one d ht fn) - (render-part d ht)) + (define/public (render-one d ri fn) + (render-part d ri)) - (define/public (render-part d ht) + (define/public (render-part d ri) (list (when (part-title-content d) - (render-content (part-title-content d) d ht)) - (render-flow (part-flow d) d ht) - (map (lambda (s) (render-part s ht)) + (render-content (part-title-content d) d ri)) + (render-flow (part-flow d) d ri) + (map (lambda (s) (render-part s ri)) (part-parts d)))) - (define/public (render-content c part ht) + (define/public (render-content c part ri) (apply append (map (lambda (i) - (render-element i part ht)) + (render-element i part ri)) c))) - (define/public (render-paragraph p part ht) - (render-content (paragraph-content p) part ht)) + (define/public (render-paragraph p part ri) + (render-content (paragraph-content p) part ri)) - (define/public (render-flow p part ht) + (define/public (render-flow p part ri) (apply append (map (lambda (p) - (render-flow-element p part ht)) + (render-flow-element p part ri)) (flow-paragraphs p)))) - (define/public (render-flow-element p part ht) + (define/public (render-flow-element p part ri) (cond [(table? p) (if (auxiliary-table? p) - (render-auxiliary-table p part ht) - (render-table p part ht))] - [(itemization? p) (render-itemization p part ht)] - [(blockquote? p) (render-blockquote p part ht)] - [(delayed-flow-element? p) (render-flow-element - ((delayed-flow-element-render p) this part ht) - part ht)] - [else (render-paragraph p part ht)])) + (render-auxiliary-table p part ri) + (render-table p part ri))] + [(itemization? p) (render-itemization p part ri)] + [(blockquote? p) (render-blockquote p part ri)] + [(delayed-flow-element? p) + (render-flow-element (delayed-flow-element-flow-elements p ri) part ri)] + [else (render-paragraph p part ri)])) - (define/public (render-auxiliary-table i part ht) + (define/public (render-auxiliary-table i part ri) null) - (define/public (render-table i part ht) + (define/public (render-table i part ri) (map (lambda (d) (if (flow? i) - (render-flow d part ht) + (render-flow d part ri) null)) (apply append (table-flowss i)))) - (define/public (render-itemization i part ht) - (map (lambda (d) (render-flow d part ht)) + (define/public (render-itemization i part ri) + (map (lambda (d) (render-flow d part ri)) (itemization-flows i))) - (define/public (render-blockquote i part ht) - (map (lambda (d) (render-flow-element d part ht)) + (define/public (render-blockquote i part ri) + (map (lambda (d) (render-flow-element d part ri)) (blockquote-paragraphs i))) - (define/public (render-element i part ht) + (define/public (render-element i part ri) (cond [(and (link-element? i) (null? (element-content i))) - (let ([v (lookup part ht (link-element-tag i))]) + (let ([v (resolve-get part ri (link-element-tag i))]) (if v - (render-content (strip-aux (car v)) part ht) - (render-content (list "[missing]") part ht)))] + (render-content (strip-aux (car v)) part ri) + (render-content (list "[missing]") part ri)))] [(element? i) - (render-content (element-content i) part ht)] + (render-content (element-content i) part ri)] [(delayed-element? i) - (render-content (force-delayed-element i this part ht) part ht)] + (render-content (delayed-element-content i ri) part ri)] [else - (render-other i part ht)])) + (render-other i part ri)])) - (define/public (render-other i part ht) + (define/public (render-other i part ri) (list i)) ;; ---------------------------------------- @@ -280,34 +404,32 @@ ;; ---------------------------------------- - (define/private (do-table-of-contents part ht delta quiet) - (make-table #f (render-toc part - (+ delta - (length (collected-info-number - (part-collected-info part)))) - #t - quiet))) + (define/private (do-table-of-contents part ri delta quiet) + (make-table #f (generate-toc part + ri + (+ delta + (length (collected-info-number + (part-collected-info part ri)))) + #t + quiet))) - (define/public (table-of-contents part ht) - (do-table-of-contents part ht -1 not)) + (define/public (table-of-contents part ri) + (do-table-of-contents part ri -1 not)) - (define/public (local-table-of-contents part ht) - (table-of-contents part ht)) + (define/public (local-table-of-contents part ri) + (table-of-contents part ri)) - (define/public (quiet-table-of-contents part ht) - (do-table-of-contents part ht 1 (lambda (x) #t))) + (define/public (quiet-table-of-contents part ri) + (do-table-of-contents part ri 1 (lambda (x) #t))) - (define/private (render-toc part base-len skip? quiet) - (let ([number (collected-info-number (part-collected-info part))]) + (define/private (generate-toc part ri base-len skip? quiet) + (let ([number (collected-info-number (part-collected-info part ri))]) (let ([subs - (if (quiet (and (styled-part? part) - (let ([st(styled-part-style part)]) - (or (eq? 'quiet st) - (and (list? st) (memq 'quiet st)))) + (if (quiet (and (part-style? part 'quiet) (not (= base-len (sub1 (length number)))))) (apply append - (map (lambda (p) (render-toc p base-len #f quiet)) (part-parts part))) + (map (lambda (p) (generate-toc p ri base-len #f quiet)) (part-parts part))) null)]) (if skip? subs @@ -324,8 +446,8 @@ (format-number number (list (make-element 'hspace '(" ")))) - (part-title-content part)) - `(part ,(car (part-tags part))))))))) + (or (part-title-content part) '("???"))) + (car (part-tags part)))))))) subs)]) (if (and (= 1 (length number)) (or (not (car number)) diff --git a/collects/scribble/basic.ss b/collects/scribble/basic.ss index 8a60e1657b..0ec3c1b98b 100644 --- a/collects/scribble/basic.ss +++ b/collects/scribble/basic.ss @@ -4,7 +4,9 @@ "struct.ss" "config.ss" (lib "list.ss") - (lib "class.ss")) + (lib "class.ss") + (lib "main-collects.ss" "setup") + (lib "modresolve.ss" "syntax")) (provide title section @@ -18,21 +20,41 @@ (content->string content) "_")) - (define (title #:tag [tag #f] #:style [style #f] . str) + (define (prefix->string p) + (and p + (if (string? p) + p + (module-path-prefix->string p)))) + + (define (title #:tag [tag #f] #:tag-prefix [prefix #f] #:style [style #f] . str) (let ([content (decode-content str)]) - (make-title-decl (or tag (gen-tag content)) style content))) + (make-title-decl (prefix->string prefix) + `((part ,(or tag (gen-tag content)))) + style + content))) - (define (section #:tag [tag #f] #:style [style #f] . str) + (define (section #:tag [tag #f] #:tag-prefix [prefix #f] #:style [style #f] . str) (let ([content (decode-content str)]) - (make-part-start 0 (or tag (gen-tag content)) style content))) + (make-part-start 0 (prefix->string prefix) + `((part ,(or tag (gen-tag content)))) + style + content))) - (define (subsection #:tag [tag #f] . str) + (define (subsection #:tag [tag #f] #:tag-prefix [prefix #f] . str) (let ([content (decode-content str)]) - (make-part-start 1 (or tag (gen-tag content)) #f content))) + (make-part-start 1 + (prefix->string prefix) + `((part ,(or tag (gen-tag content)))) + #f + content))) - (define (subsubsection #:tag [tag #f] . str) + (define (subsubsection #:tag [tag #f] #:tag-prefix [prefix #f] . str) (let ([content (decode-content str)]) - (make-part-start 2 (or tag (gen-tag content)) #f content))) + (make-part-start 2 + (prefix->string prefix) + `((part ,(or tag (gen-tag content)))) + #f + content))) (define (subsubsub*section #:tag [tag #f] . str) (let ([content (decode-content str)]) @@ -47,6 +69,14 @@ ;; ---------------------------------------- + (provide module-path-prefix->string) + + (define (module-path-prefix->string p) + (format "~a" (path->main-collects-relative + (resolve-module-path p #f)))) + + ;; ---------------------------------------- + (provide itemize item item?) (define (itemize . items) @@ -124,19 +154,16 @@ (define (section-index . elems) (make-part-index-decl (map element->string elems) elems)) - (define (gen-target) - (format "index:~s:~s" (current-inexact-milliseconds) (gensym))) - (define (record-index word-seq element-seq tag content) (make-index-element #f - (list (make-target-element #f content tag)) - tag + (list (make-target-element #f content `(idx ,tag))) + `(idx ,tag) word-seq element-seq)) (define (index* word-seq content-seq . s) - (let ([key (gen-target)]) + (let ([key (make-generated-tag)]) (record-index word-seq content-seq key @@ -149,7 +176,7 @@ (apply index* word-seq word-seq s))) (define (as-index . s) - (let ([key (gen-target)] + (let ([key (make-generated-tag)] [content (decode-content s)]) (record-index (list (content->string content)) (list (make-element #f content)) @@ -158,18 +185,21 @@ (define (index-section tag) (make-unnumbered-part - (and tag (list tag)) - (list "Index") #f + `((part , (or tag + (make-generated-tag)))) + '("Index") + 'index null (make-flow (list (make-delayed-flow-element - (lambda (renderer sec ht) + (lambda (renderer sec ri) (let ([l null]) (hash-table-for-each (collected-info-info (part-collected-info (collected-info-parent - (part-collected-info sec)))) + (part-collected-info sec ri)) + ri)) (lambda (k v) (if (and (pair? k) (eq? 'index-entry (car k))) @@ -204,8 +234,7 @@ (commas (caddr i)) (car i)))))))) l)))))))) - null - 'index)) + null)) ;; ---------------------------------------- @@ -214,13 +243,13 @@ (define (table-of-contents) (make-delayed-flow-element - (lambda (renderer part ht) - (send renderer table-of-contents part ht)))) + (lambda (renderer part ri) + (send renderer table-of-contents part ri)))) (define (local-table-of-contents) (make-delayed-flow-element - (lambda (renderer part ht) - (send renderer local-table-of-contents part ht))))) + (lambda (renderer part ri) + (send renderer local-table-of-contents part ri))))) diff --git a/collects/scribble/decode.ss b/collects/scribble/decode.ss index a21c3ca44c..e4a78e9d64 100644 --- a/collects/scribble/decode.ss +++ b/collects/scribble/decode.ss @@ -13,16 +13,19 @@ whitespace?) (provide-structs - [title-decl ([tag any/c] + [title-decl ([tag-prefix (or/c false/c string?)] + [tags (listof tag?)] [style any/c] [content list?])] [part-start ([depth integer?] - [tag (or/c false/c string?)] + [tag-prefix (or/c false/c string?)] + [tags (listof tag?)] [style any/c] [title list?])] [splice ([run list?])] [part-index-decl ([plain-seq (listof string?)] - [entry-seq list?])]) + [entry-seq list?])] + [part-collect-decl ([element element?])]) (define (decode-string s) (let loop ([l '((#rx"---" mdash) @@ -52,39 +55,42 @@ null (list (decode-paragraph (reverse (skip-whitespace accum)))))) - (define (decode-flow* l keys tag style title part-depth) - (let loop ([l l][next? #f][keys keys][accum null][title title][tag tag][style style]) + (define (decode-flow* l keys colls tag-prefix tags style title part-depth) + (let loop ([l l][next? #f][keys keys][colls colls][accum null][title title][tag-prefix tag-prefix][tags tags][style style]) (cond [(null? l) - (let ([tags (map (lambda (k) - (format "secindex:~a:~a" (current-inexact-milliseconds) (gensym))) - keys)] - [tag (or tag (format "sec:~a:~a" (current-inexact-milliseconds) (gensym)))]) - (make-styled-part (cons tag - tags) - title - #f - (let ([l (map (lambda (k tag) - (make-index-element - #f - null - `(part ,tag) - (part-index-decl-plain-seq k) - (part-index-decl-entry-seq k))) - keys tags)]) - (if title - (cons (make-index-element - #f - null - `(part ,tag) - (list (regexp-replace #px"^(?:A|An|The)\\s" (content->string title) - "")) - (list (make-element #f title))) - l) - l)) - (make-flow (decode-accum-para accum)) - null - style))] + (let ([k-tags (map (lambda (k) + `(idx ,(make-generated-tag))) + keys)] + [tags (if (null? tags) + (list `(part ,(make-generated-tag))) + tags)]) + (make-part tag-prefix + (append tags k-tags) + title + style + (let ([l (map (lambda (k tag) + (make-index-element + #f + null + tag + (part-index-decl-plain-seq k) + (part-index-decl-entry-seq k))) + keys k-tags)]) + (append + (if title + (cons (make-index-element + #f + null + (car tags) + (list (regexp-replace #px"^(?:A|An|The)\\s" (content->string title) + "")) + (list (make-element #f title))) + l) + l) + colls)) + (make-flow (decode-accum-para accum)) + null))] [(title-decl? (car l)) (unless part-depth (error 'decode @@ -94,34 +100,35 @@ (error 'decode "found extra title: ~v" (car l))) - (loop (cdr l) next? keys accum + (loop (cdr l) next? keys colls accum (title-decl-content (car l)) - (title-decl-tag (car l)) + (title-decl-tag-prefix (car l)) + (title-decl-tags (car l)) (title-decl-style (car l)))] [(flow-element? (car l)) (let ([para (decode-accum-para accum)] - [part (decode-flow* (cdr l) keys tag style title part-depth)]) - (make-styled-part (part-tags part) - (part-title-content part) - (part-collected-info part) - (part-to-collect part) - (make-flow (append para - (list (car l)) - (flow-paragraphs (part-flow part)))) - (part-parts part) - (styled-part-style part)))] + [part (decode-flow* (cdr l) keys colls tag-prefix tags style title part-depth)]) + (make-part (part-tag-prefix part) + (part-tags part) + (part-title-content part) + (part-style part) + (part-to-collect part) + (make-flow (append para + (list (car l)) + (flow-paragraphs (part-flow part)))) + (part-parts part)))] [(part? (car l)) (let ([para (decode-accum-para accum)] - [part (decode-flow* (cdr l) keys tag style title part-depth)]) - (make-styled-part (part-tags part) - (part-title-content part) - (part-collected-info part) - (part-to-collect part) - (make-flow (append para - (flow-paragraphs - (part-flow part)))) - (cons (car l) (part-parts part)) - (styled-part-style part)))] + [part (decode-flow* (cdr l) keys colls tag-prefix tags style title part-depth)]) + (make-part (part-tag-prefix part) + (part-tags part) + (part-title-content part) + (part-style part) + (part-to-collect part) + (make-flow (append para + (flow-paragraphs + (part-flow part)))) + (cons (car l) (part-parts part))))] [(and (part-start? (car l)) (or (not part-depth) ((part-start-depth (car l)) . <= . part-depth))) @@ -138,54 +145,57 @@ (part? (car l)))) (let ([para (decode-accum-para accum)] [s (decode-styled-part (reverse s-accum) - (part-start-tag s) + (part-start-tag-prefix s) + (part-start-tags s) (part-start-style s) (part-start-title s) (add1 part-depth))] - [part (decode-flow* l keys tag style title part-depth)]) - (make-styled-part (part-tags part) - (part-title-content part) - (part-collected-info part) - (part-to-collect part) - (make-flow para) - (cons s (part-parts part)) - (styled-part-style part))) + [part (decode-flow* l keys colls tag-prefix tags style title part-depth)]) + (make-part (part-tag-prefix part) + (part-tags part) + (part-title-content part) + (part-style part) + (part-to-collect part) + (make-flow para) + (cons s (part-parts part)))) (if (splice? (car l)) (loop (append (splice-run (car l)) (cdr l)) s-accum) (loop (cdr l) (cons (car l) s-accum))))))] [(splice? (car l)) - (loop (append (splice-run (car l)) (cdr l)) next? keys accum title tag style)] - [(null? (cdr l)) (loop null #f keys (cons (car l) accum) title tag style)] + (loop (append (splice-run (car l)) (cdr l)) next? keys colls accum title tag-prefix tags style)] + [(null? (cdr l)) (loop null #f keys colls (cons (car l) accum) title tag-prefix tags style)] [(part-index-decl? (car l)) - (loop (cdr l) next? (cons (car l) keys) accum title tag style)] + (loop (cdr l) next? (cons (car l) keys) colls accum title tag-prefix tags style)] + [(part-collect-decl? (car l)) + (loop (cdr l) next? keys (cons (part-collect-decl-element (car l)) colls) accum title tag-prefix tags style)] [(and (pair? (cdr l)) (splice? (cadr l))) - (loop (cons (car l) (append (splice-run (cadr l)) (cddr l))) next? keys accum title tag style)] + (loop (cons (car l) (append (splice-run (cadr l)) (cddr l))) next? keys colls accum title tag-prefix tags style)] [(line-break? (car l)) (if next? - (loop (cdr l) #t keys accum title tag style) + (loop (cdr l) #t keys colls accum title tag-prefix tags style) (let ([m (match-newline-whitespace (cdr l))]) (if m - (let ([part (loop m #t keys null title tag style)]) - (make-styled-part (part-tags part) - (part-title-content part) - (part-collected-info part) - (part-to-collect part) - (make-flow (append (decode-accum-para accum) - (flow-paragraphs (part-flow part)))) - (part-parts part) - (styled-part-style part))) - (loop (cdr l) #f keys (cons (car l) accum) title tag style))))] - [else (loop (cdr l) #f keys (cons (car l) accum) title tag style)]))) + (let ([part (loop m #t keys colls null title tag-prefix tags style)]) + (make-part (part-tag-prefix part) + (part-tags part) + (part-title-content part) + (part-style part) + (part-to-collect part) + (make-flow (append (decode-accum-para accum) + (flow-paragraphs (part-flow part)))) + (part-parts part))) + (loop (cdr l) #f keys colls (cons (car l) accum) title tag-prefix tags style))))] + [else (loop (cdr l) #f keys colls (cons (car l) accum) title tag-prefix tags style)]))) - (define (decode-part l tag title depth) - (decode-flow* l null tag #f title depth)) + (define (decode-part l tags title depth) + (decode-flow* l null null #f tags #f title depth)) - (define (decode-styled-part l tag style title depth) - (decode-flow* l null tag style title depth)) + (define (decode-styled-part l tag-prefix tags style title depth) + (decode-flow* l null null tag-prefix tags style title depth)) (define (decode-flow l) - (part-flow (decode-flow* l null #f #f #f #f))) + (part-flow (decode-flow* l null null #f null #f #f #f))) (define (match-newline-whitespace l) (cond @@ -207,7 +217,7 @@ (loop (cdr l))))) (define (decode l) - (decode-part l #f #f 0)) + (decode-part l null #f 0)) (define (decode-paragraph l) (make-paragraph diff --git a/collects/scribble/defreader.ss b/collects/scribble/defreader.ss index e41feb7574..2332be627e 100644 --- a/collects/scribble/defreader.ss +++ b/collects/scribble/defreader.ss @@ -19,6 +19,6 @@ (string->symbol (path->string (path-replace-suffix name #"")))) 'page)] [id 'doc]) - `(module ,name mzscheme + `(module ,name (lib "lang.ss" "big") . ,body)))) diff --git a/collects/scribble/doclang.ss b/collects/scribble/doclang.ss index 31eb64b04b..61df31a4ba 100644 --- a/collects/scribble/doclang.ss +++ b/collects/scribble/doclang.ss @@ -43,7 +43,8 @@ (kernel-form-identifier-list #'here) (syntax->list #'(provide require - require-for-syntax))))]) + require-for-syntax + require-for-label))))]) (syntax-case expanded (begin) [(begin body1 ...) #`(doc-begin m-id exprs body1 ... . body)] @@ -53,6 +54,7 @@ (syntax->list #'(require provide require-for-syntax + require-for-label define-values define-syntaxes define-for-syntaxes)))) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index 1e04b7b4dd..f4ce24ebe0 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -5,6 +5,8 @@ (lib "file.ss") (lib "list.ss") (lib "runtime-path.ss") + (lib "main-doc.ss" "setup") + (lib "main-collects.ss" "setup") (prefix xml: (lib "xml.ss" "xml"))) (provide render-mixin render-multi-mixin) @@ -15,12 +17,25 @@ (define current-subdirectory (make-parameter #f)) (define current-output-file (make-parameter #f)) + (define current-top-part (make-parameter #f)) (define on-separate-page (make-parameter #t)) (define next-separate-page (make-parameter #f)) (define collecting-sub (make-parameter 0)) (define current-no-links (make-parameter #f)) (define extra-breaking? (make-parameter #f)) + (define (path->relative p) + (let ([p (path->main-doc-relative p)]) + (if (path? p) + (path->main-collects-relative p) + p))) + + (define (relative->path p) + (let ([p (main-doc-relative->path p)]) + (if (path? p) + p + (main-collects-relative->path p)))) + ;; ---------------------------------------- ;; main mixin @@ -33,58 +48,57 @@ get-dest-directory format-number strip-aux - lookup quiet-table-of-contents) (define/override (get-suffix) #".html") ;; ---------------------------------------- - (define/override (collect ds fns) - (let ([ht (make-hash-table 'equal)]) - (map (lambda (d fn) - (parameterize ([current-output-file fn]) - (collect-part d #f ht null))) - ds - fns) - ht)) + (define/override (start-collect ds fns ci) + (map (lambda (d fn) + (parameterize ([current-output-file fn] + [current-top-part d]) + (collect-part d #f ci null))) + ds + fns)) - (define/public (part-whole-page? p ht) - (let ([dest (lookup p ht `(part ,(car (part-tags p))))]) + (define/public (part-whole-page? p ri) + (let ([dest (resolve-get p ri (car (part-tags p)))]) (caddr dest))) - (define/public (current-part-whole-page?) - #f) + (define/public (current-part-whole-page? d) + (eq? d (current-top-part))) - (define/override (collect-part-tags d ht number) + (define/override (collect-part-tags d ci number) (for-each (lambda (t) - (hash-table-put! ht - `(part ,t) - (list (current-output-file) - (part-title-content d) - (current-part-whole-page?)))) + (let ([key (generate-tag t ci)]) + (collect-put! ci + key + (list (path->relative (current-output-file)) + (or (part-title-content d) + '("???")) + (current-part-whole-page? d) + (format "~a" key))))) (part-tags d))) - (define/override (collect-target-element i ht) - (hash-table-put! ht - (target-element-tag i) - (list (current-output-file) - #f - (page-target-element? i)))) - + (define/override (collect-target-element i ci) + (let ([key (generate-tag (target-element-tag i) ci)]) + (collect-put! ci + key + (list (path->relative (current-output-file)) + #f + (page-target-element? i) + (format "~a" key))))) + ;; ---------------------------------------- (define/private (reveal-subparts? p) - (and (styled-part? p) - (let ([s (styled-part-style p)]) - (or (eq? s 'reveal) - (and (list? s) - (memq 'reveal s)))))) - - (define/public (render-toc-view d ht) + (part-style? p 'reveal)) + + (define/public (render-toc-view d ri) (let-values ([(top mine) (let loop ([d d][mine d]) - (let ([p (collected-info-parent (part-collected-info d))]) + (let ([p (collected-info-parent (part-collected-info d ri))]) (if p (loop p (if (reveal-subparts? d) mine @@ -95,7 +109,7 @@ (div ((class "tocviewtitle")) (a ((href "index.html") (class "tocviewlink")) - ,@(render-content (part-title-content top) d ht))) + ,@(render-content (or (part-title-content top) '("???")) d ri))) (div nbsp) (table ((class "tocviewlist") @@ -107,24 +121,24 @@ (td ((align "right")) ,@(if show-number? - (format-number (collected-info-number (part-collected-info p)) + (format-number (collected-info-number (part-collected-info p ri)) '((tt nbsp))) '("-" nbsp))) (td - (a ((href ,(let ([dest (lookup p ht `(part ,(car (part-tags p))))]) + (a ((href ,(let ([dest (resolve-get p ri (car (part-tags p)))]) (format "~a~a~a" - (from-root (car dest) + (from-root (relative->path (car dest)) (get-dest-directory)) (if (caddr dest) "" "#") (if (caddr dest) "" - `(part ,(car (part-tags p))))))) + (cadddr dest))))) (class ,(if (eq? p mine) "tocviewselflink" "tocviewlink"))) - ,@(render-content (part-title-content p) d ht)))))) + ,@(render-content (or (part-title-content p) '("???")) d ri)))))) (let loop ([l (map (lambda (v) (cons v #t)) (part-parts top))]) (cond [(null? l) null] @@ -133,92 +147,101 @@ (part-parts (caar l))) (cdr l))))] [else (cons (car l) (loop (cdr l)))]))))) - ,@(if (ormap (lambda (p) (part-whole-page? p ht)) (part-parts d)) - null - (let ([ps (cdr - (let flatten ([d d]) - (cons d - (apply - append - (letrec ([flow-targets - (lambda (flow) - (apply append (map flow-element-targets (flow-paragraphs flow))))] - [flow-element-targets - (lambda (e) - (cond - [(table? e) (table-targets e)] - [(paragraph? e) (para-targets e)] - [(itemization? e) - (apply append (map flow-targets (itemization-flows e)))] - [(blockquote? e) - (apply append (map flow-element-targets (blockquote-paragraphs e)))] - [(delayed-flow-element? e) - null]))] - [para-targets - (lambda (para) - (let loop ([c (paragraph-content para)]) - (cond - [(empty? c) null] - [else (let ([a (car c)]) - (cond - [(toc-target-element? a) - (cons a (loop (cdr c)))] - [(element? a) - (append (loop (element-content a)) - (loop (cdr c)))] - [(delayed-element? a) - (loop (cons (force-delayed-element a this d ht) - (cdr c)))] - [else - (loop (cdr c))]))])))] - [table-targets - (lambda (table) - (apply append - (map (lambda (flows) - (apply append (map (lambda (f) - (if (eq? f 'cont) - null - (flow-targets f))) - flows))) - (table-flowss table))))]) - (apply append (map flow-element-targets (flow-paragraphs (part-flow d))))) - (map flatten (part-parts d))))))]) - (if (null? ps) - null - `((div ((class "tocsub")) - (div ((class "tocsubtitle")) - "On this page:") - (table - ((class "tocsublist") - (cellspacing "0")) - ,@(map (lambda (p) - (parameterize ([current-no-links #t] - [extra-breaking? #t]) - `(tr - (td - ,@(if (part? p) - `((span ((class "tocsublinknumber")) - ,@(format-number (collected-info-number (part-collected-info p)) - '((tt nbsp))))) - '("")) - (a ((href ,(if (part? p) - (let ([dest (lookup p ht `(part ,(car (part-tags p))))]) - (format "#~a" - `(part ,(car (part-tags p))))) - (format "#~a" (target-element-tag p)))) - (class ,(if (part? p) - "tocsubseclink" - "tocsublink"))) - ,@(if (part? p) - (render-content (part-title-content p) d ht) - (render-content (element-content p) d ht))))))) - ps))))))) + ,@(render-onthispage-contents d ri top) ,@(apply append (map (lambda (t) - (render-table t d ht)) + (render-table t d ri)) (filter auxiliary-table? (flow-paragraphs (part-flow d))))))))) - (define/public (render-one-part d ht fn number) + (define/private (render-onthispage-contents d ri top) + (if (ormap (lambda (p) (part-whole-page? p ri)) + (part-parts d)) + null + (let* ([nearly-top? (lambda (d) + (eq? top (collected-info-parent (part-collected-info d ri))))] + [ps ((if (nearly-top? d) values cdr) + (let flatten ([d d]) + (apply + append + ;; don't include the section if it's in the TOC + (if (nearly-top? d) + null + (list d)) + ;; get internal targets: + (letrec ([flow-targets + (lambda (flow) + (apply append (map flow-element-targets (flow-paragraphs flow))))] + [flow-element-targets + (lambda (e) + (cond + [(table? e) (table-targets e)] + [(paragraph? e) (para-targets e)] + [(itemization? e) + (apply append (map flow-targets (itemization-flows e)))] + [(blockquote? e) + (apply append (map flow-element-targets (blockquote-paragraphs e)))] + [(delayed-flow-element? e) + null]))] + [para-targets + (lambda (para) + (let loop ([c (paragraph-content para)]) + (cond + [(empty? c) null] + [else (let ([a (car c)]) + (cond + [(toc-target-element? a) + (cons a (loop (cdr c)))] + [(element? a) + (append (loop (element-content a)) + (loop (cdr c)))] + [(delayed-element? a) + (loop (cons (delayed-element-content a ri) + (cdr c)))] + [else + (loop (cdr c))]))])))] + [table-targets + (lambda (table) + (apply append + (map (lambda (flows) + (apply append (map (lambda (f) + (if (eq? f 'cont) + null + (flow-targets f))) + flows))) + (table-flowss table))))]) + (apply append (map flow-element-targets (flow-paragraphs (part-flow d))))) + (map flatten (part-parts d)))))]) + (if (null? ps) + null + `((div ((class "tocsub")) + (div ((class "tocsubtitle")) + "On this page:") + (table + ((class "tocsublist") + (cellspacing "0")) + ,@(map (lambda (p) + (parameterize ([current-no-links #t] + [extra-breaking? #t]) + `(tr + (td + ,@(if (part? p) + `((span ((class "tocsublinknumber")) + ,@(format-number (collected-info-number + (part-collected-info p ri)) + '((tt nbsp))))) + '("")) + (a ((href ,(if (part? p) + (format "#~a" (tag-key (car (part-tags p)) ri)) + (format "#~a" (tag-key (target-element-tag p) ri)))) + (class ,(if (part? p) + "tocsubseclink" + "tocsublink"))) + ,@(if (part? p) + (render-content (or (part-title-content p) '("???")) d ri) + (render-content (element-content p) d ri))))))) + ps)))))))) + + (define/public (render-one-part d ri fn number) (parameterize ([current-output-file fn]) (let ([xpr `(html () (head @@ -226,32 +249,28 @@ (content "text-html; charset=utf-8"))) ,@(let ([c (part-title-content d)]) (if c - `((title ,@(format-number number '(nbsp)) ,(content->string c this d ht))) + `((title ,@(format-number number '(nbsp)) ,(content->string c this d ri))) null)) (link ((rel "stylesheet") (type "text/css") (href "scribble.css") (title "default")))) - (body ,@(render-toc-view d ht) - (div ((class "main")) ,@(render-part d ht))))]) + (body ,@(render-toc-view d ri) + (div ((class "main")) ,@(render-part d ri))))]) (install-file scribble-css) (xml:write-xml/content (xml:xexpr->xml xpr))))) - (define/override (render-one d ht fn) - (render-one-part d ht fn null)) + (define/override (render-one d ri fn) + (render-one-part d ri fn null)) - (define/override (render-part d ht) - (let ([number (collected-info-number (part-collected-info d))]) + (define/override (render-part d ri) + (let ([number (collected-info-number (part-collected-info d ri))]) `(,@(if (and (not (part-title-content d)) (null? number)) null - (if (and (styled-part? d) - (let ([s (styled-part-style d)]) - (or (eq? s 'hidden) - (and (list? s) - (memq 'hidden s))))) + (if (part-style? d 'hidden) (map (lambda (t) - `(a ((name ,(format "~a" `(part ,t)))))) + `(a ((name ,(format "~a" (tag-key t ri)))))) (part-tags d)) `((,(case (length number) [(0) 'h2] @@ -260,21 +279,21 @@ [else 'h5]) ,@(format-number number '((tt nbsp))) ,@(map (lambda (t) - `(a ((name ,(format "~a" `(part ,t)))))) + `(a ((name ,(format "~a" (tag-key t ri)))))) (part-tags d)) ,@(if (part-title-content d) - (render-content (part-title-content d) d ht) + (render-content (part-title-content d) d ri) null))))) - ,@(render-flow* (part-flow d) d ht #f) + ,@(render-flow* (part-flow d) d ri #f) ,@(let loop ([pos 1] [secs (part-parts d)]) (if (null? secs) null (append - (render-part (car secs) ht) + (render-part (car secs) ri) (loop (add1 pos) (cdr secs)))))))) - (define/private (render-flow* p part ht special-last?) + (define/private (render-flow* p part ri special-last?) ;; Wrap each table with

, except for a trailing table ;; when `special-last?' is #t (let loop ([f (flow-paragraphs p)]) @@ -283,71 +302,78 @@ [(and (table? (car f)) (or (not special-last?) (not (null? (cdr f))))) - (cons `(p ,@(render-flow-element (car f) part ht)) + (cons `(p ,@(render-flow-element (car f) part ri)) (loop (cdr f)))] [else - (append (render-flow-element (car f) part ht) + (append (render-flow-element (car f) part ri) (loop (cdr f)))]))) - (define/override (render-flow p part ht) - (render-flow* p part ht #t)) + (define/override (render-flow p part ri) + (render-flow* p part ri #t)) - (define/override (render-paragraph p part ht) + (define/override (render-paragraph p part ri) `((p ,@(if (styled-paragraph? p) `(((class ,(styled-paragraph-style p)))) null) - ,@(super render-paragraph p part ht)))) + ,@(super render-paragraph p part ri)))) - (define/override (render-element e part ht) + (define/override (render-element e part ri) (cond + [(hover-element? e) + `((span ((title ,(hover-element-text e))) ,@(render-plain-element e part ri)))] [(target-element? e) - `((a ((name ,(target-element-tag e)))) - ,@(render-plain-element e part ht))] + `((a ((name ,(format "~a" (tag-key (target-element-tag e) ri))))) + ,@(render-plain-element e part ri))] [(and (link-element? e) (not (current-no-links))) (parameterize ([current-no-links #t]) - (let ([dest (lookup part ht (link-element-tag e))]) + (let ([dest (resolve-get part ri (link-element-tag e))]) (if dest `((a ((href ,(format "~a~a~a" - (from-root (car dest) + (from-root (relative->path (car dest)) (get-dest-directory)) (if (caddr dest) "" "#") (if (caddr dest) "" - (link-element-tag e)))) + (cadddr dest)))) ,@(if (string? (element-style e)) `((class ,(element-style e))) null)) ,@(if (null? (element-content e)) - (render-content (strip-aux (cadr dest)) part ht) - (render-content (element-content e) part ht)))) - (begin (fprintf (current-error-port) "Undefined link: ~s~n" (link-element-tag e)) ; XXX Add source info - `((font ((class "badlink")) - ,@(if (null? (element-content e)) - `(,(format "~s" (link-element-tag e))) - (render-plain-element e part ht))))))))] - [else (render-plain-element e part ht)])) + (render-content (strip-aux (cadr dest)) part ri) + (render-content (element-content e) part ri)))) + (begin + (when #f + (fprintf (current-error-port) + "Undefined link: ~s~n" + (tag-key (link-element-tag e) ri))) + `((font ((class "badlink")) + ,@(if (null? (element-content e)) + `(,(format "~s" (tag-key (link-element-tag e) ri))) + (render-plain-element e part ri))))))))] + [else (render-plain-element e part ri)])) - (define/private (render-plain-element e part ht) + (define/private (render-plain-element e part ri) (let ([style (and (element? e) (element-style e))]) (cond [(symbol? style) (case style - [(italic) `((i ,@(super render-element e part ht)))] - [(bold) `((b ,@(super render-element e part ht)))] - [(tt) `((tt ,@(super render-element e part ht)))] - [(sf) `((b (font ([size "-1"][face "Helvetica"]) ,@(super render-element e part ht))))] - [(subscript) `((sub ,@(super render-element e part ht)))] - [(superscript) `((sup ,@(super render-element e part ht)))] + [(italic) `((i ,@(super render-element e part ri)))] + [(bold) `((b ,@(super render-element e part ri)))] + [(tt) `((tt ,@(super render-element e part ri)))] + [(no-break) `((span ([class "nobreak"]) ,@(super render-element e part ri)))] + [(sf) `((b (font ([size "-1"][face "Helvetica"]) ,@(super render-element e part ri))))] + [(subscript) `((sub ,@(super render-element e part ri)))] + [(superscript) `((sup ,@(super render-element e part ri)))] [(hspace) `((span ([class "hspace"]) ,@(let ([str (content->string (element-content e))]) (map (lambda (c) 'nbsp) (string->list str)))))] [else (error 'html-render "unrecognized style symbol: ~e" style)])] [(string? style) - `((span ([class ,style]) ,@(super render-element e part ht)))] + `((span ([class ,style]) ,@(super render-element e part ri)))] [(and (pair? style) (eq? (car style) 'show-color)) `((font ((style ,(format "background-color: ~a" @@ -357,16 +383,16 @@ (cdr style)))))) (tt nbsp nbsp nbsp nbsp nbsp)) nbsp - ,@(super render-element e part ht))] + ,@(super render-element e part ri))] [(target-url? style) (if (current-no-links) - (super render-element e part ht) + (super render-element e part ri) (parameterize ([current-no-links #t]) - `((a ((href ,(target-url-addr style))) ,@(super render-element e part ht)))))] + `((a ((href ,(target-url-addr style))) ,@(super render-element e part ri)))))] [(image-file? style) `((img ((src ,(install-file (image-file-path style))))))] - [else (super render-element e part ht)]))) + [else (super render-element e part ri)]))) - (define/override (render-table t part ht) + (define/override (render-table t part ri) `((table ((cellspacing "0") ,@(case (table-style t) [(boxed) '((class "boxed"))] @@ -423,36 +449,36 @@ [(eq? 'cont (car ds)) (loop (+ n 1) (cdr ds))] [else n]))))) null)) - ,@(render-flow d part ht)) + ,@(render-flow d part ri)) (loop (cdr ds) (cdr as) (cdr vas))))))))) (table-flowss t) (cdr (or (and (list? (table-style t)) (assoc 'row-styles (or (table-style t) null))) (cons #f (map (lambda (x) #f) (table-flowss t))))))))) - (define/override (render-blockquote t part ht) + (define/override (render-blockquote t part ri) `((blockquote ,@(if (string? (blockquote-style t)) `(((class ,(blockquote-style t)))) null) ,@(apply append (map (lambda (i) - (render-flow-element i part ht)) + (render-flow-element i part ri)) (blockquote-paragraphs t)))))) - (define/override (render-itemization t part ht) + (define/override (render-itemization t part ri) `((ul ,@(map (lambda (flow) - `(li ,@(render-flow flow part ht))) + `(li ,@(render-flow flow part ri))) (itemization-flows t))))) - (define/override (render-other i part ht) + (define/override (render-other i part ri) (cond [(string? i) (let ([m (and (extra-breaking?) (regexp-match-positions #rx":" i))]) (if m (list* (substring i 0 (cdar m)) `(span ((class "mywbr")) " ") - (render-other (substring i (cdar m)) part ht)) + (render-other (substring i (cdar m)) part ri)) (list i)))] [(eq? i 'mdash) `(" " ndash " ")] [(eq? i 'hline) `((hr))] @@ -470,7 +496,9 @@ (class % (inherit render-one render-one-part - render-content) + render-content + part-whole-page? + format-number) (define/override (get-suffix) #"") @@ -479,10 +507,16 @@ (current-subdirectory)) (super get-dest-directory))) - (define/private (derive-filename d ht) + (define/private (derive-filename d) (let ([fn (format "~a.html" (regexp-replace* "[^-a-zA-Z0-9_=]" - (format "~a" (car (part-tags d))) + (let ([s (cadr (car (part-tags d)))]) + (if (string? s) + s + (if (part-title-content d) + (content->string (part-title-content d)) + ;; last-ditch effort to make up a unique name: + (format "???~a" (eq-hash-code d))))) "_"))]) (when ((string-length fn) . >= . 48) (error "file name too long (need a tag):" fn)) @@ -493,28 +527,25 @@ (build-path fn "index.html")) fns))) - (define/override (current-part-whole-page?) + (define/override (current-part-whole-page? d) ((collecting-sub) . <= . 2)) (define/private (toc-part? d) - (and (styled-part? d) - (let ([st (styled-part-style d)]) - (or (eq? 'toc st) - (and (list? st) (memq 'toc st)))))) + (part-style? d 'toc)) - (define/override (collect-part d parent ht number) + (define/override (collect-part d parent ci number) (let ([prev-sub (collecting-sub)]) (parameterize ([collecting-sub (if (toc-part? d) 1 (add1 prev-sub))]) (if (= 1 prev-sub) - (let ([filename (derive-filename d ht)]) + (let ([filename (derive-filename d)]) (parameterize ([current-output-file (build-path (path-only (current-output-file)) filename)]) - (super collect-part d parent ht number))) - (super collect-part d parent ht number))))) + (super collect-part d parent ci number))) + (super collect-part d parent ci number))))) - (define/override (render ds fns ht) + (define/override (render ds fns ri) (map (lambda (d fn) (printf " [Output to ~a/index.html]\n" fn) (unless (directory-exists? fn) @@ -523,7 +554,7 @@ (let ([fn (build-path fn "index.html")]) (with-output-to-file fn (lambda () - (render-one d ht fn)) + (render-one d ri fn)) 'truncate/replace)))) ds fns)) @@ -538,8 +569,8 @@ (inherit render-table) - (define/private (find-siblings d) - (let ([parent (collected-info-parent (part-collected-info d))]) + (define/private (find-siblings d ri) + (let ([parent (collected-info-parent (part-collected-info d ri))]) (let loop ([l (if parent (part-parts parent) (if (null? (part-parts d)) @@ -552,12 +583,12 @@ (cadr l)))] [else (loop (cdr l) (car l))])))) - (define/private (part-parent d) - (collected-info-parent (part-collected-info d))) + (define/private (part-parent d ri) + (collected-info-parent (part-collected-info d ri))) - (define/private (navigation d ht) - (let ([parent (part-parent d)]) - (let*-values ([(prev next) (find-siblings d)] + (define/private (navigation d ri) + (let ([parent (part-parent d ri)]) + (let*-values ([(prev next) (find-siblings d ri)] [(prev) (if prev (let loop ([prev prev]) (if (and (toc-part? prev) @@ -575,17 +606,17 @@ parent (toc-part? parent)) (let-values ([(prev next) - (find-siblings parent)]) + (find-siblings parent ri)]) next)] [else next])] [(index) (let loop ([d d]) - (let ([p (part-parent d)]) + (let ([p (part-parent d ri)]) (if p (loop p) (let ([subs (part-parts d)]) (and (pair? subs) (let ([d (car (last-pair subs))]) - (and (equal? '("Index") (part-title-content d)) + (and (part-style? d 'index) d)))))))]) `(,@(render-table (make-table 'at-left @@ -614,9 +645,9 @@ (make-link-element #f index-content - `(part ,(car (part-tags index)))))))))) + (car (part-tags index))))))))) null)))) - d ht) + d ri) ,@(render-table (make-table 'at-right (list @@ -628,7 +659,7 @@ (make-element (if parent (make-target-url (if prev - (derive-filename prev ht) + (derive-filename prev) "index.html")) "nonavigation") prev-content) @@ -637,34 +668,34 @@ (if parent (make-target-url (if (toc-part? parent) - (derive-filename parent ht) + (derive-filename parent) "index.html")) "nonavigation") up-content) sep-element (make-element (if next - (make-target-url (derive-filename next ht)) + (make-target-url (derive-filename next)) "nonavigation") next-content)))))))) d - ht))))) + ri))))) - (define/override (render-part d ht) - (let ([number (collected-info-number (part-collected-info d))]) + (define/override (render-part d ri) + (let ([number (collected-info-number (part-collected-info d ri))]) (cond [(and (not (on-separate-page)) (or (= 1 (length number)) (next-separate-page))) ;; Render as just a link, and put the actual ;; content in a new file: - (let* ([filename (derive-filename d ht)] + (let* ([filename (derive-filename d)] [full-path (build-path (path-only (current-output-file)) filename)]) (parameterize ([on-separate-page #t]) (with-output-to-file full-path (lambda () - (render-one-part d ht full-path number)) + (render-one-part d ri full-path number)) 'truncate/replace) null))] [else @@ -673,14 +704,14 @@ [on-separate-page #f]) (if sep? ;; Navigation bars; - `(,@(navigation d ht) + `(,@(navigation d ri) (p nbsp) - ,@(super render-part d ht) + ,@(super render-part d ri) (p nbsp) - ,@(navigation d ht) + ,@(navigation d ri) (p nbsp)) ;; Normal section render - (super render-part d ht))))]))) + (super render-part d ri))))]))) (super-new))) diff --git a/collects/scribble/latex-render.ss b/collects/scribble/latex-render.ss index c439a1b3ab..57dcc9bc2b 100644 --- a/collects/scribble/latex-render.ss +++ b/collects/scribble/latex-render.ss @@ -18,13 +18,12 @@ render-flow-element render-content install-file - format-number - lookup) + format-number) (define (define-color s s2) (printf "\\newcommand{\\~a}[1]{{\\mytexttt{\\color{~a}{#1}}}}\n" s s2)) - (define/override (render-one d ht fn) + (define/override (render-one d ri fn) (printf "\\documentclass{article}\n") (printf "\\parskip=10pt%\n") (printf "\\parindent=0pt%\n") @@ -75,17 +74,16 @@ (printf "\\begin{document}\n\\sloppy\n") (when (part-title-content d) (printf "\\title{") - (render-content (part-title-content d) d ht) + (render-content (part-title-content d) d ri) (printf "}\\maketitle\n")) - (render-part d ht) + (render-part d ri) (printf "\\end{document}\n")) - (define/override (render-part d ht) - (let ([number (collected-info-number (part-collected-info d))]) + (define/override (render-part d ri) + (let ([number (collected-info-number (part-collected-info d ri))]) (when (and (part-title-content d) (pair? number)) - (when (and (styled-part? d) - (eq? 'index (styled-part-style d))) + (when (part-style? d 'index) (printf "\\twocolumn\n\\parskip=0pt\n\\addcontentsline{toc}{section}{Index}\n")) (printf "\\~a~a{" (case (length number) @@ -97,20 +95,19 @@ (not (car number))) "*" "")) - (render-content (part-title-content d) d ht) + (render-content (part-title-content d) d ri) (printf "}") - (when (and (styled-part? d) - (eq? 'index (styled-part-style d))) + (when (part-style? d 'index) (printf "\n\n"))) (for-each (lambda (t) - (printf "\\label{t:~a}" (t-encode `(part ,t)))) + (printf "\\label{t:~a}" (t-encode (tag-key t ri)))) (part-tags d)) - (render-flow (part-flow d) d ht) - (for-each (lambda (sec) (render-part sec ht)) + (render-flow (part-flow d) d ri) + (for-each (lambda (sec) (render-part sec ri)) (part-parts d)) null)) - (define/override (render-paragraph p part ht) + (define/override (render-paragraph p part ri) (printf "\n\n") (let ([margin? (and (styled-paragraph? p) (equal? "refpara" (styled-paragraph-style p)))]) @@ -118,28 +115,35 @@ (printf "\\marginpar{\\footnotesize ")) (if (toc-paragraph? p) (printf "\\newpage \\tableofcontents \\newpage") - (super render-paragraph p part ht)) + (super render-paragraph p part ri)) (when margin? (printf "}"))) (printf "\n\n") null) - (define/override (render-element e part ht) + (define/override (render-element e part ri) (let ([part-label? (and (link-element? e) (pair? (link-element-tag e)) (eq? 'part (car (link-element-tag e))) (null? (element-content e)))]) (parameterize ([show-link-page-numbers #f]) (when (target-element? e) - (printf "\\label{t:~a}" (t-encode (target-element-tag e)))) + (printf "\\label{t:~a}" (t-encode (tag-key (target-element-tag e) ri)))) (when part-label? (printf "\\S") - (render-content (let ([dest (lookup part ht (link-element-tag e))]) + (render-content (let ([dest (resolve-get part ri (link-element-tag e))]) (if dest - (format-number (cadr dest) null) + (if (list? (cadr dest)) + (format-number (cadr dest) null) + (begin + (fprintf (current-error-port) + "Internal tag error: ~s -> ~s\n" + (link-element-tag e) + dest) + '("!!!"))) (list "???"))) part - ht) + ri) (printf " ``")) (let ([style (and (element? e) (element-style e))] @@ -147,7 +151,7 @@ (printf "{\\~a{" s) (parameterize ([rendering-tt (or tt? (rendering-tt))]) - (super render-element e part ht)) + (super render-element e part ri)) (printf "}}"))]) (cond [(symbol? style) @@ -155,6 +159,7 @@ [(italic) (wrap e "textit" #f)] [(bold) (wrap e "textbf" #f)] [(tt) (wrap e "mytexttt" #t)] + [(nobreak) (super render-element e part ri)] [(sf) (wrap e "textsf" #f)] [(subscript) (wrap e "textsub" #f)] [(superscript) (wrap e "textsuper" #f)] @@ -170,12 +175,12 @@ [(image-file? style) (let ([fn (install-file (image-file-path style))]) (printf "\\includegraphics{~a}" fn))] - [else (super render-element e part ht)]))) + [else (super render-element e part ri)]))) (when part-label? (printf "''")) (when (and (link-element? e) (show-link-page-numbers)) - (printf ", \\pageref{t:~a}" (t-encode (link-element-tag e)))) + (printf ", \\pageref{t:~a}" (t-encode (tag-key (link-element-tag e) ri)))) null)) (define/private (t-encode s) @@ -192,7 +197,7 @@ (format "x~x" (char->integer c))])) (string->list (format "~s" s))))) - (define/override (render-table t part ht) + (define/override (render-table t part ri) (let* ([boxed? (eq? 'boxed (table-style t))] [index? (eq? 'index (table-style t))] [inline? (and (not boxed?) @@ -262,7 +267,7 @@ [else n]))]) (unless (= cnt 1) (printf "\\multicolumn{~a}{l}{" cnt)) - (render-flow (car flows) part ht) + (render-flow (car flows) part ri) (unless (= cnt 1) (printf "}")) (unless (null? (list-tail flows cnt)) @@ -284,25 +289,25 @@ "")))))) null) - (define/override (render-itemization t part ht) + (define/override (render-itemization t part ri) (printf "\n\n\\begin{itemize}\n") (for-each (lambda (flow) (printf "\n\n\\item ") - (render-flow flow part ht)) + (render-flow flow part ri)) (itemization-flows t)) (printf "\n\n\\end{itemize}\n") null) - (define/override (render-blockquote t part ht) + (define/override (render-blockquote t part ri) (printf "\n\n\\begin{quote}\n") (parameterize ([current-table-mode (list "blockquote" t)]) (for-each (lambda (e) - (render-flow-element e part ht)) + (render-flow-element e part ri)) (blockquote-paragraphs t))) (printf "\n\n\\end{quote}\n") null) - (define/override (render-other i part ht) + (define/override (render-other i part ri) (cond [(string? i) (display-protected i)] [(symbol? i) (display @@ -362,11 +367,11 @@ ;; ---------------------------------------- - (define/override (table-of-contents sec ht) + (define/override (table-of-contents sec ri) ;; FIXME: isn't local to the section (make-toc-paragraph null)) - (define/override (local-table-of-contents part ht) + (define/override (local-table-of-contents part ri) (make-paragraph null)) ;; ---------------------------------------- diff --git a/collects/scribble/manual.ss b/collects/scribble/manual.ss index 2833ca2bca..29e177086f 100644 --- a/collects/scribble/manual.ss +++ b/collects/scribble/manual.ss @@ -10,6 +10,8 @@ (lib "class.ss") (lib "stxparam.ss")) (require-for-syntax (lib "stxparam.ss")) + (require-for-label (lib "lang.ss" "big") + (lib "class.ss")) (provide (all-from "basic.ss")) @@ -50,10 +52,24 @@ (define (to-element/id s) (make-element "schemesymbol" (list (to-element/no-color s)))) - (define (keep-s-expr ctx s v) + (define-syntax (keep-s-expr stx) + (syntax-case stx () + [(_ ctx s srcloc) + (let ([sv (syntax-e #'s)]) + (if (or (number? sv) + (boolean? sv) + (and (pair? sv) + (identifier? (car sv)) + (module-identifier=? #'cons (car sv)))) + ;; We know that the context is irrelvant + #'s + ;; Context may be relevant: + #'(*keep-s-expr s ctx)))])) + (define (*keep-s-expr s ctx) (if (symbol? s) (make-just-context s ctx) s)) + (define (add-sq-prop s name val) (if (eq? name 'paren-shape) (make-shaped-parens s val) @@ -158,9 +174,9 @@ (define (exec . str) (make-element 'tt (decode-content str))) (define (Flag . str) - (make-element 'tt (cons "-" (decode-content str)))) + (make-element 'no-break (list (make-element 'tt (cons "-" (decode-content str)))))) (define (DFlag . str) - (make-element 'tt (cons "--" (decode-content str)))) + (make-element 'no-break (list (make-element 'tt (cons "--" (decode-content str)))))) (define (envvar . str) (make-element 'tt (decode-content str))) (define (indexed-envvar . str) @@ -198,9 +214,8 @@ (elem (method a b) " in " (scheme a))])) (define (*method sym id) - (let ([tag (format "~a::~a" - (register-scheme-definition id) - sym)]) + (let ([tag (method-tag (register-scheme-definition id #t) + sym)]) (make-element "schemesymbol" (list (make-link-element @@ -208,6 +223,9 @@ (list (symbol->string sym)) tag))))) + (define (method-tag vtag sym) + (list 'meth + (format "~a::~a" (cadr vtag) sym))) ;; ---------------------------------------- @@ -222,7 +240,7 @@ (provide deftech tech techlink) - (define (*tech make-elem style s) + (define (*tech make-elem style doc s) (let* ([c (decode-content s)] [s (regexp-replace* #px"[-\\s]+" (regexp-replace @@ -235,26 +253,27 @@ " ")]) (make-elem style c - (format "tech-term:~a" s)))) + (list 'tech (doc-prefix doc s))))) (define (deftech . s) (let* ([e (apply defterm s)] - [t (*tech make-target-element #f (list e))]) + [t (*tech make-target-element #f #f (list e))]) (make-index-element #f (list t) (target-element-tag t) (list (element->string e)) (list e)))) - (define (tech . s) - (*tech make-link-element "techlink" s)) + (define (tech #:doc [doc #f] . s) + (*tech make-link-element "techlink" doc s)) - (define (techlink . s) - (*tech make-link-element #f s)) + (define (techlink #:doc [doc #f] . s) + (*tech make-link-element #f doc s)) ;; ---------------------------------------- - (provide defproc defproc* defstruct defthing defparam defboolparam + (provide declare-exporting + defproc defproc* defstruct defthing defparam defboolparam defform defform* defform/subs defform*/subs defform/none defidform specform specform/subs @@ -262,6 +281,33 @@ schemegrammar schemegrammar* var svar void-const undefined-const) + (define-syntax declare-exporting + (syntax-rules () + [(_ lib ...) (*declare-exporting '(lib ...))])) + + (define (*declare-exporting libs) + (make-part-collect-decl + (make-collect-element #f + null + (lambda (ri) + (collect-put! ri '(exporting-libraries #f)libs))))) + + (define-syntax (quote-syntax/loc stx) + (syntax-case stx () + [(_ id) + (with-syntax ([loc + (let ([s #'id]) + (list (syntax-source s) + (syntax-line s) + (syntax-column s) + (syntax-position s) + (syntax-span s)))]) + #'(let ([s (quote-syntax id)]) + (datum->syntax-object s + (syntax-e s) + 'loc + s)))])) + (define void-const (schemeresultfont "#")) (define undefined-const @@ -304,13 +350,13 @@ (syntax-rules () [(_ (id arg ...) result desc ...) (defproc* [[(id arg ...) result]] desc ...)])) - (define-syntax defproc* + (define-syntax defproc* (syntax-rules () [(_ [[(id arg ...) result] ...] desc ...) (defproc* #:mode procedure #:within #f [[(id arg ...) result] ...] desc ...)] [(_ #:mode m #:within cl [[(id arg ...) result] ...] desc ...) - (*defproc 'm (quote-syntax cl) - (list (quote-syntax id) ...) + (*defproc 'm (quote-syntax/loc cl) + (list (quote-syntax/loc id) ...) '[(id arg ...) ...] (list (list (lambda () (arg-contract arg)) ...) ...) (list (lambda () (schemeblock0 result)) ...) @@ -328,7 +374,7 @@ (define-syntax **defstruct (syntax-rules () [(_ name ([field field-contract] ...) immutable? transparent? desc ...) - (*defstruct (quote-syntax name) 'name + (*defstruct (quote-syntax/loc name) 'name '([field field-contract] ...) (list (lambda () (schemeblock0 field-contract)) ...) #t #t (lambda () (list desc ...)))])) (define-syntax (defform*/subs stx) @@ -347,7 +393,7 @@ [spec-id (syntax-case #'spec () [(name . rest) #'name])]) - #'(*defforms (quote-syntax spec-id) '(lit ...) + #'(*defforms (quote-syntax/loc spec-id) '(lit ...) '(spec spec1 ...) (list (lambda (x) (schemeblock0 new-spec)) (lambda (ignored) (schemeblock0 spec1)) ...) @@ -381,7 +427,7 @@ (define-syntax (defidform stx) (syntax-case stx () [(_ spec-id desc ...) - #'(*defforms (quote-syntax spec-id) null + #'(*defforms (quote-syntax/loc spec-id) null '(spec-id) (list (lambda (x) (make-paragraph (list x)))) null @@ -440,7 +486,7 @@ (define-syntax defthing (syntax-rules () [(_ id result desc ...) - (*defthing (quote-syntax id) 'id (quote-syntax result) (lambda () (list desc ...)))])) + (*defthing (quote-syntax/loc id) 'id (quote-syntax result) (lambda () (list desc ...)))])) (define-syntax defparam (syntax-rules () [(_ id arg contract desc ...) @@ -494,6 +540,27 @@ type-sym) "")))) + (define (annote-exporting-library e) + (make-delayed-element + (lambda (render p ri) + (let ([from (resolve-get p ri '(exporting-libraries #f))]) + (if (and from + (pair? from)) + (list (make-hover-element + #f + (list e) + (string-append + "Provided from: " + (let loop ([from from]) + (if (null? (cdr from)) + (format "~s" (car from)) + (format "~s, ~a" + (car from) + (loop (cdr from)))))))) + (list e)))) + (lambda () e) + (lambda () e))) + (define (*defproc mode within-id stx-ids prototypes arg-contractss result-contracts content-thunk) (let ([spacer (hspace 1)] @@ -589,34 +656,40 @@ (hspace 1) (if first? (let* ([mname (car prototype)] - [tag (format "~a::~a" - (register-scheme-definition within-id) - mname)] + [ctag (register-scheme-definition within-id #t)] + [tag (method-tag ctag mname)] [content (list (*method mname within-id))]) - (make-toc-target-element - #f - (list (make-index-element #f - content - tag - (list (symbol->string mname)) - content)) - tag)) + (if tag + (make-toc-target-element + #f + (list (make-index-element #f + content + tag + (list (symbol->string mname)) + content)) + tag) + (car content))) (*method (car prototype) within-id))))] [else (if first? - (let ([tag (register-scheme-definition stx-id)] - [content (list (to-element (make-just-context (car prototype) - stx-id)))]) - (make-toc-target-element - #f - (list (make-index-element #f - content - tag - (list (symbol->string (car prototype))) - content)) - tag)) - (to-element (make-just-context (car prototype) - stx-id)))])] + (let ([tag (register-scheme-definition stx-id #t)] + [content (list + (annote-exporting-library + (to-element (make-just-context (car prototype) + stx-id))))]) + (if tag + (make-toc-target-element + #f + (list (make-index-element #f + content + tag + (list (symbol->string (car prototype))) + content)) + tag) + (car content))) + (annote-exporting-library + (to-element (make-just-context (car prototype) + stx-id))))])] [(flat-size) (+ (prototype-size (cdr prototype) + +) (element-width tagged))] [(short?) (or (flat-size . < . 40) @@ -799,16 +872,19 @@ (register-scheme-definition (datum->syntax-object stx-id (string->symbol - name)))]) - (inner-make-target-element - #f - (list - (make-index-element #f - (list content) - tag - (list name) - (list (schemeidfont (make-element "schemevaluelink" (list name)))))) - tag)) + name)) + #t)]) + (if tag + (inner-make-target-element + #f + (list + (make-index-element #f + (list content) + tag + (list name) + (list (schemeidfont (make-element "schemevaluelink" (list name)))))) + tag) + content)) (cdr wrappers)))) (define (*defstruct stx-id name fields field-contracts immutable? transparent? content-thunk) @@ -826,9 +902,10 @@ (make-target-element* make-toc-target-element stx-id - (to-element (if (pair? name) - (make-just-context (car name) stx-id) - stx-id)) + (annote-exporting-library + (to-element (if (pair? name) + (make-just-context (car name) stx-id) + stx-id))) (let ([name (if (pair? name) (car name) name)]) @@ -975,16 +1052,19 @@ (list (make-flow (list (make-paragraph - (list (let ([tag (register-scheme-definition stx-id)] - [content (list (to-element (make-just-context name stx-id)))]) - (make-toc-target-element - #f - (list (make-index-element #f - content - tag - (list (symbol->string name)) - content)) - tag)) + (list (let ([tag (register-scheme-definition stx-id #t)] + [content (list (annote-exporting-library + (to-element (make-just-context name stx-id))))]) + (if tag + (make-toc-target-element + #f + (list (make-index-element #f + content + tag + (list (symbol->string name)) + content)) + tag) + (car content))) spacer ":" spacer (to-element result-contract)))))))) (content-thunk)))) @@ -1026,25 +1106,32 @@ (make-paragraph (list (to-element - `(,x - . ,(cdr form))))))) + `(,x . ,(cdr form))))))) (and kw-id (eq? form (car forms)) - (let ([tag (register-scheme-form-definition kw-id)] - [content (list (to-element (make-just-context (if (pair? form) - (car form) - form) - kw-id)))]) - (make-toc-target-element - #f - (if kw-id - (list (make-index-element #f - content - tag - (list (symbol->string (syntax-e kw-id))) - content)) - content) - tag)))))))) + (let ([tag (register-scheme-definition kw-id #t)] + [stag (register-scheme-form-definition kw-id)] + [content (list (annote-exporting-library + (to-element (make-just-context (if (pair? form) + (car form) + form) + kw-id))))]) + (if tag + (make-toc-target-element + #f + (list + (make-toc-target-element + #f + (if kw-id + (list (make-index-element #f + content + tag + (list (symbol->string (syntax-e kw-id))) + content)) + content) + tag)) + stag) + (car content))))))))) forms form-procs) (if (null? sub-procs) null @@ -1156,17 +1243,25 @@ (make-paragraph (list (hspace 2) (apply tt s)))) (define (elemtag t . body) - (make-target-element #f (decode-content body) t)) + (make-target-element #f (decode-content body) `(elem ,t))) (define (elemref t . body) - (make-link-element #f (decode-content body) t)) + (make-link-element #f (decode-content body) `(elem ,t))) (provide elemtag elemref) - (define (secref s) - (make-link-element #f null `(part ,s))) - (define (seclink tag . s) - (make-link-element #f (decode-content s) `(part ,tag))) + (define (doc-prefix doc s) + (if doc + (format "~a:~a" + (module-path-prefix->string doc) + s) + s)) + + (define (secref s #:doc [doc #f]) + (make-link-element #f null `(part ,(doc-prefix doc s)))) + (define (seclink tag #:doc [doc #f] . s) + (make-link-element #f (decode-content s) `(part ,(doc-prefix doc tag)))) (define (*schemelink stx-id id . s) - (make-link-element #f (decode-content s) (register-scheme-definition stx-id))) + (make-link-element #f (decode-content s) (or (register-scheme-definition stx-id) + (format "--UNDEFINED:~a--" (syntax-e stx-id))))) (define-syntax schemelink (syntax-rules () [(_ id . content) (*schemelink (quote-syntax id) 'id . content)])) @@ -1261,7 +1356,7 @@ (define id val)))])) (define-syntax (class-doc-info stx) - (syntax-case stx (object%) + (syntax-case* stx (object%) module-label-identifier=? [(_ object%) #'#f] [(_ id) (class-id->class-doc-info-id #'id)])) @@ -1357,18 +1452,22 @@ (list (make-flow (list (make-paragraph - (list (let ([tag (register-scheme-definition stx-id)] - [content (list (to-element stx-id))]) - ((if whole-page? - make-page-target-element - make-toc-target-element) - #f - (list (make-index-element #f - content - tag - (list (symbol->string (syntax-e stx-id))) - content)) - tag)) + (list (let ([tag (register-scheme-definition stx-id #t)] + [content (list (annote-exporting-library (to-element stx-id)))]) + (if tag + ((if whole-page? + make-page-target-element + make-toc-target-element) + #f + (if whole-page? + content ; title is already an index entry + (list (make-index-element #f + content + tag + (list (symbol->string (syntax-e stx-id))) + content))) + tag) + (car content))) spacer ":" spacer (if super (scheme class?) @@ -1403,12 +1502,12 @@ [(_ name super (intf ...) body ...) (define-class-doc-info name (syntax-parameterize ([current-class (quote-syntax name)]) - (register-class (quote-syntax name) + (register-class (quote-syntax/loc name) (class-doc-info super) (list (class-doc-info intf) ...) (lambda (whole-page?) (list - (*defclass (quote-syntax name) + (*defclass (quote-syntax/loc name) (quote-syntax super) (list (quote-syntax intf) ...) whole-page?))) @@ -1419,12 +1518,12 @@ [(_ name (intf ...) body ...) (define-class-doc-info name (syntax-parameterize ([current-class (quote-syntax name)]) - (register-class (quote-syntax name) + (register-class (quote-syntax/loc name) #f (list (class-doc-info intf) ...) (lambda (whole-page?) (list - (*defclass (quote-syntax name) + (*defclass (quote-syntax/loc name) #f (list (quote-syntax intf) ...) whole-page?))) diff --git a/collects/scribble/run.ss b/collects/scribble/run.ss index 2c0cde96e5..c7871114cd 100644 --- a/collects/scribble/run.ss +++ b/collects/scribble/run.ss @@ -67,7 +67,7 @@ (when dir (make-directory* dir)) - (let ([renderer (new ((current-render-mixin) render% ) + (let ([renderer (new ((current-render-mixin) render%) [dest-dir dir])]) (let* ([fns (map (lambda (fn) (let-values ([(base name dir?) (split-path fn)]) @@ -82,8 +82,15 @@ [files (reverse (current-info-input-files))]) (if (null? files) info - (loop (send renderer load-info (car files) info) + (loop (let ([s (with-input-from-file (car files) read)]) + (send renderer deserialize-info s info) + info) (cdr files))))]) - (send renderer render docs fns info)) - (when (current-info-output-file) - (send renderer save-info (current-info-output-file) info))))))) + (let ([r-info (send renderer resolve docs fns info)]) + (send renderer render docs fns r-info) + (when (current-info-output-file) + (let ([s (send renderer serialize-info r-info)]) + (with-output-to-file (current-info-output-file) + (lambda () + (write s)) + 'truncate/replace)))))))))) diff --git a/collects/scribble/scheme.ss b/collects/scribble/scheme.ss index d08be8c494..60e3a569f2 100644 --- a/collects/scribble/scheme.ss +++ b/collects/scribble/scheme.ss @@ -1,9 +1,10 @@ -(module scheme mzscheme +(module scheme (lib "lang.ss" "big") (require "struct.ss" "basic.ss" (lib "class.ss") (lib "for.ss") - (lib "modcollapse.ss" "syntax")) + (lib "main-collects.ss" "setup") + (lib "modresolve.ss" "syntax")) (provide define-code to-element @@ -33,13 +34,7 @@ (define opt-color "schemeopt") (define current-keyword-list - ;; This is temporary, until the MzScheme manual is filled in... - (make-parameter null #;'(require - provide - new send else => and or - define-syntax syntax-rules define-struct - quasiquote unquote unquote-splicing - syntax quasisyntax unsyntax unsyntax-splicing))) + (make-parameter null)) (define current-variable-list (make-parameter null)) (define current-meta-list @@ -51,7 +46,76 @@ (define-struct spaces (pre cnt post)) - (define (typeset c multi-line? prefix1 prefix suffix color?) + (define (literalize-spaces i) + (let ([m (regexp-match-positions #rx" +" i)]) + (if m + (make-spaces (literalize-spaces (substring i 0 (caar m))) + (- (cdar m) (caar m)) + (literalize-spaces (substring i (cdar m)))) + i))) + + (define (typeset-atom c out color? quote-depth) + (let-values ([(s it? sub?) + (let ([c (syntax-e c)]) + (let ([s (format "~s" c)]) + (if (and (symbol? c) + ((string-length s) . > . 1) + (char=? (string-ref s 0) #\_)) + (values (substring s 1) #t #f) + (values s #f #f))))] + [(is-var?) (and (identifier? c) + (memq (syntax-e c) (current-variable-list)))]) + (if (or (element? (syntax-e c)) + (delayed-element? (syntax-e c))) + (out (syntax-e c) #f) + (out (if (and (identifier? c) + color? + (quote-depth . <= . 0) + (not (or it? is-var?))) + (let ([tag (register-scheme c)]) + (if tag + (make-delayed-element + (lambda (renderer sec ri) + (let* ([vtag `(def ,tag)] + [stag `(form ,tag)] + [sd (resolve-get sec ri stag)]) + (list + (cond + [sd + (make-link-element "schemesyntaxlink" (list s) stag)] + [else + (make-link-element "schemevaluelink" (list s) vtag)])))) + (lambda () s) + (lambda () s)) + s)) + (literalize-spaces s)) + (cond + [(positive? quote-depth) value-color] + [(let ([v (syntax-e c)]) + (or (number? v) + (string? v) + (bytes? v) + (char? v) + (regexp? v) + (byte-regexp? v) + (boolean? v))) + value-color] + [(identifier? c) + (cond + [is-var? + variable-color] + [(and (identifier? c) + (memq (syntax-e c) (current-keyword-list))) + keyword-color] + [(and (identifier? c) + (memq (syntax-e c) (current-meta-list))) + meta-color] + [it? variable-color] + [else symbol-color])] + [else paren-color]) + (string-length s))))) + + (define (gen-typeset c multi-line? prefix1 prefix suffix color?) (let* ([c (syntax-ize c 0)] [content null] [docs null] @@ -80,6 +144,10 @@ [(and (element? v) (= 1 (length (element-content v)))) (sz-loop (car (element-content v)))] + [(element? v) + (element-width v)] + [(delayed-element? v) + (element-width v)] [(spaces? v) (+ (sz-loop (spaces-pre v)) (spaces-cnt v) @@ -176,13 +244,6 @@ c) (loop (cdr l) (cons (car l) prev))))])))))) - (define (literalize-spaces i) - (let ([m (regexp-match-positions #rx" +" i)]) - (if m - (make-spaces (literalize-spaces (substring i 0 (caar m))) - (- (cdar m) (caar m)) - (literalize-spaces (substring i (cdar m)))) - i))) (define (no-fancy-chars s) (cond [(eq? s 'rsquo) "'"] @@ -359,65 +420,10 @@ (set! src-col (+ orig-col (syntax-span c)))))] [else (advance c init-line!) - (let-values ([(s it? sub?) - (let ([c (syntax-e c)]) - (let ([s (format "~s" c)]) - (if (and (symbol? c) - ((string-length s) . > . 1) - (char=? (string-ref s 0) #\_)) - (values (substring s 1) #t #f) - (values s #f #f))))] - [(is-var?) (and (identifier? c) - (memq (syntax-e c) (current-variable-list)))]) - (if (element? (syntax-e c)) - (out (syntax-e c) #f) - (out (if (and (identifier? c) - color? - (quote-depth . <= . 0) - (not (or it? is-var?))) - (make-delayed-element - (lambda (renderer sec ht) - (let* ([vtag (register-scheme-definition c)] - [stag (register-scheme-form-definition c)] - [vd (hash-table-get ht vtag #f)] - [sd (hash-table-get ht stag #f)]) - (list - (cond - [sd - (make-link-element "schemesyntaxlink" (list s) stag)] - [vd - (make-link-element "schemevaluelink" (list s) vtag)] - [else s])))) - (lambda () s) - (lambda () s)) - (literalize-spaces s)) - (cond - [(positive? quote-depth) value-color] - [(or (number? (syntax-e c)) - (string? (syntax-e c)) - (bytes? (syntax-e c)) - (char? (syntax-e c)) - (regexp? (syntax-e c)) - (byte-regexp? (syntax-e c)) - (boolean? (syntax-e c))) - value-color] - [(identifier? c) - (cond - [is-var? - variable-color] - [(and (identifier? c) - (memq (syntax-e c) (current-keyword-list))) - keyword-color] - [(and (identifier? c) - (memq (syntax-e c) (current-meta-list))) - meta-color] - [it? variable-color] - [else symbol-color])] - [else paren-color]) - (string-length s))) - (set! src-col (+ src-col (or (syntax-span c) 1))) - #; - (hash-table-put! next-col-map src-col dest-col))]))) + (typeset-atom c out color? quote-depth) + (set! src-col (+ src-col (or (syntax-span c) 1))) + #; + (hash-table-put! next-col-map src-col dest-col)]))) (out prefix1 #f) (set! dest-col 0) (hash-table-put! next-col-map init-col dest-col) @@ -436,6 +442,25 @@ (make-table "schemeblock" (map list (reverse docs)))) (make-sized-element #f (reverse content) dest-col)))) + (define (typeset c multi-line? prefix1 prefix suffix color?) + (let* ([c (syntax-ize c 0)] + [s (syntax-e c)]) + (if (or multi-line? + (eq? 'code:blank s) + (pair? s) + (vector? s) + (box? s) + (null? s) + (hash-table? s)) + (gen-typeset c multi-line? prefix1 prefix suffix color?) + (typeset-atom c + (case-lambda + [(elem color) + (make-sized-element (and color? color) (list elem) (or (syntax-span c) 1))] + [(elem color len) + (make-sized-element (and color? color) (list elem) len)]) + color? 0)))) + (define (to-element c) (typeset c #f "" "" "" #t)) @@ -457,15 +482,15 @@ (cond [(syntax? v) (let ([mk `(,#'d->s - (quote-syntax ,v) + (quote-syntax ,(datum->syntax-object v 'defcode)) ,(syntax-case v (uncode) [(uncode e) #'e] [else (stx->loc-s-expr (syntax-e v))]) - (list 'code - ,(syntax-line v) - ,(syntax-column v) - ,(syntax-position v) - ,(syntax-span v)))]) + '(code + ,(syntax-line v) + ,(syntax-column v) + ,(syntax-position v) + ,(syntax-span v)))]) (let ([prop (syntax-property v 'paren-shape)]) (if prop `(,#'stx-prop ,mk 'paren-shape ,prop) @@ -484,27 +509,43 @@ [(_ expr) #`(typeset-code #,(cvt #'expr))] [(_ expr (... ...)) #`(typeset-code #,(cvt #'(code:line expr (... ...))))])))] + [(_ code typeset-code uncode d->s) + #'(define-code code typeset-code uncode d->s syntax-property)] [(_ code typeset-code uncode) #'(define-code code typeset-code uncode datum->syntax-object syntax-property)] [(_ code typeset-code) #'(define-code code typeset-code unsyntax)])) - (define (register-scheme-definition stx) + (define (register-scheme stx [warn-if-no-label? #f]) (unless (identifier? stx) (error 'register-scheme-definition "not an identifier: ~e" (syntax-object->datum stx))) - (format "definition:~a" - (let ([b (identifier-binding stx)]) - (cond - [(not b) (format "top:~a" (syntax-e stx))] - [(eq? b 'lexical) (format "lexical:~a" (syntax-e stx))] - [else (format "module:~a:~a" - (if (module-path-index? (car b)) - (collapse-module-path-index (car b) '(lib "ack.ss" "scribble")) - (car b)) - (cadr b))])))) + (let ([b (identifier-label-binding stx)]) + (if (or (not b) + (eq? b 'lexical)) + (if warn-if-no-label? + (begin + (fprintf (current-error-port) + "~a\n" + ;; Call raise-syntax-error to capture error message: + (with-handlers ([exn:fail:syntax? (lambda (exn) + (exn-message exn))]) + (raise-syntax-error 'WARNING + "no for-label binding of identifier" + stx))) + (format ":NOLABEL:~a" (syntax-e stx))) + #f) + (format ":~a:~a" + (if (module-path-index? (car b)) + (let ([p (resolve-module-path-index (car b) #f)]) + (path->main-collects-relative p)) + (car b)) + (cadr b))))) - (define (register-scheme-form-definition stx) - (format "form~s" (register-scheme-definition stx))) + (define (register-scheme-definition stx [warn-if-no-label? #f]) + `(def ,(register-scheme stx warn-if-no-label?))) + + (define (register-scheme-form-definition stx [warn-if-no-label? #f]) + `(form ,(register-scheme stx warn-if-no-label?))) (define syntax-ize-hook (make-parameter (lambda (v col) #f))) @@ -551,7 +592,11 @@ (just-context-ctx v)))] [(and (list? v) (pair? v) - (memq (car v) '(quote unquote unquote-splicing))) + (memq (let ([s (car v)]) + (if (just-context? s) + (just-context-val s) + s)) + '(quote unquote unquote-splicing))) (let ([c (syntax-ize (cadr v) (+ col 1))]) (datum->syntax-object #f (list (syntax-ize (car v) col) diff --git a/collects/scribble/scribble.css b/collects/scribble/scribble.css index 843c427294..160ff538c8 100644 --- a/collects/scribble/scribble.css +++ b/collects/scribble/scribble.css @@ -140,6 +140,10 @@ text-decoration: none; } + .nobreak { + white-space: nowrap; + } + .title { font-size: 200%; font-weight: normal; diff --git a/collects/scribble/struct.ss b/collects/scribble/struct.ss index 5c07eeca90..24001b989a 100644 --- a/collects/scribble/struct.ss +++ b/collects/scribble/struct.ss @@ -1,8 +1,56 @@ -(module struct mzscheme +(module struct (lib "lang.ss" "big") (require (lib "contract.ss") (lib "serialize.ss")) + ;; ---------------------------------------- + + (define-struct collect-info (ht ext-ht parts tags gen-prefix)) + (define-struct resolve-info (ci delays undef)) + + (define (part-collected-info part ri) + (hash-table-get (collect-info-parts (resolve-info-ci ri)) + part)) + + + (define (collect-put! ci key val) + (hash-table-put! (collect-info-ht ci) + key + val)) + + (define (resolve-get/where part ri key) + (let ([key (tag-key key ri)]) + (let ([v (hash-table-get (if part + (collected-info-info (part-collected-info part ri)) + (collect-info-ht (resolve-info-ci ri))) + key + #f)]) + (cond + [v (values v #f)] + [part (resolve-get/where (collected-info-parent + (part-collected-info part ri)) + ri + key)] + [else + (let ([v (hash-table-get (collect-info-ext-ht (resolve-info-ci ri)) + key + #f)]) + (values v #t))])))) + + (define (resolve-get part ri key) + (let-values ([(v ext?) (resolve-get/where part ri key)]) + v)) + + (provide + (struct collect-info (ht ext-ht parts tags gen-prefix)) + (struct resolve-info (ci delays undef)) + part-collected-info + collect-put! + resolve-get + resolve-get/where) + + ;; ---------------------------------------- + (provide provide-structs) (define-syntax (provide-structs stx) @@ -36,12 +84,12 @@ fields+cts)))))])) (provide tag?) - (define (tag? s) (or (string? s) - (and (pair? s) - (symbol? (car s)) - (pair? (cdr s)) - (string? (cadr s)) - (null? (cddr s))))) + (define (tag? s) (and (pair? s) + (symbol? (car s)) + (pair? (cdr s)) + (or (string? (cadr s)) + (generated-tag? (cadr s))) + (null? (cddr s)))) (provide flow-element?) (define (flow-element? p) @@ -52,21 +100,21 @@ (delayed-flow-element? p))) (provide-structs - [part ([tags (listof tag?)] + [part ([tag-prefix (or/c false/c string?)] + [tags (listof tag?)] [title-content (or/c false/c list?)] - [collected-info (or/c false/c collected-info?)] + [style any/c] [to-collect list?] [flow flow?] [parts (listof part?)])] - [(styled-part part) ([style any/c])] - [(unnumbered-part styled-part) ()] + [(unnumbered-part part) ()] [flow ([paragraphs (listof flow-element?)])] [paragraph ([content list?])] [(styled-paragraph paragraph) ([style any/c])] [table ([style any/c] [flowss (listof (listof (or/c flow? (one-of/c 'cont))))])] [(auxiliary-table table) ()] - [delayed-flow-element ([render (any/c part? any/c . -> . flow-element?)])] + [delayed-flow-element ([resolve (any/c part? resolve-info? . -> . flow-element?)])] [itemization ([flows (listof flow?)])] [blockquote ([style any/c] [paragraphs (listof flow-element?)])] @@ -81,6 +129,7 @@ [plain-seq (listof string?)] [entry-seq list?])] [(aux-element element) ()] + [(hover-element element) ([text string?])] ;; specific renders support other elements, especially strings [collected-info ([number (listof (or/c false/c integer?))] @@ -89,46 +138,32 @@ [target-url ([addr string?])] [image-file ([path path-string?])]) - + ;; ---------------------------------------- ;; Delayed element has special serialization support: - (define-values (struct:delayed-element - make-delayed-element - delayed-element? - delayed-element-ref - delayed-element-set!) - (make-struct-type 'delayed-element #f - 3 1 #f - (list (cons prop:serializable - (make-serialize-info - (lambda (d) - (unless (delayed-element-ref d 3) - (error 'serialize-delayed-element - "cannot serialize a delayed element that was not resolved: ~e" - d)) - (vector (delayed-element-ref d 3))) - #'deserialize-delayed-element - #f - (or (current-load-relative-directory) (current-directory))))))) - (define-syntax delayed-element (list-immutable #'struct:delayed-element - #'make-delayed-element - #'delayed-element? - (list-immutable #'delayed-element-plain - #'delayed-element-sizer - #'delayed-element-render) - (list-immutable #'set-delayed-element-plain! - #'set-delayed-element-sizer! - #'set-delayed-element-render!) - #t)) - (define delayed-element-render (make-struct-field-accessor delayed-element-ref 0)) - (define delayed-element-sizer (make-struct-field-accessor delayed-element-ref 1)) - (define delayed-element-plain (make-struct-field-accessor delayed-element-ref 2)) - (define set-delayed-element-render! (make-struct-field-mutator delayed-element-set! 0)) - (define set-delayed-element-sizer! (make-struct-field-mutator delayed-element-set! 1)) - (define set-delayed-element-plain! (make-struct-field-mutator delayed-element-set! 2)) + (define-struct delayed-element (resolve sizer plain) + #:property + prop:serializable + (make-serialize-info + (lambda (d) + (let ([ri (current-serialize-resolve-info)]) + (unless ri + (error 'serialize-delayed-element + "current-serialize-resolve-info not set")) + (with-handlers ([exn:fail:contract? + (lambda (exn) + (error 'serialize-delayed-element + "serialization failed (wrong resolve info?); ~a" + (exn-message exn)))]) + (vector + (make-element #f (delayed-element-content d ri)))))) + #'deserialize-delayed-element + #f + (or (current-load-relative-directory) (current-directory)))) + (provide/contract - (struct delayed-element ([render (any/c part? any/c . -> . list?)] + (struct delayed-element ([resolve (any/c part? resolve-info? . -> . list?)] [sizer (-> any)] [plain (-> any)]))) @@ -136,12 +171,90 @@ (define deserialize-delayed-element (make-deserialize-info values values)) - (provide force-delayed-element) - (define (force-delayed-element d renderer sec ht) - (or (delayed-element-ref d 3) - (let ([v ((delayed-element-ref d 0) renderer sec ht)]) - (delayed-element-set! d 3 v) - v))) + (provide delayed-element-content) + (define (delayed-element-content e ri) + (hash-table-get (resolve-info-delays ri) e)) + + (provide delayed-flow-element-flow-elements) + (define (delayed-flow-element-flow-elements p ri) + (hash-table-get (resolve-info-delays ri) p)) + + (provide current-serialize-resolve-info) + (define current-serialize-resolve-info (make-parameter #f)) + + ;; ---------------------------------------- + + (define-struct (collect-element element) (collect) + #:property + prop:serializable + (make-serialize-info + (lambda (d) + (vector (collect-element-collect d))) + #'deserialize-collect-element + #f + (or (current-load-relative-directory) (current-directory)))) + + (provide deserialize-collect-element) + (define deserialize-collect-element + (make-deserialize-info values values)) + + (provide/contract + [struct collect-element ([style any/c] + [content list?] + [collect (collect-info? . -> . any)])]) + + ;; ---------------------------------------- + + (define-struct generated-tag () + #:property + prop:serializable + (make-serialize-info + (lambda (g) + (let ([ri (current-serialize-resolve-info)]) + (unless ri + (error 'serialize-generated-tag + "current-serialize-resolve-info not set")) + (let ([t (hash-table-get (collect-info-tags + (resolve-info-ci ri)) + g + #f)]) + (if t + (vector t) + (error 'serialize-generated-tag + "serialization failed (wrong resolve info?)"))))) + #'deserialize-generated-tag + #f + (or (current-load-relative-directory) (current-directory)))) + + (provide + (struct generated-tag ())) + + (provide deserialize-generated-tag) + (define deserialize-generated-tag + (make-deserialize-info values values)) + + (provide generate-tag tag-key) + + (define (generate-tag tg ci) + (if (generated-tag? (cadr tg)) + (let ([t (cadr tg)]) + (list (car tg) + (let ([tags (collect-info-tags ci)]) + (or (hash-table-get tags t #f) + (let ([key (format "gentag:~a~a" + (collect-info-gen-prefix ci) + (hash-table-count tags))]) + (hash-table-put! tags t key) + key))))) + tg)) + + (define (tag-key tg ri) + (if (generated-tag? (cadr tg)) + (list (car tg) + (hash-table-get (collect-info-tags + (resolve-info-ci ri)) + (cadr tg))) + tg)) ;; ---------------------------------------- @@ -151,8 +264,8 @@ (define content->string (case-lambda [(c) (c->s c element->string)] - [(c renderer sec ht) (c->s c (lambda (e) - (element->string e renderer sec ht)))])) + [(c renderer sec ri) (c->s c (lambda (e) + (element->string e renderer sec ri)))])) (define (c->s c do-elem) (apply string-append @@ -171,12 +284,12 @@ [(rsquo) "'"] [(rarr) "->"] [else (format "~s" c)])])] - [(c renderer sec ht) + [(c renderer sec ri) (cond - [(element? c) (content->string (element-content c) renderer sec ht)] + [(element? c) (content->string (element-content c) renderer sec ri)] [(delayed-element? c) - (content->string (force-delayed-element c renderer sec ht) - renderer sec ht)] + (content->string (delayed-element-content c ri) + renderer sec ri)] [else (element->string c)])])) ;; ---------------------------------------- @@ -226,5 +339,14 @@ ;; ---------------------------------------- + (provide part-style?) + + (define (part-style? p s) + (let ([st (part-style p)]) + (or (eq? s st) + (and (list? st) (memq s st))))) + + ;; ---------------------------------------- + ) diff --git a/collects/scribblings/core.ss b/collects/scribblings/core.ss deleted file mode 100644 index 9d54f028f9..0000000000 --- a/collects/scribblings/core.ss +++ /dev/null @@ -1,16 +0,0 @@ - -(module core mzscheme - (require "to-html.ss" - (prefix ref: "reference/reference.scrbl") - (prefix guide: "guide/guide.scrbl")) - - (provide build) - - (define (build) - (to-html #t #t - (list ref:doc - guide:doc) - (list "reference" - "guide")))) - - diff --git a/collects/scribblings/doc-installer.ss b/collects/scribblings/doc-installer.ss deleted file mode 100644 index 9a02670231..0000000000 --- a/collects/scribblings/doc-installer.ss +++ /dev/null @@ -1,17 +0,0 @@ -(module doc-installer mzscheme - (require (lib "dirs.ss" "setup") - (prefix core: "core.ss") - (prefix quick: "quick.ss") - (prefix scribble: "scribble.ss") - (prefix gui: "gui.ss")) - - (provide post-installer) - - (define post-installer - (lambda (path) - (let ([doc (find-doc-dir)]) - (when doc - (core:build) - (quick:build) - (scribble:build) - (gui:build)))))) diff --git a/collects/scribblings/gui.ss b/collects/scribblings/gui.ss deleted file mode 100644 index 2eb7875ab3..0000000000 --- a/collects/scribblings/gui.ss +++ /dev/null @@ -1,11 +0,0 @@ - -(module gui mzscheme - (require "to-html.ss" - (prefix gui: "gui/gui.scrbl")) - - (provide build) - - (define (build) - (to-html #t #f - (list gui:doc) - (list "gui")))) diff --git a/collects/scribblings/gui/blurbs.ss b/collects/scribblings/gui/blurbs.ss index f556a96a08..447e41b9e6 100644 --- a/collects/scribblings/gui/blurbs.ss +++ b/collects/scribblings/gui/blurbs.ss @@ -1,9 +1,10 @@ #reader(lib "reader.ss" "scribble") -(module blurbs mzscheme +(module blurbs (lib "lang.ss" "big") (require (lib "struct.ss" "scribble") (lib "manual.ss" "scribble") (lib "scheme.ss" "scribble") (lib "decode.ss" "scribble")) + (require-for-label (lib "mred.ss" "mred")) (provide (all-defined-except p)) @@ -96,7 +97,7 @@ start/end @techlink{position} is incremented by @|what|.}) (define OVD @elem{The result is only valid when the editor is displayed (see - @secref["mr:tb:miaoverview"]).}) + @secref["tb:miaoverview"]).}) (define (FCAX c details) @elem{@|c|alling this method may force the recalculation of @techlink{location} @@ -119,28 +120,28 @@ information@|details|, even if the editor currently has delayed refreshing (see instead of lines (determined by both explicit newline characters and automatic line-wrapping).}) - (define admindiscuss @secref["mr:editoradministrators"]) - (define ateoldiscuss @secref["mr:editoreol"]) - (define textdiscuss @secref["mr:editorflattened"]) - (define clickbackdiscuss @secref["mr:editorclickback"]) - (define stylediscuss @secref["mr:editorstyles"]) - (define timediscuss @secref["mr:editorcutandpastetime"]) - (define filediscuss @secref["mr:editorfileformat"]) - (define editordatadiscuss @secref["mr:editordata"]) - (define snipclassdiscuss @secref["mr:editorsnipclasses"]) - (define togglediscuss @secref["mr:styledeltatoggle"]) - (define drawcaretdiscuss @secref["mr:drawcaretinfo"]) - (define eventspacediscuss @secref["mr:eventspaceinfo"]) - (define lockdiscuss @secref["mr:lockinfo"]) - (define mousekeydiscuss @secref["mr:mouseandkey"]) - (define globaleditordatadiscuss @secref["mr:globaleditordata"]) + (define admindiscuss @secref["editoradministrators"]) + (define ateoldiscuss @secref["editoreol"]) + (define textdiscuss @secref["editorflattened"]) + (define clickbackdiscuss @secref["editorclickback"]) + (define stylediscuss @secref["editorstyles"]) + (define timediscuss @secref["editorcutandpastetime"]) + (define filediscuss @secref["editorfileformat"]) + (define editordatadiscuss @secref["editordata"]) + (define snipclassdiscuss @secref["editorsnipclasses"]) + (define togglediscuss @secref["styledeltatoggle"]) + (define drawcaretdiscuss @secref["drawcaretinfo"]) + (define eventspacediscuss @secref["eventspaceinfo"]) + (define lockdiscuss @secref["lockinfo"]) + (define mousekeydiscuss @secref["mouseandkey"]) + (define globaleditordatadiscuss @secref["globaleditordata"]) - (define geomdiscuss @secref["mr:containeroverview"]) + (define geomdiscuss @secref["containeroverview"]) - (define mrprefsdiscuss @secref["mr:mredprefs"]) + (define mrprefsdiscuss @secref["mredprefs"]) (define seesniporderdiscuss - @elem{See @secref["mr:tb:miaoverview"] for information about snip order in pasteboards.}) + @elem{See @secref["tb:miaoverview"] for information about snip order in pasteboards.}) (define (clipboardtypes) @elem{The @scheme[format] string is typically four capital letters. (Under @@ -159,7 +160,9 @@ information@|details|, even if the editor currently has delayed refreshing (see @item{@method[dc<%> end-doc]}} @p{Attempts to use a drawing method outside of an active page raises an exception.}))) - (define SeeMzParam @elem{(see @secref["mz:parameters"])}) + (define reference-doc '(lib "reference.scrbl" "scribblings" "reference")) + + (define SeeMzParam @elem{(see @secref[#:doc reference-doc "parameters"])}) (define DrawSizeNote @elem{Restrictions on the magnitude of drawing coordinates are described with @scheme[dc<%>].}) diff --git a/collects/scribblings/gui/common.ss b/collects/scribblings/gui/common.ss index 974fce2d32..44a3edc1d1 100644 --- a/collects/scribblings/gui/common.ss +++ b/collects/scribblings/gui/common.ss @@ -11,6 +11,12 @@ (all-from (lib "class.ss")) (all-from (lib "contract.ss")) (all-from "blurbs.ss") - (all-from "../reference/mz.ss"))) + (all-from "../reference/mz.ss")) + (require-for-label (lib "mred.ss" "mred") + (lib "class.ss") + (lib "lang.ss" "big")) + (provide-for-label (all-from (lib "mred.ss" "mred")) + (all-from (lib "class.ss")) + (all-from (lib "lang.ss" "big")))) diff --git a/collects/scribblings/gui/diagrams.ss b/collects/scribblings/gui/diagrams.ss index 0b33841277..754f730389 100644 --- a/collects/scribblings/gui/diagrams.ss +++ b/collects/scribblings/gui/diagrams.ss @@ -3,6 +3,7 @@ (lib "struct.ss" "scribble") (lib "scheme.ss" "scribble") (lib "manual.ss" "scribble")) + (require-for-label (lib "mred.ss" "mred")) (provide diagram->table short-windowing-diagram @@ -31,7 +32,8 @@ [(regexp-match #rx"([^-a-zA-Z0-9]*)([-a-zA-Z0-9<%>]+)(.*)" line) => (lambda (m) (append (loop (cadr m)) - (list (to-element (string->symbol (caddr m)))) + (list (to-element (make-just-context (string->symbol (caddr m)) + #'here))) (loop (cadddr m))))] [else (list (make-element 'tt (list line)))]))))))) (regexp-split #rx"[\r\n]+" d)))) diff --git a/collects/scribblings/gui/draw-overview.scrbl b/collects/scribblings/gui/draw-overview.scrbl index f2ce43f210..808564e097 100644 --- a/collects/scribblings/gui/draw-overview.scrbl +++ b/collects/scribblings/gui/draw-overview.scrbl @@ -3,7 +3,7 @@ @require["common.ss"] @require["diagrams.ss"] -@title[#:tag "mr:drawing-overview"]{Drawing} +@title[#:tag "drawing-overview"]{Drawing} Drawing in MrEd requires a @deftech{device context} (@deftech{DC}), which is an instance of the @scheme[dc<%>] interface. For example, diff --git a/collects/scribblings/gui/editor-funcs.scrbl b/collects/scribblings/gui/editor-funcs.scrbl index 921843edd5..f529f03657 100644 --- a/collects/scribblings/gui/editor-funcs.scrbl +++ b/collects/scribblings/gui/editor-funcs.scrbl @@ -350,9 +350,9 @@ If @scheme[raise-errors?] is true, then an error in reading triggers an This procedure is a load handler for use with @scheme[current-load]. The handler recognizes MrEd editor-format files (see - @secref["mr:editorfileformat"]) and decodes them for loading. It is + @secref["editorfileformat"]) and decodes them for loading. It is normally installed as MrEd starts (see - @secref["mr:startupsequence"]). + @secref[#:doc reference-doc "running-sa"]). The handler recognizes editor files by the first twelve characters of the file: @litchar{WXME01}@nonterm{digit}@nonterm{digit}@litchar{ ## }. @@ -412,7 +412,7 @@ One or more editors can be written to the stream by calling the To support streams that span MrEd versions, use @scheme[write-editor-version] before this procedure. -See also @secref["mr:editorfileformat"]. +See also @secref["editorfileformat"]. } diff --git a/collects/scribblings/gui/editor-intf.scrbl b/collects/scribblings/gui/editor-intf.scrbl index 600153f2a9..4bca91bad3 100644 --- a/collects/scribblings/gui/editor-intf.scrbl +++ b/collects/scribblings/gui/editor-intf.scrbl @@ -205,7 +205,7 @@ When an editor contains other editors, using @method[editor<%> end-edit-sequence] for the sub-editor. See also @method[editor<%> refresh-delayed?] and @method[editor<%> - in-edit-sequence?], and see @secref["mr:editorthreads"] for + in-edit-sequence?], and see @secref["editorthreads"] for information about edit sequences and refresh requests. If the @scheme[undoable?] flag is @scheme[#f], then the changes made @@ -1322,7 +1322,7 @@ If automatic wrapping is enabled (see @method[editor<%> auto-wrap] ) Calls @method[editor<%> on-display-size] unless the editor is currently in an edit sequence or currently being refreshed. In the latter cases, the call to @method[editor<%> on-display-size] is - delegated to another thread; see @secref["mr:editorthreads"] for more + delegated to another thread; see @secref["editorthreads"] for more information. } @@ -1853,7 +1853,7 @@ See also @method[editor<%> add-undo]. void?]{ Repaints a region of the editor, generally called by an editor - administrator. See @secref["mr:editorthreads"] for information about + administrator. See @secref["editorthreads"] for information about edit sequences and refresh requests. The @scheme[x], @scheme[y], @scheme[width], and @scheme[height] arguments specify diff --git a/collects/scribblings/gui/editor-overview.scrbl b/collects/scribblings/gui/editor-overview.scrbl index 33099e56b4..3b95215503 100644 --- a/collects/scribblings/gui/editor-overview.scrbl +++ b/collects/scribblings/gui/editor-overview.scrbl @@ -2,7 +2,7 @@ @require[(lib "bnf.ss" "scribble")] @require["common.ss"] -@title[#:tag "mr:editor-overview"]{Editor} +@title[#:tag "editor-overview"]{Editor} The editor toolbox provides a foundation for two common kinds of applications: @@ -154,7 +154,7 @@ Applications that use the editor classes typically derive new versions (super-new))) ] -@section[#:tag "mr:tb:miaoverview"]{Editor Structure and Terminology} +@section[#:tag "tb:miaoverview"]{Editor Structure and Terminology} MrEd supports extensible and nestable editors by decomposing an editor assembly into three functional parts: @@ -221,7 +221,7 @@ When an editor is drawn into a display, each snip and position has a displayed. -@subsection[#:tag "mr:editoradministrators"]{Administrators} +@subsection[#:tag "editoradministrators"]{Administrators} Two extra layers of administration manage the @techlink{display}-editor and editor-snip connections. An editor never communicates directly with @@ -259,7 +259,7 @@ When an editor is displayed by multiple canvases, one of the canvases' editor's @method[editor<%> get-admin] method thus depends on the context of the call. -@subsection[#:tag "mr:editorstyles"]{Styles} +@subsection[#:tag "editorstyles"]{Styles} A @deftech{style}, an instance of the @scheme[style<%>] interface, parameterizes high-level display information that is common to all @@ -336,7 +336,7 @@ See @xmethod[text% get-styles-sticky] for more information about the style of inserted text. -@section[#:tag "mr:editorfileformat"]{File Format} +@section[#:tag "editorfileformat"]{File Format} To allow editor content to be saved to a file, the editor classes implement a special file format. (The format is used when cutting and @@ -412,7 +412,7 @@ Snip classes, snip data, and snip data classes solve problems related for saving files or cut-and-paste, these issues can be safely ignored. -@subsubsection[#:tag "mr:editorsnipclasses"]{Snip Classes} +@subsubsection[#:tag "editorsnipclasses"]{Snip Classes} Each snip can be associated to a @deftech{snip class}. This ``class'' is not a class description in the programmer's language; it is an @@ -435,7 +435,7 @@ If a snip class's name is of the form @scheme["(lib ...)"], then the it is inserted into the current eventspace's snip class list, and loading or saving continues using the new class. -@subsubsection[#:tag "mr:editordata"]{Editor Data} +@subsubsection[#:tag "editordata"]{Editor Data} While a snip belongs to an editor, the editor may store extra information about a snip in some specialized way. When the snip is to @@ -475,7 +475,7 @@ To store and load information about a snip or region in an editor: } -@subsection[#:tag "mr:globaleditordata"]{Global Data: Headers and Footers} +@subsection[#:tag "globaleditordata"]{Global Data: Headers and Footers} The editor file format provides for adding extra global data in special header and footer sections. To save and load special header @@ -517,7 +517,7 @@ See also @method[editor<%> write-headers-to-file] and @method[editor<%> write-headers-to-file]. -@section[#:tag "mr:editoreol"]{End of Line Ambiguity} +@section[#:tag "editoreol"]{End of Line Ambiguity} Because an editor can force a line break even when there is no carriage return item, a @techlink{position} alone does not always @@ -539,7 +539,7 @@ For this reason, @techlink{position}-setting and is filled with @scheme[#t] if the position is ambiguous and it came from a right-side location, or @scheme[#f] otherwise. -@section[#:tag "mr:editorflattened"]{Flattened Text} +@section[#:tag "editorflattened"]{Flattened Text} In plain text editors, there is a simple correlation between @techlink{position}s and characters. In an @scheme[editor<%>] object, @@ -568,7 +568,7 @@ Text can be extracted from an editor in either of two forms: } -@section[#:tag "mr:drawcaretinfo"]{Caret Ownership} +@section[#:tag "drawcaretinfo"]{Caret Ownership} Within a frame, only one object can contain the keyboard focus. This property must be maintained when a frame contains multiple editors in @@ -609,7 +609,7 @@ The @scheme['show-inactive-caret] display mode is useful for showing its selection. -@section[#:tag "mr:editorcutandpastetime"]{Cut and Paste Time Stamps} +@section[#:tag "editorcutandpastetime"]{Cut and Paste Time Stamps} Methods of @scheme[editor<%>] that use the clipboard --- including @method[editor<%> copy], @method[editor<%> cut], @method[editor<%> @@ -627,7 +627,7 @@ If the time stamp is 0, it defaults to the current time. Using 0 as the under X. -@section[#:tag "mr:editorclickback"]{Clickbacks} +@section[#:tag "editorclickback"]{Clickbacks} @deftech{Clickbacks} in a @scheme[text%] editor facilitate the creation of simple interactive objects, such as hypertext. A @@ -647,7 +647,7 @@ Note that there is no attempt to save clickback information when a file is saved, since a clickback will have an arbitrary procedure associated with it. -@section[#:tag "mr:lockinfo"]{Internal Editor Locks} +@section[#:tag "lockinfo"]{Internal Editor Locks} Instances of @scheme[editor<%>] have three levels of internal locking: @@ -693,7 +693,7 @@ Methods that report @techlink{location}-independent information about an that modifies the editor in any way, even setting the selection position, can trigger a read lock, flow lock, or write lock. -@section[#:tag "mr:editorthreads"]{Editors and Threads} +@section[#:tag "editorthreads"]{Editors and Threads} An editor is not tied to any particular thread or eventspace, except to the degree that it is displayed in a canvas (which has an diff --git a/collects/scribblings/gui/eventspace-funcs.scrbl b/collects/scribblings/gui/eventspace-funcs.scrbl index 800429140d..1ea813af7b 100644 --- a/collects/scribblings/gui/eventspace-funcs.scrbl +++ b/collects/scribblings/gui/eventspace-funcs.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["common.ss"] -@title[#:tag "mr:eventspace-funcs"]{Eventspaces} +@title[#:tag "eventspace-funcs"]{Eventspaces} @defproc[(make-eventspace) eventspace]{ @@ -139,7 +139,7 @@ A second (optional) boolean argument indicates whether the callback any/c])]{ \index{pause}\index{wait} Yields control to event dispatching. See - @secref["mr:eventspaceinfo"] for details. + @secref["eventspaceinfo"] for details. A handler procedure invoked by the system during a call to @scheme[yield] can itself call @scheme[yield], creating @@ -180,18 +180,18 @@ Evaluating @scheme[(yield 'wait)] is thus similar to sensitive to whether the current thread is a handler thread, instead of the value of the @scheme[current-eventspace] parameter. -If @scheme[v] is an event in MzScheme's sense (not to be confused with a - GUI event), @scheme[yield] blocks on @scheme[v] in the same way as - MzScheme's \Mzhyperref{@scheme[sync]}{mz:sync}, except that it may - start a @scheme[sync] on @scheme[v] multiple times (but it will complete - a @scheme[sync] on @scheme[v] at most one time). If the current thread - is the current eventspace's handler thread, events are dispatched - until a @scheme[v] sync succeeds on a MrEd event boundary. For other - threads, calling @scheme[yield] with a MzScheme event is - equivalent to calling @scheme[sync]. In either case, the result is - the same that of @scheme[sync]; however, if a wrapper procedure is - associated with @scheme[v] via @scheme[handle-evt], it is not called in - tail position with respect to the @scheme[yield]. +If @scheme[v] is an event in MzScheme's sense (not to be confused with + a GUI event), @scheme[yield] blocks on @scheme[v] in the same way as + @scheme[sync], except that it may start a @scheme[sync] on @scheme[v] + multiple times (but it will complete a @scheme[sync] on @scheme[v] at + most one time). If the current thread is the current eventspace's + handler thread, events are dispatched until a @scheme[v] sync + succeeds on a MrEd event boundary. For other threads, calling + @scheme[yield] with a MzScheme event is equivalent to calling + @scheme[sync]. In either case, the result is the same that of + @scheme[sync]; however, if a wrapper procedure is associated with + @scheme[v] via @scheme[handle-evt], it is not called in tail position + with respect to the @scheme[yield]. Always use @scheme[(yield @scheme[v])] instead of a busy-wait loop. } diff --git a/collects/scribblings/gui/font-config.scrbl b/collects/scribblings/gui/font-config.scrbl index 8171153b3b..c5473cc545 100644 --- a/collects/scribblings/gui/font-config.scrbl +++ b/collects/scribblings/gui/font-config.scrbl @@ -2,7 +2,7 @@ @require["common.ss"] @require[(lib "bnf.ss" "scribble")] -@title[#:tag "mr:fontresources"]{Font Configuration} +@title[#:tag "fontresources"]{Font Configuration} This chapter describes how to set up face mappings for screen and PostScript fonts via preferences (see @|mrprefsdiscuss|). The @@ -50,7 +50,7 @@ The value of the preference is parsed as described in @; ------------------------------------------------------------------------ -@section[#:tag "mr:exampleresources"]{Wildcards} +@section[#:tag "exampleresources"]{Wildcards} Building items names by concatenating @nonterm{dest}, @nonterm{type}, @nonterm{weight}, and @nonterm{style} can create a large number of preference @@ -319,7 +319,7 @@ Internal preferences for Mac OS X only: @; ------------------------------------------------------------------------ -@section[#:tag "mr:postscriptfonts"]{PostScript Fonts} +@section[#:tag "postscriptfonts"]{PostScript Fonts} @section-index["fonts" "PostScript"] @section-index["PostScript fonts"] diff --git a/collects/scribblings/gui/font-funcs.scrbl b/collects/scribblings/gui/font-funcs.scrbl index c43ffc55a6..e0a3c58bdb 100644 --- a/collects/scribblings/gui/font-funcs.scrbl +++ b/collects/scribblings/gui/font-funcs.scrbl @@ -19,7 +19,7 @@ Returns a list of font face names available on the current system. If Returns the built-in default face mapping for a particular font family. The built-in default can be overridden via preferences, as - described in @secref["mr:fontresources"]. + described in @secref["fontresources"]. See @scheme[font%] for information about @scheme[family]. diff --git a/collects/scribblings/gui/font-name-directory-intf.scrbl b/collects/scribblings/gui/font-name-directory-intf.scrbl index 9a4a5bcb09..c64b46d704 100644 --- a/collects/scribblings/gui/font-name-directory-intf.scrbl +++ b/collects/scribblings/gui/font-name-directory-intf.scrbl @@ -35,7 +35,7 @@ To extract mapping information from @scheme[the-font-name-directory], For a family without a face string, the corresponding font ID has a useful built-in mapping for every platform and device. (The built-in mapping can be overridden through the user's preferences; see - @secref["mr:fontresources"] for information.) For a family with a + @secref["fontresources"] for information.) For a family with a face string, @scheme[the-font-name-directory] interprets the string (in a platform-specific way) to generate a mapping for ``screen'' drawing (to a canvas's @scheme[dc<%>], a @scheme[bitmap-dc%], or a @@ -93,7 +93,7 @@ Under Windows and Mac OS X, a face name is interpreted simply as a The mapping for face names can be overridden (on all platforms) through the user's preferences, as described in - @secref["mr:fontresources"]. + @secref["fontresources"]. @@ -159,7 +159,7 @@ Font ID are useful only as mapping indices for Gets a PostScript font name for a font ID, weight, and style combination. The PostScript font name is used both for the font name in PostScript output (sans character set) and as the @|AFM| file - name; see also @secref["mr:postscriptfonts"]. + name; see also @secref["postscriptfonts"]. See @scheme[font%] for information about @scheme[weight] and @scheme[style]. diff --git a/collects/scribblings/gui/gl-context-intf.scrbl b/collects/scribblings/gui/gl-context-intf.scrbl index b7f5ca947e..76f7b79a8a 100644 --- a/collects/scribblings/gui/gl-context-intf.scrbl +++ b/collects/scribblings/gui/gl-context-intf.scrbl @@ -53,8 +53,9 @@ The lock prevents interference among OpenGL-using threads. If a set the OpenGL context. See @scheme[gl-context<%>] for more information on interference. -The method accepts an alternate @tech{synchronizable event} for use - while blocking for the context lock; see also @scheme[sync]. +The method accepts an alternate @tech[#:doc + reference-doc]{synchronizable event} for use while blocking for the + context lock; see also @scheme[sync]. The result of the method call is the result of the thunk if it is called, or the result of the alternate event if it is chosen instead diff --git a/collects/scribblings/gui/gui.scrbl b/collects/scribblings/gui/gui.scrbl index c9ae8c3450..1d0c02fbfd 100644 --- a/collects/scribblings/gui/gui.scrbl +++ b/collects/scribblings/gui/gui.scrbl @@ -1,12 +1,15 @@ #reader(lib "docreader.ss" "scribble") @require["common.ss"] -@title{PLT Scheme GUI: MrEd} +@title[#:tag-prefix '(lib "gui.scrbl" "scribblings" "gui") + #:tag "top"]{PLT Scheme GUI: MrEd} + +@declare-exporting[(lib "mred")] This reference manual describes the MrEd GUI toolbox that is part of - PLT Scheme. See @secref["guide:mred"] in - @italic{@link["../guide/index.html"]{A Guide to PLT Scheme}} for an - introduction to MrEd. + PLT Scheme. See @secref[#:doc '(lib "guide.scrbl" "scribblings" + "guide") "mred"] in @italic{@link["../guide/index.html"]{A Guide to + PLT Scheme}} for an introduction to MrEd. The @scheme[(lib "mred")] module provides all of the class, interface, and procedure bindings defined in this manual. The diff --git a/collects/scribblings/gui/guide.scrbl b/collects/scribblings/gui/guide.scrbl index c289b961ce..afd4eea6c5 100644 --- a/collects/scribblings/gui/guide.scrbl +++ b/collects/scribblings/gui/guide.scrbl @@ -11,18 +11,18 @@ For documentation purposes, the MrEd toolbox is organized into three @item{The @deftech{windowing} toolbox, for implementing form-filling GUI programs (such as a database query window) using buttons, menus, text fields, and events. The windowing toolbox is described in - @secref["mr:windowing-overview"].} + @secref["windowing-overview"].} @item{The @deftech{drawing} toolbox, for drawing pictures or implementing dynamic GUI programs (such as a video game) using drawing canvases, pens, and brushes. The drawing toolbox is - described in @secref["mr:drawing-overview"].} + described in @secref["drawing-overview"].} @item{The @deftech{editor} toolbox, for developing traditional text editors, editors that mix text and graphics, or free-form layout editors (such as a word processor, HTML editor, or icon-based file browser). The editor toolbox is described in - @secref["mr:editor-overview"].} + @secref["editor-overview"].} } diff --git a/collects/scribblings/gui/info.ss b/collects/scribblings/gui/info.ss new file mode 100644 index 0000000000..5ac00bf428 --- /dev/null +++ b/collects/scribblings/gui/info.ss @@ -0,0 +1,4 @@ +(module info (lib "infotab.ss" "setup") + (define name "Scribblings: GUI") + (define scribblings '(("gui.scrbl" (multi-page main-doc))))) + diff --git a/collects/scribblings/gui/keymap-class.scrbl b/collects/scribblings/gui/keymap-class.scrbl index 6f6c547093..4f0a385768 100644 --- a/collects/scribblings/gui/keymap-class.scrbl +++ b/collects/scribblings/gui/keymap-class.scrbl @@ -83,7 +83,7 @@ If @scheme[try-chain?] is not @scheme[#f], keymaps chained to this one are searched for the function name. If the function is not found and @scheme[try-chain?] is @scheme[#f]; an exception is also raised, but the exception handler cannot escape (see - @secref["mr:evtcontjump"]). + @secref["evtcontjump"]). } @@ -327,7 +327,7 @@ Examples: A call to @method[keymap% map-function] that would map a particular key sequence both as a prefix and as a complete sequence raises an exception, but the exception handler cannot escape (see - @secref["mr:evtcontjump"]). + @secref["evtcontjump"]). A function name does not have to be mapped to a handler before input states are mapped to the name; the handler is dispatched by name at diff --git a/collects/scribblings/gui/post-script-funcs.scrbl b/collects/scribblings/gui/post-script-funcs.scrbl index ebef3e979e..7cbce17a31 100644 --- a/collects/scribblings/gui/post-script-funcs.scrbl +++ b/collects/scribblings/gui/post-script-funcs.scrbl @@ -6,14 +6,14 @@ @defparam[current-ps-afm-file-paths paths (listof path?)]{ A parameter determines the list of paths that is used to find AFM - files. See @secref["mr:postscriptfonts"] for more information. + files. See @secref["postscriptfonts"] for more information. } @defparam[current-ps-cmap-file-paths paths (listof path?)]{ A parameter that determines the list of paths that is used to find - CMap files. See @secref["mr:postscriptfonts"] for more information. + CMap files. See @secref["postscriptfonts"] for more information. } diff --git a/collects/scribblings/gui/prefs.scrbl b/collects/scribblings/gui/prefs.scrbl index d44ee56971..38ff3d6031 100644 --- a/collects/scribblings/gui/prefs.scrbl +++ b/collects/scribblings/gui/prefs.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["common.ss"] -@title[#:tag "mr:mredprefs"]{Preferences} +@title[#:tag "mredprefs"]{Preferences} MrEd supports a number of preferences for global configuration. The MrEd preferences are stored in the common file reported by @@ -22,7 +22,7 @@ The following are the (case-sensitive) preference names used by MrEd: @item{@ResourceFirst{controlFontSize} --- sets the font size for control and menu labels (Windows, X); the font is the @scheme['system] font, which can be configured as described in - @secref["mr:fontresources"].} + @secref["fontresources"].} @item{@ResourceFirst{defaultMenuPrefix} --- sets the prefix used by default for menu item shortcuts under X, one of @scheme['ctl], @@ -82,4 +82,4 @@ The following are the (case-sensitive) preference names used by MrEd: In addition, preference names built from font face names can provide or override default entries for the @scheme[font-name-directory<%>]; - see @secref["mr:fontresources"] for information. + see @secref["fontresources"] for information. diff --git a/collects/scribblings/gui/readable-snip-intf.scrbl b/collects/scribblings/gui/readable-snip-intf.scrbl index 6e3f6638d6..4826edaba6 100644 --- a/collects/scribblings/gui/readable-snip-intf.scrbl +++ b/collects/scribblings/gui/readable-snip-intf.scrbl @@ -16,7 +16,8 @@ A @scheme[readable-snip<%>] object is treated specially by the port any/c]{ The arguments are the same as the arguments to a procedure returned by - a custom input port's @scheme[read]; see @secref["mz:customport"] for + a custom input port's @scheme[read]; see @secref[#:doc '(lib + "reference.scrbl" "scribblings" "reference") "customport"] for details. The result is also the same as the result from a @scheme[read]-produced procedure. diff --git a/collects/scribblings/gui/text-class.scrbl b/collects/scribblings/gui/text-class.scrbl index 1aa4e55bc2..726560722c 100644 --- a/collects/scribblings/gui/text-class.scrbl +++ b/collects/scribblings/gui/text-class.scrbl @@ -1228,7 +1228,7 @@ If the line starts with invisible @techlink{item}s and @scheme[visible?] is not To calculate lines, if the following are true: @itemize{ - @item{the editor is not displayed (see @secref["mr:tb:miaoverview"]),} + @item{the editor is not displayed (see @secref["tb:miaoverview"]),} @item{a maximum width is set for the editor, and} diff --git a/collects/scribblings/gui/timer-class.scrbl b/collects/scribblings/gui/timer-class.scrbl index 2810ef376d..9109d0fa98 100644 --- a/collects/scribblings/gui/timer-class.scrbl +++ b/collects/scribblings/gui/timer-class.scrbl @@ -18,7 +18,7 @@ Timers have a relatively high priority in the event queue. Thus, if within the @method[timer% notify] procedure to allow guaranteed event processing. -See @secref["mr:eventspaceinfo"] for more information about event +See @secref["eventspaceinfo"] for more information about event priorities. diff --git a/collects/scribblings/gui/win-overview.scrbl b/collects/scribblings/gui/win-overview.scrbl index 7dc42d5097..c35e37c58c 100644 --- a/collects/scribblings/gui/win-overview.scrbl +++ b/collects/scribblings/gui/win-overview.scrbl @@ -3,7 +3,7 @@ @require["common.ss"] @require["diagrams.ss"] -@title[#:tag "mr:windowing-overview"]{Windowing} +@title[#:tag "windowing-overview"]{Windowing} @section{Basic GUI Building Blocks} @@ -18,7 +18,7 @@ MrEd's windowing toolbox provides the basic building blocks of GUI (define frame (new frame% [label "Example"])) (code:comment #, @t{Show the frame by calling its @method[top-level-window<%> show] method}) -(send frame top-level-window::show #t) +(send frame #,(:: top-level-window<%> show) #t) ] The built-in classes provide various mechanisms for handling GUI @@ -103,7 +103,7 @@ The system dispatches GUI events sequentially; that is, after invoking After the user clicks @onscreen{Pause}, the entire frame becomes unresponsive for five seconds; the system cannot dispatch more events until the call to @scheme[sleep] returns. For more information about - event dispatching, see @secref["mr:eventspaceinfo"]. + event dispatching, see @secref["eventspaceinfo"]. In addition to dispatching events, the GUI classes also handle the graphical layout of windows. Our example frame demonstrates a simple @@ -128,7 +128,7 @@ In addition to dispatching events, the GUI classes also handle the ] For more information about window layout and containers, see - @secref["mr:containeroverview"]. + @secref["containeroverview"]. @section{Core Windowing Classes} @@ -180,7 +180,7 @@ The fundamental graphical element in MrEd's windowing toolbox is an @item{@scheme[editor-canvas%] --- an @deftech{editor canvas} is a subwindow for displaying a text editor or pasteboard editor. The @scheme[editor-canvas%] class is documented with the editor classes - in @secref["mr:editor-overview"].} + in @secref["editor-overview"].} @item{@deftech{Controls} --- containees that the user can manipulate: @@ -318,7 +318,7 @@ system: @; ------------------------------------------------------------------------ -@section[#:tag "mr:containeroverview"]{Geometry Management} +@section[#:tag "containeroverview"]{Geometry Management} MrEd's geometry management makes it easy to design windows that look right on all platforms, despite different graphical representations @@ -385,15 +385,15 @@ As the example demonstrates, a stretchable container grows to fill its The following subsections describe the container system in detail, first discussing the attributes of a containee in - @secref["mr:containees"], and then describing + @secref["containees"], and then describing the attributes of a container in - @secref["mr:containers"]. In addition to the + @secref["containers"]. In addition to the built-in vertical and horizontal containers, programmers can define new types of containers as discussed in the final subsection, - @secref["mr:new-containers"]. + @secref["new-containers"]. -@subsection[#:tag "mr:containees"]{Containees} +@subsection[#:tag "containees"]{Containees} Each @tech{containee}, or child, has the following properties: @@ -414,7 +414,7 @@ A @tech{container} arranges its children based on these four container is specified when the @tech{containee} is created, and the parent cannot be changed. However, a @tech{containee} can be @tech{hidden} or @tech{deleted} within its parent, as described in - @secref["mr:containers"]. + @secref["containers"]. The @deftech{graphical minimum size} of a particular containee, as reported by @method[area<%> get-graphical-min-size], depends on the @@ -462,7 +462,7 @@ In practice, the @tech{requested minimum size} and @tech{margin} of a containee, depending on the visual effect desired by the programmer. -@subsection[#:tag "mr:containers"]{Containers} +@subsection[#:tag "containers"]{Containers} A container has the following properties: @@ -573,7 +573,7 @@ The alignment specification for a container determines how it the container. A container's alignment is changed with the @method[area-container<%> set-alignment] method. -@subsection[#:tag "mr:new-containers"]{Defining New Types of Containers} +@subsection[#:tag "new-containers"]{Defining New Types of Containers} Although nested horizontal and vertical containers can express most layout patterns, a programmer can define a new type of container with @@ -613,7 +613,7 @@ The widths and heights for both the input and output include the placing the control. -@section[#:tag "mr:mouseandkey"]{Mouse and Keyboard Events} +@section[#:tag "mouseandkey"]{Mouse and Keyboard Events} Whenever the user moves the mouse, clicks or releases a mouse button, or presses a key on the keyboard, an event is generated for some @@ -698,7 +698,7 @@ Controls, such as buttons and list boxes, handle keyboard and mouse @; ------------------------------------------------------------------------ -@section[#:tag "mr:eventspaceinfo"]{Event Dispatching and Eventspaces} +@section[#:tag "eventspaceinfo"]{Event Dispatching and Eventspaces} @section-index["events" "dispatching"] @@ -754,12 +754,12 @@ In MrEd, an @deftech{eventspace} is a context for processing GUI @index['("dialogs" "modal")]{When} a frame or dialog is created without a parent, it is associated with the @tech{current eventspace} - as described in @secref["mr:currenteventspace"]. Events for a + as described in @secref["currenteventspace"]. Events for a top-level window and its descendants are always dispatched in the window's eventspace. Every dialog is modal; a dialog's @method[dialog% show] method implicitly calls @scheme[yield] to handle events while the dialog is shown. (See also - @secref["mr:espacethreads"] for information about threads and modal + @secref["espacethreads"] for information about threads and modal dialogs.) Furthermore, when a modal dialog is shown, the system disables all other top-level windows in the dialog's eventspace, but windows in other eventspaces are unaffected by the modal dialog. @@ -783,7 +783,7 @@ In addition to events corresponding to user and windowing actions, call the timer's @method[timer% notify] method. Like a top-level window, each timer is associated with a particular eventspace (the @tech{current eventspace} as described in - @secref["mr:currenteventspace"]) when it is created, and the timer + @secref["currenteventspace"]) when it is created, and the timer queues the event in its eventspace. @deftech{Explicitly queued events} are created with @@ -817,10 +817,10 @@ Although a programmer has no direct control over the order in which dispatches by setting the event dispatch handler via the @scheme[event-dispatch-handler] parameter. This parameter and other eventspace procedures are described in more detail in - @secref["mr:eventspace-funcs"]. + @secref["eventspace-funcs"]. -@subsection[#:tag "mr:espacethreads"]{Eventspaces and Threads} +@subsection[#:tag "espacethreads"]{Eventspaces and Threads} When a new eventspace is created, a corresponding @deftech{handler thread} is created for the eventspace. When the system dispatches an @@ -840,7 +840,7 @@ When a handler thread shows a dialog, the dialog's @method[dialog% @scheme[semaphore-wait]. -@subsection[#:tag "mr:currenteventspace"]{Creating and Setting the Eventspace} +@subsection[#:tag "currenteventspace"]{Creating and Setting the Eventspace} Whenever a frame, dialog, or timer is created, it is associated with the @deftech{current eventspace} as determined by the @@ -858,23 +858,24 @@ The @scheme[make-eventspace] procedure creates a new ] When an eventspace is created, it is placed under the management of - the @tech{current custodian}. When a custodian shuts down an - eventspace, all frames and dialogs associated with the eventspace are - destroyed (without calling @method[top-level-window<%> can-close?] - or @xmethod[top-level-window<%> on-close]), all timers in the - eventspace are stopped, and all enqueued callbacks are removed. - Attempting to create a new window, timer, or explicitly queued event - in a shut-down eventspace raises the @scheme[exn:misc] exception. + the @tech[#:doc reference-doc]{current custodian}. When a custodian + shuts down an eventspace, all frames and dialogs associated with the + eventspace are destroyed (without calling @method[top-level-window<%> + can-close?] or @xmethod[top-level-window<%> on-close]), all timers + in the eventspace are stopped, and all enqueued callbacks are + removed. Attempting to create a new window, timer, or explicitly + queued event in a shut-down eventspace raises the @scheme[exn:misc] + exception. -An eventspace is a @techlink{synchronizable event} (not to be confused - with a GUI event), so it can be used with @scheme[sync]. As a - synchronizable event, an eventspace is in a blocking state when a - frame is visible, a timer is active, a callback is queued, or a - @scheme[menu-bar%] is created with a @scheme['root] parent. (Note - that the blocking state of an eventspace is unrelated to whether an - event is ready for dispatching.) +An eventspace is a @techlink[#:doc reference-doc]{synchronizable + event} (not to be confused with a GUI event), so it can be used with + @scheme[sync]. As a synchronizable event, an eventspace is in a + blocking state when a frame is visible, a timer is active, a callback + is queued, or a @scheme[menu-bar%] is created with a @scheme['root] + parent. (Note that the blocking state of an eventspace is unrelated + to whether an event is ready for dispatching.) -@subsection[#:tag "mr:evtcontjump"]{Exceptions and Continuation Jumps} +@subsection[#:tag "evtcontjump"]{Exceptions and Continuation Jumps} Whenever the system dispatches an event, the call to the handler procedure is wrapped so that full continuation jumps are not allowed diff --git a/collects/scribblings/guide/apply.scrbl b/collects/scribblings/guide/apply.scrbl index 6bacfcaaf0..62a8b390ae 100644 --- a/collects/scribblings/guide/apply.scrbl +++ b/collects/scribblings/guide/apply.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:application"]{Function Calls@aux-elem{ (Procedure Applications)}} +@title[#:tag "application"]{Function Calls@aux-elem{ (Procedure Applications)}} An expression of the form @@ -39,14 +39,14 @@ arguments. A function's @idefterm{arity} is the number of arguments that it accepts. @;------------------------------------------------------------------------ -@section[#:tag "guide:keyword-args"]{Keyword Arguments} +@section[#:tag "keyword-args"]{Keyword Arguments} Some functions accept @defterm{keyword arguments} in addition to by-position arguments. For that case, an @scheme[_arg] can be an @scheme[_arg-keyword _arg-expr] sequence instead of just a @scheme[_arg-expr]: -@guideother{@secref["guide:keywords"] introduces keywords.} +@guideother{@secref["keywords"] introduces keywords.} @specform/subs[ (_proc-expr _arg ...) @@ -78,10 +78,10 @@ above call to @scheme[go] can be equivalently written @schemeblock[(go #:mode 'fast "super.ss")] -@refdetails["mz:application"]{procedure applications} +@refdetails["application"]{procedure applications} @;------------------------------------------------------------------------ -@section[#:tag "guide:apply"]{The @scheme[apply] Function} +@section[#:tag "apply"]{The @scheme[apply] Function} The syntax for function calls supports any number of arguments, but a specific call always specifies a fixed number of arguments. As a diff --git a/collects/scribblings/guide/begin.scrbl b/collects/scribblings/guide/begin.scrbl index c77e3f99ba..1338bbc559 100644 --- a/collects/scribblings/guide/begin.scrbl +++ b/collects/scribblings/guide/begin.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:begin"]{Sequencing} +@title[#:tag "begin"]{Sequencing} Scheme programmers prefer to write programs with as few side-effects as possible, since purely functional code is more easily tested and @@ -14,7 +14,7 @@ display, opening a graphical window, or manipulating a file on disk. @;------------------------------------------------------------------------ @section{Effects Before: @scheme[begin]} -@refalso["mz:begin"]{@scheme[begin]} +@refalso["begin"]{@scheme[begin]} A @scheme[begin] expression sequences expressions: @@ -64,12 +64,12 @@ positions, instead of forming an expression, the content of ] This splicing behavior is mainly useful for macros, as we discuss -later in @secref["guide:macros"]. +later in @secref["macros"]. @;------------------------------------------------------------------------ @section{Effects After: @scheme[begin0]} -@refalso["mz:begin"]{@scheme[begin0]} +@refalso["begin"]{@scheme[begin0]} A @scheme[begin0] expression has the same syntax as a @scheme[begin] expression: @@ -93,9 +93,9 @@ computation produces an unknown number of results. ] @;------------------------------------------------------------------------ -@section[#:tag "guide:when+unless"]{Effects If...: @scheme[when] and @scheme[unless]} +@section[#:tag "when+unless"]{Effects If...: @scheme[when] and @scheme[unless]} -@refalso["mz:when+unless"]{@scheme[when] and @scheme[unless]} +@refalso["when+unless"]{@scheme[when] and @scheme[unless]} The @scheme[when] form combines an @scheme[if]-style conditional with sequencing for the ``then'' clause and no ``else'' clause: diff --git a/collects/scribblings/guide/binding.scrbl b/collects/scribblings/guide/binding.scrbl index 8289bcb448..fa84a14e43 100644 --- a/collects/scribblings/guide/binding.scrbl +++ b/collects/scribblings/guide/binding.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:binding"]{Identifiers and Binding} +@title[#:tag "binding"]{Identifiers and Binding} The context of an expression determines the meaning of identifiers that appear in the expression. In particular, starting a module with @@ -16,7 +16,7 @@ start with the meaning described here: @scheme[cons] refers to the function that creates a pair, @scheme[car] refers to the function that extracts the first element of a pair, and so on. -@guideother{@secref["guide:symbols"] introduces the syntax of +@guideother{@secref["symbols"] introduces the syntax of identifiers.} Forms like @scheme[define], @scheme[lambda], and @scheme[let] diff --git a/collects/scribblings/guide/booleans.scrbl b/collects/scribblings/guide/booleans.scrbl index 29ab4682f3..393f71e536 100644 --- a/collects/scribblings/guide/booleans.scrbl +++ b/collects/scribblings/guide/booleans.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:booleans"]{Booleans} +@title[#:tag "booleans"]{Booleans} Scheme has two distinguished constants to represent boolean values: @scheme[#t] for true and @scheme[#f] for false. Uppercase diff --git a/collects/scribblings/guide/boxes.scrbl b/collects/scribblings/guide/boxes.scrbl index c7b62c65dc..7d36f10f47 100644 --- a/collects/scribblings/guide/boxes.scrbl +++ b/collects/scribblings/guide/boxes.scrbl @@ -18,4 +18,4 @@ b b ] -@refdetails["mz:boxes"]{boxes and box procedures} +@refdetails["boxes"]{boxes and box procedures} diff --git a/collects/scribblings/guide/byte-strings.scrbl b/collects/scribblings/guide/byte-strings.scrbl index 89bd6a0990..a5d956c861 100644 --- a/collects/scribblings/guide/byte-strings.scrbl +++ b/collects/scribblings/guide/byte-strings.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:bytestrings"]{Bytes and Byte Strings} +@title[#:tag "bytestrings"]{Bytes and Byte Strings} A @defterm{byte} is an inexact integer between @scheme[0] and @scheme[255], inclusive. The @scheme[byte?] predicate recognizes @@ -15,7 +15,7 @@ numbers that represent bytes. ] A @defterm{byte string} is similar to a string---see -@secref["guide:strings"]---but its content is a sequence of bytes +@secref["strings"]---but its content is a sequence of bytes instead of characters. Byte strings can be used in applications that process pure ASCII instead of Unicode text. The printed and form of a byte string supports such uses in particular, because a byte string @@ -23,7 +23,7 @@ prints like the ASCII decoding of the byte string, but prefixed with a @litchar{#}. Unprintable ASCII characters or non-ASCII bytes in the byte string are written with octal notation. -@refdetails/gory["mz:parse-string"]{the syntax of byte strings} +@refdetails/gory["parse-string"]{the syntax of byte strings} @examples[ #"Apple" @@ -37,7 +37,7 @@ b ] The @scheme[display] form of a byte string writes its raw bytes to the -current output port (see @secref["guide:i/o"]). Technically, +current output port (see @secref["i/o"]). Technically, @scheme[display] of a normal (i.e,. character) string prints the UTF-8 encoding of the string to the current output port, since output is ultimately defined in terms of bytes; @scheme[display] of a byte @@ -72,4 +72,4 @@ arbitrary string encodings. (bytes->string/utf-8 dest)) ] -@refdetails["mz:bytestrings"]{byte strings and byte-string procedures} +@refdetails["bytestrings"]{byte strings and byte-string procedures} diff --git a/collects/scribblings/guide/certificates.scrbl b/collects/scribblings/guide/certificates.scrbl index 285a679c63..63a888a515 100644 --- a/collects/scribblings/guide/certificates.scrbl +++ b/collects/scribblings/guide/certificates.scrbl @@ -59,7 +59,7 @@ these certifications, the macro expander rejects the local-binding reference, and @scheme[unchecked-go] remains protected. In much the same way that the macro expander copies properties from a -syntax transformer's input to its output (see @secref["mz:stxprops"]), +syntax transformer's input to its output (see @refsecref["stxprops"]), the expander copies certificates from a transformer's input to its output. Building on the previous example, @@ -81,11 +81,11 @@ to @scheme[unchecked-go]. When a protected identifier becomes inaccessible by direct reference (i.e., when the current code inspector is changed so that it does not -control the module's invocation; see @secref["mz:modprotect"]), the +control the module's invocation; see @refsecref["modprotect"]), the protected identifier is treated like an unexported identifier. @;------------------------------------------------------------------------ -@section[#:tag "mz:stxinactivecerts"]{Certificate Propagation} +@section[#:tag "stxinactivecerts"]{Certificate Propagation} When the result of a macro expansion contains a @scheme[quote-syntax] form, the macro expansion's certificate must be attached to the @@ -239,7 +239,7 @@ handling recursively, in case a macro produces a @scheme[begin] form that contains nested @scheme[define-values] forms. The default application of certificates can be overridden by attaching -a @scheme['certify-mode] property (see @secref["mz:stxprops"]) to the +a @scheme['certify-mode] property (see @refsecref["stxprops"]) to the result syntax object of a macro transformer. If the property value is @scheme['opaque], then the certificate is attached to the syntax object and not its parts. If the property value is diff --git a/collects/scribblings/guide/char-strings.scrbl b/collects/scribblings/guide/char-strings.scrbl index ed00e518ca..5f03eee2bf 100644 --- a/collects/scribblings/guide/char-strings.scrbl +++ b/collects/scribblings/guide/char-strings.scrbl @@ -3,10 +3,10 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:strings"]{Strings (Unicode)} +@title[#:tag "strings"]{Strings (Unicode)} A @defterm{string} is a fixed-length array of -@seclink["guide:characters"]{characters}. It prints using doublequotes, +@seclink["characters"]{characters}. It prints using doublequotes, where doublequote and backslash characters within the string are escaped with backslashes. Other common string escapes are supported, including @litchar["\\n"] for a linefeed, @litchar["\\r"] for a @@ -15,10 +15,10 @@ to three octal digits, and hexadimal escapes with @litchar["\\u"] (up to four digits). Unprintable characters in a string normally shown with @litchar["\\u"] when the string is printed. -@refdetails/gory["mz:parse-string"]{the syntax of strings} +@refdetails/gory["parse-string"]{the syntax of strings} The @scheme[display] procedure directly writes the characters of a -string to the current output port (see @secref["guide:i/o"]), in contrast +string to the current output port (see @secref["i/o"]), in contrast to the string-constant syntax used to print a string result. @examples[ @@ -66,6 +66,6 @@ for an end user. For working with plain ASCII, working with raw bytes, or encoding/decoding Unicode strings as bytes, use -@seclink["guide:bytestrings"]{byte strings}. +@seclink["bytestrings"]{byte strings}. -@refdetails["mz:strings"]{strings and string procedures} +@refdetails["strings"]{strings and string procedures} diff --git a/collects/scribblings/guide/chars.scrbl b/collects/scribblings/guide/chars.scrbl index 96300ba532..a5c4ef3876 100644 --- a/collects/scribblings/guide/chars.scrbl +++ b/collects/scribblings/guide/chars.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:characters"]{Characters} +@title[#:tag "characters"]{Characters} A Scheme @defterm{character} corresponds to a Unicode @defterm{scalar value}. Roughly, a scalar value is an unsigned integer whose @@ -26,7 +26,7 @@ number. A few characters are printed specially; for example, the space and linefeed characters print as @scheme[#\space] and @scheme[#\newline], respectively. -@refdetails/gory["mz:parse-character"]{the syntax of characters} +@refdetails/gory["parse-character"]{the syntax of characters} @examples[ (integer->char 65) @@ -38,7 +38,7 @@ and linefeed characters print as @scheme[#\space] and ] The @scheme[display] procedure directly writes a character to the -current output port (see @secref["guide:i/o"]), in contrast to the +current output port (see @secref["i/o"]), in contrast to the character-constant syntax used to print a character result. @examples[ @@ -72,4 +72,4 @@ characters. (eqv? #\a #\A) ] -@refdetails["mz:characters"]{characters and character procedures} +@refdetails["characters"]{characters and character procedures} diff --git a/collects/scribblings/guide/class.scrbl b/collects/scribblings/guide/class.scrbl index 45a26c87b9..a82e90bb18 100644 --- a/collects/scribblings/guide/class.scrbl +++ b/collects/scribblings/guide/class.scrbl @@ -95,7 +95,7 @@ avoid imperative assignment. The relative order of method declarations makes no difference for evaluation, because methods are fully defined before a class is instantiated. -@section[#:tag "guide:methods"]{Methods} +@section[#:tag "methods"]{Methods} Each of the three @scheme[define/public] declarations in @scheme[fish%] introduces a new method. The declaration uses the same @@ -196,7 +196,7 @@ 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. -@section[#:tag "guide:initargs"]{Initialization Arguments} +@section[#:tag "initargs"]{Initialization Arguments} Since @scheme[picky-fish%] declares no initialization arguments, any initialization values supplied in @scheme[(new picky-fish% ...)] are @@ -235,7 +235,7 @@ In this example, the @scheme[super-new] call propagates its own @scheme[size] value as the @scheme[size] initialization argument to the superclass. -@section[#:tag "guide:intnames"]{Internal and External Names} +@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 @@ -298,7 +298,7 @@ checks whether the object's class implements the interface. In addition, the @scheme[implementation?] predicate checks whether a given class implements a given interface. -@section[#:tag "guide:inner"]{Final, Augment, and Inner} +@section[#:tag "inner"]{Final, Augment, and Inner} As in Java, a method in a @scheme[class] form can be specified as @defterm{final}, which means that a subclass cannot override the @@ -324,9 +324,9 @@ and makes the overriding implementation augmentable. Our earlier work~\cite{Super+Inner} motivates and explains these extensions and their interleaving. -@section[#:tag "guide:extnames"]{Controlling the Scope of External Names} +@section[#:tag "extnames"]{Controlling the Scope of External Names} -As noted in @secref["guide:intnames"], class members have both +As noted in @secref["intnames"], class members have both internal and external names. A member definition binds an internal name locally, and this binding can be locally renamed. External names, in contrast, have global scope by default, and a member diff --git a/collects/scribblings/guide/cond.scrbl b/collects/scribblings/guide/cond.scrbl index 4b4c4de131..7a2eb47a31 100644 --- a/collects/scribblings/guide/cond.scrbl +++ b/collects/scribblings/guide/cond.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:conditionals"]{Conditionals} +@title[#:tag "conditionals"]{Conditionals} Most functions used for branching, such as @scheme[<] and @scheme[string?], produce either @scheme[#t] or @scheme[#f]. Scheme's @@ -35,7 +35,7 @@ list: @;------------------------------------------------------------------------ @section{Simple Branching: @scheme[if]} -@refalso["mz:if"]{@scheme[if]} +@refalso["if"]{@scheme[if]} In an @scheme[if] form, @@ -48,12 +48,12 @@ evaluated. Otherwise, @scheme[_else-expr] is evaluated. An @scheme[if] form must have both an @scheme[_then-expr] and an @scheme[_else-expr]; the latter is not optional. To perform (or skip) side-effects based on a @scheme[_test-expr], use @scheme[when] or -@scheme[unless], which we describe later in @secref["guide:begin"]. +@scheme[unless], which we describe later in @secref["begin"]. @;------------------------------------------------------------------------ -@section[#:tag "guide:and+or"]{Combining Tests: @scheme[and] and @scheme[or]} +@section[#:tag "and+or"]{Combining Tests: @scheme[and] and @scheme[or]} -@refalso["mz:if"]{@scheme[and] and @scheme[or]} +@refalso["if"]{@scheme[and] and @scheme[or]} Scheme's @scheme[and] and @scheme[or] are syntactic forms, rather than functions. Unlike a function, the @scheme[and] and @scheme[or] forms @@ -90,16 +90,16 @@ the @scheme[and] or @scheme[or] result. Therefore, the last @scheme[expr] is in tail position, which means that the above @scheme[got-milk?] function runs in constant space. -@guideother{@secref["guide:tail-recursion"] introduces tail calls and tail positions.} +@guideother{@secref["tail-recursion"] introduces tail calls and tail positions.} @;------------------------------------------------------------------------ -@section[#:tag "guide:cond"]{Chaining Tests: @scheme[cond]} +@section[#:tag "cond"]{Chaining Tests: @scheme[cond]} The @scheme[cond] form chains a series of tests to select a result expression. To a first approximation, the syntax of @scheme[cond] is as follows: -@refalso["mz:if"]{@scheme[cond]} +@refalso["if"]{@scheme[cond]} @specform[(cond [test-expr expr ...+] ...)] diff --git a/collects/scribblings/guide/data.scrbl b/collects/scribblings/guide/data.scrbl index 6987f0a6c8..dc6bfabca3 100644 --- a/collects/scribblings/guide/data.scrbl +++ b/collects/scribblings/guide/data.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:datatypes" #:style 'toc]{Built-In Datatypes} +@title[#:tag "datatypes" #:style 'toc]{Built-In Datatypes} The @seclink["to-scheme"]{previous chapter} introduced some of Scheme's built-in datatype: numbers, booleans, strings, lists, and diff --git a/collects/scribblings/guide/define-struct.scrbl b/collects/scribblings/guide/define-struct.scrbl index add6c80762..3cab5dbd64 100644 --- a/collects/scribblings/guide/define-struct.scrbl +++ b/collects/scribblings/guide/define-struct.scrbl @@ -4,9 +4,9 @@ @require[(lib "bnf.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:define-struct"]{Programmer-Defined Datatypes} +@title[#:tag "define-struct"]{Programmer-Defined Datatypes} -@refalso["mz:structures"]{structure types} +@refalso["structures"]{structure types} New datatypes are normally created with the @scheme[define-struct] form, which is the topic of this chapter. The class-based object @@ -17,7 +17,7 @@ implemented in terms of structure types. @; ------------------------------------------------------------ @section{Simple Structure Types: @scheme[define-struct]} -@refalso["mz:define-struct"]{@scheme[define-struct]} +@refalso["define-struct"]{@scheme[define-struct]} To a first approximation, the syntax of @scheme[define-struct] is @@ -35,7 +35,7 @@ posn ] We explain one use of the @scheme[_struct-id] binding in the next -section, @secref["guide:struct-subtypes"]. +section, @secref["struct-subtypes"]. Meanwhile, in addition to defining @scheme[_struct-id], @scheme[define-struct] also defines a number of identifiers that are @@ -78,7 +78,7 @@ built from @scheme[_struct-id] and the @scheme[_field-id]s: @deftech{structure type descriptor}, which is a value that represents the structure type as a first-class value (with @scheme[#:super], as discussed later in - @secref["guide:struct-options"]).} + @secref["struct-options"]).} } @@ -89,10 +89,10 @@ instance of @scheme[posn], even though @scheme["apple"] and @scheme[#f] are not valid coordinates for the obvious uses of @scheme[posn] instances. Enforcing constraints on field values, such as requiring them to be numbers, is normally the job of a contract, as -discussed later in @secref["guide:contracts"]. +discussed later in @secref["contracts"]. @; ------------------------------------------------------------ -@section[#:tag "guide:struct-subtypes"]{Structure Subtypes} +@section[#:tag "struct-subtypes"]{Structure Subtypes} An extended form of @scheme[define-struct] can be used to define a @defterm{structure subtype}, which is a structure type that extends an @@ -126,7 +126,7 @@ p ] @; ------------------------------------------------------------ -@section[#:tag "guide:trans-struct"]{Opaque versus Transparent Stucture Types} +@section[#:tag "trans-struct"]{Opaque versus Transparent Stucture Types} With a structure type definition like @@ -164,7 +164,7 @@ library cannot manipulate the data in the structure except as allowed by the library. @; ------------------------------------------------------------ -@section[#:tag "guide:struct-options"]{More Structure Type Options} +@section[#:tag "struct-options"]{More Structure Type Options} The full syntax of @scheme[define-struct] supports many options, both at the structure-type level and at the level of individual fields: @@ -198,7 +198,7 @@ A @scheme[_struct-option] always starts with a keyword: @specspecsubform[(code:line #:inspector inspector-expr)]{ Controls reflective access to structure instances, as discussed - in the previous section (@secref["guide:trans-struct"]). + in the previous section (@secref["trans-struct"]). } @specspecsubform[(code:line #:auto-value auto-expr)]{ @@ -327,4 +327,4 @@ times. (add-bigger-fish (add-bigger-fish null)) ] -@refdetails["mz:structures"]{structure types} +@refdetails["structures"]{structure types} diff --git a/collects/scribblings/guide/define.scrbl b/collects/scribblings/guide/define.scrbl index 5f43eb83ea..8df75d065d 100644 --- a/collects/scribblings/guide/define.scrbl +++ b/collects/scribblings/guide/define.scrbl @@ -4,7 +4,7 @@ @require["guide-utils.ss"] @require[(lib "string.ss")] -@title[#:tag "guide:define"]{Definitions: @scheme[define]} +@title[#:tag "define"]{Definitions: @scheme[define]} A basic definition has the form @@ -127,7 +127,7 @@ for each @scheme[_head] in the definition, where the innermost @;------------------------------------------------------------------------ -@section[#:tag "guide:multiple-values"]{Multiple Values and @scheme[define-values]} +@section[#:tag "multiple-values"]{Multiple Values and @scheme[define-values]} A Scheme expression normally produces a single result, but some expressions can produce multiple results. For example, @@ -176,10 +176,10 @@ surname A @scheme[define] form (that is not a function shorthand) is equivalent to a @scheme[define-values] form with a single @scheme[_id]. -@refdetails["mz:define"]{definitions} +@refdetails["define"]{definitions} @;------------------------------------------------------------------------ -@section[#:tag "guide:intdefs"]{Internal Definitions} +@section[#:tag "intdefs"]{Internal Definitions} When the grammar for a syntactic form specifies @scheme[_body], then the corresponding form can be either a definition or an expression. @@ -240,7 +240,7 @@ A sequence of internal definitions using just @scheme[define] is easily translated to an equivalent @scheme[letrec] form (as introduced in the next section). However, other definition forms can appear as a @scheme[_body], including @scheme[define-values], @scheme[define-struct] (see -@secref["guide:define-struct"]) or @scheme[define-syntax] (see -@secref["guide:macros"]). +@secref["define-struct"]) or @scheme[define-syntax] (see +@secref["macros"]). -@refdetails/gory["mz:intdef-body"]{internal definitions} +@refdetails/gory["intdef-body"]{internal definitions} diff --git a/collects/scribblings/guide/for.scrbl b/collects/scribblings/guide/for.scrbl index 30c57aea50..a8d5563392 100644 --- a/collects/scribblings/guide/for.scrbl +++ b/collects/scribblings/guide/for.scrbl @@ -4,7 +4,7 @@ @require["guide-utils.ss"] @require[(lib "for.ss")] -@title[#:tag "guide:for"]{Iterations and Comprehensions} +@title[#:tag "for"]{Iterations and Comprehensions} The @scheme[for] family of syntactic forms support iteration over @defterm{sequences}. Lists, vectors, strings, byte strings, input @@ -55,7 +55,7 @@ iterations can be included along with bindings. Before details on the variations of @scheme[for], though, it's best to see the kinds of sequence generators that make interesting examples. -@section[#:tag "guide:sequences"]{Sequence Constructors} +@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 @@ -115,7 +115,7 @@ code generation; see @secref["for-performance"] for more information. (display i)) ] -@refdetails["mz:sequences"]{sequences} +@refdetails["sequences"]{sequences} @section{@scheme[for] and @scheme[for*]} @@ -290,7 +290,7 @@ the same facility with nested iterations: (list book chapter)) ] -@section[#:tag "guide:for/fold"]{@scheme[for/fold] and @scheme[for*/fold]} +@section[#:tag "for/fold"]{@scheme[for/fold] and @scheme[for*/fold]} The @scheme[for/fold] form generalizes the way to combine iteration results. Its syntax is slightly different than the syntax of @@ -438,4 +438,4 @@ 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]. -@refdetails["mz:for"]{iterations and comprehensions} +@refdetails["for"]{iterations and comprehensions} diff --git a/collects/scribblings/guide/forms.scrbl b/collects/scribblings/guide/forms.scrbl index 44154ff327..c940f2ae02 100644 --- a/collects/scribblings/guide/forms.scrbl +++ b/collects/scribblings/guide/forms.scrbl @@ -12,7 +12,7 @@ additional basic forms. @local-table-of-contents[] -@section[#:tag "guide:syntax-notation"]{Notation} +@section[#:tag "syntax-notation"]{Notation} This chapter (and the rest of the documentation) uses a slightly different notation than the character-based grammars of the @@ -42,7 +42,7 @@ convention implicitly defines the meaning of many meta-variables: sub-form; it will be parsed as either a local definition or an expression. A @scheme[_body] can parse as a definition only if it is not preceded by any expression, and the last - @scheme[_body] must be an expression; see also @secref["guide:intdefs"].} + @scheme[_body] must be an expression; see also @secref["intdefs"].} } diff --git a/collects/scribblings/guide/guide-utils.ss b/collects/scribblings/guide/guide-utils.ss index 7274dbb545..87b1f31f01 100644 --- a/collects/scribblings/guide/guide-utils.ss +++ b/collects/scribblings/guide/guide-utils.ss @@ -6,6 +6,9 @@ (lib "eval.ss" "scribble") "../icons.ss") + (require-for-label (lib "lang.ss" "big")) + (provide-for-label (all-from (lib "lang.ss" "big"))) + (provide Quick MzScheme HtDP tool moreguide @@ -13,13 +16,11 @@ refalso refdetails refdetails/gory - refsecref) + refsecref + ext-refsecref) (define Quick - (italic (link "../quick/index.html" "An Introduction to PLT Scheme with Pictures"))) - - (define MzScheme - (italic (link "../reference/index.html" "PLT Scheme Reference"))) + (italic (secref #:doc '(lib "quick.scrbl" "scribblings" "quick") "top"))) (define HtDP (italic (link "http://www.htdp.org" "How to Design Programs"))) @@ -42,7 +43,7 @@ (define (refdetails* tag what . s) (apply margin-note - (decode-content (append (list magnify (refsecref tag)) + (decode-content (append (list magnify (ext-refsecref tag)) (list what) s (list "."))))) @@ -57,4 +58,10 @@ (apply refdetails* tag " documents the fine points of " s)) (define (refsecref s) - (make-element #f (list (secref s) " in " MzScheme)))) + (secref #:doc '(lib "reference.scrbl" "scribblings" "reference") s)) + + (define (ext-refsecref s) + (make-element #f (list (refsecref s) " in " MzScheme))) + + (define MzScheme + (italic (refsecref "top")))) diff --git a/collects/scribblings/guide/guide.scrbl b/collects/scribblings/guide/guide.scrbl index 8142d7021a..c67ef987db 100644 --- a/collects/scribblings/guide/guide.scrbl +++ b/collects/scribblings/guide/guide.scrbl @@ -3,7 +3,8 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title{A Guide to PLT Scheme} +@title[#:tag-prefix '(lib "guide.scrbl" "scribblings" "guide") + #:tag "top"]{A Guide to PLT Scheme} This guide is intended for programmers who are new to Scheme, new to PLT Scheme, or new to some part of PLT Scheme. It assumes @@ -36,7 +37,7 @@ precise details to @|MzScheme| and other reference manuals. @include-section["io.scrbl"] @; ---------------------------------------------------------------------- -@section[#:tag "guide:contracts"]{Contracts} +@section[#:tag "contracts"]{Contracts} In the reference manual, the documentation for each procedure describes the acceptable arguments and the result of the procedure @@ -79,6 +80,12 @@ of an expression to the values for the clause: @; ---------------------------------------------------------------------- @section[#:tag "threads"]{Threads} +@subsection[#:tag "parameters"]{Parameters} + +A @deftech{parameter} holds a kind of global option. For example, +there is a parameter that determines the default destination for +printed output. + @; ---------------------------------------------------------------------- @include-section["macros.scrbl"] @@ -97,9 +104,9 @@ of an expression to the values for the clause: @; ---------------------------------------------------------------------- @section[#:tag "memory-management"]{Memory Management} -@subsection[#:tag "guide:weakboxes"]{Weak Boxes} +@subsection[#:tag "weakboxes"]{Weak Boxes} -@subsection[#:tag "guide:ephemerons"]{Ephemerons} +@subsection[#:tag "ephemerons"]{Ephemerons} @; ---------------------------------------------------------------------- @section[#:tag "performance"]{Performance} @@ -121,7 +128,7 @@ constant propagation, constant folding, and inlining optimizations. @; ---------------------------------------------------------------------- -@section[#:tag "guide:mred"]{Graphical User Interfaces@aux-elem{ (GUIs)}} +@section[#:tag "mred"]{Graphical User Interfaces@aux-elem{ (GUIs)}} @deftech{MrEd} is both a library and an executable. As a library, @scheme[(lib "mred/mred.ss")] provides class, interface, and function diff --git a/collects/scribblings/guide/hash-tables.scrbl b/collects/scribblings/guide/hash-tables.scrbl index 4d4abc4576..09f1890ff1 100644 --- a/collects/scribblings/guide/hash-tables.scrbl +++ b/collects/scribblings/guide/hash-tables.scrbl @@ -33,7 +33,7 @@ key--value pair. Literal hash tables are immutable. (hash-table-get ht "apple") ] -@refdetails/gory["mz:parse-hashtable"]{the syntax of hash table literals} +@refdetails/gory["parse-hashtable"]{the syntax of hash table literals} A hash table can optionally retain its keys @defterm{weakly}, so each mapping is retained only so long as the key is retained elsewhere. @@ -49,7 +49,7 @@ Beware that even a weak hash table retains its values strongly, as long as the corresponding key is accessible. This creates a catch-22 dependency when a value refers back to its key, so that the mapping is retained permanently. To break the cycle, map the key to an -@seclink["guide:ephemerons"]{ephemeron} that pairs the value with its key (in +@seclink["ephemerons"]{ephemeron} that pairs the value with its key (in addition to the implicit pairing of the hash table). @examples[ @@ -68,4 +68,4 @@ addition to the implicit pairing of the hash table). (eval:alts (hash-table-count ht) 0) ] -@refdetails["mz:hashtables"]{hash tables and hash-table procedures} +@refdetails["hashtables"]{hash tables and hash-table procedures} diff --git a/collects/scribblings/guide/info.ss b/collects/scribblings/guide/info.ss new file mode 100644 index 0000000000..9bd27119a9 --- /dev/null +++ b/collects/scribblings/guide/info.ss @@ -0,0 +1,3 @@ +(module info (lib "infotab.ss" "setup") + (define name "Scribblings: Guide") + (define scribblings '(("guide.scrbl" (multi-page main-doc))))) diff --git a/collects/scribblings/guide/io.scrbl b/collects/scribblings/guide/io.scrbl index 2cff0604f6..b88afdf3aa 100644 --- a/collects/scribblings/guide/io.scrbl +++ b/collects/scribblings/guide/io.scrbl @@ -12,7 +12,7 @@ (make-flow (list b)))))] @interaction-eval[(print-hash-table #t)] -@title[#:tag "guide:i/o" #:style 'toc]{Input and Output} +@title[#:tag "i/o" #:style 'toc]{Input and Output} A Scheme @defterm{port} represents an input or output stream, such as a file, a terminal, a TCP connection, or an in-memory string. More @@ -167,7 +167,7 @@ stdout in purple, and output written to stderr in red italics. The current-port functions actually @tech{parameters}, which means that their values can be set with @scheme[parameterize]. -@moreguide["guide:parameters"]{parameters} +@moreguide["parameters"]{parameters} @examples[ (let ([s (open-output-string)]) @@ -181,7 +181,7 @@ that their values can be set with @scheme[parameterize]. @; ---------------------------------------------------------------------- @section{Reading and Writing Scheme Data} -As noted throughout @secref["guide:datatypes"], Scheme provides two +As noted throughout @secref["datatypes"], Scheme provides two ways to print an instance of a built-in value: @itemize{ diff --git a/collects/scribblings/guide/keywords.scrbl b/collects/scribblings/guide/keywords.scrbl index 960a2ff07c..7af3d01994 100644 --- a/collects/scribblings/guide/keywords.scrbl +++ b/collects/scribblings/guide/keywords.scrbl @@ -3,13 +3,13 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:keywords"]{Keywords} +@title[#:tag "keywords"]{Keywords} A @defterm{keyword} value is similar to a symbol (see -@secref["guide:symbols"]), but its printed form is prefixed with +@secref["symbols"]), but its printed form is prefixed with @litchar{#:}. -@refdetails/gory["mz:parse-keyword"]{the syntax of keywords} +@refdetails/gory["parse-keyword"]{the syntax of keywords} @examples[ (string->keyword "apple") diff --git a/collects/scribblings/guide/lambda.scrbl b/collects/scribblings/guide/lambda.scrbl index 54e92ea4b9..ff56e835ac 100644 --- a/collects/scribblings/guide/lambda.scrbl +++ b/collects/scribblings/guide/lambda.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:lambda"]{Functions@aux-elem{ (Procedures)}: @scheme[lambda]} +@title[#:tag "lambda"]{Functions@aux-elem{ (Procedures)}: @scheme[lambda]} A @scheme[lambda] expression creates a function. In the simplest case, a @scheme[lambda] expression has the form @@ -51,7 +51,7 @@ into a list bound to @scheme[_rest-id]. Functions with a @scheme[_rest-id] often use @scheme[apply] to call another function that accepts any number of arguments. -@guideother{@secref["guide:apply"] describes @scheme[apply].} +@guideother{@secref["apply"] describes @scheme[apply].} @defexamples[ (define max-mag @@ -129,14 +129,14 @@ and every following @scheme[_arg-id] must have a default as well. (greet "Adam") ] -@section[#:tag "guide:lambda-keywords"]{Declaring Keyword Arguments} +@section[#:tag "lambda-keywords"]{Declaring Keyword Arguments} A @scheme[lambda] form can declare an argument to be passed by keyword, instead of position. Keyword arguments can be mixed with by-position arguments, and default-value expressions can be supplied for either kind of argument: -@guideother{@secref["guide:keyword-args"] introduces function +@guideother{@secref["keyword-args"] introduces function calls with keywords.} @specform/subs[ @@ -186,7 +186,7 @@ through parallel lists in the first two (by-position) arguments, and then all by-position arguments from an application as the remaining by-position arguments. -@guideother{@secref["guide:apply"] inroduces @scheme[keyword-apply].} +@guideother{@secref["apply"] inroduces @scheme[keyword-apply].} @defexamples[ (define (trace-wrap f) @@ -197,7 +197,7 @@ remaining by-position arguments. ((trace-wrap greet) "John" #:hi "Howdy") ] -@refdetails["mz:lambda"]{function expressions} +@refdetails["lambda"]{function expressions} @;------------------------------------------------------------------------ @section{Arity-Sensitive Functions: @scheme[case-lambda]} diff --git a/collects/scribblings/guide/let.scrbl b/collects/scribblings/guide/let.scrbl index 3216ff4ad8..65d1d71a15 100644 --- a/collects/scribblings/guide/let.scrbl +++ b/collects/scribblings/guide/let.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:let"]{Local Binding} +@title[#:tag "let"]{Local Binding} Although internal @scheme[define]s can be used for local binding, Scheme provides three forms that give the programmer more @@ -13,7 +13,7 @@ control over bindings: @scheme[let], @scheme[let*], and @;------------------------------------------------------------------------ @section{Parallel Binding: @scheme[let]} -@refalso["mz:let"]{@scheme[let]} +@refalso["let"]{@scheme[let]} A @scheme[let] form binds a set of identifiers, each to the result of some expression, for use in the @scheme[let] body: @@ -69,7 +69,7 @@ evaluated in order, even though the bindings are delayed until all @;------------------------------------------------------------------------ @section{Sequential Binding: @scheme[let*]} -@refalso["mz:let"]{@scheme[let*]} +@refalso["let"]{@scheme[let*]} The syntax of @scheme[let*] is the same as @scheme[let]: @@ -104,7 +104,7 @@ In other words, a @scheme[let*] form is equivalent to nested @;------------------------------------------------------------------------ @section{Recursive Binding: @scheme[letrec]} -@refalso["mz:let"]{@scheme[letrec]} +@refalso["let"]{@scheme[letrec]} The syntax of @scheme[letrec] is also the same as @scheme[let]: @@ -163,10 +163,10 @@ an @scheme[_id] is referenced before its value is ready, the result is @; ---------------------------------------- @section{Multiple Values: @scheme[let-values], @scheme[let*-values], @scheme[letrec-values]} -@refalso["mz:let"]{multiple-value binding forms} +@refalso["let"]{multiple-value binding forms} In the same way that @scheme[define-values] binds multiple -results in a definition (see @secref["guide:multiple-values"]), +results in a definition (see @secref["multiple-values"]), @scheme[let-values], @scheme[let*-values], and @scheme[letrec-values] bind multiple results locally. diff --git a/collects/scribblings/guide/lists.scrbl b/collects/scribblings/guide/lists.scrbl index 670cfc10b6..5e28e53986 100644 --- a/collects/scribblings/guide/lists.scrbl +++ b/collects/scribblings/guide/lists.scrbl @@ -110,7 +110,7 @@ list loops. Scheme provides a general @defterm{list compherension} form @scheme[for/list], which builds a list by iterating through @defterm{sequences}. List comprehensions and related iteration forms -are described in see @secref["guide:for"]. +are described in see @secref["for"]. @;------------------------------------------------------------------------ @section{List Iteration from Scratch} @@ -183,7 +183,7 @@ consider reading @|HtDP|. If you are merely suspicious of the use of recursive calls instead of a looping construct, then read on. @;------------------------------------------------------------------------ -@section[#:tag "guide:tail-recursion"]{Tail Recursion} +@section[#:tag "tail-recursion"]{Tail Recursion} Both the @scheme[my-length] and @scheme[my-map] functions run in @math{O(n)} time for a list of length @math{n}. This is easy to see by diff --git a/collects/scribblings/guide/macros.scrbl b/collects/scribblings/guide/macros.scrbl index de01493f59..195a8b723e 100644 --- a/collects/scribblings/guide/macros.scrbl +++ b/collects/scribblings/guide/macros.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:macros" #:style 'toc]{Syntactic Extension@aux-elem{ (Macros)}} +@title[#:tag "macros" #:style 'toc]{Syntactic Extension@aux-elem{ (Macros)}} @local-table-of-contents[] diff --git a/collects/scribblings/guide/module-basics.scrbl b/collects/scribblings/guide/module-basics.scrbl index 28c7d93e5f..0071022dea 100644 --- a/collects/scribblings/guide/module-basics.scrbl +++ b/collects/scribblings/guide/module-basics.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:module-basics"]{Module Basics} +@title[#:tag "module-basics"]{Module Basics} The space of module names is distinct from the space of normal Scheme definitions. Indeed, since modules typically reside in files, the @@ -62,4 +62,4 @@ big ] We discuss more forms of module reference later in -@secref["guide:module-paths"]. +@secref["module-paths"]. diff --git a/collects/scribblings/guide/module-paths.scrbl b/collects/scribblings/guide/module-paths.scrbl index 99d93b9d37..d39470dddc 100644 --- a/collects/scribblings/guide/module-paths.scrbl +++ b/collects/scribblings/guide/module-paths.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:module-paths"]{Module Paths} +@title[#:tag "module-paths"]{Module Paths} A @deftech{module path} is a reference to a module, as used with @scheme[require] or as the @scheme[_initial-module-path] in a @@ -40,7 +40,7 @@ to the current directory. (More precisely, the path is relative to the value of @scheme[(current-load-relative-directory)], which is set while loading a file.) -@secref["guide:module-basics"] shows examples using relative paths. +@secref["module-basics"] shows examples using relative paths. } @; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -50,7 +50,7 @@ while loading a file.) Like a plain-string @scheme[rel-path], but the elements of @scheme[rel-path] refer to @tech{collection}s and sub-@tech{collections}, instead of directories and sub-directories. A -collection is represented by a directory in one of several +@deftech{collection} is represented by a directory in one of several installation-specific locations. An example of this form is @scheme[(lib "big/lang.ss")], which is diff --git a/collects/scribblings/guide/module-provide.scrbl b/collects/scribblings/guide/module-provide.scrbl index 726994d178..35cdd40a8b 100644 --- a/collects/scribblings/guide/module-provide.scrbl +++ b/collects/scribblings/guide/module-provide.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:module-provide"]{Exports: @scheme[provide]} +@title[#:tag "module-provide"]{Exports: @scheme[provide]} By default, all of a module's definitions are private to the module. The @scheme[provide] form specifies definitions to be made @@ -11,10 +11,11 @@ available where the module is @scheme[require]d. @specform[(provide provide-spec ...)]{} -A @scheme[provide] form can only appear at @tech{module level}. -Specifying multiple @scheme[_provide-spec]s in a single -@scheme[require] is exactly the same as using multiple -@scheme[provide]s each with a single @scheme[_provide-spec]. +A @scheme[provide] form can only appear at module level (i.e., in the +immediate body of a @scheme[module]). Specifying multiple +@scheme[_provide-spec]s in a single @scheme[require] is exactly the +same as using multiple @scheme[provide]s each with a single +@scheme[_provide-spec]. Each identifier can be exported at most once from a module across all @scheme[provide]s within the module. More precisely, the external name diff --git a/collects/scribblings/guide/module-require.scrbl b/collects/scribblings/guide/module-require.scrbl index adcc1187a2..adccc99b42 100644 --- a/collects/scribblings/guide/module-require.scrbl +++ b/collects/scribblings/guide/module-require.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:module-require"]{Imports: @scheme[require]} +@title[#:tag "module-require"]{Imports: @scheme[require]} The @scheme[require] form imports from another module. A @scheme[require] form can appear within a module, in which case it @@ -32,7 +32,7 @@ The allowed shape of a @scheme[_require-spec] is defined recursively: In its simplest form, a @scheme[_require-spec] is a @scheme[module-path] (as defined in the previous section, -@secref["guide:module-paths"]). In this case, the bindings introduced +@secref["module-paths"]). In this case, the bindings introduced by @scheme[require] are determined by @scheme[provide] declarations within each module referenced by each @scheme[module-path]. diff --git a/collects/scribblings/guide/module-set.scrbl b/collects/scribblings/guide/module-set.scrbl index bd5ed2cb32..041eec5b24 100644 --- a/collects/scribblings/guide/module-set.scrbl +++ b/collects/scribblings/guide/module-set.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:module-set"]{Assignment and Redefinition} +@title[#:tag "module-set"]{Assignment and Redefinition} The use of @scheme[set!] on variables defined within a module is limited to the body of the defining module. That is, a module is diff --git a/collects/scribblings/guide/module-syntax.scrbl b/collects/scribblings/guide/module-syntax.scrbl index ea0d00eb36..1cf3a380b5 100644 --- a/collects/scribblings/guide/module-syntax.scrbl +++ b/collects/scribblings/guide/module-syntax.scrbl @@ -38,7 +38,7 @@ supplies most of the bindings described in this guide, including @scheme[require], @scheme[define], and @scheme[provide]. For example, the @file{cake.ss} example of the -@seclink["guide:module-basics"]{previous section} could be written as +@seclink["module-basics"]{previous section} could be written as @schemeblock[ (module cake (lib "big/lang.ss") diff --git a/collects/scribblings/guide/modules.scrbl b/collects/scribblings/guide/modules.scrbl index 86fe04cbb0..9eb5ba305a 100644 --- a/collects/scribblings/guide/modules.scrbl +++ b/collects/scribblings/guide/modules.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:modules" #:style 'toc]{Modules} +@title[#:tag "modules" #:style 'toc]{Modules} Scheme definitions and expressions are normally written inside of a module. Although a @tech{REPL} evaluates definitions and expressions outside diff --git a/collects/scribblings/guide/numbers.scrbl b/collects/scribblings/guide/numbers.scrbl index 2cbf582e8c..05a79e07a2 100644 --- a/collects/scribblings/guide/numbers.scrbl +++ b/collects/scribblings/guide/numbers.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:numbers"]{Numbers} +@title[#:tag "numbers"]{Numbers} A Scheme @defterm{number} is either exact or inexact: @@ -53,7 +53,7 @@ or inexact number. The prefixes @litchar{#b}, @litchar{#o}, and @litchar{#x} specificy binary, octal, and hexadecimal interprertation of digits. -@refdetails/gory["mz:parse-number"]{the syntax of numbers} +@refdetails/gory["parse-number"]{the syntax of numbers} @examples[ 0.5 @@ -146,4 +146,4 @@ can only approximate @scheme[1/10]: (inexact->exact 0.1) ] -@refdetails["mz:numbers"]{numbers and number procedures} +@refdetails["numbers"]{numbers and number procedures} diff --git a/collects/scribblings/guide/pairs.scrbl b/collects/scribblings/guide/pairs.scrbl index 77f4a8e1d9..deb0364431 100644 --- a/collects/scribblings/guide/pairs.scrbl +++ b/collects/scribblings/guide/pairs.scrbl @@ -86,4 +86,4 @@ iterate through the lists elements: '((when "3:30") (where "Florida") (who "Mickey"))) ] -@refdetails["mz:pairs"]{pairs and lists} +@refdetails["pairs"]{pairs and lists} diff --git a/collects/scribblings/guide/paths.scrbl b/collects/scribblings/guide/paths.scrbl index f15c470875..7dabb6053e 100644 --- a/collects/scribblings/guide/paths.scrbl +++ b/collects/scribblings/guide/paths.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:paths"]{Paths} +@title[#:tag "paths"]{Paths} A @defterm{path} encapsulates a filesystem path that (potentially) names a file or directory. Although paths can be converted to and from @@ -45,7 +45,7 @@ named @file{~}. Windows path manipulation, furthermore, is far trickier, because path elements like @file{aux} can have special meanings. -@refdetails/gory["mz:windows-path"]{Windows filesystem paths} +@refdetails/gory["windows-path"]{Windows filesystem paths} Use procedures like @scheme[split-path] and @scheme[build-path] to deconstruct and construct paths. When you must manipulate the name of diff --git a/collects/scribblings/guide/quote.scrbl b/collects/scribblings/guide/quote.scrbl index 8b1eff3527..0fc82a57de 100644 --- a/collects/scribblings/guide/quote.scrbl +++ b/collects/scribblings/guide/quote.scrbl @@ -3,9 +3,9 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:quote"]{Quoting: @scheme[quote] and @schemevalfont{'}} +@title[#:tag "quote"]{Quoting: @scheme[quote] and @schemevalfont{'}} -@refalso["mz:quote"]{@scheme[quote]} +@refalso["quote"]{@scheme[quote]} The @scheme[quote] form produces a constant: @@ -59,7 +59,7 @@ and this shorthand is almost always used instead of @scheme[quote]. The shorthand applies even within the @scheme[_datum], so it can produce a list containing @scheme[quote]. -@refdetails["mz:parse-quote"]{the @schemevalfont{'} shorthand} +@refdetails["parse-quote"]{the @schemevalfont{'} shorthand} @examples[ 'apple diff --git a/collects/scribblings/guide/regexps-data.scrbl b/collects/scribblings/guide/regexps-data.scrbl index c0e14dc3df..5709814cda 100644 --- a/collects/scribblings/guide/regexps-data.scrbl +++ b/collects/scribblings/guide/regexps-data.scrbl @@ -3,6 +3,6 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:regexp-literals"]{Regexps} +@title[#:tag "regexp-literals"]{Regexps} A @defterm{regexp} is a pattern for regular-expression matching. diff --git a/collects/scribblings/guide/set.scrbl b/collects/scribblings/guide/set.scrbl index fb40281855..3e0d27bf1a 100644 --- a/collects/scribblings/guide/set.scrbl +++ b/collects/scribblings/guide/set.scrbl @@ -5,9 +5,9 @@ @interaction-eval[(require (lib "for.ss"))] -@title[#:tag "guide:set!"]{Assignment: @scheme[set!]} +@title[#:tag "set!"]{Assignment: @scheme[set!]} -@refalso["mz:set!"]{@scheme[set!]} +@refalso["set!"]{@scheme[set!]} Assign to a variable using @scheme[set!]: @@ -166,7 +166,7 @@ the program. @;------------------------------------------------------------------------ @section{Multiple Values: @scheme[set!-values]} -@refalso["mz:set!"]{@scheme[set!-values]} +@refalso["set!"]{@scheme[set!-values]} The @scheme[set!-values] form assigns to multiple variables at once, given an expression that produces an appropriate number of values: diff --git a/collects/scribblings/guide/simple-data.scrbl b/collects/scribblings/guide/simple-data.scrbl index 4411136da6..b2822721d5 100644 --- a/collects/scribblings/guide/simple-data.scrbl +++ b/collects/scribblings/guide/simple-data.scrbl @@ -12,7 +12,7 @@ in color), value expression are shown in green. @defterm{Numbers} are written in the usual way, including fractions and imagnary numbers: -@moreguide["guide:numbers"]{numbers} +@moreguide["numbers"]{numbers} @schemeblock[ 1 1.0 @@ -25,7 +25,7 @@ and imagnary numbers: false. In conditionals, however, all non-@scheme[#f] values are treated as true. -@moreguide["guide:booleans"]{booleans} +@moreguide["booleans"]{booleans} @defterm{Strings} are written between doublequotes. Within a string, backslash is an escaping character; for example, a backslash followed @@ -33,7 +33,7 @@ by a doublequote includes a little doublequote in the string. Except for an unescaped doublequote or backslash, any Unicode character can appear in a string constant. -@moreguide["guide:strings"]{strings} +@moreguide["strings"]{strings} @schemeblock[ "hello world" diff --git a/collects/scribblings/guide/simple-syntax.scrbl b/collects/scribblings/guide/simple-syntax.scrbl index ca562706d5..da1562c5cb 100644 --- a/collects/scribblings/guide/simple-syntax.scrbl +++ b/collects/scribblings/guide/simple-syntax.scrbl @@ -62,7 +62,7 @@ a sequence as an element for repetition. A definition of the form -@moreguide["guide:define"]{definitions} +@moreguide["define"]{definitions} @schemeblock[#, @val-defn-stx] @@ -166,7 +166,7 @@ source's indentation information to suggest where it might be missing. Scheme's syntax for identifiers is especially liberal. Excluding the special characters -@moreguide["guide:binding"]{identifiers} +@moreguide["binding"]{identifiers} @t{ @hspace[2] @litchar{(} @litchar{)} @litchar{[} @litchar{]} @@ -198,7 +198,7 @@ We have already seen many function calls---or @defterm{procedure applications} in more traditional Scheme terminology. The syntax of a function call is -@moreguide["guide:application"]{function calls} +@moreguide["application"]{function calls} @schemeblock[ #, app-expr-stx @@ -242,7 +242,7 @@ The next simplest kind of expression is an @scheme[if] conditional: #, if-expr-stx ] -@moreguide["guide:conditionals"]{conditionals} +@moreguide["conditionals"]{conditionals} The first @nonterm{expr} is always evaluted. If it produces a non-@scheme[#f] value, then the second @nonterm{expr} is @@ -293,7 +293,7 @@ but these kinds of nested @scheme[if]s are difficult to read. Scheme provides more readable shortcuts through the @scheme[and] and @scheme[or] forms, which work with any number of expressions: -@moreguide["guide:and+or"]{@scheme[and] and @scheme[or]} +@moreguide["and+or"]{@scheme[and] and @scheme[or]} @schemeblock[ #, and-expr-stx @@ -332,7 +332,7 @@ tests, each with its own result: The shorthand for a sequence of tests is the @scheme[cond] form: -@moreguide["guide:cond"]{@scheme[cond]} +@moreguide["cond"]{@scheme[cond]} @schemeblock[ #, cond-expr-stx @@ -380,7 +380,7 @@ In our earlier grammar of function calls, we oversimplified. The actual syntax of a function call allows an arbitrary expression for the function, instead of just an @nonterm{id}: -@moreguide["guide:application"]{function calls} +@moreguide["application"]{function calls} @schemeblock[ #, app2-expr-stx @@ -414,7 +414,7 @@ a procedure'' error like this one. Programming in Scheme would be tedious if you had to name all of your numbers. Instead of writing @scheme[(+ 1 2)], you'd have to write -@moreguide["guide:lambda"]{@scheme[lambda]} +@moreguide["lambda"]{@scheme[lambda]} @interaction[ (define a 1) @@ -522,7 +522,7 @@ It's time to retract another simplification in our grammar of Scheme. In the body of a function, definitions can appear before the body expressions: -@moreguide["guide:intdefs"]{local (internal) definitions} +@moreguide["intdefs"]{local (internal) definitions} @schemeblock[ #, fun-defn2-stx @@ -552,7 +552,7 @@ advantage of @scheme[let] is that it can be used in any expression position. Also, @scheme[let] binds many identifiers at once, instead of requiring a separate @scheme[define] for each identifier. -@moreguide["guide:intdefs"]{@scheme[let] and @scheme[let*]} +@moreguide["intdefs"]{@scheme[let] and @scheme[let*]} @schemeblock[ #, let-expr-stx diff --git a/collects/scribblings/guide/symbols.scrbl b/collects/scribblings/guide/symbols.scrbl index b380e830f8..e1b74ae260 100644 --- a/collects/scribblings/guide/symbols.scrbl +++ b/collects/scribblings/guide/symbols.scrbl @@ -3,7 +3,7 @@ @require[(lib "eval.ss" "scribble")] @require["guide-utils.ss"] -@title[#:tag "guide:symbols"]{Symbols} +@title[#:tag "symbols"]{Symbols} A @defterm{symbol} is an atomic value that prints like an identifier. An expression that starts with @litchar{'} and continues with an @@ -59,7 +59,7 @@ special characters or that might otherwise look like numbers. (string->symbol "6") ] -@refdetails/gory["mz:parse-symbol"]{the syntax of symbols} +@refdetails/gory["parse-symbol"]{the syntax of symbols} The @scheme[display] form of a symbol is the same as the corresponding string. @@ -83,4 +83,4 @@ confused with any other value. ] -@refdetails["mz:symbols"]{symbols} +@refdetails["symbols"]{symbols} diff --git a/collects/scribblings/guide/truth.scrbl b/collects/scribblings/guide/truth.scrbl index 60cd9f6ee3..4cdb686c12 100644 --- a/collects/scribblings/guide/truth.scrbl +++ b/collects/scribblings/guide/truth.scrbl @@ -182,7 +182,7 @@ Beware, however, that the @tech{REPL}'s printer recognizes the symbol ] @;------------------------------------------------------------------------ -@section[#:tag "guide:lists-and-syntax"]{Lists and Scheme Syntax} +@section[#:tag "lists-and-syntax"]{Lists and Scheme Syntax} Now that you know the truth about pairs and lists, and now that you've seen @scheme[quote], you're ready to understand the main way in which diff --git a/collects/scribblings/guide/vectors.scrbl b/collects/scribblings/guide/vectors.scrbl index 8c21f209eb..049d000197 100644 --- a/collects/scribblings/guide/vectors.scrbl +++ b/collects/scribblings/guide/vectors.scrbl @@ -16,7 +16,7 @@ expression. Also, a vector as an expression implicitly quotes the forms for its content, which means that identifiers and parenthesized forms in a vector constant represent symbols and lists. -@refdetails/gory["mz:parse-vector"]{the syntax of vectors} +@refdetails/gory["parse-vector"]{the syntax of vectors} @examples[ (eval:alts #, @schemevalfont{#("a" "b" "c")} #("a" "b" "c")) @@ -55,4 +55,4 @@ well as lists. (vector->list #("three" "blind" "mice")))) ] -@refdetails["mz:vectors"]{vectors and vector procedures} +@refdetails["vectors"]{vectors and vector procedures} diff --git a/collects/scribblings/info.ss b/collects/scribblings/info.ss index 45d31cb27e..734807f194 100644 --- a/collects/scribblings/info.ss +++ b/collects/scribblings/info.ss @@ -1,3 +1,2 @@ (module info (lib "infotab.ss" "setup") - (define name "Scribblings") - (define post-install-collection "doc-installer.ss")) + (define name "Scribblings")) diff --git a/collects/scribblings/quick.ss b/collects/scribblings/quick.ss deleted file mode 100644 index e38beab004..0000000000 --- a/collects/scribblings/quick.ss +++ /dev/null @@ -1,11 +0,0 @@ - -(module quick mzscheme - (require "to-html.ss" - (prefix quick: "quick/quick.scrbl")) - - (provide build) - - (define (build) - (to-html #f #f - (list quick:doc) - (list "quick")))) diff --git a/collects/scribblings/quick/images/exprs.dat b/collects/scribblings/quick/images/exprs.dat index 5cca28abc8..503673d156 100644 --- a/collects/scribblings/quick/images/exprs.dat +++ b/collects/scribblings/quick/images/exprs.dat @@ -3,87 +3,87 @@ (0 () 0 () () "art gallery") (0 () 0 () () "art gallery") (0 () 0 () () (c! circle c! 10)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img0.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img0.png")) (c! "[image]"))))) (0 () 0 () () (c! rectangle c! 10 c! 20)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img1.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img1.png")) (c! "[image]"))))) (0 () 0 () () (c! circle c! 10 c! 20)) (1 (((lib "quick/exn.ss" "scribblings") . deserialize-info:mr-exn-v0)) 0 () () (0 "procedure circle: expects 1 argument, given 2: 10 20")) (0 () 0 () () (c! hc-append c! (c! circle c! 10) c! (c! rectangle c! 10 c! 20))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img2.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img2.png")) (c! "[image]"))))) (0 () 0 () () (c! define c! c c! (c! circle c! 10))) (0 () 0 () () (void)) (0 () 0 () () (c! define c! r c! (c! rectangle c! 10 c! 20))) (0 () 0 () () (void)) (0 () 0 () () r) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img3.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img3.png")) (c! "[image]"))))) (0 () 0 () () (c! hc-append c! c c! r)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img4.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img4.png")) (c! "[image]"))))) (0 () 0 () () (c! hc-append c! 20 c! c c! r c! c)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img5.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img5.png")) (c! "[image]"))))) (0 () 0 () () (c! define c! (c! square c! n) c! (c! filled-rectangle c! n c! n))) (0 () 0 () () (void)) (0 () 0 () () (c! square c! 10)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img6.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img6.png")) (c! "[image]"))))) (0 () 0 () () (c! define c! (c! four c! p) c! (c! define c! two-p c! (c! hc-append c! p c! p)) c! (c! vc-append c! two-p c! two-p))) (0 () 0 () () (void)) (0 () 0 () () (c! four c! (c! circle c! 10))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img7.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img7.png")) (c! "[image]"))))) (0 () 0 () () (c! define c! (c! checker c! p1 c! p2) c! (c! let c! (c! (c! p12 c! (c! hc-append c! p1 c! p2)) c! (c! p21 c! (c! hc-append c! p2 c! p1))) c! (c! vc-append c! p12 c! p21)))) (0 () 0 () () (void)) (0 () 0 () () (c! checker c! (c! colorize c! (c! square c! 10) c! "red") c! (c! colorize c! (c! square c! 10) c! "black"))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img8.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img8.png")) (c! "[image]"))))) (0 () 0 () () (c! define c! (c! checkerboard c! p) c! (c! let* c! (c! (c! rp c! (c! colorize c! p c! "red")) c! (c! bp c! (c! colorize c! p c! "black")) c! (c! c c! (c! checker c! rp c! bp)) c! (c! c4 c! (c! four c! c))) c! (c! four c! c4)))) (0 () 0 () () (void)) (0 () 0 () () (c! checkerboard c! (c! square c! 10))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img9.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img9.png")) (c! "[image]"))))) (0 () 0 () () circle) (1 (((lib "struct.ss" "scribble") . deserialize-info:element-v0)) 0 () () (0 #f (c! (u . "#")))) (0 () 0 () () (c! define c! (c! series c! mk) c! (c! hc-append c! 4 c! (c! mk c! 5) c! (c! mk c! 10) c! (c! mk c! 20)))) (0 () 0 () () (void)) (0 () 0 () () (c! series c! circle)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img10.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img10.png")) (c! "[image]"))))) (0 () 0 () () (c! series c! square)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img11.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img11.png")) (c! "[image]"))))) (0 () 0 () () (c! series c! (c! lambda c! (c! size) c! (c! checkerboard c! (c! square c! size))))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img12.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img12.png")) (c! "[image]"))))) (0 () 0 () () (c! define c! (c! rgb-series c! mk) c! (c! vc-append c! (c! series c! (c! lambda c! (c! sz) c! (c! colorize c! (c! mk c! sz) c! "red"))) c! (c! series c! (c! lambda c! (c! sz) c! (c! colorize c! (c! mk c! sz) c! "green"))) c! (c! series c! (c! lambda c! (c! sz) c! (c! colorize c! (c! mk c! sz) c! "blue")))))) (0 () 0 () () (void)) (0 () 0 () () (c! rgb-series c! circle)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img13.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img13.png")) (c! "[image]"))))) (0 () 0 () () (c! rgb-series c! square)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img14.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img14.png")) (c! "[image]"))))) (0 () 0 () () (c! define c! (c! rgb-maker c! mk) c! (c! lambda c! (c! sz) c! (c! vc-append c! (c! colorize c! (c! mk c! sz) c! "red") c! (c! colorize c! (c! mk c! sz) c! "green") c! (c! colorize c! (c! mk c! sz) c! "blue"))))) (0 () 0 () () (void)) (0 () 0 () () (c! series c! (c! rgb-maker c! circle))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img15.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img15.png")) (c! "[image]"))))) (0 () 0 () () (c! series c! (c! rgb-maker c! square))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img16.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img16.png")) (c! "[image]"))))) (0 () 0 () () (c! list c! "red" c! "green" c! "blue")) (0 () 0 () () (c! "red" c! "green" c! "blue")) (0 () 0 () () (c! list c! (c! circle c! 10) c! (c! square c! 10))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 1 ("[image]") () (c! (0 #f (c! (0 (1 (u . "quick/images/img17.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "quick/images/img18.png")) (c! (? . 0))))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 1 ("[image]") () (c! (0 #f (c! (0 (1 (u . "images/img17.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "images/img18.png")) (c! (? . 0))))))) (0 () 0 () () (c! define c! (c! rainbow c! p) c! (c! map c! (c! lambda c! (c! color) c! (c! colorize c! p c! color)) c! (c! list c! "red" c! "orange" c! "yellow" c! "green" c! "blue" c! "purple")))) (0 () 0 () () (void)) (0 () 0 () () (c! rainbow c! (c! square c! 5))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 1 ("[image]") () (c! (0 #f (c! (0 (1 (u . "quick/images/img19.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "quick/images/img20.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "quick/images/img21.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "quick/images/img22.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "quick/images/img23.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "quick/images/img24.png")) (c! (? . 0))))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 1 ("[image]") () (c! (0 #f (c! (0 (1 (u . "images/img19.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "images/img20.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "images/img21.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "images/img22.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "images/img23.png")) (c! (? . 0))))) c! (0 #f (c! (0 (1 (u . "images/img24.png")) (c! (? . 0))))))) (0 () 0 () () (c! apply c! vc-append c! (c! rainbow c! (c! square c! 5)))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img25.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img25.png")) (c! "[image]"))))) (0 () 0 () () (c! require c! (c! lib c! "flash.ss" c! "texpict"))) (0 () 0 () () (void)) (0 () 0 () () (c! filled-flash c! 40 c! 30)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img26.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img26.png")) (c! "[image]"))))) (0 () 0 () () (c! require c! (c! planet c! "random.ss" c! (c! "schematics" c! "random.plt" c! 1 c! 0)))) (0 () 0 () () (void)) (0 () 0 () () (c! random-gaussian)) -(0 () 0 () () 0.7386912134436788) +(0 () 0 () () 0.9050686838895684) (0 () 0 () () (c! require c! (c! lib c! "code.ss" c! "slideshow"))) (0 () 0 () () (void)) (0 () 0 () () (c! code c! (c! circle c! 10))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img27.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img27.png")) (c! "[image]"))))) (0 () 0 () () (c! define-syntax c! pict+code c! (c! syntax-rules c! () c! (c! (c! pict+code c! expr) c! (c! hc-append c! 10 c! expr c! (c! code c! expr)))))) (0 () 0 () () (void)) (0 () 0 () () (c! pict+code c! (c! circle c! 10))) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img28.png")) (c! "[image]"))))) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img28.png")) (c! "[image]"))))) (0 () 0 () () (c! require c! (c! lib c! "class.ss" c! "mzlib") c! (c! lib c! "mred.ss" c! "mred"))) (0 () 0 () () (void)) (0 () 0 () () (c! define c! f c! (c! new c! frame% c! (c! label c! "My Art") c! (c! width c! 300) c! (c! height c! 300) c! (c! alignment c! (c! quote c! (c! center c! center)))))) @@ -98,5 +98,5 @@ (1 (((lib "struct.ss" "scribble") . deserialize-info:element-v0)) 0 () () (0 #f (c! (u . "#2(struct:object:canvas% ...)")))) (0 () 0 () () (c! add-drawing c! (c! colorize c! (c! filled-flash c! 50 c! 30) c! "yellow"))) (1 (((lib "struct.ss" "scribble") . deserialize-info:element-v0)) 0 () () (0 #f (c! (u . "#2(struct:object:canvas% ...)")))) -(0 () 0 () () (c! scale c! (c! bitmap c! "quick/art.png") c! 0.5)) -(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "quick/images/img29.png")) (c! "[image]"))))) +(0 () 0 () () (c! scale c! (c! bitmap c! "art.png") c! 0.5)) +(2 (((lib "struct.ss" "scribble") . deserialize-info:element-v0) ((lib "struct.ss" "scribble") . deserialize-info:image-file-v0)) 0 () () (0 #f (c! (0 (1 (u . "images/img29.png")) (c! "[image]"))))) diff --git a/collects/scribblings/quick/info.ss b/collects/scribblings/quick/info.ss new file mode 100644 index 0000000000..140f8db8bf --- /dev/null +++ b/collects/scribblings/quick/info.ss @@ -0,0 +1,3 @@ +(module info (lib "infotab.ss" "setup") + (define name "Scribblings: Quick") + (define scribblings '(("quick.scrbl" (main-doc))))) diff --git a/collects/scribblings/quick/mreval.ss b/collects/scribblings/quick/mreval.ss index d0d468445b..1089281ff9 100644 --- a/collects/scribblings/quick/mreval.ss +++ b/collects/scribblings/quick/mreval.ss @@ -34,7 +34,7 @@ ;; This one needs to be relative, because it ends up in the ;; exprs.dat file: - (define img-dir "quick/images") ; relative to scribbles dir + (define img-dir "images") ; relative to src dir ;; This one can be absolute: (define exprs-dat-file (build-path (collection-path "scribblings") diff --git a/collects/scribblings/quick/quick.scrbl b/collects/scribblings/quick/quick.scrbl index 693afaa4fd..2284bf84f9 100644 --- a/collects/scribblings/quick/quick.scrbl +++ b/collects/scribblings/quick/quick.scrbl @@ -1,6 +1,7 @@ #reader(lib "docreader.ss" "scribble") -@title{An Introduction to PLT Scheme with Pictures} +@title[#:tag-prefix '(lib "quick.scrbl" "scribblings" "quick") + #:tag "top"]{An Introduction to PLT Scheme with Pictures} @bold{This reference describes a potential future version of PLT Scheme. It does not match the current implementation.} @@ -14,6 +15,11 @@ @require["slideshow-doc.ss"] @require["slideshow-code-doc.ss"] @require["mred-doc.ss"] + +@require-for-label[(lib "lang.ss" "big")] +@require-for-label[(lib "mred.ss" "mred")] +@require-for-label[(lib "class.ss")] + @require-for-syntax[mzscheme] @define[filled-flash (lambda args (apply (eval 'filled-flash) args))] @@ -485,7 +491,7 @@ constantly giving talks and writing papers that involve Scheme code, and it's worthwhile for everyone who works on those products to know about @scheme[code]. -In fact, you might want to take a look at the @link["quick/quick.scrbl"]{source of +In fact, you might want to take a look at the @link["quick.scrbl"]{source of this document}. You'll see that it starts with @schemefont{#module}, but otherwise doesn't look a lot like Scheme; nevertheless, we build this document by running its source as a PlT Scheme program. We have @@ -545,7 +551,7 @@ picture into a canvas: (add-drawing (colorize (filled-flash 50 30) "yellow")) ] -@centerline{@mr-interaction-eval-show[(scale (bitmap "quick/art.png") 0.5)]} +@centerline{@mr-interaction-eval-show[(scale (bitmap "art.png") 0.5)]} Each canvas stratches to fill an equal portion of the frame, because that's how a frame manages its children by default. @@ -568,4 +574,5 @@ way that Scheme is often described---PLT Scheme offers a rich language with an extensive set of libraries and tools. To start learning about the full PLT Scheme language and tools in -depth, move on to @link["../guide/index.html"]{A Guide to PLT Scheme}. +depth, move on to @italic[@secref[#:doc '(lib "guide.scrbl" +"scribblings" "guide") "top"]]. diff --git a/collects/scribblings/reference/breaks.scrbl b/collects/scribblings/reference/breaks.scrbl index dbfe2d6a93..4ef8549e6c 100644 --- a/collects/scribblings/reference/breaks.scrbl +++ b/collects/scribblings/reference/breaks.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:breakhandler"]{Breaks} +@title[#:tag "breakhandler"]{Breaks} @section-index["threads" "breaking"] @@ -72,7 +72,7 @@ internal sub-expressions that can be interrupted by a break. In general, it is impossible using only @scheme[semaphore-wait] to implement the guarantee that either the semaphore is decremented or an exception is raised, but not both. Scheme therefore supplies -@scheme[semaphore-wait/enable-break] (see @secref["mz:semaphore"]), +@scheme[semaphore-wait/enable-break] (see @secref["semaphore"]), which does permit the implementation of such an exclusive guarantee: @schemeblock[ @@ -110,8 +110,8 @@ enabled in while evaluating the @scheme[body]s in sequence. The result of the @scheme[parameter-break] expression is the result of the last @scheme[expr]. -Like @scheme[parameterize] (see @secref["mz:parameters"]), a fresh -@tech{thread cell} (see @secref["mz:threadcells"]) is allocated to +Like @scheme[parameterize] (see @secref["parameters"]), a fresh +@tech{thread cell} (see @secref["threadcells"]) is allocated to hold the break-enabled state of the continuation, and calls to @scheme[break-enabled] within the continuation access or modify the new cell. Unlike parameters, the break setting is not inherited by new @@ -119,7 +119,7 @@ threads.} @defproc[(current-break-parameterization) break-parameterization?]{ Analogous to @scheme[(current-parameterization)] (see -@secref["mz:parameters"]); it returns a break-parameterization +@secref["parameters"]); it returns a break-parameterization (effectively a thread cell) that holds the current continuation's break-enable state.} @@ -128,7 +128,7 @@ break-enable state.} [thunk (-> any)]) any]{ Analogous to @scheme[(call-with-parameterization parameterization -thunk)] (see @secref["mz:parameters"]), calls @scheme[thunk] in a +thunk)] (see @secref["parameters"]), calls @scheme[thunk] in a continuation whose break-enabled state is in @scheme[break-param]. The @scheme[thunk] is @italic{not} called in tail position with respect to the @scheme[call-with-break-parameterization] call.} diff --git a/collects/scribblings/reference/bytes.scrbl b/collects/scribblings/reference/bytes.scrbl index 5d7d4ebc40..b13742ff67 100644 --- a/collects/scribblings/reference/bytes.scrbl +++ b/collects/scribblings/reference/bytes.scrbl @@ -1,9 +1,9 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:bytestrings"]{Byte Strings} +@title[#:tag "bytestrings"]{Byte Strings} -@guideintro["guide:bytestrings"]{byte strings} +@guideintro["bytestrings"]{byte strings} A @pidefterm{byte string} is a fixed-length arary of bytes. A @pidefterm{byte} is an exact integer between @scheme[0] and @@ -13,13 +13,13 @@ A @pidefterm{byte string} is a fixed-length arary of bytes. A @defterm{mutable} or @defterm{immutable}. When an immutable byte string is provided to a procedure like @scheme[bytes-set!], the @exnraise[exn:fail:contract]. Byte-string constants generated by the -default reader (see @secref["mz:parse-string"]) are immutable. +default reader (see @secref["parse-string"]) are immutable. Two byte strings are @scheme[equal?] when they have the same length and contain the same sequence of bytes. A byte string can be used as a single-valued sequence (see -@secref["mz:sequences"]). The bytes of the string serve as elements +@secref["sequences"]). The bytes of the string serve as elements of the sequence. See also @scheme[in-bytes]. See also: @scheme[immutable]. @@ -210,7 +210,7 @@ string. points. If @scheme[err-char] is not @scheme[#f], then it is used for bytes that fall in the range @scheme[#o200] to @scheme[#o377] but are not part of a valid encoding sequence. (This is consistent with - reading characters from a port; see @secref["mz:encodings"] for more + reading characters from a port; see @secref["encodings"] for more details.) If @scheme[err-char] is @scheme[#f], and if the @scheme[start] to @scheme[end] substring of @scheme[bstr] is not a valid UTF-8 encoding overall, then the @exnraise[exn:fail:contract].} @@ -222,7 +222,7 @@ string. string?]{ Produces a string by decoding the @scheme[start] to @scheme[end] substring of @scheme[bstr] using the current locale's encoding (see also - @secref["mz:encodings"]). If @scheme[err-char] is not + @secref["encodings"]). If @scheme[err-char] is not @scheme[#f], it is used for each byte in @scheme[bstr] that is not part of a valid encoding; if @scheme[err-char] is @scheme[#f], and if the @scheme[start] to @scheme[end] substring of @scheme[bstr] is not a valid @@ -237,7 +237,7 @@ string. of @scheme[bstr] as a Latin-1 encoding of Unicode code points; i.e., each byte is translated directly to a character using @scheme[integer->char], so the decoding always succeeds. (See also the - Latin-1 footnote of @secref["mz:encodings"].) The @scheme[err-char] + Latin-1 footnote of @secref["encodings"].) The @scheme[err-char] argument is ignored, but present for consistency with the other operations.} @@ -258,7 +258,7 @@ string. bytes?]{ Produces a string by encoding the @scheme[start] to @scheme[end] substring of @scheme[str] using the current locale's encoding (see also - @secref["mz:encodings"]). If @scheme[err-byte] is not @scheme[#f], it is used + @secref["encodings"]). If @scheme[err-byte] is not @scheme[#f], it is used for each character in @scheme[str] that cannot be encoded for the current locale; if @scheme[err-byte] is @scheme[#f], and if the @scheme[start] to @scheme[end] substring of @scheme[str] cannot be encoded, @@ -274,7 +274,7 @@ string. directly to a byte using @scheme[char->integer]. If @scheme[err-byte] is not @scheme[#f], it is used for each character in @scheme[str] whose value is greater than @scheme[255]. (See also the Latin-1 footnote of - @secref["mz:encodings"]. If @scheme[err-byte] is @scheme[#f], and if the + @secref["encodings"]. If @scheme[err-byte] is @scheme[#f], and if the @scheme[start] to @scheme[end] substring of @scheme[str] has a character with a value greater than @scheme[255], then the @exnraise[exn:fail:contract].} @@ -355,15 +355,15 @@ Certain encoding combinations are always available: any input byte that is not part of a valid encoding sequence is effectively replaced by @scheme[(char->integer #\?)]. (This handling of invalid sequences is consistent with the interpretation - of port bytes streams into characters; see @secref["mz:ports"].)} + of port bytes streams into characters; see @secref["ports"].)} @item{@scheme[(bytes-open-converter "" "UTF-8")] --- converts from - the current locale's default encoding (see @secref["mz:encodings"]) + the current locale's default encoding (see @secref["encodings"]) to UTF-8.} @item{@scheme[(bytes-open-converter "UTF-8" "")] --- converts from UTF-8 to the current locale's default encoding (see - @secref["mz:encodings"]).} + @secref["encodings"]).} @item{@scheme[(bytes-open-converter "platform-UTF-8" "platform-UTF-16")] --- converts UTF-8 to UTF-16 under @|AllUnix|, where each UTF-16 @@ -395,7 +395,7 @@ Certain encoding combinations are always available: } A newly opened byte converter is registered with the current custodian -(see @secref["mz:custodians"]), so that the converter is closed when +(see @secref["custodians"]), so that the converter is closed when the custodian is shut down. A converter is not registered with a custodian (and does not need to be closed) if it is one of the guaranteed combinations not involving @scheme[""] under Unix, or if it diff --git a/collects/scribblings/reference/channels.scrbl b/collects/scribblings/reference/channels.scrbl index 86a5cd5e8b..513f92f981 100644 --- a/collects/scribblings/reference/channels.scrbl +++ b/collects/scribblings/reference/channels.scrbl @@ -3,7 +3,7 @@ @require["mz.ss"] -@title[#:tag "mz:channel"]{Channels} +@title[#:tag "channel"]{Channels} A @deftech{channel} both synchronizes a pair of threads and passes a value from one to the other. Channels are synchronous; both the sender @@ -15,13 +15,13 @@ Channel synchronization is @defterm{fair}: if a thread is blocked on a channel and transaction opportunities for the channel occur infinitely often, then the thread eventually participates in a transaction. -For buffered asynchronous channels, see @secref["mz:async-channel"]. +For buffered asynchronous channels, see @secref["async-channel"]. @defproc[(make-channel) channel?]{ Creates and returns a new channel. The channel can be used with @scheme[channel-get], with @scheme[channel-try-get], or as a -@tech{synchronizable event} (see @secref["mz:sync"]) to receive a value +@tech{synchronizable event} (see @secref["sync"]) to receive a value through the channel. The channel can be used with @scheme[channel-put] or through the result of @scheme[channel-put-evt] to send a value through the channel.} diff --git a/collects/scribblings/reference/chars.scrbl b/collects/scribblings/reference/chars.scrbl index 74d7b87814..c3fb00afff 100644 --- a/collects/scribblings/reference/chars.scrbl +++ b/collects/scribblings/reference/chars.scrbl @@ -3,9 +3,9 @@ @define[(UCat x) x] -@title[#:tag "mz:characters"]{Characters} +@title[#:tag "characters"]{Characters} -@guideintro["guide:characters"]{characters} +@guideintro["characters"]{characters} MzScheme characters range over Unicode scalar values, which includes characters whose values range from @schemevalfont{#x0} to @@ -202,7 +202,7 @@ Return @scheme[#t] if @scheme[char] is between @scheme[#\u0000] and @scheme[#\u001F] inclusive or @scheme[#\u007F] and @scheme[#\u009F] inclusive.} -@defproc[(char-general-category [char char?]) boolean?]{ +@defproc[(char-general-category [char char?]) symbol?]{ Returns a symbol representing the character's Unicode general category, which is @indexed-scheme['lu], @indexed-scheme['ll], diff --git a/collects/scribblings/reference/class.scrbl b/collects/scribblings/reference/class.scrbl index fbb7d237f1..7f47c28a77 100644 --- a/collects/scribblings/reference/class.scrbl +++ b/collects/scribblings/reference/class.scrbl @@ -2,6 +2,7 @@ @require["mz.ss"] @require[(lib "class.ss")] @require-for-syntax[mzscheme] +@require-for-label[(lib "class.ss")] @begin[ @@ -71,6 +72,8 @@ @title[#:tag "mzlib:class" #:style 'toc]{Classes and Objects} +@declare-exporting[big (lib "big/class")] + @local-table-of-contents[] A @deftech{class} specifies @@ -147,7 +150,7 @@ interface is not an object (i.e., there are no ``meta-classes'' or @; ------------------------------------------------------------------------ -@section[#:tag "mz:createinterface"]{Creating Interfaces} +@section[#:tag "createinterface"]{Creating Interfaces} @defform[(interface (super-interface-expr ...) id ...)]{ @@ -179,7 +182,7 @@ superinterfaces specify inconsistent derivation requirements, the @; ------------------------------------------------------------------------ -@section[#:tag "mz:createclass"]{Creating Classes} +@section[#:tag "createclass"]{Creating Classes} @defthing[object% class?]{ @@ -277,14 +280,14 @@ implementation requirement of each interface, otherwise the @exnraise[exn:fail:object]. An @scheme[inspect] @scheme[class-clause] selects an inspector (see -@secref["mz:inspectors"]) for the class extension. The +@secref["inspectors"]) for the class extension. The @scheme[inspector-expr] must evaluate to an inspector or @scheme[#f] when the @scheme[class*] form is evaluated. Just as for structure types, an inspector controls access to the class's fields, including private fields, and also affects comparisons using @scheme[equal?]. If no @scheme[inspect] clause is provided, access to the class is controlled by the parent of the current inspector (see -@secref["mz:inspectors"]). A syntax error is reported if more than one +@secref["inspectors"]). A syntax error is reported if more than one @scheme[inspect] clause is specified. The other @scheme[class-clause]s define initialization arguments, @@ -296,13 +299,13 @@ public and private fields, and public and private methods. For each clause, there must be one @scheme[method-definition]. All other definition @scheme[class-clause]s create private fields. All remaining @scheme[expr]s are initialization expressions to be evaluated when the -class is instantiated (see @secref["mz:objcreation"]). +class is instantiated (see @secref["objcreation"]). The result of a @scheme[class*] expression is a new class, derived from the specified superclass and implementing the specified interfaces. Instances of the class are created with the @scheme[instantiate] form or @scheme[make-object] procedure, as -described in @secref["mz:objcreation"]. +described in @secref["objcreation"]. Each @scheme[class-clause] is (partially) macro-expanded to reveal its shapes. If a @scheme[class-clause] is a @scheme[begin] expression, its @@ -314,39 +317,44 @@ Within a @scheme[class*] form for instances of the new class, @scheme[this] is bound to the object itself; @scheme[super-instantiate], @scheme[super-make-object], and @scheme[super-new] are bound to forms to initialize fields in the -superclass (see @secref["mz:objcreation"]); @scheme[super] is +superclass (see @secref["objcreation"]); @scheme[super] is available for calling superclass methods (see -@secref["mz:clmethoddefs"]); and @scheme[inner] is available for +@secref["clmethoddefs"]); and @scheme[inner] is available for calling subclass augmentations of methods (see -@secref["mz:clmethoddefs"]).} +@secref["clmethoddefs"]).} @defform[(class superclass-expr class-clause ...)]{ Like @scheme[class*], but omits the @scheme[interface-expr]s, for the case that none are needed.} +@defidform[this]{ + +Within a @scheme[class*] form, refers to the current object (i.e., the +object being initialized or whose method was called). Use outside the +body of a @scheme[class*] form is a syntax error.} @defclassforms[ [(inspect inspector-expr) ()] - [(init init-decl ...) ("mz:clinitvars")] - [(init-field init-decl ...) ("mz:clinitvars" "mz:clfields")] - [(field field-decl ...) ("mz:clfields")] - [(inherit-field maybe-renamed ...) ("mz:clfields")] - [* ((init-rest id) (init-rest)) ("mz:clinitvars")] - [(public maybe-renamed ...) ("mz:clmethoddefs")] - [(pubment maybe-renamed ...) ("mz:clmethoddefs")] - [(public-final maybe-renamed ...) ("mz:clmethoddefs")] - [(override maybe-renamed ...) ("mz:clmethoddefs")] - [(overment maybe-renamed ...) ("mz:clmethoddefs")] - [(override-final maybe-renamed ...) ("mz:clmethoddefs")] - [(augment maybe-renamed ...) ("mz:clmethoddefs")] - [(augride maybe-renamed ...) ("mz:clmethoddefs")] - [(augment-final maybe-renamed ...) ("mz:clmethoddefs")] - [(private id ...) ("mz:clmethoddefs")] - [(inherit maybe-renamed ...) ("mz:classinherit")] - [(inherit/super maybe-renamed ...) ("mz:classinherit")] - [(inherit/inner maybe-renamed ...) ("mz:classinherit")] - [(rename-super renamed ...) ("mz:classinherit")] - [(rename-inner renamed ...) ("mz:classinherit")] + [(init init-decl ...) ("clinitvars")] + [(init-field init-decl ...) ("clinitvars" "clfields")] + [(field field-decl ...) ("clfields")] + [(inherit-field maybe-renamed ...) ("clfields")] + [* ((init-rest id) (init-rest)) ("clinitvars")] + [(public maybe-renamed ...) ("clmethoddefs")] + [(pubment maybe-renamed ...) ("clmethoddefs")] + [(public-final maybe-renamed ...) ("clmethoddefs")] + [(override maybe-renamed ...) ("clmethoddefs")] + [(overment maybe-renamed ...) ("clmethoddefs")] + [(override-final maybe-renamed ...) ("clmethoddefs")] + [(augment maybe-renamed ...) ("clmethoddefs")] + [(augride maybe-renamed ...) ("clmethoddefs")] + [(augment-final maybe-renamed ...) ("clmethoddefs")] + [(private id ...) ("clmethoddefs")] + [(inherit maybe-renamed ...) ("classinherit")] + [(inherit/super maybe-renamed ...) ("classinherit")] + [(inherit/inner maybe-renamed ...) ("classinherit")] + [(rename-super renamed ...) ("classinherit")] + [(rename-inner renamed ...) ("classinherit")] ] @defstarshorthands[ @@ -404,7 +412,7 @@ with @scheme[deserialize-id-expr].} @; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:clinitvars"]{Initialization Variables} +@subsection[#:tag "clinitvars"]{Initialization Variables} A class's initialization variables, declared with @scheme[init], @scheme[init-field], and @scheme[init-rest], are instantiated @@ -438,7 +446,7 @@ an argument is not provided for its variable. The environment of variables, all of the fields, and all of the methods of the class. If multiple @scheme[default-value-expr]s are evaluated, they are evaluated from left to right. Object creation and field initialization -are described in detail in @secref["mz:objcreation"]. +are described in detail in @secref["objcreation"]. If an initialization variable has no @scheme[default-value-expr], then the object creation or superclass initialization call must supply an @@ -456,7 +464,7 @@ using the order of @scheme[init] and @scheme[init-field] clauses and the order of variables within each clause. When a @scheme[instantiate] form provides both by-position and by-name arguments, the converted arguments are placed before by-name arguments. (The order can be -significant; see also @secref["mz:objcreation"].) +significant; see also @secref["objcreation"].) Unless a class contains an @scheme[init-rest] clause, when the number of by-position arguments exceeds the number of declared initialization @@ -480,18 +488,18 @@ are provided to a class with an @scheme[init-rest] clause, the @exnraise[exn:fail:object]. Unused (by-name) arguments are to be propagated to the superclass, as -described in @secref["mz:objcreation"]. Multiple initialization +described in @secref["objcreation"]. Multiple initialization arguments can use the same name if the class derivation contains multiple declarations (in different classes) of initialization -variables with the name. See @secref["mz:objcreation"] for further +variables with the name. See @secref["objcreation"] for further details. -See also @secref["mz:extnames"] for information about internal and +See also @secref["extnames"] for information about internal and external names. @; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:clfields"]{Fields} +@subsection[#:tag "clfields"]{Fields} Each @scheme[field], @scheme[init-field], and non-method @scheme[define-values] clause in a class declares one or more new @@ -500,11 +508,11 @@ fields for the class. Fields declared with @scheme[field] or mutated by subclasses using @scheme[inherit-field]. Public fields are also accessible outside the class via @scheme[class-field-accessor] and mutable via @scheme[class-field-mutator] (see -@secref["mz:ivaraccess"]). Fields declared with @scheme[define-values] +@secref["ivaraccess"]). Fields declared with @scheme[define-values] are accessible only within the class. A field declared with @scheme[init-field] is both a public field and -an initialization variable. See @secref["mz:clinitvars"] for +an initialization variable. See @secref["clinitvars"] for information about initialization variables. An @scheme[inherit-field] declaration makes a public field defined by @@ -517,19 +525,19 @@ is not declared with @scheme[inherit-field] in the derived class. The controls lexical scope within a class expression. When an object is first created, all of its fields have the -@|undefined-const| value (see @secref["mz:void"]). The fields of a +@|undefined-const| value (see @secref["void"]). The fields of a class are initialized at the same time that the class's initialization -expressions are evaluated; see @secref["mz:objcreation"] for more +expressions are evaluated; see @secref["objcreation"] for more information. -See also @secref["mz:extnames"] for information about internal and +See also @secref["extnames"] for information about internal and external names. @; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:clmethods"]{Methods} +@subsection[#:tag "clmethods"]{Methods} -@subsubsection[#:tag "mz:clmethoddefs"]{Method Definitions} +@subsubsection[#:tag "clmethoddefs"]{Method Definitions} Each @scheme[public], @scheme[override], @scheme[augment], @scheme[pubment], @scheme[overment], @scheme[augride], @@ -631,7 +639,7 @@ the @scheme[arg-list-expr] must not be a parenthesized expression.} @; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsubsection[#:tag "mz:classinherit"]{Inherited and Superclass Methods} +@subsubsection[#:tag "classinherit"]{Inherited and Superclass Methods} Each @scheme[inherit], @scheme[inherit/super], @scheme[inherit/inner], @scheme[rename-super], and @scheme[rename-inner] clause declares one @@ -683,7 +691,7 @@ If a method declared with @scheme[inherit], @scheme[inherit/super], @; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsubsection[#:tag "mz:extnames"]{Internal and External Names} +@subsubsection[#:tag "extnames"]{Internal and External Names} Each method declared with @scheme[public], @scheme[override], @scheme[augment], @scheme[pubment], @scheme[overment], @@ -695,7 +703,7 @@ when @scheme[(internal-id external-id)] is used for declaring the method. The internal name is used to access the method directly within the class expression (including within @scheme[super] or @scheme[inner] forms), while the external name is used with -@scheme[send] and @scheme[generic] (see @secref["mz:ivaraccess"]). If +@scheme[send] and @scheme[generic] (see @secref["ivaraccess"]). If a single @scheme[identifier] is provided for a method declaration, the identifier is used for both the internal and external names. @@ -844,7 +852,7 @@ Produces an integer hash code consistent with @; ------------------------------------------------------------------------ -@section[#:tag "mz:objcreation"]{Creating Objects} +@section[#:tag "objcreation"]{Creating Objects} The @scheme[make-object] procedure creates a new object with by-position initialization arguments, the @scheme[new] form @@ -855,7 +863,7 @@ by-position and by-name initialization arguments. All fields in the newly created object are initially bound to the special @|undefined-const| value (see -@secref["mz:void"]). Initialization variables with default value +@secref["void"]). Initialization variables with default value expressions (and no provided value) are also initialized to @|undefined-const|. After argument values are assigned to initialization variables, expressions in @scheme[field] clauses, @@ -901,7 +909,7 @@ initialization (unlike objects in C++). Creates an instance of @scheme[class]. The @scheme[init-v]s are passed as initialization arguments, bound to the initialization variables of @scheme[class] for the newly created object as -described in @secref["mz:clinitvars"]. If @scheme[class] is not a +described in @secref["clinitvars"]. If @scheme[class] is not a class, the @exnraise[exn:fail:contract].} @defform[(new class-expr (id by-name-expr) ...)]{ @@ -922,7 +930,7 @@ argument for the corresponding @scheme[id].} @defidform[super-make-object]{ Produces a procedure that takes by-position arguments an invokes -superclass initialization. See @secref["mz:objcreation"] for more +superclass initialization. See @secref["objcreation"] for more information.} @@ -930,18 +938,18 @@ information.} Invokes superclass initialization with the specified by-position and -by-name arguments. See @secref["mz:objcreation"] for more +by-name arguments. See @secref["objcreation"] for more information.} @defform[(super-new (id by-name-expr ...) ...)]{ Invokes superclass initialization with the specified by-name -arguments. See @secref["mz:objcreation"] for more information.} +arguments. See @secref["objcreation"] for more information.} @; ------------------------------------------------------------------------ -@section[#:tag "mz:ivaraccess"]{Field and Method Access} +@section[#:tag "ivaraccess"]{Field and Method Access} In expressions within a class definition, the initialization variables, fields, and methods of the class all part of the @@ -953,7 +961,7 @@ initialization variables can be mutated with @scheme[set!]. @; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:methodcalls"]{Methods} +@subsection[#:tag "methodcalls"]{Methods} Method names within a class can only be used in the procedure position of an application expression; any other use is a syntax error. @@ -1024,7 +1032,7 @@ applied directly (in the same way as declared methods within a class) for each method. The each @scheme[obj-expr] must produce an object, which must have a public method named by the corresponding @scheme[method-id]. The corresponding @scheme[id] is bound so that it -can be applied directly (see @secref["mz:methodcalls"]). +can be applied directly (see @secref["methodcalls"]). Example: @@ -1123,7 +1131,7 @@ of @scheme[generic-expr], the @exnraise[exn:fail:object].} @; ------------------------------------------------------------------------ -@section[#:tag "mz:mixins"]{Mixins} +@section[#:tag "mixins"]{Mixins} @defform[(mixin (interface-expr ...) (interface-expr ...) class-clause ...)]{ @@ -1146,7 +1154,7 @@ Evaluation of a @scheme[mixin] form checks that the @; ------------------------------------------------------------------------ -@section[#:tag "mz:objectserialize"]{Object Serialization} +@section[#:tag "objectserialize"]{Object Serialization} @defform[ (define-serializable-class* class-id superclass-expr @@ -1230,7 +1238,7 @@ The @scheme[externalizable<%>] interface includes only the @; ------------------------------------------------------------------------ -@section[#:tag "mz:objectutils"]{Object, Class, and Interface Utilities} +@section[#:tag "objectutils"]{Object, Class, and Interface Utilities} @defproc[(object? [v any/c]) boolean?]{ @@ -1385,3 +1393,10 @@ values of @scheme[struct-type-info]: specific ancestor class, @scheme[#t] otherwise.} }} + +@defstruct[(exn:fail:object exn:fail) ()]{ + +Raised for @scheme[class]-related failures, such as attempting to call +a method that is not supplied by an object. + +} diff --git a/collects/scribblings/reference/code-inspectors.scrbl b/collects/scribblings/reference/code-inspectors.scrbl index 51eb52bf2d..37505cf423 100644 --- a/collects/scribblings/reference/code-inspectors.scrbl +++ b/collects/scribblings/reference/code-inspectors.scrbl @@ -1,10 +1,10 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:modprotect"]{Code Inspectors} +@title[#:tag "modprotect"]{Code Inspectors} In the same way that inspectors control access to structure fields -(see @secref["mz:inspectors"]), inspectors also control access to +(see @secref["inspectors"]), inspectors also control access to @tech{module bindings}. The default inspector for @tech{module bindings} is determined by the @scheme[current-code-inspector] parameter, instead of the @scheme[current-inspector] parameter. @@ -51,7 +51,7 @@ macro expander prevent any reference to an unexported identifier, unless the reference appears within an expression that was generated by the module's macros (or, more precisely, a macro from a module whose declaration inspector controls the invocation of the -identifier's module). See @secref["mz:stxcerts"] for further +identifier's module). See @secref["stxcerts"] for further information. @defparam[current-code-inspector insp inspector?]{ diff --git a/collects/scribblings/reference/collects.scrbl b/collects/scribblings/reference/collects.scrbl index 9d94ce8c59..b2431cb431 100644 --- a/collects/scribblings/reference/collects.scrbl +++ b/collects/scribblings/reference/collects.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:collects"]{Libraries and Collections} +@title[#:tag "collects"]{Libraries and Collections} A @deftech{library} is @scheme[module] declaration for use by multiple programs. Scheme further groups libraries into @deftech{collections} @@ -106,7 +106,7 @@ collection is not found, the @exnraise[exn:fail:filesystem].} Parameter that determines a list of complete directory paths for library collections used by @scheme[require]. See -@secref["mz:collects"] for more information.} +@secref["collects"] for more information.} @defboolparam[use-user-specific-search-paths on?]{ diff --git a/collects/scribblings/reference/concurrency.scrbl b/collects/scribblings/reference/concurrency.scrbl index 990f4f2555..a072d32b80 100644 --- a/collects/scribblings/reference/concurrency.scrbl +++ b/collects/scribblings/reference/concurrency.scrbl @@ -2,7 +2,7 @@ @require[(lib "bnf.ss" "scribble")] @require["mz.ss"] -@title[#:tag "mz:concurrency" #:style 'toc]{Concurrency} +@title[#:tag "concurrency" #:style 'toc]{Concurrency} PLT Scheme supports multiple threads of control within a program. Threads run concurrently, in the sense that one thread can diff --git a/collects/scribblings/reference/cont-marks.scrbl b/collects/scribblings/reference/cont-marks.scrbl index 0267e2749e..1ccaaf590d 100644 --- a/collects/scribblings/reference/cont-marks.scrbl +++ b/collects/scribblings/reference/cont-marks.scrbl @@ -5,9 +5,9 @@ @define[(cont n) (make-element "schemevariable" (list "C" (make-element 'subscript (list (format "~a" n)))))] -@title[#:tag "mz:contmarks"]{Continuation Marks} +@title[#:tag "contmarks"]{Continuation Marks} -See @secref["mz:mark-model"] and @secref["mz:prompt-model"] for +See @secref["mark-model"] and @secref["prompt-model"] for general information about continuation marks. The list of continuation marks for a key @scheme[_k] and a continuation @@ -29,7 +29,7 @@ The list of continuation marks for a key @scheme[_k] and a continuation } The @scheme[with-continuation-mark] form installs a mark on the first -frame of the current continuation (see @secref["mz:wcm"]). Procedures +frame of the current continuation (see @secref["wcm"]). Procedures such as @scheme[current-continuation-marks] allow inspection of marks. Whenever Scheme creates an exception record for a primitive exception, @@ -52,7 +52,7 @@ continuation's frames to the marks that were present when Returns an opaque value containing the set of continuation marks for all keys in the continuation @scheme[cont] up to the prompt tagged by @scheme[prompt-tag]. If @scheme[cont] is an escape continuation (see -@secref["mz:prompt-model"]), then the current continuation must extend +@secref["prompt-model"]), then the current continuation must extend @scheme[cont], or the @exnraise[exn:fail:contract]. If @scheme[cont] was not captured with respect to @scheme[prompt-tag] and does not include a prompt for @scheme[prompt-tag], the @@ -125,7 +125,7 @@ trace}}'' for @scheme[mark-set]'s continuation. The list contains pairs, where the @scheme[car] of each pair contains either @scheme[#f] or a symbol for a procedure name, and the @scheme[cdr] of each pair contains either @scheme[#f] or a @scheme[srcloc] value for the -procedure's source location (see @secref["mz:linecol"]); the +procedure's source location (see @secref["linecol"]); the @scheme[car] and @scheme[cdr] are never both @scheme[#f]. The stack-trace list is the result of @@ -134,7 +134,7 @@ Scheme's private key for procedure-call marks. A stack trace is extracted from an exception and displayed by the default error display handler (see @scheme[current-error-display-handler]) for exceptions other than @scheme[exn:fail:user] (see @scheme[raise-user-error] in -@secref["mz:errorproc"]).} +@secref["errorproc"]).} @examples[ (define (extract-current-continuation-marks key) diff --git a/collects/scribblings/reference/cont.scrbl b/collects/scribblings/reference/cont.scrbl index 6e1c320032..5694ee84c5 100644 --- a/collects/scribblings/reference/cont.scrbl +++ b/collects/scribblings/reference/cont.scrbl @@ -1,9 +1,9 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:cont"]{Continuations} +@title[#:tag "cont"]{Continuations} -See @secref["mz:cont-model"] and @secref["mz:prompt-model"] for +See @secref["cont-model"] and @secref["prompt-model"] for general information about continuations. PLT Scheme's support for prompts and composable continuations most closely resembles Dorai Sitaram's @scheme[\%] and @scheme[fcontrol] operator @cite[#:key @@ -18,23 +18,23 @@ barrier: @itemize{ @item{applying an exception handler, an error escape handler, or an - error display handler (see @secref["mz:exns"]);} + error display handler (see @secref["exns"]);} - @item{applying a macro transformer (see @secref["mz:stxtrans"]), + @item{applying a macro transformer (see @secref["stxtrans"]), evaluating a compile-time expression, or applying a module name - resolver (see @secref["mz:modnameresolver"]);} + resolver (see @secref["modnameresolver"]);} - @item{applying a custom-port procedure (see @secref["mz:customport"]), an - event guard procedure (see @secref["mz:sync"]), or a parameter guard - procedure (see @secref["mz:parameters"]);} + @item{applying a custom-port procedure (see @secref["customport"]), an + event guard procedure (see @secref["sync"]), or a parameter guard + procedure (see @secref["parameters"]);} @item{applying a security-guard procedure (see - @secref["mz:securityguards"]);} + @secref["securityguards"]);} - @item{applying a will procedure (see @secref["mz:willexecutor"]); or} + @item{applying a will procedure (see @secref["willexecutor"]); or} @item{evaluating or loading code from the stand-alone MzScheme - command line (see @secref["mz:running-sa"]).} + command line (see @secref["running-sa"]).} } @@ -141,7 +141,7 @@ and if the same barrier is not part of the captured continuation, then the @exnraise[exn:fail:contract:continuation]. A continuation can be invoked from the thread (see -@secref["mz:threads"]) other than the one where it was captured.} +@secref["threads"]) other than the one where it was captured.} @defproc[(call/cc [proc (continuation? . -> . any)] @@ -275,12 +275,12 @@ Normally, the second part of this continuation is never reached, due to a jump in the first part. However, the second part is relevant because it enables jumps to escape continuations that are contained in the context of the @scheme[dynamic-wind] call. Furthermore, it means -that the continuation marks (see @secref["mz:contmarks"]) and -parameterization (see @secref["mz:parameters"]) for @scheme[pre-thunk] +that the continuation marks (see @secref["contmarks"]) and +parameterization (see @secref["parameters"]) for @scheme[pre-thunk] correspond to those of the @scheme[dynamic-wind] call that installed @scheme[pre-thunk]. The @scheme[pre-thunk] call, however, is @scheme[parameterize-break]ed to disable breaks (see also -@secref["mz:breakhandler"]). +@secref["breakhandler"]). Similarly, when @scheme[post-thunk] is called due to a continuation jump, the continuation of @scheme[post-thunk] jumps to a less deeply @@ -294,7 +294,7 @@ to disable breaks. In both cases, the target for a jump is recomputed after each @scheme[pre-thunk] or @scheme[post-thunk] completes. When a -prompt-delimited continuation (see @secref["mz:prompt-model"]) is +prompt-delimited continuation (see @secref["prompt-model"]) is captured in a @scheme[post-thunk], it might be delimited and instantiated in such a way that the target of a jump turns out to be different when the continuation is applied than when the continuation diff --git a/collects/scribblings/reference/contracts.scrbl b/collects/scribblings/reference/contracts.scrbl index 64bf6a4c11..4f65daff9b 100644 --- a/collects/scribblings/reference/contracts.scrbl +++ b/collects/scribblings/reference/contracts.scrbl @@ -3,6 +3,8 @@ @title[#:tag "mzlib:contract" #:style 'toc]{Contracts} +@declare-exporting[big (lib "big/contract")] + A @defterm{contract} controls the flow of values to ensure that the expectations of one party are met by another party. The @scheme[provide/contract] form is the primary mechanism for @@ -361,7 +363,7 @@ produces a contract on functions of two arguments. The first argument must be an integer, and the second argument must be a boolean. The function must produce an integer. (This example uses Scheme's infix notation so that the @scheme[->] appears in a suggestive place; see -@secref["mz:parse-pair"]). +@secref["parse-pair"]). If @scheme[any] is used as the last argument to @scheme[->], no contract checking is performed on the result of the function, and @@ -854,7 +856,7 @@ Here is the first of those two projections, rewritten for use in the contract system: @schemeblock[ -(define (int-proj pos neg src-info contract-name) +(define (int-proj pos neg src-info name) (lambda (x) (if (integer? x) x @@ -862,7 +864,7 @@ use in the contract system: val src-info pos - contract-name + name "expected , given: ~e" val)))) ] @@ -883,9 +885,9 @@ to @scheme[raise-contract-error]). Compare that to the projection for our function contract: @schemeblock[ -(define (int->int-proj pos neg src-info contract-name) - (let ([dom (int-proj neg pos src-info contract-name)] - [rng (int-proj pos neg src-info contract-name)]) +(define (int->int-proj pos neg src-info name) + (let ([dom (int-proj neg pos src-info name)] + [rng (int-proj pos neg src-info name)]) (lambda (f) (if (and (procedure? f) (procedure-arity-includes? f 1)) @@ -895,7 +897,7 @@ Compare that to the projection for our function contract: val src-info pos - contract-name + name "expected a procedure of one argument, given: ~e" val))))) ] @@ -940,9 +942,9 @@ returns a contract for functions between them. @schemeblock[ (define (make-simple-function-contract dom-proj range-proj) - (lambda (pos neg src-info contract-name) - (let ([dom (dom-proj neg pos src-info contract-name)] - [rng (range-proj pos neg src-info contract-name)]) + (lambda (pos neg src-info name) + (let ([dom (dom-proj neg pos src-info name)] + [rng (range-proj pos neg src-info name)]) (lambda (f) (if (and (procedure? f) (procedure-arity-includes? f 1)) @@ -952,7 +954,7 @@ returns a contract for functions between them. val src-info pos - contract-name + name "expected a procedure of one argument, given: ~e" val)))))) ] @@ -1131,7 +1133,7 @@ For example, (define-opt/c (bst-between/c lo hi) (or/c null? - (bt/c [val (between/c lo hi)] + (bt/c [val (real-in lo hi)] [left (val) (bst-between/c lo val)] [right (val) (bst-between/c val hi)]))) diff --git a/collects/scribblings/reference/control.scrbl b/collects/scribblings/reference/control.scrbl index b0c97e27bb..7fda39169f 100644 --- a/collects/scribblings/reference/control.scrbl +++ b/collects/scribblings/reference/control.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:control" #:style 'toc]{Control Flow} +@title[#:tag "control" #:style 'toc]{Control Flow} @local-table-of-contents[] diff --git a/collects/scribblings/reference/custodians.scrbl b/collects/scribblings/reference/custodians.scrbl index bb5820350e..f56a8967ab 100644 --- a/collects/scribblings/reference/custodians.scrbl +++ b/collects/scribblings/reference/custodians.scrbl @@ -2,9 +2,9 @@ @require[(lib "bnf.ss" "scribble")] @require["mz.ss"] -@title[#:tag "mz:custodians"]{Custodians} +@title[#:tag "custodians"]{Custodians} -See @secref["mz:custodian-model"] for basic information on the PLT +See @secref["custodian-model"] for basic information on the PLT Scheme custodian model. @defproc[(custodian? [v any/c]) boolean?]{ @@ -65,7 +65,7 @@ per-custodian memory accounting, otherwise the @exnraise[exn:fail:unsupported]. If a check is registered, and if PLT Scheme later reaches a state after -garbage collection (see @secref["mz:gc-model"]) where allocating +garbage collection (see @secref["gc-model"]) where allocating @scheme[need-amt] bytes charged to @scheme[limit-cust] would fail or tigger some shutdown, then @scheme[stop-cust] is shut down.} @@ -78,7 +78,7 @@ per-custodian memory accounting, otherwise the @exnraise[exn:fail:unsupported]. If a check is registered, and if PLT Scheme later reaches a state -after garbage collection (see @secref["mz:gc-model"]) where +after garbage collection (see @secref["gc-model"]) where @scheme[limit-cust] owns more than @scheme[limit-amt] bytes, then @scheme[stop-cust] is shut down. diff --git a/collects/scribblings/reference/custom-ports.scrbl b/collects/scribblings/reference/custom-ports.scrbl index 5f809c31f0..a41693f038 100644 --- a/collects/scribblings/reference/custom-ports.scrbl +++ b/collects/scribblings/reference/custom-ports.scrbl @@ -3,7 +3,7 @@ @require[(lib "list.ss")] -@title[#:tag "mz:customport"]{Custom Ports} +@title[#:tag "customport"]{Custom Ports} The @scheme[make-input-port] and @scheme[make-output-port] procedures create custom ports with arbitrary control procedures (much like @@ -69,7 +69,7 @@ The arguments implement the port as follows: but a procedure result is allowed only when @scheme[peek] is not @scheme[#f]; or} - @item{a @tech{synchronizable event} (see @secref["mz:sync"]) + @item{a @tech{synchronizable event} (see @secref["sync"]) that becomes ready when the read is complete (roughly): the event's value can one of the above three results or another event like itself; in the last case, a reading process loops @@ -281,7 +281,7 @@ The arguments implement the port as follows: positive number or @scheme[#f]), the column number for the next item in the port's stream (a non-negative number or @scheme[#f]), and the position for the next item in the port's stream (a - positive number or @scheme[#f]). See also @secref["mz:linecol"]. + positive number or @scheme[#f]). See also @secref["linecol"]. This procedure is only called if line counting is enabled for the port via @scheme[port-count-lines!] (in which case @@ -308,7 +308,7 @@ The arguments implement the port as follows: @scheme['none]) to set the buffer mode, and it is called with zero arguments to get the current buffer mode. In the latter case, the result must be @scheme['block], @scheme['none], or @scheme[#f] - (unknown). See @secref["mz:port-buffers"] for more information on + (unknown). See @secref["port-buffers"] for more information on buffer modes.} } @@ -339,7 +339,7 @@ The arguments implement the port as follows: The special-value procedure can return an arbitrary value, and it will be called zero or one times (not necessarily before further - reads or peeks from the port). See @secref["mz:reader-procs"] for + reads or peeks from the port). See @secref["reader-procs"] for more details on the procedure's result. If @scheme[read-in] or @scheme[peek] returns a special @@ -686,7 +686,7 @@ procedures. @item{@scheme[name] --- the name for the output port.} - @item{@scheme[evt] --- a synchronization event (see @secref["mz:sync"]; + @item{@scheme[evt] --- a synchronization event (see @secref["sync"]; e.g., a semaphore or another port). The event is used in place of the output port when the port is supplied to synchronization procedures like @scheme[sync]. Thus, the event should be @@ -734,7 +734,7 @@ procedures. @item{@scheme[#f] if no bytes could be written, perhaps because the internal buffer could not be completely flushed;} - @item{a synchronizable event (see @secref["mz:sync"]) that acts like + @item{a synchronizable event (see @secref["sync"]) that acts like the result of @scheme[write-bytes-avail-evt] to complete the write.} @@ -824,7 +824,7 @@ procedures. @item{@scheme[#f] if the special could not be written, perhaps because an internal buffer could not be completely flushed;} - @item{a synchronizable event (see @secref["mz:sync"]) that acts like + @item{a synchronizable event (see @secref["sync"]) that acts like the result of @scheme[get-write-special-evt] to complete the write.} } @@ -857,7 +857,7 @@ procedures. } - The result is a synchronizable event (see @secref["mz:sync"]) to act as + The result is a synchronizable event (see @secref["sync"]) to act as the result of @scheme[write-bytes-avail-evt] for the port (i.e., to complete a write or flush), which becomes available only as data is committed to the port's underlying device, and whose @@ -914,7 +914,7 @@ procedures. the next item written to port's stream (a non-negative number or @scheme[#f]), and the position for the next item written to port's stream (a positive number or @scheme[#f]). See also - @secref["mz:linecol"]. + @secref["linecol"]. This procedure is only called if line counting is enabled for the port via @scheme[port-count-lines!] (in which case @@ -937,7 +937,7 @@ procedures. @scheme['line], or @scheme['none]) to set the buffer mode, and it is called with zero arguments to get the current buffer mode. In the latter case, the result must be @scheme['block], @scheme['line], - @scheme['none], or @scheme[#f] (unknown). See @secref["mz:port-buffers"] + @scheme['none], or @scheme[#f] (unknown). See @secref["port-buffers"] for more information on buffer modes.} } diff --git a/collects/scribblings/reference/custom-write.scrbl b/collects/scribblings/reference/custom-write.scrbl index df1f76a541..ccfd05e2cb 100644 --- a/collects/scribblings/reference/custom-write.scrbl +++ b/collects/scribblings/reference/custom-write.scrbl @@ -9,7 +9,7 @@ Associates a procedure to a structure type to used by the default printer to @scheme[display] or @scheme[write] (or @scheme[print]) instances of the structure type. -@moreref["mz:structprops"]{structure type properties} +@moreref["structprops"]{structure type properties} The procedure for a @scheme[prop:custom-write] value takes three arguments: the structure to be printed, the target port, and a boolean diff --git a/collects/scribblings/reference/data.scrbl b/collects/scribblings/reference/data.scrbl index a5a0b0e3e2..fe199da9b3 100644 --- a/collects/scribblings/reference/data.scrbl +++ b/collects/scribblings/reference/data.scrbl @@ -25,6 +25,12 @@ Returns @scheme[#t] if @scheme[v] is @scheme[#t] or @scheme[#f], @scheme[#f] otherwise.} +@defproc[(not [v any/c]) boolean?]{ + +Returns @scheme[#t] if @scheme[v] is @scheme[#f], @scheme[#f] otherwise. +} + + @defproc[(equal? [v1 any/c] [v2 any/c]) boolean?]{ Two values are @scheme[equal?] if and only if they are @scheme[eqv?], @@ -46,7 +52,7 @@ The number and character datatypes are the only ones for which @defproc[(eq? [v1 any/c] [v2 any/c]) boolean?]{ Return @scheme[#t] if @scheme[v1] and @scheme[v2] refer to the same -object, @scheme[#f] otherwise. See also @secref["mz:model-eq"].} +object, @scheme[#f] otherwise. See also @secref["model-eq"].} @; ------------------------------------------------------------ @@ -62,9 +68,9 @@ object, @scheme[#f] otherwise. See also @secref["mz:model-eq"].} @include-section["chars.scrbl"] @; ------------------------------------------------------------ -@section[#:tag "mz:symbols"]{Symbols} +@section[#:tag "symbols"]{Symbols} -@guideintro["guide:symbols"]{symbols} +@guideintro["symbols"]{symbols} @section-index["symbols" "generating"] @section-index["symbols" "unique"] @@ -72,7 +78,7 @@ object, @scheme[#f] otherwise. See also @secref["mz:model-eq"].} A symbol is like an immutable string, but symbols are normally @deftech{interned}, so that two symbols with the same character content are normally @scheme[eq?]. All symbols produced by the default -reader (see @secref["mz:parse-symbol"]) are interned. +reader (see @secref["parse-symbol"]) are interned. The two procedures @scheme[string->uninterned-symbol] and @scheme[gensym] generate @deftech{uninterned} symbols, i.e., symbols @@ -82,9 +88,9 @@ other symbol, although they may print the same as other symbols. Regular (interned) symbols are only weakly held by the internal symbol table. This weakness can never affect the result of an @scheme[eq?], @scheme[eqv?], or @scheme[equal?] test, but a symbol may disappear -when placed into a weak box (see @secref["mz:weakbox"]) used as the key -in a weak hash table (see @secref["mz:hashtables"]), or used as an -ephemeron key (see @secref["mz:ephemerons"]). +when placed into a weak box (see @secref["weakbox"]) used as the key +in a weak hash table (see @secref["hashtables"]), or used as an +ephemeron key (see @secref["ephemerons"]). @defproc[(symbol? [v any/c]) boolean?]{Returns @scheme[#t] if @scheme[v] is a symbol, @scheme[#f] otherwise.} @@ -124,9 +130,9 @@ ephemeron key (see @secref["mz:ephemerons"]). @include-section["regexps.scrbl"] @; ------------------------------------------------------------ -@section[#:tag "mz:keywords"]{Keywords} +@section[#:tag "keywords"]{Keywords} -@guideintro["guide:keywords"]{keywords} +@guideintro["keywords"]{keywords} A keyword is like an @tech{interned} symbol, but its printed form starts with @litchar{#:}, and a keyword cannot be used as an @@ -137,10 +143,11 @@ expression that produces the symbol. Two keywords are @scheme[eq?] if and only if they print the same. Like symbols, keywords are only weakly held by the internal keyword -table; see @secref["mz:symbols"] for more information. +table; see @secref["symbols"] for more information. -@item{@defproc[(keyword? [v any/c]) any] returns @scheme[#t] if @scheme[v] is a -keyword, @scheme[#f] otherwise.} +@defproc[(keyword? [v any/c]) boolean?]{ + +Returns @scheme[#t] if @scheme[v] is a keyword, @scheme[#f] otherwise.} @defproc[(keyword->string [keyword keyword?]) string?]{ @@ -159,111 +166,10 @@ for each pair of keywords is the same as using @scheme[keyword->string] and @scheme[stringinteger #\?)] produces) so that the entire sequence of bytes is a valid UTF-8 encoding. -See @secref["mz:bytestrings"] for procedures that facilitate +See @secref["bytestrings"] for procedures that facilitate conversions using UTF-8 or other encodings. See also @scheme[reencode-input-port] and @scheme[reencode-output-port] for obtaining a UTF-8-based port from one that uses a different encoding @@ -38,9 +38,9 @@ culture-specific interpretation of character sequences. In particular, a locale determines how strings are ``alphabetized,'' how a lowercase character is converted to an uppercase character, and how strings are compared without regard to case. String operations such as -@scheme[string-ci?] are @italic{not} sensitive to the current locale, -but operations such as @scheme[string-locale-ci?] (see -@secref["mz:strings"]) produce results consistent with the current +@scheme[string-ci=?] are @italic{not} sensitive to the current locale, +but operations such as @scheme[string-locale-ci=?] (see +@secref["strings"]) produce results consistent with the current locale. A locale also designates a particular encoding of code-point sequences @@ -73,3 +73,23 @@ environment-specified locale, if desired.) Setting the current locale to @scheme[#f] makes locale-sensitive operations locale-insensitive, which means using the Unicode mapping for case operations and using UTF-8 for encoding. + +@defparam[current-locale locale (or/c string? false/c)]{ + +A parameter that determines the current @deftech{locale} for +procedures such as @scheme[string-locale-ci=?]. + +When locale sensitivity is disabled by setting the parameter to +@scheme[#f], strings are compared (etc.) in a fully portable manner, +which is the same as the standard procedures. Otherwise, strings are +interpreted according to a locale setting (in the sense of the C +library's @tt{setlocale}). The @scheme[""] locale is always a synonym +for the current machine's default locale, and it is the default. The +@scheme["C"] locale is also always available; setting the locale to +@scheme["C"] is the same as disabling locale sensitivity with +@scheme[#f] only when string operations are restricted to the first +128 characters. Other locale names are platform-specific. + +String or character printing with @scheme[write] is not affected by +the parameter, and neither are symbol case or regular expressions (see +@secref["regexp"]).} diff --git a/collects/scribblings/reference/eval.scrbl b/collects/scribblings/reference/eval.scrbl index 53b7e75ecb..afd3a40a31 100644 --- a/collects/scribblings/reference/eval.scrbl +++ b/collects/scribblings/reference/eval.scrbl @@ -76,7 +76,7 @@ top-level forms from a file. The @tech{load handler} is called by default @tech{compiled-load handler}. A load handler takes two arguments: a path (see -@secref["mz:pathutils"]) and an expected module name. The expected +@secref["pathutils"]) and an expected module name. The expected module name is a symbol when the call is to load a module declaration in response to a @scheme[require] (in which case the file should contain a module declaration), or @scheme[#f] for any other load. @@ -261,7 +261,7 @@ default @tech{compiled-load handler}, and used by default @tech{compiled-load handler}. When a new path or string is provided as the parameter's value, it is -immediately expanded (see @secref["mz:pathutils"]) and converted to a +immediately expanded (see @secref["pathutils"]) and converted to a path. (The directory need not exist.)} @@ -302,11 +302,23 @@ evaluate. This procedure is called by the read phase of ]} +@defparam[current-print proc (any/c -> any)]{ + +A parameter that determines the @deftech{print handler} that is called + by @scheme[read-eval-print-loop] to print the result of an evaluation + (and the result is ignored). + +The default @tech{print handler} @scheme[print]s the value to the + current output port (as determined by the + @scheme[current-output-port] parameter) and then outputs a newline, + except that it prints nothing when the value is @|void-const|.} + + @defparam[current-compile proc (any/c boolean? . -> . compiled-expression?)]{ A parameter that determines the current @deftech{compilation handler}. The @tech{compilation handler} is a procedure that takes a top-level form and -returns a compiled form; see see @secref["mz:compilation-model"] for +returns a compiled form; see see @secref["compilation-model"] for more information on compilation. The @tech{compilation handler} is called by @scheme[compile], and @@ -326,17 +338,17 @@ long as the @scheme[read-accept-compiled] parameter is set to When a compiled form contains syntax object constants, the @litchar{#~}-marshaled form drops source-location information and -properties (@secref["mz:stxprops"]) for the @tech{syntax objects}. +properties (@secref["stxprops"]) for the @tech{syntax objects}. Compiled code parsed from @litchar{#~} may contain references to unexported or protected bindings from a module. At read time, such references are associated with the current code inspector (see @scheme[current-code-inspector]), and the code will only execute if that inspector controls the relevant module invocation (see -@secref["mz:modprotect"]). +@secref["modprotect"]). A compiled-form object may contain @tech{uninterned} symbols (see -@secref["mz:symbols"]) that were created by @scheme[gensym] or +@secref["symbols"]) that were created by @scheme[gensym] or @scheme[string->uninterned-symbol]. When the compiled object is read via @litchar{#~}, each uninterned symbol in the original form is mapped to a new uninterned symbol, where multiple instances of a @@ -366,3 +378,20 @@ handler} in tail position with @scheme[stx].} Returns @scheme[#t] if @scheme[v] is a compiled form, @scheme[#f] otherwise.} + + +@defboolparam[compile-enforce-module-constants on?]{ + +A parameter that determines how a module declaration is compiled. + +When constants are enforced, and when the macro-expanded body of a +module contains no @scheme[set!] assignment to a particular variable +defined within the module, then the variable is marked as constant +when the definition is evaluated. Afterward, the variable's value +cannot be assigned or undefined through @scheme[module->namespace], +and it cannot be defined by redeclaring the module. + +Enforcing constants allows the compiler to inline some variable +values, and it allows the native-code just-in-time compiler to +generate code that skips certain run-time checks.} + diff --git a/collects/scribblings/reference/evts.scrbl b/collects/scribblings/reference/evts.scrbl index e069a96fe4..7a0dbe16d6 100644 --- a/collects/scribblings/reference/evts.scrbl +++ b/collects/scribblings/reference/evts.scrbl @@ -7,7 +7,7 @@ (tech "synchronization result") " of " x " is " x " itself"))] -@title[#:tag "mz:sync"]{Events} +@title[#:tag "sync"]{Events} @section-index["select"] @section-index["poll"] @@ -120,7 +120,7 @@ types can generate events (see @scheme[prop:evt]). ready. The event's result is obtained by a tail call to @scheme[proc] on the result of @scheme[evt].} - @item{@elemtag["mz:guard-evt"]{@scheme[guard]} --- an event returned by @scheme[guard-evt] applied + @item{@elemtag["guard-evt"]{@scheme[guard]} --- an event returned by @scheme[guard-evt] applied to @scheme[thunk] generates a new event every time that @scheme[guard] is used with @scheme[sync] (or whenever it is part of a choice event used with @scheme[sync], etc.); the generated event is the result of @@ -128,7 +128,7 @@ types can generate events (see @scheme[prop:evt]). returns a non-event, then @scheme[thunk]'s result is replaced with an event that is ready and whose result is @scheme[guard].} - @item{@elemtag["mz:nack-guard-evt"]{@scheme[nack-guard]} --- an event + @item{@elemtag["nack-guard-evt"]{@scheme[nack-guard]} --- an event returned by @scheme[nack-guard-evt] applied to @scheme[proc] generates a new event every time that @scheme[nack-guard] is used with @scheme[sync] (or whenever it is part of a choice event used @@ -147,7 +147,7 @@ types can generate events (see @scheme[prop:evt]). has not yet returned a value). If the event returned by @scheme[proc] is chosen, then the NACK event never becomes ready.} - @item{@elemtag["mz:poll-guard-evt"]{@scheme[poll-guard]} --- an event + @item{@elemtag["poll-guard-evt"]{@scheme[poll-guard]} --- an event returned by @scheme[poll-guard-evt] applied to @scheme[proc] generates a new event every time that @scheme[poll-guard] is used with @scheme[sync] (or whenever it is part of a choice event used @@ -169,7 +169,7 @@ types can generate events (see @scheme[prop:evt]). @item{@scheme[never-evt] --- a constant event that is never ready.} - @item{@elemtag["mz:system-idle-evt"]{@scheme[idle]} --- an event + @item{@elemtag["system-idle-evt"]{@scheme[idle]} --- an event produced by @scheme[system-idle-evt] is ready when, if this event were replaced by @scheme[never-evt], no thread in the system would be available to run. In other words, all threads must be suspended @@ -217,7 +217,7 @@ See also @scheme[alarm-evt] for an alternative timeout mechanism.} @defproc[(sync/enable-break [evt evt?] ...+) any]{ Like @scheme[sync], but breaking is enabled (see -@secref["mz:breakhandler"]) while waiting on the @scheme[evt]s. If +@secref["breakhandler"]) while waiting on the @scheme[evt]s. If breaking is disabled when @scheme[sync/enable-break] is called, then either all @scheme[evt]s remain unchosen or the @scheme[exn:break] exception is raised, but not both.} @@ -261,7 +261,7 @@ breaks explicitly disabled.} @defproc[(guard-evt [generator (-> evt?)]) evt?]{ Creates a value that behaves as an event, but that is actually an -event generator. For details, see @elemref["mz:guard-evt"]{the +event generator. For details, see @elemref["guard-evt"]{the overview}.} @defproc[(nack-guard-evt [generator (evt? . -> . evt?)]) evt?]{ @@ -270,14 +270,14 @@ Creates a value that behaves as an event, but that is actually an event generator; the generator procedure receives an event that becomes ready with a @|void-const| value if the generated event was not ultimately chosen. For details, see -@elemref["mz:nack-guard-evt"]{the overview}.} +@elemref["nack-guard-evt"]{the overview}.} @defproc[(poll-guard-evt [generator (boolean? . -> . evt?)]) evt?]{ Creates a value that behaves as an event, but that is actually an event generator; the generator procedure receives a boolean indicating whether the event is used for polling. For details, see -@elemref["mz:poll-guard-evt"]{the overview}.} +@elemref["poll-guard-evt"]{the overview}.} @defthing[always-evt evt?]{A constant event that is always ready, with itself as its result.} @@ -286,7 +286,7 @@ itself as its result.} @defproc[(system-idle-evt) evt?]{Returns an event that is ready when -the system is otherwise idle; see @elemref["mz:system-idle-evt"]{the +the system is otherwise idle; see @elemref["system-idle-evt"]{the overview} for more information. The result of the @scheme[system-idle-evt] procedure is always the same event.} @@ -366,3 +366,9 @@ and the @scheme[prop:input-port] property takes precedence over (sync/timeout 0 my-wt) (sync/timeout 0 my-wt) ]} + + +@defparam[current-evt-pseudo-random-generator generator pseudo-random-generator?]{ + +A parameter that determines the pseudo-random number generator used by +@scheme[sync] for events created by @scheme[choice-evt].} diff --git a/collects/scribblings/reference/exns.scrbl b/collects/scribblings/reference/exns.scrbl index b3694886c6..289b1c3ae4 100644 --- a/collects/scribblings/reference/exns.scrbl +++ b/collects/scribblings/reference/exns.scrbl @@ -2,9 +2,9 @@ @require[(lib "bnf.ss" "scribble")] @require["mz.ss"] -@title[#:tag "mz:exns"]{Exceptions} +@title[#:tag "exns"]{Exceptions} -See @secref["mz:exn-model"] for information on the PLT Scheme +See @secref["exn-model"] for information on the PLT Scheme exception model. It is based on @cite[#:key "friedman-exns" #:title "Exception system proposal" #:author "Daniel P. Friedman and C. T. Haynes and R. Kent Dybvig" #:location @@ -26,7 +26,7 @@ particular required arity (e.g., @scheme[call-with-input-file], @scheme[exn:fail:contract] if the arity is incorrect. @;------------------------------------------------------------------------ -@section[#:tag "mz:errorproc"]{Raising Exceptions} +@section[#:tag "errorproc"]{Raising Exceptions} @defproc[(raise [v any/c]) any]{ @@ -35,7 +35,7 @@ raised. The @scheme[v] argument can be anything; it is passed to the current @deftech{exception handler}. Breaks are disabled from the time the exception is raised until the exception handler obtains control, and the handler itself is @scheme[parameterize-break]ed to -disable breaks initially; see @secref["mz:breakhandler"] for more +disable breaks initially; see @secref["breakhandler"] for more information on breaks.} @@ -77,7 +77,7 @@ In all cases, the constructed message string is passed to Like @scheme[error], but constructs an exception with @scheme[make-exn:fail:user] instead of @scheme[make-exn:fail]. The default error display handler does not show a ``stack trace'' for -@scheme[exn:fail:user] exceptions (see @secref["mz:contmarks"]), so +@scheme[exn:fail:user] exceptions (see @secref["contmarks"]), so @scheme[raise-user-error] should be used for errors that are intended for end users.} @@ -190,7 +190,7 @@ exception is raised during the evaluation of @scheme[thunk] (in an extension of the current continuation that does not have its own exception handler), then @scheme[f] is applied to the @scheme[raise]d value in the continuation of the @scheme[raise] call (but extended -with a @tech{continuation barrier}; see @secref["mz:prompt-model"]). +with a @tech{continuation barrier}; see @secref["prompt-model"]). Any procedure that takes one argument can be an exception handler. If the exception handler returns a value when invoked by @scheme[raise], @@ -258,7 +258,7 @@ Before any predicate or handler procedure is invoked, the continuation of the entire @scheme[with-handlers] expression is restored, but also @scheme[parameterize-break]ed to disable breaks. Thus, breaks are disabled by default during the predicate and handler procedures (see -@secref["mz:breakhandler"]), and the exception handler is the one from +@secref["breakhandler"]), and the exception handler is the one from the continuation of the @scheme[with-handlers] expression. The @scheme[exn:fail?] procedure is useful as a handler predicate to @@ -518,7 +518,7 @@ The fields of an @scheme[srcloc] instance are as follows: @itemize{ @item{@scheme[source] --- An arbitrary value identifying the source, - often a path (see @secref["mz:pathutils"]).} + often a path (see @secref["pathutils"]).} @item{@scheme[line] --- The line number (counts from 1) or @scheme[#f] (unknown).} diff --git a/collects/scribblings/reference/file-ports.scrbl b/collects/scribblings/reference/file-ports.scrbl index 115eb9aeba..a426bb8091 100644 --- a/collects/scribblings/reference/file-ports.scrbl +++ b/collects/scribblings/reference/file-ports.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:file-ports"]{File Ports} +@title[#:tag "file-ports"]{File Ports} A port created by @scheme[open-input-file], @scheme[open-output-file], @scheme[subprocess], and related functions is a @deftech{file-stream @@ -11,7 +11,7 @@ predicate recognizes file-stream ports. When an input or output file-stream port is created, it is placed into the management of the current custodian (see -@secref["mz:custodians"]). +@secref["custodians"]). @defproc[(open-input-file [path path-string?] [#:mode mode-flag (one-of/c 'binary 'text) 'binary]) @@ -55,8 +55,8 @@ closed, either though @scheme[close-input-port] or indirectly via @scheme[custodian-shutdown-all], to release the OS-level file handle. The input port will not closed automatically if it is otherwise available for garbage collection (see -@secref["mz:gc-model"]); a @tech{will} could be associated input port -to close it more automatically (see @secref["mz:willexecutor"]). +@secref["gc-model"]); a @tech{will} could be associated input port +to close it more automatically (see @secref["willexecutor"]). A @tech{path} value that is the expanded version of @scheme[path] is used as the name of the opened port.} @@ -123,8 +123,8 @@ closed, either though @scheme[close-output-port] or indirectly via @scheme[custodian-shutdown-all], to release the OS-level file handle. The output port will not closed automatically if it is otherwise available for garbage collection (see -@secref["mz:gc-model"]); a @tech{will} could be associated input port -to close it more automatically (see @secref["mz:willexecutor"]). +@secref["gc-model"]); a @tech{will} could be associated input port +to close it more automatically (see @secref["willexecutor"]). A @tech{path} value that is the expanded version of @scheme[path] is used as the name of the opened port.} diff --git a/collects/scribblings/reference/filesystem.scrbl b/collects/scribblings/reference/filesystem.scrbl index a6dcd011fc..13635871f5 100644 --- a/collects/scribblings/reference/filesystem.scrbl +++ b/collects/scribblings/reference/filesystem.scrbl @@ -4,7 +4,7 @@ @title{Filesystem} @;------------------------------------------------------------------------ -@section[#:tag "mz:findpaths"]{Locating Paths} +@section[#:tag "findpaths"]{Locating Paths} @defproc[(find-system-path [kind symbol?]) path?]{ @@ -113,7 +113,7 @@ by @scheme[kind], which must be one of the following: bound initially to @scheme[program].} @item{@indexed-scheme['collects-dir] --- a path to the main - collection of libraries (see @secref["mz:collects"]). If this path is + collection of libraries (see @secref["collects"]). If this path is relative, it's relative to the directory of @scheme[(find-system-path 'exec-file)]. This path is normally embedded in the @exec{mzscheme} executable, but it can be overridden by the @DFlag{collects} or @@ -153,7 +153,7 @@ directory as the executable. The result is then the full path for the found @scheme[related-sub], instead of the path for the executable. This procedure is used by the @exec{mzscheme} executable to find the -standard library collection directory (see @secref["mz:collects"]). In +standard library collection directory (see @secref["collects"]). In this case, @scheme[program] is the name used to start MzScheme and @scheme[related] is @scheme["collects"]. The @scheme[related-sub] argument is used because, under @|AllUnix|, @scheme[program-sub] may @@ -185,7 +185,7 @@ current directory is always implicitly the first item in directory first under Windows.)} @;------------------------------------------------------------------------ -@section[#:tag "mz:fileutils"]{Files} +@section[#:tag "fileutils"]{Files} @defproc[(file-exists? [path path-string?]) boolean?]{ @@ -249,7 +249,7 @@ existing @scheme[new].} any]{ Returns the file or directory's last modification date as -platform-specific seconds (see also @secref["mz:time"]) when +platform-specific seconds (see also @secref["time"]) when @scheme[secs-n] is not provided or is @scheme[#f]. (For FAT filesystems under Windows, directories do not have modification dates. Therefore, the creation date is returned for a directory (but @@ -298,7 +298,7 @@ successfully,the @exnraise[exn:fail:filesystem]. Under Windows, the @exnraise[exn:fail:unsupported] always.} @;------------------------------------------------------------------------ -@section[#:tag "mz:directories"]{Directories} +@section[#:tag "directories"]{Directories} See also: @scheme[rename-file-or-directory], @scheme[file-or-directory-modify-seconds], diff --git a/collects/scribblings/reference/for.scrbl b/collects/scribblings/reference/for.scrbl index feae931991..289fc97bf0 100644 --- a/collects/scribblings/reference/for.scrbl +++ b/collects/scribblings/reference/for.scrbl @@ -2,9 +2,9 @@ @require["mz.ss"] @require[(lib "for.ss")] -@title[#:tag "mz:for"]{Iterations and Comprehensions: @scheme[for], @scheme[for/list], ...} +@title[#:tag "for"]{Iterations and Comprehensions: @scheme[for], @scheme[for/list], ...} -@guideintro["guide:for"]{iterations and comprehensions} +@guideintro["for"]{iterations and comprehensions} The PLT Scheme iteration forms are based on SRFI-42 @cite[#:key "srfi-42" @@ -28,7 +28,7 @@ In the simple case, each @scheme[for-clause] has one of its first two forms, where @scheme[[id seq-expr]] is a shorthand for @scheme[[(id ...) seq-expr]]. In this simple case, the @scheme[seq-expr]s are evaluated left-to-right, and each must produce a sequence value (see -@secref["mz:sequences"]). +@secref["sequences"]). The @scheme[for] form iterates by drawing an element from each sequence; if any sequence is empty, then the iteration stops, and diff --git a/collects/scribblings/reference/info.ss b/collects/scribblings/reference/info.ss new file mode 100644 index 0000000000..11dbd0f1ab --- /dev/null +++ b/collects/scribblings/reference/info.ss @@ -0,0 +1,4 @@ +(module info (lib "infotab.ss" "setup") + (define name "Scribblings: Reference") + (define scribblings '(("reference.scrbl" (multi-page main-doc))))) + diff --git a/collects/scribblings/reference/io.scrbl b/collects/scribblings/reference/io.scrbl index dafda07a6d..f5ca2024c6 100644 --- a/collects/scribblings/reference/io.scrbl +++ b/collects/scribblings/reference/io.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:input-and-output" #:style 'toc]{Input and Output} +@title[#:tag "input-and-output" #:style 'toc]{Input and Output} @local-table-of-contents[] diff --git a/collects/scribblings/reference/macros.scrbl b/collects/scribblings/reference/macros.scrbl index a6e7388d19..c515842368 100644 --- a/collects/scribblings/reference/macros.scrbl +++ b/collects/scribblings/reference/macros.scrbl @@ -3,10 +3,10 @@ @title[#:style 'toc]{Macros} -See @secref["mz:syntax-model"] for general information on how programs -are parsed. In particular, the subsection @secref["mz:expand-steps"] +See @secref["syntax-model"] for general information on how programs +are parsed. In particular, the subsection @secref["expand-steps"] describes how parsing triggers macros, and -@secref["mz:transformer-model"] describes how macro transformers are +@secref["transformer-model"] describes how macro transformers are called. @local-table-of-contents[] diff --git a/collects/scribblings/reference/memory.scrbl b/collects/scribblings/reference/memory.scrbl index e6f6638dd1..7acfb92c55 100644 --- a/collects/scribblings/reference/memory.scrbl +++ b/collects/scribblings/reference/memory.scrbl @@ -1,21 +1,21 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:memory" #:style 'toc]{Memory Management} +@title[#:tag "memory" #:style 'toc]{Memory Management} @local-table-of-contents[] -@section[#:tag "mz:weakbox"]{Weak Boxes} +@section[#:tag "weakbox"]{Weak Boxes} A @deftech{weak box} is similar to a normal box (see -@secref["mz:boxes"]), but when the garbage collector (see -@secref["mz:gc-model"]) can prove that the content value of a weak box +@secref["boxes"]), but when the garbage collector (see +@secref["gc-model"]) can prove that the content value of a weak box is only reachable via weak references, the content of the weak box is replaced with @scheme[#f]. A @deftech{weak reference} is a reference through a weak box, through a key reference in a weak hash table (see -@secref["mz:hashtables"]), through a value in an ephemeron where the -value can be replaced by @scheme[#f] (see @secref["mz:ephemerons"]), or -through a custodian (see @secref["mz:custodians"]). +@secref["hashtables"]), through a value in an ephemeron where the +value can be replaced by @scheme[#f] (see @secref["ephemerons"]), or +through a custodian (see @secref["custodians"]). @defproc[(make-weak-box [v any/c]) weak-box?]{ @@ -34,10 +34,10 @@ collector has proven that the previous content value of Returns @scheme[#t] if @scheme[v] is a weak box, @scheme[#f] otherwise.} @;------------------------------------------------------------------------ -@section[#:tag "mz:ephemerons"]{Ephemerons} +@section[#:tag "ephemerons"]{Ephemerons} An @deftech{ephemeron} is similar to a weak box (see -@secref["mz:weakbox"]), except that +@secref["weakbox"]), except that @itemize{ @@ -45,19 +45,19 @@ An @deftech{ephemeron} is similar to a weak box (see extracted from the ephemeron, but the value is replaced by @scheme[#f] when the automatic memory manager can prove that either the ephemeron or the key is reachable only through weak - references (see @secref["mz:weakbox"]); and} + references (see @secref["weakbox"]); and} @item{nothing reachable from the value in an ephemeron counts toward the reachability of an ephemeron key (whether for the same ephemeron or another), unless the same value is reachable through a non-weak reference, or unless the value's ephemeron key is reachable through a - non-weak reference (see @secref["mz:weakbox"] for information on weak + non-weak reference (see @secref["weakbox"] for information on weak references).} } In particular, an ephemeron can be combined with a weak hash table -(see @secref["mz:hashtables"]) to produce a mapping where the memory +(see @secref["hashtables"]) to produce a mapping where the memory manager can reclaim key--value pairs even when the value refers to the key. @@ -81,13 +81,13 @@ Returns @scheme[#t] if @scheme[v] is an @tech{ephemeron}, @scheme[#f] otherwise.} @;------------------------------------------------------------------------ -@section[#:tag "mz:willexecutor"]{Wills and Executors} +@section[#:tag "willexecutor"]{Wills and Executors} A @deftech{will executor} manages a collection of values and associated @deftech{will} procedures. The will procedure for each value is ready to be executed when the value has been proven (by the garbage collector) to be unreachable, except through weak references -(see @secref["mz:weakbox"]) or as the registrant for other will +(see @secref["weakbox"]) or as the registrant for other will executors. A @tech{will} is useful for triggering clean-up actions on data associated with an unreachable value, such as closing a port embedded in an object when the object is no longer used. @@ -110,7 +110,7 @@ the values are reachable from each other. A will executor's register is held non-weakly until after the corresponding will procedure is executed. Thus, if the content value -of a weak box (see @secref["mz:weakbox"]) is registered with a will +of a weak box (see @secref["weakbox"]) is registered with a will executor, the weak box's content is not changed to @scheme[#f] until all wills have been executed for the value and the value has been proven again reachable through only weak references. @@ -153,7 +153,7 @@ Like @scheme[will-execute] if a will is ready for immediate execution. Otherwise, @scheme[#f] is returned.} @;------------------------------------------------------------------------ -@section[#:tag "mz:garbagecollection"]{Garbage Collection} +@section[#:tag "garbagecollection"]{Garbage Collection} @defproc[(collect-garbage) void?]{ diff --git a/collects/scribblings/reference/model.scrbl b/collects/scribblings/reference/model.scrbl index 50d3adb91c..f0813b894c 100644 --- a/collects/scribblings/reference/model.scrbl +++ b/collects/scribblings/reference/model.scrbl @@ -48,7 +48,7 @@ expression that evaluation simplifies no further, such as the number @scheme[2]. @;------------------------------------------------------------------------ -@section[#:tag "mz:cont-model"]{Sub-expression Evaluation and Continuations} +@section[#:tag "cont-model"]{Sub-expression Evaluation and Continuations} Some simplifications require more than one step. For example: @@ -119,7 +119,7 @@ specification of @tech{tail positions} goes with each syntactic form, like @scheme[if]. @;------------------------------------------------------------------------ -@section[#:tag "mz:values-model"]{Multiple Return Values} +@section[#:tag "values-model"]{Multiple Return Values} A Scheme expression can evaluate to @deftech{multiple values}, in the same way that a procedure can accept multiple arguments. @@ -309,7 +309,7 @@ program. A program representation created with existing @tech{objects}. @;------------------------------------------------------------------------ -@section[#:tag "mz:model-eq"]{Object Identity and Comparisons} +@section[#:tag "model-eq"]{Object Identity and Comparisons} The @scheme[eq?] operator compares two @tech{values}, returning @scheme[#t] when the values refer to the same @tech{object}. This form @@ -332,7 +332,7 @@ The behavior of a datatype with respect to @scheme[eq?] is generally specified with the datatype and its associated procedures. @;------------------------------------------------------------------------ -@section[#:tag "mz:gc-model"]{Garbage Collection} +@section[#:tag "gc-model"]{Garbage Collection} In the program state @@ -497,7 +497,7 @@ forms. As a result, future references of the @tech{variable} always access the same @tech{location}. @;------------------------------------------------------------------------ -@section[#:tag "mz:module-eval-model"]{Modules and Module-Level Variables} +@section[#:tag "module-eval-model"]{Modules and Module-Level Variables} Most definitions in PLT Scheme are in modules. In terms of evaluation, a module is essentially a prefix on a defined name, so that different @@ -524,7 +524,7 @@ and installs @scheme[10] as its value. This @scheme[x] is unrelated to any top-level definition of @scheme[x]. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:module-phase"]{Module Phases} +@subsection[#:tag "module-phase"]{Module Phases} A module can be @tech{instantiate}d in multiple @deftech{phases}. A phase is an integer that, again, is effectively a prefix on the names @@ -535,7 +535,7 @@ already @tech{instantiate}d at phase 0. A top-level @tech{phase} 1 (if it is not already @tech{instantiate}d at that level); a @scheme[require-for-syntax] also has a different binding effect on further program parsing, as described in -@secref["mz:intro-binding"]. +@secref["intro-binding"]. Within a module, some definitions are shifted by a phase already; the @scheme[define-for-syntax] form is like @scheme[define], but it @@ -562,11 +562,11 @@ first @tech{instantiate}d at @tech{phase} @math{n-1}, and so on. A final distinction among module @tech{instantiations} is that multiple @tech{instantiations} may exist at phase 1 and higher. These @tech{instantiations} are created by the parsing of module forms (see -@secref["mz:mod-parse"]), and are, again, conceptually distinguished +@secref["mod-parse"]), and are, again, conceptually distinguished by prefixes. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:module-redeclare"]{Module Re-declarations} +@subsection[#:tag "module-redeclare"]{Module Re-declarations} @section-index["modules" "re-define"] @@ -583,7 +583,7 @@ re-declared, each re-declaration of the module is immediately @tech{instantiate}d in the same @tech{phase}s. @;------------------------------------------------------------------------ -@section[#:tag "mz:mark-model"]{Continuation Frames and Marks} +@section[#:tag "mark-model"]{Continuation Frames and Marks} Every continuation @scheme[_C] can be partitioned into @deftech{continuation frames} @frame[1], @frame[2], ..., @frame["n"] @@ -602,7 +602,7 @@ for a ``stack trace'' to be used when an exception is raised, or to implement dynamic scope. @;------------------------------------------------------------------------ -@section[#:tag "mz:prompt-model"]{Prompts, Delimited Continuations, and Barriers} +@section[#:tag "prompt-model"]{Prompts, Delimited Continuations, and Barriers} A @deftech{prompt} is a special kind of continuation frame that is annotated with a specific @deftech{prompt-tag} (essentially a @@ -634,7 +634,7 @@ used only to abort to the point of capture, which means that escape-continuation aborts can cross continuation barriers. @;------------------------------------------------------------------------ -@section[#:tag "mz:thread-model"]{Threads} +@section[#:tag "thread-model"]{Threads} Scheme supports multiple, pre-emptive @deftech{threads} of evaluation. In terms of the evaluation model, this means that each @@ -657,7 +657,7 @@ new thread sees the same initial value (specified when the thread cell is created) as all other threads. @;------------------------------------------------------------------------ -@section[#:tag "mz:parameter-model"]{Parameters} +@section[#:tag "parameter-model"]{Parameters} @deftech{Parameters} are essentially a derived concept in Scheme; they are defined in terms of continuation marks and thread cells. However, @@ -684,7 +684,7 @@ Various operations, such as @scheme[parameterize] or current continuation's frame. @;------------------------------------------------------------------------ -@section[#:tag "mz:exn-model"]{Exceptions} +@section[#:tag "exn-model"]{Exceptions} @deftech{Exceptions} are essentially a derived concept in Scheme; they are defined in terms of continuations, prompts, and continuation @@ -706,7 +706,7 @@ prompt is installed in the outermost frame of the continuation for any new thread. @;------------------------------------------------------------------------ -@section[#:tag "mz:custodian-model"]{Custodians} +@section[#:tag "custodian-model"]{Custodians} A @deftech{custodian} manages a collection of threads, file-stream ports, TCP ports, TCP listeners, UDP sockets, and byte converters. @@ -734,7 +734,7 @@ down before a procedure is called to create a managed resource (e.g., A thread can have multiple managing custodians, and a suspended thread created with @scheme[thread/suspend-to-kill] can have zero custodians. Extra custodians become associated with a thread through -@scheme[thread-resume] (see @secref["mz:threadkill"]). When a thread +@scheme[thread-resume] (see @secref["threadkill"]). When a thread has multiple custodians, it is not necessarily killed by a @scheme[custodian-shutdown-all], but shut-down custodians are removed from the thread's managing set, and the thread is killed when its diff --git a/collects/scribblings/reference/module-reflect.scrbl b/collects/scribblings/reference/module-reflect.scrbl index 482e826a3d..cacdc99752 100644 --- a/collects/scribblings/reference/module-reflect.scrbl +++ b/collects/scribblings/reference/module-reflect.scrbl @@ -4,13 +4,13 @@ @title{Module Names and Loading} @;------------------------------------------------------------------------ -@section[#:tag "mz:modnameresolver"]{Resolving Module Names} +@section[#:tag "modnameresolver"]{Resolving Module Names} The name of a declared module is either a symbol or a @deftech{resolved module path}. A symbol normally refers to a predefined module or module declared through reflective evaluation (e.g., @scheme[eval]). A @tech{resolved module path} encapsulates a filesystem path (see -@secref["mz:pathutils"]) and normally refers to a module declaration +@secref["pathutils"]) and normally refers to a module declaration that was loaded on demand via @scheme[require] or other forms. @defproc[(resolved-module-path? [v any/c]) boolean?]{ @@ -110,7 +110,7 @@ with a message about a dependency cycle. Module loading is suppressed (i.e., @scheme[#f] is supplied as a third argument to the module name resolver) when resolving module paths in -@tech{syntax objects} (see @secref["mz:stxobj-model"]). When a +@tech{syntax objects} (see @secref["stxobj-model"]). When a @tech{syntax object} is manipulated, the current namespace might not match the original namespace for the syntax object, and the module should not necessarily be loaded in the current namespace. @@ -136,7 +136,7 @@ with the prefix (via @scheme[build-path]), and then converted to a which is used as the name of the declared module.} @;------------------------------------------------------------------------ -@section[#:tag "mz:modpathidx"]{Compiled Modules and References} +@section[#:tag "modpathidx"]{Compiled Modules and References} While expanding a @scheme[module] declaration, the expander resolves module paths for imports to load module declarations as necessary and @@ -148,7 +148,7 @@ among compiled code. When a module reference is extracted from compiled form (see @scheme[module-compiled-imports]) or from syntax objects in macro -expansion (see @secref["mz:stxops"]), the module reference is +expansion (see @secref["stxops"]), the module reference is typically reported in the form of a @deftech{module path index}. A @tech{module path index} is a semi-interned (multiple references to the same relative module tend to use the same @tech{module path index} @@ -267,7 +267,7 @@ list of symbols for the module's explicit variable exports, a list symbols for the module's explicit syntax exports.} @;------------------------------------------------------------------------ -@section[#:tag "mz:dynreq"]{Dynamic Module Access} +@section[#:tag "dynreq"]{Dynamic Module Access} @defproc[(dynamic-require [mod module-path?][provided (or/c symbol? false/c void?)]) any]{ @@ -286,11 +286,11 @@ value of the module's export with the given name is returned. If the module exports @scheme[provide] as syntax, then a use of the binding is expanded and evaluated (in a fresh namespace to which the module is attached). If the module has no such exported variable or syntax, or -if the variable is protected (see @secref["mz:modprotect"]), the +if the variable is protected (see @secref["modprotect"]), the @exnraise[exn:fail:contract]. If @scheme[provided] is @|void-const|, then the module is -@tech{visit}ed (see @secref["mz:mod-parse"]), but not +@tech{visit}ed (see @secref["mod-parse"]), but not @tech{instantiate}d. The result is @|void-const|.} diff --git a/collects/scribblings/reference/mz.ss b/collects/scribblings/reference/mz.ss index f6748ebb96..8a9b3795a8 100644 --- a/collects/scribblings/reference/mz.ss +++ b/collects/scribblings/reference/mz.ss @@ -1,4 +1,4 @@ -(module mz mzscheme +(module mz (lib "lang.ss" "big") (require (lib "struct.ss" "scribble") (lib "manual.ss" "scribble") (lib "eval.ss" "scribble") @@ -11,6 +11,11 @@ (all-from (lib "eval.ss" "scribble")) (all-from (lib "contract.ss"))) + (require-for-label (lib "lang.ss" "big") + "to-do.ss") + (provide-for-label (all-from (lib "lang.ss" "big")) + (all-from "to-do.ss")) + (define AllUnix "Unix and Mac OS X") (provide AllUnix) @@ -24,7 +29,7 @@ [(_ s) (scheme s)])) (provide exnraise Exn) - (provide refalso moreref Guide guideintro) + (provide refalso moreref Guide guideintro guidesecref) (define/kw (refalso tag #:body s) (apply margin-note @@ -38,12 +43,15 @@ s (list "."))))) - (define Guide - (italic (link "../guide/index.html" "A Guide to PLT Scheme"))) + (define (guidesecref s) + (secref #:doc '(lib "guide.scrbl" "scribblings" "guide") s)) (define/kw (guideintro tag #:body s) (apply margin-note - (decode-content (append (list finger (secref tag) " in " Guide " introduces ") + (decode-content (append (list finger (guidesecref tag) " in " Guide " introduces ") s - (list ".")))))) + (list "."))))) + + (define Guide + (italic (guidesecref "top")))) diff --git a/collects/scribblings/reference/namespaces.scrbl b/collects/scribblings/reference/namespaces.scrbl index 4e5fde0d6e..aa1bdc9113 100644 --- a/collects/scribblings/reference/namespaces.scrbl +++ b/collects/scribblings/reference/namespaces.scrbl @@ -3,7 +3,7 @@ @title{Namespaces} -See @secref["mz:namespace-model"] for basic information on the +See @secref["namespace-model"] for basic information on the namespace model. A new namespace is created with the @scheme[make-namespace] procedure, @@ -40,6 +40,11 @@ is an option that determines the initial bindings in the namespace: }} +@defparam[current-namespace n namespace?]{ + +A parameter that determines the @techlink{current namespace}.} + + @defproc[(namespace-symbol->identifier [sym symbol?]) identifier?]{ Similar to @scheme[datum->syntax-object] restricted to symbols. The @@ -60,7 +65,7 @@ depends on @scheme[use-mapping?]: @item{If @scheme[use-mapping?] is true (the default), and if @scheme[sym] maps to a top-level variable or an imported variable - (see @secref["mz:namespace-model"]), then the result is the same as + (see @secref["namespace-model"]), then the result is the same as evaluating @scheme[sym] as an expression. If @scheme[sym] maps to syntax or imported syntax, then @scheme[failure-thunk] is called or the @exnraise[exn:fail:syntax]. If @scheme[sym] is mapped to an @@ -94,7 +99,7 @@ Sets the value of @scheme[sym] in the top-level environment of it is not already defined. If @scheme[map?] is supplied as true, then the namespace's identifier -mapping is also adjusted (see @secref["mz:namespace-model"]) so that +mapping is also adjusted (see @secref["namespace-model"]) so that @scheme[sym] maps to the variable.} @@ -104,7 +109,7 @@ mapping is also adjusted (see @secref["mz:namespace-model"]) so that Removes the @scheme[sym] variable, if any, in the top-level environment of @scheme[namespace] at @tech{phase level} 0. The -namespace's identifier mapping (see @secref["mz:namespace-model"]) is +namespace's identifier mapping (see @secref["namespace-model"]) is unaffected.} @@ -151,7 +156,7 @@ value is copied to a top-level variable in the current namespace.} Like @scheme[namespace-require], but only the transformer part of the module is executed; that is, the module is merely @tech{visit}ed, and -not @tech{instantiate}d (see @secref["mz:mod-parse"]). If the required +not @tech{instantiate}d (see @secref["mod-parse"]). If the required module has not been instantiated before, the module's variables remain undefined.} @@ -186,7 +191,7 @@ Changes the inspector for the instance of the module referenced by controlled by the current code inspector. The given @scheme[inspector] must currently control the invocation of the module in @scheme[namespace]'s registry, otherwise the -@exnraise[exn:fail:contract]. See also @secref["mz:modprotect"].} +@exnraise[exn:fail:contract]. See also @secref["modprotect"].} @defproc[(namespace-module-registry [namespace namespace?]) @@ -211,7 +216,7 @@ declarations are not allowed. If the current code inspector does not control the invocation of the module in the current namespace's registry, the @exnraise[exn:fail:contract]; see also -@secref["mz:modprotect"]. +@secref["modprotect"]. Bindings in the namespace cannot be modified if the @scheme[compile-enforce-module-constants] parameter was true when the @@ -223,7 +228,7 @@ assignments to the binding via @scheme[set!].} Returns a syntax object like @scheme[stx], except that the current namespace's bindings are included in the @tech{syntax object}'s -@tech{lexical information} (see @secref["mz:stxobj-model"]). The +@tech{lexical information} (see @secref["stxobj-model"]). The additional context is overridden by any existing @tech{top-level bindings} in the @tech{syntax object}'s @tech{lexical information}, or by any existing or future @tech{module bindings} in the @tech{lexical @@ -241,7 +246,7 @@ corresponds to an unexported definition, a protected export, or an identifier that is not defined at all within the module). The @scheme[module-path-index] argument can be a symbol; see -@secref["mz:modpathidx"] for more information on module path +@secref["modpathidx"] for more information on module path indices. Typically, the arguments to @scheme[module-provide-protected?] diff --git a/collects/scribblings/reference/networking.scrbl b/collects/scribblings/reference/networking.scrbl index c38226ae43..60361587c4 100644 --- a/collects/scribblings/reference/networking.scrbl +++ b/collects/scribblings/reference/networking.scrbl @@ -1,12 +1,12 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:networking" #:style 'toc]{Networking} +@title[#:tag "networking" #:style 'toc]{Networking} @local-table-of-contents[] @;------------------------------------------------------------------------ -@section[#:tag "mz:tcp"]{TCP} +@section[#:tag "tcp"]{TCP} For information about TCP in general, see @italic{TCP/IP Illustrated, Volume 1} by W. Richard Stevens. @@ -53,7 +53,7 @@ The return value of @scheme[tcp-listen] is a TCP listener value. This value can be used in future calls to @scheme[tcp-accept], @scheme[tcp-accept-ready?], and @scheme[tcp-close]. Each new TCP listener value is placed into the management of the current custodian -(see @secref["mz:custodians"]). +(see @secref["custodians"]). If the server cannot be started by @scheme[tcp-listen], the @exnraise[exn:fail:network].} @@ -90,7 +90,7 @@ output port. Data can be received from the server through the input port and sent to the server through the output port. If the server is a @exec{mzscheme} process, it can obtain ports to communicate to the client with @scheme[tcp-accept]. These ports are placed into the -management of the current custodian (see @secref["mz:custodians"]). +management of the current custodian (see @secref["custodians"]). Initially, the returned input port is block-buffered, and the returned output port is block-buffered. Change the buffer mode using @@ -125,7 +125,7 @@ If a connection cannot be established by @scheme[tcp-connect], the (values input-port? output-port?)]{ Like @scheme[tcp-connect], but breaking is enabled (see -@secref["mz:breakhandler"]) while trying to connect. If breaking is +@secref["breakhandler"]) while trying to connect. If breaking is disabled when @scheme[tcp-connect/enable-break] is called, then either ports are returned or the @scheme[exn:break] exception is raised, but not both.} @@ -143,7 +143,7 @@ Two values are returned by @scheme[tcp-accept]: an input port and an output port. Data can be received from the client through the input port and sent to the client through the output port. These ports are placed into the management of the current custodian (see -@secref["mz:custodians"]). +@secref["custodians"]). In terms of buffering and connection states, the ports act the same as ports from @scheme[tcp-connect]. @@ -156,7 +156,7 @@ listener has been closed, the @exnraise[exn:fail:network].} (values input-port? output-port?)]{ Like @scheme[tcp-accept], but breaking is enabled (see -@secref["mz:breakhandler"]) while trying to accept a connection. If +@secref["breakhandler"]) while trying to accept a connection. If breaking is disabled when @scheme[tcp-accept/enable-break] is called, then either ports are returned or the @scheme[exn:break] exception is raised, but not both.} @@ -198,7 +198,7 @@ Returns @scheme[#t] if @scheme[v] is a TCP listener value created by @defproc[(tcp-accept-evt [listener tcp-listener?]) evt?]{ -Returns a @tech{synchronizable event} (see @secref["mz:sync"]) that is +Returns a @tech{synchronizable event} (see @secref["sync"]) that is in a blocking state when @scheme[tcp-accept] on @scheme[listener] would block. If the event is chosen in a synchronization, the result is a list of two items, which correspond to the two results of @@ -251,7 +251,7 @@ Returns @scheme[#t] if @scheme[v] is a port returned by @scheme[tcp-connect/enable-break], @scheme[#f] otherwise.} @;------------------------------------------------------------------------ -@section[#:tag "mz:udp"]{UDP} +@section[#:tag "udp"]{UDP} For information about UDP in general, see @italic{TCP/IP Illustrated, Volume 1} by W. Richard Stevens. @@ -299,7 +299,7 @@ and port. If a socket is not bound before it is used with a sending procedure @scheme[udp-send], @scheme[udp-send-to], etc., the sending procedure binds the socket to a random local port. Similarly, if an event from @scheme[udp-send-evt] or @scheme[udp-send-to-evt] is chosen -for a synchronization (see @secref["mz:sync"]), the socket is bound; +for a synchronization (see @secref["sync"]), the socket is bound; if the event is not chosen, the socket may or may not become bound. The binding of a bound socket cannot be changed. @@ -399,7 +399,7 @@ never blocks and returns @scheme[#f] or @scheme[#t].} void]{ Like @scheme[udp-send-to], but breaking is enabled (see -@secref["mz:breakhandler"]) while trying to send the datagram. If +@secref["breakhandler"]) while trying to send the datagram. If breaking is disabled when @scheme[udp-send-to/enable-break] is called, then either the datagram is sent or the @scheme[exn:break] exception is raised, but not both.} @@ -462,7 +462,7 @@ datagram is available, the three result values are all @scheme[#f].} (integer-in 1 65535))]{ Like @scheme[udp-receive!], but breaking is enabled (see -@secref["mz:breakhandler"]) while trying to receive the datagram. If +@secref["breakhandler"]) while trying to receive the datagram. If breaking is disabled when @scheme[udp-receive!/enable-break] is called, then either a datagram is received or the @scheme[exn:break] exception is raised, but not both.} @@ -494,14 +494,14 @@ address and port, @scheme[#f] otherwise.} @defproc[(udp-send-ready-evt [udp-socket udp?]) evt?]{ -Returns a @tech{synchronizable event} (see @secref["mz:sync"]) that is +Returns a @tech{synchronizable event} (see @secref["sync"]) that is in a blocking state when @scheme[udp-send-to] on @scheme[udp-socket] would block.} @defproc[(udp-receive-ready-evt [udp-socket udp?]) evt?]{ -Returns a @tech{synchronizable event} (see @secref["mz:sync"]) that is +Returns a @tech{synchronizable event} (see @secref["sync"]) that is in a blocking state when @scheme[udp-receive!] on @scheme[udp-socket] would block.} diff --git a/collects/scribblings/reference/numbers.scrbl b/collects/scribblings/reference/numbers.scrbl index 72f0896dae..5e4b1aee14 100644 --- a/collects/scribblings/reference/numbers.scrbl +++ b/collects/scribblings/reference/numbers.scrbl @@ -1,9 +1,9 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:numbers"]{Numbers} +@title[#:tag "numbers"]{Numbers} -@guideintro["guide:numbers"]{numbers} +@guideintro["numbers"]{numbers} All numbers are @deftech{complex numbers}. Some of them are @deftech{real numbers}, and all of the real numbers that can be @@ -621,7 +621,7 @@ one of the last three integers must be non-zero.} @defproc[(string->number [s string?] [radix (exact-integer-in/c 2 16) 10]) (or/c number? false/c)]{ Reads and returns a number datum from - @scheme[s] (see @secref["mz:parse-number"]), returning @scheme[#f] if + @scheme[s] (see @secref["parse-number"]), returning @scheme[#f] if @scheme[s] does not parse exactly as a number datum (with no whitespace). The optional @scheme[radix] argument specifies the default base for the number, which can be overriden by @litchar{#b}, diff --git a/collects/scribblings/reference/os.scrbl b/collects/scribblings/reference/os.scrbl index 46e6efed08..542868b4d9 100644 --- a/collects/scribblings/reference/os.scrbl +++ b/collects/scribblings/reference/os.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:os" #:style 'toc]{Operating System} +@title[#:tag "os" #:style 'toc]{Operating System} @local-table-of-contents[] diff --git a/collects/scribblings/reference/pairs-scrbl.scrbl b/collects/scribblings/reference/pairs-scrbl.scrbl new file mode 100644 index 0000000000..73d43b26a5 --- /dev/null +++ b/collects/scribblings/reference/pairs-scrbl.scrbl @@ -0,0 +1,308 @@ +#reader(lib "docreader.ss" "scribble") +@require["mz.ss"] +@require[(lib "scheme.ss" "scribble")] +@require-for-syntax[mzscheme] + +@define-syntax[(defc_r stx) + (syntax-case stx () + [(_ x ...) + (let ([xs (map syntax-e (syntax->list #'(x ...)))]) + (let ([name (string->symbol + (string-append + "c" + (apply string-append (map symbol->string xs)) + "r"))] + [contract (let loop ([l (reverse xs)]) + (cond + [(null? (cdr l)) 'pair?] + [(eq? (car l) 'a) `(cons/c ,(loop (cdr l)) any/c)] + [(eq? (car l) 'd) `(cons/c any/c ,(loop (cdr l)))]))] + [equiv (let loop ([l xs]) + (cond + [(null? l) 'p] + [(eq? (car l) 'a) `(car ,(loop (cdr l)))] + [(eq? (car l) 'd) `(cdr ,(loop (cdr l)))]))]) + (with-syntax ([name name] + [contract (let loop ([c contract][pos 0]) + (if (pair? c) + (let* ([a (loop (car c) (add1 pos))] + [b (loop (cdr c) (+ 1 pos (syntax-span a)))] + [span (+ 1 (syntax-span a) (syntax-span b))]) + (datum->syntax-object #'here + (cons a b) + (list (syntax-source stx) + 1 + pos + (add1 pos) + span))) + (datum->syntax-object #'here c + (list (syntax-source stx) 1 pos (add1 pos) 1))))] + [equiv equiv]) + #'(defproc (name [v contract]) any/c + "Returns " (to-element 'equiv)))))])] + +@title[#:tag "pairs"]{Pairs and Lists} + +A list can be used as a single-valued sequence (see +@secref["sequences"]). The elements of the list serve as elements +of the sequence. See also @scheme[in-list]. + +@; ---------------------------------------- +@section{Pair Constructors, Selectors, and Mutators} + +@defproc[(pair? [v any/c]) boolean?]{Returns @scheme[#t] if @scheme[v] is +a pair, @scheme[#f] otherwise.} + +@defproc[(cons? [v any/c]) boolean?]{The same as @scheme[(pair? v)].} + +@defproc[(null? [v any/c]) boolean?]{Returns @scheme[#t] if @scheme[v] is +the empty list, @scheme[#f] otherwise.} + +@defproc[(empty? [v any/c]) boolean?]{The same as @scheme[(null? v)].} + +@defproc[(cons [a any/c] [d any/c]) pair?]{Returns a pair whose first +element is @scheme[a] and second element is @scheme[d].} + +@defproc[(car [p pair?]) any/c]{Returns the first element of the +pair @scheme[p].} + +@defproc[(cdr [p pair?]) any/c]{Returns the second element of the +pair @scheme[p].} + +@defproc[(first [p pair?]) any/c]{The same as @scheme[(car p)].} + +@defproc[(rest [p pair?]) any/c]{The same as @scheme[(cdr p)].} + +@defthing[null null?]{The empty list.} + +@defthing[empty null?]{The empty list.} + + +@defproc[(list? [v any/c]) boolean?]{Returns @scheme[#t] if @scheme[v] + is a list: either the empty list, or a pair whose second element is a + list.} + +@defproc[(list [v any/c] ...) list?]{Returns a newly allocated list +containing the @scheme[v]s as its elements.} + +@defproc[(list* [v any/c] ... [tail any/c]) any/c]{ + +Like @scheme[list], but the last argument is used as the tail of +the result, insteda of the final element. The result is a list +only if the last argument is a list.} + + +@defproc[(set-car! [p mutable-pair?] [v any/v]) + void?]{ + +Changes the mutable pair @scheme[p] so that its first element is +@scheme[v].} + + +@defproc[(set-cdr! [p mutable-pair?] [v any/v]) + void?]{ + +Changes the mutable pair @scheme[p] so that its second element is +@scheme[v].} + + +@defproc[(immutable? [v any/c]) boolean?]{ + +Returns @scheme[#t] if @scheme[v] is a mutable pair, string, byte +string, vector, or box, @scheme[#f] otherwise.} + +@; ---------------------------------------- +@section{List Operations} + +@defproc[(length [lst list?]) + nonnegative-exact-integer?]{ + +Returns the number of elements in @scheme[lst].} + + +@defproc[(list-ref [lst list?][pos nonnegative-exact-integer?]) + any/c]{ + +Returns the element of @scheme[vec] at position @scheme[pos], where +the list's first element is position @scheme[0]. If the list has +@scheme[pos] or fewer elements, then the +@exnraise[exn:fail:contract].} + + +@defproc[(list-tail [lst list?][pos nonnegative-exact-integer?]) + any/c]{ + +Returns the list after the first @scheme[pos] elements of +@scheme[lst]. If the list has @scheme[pos] or fewer elements, then the +@exnraise[exn:fail:contract].} + + +@defproc*[([(append [lst list?] ...) list?] + [(append [lst list?] ... [v any/c]) any/c])]{ + +When given all list arguments, the result is a lists that contains all +of the elements of the given lists in order. The last argument is used +directly in the tail of the result. + +The last argument need not be a list, in which case the result is an +``improper list'' ...} + +@defproc[(reverse [lst list?]) list?]{ + +Returns a list that has the same elements as @scheme[lst], but in +reverse order.} + + +@; ---------------------------------------- +@section{List Iteration} + +@defproc[(map [proc procedure?] [lst list?] ...+) + list?]{ + +Applies @scheme[proc] to the elements of the @scheme[lst]s from the + first elements to the last, returning @scheme[#f] as soon as any + application returns @scheme[#f]. The @scheme[proc] argument must + accept the same number of arguments as the number of supplied + @scheme[lst]s, and all @scheme[lst]s must have the same number of + elements. The result is a list containing each result of + @scheme[proc].} + + +@defproc[(andmap [proc procedure?] [lst list?] ...+) + any]{ + +Similar to @scheme[map], except that + +@itemize{ + + @item{the result is @scheme[#f] if any application of @scheme[proc] produces + @scheme[#f], in which case @scheme[proc] is not applied to later + elements of the @scheme[lst]s; or} + + @item{the result is that of @scheme[proc] applied to the last elements + of the @scheme[lsts]s; more specifically, the application of + @scheme[proc] to the last elements in the @scheme[lst]s is in tail + position with respect to the @scheme[andmap] call.} + +} + +If the @scheme[lst]s are empty, then @scheme[#t] is returned.} + +@examples[ +(andmap positive? '(1 2 3)) +(andmap positive? '(1 2 a)) +(andmap positive? '(1 -2 a)) +(andmap + '(1 2 3) '(4 5 6)) +] + + +@defproc[(ormap [proc procedure?] [lst list?] ...+) + any]{ + +Similar to @scheme[map], except that + +@itemize{ + + @item{the result is @scheme[#f] if every application of @scheme[proc] produces + @scheme[#f]; or} + + @item{the result of the first applciation of @scheme[proc] to produces a + value other than @scheme[#f], in which case @scheme[proc] is not + applied to later elements of the @scheme[lst]s; more specifically, + the application of @scheme[proc] to the last elements in the + @scheme[lst]s is in tail position with respect to the + @scheme[andmap] call.} + +} + +If the @scheme[lst]s are empty, then @scheme[#f] is returned.} + +@examples[ +(ormap eq? '(a b c) '(a b c)) +(ormap positive? '(1 2 a)) +(ormap + '(1 2 3) '(4 5 6)) +] + + +@defproc[(for-each [proc procedure?] [lst list?] ...+) + void?]{ + +Similar to @scheme[map], but @scheme[proc] is called only for its + effect, and its result (which can be any number of values) is + ignored.} + + +@defproc[(member [v any/c] [lst list?]) + (or/c list? false/c)]{ + +Locates the first element of @scheme[lst] that is @scheme[equal?] to + @scheme[v]. If such an element exists, the tail of @scheme[lst] + starting with that element is returned. Otherwise, the result is + @scheme[#f].} + + +@defproc[(memv [v any/c] [lst list?]) + (or/c list? false/c)]{ + +Like @scheme[member], but finds an element using @scheme[eqv?].} + + +@defproc[(memq [v any/c] [lst list?]) + (or/c list? false/c)]{ + +Like @scheme[member], but finds an element using @scheme[eq?].} + + +@defproc[(assoc [v any/c] [lst (listof pair?)]) + (or/c pair? false/c)]{ + +Locates the first element of @scheme[lst] whose @scheme[car] is + @scheme[equal?] to @scheme[v]. If such an element exists, the pair + (i.e., an element of @scheme[lst]) is returned. Otherwise, the result + is @scheme[#f].} + + +@defproc[(assv [v any/c] [lst (listof pair?)]) + (or/c pair? false/c)]{ + +Like @scheme[assoc], but finds an element using @scheme[eqv?].} + + +@defproc[(assq [v any/c] [lst (listof pair?)]) + (or/c pair? false/c)]{ + +Like @scheme[assoc], but finds an element using @scheme[eq?].} + + +@; ---------------------------------------- +@section{Pair Accessor Shorthands} + +@defc_r[a a] +@defc_r[a d] +@defc_r[d a] +@defc_r[d d] +@defc_r[a a a] +@defc_r[a a d] +@defc_r[a d a] +@defc_r[a d d] +@defc_r[d a a] +@defc_r[d a d] +@defc_r[d d a] +@defc_r[d d d] +@defc_r[a a a a] +@defc_r[a a a d] +@defc_r[a a d a] +@defc_r[a a d d] +@defc_r[a d a a] +@defc_r[a d a d] +@defc_r[a d d a] +@defc_r[a d d d] +@defc_r[d a a a] +@defc_r[d a a d] +@defc_r[d a d a] +@defc_r[d a d d] +@defc_r[d d a a] +@defc_r[d d a d] +@defc_r[d d d a] +@defc_r[d d d d] + diff --git a/collects/scribblings/reference/parameters.scrbl b/collects/scribblings/reference/parameters.scrbl index 4c01e339b0..625c369c15 100644 --- a/collects/scribblings/reference/parameters.scrbl +++ b/collects/scribblings/reference/parameters.scrbl @@ -1,9 +1,9 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:parameters"]{Parameters} +@title[#:tag "parameters"]{Parameters} -See @secref["mz:parameter-model"] for basic information on the +See @secref["parameter-model"] for basic information on the parameter model. Parameters correspond to @defterm{preserved thread fluids} in Scsh @cite[#:key "cite:thread-fluids" #:title "Processes vs. User-Level Threads in Scsh" #:author "Martin Gasbichler and @@ -67,7 +67,7 @@ If a continuation is captured during the evaluation of @scheme[parameterize], invoking the continuation effectively re-introduces the @tech{parameterization}, since a parameterization is associated to a continuation via a continuation mark (see -@secref["mz:contmarks"]) using a private key.} +@secref["contmarks"]) using a private key.} @examples[ (parameterize ([exit-handler (lambda (x) 'no-exit)]) diff --git a/collects/scribblings/reference/paths.scrbl b/collects/scribblings/reference/paths.scrbl index b5617d39a9..4846e9cd64 100644 --- a/collects/scribblings/reference/paths.scrbl +++ b/collects/scribblings/reference/paths.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:pathutils" #:style 'toc]{Paths} +@title[#:tag "pathutils" #:style 'toc]{Paths} When a Scheme procedure takes a filesystem path as an argument, the path can be provided either as a string or as an instance of the @@ -33,8 +33,8 @@ the path before using it. Procedures that build paths or merely check the form of a path do not perform this expansion, with the exception of @scheme[simplify-path] for Windows paths. For more information about path expansion and other platform-specific details, see -@secref["mz:unixpaths"] for @|AllUnix| paths and -@secref["mz:windowspaths"] for Windows paths. +@secref["unixpaths"] for @|AllUnix| paths and +@secref["windowspaths"] for Windows paths. @;------------------------------------------------------------------------ @section{Manipulating Paths} @@ -96,7 +96,7 @@ information. Furthermore, for display and sorting based on individual path elements (such as pathless file names), use @scheme[path-element->string], instead, to avoid special encodings use to represent some relative -paths. See @secref["mz:windowspaths"] for specific information about +paths. See @secref["windowspaths"] for specific information about the conversion of Windows paths.} @defproc[(path->bytes [path path?]) bytes?]{ @@ -119,9 +119,9 @@ individual path elements.} Like @scheme[string->path], except that @scheme[str] corresponds to a single relative element in a path, and it is encoded as necessary to -convert it to a path. See @secref["mz:unixpaths"] for more information +convert it to a path. See @secref["unixpaths"] for more information on the conversion for @|AllUnix| paths, and see -@secref["mz:windowspaths"] for more information on the conversion for +@secref["windowspaths"] for more information on the conversion for Windows paths. If @scheme[str] does not correspond to any path element @@ -151,8 +151,8 @@ elements is necessary.} @defproc[(path-element->string [path path?]) string?]{ Like @scheme[path->string], except any encoding prefix is removed. See -@secref["mz:unixpaths"] for more information on the conversion for -@|AllUnix| paths, and see @secref["mz:windowspaths"] for more +@secref["unixpaths"] for more information on the conversion for +@|AllUnix| paths, and see @secref["windowspaths"] for more information on the conversion for Windows paths. In addition, trailing path separators are removed, as by @scheme[split-path]. @@ -235,8 +235,8 @@ is empty or contains a nul character), the The @scheme[build-path] procedure builds a path @italic{without} checking the validity of the path or accessing the filesystem. -See @secref["mz:unixpaths"] for more information on the construction -of @|AllUnix| paths, and see @secref["mz:windowspaths"] for more +See @secref["unixpaths"] for more information on the construction +of @|AllUnix| paths, and see @secref["windowspaths"] for more information on the construction of Windows paths. The following examples assume that the current directory is @@ -390,8 +390,8 @@ true, but the source or expanded path might be a non-existent path. If still involve a cycle of links if the cycle did not inhibit the simplification). -See @secref["mz:unixpaths"] for more information on simplifying -@|AllUnix| paths, and see @secref["mz:windowspaths"] for more +See @secref["unixpaths"] for more information on simplifying +@|AllUnix| paths, and see @secref["windowspaths"] for more information on simplifying Windows paths.} @@ -460,8 +460,8 @@ platform, and resulting paths for the same platform. This procedure does not access the filesystem. -See @secref["mz:unixpaths"] for more information on splitting -@|AllUnix| paths, and see @secref["mz:windowspaths"] for more +See @secref["unixpaths"] for more information on splitting +@|AllUnix| paths, and see @secref["windowspaths"] for more information on splitting Windows paths.} diff --git a/collects/scribblings/reference/pipes.scrbl b/collects/scribblings/reference/pipes.scrbl index 2dde5f1800..5856479290 100644 --- a/collects/scribblings/reference/pipes.scrbl +++ b/collects/scribblings/reference/pipes.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:pipeports"]{Pipes} +@title[#:tag "pipeports"]{Pipes} A Scheme @deftech{pipe} is internal to Scheme, and not related to OS-level pipes (which are @tech{file-stream ports}) for communicating diff --git a/collects/scribblings/reference/port-buffers.scrbl b/collects/scribblings/reference/port-buffers.scrbl index de1f2718a5..91b1d3e56b 100644 --- a/collects/scribblings/reference/port-buffers.scrbl +++ b/collects/scribblings/reference/port-buffers.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:port-buffers"]{Port Buffers and Positions} +@title[#:tag "port-buffers"]{Port Buffers and Positions} Some ports---especially those that read from and write to files---are internally buffered: @@ -52,7 +52,7 @@ the default port read handler (see @scheme[port-read-handler]). @index['("ports" "flushing")]{Forces} all buffered data in the given output port to be physically written. Only @tech{file-stream ports}, -TCP ports, and custom ports (see @secref["mz:customport"]) use +TCP ports, and custom ports (see @secref["customport"]) use buffers; when called on a port without a buffer, @scheme[flush-output] has no effect.} @@ -61,8 +61,8 @@ has no effect.} Gets or sets the buffer mode for @scheme[port], if possible. @tech{File-stream ports} support setting the buffer mode, -TCP ports (see @secref["mz:networking"]) support setting and getting -the buffer mode, and custom ports (see @secref["mz:customport"]) may +TCP ports (see @secref["networking"]) support setting and getting +the buffer mode, and custom ports (see @secref["customport"]) may support getting and setting buffer modes. If @scheme[mode] is provided, it must be one of @@ -84,7 +84,7 @@ Returns or sets the current read/write position of @scheme[port]. Calling @scheme[file-position] without a position on a non-file/non-string input port returns the number of bytes that have been read from that port if the position is known (see -@secref["mz:linecol"]), otherwise the @exnraise[exn:fail:filesystem]. +@secref["linecol"]), otherwise the @exnraise[exn:fail:filesystem]. For @tech{file-stream ports} and string ports, the position-setting variants sets the read/write position to @scheme[pos] relative to the diff --git a/collects/scribblings/reference/port-line-counting.scrbl b/collects/scribblings/reference/port-line-counting.scrbl index f1110781a0..15fd7255d4 100644 --- a/collects/scribblings/reference/port-line-counting.scrbl +++ b/collects/scribblings/reference/port-line-counting.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:linecol"]{Counting Positions, Lines, and Columns} +@title[#:tag "linecol"]{Counting Positions, Lines, and Columns} @section-index["line numbers"] @section-index["column numbers"] @@ -27,7 +27,7 @@ before the next multiple of @math{8}. When a sequence of bytes in the range 128 to 253 forms a UTF-8 encoding of a character, the position/column is incremented is incremented once for each byte, and then decremented appropriately when a complete encoding sequence is -discovered. See also @secref["mz:ports"] for more information on UTF-8 +discovered. See also @secref["ports"] for more information on UTF-8 decoding for ports. A position is known for any port as long as its value can be expressed diff --git a/collects/scribblings/reference/port-procs.scrbl b/collects/scribblings/reference/port-procs.scrbl index f9db4e6acd..50b2d0653f 100644 --- a/collects/scribblings/reference/port-procs.scrbl +++ b/collects/scribblings/reference/port-procs.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:port-ops"]{Managing Ports} +@title[#:tag "port-ops"]{Managing Ports} @defproc[(input-port? [v any/c]) boolean?]{ Returns @scheme[#t] if @scheme[v] is an input port, @scheme[#f] otherwise.} @@ -44,7 +44,7 @@ port.} @defproc[(file-stream-port? [port port?]) boolean?]{ Returns @scheme[#t] if the given port is a @tech{file-stream port} (see -@secref["mz:file-ports"]), @scheme[#f] otherwise.} +@secref["file-ports"]), @scheme[#f] otherwise.} @defproc[(terminal-port? [port port?]) boolean?]{ Returns @scheme[#t] if the given port is attached to an interactive diff --git a/collects/scribblings/reference/ports.scrbl b/collects/scribblings/reference/ports.scrbl index c13479953a..4bc4fe0ec2 100644 --- a/collects/scribblings/reference/ports.scrbl +++ b/collects/scribblings/reference/ports.scrbl @@ -1,11 +1,11 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:ports" #:style 'toc]{Ports} +@title[#:tag "ports" #:style 'toc]{Ports} @deftech{Ports} produce and consume bytes. When a port is provided to a character-based operation, the port's bytes are decoded; see -@secref["mz:encodings"]. +@secref["encodings"]. The global variable @scheme[eof] is bound to the end-of-file value, and @scheme[eof-object?] returns @scheme[#t] only when applied to this diff --git a/collects/scribblings/reference/printer.scrbl b/collects/scribblings/reference/printer.scrbl index 0eef880437..ddc1df0eb0 100644 --- a/collects/scribblings/reference/printer.scrbl +++ b/collects/scribblings/reference/printer.scrbl @@ -2,7 +2,7 @@ @require[(lib "bnf.ss" "scribble")] @require["mz.ss"] -@title[#:tag "mz:printing" #:style 'quiet]{The Printer} +@title[#:tag "printing" #:style 'quiet]{The Printer} The default printer generally prints core datatypes in such a way that using @scheme[read] on the output produces a value that is @@ -19,16 +19,16 @@ the components of pairs, vectors, boxes (when @scheme[print-box] is @scheme[struct->vector] (when @scheme[print-struct] is @scheme[#t]). If @scheme[print-graph] is @scheme[#t], then this information is used to display sharing by printing graph definitions -and references (see @secref["mz:parse-graph"]). If a cycle is detected +and references (see @secref["parse-graph"]). If a cycle is detected in the initial scan, then @scheme[print-graph] is effectively set to @scheme[#t] automatically. With the exception of displaying byte strings, printing is defined in -terms of Unicode characters; see @secref["mz:ports"] for information +terms of Unicode characters; see @secref["ports"] for information on how a character stream is written to an port's underlying byte stream. -@section[#:tag "mz:print-symbol"]{Printing Symbols} +@section[#:tag "print-symbol"]{Printing Symbols} Symbols containing spaces or special characters @scheme[write] using escaping @litchar["\\"] and quoting @litchar{|}s. When the @@ -131,7 +131,7 @@ with two exceptions: @litchar{"} is printed as @litchar{\"}, and @litchar{\} is printed as @litchar{\\}. Each non-graphic, non-blank character (according to @scheme[char-graphic?] and @scheme[char-blank?]) is printed using the escape sequences described -in @secref["mz:parse-string"], using @litchar{\a}, @litchar{\b}, +in @secref["parse-string"], using @litchar{\a}, @litchar{\b}, @litchar{\t}, @litchar{\n}, @litchar{\v}, @litchar{\f}, @litchar{\r}, or @litchar{\e} if possible, otherwise using @litchar{\u} with four hexadecimal digits or @litchar{\U} with eight hexadecimal digits @@ -152,7 +152,7 @@ is written using @litchar{\a}, @litchar{\b}, @litchar{\t}, @litchar{\e} if possible, otherwise using @litchar{\} followed by one to three octal digits (only as many as necessary). -@section[#:tag "mz:print-vectors"]{Printing Vectors} +@section[#:tag "print-vectors"]{Printing Vectors} In @scheme[display] mode, the printed form of a vector is @litchar{#} followed by the printed form of @scheme[vector->list] applied to the @@ -160,7 +160,7 @@ vector. In @scheme[write] mode, the printed form is the same, except that a decimal integer is printed after the @litchar{#} when the @scheme[print-vector-length] parameter is @scheme[#t]. -@section[#:tag "mz:print-hashtable"]{Printing Hash Tables} +@section[#:tag "print-hashtable"]{Printing Hash Tables} When the @scheme[print-hash-table] parameter is set to @scheme[#t], a hash table prints starting with @litchar{#hash(} or @litchar{#hasheq(} @@ -175,7 +175,7 @@ After all key-value pairs, the printed form completes with When the @scheme[print-hash-table] parameter is set to @scheme[#f], a hash table prints (un@scheme[read]ably) as @litchar{#}. -@section[#:tag "mz:print-box"]{Printing Boxes} +@section[#:tag "print-box"]{Printing Boxes} When the @scheme[print-box] parameter is set to @scheme[#t], a box prints as @litchar{#&} followed by the printed form of its content. @@ -186,7 +186,7 @@ prints (un@scheme[read]ably) as @litchar{#}. @section{Printing Characters} Characters with the special names described in -@secref["mz:parse-character"] @scheme[write] using the same name. +@secref["parse-character"] @scheme[write] using the same name. (Some characters have multiple names; the @scheme[#\newline] and @scheme[#\nul] names are used instead of @scheme[#\linefeed] and @scheme[#\null]). Other graphic characters (according to @@ -202,7 +202,7 @@ character). @section{Printing Keywords} Keywords @scheme[write] and @scheme[display] the same as symbols, -except (see @secref["mz:print-symbol"]) with a leading @litchar{#:}, +except (see @secref["print-symbol"]) with a leading @litchar{#:}, and without special handing for an initial @litchar{#} or when the printed form would matches a number or a delimited @litchar{.} (since @litchar{#:} distinguishes the keyword). diff --git a/collects/scribblings/reference/procedures.scrbl b/collects/scribblings/reference/procedures.scrbl index 0115b4c9c1..b7d7905598 100644 --- a/collects/scribblings/reference/procedures.scrbl +++ b/collects/scribblings/reference/procedures.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:procedures"]{Procedures} +@title[#:tag "procedures"]{Procedures} @defproc[(procedure? [v any/c]) boolean]{ Returns @scheme[#t] if @scheme[v] is a procedure, @scheme[#f] otherwise.} @@ -9,7 +9,7 @@ @defproc[(apply [proc procedure?] [v any/c] ... [lst list?]) any]{ -@guideintro["guide:apply"]{@scheme[apply]} +@guideintro["apply"]{@scheme[apply]} Applies @scheme[proc] using the content of @scheme[(list* v ... lst)] as the (by-position) arguments. The given @scheme[proc] must accept as @@ -32,7 +32,7 @@ is called in tail position with respect to the @scheme[apply] call. [lst list?]) any]{ -@guideintro["guide:apply"]{@scheme[keyword-apply]} +@guideintro["apply"]{@scheme[keyword-apply]} Like @scheme[apply], but @scheme[kw-lst] and @scheme[kw-val-lst] supply by-keyword arguments in addition to the by-position arguments diff --git a/collects/scribblings/reference/prop-port.scrbl b/collects/scribblings/reference/prop-port.scrbl index c4c39c79c9..0a8022a209 100644 --- a/collects/scribblings/reference/prop-port.scrbl +++ b/collects/scribblings/reference/prop-port.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:portstructs"]{Structures as Ports} +@title[#:tag "portstructs"]{Structures as Ports} @defthing[prop:input-port struct-type-property?] @defthing[prop:output-port struct-type-property?] diff --git a/collects/scribblings/reference/read.scrbl b/collects/scribblings/reference/read.scrbl index f5bc1d56ad..8c32abffa0 100644 --- a/collects/scribblings/reference/read.scrbl +++ b/collects/scribblings/reference/read.scrbl @@ -12,7 +12,7 @@ default reader is used, as parameterized by the @scheme[current-readtable] parameter, as well as many other parameters. -See @secref["mz:reader"] for information on the default reader.} +See @secref["reader"] for information on the default reader.} @defproc[(read-syntax [source-name any/c (object-name in)] [in input-port? (current-input-port)]) @@ -23,7 +23,7 @@ source-location information. The @scheme[source-name] is used as the source field of the syntax object; it can be an arbitrary value, but it should generally be a path for the source file. -See @secref["mz:reader"] for information on the default reader in +See @secref["reader"] for information on the default reader in @scheme[read-syntax] mode.} @defproc[(read/recursive [in input-port? (current-input-port)] @@ -34,9 +34,9 @@ See @secref["mz:reader"] for information on the default reader in Similar to calling @scheme[read], but normally used during the dynamic extent of @scheme[read] within a reader-extension procedure (see -@secref["mz:reader-procs"]). The main effect of using +@secref["reader-procs"]). The main effect of using @scheme[read/recursive] instead of @scheme[read] is that -graph-structure annotations (see @secref["mz:parse-graph"]) in the +graph-structure annotations (see @secref["parse-graph"]) in the nested read are considered part of the overall read, at least when the @scheme[graph?] argument is true; since the result is wrapped in a placeholder, however, it is not directly inspectable. @@ -60,17 +60,17 @@ the read datum are local to the datum. When called within the dynamic extent of @scheme[read], the @scheme[read/recursive] procedure produces either an opaque placeholder value, a special-comment value, or an end-of-file. The -result is a special-comment value (see @secref["mz:special-comments"]) +result is a special-comment value (see @secref["special-comments"]) when the input stream's first non-whitespace content parses as a comment. The result is end-of-file when @scheme[read/recursive] encounters an end-of-file. Otherwise, the result is a placeholder that protects graph references that are not yet resolved. When this placeholder is returned within an S-expression that is produced by any -reader-extension procedure (see @secref["mz:reader-procs"]) for the +reader-extension procedure (see @secref["reader-procs"]) for the same outermost @scheme[read], it will be replaced with the actual read value before the outermost @scheme[read] returns. -See @secref["mz:readtables"] for an extended example that uses +See @secref["readtables"] for an extended example that uses @scheme[read/recursive].} @defproc[(read-syntax/recursive [source-name any/c (object-name in)] @@ -101,7 +101,7 @@ using @scheme[read-syntax/recursive] within the dynamic extent of @scheme[read-syntax], except that a special-comment value is returned when the input stream starts with a comment (after whitespace). -See @secref["mz:readtables"] for an extended example that uses +See @secref["readtables"] for an extended example that uses @scheme[read-syntax/recursive].} @@ -117,86 +117,86 @@ symbols are printed with uppercase characters quoted by a @litchar["\\"] or @litchar["|"]. The parameter's value is overridden by quoting @litchar["\\"] or @litchar["|"] vertical-bar quotes and the @litchar{#cs} and @litchar{#ci} prefixes; see -@secref["mz:parse-symbol"] for more information. While a module is +@secref["parse-symbol"] for more information. While a module is loaded, the parameter is set to @scheme[#t] (see @scheme[current-load]).} @defboolparam[read-square-bracket-as-paren on?]{ A parameter that controls whether @litchar["["] and @litchar["]"] -are treated as parentheses. See @secref["mz:parse-pair"] for more +are treated as parentheses. See @secref["parse-pair"] for more information.} @defboolparam[read-curly-brace-as-paren on?]{ A parameter that controls whether @litchar["{"] and @litchar["}"] -are treated as parentheses. See @secref["mz:parse-pair"] for more +are treated as parentheses. See @secref["parse-pair"] for more information.} @defboolparam[read-accept-box on?]{ A parameter that controls parsing @litchar{#&} input. See -@secref["mz:parse-box"] for more information.} +@secref["parse-box"] for more information.} @defboolparam[read-accept-compiled on?]{ A parameter that controls parsing @litchar{#~} compiled input. See -@secref["mz:reader"] and @scheme[current-compile] for more +@secref["reader"] and @scheme[current-compile] for more information.} @defboolparam[read-accept-bar-quote on?]{ A parameter that controls parsing and printing of @litchar["|"] in -symbols. See @secref["mz:parse-symbol"] and @secref["mz:printing"] for +symbols. See @secref["parse-symbol"] and @secref["printing"] for more information.} @defboolparam[read-accept-graph on?]{ A parameter value that controls parsing input with sharing. See -@secref["mz:parse-graph"] for more information.} +@secref["parse-graph"] for more information.} @defboolparam[read-decimal-as-inexact on?]{ A parameter that controls parsing input numbers with a decimal point or exponent (but no explicit exactness tag). See -@secref["mz:parse-number"] for more information.} +@secref["parse-number"] for more information.} @defboolparam[read-accept-dot on?]{ A parameter that controls parsing input with a dot, which is normally -used for literal cons cells. See @secref["mz:parse-pair"] for more +used for literal cons cells. See @secref["parse-pair"] for more information.} @defboolparam[read-accept-infix-dot on?]{ A parameter that controls parsing input with two dots to trigger infix - conversion. See @secref["mz:parse-pair"] for more information.} + conversion. See @secref["parse-pair"] for more information.} @defboolparam[read-accept-quasiquote on?]{ A parameter that controls parsing input with @litchar{`} or @litchar{,} which is normally used for @scheme[quasiquote], @scheme[unquote], and @scheme[unquote-splicing] abbreviations. See -@secref["mz:parse-quote"] for more information.} +@secref["parse-quote"] for more information.} @defboolparam[read-accept-reader on?]{ A parameter that controls whether @litchar{#reader} is allowed for -selecting a parser. See @secref["mz:parse-reader"] for more +selecting a parser. See @secref["parse-reader"] for more information.} @defparam[current-reader-guard proc (any/c . -> . any)]{ A parameter whose value converts or rejects (by raising an exception) a module-path datum following @litchar{#reader}. See -@secref["mz:parse-reader"] for more information.} +@secref["parse-reader"] for more information.} @defparam[current-readtable readtable (or/c readtable? false/c)]{ A parameter whose value determines a readtable that adjusts the parsing of S-expression input, where @scheme[#f] implies the -default behavior. See @secref["mz:readtables"] for more information.} +default behavior. See @secref["readtables"] for more information.} @defproc*[([(port-read-handler [in input-port?]) (case-> (input-port? . -> . any) @@ -230,11 +230,42 @@ arguments: } The default port read handler reads standard Scheme expressions with -Scheme's built-in parser (see @secref["mz:reader"]). It handles a +Scheme's built-in parser (see @secref["reader"]). It handles a special result from a custom input port (see @scheme[make-custom-input-port]) by treating it as a single expression, except that special-comment values (see -@secref["mz:special-comments"]) are treated as whitespace. +@secref["special-comments"]) are treated as whitespace. The default port read handler itself can be customized through a -readtable; see @secref["mz:readtables"] for more information.} +readtable; see @secref["readtables"] for more information.} + + +@defproc[(read-honu [in input-port? (current-input-port)]) any]{ + +Like @scheme[read], but for Honu mode (see @secref["parse-honu"]).} + +@defproc[(read-honu-syntax [source-name any/c (object-name in)] + [in input-port? (current-input-port)]) + (or/c syntax? eof-object?)]{ + +Like @scheme[read-syntax], but for Honu mode (see +@secref["parse-honu"]).} + +@defproc[(read-honu/recursive [in input-port? (current-input-port)] + [start (or/c character? false/c) #f] + [readtable readtable? (current-readtable)] + [graph? any/c #f]) + any]{ + +Like @scheme[read/recursive], but for Honu mode (see +@secref["parse-honu"]).} + +@defproc[(read-honu-syntax/recursive [source-name any/c (object-name in)] + [in input-port? (current-input-port)] + [start (or/c character? false/c) #f] + [readtable readtable? (current-readtable)] + [graph? any/c #f]) + any]{ + +Like @scheme[read-syntax/recursive], but for Honu mode (see +@secref["parse-honu"]).} diff --git a/collects/scribblings/reference/reader.scrbl b/collects/scribblings/reference/reader.scrbl index 104974cac1..a415f8ca3c 100644 --- a/collects/scribblings/reference/reader.scrbl +++ b/collects/scribblings/reference/reader.scrbl @@ -15,10 +15,10 @@ @define[(graph-defn) @elem{@litchar{#}@graph-tag[]@litchar{=}}] @define[(graph-ref) @elem{@litchar{#}@graph-tag[]@litchar{#}}] -@title[#:tag "mz:reader" #:style 'quiet]{The Reader} +@title[#:tag "reader" #:style 'quiet]{The Reader} Scheme's reader is a recursive-descent parser that can be configured -through a @seclink["mz:readtables"]{readtable} and various other +through a @seclink["readtables"]{readtable} and various other @tech{parameters}. This section describes the reader's parsing when using the default readtable. @@ -38,11 +38,11 @@ and @scheme[read-syntax] mode does the same modulo wrapping the final result. Reading is defined in terms of Unicode characters; see -@secref["mz:ports"] for information on how a byte stream is converted +@secref["ports"] for information on how a byte stream is converted to a character stream. @;------------------------------------------------------------------------ -@section[#:tag "mz:default-readtable-dispatch"]{Delimiters and Dispatch} +@section[#:tag "default-readtable-dispatch"]{Delimiters and Dispatch} Along with @schemelink[char-whitespace?]{whitespace}, the following characters are @defterm{delimiters}: @@ -82,86 +82,86 @@ on the next character or characters in the input stream as follows: @dispatch-table[ - @dispatch[@litchar{(}]{starts a pair or list; see @secref["mz:parse-pair"]} - @dispatch[@litchar{[}]{starts a pair or list; see @secref["mz:parse-pair"]} - @dispatch[@litchar["{"]]{starts a pair or list; see @secref["mz:parse-pair"]} + @dispatch[@litchar{(}]{starts a pair or list; see @secref["parse-pair"]} + @dispatch[@litchar{[}]{starts a pair or list; see @secref["parse-pair"]} + @dispatch[@litchar["{"]]{starts a pair or list; see @secref["parse-pair"]} @dispatch[@litchar{)}]{matches @litchar{(} or raises @Exn{exn:fail:read}} @dispatch[@litchar{]}]{matches @litchar{[} or raises @Exn{exn:fail:read}} @dispatch[@litchar["}"]]{matches @litchar["{"] or raises @Exn{exn:fail:read}} - @dispatch[@litchar{"}]{starts a string; see @secref["mz:parse-string"]} - @dispatch[@litchar{,}]{starts a quote; see @secref["mz:parse-quote"]} - @dispatch[@litchar{`}]{starts a quasiquote; see @secref["mz:parse-quote"]} - @dispatch[@litchar{,}]{starts an unquote or splicing unquote; see @secref["mz:parse-quote"]} + @dispatch[@litchar{"}]{starts a string; see @secref["parse-string"]} + @dispatch[@litchar{,}]{starts a quote; see @secref["parse-quote"]} + @dispatch[@litchar{`}]{starts a quasiquote; see @secref["parse-quote"]} + @dispatch[@litchar{,}]{starts an unquote or splicing unquote; see @secref["parse-quote"]} - @dispatch[@litchar{;}]{starts a line comment; see @secref["mz:parse-comment"]} + @dispatch[@litchar{;}]{starts a line comment; see @secref["parse-comment"]} - @dispatch[@cilitchar{#t}]{true; see @secref["mz:parse-boolean"]} - @dispatch[@cilitchar{#f}]{false; see @secref["mz:parse-boolean"]} + @dispatch[@cilitchar{#t}]{true; see @secref["parse-boolean"]} + @dispatch[@cilitchar{#f}]{false; see @secref["parse-boolean"]} - @dispatch[@litchar{#(}]{starts a vector; see @secref["mz:parse-vector"]} - @dispatch[@litchar{#[}]{starts a vector; see @secref["mz:parse-vector"]} - @dispatch[@litchar["#{"]]{starts a vector; see @secref["mz:parse-vector"]} + @dispatch[@litchar{#(}]{starts a vector; see @secref["parse-vector"]} + @dispatch[@litchar{#[}]{starts a vector; see @secref["parse-vector"]} + @dispatch[@litchar["#{"]]{starts a vector; see @secref["parse-vector"]} - @dispatch[@litchar["#\\"]]{starts a character; see @secref["mz:parse-character"]} + @dispatch[@litchar["#\\"]]{starts a character; see @secref["parse-character"]} - @dispatch[@litchar{#"}]{starts a byte string; see @secref["mz:parse-string"]} - @dispatch[@litchar{#%}]{starts a symbol; see @secref["mz:parse-symbol"]} - @dispatch[@litchar{#:}]{starts a keyword; see @secref["mz:parse-keyword"]} - @dispatch[@litchar{#&}]{starts a box; see @secref["mz:parse-box"]} + @dispatch[@litchar{#"}]{starts a byte string; see @secref["parse-string"]} + @dispatch[@litchar{#%}]{starts a symbol; see @secref["parse-symbol"]} + @dispatch[@litchar{#:}]{starts a keyword; see @secref["parse-keyword"]} + @dispatch[@litchar{#&}]{starts a box; see @secref["parse-box"]} - @dispatch[@litchar["#|"]]{starts a block comment; see @secref["mz:parse-comment"]} - @dispatch[@litchar["#;"]]{starts an S-expression comment; see @secref["mz:parse-comment"]} - @dispatch[@litchar{#,}]{starts a syntax quote; see @secref["mz:parse-quote"]} - @dispatch[@litchar["#! "]]{starts a line comment; see @secref["mz:parse-comment"]} - @dispatch[@litchar["#!/"]]{starts a line comment; see @secref["mz:parse-comment"]} - @dispatch[@litchar{#`}]{starts a syntax quasiquote; see @secref["mz:parse-quote"]} - @dispatch[@litchar{#,}]{starts an syntax unquote or splicing unquote; see @secref["mz:parse-quote"]} + @dispatch[@litchar["#|"]]{starts a block comment; see @secref["parse-comment"]} + @dispatch[@litchar["#;"]]{starts an S-expression comment; see @secref["parse-comment"]} + @dispatch[@litchar{#,}]{starts a syntax quote; see @secref["parse-quote"]} + @dispatch[@litchar["#! "]]{starts a line comment; see @secref["parse-comment"]} + @dispatch[@litchar["#!/"]]{starts a line comment; see @secref["parse-comment"]} + @dispatch[@litchar{#`}]{starts a syntax quasiquote; see @secref["parse-quote"]} + @dispatch[@litchar{#,}]{starts an syntax unquote or splicing unquote; see @secref["parse-quote"]} @dispatch[@litchar["#~"]]{starts compiled code; see @scheme[current-compile]} - @dispatch[@cilitchar{#i}]{starts a number; see @secref["mz:parse-number"]} - @dispatch[@cilitchar{#e}]{starts a number; see @secref["mz:parse-number"]} - @dispatch[@cilitchar{#x}]{starts a number; see @secref["mz:parse-number"]} - @dispatch[@cilitchar{#o}]{starts a number; see @secref["mz:parse-number"]} - @dispatch[@cilitchar{#d}]{starts a number; see @secref["mz:parse-number"]} - @dispatch[@cilitchar{#b}]{starts a number; see @secref["mz:parse-number"]} + @dispatch[@cilitchar{#i}]{starts a number; see @secref["parse-number"]} + @dispatch[@cilitchar{#e}]{starts a number; see @secref["parse-number"]} + @dispatch[@cilitchar{#x}]{starts a number; see @secref["parse-number"]} + @dispatch[@cilitchar{#o}]{starts a number; see @secref["parse-number"]} + @dispatch[@cilitchar{#d}]{starts a number; see @secref["parse-number"]} + @dispatch[@cilitchar{#b}]{starts a number; see @secref["parse-number"]} - @dispatch[@cilitchar["#<<"]]{starts a string; see @secref["mz:parse-string"]} + @dispatch[@cilitchar["#<<"]]{starts a string; see @secref["parse-string"]} - @dispatch[@litchar{#rx}]{starts a regular expression; see @secref["mz:parse-regexp"]} - @dispatch[@litchar{#px}]{starts a regular expression; see @secref["mz:parse-regexp"]} + @dispatch[@litchar{#rx}]{starts a regular expression; see @secref["parse-regexp"]} + @dispatch[@litchar{#px}]{starts a regular expression; see @secref["parse-regexp"]} - @dispatch[@cilitchar{#ci}]{switches case sensitivity; see @secref["mz:parse-symbol"]} - @dispatch[@cilitchar{#cs}]{switches case sensitivity; see @secref["mz:parse-symbol"]} + @dispatch[@cilitchar{#ci}]{switches case sensitivity; see @secref["parse-symbol"]} + @dispatch[@cilitchar{#cs}]{switches case sensitivity; see @secref["parse-symbol"]} - @dispatch[@cilitchar["#sx"]]{starts a Scheme expression; see @secref["mz:parse-honu"]} + @dispatch[@cilitchar["#sx"]]{starts a Scheme expression; see @secref["parse-honu"]} - @dispatch[@litchar["#hx"]]{starts a Honu expression; see @secref["mz:parse-honu"]} - @dispatch[@litchar["#honu"]]{starts a Honu module; see @secref["mz:parse-honu"]} + @dispatch[@litchar["#hx"]]{starts a Honu expression; see @secref["parse-honu"]} + @dispatch[@litchar["#honu"]]{starts a Honu module; see @secref["parse-honu"]} - @dispatch[@litchar["#hash"]]{starts a hash table; see @secref["mz:parse-hashtable"]} + @dispatch[@litchar["#hash"]]{starts a hash table; see @secref["parse-hashtable"]} - @dispatch[@litchar["#reader"]]{starts a reader extension use; see @secref["mz:parse-reader"]} + @dispatch[@litchar["#reader"]]{starts a reader extension use; see @secref["parse-reader"]} - @dispatch[@elem{@litchar{#}@kleeneplus{@nonterm{digit@sub{10}}}@litchar{(}}]{starts a vector; see @secref["mz:parse-vector"]} - @dispatch[@elem{@litchar{#}@kleeneplus{@nonterm{digit@sub{10}}}@litchar{[}}]{starts a vector; see @secref["mz:parse-vector"]} - @dispatch[@elem{@litchar{#}@kleeneplus{@nonterm{digit@sub{10}}}@litchar["{"]}]{starts a vector; see @secref["mz:parse-vector"]} - @dispatch[@graph-defn[]]{binds a graph tag; see @secref["mz:parse-graph"]} - @dispatch[@graph-ref[]]{uses a graph tag; see @secref["mz:parse-graph"]} + @dispatch[@elem{@litchar{#}@kleeneplus{@nonterm{digit@sub{10}}}@litchar{(}}]{starts a vector; see @secref["parse-vector"]} + @dispatch[@elem{@litchar{#}@kleeneplus{@nonterm{digit@sub{10}}}@litchar{[}}]{starts a vector; see @secref["parse-vector"]} + @dispatch[@elem{@litchar{#}@kleeneplus{@nonterm{digit@sub{10}}}@litchar["{"]}]{starts a vector; see @secref["parse-vector"]} + @dispatch[@graph-defn[]]{binds a graph tag; see @secref["parse-graph"]} + @dispatch[@graph-ref[]]{uses a graph tag; see @secref["parse-graph"]} - @dispatch[@italic{otherwise}]{starts a symbol; see @secref["mz:parse-symbol"]} + @dispatch[@italic{otherwise}]{starts a symbol; see @secref["parse-symbol"]} ] -@section[#:tag "mz:parse-symbol"]{Reading Symbols} +@section[#:tag "parse-symbol"]{Reading Symbols} -@guideintro["guide:symbols"]{the syntax of symbols} +@guideintro["symbols"]{the syntax of symbols} A sequence that does not start with a delimiter or @litchar{#} is parsed as either a symbol or a number (see -@secref["mz:parse-number"]), except that @litchar{.} by itself is +@secref["parse-number"]), except that @litchar{.} by itself is never parsed as a symbol or character (unless the @scheme[read-accept-dot] parameter is set to @scheme[#f]). A @as-index{@litchar{#%}} also starts a symbol. A successful number @@ -191,9 +191,9 @@ case-sensitive mode. "#%Apple" ] -@section[#:tag "mz:parse-number"]{Reading Numbers} +@section[#:tag "parse-number"]{Reading Numbers} -@guideintro["guide:numbers"]{the syntax of numbers} +@guideintro["numbers"]{the syntax of numbers} @section-index["numbers" "parsing"] @@ -205,7 +205,7 @@ meta-meta-variable in the grammar. A number is optionally prefixed by an exactness specifier, @as-index{@litchar{#e}} (exact) or @as-index{@litchar{#i}} (inexact), which specifies its parsing as an exact or inexact number; see -@secref["mz:numbers"] for information on number exactness. As the +@secref["numbers"] for information on number exactness. As the non-terminal names suggest, a number that has no exactness specifier and matches only @nunterm{inexact-number} is normally parsed as an inexact number, otherwise it is parsed as an excat number. If the @@ -223,7 +223,7 @@ matches the @nonterm{general-number@sub{2}}, An @nunterm{exponent-mark} in an inexact number serves both to specify an exponent and specify a numerical precision. If single-precision -IEEE floating point is supported (see @secref["mz:numbers"]), the marks +IEEE floating point is supported (see @secref["numbers"]), the marks @litchar{f} and @litchar{s} specifies single-precision. Otherwise, or with any other mark, double-precision IEEE floating point is used. @@ -283,7 +283,7 @@ with any other mark, double-precision IEEE floating point is used. "#b101" ] -@section[#:tag "mz:parse-boolean"]{Reading Booleans} +@section[#:tag "parse-boolean"]{Reading Booleans} A @as-index{@litchar{#t}} or @as-index{@litchar{#T}} is the complete input syntax for the boolean constant true, and @@ -291,11 +291,11 @@ input syntax for the boolean constant true, and input syntax for the boolean constant false. -@section[#:tag "mz:parse-pair"]{Reading Pairs and Lists} +@section[#:tag "parse-pair"]{Reading Pairs and Lists} When the reader encounters a @as-index{@litchar{(}}, @as-index{@litchar["["]}, or @as-index{@litchar["{"]}, it starts -parsing a pair or list; see @secref["mz:pairs"] for information on pairs +parsing a pair or list; see @secref["pairs"] for information on pairs and lists. To parse the pair or list, the reader recursively reads data @@ -366,9 +366,9 @@ is instead parsed a s symbol. If the @scheme[read-accept-infix-dot] @litchar{.}s trigger a @scheme[exn:fail:read], instead of the infix conversion. -@section[#:tag "mz:parse-string"]{Reading Strings} +@section[#:tag "parse-string"]{Reading Strings} -@guideintro["guide:strings"]{the syntax of strings} +@guideintro["strings"]{the syntax of strings} @section-index["strings" "parsing"] @@ -439,13 +439,13 @@ Within a string sequence, the following escape sequences are If the reader encounteres any other use of a backslash in a string constant, the @exnraise[exn:fail:read]. -@guideintro["guide:bytestrings"]{the syntax of byte strings} +@guideintro["bytestrings"]{the syntax of byte strings} @section-index["byte strings" "parsing"] A string constant preceded by @litchar{#} is parsed as a byte-string. (That is, @as-index{@litchar{#"}} starts a byte-string -literal.) See @secref["mz:bytestrings"] for information on byte +literal.) See @secref["bytestrings"] for information on byte strings. Byte string constants support the same escape sequences as character strings, except @litchar["\\u"] and @litchar["\\U"]. @@ -472,7 +472,7 @@ encountered before a terminating line, the @exnraise[exn:fail:read]. "#\"Apple\"" ] -@section[#:tag "mz:parse-quote"]{Reading Quotes} +@section[#:tag "parse-quote"]{Reading Quotes} When the reader enounters @as-index{@litchar{'}}, then it recursively reads one datum, and it forms a new list containing the symbol @@ -501,7 +501,7 @@ The @litchar{`}, @litchar{,}, and @litchar[",@"] forms are disabled when the @scheme[read-accept-quasiquote] @tech{parameter} is set to @scheme[#f], in which case the @exnraise[exn:fail:read], instead. -@section[#:tag "mz:parse-comment"]{Reading Comments} +@section[#:tag "parse-comment"]{Reading Comments} A @as-index{@litchar{;}} starts a line comment. When the reader encounters @litchar{;}, then it skips past all characters until the @@ -531,7 +531,7 @@ normally appears at the beginning of a Unix script file. "#! /bin/sh" ] -@section[#:tag "mz:parse-vector"]{Reading Vectors} +@section[#:tag "parse-vector"]{Reading Vectors} When the reader encounters a @litchar{#(}, @litchar{#[}, or @litchar["#{"], it starts parsing a vector; see @secref["vectors"] for @@ -539,7 +539,7 @@ information on vectors. The elements of the vector are recursively read until a matching @litchar{)}, @litchar{]}, or @litchar["}"] is found, just as for -lists (see @secref["mz:parse-pair"]). A delimited @litchar{.} is not +lists (see @secref["parse-pair"]). A delimited @litchar{.} is not allowed among the vector elements. An optional vector length can be specified between the @litchar{#} and @@ -560,11 +560,11 @@ vector's elements are also wraped as syntax objects. "#3()" ] -@section[#:tag "mz:parse-hashtable"]{Reading Hash Tables} +@section[#:tag "parse-hashtable"]{Reading Hash Tables} A @litchar{#hash} starts an immutable hash-table constant with key matching based on @scheme[equal?]. The characters after @litchar{hash} -must parse as a list of pairs (see @secref["mz:parse-pair"]) with a +must parse as a list of pairs (see @secref["parse-pair"]) with a specific use of delimited @litchar{.}: it must appear between the elements of each pair in the list, and nowhere in the sequence of list elements. The first element of each pair is used as the key for a @@ -588,7 +588,7 @@ In either case, the table is constructed by adding each mapping to the "#hasheq((a . 5) (a . 7))" ] -@section[#:tag "mz:parse-box"]{Reading Boxes} +@section[#:tag "parse-box"]{Reading Boxes} When the reader encounters a @litchar{#&}, it starts parsing a box; see @secref["boxes"] for information on boxes. The content of the box @@ -602,9 +602,9 @@ content is also wraped as a syntax object. "#&17" ] -@section[#:tag "mz:parse-character"]{Reading Characters} +@section[#:tag "parse-character"]{Reading Characters} -@guideintro["guide:characters"]{the syntax of characters} +@guideintro["characters"]{the syntax of characters} A @litchar["#\\"] starts a character constant, which has one of the following forms: @@ -624,12 +624,12 @@ following forms: @item{@litchar["#\\"]@kleenerange[1 3]{@nonterm{digit@sub{8}}}: Unicode for the octal number specified by @kleenerange[1 3]{@nonterm{digit@sub{8}}}, as in string escapes (see - @secref["mz:parse-string"]).} + @secref["parse-string"]).} @item{@litchar["#\\x"]@kleenerange[1 2]{@nonterm{digit@sub{16}}}: Unicode for the hexadecimal number specified by @kleenerange[1 2]{@nonterm{digit@sub{16}}}, as in string escapes (see - @secref["mz:parse-string"]).} + @secref["parse-string"]).} @item{@litchar["#\\u"]@kleenerange[1 4]{@nonterm{digit@sub{16}}}: like @litchar["#\\x"], but with up to four hexadecimal digits.} @@ -652,7 +652,7 @@ following forms: "#\\\u3BB" ] -@section[#:tag "mz:parse-keyword"]{Reading Keywords} +@section[#:tag "parse-keyword"]{Reading Keywords} A @litchar{#:} starts a keyword. The parsing of a keyword after the @litchar{#:} is the same as for a symbol, including case-folding in @@ -664,11 +664,11 @@ never parsed as a number. "#:1" ] -@section[#:tag "mz:parse-regexp"]{Reading Regular Expressions} +@section[#:tag "parse-regexp"]{Reading Regular Expressions} A @litchar{#rx} or @litchar{#px} starts a regular expression. The characters immediately after @litchar{#rx} or @litchar{#px} must parse -as a string or byte string (see @secref["mz:parse-string"]). A +as a string or byte string (see @secref["parse-string"]). A @litchar{#rx} prefix starts a regular expression as would be constructed by @scheme[regexp], @litchar{#px} as constructed by @scheme[pregexp], @litchar{#rx#} as @@ -682,7 +682,7 @@ constructed by @scheme[byte-pregexp]. "#px#\"[\\\\s]*\"" ] -@section[#:tag "mz:parse-graph"]{Reading Graph Structure} +@section[#:tag "parse-graph"]{Reading Graph Structure} A @graph-defn[] tags the following datum for reference via @graph-ref[], which allows the reader to produce a datum that @@ -712,7 +712,7 @@ neither defines nor uses graph tags for other top-level forms. @local-table-of-contents[] -@section[#:tag "mz:parse-reader"]{Reading via an External Reader} +@section[#:tag "parse-reader"]{Reading via an External Reader} When the reader encounters @litchar{#reader}, then it loads an external reader procedure and applies it to the current input stream. @@ -733,10 +733,10 @@ the result is a syntax object in @scheme[read] mode, then it is converted to a datum using @scheme[syntax-object->datum]; if the result is not a syntax object in @scheme[read-syntax] mode, then it is converted to one using @scheme[datum->syntax-object]. See also -@secref["mz:reader-procs"] for information on the procedure's results. +@secref["reader-procs"] for information on the procedure's results. If the @scheme[read-accept-reader] @tech{parameter} is set to @scheme[#f], then if the reader encounters @litchar{#reader}, the @exnraise[exn:fail:read]. -@section[#:tag "mz:parse-honu"]{Honu Parsing} +@section[#:tag "parse-honu"]{Honu Parsing} diff --git a/collects/scribblings/reference/readtables.scrbl b/collects/scribblings/reference/readtables.scrbl index 7fb5d7fc80..cb588b1398 100644 --- a/collects/scribblings/reference/readtables.scrbl +++ b/collects/scribblings/reference/readtables.scrbl @@ -5,10 +5,10 @@ @title[#:style 'toc]{Reader Extension} Scheme's reader can be extended in three ways: through a reader-macro -procedure in a readtable (see @secref["mz:readtables"]), through a -@litchar{#reader} form (see @secref["mz:parse-reader"]), or through a +procedure in a readtable (see @secref["readtables"]), through a +@litchar{#reader} form (see @secref["parse-reader"]), or through a custom-port byte reader that returns a ``special'' result procedure -(see @secref["mz:customport"]). All three kinds of @deftech{reader +(see @secref["customport"]). All three kinds of @deftech{reader extension procedures} accept similar arguments, and their results are treated in the same way by @scheme[read] and @scheme[read-syntax] (or, more precisely, by the default read handler; see @@ -17,9 +17,9 @@ more precisely, by the default read handler; see @local-table-of-contents[] @;------------------------------------------------------------------------ -@section[#:tag "mz:readtables"]{Readtables} +@section[#:tag "readtables"]{Readtables} -The dispatch table in @secref["mz:default-readtable-dispatch"] +The dispatch table in @secref["default-readtable-dispatch"] corresponds to the default @deftech{readtable}. By creating a new readtable and installing it via the @scheme[current-readtable] parameter, the reader's behavior can be extended. @@ -59,7 +59,14 @@ does not consult the readtable. For many contexts, @scheme[#f] identifies the default readtable. In particular, @scheme[#f] is the initial value for the @scheme[current-readtable] parameter, which causes the reader to -behave as described in @secref["mz:reader"]. +behave as described in @secref["reader"]. + +@defproc[(readtable? [v any/c]) boolean?]{ + +Returns @scheme[#t] if @scheme[v] is a readtable, @scheme[#f] +otherwise. + +} @defproc[(make-readtable [readtable readtable?] [key (or/c character? false/c)] @@ -142,13 +149,13 @@ additional arguments that represent a source location. When the reader macro is triggered by @scheme[read] (or @scheme[read/recursive]), the procedure is passed only two arguments if it accepts two arguments, otherwise it is passed six arguments where the last four are all -@scheme[#f]. See @secref["mz:reader-procs"] for information on the +@scheme[#f]. See @secref["reader-procs"] for information on the procedure's results. A reader macro normally reads characters from the given input port to produce a value to be used as the ``reader macro-expansion'' of the consumed characters. The reader macro might produce a special-comment -value (see @secref["mz:special-comments"]) to cause the consumed +value (see @secref["special-comments"]) to cause the consumed character to be treated as whitespace, and it might use @scheme[read/recursive] or @scheme[read-syntax/recursive].} @@ -316,7 +323,7 @@ character and the @scheme[#f] readtable.} ]] @;------------------------------------------------------------------------ -@section[#:tag "mz:reader-procs"]{Reader-Extension Procedures} +@section[#:tag "reader-procs"]{Reader-Extension Procedures} Calls to @techlink{reader extension procedures} can be triggered through @scheme[read], @scheme[read/recursive], @scheme[read-syntax], @@ -339,7 +346,7 @@ object that has no lexical context (e.g., a syntax object created using @scheme[datum->syntax-object] with @scheme[#f] as the first argument and with the given location information as the third argument). Another possible result is a special-comment value (see -@secref["mz:special-comments"]). If the procedure's result is not a +@secref["special-comments"]). If the procedure's result is not a syntax object and not a special-comment value, it is converted to one using @scheme[datum->syntax-object]. @@ -349,7 +356,7 @@ object is returned, it is converted to a plain value using @scheme[syntax-object->datum]. In either context, when the result from a reader-extension procedure -is a special-comment value (see @secref["mz:special-comments"]), then +is a special-comment value (see @secref["special-comments"]), then @scheme[read], @scheme[read-syntax], @|etc| treat the value as a delimiting comment and otherwise ignore it. @@ -363,7 +370,7 @@ shared value. Graph structure (including cycles) is preserved in the copy. @;------------------------------------------------------------------------ -@section[#:tag "mz:special-comments"]{Special Comments} +@section[#:tag "special-comments"]{Special Comments} @defproc[(make-special-comment [v any/c]) special-comment?]{ @@ -371,7 +378,7 @@ Creates a special-comment value that encapsulates @scheme[v]. The @scheme[read], @scheme[read-syntax], @|etc| procedures treat values constructed with @scheme[make-special-comment] as delimiting whitespace when returned by a reader-extension procedure (see -@secref["mz:reader-procs"]).} +@secref["reader-procs"]).} @defproc[(special-comment? [v any/c]) boolean?]{ diff --git a/collects/scribblings/reference/reference.scrbl b/collects/scribblings/reference/reference.scrbl index b210c9e83a..0941070f77 100644 --- a/collects/scribblings/reference/reference.scrbl +++ b/collects/scribblings/reference/reference.scrbl @@ -1,12 +1,14 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title{PLT Scheme Reference} +@title[#:tag-prefix '(lib "reference.scrbl" "scribblings" "reference") + #:tag "top"]{PLT Scheme Reference} + +@declare-exporting[big little] This manual defines the core PLT Scheme language and describes its -most prominent libraries. The companion manual -@italic{@link["../guide/index.html"]{A Guide to PLT Scheme}} provides -a friendlier (though less precise and less complete) overview of the +most prominent libraries. The companion manual @|Guide| provides a +friendlier (though less precise and less complete) overview of the language. @bold{This reference describes a potential future version of PLT Scheme. @@ -33,4 +35,15 @@ language. @;------------------------------------------------------------------------ +@section{To Do} + +This chapter provides some temporary hyper-link targets. + +@subsection[#:tag "inside-mzscheme"]{Inside MzScheme} +@subsection[#:tag "running-sa"]{Running MzScheme} +@subsection[#:tag "async-channel"]{Asynchronous Channels} +@subsection[#:tag "honu"]{Honu} + +@;------------------------------------------------------------------------ + @index-section["mzscheme-index"] diff --git a/collects/scribblings/reference/regexps.scrbl b/collects/scribblings/reference/regexps.scrbl index 667173b09f..fe49bb0124 100644 --- a/collects/scribblings/reference/regexps.scrbl +++ b/collects/scribblings/reference/regexps.scrbl @@ -4,7 +4,9 @@ @require["rx.ss"] -@title[#:tag "mz:regexp"]{Regular Expressions} +@title[#:tag "regexp"]{Regular Expressions} + +@declare-exporting[big (lib "big/regexp")] @section-index{regexps} @section-index{pattern matching} @@ -16,7 +18,7 @@ the same pattern language as the Unix utility @exec{egrep} or Perl. A string-specified pattern produces a character regexp matcher, and a byte-string pattern produces a byte regexp matcher. If a character regexp is used with a byte string or input port, it matches UTF-8 -encodings (see @secref["mz:encodings"]) of matching character streams; +encodings (see @secref["encodings"]) of matching character streams; if a byte regexp is used with a character string, it matches bytes in the UTF-8 encoding of the string. @@ -28,7 +30,7 @@ compatible to @exec{egrep}. The @scheme[pregexp] and @scheme[byte-pregexp] procedures produce a regexp value using a slightly different syntax of regular expressions that is more compatible with Perl. In addition, Scheme constants written with -@litchar{#rx} or @litchar{#px} (see @secref["mz:reader"]) produce +@litchar{#rx} or @litchar{#px} (see @secref["reader"]) produce compiled regexp values. The internal size of a regexp value is limited to 32 kilobytes; this @@ -36,7 +38,7 @@ limit roughly corresponds to a source string with 32,000 literal characters or 5,000 operators. @;------------------------------------------------------------------------ -@section[#:tag "mz:regexp-syntax"]{Regexp Syntax} +@section[#:tag "regexp-syntax"]{Regexp Syntax} The following syntax specifications describe the content of a string that represents a regular expression. The syntax of the corresponding @@ -126,7 +128,7 @@ otherwise.} @defproc[(regexp [str string?]) regexp?]{ Takes a string representation of a regular expression (using the -syntax in @secref["mz:regexp-syntax"]) and compiles it into a regexp +syntax in @secref["regexp-syntax"]) and compiles it into a regexp value. Other regular expression procedures accept either a string or a regexp value as the matching pattern. If a regular expression string is used multiple times, it is faster to compile the string once to a @@ -144,7 +146,7 @@ the source string for a regexp value. @defproc[(pregexp [string string?]) pregexp?]{ Like @scheme[regexp], except that it uses a slightly different syntax -(see @secref["mz:regexp-syntax"]). The result can be used with +(see @secref["regexp-syntax"]). The result can be used with @scheme[regexp-match], etc., just like the result from @scheme[regexp]. @@ -156,7 +158,7 @@ Like @scheme[regexp], except that it uses a slightly different syntax @defproc[(byte-regexp [bstr bytes?]) byte-regexp?]{ Takes a byte-string representation of a regular expression (using the -syntax in @secref["mz:regexp-syntax"]) and compiles it into a +syntax in @secref["regexp-syntax"]) and compiles it into a byte-regexp value. The @scheme[object-name] procedure @@ -170,7 +172,7 @@ returns the source byte string for a regexp value. @defproc[(byte-pregexp [bstr bytes?]) byte-pregexp?]{ Like @scheme[byte-regexp], except that it uses a slightly different -syntax (see @secref["mz:regexp-syntax"]). The result can be used with +syntax (see @secref["regexp-syntax"]). The result can be used with @scheme[regexp-match], etc., just like the result from @scheme[byte-regexp]. @@ -265,7 +267,7 @@ determine a match. If the input port is read simultaneously by another thread, or if the port is a custom port with inconsistent reading and peeking procedures -(see @secref["mz:customport"]), then the bytes that are peeked and +(see @secref["customport"]), then the bytes that are peeked and used for matching may be different than the bytes read and discarded after the match completes; the matcher inspects only the peeked bytes. To avoid such interleaving, use @scheme[regexp-match-peek] diff --git a/collects/scribblings/reference/running.scrbl b/collects/scribblings/reference/running.scrbl index 2e1a2324ef..641350f90a 100644 --- a/collects/scribblings/reference/running.scrbl +++ b/collects/scribblings/reference/running.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:running" #:style 'toc]{Running PLT Scheme} +@title[#:tag "running" #:style 'toc]{Running PLT Scheme} @local-table-of-contents[] diff --git a/collects/scribblings/reference/security-guards.scrbl b/collects/scribblings/reference/security-guards.scrbl index b04ccdb66a..1fcbff83f1 100644 --- a/collects/scribblings/reference/security-guards.scrbl +++ b/collects/scribblings/reference/security-guards.scrbl @@ -2,7 +2,7 @@ @require[(lib "bnf.ss" "scribble")] @require["mz.ss"] -@title[#:tag "mz:securityguards"]{Security Guards} +@title[#:tag "securityguards"]{Security Guards} @defproc[(security-guard? [v any/c]) boolean?]{ @@ -18,7 +18,7 @@ current security guard is consulted to check whether the thread is allowed read access to the file. If access is granted, the thread receives a port that it may use indefinitely, regardless of changes to the security guard (although the port's custodian could shut down the -port; see @secref["mz:custodians"]). +port; see @secref["custodians"]). A thread's current security guard is determined by the @scheme[current-security-guard] parameter. Every security guard has a @@ -52,7 +52,7 @@ The @scheme[file-guard] procedure must accept three arguments: @item{a symbol for the primitive procedure that triggered the access check, which is useful for raising an exception to deny access.} - @item{a path (see @secref["mz:pathutils"]) or @scheme[#f] for + @item{a path (see @secref["pathutils"]) or @scheme[#f] for pathless queries, such as @scheme[(current-directory)], @scheme[(filesystem-root-list)], and @scheme[(find-system-path symbol)]. A path provided to @scheme[file-guard] is not expanded or @@ -121,7 +121,7 @@ three arguments: @item{a symbol for the primitive procedure that triggered the access check, which is useful for raising an exception to deny access.} - @item{a complete path (see @secref["mz:pathutils"]) representing the + @item{a complete path (see @secref["pathutils"]) representing the file to create as link.} @item{a path representing the content of the link, which may be @@ -143,9 +143,9 @@ security guards. The @scheme[file-guard], @scheme[network-guard], and @scheme[link-guard] procedures are invoked in the thread that called the access-checked primitive. Breaks may or may not be enabled (see -@secref["mz:breakhandler"]). Full continuation jumps are blocked going +@secref["breakhandler"]). Full continuation jumps are blocked going into or out of the @scheme[file-guard] or @scheme[network-guard] call -(see @secref["mz:prompt-model"]).} +(see @secref["prompt-model"]).} @defparam[current-security-guard guard security-guard?]{ diff --git a/collects/scribblings/reference/semaphores.scrbl b/collects/scribblings/reference/semaphores.scrbl index 01c8d0ebfd..bd7aaf3e5e 100644 --- a/collects/scribblings/reference/semaphores.scrbl +++ b/collects/scribblings/reference/semaphores.scrbl @@ -2,7 +2,7 @@ @require[(lib "bnf.ss" "scribble")] @require["mz.ss"] -@title[#:tag "mz:semaphore"]{Semaphores} +@title[#:tag "semaphore"]{Semaphores} A @deftech{semaphore} has an internal counter; when this counter is zero, the semaphore can block a thread's execution (through @@ -18,7 +18,7 @@ semaphore's internal value is non-zero infinitely often, then the thread is eventually unblocked. In addition to its use with semaphore-specific procedures, semaphores -can be used as events; see @secref["mz:sync"]. +can be used as events; see @secref["sync"]. @defproc[(make-semaphore [init nonnegative-exact-integer? 0]) semaphore?]{ @@ -52,7 +52,7 @@ is decremented and @scheme[#t] is returned.} @defproc[(semaphore-wait/enable-break [sema semaphore?]) void?]{Like @scheme[semaphore-wait], but breaking is enabled (see -@secref["mz:breakhandler"]) while waiting on @scheme[sema]. If +@secref["breakhandler"]) while waiting on @scheme[sema]. If breaking is disabled when @scheme[semaphore-wait/enable-break] is called, then either the semaphore's counter is decremented or the @scheme[exn:break] exception is raised, but not both.} @@ -70,7 +70,7 @@ the event does not decrement @scheme[sema]'s internal count.} Waits on @scheme[sema] using @scheme[semaphore-wait], calls @scheme[proc] with all @scheme[arg]s, and then posts to @scheme[sema]. A @tech{continuation barrier} blocks full continuation jumps -into or out of @scheme[proc] (see @secref["mz:prompt-model"]), but +into or out of @scheme[proc] (see @secref["prompt-model"]), but escape jumps are allowed, and @scheme[sema] is posted on escape. If @scheme[try-fail-thunk] is provided and is not @scheme[#f], then @scheme[semaphore-try-wait?] is called on @scheme[sema] instead of diff --git a/collects/scribblings/reference/sequences.scrbl b/collects/scribblings/reference/sequences.scrbl index de7d583f05..16b947ed00 100644 --- a/collects/scribblings/reference/sequences.scrbl +++ b/collects/scribblings/reference/sequences.scrbl @@ -9,31 +9,31 @@ @elem[what] iteration when it appears directly in a @scheme[for] clause.}])] -@title[#:tag "mz:sequences"]{Sequences} +@title[#:tag "sequences"]{Sequences} -@guideintro["guide:sequences"]{sequences} +@guideintro["sequences"]{sequences} A @pidefterm{sequence} encapsulates an ordered stream of values. The elements of a sequence can be extracted with one of the @scheme[for] syntactic forms or with the procedures returned by -@scheme[generate-sequence]. +@scheme[sequence-generate]. The sequence datatype overlaps with many other datatypes. Among built-in datatypes, the sequence datatype includes the following: @itemize{ - @item{lists (see @secref["mz:pairs"])} + @item{lists (see @secref["pairs"])} - @item{vectors (see @secref["mz:vectors"])} + @item{vectors (see @secref["vectors"])} - @item{hash tables (see @secref["mz:hashtables"])} + @item{hash tables (see @secref["hashtables"])} - @item{strings (see @secref["mz:strings"])} + @item{strings (see @secref["strings"])} - @item{byte strings (see @secref["mz:bytestrings"])} + @item{byte strings (see @secref["bytestrings"])} - @item{input ports (see @secref["mz:ports"])} + @item{input ports (see @secref["ports"])} } @@ -179,7 +179,7 @@ The @scheme[thunk] results define the generated elements as follows: @section{Sequence Generators} -@defproc[(generate-sequence [seq sequence?]) (values (-> boolean?) +@defproc[(sequence-generate [seq sequence?]) (values (-> boolean?) (-> any))]{ Returns two thunks to extract elements from the sequence. The first returns @scheme[#t] if more values are available for the sequence. The diff --git a/collects/scribblings/reference/string-input.scrbl b/collects/scribblings/reference/string-input.scrbl index d11abb60d9..4bfdde5b2e 100644 --- a/collects/scribblings/reference/string-input.scrbl +++ b/collects/scribblings/reference/string-input.scrbl @@ -9,7 +9,7 @@ Reads a single character from @scheme[in]---which may involve reading several bytes to UTF-8-decode them into a character (see -@secref["mz:ports"]); a minimal number of bytes are read/peeked to +@secref["ports"]); a minimal number of bytes are read/peeked to perform the decoding. If no bytes are available before an end-of-file, then @scheme[eof] is returned.} @@ -145,10 +145,10 @@ triggered by future reads.) If an error is encountered before any bytes have been read, an exception is raised. When @scheme[in] produces a special value, as described in -@secref["mz:customport"], the result is a procedure of four +@secref["customport"], the result is a procedure of four arguments. The four arguments correspond to the location of the special value within the port, as described in -@secref["mz:customport"]. If the procedure is called more than once +@secref["customport"]. If the procedure is called more than once with valid arguments, the @exnraise[exn:fail:contract]. If @scheme[read-bytes-avail] returns a special-producing procedure, then it does not place characters in @scheme[bstr]. Similarly, @@ -172,7 +172,7 @@ is not reached.} (or/c positive-exact-integer? eof-object? procedure?)]{ Like @scheme[read-bytes-avail!], but breaks are enabled during the -read (see also @secref["mz:breakhandler"]). If breaking is disabled +read (see also @secref["breakhandler"]). If breaking is disabled when @scheme[read-bytes-avail!/enable-break] is called, and if the @scheme[exn:break] exception is raised as a result of the call, then no bytes will have been read from @scheme[in].} @@ -196,10 +196,10 @@ For most kinds of ports, inspecting @scheme[skip-bytes-amt] bytes and @math{@scheme[skip-bytes-amt]+@scheme[amt]} bytes of memory overhead associated with the port, at least until the bytes/characters are read. No such overhead is required when peeking into a string port -(see @secref["mz:stringport"]), a pipe port (see -@secref["mz:pipeports"]), or a custom port with a specific peek +(see @secref["stringport"]), a pipe port (see +@secref["pipeports"]), or a custom port with a specific peek procedure (depending on how the peek procedure is implemented; see -@secref["mz:customport"]). +@secref["customport"]). If a port produces @scheme[eof] mid-stream, peek skips beyond the @scheme[eof] always produce @scheme[eof] until the @scheme[eof] is @@ -284,7 +284,7 @@ with @scheme[skip-bytes-amt] and @scheme[progress] arguments like Like @scheme[read-char], but that if the input port returns a non-byte value (through a value-generating procedure in a custom port; see -@secref["mz:customport"] and @secref["mz:special-comments"] for +@secref["customport"] and @secref["special-comments"] for details), the non-byte value is returned.} @defproc[(read-byte-or-special [in input-port? (current-input-port)]) @@ -338,7 +338,7 @@ ready, it remains ready. If progress events are unavailable for Returns @scheme[#t] if @scheme[port-progress-evt] can return an event for @scheme[in]. All built-in kinds of ports support progress events, but ports created with @scheme[make-input-port] (see -@secref["mz:customport"]) may not.} +@secref["customport"]) may not.} @defproc[(port-commit-peeked [amt nonnegative-exact-integer?] [progress evt?] diff --git a/collects/scribblings/reference/string-output.scrbl b/collects/scribblings/reference/string-output.scrbl index 734c0399bf..dbde410e41 100644 --- a/collects/scribblings/reference/string-output.scrbl +++ b/collects/scribblings/reference/string-output.scrbl @@ -16,6 +16,11 @@ that are the UTF-8 encoding of @scheme[char] are written to Writes a single byte to @scheme[out].} +@defproc[(newline [out output-port? (current-output-port)]) + void?]{ + +The same as @scheme[(write-char #\newline out)].} + @defproc[(write-string [str string?] [out output-port? (current-output-port)] [start-pos nonnegative-exact-integer? 0] @@ -84,7 +89,7 @@ writing and breaks: if breaking is disabled when @scheme[write-bytes-avail/enable-break] is called, and if the @scheme[exn:break] exception is raised as a result of the call, then no bytes will have been written to @scheme[out]. See also -@secref["mz:breakhandler"].} +@secref["breakhandler"].} @defproc[(write-special [v any/c][out output-port? (current-output-port)]) boolean?]{ @@ -108,7 +113,7 @@ is written.} Similar to @scheme[write-bytes-avail], but instead of writing bytes immediately, it returns a synchronizable event (see -@secref["mz:sync"]). The @scheme[out] must support atomic writes, as +@secref["sync"]). The @scheme[out] must support atomic writes, as indicated by @scheme[port-writes-atomic?]. Synchronizing on the object starts a write from @scheme[bstr], and the @@ -123,7 +128,7 @@ bytes will have been written to @scheme[out].} Similar to @scheme[write-special], but instead of writing the special value immediately, it returns a synchronizable event (see -@secref["mz:sync"]). The @scheme[out] must support atomic writes, as +@secref["sync"]). The @scheme[out] must support atomic writes, as indicated by @scheme[port-writes-atomic?]. Synchronizing on the object starts a write of the special value, and @@ -138,7 +143,7 @@ provide an exclusive-or guarantee (break or write, but not both) for @scheme[out], and if the port can be used with procedures like @scheme[write-bytes-avail-evt]. Scheme's file-stream ports, pipes, string ports, and TCP ports all support atomic writes; ports created -with @scheme[make-output-port] (see @secref["mz:customport"]) may +with @scheme[make-output-port] (see @secref["customport"]) may support atomic writes.} @defproc[(port-writes-special? [out output-port?]) boolean?]{ @@ -147,4 +152,4 @@ Returns @scheme[#t] if procedures like @scheme[write-special] can write arbitrary values to the port. Scheme's file-stream ports, pipes, string ports, and TCP ports all reject special values, but ports created with @scheme[make-output-port] (see -@secref["mz:customport"]) may support them.} +@secref["customport"]) may support them.} diff --git a/collects/scribblings/reference/string-ports.scrbl b/collects/scribblings/reference/string-ports.scrbl index 25c9530782..a85a959b5f 100644 --- a/collects/scribblings/reference/string-ports.scrbl +++ b/collects/scribblings/reference/string-ports.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:stringport"]{String Ports} +@title[#:tag "stringport"]{String Ports} String input and output ports do not need to be explicitly closed. The @scheme[file-position] procedure works for string ports in @@ -10,14 +10,14 @@ position-setting mode. @defproc[(open-input-bytes [bstr bytes?][name any/c 'string]) input-port?]{ Creates an input port that reads characters from @scheme[bstr] (see -@secref["mz:bytestrings"]). Modifying @scheme[bstr] afterward does not +@secref["bytestrings"]). Modifying @scheme[bstr] afterward does not affect the byte stream produced by the port. The optional @scheme[name] argument is used as the name for the returned port.} @defproc[(open-input-string [str string?][name any/c 'string]) input-port?]{ Creates an input port that reads bytes from the UTF-8 encoding (see -@secref["mz:encodings"]) of @scheme[str]. The optional @scheme[name] +@secref["encodings"]) of @scheme[str]. The optional @scheme[name] argument is used as the name for the returned port.} @defproc[(open-output-bytes [name any/c 'string]) output-port?]{ diff --git a/collects/scribblings/reference/strings.scrbl b/collects/scribblings/reference/strings.scrbl index e6431ec816..66f7155c22 100644 --- a/collects/scribblings/reference/strings.scrbl +++ b/collects/scribblings/reference/strings.scrbl @@ -1,25 +1,25 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:strings"]{Strings} +@title[#:tag "strings"]{Strings} -@guideintro["guide:strings"]{strings} +@guideintro["strings"]{strings} A @pidefterm{string} is a fixed-length arary of -@seclink["mz:characters"]{characters}. +@seclink["characters"]{characters}. @index['("strings" "immutable")]{A} string can be @defterm{mutable} or @defterm{immutable}. When an immutable string is provided to a procedure like @scheme[string-set!], the @exnraise[exn:fail:contract]. String constants generated by the -default reader (see @secref["mz:parse-string"]) are +default reader (see @secref["parse-string"]) are immutable. Two strings are @scheme[equal?] when they have the same length and contain the same sequence of characters. A string can be used as a single-valued sequence (see -@secref["mz:sequences"]). The characters of the string serve as elements +@secref["sequences"]). The characters of the string serve as elements of the sequence. See also @scheme[in-string]. See also: @scheme[immutable], @scheme[symbol->string], @@ -311,7 +311,7 @@ allocated string).} @defproc[(string-locale=? [str1 string?] [str2 string?] ...+) boolean?]{ Like @scheme[string=?], but the strings are compared in a locale-specific way, based the value of @scheme[current-locale]. See - @secref["mz:encodings"] for more information on locales.} + @secref["encodings"] for more information on locales.} @defproc[(string-localevector [v any/c] [opaque-v any/c '...]) vector?]{ @@ -344,7 +344,7 @@ is inaccessible.)} @scheme[make-struct-field-mutator], @scheme[#f] otherwise.} @;------------------------------------------------------------------------ -@section[#:tag "mz:structinfo"]{Structure Type Transformer Binding} +@section[#:tag "structinfo"]{Structure Type Transformer Binding} The @scheme[define-struct] form binds the name of a structure type as a @tech{transformer binding} that records the other identifiers bound diff --git a/collects/scribblings/reference/stx-certs.scrbl b/collects/scribblings/reference/stx-certs.scrbl index 0e785a0f14..4aa0d89200 100644 --- a/collects/scribblings/reference/stx-certs.scrbl +++ b/collects/scribblings/reference/stx-certs.scrbl @@ -3,12 +3,12 @@ @require-for-syntax[mzscheme] -@title[#:tag "mz:stxcerts"]{Syntax Certificates} +@title[#:tag "stxcerts"]{Syntax Certificates} A @deftech{syntax certificate} combines a @tech{syntax mark} (see -@secref["mz:transformer-model"]), a @tech{module path index} or symbol -module name (see @secref["mz:modpathidx"]), an @tech{inspector} (see -@secref["mz:modprotect"]), and an arbitrary key object. A certificate +@secref["transformer-model"]), a @tech{module path index} or symbol +module name (see @secref["modpathidx"]), an @tech{inspector} (see +@secref["modprotect"]), and an arbitrary key object. A certificate is attached as either an @deftech{active certificate} or an @deftech{inactive certificate}. @@ -26,20 +26,20 @@ The expander generates a certificate when it applies a syntax transformer. The @tech{syntax mark} in the certificate is fresh, the certificate's module reference corresponds to the module that defined the @tech{transformer binding}, the inspector is the inspector for the -module's declaration (see @secref["mz:modprotect"]), and the key +module's declaration (see @secref["modprotect"]), and the key object is hidden. (Applying the result of @scheme[syntax-local-certifier] can introduce certificates with other keys.) The certificate's mark is applied to both the input and output of the syntax transformer, so that it identifies every piece of syntax that was introduced by the transformer (see -@secref["mz:transformer-model"]). The expander attaches this +@secref["transformer-model"]). The expander attaches this certificate to parts of the transformer's result, depending on the shape and properties of the result: @itemize{ @item{If the result has a @indexed-scheme['certify-mode] property - (see @secref["mz:stxprops"]) that is + (see @secref["stxprops"]) that is @indexed-scheme['opaque], then the certificate is attached to the immediate syntax object.} @@ -94,7 +94,7 @@ expansion context: some mark, the identifier's enclosing expressions include a certificate with the mark, the identifier's binding module, and with an inspector that controls the module's invocation (as opposed - to the module's declaration; see again @secref["mz:modprotect"]), + to the module's declaration; see again @secref["modprotect"]), then the access is allowed. To check access to a protected identifier, only the certificate's mark and inspector are used (i.e., the module that bound the transformer is irrelevant, as long diff --git a/collects/scribblings/reference/stx-comp.scrbl b/collects/scribblings/reference/stx-comp.scrbl index 6d915034a0..aa0f56930a 100644 --- a/collects/scribblings/reference/stx-comp.scrbl +++ b/collects/scribblings/reference/stx-comp.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:stxcmp"]{Syntax Object Bindings} +@title[#:tag "stxcmp"]{Syntax Object Bindings} @defproc[(bound-identifier=? [a-id syntax?][b-id syntax?]) boolean?]{ @@ -25,14 +25,21 @@ definition site, not necessarily the @scheme[require] or Returns @scheme[#t] if @scheme[a-id] and @scheme[b-id] access the same lexical, module, or top-level binding at @tech{phase level} 1 (see -@secref["mz:id-model"]).} +@secref["id-model"]).} @defproc[(free-template-identifier=? [a-id syntax?][b-id syntax?]) boolean?]{ Returns @scheme[#t] if @scheme[a-id] and @scheme[b-id] access the same lexical or module binding at @tech{phase level} -1 (see -@secref["mz:id-model"]).} +@secref["id-model"]).} + + +@defproc[(free-label-identifier=? [a-id syntax?][b-id syntax?]) boolean?]{ + +Returns @scheme[#t] if @scheme[a-id] and @scheme[b-id] access the same +lexical or module binding at the @tech{label phase level} (see +@secref["id-model"]).} @defproc[(check-duplicate-identifier [ids (listof identifier?)]) @@ -68,7 +75,7 @@ Returns one of three kinds of values, depending on the binding of @itemize{ @item{@scheme[source-mod] is a module path index or symbol (see - @secref["mz:modpathidx"]) that indicates the defining module.} + @secref["modpathidx"]) that indicates the defining module.} @item{@scheme[source-id] is a symbol for the identifier's name at its definition site in the source module. This can be @@ -79,7 +86,7 @@ Returns one of three kinds of values, depending on the binding of generated by a macro invocation.} @item{@scheme[nominal-source-mod] is a module path index or - symbol (see @secref["mz:modpathidx"]) that indicates the + symbol (see @secref["modpathidx"]) that indicates the module @scheme[require]d into the context of @scheme[id-stx] to provide its binding. It can be different from @scheme[source-mod] due to a re-export in @@ -112,7 +119,7 @@ Returns one of three kinds of values, depending on the binding of Like @scheme[identifier-binding], but that the reported information is for the identifier's binding in @tech{phase level} 1 (see -@secref["mz:id-model"]). +@secref["id-model"]). If the result is @scheme['lexical] for either of @scheme[identifier-binding] or @@ -130,9 +137,25 @@ If the result is @scheme['lexical] for either of Like @scheme[identifier-binding], but that the reported information is for the identifier's binding in @tech{phase level} -1 (see -@secref["mz:id-model"]). +@secref["id-model"]). If the result is @scheme['lexical] for either of @scheme[identifier-binding] or @scheme[identifier-template-binding], then the result is always @scheme['lexical] for both.} + + +@defproc[(identifier-label-binding [id-stx syntax?]) + (or/c false/c + (listof (or/c module-path-index? symbol?) + symbol? + (or/c module-path-index? symbol?) + symbol? + boolean?))]{ + +Like @scheme[identifier-binding], but that the reported information is +for the identifier's binding in the @tech{label phase level} (see +@secref["id-model"]). + +Unlike @scheme[identifier-binding], the result cannot be +@scheme['lexical].} diff --git a/collects/scribblings/reference/stx-expand.scrbl b/collects/scribblings/reference/stx-expand.scrbl index 96b3d6d527..f4d4335796 100644 --- a/collects/scribblings/reference/stx-expand.scrbl +++ b/collects/scribblings/reference/stx-expand.scrbl @@ -1,14 +1,14 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:expansion"]{Expanding Top-Level Forms} +@title[#:tag "expansion"]{Expanding Top-Level Forms} @defproc[(expand [top-level-form any/c]) syntax?]{ Expands all non-primitive syntax in @scheme[top-level-form], and returns a syntax object for the expanded form that contains only core -forms, matching the grammar specified by @secref["mz:fully-expanded"]. +forms, matching the grammar specified by @secref["fully-expanded"]. Before @scheme[top-level-form] is expanded, its lexical context is enriched with @scheme[namespace-syntax-introduce], just as for @@ -64,10 +64,10 @@ be a @tech{syntax object}, and its lexical context is not enriched before expansion.} @;------------------------------------------------------------------------ -@section[#:tag "mz:modinfo"]{Information on Expanded Modules} +@section[#:tag "modinfo"]{Information on Expanded Modules} Information for an expanded @scheme[module] declaration is stored in a -set of @tech{syntax properties} (see @secref["mz:stxprops"]) attached +set of @tech{syntax properties} (see @secref["stxprops"]) attached to the syntax object: @itemize{ @@ -100,7 +100,7 @@ to the syntax object: @item{@scheme[(list* module-path-index _provided-sym _defined-sym)] --- represents a re-exported and possibly re-named variable from the specified module; @scheme[module-path-index] is either a - @tech{module path index} or symbol (see @secref["mz:modpathidx"]), + @tech{module path index} or symbol (see @secref["modpathidx"]), indicating the source module for the binding. The @scheme[_provided-sym] is the external name for the re-export, and @scheme[_defined-sym] is the originally defined name in the module diff --git a/collects/scribblings/reference/stx-ops.scrbl b/collects/scribblings/reference/stx-ops.scrbl index b781e25bad..d9e3b9d6b2 100644 --- a/collects/scribblings/reference/stx-ops.scrbl +++ b/collects/scribblings/reference/stx-ops.scrbl @@ -1,12 +1,12 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:stxops"]{Syntax Object Content} +@title[#:tag "stxops"]{Syntax Object Content} @defproc[(syntax? [v any/c]) boolean?]{ Returns @scheme[#t] if @scheme[v] is a @tech{syntax object}, @scheme[#f] -otherwise. See also @secref["mz:stxobj-model"].} +otherwise. See also @secref["stxobj-model"].} @defproc[(syntax-source [stx syntax?]) any]{ @@ -26,7 +26,7 @@ Returns the line number (positive exact integer) for the start of the syntax object in its source, or @scheme[#f] if the line number or source is unknown. The result is @scheme[#f] if and only if @scheme[(syntax-column stx)] produces @scheme[#f]. See also -@secref["mz:linecol"], and see @scheme[syntax-source] for information +@secref["linecol"], and see @scheme[syntax-source] for information about marshaling compiled syntax objects.} @@ -38,7 +38,7 @@ Returns the column number (non-negative exact integer) for the start of the syntax object in its source, or @scheme[#f] if the source column is unknown. The result is @scheme[#f] if and only if @scheme[(syntax-line stx)] produces @scheme[#f]. See also -@secref["mz:linecol"], and see @scheme[syntax-source] for information +@secref["linecol"], and see @scheme[syntax-source] for information about marshaling compiled syntax objects.} @@ -48,7 +48,7 @@ about marshaling compiled syntax objects.} Returns the character position (positive exact integer) for the start of the syntax object in its source, or @scheme[#f] if the source -position is unknown. See also @secref["mz:linecol"], and see +position is unknown. See also @secref["linecol"], and see @scheme[syntax-source] for information about marshaling compiled syntax objects.} @@ -67,10 +67,10 @@ marshaling compiled syntax objects.} Returns @scheme[#t] if @scheme[stx] has the property that @scheme[read-syntax] and @scheme[read-honu-syntax] attach to the -syntax objects that they generate (see @secref["mz:stxprops"]), and if +syntax objects that they generate (see @secref["stxprops"]), and if @scheme[stx]'s @tech{lexical information} does not indicate that the object was introduced by a syntax transformer (see -@secref["mz:stxobj-model"]). The result is @scheme[#f] otherwise. This +@secref["stxobj-model"]). The result is @scheme[#f] otherwise. This predicate can be used to distinguish syntax objects in an expanded expression that were directly present in the original expression, as opposed to syntax objects inserted by macros.} @@ -79,7 +79,7 @@ opposed to syntax objects inserted by macros.} @defproc[(syntax-source-module [stx syntax?]) (or/c module-path-index? symbol?)]{ -Returns a module path index or symbol (see @secref["mz:modpathidx"]) +Returns a module path index or symbol (see @secref["modpathidx"]) for the module whose source contains @scheme[stx], or @scheme[#f] if @scheme[stx] has no source module.} @@ -112,7 +112,7 @@ A syntax object that is the result of @scheme[read-syntax] reflects the use of delimited @litchar{.} in the input by creating a syntax object for every pair of parentheses in the source, and by creating a pair-valued syntax object @italic{only} for parentheses in the -source. See @secref["mz:parse-pair"] for more information.} +source. See @secref["parse-pair"] for more information.} @defproc[(syntax->list [stx syntax?]) @@ -124,12 +124,17 @@ would produce a list. In other words, @tech{syntax pairs} in @scheme[(syntax-e @scheme[stx])] are flattened.} -@defproc[(syntax->datum [stx syntax?]) any]{ +@defproc[(syntax->datum ...) any]{ Returns a datum by stripping the lexical and source-location information from @scheme[stx]. Graph structure is preserved by the conversion.} +@defproc[(syntax-object->datum [stx syntax?]) any]{ + +FIXME: this entry is a temporary target for references that should be +to @scheme[syntax->datum]. } + @defproc[(datum->syntax [ctxt (or/c syntax? false/c)] [v any/c] @@ -149,8 +154,8 @@ in @scheme[v] are given the lexical context information of @scheme[ctxt] and the source-location information of @scheme[srcloc]. If @scheme[v] is not already a syntax object, then the resulting immediate syntax object it is given the properties (see -@secref["mz:stxprops"]) of @scheme[prop] and the @tech{inactive certificates} -(see @secref["mz:stxcerts"]) of @scheme[cert]. Any of +@secref["stxprops"]) of @scheme[prop] and the @tech{inactive certificates} +(see @secref["stxcerts"]) of @scheme[cert]. Any of @scheme[ctxt], @scheme[srcloc], @scheme[prop], or @scheme[cert] can be @scheme[#f], in which case the resulting syntax has no lexical context, source information, new properties, and/or certificates. @@ -177,6 +182,12 @@ syntax objects in @scheme[v] may be hidden from future applications of @scheme[syntax->datum] and @scheme[syntax-graph?] to the new syntax object.} +@defproc[(datum->syntax-object ...) any]{ + +FIXME: this entry is a temporary target for references that should be +to @scheme[datum->syntax]. } + + @defproc[(syntax-graph? [stx syntax?]) boolean?]{ Returns @scheme[#t] if @scheme[stx] might be preservably shared within diff --git a/collects/scribblings/reference/stx-patterns.scrbl b/collects/scribblings/reference/stx-patterns.scrbl index b9473cc69b..b1320fd5fc 100644 --- a/collects/scribblings/reference/stx-patterns.scrbl +++ b/collects/scribblings/reference/stx-patterns.scrbl @@ -278,7 +278,7 @@ Template forms produce a syntax object as follows: A @scheme[(#,(schemekeywordfont "syntax") template)] form is normally abbreviated as @scheme[#'template]; see also -@secref["mz:parse-quote"]. If @scheme[template] contains no pattern +@secref["parse-quote"]. If @scheme[template] contains no pattern variables, then @scheme[#'template] is equivalent to @scheme[(quote-syntax template)].} @@ -302,7 +302,7 @@ as nested @scheme[quasiquote]s. Also analogous @scheme[quasiquote], the reader converts @litchar{#`} to @scheme[quasisyntax], @litchar{#,} to @scheme[unsyntax], and @litchar["#,@"] to @scheme[unsyntax-splicing]. See also -@secref["mz:parse-quote"].} +@secref["parse-quote"].} diff --git a/collects/scribblings/reference/stx-props.scrbl b/collects/scribblings/reference/stx-props.scrbl index c0b310455a..dd012f4b35 100644 --- a/collects/scribblings/reference/stx-props.scrbl +++ b/collects/scribblings/reference/stx-props.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:stxprops"]{Syntax Object Properties} +@title[#:tag "stxprops"]{Syntax Object Properties} Every syntax object has an associated @deftech{syntax property} list, which can be queried or extended with @@ -29,7 +29,7 @@ automatically adds a property to the original syntax object using the key @indexed-scheme['origin]. If the source syntax has no @scheme['origin] property, it is set to the empty list. Then, still before the merge, the identifier that triggered the macro expansion -(as syntax) is @scheme[cons-immutable]d onto the @scheme['origin] +(as syntax) is @scheme[cons]ed onto the @scheme['origin] property so far. The @scheme['origin] property thus records (in reverse order) the sequence of macro expansions that produced an expanded expression. Usually, the @scheme['origin] value is an @@ -45,7 +45,7 @@ MzScheme adds properties to expanded syntax (often using @itemize{ @item{When a @scheme[begin] form is spliced into a sequence with - internal definitions (see @secref["mz:intdef-body"]), + internal definitions (see @secref["intdef-body"]), @scheme[syntax-track-origin] is applied to every spliced element from the @scheme[begin] body. The second argument to @scheme[syntax-track-origin] is the @scheme[begin] form, and the @@ -54,7 +54,7 @@ MzScheme adds properties to expanded syntax (often using @item{When an internal @scheme[define-values] or @scheme[define-syntaxes] form is converted into a - @scheme[letrec-values+syntaxes] form (see @secref["mz:intdef-body"]), + @scheme[letrec-values+syntaxes] form (see @secref["intdef-body"]), @scheme[syntax-track-origin] is applied to each generated binding clause. The second argument to @scheme[syntax-track-origin] is the converted form, and the third argument is the @scheme[define-values] @@ -78,21 +78,21 @@ MzScheme adds properties to expanded syntax (often using @item{When a reference to an unexported or protected identifier from a module is discovered (and the reference is certified; see - @secref["mz:stxcerts"]), the @indexed-scheme['protected] property is + @secref["stxcerts"]), the @indexed-scheme['protected] property is added to the identifier with a @scheme[#t] value.} @item{When or @scheme[read-syntax] or @scheme[read-honu-syntax] generates a syntax object, it attaches a property to the object (using a private key) to mark the object as originating from a read. The @scheme[syntax-original?] predicate looks for the property - to recognize such syntax objects. (See @secref["mz:stxops"] for more + to recognize such syntax objects. (See @secref["stxops"] for more information.)} } -See @secref["mz:modinfo"] for information about properties generated +See @secref["modinfo"] for information about properties generated by the expansion of a module declaration. See @scheme[lambda] and -@secref["mz:infernames"] for information about properties recognized +@secref["infernames"] for information about properties recognized when compiling a procedure. See @scheme[current-compile] for information on properties and byte codes. @@ -116,7 +116,7 @@ the key @scheme[key], or @scheme[#f] if no value is associated to @defproc[(syntax-property-symbol-keys [stx syntax?]) list?]{ Returns a list of all symbols that as keys have associated properties -in @scheme[stx]. @tech{Uninterned} symbols (see @secref["mz:symbols"]) +in @scheme[stx]. @tech{Uninterned} symbols (see @secref["symbols"]) are not included in the result list.} diff --git a/collects/scribblings/reference/stx-trans.scrbl b/collects/scribblings/reference/stx-trans.scrbl index 0c0516cd77..4fc392701d 100644 --- a/collects/scribblings/reference/stx-trans.scrbl +++ b/collects/scribblings/reference/stx-trans.scrbl @@ -7,7 +7,7 @@ dynamic extent of a @tech{syntax transformer} application by the expander, otherwise the @exnraise[exn:fail:contract].}] -@title[#:tag "mz:stxtrans"]{Syntax Transformers} +@title[#:tag "stxtrans"]{Syntax Transformers} @defproc[(make-set!-transformer [proc (syntax? . -> . syntax?)]) set!-transformer?]{ @@ -109,9 +109,9 @@ added to the expansion result (because the expansion might introduce bindings or references to internal-definition bindings). Expansion of @scheme[stx] can use certificates for the expression -already being expanded (see @secref["mz:stxcerts"]) , and inactive -certificates associated with @scheme[stx] are activated for -@scheme[stx] (see @secref["mz:stxinactivecerts"]). Furthermore, if the +already being expanded (see @secref["stxcerts"]) , and @tech{inactive +certificates} associated with @scheme[stx] are activated for +@scheme[stx] (see @secref["stxcerts"]). Furthermore, if the transformer is defined within a module (i.e., the current expansion was triggered by a use of a module-defined identifier with a @tech{transformer binding}) or if the current expression is being @@ -247,12 +247,12 @@ if not @scheme[#f]. If @scheme[failure-thunk] is @scheme[false], the @exnraise[exn:fail:contract]. Resolving @scheme[id-stx] can use certificates for the expression -being transformed (see @secref["mz:stxcerts"]) as well as inactive -certificates associated with @scheme[id-stx] (see -@secref["mz:stxinactivecerts"]). Furthermore, if the transformer is -defined within a module (i.e., the current transformation was -triggered by a use of a module-defined identifier) or if the current -expression is being expanded for the body of a module, then resolving +being transformed (see @secref["stxcerts"]) as well as @tech{inactive +certificates} associated with @scheme[id-stx] (see +@secref["stxcerts"]). Furthermore, if the transformer is defined +within a module (i.e., the current transformation was triggered by a +use of a module-defined identifier) or if the current expression is +being expanded for the body of a module, then resolving @scheme[id-stx] can access any identifier defined by the module. @transform-time[]} @@ -301,7 +301,7 @@ eventually expanded in an expression context. Returns an inferred name for the expression position being transformed, or @scheme[#f] if no such name is available. See also -@secref["mz:infernames"]. +@secref["infernames"]. @transform-time[]} @@ -311,7 +311,7 @@ transformed, or @scheme[#f] if no such name is available. See also list?)]{ Returns an indication of the context for expansion that triggered a -@tech{syntax transformer} call. See @secref["mz:expand-context-model"] +@tech{syntax transformer} call. See @secref["expand-context-model"] for more information on contexts. The symbol results indicate that the expression is being expanded for @@ -365,14 +365,14 @@ procedure accepts one to three arguments: @scheme[_stx] (required), @scheme[_key] (optional), and @scheme[_intro] (optional). The procedure's result is a syntax object like @scheme[stx], except that it includes the captured certificates as inactive (see -@secref["mz:stxinactivecerts"]) if @scheme[active?] is @scheme[#f] -(the default) or active otherwise. If @scheme[key] is supplied and not -@scheme[#f], it is associated with each captured certificate for later -use through @scheme[syntax-recertify]. If @scheme[_intro] is supplied, -and if it is not @scheme[#f] (the default), then it must be a -procedure created by @scheme[make-syntax-introducer], in which case -the certificate applies only to parts of @scheme[stx] that are marked -as introduced by @scheme[_intro]. +@secref["stxcerts"]) if @scheme[active?] is @scheme[#f] (the default) +or active otherwise. If @scheme[key] is supplied and not @scheme[#f], +it is associated with each captured certificate for later use through +@scheme[syntax-recertify]. If @scheme[_intro] is supplied, and if it +is not @scheme[#f] (the default), then it must be a procedure created +by @scheme[make-syntax-introducer], in which case the certificate +applies only to parts of @scheme[stx] that are marked as introduced by +@scheme[_intro]. Supply @scheme[#t] for @scheme[active?] when the syntax to be certified can be safely used in any context by any party, and where @@ -396,7 +396,7 @@ transformer} application by the expander, @scheme[#f] otherwise.} Produces a syntax object that is like @scheme[stx], except that a @tech{syntax mark} for the current expansion is added (possibly canceling an existing mark in parts of @scheme[stx]). See -@secref["mz:transformer-model"] for information on @tech{syntax +@secref["transformer-model"] for information on @tech{syntax marks}. @transform-time[]} diff --git a/collects/scribblings/reference/subprocess.scrbl b/collects/scribblings/reference/subprocess.scrbl index 3b8c3653dc..32f9261495 100644 --- a/collects/scribblings/reference/subprocess.scrbl +++ b/collects/scribblings/reference/subprocess.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:subprocess"]{Processes} +@title[#:tag "subprocess"]{Processes} @defproc[(subprocess [stdout (or/c output-port? false/c)] [stdin (or/c input-port? false/c)] @@ -18,7 +18,7 @@ Creates a new process in the underlying operating system to execute path to a program executable, and the @scheme[arg]s are command-line arguments for the program. Under Unix and Mac OS X, command-line arguments are passed as byte strings using the current locale's -encoding (see @secref["mz:encodings"]). +encoding (see @secref["encodings"]). Under Windows, the first @scheme[arg] can be @indexed-scheme['exact], which triggers a Windows-specific hack: the second @scheme[arg] is @@ -63,8 +63,8 @@ explicitly closed with @scheme[close-input-port] or @scheme[close-output-port]. The returned ports are @tech{file-stream ports} (see -@secref["mz:file-ports"]), and they are placed into the management of -the current custodian (see @secref["mz:custodians"]). The +@secref["file-ports"]), and they are placed into the management of +the current custodian (see @secref["custodians"]). The @exnraise[exn:fail] when a low-level error prevents the spawning of a process or the creation of operating system pipes for process communication.} diff --git a/collects/scribblings/reference/sync.scrbl b/collects/scribblings/reference/sync.scrbl index ad90ca95f0..590de028bd 100644 --- a/collects/scribblings/reference/sync.scrbl +++ b/collects/scribblings/reference/sync.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:all-sync" #:style 'toc]{Synchronization} +@title[#:tag "all-sync" #:style 'toc]{Synchronization} Scheme's synchronization toolbox spans three layers: diff --git a/collects/scribblings/reference/syntax-model.scrbl b/collects/scribblings/reference/syntax-model.scrbl index 380a15913c..7ab9c60aea 100644 --- a/collects/scribblings/reference/syntax-model.scrbl +++ b/collects/scribblings/reference/syntax-model.scrbl @@ -4,7 +4,7 @@ @require["mz.ss"] @;------------------------------------------------------------------------ -@title[#:tag "mz:syntax-model"]{Syntax Model} +@title[#:tag "syntax-model"]{Syntax Model} The syntax of a Scheme program is defined by @@ -18,7 +18,7 @@ The syntax of a Scheme program is defined by } -For details on the @tech{read} phase, see @secref["mz:reader"]. Source +For details on the @tech{read} phase, see @secref["reader"]. Source code is normally read in @scheme[read-syntax] mode, which produces a @tech{syntax object}. @@ -30,9 +30,9 @@ process, and when the @tech{expansion} process encounters a new binding information. @;------------------------------------------------------------------------ -@section[#:tag "mz:id-model"]{Identifiers and Binding} +@section[#:tag "id-model"]{Identifiers and Binding} -@guideintro["guide:binding"]{binding} +@guideintro["binding"]{binding} An @deftech{identifier} is source-program entity. Parsing (i.e., expanding) a Scheme program reveals that some @tech{identifiers} @@ -72,17 +72,22 @@ variable}. A hyperlinked @tech{identifier} @scheme[cons] is a reference to a specific @tech{top-level variable}. Every binding has a @deftech{phase level} in which it can be -referenced, where a @tech{phase level} corresponds to an -integer. @tech{Phase level} 0 corresponds to the run time of the -enclosing module (or the run time of top-level expression). bindings -in @tech{phase level} 0 constitute the @deftech{base environment}. -@tech{Phase level} 1 corresponds to the time during which the -enclosing module (or top-level expression) is expanded; bindings in -@tech{phase level} 0 constitute the @deftech{transformer environment}. -Phase level -1 corresponds to the run time of a different module for -which the enclosing module is imported for use at @tech{phase level} 1 -(relative to the importing module); bindings in @tech{phase level} -1 -constitute the @deftech{template environment}. +referenced, where a @tech{phase level} normally corresponds to an +integer (but the special @deftech{label phase level} does not +correspond to an integer). @tech{Phase level} 0 corresponds to the +run time of the enclosing module (or the run time of top-level +expression). Bindings in @tech{phase level} 0 constitute the +@deftech{base environment}. @tech{Phase level} 1 corresponds to the +time during which the enclosing module (or top-level expression) is +expanded; bindings in @tech{phase level} 0 constitute the +@deftech{transformer environment}. Phase level -1 corresponds to the +run time of a different module for which the enclosing module is +imported for use at @tech{phase level} 1 (relative to the importing +module); bindings in @tech{phase level} -1 constitute the +@deftech{template environment}. The @tech{label phase level} does not +correspond to any execution time; it is used to track bindings (e.g., +to identifiers within documentation) without implying an execution +dependency. If an identifier has a @tech{local binding}, then it is the same for all phase levels, though the reference is allowed only at a particular @@ -93,7 +98,7 @@ syntax error. If an identifier has a @tech{top-level binding} or different phase levels. @;------------------------------------------------------------------------ -@section[#:tag "mz:stxobj-model"]{Syntax Objects} +@section[#:tag "stxobj-model"]{Syntax Objects} A @deftech{syntax object} combines a simpler Scheme value, such as a symbol or pair, with @deftech{lexical information} about bindings, @@ -153,7 +158,7 @@ information that @scheme[_datum] had when it was parsed as part of the @scheme[quote-syntax] form. @;------------------------------------------------------------------------ -@section[#:tag "mz:expansion"]{Expansion@aux-elem{ (Parsing)}} +@section[#:tag "expansion"]{Expansion@aux-elem{ (Parsing)}} @deftech{Expansion} recursively processes a @tech{syntax object} in a particular phase level, starting with @tech{phase level} 0. @tech{Bindings} @@ -164,15 +169,16 @@ sub-expression is expanded in a deeper phase than the enclosing expression. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:fully-expanded"]{Fully Expanded Programs} +@subsection[#:tag "fully-expanded"]{Fully Expanded Programs} A complete expansion produces a @tech{syntax object} matching the following grammar: @schemegrammar*[ #:literals (#%expression module #%module-begin begin provide + provide-for-syntax provide-for-label define-values define-syntaxes define-values-for-syntax - require require-for-syntax require-for-template + require require-for-syntax require-for-template require-for-label #%plain-lambda case-lambda if begin begin0 let-values letrec-values set! quote-syntax quote with-continuation-mark #%plain-app #%datum #%top #%variable-reference) @@ -183,14 +189,17 @@ following grammar: module-level-form ...)) (begin top-level-form ...)] [module-level-form general-top-level-form - (provide provide-spec ...)] + (provide provide-spec ...) + (provide-for-syntax provide-spec ...) + (provide-for-label provide-spec ...)] [general-top-level-form expr (define-values (id ...) expr) (define-syntaxes (id ...) expr) (define-values-for-syntax (id ...) expr) (require require-spec ...) (require-for-syntax require-spec ...) - (require-for-template require-spec ...)] + (require-for-template require-spec ...) + (require-for-label require-spec ...)] [expr id (#%plain-lambda formals expr ...+) (case-lambda (formals expr ...+) ...) @@ -226,7 +235,7 @@ binding to the @scheme[define-values] of the @schememodname[big] language (i.e., the @tech{identifier} is @scheme[free-identifier=?] to one whose binding is @scheme[define-values]). In all cases, identifiers above typeset as syntactic-form names refer to the -bindings defined in @secref["mz:syntax"]. +bindings defined in @secref["syntax"]. Only @tech{phase levels} 0 and 1 are relevant for the parse of a program (though the @scheme[_datum] in a @scheme[quote-syntax] form @@ -239,7 +248,7 @@ comparisons are made using @scheme[free-transformer-identifier=?] instead of @scheme[free-identifier=?]). @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:expand-steps"]{Expansion Steps} +@subsection[#:tag "expand-steps"]{Expansion Steps} In a recursive expansion, each single step in expanding a @tech{syntax object} at a particular @tech{phase level} depends on the immediate shape of @@ -319,7 +328,7 @@ things: parsing continues.} @item{A core @deftech{syntactic form}, which is parsed as described - for each form in @secref["mz:syntax"]. Parsing a core syntactic + for each form in @secref["syntax"]. Parsing a core syntactic form typically involves recursive parsing of sub-forms, and may introduce @tech{bindings} that determine the parsing of sub-forms.} @@ -327,7 +336,7 @@ things: } @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:expand-context-model"]{Expansion Context} +@subsection[#:tag "expand-context-model"]{Expansion Context} Each expansion step occurs in a particular @deftech{context}, and transformers and core syntactic forms may expand differently for @@ -362,7 +371,7 @@ but it starts parsing the body in an @tech{internal-definition context}. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:intro-binding"]{Introducing Bindings} +@subsection[#:tag "intro-binding"]{Introducing Bindings} @tech{Bindings} are introduced during @tech{expansion} when certain core syntactic forms are encountered: @@ -373,17 +382,25 @@ core syntactic forms are encountered: module level, all lexical information derived from the top level or the specific module's level are extended with bindings from the specified modules, and at the @tech{phase level}s - (normally 0) specified by the exporting modules.} + specified by the exporting modules: @tech{phase level} 0 for + each @scheme[provide], @tech{phase level} 1 for each + @scheme[provide-for-syntax], and the @tech{label phase level} + for each @scheme[provide-for-label].} @item{When a @scheme[require-for-syntax] form is encountered at the top level or module level, it is treated like @scheme[require], - except that the @tech{phase level} for all bindings is incremented by - 1.} + except that only @tech{phase level} 0 exports are imported, + and the resulting bindings are for @tech{phase level} 1.} @item{When a @scheme[require-for-template] form is encountered at the top level or module level, it is treated like @scheme[require], - except that the @tech{phase level} for all bindings is decremented by - 1.} + except that only @tech{phase level} 0 exports are imported, + and the resulting bindings are for @tech{phase level} -1.} + + @item{When a @scheme[require-for-label] form is encountered at the + top level or module level, it is treated like @scheme[require], + except that only @tech{phase level} 0 exports are imported, and + the resulting bindings are for the @tech{label phase level}.} @item{When a @scheme[define], @scheme[define-values], @scheme[define-syntax], or @scheme[define-syntaxes] form is @@ -417,7 +434,7 @@ core syntactic forms are encountered: bindings.} @item{Definitions in @scheme[internal-definition contexts] introduce - bindings as described in @secref["mz:intdef-body"].} + bindings as described in @secref["intdef-body"].} } @@ -439,7 +456,7 @@ binding @scheme[x] and the body @scheme[y] are not @scheme[bound-identifier=?]. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:transformer-model"]{Transformer Bindings} +@subsection[#:tag "transformer-model"]{Transformer Bindings} In a @tech{top-level context} or @tech{module context}, when the expander encounters a @scheme[define-syntaxes] form, the binding that @@ -461,7 +478,7 @@ it used as a @deftech{syntax transformer} (a.k.a. @deftech{macro}). The procedure is expected to accept a syntax object and return a syntax object. A use of the binding (at @tech{phase level} 0) triggers a call of the @tech{syntax transformer} by the expander; see -@secref["mz:expand-steps"]. +@secref["expand-steps"]. Before the expander passes a @tech{syntax object} to a transformer, the @tech{syntax object} is extend with a @deftech{syntax mark} (that @@ -521,12 +538,12 @@ is also specially handled by @scheme[syntax-local-value] as used by In addition to using marks to track introduced identifiers, the expander tracks the expansion history of a form through @tech{syntax -properties} such as @scheme['origin]. See @secref["mz:stxprops"] for +properties} such as @scheme['origin]. See @secref["stxprops"] for more information. Finally, the expander uses @tech{syntax certificates} to control the way that unexported and protected @tech{module bindings} are used. See -@secref["mz:stxcerts"] for more information on @tech{syntax +@secref["stxcerts"] for more information on @tech{syntax certificates}. The expander's handling of @scheme[letrec-values+syntaxes] is similar @@ -542,7 +559,7 @@ is a variable binding at @tech{phase level} 1 (not a @tech{transformer binding} at @tech{phase level} 0). @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:partial-expansion"]{Partial Expansion} +@subsection[#:tag "partial-expansion"]{Partial Expansion} In certain contexts, such as an @tech{internal-definition context} or @tech{module context}, forms are partially expanded to determine @@ -557,10 +574,10 @@ primitive @scheme[#%app], @scheme[#%datum], or @scheme[#%top] form, then expansion stops without adding the identifier. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:intdef-body"]{Internal Definitions} +@subsection[#:tag "intdef-body"]{Internal Definitions} An internal-definition context corresponds to a partial expansion step -(see @secref["mz:partial-expansion"]). A form that supports internal +(see @secref["partial-expansion"]). A form that supports internal definitions starts by expanding its first form in an internal-definition context, but only partially. That is, it recursively expands only until the form becomes one of the following: @@ -605,7 +622,7 @@ If the last expression form turns out to be a @scheme[define-values] or @scheme[define-syntaxes] form, expansion fails with a syntax error. @;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@subsection[#:tag "mz:mod-parse"]{Module Phases} +@subsection[#:tag "mod-parse"]{Module Phases} A @scheme[require] form not only introduces @tech{bindings} at expansion time, but also @deftech{visits} the referenced module when @@ -635,7 +652,7 @@ expansion of the enclosing module, and are kept separate from @tech{top-level context} or from the expansion of a different module. @;------------------------------------------------------------------------ -@section[#:tag "mz:compilation-model"]{Compilation} +@section[#:tag "compilation-model"]{Compilation} Before expanded code is evaluated, it is first @deftech{compiled}. A compiled form has essentially the same information as the @@ -653,7 +670,7 @@ example, the @scheme[eval] procedure takes a syntax object and expands it, compiles it, and evaluates it. @;------------------------------------------------------------------------ -@section[#:tag "mz:namespace-model"]{Namespaces} +@section[#:tag "namespace-model"]{Namespaces} A @deftech{namespace} is a top-level mapping from symbols to binding information. It is the starting point for expanding an expression; a @@ -685,7 +702,7 @@ for all of the imported named, and evaluating a top-level variable (in addition to installing a value into the variable). A namespace also has a @deftech{module registry} that maps module -names to module declarations (see @secref["mz:module-eval-model"]). +names to module declarations (see @secref["module-eval-model"]). This registry is shared by all @tech{phase level}s. For evaluation, each namespace encapsulates a distinct set of @@ -754,7 +771,7 @@ x ] @;------------------------------------------------------------------------ -@section[#:tag "mz:infernames"]{Inferred Value Names} +@section[#:tag "infernames"]{Inferred Value Names} To improve error reporting, names are inferred at compile-time for certain kinds of values, such as procedures. For example, evaluating @@ -782,7 +799,7 @@ the procedure bound to @scheme[my-f] will have the inferred name @scheme['f]. When an @indexed-scheme['inferred-name] property is attached to a -syntax object for an expression (see @secref["mz:stxprops"]), the +syntax object for an expression (see @secref["stxprops"]), the property value is used for naming the expression, and it overrides any name that was inferred from the expression's context. diff --git a/collects/scribblings/reference/syntax.scrbl b/collects/scribblings/reference/syntax.scrbl index 3dfc6b7711..9a947aff2c 100644 --- a/collects/scribblings/reference/syntax.scrbl +++ b/collects/scribblings/reference/syntax.scrbl @@ -3,7 +3,7 @@ @define[cvt (schemefont "CVT")] -@title[#:tag "mz:syntax" #:style 'toc]{Core Syntactic Forms} +@title[#:tag "syntax" #:style 'toc]{Core Syntactic Forms} This section describes the core syntax forms that apear in a fully expanded expression, plus a many closely-related non-core forms. @@ -46,14 +46,14 @@ Within such specifications, @item{A meta-identifier that ends with @scheme[_body] stands for a sub-form that is expanded in an internal-definition context (see - @secref["mz:intdef-body"]).} + @secref["intdef-body"]).} }} } @;------------------------------------------------------------------------ -@section[#:tag "mz:quote"]{Literals: @scheme[quote] and @scheme[#%datum]} +@section[#:tag "quote"]{Literals: @scheme[quote] and @scheme[#%datum]} -@guideintro["guide:quote"]{@scheme[quote]} +@guideintro["quote"]{@scheme[quote]} @defform[(quote datum)]{ @@ -70,7 +70,7 @@ actual representation of the program fragment) without its @defform[(#%datum . datum)]{ -Expands to @scheme[(#,(schemekeywordfont "quote") datum)]. See also @secref["mz:expand-steps"] +Expands to @scheme[(#,(schemekeywordfont "quote") datum)]. See also @secref["expand-steps"] for information on how the expander introduces @schemeidfont{#%datum} identifiers. @@ -81,7 +81,7 @@ identifiers. } @;------------------------------------------------------------------------ -@section[#:tag "mz:#%expression"]{Expression Wrapper: @scheme[#%expression]} +@section[#:tag "#%expression"]{Expression Wrapper: @scheme[#%expression]} @defform[(#%expression expr)]{ @@ -95,12 +95,12 @@ expression. ]} @;------------------------------------------------------------------------ -@section[#:tag "mz:#%top"]{Variable References and @scheme[#%top]} +@section[#:tag "#%top"]{Variable References and @scheme[#%top]} @defform/none[id]{ Refers to a module-level or local binding, when @scheme[id] is -not bound as a transformer (see @secref["mz:expansion"]). At run-time, +not bound as a transformer (see @secref["expansion"]). At run-time, the reference evaluates to the value in the location associated with the binding. @@ -108,7 +108,7 @@ When the expander encounters an @scheme[id] that is not bound by a module-level or local binding, it converts the expression to @scheme[(#, @schemeidfont{#%top} . id)] giving @schemeidfont{#%top} the lexical context of the @scheme[id]; typically, that context refers to -@scheme[#%top]. See also @secref["mz:expand-steps"]. +@scheme[#%top]. See also @secref["expand-steps"]. @examples[ (define x 10) @@ -122,7 +122,7 @@ x Refers to a top-level definition that could bind @scheme[id], even if @scheme[id] has a local binding in its context. Such references are disallowed anywhere within a @scheme[module] form. See also -@secref["mz:expand-steps"] for information on how the expander +@secref["expand-steps"] for information on how the expander introduces @schemeidfont{#%top} identifiers. @examples[ @@ -145,17 +145,17 @@ The result is useful only to low-level extensions; see @secref["inside-mzscheme"].} @;------------------------------------------------------------------------ -@section[#:tag "mz:application"]{Procedure Applications and @scheme[#%app]} +@section[#:tag "application"]{Procedure Applications and @scheme[#%app]} @section-index{evaluation order} -@guideintro["guide:application"]{procedure applications} +@guideintro["application"]{procedure applications} @defform/none[(proc-expr arg ...)]{ Applies a procedure, when @scheme[proc-expr] is not an identifier that has a transformer binding (see -@secref["mz:expansion"]). +@secref["expansion"]). More precisely, the expander converts this form to @scheme[(#, @schemeidfont{#%app} proc-expr arg ...)], giving @schemeidfont{#%app} @@ -163,7 +163,7 @@ the lexical context that is associated with the original form (i.e., the pair that combines @scheme[proc-expr] and its arguments). Typically, the lexical context of the pair indicates the procedure-application @scheme[#%app] that is described next. See also -@secref["mz:expand-steps"]. +@secref["expand-steps"]. @examples[ (+ 1 2) @@ -201,7 +201,7 @@ the @scheme[_keyword]s, and not their positions. The other @scheme[_arg-expr] values, in contrast, are associated with variables according to their order in the application form. -See also @secref["mz:expand-steps"] for information on how the +See also @secref["expand-steps"] for information on how the expander introduces @schemeidfont{#%app} identifiers. @examples[ @@ -215,9 +215,9 @@ Like @scheme[#%app], but without support for keyword arguments. } @;------------------------------------------------------------------------ -@section[#:tag "mz:lambda"]{Procedure Expressions: @scheme[lambda] and @scheme[case-lambda]} +@section[#:tag "lambda"]{Procedure Expressions: @scheme[lambda] and @scheme[case-lambda]} -@guideintro["guide:lambda"]{procedure expressions} +@guideintro["lambda"]{procedure expressions} @defform/subs[(lambda gen-formals body ...+) ([formals (id ...) @@ -328,7 +328,7 @@ the procedure body. When compiling a @scheme[lambda] or @scheme[case-lambda] expression, Scheme looks for a @indexed-scheme['method-arity-error] property -attached to the expression (see @secref["mz:stxprops"]). If it is +attached to the expression (see @secref["stxprops"]). If it is present with a true value, and if no case of the procedure accepts zero arguments, then the procedure is marked so that an @scheme[exn:fail:contract:arity] exception involving the procedure @@ -371,9 +371,9 @@ Like @scheme[lambda], but without support for keyword or optional arguments. } @;------------------------------------------------------------------------ -@section[#:tag "mz:let"]{Local Binding: @scheme[let], @scheme[let*], @scheme[letrec], ...} +@section[#:tag "let"]{Local Binding: @scheme[let], @scheme[let*], @scheme[letrec], ...} -@guideintro["guide:let"]{local binding} +@guideintro["let"]{local binding} @defform*[[(let ([id val-expr] ...) body ...+) (let proc-id ([id init-expr] ...) body ...+)]]{ @@ -479,10 +479,45 @@ and in the @scheme[body]s. (is-odd? 11)) ]} -@;------------------------------------------------------------------------ -@section[#:tag "mz:if"]{Conditionals: @scheme[if], @scheme[cond], @scheme[and], and @scheme[or]} +@defform[(let-syntax ([id trans-expr] ...) body ...+)]{ -@guideintro["guide:conditionals"]{conditionals} +Creates a @tech{transformer binding} (see +@secref["transformer-model"]) of each @scheme[id] with the value of +@scheme[trans-expr], which is an expression at @tech{phase level} 1 +relative to the surrounding context. (See @secref["id-model"] for +information on @tech{phase levels}.) + +Each @scheme[id] is bound in the @scheme[body]s, and not in other +@scheme[trans-expr]s.} + +@defform[(letrec-syntax ([id trans-expr] ...) body ...+)]{ + +Like @scheme[let-syntax], except that each @scheme[id] is also bound +within all @scheme[trans-expr]s.} + +@defform[(let-syntaxes ([(id ...) trans-expr] ...) body ...+)]{ + +Like @scheme[let-syntax], but each @scheme[trans-expr] must produce as +many values as corresponding @scheme[id]s, each of which is bound to +the corresponding value.} + +@defform[(letrec-syntaxes ([(id ...) trans-expr] ...) body ...+)]{ + +Like @scheme[let-syntax], except that each @scheme[id] is also bound +within all @scheme[trans-expr]s.} + +@defform[(letrec-syntaxes+values ([(trans-id ...) trans-expr] ...) + ([(val-id ...) val-expr] ...) + body ...+)]{ + +Combines @scheme[letrec-syntaxes] with @scheme[letrec-values]: each +@scheme[trans-id] and @scheme[val-id] is bound in all +@scheme[trans-expr]s and @scheme[val-expr]s.} + +@;------------------------------------------------------------------------ +@section[#:tag "if"]{Conditionals: @scheme[if], @scheme[cond], @scheme[and], and @scheme[or]} + +@guideintro["conditionals"]{conditionals} @defform[(if test-expr then-expr else-expr)]{ @@ -505,7 +540,7 @@ position with respect to the @scheme[if] form. [test-expr => proc-expr] [test-expr]])]{ -@guideintro["guide:cond"]{@scheme[cond]} +@guideintro["cond"]{@scheme[cond]} A @scheme[cond-clause] that starts with @scheme[else] must be the last @scheme[cond-clause]. @@ -516,7 +551,7 @@ If only a @scheme[[else then-expr ...+]] is present, then the @scheme[then-expr]s are evaluated. The results from all but the last @scheme[then-expr] are ignored. The results of the last @scheme[then-expr], which is in tail position with respect to the -@scheme[cond] form, provides the result for the whole @scheme[cond] +@scheme[cond] form, are the results for the whole @scheme[cond] form. Otherwise, the first @scheme[test-expr] is evaluated. If it produces @@ -556,9 +591,16 @@ returned as the result of the @scheme[cond] form. The [(member 2 '(1 2 3))]) ]} + +@defidform[else]{ + +Recognized special ly withing forms like @scheme[cond]. An +@scheme[else] form as an expression is a syntax error.} + + @defform[(and expr ...)]{ -@guideintro["guide:and+or"]{@scheme[and]} +@guideintro["and+or"]{@scheme[and]} If no @scheme[expr]s are provided, then result is @scheme[#f]. @@ -582,7 +624,7 @@ respect to the original @scheme[and] form. @defform[(or expr ...)]{ -@guideintro["guide:and+or"]{@scheme[or]} +@guideintro["and+or"]{@scheme[or]} If no @scheme[expr]s are provided, then result is @scheme[#t]. @@ -605,9 +647,51 @@ position with respect to the original @scheme[or] form. ]} @;------------------------------------------------------------------------ -@section[#:tag "mz:define"]{Definitions: @scheme[define], @scheme[define-syntax], ...} +@section[#:tag "case"]{Dispatch: @scheme[case]} -@guideintro["guide:define"]{definitions} +@defform/subs[#:literals (else) + (case val-expr case-clause ...) + ([case-clause [(datum ...) then-expr ...+] + [else then-expr ...+]])]{ + +Evaluates @scheme[val-expr] and uses the result to select a +@scheme[case-clause]. The selected clause is the first one with a +@scheme[datum] whose @scheme[quote]d form is @scheme[eqv?] to the +result of @scheme[val-expr]. If no such @scheme[datum] is present, the +@scheme[else] @scheme[case-clause] is selected; if no @scheme[else] +@scheme[case-clause] is present, either, then the result of the +@scheme[case] form is @|void-const|. + +For the selected @scheme[case-clause], the results of the last +@scheme[then-expr], which is in tail position with respect to the +@scheme[cond] form, are the results for the whole @scheme[cond] form. + +A @scheme[case-clause] that starts with @scheme[else] must be the last +@scheme[case-clause]. + +@examples[ +(case (+ 7 5) + [(1 2 3) 'small] + [(10 11 12) 'big]) +(case (- 7 5) + [(1 2 3) 'small] + [(10 11 12) 'big]) +] +@def+int[ +(define (classify c) + (case (char-general-category c) + [(ll lu lt ln lo) "letter"] + [(nd nl no) "number"] + [else "other"])) +(classify #\A) +(classify #\1) +(classify #\!) +]} + +@;------------------------------------------------------------------------ +@section[#:tag "define"]{Definitions: @scheme[define], @scheme[define-syntax], ...} + +@guideintro["define"]{definitions} @defform*/subs[[(define id expr) (define (head args) body ...+)] @@ -680,9 +764,9 @@ z (define-syntax (head args) body ...+)]]{ The first form creates a @tech{transformer binding} (see -@secref["mz:transformer-model"]) of @scheme[id] with the value of +@secref["transformer-model"]) of @scheme[id] with the value of @scheme[expr], which is an expression at @tech{phase level} 1 relative -to the surrounding context. (See @secref["mz:id-model"] for +to the surrounding context. (See @secref["id-model"] for information on @tech{phase levels}.) The second form is a shorthand the same as for @scheme[define]; it @@ -704,7 +788,7 @@ as @scheme[id]s, and each value is bound to the corresponding Like @scheme[define], except that the binding is at @tech{phase level} 1 instead of @tech{phase level} 0 relative to its context. The expression for the binding is also at @tech{phase level} 1. (See -@secref["mz:id-model"] for information on @tech{phase levels}.)} +@secref["id-model"] for information on @tech{phase levels}.)} @defform[(define-values-for-syntax (id ...) expr)]{ @@ -713,9 +797,9 @@ many value as supplied @scheme[id]s, and all of the @scheme[id]s are bound (at @tech{phase level} 1).} @;------------------------------------------------------------------------ -@section[#:tag "mz:begin"]{Sequencing: @scheme[begin], @scheme[begin0], and @scheme[begin-for-syntax]} +@section[#:tag "begin"]{Sequencing: @scheme[begin], @scheme[begin0], and @scheme[begin-for-syntax]} -@guideintro["guide:begin"]{@scheme[begin] and @scheme[begin0]} +@guideintro["begin"]{@scheme[begin] and @scheme[begin0]} @defform*[[(begin form ...) (begin expr ...+)]]{ @@ -762,7 +846,7 @@ in tail position only if no @scheme[body]s are present. Allowed only in a @tech{top-level context} or @tech{module context}. Each @scheme[form] is partially expanded (see -@secref["mz:partial-expansion"]) to determine one of the following +@secref["partial-expansion"]) to determine one of the following classifications: @itemize{ @@ -787,9 +871,9 @@ classifications: } @;------------------------------------------------------------------------ -@section[#:tag "mz:when+unless"]{Guarded Evaluation: @scheme[when] and @scheme[unless]} +@section[#:tag "when+unless"]{Guarded Evaluation: @scheme[when] and @scheme[unless]} -@guideintro["guide:when+unless"]{@scheme[when] and @scheme[unless]} +@guideintro["when+unless"]{@scheme[when] and @scheme[unless]} @defform[(when test-expr expr ...)]{ @@ -819,9 +903,9 @@ Equivalent to @scheme[(when (not test-expr) expr ...)]. ]} @;------------------------------------------------------------------------ -@section[#:tag "mz:set!"]{Assignment: @scheme[set!] and @scheme[set!-values]} +@section[#:tag "set!"]{Assignment: @scheme[set!] and @scheme[set!-values]} -@guideintro["guide:set!"]{@scheme[set!]} +@guideintro["set!"]{@scheme[set!]} @defform[(set! id expr)]{ @@ -880,7 +964,7 @@ binding to an @tech{assignment transformer}.} @include-section["for.scrbl"] @;------------------------------------------------------------------------ -@section[#:tag "mz:wcm"]{Continuation Marks: @scheme[with-continuation-mark]} +@section[#:tag "wcm"]{Continuation Marks: @scheme[with-continuation-mark]} @defform[(with-continuation-mark key-expr val-expr result-expr)]{ @@ -897,10 +981,10 @@ result of the @scheme[resultbody-expr] is the result of the is in tail position for the @scheme[with-continuation-mark] expression). -@moreref["mz:contmarks"]{continuation marks}} +@moreref["contmarks"]{continuation marks}} @;------------------------------------------------------------------------ -@section[#:tag "mz:quasiquote"]{Quasiquoting: @scheme[quasiquote], @scheme[unquote], and @scheme[unquote-splicing]} +@section[#:tag "quasiquote"]{Quasiquoting: @scheme[quasiquote], @scheme[unquote], and @scheme[unquote-splicing]} @defform[(quasiquote datum)]{ @@ -922,7 +1006,7 @@ must appear as the @scheme[car] or a quoted pair. A @scheme[quasiquote], @scheme[unquote], or @scheme[unquote-splicing] form is typically abbreviated with @litchar{`}, @litchar{,}, or -@litchar[",@"], respectively. See also @secref["mz:parse-quote"]. +@litchar[",@"], respectively. See also @secref["parse-quote"]. @examples[ `(0 1 2) @@ -980,7 +1064,7 @@ information} and source-location information attached to } @;------------------------------------------------------------------------ -@section[#:tag "mz:module"]{Modules: @scheme[module], ...} +@section[#:tag "module"]{Modules: @scheme[module], ...} @defform[(module id require-spec form ...)]{ @@ -1010,11 +1094,11 @@ multiple @scheme[form]s are provided, they are wrapped with After such wrapping, if any, and before any expansion, an @indexed-scheme['enclosing-module-name] property is attached to the @schemeidfont{#%module-begin} syntax object (see -@secref["mz:stxprops"]); the property's value is a symbol +@secref["stxprops"]); the property's value is a symbol corresponding to @scheme[id]. Each @scheme[form] is partially expanded (see -@secref["mz:partial-expansion"]) in a @tech{module context}. Further +@secref["partial-expansion"]) in a @tech{module context}. Further action depends on the shape of the form: @itemize{ @@ -1076,7 +1160,7 @@ are evaluated in order as they appear within the module; accessing a @tech{module-level variable} before it is defined signals a run-time error, just like accessing an undefined global variable. -See also @secref["mz:module-eval-model"] and @secref["mz:mod-parse"].} +See also @secref["module-eval-model"] and @secref["mod-parse"].} @defform[(#%module-begin form ...)]{ @@ -1084,7 +1168,7 @@ Legal only in a @tech{module begin context}, and handled by the @scheme[module] form.} @;------------------------------------------------------------------------ -@section[#:tag "mz:require"]{Importing: @scheme[require], @scheme[require-for-syntax], @scheme[require-for-template]} +@section[#:tag "require"]{Importing: @scheme[require], @scheme[require-for-syntax], @scheme[require-for-template]} @section-index["modules" "imports"] @@ -1109,12 +1193,12 @@ Legal only in a @tech{module begin context}, and handled by the (- nat)])]{ In a @tech{top-level context}, @scheme[require] instantiates modules -(see @secref["mz:module-eval-model"]). In a @tech{module context}, -@scheme[require] visits modules (see @secref["mz:mod-parse"]). In both -contexts, @scheme[require] introduces bindings into a @tech{namespace} -or a module (see @secref["mz:intro-binding"]). A @scheme[require] form -in a @tech{expression context} or @tech{internal-definition context} -is a syntax error. +(see @secref["module-eval-model"]). In a @tech{module context}, +@scheme[require] @tech{visits} modules (see @secref["mod-parse"]). In +both contexts, @scheme[require] introduces bindings into a +@tech{namespace} or a module (see @secref["intro-binding"]). A +@scheme[require] form in a @tech{expression context} or +@tech{internal-definition context} is a syntax error. A @scheme[require-spec] designates a particular set of identifiers to be bound in the importing context. Each identifier is mapped to a @@ -1123,7 +1207,7 @@ be different from the symbolic name of the originally exported identifier. @specsubform[module-path]{ Imports all exported bindings from the - named module, using the export identifier as the local identifiers. + named module, using the export identifiers as the local identifiers. (See below for information on @scheme[module-path].)} @specsubform[#:literals (only) (only require-spec id-maybe-renamed ...)]{ @@ -1176,7 +1260,7 @@ corresponds to the default @tech{module name resolver}. least two path elements. All path elements up to the last one form a @tech{collection} path, which is used to locate the relevant directory (not relative to the containing source), and the last path - element refers to a file. See @secref["mz:collects"] for more + element refers to a file. See @secref["collects"] for more information.} @specsubform[#:literals (file) (file string)]{Similar to the plain @@ -1187,27 +1271,35 @@ corresponds to the default @tech{module name resolver}. (planet rel-string (user-string pkg-string vers ...))]{ Specifies a library available via the @PLaneT server.} -No identifier can be bound multiple times by an import, unless all of -the bindings refer to the same original definition in the same module. -In a @tech{module context}, an identifier can be either imported or -defined for a given @tech{phase level}, but not both.} +No identifier can be bound multiple times in a given @tech{phase +level} by an import, unless all of the bindings refer to the same +original definition in the same module. In a @tech{module context}, +an identifier can be either imported or defined for a given +@tech{phase level}, but not both.} @defform[(require-for-syntax require-spec ...)]{ Like @scheme[require], but @tech{instantiate}s a module at phase 1 -(see @secref["mz:module-eval-model"]) in a @tech{top-level context} or +(see @secref["module-eval-model"]) in a @tech{top-level context} or @tech{module context}, and introduces bindings at phase level 1 (see -@secref["mz:intro-binding"] and @secref["mz:mod-parse"]). +@secref["intro-binding"] and @secref["mod-parse"]). } @defform[(require-for-template require-spec ...)]{ Like @scheme[require], but without @tech{instantiation} (see -@secref["mz:module-eval-model"]) in a @tech{top-level context}, and -introduces bindings at phase level -1 (see @secref["mz:intro-binding"] -and @secref["mz:mod-parse"]). +@secref["module-eval-model"]) in a @tech{top-level context}, and +introduces bindings at phase level -1 (see @secref["intro-binding"] +and @secref["mod-parse"]). } +@defform[(require-for-label require-spec ...)]{ Like @scheme[require], +but without implying @tech{instantiation} (see +@secref["module-eval-model"]) at all, and introducing bindings only in +the @tech{label phase level}. Such bindings are accessible via +@scheme[identifier-label-binding] and +@scheme[free-label-identifier=?].} + @;------------------------------------------------------------------------ -@section[#:tag "mz:provide"]{Exporting: @scheme[provide] and @scheme[provide-for-syntax]} +@section[#:tag "provide"]{Exporting: @scheme[provide] and @scheme[provide-for-syntax]} @section-index["modules" "exports"] @@ -1244,7 +1336,7 @@ the symbolic form of the identifier bound within the module: @specsubform[#:literals (all-from) (all-from module-path)]{ Exports all identifiers that are imported into the exporting module at @tech{phase level} 0 using a @scheme[require-spec] built on - @scheme[module-path] (see @secref["mz:require"]). The symbolic name + @scheme[module-path] (see @secref["require"]). The symbolic name for export is derived from the name that is bound within the module, as opposed to the symbolic name of the export from @scheme[module-path].} @@ -1265,7 +1357,7 @@ the symbolic form of the identifier bound within the module: If @scheme[provide] wraps a @scheme[provide-spec], then the exports of the @scheme[provide-spec] are protected; see -@secref["mz:modprotect"]. The @scheme[provide-spec] must +@secref["modprotect"]. The @scheme[provide-spec] must specify only bindings that are defined within the exporting module. Each export specified within a module must have a distinct symbolic @@ -1273,5 +1365,7 @@ export name, though the same binding can be specified with the multiple symbolic names.} @defform[(provide-for-syntax protected-provide-spec ...)]{Like -@scheme[provide], but exports at @tech{phase level} 1 bindings within -the module at @tech{phase level} 1.} +@scheme[provide], but for @tech{phase level} 1.} + +@defform[(provide-for-label protected-provide-spec ...)]{Like +@scheme[provide], but for the @tech{label phase level}.} diff --git a/collects/scribblings/reference/thread-cells.scrbl b/collects/scribblings/reference/thread-cells.scrbl index b1e6c15c90..e311554fb2 100644 --- a/collects/scribblings/reference/thread-cells.scrbl +++ b/collects/scribblings/reference/thread-cells.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:threadcells"]{Thread Cells} +@title[#:tag "threadcells"]{Thread Cells} A @deftech{thread cell} contains a thread-specific value; that is, it contains a specific value for each thread, but it may contain diff --git a/collects/scribblings/reference/thread-groups.scrbl b/collects/scribblings/reference/thread-groups.scrbl index 75d88892ef..8e7839f797 100644 --- a/collects/scribblings/reference/thread-groups.scrbl +++ b/collects/scribblings/reference/thread-groups.scrbl @@ -2,7 +2,7 @@ @require[(lib "bnf.ss" "scribble")] @require["mz.ss"] -@title[#:tag "mz:threadgroups"]{Thread Groups} +@title[#:tag "threadgroups"]{Thread Groups} A @deftech{thread group} is a collection of threads and other thread groups that have equal claim to the CPU. By nesting thread groups and @@ -10,7 +10,7 @@ by creating certain threads within certain groups, a programmer can control the amount of CPU allocated to a set of threads. Every thread belongs to a thread group, which is determined by the @scheme[current-thread-group] parameter when the thread is -created. Thread groups and custodians (see @secref["mz:custodians"]) +created. Thread groups and custodians (see @secref["custodians"]) are independent. The root thread group receives all of the CPU that the operating diff --git a/collects/scribblings/reference/thread-local.scrbl b/collects/scribblings/reference/thread-local.scrbl index 5b0e18d92f..6648132fc6 100644 --- a/collects/scribblings/reference/thread-local.scrbl +++ b/collects/scribblings/reference/thread-local.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:thread-local-storage" #:style 'toc]{Thread-Local Storage} +@title[#:tag "thread-local-storage" #:style 'toc]{Thread-Local Storage} @tech{Thread cells} provides primitive support for thread-local storage. @tech{Parameters} combine thread cells and continuation marks diff --git a/collects/scribblings/reference/threads.scrbl b/collects/scribblings/reference/threads.scrbl index 859b95014d..e9fbef6495 100644 --- a/collects/scribblings/reference/threads.scrbl +++ b/collects/scribblings/reference/threads.scrbl @@ -2,18 +2,18 @@ @require[(lib "bnf.ss" "scribble")] @require["mz.ss"] -@title[#:tag "mz:threads"]{Threads} +@title[#:tag "threads"]{Threads} -See @secref["mz:thread-model"] for basic information on the PLT Scheme +See @secref["thread-model"] for basic information on the PLT Scheme thread model. When a thread is created, it is placed into the management of the @tech{current custodian} and added to the current thread group (see -@secref["mz:threadgroups"]). A thread can have any number of custodian +@secref["threadgroups"]). A thread can have any number of custodian managers added through @scheme[thread-resume]. A thread that has not terminated can be garbage collected (see -@secref["mz:gc-model"]) if it is unreachable and suspended, or if it +@secref["gc-model"]) if it is unreachable and suspended, or if it is unreachable and blocked on a set of unreachable events through @scheme[semaphore-wait] or @scheme[semaphore-wait/enable-break], @scheme[channel-put] or @scheme[channel-get], @scheme[sync] or @@ -30,7 +30,7 @@ thread-safe because they are @defterm{atomic}. For example, to all threads, so that no thread can see a ``half-assigned'' variable. Similarly, @scheme[vector-set!] assigns to a vector atomically. The @scheme[hash-table-put!] procedure is not atomic, but -the table is protected by a lock; see @secref["mz:hashtables"] for more +the table is protected by a lock; see @secref["hashtables"] for more information. Port operations are generally not atomic, but they are thread-safe in the sense that a byte consumed by one thread from an input port will not be returned also to another thread, and procedures @@ -90,7 +90,7 @@ moved to the nested thread. If a break remains queued on the nested thread when it completes, the break is moved to the original thread.} @;------------------------------------------------------------------------ -@section[#:tag "mz:threadkill"]{Suspending, Resuming, and Killing Threads} +@section[#:tag "threadkill"]{Suspending, Resuming, and Killing Threads} @defproc[(thread-suspend [thd thread?]) void?]{ @@ -163,7 +163,7 @@ consumed or not consumed, and other threads can safely use the port.} @index['("threads" "breaking")]{Registers} a break with the specified thread. If breaking is disabled in @scheme[thd], the break will be -ignored until breaks are re-enabled (see @secref["mz:breakhandler"]).} +ignored until breaks are re-enabled (see @secref["breakhandler"]).} @defproc[(sleep [secs nonnegative-number? 0]) void?]{ @@ -185,26 +185,26 @@ Returns @scheme[#t] if @scheme[thd] has terminated, @scheme[#f] otherwise.} @;------------------------------------------------------------------------ -@section[#:tag "mz:threadsync"]{Synchronizing Thread State} +@section[#:tag "threadsync"]{Synchronizing Thread State} @defproc[(thread-wait [thd thread?]) void?]{ Blocks execution of the current thread until @scheme[thd] has terminated. Note that @scheme[(thread-wait (current-thread))] deadlocks the current thread, but a break can end the deadlock (if -breaking is enabled; see @secref["mz:breakhandler"]).} +breaking is enabled; see @secref["breakhandler"]).} @defproc[(thread-dead-evt [thd thread?]) evt?]{ -Returns a @tech{synchronizable event} (see @secref["mz:sync"]) that is +Returns a @tech{synchronizable event} (see @secref["sync"]) that is ready if and only if @scheme[thd] has terminated. Unlike using @scheme[thd] directly, however, a reference to the event does not prevent @scheme[thd] from being garbage collected (see -@secref["mz:gc-model"]).} +@secref["gc-model"]).} @defproc[(thread-resume-evt [thd thread?]) evt?]{ -Returns a @tech{synchronizable event} (see @secref["mz:sync"]) that +Returns a @tech{synchronizable event} (see @secref["sync"]) that becomes ready when @scheme[thd] is running. (If @scheme[thd] has terminated, the event never becomes ready.) If @scheme[thd] runs and is then suspended after a call to @scheme[thread-resume-evt], the @@ -212,11 +212,11 @@ result event remains ready; after each suspend of @scheme[thd] a fresh event is generated to be returned by @scheme[thread-resume-evt]. The result of the event is @scheme[thd], but if @scheme[thd] is never resumed, then reference to the event does not prevent @scheme[thd] -from being garbage collected (see @secref["mz:gc-model"]).} +from being garbage collected (see @secref["gc-model"]).} @defproc[(thread-suspend-evt [thd thread?]) evt?]{ -Returns a @tech{synchronizable event} (see @secref["mz:sync"]) that +Returns a @tech{synchronizable event} (see @secref["sync"]) that becomes ready when @scheme[thd] is suspended. (If @scheme[thd] has terminated, the event will never unblock.) If @scheme[thd] is suspended and then resumes after a call to diff --git a/collects/scribblings/reference/time.scrbl b/collects/scribblings/reference/time.scrbl index b09d1b292e..8bc4265ddc 100644 --- a/collects/scribblings/reference/time.scrbl +++ b/collects/scribblings/reference/time.scrbl @@ -1,7 +1,7 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:time"]{Time} +@title[#:tag "time"]{Time} @defproc[(current-seconds) exact-integer?]{ diff --git a/collects/scribblings/reference/to-do.ss b/collects/scribblings/reference/to-do.ss new file mode 100644 index 0000000000..fb5ccad64b --- /dev/null +++ b/collects/scribblings/reference/to-do.ss @@ -0,0 +1,32 @@ + +(module to-do mzscheme + + (define make-resolved-module-path #f) + (define resolved-module-path? #f) + (define resolved-module-path->path #f) + (define module-path? #f) + + (define call-with-input-file* #f) + (define call-with-output-file* #f) + + (define free-transformer-identifier=? #f) + (define free-template-identifier=? #f) + (define free-label-identifier=? #f) + + (define syntax->datum #f) + (define datum->syntax #f) + + (define-syntax else #f) + (define-syntax _ #f) + + (define list-mutableof #t) + (define list-mutable/c #t) + (define cons-mutable/c #t) + + (define cons? #f) + (define first #f) + (define rest #f) + (define empty? #f) + (define empty #f) + + (provide (all-defined))) diff --git a/collects/scribblings/reference/units.scrbl b/collects/scribblings/reference/units.scrbl index b6830c4b75..50f784a484 100644 --- a/collects/scribblings/reference/units.scrbl +++ b/collects/scribblings/reference/units.scrbl @@ -2,6 +2,7 @@ @require[(all-except "mz.ss" link)] @require[(lib "unit.ss")] @require-for-syntax[mzscheme] +@require-for-label[(lib "unit.ss")] @begin[ (define-syntax defkeywords @@ -22,6 +23,8 @@ @title[#:tag "mzlib:unit" #:style 'toc]{Units} +@declare-exporting[big (lib "big/unit")] + @local-table-of-contents[] @deftech{Units} are used to organize a program into separately @@ -41,7 +44,7 @@ from the linked units for further linking. @; ------------------------------------------------------------------------ -@section[#:tag "mz:creatingunits"]{Creating Units} +@section[#:tag "creatingunits"]{Creating Units} @defform/subs[ #:literals (import export prefix rename only except tag init-depend tag) @@ -226,7 +229,7 @@ This form is allowed only within @scheme[define-signature].} @; ------------------------------------------------------------------------ -@section[#:tag "mz:invokingunits"]{Invoking Units} +@section[#:tag "invokingunits"]{Invoking Units} @defform*[#:literals (import) [(invoke-unit unit-expr) @@ -274,7 +277,7 @@ definition is generated for the context of the @; ------------------------------------------------------------------------ -@section[#:tag "mz:compoundunits"]{Linking Units and Creating Compound Units} +@section[#:tag "compoundunits"]{Linking Units and Creating Compound Units} @defform/subs[ #:literals (: import export link tag) @@ -351,7 +354,7 @@ evaluated.} @; ------------------------------------------------------------------------ -@section[#:tag "mz:linkinference"]{Inferred Linking} +@section[#:tag "linkinference"]{Inferred Linking} @defform[ #:literals (import export) @@ -569,7 +572,7 @@ Like @scheme[unit/new-import-export], but binds static information to @; ------------------------------------------------------------------------ -@section[#:tag "mz:define-sig-form"]{Extending the Syntax of Signatures} +@section[#:tag "define-sig-form"]{Extending the Syntax of Signatures} @defform*[ [(define-signature-form sig-form-id expr) diff --git a/collects/scribblings/reference/unix-paths.scrbl b/collects/scribblings/reference/unix-paths.scrbl index 196981168c..de35095c4a 100644 --- a/collects/scribblings/reference/unix-paths.scrbl +++ b/collects/scribblings/reference/unix-paths.scrbl @@ -2,7 +2,7 @@ @require[(lib "bnf.ss" "scribble")] @require["mz.ss"] -@title[#:tag "mz:unixpaths"]{@|AllUnix| Paths} +@title[#:tag "unixpaths"]{@|AllUnix| Paths} In @|AllUnix| paths, a @litchar{/} separates elements of the path, @litchar{.} as a path element always means the directory indicated by diff --git a/collects/scribblings/reference/values.scrbl b/collects/scribblings/reference/values.scrbl index 5f265cab06..8c466de7e6 100644 --- a/collects/scribblings/reference/values.scrbl +++ b/collects/scribblings/reference/values.scrbl @@ -1,9 +1,9 @@ #reader(lib "docreader.ss" "scribble") @require["mz.ss"] -@title[#:tag "mz:values"]{Multiple Values} +@title[#:tag "values"]{Multiple Values} -See @secref["mz:values-model"] for general information about multiple +See @secref["values-model"] for general information about multiple result values. In addition to @scheme[call-with-values] (described in this section), the @scheme[let-values], @scheme[let*-values], @scheme[letrec-values], and @scheme[define-values] forms (among diff --git a/collects/scribblings/reference/windows-paths.scrbl b/collects/scribblings/reference/windows-paths.scrbl index ea6841df8e..c2c9b96486 100644 --- a/collects/scribblings/reference/windows-paths.scrbl +++ b/collects/scribblings/reference/windows-paths.scrbl @@ -4,7 +4,7 @@ @define[MzAdd (italic "Scheme-specific:")] -@title[#:tag "mz:windowspaths"]{Windows Path Conventions} +@title[#:tag "windowspaths"]{Windows Path Conventions} In general, a Windows pathname consists of an optional drive specifier and a drive-specific path. A Windows path can be @defterm{absolute} diff --git a/collects/scribblings/reference/write.scrbl b/collects/scribblings/reference/write.scrbl index 1bfc702445..c11be89dd8 100644 --- a/collects/scribblings/reference/write.scrbl +++ b/collects/scribblings/reference/write.scrbl @@ -15,7 +15,7 @@ handler associated to it via @scheme[port-write-handler], then the handler is called. Otherwise, the default printer is used (in @scheme[write] mode), as configured by various parameters. -See @secref["mz:printing"] for more information about the default +See @secref["printing"] for more information about the default printer. In particular, note that @scheme[write] may require memory proportional to the depth of the value being printed, due to the initial cycle check.} @@ -30,7 +30,7 @@ associated to it via @scheme[port-display-handler], then the handler is called. Otherwise, the default printer is used (in @scheme[display] mode), as configured by various parameters. -See @secref["mz:printing"] for more information about the default +See @secref["printing"] for more information about the default printer. In particular, note that @scheme[display] may require memory proportional to the depth of the value being printed, due to the initial cycle check.} @@ -138,17 +138,17 @@ A parameter that controls printing values that have no @scheme[read]able form (using the default reader), including structures that have a custom-write procedure (see @scheme[prop:custom-write]); defaults to @scheme[#t]. See -@secref["mz:printing"] for more information.} +@secref["printing"] for more information.} @defboolparam[print-graph on?]{ A parameter that controls printing data with sharing; defaults to -@scheme[#f]. See @secref["mz:printing"] for more information.} +@scheme[#f]. See @secref["printing"] for more information.} @defboolparam[print-struct on?]{ A parameter that controls printing structure values in vector form; -defaults to @scheme[#t]. See @secref["mz:printing"] for more +defaults to @scheme[#t]. See @secref["printing"] for more information. This parameter has no effect on the printing of structures that have a custom-write procedure (see @scheme[prop:custom-write]).} @@ -156,22 +156,22 @@ structures that have a custom-write procedure (see @defboolparam[print-box on?]{ A parameter that controls printing box values; defaults to -@scheme[#t]. See @secref["mz:print-box"] for more information.} +@scheme[#t]. See @secref["print-box"] for more information.} @defboolparam[print-vector-length on?]{ A parameter that controls printing vectors; defaults to -@scheme[#t]. See @secref["mz:print-vectors"] for more information.} +@scheme[#t]. See @secref["print-vectors"] for more information.} @defboolparam[print-hash-table on?]{ A parameter that controls printing hash tables; defaults to -@scheme[#f]. See @secref["mz:print-hashtable"] for more information.} +@scheme[#f]. See @secref["print-hashtable"] for more information.} @defboolparam[print-honu on?]{ A parameter that controls printing values in an alternate syntax. See -@secref["mz:honu"] for more information.} +@secref["honu"] for more information.} @defproc*[([(port-write-handler [out output-port?]) (any/c output-port? . -> . any)] @@ -197,7 +197,7 @@ port. Each handler takes a two arguments: the value to be printed and the destination port. The handler's return value is ignored. The default port display and write handlers print Scheme expressions -with Scheme's built-in printer (see @secref["mz:printing"]). The +with Scheme's built-in printer (see @secref["printing"]). The default print handler calls the global port print handler (the value of the @scheme[global-port-print-handler] parameter); the default global port print handler is the same as the default write handler.} @@ -208,4 +208,4 @@ A parameter that determines @deftech{global port print handler}, which is called by the default port print handler (see @scheme[port-print-handler]) to @scheme[print] values into a port. The default value uses the built-in printer (see -@secref["mz:printing"]) in @scheme[write] mode.} +@secref["printing"]) in @scheme[write] mode.} diff --git a/collects/scribblings/scribble.ss b/collects/scribblings/scribble.ss deleted file mode 100644 index 5a07e5b6a3..0000000000 --- a/collects/scribblings/scribble.ss +++ /dev/null @@ -1,11 +0,0 @@ - -(module scribble mzscheme - (require "to-html.ss" - (prefix scribble: "scribble/scribble.scrbl")) - - (provide build) - - (define (build) - (to-html #t #f - (list scribble:doc ) - (list "scribble")))) diff --git a/collects/scribblings/scribble/basic.scrbl b/collects/scribblings/scribble/basic.scrbl index bce5f6fdc3..aa19fcf11c 100644 --- a/collects/scribblings/scribble/basic.scrbl +++ b/collects/scribblings/scribble/basic.scrbl @@ -96,6 +96,11 @@ removed.} @scheme[pre-flow] list is parsed with @scheme[decode-flow]. } +@defproc[(item? [v any/c]) boolean?]{ + +Returns @scheme[#t] if @scheme[v] is an item produced by +@scheme[item], @scheme[#f] otherwise.} + @defform[(include-section module-path)]{ Requires @scheme[module-path] and returns its @scheme[doc] export (without making any imports visible to the enclosing context). Since this form expands to diff --git a/collects/scribblings/scribble/decode.scrbl b/collects/scribblings/scribble/decode.scrbl index 3d3c94b413..0727542d30 100644 --- a/collects/scribblings/scribble/decode.scrbl +++ b/collects/scribblings/scribble/decode.scrbl @@ -5,7 +5,7 @@ @title[#:tag "decode"]{Text Decoder} The @file{decode.ss} library helps you write document content in a -natural way---more like plain text, except for @elem["@"] escapes. +natural way---more like plain text, except for @litchar["@"] escapes. Roughly, it processes a stream of strings to produces instances of the @file{struct.ss} datatypes (see @secref["struct"]). @@ -34,24 +34,26 @@ special text conversions: Decodes a document, producing a part. In @scheme[lst], instances of @scheme[splice] are inlined into the list. An instance of @scheme[title-decl] supplies the title for the part. Instances of -@scheme[index-section-decl] (that preceed any sub-part) add index -entries that point to the section. Instances of @scheme[part-start] at -level 0 trigger sub-part parsing. Instances of @scheme[section] -trigger are used as-is as subsections, and instances of -@scheme[paragraph] and other flow-element datatypes are used as-is in -the enclosing flow. +@scheme[part-index-decl] (that precede any sub-part) add index entries +that point to the section. Instances of @scheme[part-collect-decl] add +elements to the part that are used only during the @techlink{collect +pass}. Instances of @scheme[part-start] at level 0 trigger sub-part +parsing. Instances of @scheme[section] trigger are used as-is as +subsections, and instances of @scheme[paragraph] and other +flow-element datatypes are used as-is in the enclosing flow. } @defproc[(decode-part [lst list?] - [tag string?] + [tags (listof string?)] [title (or/c false/c list?)] [depth excat-nonnegative-integer?]) part?]{ -Like @scheme[decode], but given a tag for the section, a title (if -@scheme[#f], then a @scheme[title-decl] instance is used if found), -and a depth for @scheme[part-start]s to trigger sub-part parsing. +Like @scheme[decode], but given a list of tag string for the part, a +title (if @scheme[#f], then a @scheme[title-decl] instance is used if +found), and a depth for @scheme[part-start]s to trigger sub-part +parsing. } @@ -90,28 +92,41 @@ otherwise. } -@defstruct[title-decl ([tag any/c] +@defstruct[title-decl ([tag-prefix (or/c false/c string?)] + [tags (listof string?)] + [style any/c] [content list?])]{ -See @scheme[decode] and @scheme[decode-part]. +See @scheme[decode] and @scheme[decode-part]. The @scheme[tag-prefix] +and @scheme[style] fields are propagated to the resulting +@scheme[part]. } @defstruct[part-start ([depth integer?] - [tag (or/c false/c string?)] + [tag-prefix (or/c false/c string?)] + [tags (listof string?)] + [style any/c] [title list?])]{ -See @scheme[decode] and @scheme[decode-part]. +Like @scheme[title-decl], but for a sub-part. See @scheme[decode] and +@scheme[decode-part]. } @defstruct[part-index-decl ([plain-seq (listof string?)] - [content-seq list?])]{ + [entry-seq list?])]{ See @scheme[decode]. The two fields are as for @scheme[index-element]. } +@defstruct[part-collect-decl ([element element?])]{ + +See @scheme[decode]. + +} + @defstruct[splice ([run list?])]{ See @scheme[decode], @scheme[decode-part], and @scheme[decode-flow]. diff --git a/collects/scribblings/scribble/how-to.scrbl b/collects/scribblings/scribble/how-to.scrbl new file mode 100644 index 0000000000..cef9ddadfe --- /dev/null +++ b/collects/scribblings/scribble/how-to.scrbl @@ -0,0 +1,474 @@ +#reader(lib "docreader.ss" "scribble") +@require[(lib "manual.ss" "scribble") + (lib "bnf.ss" "scribble")] +@require["utils.ss"] + +@title{How to Scribble Documentation} + +@;---------------------------------------- +@section[#:tag "getting-started"]{Getting Started} + +To document a collection or @|PLaneT| package: + +@itemize{ + + @item{Create a file in your collection or planet package with the + file extension @file{.scrbl}. The remainder of these + instructions assume that the file is called @file{manual.scrbl}.} + + @item{Start @file{manual.scrbl} like this: +@verbatim[#< . flow-element?)])]{ - -For the @scheme[render] procedure, the first argument corresponds to -the rendering context, the second to the immediately enclosing -section, and the last argument correspond to global information -(possibly psanning multiple documents). +A @techlink{table} has, roughly, a list of list of flows. A cell in +the table can span multiple columns by using @scheme['cont] instead of +a flow in the following columns (i.e., for all but the first in a set +of cells that contain a single flow). } @defstruct[itemization ([flows (listof flow?)])]{ +A @techlink{itemization} has a list of flows. + } @defstruct[blockquote ([style any/c] - [flows (listof flow-element?)])]{ + [paragraphs (listof flow-element?)])]{ + +A @techlink{blockquote} has a style and a list of flow elements. The +@scheme[style] field is normally a string that corresponds to a CSS +class for HTML output. } +@defstruct[delayed-flow-element ([resolve (any/c part? resolve-info? . -> . flow-element?)])]{ + +The @scheme[resolve] procedure is called during the @techlink{resolve +pass} to obtain a normal flow element. The first argument to +@scheme[resolve] is the renderer. + +} + + @defstruct[element ([style any/c] [content list?])]{ +The @scheme[style] field is normally either + +@itemize{ + + @item{a string, which corresponds to a CSS class for HTML output;} + + @item{one of the symbols that all renderers recognize: @scheme['tt], + @scheme['italic], @scheme['bold], @scheme['sf], + @scheme['subscript], @scheme['superscript], or + @scheme['hspace];} + + @item{an instance of @scheme[target-url] to generate a hyperlink; or} + + @item{an instance of @scheme[image-file] to support an inline image.} + } +The @scheme[content] field is a list of @techlink{elements}. + +} + + @defstruct[(target-element element) ([tag tag?])]{ +Declares the content as a hyperlink target for @scheme[tag]. + } + @defstruct[(toc-target-element target-element) ()]{ +Like @scheme[target-element], the content is also a kind of section +label to be shown in the ``on this page'' table for HTML output. + } -@defstruct[(link-element element) ([tag any/c] - [complain-if-fail? boolean?])]{ + +@defstruct[(link-element element) ([tag any/c])]{ + +Hyperlinks the content to @scheme[tag]. } @@ -227,49 +364,69 @@ section, and the last argument correspond to global information [entry-seq list?])]{ The @scheme[plain-seq] specifies the keys for sorting, where the first -element is the main key, the second is a sub-key, etc. The -@scheme[entry-seq] list must have the same length, and it provides the -form of each key to render in the final document. See also -@scheme[index]. + element is the main key, the second is a sub-key, etc. The + @scheme[entry-seq] list must have the same length, and it provides + the form of each key to render in the final document. See also + @scheme[index]. } + @defstruct[(aux-element element) ()]{ Instances of this structure type are intended for use in titles, where -the auxiliary part of the title can be omitted in hyperlinks. See, for -example, @scheme[secref]. + the auxiliary part of the title can be omitted in hyperlinks. See, + for example, @scheme[secref]. } -@defstruct[delayed-element ([render (any/c part? any/c . -> . list?)] +@defstruct[delayed-element ([resolve (any/c part? resolve-info? . -> . list?)] [sizer (-> any/c)] [plain (-> any/c)])]{ The @scheme[render] procedure's arguments are the same as for -@scheme[delayed-flow-element]. Unlike @scheme[delayed-flow-element], -the result of the @scheme[render] procedure's argument is remembered -on the first call. Furthemore, the element can be marshelled (e.g., -for an index entry or a section-title entry) only if it has been -rendered first. + @scheme[delayed-flow-element]. Unlike @scheme[delayed-flow-element], + the result of the @scheme[render] procedure's argument is remembered + on the first call. The @scheme[sizer] field is a procedure that produces a substitute -element for the delayed element for the purposes of determine the -element's width (see @scheme[element-width]). + element for the delayed element for the purposes of determining the + element's width (see @scheme[element-width]). The @scheme[plain] field is a procedure that produces a substitute for -the element when needed before the ``collect'' phase. + the element when needed before the @techlink{collect pass}. } + +@defstruct[(collect-element element) ([collect (collect-info . -> . any)])]{ + +Like @scheme[element], but the @scheme[collect] procedure is called +during the @techlink{collect pass}. The @scheme[collect] procedure +normally calls @scheme[collect-put!]. + +} + + @defstruct[collected-info ([number (listof (or/c false/c integer?))] [parent (or/c false/c part?)] [info any/c])]{ -Computed for each part by the ``collect'' phase. +Computed for each part by the @techlink{collect pass}. } + +@defstruct[target-url ([addr string?])]{ + +Used as a style for an @scheme[element].} + + +@defstruct[image-file ([path path-string?])]{ + +Used as a style for an @scheme[element].} + + @defproc[(flow-element? [v any/c]) boolean?]{ Returns @scheme[#t] if @scheme[v] is a @scheme[paragraph], @@ -281,13 +438,22 @@ Returns @scheme[#t] if @scheme[v] is a @scheme[paragraph], @defproc[(tag? [v any/c]) boolean?]{ -Returns @scheme[#t] if @scheme[v] is acceptable as a link tag, -@scheme[#f], otherwise. Currently, an acceptable tag is either a -string or a list containing a symbol and a string.} +Returns @scheme[#t] if @scheme[v] is acceptable as a link tag, which +is a list containing a symbol and either a string or a +@scheme[generated-tag] instance.} + + +@defstruct[generated-tag ()]{ + +A placeholder for a tag to be generated during the @scheme{collect + pass}. Use @scheme[tag-key] to convert a tag containing a + @scheme[generated-tag] instance to one containing a string. + +} @defproc*[([(content->string (content list?)) string?] - [(content->string (content list?) (p part?) (info any/c)) string?])]{ + [(content->string (content list?) (p part?) (info resolve-info?)) string?])]{ Converts a list of elements to a single string (essentially rendering the content as ``plain text''). @@ -299,7 +465,65 @@ element (if it has not been forced already).} @defproc*[([(element->string (element any/c)) string?] - [(element->string (element any/c) (p part?) (info any/c)) string?])]{ + [(element->string (element any/c) (p part?) (info resolve-info?)) string?])]{ Like @scheme[content->string], but for a single element. } + +@defproc[(element-width (element any/c)) nonnegative-exact-integer?]{ + +Returns the width in characters of the given element.} + + +@defproc[(flow-element-width (e flow-element?)) nonnegative-exact-integer?]{ + +Returns the width in characters of the given flow element.} + +@defstruct[collect-info ([ht any/c] [ext-ht any/c] [parts any/c] [tags any/c] [gen-prefix any/c])]{ + +Encapsulates information accumulated (or being accumulated) from the +@techlink{collect pass}. The fields are exposed, but not currently +intended for external use. + +} + +@defstruct[resolve-info ([ci any/c] [delays any/c] [undef any/c])]{ + +Encapsulates information accumulated (or being accumulated) from the +@techlink{resolve pass}. The fields are exposed, but not currently +intended for external use. + +} + +@defproc[(collect-put! [ci collect-info?] [key any/c] [val any/c]) + void?]{ + +Registers information in @scheme[ci]. This procedure should be called +only during the @techlink{collect pass}. + +} + +@defproc[(resolve-get [ri resolve-info?] [key any/c]) + void?]{ + +Extract information during the @techlink{resolve pass} or +@techlink{render pass} from @scheme[ri], where the information was +previously registered during the @techlink{collect pass}. See also +@secref["passes"]. + +} + +@defproc[(part-collected-info [p part?] + [ri resolve-info?]) + collected-info?]{ + +Returns the information collected for @scheme[p] as recorded within +@scheme[ri]. + +} + +@defproc[(tag-key [t tag?] [ri resolve-info?]) tag?]{ + +Converts a @scheme[generated-tag] value with @scheme[t] to a string. + +} diff --git a/collects/scribblings/scribble/style.scrbl b/collects/scribblings/scribble/style.scrbl index d8f535b8c3..23eb243ef7 100644 --- a/collects/scribblings/scribble/style.scrbl +++ b/collects/scribblings/scribble/style.scrbl @@ -2,12 +2,10 @@ @require[(lib "manual.ss" "scribble")] @require["utils.ss"] -@title[#:tag "reference-style"]{PLT Reference Style Guide} - -@italic{Notes toward an eventual guide chapter...} +@title[#:tag "reference-style"]{Style Guide} In the descriptive body of @scheme[defform], @scheme[defproc], etc., -do not start with ``This...'' Instead, start with a sentence whose +do not start with ``This ...'' Instead, start with a sentence whose implicit subject is the form or value being described. Thus, the description will often start with ``Produces.'' Refer to arguments by name. @@ -20,24 +18,6 @@ expression position within a syntactic form. Use @schemeidfont{body} for a form (definition or expression) in an internal-definition position. -Break up HTML documents into multiple pages by using the @scheme['toc] -section style in combination with -@scheme[local-table-of-contents]. The @scheme[local-table-of-contents] -should go after a short introduction, if any. In some cases, a longer -introduction is better placed after the -@scheme[local-table-of-contents] call, especially if the contents are -short. - -Favor hyperlinks installed by @scheme[scheme] instead of explicit -section links produced by @scheme[secref]. In particular, there's -rarely a need to have both links (e.g., ``see @scheme[scheme] in -@secref["scribble:manual:code"]''). - -Link tags are resolved relative to surrounding sections, but if you -think anyone will ever refer to a link targer, try to pick a tag that -will be globally unique. For example, all of the section tags in the -PLT Scheme reference start with @litchar["mz:"]. - Pay attention to the difference between identifiers and meta-variables when using @scheme[scheme], especially outside of @scheme[defproc] or @scheme[defform]. Prefix a meta-variable with @litchar{_}; for diff --git a/collects/scribblings/scribble/utils.ss b/collects/scribblings/scribble/utils.ss index 0be48cabcf..942aa05c98 100644 --- a/collects/scribblings/scribble/utils.ss +++ b/collects/scribblings/scribble/utils.ss @@ -6,6 +6,23 @@ (prefix scribble: (lib "reader.ss" "scribble")) (lib "string.ss")) + (define-syntax bounce-for-label + (syntax-rules () + [(_ mod) (begin + (require-for-label mod) + (provide-for-label (all-from mod)))] + [(_ mod ...) (begin (bounce-for-label mod) ...)])) + + (bounce-for-label (lib "lang.ss" "big") + (lib "struct.ss" "scribble") + (lib "base-render.ss" "scribble") + (lib "decode.ss" "scribble") + (lib "basic.ss" "scribble") + (lib "manual.ss" "scribble") + (lib "scheme.ss" "scribble") + (lib "eval.ss" "scribble") + (lib "bnf.ss" "scribble")) + (provide scribble-examples litchar/lines) (define (litchar/lines . strs) diff --git a/collects/scribblings/to-html.ss b/collects/scribblings/to-html.ss deleted file mode 100644 index 461a5374b6..0000000000 --- a/collects/scribblings/to-html.ss +++ /dev/null @@ -1,45 +0,0 @@ - -(module to-html mzscheme - (require (lib "dirs.ss" "setup") - (lib "run.ss" "scribble") - (lib "file.ss")) - - (provide to-html) - - (define (to-html multi? core? docs names) - (let ([main-doc-dir (find-doc-dir)] - [dir (collection-path "scribblings")]) - (unless main-doc-dir - (error "cannot find installation doc directory")) - (let ([doc-dir (if multi? - main-doc-dir - (build-path main-doc-dir (car names)))]) - (unless multi? - (make-directory* doc-dir)) - (when multi? - (for-each (lambda (name) - (let ([out-dir (build-path doc-dir name)]) - (when (directory-exists? out-dir) - (delete-directory/files out-dir)))) - names)) - (parameterize ([current-directory dir] - [current-dest-directory doc-dir] - [current-render-mixin (if multi? - multi-html:render-mixin - html:render-mixin)] - [current-info-output-file (if core? - (build-path main-doc-dir - "reference" - "core-info-html.data") - (current-info-output-file))] - [current-info-input-files (append - (if core? - null - (list (build-path main-doc-dir - "reference" - "core-info-html.data"))) - (current-info-input-files))]) - (build-docs docs (if multi? - names - (list "index")))))))) - diff --git a/collects/setup/main-collects.ss b/collects/setup/main-collects.ss index 6cc7eddf96..fdedea4c10 100644 --- a/collects/setup/main-collects.ss +++ b/collects/setup/main-collects.ss @@ -1,74 +1,13 @@ (module main-collects mzscheme - (require "dirs.ss") + (require "dirs.ss" + "path-relativize.ss") (provide path->main-collects-relative main-collects-relative->path) - ;; Historical note: this module is based on the old "plthome.ss" + (define-values (path->main-collects-relative + main-collects-relative->path) + (make-relativize find-collects-dir 'collects + 'path->main-collects-relative + 'main-collects-relative->path))) - ;; The `path->main-collects-relative' and - ;; `main-collects-relative->path' functions are used to store paths - ;; that are relative to the main "collects" directory, such as in - ;; .dep files. This means that if the plt tree is moved, .dep files - ;; still work. It is generally fine if - ;; `path->main-collects-relative' misses some usages, as long as it - ;; works when we prepare a distribution tree. Otherwise, things - ;; will continue to work fine and .dep files will just contain - ;; absolute path names. These functions work on .dep elements: - ;; either a pathname or a pair with a pathname in its cdr; the - ;; `path->main-collects-relative' pathname will itself be a pair. - - ;; We need to compare paths to find when something is in the plt - ;; tree -- this does some basic "normalization" that should work - ;; fine: getting rid of `.' and `..', collapsing multiple - ;; `/'s to one `/', and converting '/'s to '\'s under Windows. - (define (simplify-path* bytes) - (path->bytes (simplify-path (bytes->path bytes)))) - - (define main-collects-dir/ - (delay (let ([dir (find-collects-dir)]) - (and dir (simplify-path* (path->bytes (path->directory-path dir))))))) - - (define (maybe-cdr-op fname f) - (lambda (x) - (cond [(and (pair? x) (not (eq? 'collects (car x)))) - (cons (car x) (f (cdr x)))] - [else (f x)]))) - - ;; path->main-collects-relative* : path-or-bytes -> datum-containing-bytes-or-path - (define (path->main-collects-relative* path) - (let* ([path (cond [(bytes? path) path] - [(path? path) (path->bytes path)] - [else (error 'path->main-collects-relative - "expecting a byte-string, got ~e" path)])] - [path* (simplify-path* path)] - [main-collects-dir/ (force main-collects-dir/)] - [mcd-len (bytes-length main-collects-dir/)]) - (cond [(and path* - mcd-len - (> (bytes-length path*) mcd-len) - (equal? (subbytes path* 0 mcd-len) - main-collects-dir/)) - (cons 'collects (subbytes path* mcd-len))] - [(equal? path* main-collects-dir/) (cons 'collects #"")] - [else path]))) - - ;; main-collects-relative->path* : datum-containing-bytes-or-path -> path - (define (main-collects-relative->path* path) - (cond [(and (pair? path) - (eq? 'collects (car path)) - (bytes? (cdr path))) - (let ([dir (or (find-collects-dir) - ;; No main "collects"? Use original working directory: - (find-system-path 'orig-dir))]) - (if (equal? (cdr path) #"") - dir - (build-path dir (bytes->path (cdr path)))))] - [(bytes? path) (bytes->path path)] - [else path])) - - (define path->main-collects-relative - (maybe-cdr-op 'path->main-collects-relative path->main-collects-relative*)) - (define main-collects-relative->path - (maybe-cdr-op 'main-collects-relative->path main-collects-relative->path*)) - ) diff --git a/collects/setup/main-doc.ss b/collects/setup/main-doc.ss new file mode 100644 index 0000000000..9db119ccce --- /dev/null +++ b/collects/setup/main-doc.ss @@ -0,0 +1,13 @@ +(module main-doc mzscheme + (require "dirs.ss" + "path-relativize.ss") + + (provide path->main-doc-relative + main-doc-relative->path) + + (define-values (path->main-doc-relative + main-doc-relative->path) + (make-relativize find-doc-dir 'doc + 'path->main-doc-relative + 'main-doc-relative->path))) + diff --git a/collects/setup/option-sig.ss b/collects/setup/option-sig.ss index 517d218662..cd577e538e 100644 --- a/collects/setup/option-sig.ss +++ b/collects/setup/option-sig.ss @@ -14,9 +14,12 @@ make-so make-info-domain make-launchers + make-docs call-install + call-post-install pause-on-errors force-unpacks + doc-pdf-dest specific-collections specific-planet-dirs archives diff --git a/collects/setup/option-unit.ss b/collects/setup/option-unit.ss index 593e5a7be7..c347e04a29 100644 --- a/collects/setup/option-unit.ss +++ b/collects/setup/option-unit.ss @@ -19,13 +19,16 @@ (define make-so (make-parameter #f)) (define make-launchers (make-parameter #t)) (define make-info-domain (make-parameter #t)) + (define make-docs (make-parameter #t)) (define call-install (make-parameter #t)) + (define call-post-install (make-parameter #t)) (define pause-on-errors (make-parameter #f)) (define force-unpacks (make-parameter #f)) - + (define doc-pdf-dest (make-parameter #f)) + (define specific-collections (make-parameter null)) (define specific-planet-dirs (make-parameter null)) - + (define archives (make-parameter null)) (define current-target-directory-getter (make-parameter current-directory)) diff --git a/collects/setup/path-relativize.ss b/collects/setup/path-relativize.ss new file mode 100644 index 0000000000..8a56898d5f --- /dev/null +++ b/collects/setup/path-relativize.ss @@ -0,0 +1,75 @@ +(module path-relativize mzscheme + + (provide make-relativize) + + (define (make-relativize find-main-dir + tag + to-rel-name + from-rel-name) + + ;; Historical note: this module is based on the old "plthome.ss" + + ;; The `path->main-collects-relative' and + ;; `main-collects-relative->path' functions are used to store paths + ;; that are relative to the main "collects" directory, such as in + ;; .dep files. This means that if the plt tree is moved, .dep files + ;; still work. It is generally fine if + ;; `path->main-collects-relative' misses some usages, as long as it + ;; works when we prepare a distribution tree. Otherwise, things + ;; will continue to work fine and .dep files will just contain + ;; absolute path names. These functions work on .dep elements: + ;; either a pathname or a pair with a pathname in its cdr; the + ;; `path->main-collects-relative' pathname will itself be a pair. + + ;; We need to compare paths to find when something is in the plt + ;; tree -- this does some basic "normalization" that should work + ;; fine: getting rid of `.' and `..', collapsing multiple + ;; `/'s to one `/', and converting '/'s to '\'s under Windows. + (define (simplify-path* bytes) + (path->bytes (simplify-path (bytes->path bytes)))) + + (define main-collects-dir/ + (delay (let ([dir (find-main-dir)]) + (and dir (simplify-path* (path->bytes (path->directory-path dir))))))) + + (define (maybe-cdr-op fname f) + (lambda (x) + (cond [(and (pair? x) (not (eq? tag (car x)))) + (cons (car x) (f (cdr x)))] + [else (f x)]))) + + ;; path->main-collects-relative* : path-or-bytes -> datum-containing-bytes-or-path + (define (path->main-collects-relative* path) + (let* ([path (cond [(bytes? path) path] + [(path? path) (path->bytes path)] + [else (error 'path->main-collects-relative + "expecting a byte-string, got ~e" path)])] + [path* (simplify-path* path)] + [main-collects-dir/ (force main-collects-dir/)] + [mcd-len (bytes-length main-collects-dir/)]) + (cond [(and path* + mcd-len + (> (bytes-length path*) mcd-len) + (equal? (subbytes path* 0 mcd-len) + main-collects-dir/)) + (cons tag (subbytes path* mcd-len))] + [(equal? path* main-collects-dir/) (cons tag #"")] + [else path]))) + + ;; main-collects-relative->path* : datum-containing-bytes-or-path -> path + (define (main-collects-relative->path* path) + (cond [(and (pair? path) + (eq? tag (car path)) + (bytes? (cdr path))) + (let ([dir (or (find-main-dir) + ;; No main "collects"/"doc"/whatever? Use original working directory: + (find-system-path 'orig-dir))]) + (if (equal? (cdr path) #"") + dir + (build-path dir (bytes->path (cdr path)))))] + [(bytes? path) (bytes->path path)] + [else path])) + + (values + (maybe-cdr-op to-rel-name path->main-collects-relative*) + (maybe-cdr-op from-rel-name main-collects-relative->path*)))) diff --git a/collects/setup/scribble.ss b/collects/setup/scribble.ss new file mode 100644 index 0000000000..8a2d073c77 --- /dev/null +++ b/collects/setup/scribble.ss @@ -0,0 +1,408 @@ + +(module scribble mzscheme + (require (lib "getinfo.ss" "setup") + (lib "dirs.ss" "setup") + (lib "class.ss") + (lib "file.ss") + (lib "main-collects.ss" "setup") + (lib "base-render.ss" "scribble") + (lib "struct.ss" "scribble") + (prefix html: (lib "html-render.ss" "scribble")) + (prefix latex: (lib "latex-render.ss" "scribble"))) + + (provide setup-scribblings + verbose) + + (define verbose (make-parameter #t)) + + (define-struct doc (src-dir src-file dest-dir flags)) + (define-struct info (doc sci provides undef deps + build? time out-time need-run? + need-in-write? need-out-write? + vers rendered?)) + + (define (setup-scribblings only-dirs latex-dest) + (let* ([dirs (find-relevant-directories '(scribblings))] + [infos (map get-info/full dirs)] + [docs (apply + append + (map (lambda (i dir) + (let ([s (i 'scribblings)]) + (if (and (list? s) + (andmap (lambda (v) + (and (list? v) + (<= 1 (length v) 3) + (string? (car v)) + (relative-path? (car v)) + (or (null? (cdr v)) + (and (and (list? (cadr v)) + (andmap (lambda (i) + (member i '(main-doc + multi-page))) + (cadr v))) + (or (null? (cddr v)) + (and (path-string? (caddr v)) + (relative-path? (caddr v)))))))) + s)) + (map (lambda (d) + (let ([flags (if (pair? (cdr d)) + (cadr d) + null)]) + (make-doc dir + (build-path dir (car d)) + (let ([name (if (and (pair? (cdr d)) + (pair? (cddr d)) + (caddr d)) + (cadr d) + (let-values ([(base name dir?) (split-path (car d))]) + (path-replace-suffix name #"")))]) + (if (memq 'main-doc flags) + (build-path (find-doc-dir) name) + (build-path dir "compiled" "doc" name))) + flags))) + s) + (begin + (fprintf (current-error-port) + " bad 'scribblings info: ~e from: ~e\n" + s + dir) + null)))) + infos dirs))]) + (when (ormap (can-build? only-dirs) docs) + (let ([infos (map (get-doc-info only-dirs latex-dest) docs)]) + (let loop ([first? #t][iter 0]) + (let ([ht (make-hash-table 'equal)]) + ;; Collect definitions + (for-each (lambda (info) + (for-each (lambda (k) + (let ([prev (hash-table-get ht k #f)]) + (when (and first? prev) + (fprintf (current-error-port) + "DUPLICATE tag: ~s\n in: ~a\n and: ~a\n" + k + (doc-src-file (info-doc prev)) + (doc-src-file (info-doc info)))) + (hash-table-put! ht k info))) + (info-provides info))) + infos) + ;; Build deps: + (let ([src->info (make-hash-table 'equal)]) + (for-each (lambda (i) + (hash-table-put! src->info (doc-src-file (info-doc i)) i)) + infos) + (for-each (lambda (info) + (when (info-build? info) + (let ([one? #f] + [added? #f] + [deps (make-hash-table)]) + (set-info-deps! info + (map (lambda (d) + (let ([i (if (info? d) + d + (hash-table-get src->info d #f))]) + (or i d))) + (info-deps info))) + (for-each (lambda (d) + (let ([i (if (info? d) + d + (hash-table-get src->info d #f))]) + (if i + (hash-table-put! deps i #t) + (begin + (set! added? #t) + (when (verbose) + (printf " [Removed Dependency: ~a]\n" + (doc-src-file (info-doc info)))))))) + (info-deps info)) + (for-each (lambda (k) + (let ([i (hash-table-get ht k #f)]) + (if i + (when (not (hash-table-get deps i #f)) + (set! added? #t) + (hash-table-put! deps i #t)) + (when first? + (unless one? + (fprintf (current-error-port) + "In ~a:\n" + (doc-src-file (info-doc info))) + (set! one? #t)) + (fprintf (current-error-port) + " undefined tag: ~s\n" + k))))) + (info-undef info)) + (when added? + (when (verbose) + (printf " [Added Dependency: ~a]\n" + (doc-src-file (info-doc info)))) + (set-info-deps! info (hash-table-map deps (lambda (k v) k))) + (set-info-need-run?! info #t))))) + infos)) + ;; If a dependency changed, then we need a re-run: + (for-each (lambda (i) + (unless (or (info-need-run? i) + (not (info-build? i))) + (let ([ch (ormap (lambda (i2) + (and (>= (info-out-time i2) + (info-time i)) + i2)) + (info-deps i))]) + (when ch + (when (verbose) + (printf " [Dependency: ~a\n <- ~a]\n" + (doc-src-file (info-doc i)) + (doc-src-file (info-doc ch)))) + (set-info-need-run?! i #t))))) + infos) + ;; Iterate, if any need to run: + (when (and (ormap info-need-run? infos) + (iter . < . 30)) + ;; Build again, using dependencies + (for-each (lambda (i) + (when (info-need-run? i) + (set-info-need-run?! i #f) + (build-again! latex-dest i))) + infos) + (loop #f (add1 iter))))) + ;; cache info to disk + (unless latex-dest + (for-each (lambda (i) + (when (info-need-in-write? i) + (write-in i))) + infos)))))) + + (define (make-renderer latex-dest doc) + (if latex-dest + (new (latex:render-mixin render%) + [dest-dir latex-dest]) + (new ((if (memq 'multi-page (doc-flags doc)) + html:render-multi-mixin + values) + (html:render-mixin render%)) + [dest-dir (if (memq 'multi-page (doc-flags doc)) + (let-values ([(base name dir?) (split-path (doc-dest-dir doc))]) + base) + (doc-dest-dir doc))]))) + + (define (pick-dest latex-dest doc) + (if latex-dest + (build-path latex-dest (let-values ([(base name dir?) (split-path (doc-src-file doc))]) + (path-replace-suffix name #".tex"))) + (if (memq 'multi-page (doc-flags doc)) + (doc-dest-dir doc) + (build-path (doc-dest-dir doc) "index.html")))) + + (define ((can-build? only-dirs) doc) + (or (not only-dirs) + (ormap (lambda (d) + (let ([d (path->directory-path d)]) + (let loop ([dir (path->directory-path (doc-src-dir doc))]) + (or (equal? dir d) + (let-values ([(base name dir?) (split-path dir)]) + (and (path? base) + (loop base))))))) + only-dirs))) + + (define (ensure-doc-prefix! src-file v) + (let ([p (format "~a" + (path->main-collects-relative src-file))]) + (if (part-tag-prefix v) + (unless (equal? p + (part-tag-prefix v)) + (error 'setup + "bad tag prefix: ~e for: ~a expected: ~e" + (part-tag-prefix v) + src-file + p)) + (set-part-tag-prefix! v p)))) + + (define ((get-doc-info only-dirs latex-dest) doc) + (let ([info-out-file (build-path (or latex-dest (doc-dest-dir doc)) "xref-out.ss")] + [info-in-file (build-path (or latex-dest (doc-dest-dir doc)) "xref-in.ss")] + [out-file (build-path (doc-dest-dir doc) "index.html")] + [src-zo (let-values ([(base name dir?) (split-path (doc-src-file doc))]) + (build-path base "compiled" (path-replace-suffix name ".zo")))] + [renderer (make-renderer latex-dest doc)] + [can-run? ((can-build? only-dirs) doc)]) + (let ([my-time (file-or-directory-modify-seconds out-file #f (lambda () -inf.0))] + [info-out-time (file-or-directory-modify-seconds info-out-file #f (lambda () #f))] + [info-in-time (file-or-directory-modify-seconds info-in-file #f (lambda () #f))] + [vers (send renderer get-serialize-version)]) + (let ([up-to-date? + (and info-out-time + info-in-time + (or (not can-run?) + (my-time + . >= . + (file-or-directory-modify-seconds src-zo #f (lambda () +inf.0)))))]) + (printf " [~a ~a]\n" + (if up-to-date? "Using" "Running") + (doc-src-file doc)) + (if up-to-date? + ;; Load previously calculated info: + (with-handlers ([exn? (lambda (exn) + (fprintf (current-error-port) + "~a\n" + (exn-message exn)) + (delete-file info-out-file) + (delete-file info-in-file) + ((get-doc-info only-dirs latex-dest) doc))]) + (let* ([v-in (with-input-from-file info-in-file read)] + [v-out (with-input-from-file info-out-file read)]) + (unless (and (equal? (car v-in) (list vers (doc-flags doc))) + (equal? (car v-out) (list vers (doc-flags doc)))) + (error "old info has wrong version or flags")) + (make-info doc + (list-ref v-out 1) ; sci + (list-ref v-out 2) ; provides + (list-ref v-in 1) ; undef + (map string->path (list-ref v-in 2)) ; deps, in case we don't need to build... + can-run? + my-time info-out-time #f + #f #f + vers + #f))) + ;; Run the doc once: + (parameterize ([current-directory (doc-src-dir doc)]) + (let ([v (dynamic-require-doc (doc-src-file doc))] + [dest-dir (pick-dest latex-dest doc)]) + (ensure-doc-prefix! (doc-src-file doc) v) + (let* ([ci (send renderer collect (list v) (list dest-dir))]) + (let ([ri (send renderer resolve (list v) (list dest-dir) ci)] + [out-v (and info-out-time + (with-handlers ([exn? (lambda (exn) #f)]) + (let ([v (with-input-from-file info-out-file read)]) + (unless (equal? (car v) (list vers (doc-flags doc))) + (error "old info has wrong version or flags")) + v)))]) + (let ([sci (send renderer serialize-info ri)] + [defs (send renderer get-defined ci)]) + (let ([need-out-write? + (or (not (equal? (list (list vers (doc-flags doc)) sci defs) + out-v)) + (info-out-time . > . (current-seconds)))]) + (when (verbose) + (when need-out-write? + (fprintf (current-error-port) + " [New out ~a]\n" + (doc-src-file doc)))) + (make-info doc + sci + defs + (send renderer get-undefined ri) + null ; no deps, yet + can-run? + -inf.0 + (if need-out-write? + (/ (current-inexact-milliseconds) 1000) + info-out-time) + #t + can-run? need-out-write? + vers + #f)))))))))))) + + (define (build-again! latex-dest info) + (let* ([doc (info-doc info)] + [renderer (make-renderer latex-dest doc)]) + (printf " [R~aendering ~a]\n" + (if (info-rendered? info) + "e-r" + "") + (doc-src-file doc)) + (set-info-rendered?! info #t) + (parameterize ([current-directory (doc-src-dir doc)]) + (let ([v (dynamic-require-doc (doc-src-file doc))] + [dest-dir (pick-dest latex-dest doc)]) + (ensure-doc-prefix! (doc-src-file doc) v) + (let* ([ci (send renderer collect (list v) (list dest-dir))]) + (for-each (lambda (i) + (send renderer deserialize-info (info-sci i) ci)) + (info-deps info)) + (let ([ri (send renderer resolve (list v) (list dest-dir) ci)]) + (let ([sci (send renderer serialize-info ri)] + [defs (send renderer get-defined ci)] + [undef (send renderer get-undefined ri)]) + (let ([in-delta? (not (equal? undef (info-undef info)))] + [out-delta? (not (equal? (list sci defs) + (list (info-sci info) + (info-provides info))))]) + (when (verbose) + (printf " [~a~afor ~a]\n" + (if in-delta? + "New in " + "") + (if out-delta? + "New out " + (if in-delta? + "" + "No change ")) + (doc-src-file doc))) + (when out-delta? + (set-info-out-time! info (/ (current-inexact-milliseconds) 1000))) + (set-info-sci! info sci) + (set-info-provides! info defs) + (set-info-undef! info undef) + (when in-delta? + (set-info-deps! info null)) ; recompute deps outside + (when (or out-delta? + (info-need-out-write? info)) + (unless latex-dest + (write-out info)) + (set-info-need-out-write?! info #f)) + (when in-delta? + (set-info-need-in-write?! info #t)) + (unless latex-dest + (let ([dir (doc-dest-dir doc)]) + (unless (directory-exists? dir) + (make-directory dir)) + (for-each (lambda (f) + (when (regexp-match? #"[.]html$" (path-element->bytes f)) + (delete-file (build-path dir f)))) + (directory-list dir)))) + (send renderer render (list v) (list dest-dir) ri) + (set-info-time! info (/ (current-inexact-milliseconds) 1000)) + (void))))))))) + + (define (dynamic-require-doc path) + ;; Use a separate namespace so that we don't end up with all the documentation + ;; loaded at once. + ;; Use a custodian to compensate for examples executed during the build + ;; that may not be entirely clean (e.g., leaves a stuck thread). + (let ([p (make-namespace)] + [c (make-custodian)] + [ch (make-channel)]) + (parameterize ([current-custodian c]) + (namespace-attach-module (current-namespace) '(lib "base-render.ss" "scribble") p) + (namespace-attach-module (current-namespace) '(lib "html-render.ss" "scribble") p) + (parameterize ([current-namespace p]) + (call-in-nested-thread + (lambda () + (dynamic-require path 'doc))))))) + + (define (write- info name sel) + (let* ([doc (info-doc info)] + [info-file (build-path (doc-dest-dir doc) name)]) + (when (verbose) + (printf " [Caching ~a]\n" info-file)) + (with-output-to-file info-file + (lambda () + (write ((sel (lambda () + (list (list (info-vers info) (doc-flags doc)) + (info-sci info) + (info-provides info))) + (lambda () + (list + (list (info-vers info) (doc-flags doc)) + (info-undef info) + (map (lambda (i) + (path->string (doc-src-file (info-doc i)))) + (info-deps info)))))))) + 'truncate/replace))) + + (define (write-out info) + (make-directory* (doc-dest-dir (info-doc info))) + (write- info "xref-out.ss" (lambda (o i) o))) + (define (write-in info) + (make-directory* (doc-dest-dir (info-doc info))) + (write- info "xref-in.ss" (lambda (o i) i))) + + ) diff --git a/collects/setup/setup-cmdline.ss b/collects/setup/setup-cmdline.ss index 1432e59855..3d7aedf485 100644 --- a/collects/setup/setup-cmdline.ss +++ b/collects/setup/setup-cmdline.ss @@ -38,15 +38,20 @@ (make-zo #f) (call-install #f) (make-launchers #f) - (make-info-domain #f)))] + (make-info-domain #f) + (make-doc #f)))] [("-n" "--no-zo") "Do not produce .zo files" (add-flags '((make-zo #f)))] [("-x" "--no-launcher") "Do not produce launcher programs" (add-flags '((make-launchers #f)))] [("-i" "--no-install") "Do not call collection-specific pre-installers" (add-flags '((call-install #f)))] + [("-I" "--no-post-install") "Do not call collection-specific post-installers" + (add-flags '((call-post-install #f)))] [("-d" "--no-info-domain") "Do not produce info-domain caches" (add-flags '((make-info-domain #f)))] + [("-D" "--no-docs") "Do not produce documentation" + (add-flags '((make-docs #f)))] [("-e" "--extension") "Produce native code extensions" (add-flags '((make-so #t)))] [("-v" "--verbose") "See names of compiled files and info printfs" @@ -66,6 +71,8 @@ (add-flags '((all-users #t)))] [("--mode") mode "Select a compilation mode" (add-flags `((compile-mode ,mode)))] + [("--doc-pdf") dir "Write doc PDF to

" + (add-flags `((doc-pdf-dest ,dir)))] [("-l") => (lambda (flag . collections) (map list collections)) diff --git a/collects/setup/setup-go.ss b/collects/setup/setup-go.ss index 946fd72d42..03ffa32fd8 100644 --- a/collects/setup/setup-go.ss +++ b/collects/setup/setup-go.ss @@ -33,6 +33,7 @@ (all-flags clean make-zo call-install + call-post-install make-launchers make-so verbose @@ -41,7 +42,9 @@ pause-on-errors force-unpacks all-users - compile-mode) + compile-mode + make-docs + doc-pdf-dest) (specific-collections x-specific-collections) (archives x-archives) diff --git a/collects/setup/setup-unit.ss b/collects/setup/setup-unit.ss index 4d56a8e65e..06db49082b 100644 --- a/collects/setup/setup-unit.ss +++ b/collects/setup/setup-unit.ss @@ -9,12 +9,15 @@ (lib "cm.ss") (lib "port.ss") (lib "match.ss") + (lib "process.ss") (lib "planet-archives.ss" "planet") (lib "planet-shared.ss" "planet" "private") "option-sig.ss" (lib "sig.ss" "compiler") (lib "launcher-sig.ss" "launcher") + + (prefix doc: "scribble.ss") "unpack.ss" "getinfo.ss" @@ -22,7 +25,7 @@ "main-collects.ss") (provide setup@) - + (define-unit setup@ (import setup-option^ compiler^ @@ -37,7 +40,7 @@ (define setup-printf (lambda (s . args) (apply setup-fprintf (current-output-port) s args))) - + (setup-printf "Setup version is ~a [~a]" (version) (system-type 'gc)) (setup-printf "Available variants:~a" (apply string-append (map (lambda (s) (format " ~a" s)) @@ -519,7 +522,9 @@ (compiler:option:compile-subcollections #f)) (define (do-install-part part) - (when (or (call-install) (eq? part 'post)) + (when (or (call-install) + (and (eq? part 'post) + (call-post-install))) (for-each (lambda (cc) (let/ec k @@ -636,7 +641,7 @@ (lambda () (make-it ".zos" compile-directory-zos make-namespace)))) (when (make-so) (make-it "extensions" compile-directory-extension current-namespace)) - + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Info-Domain Cache ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -735,6 +740,53 @@ (newline)) 'truncate/replace))))))))) + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Docs ;; + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + (when (make-docs) + (setup-printf "Building documentation") + (doc:verbose (verbose)) + (doc:setup-scribblings (if (and (null? x-specific-collections) + (null? x-specific-planet-dirs)) + #f + (map cc-path ccs-to-compile)) + #f)) + + (when (doc-pdf-dest) + (setup-printf "Building PDF documentation (via pdflatex)") + (unless (directory-exists? (doc-pdf-dest)) + (make-directory (doc-pdf-dest))) + (let ([tmp-dir (build-path (find-system-path 'temp-dir) + (format "pltpdfdoc~a" (current-seconds)))]) + (dynamic-wind + void + (lambda () + (make-directory tmp-dir) + (doc:verbose (verbose)) + (doc:setup-scribblings (if (and (null? x-specific-collections) + (null? x-specific-planet-dirs)) + #f + (map cc-path ccs-to-compile)) + tmp-dir) + (parameterize ([current-directory tmp-dir]) + (for-each (lambda (f) + (when (regexp-match? #rx#"[.]tex$" (path-element->bytes f)) + (let loop ([n 3]) + (unless (zero? n) + (unless (system (format "pdflatex ~a" f)) + (error 'setup-plt "pdflatex failed")) + (loop (sub1 n)))) + (let* ([f (path-replace-suffix f #".pdf")] + [target (build-path (doc-pdf-dest) f)]) + (when (file-exists? target) + (delete-file target)) + (copy-file f target)))) + (directory-list)))) + (lambda () + (when (directory-exists? tmp-dir) + (delete-directory/files tmp-dir)))))) + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Make Launchers ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/collects/syntax/kerncase.ss b/collects/syntax/kerncase.ss index 47ecb02b2e..6afe3a3641 100644 --- a/collects/syntax/kerncase.ss +++ b/collects/syntax/kerncase.ss @@ -20,6 +20,8 @@ define-values define-syntaxes define-values-for-syntax module #%plain-module-begin require provide require-for-syntax require-for-template + require-for-label + provide-for-syntax provide-for-label #%variable-reference))) (if trans? module-transformer-identifier=? module-identifier=?) clause ...))]))) diff --git a/collects/syntax/moddep.ss b/collects/syntax/moddep.ss index 727d62e3b8..93a5cd2bf7 100644 --- a/collects/syntax/moddep.ss +++ b/collects/syntax/moddep.ss @@ -15,7 +15,7 @@ (let loop ([path (resolve-module-path module-path #f)][indent ""][fs ""]) (printf "~a~a~a\n" indent path fs) (let ([code (get-module-code path)]) - (let-values ([(imports fs-imports ft-imports) + (let-values ([(imports fs-imports ft-imports fl-imports) (module-compiled-imports code)]) (define ((mk-loop fs) i) (unless (symbol? i) @@ -24,5 +24,6 @@ fs))) (for-each (mk-loop "") imports) (for-each (mk-loop " [for-syntax]") fs-imports) - (for-each (mk-loop " [for-template]") ft-imports)))))) + (for-each (mk-loop " [for-template]") ft-imports) + (for-each (mk-loop " [for-label]") fl-imports)))))) diff --git a/collects/tests/mzscheme/number.ss b/collects/tests/mzscheme/number.ss index b5e7c5e9b5..b6236e5c05 100644 --- a/collects/tests/mzscheme/number.ss +++ b/collects/tests/mzscheme/number.ss @@ -1466,6 +1466,16 @@ (test (make-rectangular 0 +inf.0) sqrt -inf.0) (test-nan.0 sqrt +nan.0) +;; Complex `sqrt' cases where both z and (magnitude z) are exact: +(test 1414.0 round (* 1000 (real-part (sqrt +4i)))) +(test +1414.0 round (* 1000 (imag-part (sqrt +4i)))) +(test 1414.0 round (* 1000 (real-part (sqrt -4i)))) +(test -1414.0 round (* 1000 (imag-part (sqrt -4i)))) +(test 1155.0 round (* 1000 (real-part (sqrt 1+4/3i)))) +(test +577.0 round (* 1000 (imag-part (sqrt 1+4/3i)))) +(test 1155.0 round (* 1000 (real-part (sqrt 1-4/3i)))) +(test -577.0 round (* 1000 (imag-part (sqrt 1-4/3i)))) + (test (expt 5 13) sqrt (expt 5 26)) (test 545915034.0 round (sqrt (expt 5 25))) (test (make-rectangular 0 (expt 5 13)) sqrt (- (expt 5 26))) diff --git a/collects/tests/mzscheme/optimize.ss b/collects/tests/mzscheme/optimize.ss index d7bf0df803..f5de7a5962 100644 --- a/collects/tests/mzscheme/optimize.ss +++ b/collects/tests/mzscheme/optimize.ss @@ -442,6 +442,10 @@ 5) 5) +(test-comp '(let-values ([() (values)]) + (lambda () x)) + '(lambda () x)) + (test-comp '(letrec-values ([() (values)]) 5) 5) diff --git a/collects/texpict/private/mrpict-extra.ss b/collects/texpict/private/mrpict-extra.ss index 8ea477ad91..10e8239666 100644 --- a/collects/texpict/private/mrpict-extra.ss +++ b/collects/texpict/private/mrpict-extra.ss @@ -185,7 +185,7 @@ [sup? (memq* 'superscript orig-style)]) (let ([s-font (if (or sub? sup?) (extend-font font - (floor (* 2/3 (send font get-point-size))) + (floor (* 6/10 (send font get-point-size))) (send font get-style) (send font get-weight)) font)] diff --git a/doc/release-notes/mzscheme/HISTORY b/doc/release-notes/mzscheme/HISTORY index f7a58db323..a52fe5e19d 100644 --- a/doc/release-notes/mzscheme/HISTORY +++ b/doc/release-notes/mzscheme/HISTORY @@ -1,3 +1,8 @@ +Version 371.2 +Added require-for-label, provide-for-syntax, provide-for-label, + identifier-label-binding, module-label-identifier=? + + Version 371, August 2007 Added hash-table-iterate-{first,next,key,value} Added keywordgenv->module->et_rn_stx); s = scheme_add_rename(s, v); } + if (env->genv->module->dt_rn_stx && !SAME_OBJ(scheme_true, env->genv->module->dt_rn_stx)) { + v = scheme_stx_to_rename(env->genv->module->dt_rn_stx); + s = scheme_add_rename(s, v); + } } else { if (env->genv->rename) s = scheme_add_rename(s, env->genv->rename); if (env->genv->et_rename) s = scheme_add_rename(s, env->genv->et_rename); + if (env->genv->dt_rename) { + s = scheme_add_rename(s, env->genv->dt_rename); + } } } diff --git a/src/mzscheme/src/eval.c b/src/mzscheme/src/eval.c index 747152abae..e9b92e1beb 100644 --- a/src/mzscheme/src/eval.c +++ b/src/mzscheme/src/eval.c @@ -3651,6 +3651,8 @@ static Scheme_Object *add_renames_unless_module(Scheme_Object *form, Scheme_Env form = scheme_add_rename(form, genv->exp_env->rename); if (genv->template_env && genv->template_env->rename) form = scheme_add_rename(form, genv->template_env->rename); + if (genv->dt_rename) + form = scheme_add_rename(form, genv->dt_rename); return form; } @@ -6327,7 +6329,8 @@ scheme_do_eval(Scheme_Object *obj, int num_rands, Scheme_Object **rands, extra = num_rands - n; if (extra) { - Scheme_Object *rest_vals, *pairs; + Scheme_Object *rest_vals; + GC_CAN_IGNORE Scheme_Object *pairs; /* This is a special case: GC may be triggered, but p->runstack does not point at everything that needs @@ -6613,6 +6616,7 @@ scheme_do_eval(Scheme_Object *obj, int num_rands, Scheme_Object **rands, { case scheme_toplevel_type: { + /* Make sure that the GC can ignore tmp: */ #define global_lookup(prefix, _obj, tmp) \ tmp = RUNSTACK[SCHEME_TOPLEVEL_DEPTH(_obj)]; \ tmp = ((Scheme_Object **)tmp)[SCHEME_TOPLEVEL_POS(_obj)]; \ @@ -6747,7 +6751,7 @@ scheme_do_eval(Scheme_Object *obj, int num_rands, Scheme_Object **rands, case scheme_application2_type: { Scheme_App2_Rec *app; - Scheme_Object *arg; + GC_CAN_IGNORE Scheme_Object *arg; short flags; app = (Scheme_App2_Rec *)obj; @@ -6811,7 +6815,7 @@ scheme_do_eval(Scheme_Object *obj, int num_rands, Scheme_Object **rands, case scheme_application3_type: { Scheme_App3_Rec *app; - Scheme_Object *arg; + GC_CAN_IGNORE Scheme_Object *arg; short flags; GC_CAN_IGNORE Scheme_Object *tmpv; @@ -7423,7 +7427,7 @@ Scheme_Object *scheme_eval_compiled_stx_string(Scheme_Object *expr, Scheme_Env * static void *expand_k(void) { Scheme_Thread *p = scheme_current_thread; - Scheme_Object *obj, *certs; + Scheme_Object *obj, *certs, *observer; Scheme_Comp_Env *env; Scheme_Expand_Info erec1; int depth, rename, just_to_top, catch_lifts; @@ -7448,13 +7452,16 @@ static void *expand_k(void) obj = add_renames_unless_module(obj, env->genv); } + observer = scheme_get_expand_observe(); + SCHEME_EXPAND_OBSERVE_START_EXPAND(observer); + /* Loop for lifted expressions: */ while (1) { erec1.comp = 0; erec1.depth = depth; erec1.value_name = scheme_false; erec1.certs = certs; - erec1.observer = scheme_get_expand_observe(); + erec1.observer = observer; if (catch_lifts) scheme_frame_captures_lifts(env, scheme_make_lifted_defn, scheme_sys_wraps(env), scheme_false); diff --git a/src/mzscheme/src/fun.c b/src/mzscheme/src/fun.c index 890959c32d..83e69b87f0 100644 --- a/src/mzscheme/src/fun.c +++ b/src/mzscheme/src/fun.c @@ -133,6 +133,7 @@ static Scheme_Object *seconds_to_date(int argc, Scheme_Object **argv); static Scheme_Object *object_name(int argc, Scheme_Object *argv[]); static Scheme_Object *procedure_arity(int argc, Scheme_Object *argv[]); static Scheme_Object *procedure_arity_includes(int argc, Scheme_Object *argv[]); +static Scheme_Object *procedure_reduce_arity(int argc, Scheme_Object *argv[]); static Scheme_Object *procedure_equal_closure_p(int argc, Scheme_Object *argv[]); static Scheme_Object *primitive_p(int argc, Scheme_Object *argv[]); static Scheme_Object *primitive_closure_p(int argc, Scheme_Object *argv[]); @@ -465,6 +466,11 @@ scheme_init_fun (Scheme_Env *env) "procedure-arity-includes?", 2, 2, 1), env); + scheme_add_global_constant("procedure-reduce-arity", + scheme_make_prim_w_arity(procedure_reduce_arity, + "procedure-reduce_arity", + 2, 2), + env); scheme_add_global_constant("procedure-closure-contents-eq?", scheme_make_folding_prim(procedure_equal_closure_p, "procedure-closure-contents-eq?", @@ -3104,6 +3110,14 @@ static Scheme_Object *procedure_arity_includes(int argc, Scheme_Object *argv[]) return scheme_get_or_check_arity(argv[0], n); } +static Scheme_Object *procedure_reduce_arity(int argc, Scheme_Object *argv[]) +{ + if (!SCHEME_PROCP(argv[0])) + scheme_wrong_type("procedure-reduce-arity", "procedure", 0, argc, argv); + + return argv[0]; +} + static Scheme_Object *procedure_equal_closure_p(int argc, Scheme_Object *argv[]) { Scheme_Object *v1 = argv[0], *v2 = argv[1]; diff --git a/src/mzscheme/src/module.c b/src/mzscheme/src/module.c index 986349bf1a..74d7b260b5 100644 --- a/src/mzscheme/src/module.c +++ b/src/mzscheme/src/module.c @@ -67,6 +67,8 @@ static Scheme_Object *require_for_syntax_syntax(Scheme_Object *form, Scheme_Comp static Scheme_Object *require_for_syntax_expand(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Expand_Info *erec, int drec); static Scheme_Object *require_for_template_syntax(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Compile_Info *rec, int drec); static Scheme_Object *require_for_template_expand(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Expand_Info *erec, int drec); +static Scheme_Object *require_for_label_syntax(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Compile_Info *rec, int drec); +static Scheme_Object *require_for_label_expand(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Expand_Info *erec, int drec); static Scheme_Object *provide_syntax(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Compile_Info *rec, int drec); static Scheme_Object *provide_expand(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Expand_Info *erec, int drec); @@ -138,7 +140,10 @@ static Scheme_Object *define_for_syntaxes_stx; static Scheme_Object *require_stx; static Scheme_Object *require_for_syntax_stx; static Scheme_Object *require_for_template_stx; +static Scheme_Object *require_for_label_stx; static Scheme_Object *provide_stx; +static Scheme_Object *provide_for_syntax_stx; +static Scheme_Object *provide_for_label_stx; static Scheme_Object *set_stx; static Scheme_Object *app_stx; Scheme_Object *scheme_top_stx; @@ -181,10 +186,27 @@ static Scheme_Object *parse_requires(Scheme_Object *form, Scheme_Object *base_modidx, Scheme_Env *env, Scheme_Object *rn, Scheme_Object *post_ex_rn, - Check_Func ck, void *data, + Scheme_Object *et_rn, Scheme_Object *et_post_ex_rn, + Scheme_Object *dt_rn, Scheme_Object *dt_post_ex_rn, + Check_Func ck, void *data, void *et_data, void *dt_data, int start, int expstart, Scheme_Object *redef_modname, int unpack_kern, int copy_vars, int can_save_marshal, int *all_simple); +static Scheme_Object *parse_provides(Scheme_Object *form, Scheme_Object *fst, Scheme_Object *e, + Scheme_Hash_Table *provided, Scheme_Object *reprovided, + Scheme_Object *self_modidx, + Scheme_Object **_all_defs_out); +static int compute_reprovides(Scheme_Hash_Table *provided, Scheme_Object *reprovided, + Scheme_Object *requires, Scheme_Hash_Table *required, + Scheme_Env *genv, Scheme_Object *all_defs, Scheme_Object *all_defs_out, + Scheme_Object **_exclude_hint, + const char *matching_form); +static char *compute_provide_arrays(Scheme_Hash_Table *provided, Scheme_Hash_Table *required, + Scheme_Module_Phase_Exports *pt, + Scheme_Env *genv, int def_phase, + int reprovide_kernel, + Scheme_Object *form, + const char *def_way); static void start_module(Scheme_Module *m, Scheme_Env *env, int restart, Scheme_Object *syntax_idx, int delay_exptime, int with_tt, Scheme_Object *cycle_list); static void expstart_module(Scheme_Module *m, Scheme_Env *env, int restart, Scheme_Object *syntax_idx, int delay_exptime, int with_tt, Scheme_Object *cycle_list); static void finish_expstart_module(Scheme_Env *menv, Scheme_Env *env, int with_tt, Scheme_Object *cycle_list); @@ -245,10 +267,22 @@ void scheme_init_module(Scheme_Env *env) scheme_make_compiled_syntax(require_for_template_syntax, require_for_template_expand), env); + scheme_add_global_keyword("require-for-label", + scheme_make_compiled_syntax(require_for_label_syntax, + require_for_label_expand), + env); scheme_add_global_keyword("provide", scheme_make_compiled_syntax(provide_syntax, provide_expand), env); + scheme_add_global_keyword("provide-for-syntax", + scheme_make_compiled_syntax(provide_syntax, + provide_expand), + env); + scheme_add_global_keyword("provide-for-label", + scheme_make_compiled_syntax(provide_syntax, + provide_expand), + env); REGISTER_SO(kernel_symbol); kernel_symbol = scheme_intern_symbol("#%kernel"); @@ -404,6 +438,7 @@ void scheme_finish_kernel(Scheme_Env *env) kernel->requires = scheme_null; kernel->et_requires = scheme_null; kernel->tt_requires = scheme_null; + kernel->dt_requires = scheme_null; kernel->insp = insp; @@ -452,18 +487,18 @@ void scheme_finish_kernel(Scheme_Env *env) kernel->me = me; } - kernel->me->provides = exs; - kernel->me->provide_srcs = NULL; - kernel->me->provide_src_names = exs; - kernel->me->num_provides = count; - kernel->me->num_var_provides = syntax_start; + kernel->me->rt->provides = exs; + kernel->me->rt->provide_srcs = NULL; + kernel->me->rt->provide_src_names = exs; + kernel->me->rt->num_provides = count; + kernel->me->rt->num_var_provides = syntax_start; scheme_initial_env->running = 1; scheme_initial_env->et_running = 1; scheme_initial_env->attached = 1; rn = scheme_make_module_rename(0, mzMOD_RENAME_NORMAL, NULL); - for (i = kernel->me->num_provides; i--; ) { + for (i = kernel->me->rt->num_provides; i--; ) { scheme_extend_module_rename(rn, kernel_symbol, exs[i], exs[i], kernel_symbol, exs[i], 0, 0); } @@ -477,7 +512,10 @@ void scheme_finish_kernel(Scheme_Env *env) REGISTER_SO(require_stx); REGISTER_SO(require_for_syntax_stx); REGISTER_SO(require_for_template_stx); + REGISTER_SO(require_for_label_stx); REGISTER_SO(provide_stx); + REGISTER_SO(provide_for_syntax_stx); + REGISTER_SO(provide_for_label_stx); REGISTER_SO(set_stx); REGISTER_SO(app_stx); REGISTER_SO(scheme_top_stx); @@ -502,7 +540,10 @@ void scheme_finish_kernel(Scheme_Env *env) require_stx = scheme_datum_to_syntax(scheme_intern_symbol("require"), scheme_false, w, 0, 0); require_for_syntax_stx = scheme_datum_to_syntax(scheme_intern_symbol("require-for-syntax"), scheme_false, w, 0, 0); require_for_template_stx = scheme_datum_to_syntax(scheme_intern_symbol("require-for-template"), scheme_false, w, 0, 0); + require_for_label_stx = scheme_datum_to_syntax(scheme_intern_symbol("require-for-label"), scheme_false, w, 0, 0); provide_stx = scheme_datum_to_syntax(scheme_intern_symbol("provide"), scheme_false, w, 0, 0); + provide_for_syntax_stx = scheme_datum_to_syntax(scheme_intern_symbol("provide-for-syntax"), scheme_false, w, 0, 0); + provide_for_label_stx = scheme_datum_to_syntax(scheme_intern_symbol("provide-for-label"), scheme_false, w, 0, 0); set_stx = scheme_datum_to_syntax(scheme_intern_symbol("set!"), scheme_false, w, 0, 0); app_stx = scheme_datum_to_syntax(scheme_intern_symbol("#%app"), scheme_false, w, 0, 0); scheme_top_stx = scheme_datum_to_syntax(scheme_intern_symbol("#%top"), scheme_false, w, 0, 0); @@ -560,9 +601,9 @@ void scheme_require_from_original_env(Scheme_Env *env, int syntax_only) env->rename = rn; } - exs = kernel->me->provides; - c = kernel->me->num_provides; - i = (syntax_only ? kernel->me->num_var_provides : 0); + exs = kernel->me->rt->provides; + c = kernel->me->rt->num_provides; + i = (syntax_only ? kernel->me->rt->num_var_provides : 0); for (; i < c; i++) { scheme_extend_module_rename(rn, kernel_symbol, exs[i], exs[i], kernel_symbol, exs[i], 0, 0); } @@ -827,25 +868,25 @@ static Scheme_Object *_dynamic_require(int argc, Scheme_Object *argv[], try_again: /* Before starting, check whether the name is provided */ - count = srcm->me->num_provides; + count = srcm->me->rt->num_provides; if (position >= 0) { - if (position < srcm->me->num_var_provides) { + if (position < srcm->me->rt->num_var_provides) { i = position; - if ((SCHEME_SYM_LEN(name) == SCHEME_SYM_LEN(srcm->me->provide_src_names[i])) - && !memcmp(SCHEME_SYM_VAL(name), SCHEME_SYM_VAL(srcm->me->provide_src_names[i]), SCHEME_SYM_LEN(name))) { - name = srcm->me->provides[i]; + if ((SCHEME_SYM_LEN(name) == SCHEME_SYM_LEN(srcm->me->rt->provide_src_names[i])) + && !memcmp(SCHEME_SYM_VAL(name), SCHEME_SYM_VAL(srcm->me->rt->provide_src_names[i]), SCHEME_SYM_LEN(name))) { + name = srcm->me->rt->provides[i]; } else { i = count; /* not found */ indirect_ok = 0; /* don't look further */ } } else { - position -= srcm->me->num_var_provides; + position -= srcm->me->rt->num_var_provides; i = count; } } else { for (i = 0; i < count; i++) { - if (SAME_OBJ(name, srcm->me->provides[i])) { - if (i < srcm->me->num_var_provides) { + if (SAME_OBJ(name, srcm->me->rt->provides[i])) { + if (i < srcm->me->rt->num_var_provides) { break; } else { if (fail_with_error) { @@ -881,17 +922,17 @@ static Scheme_Object *_dynamic_require(int argc, Scheme_Object *argv[], if (i < count) { if (srcm->provide_protects) protected = srcm->provide_protects[i]; - srcmname = (srcm->me->provide_srcs ? srcm->me->provide_srcs[i] : scheme_false); + srcmname = (srcm->me->rt->provide_srcs ? srcm->me->rt->provide_srcs[i] : scheme_false); if (SCHEME_FALSEP(srcmname)) srcmname = srcm->modname; else { srcmname = scheme_modidx_shift(srcmname, srcm->me->src_modidx, srcm->self_modidx); srcmname = scheme_module_resolve(srcmname, 1); } - srcname = srcm->me->provide_src_names[i]; + srcname = srcm->me->rt->provide_src_names[i]; } - if ((position < 0) && (i == count) && srcm->me->reprovide_kernel) { + if ((position < 0) && (i == count) && srcm->me->rt->reprovide_kernel) { /* Check kernel. */ srcm = kernel; goto try_again; @@ -1006,7 +1047,7 @@ static Scheme_Object *do_namespace_require(Scheme_Env *env, int argc, Scheme_Obj rn = scheme_make_module_rename(for_exp, mzMOD_RENAME_TOPLEVEL, NULL); - (void)parse_requires(form, scheme_false, env, rn, rn, + (void)parse_requires(form, scheme_false, env, rn, rn, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, !etonly, etonly, NULL, 1, copy, 0, NULL); brn = env->rename; @@ -1039,7 +1080,13 @@ static Scheme_Object *namespace_require_etonly(int argc, Scheme_Object *argv[]) { return do_namespace_require(NULL, argc, argv, 0, 0, 1); } - + +/* I think we don't need to copy phaseless modules for an + attach. (If we do try to copy, there's a problem in that the + transitive requirements of a for-label import are not + necessarily loaded, yet.) */ +#define NEED_COPY_NOPHASE 0 + static Scheme_Object *namespace_attach_module(int argc, Scheme_Object *argv[]) { Scheme_Env *from_env, *to_env, *menv, *menv2; @@ -1049,6 +1096,10 @@ static Scheme_Object *namespace_attach_module(int argc, Scheme_Object *argv[]) Scheme_Hash_Table *checked, *next_checked, *prev_checked; Scheme_Object *past_checkeds, *future_checkeds, *future_todos, *past_to_modchains; Scheme_Module *m2; +# if NEED_COPY_NOPHASE + Scheme_Object *nophase_todo; + Scheme_Hash_Table *nophase_checked; +# endif int same_namespace, set_env_for_notify = 0, phase; if (!SCHEME_NAMESPACEP(argv[0])) @@ -1073,6 +1124,9 @@ static Scheme_Object *namespace_attach_module(int argc, Scheme_Object *argv[]) todo = scheme_make_pair(name, scheme_null); next_phase_todo = scheme_null; prev_phase_todo = scheme_null; +# if NEED_COPY_NOPHASE + nophase_todo = scheme_null; +# endif from_modchain = from_env->modchain; to_modchain = to_env->modchain; phase = 0; @@ -1086,6 +1140,10 @@ static Scheme_Object *namespace_attach_module(int argc, Scheme_Object *argv[]) future_todos = scheme_null; past_to_modchains = scheme_null; +# if NEED_COPY_NOPHASE + nophase_checked = scheme_make_hash_table(SCHEME_hash_ptr); +# endif + /* Check whether todo, or anything it needs, is already declared incompatibly. Successive iterations of the outer loop explore successive phases (i.e, for-syntax levels). */ @@ -1167,7 +1225,7 @@ static Scheme_Object *namespace_attach_module(int argc, Scheme_Object *argv[]) while (!SCHEME_NULLP(l)) { name = scheme_module_resolve(SCHEME_CAR(l), 0); if (!scheme_hash_get(checked, name)) { - /* printf("Add %d %s (%p)\n", phase, SCHEME_SYM_VAL(name), checked); */ + /* printf("Add %d %s (%p)\n", phase, SCHEME_SYM_VAL(name), checked); */ todo = scheme_make_pair(name, todo); scheme_hash_set(checked, name, scheme_true); } @@ -1189,26 +1247,117 @@ static Scheme_Object *namespace_attach_module(int argc, Scheme_Object *argv[]) l = SCHEME_CDR(l); } - if (phase > 0) { - l = menv->tt_require_names; - if (l) { - while (!SCHEME_NULLP(l)) { - if (!prev_checked) - prev_checked = scheme_make_hash_table(SCHEME_hash_ptr); - - name = scheme_module_resolve(SCHEME_CAR(l), 0); - if (!scheme_hash_get(prev_checked, name)) { - /* printf("Add -%d %s (%p)\n", phase-1, SCHEME_SYM_VAL(name), prev_checked); */ - prev_phase_todo = scheme_make_pair(name, prev_phase_todo); - scheme_hash_set(prev_checked, name, scheme_true); - } - l = SCHEME_CDR(l); - } - } + l = menv->tt_require_names; + if (l) { + while (!SCHEME_NULLP(l)) { + name = scheme_module_resolve(SCHEME_CAR(l), 0); + if (phase > 0) { + if (!prev_checked) + prev_checked = scheme_make_hash_table(SCHEME_hash_ptr); + if (!scheme_hash_get(prev_checked, name)) { + /* printf("Add -%d %s (%p)\n", phase-1, SCHEME_SYM_VAL(name), prev_checked); */ + prev_phase_todo = scheme_make_pair(name, prev_phase_todo); + scheme_hash_set(prev_checked, name, scheme_true); + } + } else { +# if NEED_COPY_NOPHASE + /* Need (phaseless) declaration, only */ + if (!same_namespace) { + if (!scheme_hash_get(nophase_checked, name)) { + /* printf("Add -* %s\n", SCHEME_SYM_VAL(name)); */ + nophase_todo = scheme_make_pair(name, nophase_todo); + scheme_hash_set(nophase_checked, name, scheme_true); + } + } +# endif + } + l = SCHEME_CDR(l); + } } - } + +# if NEED_COPY_NOPHASE + if (!same_namespace) { + l = menv->dt_require_names; + if (l) { + /* Need (phaseless) declaration, only */ + while (!SCHEME_NULLP(l)) { + name = scheme_module_resolve(SCHEME_CAR(l), 0); + + if (!scheme_hash_get(nophase_checked, name)) { + /* printf("Add * %s\n", SCHEME_SYM_VAL(name)); */ + nophase_todo = scheme_make_pair(name, nophase_todo); + scheme_hash_set(nophase_checked, name, scheme_true); + } + l = SCHEME_CDR(l); + } + } + } +# endif + } } } + +# if NEED_COPY_NOPHASE + while (!SCHEME_NULLP(nophase_todo)) { + name = SCHEME_CAR(nophase_todo); + nophase_todo = SCHEME_CDR(nophase_todo); + + if (!SAME_OBJ(name, kernel_symbol)) { + if (!scheme_hash_get(to_env->module_registry, name)) { + Scheme_Object *m1; + int step; + + m1 = (Scheme_Module *)scheme_hash_get(from_env->module_registry, name); + + if (!m1) { + /* This shouldn't happen! */ + scheme_arg_mismatch("namespace-attach-module", + "unknown module (in the source namespace, for no-phase): ", + name); + } + + m2 = (Scheme_Module *)scheme_hash_get(from_env->module_registry, name); + + if (m2 && !SAME_OBJ(m1, m2)) { + scheme_raise_exn(MZEXN_FAIL_CONTRACT, + "namespace-attach-module: " + "a different module with the same name is already " + "in the destination namespace, for name: %S", + name); + } + + /* Need transitive declarations for all phases + (but not neecssarily instantiations): */ + for (step = 0; step < 4; step++) { + switch (step) { + case 0: + l = m2->requires; + break; + case 1: + l = m2->et_requires; + break; + case 2: + l = m2->tt_requires; + break; + case 3: + default: + l = m2->dt_requires; + break; + } + + while (!SCHEME_NULLP(l)) { + name = scheme_module_resolve(SCHEME_CAR(l), 0); + if (!scheme_hash_get(nophase_checked, name)) { + nophase_todo = scheme_make_pair(name, nophase_todo); + scheme_hash_set(nophase_checked, name, scheme_true); + } + l = SCHEME_CDR(l); + } + } + } + } + } +# endif do { if (SCHEME_PAIRP(prev_phase_todo)) { @@ -1286,7 +1435,26 @@ static Scheme_Object *namespace_attach_module(int argc, Scheme_Object *argv[]) /* Now all the modules to check are in the future_checkeds list of hash tables. */ - /* Go through that list, this time tranferring modules */ +# if NEED_COPY_NOPHASE + /* Before we transfer instances, we can transfer modules for which we + just need declarations. */ + { + int i; + for (i = nophase_checked->size; i--; ) { + if (nophase_checked->vals[i]) { + name = nophase_checked->keys[i]; + + if (!SAME_OBJ(name, kernel_symbol)) { + + m2 = (Scheme_Module *)scheme_hash_get(from_env->module_registry, name); + scheme_hash_set(to_env->module_registry, name, (Scheme_Object *)m2); + } + } + } + } +# endif + + /* Go through that list, this time tranferring module instances */ from_modchain = from_env->modchain; to_modchain = to_env->modchain; @@ -1409,37 +1577,102 @@ static Scheme_Object *namespace_unprotect_module(int argc, Scheme_Object *argv[] return scheme_void; } -static int add_require_renames(Scheme_Object *rn, Scheme_Module *im, Scheme_Object *idx) +static int do_add_require_renames(Scheme_Object *rn, + Scheme_Hash_Table *required, Scheme_Object *orig_src, + Scheme_Module *im, Scheme_Module_Phase_Exports *pt, + Scheme_Object *idx, + int marshal_k) { - int i, saw_mb; - Scheme_Object **exs, **exss, **exsns, *midx, *info; + int i, saw_mb, numvals; + Scheme_Object **exs, **exss, **exsns, *midx, *info, *vec, *nml; + char *exets; saw_mb = 0; - exs = im->me->provides; - exsns = im->me->provide_src_names; - exss = im->me->provide_srcs; - for (i = im->me->num_provides; i--; ) { + exs = pt->provides; + exsns = pt->provide_src_names; + exss = pt->provide_srcs; + exets = pt->provide_src_phases; + numvals = pt->num_var_provides; + for (i = pt->num_provides; i--; ) { if (exss && !SCHEME_FALSEP(exss[i])) midx = scheme_modidx_shift(exss[i], im->me->src_modidx, idx); else midx = idx; - scheme_extend_module_rename(rn, midx, exs[i], exsns[i], idx, exs[i], 0, 1); + scheme_extend_module_rename(rn, midx, exs[i], exsns[i], idx, exs[i], + exets ? exets[i] : 0, 1); if (SAME_OBJ(exs[i], module_begin_symbol)) saw_mb = 1; + + if (required) { + vec = scheme_make_vector(6, NULL); + nml = scheme_make_pair(idx, scheme_null); + SCHEME_VEC_ELS(vec)[0] = nml; + SCHEME_VEC_ELS(vec)[1] = midx; + SCHEME_VEC_ELS(vec)[2] = exsns[i]; + SCHEME_VEC_ELS(vec)[3] = ((i < numvals) ? scheme_true : scheme_false); + SCHEME_VEC_ELS(vec)[4] = exs[i]; + SCHEME_VEC_ELS(vec)[5] = orig_src; + scheme_hash_set(required, exs[i], vec); + } } - if (im->me->reprovide_kernel) { + if (pt->reprovide_kernel) { scheme_extend_module_rename_with_kernel(rn, idx); saw_mb = 1; + + if (required) { + exs = kernel->me->rt->provides; + numvals = kernel->me->rt->num_var_provides; + for (i = kernel->me->rt->num_provides; i--; ) { + if (!SAME_OBJ(pt->kernel_exclusion, exs[i])) { + vec = scheme_make_vector(6, NULL); + nml = scheme_make_pair(idx, scheme_null); + SCHEME_VEC_ELS(vec)[0] = nml; + SCHEME_VEC_ELS(vec)[1] = kernel_symbol; + SCHEME_VEC_ELS(vec)[2] = exs[i]; + SCHEME_VEC_ELS(vec)[3] = ((i < numvals) ? scheme_true : scheme_false); + SCHEME_VEC_ELS(vec)[4] = exs[i]; + SCHEME_VEC_ELS(vec)[5] = orig_src; + scheme_hash_set(required, exs[i], vec); + } + } + } } - info = cons(idx, cons(scheme_null, scheme_false)); + info = cons(idx, cons(scheme_make_integer(marshal_k), + cons(scheme_null, scheme_false))); scheme_save_module_rename_unmarshal(rn, info); return saw_mb; } +static int add_initial_require_renames(Scheme_Object *orig_src, + Scheme_Object *rn, Scheme_Hash_Table *rn_required, + Scheme_Object *et_rn, Scheme_Hash_Table *et_required, + Scheme_Object *dt_rn, Scheme_Hash_Table *dt_required, + Scheme_Module *im, Scheme_Object *idx) +{ + int saw_mb; + + if (rn) + saw_mb = do_add_require_renames(rn, rn_required, orig_src, im, im->me->rt, idx, 0); + else + saw_mb = 0; + if (et_rn && im->me->et) + do_add_require_renames(et_rn, et_required, orig_src, im, im->me->et, idx, 1); + if (dt_rn && im->me->dt) + do_add_require_renames(dt_rn, dt_required, orig_src, im, im->me->dt, idx, 2); + + return saw_mb; +} + +static int add_require_renames(Scheme_Object *rn, Scheme_Object *et_rn, Scheme_Object *dt_rn, + Scheme_Module *im, Scheme_Object *idx) +{ + return add_initial_require_renames(NULL, rn, NULL, et_rn, NULL, dt_rn, NULL, im, idx); +} + static Scheme_Object *module_to_namespace(int argc, Scheme_Object *argv[]) { Scheme_Env *menv, *env; @@ -1494,9 +1727,9 @@ static Scheme_Object *module_to_namespace(int argc, Scheme_Object *argv[]) rn = scheme_make_module_rename(0, mzMOD_RENAME_NORMAL, mn_ht); /* Local, provided: */ - for (i = 0; i < m->me->num_provides; i++) { - if (SCHEME_FALSEP(m->me->provide_srcs[i])) { - name = m->me->provides[i]; + for (i = 0; i < m->me->rt->num_provides; i++) { + if (SCHEME_FALSEP(m->me->rt->provide_srcs[i])) { + name = m->me->rt->provides[i]; scheme_extend_module_rename(rn, m->self_modidx, name, name, m->self_modidx, name, 0, 0); } } @@ -1516,11 +1749,11 @@ static Scheme_Object *module_to_namespace(int argc, Scheme_Object *argv[]) else im = (Scheme_Module *)scheme_hash_get(menv->module_registry, name); - add_require_renames(rn, im, idx); + add_require_renames(rn, NULL, NULL, im, idx); } rn = scheme_rename_to_stx(rn); - menv->module->rn_stx = rn; + m->rn_stx = rn; } else if (SCHEME_PAIRP(m->rn_stx)) { /* Delayed shift: */ Scheme_Object *rn_stx, *rn, *midx; @@ -1532,7 +1765,7 @@ static Scheme_Object *module_to_namespace(int argc, Scheme_Object *argv[]) m->rn_stx = rn_stx; } - v = scheme_stx_to_rename(menv->module->rn_stx); + v = scheme_stx_to_rename(m->rn_stx); rn = scheme_make_module_rename(0, mzMOD_RENAME_NORMAL, NULL); scheme_append_module_rename(v, rn); menv->rename = rn; @@ -1554,7 +1787,7 @@ static Scheme_Object *module_to_namespace(int argc, Scheme_Object *argv[]) if (m->et_rn_stx) { Scheme_Object *v, *rn; - if (SAME_OBJ(scheme_true, menv->module->et_rn_stx)) { + if (SAME_OBJ(scheme_true, m->et_rn_stx)) { /* Reconstruct renames based on defns and requires */ Scheme_Module *im; Scheme_Object *l, *idx; @@ -1575,7 +1808,19 @@ static Scheme_Object *module_to_namespace(int argc, Scheme_Object *argv[]) name = scheme_module_resolve(idx, 0); im = (Scheme_Module *)scheme_hash_get(menv->module_registry, name); - add_require_renames(rn, im, idx); + add_require_renames(rn, NULL, NULL, im, idx); + } + /* Required, maybe has for-syntax exports: */ + for (l = menv->require_names; SCHEME_PAIRP(l); l = SCHEME_CDR(l)) { + idx = SCHEME_CAR(l); + name = scheme_module_resolve(idx, 0); + + if (SAME_OBJ(name, kernel_symbol)) + im = kernel; + else + im = (Scheme_Module *)scheme_hash_get(menv->module_registry, name); + + add_require_renames(NULL, rn, NULL, im, idx); } rn = scheme_rename_to_stx(rn); @@ -1591,7 +1836,7 @@ static Scheme_Object *module_to_namespace(int argc, Scheme_Object *argv[]) m->et_rn_stx = et_rn_stx; } - v = scheme_stx_to_rename(menv->module->et_rn_stx); + v = scheme_stx_to_rename(m->et_rn_stx); rn = scheme_make_module_rename(1, mzMOD_RENAME_NORMAL, NULL); scheme_append_module_rename(v, rn); menv->exp_env->rename = rn; @@ -1603,6 +1848,73 @@ static Scheme_Object *module_to_namespace(int argc, Scheme_Object *argv[]) } } + if (!menv->dt_rename) { + Scheme_Module *m = menv->module; + + if (m->dt_rn_stx) { + Scheme_Object *v, *rn; + + if (SAME_OBJ(scheme_true, m->dt_rn_stx)) { + /* Reconstruct renames based on requires */ + Scheme_Module *im; + Scheme_Object *l, *idx; + Scheme_Hash_Table *mn_ht; + + if (menv->marked_names) + mn_ht = menv->marked_names; + else { + mn_ht = scheme_make_hash_table(SCHEME_hash_ptr); + menv->marked_names = mn_ht; + } + + rn = scheme_make_module_rename(MZ_LABEL_PHASE, mzMOD_RENAME_NORMAL, mn_ht); + + /* Required for label: */ + for (l = menv->dt_require_names; SCHEME_PAIRP(l); l = SCHEME_CDR(l)) { + idx = SCHEME_CAR(l); + name = scheme_module_resolve(idx, 0); + im = (Scheme_Module *)scheme_hash_get(menv->module_registry, name); + + add_require_renames(rn, NULL, NULL, im, idx); + } + /* Required, maybe has for-label exports: */ + for (l = menv->require_names; SCHEME_PAIRP(l); l = SCHEME_CDR(l)) { + idx = SCHEME_CAR(l); + name = scheme_module_resolve(idx, 0); + + if (SAME_OBJ(name, kernel_symbol)) + im = kernel; + else + im = (Scheme_Module *)scheme_hash_get(menv->module_registry, name); + + add_require_renames(NULL, NULL, rn, im, idx); + } + + rn = scheme_rename_to_stx(rn); + m->dt_rn_stx = rn; + } else if (SCHEME_PAIRP(m->dt_rn_stx)) { + /* Delayed shift: */ + Scheme_Object *dt_rn_stx, *rn, *midx; + dt_rn_stx = SCHEME_CAR(m->dt_rn_stx); + midx = SCHEME_CDR(m->dt_rn_stx); + rn = scheme_stx_to_rename(dt_rn_stx); + rn = scheme_stx_shift_rename(rn, midx, m->self_modidx); + dt_rn_stx = scheme_rename_to_stx(rn); + m->dt_rn_stx = dt_rn_stx; + } + + v = scheme_stx_to_rename(m->dt_rn_stx); + rn = scheme_make_module_rename(MZ_LABEL_PHASE, mzMOD_RENAME_NORMAL, NULL); + scheme_append_module_rename(v, rn); + menv->dt_rename = rn; + if (!menv->marked_names) { + Scheme_Hash_Table *mn; + mn = scheme_module_rename_marked_names(rn); + menv->marked_names = mn; + } + } + } + return (Scheme_Object *)menv; } @@ -1632,8 +1944,8 @@ static Scheme_Object *module_compiled_name(int argc, Scheme_Object *argv[]) static Scheme_Object *module_compiled_imports(int argc, Scheme_Object *argv[]) { Scheme_Module *m; - Scheme_Object *a[3]; - + Scheme_Object *a[4]; + m = scheme_extract_compiled_module(argv[0]); if (m) { @@ -1641,12 +1953,14 @@ static Scheme_Object *module_compiled_imports(int argc, Scheme_Object *argv[]) scheme_make_list_immutable(m->requires); scheme_make_list_immutable(m->et_requires); scheme_make_list_immutable(m->tt_requires); + scheme_make_list_immutable(m->dt_requires); a[0] = m->requires; a[1] = m->et_requires; a[2] = m->tt_requires; + a[3] = m->dt_requires; - return scheme_values(3, a); + return scheme_values(4, a); } scheme_wrong_type("module-compiled-imports", "compiled module declaration", 0, argc, argv); @@ -1656,27 +1970,46 @@ static Scheme_Object *module_compiled_imports(int argc, Scheme_Object *argv[]) static Scheme_Object *module_compiled_exports(int argc, Scheme_Object *argv[]) { Scheme_Module *m; - Scheme_Object *a[2], *ml = scheme_null, *vl = scheme_null; - int i, n; - + Scheme_Object *a[6]; + Scheme_Object *ml, *vl; + Scheme_Module_Phase_Exports *pt; + int i, n, k; + m = scheme_extract_compiled_module(argv[0]); if (m) { - n = m->me->num_var_provides; - for (i = m->me->num_provides - 1; i >= n; --i) { - ml = scheme_make_immutable_pair(m->me->provides[i], ml); - } - for (; i >= 0; --i) { - vl = scheme_make_immutable_pair(m->me->provides[i], vl); - } + for (k = 0; k < 3; k++) { + switch(k) { + case 0: + pt = m->me->rt; + break; + case 1: + pt = m->me->et; + break; + case 2: + default: + pt = m->me->dt; + break; + } - a[0] = vl; - a[1] = ml; + ml = scheme_null; + vl = scheme_null; + n = pt->num_var_provides; + for (i = pt->num_provides - 1; i >= n; --i) { + ml = scheme_make_immutable_pair(pt->provides[i], ml); + } + for (; i >= 0; --i) { + vl = scheme_make_immutable_pair(pt->provides[i], vl); + } + + a[2 * k] = vl; + a[(2 * k) + 1] = ml; + } - return scheme_values(2, a); + return scheme_values(6, a); } - scheme_wrong_type("module-compiled-imports", "compiled module declaration", 0, argc, argv); + scheme_wrong_type("module-compiled-exports", "compiled module declaration", 0, argc, argv); return NULL; } @@ -1755,9 +2088,9 @@ static Scheme_Object *module_export_protected_p(int argc, Scheme_Object **argv) m = (Scheme_Module *)mv; - count = m->me->num_provides; + count = m->me->rt->num_provides; for (i = 0; i < count; i++) { - if (SAME_OBJ(name, m->me->provides[i])) { + if (SAME_OBJ(name, m->me->rt->provides[i])) { if (m->provide_protects && m->provide_protects[i]) return scheme_true; else @@ -2020,10 +2353,10 @@ static void setup_accessible_table(Scheme_Module *m) int i, count, nvp; ht = scheme_make_hash_table(SCHEME_hash_ptr); - nvp = m->me->num_var_provides; + nvp = m->me->rt->num_var_provides; for (i = 0; i < nvp; i++) { - if (SCHEME_FALSEP(m->me->provide_srcs[i])) { - scheme_hash_set(ht, m->me->provide_src_names[i], scheme_make_integer(i)); + if (SCHEME_FALSEP(m->me->rt->provide_srcs[i])) { + scheme_hash_set(ht, m->me->rt->provide_src_names[i], scheme_make_integer(i)); } } @@ -2034,10 +2367,10 @@ static void setup_accessible_table(Scheme_Module *m) m->accessible = ht; /* Add syntax as negative ids: */ - count = m->me->num_provides; + count = m->me->rt->num_provides; for (i = nvp; i < count; i++) { - if (SCHEME_FALSEP(m->me->provide_srcs[i])) { - scheme_hash_set(ht, m->me->provide_src_names[i], scheme_make_integer(-(i+1))); + if (SCHEME_FALSEP(m->me->rt->provide_srcs[i])) { + scheme_hash_set(ht, m->me->rt->provide_src_names[i], scheme_make_integer(-(i+1))); } } } @@ -2147,14 +2480,14 @@ Scheme_Object *scheme_check_accessible_in_module(Scheme_Env *env, Scheme_Object Scheme_Object *isym; int need_cert = 0; - if (position < env->module->me->num_var_provides) { - if (!env->module->me->provide_srcs - || SCHEME_FALSEP(env->module->me->provide_srcs[position])) - isym = env->module->me->provide_src_names[position]; + if (position < env->module->me->rt->num_var_provides) { + if (!env->module->me->rt->provide_srcs + || SCHEME_FALSEP(env->module->me->rt->provide_srcs[position])) + isym = env->module->me->rt->provide_src_names[position]; else isym = NULL; } else { - int ipos = position - env->module->me->num_var_provides; + int ipos = position - env->module->me->rt->num_var_provides; if (ipos < env->module->num_indirect_provides) { isym = env->module->indirect_provides[ipos]; need_cert = 1; @@ -2169,7 +2502,7 @@ Scheme_Object *scheme_check_accessible_in_module(Scheme_Env *env, Scheme_Object || (SCHEME_SYM_LEN(isym) == SCHEME_SYM_LEN(symbol) && !memcmp(SCHEME_SYM_VAL(isym), SCHEME_SYM_VAL(symbol), SCHEME_SYM_LEN(isym)))) { - if ((position < env->module->me->num_var_provides) + if ((position < env->module->me->rt->num_var_provides) && scheme_module_protected_wrt(env->insp, prot_insp) && env->module->provide_protects && env->module->provide_protects[position]) { @@ -2207,7 +2540,7 @@ Scheme_Object *scheme_check_accessible_in_module(Scheme_Env *env, Scheme_Object if (pos) { if (env->module->provide_protects - && (SCHEME_INT_VAL(pos) < env->module->me->num_provides) + && (SCHEME_INT_VAL(pos) < env->module->me->rt->num_provides) && env->module->provide_protects[SCHEME_INT_VAL(pos)]) { if (_protected) *_protected = 1; @@ -2215,7 +2548,7 @@ Scheme_Object *scheme_check_accessible_in_module(Scheme_Env *env, Scheme_Object } if ((position >= -1) - && (SCHEME_INT_VAL(pos) >= env->module->me->num_var_provides)) { + && (SCHEME_INT_VAL(pos) >= env->module->me->rt->num_var_provides)) { /* unexported var -- need cert */ if (_protected) *_protected = 1; @@ -2402,6 +2735,7 @@ static void expstart_module(Scheme_Module *m, Scheme_Env *env, int restart, menv->require_names = scheme_null; menv->et_require_names = scheme_null; menv->tt_require_names = scheme_null; + menv->dt_require_names = scheme_null; return; } @@ -2419,6 +2753,7 @@ static void expstart_module(Scheme_Module *m, Scheme_Env *env, int restart, menv->require_names = scheme_null; menv->et_require_names = scheme_null; menv->tt_require_names = scheme_null; + menv->dt_require_names = scheme_null; menv->phase = env->phase; menv->link_midx = syntax_idx; @@ -2437,9 +2772,9 @@ static void expstart_module(Scheme_Module *m, Scheme_Env *env, int restart, Scheme_Object **exss, **exsns; int i, count; - exsns = m->me->provide_src_names; - exss = m->me->provide_srcs; - count = m->me->num_var_provides; + exsns = m->me->rt->provide_src_names; + exss = m->me->rt->provide_srcs; + count = m->me->rt->num_var_provides; for (i = 0; i < count; i++) { if (SCHEME_FALSEP(exss[i])) @@ -2481,6 +2816,19 @@ static void expstart_module(Scheme_Module *m, Scheme_Env *env, int restart, if (scheme_starting_up) menv->attached = 1; /* protect initial modules from redefinition, etc. */ + np = scheme_null; + for (l = m->dt_requires; !SCHEME_NULLP(l); l = SCHEME_CDR(l)) { + if (syntax_idx) + midx = scheme_modidx_shift(SCHEME_CAR(l), m->me->src_modidx, syntax_idx); + else + midx = scheme_modidx_shift(SCHEME_CAR(l), m->me->src_modidx, m->self_modidx); + + np = cons(midx, np); + + im = module_load(scheme_module_resolve(midx, 1), env, NULL); + } + menv->dt_require_names = np; + if (m->prim_et_body || !SCHEME_NULLP(m->et_body) || !SCHEME_NULLP(m->et_requires)) { if (delay_exptime) { /* Set lazy-syntax flag. */ @@ -2749,6 +3097,7 @@ Scheme_Env *scheme_primitive_module(Scheme_Object *name, Scheme_Env *for_env) m->requires = scheme_null; m->et_requires = scheme_null; m->tt_requires = scheme_null; + m->dt_requires = scheme_null; m->primitive = env; m->insp = insp; @@ -2799,11 +3148,11 @@ void scheme_finish_primitive_module(Scheme_Env *env) m->et_functional = 1; m->tt_functional = 1; - m->me->provides = exs; - m->me->provide_srcs = NULL; - m->me->provide_src_names = exs; - m->me->num_provides = count; - m->me->num_var_provides = count; + m->me->rt->provides = exs; + m->me->rt->provide_srcs = NULL; + m->me->rt->provide_src_names = exs; + m->me->rt->num_provides = count; + m->me->rt->num_var_provides = count; qsort_provides(exs, NULL, NULL, NULL, 0, count, 1); @@ -2819,25 +3168,25 @@ void scheme_protect_primitive_provide(Scheme_Env *env, Scheme_Object *name) Scheme_Hash_Table *ht; char *exps; ht = scheme_make_hash_table(SCHEME_hash_ptr); - exps = MALLOC_N_ATOMIC(char, m->me->num_provides); - for (i = m->me->num_provides; i--; ) { + exps = MALLOC_N_ATOMIC(char, m->me->rt->num_provides); + for (i = m->me->rt->num_provides; i--; ) { exps[i] = 0; - scheme_hash_set(ht, m->me->provides[i], scheme_make_integer(i)); + scheme_hash_set(ht, m->me->rt->provides[i], scheme_make_integer(i)); } m->provide_protects = exps; m->accessible = ht; } if (name) { - for (i = m->me->num_provides; i--; ) { - if (SAME_OBJ(name, m->me->provides[i])) { + for (i = m->me->rt->num_provides; i--; ) { + if (SAME_OBJ(name, m->me->rt->provides[i])) { m->provide_protects[i] = 1; break; } } } else { /* Protect all */ - for (i = m->me->num_provides; i--; ) { + for (i = m->me->rt->num_provides; i--; ) { m->provide_protects[i] = 1; } } @@ -2888,10 +3237,23 @@ Scheme_Module *scheme_extract_compiled_module(Scheme_Object *o) static Scheme_Module_Exports *make_module_exports() { Scheme_Module_Exports *me; + Scheme_Module_Phase_Exports *pt; + me = MALLOC_ONE_RT(Scheme_Module_Exports); -#ifdef MZTAG_REQUIRED - me->type = scheme_rt_module_exports; -#endif + SET_REQUIRED_TAG(me->type = scheme_rt_module_exports); + + pt = MALLOC_ONE_RT(Scheme_Module_Phase_Exports); + SET_REQUIRED_TAG(pt->type = scheme_rt_module_phase_exports); + me->rt = pt; + + pt = MALLOC_ONE_RT(Scheme_Module_Phase_Exports); + SET_REQUIRED_TAG(pt->type = scheme_rt_module_phase_exports); + me->et = pt; + + pt = MALLOC_ONE_RT(Scheme_Module_Phase_Exports); + SET_REQUIRED_TAG(pt->type = scheme_rt_module_phase_exports); + me->dt = pt; + return me; } @@ -3074,6 +3436,12 @@ module_execute(Scheme_Object *data) v = scheme_make_pair(m->et_rn_stx, (Scheme_Object *)midx); m->et_rn_stx = v; } + if (m->dt_rn_stx && !SAME_OBJ(scheme_true, m->dt_rn_stx)) { + /* Delay the shift: */ + Scheme_Object *v; + v = scheme_make_pair(m->dt_rn_stx, (Scheme_Object *)midx); + m->dt_rn_stx = v; + } } } } @@ -3465,13 +3833,13 @@ module_resolve(Scheme_Object *data, Resolve_Info *old_rslv) static Scheme_Object *do_module(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Compile_Expand_Info *rec, int drec) { - Scheme_Object *fm, *nm, *ii, *rn, *et_rn, *tt_rn, *iidx, *self_modidx; + Scheme_Object *fm, *nm, *ii, *rn, *et_rn, *tt_rn, *dt_rn, *iidx, *self_modidx; Scheme_Module *iim; Scheme_Env *menv; Scheme_Comp_Env *benv; Scheme_Module *m; Scheme_Object *mbval; - Scheme_Hash_Table *mn_ht, *et_mn_ht, *tt_mn_ht; + Scheme_Hash_Table *mn_ht, *et_mn_ht, *tt_mn_ht, *dt_mn_ht; int saw_mb, check_mb = 0; int restore_confusing_name = 0; @@ -3532,11 +3900,13 @@ static Scheme_Object *do_module(Scheme_Object *form, Scheme_Comp_Env *env, m->requires = ins; m->et_requires = scheme_null; m->tt_requires = scheme_null; + m->dt_requires = scheme_null; } mn_ht = scheme_make_hash_table(SCHEME_hash_ptr); et_mn_ht = scheme_make_hash_table(SCHEME_hash_ptr); tt_mn_ht = scheme_make_hash_table(SCHEME_hash_ptr); + dt_mn_ht = mn_ht; annote_marked_names_nonempty(mn_ht); annote_marked_names_nonempty(et_mn_ht); @@ -3545,10 +3915,12 @@ static Scheme_Object *do_module(Scheme_Object *form, Scheme_Comp_Env *env, rn = scheme_make_module_rename(0, mzMOD_RENAME_NORMAL, mn_ht); et_rn = scheme_make_module_rename(1, mzMOD_RENAME_NORMAL, et_mn_ht); tt_rn = scheme_make_module_rename(-1, mzMOD_RENAME_NORMAL, tt_mn_ht); + dt_rn = scheme_make_module_rename(MZ_LABEL_PHASE, mzMOD_RENAME_NORMAL, dt_mn_ht); menv->rename = rn; menv->et_rename = et_rn; menv->tt_rename = tt_rn; + menv->dt_rename = dt_rn; { Scheme_Object *insp; @@ -3562,12 +3934,12 @@ static Scheme_Object *do_module(Scheme_Object *form, Scheme_Comp_Env *env, scheme_prepare_template_env(menv); menv->template_env->marked_names = tt_mn_ht; - /* For each (direct) provide in iim, add a module rename to fm */ + /* For each provide in iim, add a module rename to fm */ if (SAME_OBJ(iim, kernel)) { scheme_extend_module_rename_with_kernel(rn, kernel_symbol); saw_mb = 1; } else { - saw_mb = add_require_renames(rn, iim, iidx); + saw_mb = add_require_renames(rn, et_rn, dt_rn, iim, iidx); } if (rec[drec].comp) @@ -3602,6 +3974,7 @@ static Scheme_Object *do_module(Scheme_Object *form, Scheme_Comp_Env *env, fm = scheme_add_rename(fm, rn); fm = scheme_add_rename(fm, et_rn); fm = scheme_add_rename(fm, tt_rn); + fm = scheme_add_rename(fm, dt_rn); if (!check_mb) { @@ -3622,6 +3995,7 @@ static Scheme_Object *do_module(Scheme_Object *form, Scheme_Comp_Env *env, fm = scheme_add_rename(fm, rn); fm = scheme_add_rename(fm, et_rn); fm = scheme_add_rename(fm, tt_rn); + fm = scheme_add_rename(fm, dt_rn); check_mb = 1; } } @@ -3905,26 +4279,32 @@ static void flush_definitions(Scheme_Env *genv) static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Compile_Expand_Info *rec, int drec) { - Scheme_Object *fm, *first, *last, *p, *rn, *exp_body, *et_rn, *tt_rn, *self_modidx, *prev_p; + Scheme_Object *fm, *first, *last, *p, *rn, *exp_body, *et_rn, *tt_rn, *dt_rn, *self_modidx, *prev_p; Scheme_Comp_Env *xenv, *cenv, *rhs_env; Scheme_Hash_Table *et_required; /* just to avoid duplicates */ Scheme_Hash_Table *tt_required; /* just to avoid duplicates */ + Scheme_Hash_Table *dt_required; /* just to avoid duplicates */ Scheme_Hash_Table *required; /* name -> (vector nominal-modidx-list modidx srcname var? prntname) */ /**/ /* first nominal-modidx goes with modidx, rest are for re-provides */ Scheme_Hash_Table *provided; /* exname -> (cons locname-stx-or-sym protected?) */ Scheme_Object *reprovided; /* list of (list modidx syntax except-name ...) */ Scheme_Object *all_defs_out; /* list of (cons protected? (stx-list except-name ...)) */ + Scheme_Object *all_et_defs_out; + Scheme_Hash_Table *et_provided, *dt_provided; + Scheme_Object *et_reprovided, *dt_reprovided; Scheme_Object *all_defs; /* list of stxid; this is almost redundant to the syntax and toplevel tables, but it preserves the original name for exporting */ - Scheme_Object *post_ex_rn, *post_ex_et_rn, *post_ex_tt_rn; /* renames for ids introduced by expansion */ - void *tables[3], *et_tables[3], *tt_tables[3]; - Scheme_Object **exs, **exsns, **exss, **exis, *exclude_hint = scheme_false, *lift_data; + Scheme_Object *all_et_defs; + Scheme_Object *post_ex_rn, *post_ex_et_rn, *post_ex_tt_rn, *post_ex_dt_rn; /* renames for ids introduced by expansion */ + void *tables[3], *et_tables[3], *tt_tables[3], *dt_tables[3]; + Scheme_Object *exclude_hint = scheme_false, *lift_data; Scheme_Hash_Table *et_mn; + Scheme_Object **exis; + int exicount; char *exps; - int excount, exvcount, exicount; - int reprovide_kernel; - int all_simple_renames = 1, et_all_simple_renames = 1, tt_all_simple_renames = 1; + int all_simple_renames = 1, et_all_simple_renames = 1, tt_all_simple_renames = 1, dt_all_simple_renames = 1; int maybe_has_lifts = 0; + int reprovide_kernel; Scheme_Object *redef_modname; Scheme_Object *observer; @@ -3951,7 +4331,7 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, { Scheme_Object *stop; stop = scheme_get_stop_expander(); - scheme_add_local_syntax(22, xenv); + scheme_add_local_syntax(25, xenv); scheme_set_local_syntax(0, scheme_begin_stx, stop, xenv); scheme_set_local_syntax(1, scheme_define_values_stx, stop, xenv); scheme_set_local_syntax(2, scheme_define_syntaxes_stx, stop, xenv); @@ -3959,32 +4339,42 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, scheme_set_local_syntax(4, require_stx, stop, xenv); scheme_set_local_syntax(5, require_for_syntax_stx, stop, xenv); scheme_set_local_syntax(6, require_for_template_stx, stop, xenv); - scheme_set_local_syntax(7, provide_stx, stop, xenv); - scheme_set_local_syntax(8, set_stx, stop, xenv); - scheme_set_local_syntax(9, app_stx, stop, xenv); - scheme_set_local_syntax(10, scheme_top_stx, stop, xenv); - scheme_set_local_syntax(11, lambda_stx, stop, xenv); - scheme_set_local_syntax(12, case_lambda_stx, stop, xenv); - scheme_set_local_syntax(13, let_values_stx, stop, xenv); - scheme_set_local_syntax(14, letrec_values_stx, stop, xenv); - scheme_set_local_syntax(15, if_stx, stop, xenv); - scheme_set_local_syntax(16, begin0_stx, stop, xenv); - scheme_set_local_syntax(17, set_stx, stop, xenv); - scheme_set_local_syntax(18, with_continuation_mark_stx, stop, xenv); - scheme_set_local_syntax(19, letrec_syntaxes_stx, stop, xenv); - scheme_set_local_syntax(20, var_ref_stx, stop, xenv); - scheme_set_local_syntax(21, expression_stx, stop, xenv); + scheme_set_local_syntax(7, require_for_label_stx, stop, xenv); + scheme_set_local_syntax(8, provide_stx, stop, xenv); + scheme_set_local_syntax(9, provide_for_syntax_stx, stop, xenv); + scheme_set_local_syntax(10, provide_for_label_stx, stop, xenv); + scheme_set_local_syntax(11, set_stx, stop, xenv); + scheme_set_local_syntax(12, app_stx, stop, xenv); + scheme_set_local_syntax(13, scheme_top_stx, stop, xenv); + scheme_set_local_syntax(14, lambda_stx, stop, xenv); + scheme_set_local_syntax(15, case_lambda_stx, stop, xenv); + scheme_set_local_syntax(16, let_values_stx, stop, xenv); + scheme_set_local_syntax(17, letrec_values_stx, stop, xenv); + scheme_set_local_syntax(18, if_stx, stop, xenv); + scheme_set_local_syntax(19, begin0_stx, stop, xenv); + scheme_set_local_syntax(20, set_stx, stop, xenv); + scheme_set_local_syntax(21, with_continuation_mark_stx, stop, xenv); + scheme_set_local_syntax(22, letrec_syntaxes_stx, stop, xenv); + scheme_set_local_syntax(23, var_ref_stx, stop, xenv); + scheme_set_local_syntax(24, expression_stx, stop, xenv); } first = scheme_null; last = NULL; + rn = env->genv->rename; + et_rn = env->genv->et_rename; + tt_rn = env->genv->tt_rename; + dt_rn = env->genv->dt_rename; + required = scheme_make_hash_table(SCHEME_hash_ptr); + et_required = scheme_make_hash_table(SCHEME_hash_ptr); + dt_required = scheme_make_hash_table(SCHEME_hash_ptr); + /* Put initial requires into the table: */ { - int i, numvals; Scheme_Module *iim; - Scheme_Object *midx, *nmidx, *vec, *nml, *orig_src; + Scheme_Object *nmidx, *orig_src; /* stx src of original import: */ orig_src = env->genv->module->ii_src; @@ -3995,51 +4385,13 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, nmidx = SCHEME_CAR(env->genv->module->requires); iim = module_load(scheme_module_resolve(nmidx, 1), env->genv, NULL); - exs = iim->me->provides; - exsns = iim->me->provide_src_names; - exss = iim->me->provide_srcs; - numvals = iim->me->num_var_provides; - for (i = iim->me->num_provides; i--; ) { - if (exss) { - midx = exss[i]; - if (SCHEME_FALSEP(midx)) - midx = nmidx; - else - midx = scheme_modidx_shift(midx, iim->me->src_modidx, nmidx); - } else - midx = nmidx; - vec = scheme_make_vector(6, NULL); - nml = scheme_make_pair(nmidx, scheme_null); - SCHEME_VEC_ELS(vec)[0] = nml; - SCHEME_VEC_ELS(vec)[1] = midx; - SCHEME_VEC_ELS(vec)[2] = exsns[i]; - SCHEME_VEC_ELS(vec)[3] = ((i < numvals) ? scheme_true : scheme_false); - SCHEME_VEC_ELS(vec)[4] = exs[i]; - SCHEME_VEC_ELS(vec)[5] = orig_src; - scheme_hash_set(required, exs[i], vec); - } - if (iim->me->reprovide_kernel) { - exs = kernel->me->provides; - numvals = kernel->me->num_var_provides; - for (i = kernel->me->num_provides; i--; ) { - if (!SAME_OBJ(iim->me->kernel_exclusion, exs[i])) { - vec = scheme_make_vector(6, NULL); - nml = scheme_make_pair(nmidx, scheme_null); - SCHEME_VEC_ELS(vec)[0] = nml; - SCHEME_VEC_ELS(vec)[1] = kernel_symbol; - SCHEME_VEC_ELS(vec)[2] = exs[i]; - SCHEME_VEC_ELS(vec)[3] = ((i < numvals) ? scheme_true : scheme_false); - SCHEME_VEC_ELS(vec)[4] = exs[i]; - SCHEME_VEC_ELS(vec)[5] = orig_src; - scheme_hash_set(required, exs[i], vec); - } - } - } + add_initial_require_renames(orig_src, + rn, required, + et_rn, et_required, + dt_rn, dt_required, + iim, nmidx); } - rn = env->genv->rename; - et_rn = env->genv->et_rename; - tt_rn = env->genv->tt_rename; if (rec[drec].comp || (rec[drec].depth != -2)) { /* rename tables no longer needed; NULL them out */ @@ -4056,13 +4408,14 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, env->genv->module->et_rn_stx = v; v = scheme_rename_to_stx(tt_rn); env->genv->module->tt_rn_stx = v; + v = scheme_rename_to_stx(dt_rn); + env->genv->module->dt_rn_stx = v; } tables[0] = env->genv->toplevel; tables[1] = required; tables[2] = env->genv->syntax; - et_required = scheme_make_hash_table(SCHEME_hash_ptr); et_tables[0] = NULL; et_tables[1] = et_required; et_tables[2] = NULL; @@ -4072,11 +4425,22 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, tt_tables[1] = tt_required; tt_tables[2] = NULL; + dt_tables[0] = NULL; + dt_tables[1] = dt_required; + dt_tables[2] = NULL; + provided = scheme_make_hash_table(SCHEME_hash_ptr); reprovided = scheme_null; + et_provided = scheme_make_hash_table(SCHEME_hash_ptr); + et_reprovided = scheme_null; + dt_provided = scheme_make_hash_table(SCHEME_hash_ptr); + dt_reprovided = scheme_null; all_defs_out = scheme_null; + all_et_defs_out = scheme_null; + all_defs = scheme_null; + all_et_defs = scheme_null; exp_body = scheme_null; @@ -4085,6 +4449,7 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, post_ex_rn = scheme_make_module_rename(0, mzMOD_RENAME_MARKED, env->genv->marked_names); post_ex_et_rn = scheme_make_module_rename(1, mzMOD_RENAME_MARKED, env->genv->exp_env->marked_names); post_ex_tt_rn = scheme_make_module_rename(-1, mzMOD_RENAME_MARKED, env->genv->template_env->marked_names); + post_ex_dt_rn = scheme_make_module_rename(MZ_LABEL_PHASE, mzMOD_RENAME_MARKED, env->genv->template_env->marked_names); /* For syntax-local-context, etc., in a d-s RHS: */ rhs_env = scheme_new_comp_env(env->genv, env->insp, SCHEME_TOPLEVEL_FRAME); @@ -4096,6 +4461,7 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, form = scheme_add_rename(form, post_ex_rn); form = scheme_add_rename(form, post_ex_et_rn); form = scheme_add_rename(form, post_ex_tt_rn); + form = scheme_add_rename(form, post_ex_dt_rn); maybe_has_lifts = 0; @@ -4140,9 +4506,11 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, e = scheme_add_rename(e, post_ex_rn); e = scheme_add_rename(e, post_ex_et_rn); e = scheme_add_rename(e, post_ex_tt_rn); + e = scheme_add_rename(e, post_ex_dt_rn); fm = scheme_named_map_1(NULL, add_a_rename, fm, post_ex_rn); fm = scheme_named_map_1(NULL, add_a_rename, fm, post_ex_et_rn); fm = scheme_named_map_1(NULL, add_a_rename, fm, post_ex_tt_rn); + fm = scheme_named_map_1(NULL, add_a_rename, fm, post_ex_dt_rn); fm = scheme_append(fst, scheme_make_pair(e, fm)); SCHEME_EXPAND_OBSERVE_MODULE_LIFT_LOOP(observer, fst); } else { @@ -4157,6 +4525,7 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, e = scheme_add_rename(e, post_ex_rn); e = scheme_add_rename(e, post_ex_et_rn); e = scheme_add_rename(e, post_ex_tt_rn); + e = scheme_add_rename(e, post_ex_dt_rn); fm = scheme_flatten_begin(e, fm); SCHEME_EXPAND_OBSERVE_SPLICE(observer, fm); if (SCHEME_STX_NULLP(fm)) { @@ -4178,6 +4547,7 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, e = scheme_add_rename(e, post_ex_rn); e = scheme_add_rename(e, post_ex_et_rn); e = scheme_add_rename(e, post_ex_tt_rn); + e = scheme_add_rename(e, post_ex_dt_rn); if (SCHEME_STX_PAIRP(e)) { Scheme_Object *fst; @@ -4281,6 +4651,8 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, /* Remember the original: */ if (!for_stx) all_defs = scheme_make_pair(name, all_defs); + else + all_et_defs = scheme_make_pair(name, all_et_defs); name = scheme_tl_id_sym(oenv->genv, name, NULL, 2); @@ -4389,7 +4761,10 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, /* Add requires to renaming: */ imods = parse_requires(e, self_modidx, env->genv, - rn, post_ex_rn, check_require_name, tables, 0, 1, + rn, post_ex_rn, + et_rn, post_ex_et_rn, + dt_rn, post_ex_dt_rn, + check_require_name, tables, et_tables, dt_tables, 0, 1, redef_modname, 0, 0, 1, &all_simple_renames); @@ -4412,7 +4787,10 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, /* Add requires to renaming: */ imods = parse_requires(e, self_modidx, env->genv->exp_env, - et_rn, post_ex_et_rn, check_require_name, et_tables, 1, 0, + et_rn, post_ex_et_rn, + NULL, NULL, + NULL, NULL, + check_require_name, et_tables, NULL, NULL, 1, 0, redef_modname, 0, 0, 1, &et_all_simple_renames); @@ -4439,7 +4817,10 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, /* Add requires to renaming: */ imods = parse_requires(e, self_modidx, env->genv->template_env, - tt_rn, post_ex_tt_rn, check_require_name, tt_tables, 0, 0, + tt_rn, post_ex_tt_rn, + NULL, NULL, + NULL, NULL, + check_require_name, tt_tables, NULL, NULL, 0, 0, redef_modname, 0, 0, 1, &tt_all_simple_renames); @@ -4450,6 +4831,36 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, env->genv->module->tt_requires = reqs; } + if (rec[drec].comp) + e = NULL; + + SCHEME_EXPAND_OBSERVE_EXIT_PRIM(observer, e); + kind = 0; + } else if (scheme_stx_module_eq(require_for_label_stx, fst, 0)) { + /************ require-for-label *************/ + Scheme_Object *imods; + + SCHEME_EXPAND_OBSERVE_ENTER_PRIM(observer, e); + SCHEME_EXPAND_OBSERVE_PRIM_REQUIRE_FOR_TEMPLATE(observer); /* FIXME! */ + + scheme_prepare_template_env(env->genv); + + /* Add requires to renaming: */ + imods = parse_requires(e, self_modidx, env->genv->template_env, + dt_rn, post_ex_dt_rn, + NULL, NULL, + NULL, NULL, + check_require_name, dt_tables, NULL, NULL, 0, 0, + redef_modname, 0, 0, 1, + &dt_all_simple_renames); + + /* Add required modules to dt_requires list: */ + { + Scheme_Object *reqs; + reqs = add_req(imods, env->genv->module->dt_requires); + env->genv->module->dt_requires = reqs; + } + if (rec[drec].comp) e = NULL; @@ -4458,257 +4869,48 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, } else if (scheme_stx_module_eq(provide_stx, fst, 0)) { /************ provide *************/ /* Add provides to table: */ - Scheme_Object *l; - int protect_cnt = 0; SCHEME_EXPAND_OBSERVE_ENTER_PRIM(observer, e); SCHEME_EXPAND_OBSERVE_PRIM_PROVIDE(observer); - if (scheme_stx_proper_list_length(e) < 0) - scheme_wrong_syntax(NULL, e, form, "bad syntax (" IMPROPER_LIST_FORM ")"); + reprovided = parse_provides(form, fst, e, + provided, reprovided, + self_modidx, + &all_defs_out); - for (l = SCHEME_STX_CDR(e); !SCHEME_STX_NULLP(l); l = SCHEME_STX_CDR(l)) { - Scheme_Object *a, *midx, *name; + if (rec[drec].comp) + e = NULL; - a = SCHEME_STX_CAR(l); + SCHEME_EXPAND_OBSERVE_EXIT_PRIM(observer, e); + kind = 0; + } else if (scheme_stx_module_eq(provide_for_syntax_stx, fst, 0)) { + /************ provide-for-syntax *************/ + /* Add provides to table: */ - if (SCHEME_STX_PAIRP(a) && (scheme_stx_proper_list_length(a) > 0)) { - fst = SCHEME_STX_CAR(a); - if (SCHEME_STX_SYMBOLP(fst) - && (SAME_OBJ(protect_symbol, SCHEME_STX_VAL(fst)))) { - if (protect_cnt) - scheme_wrong_syntax(NULL, a, e, "bad syntax (nested protect)"); - a = SCHEME_STX_CDR(a); - a = scheme_flatten_syntax_list(a, NULL); - l = SCHEME_STX_CDR(l); - l = scheme_append(a, l); - protect_cnt = scheme_list_length(a); + SCHEME_EXPAND_OBSERVE_ENTER_PRIM(observer, e); + SCHEME_EXPAND_OBSERVE_PRIM_PROVIDE(observer); /* FIXME! */ - /* In case a provide ends with an empty protect: */ - if (SCHEME_STX_NULLP(l)) - break; + et_reprovided = parse_provides(form, fst, e, + et_provided, et_reprovided, + self_modidx, + &all_et_defs_out); - a = SCHEME_STX_CAR(l); - } - } + if (rec[drec].comp) + e = NULL; - if (SCHEME_STX_SYMBOLP(a)) { - /* */ - name = SCHEME_STX_VAL(a); - if (scheme_hash_get(provided, name)) - scheme_wrong_syntax("module", a, form, "identifier already provided"); - /* Provide a: */ - scheme_hash_set(provided, name, scheme_make_pair(a, protect_cnt ? scheme_true : scheme_false)); - } else if (SCHEME_STX_PAIRP(a)) { - Scheme_Object *rest; + SCHEME_EXPAND_OBSERVE_EXIT_PRIM(observer, e); + kind = 0; + } else if (scheme_stx_module_eq(provide_for_label_stx, fst, 0)) { + /************ provide-for-label *************/ + /* Add provides to table: */ - fst = SCHEME_STX_CAR(a); - rest = SCHEME_STX_CDR(a); + SCHEME_EXPAND_OBSERVE_ENTER_PRIM(observer, e); + SCHEME_EXPAND_OBSERVE_PRIM_PROVIDE(observer); /* FIXME! */ - if (SAME_OBJ(rename_symbol, SCHEME_STX_VAL(fst))) { - /* (rename ) */ - Scheme_Object *inm, *enm; - - if (!SCHEME_STX_PAIRP(rest) - || !SCHEME_STX_PAIRP(SCHEME_STX_CDR(rest))) - scheme_wrong_syntax(NULL, a, e, "bad syntax"); - inm = SCHEME_STX_CAR(rest); - rest = SCHEME_STX_CDR(rest); - enm = SCHEME_STX_CAR(rest); - if (!SCHEME_STX_SYMBOLP(inm)) - scheme_wrong_syntax(NULL, a, e, "bad syntax (internal name is not an identifier)"); - if (!SCHEME_STX_SYMBOLP(enm)) - scheme_wrong_syntax(NULL, a, e, "bad syntax (external name is not an identifier)"); - rest = SCHEME_STX_CDR(rest); - if (!SCHEME_STX_NULLP(rest)) - scheme_wrong_syntax(NULL, a, e, "bad syntax (data following external name)"); - - enm = SCHEME_STX_VAL(enm); - - if (scheme_hash_get(provided, enm)) - scheme_wrong_syntax("module", enm, a, "identifier already provided"); - /* Provide enm: */ - scheme_hash_set(provided, enm, scheme_make_pair(inm, protect_cnt ? scheme_true : scheme_false)); - } else if (SAME_OBJ(all_from_symbol, SCHEME_STX_VAL(fst))) { - /* (all-from ) */ - if (protect_cnt) - scheme_wrong_syntax(NULL, a, e, "bad syntax (not allowed as protected)"); - if (!SCHEME_STX_PAIRP(rest)) - scheme_wrong_syntax(NULL, a, e, "bad syntax"); - if (!SCHEME_STX_NULLP(SCHEME_STX_CDR(rest))) - scheme_wrong_syntax(NULL, a, e, "bad syntax (data following `all-from')"); - - midx = SCHEME_STX_CAR(rest); - midx = scheme_make_modidx(scheme_syntax_to_datum(midx, 0, NULL), - self_modidx, - scheme_false); - - reprovided = scheme_make_pair(scheme_make_pair(midx, scheme_make_pair(e, scheme_null)), - reprovided); - } else if (SAME_OBJ(all_from_except_symbol, SCHEME_STX_VAL(fst))) { - /* (all-from-except ...) */ - Scheme_Object *exns, *el; - int len; - - if (protect_cnt) - scheme_wrong_syntax(NULL, a, e, "bad syntax (not allowed as protected)"); - - len = scheme_stx_proper_list_length(a); - - if (len < 0) - scheme_wrong_syntax(NULL, a, e, "bad syntax (" IMPROPER_LIST_FORM ")"); - else if (len == 1) - scheme_wrong_syntax(NULL, a, e, "bad syntax (missing module name)"); - - midx = SCHEME_STX_CAR(rest); - midx = scheme_make_modidx(scheme_syntax_to_datum(midx, 0, NULL), - self_modidx, - scheme_false); - exns = SCHEME_STX_CDR(rest); - - /* Check all exclusions are identifiers: */ - for (el = exns; SCHEME_STX_PAIRP(el); el = SCHEME_STX_CDR(el)) { - p = SCHEME_STX_CAR(el); - if (!SCHEME_STX_SYMBOLP(p)) { - scheme_wrong_syntax(NULL, p, e, - "bad syntax (excluded name is not an identifier)"); - } - } - - reprovided = scheme_make_pair(scheme_make_pair(midx, scheme_make_pair(e, exns)), - reprovided); - } else if (SAME_OBJ(struct_symbol, SCHEME_STX_VAL(fst))) { - /* (struct ( ...)) */ - int len, i; - Scheme_Object *prnt_base, *base, *fields, *el, **names; - - len = scheme_stx_proper_list_length(rest); - if (len != 2) { - if (len < 0) - scheme_wrong_syntax(NULL, a, e, "bad syntax (" IMPROPER_LIST_FORM ")"); - else - scheme_wrong_syntax(NULL, a, e, "bad syntax " - "(not a struct identifier followed by " - "a sequence of field identifiers)"); - } - - base = SCHEME_STX_CAR(rest); - fields = SCHEME_STX_CDR(rest); - fields = SCHEME_STX_CAR(fields); - - if (!SCHEME_STX_SYMBOLP(base)) - scheme_wrong_syntax(NULL, base, e, - "bad syntax (struct name is not an identifier)"); - - /* Check all field names are identifiers: */ - for (el = fields; SCHEME_STX_PAIRP(el); el = SCHEME_STX_CDR(el)) { - p = SCHEME_STX_CAR(el); - if (!SCHEME_STX_SYMBOLP(p)) { - scheme_wrong_syntax(NULL, p, e, - "bad syntax (field name is not an identifier)"); - } - } - if (!SCHEME_STX_NULLP(el)) - scheme_wrong_syntax(NULL, fields, e, - "bad syntax (" IMPROPER_LIST_FORM ")"); - - prnt_base = base; - base = SCHEME_STX_VAL(base); - fields = scheme_syntax_to_datum(fields, 0, NULL); - - names = scheme_make_struct_names(base, fields, SCHEME_STRUCT_EXPTIME, &len); - - for (i = 0; i < len; i++) { - if (scheme_hash_get(provided, names[i])) - scheme_wrong_syntax("module", names[i], e, "identifier already provided"); - /* Wrap local name with prnt_base in case there are marks that - trigger "gensym"ing */ - scheme_hash_set(provided, names[i], - scheme_make_pair(scheme_datum_to_syntax(names[i], scheme_false, prnt_base, 0, 0), - protect_cnt ? scheme_true : scheme_false)); - } - } else if (SAME_OBJ(all_defined_symbol, SCHEME_STX_VAL(fst))) { - /* (all-defined) */ - if (!SCHEME_STX_NULLP(rest)) - scheme_wrong_syntax(NULL, a, e, "bad syntax"); - - all_defs_out = scheme_make_pair(scheme_make_pair(scheme_make_pair(e, - scheme_make_pair(scheme_null, - scheme_false)), - protect_cnt ? scheme_true : scheme_false), - all_defs_out); - } else if (SAME_OBJ(prefix_all_defined_symbol, SCHEME_STX_VAL(fst))) { - /* (prefix-all-defined ) */ - Scheme_Object *prefix; - - if (!SCHEME_STX_PAIRP(rest)) - scheme_wrong_syntax(NULL, a, e, "bad syntax"); - prefix = SCHEME_STX_CAR(rest); - rest = SCHEME_STX_CDR(rest); - if (!SCHEME_STX_NULLP(rest)) - scheme_wrong_syntax(NULL, a, e, "bad syntax"); - - if (!SCHEME_STX_SYMBOLP(prefix)) { - scheme_wrong_syntax(NULL, a, e, - "bad syntax (prefix is not an identifier)"); - } - prefix = SCHEME_STX_VAL(prefix); - - all_defs_out = scheme_make_pair(scheme_make_pair(scheme_make_pair(e, - scheme_make_pair(scheme_null, - prefix)), - protect_cnt ? scheme_true : scheme_false), - all_defs_out); - } else if (SAME_OBJ(all_defined_except_symbol, SCHEME_STX_VAL(fst)) - || SAME_OBJ(prefix_all_defined_except_symbol, SCHEME_STX_VAL(fst))) { - /* ([prefix-]all-defined-except ...) */ - Scheme_Object *exns, *el, *prefix = scheme_false; - int len, is_prefix; - - is_prefix = SAME_OBJ(prefix_all_defined_except_symbol, SCHEME_STX_VAL(fst)); - - len = scheme_stx_proper_list_length(a); - - if (len < 0) - scheme_wrong_syntax(NULL, a, e, "bad syntax (" IMPROPER_LIST_FORM ")"); - - if (is_prefix && (len < 2)) - scheme_wrong_syntax(NULL, a, e, "bad syntax (missing prefix)"); - - if (is_prefix) { - prefix = SCHEME_STX_CAR(rest); - if (!SCHEME_STX_SYMBOLP(prefix)) - scheme_wrong_syntax(NULL, a, e, "bad syntax (prefix is not an identifier)"); - prefix = SCHEME_STX_VAL(prefix); - rest = SCHEME_STX_CDR(rest); - } - - exns = rest; - - /* Check all exclusions are identifiers: */ - for (el = exns; SCHEME_STX_PAIRP(el); el = SCHEME_STX_CDR(el)) { - p = SCHEME_STX_CAR(el); - if (!SCHEME_STX_SYMBOLP(p)) { - scheme_wrong_syntax(NULL, p, e, - "bad syntax (excluded name is not an identifier)"); - } - } - - all_defs_out = scheme_make_pair(scheme_make_pair(scheme_make_pair(e, - scheme_make_pair(exns, - prefix)), - protect_cnt ? scheme_true : scheme_false), - all_defs_out); - } else { - scheme_wrong_syntax(NULL, a, e, NULL); - } - } else { - scheme_wrong_syntax(NULL, a, e, NULL); - } - - if (protect_cnt) - --protect_cnt; - } + dt_reprovided = parse_provides(form, fst, e, + dt_provided, dt_reprovided, + self_modidx, + NULL); if (rec[drec].comp) e = NULL; @@ -4847,10 +5049,6 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, et_mn = env->genv->exp_env->marked_names; - if (rec[drec].comp || (rec[drec].depth != -2)) { - scheme_clean_dead_env(env->genv); - } - /* If compiling, drop expressions that are constants: */ if (rec[drec].comp) { Scheme_Object *prev = NULL, *next; @@ -4867,178 +5065,25 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, } /* Compute provides for re-provides and all-defs-out: */ - { - int i; - Scheme_Object *rx; - - reprovide_kernel = 0; - - /* First, check the sanity of the re-provide specifications: */ - for (rx = reprovided; !SCHEME_NULLP(rx); rx = SCHEME_CDR(rx)) { - Scheme_Object *midx = SCHEME_CAR(SCHEME_CAR(rx)), *l, *exns; - - for (l = env->genv->module->requires; SCHEME_PAIRP(l); l = SCHEME_CDR(l)) { - if (same_modidx(midx, SCHEME_CAR(l))) - break; - } - if (SCHEME_NULLP(l)) { - /* Didn't require the named module */ - Scheme_Object *name; - name = SCHEME_CAR(rx); - name = SCHEME_STX_CDR(name); - name = SCHEME_STX_CAR(name); - scheme_wrong_syntax("module", - SCHEME_SYMBOLP(midx) ? midx : ((Scheme_Modidx *)midx)->path, - name, - "cannot provide from a module without a matching `require'"); - } - - exns = SCHEME_CDR(SCHEME_CDR(SCHEME_CAR(rx))); - for (l = exns; !SCHEME_STX_NULLP(l); l = SCHEME_STX_CDR(l)) { - /* Make sure excluded name was required: */ - Scheme_Object *a, *vec; - a = SCHEME_STX_VAL(SCHEME_STX_CAR(l)); - vec = scheme_hash_get(required, a); - if (vec) { - /* Check for nominal modidx in list */ - Scheme_Object *nml; - nml = SCHEME_VEC_ELS(vec)[0]; - for (; SCHEME_PAIRP(nml); nml = SCHEME_CDR(nml)) { - if (same_modidx(SCHEME_CAR(SCHEME_CAR(rx)), SCHEME_CAR(nml))) - break; - } - if (!SCHEME_PAIRP(nml)) - vec = NULL; /* So it was provided, but not from the indicated module */ - } - if (!vec) { - a = SCHEME_STX_CAR(l); - scheme_wrong_syntax("module", a, SCHEME_CADR(SCHEME_CAR(rx)), - "excluded name was not required from the module"); - } - } - } - - /* Walk through requires, check for re-providing: */ - for (i = required->size; i--; ) { - if (required->vals[i]) { - Scheme_Object *nominal_modidx, *name, *modidx, *srcname, *outname, *nml, *orig_nml; - int break_outer = 0; - - name = required->keys[i]; - orig_nml = SCHEME_VEC_ELS(required->vals[i])[0]; - modidx = SCHEME_VEC_ELS(required->vals[i])[1]; - srcname = SCHEME_VEC_ELS(required->vals[i])[2]; - outname = SCHEME_VEC_ELS(required->vals[i])[4]; - - for (rx = reprovided; !SCHEME_NULLP(rx); rx = SCHEME_CDR(rx)) { - for (nml = orig_nml; SCHEME_PAIRP(nml); nml = SCHEME_CDR(nml)) { - nominal_modidx = SCHEME_CAR(nml); - if (same_modidx(SCHEME_CAR(SCHEME_CAR(rx)), nominal_modidx)) { - Scheme_Object *exns, *ree; - - break_outer = 1; - - ree = SCHEME_CDR(SCHEME_CAR(rx)); - - exns = SCHEME_CDR(ree); - if (SAME_OBJ(modidx, kernel_symbol)) - if (!SCHEME_STX_NULLP(exns)) - exclude_hint = exns; - - for (; !SCHEME_STX_NULLP(exns); exns = SCHEME_STX_CDR(exns)) { - /* Was this name exluded? */ - Scheme_Object *a; - a = SCHEME_STX_VAL(SCHEME_STX_CAR(exns)); - if (SAME_OBJ(a, name)) - break; - } - - if (SCHEME_STX_NULLP(exns)) { - /* Not excluded, so provide it. */ - if (scheme_hash_get(provided, outname)) - scheme_wrong_syntax("module", outname, SCHEME_CAR(ree), "identifier already provided"); - - scheme_hash_set(provided, outname, scheme_make_pair(name, scheme_false)); - - if (SAME_OBJ(modidx, kernel_symbol) && SAME_OBJ(outname, srcname)) - reprovide_kernel++; - } - } - } - if (break_outer) break; - } - } - } - - /* Do all-defined provides */ - for (; !SCHEME_NULLP(all_defs_out); all_defs_out = SCHEME_CDR(all_defs_out)) { - Scheme_Object *exns, *ree, *ree_kw, *exl, *name, *a, *adl, *exname, *pfx; - int protected; - - ree = SCHEME_CAR(all_defs_out); - protected = SCHEME_TRUEP(SCHEME_CDR(ree)); - ree = SCHEME_CAR(ree); - ree_kw = SCHEME_CAR(ree); - ree = SCHEME_CDR(ree); - exl = SCHEME_CAR(ree); - pfx = SCHEME_CDR(ree); - - /* Make sure each excluded name was defined: */ - for (exns = exl; !SCHEME_STX_NULLP(exns); exns = SCHEME_STX_CDR(exns)) { - a = SCHEME_STX_CAR(exns); - name = scheme_tl_id_sym(env->genv, a, NULL, 0); - if (!scheme_lookup_in_table(env->genv->toplevel, (const char *)name) - && !scheme_lookup_in_table(env->genv->syntax, (const char *)name)) { - scheme_wrong_syntax("module", a, ree_kw, "excluded identifier was not defined"); - } - } - - for (adl = all_defs; SCHEME_PAIRP(adl); adl = SCHEME_CDR(adl)) { - name = SCHEME_CAR(adl); - exname = SCHEME_STX_SYM(name); - name = scheme_tl_id_sym(env->genv, name, NULL, 0); - - /* Was this one excluded? */ - for (exns = exl; !SCHEME_STX_NULLP(exns); exns = SCHEME_STX_CDR(exns)) { - a = SCHEME_STX_CAR(exns); - a = scheme_tl_id_sym(env->genv, a, NULL, 0); - if (SAME_OBJ(a, name)) - break; - } - - if (SCHEME_STX_NULLP(exns)) { - /* not excluded */ - - /* But don't export uninterned: */ - if (!SCHEME_SYM_UNINTERNEDP(name)) { - /* Also, check that ree_kw and the identifier have the same - introduction (in case one or the other was introduced by - a macro). We perform this check by getting exname's tl_id - as if it had ree_kw's context, then comparing that result - to the actual tl_id. */ - a = scheme_datum_to_syntax(exname, scheme_false, ree_kw, 0, 0); - a = scheme_tl_id_sym(env->genv, a, NULL, 0); - - if (SAME_OBJ(a, name)) { - /* Add prefix, if any */ - if (SCHEME_TRUEP(pfx)) { - exname = scheme_symbol_append(pfx, exname); - } - if (scheme_hash_get(provided, exname)) - scheme_wrong_syntax("module", exname, ree_kw, "identifier already provided"); - - scheme_hash_set(provided, exname, - scheme_make_pair(name, protected ? scheme_true : scheme_false)); - } - } - } - } - } - } + reprovide_kernel = compute_reprovides(provided, reprovided, + env->genv->module->requires, required, + env->genv, all_defs, all_defs_out, + &exclude_hint, + "require"); + (void)compute_reprovides(et_provided, et_reprovided, + env->genv->module->et_requires, et_required, + env->genv->exp_env, all_et_defs, all_et_defs_out, + NULL, + "require-for-syntax"); + (void)compute_reprovides(dt_provided, dt_reprovided, + env->genv->module->dt_requires, dt_required, + NULL, NULL, NULL, + NULL, + "require-for-label"); /* Ad hoc optimization: mzscheme is everything from kernel except #%module_begin */ - if ((reprovide_kernel == (kernel->me->num_provides - 1)) + if ((reprovide_kernel == (kernel->me->rt->num_provides - 1)) && SCHEME_FALSEP(exclude_hint)) { exclude_hint = scheme_make_pair(module_begin_symbol, scheme_null); exclude_hint = scheme_datum_to_syntax(exclude_hint, scheme_false, scheme_top_stx, 0, 0); @@ -5046,7 +5091,7 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, /* Re-providing all of the kernel without prefixing? */ if (reprovide_kernel) { - if ((reprovide_kernel == (kernel->me->num_provides - 1)) + if ((reprovide_kernel == (kernel->me->rt->num_provides - 1)) && SCHEME_TRUEP(exclude_hint)) { if (SCHEME_STX_PAIRP(exclude_hint) && SCHEME_NULLP(SCHEME_STX_CDR(exclude_hint))) { Scheme_Object *n; @@ -5068,7 +5113,7 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, reprovide_kernel = 0; } else reprovide_kernel = 0; - } else if (reprovide_kernel != kernel->me->num_provides) + } else if (reprovide_kernel != kernel->me->rt->num_provides) reprovide_kernel = 0; else exclude_hint = scheme_false; @@ -5076,124 +5121,35 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, /* If reprovide_kernel is non-zero, we re-provide all of it */ /* Compute provide arrays */ - { - int i, count; - - for (count = 0, i = provided->size; i--; ) { - if (provided->vals[i]) - count++; - } - - count -= reprovide_kernel; - - exs = MALLOC_N(Scheme_Object *, count); - exsns = MALLOC_N(Scheme_Object *, count); - exss = MALLOC_N(Scheme_Object *, count); - exps = MALLOC_N_ATOMIC(char, count); - - /* Do non-syntax first. */ - for (count = 0, i = provided->size; i--; ) { - if (provided->vals[i]) { - Scheme_Object *name, *prnt_name, *v; - int protected; - - v = provided->vals[i]; - name = SCHEME_CAR(v); - protected = SCHEME_TRUEP(SCHEME_CDR(v)); - - prnt_name = name; - if (SCHEME_STXP(name)) - name = scheme_tl_id_sym(env->genv, name, NULL, 0); - - if (scheme_lookup_in_table(env->genv->toplevel, (const char *)name)) { - /* Defined locally */ - exs[count] = provided->keys[i]; - exsns[count] = name; - exss[count] = scheme_false; /* means "self" */ - exps[count] = protected; - count++; - } else if (scheme_lookup_in_table(env->genv->syntax, (const char *)name)) { - /* Skip for now. */ - } else if ((v = scheme_hash_get(required, name))) { - /* Required */ - if (protected) { - name = SCHEME_CAR(provided->vals[i]); - scheme_wrong_syntax("module", NULL, name, "cannot protect imported identifier with re-provide"); - } - if (SCHEME_TRUEP(SCHEME_VEC_ELS(v)[3])) { - /* If this is a kernel re-provide, don't provide after all. */ - if (reprovide_kernel - && SAME_OBJ(SCHEME_VEC_ELS(v)[1], kernel_symbol) - && SAME_OBJ(provided->keys[i], SCHEME_VEC_ELS(v)[2])) { - /* skip */ - } else { - exs[count] = provided->keys[i]; - exsns[count] = SCHEME_VEC_ELS(v)[2]; - exss[count] = SCHEME_VEC_ELS(v)[1]; - exps[count] = protected; - count++; - } - } - } else { - /* Not defined! */ - scheme_wrong_syntax("module", prnt_name, form, "provided identifier not defined or imported"); - } - } - } - - exvcount = count; - - for (i = provided->size; i--; ) { - if (provided->vals[i]) { - Scheme_Object *name, *v; - int protected; - - v = provided->vals[i]; - name = SCHEME_CAR(v); - protected = SCHEME_TRUEP(SCHEME_CDR(v)); - - if (SCHEME_STXP(name)) - name = scheme_tl_id_sym(env->genv, name, NULL, 0); - - if (scheme_lookup_in_table(env->genv->syntax, (const char *)name)) { - /* Defined locally */ - exs[count] = provided->keys[i]; - exsns[count] = name; - exss[count] = scheme_false; /* means "self" */ - exps[count] = protected; - count++; - } else if ((v = scheme_hash_get(required, name))) { - /* Required */ - if (SCHEME_FALSEP(SCHEME_VEC_ELS(v)[3])) { - /* If this is a kernel re-provide, don't provide after all. */ - if (reprovide_kernel - && SAME_OBJ(SCHEME_VEC_ELS(v)[1], kernel_symbol) - && SAME_OBJ(provided->keys[i], SCHEME_VEC_ELS(v)[2])) { - /* skip */ - } else { - exs[count] = provided->keys[i]; - exsns[count] = SCHEME_VEC_ELS(v)[2]; - exss[count] = SCHEME_VEC_ELS(v)[1]; - exps[count] = protected; - count++; - } - } - } - } - } - - excount = count; - - /* Sort provide array for variables: interned followed by - uninterned, alphabetical within each. This is important for - having a consistent provide arrays. */ - qsort_provides(exs, exsns, exss, exps, 0, exvcount, 1); + exps = compute_provide_arrays(provided, required, + env->genv->module->me->rt, + env->genv, 0, + reprovide_kernel, + form, + "provided identifier not defined or imported"); + (void)compute_provide_arrays(et_provided, et_required, + env->genv->module->me->et, + env->genv->exp_env, 1, + 0, + form, + "for-syntax provided identifier not defined for syntax or imported for syntax"); + (void)compute_provide_arrays(dt_provided, dt_required, + env->genv->module->me->dt, + NULL, 0, + 0, + form, + "for-label provided identifier not imported for label"); + + if (rec[drec].comp || (rec[drec].depth != -2)) { + scheme_clean_dead_env(env->genv); } /* Compute indirect provides (which is everything at the top-level): */ { int i, count, j; Scheme_Bucket **bs, *b; + Scheme_Object **exsns = env->genv->module->me->rt->provide_src_names; + int exvcount = env->genv->module->me->rt->num_var_provides; bs = env->genv->toplevel->buckets; for (count = 0, i = env->genv->toplevel->size; i--; ) { @@ -5228,6 +5184,13 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, } if (!rec[drec].comp) { + Scheme_Module_Phase_Exports *rt = env->genv->module->me->rt; + int excount = rt->num_provides; + int exvcount = rt->num_var_provides; + Scheme_Object **exsns = rt->provide_src_names; + Scheme_Object **exs = rt->provides; + Scheme_Object **exss = rt->provide_srcs; + /* Produce annotations (in the form of properties) for module information: 'module-variable-provides = '(item ...) @@ -5271,16 +5234,16 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, if (reprovide_kernel) { if (!j) { - i = kernel->me->num_var_provides; - top = kernel->me->num_provides; + i = kernel->me->rt->num_var_provides; + top = kernel->me->rt->num_provides; } else { i = 0; - top = kernel->me->num_var_provides; + top = kernel->me->rt->num_var_provides; } for (; i < top; i++) { - if (!SAME_OBJ(kernel->me->provides[i], exclude_hint)) { - a = scheme_make_immutable_pair(kernel->me->provides[i], kernel->me->provides[i]); + if (!SAME_OBJ(kernel->me->rt->provides[i], exclude_hint)) { + a = scheme_make_immutable_pair(kernel->me->rt->provides[i], kernel->me->rt->provides[i]); a = scheme_make_immutable_pair(kernel_symbol, a); e = scheme_make_immutable_pair(a, e); } @@ -5326,16 +5289,10 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, env->genv->module->body = first; env->genv->module->et_body = exp_body_r; - /* Install final provides: */ - env->genv->module->me->num_provides = excount; - env->genv->module->me->num_var_provides = exvcount; - env->genv->module->me->provides = exs; - env->genv->module->me->provide_src_names = exsns; - env->genv->module->me->provide_srcs = exss; env->genv->module->provide_protects = exps; - env->genv->module->me->reprovide_kernel = reprovide_kernel; - env->genv->module->me->kernel_exclusion = exclude_hint; + env->genv->module->me->rt->reprovide_kernel = reprovide_kernel; + env->genv->module->me->rt->kernel_exclusion = exclude_hint; env->genv->module->indirect_provides = exis; env->genv->module->num_indirect_provides = exicount; @@ -5347,12 +5304,17 @@ static Scheme_Object *do_module_begin(Scheme_Object *form, Scheme_Comp_Env *env, env->genv->module->rn_stx = scheme_true; } if (et_all_simple_renames + && all_simple_renames && (et_mn->count == 1 /* just the false mapping */)) { env->genv->module->et_rn_stx = scheme_true; } if (tt_all_simple_renames) { env->genv->module->tt_rn_stx = scheme_true; } + if (dt_all_simple_renames + && all_simple_renames) { + env->genv->module->dt_rn_stx = scheme_true; + } return (Scheme_Object *)env->genv->module; } else { @@ -5381,6 +5343,343 @@ module_begin_expand(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Expand_Inf return do_module_begin(form, env, erec, drec); } +int compute_reprovides(Scheme_Hash_Table *provided, Scheme_Object *reprovided, + Scheme_Object *requires, Scheme_Hash_Table *required, + Scheme_Env *genv, Scheme_Object *all_defs, Scheme_Object *all_defs_out, + Scheme_Object **_exclude_hint, + const char *matching_form) +{ + int i; + Scheme_Object *rx; + int reprovide_kernel = 0; + + /* First, check the sanity of the re-provide specifications: */ + for (rx = reprovided; !SCHEME_NULLP(rx); rx = SCHEME_CDR(rx)) { + Scheme_Object *midx = SCHEME_CAR(SCHEME_CAR(rx)), *l, *exns; + + for (l = requires; SCHEME_PAIRP(l); l = SCHEME_CDR(l)) { + if (same_modidx(midx, SCHEME_CAR(l))) + break; + } + if (SCHEME_NULLP(l)) { + /* Didn't require the named module */ + Scheme_Object *name; + name = SCHEME_CAR(rx); + name = SCHEME_STX_CDR(name); + name = SCHEME_STX_CAR(name); + scheme_wrong_syntax("module", + SCHEME_SYMBOLP(midx) ? midx : ((Scheme_Modidx *)midx)->path, + name, + "cannot provide from a module without a matching `%s'", + matching_form); + } + + exns = SCHEME_CDR(SCHEME_CDR(SCHEME_CAR(rx))); + for (l = exns; !SCHEME_STX_NULLP(l); l = SCHEME_STX_CDR(l)) { + /* Make sure excluded name was required: */ + Scheme_Object *a, *vec; + a = SCHEME_STX_VAL(SCHEME_STX_CAR(l)); + vec = scheme_hash_get(required, a); + if (vec) { + /* Check for nominal modidx in list */ + Scheme_Object *nml; + nml = SCHEME_VEC_ELS(vec)[0]; + for (; SCHEME_PAIRP(nml); nml = SCHEME_CDR(nml)) { + if (same_modidx(SCHEME_CAR(SCHEME_CAR(rx)), SCHEME_CAR(nml))) + break; + } + if (!SCHEME_PAIRP(nml)) + vec = NULL; /* So it was provided, but not from the indicated module */ + } + if (!vec) { + a = SCHEME_STX_CAR(l); + scheme_wrong_syntax("module", a, SCHEME_CADR(SCHEME_CAR(rx)), + "excluded name was not required from the module"); + } + } + } + + /* Walk through requires, check for re-providing: */ + for (i = required->size; i--; ) { + if (required->vals[i]) { + Scheme_Object *nominal_modidx, *name, *modidx, *srcname, *outname, *nml, *orig_nml; + int break_outer = 0; + + name = required->keys[i]; + orig_nml = SCHEME_VEC_ELS(required->vals[i])[0]; + modidx = SCHEME_VEC_ELS(required->vals[i])[1]; + srcname = SCHEME_VEC_ELS(required->vals[i])[2]; + outname = SCHEME_VEC_ELS(required->vals[i])[4]; + + for (rx = reprovided; !SCHEME_NULLP(rx); rx = SCHEME_CDR(rx)) { + for (nml = orig_nml; SCHEME_PAIRP(nml); nml = SCHEME_CDR(nml)) { + nominal_modidx = SCHEME_CAR(nml); + if (same_modidx(SCHEME_CAR(SCHEME_CAR(rx)), nominal_modidx)) { + Scheme_Object *exns, *ree; + + break_outer = 1; + + ree = SCHEME_CDR(SCHEME_CAR(rx)); + + exns = SCHEME_CDR(ree); + if (SAME_OBJ(modidx, kernel_symbol)) + if (!SCHEME_STX_NULLP(exns)) { + if (_exclude_hint) + *_exclude_hint = exns; + } + + for (; !SCHEME_STX_NULLP(exns); exns = SCHEME_STX_CDR(exns)) { + /* Was this name exluded? */ + Scheme_Object *a; + a = SCHEME_STX_VAL(SCHEME_STX_CAR(exns)); + if (SAME_OBJ(a, name)) + break; + } + + if (SCHEME_STX_NULLP(exns)) { + /* Not excluded, so provide it. */ + if (scheme_hash_get(provided, outname)) + scheme_wrong_syntax("module", outname, SCHEME_CAR(ree), "identifier already provided"); + + scheme_hash_set(provided, outname, scheme_make_pair(name, scheme_false)); + + if (SAME_OBJ(modidx, kernel_symbol) && SAME_OBJ(outname, srcname)) + reprovide_kernel++; + } + } + } + if (break_outer) break; + } + } + } + + /* Do all-defined provides */ + if (all_defs_out) { + for (; !SCHEME_NULLP(all_defs_out); all_defs_out = SCHEME_CDR(all_defs_out)) { + Scheme_Object *exns, *ree, *ree_kw, *exl, *name, *a, *adl, *exname, *pfx; + int protected; + + ree = SCHEME_CAR(all_defs_out); + protected = SCHEME_TRUEP(SCHEME_CDR(ree)); + ree = SCHEME_CAR(ree); + ree_kw = SCHEME_CAR(ree); + ree = SCHEME_CDR(ree); + exl = SCHEME_CAR(ree); + pfx = SCHEME_CDR(ree); + + /* Make sure each excluded name was defined: */ + for (exns = exl; !SCHEME_STX_NULLP(exns); exns = SCHEME_STX_CDR(exns)) { + a = SCHEME_STX_CAR(exns); + name = scheme_tl_id_sym(genv, a, NULL, 0); + if (!scheme_lookup_in_table(genv->toplevel, (const char *)name) + && !scheme_lookup_in_table(genv->syntax, (const char *)name)) { + scheme_wrong_syntax("module", a, ree_kw, "excluded identifier was not defined"); + } + } + + for (adl = all_defs; SCHEME_PAIRP(adl); adl = SCHEME_CDR(adl)) { + name = SCHEME_CAR(adl); + exname = SCHEME_STX_SYM(name); + name = scheme_tl_id_sym(genv, name, NULL, 0); + + /* Was this one excluded? */ + for (exns = exl; !SCHEME_STX_NULLP(exns); exns = SCHEME_STX_CDR(exns)) { + a = SCHEME_STX_CAR(exns); + a = scheme_tl_id_sym(genv, a, NULL, 0); + if (SAME_OBJ(a, name)) + break; + } + + if (SCHEME_STX_NULLP(exns)) { + /* not excluded */ + + /* But don't export uninterned: */ + if (!SCHEME_SYM_UNINTERNEDP(name)) { + /* Also, check that ree_kw and the identifier have the same + introduction (in case one or the other was introduced by + a macro). We perform this check by getting exname's tl_id + as if it had ree_kw's context, then comparing that result + to the actual tl_id. */ + a = scheme_datum_to_syntax(exname, scheme_false, ree_kw, 0, 0); + a = scheme_tl_id_sym(genv, a, NULL, 0); + + if (SAME_OBJ(a, name)) { + /* Add prefix, if any */ + if (SCHEME_TRUEP(pfx)) { + exname = scheme_symbol_append(pfx, exname); + } + if (scheme_hash_get(provided, exname)) + scheme_wrong_syntax("module", exname, ree_kw, "identifier already provided"); + + scheme_hash_set(provided, exname, + scheme_make_pair(name, protected ? scheme_true : scheme_false)); + } + } + } + } + } + } + + return reprovide_kernel; +} + +char *compute_provide_arrays(Scheme_Hash_Table *provided, Scheme_Hash_Table *required, + Scheme_Module_Phase_Exports *pt, + Scheme_Env *genv, int def_phase, + int reprovide_kernel, + Scheme_Object *form, + const char *def_way) +{ + int i, count; + Scheme_Object **exs, **exsns, **exss; + char *exps, *exets; + int excount, exvcount; + + for (count = 0, i = provided->size; i--; ) { + if (provided->vals[i]) + count++; + } + + count -= reprovide_kernel; + + exs = MALLOC_N(Scheme_Object *, count); + exsns = MALLOC_N(Scheme_Object *, count); + exss = MALLOC_N(Scheme_Object *, count); + exps = MALLOC_N_ATOMIC(char, count); + if (def_phase) + exets = MALLOC_N_ATOMIC(char, count); + else + exets = NULL; + + /* Do non-syntax first. */ + for (count = 0, i = provided->size; i--; ) { + if (provided->vals[i]) { + Scheme_Object *name, *prnt_name, *v; + int protected; + + v = provided->vals[i]; + name = SCHEME_CAR(v); + protected = SCHEME_TRUEP(SCHEME_CDR(v)); + + prnt_name = name; + if (SCHEME_STXP(name)) { + if (genv) + name = scheme_tl_id_sym(genv, name, NULL, 0); + else + name = SCHEME_STX_VAL(name); /* shouldn't get here; no `define-for-label' */ + } + + if (genv && scheme_lookup_in_table(genv->toplevel, (const char *)name)) { + /* Defined locally */ + exs[count] = provided->keys[i]; + exsns[count] = name; + exss[count] = scheme_false; /* means "self" */ + exps[count] = protected; + if (exets) + exets[count] = def_phase; + count++; + } else if (genv && scheme_lookup_in_table(genv->syntax, (const char *)name)) { + /* Skip for now. */ + } else if ((v = scheme_hash_get(required, name))) { + /* Required */ + if (protected) { + name = SCHEME_CAR(provided->vals[i]); + scheme_wrong_syntax("module", NULL, name, "cannot protect imported identifier with re-provide"); + } + if (SCHEME_TRUEP(SCHEME_VEC_ELS(v)[3])) { + /* If this is a kernel re-provide, don't provide after all. */ + if (reprovide_kernel + && SAME_OBJ(SCHEME_VEC_ELS(v)[1], kernel_symbol) + && SAME_OBJ(provided->keys[i], SCHEME_VEC_ELS(v)[2])) { + /* skip */ + } else { + exs[count] = provided->keys[i]; + exsns[count] = SCHEME_VEC_ELS(v)[2]; + exss[count] = SCHEME_VEC_ELS(v)[1]; + exps[count] = protected; + count++; + } + } + } else { + /* Not defined! */ + scheme_wrong_syntax("module", prnt_name, form, def_way); + } + } + } + + exvcount = count; + + for (i = provided->size; i--; ) { + if (provided->vals[i]) { + Scheme_Object *name, *v; + int protected; + + v = provided->vals[i]; + name = SCHEME_CAR(v); + protected = SCHEME_TRUEP(SCHEME_CDR(v)); + + if (SCHEME_STXP(name)) { + if (genv) + name = scheme_tl_id_sym(genv, name, NULL, 0); + else { + name = SCHEME_STX_VAL(name); /* shouldn't get here; no `define-for-label' */ + } + } + + if (genv && scheme_lookup_in_table(genv->syntax, (const char *)name)) { + /* Defined locally */ + exs[count] = provided->keys[i]; + exsns[count] = name; + exss[count] = scheme_false; /* means "self" */ + exps[count] = protected; + if (exets) + exets[count] = def_phase; + count++; + } else if ((v = scheme_hash_get(required, name))) { + /* Required */ + if (SCHEME_FALSEP(SCHEME_VEC_ELS(v)[3])) { + /* If this is a kernel re-provide, don't provide after all. */ + if (reprovide_kernel + && SAME_OBJ(SCHEME_VEC_ELS(v)[1], kernel_symbol) + && SAME_OBJ(provided->keys[i], SCHEME_VEC_ELS(v)[2])) { + /* skip */ + } else { + exs[count] = provided->keys[i]; + exsns[count] = SCHEME_VEC_ELS(v)[2]; + exss[count] = SCHEME_VEC_ELS(v)[1]; + exps[count] = protected; + count++; + } + } + } + } + } + + excount = count; + + /* Sort provide array for variables: interned followed by + uninterned, alphabetical within each. This is important for + having a consistent provide arrays. */ + qsort_provides(exs, exsns, exss, exps, 0, exvcount, 1); + + pt->num_provides = excount; + pt->num_var_provides = exvcount; + pt->provides = exs; + pt->provide_src_names = exsns; + pt->provide_srcs = exss; + if (exets) { + for (i = 0; i < excount; i++) { + if (exets[i]) + break; + } + if (i < excount) + exets = NULL; + } + pt->provide_src_phases = exets; + + return exps; +} + /* Helper: */ static void qsort_provides(Scheme_Object **exs, Scheme_Object **exsns, Scheme_Object **exss, char *exps, int start, int count, int do_uninterned) @@ -5476,33 +5775,302 @@ static void qsort_provides(Scheme_Object **exs, Scheme_Object **exsns, Scheme_Ob } } +Scheme_Object *parse_provides(Scheme_Object *form, Scheme_Object *fst, Scheme_Object *e, + Scheme_Hash_Table *provided, Scheme_Object *reprovided, + Scheme_Object *self_modidx, Scheme_Object **_all_defs_out) +{ + Scheme_Object *l; + int protect_cnt = 0; + Scheme_Object *all_defs_out = (_all_defs_out ? *_all_defs_out : NULL); + + if (scheme_stx_proper_list_length(e) < 0) + scheme_wrong_syntax(NULL, e, form, "bad syntax (" IMPROPER_LIST_FORM ")"); + + for (l = SCHEME_STX_CDR(e); !SCHEME_STX_NULLP(l); l = SCHEME_STX_CDR(l)) { + Scheme_Object *a, *midx, *name; + + a = SCHEME_STX_CAR(l); + + if (SCHEME_STX_PAIRP(a) && (scheme_stx_proper_list_length(a) > 0)) { + fst = SCHEME_STX_CAR(a); + if (SCHEME_STX_SYMBOLP(fst) + && (SAME_OBJ(protect_symbol, SCHEME_STX_VAL(fst)))) { + if (protect_cnt) + scheme_wrong_syntax(NULL, a, e, "bad syntax (nested protect)"); + a = SCHEME_STX_CDR(a); + a = scheme_flatten_syntax_list(a, NULL); + l = SCHEME_STX_CDR(l); + l = scheme_append(a, l); + protect_cnt = scheme_list_length(a); + + /* In case a provide ends with an empty protect: */ + if (SCHEME_STX_NULLP(l)) + break; + + a = SCHEME_STX_CAR(l); + } + } + + if (SCHEME_STX_SYMBOLP(a)) { + /* */ + name = SCHEME_STX_VAL(a); + if (scheme_hash_get(provided, name)) + scheme_wrong_syntax("module", a, form, "identifier already provided"); + /* Provide a: */ + scheme_hash_set(provided, name, scheme_make_pair(a, protect_cnt ? scheme_true : scheme_false)); + } else if (SCHEME_STX_PAIRP(a)) { + Scheme_Object *rest; + + fst = SCHEME_STX_CAR(a); + rest = SCHEME_STX_CDR(a); + + if (SAME_OBJ(rename_symbol, SCHEME_STX_VAL(fst))) { + /* (rename ) */ + Scheme_Object *inm, *enm; + + if (!SCHEME_STX_PAIRP(rest) + || !SCHEME_STX_PAIRP(SCHEME_STX_CDR(rest))) + scheme_wrong_syntax(NULL, a, e, "bad syntax"); + inm = SCHEME_STX_CAR(rest); + rest = SCHEME_STX_CDR(rest); + enm = SCHEME_STX_CAR(rest); + if (!SCHEME_STX_SYMBOLP(inm)) + scheme_wrong_syntax(NULL, a, e, "bad syntax (internal name is not an identifier)"); + if (!SCHEME_STX_SYMBOLP(enm)) + scheme_wrong_syntax(NULL, a, e, "bad syntax (external name is not an identifier)"); + rest = SCHEME_STX_CDR(rest); + if (!SCHEME_STX_NULLP(rest)) + scheme_wrong_syntax(NULL, a, e, "bad syntax (data following external name)"); + + enm = SCHEME_STX_VAL(enm); + + if (scheme_hash_get(provided, enm)) + scheme_wrong_syntax("module", enm, a, "identifier already provided"); + /* Provide enm: */ + scheme_hash_set(provided, enm, scheme_make_pair(inm, protect_cnt ? scheme_true : scheme_false)); + } else if (SAME_OBJ(all_from_symbol, SCHEME_STX_VAL(fst))) { + /* (all-from ) */ + if (protect_cnt) + scheme_wrong_syntax(NULL, a, e, "bad syntax (not allowed as protected)"); + if (!SCHEME_STX_PAIRP(rest)) + scheme_wrong_syntax(NULL, a, e, "bad syntax"); + if (!SCHEME_STX_NULLP(SCHEME_STX_CDR(rest))) + scheme_wrong_syntax(NULL, a, e, "bad syntax (data following `all-from')"); + + midx = SCHEME_STX_CAR(rest); + midx = scheme_make_modidx(scheme_syntax_to_datum(midx, 0, NULL), + self_modidx, + scheme_false); + + reprovided = scheme_make_pair(scheme_make_pair(midx, scheme_make_pair(e, scheme_null)), + reprovided); + } else if (SAME_OBJ(all_from_except_symbol, SCHEME_STX_VAL(fst))) { + /* (all-from-except ...) */ + Scheme_Object *exns, *el, *p; + int len; + + if (protect_cnt) + scheme_wrong_syntax(NULL, a, e, "bad syntax (not allowed as protected)"); + + len = scheme_stx_proper_list_length(a); + + if (len < 0) + scheme_wrong_syntax(NULL, a, e, "bad syntax (" IMPROPER_LIST_FORM ")"); + else if (len == 1) + scheme_wrong_syntax(NULL, a, e, "bad syntax (missing module name)"); + + midx = SCHEME_STX_CAR(rest); + midx = scheme_make_modidx(scheme_syntax_to_datum(midx, 0, NULL), + self_modidx, + scheme_false); + exns = SCHEME_STX_CDR(rest); + + /* Check all exclusions are identifiers: */ + for (el = exns; SCHEME_STX_PAIRP(el); el = SCHEME_STX_CDR(el)) { + p = SCHEME_STX_CAR(el); + if (!SCHEME_STX_SYMBOLP(p)) { + scheme_wrong_syntax(NULL, p, e, + "bad syntax (excluded name is not an identifier)"); + } + } + + reprovided = scheme_make_pair(scheme_make_pair(midx, scheme_make_pair(e, exns)), + reprovided); + } else if (SAME_OBJ(struct_symbol, SCHEME_STX_VAL(fst))) { + /* (struct ( ...)) */ + int len, i; + Scheme_Object *prnt_base, *base, *fields, *el, **names, *p; + + len = scheme_stx_proper_list_length(rest); + if (len != 2) { + if (len < 0) + scheme_wrong_syntax(NULL, a, e, "bad syntax (" IMPROPER_LIST_FORM ")"); + else + scheme_wrong_syntax(NULL, a, e, "bad syntax " + "(not a struct identifier followed by " + "a sequence of field identifiers)"); + } + + base = SCHEME_STX_CAR(rest); + fields = SCHEME_STX_CDR(rest); + fields = SCHEME_STX_CAR(fields); + + if (!SCHEME_STX_SYMBOLP(base)) + scheme_wrong_syntax(NULL, base, e, + "bad syntax (struct name is not an identifier)"); + + /* Check all field names are identifiers: */ + for (el = fields; SCHEME_STX_PAIRP(el); el = SCHEME_STX_CDR(el)) { + p = SCHEME_STX_CAR(el); + if (!SCHEME_STX_SYMBOLP(p)) { + scheme_wrong_syntax(NULL, p, e, + "bad syntax (field name is not an identifier)"); + } + } + if (!SCHEME_STX_NULLP(el)) + scheme_wrong_syntax(NULL, fields, e, + "bad syntax (" IMPROPER_LIST_FORM ")"); + + prnt_base = base; + base = SCHEME_STX_VAL(base); + fields = scheme_syntax_to_datum(fields, 0, NULL); + + names = scheme_make_struct_names(base, fields, SCHEME_STRUCT_EXPTIME, &len); + + for (i = 0; i < len; i++) { + if (scheme_hash_get(provided, names[i])) + scheme_wrong_syntax("module", names[i], e, "identifier already provided"); + /* Wrap local name with prnt_base in case there are marks that + trigger "gensym"ing */ + scheme_hash_set(provided, names[i], + scheme_make_pair(scheme_datum_to_syntax(names[i], scheme_false, prnt_base, 0, 0), + protect_cnt ? scheme_true : scheme_false)); + } + } else if (SAME_OBJ(all_defined_symbol, SCHEME_STX_VAL(fst))) { + /* (all-defined) */ + if (!SCHEME_STX_NULLP(rest)) + scheme_wrong_syntax(NULL, a, e, "bad syntax"); + + all_defs_out = scheme_make_pair(scheme_make_pair(scheme_make_pair(e, + scheme_make_pair(scheme_null, + scheme_false)), + protect_cnt ? scheme_true : scheme_false), + all_defs_out); + } else if (SAME_OBJ(prefix_all_defined_symbol, SCHEME_STX_VAL(fst))) { + /* (prefix-all-defined ) */ + Scheme_Object *prefix; + + if (!SCHEME_STX_PAIRP(rest)) + scheme_wrong_syntax(NULL, a, e, "bad syntax"); + prefix = SCHEME_STX_CAR(rest); + rest = SCHEME_STX_CDR(rest); + if (!SCHEME_STX_NULLP(rest)) + scheme_wrong_syntax(NULL, a, e, "bad syntax"); + + if (!SCHEME_STX_SYMBOLP(prefix)) { + scheme_wrong_syntax(NULL, a, e, + "bad syntax (prefix is not an identifier)"); + } + prefix = SCHEME_STX_VAL(prefix); + + all_defs_out = scheme_make_pair(scheme_make_pair(scheme_make_pair(e, + scheme_make_pair(scheme_null, + prefix)), + protect_cnt ? scheme_true : scheme_false), + all_defs_out); + } else if (SAME_OBJ(all_defined_except_symbol, SCHEME_STX_VAL(fst)) + || SAME_OBJ(prefix_all_defined_except_symbol, SCHEME_STX_VAL(fst))) { + /* ([prefix-]all-defined-except ...) */ + Scheme_Object *exns, *el, *prefix = scheme_false, *p; + int len, is_prefix; + + is_prefix = SAME_OBJ(prefix_all_defined_except_symbol, SCHEME_STX_VAL(fst)); + + len = scheme_stx_proper_list_length(a); + + if (len < 0) + scheme_wrong_syntax(NULL, a, e, "bad syntax (" IMPROPER_LIST_FORM ")"); + + if (is_prefix && (len < 2)) + scheme_wrong_syntax(NULL, a, e, "bad syntax (missing prefix)"); + + if (is_prefix) { + prefix = SCHEME_STX_CAR(rest); + if (!SCHEME_STX_SYMBOLP(prefix)) + scheme_wrong_syntax(NULL, a, e, "bad syntax (prefix is not an identifier)"); + prefix = SCHEME_STX_VAL(prefix); + rest = SCHEME_STX_CDR(rest); + } + + exns = rest; + + /* Check all exclusions are identifiers: */ + for (el = exns; SCHEME_STX_PAIRP(el); el = SCHEME_STX_CDR(el)) { + p = SCHEME_STX_CAR(el); + if (!SCHEME_STX_SYMBOLP(p)) { + scheme_wrong_syntax(NULL, p, e, + "bad syntax (excluded name is not an identifier)"); + } + } + + all_defs_out = scheme_make_pair(scheme_make_pair(scheme_make_pair(e, + scheme_make_pair(exns, + prefix)), + protect_cnt ? scheme_true : scheme_false), + all_defs_out); + } else { + scheme_wrong_syntax(NULL, a, e, NULL); + } + } else { + scheme_wrong_syntax(NULL, a, e, NULL); + } + + if (protect_cnt) + --protect_cnt; + } + + if (_all_defs_out) + *_all_defs_out = all_defs_out; + + return reprovided; +} + /**********************************************************************/ -/* top-level require */ +/* top-level require */ /**********************************************************************/ void add_single_require(Scheme_Module_Exports *me, /* from module */ + int base_k, /* [0, 1, 2] => start with [rt, et, dt] */ Scheme_Object *idx, /* from module's idx; may be saved for unmarshalling */ - Scheme_Env *env, /* env for mark_src or copy_vars */ - Scheme_Object *rn, /* add requires to this rename when no mark_src */ - Scheme_Object *post_ex_rn, /* add requires to this rename when mark_src */ + Scheme_Env *orig_env, /* env for mark_src or copy_vars */ + Scheme_Object *rt_rn, /* add requires to this rename when no mark_src */ + Scheme_Object *post_ex_rt_rn, /* add requires to this rename when mark_src */ + Scheme_Object *et_rn, Scheme_Object *post_ex_et_rn, + Scheme_Object *dt_rn, Scheme_Object *post_ex_dt_rn, Scheme_Object *exns, /* NULL or [syntax] list of [syntax] symbols not to import */ - Scheme_Hash_Table *onlys, /* NULL or hash table of names to import */ + Scheme_Hash_Table *onlys, /* NULL or hash table of names to import; the hash table is mutated */ Scheme_Object *prefix, /* NULL or prefix symbol */ Scheme_Object *iname, /* NULL or symbol for a single import */ - Scheme_Object *ename, /* NULL or symbol for a single import */ + Scheme_Object *orig_ename, /* NULL or symbol for a single import */ Scheme_Object *mark_src, /* default mark_src; if onlys, each is also mark_src */ int unpack_kern, int copy_vars, int for_unmarshal, int can_save_marshal, int *all_simple, Check_Func ck, /* NULL or called for each addition */ - void *data, Scheme_Object *form, Scheme_Object *err_src, Scheme_Object *cki /* ck args */ + void *rt_data, void *et_data, void *dt_data, + Scheme_Object *form, Scheme_Object *err_src, Scheme_Object *cki /* ck args */ ) { int j, var_count; Scheme_Object *orig_idx = idx; Scheme_Object **exs, **exsns, **exss; + char *exets; + void *data; int is_kern, has_context, save_marshal_info = 0; - Scheme_Object *nominal_modidx, *one_exn, *prnt_iname, *name; + Scheme_Object *nominal_modidx, *one_exn, *prnt_iname, *name, *rn, *post_ex_rn, *ename = orig_ename; + Scheme_Hash_Table *orig_onlys; + Scheme_Env *env; + int k; if (mark_src) { /* Check whether there's context for this import (which @@ -5519,164 +6087,213 @@ void add_single_require(Scheme_Module_Exports *me, /* from module */ if (iname || ename || onlys || for_unmarshal || unpack_kern || has_context) can_save_marshal = 0; + + if (onlys) + orig_onlys = scheme_clone_hash_table(onlys); + else + orig_onlys = NULL; - is_kern = (SAME_OBJ(idx, kernel_symbol) - && !exns - && !onlys - && !prefix - && !iname - && !unpack_kern - && !has_context); + for (k = 0; k < (et_rn ? 3 : 1); k++) { + Scheme_Module_Phase_Exports *pt; - one_exn = NULL; - - nominal_modidx = idx; - - while (1) { /* loop to handle kernel re-provides... */ - int break_if_iname_null = !!iname; - - exs = me->provides; - exsns = me->provide_src_names; - exss = me->provide_srcs; - var_count = me->num_var_provides; - - for (j = me->num_provides; j--; ) { - Scheme_Object *modidx; - - if (ename) { - if (!SAME_OBJ(SCHEME_STX_VAL(ename), exs[j])) - continue; /* we don't want this one. */ - } else if (onlys) { - name = scheme_hash_get(onlys, exs[j]); - if (!name) - continue; /* we don't want this one. */ - mark_src = name; - { - Scheme_Object *l; - l = scheme_stx_extract_marks(mark_src); - has_context = !SCHEME_NULLP(l); - } - /* Remove to indicate that it's been imported: */ - scheme_hash_set(onlys, exs[j], NULL); - } else { - if (exns) { - Scheme_Object *l, *a; - for (l = exns; SCHEME_STX_PAIRP(l); l = SCHEME_STX_CDR(l)) { - a = SCHEME_STX_CAR(l); - if (SCHEME_STXP(a)) - a = SCHEME_STX_VAL(a); - if (SAME_OBJ(a, exs[j])) - break; - } - if (!SCHEME_STX_NULLP(l)) - continue; /* we don't want this one. */ - } - - if (one_exn) { - if (SAME_OBJ(one_exn, exs[j])) - continue; /* we don't want this one. */ - } + switch(k) { + case 0: + switch(base_k) { + case 0: + pt = me->rt; + break; + case 1: + pt = me->et; + break; + case 2: + default: + pt = me->dt; + break; } + env = orig_env; + rn = rt_rn; + post_ex_rn = post_ex_rt_rn; + data = rt_data; + break; + case 1: + pt = me->et; + env = orig_env->exp_env; + rn = et_rn; + post_ex_rn = post_ex_et_rn; + data = et_data; + break; + case 2: + default: + pt = me->dt; + env = orig_env; /* using run-time rename is consistent with dt_mn_ht = mn_ht */ + rn = dt_rn; + post_ex_rn = post_ex_dt_rn; + data = dt_data; + break; + } + + is_kern = (SAME_OBJ(idx, kernel_symbol) + && !exns + && !onlys + && !prefix + && !iname + && !unpack_kern + && !has_context); + + one_exn = NULL; + + nominal_modidx = idx; + + while (1) { /* loop to handle kernel re-provides... */ + int break_if_iname_null = !!iname; + + exs = pt->provides; + exsns = pt->provide_src_names; + exss = pt->provide_srcs; + exets = pt->provide_src_phases; + var_count = pt->num_var_provides; + + for (j = pt->num_provides; j--; ) { + Scheme_Object *modidx; - modidx = ((exss && !SCHEME_FALSEP(exss[j])) - ? scheme_modidx_shift(exss[j], me->src_modidx, idx) - : idx); + if (orig_ename) { + if (!SAME_OBJ(SCHEME_STX_VAL(orig_ename), exs[j])) + continue; /* we don't want this one. */ + } else if (onlys) { + name = scheme_hash_get(orig_onlys, exs[j]); + if (!name) + continue; /* we don't want this one. */ + mark_src = name; + { + Scheme_Object *l; + l = scheme_stx_extract_marks(mark_src); + has_context = !SCHEME_NULLP(l); + } + /* Remove to indicate that it's been imported: */ + scheme_hash_set(onlys, exs[j], NULL); + } else { + if (exns) { + Scheme_Object *l, *a; + for (l = exns; SCHEME_STX_PAIRP(l); l = SCHEME_STX_CDR(l)) { + a = SCHEME_STX_CAR(l); + if (SCHEME_STXP(a)) + a = SCHEME_STX_VAL(a); + if (SAME_OBJ(a, exs[j])) + break; + } + if (!SCHEME_STX_NULLP(l)) + continue; /* we don't want this one. */ + } + + if (one_exn) { + if (SAME_OBJ(one_exn, exs[j])) + continue; /* we don't want this one. */ + } + } + + modidx = ((exss && !SCHEME_FALSEP(exss[j])) + ? scheme_modidx_shift(exss[j], me->src_modidx, idx) + : idx); - if (!iname) - iname = exs[j]; + if (!iname) + iname = exs[j]; - if (SCHEME_SYM_WEIRDP(iname)) { - /* This shouldn't happen. In case it does, don't import a - gensym or parallel symbol. The former is useless. The - latter is supposed to be module-specific, and it could - collide with local module-specific ids. */ - iname = NULL; - continue; - } + if (SCHEME_SYM_WEIRDP(iname)) { + /* This shouldn't happen. In case it does, don't import a + gensym or parallel symbol. The former is useless. The + latter is supposed to be module-specific, and it could + collide with local module-specific ids. */ + iname = NULL; + continue; + } - if (prefix) - iname = scheme_symbol_append(prefix, iname); + if (prefix) + iname = scheme_symbol_append(prefix, iname); - prnt_iname = iname; - if (has_context) { - /* The `require' expression has a set of marks in its - context, which means that we need to generate a name. */ - iname = scheme_datum_to_syntax(iname, scheme_false, mark_src, 0, 0); - iname = scheme_tl_id_sym(env, iname, scheme_false, 2); - } + prnt_iname = iname; + if (has_context) { + /* The `require' expression has a set of marks in its + context, which means that we need to generate a name. */ + iname = scheme_datum_to_syntax(iname, scheme_false, mark_src, 0, 0); + iname = scheme_tl_id_sym(env, iname, scheme_false, 2); + } - if (ck) - ck(prnt_iname, iname, nominal_modidx, modidx, exsns[j], (j < var_count), data, cki, form, err_src); + if (ck) + ck(prnt_iname, iname, nominal_modidx, modidx, exsns[j], (j < var_count), data, cki, form, err_src); - if (!is_kern) { - if (copy_vars && (j < var_count) && !env->module && !env->phase) { - Scheme_Env *menv; - Scheme_Object *val; - modidx = scheme_module_resolve(modidx, 1); - menv = scheme_module_access(modidx, env, 0); - val = scheme_lookup_in_table(menv->toplevel, (char *)exsns[j]); - scheme_add_global_symbol(iname, val, env); - scheme_shadow(env, iname, 1); - } else if (!for_unmarshal || !has_context) { - if (!save_marshal_info && !has_context && can_save_marshal) - save_marshal_info = 1; - scheme_extend_module_rename((has_context ? post_ex_rn : rn), - modidx, iname, exsns[j], nominal_modidx, exs[j], 0, - for_unmarshal || (!has_context && can_save_marshal)); - } + if (!is_kern) { + if (copy_vars && (j < var_count) && !env->module && !env->phase && !k) { + Scheme_Env *menv; + Scheme_Object *val; + modidx = scheme_module_resolve(modidx, 1); + menv = scheme_module_access(modidx, env, 0); + val = scheme_lookup_in_table(menv->toplevel, (char *)exsns[j]); + scheme_add_global_symbol(iname, val, env); + scheme_shadow(env, iname, 1); + } else if (!for_unmarshal || !has_context) { + if (!save_marshal_info && !has_context && can_save_marshal) + save_marshal_info = 1; + scheme_extend_module_rename((has_context ? post_ex_rn : rn), + modidx, iname, exsns[j], nominal_modidx, exs[j], + exets ? exets[j] : 0, + for_unmarshal || (!has_context && can_save_marshal)); + } + } + + iname = NULL; + + if (ename) { + ename = NULL; + break; + } } - iname = NULL; - - if (ename) { - ename = NULL; - break; - } + if (is_kern) + scheme_extend_module_rename_with_kernel(rn, nominal_modidx); + + if (break_if_iname_null && !iname) + break; + + if (pt->reprovide_kernel) { + idx = kernel_symbol; + one_exn = pt->kernel_exclusion; + me = kernel->me; + pt = kernel->me->rt; + is_kern = !prefix && !unpack_kern && !ename && !has_context && !onlys; + } else + break; } - if (ename) { - if (!me->reprovide_kernel) { - scheme_wrong_syntax(NULL, ename, form, "no such provided variable"); - return; - } + if (save_marshal_info) { + Scheme_Object *info, *a; + + if (exns) { + /* Convert to a list of symbols: */ + info = scheme_null; + for (; SCHEME_STX_PAIRP(exns); exns = SCHEME_STX_CDR(exns)) { + a = SCHEME_STX_CAR(exns); + if (SCHEME_STXP(a)) + a = SCHEME_STX_VAL(a); + info = cons(a, info); + } + exns = info; + } else + exns = scheme_null; + + /* The format of this data is checked in stxobj for unmarshaling + a Module_Renames. Also the idx must be first, to support shifting. */ + info = cons(orig_idx, cons(scheme_make_integer(k+base_k), + cons(exns, prefix ? prefix : scheme_false))); + + scheme_save_module_rename_unmarshal(rn, info); + + save_marshal_info = 0; } - - if (is_kern) - scheme_extend_module_rename_with_kernel(rn, nominal_modidx); - - if (break_if_iname_null && !iname) - break; - - if (me->reprovide_kernel) { - idx = kernel_symbol; - one_exn = me->kernel_exclusion; - me = kernel->me; - is_kern = !prefix && !unpack_kern && !ename && !has_context && !onlys; - } else - break; } - if (save_marshal_info) { - Scheme_Object *info, *a; - - if (exns) { - /* Convert to a list of symbols: */ - info = scheme_null; - for (; SCHEME_STX_PAIRP(exns); exns = SCHEME_STX_CDR(exns)) { - a = SCHEME_STX_CAR(exns); - if (SCHEME_STXP(a)) - a = SCHEME_STX_VAL(a); - info = cons(a, info); - } - exns = info; - } else - exns = scheme_null; - - /* The format of this data is checked in stxobj for unmarshaling - a Module_Renames. Also the idx must be first, to support shifting. */ - info = cons(orig_idx, cons(exns, prefix ? prefix : scheme_false)); - - scheme_save_module_rename_unmarshal(rn, info); + if (ename) { + scheme_wrong_syntax(NULL, ename, form, "no such provided variable"); + return; } } @@ -5684,13 +6301,15 @@ void scheme_do_module_rename_unmarshal(Scheme_Object *rn, Scheme_Object *info, Scheme_Object *modidx_shift_from, Scheme_Object *modidx_shift_to, Scheme_Hash_Table *export_registry) { - Scheme_Object *orig_idx, *exns, *prefix, *idx, *name; + Scheme_Object *orig_idx, *exns, *prefix, *idx, *name, *kv; Scheme_Module_Exports *me; Scheme_Env *env; idx = SCHEME_CAR(info); orig_idx = idx; info = SCHEME_CDR(info); + kv = SCHEME_CAR(info); + info = SCHEME_CDR(info); exns = SCHEME_CAR(info); prefix = SCHEME_CDR(info); @@ -5698,7 +6317,7 @@ void scheme_do_module_rename_unmarshal(Scheme_Object *rn, Scheme_Object *info, prefix = NULL; if (SCHEME_NULLP(exns)) exns = NULL; - + if (modidx_shift_from) idx = scheme_modidx_shift(idx, modidx_shift_from, @@ -5724,21 +6343,26 @@ void scheme_do_module_rename_unmarshal(Scheme_Object *rn, Scheme_Object *info, } } - add_single_require(me, orig_idx, NULL, - rn, NULL, + add_single_require(me, SCHEME_INT_VAL(kv), orig_idx, NULL, + rn, NULL, + NULL, NULL, + NULL, NULL, exns, NULL, prefix, NULL, NULL, NULL, 0, 0, 1, 0, NULL, - NULL, - NULL, NULL, NULL, NULL); + NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); } Scheme_Object *parse_requires(Scheme_Object *form, Scheme_Object *base_modidx, Scheme_Env *env, Scheme_Object *rn, Scheme_Object *post_ex_rn, - Check_Func ck, void *data, + Scheme_Object *et_rn, Scheme_Object *post_ex_et_rn, + Scheme_Object *dt_rn, Scheme_Object *post_ex_dt_rn, + Check_Func ck, void *data, void *et_data, void *dt_data, int start, int expstart, Scheme_Object *redef_modname, int unpack_kern, int copy_vars, int can_save_marshal, int *all_simple) @@ -5962,12 +6586,17 @@ Scheme_Object *parse_requires(Scheme_Object *form, } } - add_single_require(m->me, idx, env, rn, post_ex_rn, + add_single_require(m->me, 0, idx, env, + rn, post_ex_rn, + et_rn, post_ex_et_rn, + dt_rn, post_ex_dt_rn, exns, onlys, prefix, iname, ename, mark_src, unpack_kern, copy_vars && start, 0, can_save_marshal, all_simple, - ck, data, form, err_src, i); + ck, + data, et_data, dt_data, + form, err_src, i); if (onlys && onlys->count) { /* Something required in `only' wasn't provided by the module */ @@ -6003,8 +6632,8 @@ static void check_dup_require(Scheme_Object *prnt_name, Scheme_Object *name, Sch static Scheme_Object * top_level_require_execute(Scheme_Object *data) { - Scheme_Hash_Table *ht; - Scheme_Object *rn, *modidx; + Scheme_Hash_Table *ht, *et_ht, *dt_ht; + Scheme_Object *rn, *et_rn, *dt_rn, *modidx; Scheme_Object *form = SCHEME_CDDR(data), *rest, *brn; int for_phase = SCHEME_INT_VAL(SCHEME_CADR(data)); Scheme_Env *env; @@ -6041,18 +6670,57 @@ top_level_require_execute(Scheme_Object *data) ht = NULL; rn = scheme_make_module_rename(for_phase, mzMOD_RENAME_TOPLEVEL, NULL); + if (!for_phase) { + scheme_prepare_exp_env(env); + et_rn = scheme_make_module_rename(1, mzMOD_RENAME_TOPLEVEL, NULL); + dt_rn = scheme_make_module_rename(MZ_LABEL_PHASE, mzMOD_RENAME_TOPLEVEL, NULL); + if (rest) { + et_ht = scheme_make_hash_table(SCHEME_hash_ptr); + dt_ht = scheme_make_hash_table(SCHEME_hash_ptr); + } else { + et_ht = NULL; + dt_ht = NULL; + } + } else { + et_rn = NULL; + dt_rn = NULL; + et_ht = NULL; + dt_ht = NULL; + } - (void)parse_requires(form, modidx, env, rn, rn, - check_dup_require, ht, (for_phase > -1), (for_phase == 0), NULL, + (void)parse_requires(form, modidx, env, + rn, rn, + et_rn, et_rn, + dt_rn, dt_rn, + check_dup_require, ht, et_ht, dt_ht, (for_phase > -1), (for_phase == 0), NULL, !env->module, 0, 0, NULL); - brn = env->rename; + brn = ((for_phase == MZ_LABEL_PHASE) ? env->dt_rename : env->rename); if (!brn) { brn = scheme_make_module_rename(for_phase, mzMOD_RENAME_TOPLEVEL, NULL); - env->rename = brn; + if (for_phase == MZ_LABEL_PHASE) + env->dt_rename = brn; + else + env->rename = brn; } scheme_append_module_rename(rn, brn); + + if (!for_phase) { + brn = env->exp_env->rename; + if (!brn) { + brn = scheme_make_module_rename(1, mzMOD_RENAME_TOPLEVEL, NULL); + env->exp_env->rename = brn; + } + scheme_append_module_rename(et_rn, brn); + + brn = env->dt_rename; + if (!brn) { + brn = scheme_make_module_rename(MZ_LABEL_PHASE, mzMOD_RENAME_TOPLEVEL, NULL); + env->dt_rename = brn; + } + scheme_append_module_rename(dt_rn, brn); + } return scheme_void; } @@ -6090,8 +6758,8 @@ static Scheme_Object *do_require(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Compile_Expand_Info *rec, int drec, int for_phase) { - Scheme_Hash_Table *ht; - Scheme_Object *rn, *dummy, *modidx; + Scheme_Hash_Table *ht, *et_ht, *dt_ht; + Scheme_Object *rn, *et_rn, *dt_rn, *dummy, *modidx; Scheme_Env *genv; if (!scheme_is_toplevel(env)) @@ -6103,6 +6771,17 @@ static Scheme_Object *do_require(Scheme_Object *form, Scheme_Comp_Env *env, ht = scheme_make_hash_table(SCHEME_hash_ptr); rn = scheme_make_module_rename(for_phase, mzMOD_RENAME_TOPLEVEL, NULL); + if (!for_phase) { + et_rn = scheme_make_module_rename(1, mzMOD_RENAME_TOPLEVEL, NULL); + dt_rn = scheme_make_module_rename(MZ_LABEL_PHASE, mzMOD_RENAME_TOPLEVEL, NULL); + et_ht = scheme_make_hash_table(SCHEME_hash_ptr); + dt_ht = scheme_make_hash_table(SCHEME_hash_ptr); + } else { + et_rn = NULL; + dt_rn = NULL; + et_ht = NULL; + dt_ht = NULL; + } genv = env->genv; @@ -6119,8 +6798,11 @@ static Scheme_Object *do_require(Scheme_Object *form, Scheme_Comp_Env *env, genv = genv->template_env; } - (void)parse_requires(form, modidx, genv, rn, rn, - check_dup_require, ht, 0, 0, + (void)parse_requires(form, modidx, genv, + rn, rn, + et_rn, et_rn, + dt_rn, dt_rn, + check_dup_require, ht, et_ht, dt_ht, 0, 0, NULL, 0, 0, 0, NULL); if (rec[drec].comp) { @@ -6176,6 +6858,19 @@ require_for_template_expand(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Ex return do_require(form, env, erec, drec, -1); } +static Scheme_Object * +require_for_label_syntax(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Compile_Info *rec, int drec) +{ + return do_require(form, env, rec, drec, MZ_LABEL_PHASE); +} + +static Scheme_Object * +require_for_label_expand(Scheme_Object *form, Scheme_Comp_Env *env, Scheme_Expand_Info *erec, int drec) +{ + SCHEME_EXPAND_OBSERVE_PRIM_REQUIRE_FOR_TEMPLATE(erec[drec].observer); + return do_require(form, env, erec, drec, MZ_LABEL_PHASE); +} + /**********************************************************************/ /* dummy forms */ /**********************************************************************/ @@ -6207,38 +6902,66 @@ XFORM_NONGCING static Scheme_Object *wrap_mod_stx(Scheme_Object *stx) static Scheme_Object *write_module(Scheme_Object *obj) { Scheme_Module *m = (Scheme_Module *)obj; + Scheme_Module_Phase_Exports *pt; Scheme_Object *l, *v; - int i, count; + int i, k, count; - l = m->tt_requires; + l = m->dt_requires; + l = cons(m->tt_requires, l); l = cons(m->et_requires, l); l = cons(m->requires, l); l = cons(m->body, l); l = cons(m->et_body, l); - l = cons(scheme_make_integer(m->me->num_provides), l); - l = cons(scheme_make_integer(m->me->num_var_provides), l); + for (k = 0; k < 3; k++) { + switch (k) { + case 2: + pt = m->me->dt; + break; + case 1: + pt = m->me->et; + break; + case 0: + default: + pt = m->me->rt; + break; + } + + l = cons(scheme_make_integer(pt->num_provides), l); + l = cons(scheme_make_integer(pt->num_var_provides), l); - count = m->me->num_provides; + count = pt->num_provides; - v = scheme_make_vector(count, NULL); - for (i = 0; i < count; i++) { - SCHEME_VEC_ELS(v)[i] = m->me->provides[i]; - } - l = cons(v, l); + v = scheme_make_vector(count, NULL); + for (i = 0; i < count; i++) { + SCHEME_VEC_ELS(v)[i] = pt->provides[i]; + } + l = cons(v, l); - v = scheme_make_vector(count, NULL); - for (i = 0; i < count; i++) { - SCHEME_VEC_ELS(v)[i] = m->me->provide_srcs[i]; + v = scheme_make_vector(count, NULL); + for (i = 0; i < count; i++) { + SCHEME_VEC_ELS(v)[i] = pt->provide_srcs[i]; + } + l = cons(v, l); + + v = scheme_make_vector(count, NULL); + for (i = 0; i < count; i++) { + SCHEME_VEC_ELS(v)[i] = pt->provide_src_names[i]; + } + l = cons(v, l); + + if (pt->provide_src_phases) { + v = scheme_make_vector(count, NULL); + for (i = 0; i < count; i++) { + SCHEME_VEC_ELS(v)[i] = (pt->provide_src_phases[i] ? scheme_true : scheme_false); + } + } else + v = scheme_false; + l = cons(v, l); } - l = cons(v, l); - - v = scheme_make_vector(count, NULL); - for (i = 0; i < count; i++) { - SCHEME_VEC_ELS(v)[i] = m->me->provide_src_names[i]; - } - l = cons(v, l); + + count = m->me->rt->num_provides; if (m->provide_protects) { for (i = 0; i < count; i++) { @@ -6266,14 +6989,15 @@ static Scheme_Object *write_module(Scheme_Object *obj) } l = cons(v, l); - l = cons(m->me->reprovide_kernel ? scheme_true : scheme_false, l); - l = cons(m->me->kernel_exclusion, l); + l = cons(m->me->rt->reprovide_kernel ? scheme_true : scheme_false, l); + l = cons(m->me->rt->kernel_exclusion, l); l = cons((Scheme_Object *)m->prefix, l); l = cons(m->dummy, l); l = cons(scheme_make_integer(m->max_let_depth), l); + l = cons(wrap_mod_stx(m->dt_rn_stx), l); l = cons(wrap_mod_stx(m->tt_rn_stx), l); l = cons(wrap_mod_stx(m->et_rn_stx), l); l = cons(wrap_mod_stx(m->rn_stx), l); @@ -6296,14 +7020,17 @@ static int check_requires_ok(Scheme_Object *l) return 1; } +#define return_NULL() return (printf("%d\n", __LINE__), NULL) + static Scheme_Object *read_module(Scheme_Object *obj) { Scheme_Module *m; Scheme_Object *ie, *nie; - Scheme_Object *esp, *esn, *es, *e, *nve, *ne, **v; + Scheme_Object *esp, *esn, *esph, *es, *e, *nve, *ne, **v; Scheme_Module_Exports *me; - char *ps; - int i, count; + Scheme_Module_Phase_Exports *pt; + char *ps, *sps; + int i, k, count; m = MALLOC_ONE_TAGGED(Scheme_Module); m->so.type = scheme_module_type; @@ -6311,64 +7038,70 @@ static Scheme_Object *read_module(Scheme_Object *obj) me = make_module_exports(); m->me = me; - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); m->modname = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); me->src_modidx = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); ((Scheme_Modidx *)m->me->src_modidx)->resolved = m->modname; m->self_modidx = m->me->src_modidx; - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); m->rn_stx = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); if (SCHEME_FALSEP(m->rn_stx)) m->rn_stx = NULL; - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); m->et_rn_stx = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); if (SCHEME_FALSEP(m->et_rn_stx)) m->et_rn_stx = NULL; - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); m->tt_rn_stx = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); if (SCHEME_FALSEP(m->tt_rn_stx)) m->tt_rn_stx = NULL; - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); + m->dt_rn_stx = SCHEME_CAR(obj); + obj = SCHEME_CDR(obj); + if (SCHEME_FALSEP(m->dt_rn_stx)) + m->dt_rn_stx = NULL; + + if (!SCHEME_PAIRP(obj)) return_NULL(); m->max_let_depth = SCHEME_INT_VAL(SCHEME_CAR(obj)); obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); m->dummy = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); m->prefix = (Resolve_Prefix *)SCHEME_CAR(obj); obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; - me->kernel_exclusion = SCHEME_CAR(obj); + if (!SCHEME_PAIRP(obj)) return_NULL(); + me->rt->kernel_exclusion = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; - me->reprovide_kernel = SCHEME_TRUEP(SCHEME_CAR(obj)); + if (!SCHEME_PAIRP(obj)) return_NULL(); + me->rt->reprovide_kernel = SCHEME_TRUEP(SCHEME_CAR(obj)); obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); ie = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); nie = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); count = SCHEME_INT_VAL(nie); - if (!SCHEME_VECTORP(ie) || (SCHEME_VEC_SIZE(ie) != count)) return NULL; + if (!SCHEME_VECTORP(ie) || (SCHEME_VEC_SIZE(ie) != count)) return_NULL(); v = MALLOC_N(Scheme_Object *, count); for (i = 0; i < count; i++) { v[i] = SCHEME_VEC_ELS(ie)[i]; @@ -6376,59 +7109,89 @@ static Scheme_Object *read_module(Scheme_Object *obj) m->indirect_provides = v; m->num_indirect_provides = count; - if (!SCHEME_PAIRP(obj)) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); esp = SCHEME_CAR(obj); obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; - esn = SCHEME_CAR(obj); - obj = SCHEME_CDR(obj); + for (k = 0; k < 3; k++) { + switch (k) { + case 0: + pt = me->dt; + break; + case 1: + pt = me->et; + break; + case 2: + default: + pt = me->rt; + break; + } - if (!SCHEME_PAIRP(obj)) return NULL; - es = SCHEME_CAR(obj); - obj = SCHEME_CDR(obj); + if (!SCHEME_PAIRP(obj)) return_NULL(); + esph = SCHEME_CAR(obj); + obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; - e = SCHEME_CAR(obj); - obj = SCHEME_CDR(obj); + if (!SCHEME_PAIRP(obj)) return_NULL(); + esn = SCHEME_CAR(obj); + obj = SCHEME_CDR(obj); + + if (!SCHEME_PAIRP(obj)) return_NULL(); + es = SCHEME_CAR(obj); + obj = SCHEME_CDR(obj); + + if (!SCHEME_PAIRP(obj)) return_NULL(); + e = SCHEME_CAR(obj); + obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; - nve = SCHEME_CAR(obj); - obj = SCHEME_CDR(obj); + if (!SCHEME_PAIRP(obj)) return_NULL(); + nve = SCHEME_CAR(obj); + obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; - ne = SCHEME_CAR(obj); - obj = SCHEME_CDR(obj); + if (!SCHEME_PAIRP(obj)) return_NULL(); + ne = SCHEME_CAR(obj); + obj = SCHEME_CDR(obj); - count = SCHEME_INT_VAL(ne); - me->num_provides = count; - me->num_var_provides = SCHEME_INT_VAL(nve); + count = SCHEME_INT_VAL(ne); + pt->num_provides = count; + pt->num_var_provides = SCHEME_INT_VAL(nve); - if (!SCHEME_VECTORP(e) || (SCHEME_VEC_SIZE(e) != count)) return NULL; - v = MALLOC_N(Scheme_Object *, count); - for (i = 0; i < count; i++) { - v[i] = SCHEME_VEC_ELS(e)[i]; + if (!SCHEME_VECTORP(e) || (SCHEME_VEC_SIZE(e) != count)) return_NULL(); + v = MALLOC_N(Scheme_Object *, count); + for (i = 0; i < count; i++) { + v[i] = SCHEME_VEC_ELS(e)[i]; + } + pt->provides = v; + + if (!SCHEME_VECTORP(es) || (SCHEME_VEC_SIZE(es) != count)) return_NULL(); + v = MALLOC_N(Scheme_Object *, count); + for (i = 0; i < count; i++) { + v[i] = SCHEME_VEC_ELS(es)[i]; + } + pt->provide_srcs = v; + + if (!SCHEME_VECTORP(esn) || (SCHEME_VEC_SIZE(esn) != count)) return_NULL(); + v = MALLOC_N(Scheme_Object *, count); + for (i = 0; i < count; i++) { + v[i] = SCHEME_VEC_ELS(esn)[i]; + } + pt->provide_src_names = v; + + if (SCHEME_FALSEP(esph)) + sps = NULL; + else { + if (!SCHEME_VECTORP(esph) || (SCHEME_VEC_SIZE(esph) != count)) return_NULL(); + sps = MALLOC_N_ATOMIC(char, count); + for (i = 0; i < count; i++) { + sps[i] = SCHEME_TRUEP(SCHEME_VEC_ELS(esph)[i]); + } + } + pt->provide_src_phases = sps; } - me->provides = v; - - if (!SCHEME_VECTORP(es) || (SCHEME_VEC_SIZE(es) != count)) return NULL; - v = MALLOC_N(Scheme_Object *, count); - for (i = 0; i < count; i++) { - v[i] = SCHEME_VEC_ELS(es)[i]; - } - me->provide_srcs = v; - - if (!SCHEME_VECTORP(esn) || (SCHEME_VEC_SIZE(esn) != count)) return NULL; - v = MALLOC_N(Scheme_Object *, count); - for (i = 0; i < count; i++) { - v[i] = SCHEME_VEC_ELS(esn)[i]; - } - me->provide_src_names = v; if (SCHEME_FALSEP(esp)) { m->provide_protects = NULL; } else { - if (!SCHEME_VECTORP(esp) || (SCHEME_VEC_SIZE(esp) != count)) return NULL; + if (!SCHEME_VECTORP(esp) || (SCHEME_VEC_SIZE(esp) != count)) return_NULL(); ps = MALLOC_N_ATOMIC(char, count); for (i = 0; i < count; i++) { ps[i] = SCHEME_TRUEP(SCHEME_VEC_ELS(esp)[i]); @@ -6436,36 +7199,43 @@ static Scheme_Object *read_module(Scheme_Object *obj) m->provide_protects = ps; } - if (!SCHEME_PAIRP(obj)) return NULL; - if (scheme_proper_list_length(SCHEME_CAR(obj)) < 0) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); + if (scheme_proper_list_length(SCHEME_CAR(obj)) < 0) return_NULL(); e = scheme_copy_list(SCHEME_CAR(obj)); m->et_body = e; obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; - if (scheme_proper_list_length(SCHEME_CAR(obj)) < 0) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); + if (scheme_proper_list_length(SCHEME_CAR(obj)) < 0) return_NULL(); e = scheme_copy_list(SCHEME_CAR(obj)); m->body = e; obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; - if (scheme_proper_list_length(SCHEME_CAR(obj)) < 0) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); + if (scheme_proper_list_length(SCHEME_CAR(obj)) < 0) return_NULL(); e = scheme_copy_list(SCHEME_CAR(obj)); m->requires = e; - if (!check_requires_ok(e)) return NULL; + if (!check_requires_ok(e)) return_NULL(); obj = SCHEME_CDR(obj); - if (!SCHEME_PAIRP(obj)) return NULL; - if (scheme_proper_list_length(SCHEME_CAR(obj)) < 0) return NULL; + if (!SCHEME_PAIRP(obj)) return_NULL(); + if (scheme_proper_list_length(SCHEME_CAR(obj)) < 0) return_NULL(); e = scheme_copy_list(SCHEME_CAR(obj)); m->et_requires = e; - if (!check_requires_ok(e)) return NULL; + if (!check_requires_ok(e)) return_NULL(); obj = SCHEME_CDR(obj); - if (scheme_proper_list_length(obj) < 0) return NULL; - e = scheme_copy_list(obj); + if (!SCHEME_PAIRP(obj)) return_NULL(); + if (scheme_proper_list_length(SCHEME_CAR(obj)) < 0) return_NULL(); + e = scheme_copy_list(SCHEME_CAR(obj)); m->tt_requires = e; - if (!check_requires_ok(e)) return NULL; + if (!check_requires_ok(e)) return_NULL(); + obj = SCHEME_CDR(obj); + + if (scheme_proper_list_length(obj) < 0) return_NULL(); + e = scheme_copy_list(obj); + m->dt_requires = e; + if (!check_requires_ok(e)) return_NULL(); return (Scheme_Object *)m; } diff --git a/src/mzscheme/src/mzmark.c b/src/mzscheme/src/mzmark.c index eb6bb74be3..ed9e75ebda 100644 --- a/src/mzscheme/src/mzmark.c +++ b/src/mzscheme/src/mzmark.c @@ -2051,6 +2051,7 @@ static int namespace_val_MARK(void *p) { gcMARK(e->rename); gcMARK(e->et_rename); gcMARK(e->tt_rename); + gcMARK(e->dt_rename); gcMARK(e->syntax); gcMARK(e->exp_env); @@ -2062,6 +2063,7 @@ static int namespace_val_MARK(void *p) { gcMARK(e->require_names); gcMARK(e->et_require_names); gcMARK(e->tt_require_names); + gcMARK(e->dt_require_names); gcMARK(e->toplevel); gcMARK(e->modchain); @@ -2085,6 +2087,7 @@ static int namespace_val_FIXUP(void *p) { gcFIXUP(e->rename); gcFIXUP(e->et_rename); gcFIXUP(e->tt_rename); + gcFIXUP(e->dt_rename); gcFIXUP(e->syntax); gcFIXUP(e->exp_env); @@ -2096,6 +2099,7 @@ static int namespace_val_FIXUP(void *p) { gcFIXUP(e->require_names); gcFIXUP(e->et_require_names); gcFIXUP(e->tt_require_names); + gcFIXUP(e->dt_require_names); gcFIXUP(e->toplevel); gcFIXUP(e->modchain); @@ -2309,8 +2313,9 @@ static int module_val_MARK(void *p) { gcMARK(m->modname); gcMARK(m->et_requires); - gcMARK(m->tt_requires); gcMARK(m->requires); + gcMARK(m->tt_requires); + gcMARK(m->dt_requires); gcMARK(m->body); gcMARK(m->et_body); @@ -2319,9 +2324,15 @@ static int module_val_MARK(void *p) { gcMARK(m->provide_protects); gcMARK(m->indirect_provides); + + gcMARK(m->et_provide_protects); + gcMARK(m->et_indirect_provides); + gcMARK(m->self_modidx); gcMARK(m->accessible); + gcMARK(m->et_accessible); + gcMARK(m->insp); gcMARK(m->hints); @@ -2334,6 +2345,7 @@ static int module_val_MARK(void *p) { gcMARK(m->rn_stx); gcMARK(m->et_rn_stx); gcMARK(m->tt_rn_stx); + gcMARK(m->dt_rn_stx); gcMARK(m->primitive); return @@ -2345,8 +2357,9 @@ static int module_val_FIXUP(void *p) { gcFIXUP(m->modname); gcFIXUP(m->et_requires); - gcFIXUP(m->tt_requires); gcFIXUP(m->requires); + gcFIXUP(m->tt_requires); + gcFIXUP(m->dt_requires); gcFIXUP(m->body); gcFIXUP(m->et_body); @@ -2355,9 +2368,15 @@ static int module_val_FIXUP(void *p) { gcFIXUP(m->provide_protects); gcFIXUP(m->indirect_provides); + + gcFIXUP(m->et_provide_protects); + gcFIXUP(m->et_indirect_provides); + gcFIXUP(m->self_modidx); gcFIXUP(m->accessible); + gcFIXUP(m->et_accessible); + gcFIXUP(m->insp); gcFIXUP(m->hints); @@ -2370,6 +2389,7 @@ static int module_val_FIXUP(void *p) { gcFIXUP(m->rn_stx); gcFIXUP(m->et_rn_stx); gcFIXUP(m->tt_rn_stx); + gcFIXUP(m->dt_rn_stx); gcFIXUP(m->primitive); return @@ -2380,6 +2400,43 @@ static int module_val_FIXUP(void *p) { #define module_val_IS_CONST_SIZE 1 +static int module_phase_exports_val_SIZE(void *p) { + return + gcBYTES_TO_WORDS(sizeof(Scheme_Module_Phase_Exports)); +} + +static int module_phase_exports_val_MARK(void *p) { + Scheme_Module_Phase_Exports *m = (Scheme_Module_Phase_Exports *)p; + + gcMARK(m->provides); + gcMARK(m->provide_srcs); + gcMARK(m->provide_src_names); + gcMARK(m->provide_src_phases); + + gcMARK(m->kernel_exclusion); + + return + gcBYTES_TO_WORDS(sizeof(Scheme_Module_Phase_Exports)); +} + +static int module_phase_exports_val_FIXUP(void *p) { + Scheme_Module_Phase_Exports *m = (Scheme_Module_Phase_Exports *)p; + + gcFIXUP(m->provides); + gcFIXUP(m->provide_srcs); + gcFIXUP(m->provide_src_names); + gcFIXUP(m->provide_src_phases); + + gcFIXUP(m->kernel_exclusion); + + return + gcBYTES_TO_WORDS(sizeof(Scheme_Module_Phase_Exports)); +} + +#define module_phase_exports_val_IS_ATOMIC 0 +#define module_phase_exports_val_IS_CONST_SIZE 1 + + static int module_exports_val_SIZE(void *p) { return gcBYTES_TO_WORDS(sizeof(Scheme_Module_Exports)); @@ -2388,11 +2445,9 @@ static int module_exports_val_SIZE(void *p) { static int module_exports_val_MARK(void *p) { Scheme_Module_Exports *m = (Scheme_Module_Exports *)p; - gcMARK(m->provides); - gcMARK(m->provide_srcs); - gcMARK(m->provide_src_names); - - gcMARK(m->kernel_exclusion); + gcMARK(m->rt); + gcMARK(m->et); + gcMARK(m->dt); gcMARK(m->src_modidx); return @@ -2402,11 +2457,9 @@ static int module_exports_val_MARK(void *p) { static int module_exports_val_FIXUP(void *p) { Scheme_Module_Exports *m = (Scheme_Module_Exports *)p; - gcFIXUP(m->provides); - gcFIXUP(m->provide_srcs); - gcFIXUP(m->provide_src_names); - - gcFIXUP(m->kernel_exclusion); + gcFIXUP(m->rt); + gcFIXUP(m->et); + gcFIXUP(m->dt); gcFIXUP(m->src_modidx); return diff --git a/src/mzscheme/src/mzmarksrc.c b/src/mzscheme/src/mzmarksrc.c index 439a654e92..f4a83fd0bf 100644 --- a/src/mzscheme/src/mzmarksrc.c +++ b/src/mzscheme/src/mzmarksrc.c @@ -814,6 +814,7 @@ namespace_val { gcMARK(e->rename); gcMARK(e->et_rename); gcMARK(e->tt_rename); + gcMARK(e->dt_rename); gcMARK(e->syntax); gcMARK(e->exp_env); @@ -825,6 +826,7 @@ namespace_val { gcMARK(e->require_names); gcMARK(e->et_require_names); gcMARK(e->tt_require_names); + gcMARK(e->dt_require_names); gcMARK(e->toplevel); gcMARK(e->modchain); @@ -912,8 +914,9 @@ module_val { gcMARK(m->modname); gcMARK(m->et_requires); - gcMARK(m->tt_requires); gcMARK(m->requires); + gcMARK(m->tt_requires); + gcMARK(m->dt_requires); gcMARK(m->body); gcMARK(m->et_body); @@ -922,9 +925,15 @@ module_val { gcMARK(m->provide_protects); gcMARK(m->indirect_provides); + + gcMARK(m->et_provide_protects); + gcMARK(m->et_indirect_provides); + gcMARK(m->self_modidx); gcMARK(m->accessible); + gcMARK(m->et_accessible); + gcMARK(m->insp); gcMARK(m->hints); @@ -937,22 +946,36 @@ module_val { gcMARK(m->rn_stx); gcMARK(m->et_rn_stx); gcMARK(m->tt_rn_stx); + gcMARK(m->dt_rn_stx); gcMARK(m->primitive); size: gcBYTES_TO_WORDS(sizeof(Scheme_Module)); } -module_exports_val { +module_phase_exports_val { mark: - Scheme_Module_Exports *m = (Scheme_Module_Exports *)p; + Scheme_Module_Phase_Exports *m = (Scheme_Module_Phase_Exports *)p; gcMARK(m->provides); gcMARK(m->provide_srcs); gcMARK(m->provide_src_names); + gcMARK(m->provide_src_phases); gcMARK(m->kernel_exclusion); + size: + gcBYTES_TO_WORDS(sizeof(Scheme_Module_Phase_Exports)); +} + +module_exports_val { + mark: + Scheme_Module_Exports *m = (Scheme_Module_Exports *)p; + + gcMARK(m->rt); + gcMARK(m->et); + gcMARK(m->dt); + gcMARK(m->src_modidx); size: gcBYTES_TO_WORDS(sizeof(Scheme_Module_Exports)); diff --git a/src/mzscheme/src/schexpobs.h b/src/mzscheme/src/schexpobs.h index 9308200f90..cca963c803 100644 --- a/src/mzscheme/src/schexpobs.h +++ b/src/mzscheme/src/schexpobs.h @@ -144,4 +144,7 @@ extern Scheme_Object *scheme_get_expand_observe(); #define SCHEME_EXPAND_OBSERVE_EXIT_LOCAL_EXPR(obs,stx,opaque) \ _SCHEME_EXPOBS(obs,140,scheme_make_pair(stx,opaque)) +#define SCHEME_EXPAND_OBSERVE_START_EXPAND(obs) \ + _SCHEME_EXPOBS(obs,141,scheme_false) + #endif diff --git a/src/mzscheme/src/schminc.h b/src/mzscheme/src/schminc.h index 677ccf1aa4..858ed0123a 100644 --- a/src/mzscheme/src/schminc.h +++ b/src/mzscheme/src/schminc.h @@ -13,7 +13,7 @@ #define USE_COMPILED_STARTUP 1 -#define EXPECTED_PRIM_COUNT 907 +#define EXPECTED_PRIM_COUNT 910 #ifdef MZSCHEME_SOMETHING_OMITTED # undef USE_COMPILED_STARTUP diff --git a/src/mzscheme/src/schpriv.h b/src/mzscheme/src/schpriv.h index dacaf3cb70..e5f1429ba9 100644 --- a/src/mzscheme/src/schpriv.h +++ b/src/mzscheme/src/schpriv.h @@ -558,6 +558,8 @@ extern Scheme_Object *scheme_source_property; /* syntax objects */ /*========================================================================*/ +#define MZ_LABEL_PHASE 30000 + typedef struct Scheme_Stx_Srcloc { MZTAG_IF_REQUIRED long line, col, pos, span; @@ -2280,6 +2282,7 @@ struct Scheme_Env { Scheme_Object *rename; /* module rename record */ Scheme_Object *et_rename; /* exp-time rename record */ Scheme_Object *tt_rename; /* template-time rename record */ + Scheme_Object *dt_rename; /* template-time rename record */ Scheme_Bucket_Table *syntax; struct Scheme_Env *exp_env; @@ -2290,7 +2293,7 @@ struct Scheme_Env { /* Per-instance: */ long phase, mod_phase; Scheme_Object *link_midx; - Scheme_Object *require_names, *et_require_names, *tt_require_names; /* resolved */ + Scheme_Object *require_names, *et_require_names, *tt_require_names, *dt_require_names; /* resolved */ char running, et_running, tt_running, lazy_syntax, attached; Scheme_Bucket_Table *toplevel; @@ -2323,6 +2326,7 @@ typedef struct Scheme_Module Scheme_Object *et_requires; /* list of symbol-or-module-path-index */ Scheme_Object *requires; /* list of symbol-or-module-path-index */ Scheme_Object *tt_requires; /* list of symbol-or-module-path-index */ + Scheme_Object *dt_requires; /* list of symbol-or-module-path-index */ Scheme_Invoke_Proc prim_body; Scheme_Invoke_Proc prim_et_body; @@ -2338,9 +2342,14 @@ typedef struct Scheme_Module Scheme_Object **indirect_provides; /* symbols (internal names) */ int num_indirect_provides; + char *et_provide_protects; /* 1 => protected, 0 => not */ + Scheme_Object **et_indirect_provides; /* symbols (internal names) */ + int num_indirect_et_provides; + Scheme_Object *self_modidx; Scheme_Hash_Table *accessible; + Scheme_Hash_Table *et_accessible; Scheme_Object *insp; /* declaration-time inspector, for creating certificates and for module instantiation */ @@ -2355,9 +2364,24 @@ typedef struct Scheme_Module Scheme_Env *primitive; - Scheme_Object *rn_stx, *et_rn_stx, *tt_rn_stx; + Scheme_Object *rn_stx, *et_rn_stx, *tt_rn_stx, *dt_rn_stx; } Scheme_Module; +typedef struct Scheme_Module_Phase_Exports +{ + MZTAG_IF_REQUIRED + + Scheme_Object **provides; /* symbols (extenal names) */ + Scheme_Object **provide_srcs; /* module access paths, #f for self */ + Scheme_Object **provide_src_names; /* symbols (original internal names) */ + char *provide_src_phases; /* NULL, or src phase for for-syntax import */ + int num_provides; + int num_var_provides; /* non-syntax listed first in provides */ + + int reprovide_kernel; /* if true, extend provides with kernel's */ + Scheme_Object *kernel_exclusion; /* we allow one exn, but it must be shadowed */ +} Scheme_Module_Phase_Exports; + typedef struct Scheme_Module_Exports { /* Scheme_Module_Exports is separate from Scheme_Module @@ -2366,14 +2390,7 @@ typedef struct Scheme_Module_Exports unmarshal syntax-object context. */ MZTAG_IF_REQUIRED - Scheme_Object **provides; /* symbols (extenal names) */ - Scheme_Object **provide_srcs; /* module access paths, #f for self */ - Scheme_Object **provide_src_names; /* symbols (original internal names) */ - int num_provides; - int num_var_provides; /* non-syntax listed first in provides */ - - int reprovide_kernel; /* if true, extend provides with kernel's */ - Scheme_Object *kernel_exclusion; /* we allow one exn, but it must be shadowed */ + Scheme_Module_Phase_Exports *rt, *et, *dt; Scheme_Object *src_modidx; /* the one used in marshalled syntax */ } Scheme_Module_Exports; diff --git a/src/mzscheme/src/schvers.h b/src/mzscheme/src/schvers.h index 68b0e10c08..a3773593d6 100644 --- a/src/mzscheme/src/schvers.h +++ b/src/mzscheme/src/schvers.h @@ -9,6 +9,6 @@ #define MZSCHEME_VERSION_MAJOR 371 -#define MZSCHEME_VERSION_MINOR 1 +#define MZSCHEME_VERSION_MINOR 2 -#define MZSCHEME_VERSION "371.1" _MZ_SPECIAL_TAG +#define MZSCHEME_VERSION "371.2" _MZ_SPECIAL_TAG diff --git a/src/mzscheme/src/stxobj.c b/src/mzscheme/src/stxobj.c index 249dc0ef28..7e574b0dbe 100644 --- a/src/mzscheme/src/stxobj.c +++ b/src/mzscheme/src/stxobj.c @@ -67,9 +67,11 @@ static Scheme_Object *free_eq(int argc, Scheme_Object **argv); static Scheme_Object *module_eq(int argc, Scheme_Object **argv); static Scheme_Object *module_trans_eq(int argc, Scheme_Object **argv); static Scheme_Object *module_templ_eq(int argc, Scheme_Object **argv); +static Scheme_Object *module_label_eq(int argc, Scheme_Object **argv); static Scheme_Object *module_binding(int argc, Scheme_Object **argv); static Scheme_Object *module_trans_binding(int argc, Scheme_Object **argv); static Scheme_Object *module_templ_binding(int argc, Scheme_Object **argv); +static Scheme_Object *module_label_binding(int argc, Scheme_Object **argv); static Scheme_Object *module_binding_pos(int argc, Scheme_Object **argv); static Scheme_Object *module_trans_binding_pos(int argc, Scheme_Object **argv); static Scheme_Object *syntax_src_module(int argc, Scheme_Object **argv); @@ -451,6 +453,11 @@ void scheme_init_stx(Scheme_Env *env) "module-template-identifier=?", 2, 2), env); + scheme_add_global_constant("module-label-identifier=?", + scheme_make_noncm_prim(module_label_eq, + "module-label-identifier=?", + 2, 2), + env); scheme_add_global_constant("identifier-binding", scheme_make_noncm_prim(module_binding, @@ -460,13 +467,18 @@ void scheme_init_stx(Scheme_Env *env) scheme_add_global_constant("identifier-transformer-binding", scheme_make_noncm_prim(module_trans_binding, "identifier-transformer-binding", - 1, 1), + 1, 2), env); scheme_add_global_constant("identifier-template-binding", scheme_make_noncm_prim(module_templ_binding, "identifier-template-binding", 1, 1), env); + scheme_add_global_constant("identifier-label-binding", + scheme_make_noncm_prim(module_label_binding, + "identifier-label-binding", + 1, 1), + env); scheme_add_global_constant("identifier-binding-export-position", scheme_make_noncm_prim(module_binding_pos, @@ -2419,6 +2431,7 @@ static Scheme_Object *stx_activate_certs(Scheme_Object *o, Scheme_Cert **cp, Sch Scheme_Object *key; if (STX_KEY(stx) & STX_GRAPH_FLAG) { + /* FIXME: this is wrong */ if (!*ht) { GC_CAN_IGNORE Scheme_Hash_Table *htv; htv = scheme_make_hash_table(SCHEME_hash_ptr); @@ -4840,9 +4853,17 @@ static Scheme_Object *datum_to_wraps(Scheme_Object *w, if (!(SCHEME_SYMBOLP(p) || SAME_TYPE(SCHEME_TYPE(p), scheme_module_index_type))) return_NULL; - mli = SCHEME_CDR(mli); if (!SCHEME_PAIRP(mli)) return_NULL; + + /* A phase/dimension index (temporarily optional) */ + p = SCHEME_CAR(mli); + if ((SCHEME_INT_VAL(p) < 0) + || (SCHEME_INT_VAL(p) > 2)) + return_NULL; + mli = SCHEME_CDR(mli); + if (!SCHEME_PAIRP(mli)) return_NULL; + /* A list of symbols: */ p = SCHEME_CAR(mli); while (SCHEME_PAIRP(p)) { @@ -5435,7 +5456,7 @@ static void simplify_syntax_inner(Scheme_Object *o, SCHEME_USE_FUEL(1); if (STX_KEY(stx) & STX_GRAPH_FLAG) { - /* Instead of potentially losing graph sructure + /* Instead of potentially losing graph structure (or looping!), give up on simplifying. */ return; } @@ -6013,9 +6034,11 @@ static Scheme_Object *do_module_eq(const char *who, int delta, int argc, Scheme_ scheme_wrong_type(who, "identifier syntax", 1, argc, argv); return (scheme_stx_module_eq(argv[0], argv[1], - delta + (p->current_local_env - ? p->current_local_env->genv->phase - : 0)) + ((delta == MZ_LABEL_PHASE) + ? MZ_LABEL_PHASE + : (delta + (p->current_local_env + ? p->current_local_env->genv->phase + : 0)))) ? scheme_true : scheme_false); } @@ -6035,6 +6058,11 @@ static Scheme_Object *module_templ_eq(int argc, Scheme_Object **argv) return do_module_eq("module-template-identifier=?", -1, argc, argv); } +static Scheme_Object *module_label_eq(int argc, Scheme_Object **argv) +{ + return do_module_eq("module-label-identifier=?", MZ_LABEL_PHASE, argc, argv); +} + static Scheme_Object *do_module_binding(char *name, int argc, Scheme_Object **argv, int dphase, int get_position) { @@ -6047,9 +6075,12 @@ static Scheme_Object *do_module_binding(char *name, int argc, Scheme_Object **ar if (!SCHEME_STXP(a) || !SCHEME_STX_SYMBOLP(a)) scheme_wrong_type(name, "identifier syntax", 0, argc, argv); - m = scheme_stx_module_name(&a, dphase + (p->current_local_env + m = scheme_stx_module_name(&a, + ((dphase == MZ_LABEL_PHASE) + ? MZ_LABEL_PHASE + : (dphase + (p->current_local_env ? p->current_local_env->genv->phase - : 0), + : 0))), &nom_mod, &nom_a, &mod_phase); @@ -6102,6 +6133,11 @@ static Scheme_Object *module_templ_binding(int argc, Scheme_Object **argv) return do_module_binding("identifier-template-binding", argc, argv, -1, 0); } +static Scheme_Object *module_label_binding(int argc, Scheme_Object **argv) +{ + return do_module_binding("identifier-label-binding", argc, argv, MZ_LABEL_PHASE, 0); +} + static Scheme_Object *module_binding_pos(int argc, Scheme_Object **argv) { return do_module_binding("identifier-binding-export-position", argc, argv, 0, 1); diff --git a/src/mzscheme/src/stypes.h b/src/mzscheme/src/stypes.h index b3342b723b..302787b0a1 100644 --- a/src/mzscheme/src/stypes.h +++ b/src/mzscheme/src/stypes.h @@ -227,10 +227,11 @@ enum { scheme_rt_native_code_plus_case, /* 205 */ scheme_rt_jitter_data, /* 206 */ scheme_rt_module_exports, /* 207 */ - scheme_rt_delay_load_info, /* 208 */ - scheme_rt_marshal_info, /* 209 */ - scheme_rt_unmarshal_info, /* 210 */ - scheme_rt_runstack, /* 211 */ + scheme_rt_module_phase_exports, /* 208 */ + scheme_rt_delay_load_info, /* 209 */ + scheme_rt_marshal_info, /* 210 */ + scheme_rt_unmarshal_info, /* 211 */ + scheme_rt_runstack, /* 212 */ #endif _scheme_last_type_ diff --git a/src/mzscheme/src/thread.c b/src/mzscheme/src/thread.c index 01d88a2958..7bc9cb52b1 100644 --- a/src/mzscheme/src/thread.c +++ b/src/mzscheme/src/thread.c @@ -2433,6 +2433,8 @@ static void do_swap_thread() } else { Scheme_Thread *new_thread = swap_target; + swap_target = NULL; + swap_no_setjmp = 0; /* We're leaving... */ diff --git a/src/mzscheme/src/type.c b/src/mzscheme/src/type.c index b0fb909c7b..99709d6a8e 100644 --- a/src/mzscheme/src/type.c +++ b/src/mzscheme/src/type.c @@ -576,6 +576,7 @@ void scheme_register_traversers(void) GC_REG_TRAV(scheme_expanded_syntax_type, twoptr_obj); GC_REG_TRAV(scheme_module_type, module_val); GC_REG_TRAV(scheme_rt_module_exports, module_exports_val); + GC_REG_TRAV(scheme_rt_module_phase_exports, module_phase_exports_val); GC_REG_TRAV(scheme_module_index_type, modidx_val); GC_REG_TRAV(scheme_security_guard_type, guard_val);