diff --git a/collects/racket/match/match.rkt b/collects/racket/match/match.rkt index aa9033396c..6b6eb9179b 100644 --- a/collects/racket/match/match.rkt +++ b/collects/racket/match/match.rkt @@ -13,7 +13,7 @@ (provide (for-syntax match-...-nesting) match-equality-test define-match-expander - struct* + struct* == exn:misc:match?) (define-forms parse diff --git a/collects/racket/match/struct.rkt b/collects/racket/match/struct.rkt index 810c27c25f..f8ee138145 100644 --- a/collects/racket/match/struct.rkt +++ b/collects/racket/match/struct.rkt @@ -70,4 +70,12 @@ (quasisyntax/loc stx (struct struct-name #,pats-in-order))))]))) -(provide struct*) +(provide struct* ==) + +(define-match-expander + == + (lambda (stx) + (syntax-case stx () + [(_ val comp) + #'(? (lambda (x) (comp val x)))] + [(_ val) #'(? (lambda (x) (equal? val x)))]))) \ No newline at end of file diff --git a/collects/scribblings/reference/match.scrbl b/collects/scribblings/reference/match.scrbl index d7636cf413..8eefe8b1c2 100644 --- a/collects/scribblings/reference/match.scrbl +++ b/collects/scribblings/reference/match.scrbl @@ -544,6 +544,26 @@ instead of @racket[match].} @section{Library Extensions} +@defform*[[(== val comparator) (== val)]]{ +A @tech{match expander} +which checks if the matched value is the same as @racket[val] when +compared by @racket[comparator]. If @racket[comparator] is +not provided, it defaults to @racket[equal?]. + +@examples[#:eval match-eval +(match (list 1 2 3) + [(== (list 1 2 3)) 'yes] + [_ 'no]) +(match (list 1 2 3) + [(== (list 1 2 3) eq?) 'yes] + [_ 'no]) +(match (list 1 2 3) + [(list 1 2 (== 3 =)) 'yes] + [_ 'no]) +] +} + + @defform[(struct* struct-id ([field pat] ...))]{ A @racket[match] pattern form that matches an instance of a structure type named @racket[struct-id], where the field @racket[field] in the diff --git a/collects/unstable/match.rkt b/collects/unstable/match.rkt index 3fb84b6fba..9fdd8d7277 100644 --- a/collects/unstable/match.rkt +++ b/collects/unstable/match.rkt @@ -5,15 +5,7 @@ (for-syntax racket/base) (for-syntax syntax/parse)) -(provide == match? as object) - -(define-match-expander - == - (lambda (stx) - (syntax-case stx () - [(_ val comp) - #'(? (lambda (x) (comp val x)))] - [(_ val) #'(== val equal?)]))) +(provide match? as object) (define-syntax-rule (match? e p ...) (match e [p #t] ... [_ #f])) diff --git a/collects/unstable/scribblings/match.scrbl b/collects/unstable/scribblings/match.scrbl index 9d84a4943e..f1edace501 100644 --- a/collects/unstable/scribblings/match.scrbl +++ b/collects/unstable/scribblings/match.scrbl @@ -9,27 +9,6 @@ @defmodule[unstable/match] -@unstable[@author+email["Sam Tobin-Hochstadt" "samth@ccs.neu.edu"]] - -@defform*[[(== val comparator) (== val)]]{ -A @tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{match expander} -which checks if the matched value is the same as @racket[val] when -compared by @racket[comparator]. If @racket[comparator] is -not provided, it defaults to @racket[equal?]. - -@examples[#:eval the-eval -(match (list 1 2 3) - [(== (list 1 2 3)) 'yes] - [_ 'no]) -(match (list 1 2 3) - [(== (list 1 2 3) eq?) 'yes] - [_ 'no]) -(match (list 1 2 3) - [(list 1 2 (== 3 =)) 'yes] - [_ 'no]) -] -} - @addition[@author+email["Carl Eastlund" "cce@racket-lang.org"]] @defform[(match? val-expr pat ...)]{