hack evcase to support old and new 'else' bindings

svn: r9481
This commit is contained in:
Matthew Flatt 2008-04-25 21:36:37 +00:00
parent f2a3317df6
commit 01baad11a0
3 changed files with 16 additions and 9 deletions

View File

@ -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)])

View File

@ -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]{

View File

@ -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