require/expose can require an unprovided binding from a module. But it only works on functions, not macros. E.g.
(module aaa racket
(define (foo a b) (+ a b))
(define-syntax-rule (myadd x y)
(+ x y)))
(require rackunit)
;; OK
(require/expose 'aaa (foo))
;; ERROR: myadd: use does not match pattern: (myadd x y)
(require/expose 'aaa (myadd))
The relative code blocks implementing require/expose:
|
(define (dynamic-require/expose* mod names) |
|
;; Make sure module the module is instantiated |
|
(dynamic-require mod #f) |
|
;; Get the module namespace |
|
(parameterize ((current-namespace (module->namespace mod))) |
|
(apply values (map eval names)))) |
The reason is quite simple: transformer bindings are not available at runtime thus (apply eval names) thows error. Is it possible to make require/expose work on macros?
require/exposecan require an unprovided binding from a module. But it only works on functions, not macros. E.g.The relative code blocks implementing
require/expose:rackunit/rackunit-lib/rackunit/private/util.rkt
Lines 72 to 77 in 6c04ee2
The reason is quite simple: transformer bindings are not available at runtime thus
(apply eval names)thows error. Is it possible to makerequire/exposework on macros?