add optional intro? argument to record-disappeared-uses

This commit is contained in:
Ryan Culpepper 2019-03-26 15:51:32 +01:00
parent 85fe092ed9
commit 6c3031a5f7
2 changed files with 12 additions and 8 deletions

View File

@ -164,19 +164,23 @@ does not satisfy the predicate, @racket[#f] is returned and the
identifier is not recorded as a disappeared use.
}
@defproc[(record-disappeared-uses [id (or/c identifier? (listof identifier?))])
@defproc[(record-disappeared-uses [id (or/c identifier? (listof identifier?))]
[intro? boolean? (syntax-transforming?)])
void?]{
Add @racket[id] to @racket[(current-recorded-disappeared-uses)] after calling
@racket[syntax-local-introduce] on the identifier. If @racket[id] is a list,
perform the same operation on all the identifiers.
Add @racket[id] to @racket[(current-recorded-disappeared-uses)]. If
@racket[id] is a list, perform the same operation on all the
identifiers. If @racket[intro?] is true, then
@racket[syntax-local-introduce] is first called on the identifiers.
If not used within the extent of a @racket[with-disappeared-uses]
form or similar, has no effect.
@history[#:changed "6.5.0.7"
@elem{Added the option to pass a single identifier instead of
requiring a list.}]
requiring a list.}
#:changed "7.2.0.11"
@elem{Added the @racket[intro?] argument.}]
}

View File

@ -87,15 +87,15 @@
(begin (record-disappeared-uses (list id))
value))))
(define (record-disappeared-uses ids)
(define (record-disappeared-uses ids [intro? (syntax-transforming?)])
(cond
[(identifier? ids) (record-disappeared-uses (list ids))]
[(identifier? ids) (record-disappeared-uses (list ids) intro?)]
[(and (list? ids) (andmap identifier? ids))
(let ([uses (current-recorded-disappeared-uses)])
(when uses
(current-recorded-disappeared-uses
(append
(if (syntax-transforming?)
(if intro?
(map syntax-local-introduce ids)
ids)
uses))))]