expand a module's toplevel macro calls for its importers

Its interface was read as written, so pub forms a macro wrote never
reached them, which list-macros' is-public? flag exists for. The
module's macros, and those its imports give it, are lent for the
reading and taken back after. One reading a type the module keeps to
itself cannot expand there, and gives importers nothing, as before.
This commit is contained in:
2026-10-19 14:18:56 +03:00
parent 3f560594c4
commit e47aa387f5
6 changed files with 141 additions and 11 deletions

View File

@@ -16,7 +16,9 @@
get-macro
macro?
apply-macro
defmacro)
defmacro
macro-definition
restore-macro!)
(define (cat-syms s-1 s-2)
(fmt #f s-1 s-2))
@@ -91,6 +93,17 @@
(sex-error form "macro takes at least this many arguments"
name required)))))
;;; What a name is defined as a macro to, or #f; and putting that back,
;;; for a macro lent for a while -- a module's, while its interface is
;;; read
(define (macro-definition name)
(get name 'sex-macro))
(define (restore-macro! name definition)
(if definition
(put! name 'sex-macro definition)
(remprop! name 'sex-macro)))
(define (defmacro form)
(let ((arglist (car form))
(body (cdr form)))