Skip to content

Commit

Permalink
make bindings "pass" implementation mirror the others
Browse files Browse the repository at this point in the history
It's useful to think of each pass as applying some core transformation
using some strategy. In this case, the transformation is the bindings
rewrite rule, and the strategy is to traverse the syntax in applying
it.
  • Loading branch information
countvajhula committed Jan 30, 2025
1 parent 3f63f9c commit 04afe5c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions qi-lib/flow/core/compiler/2000-bindings.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@

;; (as name) → (~> (esc (λ (x) (set! name x))) ⏚)
;; TODO: use a box instead of set!
(define (rewrite-all-bindings stx)
(find-and-map/qi (syntax-parser
[((~datum as) x ...)
#:with (x-val ...) (generate-temporaries (attribute x))
#'(thread (esc (λ (x-val ...) (set! x x-val) ...)) ground)]
[_ this-syntax])
stx))
(define rewrite-binding
(syntax-parser
[((~datum as) x ...)
#:with (x-val ...) (generate-temporaries (attribute x))
#'(thread (esc (λ (x-val ...) (set! x x-val) ...)) ground)]
[_ this-syntax]))

(define (bound-identifiers stx)
(let ([ids null])
Expand All @@ -68,6 +67,5 @@
;; TODO: use syntax-parse and match ~> specifically.
;; Since macros are expanded "outside in," presumably
;; it will naturally wrap the outermost ~>
(wrap-with-scopes (rewrite-all-bindings stx)
(wrap-with-scopes (find-and-map/qi rewrite-binding stx)
(bound-identifiers stx))))

0 comments on commit 04afe5c

Please sign in to comment.