removed define-pattern-variable
This commit is contained in:
parent
73ab167522
commit
86f65468d7
|
@ -1,8 +1,7 @@
|
|||
#lang racket/base
|
||||
(require (for-syntax racket/base
|
||||
racket/private/sc))
|
||||
(provide define-pattern-variable
|
||||
define/with-syntax
|
||||
(provide define/with-syntax
|
||||
|
||||
current-recorded-disappeared-uses
|
||||
with-disappeared-uses
|
||||
|
@ -22,10 +21,6 @@
|
|||
|
||||
;; == Defining pattern variables ==
|
||||
|
||||
(define-syntax-rule (define-pattern-variable name expr)
|
||||
(begin (define var expr)
|
||||
(define-syntax name (make-syntax-mapping '0 (quote-syntax var)))))
|
||||
|
||||
(define-syntax (define/with-syntax stx)
|
||||
(syntax-case stx ()
|
||||
[(define/with-syntax pattern rhs)
|
||||
|
|
|
@ -54,9 +54,9 @@ the second error but not of the first.)
|
|||
[v (or/c string? symbol? identifier? keyword? char? number?)] ...)
|
||||
symbol?]{
|
||||
|
||||
Like @racket[format-id], but produces a symbol. The format
|
||||
string must use only @litchar{~a} placeholders. Identifiers in the
|
||||
argument list are automatically converted to symbols.
|
||||
Like @racket[format], but produces a symbol. The format string must
|
||||
use only @litchar{~a} placeholders. Identifiers in the argument list
|
||||
are automatically converted to symbols.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(format-symbol "make-~a" 'triple)
|
||||
|
@ -68,7 +68,8 @@ argument list are automatically converted to symbols.
|
|||
|
||||
@section{Pattern variables}
|
||||
|
||||
@defform[(define/with-syntax pattern expr)]{
|
||||
@defform[(define/with-syntax pattern stx-expr)
|
||||
#:contracts ([stx-expr syntax?])]{
|
||||
|
||||
Definition form of @racket[with-syntax]. That is, it matches the
|
||||
syntax object result of @racket[expr] against @racket[pattern] and
|
||||
|
@ -79,18 +80,8 @@ creates pattern variable definitions for the pattern variables of
|
|||
(define/with-syntax (px ...) #'(a b c))
|
||||
(define/with-syntax (tmp ...) (generate-temporaries #'(px ...)))
|
||||
#'([tmp px] ...)
|
||||
]
|
||||
}
|
||||
|
||||
@defform[(define-pattern-variable id expr)]{
|
||||
|
||||
Evaluates @racket[expr] and binds it to @racket[id] as a pattern
|
||||
variable, so @racket[id] can be used in subsequent @racket[syntax]
|
||||
patterns.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(define-pattern-variable name #'Alice)
|
||||
#'(hello name)
|
||||
(define-pattern-variable name #'Alice)
|
||||
#'(hello name)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -222,10 +213,14 @@ environment (that is, at phase level 1), optionally extended with
|
|||
}
|
||||
|
||||
@defform[(with-syntax* ([pattern stx-expr] ...)
|
||||
body ...+)]{
|
||||
Similar to @racket[with-syntax], but the pattern variables are bound in the remaining
|
||||
@racket[stx-expr]s as well as the @racket[body]s, and the @racket[pattern]s need not
|
||||
bind distinct pattern variables; later bindings shadow earlier bindings.
|
||||
body ...+)
|
||||
#:contracts ([stx-expr syntax?])]{
|
||||
|
||||
Similar to @racket[with-syntax], but the pattern variables of each
|
||||
@racket[pattern] are bound in the @racket[stx-expr]s of subsequent
|
||||
clauses as well as the @racket[body]s, and the @racket[pattern]s need
|
||||
not bind distinct pattern variables; later bindings shadow earlier
|
||||
bindings.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(with-syntax* ([(x y) (list #'val1 #'val2)]
|
||||
|
|
|
@ -678,8 +678,8 @@ Conventions:
|
|||
[(attr-repc ...) attr-repcs]
|
||||
[tail-pattern-is-null?
|
||||
(equal? (syntax->datum #'tail) '#s(pat:datum () ()))])
|
||||
(define-pattern-variable alt-map #'((id . alt-id) ...))
|
||||
(define-pattern-variable loop-k
|
||||
(define/with-syntax alt-map #'((id . alt-id) ...))
|
||||
(define/with-syntax loop-k
|
||||
#'(dots-loop dx* dcx* loop-pr* fail-handler cut-prompt rel-rep ... alt-id ...))
|
||||
#`(let ()
|
||||
;; dots-loop : stx progress rel-rep ... alt-id ... -> Ans
|
||||
|
@ -717,7 +717,7 @@ Conventions:
|
|||
(syntax-case stx ()
|
||||
[(parse:EH x cx pr repc x* cx* pr* alts rep head es k)
|
||||
(let ()
|
||||
(define-pattern-variable k*
|
||||
(define/with-syntax k*
|
||||
(let* ([main-attrs (wash-iattrs (pattern-attrs (wash #'head)))]
|
||||
[ids (map attr-name main-attrs)]
|
||||
[alt-ids
|
||||
|
|
Loading…
Reference in New Issue
Block a user