From 01baad11a057d53c77b2f350739f79327c40054b Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 25 Apr 2008 21:36:37 +0000 Subject: [PATCH] hack evcase to support old and new 'else' bindings svn: r9481 --- collects/mzlib/etc.ss | 4 +++- collects/mzlib/scribblings/etc.scrbl | 13 +++++++++---- collects/scribblings/reference/match.scrbl | 8 ++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/collects/mzlib/etc.ss b/collects/mzlib/etc.ss index 9125609b89..3f9c69703b 100644 --- a/collects/mzlib/etc.ss +++ b/collects/mzlib/etc.ss @@ -8,6 +8,7 @@ build-list build-vector compose) + (rename scheme/base base-else else) "kw.ss") (require-for-syntax syntax/kerncase @@ -136,8 +137,9 @@ (let ([tests (syntax->list (syntax (test ...)))]) (with-syntax ([(a-test ...) (map (lambda (t) - (syntax-case t (else) + (syntax-case t (else base-else) [else (syntax #t)] + [base-else (syntax #t)] [_else (with-syntax ([t t]) (syntax (eqv? evcase-v t)))])) tests)]) diff --git a/collects/mzlib/scribblings/etc.scrbl b/collects/mzlib/scribblings/etc.scrbl index b272298a0c..28fcd5ee56 100644 --- a/collects/mzlib/scribblings/etc.scrbl +++ b/collects/mzlib/scribblings/etc.scrbl @@ -12,11 +12,12 @@ @interaction-eval[#:eval etc-eval (require mzlib/etc)] @(begin - (define-syntax-rule (bind id) + (define-syntax-rule (bind id else-id) (begin (require (for-label scheme/base)) - (define id (scheme lambda)))) - (bind base-lambda)) + (define id (scheme lambda)) + (define else-id (scheme else)))) + (bind base-lambda base-else)) @mzlib[#:mode title etc] @@ -108,7 +109,11 @@ data. After @scheme[key-expr] is evaluated, each @scheme[value-expr] is evaluated until a value is found that is @scheme[eqv?] to the key value; when a matching value is found, the corresponding @scheme[body-expr]s are evaluated and the value(s) for the last is the -result of the entire @scheme[evcase] expression.} +result of the entire @scheme[evcase] expression. + +The @scheme[else] literal is recognized either as unbound (like in the +@schememodname[mzscheme] language) or bound as @|base-else| from +@schememodname[scheme/base].} @defproc[(identity [v any/c]) any/c]{ diff --git a/collects/scribblings/reference/match.scrbl b/collects/scribblings/reference/match.scrbl index 8c813ff355..728386f4f4 100644 --- a/collects/scribblings/reference/match.scrbl +++ b/collects/scribblings/reference/match.scrbl @@ -44,10 +44,10 @@ In more detail, patterns match as follows: @itemize{ - @item{@scheme[_id], excluding the reserved names @schemeidfont{"_"}, - @schemeidfont{"..."}, @schemeidfont{".._"}, - @schemeidfont{".."}@scheme[_k], and - @schemeidfont{".."}@scheme[_k] for non-negative integers + @item{@scheme[_id], excluding the reserved names @schemeidfont{_}, + @schemeidfont{...}, @schemeidfont{.._}, + @schemeidfont{..}@scheme[_k], and + @schemeidfont{..}@scheme[_k] for non-negative integers @scheme[_k] --- matches anything, and binds @scheme[id] to the matching values. If an @scheme[_id] is used multiple times within a pattern, the corresponding matches must be the same