commit 0029c1acbfceecb4003b004c200d0b55bb1a183f
parent 81a05e6ff356068b184912a7a7d27010e2ee3891
Author: Georges Dupéron <georges.duperon@gmail.com>
Date: Fri, 27 Jan 2017 22:04:37 +0100
Fixed define-pvars (was not defining the unique-at-runtime variables)
Diffstat:
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/current-pvars.rkt b/current-pvars.rkt
@@ -88,7 +88,7 @@
(λ (lower upper)
(if (= (- upper lower) 1)
(if (try-nth-current-pvars upper)
- upper
+ upper ;; Technically not possible, still included for safety.
lower)
(let ([mid (/ (+ upper lower) 2)])
(if (try-nth-current-pvars mid)
@@ -186,6 +186,9 @@
(nth-current-pvars-id (+ old-pvars-index 1)))])
(datum->syntax
(quote-syntax here)
- `(define-syntaxes (,binding)
- (list* ,@stxquoted-pvars+unique
- (try-nth-current-pvars ,old-pvars-index))))))))
-\ No newline at end of file
+ `(begin
+ (define-values (,@unique-at-runtime)
+ (values ,@(map (λ (pvar) `(gensym (quote ,pvar))) pvars)))
+ (define-syntaxes (,binding)
+ (list* ,@stxquoted-pvars+unique
+ (try-nth-current-pvars ,old-pvars-index)))))))))
+\ No newline at end of file
diff --git a/scribblings/stxparse-info.scrbl b/scribblings/stxparse-info.scrbl
@@ -26,10 +26,10 @@ and the @racket[syntax-case] family. These patched versions track which syntax
pattern variables are bound. This allows some libraries to change the way
syntax pattern variables work.
-For example, @racketmodname[subtemplate] automatically derives temporary
+For example, @tt{subtemplate} automatically derives temporary
identifiers when a template contains @racket[yᵢ …], and @racket[xᵢ] is a
pattern variable. To know from which @racket[varᵢ] the @racket[yᵢ …]
-identifiers must be derived, @racketmodname[subtemplate] needs to know which
+identifiers must be derived, @tt{subtemplate} needs to know which
syntax pattern variables are within scope.
@section{Tracking currently-bound pattern variables with @racket[syntax-parse]}
@@ -86,7 +86,7 @@ track which syntax or datum pattern variables are bound.
This can be used to associate run-time data with each syntax pattern
variable, via a weak hash table created with @racket[make-weak-hasheq]. For
- example, the @racketmodname[subtemplate] library implicitly derives
+ example, the @tt{subtemplate} library implicitly derives
identifiers (similarly to @racket[generate-temporaries]) for uses of
@racket[yᵢ ...] from a @racket[xᵢ] pattern variable bearing the same
subscript. The generated identifiers are associated with @racket[xᵢ] via this