diff --git a/collects/syntax/private/stxparse/rep.ss b/collects/syntax/private/stxparse/rep.ss index f8e2e99957..f487b7dee3 100644 --- a/collects/syntax/private/stxparse/rep.ss +++ b/collects/syntax/private/stxparse/rep.ss @@ -689,6 +689,10 @@ [(cons (list '#:fail-unless fu-stx unless-condition expr) rest) (cons (make clause:fail #`(not #,unless-condition) expr) (parse-pattern-sides rest decls))] + [(cons (list '#:when unless-condition) rest) + ;; Bleh: when is basically fail-unless without the msg argument + (cons (make clause:fail #`(not #,unless-condition) #'#f) + (parse-pattern-sides rest decls))] [(cons (list '#:with with-stx pattern expr) rest) (let-values ([(decls2 rest) (grab-decls rest decls)]) (let-values ([(decls2a defs) (decls-create-defs decls2)]) @@ -876,6 +880,7 @@ (list (list '#:declare check-identifier check-expression) (list '#:fail-when check-expression check-expression) (list '#:fail-unless check-expression check-expression) + (list '#:when check-expression) (list '#:with check-expression check-expression) (list '#:attr check-attr-arity check-expression))) diff --git a/collects/syntax/scribblings/parse.scrbl b/collects/syntax/scribblings/parse.scrbl index bd2910e358..cda0b8ae2c 100644 --- a/collects/syntax/scribblings/parse.scrbl +++ b/collects/syntax/scribblings/parse.scrbl @@ -603,7 +603,8 @@ conditions. The grammar for pattern directives follows: (code:line #:with syntax-pattern expr) (code:line #:attr attr-id expr) (code:line #:fail-when condition-expr message-expr) - (code:line #:fail-unless condition-expr message-expr)] + (code:line #:fail-unless condition-expr message-expr) + (code:line #:when condition-expr)] @specsubform[(code:line #:declare pvar-id syntax-class-id)] @specsubform[(code:line #:declare pvar-id (syntax-class-id expr ...))]{ @@ -650,6 +651,15 @@ given message); otherwise, it continues. } +@specsubform[(code:line #:when condition-expr)]{ + +Evaluates the @scheme[condition-expr] in the context of all previous +attribute bindings. If the value is @scheme[#f], the matching process +backtracks. In other words, @scheme[#:when] is like +@scheme[#:fail-unless] without the message argument. + +} + @deftogether[[ @defidform[~or] @defidform[~and]