preserve imperative changes to metas

pull/218/head
Matthew Butterick 4 years ago
parent 9e3a0f59e8
commit c8c23a1d39

@ -53,16 +53,19 @@
;; and we want root to see those changes
(begin0
(parse xs PARSER-MODE ROOT-ID)
;; pick up any imperative changes to current-metas by tag functions
(set! METAS-ID-CALLER (current-metas))
;; restore previous value of metas
(current-metas prev-metas)))
(module METAS-ID racket/base
(provide METAS-ID)
(define METAS-ID META-HASH))
(require POLLEN/TOP (submod "." METAS-ID))
(provide ALL-DEFINED-OUT ; implicitly picks up METAS-ID-CALLER
(provide ALL-DEFINED-OUT; implicitly picks up METAS-ID-CALLER
DOC-ID)
(define prev-metas (current-metas))
(define METAS-ID-CALLER METAS-ID)
(and (current-metas METAS-ID) "") ; because empty strings get stripped, voids don't
;; we set current-metas imperatively rather than using `splicing-parameterize`
;; so that we can unset it in the post processor, rather than out here
;; so that we can restore it in the post-processor, rather than out here
(define METAS-ID-CALLER METAS-ID) ; grab the new metas
(define prev-metas (current-metas)) ; stash the old metas
(and (current-metas METAS-ID-CALLER) "") ; because empty strings get stripped, voids don't
(begin . EXPRS)))]))

@ -1 +1 @@
1578891880
1578951924

@ -7,4 +7,18 @@
(provide val))
(require rackunit 'metatest)
(check-equal? val "value")
(check-equal? val "value")
;; check that exported metas are a copy of final state of current-metas
(module metatest2 pollen
(define-meta key "value")
(define (tag . xs)
(current-metas (hash-set (current-metas) 'key "reset"))
"")
(tag "hello")
(define val (hash-ref metas 'key))
(provide val))
(require (prefix-in 2: 'metatest2))
(check-equal? val "value")
(check-equal? (hash-ref 2:metas 'key) "reset")
Loading…
Cancel
Save