From a68c0594a5efbbdcc9d65a627742b7359fb7682f Mon Sep 17 00:00:00 2001
From: Matthew Flatt
for further description of the file's format. Note in particular the
-two-letter category specified in the the third field, which is referenced
+two-letter category specified in the third field, which is referenced
frequently in the descriptions below.
diff --git a/doc/srfi-std/srfi-35.html b/doc/srfi-std/srfi-35.html
index 7e2964690e..de261a8b17 100644
--- a/doc/srfi-std/srfi-35.html
+++ b/doc/srfi-std/srfi-35.html
@@ -145,7 +145,7 @@ returns a condition of condition type condition-type
is a compound condition, TRUE
if and only if the given
- * String is equal, ignoring case, to the the String "true", otherwise
+ * String is equal, ignoring case, to the String "true", otherwise
* it will return the Boolean FALSE
.
*
* @param s the string to convert
diff --git a/collects/redex/doc.txt b/collects/redex/doc.txt
index dfab824865..34a310f375 100644
--- a/collects/redex/doc.txt
+++ b/collects/redex/doc.txt
@@ -540,7 +540,7 @@ c.
This form extends the reduction relation in its first
argument with the rules specified in extract-condition
extracts the field values from the subcondition belonging to condition-type
that appeared first in the call to make-compound-condition
- that created the the condition. The returned condition may be newly created; it is possible for(let* ((&c (make-condition-type 'c &condition '()))
+ that created the condition. The returned condition may be newly created; it is possible for
(let* ((&c (make-condition-type 'c &condition '())) (c0 (make-condition &c)) (c1 (make-compound-condition c0))) (eq? c0 (extract-condition c1 &c))) diff --git a/doc/srfi-std/srfi-43.html b/doc/srfi-std/srfi-43.html index af42c0c436..55e02c1876 100644 --- a/doc/srfi-std/srfi-43.html +++ b/doc/srfi-std/srfi-43.html @@ -389,7 +389,7 @@ You can access the discussion via vector->list, but the resulting list contains the elements in reverse between - the the specified range. + the specified range.
diff --git a/doc/srfi-std/srfi-69.html b/doc/srfi-std/srfi-69.html index b93e00c9cd..91ad15374c 100644 --- a/doc/srfi-std/srfi-69.html +++ b/doc/srfi-std/srfi-69.html @@ -107,7 +107,7 @@ tables so that portable programs can be written that make efficient use of common hash table functionality. The SRFI resolves discrepancies that exist between the various hash table API's with respect to naming and semantics of hash table operations. A lot of effort has been put -into making the the API consistent, simple and generic. The SRFI also +into making the API consistent, simple and generic. The SRFI also defines some of the most common utility routines that would otherwise need to be written and rewritten for various applications. diff --git a/src/mzscheme/gc/configure.host b/src/mzscheme/gc/configure.host index a98a0a7cb3..04526cfdf8 100644 --- a/src/mzscheme/gc/configure.host +++ b/src/mzscheme/gc/configure.host @@ -2,7 +2,7 @@ # This shell script handles all host based configuration for the garbage # collector. -# It sets various shell variables based on the the host and the +# It sets various shell variables based on the host and the # configuration options. You can modify this shell script without # needing to rerun autoconf. diff --git a/src/mzscheme/src/read.c b/src/mzscheme/src/read.c index 6ea1585bbf..a0e2b0d549 100644 --- a/src/mzscheme/src/read.c +++ b/src/mzscheme/src/read.c @@ -5289,7 +5289,7 @@ static Scheme_Object *read_compiled(Scheme_Object *port, top->prefix->num_stxes, top->prefix->num_lifts, 0); - /* If no exception, the the resulting code is ok. */ + /* If no exception, the resulting code is ok. */ } else scheme_ill_formed_code(rp); diff --git a/src/wxxt/src/Utilities/Home.cc b/src/wxxt/src/Utilities/Home.cc index 5004f213f6..8ba766afd4 100644 --- a/src/wxxt/src/Utilities/Home.cc +++ b/src/wxxt/src/Utilities/Home.cc @@ -44,7 +44,7 @@ char *wxGetUserHome(const char *user) || (ptr = getenv("LOGNAME")) != NULL) { who = getpwnam(ptr); } - // We now make sure the the user exists! + // We now make sure the user exists! if (who == NULL) who = getpwuid(getuid()); } else diff --git a/src/wxxt/src/Windows/RadioBox.cc b/src/wxxt/src/Windows/RadioBox.cc index 6525ef942c..6daea4bb15 100644 --- a/src/wxxt/src/Windows/RadioBox.cc +++ b/src/wxxt/src/Windows/RadioBox.cc @@ -132,7 +132,7 @@ Bool wxRadioBox::Create(wxPanel *panel, wxFunction func, char *label, else XtRealizeWidget(wgt); X->frame = wgt; - // create group widget, which holds the the toggles + // create group widget, which holds the toggles wgt = XtVaCreateManagedWidget("radiobox", xfwfGroupWidgetClass, X->frame, XtNselectionStyle, (style & wxAT_MOST_ONE) ? XfwfSingleSelection : XfwfOneSelection, @@ -263,7 +263,7 @@ Bool wxRadioBox::Create(wxPanel *panel, wxFunction func, char *label, XtRealizeWidget(wgt); X->frame = wgt; - // create group widget, which holds the the toggles + // create group widget, which holds the toggles wgt = XtVaCreateManagedWidget("radiobox", xfwfGroupWidgetClass, X->frame, XtNselectionStyle, (style & wxAT_MOST_ONE) ? XfwfSingleSelection : XfwfOneSelection, diff --git a/src/wxxt/src/Windows/Window.cc b/src/wxxt/src/Windows/Window.cc index 259a9ce0dd..ecfef4f77d 100644 --- a/src/wxxt/src/Windows/Window.cc +++ b/src/wxxt/src/Windows/Window.cc @@ -1019,7 +1019,7 @@ _XFUNCPROTOEND // I've used the following way to intercept the incomming events: // - first Xt calls the expose method of the widget // - second it calls all event handlers installed by XtAddEventHandler -// - third it evaluates the the widget's translation table +// - third it evaluates the widget's translation table // --> I forbid the evaluation of the translation table and call // _XtTranslateEvent by myself. // diff --git a/src/wxxt/src/XWidgets/xwScrollWin.w b/src/wxxt/src/XWidgets/xwScrollWin.w index 076f53f974..6abf9d069a 100644 --- a/src/wxxt/src/XWidgets/xwScrollWin.w +++ b/src/wxxt/src/XWidgets/xwScrollWin.w @@ -28,7 +28,7 @@ is invoked {\em after} the CW is moved. @var highlightThickness = 0 -@ Decide, if the the scrolled window should be included in the +@ Decide, if the scrolled window should be included in the keyboard traversal. @var Boolean traverseToChild = TRUE From 24571c0093aa127363ccb9926166c1c832d09324 Mon Sep 17 00:00:00 2001 From: Eli BarzilayDate: Fri, 1 May 2009 22:39:30 +0000 Subject: [PATCH 06/32] make sure "coLLECTs dIRECTORy:" is on a single line, and remove "now" from the 3m description svn: r14682 --- src/README | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/README b/src/README index ce46ce9bb6..508c502f2c 100644 --- a/src/README +++ b/src/README @@ -219,8 +219,8 @@ but it will not work properly unless --enable-pthread is specified. MzScheme and MrEd have two variants: CGC and 3m. The CGC variant is older, and it cooperates more easily with extensions written in C. -The 3m variant is now the default, and it usually provides better -overall performance. +The 3m variant is the default, and it usually provides better overall +performance. The default build mode creates 3m binaries only. To create CGC binaries in addition, run `make cgc' in addition to `make', or run @@ -245,10 +245,10 @@ case the first path is the main "collects" path, and additional paths are placed before the main path (but after a user-specific "collects" path) in the default collection path list. -The paths are embedded in the binary immediately after a "coLLECTs -dIRECTORy:" tag. Each path must be NUL terminated, the entire list of -paths must end with an additional NUL terminator, and the overall list -must be less than 1024 bytes long. +The paths are embedded in the binary immediately after a special +"coLLECTs dIRECTORy:" tag. Each path must be NUL terminated, the +entire list of paths must end with an additional NUL terminator, and +the overall list must be less than 1024 bytes long. As an alternative to editing an exeuctable directly, the `create-embedding-executable' procedure from `compiler/embed' can be From 930eec2d028e8cc2b42cc105158357d7ff5ca22c Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Fri, 1 May 2009 22:54:54 +0000 Subject: [PATCH 07/32] be more explicit about building from a new directory svn: r14683 --- src/README | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/README b/src/README index 508c502f2c..bd3ee6b6ad 100644 --- a/src/README +++ b/src/README @@ -80,8 +80,9 @@ the Unix instructions below, but note the following: try using GNU `make'. 1. Run the script `configure' (which is in the same directory as this - README), usually with a --prefix=TARGETDIR command-line argument - and optionally with --enable-shared. + README), possibly with a --prefix=TARGETDIR command-line argument + and optionally with --enable-shared. It is better to run the + build in a different directory rather then use this directory. For example, if you want to install into /usr/local/plt using dynamic libraries, then run @@ -90,7 +91,21 @@ the Unix instructions below, but note the following: where "[here]" is the directory path containing the `configure' script (possibly unnecessary, or possibly just "./", depending on - your shell and PATH setting). + your shell and PATH setting). To use a different directory for + the build (which is recommended), for example a subdirectory named + "build": + + cd [here] + mkdir build + cd build + ../configure --prefix=/usr/local/plt --enable-shared + + (This is especially more convenient if you plan to update your + source tree from the plt repository. Such updates might involve + changes in the structure, which will leave your source tree in an + inconsistent state (eg, old Makefiles referring to inexistent + files). In such cases it is convenient to just remove the "build" + directory and start a fresh build.) If the --prefix flag is omitted, the binaries are built for an in-place installation (i.e., the parent of the directory @@ -106,8 +121,8 @@ the Unix instructions below, but note the following: executables (independent of --prefix). This build directory does not have to be in the source tree, even for an "in-place" build. It's ok to run `configure' from its own directory (as in - the example above), but it's often better to pick a separate build - directory that is otherwise empty. + the first example above), but it's better to pick a separate build + directory that is otherwise empty (as in the second example). The `configure' script accepts many other flags that adjust the build process. Run `configure --help' for more information. In From 55a98bf037f64453536b72a0a30950afea73c20a Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 2 May 2009 00:57:18 +0000 Subject: [PATCH 08/32] fixed a bug with holes used in certain places in patterns svn: r14684 --- collects/redex/private/core-layout.ss | 10 ---------- collects/redex/private/reduction-semantics.ss | 4 ++-- .../redex/private/rewrite-side-conditions.ss | 18 ++++-------------- collects/redex/private/term.ss | 2 +- collects/redex/private/tl-test.ss | 14 ++++++++++++++ 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/collects/redex/private/core-layout.ss b/collects/redex/private/core-layout.ss index b6cb0df392..5125fb3686 100644 --- a/collects/redex/private/core-layout.ss +++ b/collects/redex/private/core-layout.ss @@ -75,16 +75,6 @@ (equal? (lw-e thing-in-hole) 'hole)) (list (blank) context (blank)) (list (blank) context "" "[" thing-in-hole "]"))))) - (in-named-hole ,(λ (args) - (let ([name (lw-e (list-ref args 2))] - [context (list-ref args 3)] - [thing-in-hole (list-ref args 4)]) - (if (and (lw? thing-in-hole) - (equal? (lw-e thing-in-hole) 'hole)) - (list (blank) context "[]" - (basic-text (format "~a" name) (non-terminal-subscript-style))) - (list (blank) context "" "[" thing-in-hole "]" - (basic-text (format "~a" name) (non-terminal-subscript-style))))))) (hide-hole ,(λ (args) (list (blank) (list-ref args 2) diff --git a/collects/redex/private/reduction-semantics.ss b/collects/redex/private/reduction-semantics.ss index 7fdb50eb2c..b4504a23bf 100644 --- a/collects/redex/private/reduction-semantics.ss +++ b/collects/redex/private/reduction-semantics.ss @@ -1008,8 +1008,8 @@ (with-syntax ([(side-conditions-rewritten ...) (map (λ (x) (rewrite-side-conditions/check-errs lang-nts - #t 'define-metafunction + #t x)) (syntax->list (syntax ((side-condition lhs (and tl-side-conds ...)) ...))))] [dom-side-conditions-rewritten @@ -1398,7 +1398,7 @@ (for-each (λ (name) (let ([x (syntax->datum name)]) - (when (memq x '(any number string variable natural integer real variable-except variable-prefix hole name in-hole in-named-hole hide-hole side-condition cross ...)) + (when (memq x '(any number string variable natural integer real variable-except variable-prefix hole name in-hole hide-hole side-condition cross ...)) (raise-syntax-error 'language (format "cannot use pattern language keyword ~a as non-terminal" x) diff --git a/collects/redex/private/rewrite-side-conditions.ss b/collects/redex/private/rewrite-side-conditions.ss index 58da06c255..2d41087d01 100644 --- a/collects/redex/private/rewrite-side-conditions.ss +++ b/collects/redex/private/rewrite-side-conditions.ss @@ -33,7 +33,7 @@ (define (expected-arguments name stx) (raise-syntax-error what (format "~a expected to have arguments" name) orig-stx stx)) (let loop ([term orig-stx]) - (syntax-case term (side-condition variable-except variable-prefix hole name in-hole in-named-hole hide-hole side-condition cross) + (syntax-case term (side-condition variable-except variable-prefix hole name in-hole hide-hole side-condition cross) [(side-condition pre-pat (and)) ;; rewriting metafunctions (and possibly other things) that have no where, etc clauses ;; end up with side-conditions that are empty 'and' expressions, so we just toss them here. @@ -58,20 +58,15 @@ [(variable-prefix a ...) (expected-exact 'variable-prefix 1 term)] [variable-prefix (expected-arguments 'variable-prefix term)] [hole term] - [(hole a) #`(hole #,(loop #'a))] - [(hole a ...) (raise-syntax-error what "hole expected to stand alone or to have one argument")] [(name x y) #`(name #,(loop #'x) #,(loop #'y))] [(name x ...) (expected-exact 'name 2 term)] [name (expected-arguments 'name term)] [(in-hole a b) #`(in-hole #,(loop #'a) #,(loop #'b))] [(in-hole a ...) (expected-exact 'in-hole 2 term)] [in-hole (expected-arguments 'in-hole term)] - [(in-named-hole a b c) #`(in-named-hole #,(loop #'a) #,(loop #'b) #,(loop #'c))] - [(in-named-hole a ...) (expected-exact 'in-named-hole 3 term)] - [in-named-hole (expected-arguments 'in-named-hole term)] [(hide-hole a) #`(hide-hole #,(loop #'a))] - [(in-named-hole a ...) (expected-exact 'hide-hole 1 term)] - [in-named-hole (expected-arguments 'hide-hole term)] + [(hide-hole a ...) (expected-exact 'hide-hole 1 term)] + [hide-hole (expected-arguments 'hide-hole term)] [(cross a) #`(cross #,(loop #'a))] [(cross a ...) (expected-exact 'cross 1 term)] [cross (expected-arguments 'cross term)] @@ -96,17 +91,12 @@ (let loop ([stx orig-stx] [names null] [depth 0]) - (syntax-case stx (name in-hole in-named-hole side-condition) + (syntax-case stx (name in-hole side-condition) [(name sym pat) (identifier? (syntax sym)) (loop (syntax pat) (cons (make-id/depth (syntax sym) depth) names) depth)] - [(in-named-hole hlnm sym pat1 pat2) - (identifier? (syntax sym)) - (loop (syntax pat1) - (loop (syntax pat2) names depth) - depth)] [(in-hole pat1 pat2) (loop (syntax pat1) (loop (syntax pat2) names depth) diff --git a/collects/redex/private/term.ss b/collects/redex/private/term.ss index 20b7e03cbb..e739cc8f7c 100644 --- a/collects/redex/private/term.ss +++ b/collects/redex/private/term.ss @@ -34,7 +34,7 @@ (define (rewrite/has-term-let-bound-id? stx) (let loop ([stx stx] [depth 0]) - (syntax-case stx (unquote unquote-splicing in-hole in-named-hole hole) + (syntax-case stx (unquote unquote-splicing in-hole hole) [(metafunc-name arg ...) (and (identifier? (syntax metafunc-name)) (term-fn? (syntax-local-value (syntax metafunc-name) (λ () #f)))) diff --git a/collects/redex/private/tl-test.ss b/collects/redex/private/tl-test.ss index a35495e14a..4532823cbd 100644 --- a/collects/redex/private/tl-test.ss +++ b/collects/redex/private/tl-test.ss @@ -546,6 +546,20 @@ (test (term (f ((((x)))))) (term x))) + (let () + (define-language lamv + (z variable hole)) + + (define-metafunction lamv + foo : z -> any + [(foo hole) dontcare] + [(foo variable) docare]) + + (test (term (foo hole)) + (term dontcare)) + (test (term (foo y)) + (term docare))) + ;; test that tracing works properly ;; note that caching comes into play here (which is why we don't see the recursive calls) (let () From a7ad3ce74c270c90cf1f81c61c044b5f9a8710ff Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sat, 2 May 2009 07:50:11 +0000 Subject: [PATCH 09/32] Welcome to a new PLT day. svn: r14686 --- collects/repos-time-stamp/stamp.ss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collects/repos-time-stamp/stamp.ss b/collects/repos-time-stamp/stamp.ss index 393621aa2d..92b8dbdc6e 100644 --- a/collects/repos-time-stamp/stamp.ss +++ b/collects/repos-time-stamp/stamp.ss @@ -1 +1 @@ -#lang scheme/base (provide stamp) (define stamp "1may2009") +#lang scheme/base (provide stamp) (define stamp "2may2009") From ea1ace602228e6a33b4ee810bf7a7bec1cb5495a Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 2 May 2009 12:32:04 +0000 Subject: [PATCH 10/32] added horizontal-left-align style svn: r14687 --- collects/redex/pict.ss | 1 + collects/redex/private/pict.ss | 11 +++++++---- collects/redex/redex.scrbl | 19 +++++++++++-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/collects/redex/pict.ss b/collects/redex/pict.ss index 10cc69a8ea..d5ebef2e4b 100644 --- a/collects/redex/pict.ss +++ b/collects/redex/pict.ss @@ -12,6 +12,7 @@ (symbols 'compact-vertical 'vertical 'vertical-overlapping-side-conditions + 'horizontal-left-align 'horizontal)) (provide reduction-rule-style/c) diff --git a/collects/redex/private/pict.ss b/collects/redex/private/pict.ss index 010ea726fb..9a97ceac3a 100644 --- a/collects/redex/private/pict.ss +++ b/collects/redex/private/pict.ss @@ -127,7 +127,7 @@ (define current-label-extra-space (make-parameter 0)) (define reduction-relation-rule-separation (make-parameter 4)) -(define (rule-picts->pict/horizontal rps) +(define ((rule-picts->pict/horizontal left-column-align) rps) (let* ([sep 2] [max-rhs (apply max 0 @@ -160,8 +160,8 @@ (blank) sep (blank) (blank) (blank)))) rps)) - (list* rtl-superimpose ctl-superimpose ltl-superimpose) - (list* rtl-superimpose ctl-superimpose ltl-superimpose) + (list* left-column-align ctl-superimpose ltl-superimpose) + (list* left-column-align ctl-superimpose ltl-superimpose) (list* sep sep (+ sep (current-label-extra-space))) 2))) (define arrow-space (make-parameter 0)) @@ -326,7 +326,10 @@ [(compact-vertical) rule-picts->pict/compact-vertical] [(vertical-overlapping-side-conditions) rule-picts->pict/vertical-overlapping-side-conditions] - [else rule-picts->pict/horizontal])) + [(horizontal-left-align) + (rule-picts->pict/horizontal ltl-superimpose)] + [else ;; horizontal + (rule-picts->pict/horizontal rtl-superimpose)])) (define (mk-arrow-pict sz style) (let ([cache (make-hash)]) diff --git a/collects/redex/redex.scrbl b/collects/redex/redex.scrbl index 20122a4d70..5d72329009 100644 --- a/collects/redex/redex.scrbl +++ b/collects/redex/redex.scrbl @@ -1672,14 +1672,17 @@ multi-line right-hand sides. This parameter controls the style used by default for the reduction relation. It can be @scheme['horizontal], where the left and -right-hand sides of the reduction rule are beside each other -or @scheme['vertical], where the left and right-hand sides of the -reduction rule are above each other. -The @scheme['compact-vertical] style moves the reduction arrow -to the second line and uses less space between lines. -Finally, in the @scheme['vertical-overlapping-side-conditions] variant, the side-conditions don't contribute to -the width of the pict, but are just overlaid on the second -line of each rule. +right-hand sides of the reduction rule are beside each other or +@scheme['vertical], where the left and right-hand sides of the +reduction rule are above each other. The @scheme['compact-vertical] +style moves the reduction arrow to the second line and uses less space +between lines. The @scheme['vertical-overlapping-side-conditions] +variant, the side-conditions don't contribute to the width of the +pict, but are just overlaid on the second line of each rule. The +@scheme['horizontal-left-align] style is like the @scheme['horizontal] +style, but the left-hand sides of the rules are aligned on the left, +instead of on the right. + } @defthing[reduction-rule-style/c flat-contract?]{ From 5f2a62f37cd8d1923b4cdd4e1df1170529d6f00a Mon Sep 17 00:00:00 2001 From: Matthias Felleisen Date: Sat, 2 May 2009 15:25:15 +0000 Subject: [PATCH 11/32] svn: r14689 --- collects/lang/private/TODO | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 collects/lang/private/TODO diff --git a/collects/lang/private/TODO b/collects/lang/private/TODO new file mode 100644 index 0000000000..7f7f0cfc8b --- /dev/null +++ b/collects/lang/private/TODO @@ -0,0 +1,41 @@ +If we eliminate char from HtDP/I, we need to add re-think the following +functions: + +integer->char -- 1string version + +char->integer -- 1string version + +string->list -- explode + +list->string -- implode + +char-numeric? -- in a sense string->number is enough + (number? (string->number s)) + +char-alphabetic? -- + (andmap (lambda (c) + (or (string<=? "A" x "Z") (string<=? "a" x "z"))) + (string->list s)) + +char-whitespace? -- (andmap char-whitespace? s) + +char-upper-case? -- (string<=? "A" x "Z") + +char-lower-case? -- (string<=? "a" x "z") + +char-upcase string-upcase + +char-downcase string-downcase + +make-string : Nat Char -> String + Nat String1 -> String + +string : Char ... -> String + delete, string-append is enough + +string-ref : String Nat -> Char + ith + +NOTE: +substring consumes 2 or 3 arguments + From 7315ff502b0dd1d01b77ac64646454504d03d397 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 2 May 2009 16:18:12 +0000 Subject: [PATCH 12/32] fixed label ordering for reductions when extracted via reduction-relation->rule names svn: r14690 --- collects/redex/private/reduction-semantics.ss | 31 ++++++----- collects/redex/private/struct.ss | 4 +- collects/redex/private/tl-test.ss | 52 +++++++++++++++++++ collects/redex/redex.scrbl | 6 +-- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/collects/redex/private/reduction-semantics.ss b/collects/redex/private/reduction-semantics.ss index b4504a23bf..4b4c450d90 100644 --- a/collects/redex/private/reduction-semantics.ss +++ b/collects/redex/private/reduction-semantics.ss @@ -453,12 +453,18 @@ (for-each loop nexts))))) all-top-levels) - (let ([name-ht (make-hasheq)] + (let ([name-table (make-hasheq)] [lang-nts (language-id-nts lang-id orig-name)]) + (hash-set! name-table #f 0) + ;; name table maps symbols for the rule names to their syntax objects and to a counter indicating what + ;; order the names were encountered in. The current value of the counter is stored in the table at key '#f'. (with-syntax ([lang-id lang-id] [(top-level ...) (get-choices stx orig-name ht lang-id main-arrow - name-ht lang-id allow-zero-rules?)] - [(rule-names ...) (hash-map name-ht (λ (k v) k))] + name-table lang-id allow-zero-rules?)] + [(rule-names ...) + (begin + (hash-remove! name-table #f) + (map car (sort (hash-map name-table (λ (k v) (list k (list-ref v 1)))) < #:key cadr)))] [lws lws] [domain-pattern-side-conditions-rewritten @@ -660,9 +666,11 @@ (raise-syntax-errors orig-name "same name on multiple rules" stx - (list (hash-ref name-table name-sym) + (list (car (hash-ref name-table name-sym)) (syntax name)))) - (hash-set! name-table name-sym (syntax name)) + (let ([num (hash-ref name-table #f)]) + (hash-set! name-table #f (+ num 1)) + (hash-set! name-table name-sym (list (syntax name) num))) (when the-name (raise-syntax-errors orig-name @@ -773,6 +781,7 @@ (define (union-reduction-relations fst snd . rst) (let ([name-ht (make-hasheq)] + [counter 0] [lst (list* fst snd rst)] [first-lang (reduction-relation-lang fst)]) (for-each @@ -783,14 +792,15 @@ (for-each (λ (name) (when (hash-ref name-ht name #f) (error 'union-reduction-relations "multiple rules with the name ~s" name)) - (hash-set! name-ht name #t)) + (hash-set! name-ht name counter) + (set! counter (+ counter 1))) (reduction-relation-rule-names red))) - lst) + (reverse lst)) ;; reverse here so the names get put into the hash in the proper (backwards) order (build-reduction-relation #f first-lang (reverse (apply append (map reduction-relation-make-procs lst))) - (hash-map name-ht (λ (k v) k)) + (map car (sort (hash-map name-ht list) < #:key cadr)) (apply append (map reduction-relation-lws lst)) `any))) @@ -1772,10 +1782,7 @@ (equal? str1 (substring str2 0 (string-length str1))))) -;; The struct selector extracts the reduction relation rules, which -;; are in reverse order compared to the way the reduction relation was written -;; in the program text. So reverse them. -(define (reduction-relation->rule-names x) +(define (reduction-relation->rule-names x) (reverse (reduction-relation-rule-names x))) diff --git a/collects/redex/private/struct.ss b/collects/redex/private/struct.ss index 569a0c82d1..0627ffa9c3 100644 --- a/collects/redex/private/struct.ss +++ b/collects/redex/private/struct.ss @@ -82,8 +82,8 @@ make-procs/check-domain)]) (make-reduction-relation lang all-make-procs - (append (reduction-relation-rule-names orig-reduction-relation) - rule-names) + (append rule-names + (reduction-relation-rule-names orig-reduction-relation)) lws ;; only keep new lws for typesetting (map (λ (make-proc) (make-proc lang)) all-make-procs)))] [else diff --git a/collects/redex/private/tl-test.ss b/collects/redex/private/tl-test.ss index 4532823cbd..969de8825b 100644 --- a/collects/redex/private/tl-test.ss +++ b/collects/redex/private/tl-test.ss @@ -1131,6 +1131,58 @@ (test (apply-reduction-relation red2 (term (X q))) (list (term (X z)) (term (X w))))) + (test (reduction-relation->rule-names + (reduction-relation + empty-language + (--> x y a))) + '(a)) + + (test (reduction-relation->rule-names + (reduction-relation + empty-language + (--> x y a) + (--> y z b) + (--> z w c))) + '(a b c)) + + (test (reduction-relation->rule-names + (reduction-relation + empty-language + (--> x y a) + (--> y z b) + (--> z w c) + (--> p q z) + (--> q r y) + (--> r p x))) + '(a b c z y x)) + + (test (reduction-relation->rule-names + (extend-reduction-relation + (reduction-relation + empty-language + (--> x y a) + (--> y z b) + (--> z w c)) + empty-language + (--> p q z) + (--> q r y) + (--> r p x))) + '(a b c z y x)) + + (test (reduction-relation->rule-names + (union-reduction-relations + (reduction-relation + empty-language + (--> x y a) + (--> y z b) + (--> z w c)) + (reduction-relation + empty-language + (--> p q z) + (--> q r y) + (--> r p x)))) + '(a b c z y x)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; examples from doc.txt diff --git a/collects/redex/redex.scrbl b/collects/redex/redex.scrbl index 5d72329009..683503f318 100644 --- a/collects/redex/redex.scrbl +++ b/collects/redex/redex.scrbl @@ -8,7 +8,7 @@ scheme/pretty scheme/contract mrlib/graph - (only-in slideshow/pict pict? text dc-for-text-size) + (only-in slideshow/pict pict? text dc-for-text-size text-style/c) redex)) @(define-syntax (defpattech stx) @@ -887,9 +887,7 @@ The @scheme[define-metafunction] form builds a function on sexpressions according to the pattern and right-hand-side expressions. The first argument indicates the language used to resolve non-terminals in the pattern expressions. Each of -the rhs-expressions is implicitly wrapped in @|tttterm|. In -addition, recursive calls in the right-hand side of the -metafunction clauses should appear inside @|tttterm|. +the rhs-expressions is implicitly wrapped in @|tttterm|. If specified, the side-conditions are collected with @scheme[and] and used as guards on the case being matched. The From c78c9f1e1bb6a60e3c4dd58aee2baeb4180cf082 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 3 May 2009 07:50:16 +0000 Subject: [PATCH 13/32] Welcome to a new PLT day. svn: r14691 --- collects/repos-time-stamp/stamp.ss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collects/repos-time-stamp/stamp.ss b/collects/repos-time-stamp/stamp.ss index 92b8dbdc6e..0c63e9c947 100644 --- a/collects/repos-time-stamp/stamp.ss +++ b/collects/repos-time-stamp/stamp.ss @@ -1 +1 @@ -#lang scheme/base (provide stamp) (define stamp "2may2009") +#lang scheme/base (provide stamp) (define stamp "3may2009") From 75527a8821f20727615966ad1336093be94011f8 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 3 May 2009 15:45:53 +0000 Subject: [PATCH 14/32] better tracking of lexical context for unwrapped syntax objects svn: r14692 --- collects/r6rs/private/reconstruct.ss | 4 ++++ collects/rnrs/base-6.ss | 14 +++++++++----- collects/rnrs/syntax-case-6.ss | 8 +++++++- 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 collects/r6rs/private/reconstruct.ss diff --git a/collects/r6rs/private/reconstruct.ss b/collects/r6rs/private/reconstruct.ss new file mode 100644 index 0000000000..95d3c9175f --- /dev/null +++ b/collects/r6rs/private/reconstruct.ss @@ -0,0 +1,4 @@ +#lang scheme/base + +(provide reconstruction-memory) +(define reconstruction-memory (make-weak-hasheq)) diff --git a/collects/rnrs/base-6.ss b/collects/rnrs/base-6.ss index 0c7b240f08..40c4facd7a 100644 --- a/collects/rnrs/base-6.ss +++ b/collects/rnrs/base-6.ss @@ -7,6 +7,7 @@ scheme/splicing r6rs/private/qq-gen r6rs/private/exns + (for-syntax r6rs/private/reconstruct) (prefix-in r5rs: r5rs) (only-in r6rs/private/readtable rx:number) scheme/bool) @@ -561,11 +562,14 @@ [(symbol? r) (error 'macro "transformer result included a raw symbol: ~e" r)] - [(mpair? r) (datum->syntax - stx - (cons (wrap (mcar r) stx) - (wrap (mcdr r) stx)) - stx)] + [(mpair? r) + (let ([istx (or (hash-ref reconstruction-memory r #f) + stx)]) + (datum->syntax + istx + (cons (wrap (mcar r) stx) + (wrap (mcdr r) stx)) + istx))] [(vector? r) (datum->syntax stx (list->vector diff --git a/collects/rnrs/syntax-case-6.ss b/collects/rnrs/syntax-case-6.ss index 6404d5bb5b..05f9e0bae9 100644 --- a/collects/rnrs/syntax-case-6.ss +++ b/collects/rnrs/syntax-case-6.ss @@ -2,6 +2,7 @@ (require (for-syntax scheme/base) r6rs/private/qq-gen + r6rs/private/reconstruct scheme/mpair r6rs/private/exns (for-syntax syntax/template @@ -179,6 +180,8 @@ ;; ---------------------------------------- (define (unwrap-reconstructed data stx datum) + (when (mpair? datum) + (hash-set! reconstruction-memory datum (datum->syntax stx 'memory stx))) datum) (define (unwrap-pvar data stx) @@ -187,7 +190,10 @@ (cond [(syntax? v) (if (eq? (syntax-source v) unwrapped-tag) - (loop (syntax-e v)) + (let ([r (loop (syntax-e v))]) + (when (mpair? r) + (hash-set! reconstruction-memory r (datum->syntax v 'memory v))) + r) v)] [(pair? v) (mcons (loop (car v)) (loop (cdr v)))] From 3ca6ac2175680850e6df5cfc0f735fab2f508fe2 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 3 May 2009 16:17:48 +0000 Subject: [PATCH 15/32] added stupid make-list and stupid const svn: r14693 --- collects/scheme/function.ss | 6 +++++- collects/scheme/list.ss | 8 ++++++++ collects/scribblings/reference/pairs.scrbl | 6 ++++++ collects/scribblings/reference/procedures.scrbl | 9 +++++++++ collects/srfi/1/cons.ss | 13 +++++++------ collects/tests/mzscheme/function.ss | 6 ++++++ collects/tests/mzscheme/list.ss | 7 +++++++ 7 files changed, 48 insertions(+), 7 deletions(-) diff --git a/collects/scheme/function.ss b/collects/scheme/function.ss index ffe2962b95..56a55e7a38 100644 --- a/collects/scheme/function.ss +++ b/collects/scheme/function.ss @@ -1,6 +1,10 @@ #lang scheme/base -(provide negate curry curryr) +(provide const negate curry curryr) + +(define (const c) + (define (const . _) c) + const) (define (negate f) (unless (procedure? f) (raise-type-error 'negate "procedure" f)) diff --git a/collects/scheme/list.ss b/collects/scheme/list.ss index cedd06621c..25820d9c9d 100644 --- a/collects/scheme/list.ss +++ b/collects/scheme/list.ss @@ -8,6 +8,8 @@ empty empty? + make-list + drop take split-at @@ -81,6 +83,12 @@ (define empty? (lambda (l) (null? l))) (define empty '()) +(define (make-list n x) + (unless (exact-nonnegative-integer? n) + (raise-type-error 'make-list "non-negative exact integer" n)) + (let loop ([n n] [r '()]) + (if (zero? n) r (loop (sub1 n) (cons x r))))) + ;; internal use below (define (drop* list n) ; no error checking, returns #f if index is too large (if (zero? n) list (and (pair? list) (drop* (cdr list) (sub1 n))))) diff --git a/collects/scribblings/reference/pairs.scrbl b/collects/scribblings/reference/pairs.scrbl index cc60d0af62..14c990dc76 100644 --- a/collects/scribblings/reference/pairs.scrbl +++ b/collects/scribblings/reference/pairs.scrbl @@ -513,6 +513,12 @@ Like @scheme[assoc], but finds an element using the predicate @defproc[(last-pair [p pair?]) pair?]{ Returns the last pair of a (possibly improper) list.} +@defproc[(make-list [k exact-nonnegative-integer?] [v any?]) list?]{ +Returns a newly constructed list of length @scheme[k], holding +@scheme[v] in all positions. + +@mz-examples[(make-list 7 'foo)]} + @defproc[(take [lst any/c] [pos exact-nonnegative-integer?]) list?]{ Returns a fresh list whose elements are the first @scheme[pos] elements of @scheme[lst]. If @scheme[lst] has fewer than diff --git a/collects/scribblings/reference/procedures.scrbl b/collects/scribblings/reference/procedures.scrbl index e062acab2d..329ca50ed4 100644 --- a/collects/scribblings/reference/procedures.scrbl +++ b/collects/scribblings/reference/procedures.scrbl @@ -422,6 +422,15 @@ applied.} @(define fun-eval (make-base-eval)) @(interaction-eval #:eval fun-eval (require scheme/function)) +@defproc[(const [v any]) procedure?]{ + +Returns a procedure that accepts any arguments and returns @scheme[v]. + +@mz-examples[#:eval fun-eval +((const 'foo) 1 2 3) +((const 'foo)) +]} + @defproc[(negate [proc procedure?]) procedure?]{ Returns a procedure that is just like @scheme[proc], except that it diff --git a/collects/srfi/1/cons.ss b/collects/srfi/1/cons.ss index 21ff7097ea..45230fb774 100644 --- a/collects/srfi/1/cons.ss +++ b/collects/srfi/1/cons.ss @@ -34,12 +34,12 @@ #lang scheme/base -(require srfi/optional "selector.ss") +(require srfi/optional "selector.ss" (only-in scheme/list make-list)) (provide xcons make-list list-tabulate - cons* + (rename-out [list* cons*]) list-copy circular-list iota) @@ -50,9 +50,10 @@ ;; Make a list of length LEN. -(define (make-list len [elt #f]) - (check-arg (lambda (n) (and (integer? n) (>= n 0))) len 'make-list) - (for/list ([i (in-range len)]) elt)) +;; reprovided from mzscheme +;; (define (make-list len [elt #f]) +;; (check-arg (lambda (n) (and (integer? n) (>= n 0))) len 'make-list) +;; (for/list ([i (in-range len)]) elt)) ;; Make a list of length LEN. Elt i is (PROC i) for 0 <= i < LEN. @@ -66,7 +67,7 @@ ;; ;; (cons first (unfold not-pair? car cdr rest values)) -(define cons* list*) ; same in mzscheme +;; reprovided as mzscheme's list* ;; (define (cons* first . rest) ;; (let recur ((x first) (rest rest)) ;; (if (pair? rest) diff --git a/collects/tests/mzscheme/function.ss b/collects/tests/mzscheme/function.ss index 8f60fd65c7..9dfa210674 100644 --- a/collects/tests/mzscheme/function.ss +++ b/collects/tests/mzscheme/function.ss @@ -42,6 +42,12 @@ (test 'f object-name (rec f (lambda (x) x))) (test (list 2) (rec (f . x) (if (= (car x) 3) (f 2) x)) 3)) +;; ---------- const ---------- +(let () + (test 'foo (const 'foo)) + (test 'foo (const 'foo) 1) + (test 'foo (const 'foo) 1 2 3 4 5)) + ;; ---------- negate ---------- (let () (define *not (negate not)) diff --git a/collects/tests/mzscheme/list.ss b/collects/tests/mzscheme/list.ss index ca1d8877db..cf6d65578c 100644 --- a/collects/tests/mzscheme/list.ss +++ b/collects/tests/mzscheme/list.ss @@ -145,6 +145,13 @@ (test '(1 2 3 4) sort '(4 2 3 1) < #:key getkey #:cache-keys? #t) (test #t = c 10))) +;; ---------- make-list ---------- +(let () + (test '() make-list 0 'x) + (test '(x) make-list 1 'x) + (test '(x x) make-list 2 'x) + (err/rt-test (make-list -3 'x))) + ;; ---------- take/drop[-right] ---------- (let () (define-syntax-rule (vals-list expr) From 2b4d03270157451fea8261dc76deb2608e80a437 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 3 May 2009 16:59:44 +0000 Subject: [PATCH 16/32] little edits to the README additions recommending a 'build' directory svn: r14694 --- src/README | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/README b/src/README index bd3ee6b6ad..dc9b3bb970 100644 --- a/src/README +++ b/src/README @@ -61,6 +61,13 @@ the Unix instructions below, but note the following: Compiling for supported Unix variants (including Linux) or Cygwin ======================================================================== +Quick instructions: + + The usual `./configure', `make', and `make install' sequence + typically works fine. + +Detailed instructions: + 0. If you have an old PLT installation in the target directory, remove it (unless you are using Subversion with an "in-place" build as described below). @@ -81,8 +88,7 @@ the Unix instructions below, but note the following: 1. Run the script `configure' (which is in the same directory as this README), possibly with a --prefix=TARGETDIR command-line argument - and optionally with --enable-shared. It is better to run the - build in a different directory rather then use this directory. + and optionally with --enable-shared. For example, if you want to install into /usr/local/plt using dynamic libraries, then run @@ -91,21 +97,24 @@ the Unix instructions below, but note the following: where "[here]" is the directory path containing the `configure' script (possibly unnecessary, or possibly just "./", depending on - your shell and PATH setting). To use a different directory for - the build (which is recommended), for example a subdirectory named - "build": + your shell and PATH setting). + + It's better to run the build in a directory other than the one + contianing `configure', especially if you're getting sources via + Subversion. Also, `svn update' ignores a subdirectory next to + `configure' called "build", so a better and more common way to + configure a Subversion-based build is as follows: cd [here] mkdir build cd build - ../configure --prefix=/usr/local/plt --enable-shared + ../configure - (This is especially more convenient if you plan to update your - source tree from the plt repository. Such updates might involve - changes in the structure, which will leave your source tree in an - inconsistent state (eg, old Makefiles referring to inexistent - files). In such cases it is convenient to just remove the "build" - directory and start a fresh build.) + A separate build directory is better in case the Makefile + organization changes, or in case the Makefiles lack some + dependencies. In those cases, when using a "build" subdirectory, + you can just delete and re-create "build" without mangling your + source tree. If the --prefix flag is omitted, the binaries are built for an in-place installation (i.e., the parent of the directory From c17c267f481d0e755a06e42091682e7f06b68316 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 3 May 2009 17:40:31 +0000 Subject: [PATCH 17/32] R6RS: disallow assignment to exported identifier svn: r14695 --- collects/r6rs/main.ss | 9 +++++- collects/r6rs/private/identifier-syntax.ss | 15 +++++----- collects/r6rs/private/no-set.ss | 33 ++++++++++++++++++++++ collects/rnrs/base-6.ss | 7 +++-- collects/rnrs/syntax-case-6.ss | 11 ++++++-- 5 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 collects/r6rs/private/no-set.ss diff --git a/collects/r6rs/main.ss b/collects/r6rs/main.ss index a2e9ea79c0..3cb88cbb92 100644 --- a/collects/r6rs/main.ss +++ b/collects/r6rs/main.ss @@ -9,7 +9,8 @@ FIXME: (require (for-syntax scheme/base syntax/kerncase "private/parse-ref.ss" - scheme/provide-transform)) + scheme/provide-transform) + "private/no-set.ss") (provide (rename-out [module-begin #%module-begin])) @@ -232,6 +233,12 @@ FIXME: orig ex)]))) exs) + (add-no-set!-identifiers (map (lambda (ex) + (syntax-case ex () + [(rename (id ex-id)) + #'id] + [id ex])) + exs)) (with-syntax ([((ex ...) ...) (map (lambda (ex) (syntax-case ex () diff --git a/collects/r6rs/private/identifier-syntax.ss b/collects/r6rs/private/identifier-syntax.ss index a84350f18a..dfc87c79e3 100644 --- a/collects/r6rs/private/identifier-syntax.ss +++ b/collects/r6rs/private/identifier-syntax.ss @@ -1,26 +1,27 @@ #lang scheme/base (require (for-syntax scheme/base) - (for-template (only-in scheme/base set! #%app))) + (for-template "no-set.ss" + (only-in scheme/base #%app set!))) (provide identifier-syntax) (define-syntax (identifier-syntax stx) - (syntax-case* stx (set!) (lambda (a b) - (free-template-identifier=? a b)) + (syntax-case* stx (r6rs:set!) (lambda (a b) + (free-template-identifier=? a b)) [(identifier-syntax template) #'(... (make-set!-transformer (lambda (stx) (syntax-case stx (set!) [(set! . _) (raise-syntax-error - #f - "cannot assign to identifier macro" - stx)] + #f + "cannot assign to identifier macro" + stx)] [(_ arg ...) #'(template arg ...)] [_ #'template]))))] [(identifier-syntax [id1 template1] - [(set! id2 pat) template2]) + [(r6rs:set! id2 pat) template2]) (and (identifier? #'id1) (identifier? #'id2)) #'(... diff --git a/collects/r6rs/private/no-set.ss b/collects/r6rs/private/no-set.ss new file mode 100644 index 0000000000..fe3b43b567 --- /dev/null +++ b/collects/r6rs/private/no-set.ss @@ -0,0 +1,33 @@ +#lang scheme/base +(require (for-syntax scheme/base + syntax/boundmap)) + +(provide (for-syntax add-no-set!-identifiers) + r6rs:set!) + +;; Provided identifier cannot be `set!'ed. The list +;; is relevant only within the module being compiled. +(define-for-syntax no-set!-identifiers (make-free-identifier-mapping)) + +(define-for-syntax (add-no-set!-identifiers ids) + (for ([id (in-list ids)]) + (free-identifier-mapping-put! no-set!-identifiers id #t))) + +(define-for-syntax (no-set!-identifier? id) + (free-identifier-mapping-get no-set!-identifiers id (lambda () #f))) + +;; ---------------------------------------- + +(define-syntax (r6rs:set! stx) + (syntax-case stx () + [(_ id rhs) + (identifier? #'id) + (if (no-set!-identifier? #'id) + (raise-syntax-error + #f + "cannot mutate exported identifier" + stx + #'id) + (syntax/loc stx (set! id rhs)))] + [(_ . rest) + (syntax/loc stx (set! . rest))])) diff --git a/collects/rnrs/base-6.ss b/collects/rnrs/base-6.ss index 40c4facd7a..998af489ba 100644 --- a/collects/rnrs/base-6.ss +++ b/collects/rnrs/base-6.ss @@ -7,6 +7,7 @@ scheme/splicing r6rs/private/qq-gen r6rs/private/exns + r6rs/private/no-set (for-syntax r6rs/private/reconstruct) (prefix-in r5rs: r5rs) (only-in r6rs/private/readtable rx:number) @@ -28,7 +29,7 @@ (rename-out [r5rs:if if]) ;; 11.4.4 - set! + (rename-out [r6rs:set! set!]) ;; 11.4.5 cond else => case @@ -269,8 +270,8 @@ (lambda (stx) (if (identifier? stx) (syntax/loc stx r6rs-/) - (syntax-case stx (set!) - [(set! . _) + (syntax-case stx (r6rs:set!) + [(r6rs:set! . _) (raise-syntax-error #f "cannot mutate imported identifier" stx)] diff --git a/collects/rnrs/syntax-case-6.ss b/collects/rnrs/syntax-case-6.ss index 05f9e0bae9..03eb0af3c6 100644 --- a/collects/rnrs/syntax-case-6.ss +++ b/collects/rnrs/syntax-case-6.ss @@ -6,7 +6,9 @@ scheme/mpair r6rs/private/exns (for-syntax syntax/template - r6rs/private/check-pattern)) + r6rs/private/check-pattern) + (for-template (only-in scheme/base set!) + r6rs/private/no-set)) (provide make-variable-transformer (rename-out [r6rs:syntax-case syntax-case] @@ -105,7 +107,12 @@ l)]))))) (define (make-variable-transformer proc) - (make-set!-transformer proc)) + (make-set!-transformer + (lambda (stx) + (syntax-case* stx (set!) free-template-identifier=? + [(set! . rest) + (proc (syntax/loc stx (r6rs:set! . rest)))] + [else (proc stx)])))) (define unwrapped-tag (gensym)) From a1b65fb0552cc80101feb32a294a88ea9301ded1 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 3 May 2009 19:33:10 +0000 Subject: [PATCH 18/32] doc corrections svn: r14696 --- collects/scribblings/inside/namespaces.scrbl | 6 +++--- collects/scribblings/reference/printer.scrbl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/collects/scribblings/inside/namespaces.scrbl b/collects/scribblings/inside/namespaces.scrbl index 33d0728a83..c97ba9a896 100644 --- a/collects/scribblings/inside/namespaces.scrbl +++ b/collects/scribblings/inside/namespaces.scrbl @@ -29,7 +29,7 @@ A @as-index{module}'s set of top-level bindings is implemented using the same machinery as a namespace. Use @cppi{scheme_primitive_module} to create a new @cpp{Scheme_Env*} that represents a primitive module. The name provided to @cppi{scheme_primitive_module} is subject -to prefixing through the @scheme[current-module-name-prefix] parameter +to change through the @scheme[current-module-declare-name] parameter (which is normally set by the module name resolver when auto-loading module files). After installing variables into the module with @cppi{scheme_add_global}, etc., call @@ -129,8 +129,8 @@ available as @cppi{scheme_config}.} [Scheme_Object* name] [Scheme_Env* for_env])]{ -Prepares a new primitive module whose name is the symbol @var{name} (plus any - prefix that is active via @scheme[current-module-name-prefix]). The +Prepares a new primitive module whose name is the symbol @var{name} (or an + alternative that is active via @scheme[current-module-declare-name]). The module will be declared within the namespace @var{for_env}. The result is a @cpp{Scheme_Env *} value that can be used with @cpp{scheme_add_global}, etc., but it represents a module instead diff --git a/collects/scribblings/reference/printer.scrbl b/collects/scribblings/reference/printer.scrbl index 7604be6ab6..7c8eb1f1ba 100644 --- a/collects/scribblings/reference/printer.scrbl +++ b/collects/scribblings/reference/printer.scrbl @@ -208,12 +208,12 @@ unreadable values. @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(} -for a table using @scheme[equal?] or @scheme[eq?] key comparisons, +hash table prints starting with @litchar{#hash(}, @litchar{#hasheqv(}, or @litchar{#hasheq(} +for a table using @scheme[equal?], @scheme[eqv?], or @scheme[eq?] key comparisons, respectively. After this prefix, each key--value mapping is shown as @litchar{(}, the printed form of a key, a space, @litchar{.}, a space, the printed form the corresponding value, and @litchar{)}, with an -addition space if the key--value pairs is not the last to be printed. +additional space if the key--value pairs is not the last to be printed. After all key-value pairs, the printed form completes with @litchar{)}. From a1d943146bfce6c737b9c3a4477e6eab9ba5015f Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 3 May 2009 20:41:37 +0000 Subject: [PATCH 19/32] added a nullary case to compose svn: r14697 --- collects/scheme/private/list.ss | 3 ++- collects/scribblings/reference/procedures.scrbl | 3 ++- collects/tests/mzscheme/function.ss | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/collects/scheme/private/list.ss b/collects/scheme/private/list.ss index bd3dc7565c..07305f74b5 100644 --- a/collects/scheme/private/list.ss +++ b/collects/scheme/private/list.ss @@ -232,7 +232,7 @@ (define compose (case-lambda - [(f) (if (procedure? f) + [(f) (if (procedure? f) f (raise-type-error 'compose "procedure" f))] [(f g) @@ -247,6 +247,7 @@ (call-with-values (lambda () (g a)) f)) (lambda args (call-with-values (lambda () (apply g args)) f)))))] + [() values] [(f . more) (if (procedure? f) (let ([m (apply compose more)]) diff --git a/collects/scribblings/reference/procedures.scrbl b/collects/scribblings/reference/procedures.scrbl index 329ca50ed4..c3fa23d127 100644 --- a/collects/scribblings/reference/procedures.scrbl +++ b/collects/scribblings/reference/procedures.scrbl @@ -38,7 +38,8 @@ Returns a procedure that composes the given functions, applying the last @scheme[proc] first and the first @scheme[proc] last. The composed functions can consume and produce any number of values, as long as each function produces as many values as the preceding -function consumes. +function consumes. When no @scheme[proc] arguments are given, the +result is @scheme[values]. @mz-examples[ ((compose - sqrt) 10) diff --git a/collects/tests/mzscheme/function.ss b/collects/tests/mzscheme/function.ss index 9dfa210674..13d5a524d3 100644 --- a/collects/tests/mzscheme/function.ss +++ b/collects/tests/mzscheme/function.ss @@ -14,6 +14,7 @@ (test 'hi (compose (case-lambda [(x) 'bye][(y z) 'hi]) (lambda () (values 1 2)))) (test 'ok (compose (lambda () 'ok) (lambda () (values)))) (test 'ok (compose (lambda () 'ok) (lambda (w) (values))) 5) +(test 0 (compose) 0) (test-values '(1 2 3) (lambda () ((compose (lambda (x) (values x (add1 x) (+ x 2))) (lambda (y) y)) 1))) (err/rt-test (compose 5)) From 26667f22757cc096637349bdc265abff479e996a Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 3 May 2009 20:43:26 +0000 Subject: [PATCH 20/32] Patch from Jon Wilson: added a home function svn: r14698 --- collects/graphics/turtle-sig.ss | 2 +- collects/graphics/turtle-unit.ss | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/collects/graphics/turtle-sig.ss b/collects/graphics/turtle-sig.ss index 60feede3c3..b49e359269 100644 --- a/collects/graphics/turtle-sig.ss +++ b/collects/graphics/turtle-sig.ss @@ -1,7 +1,7 @@ #lang scheme/signature turtles -clear +clear home turn turn/radians move move-offset draw draw-offset diff --git a/collects/graphics/turtle-unit.ss b/collects/graphics/turtle-unit.ss index 82016f0475..94d813033e 100644 --- a/collects/graphics/turtle-unit.ss +++ b/collects/graphics/turtle-unit.ss @@ -227,6 +227,13 @@ (set! lines-in-drawing null) (clear-window))) +(define home + (lambda () + (flip-icons) + (set! turtles-cache empty-cache) + (set! turtles-state (list clear-turtle)) + (flip-icons))) + ;; cache elements: (define-struct c-forward (distance)) (define-struct c-turn (angle)) From 23e2b997a0d79f727b50ac8dfff8ad05155b7c4d Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 3 May 2009 20:45:36 +0000 Subject: [PATCH 21/32] doc for home svn: r14699 --- collects/graphics/scribblings/traditional-turtles.scrbl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/collects/graphics/scribblings/traditional-turtles.scrbl b/collects/graphics/scribblings/traditional-turtles.scrbl index 54442717c2..26d76687b5 100644 --- a/collects/graphics/scribblings/traditional-turtles.scrbl +++ b/collects/graphics/scribblings/traditional-turtles.scrbl @@ -47,6 +47,10 @@ Turns the turtle @scheme[theta] radians counter-clockwise.} Erases the turtles window.} +@defproc[(home) void?]{ + +Leaves only one turtle, in the start position.} + @defform[(split expr ...)]{ Spawns a new turtle where the turtle is currently located. In order to From db90b44b0da6295cd7da556db27d7f392a7ee276 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 3 May 2009 22:08:57 +0000 Subject: [PATCH 22/32] make const accept arbitrary keywords svn: r14700 --- collects/scheme/function.ss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collects/scheme/function.ss b/collects/scheme/function.ss index 56a55e7a38..d60c1a670d 100644 --- a/collects/scheme/function.ss +++ b/collects/scheme/function.ss @@ -4,7 +4,7 @@ (define (const c) (define (const . _) c) - const) + (make-keyword-procedure const const)) (define (negate f) (unless (procedure? f) (raise-type-error 'negate "procedure" f)) From 16e483033c9278d2bd386a3d419d4caedc4a1a77 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 3 May 2009 23:49:22 +0000 Subject: [PATCH 23/32] fix define after define* in package; doc repairs svn: r14701 --- collects/scheme/package.ss | 5 +- collects/scribblings/reference/package.scrbl | 2 +- collects/scribblings/reference/printer.scrbl | 2 +- collects/tests/mzscheme/package.ss | 21 +++++++++ src/mzscheme/src/env.c | 9 +++- src/mzscheme/src/eval.c | 49 ++++++++++++++++---- 6 files changed, 74 insertions(+), 14 deletions(-) diff --git a/collects/scheme/package.ss b/collects/scheme/package.ss index cf8b4d4c83..38bbbed2db 100644 --- a/collects/scheme/package.ss +++ b/collects/scheme/package.ss @@ -1,5 +1,6 @@ #lang scheme/base (require (for-syntax scheme/base + scheme/list syntax/kerncase syntax/boundmap syntax/define @@ -312,7 +313,7 @@ [ids (syntax->list #'(id ...))]) (let* ([def-ctx (if star? (syntax-local-make-definition-context (car def-ctxes)) - (car def-ctxes))] + (last def-ctxes))] [ids (if star? (map (add-package-context (list def-ctx)) ids) ids)]) @@ -330,7 +331,7 @@ [ids (syntax->list #'(id ...))]) (let* ([def-ctx (if star? (syntax-local-make-definition-context (car def-ctxes)) - (car def-ctxes))] + (last def-ctxes))] [ids (if star? (map (add-package-context (list def-ctx)) ids) ids)]) diff --git a/collects/scribblings/reference/package.scrbl b/collects/scribblings/reference/package.scrbl index fc966df479..9b56433a6c 100644 --- a/collects/scribblings/reference/package.scrbl +++ b/collects/scribblings/reference/package.scrbl @@ -41,7 +41,7 @@ expressions within the body (and, in particular, the definitions can refer to each other). However, @scheme[define-package] handles @scheme[define*], @scheme[define*-syntax], @scheme[define*-values], @scheme[define*-syntaxes], and -@scheme[open*-syntaxes] specially: the bindings introduced by those +@scheme[open*-package] specially: the bindings introduced by those forms within a @scheme[define-package] body are visible only to @scheme[form]s that appear later in the body, and they can shadow any binding from preceding @scheme[form]s (even if the preceding binding diff --git a/collects/scribblings/reference/printer.scrbl b/collects/scribblings/reference/printer.scrbl index 7c8eb1f1ba..5998ed15b4 100644 --- a/collects/scribblings/reference/printer.scrbl +++ b/collects/scribblings/reference/printer.scrbl @@ -213,7 +213,7 @@ for a table using @scheme[equal?], @scheme[eqv?], or @scheme[eq?] key comparison respectively. After this prefix, each key--value mapping is shown as @litchar{(}, the printed form of a key, a space, @litchar{.}, a space, the printed form the corresponding value, and @litchar{)}, with an -additional space if the key--value pairs is not the last to be printed. +additional space if the key--value pair is not the last to be printed. After all key-value pairs, the printed form completes with @litchar{)}. diff --git a/collects/tests/mzscheme/package.ss b/collects/tests/mzscheme/package.ss index 246784e200..b907652e5e 100644 --- a/collects/tests/mzscheme/package.ss +++ b/collects/tests/mzscheme/package.ss @@ -150,6 +150,27 @@ (open-package p) x) +(test-pack-seq + 14 + (define-package p (z) + (define* x (lambda () y)) + (define z x) + (define* x 2) + (define y 14)) + (open-package p) + (z)) + +(test-pack-seq + 21 + (define-package p (x) + (define* x (lambda () y)) + (define* x2 0) + (define* x3 1) + (define* x4 1) + (define y 21)) + (open-package p) + (x)) + (test-pack-seq '(2 1) (define-package p (x y) diff --git a/src/mzscheme/src/env.c b/src/mzscheme/src/env.c index e48ae4f104..1bca08a509 100644 --- a/src/mzscheme/src/env.c +++ b/src/mzscheme/src/env.c @@ -4381,6 +4381,9 @@ local_make_intdef_context(int argc, Scheme_Object *argv[]) { Scheme_Comp_Env *env, *senv; Scheme_Object *c, *rib; + void **d; + + d = MALLOC_N(void*, 3); env = scheme_current_thread->current_local_env; if (!env) @@ -4389,19 +4392,21 @@ local_make_intdef_context(int argc, Scheme_Object *argv[]) if (argc && SCHEME_TRUEP(argv[0])) { if (!SAME_TYPE(scheme_intdef_context_type, SCHEME_TYPE(argv[0]))) scheme_wrong_type("syntax-local-bind-syntaxes", "internal-definition context or #f", 0, argc, argv); - senv = (Scheme_Comp_Env *)SCHEME_PTR1_VAL(argv[0]); + senv = (Scheme_Comp_Env *)((void **)SCHEME_PTR1_VAL(argv[0]))[0]; if (!scheme_is_sub_env(senv, env)) { scheme_raise_exn(MZEXN_FAIL_CONTRACT, "syntax-local-make-definition-context: transforming context does " "not match given internal-definition context"); } env = senv; + d[1] = argv[0]; } + d[0] = env; rib = scheme_make_rename_rib(); c = scheme_alloc_object(); c->type = scheme_intdef_context_type; - SCHEME_PTR1_VAL(c) = env; + SCHEME_PTR1_VAL(c) = d; SCHEME_PTR2_VAL(c) = rib; return c; diff --git a/src/mzscheme/src/eval.c b/src/mzscheme/src/eval.c index 1115e4c34b..65811c5675 100644 --- a/src/mzscheme/src/eval.c +++ b/src/mzscheme/src/eval.c @@ -6339,6 +6339,7 @@ scheme_compile_expand_block(Scheme_Object *forms, Scheme_Comp_Env *env, before deciding what we have. */ { Scheme_Object *first, *rib, *ctx, *ectx, *orig = forms; + void **d; Scheme_Comp_Env *xenv = NULL; Scheme_Compile_Info recs[2]; DupCheckRecord r; @@ -6364,7 +6365,9 @@ scheme_compile_expand_block(Scheme_Object *forms, Scheme_Comp_Env *env, rib = scheme_make_rename_rib(); ctx = scheme_alloc_object(); ctx->type = scheme_intdef_context_type; - SCHEME_PTR1_VAL(ctx) = env; + d = MALLOC_N(void*, 3); + d[0] = env; + SCHEME_PTR1_VAL(ctx) = d; SCHEME_PTR2_VAL(ctx) = rib; ectx = scheme_make_pair(ctx, scheme_null); scheme_begin_dup_symbol_check(&r, env); @@ -6561,7 +6564,7 @@ scheme_compile_expand_block(Scheme_Object *forms, Scheme_Comp_Env *env, } /* Remember extended environment */ - SCHEME_PTR1_VAL(ctx) = new_env; + ((void **)SCHEME_PTR1_VAL(ctx))[0] = new_env; env = new_env; xenv = NULL; } @@ -9292,6 +9295,31 @@ static Scheme_Object *add_intdef_renamings(Scheme_Object *l, Scheme_Object *rena return l; } +static void update_intdef_chain(Scheme_Object *intdef) +{ + Scheme_Comp_Env *orig, *current_next; + Scheme_Object *base; + + /* If this intdef chains to another, and if the other has been + extended, then fix up the chain. */ + + while (1) { + base = (Scheme_Object *)((void **)SCHEME_PTR1_VAL(intdef))[1]; + if (base) { + current_next = (Scheme_Comp_Env *)((void **)SCHEME_PTR1_VAL(base))[0]; + orig = (Scheme_Comp_Env *)((void **)SCHEME_PTR1_VAL(intdef))[2]; + if (orig) { + orig->next = current_next; + } else { + ((void **)SCHEME_PTR1_VAL(base))[0] = current_next; + } + intdef = base; + } else { + break; + } + } +} + static Scheme_Object * do_local_expand(const char *name, int for_stx, int catch_lifts, int for_expr, int argc, Scheme_Object **argv) { @@ -9337,7 +9365,8 @@ do_local_expand(const char *name, int for_stx, int catch_lifts, int for_expr, in if (SCHEME_TRUEP(argv[3])) { if (SAME_TYPE(scheme_intdef_context_type, SCHEME_TYPE(argv[3]))) { Scheme_Comp_Env *stx_env; - stx_env = (Scheme_Comp_Env *)SCHEME_PTR1_VAL(argv[3]); + update_intdef_chain(argv[3]); + stx_env = (Scheme_Comp_Env *)((void **)SCHEME_PTR1_VAL(argv[3]))[0]; renaming = SCHEME_PTR2_VAL(argv[3]); if (!scheme_is_sub_env(stx_env, env)) bad_sub_env = 1; @@ -9347,7 +9376,7 @@ do_local_expand(const char *name, int for_stx, int catch_lifts, int for_expr, in while (SCHEME_PAIRP(rl)) { if (SAME_TYPE(scheme_intdef_context_type, SCHEME_TYPE(SCHEME_CAR(rl)))) { Scheme_Comp_Env *stx_env; - stx_env = (Scheme_Comp_Env *)SCHEME_PTR1_VAL(SCHEME_CAR(rl)); + stx_env = (Scheme_Comp_Env *)((void **)SCHEME_PTR1_VAL(SCHEME_CAR(rl)))[0]; if (!scheme_is_sub_env(stx_env, env)) bad_sub_env = 1; } else @@ -9358,7 +9387,8 @@ do_local_expand(const char *name, int for_stx, int catch_lifts, int for_expr, in bad_intdef = 1; else { rl = argv[3]; - env = (Scheme_Comp_Env *)SCHEME_PTR1_VAL(SCHEME_CAR(rl)); + update_intdef_chain(SCHEME_CAR(rl)); + env = (Scheme_Comp_Env *)((void **)SCHEME_PTR1_VAL(SCHEME_CAR(rl)))[0]; if (SCHEME_NULLP(SCHEME_CDR(rl))) renaming = SCHEME_PTR2_VAL(SCHEME_CAR(rl)); else { @@ -9837,7 +9867,7 @@ local_eval(int argc, Scheme_Object **argv) cnt++; } if (!SCHEME_NULLP(l)) - scheme_wrong_type("syntax-local-bind-syntaxes", "list of syntax identifieres", 0, argc, argv); + scheme_wrong_type("syntax-local-bind-syntaxes", "list of syntax identifiers", 0, argc, argv); expr = argv[1]; if (!SCHEME_FALSEP(expr) && !SCHEME_STXP(expr)) @@ -9849,7 +9879,8 @@ local_eval(int argc, Scheme_Object **argv) if (!env) scheme_raise_exn(MZEXN_FAIL_CONTRACT, "syntax-local-bind-syntaxes: not currently transforming"); - stx_env = (Scheme_Comp_Env *)SCHEME_PTR1_VAL(argv[2]); + update_intdef_chain(argv[2]); + stx_env = (Scheme_Comp_Env *)((void **)SCHEME_PTR1_VAL(argv[2]))[0]; rib = SCHEME_PTR2_VAL(argv[2]); if (*scheme_stx_get_rib_sealed(rib)) { @@ -9909,7 +9940,9 @@ local_eval(int argc, Scheme_Object **argv) scheme_add_env_renames(rib, stx_env, old_stx_env); /* Remember extended environment */ - SCHEME_PTR1_VAL(argv[2]) = stx_env; + ((void **)SCHEME_PTR1_VAL(argv[2]))[0] = stx_env; + if (!((void **)SCHEME_PTR1_VAL(argv[2]))[2]) + ((void **)SCHEME_PTR1_VAL(argv[2]))[2] = stx_env; return scheme_void; } From d7570ee9e7781d7bdbfde7dcdc894544c6da3350 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 4 May 2009 00:46:33 +0000 Subject: [PATCH 24/32] fix mred-text for Windows (startup banner) svn: r14702 --- src/mred/mred.cxx | 51 +++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/mred/mred.cxx b/src/mred/mred.cxx index b975326b7b..8c50f739fa 100644 --- a/src/mred/mred.cxx +++ b/src/mred/mred.cxx @@ -2276,32 +2276,35 @@ static void MrEdSchemeMessages(char *msg, ...) if (!console_out) { AllocConsole(); console_out = GetStdHandle(STD_OUTPUT_HANDLE); - console_in = GetStdHandle(STD_INPUT_HANDLE); - has_stdio = 1; - waiting_sema = CreateSemaphore(NULL, 0, 1, NULL); - SetConsoleCtrlHandler(ConsoleHandler, TRUE); + + if (!wx_in_terminal) { + console_in = GetStdHandle(STD_INPUT_HANDLE); + has_stdio = 1; + waiting_sema = CreateSemaphore(NULL, 0, 1, NULL); + SetConsoleCtrlHandler(ConsoleHandler, TRUE); + + wxREGGLOB(console_inport); + console_inport = scheme_make_fd_input_port((int)console_in, scheme_intern_symbol("stdin"), 0, 0); + + { + HMODULE hm; + gcw_proc gcw; + + hm = LoadLibrary("kernel32.dll"); + if (hm) + gcw = (gcw_proc)GetProcAddress(hm, "GetConsoleWindow"); + else + gcw = NULL; - wxREGGLOB(console_inport); - console_inport = scheme_make_fd_input_port((int)console_in, scheme_intern_symbol("stdin"), 0, 0); + if (gcw) + console_hwnd = gcw(); + } - { - HMODULE hm; - gcw_proc gcw; - - hm = LoadLibrary("kernel32.dll"); - if (hm) - gcw = (gcw_proc)GetProcAddress(hm, "GetConsoleWindow"); - else - gcw = NULL; - - if (gcw) - console_hwnd = gcw(); - } - - if (console_hwnd) { - EnableMenuItem(GetSystemMenu(console_hwnd, FALSE), SC_CLOSE, - MF_BYCOMMAND | MF_GRAYED); - RemoveMenu(GetSystemMenu(console_hwnd, FALSE), SC_CLOSE, MF_BYCOMMAND); + if (console_hwnd) { + EnableMenuItem(GetSystemMenu(console_hwnd, FALSE), SC_CLOSE, + MF_BYCOMMAND | MF_GRAYED); + RemoveMenu(GetSystemMenu(console_hwnd, FALSE), SC_CLOSE, MF_BYCOMMAND); + } } } #endif From 2b4a0692eb3773c2bf1365edd023e2e307fe27e9 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 4 May 2009 01:38:54 +0000 Subject: [PATCH 25/32] doc repairs (PR 10225) svn: r14703 --- collects/scribblings/reference/syntax.scrbl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collects/scribblings/reference/syntax.scrbl b/collects/scribblings/reference/syntax.scrbl index 7d5c629922..35285cca25 100644 --- a/collects/scribblings/reference/syntax.scrbl +++ b/collects/scribblings/reference/syntax.scrbl @@ -2046,13 +2046,13 @@ classifications: @itemize[ @item{@scheme[define] or @scheme[define-values] form: converted to - a @scheme[define-for-syntax] form.} + a @scheme[define-values-for-syntax] form.} @item{@scheme[require] form: content is wrapped with @scheme[for-syntax].} @item{expression form @scheme[_expr]: converted to - @scheme[(define-values () (begin _expr (values)))], which + @scheme[(define-values-for-syntax () (begin _expr (values)))], which effectively evaluates the expression at expansion time and, in the case of a @tech{module context}, preserves the expression for future @tech{visit}s of the module.} From e3d9f396c46c7097ead41a86a15b48d6cd58a495 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Mon, 4 May 2009 02:10:01 +0000 Subject: [PATCH 26/32] compose now gets 0 or more inputs svn: r14704 --- collects/tests/mzscheme/function.ss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collects/tests/mzscheme/function.ss b/collects/tests/mzscheme/function.ss index 13d5a524d3..07e3f65b9a 100644 --- a/collects/tests/mzscheme/function.ss +++ b/collects/tests/mzscheme/function.ss @@ -25,7 +25,7 @@ (err/rt-test ((compose add1 sub1)) exn:application:arity?) (err/rt-test ((compose (lambda () 1) add1) 8) exn:application:arity?) -(arity-test compose 1 -1) +(arity-test compose 0 -1) ;; ---------- rec (from mzlib/etc) ---------- (let () From 57d518dc8cf6b2e9229d0e04895646cfc2927386 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 4 May 2009 02:19:27 +0000 Subject: [PATCH 27/32] doc typo svn: r14705 --- collects/scribblings/reference/exns.scrbl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collects/scribblings/reference/exns.scrbl b/collects/scribblings/reference/exns.scrbl index a8f0075699..2117c1d273 100644 --- a/collects/scribblings/reference/exns.scrbl +++ b/collects/scribblings/reference/exns.scrbl @@ -87,7 +87,7 @@ for end users.} @defproc*[([(raise-type-error [name symbol?][expected string?][v any/c]) any] - [(raise-type-error [name symbol?][expected string?][bad-pos exact-nonnegative-integer?][v any/c]) any])]{ + [(raise-type-error [name symbol?][expected string?][bad-pos exact-nonnegative-integer?][v any/c] ...) any])]{ Creates an @scheme[exn:fail:contract] value and @scheme[raise]s it as an exception. The @scheme[name] argument is used as the source From 57ff3c2486ded58990798851f0eb78165fe9e3cf Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 4 May 2009 02:20:06 +0000 Subject: [PATCH 28/32] fix foldr/foldr argument checking (PR 10215) svn: r14706 --- collects/scheme/private/list.ss | 28 ++++++++++++++++++++++++++++ collects/tests/mzscheme/list.ss | 17 +++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/collects/scheme/private/list.ss b/collects/scheme/private/list.ss index 07305f74b5..383e1426b6 100644 --- a/collects/scheme/private/list.ss +++ b/collects/scheme/private/list.ss @@ -151,12 +151,38 @@ (list last) (cons (f (car l)) (loop (cdr l)))))) + (define (check-fold name proc init l more) + (unless (procedure? proc) + (apply raise-type-error name "procedure" 0 proc init l more)) + (unless (list? l) + (apply raise-type-error name "list" 2 proc init l more)) + (if (null? more) + (unless (procedure-arity-includes? proc 2) + (raise-mismatch-error name "arity mismatch, does not accept 1 argument: " proc)) + (let ([len (length l)]) + (let loop ([more more][n 3]) + (unless (null? more) + (unless (list? (car more)) + (apply raise-type-error name "list" n proc init l more)) + (unless (= len (length (car more))) + (raise-mismatch-error name + "given list does not have the same size as the first list: " + (car more))) + (loop (cdr more) (add1 n)))) + (unless (procedure-arity-includes? proc (+ 2 (length more))) + (raise-mismatch-error name + (format "arity mismatch, does not accept ~a arguments: " + (add1 (length more))) + proc))))) + (define foldl (case-lambda [(f init l) + (check-fold 'foldl f init l null) (let loop ([init init] [l l]) (if (null? l) init (loop (f (car l) init) (cdr l))))] [(f init l . ls) + (check-fold 'foldl f init l ls) (let loop ([init init] [ls (cons l ls)]) (cond [(andmap pair? ls) (loop (apply f (mapadd car ls init)) (map cdr ls))] @@ -167,11 +193,13 @@ (define foldr (case-lambda [(f init l) + (check-fold 'foldr f init l null) (let loop ([init init] [l l]) (if (null? l) init (f (car l) (loop init (cdr l)))))] [(f init l . ls) + (check-fold 'foldr f init l ls) (let loop ([ls (cons l ls)]) (cond [(andmap pair? ls) (apply f (mapadd car ls (loop (map cdr ls))))] diff --git a/collects/tests/mzscheme/list.ss b/collects/tests/mzscheme/list.ss index cf6d65578c..891bdf4348 100644 --- a/collects/tests/mzscheme/list.ss +++ b/collects/tests/mzscheme/list.ss @@ -21,6 +21,23 @@ (arity-test foldl 3 -1) (arity-test foldr 3 -1) +(err/rt-test (foldl 'list 0 10)) +(err/rt-test (foldl list 0 10)) +(err/rt-test (foldl add1 0 '())) +(err/rt-test (foldl cons 0 '() '())) +(err/rt-test (foldl list 0 '() 10)) +(err/rt-test (foldl list 0 '() '() 10)) +(err/rt-test (let/ec k (foldl k 0 '(1 2) '(1 2 3)))) +(err/rt-test (let/ec k (foldl k 0 '(1 2) '(1 2) '(1 2 3)))) +(err/rt-test (foldr 'list 0 10)) +(err/rt-test (foldr list 0 10)) +(err/rt-test (foldr add1 0 '())) +(err/rt-test (foldr cons 0 '() '())) +(err/rt-test (foldr list 0 '() 10)) +(err/rt-test (foldr list 0 '() '() 10)) +(err/rt-test (let/ec k (foldr k 0 '(1 2) '(1 2 3)))) +(err/rt-test (let/ec k (foldr k 0 '(1 2) '(1 2) '(1 2 3)))) + (test '(0 1 2) memf add1 '(0 1 2)) (test '(2 (c 17)) memf number? '((a 1) (0 x) (1 w) 2 (c 17))) (test '("ok" (2 .7) c) memf string? '((a 0) (0 a) (1 w) "ok" (2 .7) c)) From 5cb9e66cd2189b4a0698c1b25aa4a5f10de1f69b Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Mon, 4 May 2009 06:37:27 +0000 Subject: [PATCH 29/32] fixed a probable bug in invoking format-time svn: r14707 --- collects/compiler/cm.ss | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/collects/compiler/cm.ss b/collects/compiler/cm.ss index fda77af2bb..e489f2109e 100644 --- a/collects/compiler/cm.ss +++ b/collects/compiler/cm.ss @@ -107,10 +107,8 @@ [(< zo-sec ss-sec) (error 'compile-zo "date for newly created .zo file (~a @ ~a) ~ is before source-file date (~a @ ~a)~a" - zo-name - (format-time (seconds->date zo-sec)) - ss-name - (format-time (seconds->date ss-sec)) + zo-name (format-time zo-sec) + ss-name (format-time ss-sec) (if (> ss-sec (current-seconds)) ", which appears to be in the future" ""))])) From bee5c5b90f15ecdb84e458f7556be086d9c852ca Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Mon, 4 May 2009 07:50:13 +0000 Subject: [PATCH 30/32] Welcome to a new PLT day. svn: r14708 --- collects/repos-time-stamp/stamp.ss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collects/repos-time-stamp/stamp.ss b/collects/repos-time-stamp/stamp.ss index 0c63e9c947..f615722162 100644 --- a/collects/repos-time-stamp/stamp.ss +++ b/collects/repos-time-stamp/stamp.ss @@ -1 +1 @@ -#lang scheme/base (provide stamp) (define stamp "3may2009") +#lang scheme/base (provide stamp) (define stamp "4may2009") From 8b4844cf5ea7020bdb3d7f7d0cff715ce1141bfe Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Mon, 4 May 2009 09:34:07 +0000 Subject: [PATCH 31/32] some typos svn: r14709 --- collects/framework/preferences.ss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/collects/framework/preferences.ss b/collects/framework/preferences.ss index 0671752af2..22a4e13cd2 100644 --- a/collects/framework/preferences.ss +++ b/collects/framework/preferences.ss @@ -355,7 +355,7 @@ the state transitions / contracts are: ((p f) ((weak? #f))) @{This function adds a callback which is called with a symbol naming a - preference and it's value, when the preference changes. + preference and its value, when the preference changes. @scheme[preferences:add-callback] returns a thunk, which when invoked, removes the callback from this preference. @@ -406,7 +406,7 @@ the state transitions / contracts are: preferences to turn the preference value for @scheme[symbol] into a printable value. @scheme[unmarshall] will be called when the user's preferences are read from the file to transform the printable value - into it's internal representation. If @scheme[preference:set-un/marshall] + into its internal representation. If @scheme[preference:set-un/marshall] is never called for a particular preference, the values of that preference are assumed to be printable. @@ -450,7 +450,7 @@ the state transitions / contracts are: (parameter/c (-> (listof symbol?) (listof any/c) any)) put-preference @{This parameter's value - is called when to save preference the preferences. Its interface should + is called to save preference the preferences. Its interface should be just like mzlib's @scheme[put-preference].}) (proc-doc/names @@ -477,7 +477,7 @@ the state transitions / contracts are: @{Caches all of the current values of the preferences and returns them. For any preference that has marshalling and unmarshalling set (see @scheme[preferences:set-un/marshall]), the preference value is - copied by passing it thru the marshalling and unmarshalling process. + copied by passing it through the marshalling and unmarshalling process. Other values are not copied, but references to them are instead saved. See also @scheme[preferences:restore-prefs-snapshot].})) From 83cd3964f4e27c38790762dc44c00b0bf57f6fb2 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 4 May 2009 12:22:01 +0000 Subject: [PATCH 32/32] fix file-descriptor leak in process[*]/ports (PR 10229) svn: r14710 --- collects/mzlib/process.ss | 6 +++++- collects/tests/mzscheme/subprocess.ss | 25 +++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/collects/mzlib/process.ss b/collects/mzlib/process.ss index 21d246b83a..24775a39d0 100644 --- a/collects/mzlib/process.ss +++ b/collects/mzlib/process.ss @@ -71,7 +71,11 @@ (define (streamify-out cout out get-thread?) (if (and cout (not (file-stream-port? cout))) - (let ([t (thread (lambda () (copy-port out cout)))]) + (let ([t (thread (lambda () + (dynamic-wind + void + (lambda () (copy-port out cout)) + (lambda () (close-input-port out)))))]) (and get-thread? t)) out)) diff --git a/collects/tests/mzscheme/subprocess.ss b/collects/tests/mzscheme/subprocess.ss index 432becf5f0..247b0e18e3 100644 --- a/collects/tests/mzscheme/subprocess.ss +++ b/collects/tests/mzscheme/subprocess.ss @@ -48,7 +48,7 @@ ;; Supply file for stdout -(let ([f (open-output-file tmpfile 'truncate/replace)]) +(let ([f (open-output-file tmpfile #:exists 'truncate/replace)]) (let ([p (process*/ports f #f #f cat)]) (test #f car p) @@ -67,7 +67,7 @@ ;; Supply file for stdout & stderr, only stdout writes -(let ([f (open-output-file tmpfile 'truncate/replace)]) +(let ([f (open-output-file tmpfile #:exists 'truncate/replace)]) (let ([p (process*/ports f #f f cat)]) (test #f car p) (test #f cadddr p) @@ -84,7 +84,7 @@ ;; Supply file for stderr -(let ([f (open-output-file tmpfile 'truncate/replace)]) +(let ([f (open-output-file tmpfile #:exists 'truncate/replace)]) (let ([p (process*/ports #f #f f cat "nosuchfile")]) (test #f cadddr p) @@ -104,7 +104,7 @@ ;; Supply file for stdout & stderr, only stderr writes -(let ([f (open-output-file tmpfile 'truncate/replace)]) +(let ([f (open-output-file tmpfile #:exists 'truncate/replace)]) (let ([p (process*/ports f #f f cat "nosuchfile")]) (test #f car p) (test #f cadddr p) @@ -121,7 +121,7 @@ ;; Supply file for stdout & stderr, both write -(let ([f (open-output-file tmpfile 'truncate/replace)]) +(let ([f (open-output-file tmpfile #:exists 'truncate/replace)]) (let ([p (process*/ports f #f f cat "-" "nosuchfile")]) (test #f car p) (test #f cadddr p) @@ -141,8 +141,8 @@ ;; Supply separate files for stdout & stderr -(let ([f (open-output-file tmpfile 'truncate/replace)] - [f2 (open-output-file tmpfile2 'truncate/replace)]) +(let ([f (open-output-file tmpfile #:exists 'truncate/replace)] + [f2 (open-output-file tmpfile2 #:exists 'truncate/replace)]) (let ([p (process*/ports f #f f2 cat "-" "nosuchfile")]) (test #f car p) (test #f cadddr p) @@ -168,7 +168,7 @@ ;; Supply file for stdin -(let ([f (open-output-file tmpfile 'truncate/replace)]) +(let ([f (open-output-file tmpfile #:exists 'truncate/replace)]) (fprintf f "Howdy~n") (close-output-port f)) (let ([f (open-input-file tmpfile)]) @@ -187,7 +187,7 @@ ;; Files for everyone (let ([f (open-input-file tmpfile)] - [f2 (open-output-file tmpfile2 'truncate/replace)]) + [f2 (open-output-file tmpfile2 #:exists 'truncate/replace)]) (let ([p (process*/ports f2 f f2 cat "-" "nosuchfile")]) (test #f car p) (test #f cadr p) @@ -227,7 +227,7 @@ ;; Check error cases (let ([f (open-input-file tmpfile)] - [f2 (open-output-file tmpfile2 'truncate/replace)]) + [f2 (open-output-file tmpfile2 #:exists 'truncate/replace)]) (let ([test (lambda (o i e) @@ -245,16 +245,17 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-values (r w id e f) - (apply values (process* self "-mvq" + (apply values (process* self "-e" "(let loop () (unless (eof-object? (eval (read))) (loop)))"))) (define (test-line out in) (fprintf w "~a~n" in) + (flush-output w) (when out (test out (lambda (ignored) (read-line r)) in))) -(test-line "17" "(display 17) (newline)") +(test-line "17" "(display 17) (newline) (flush-output)") (close-input-port r) (close-input-port e)