SRFI 211 is mostly done except for the exact specifications of the syntactic closures macro facility (SC). During the last few days, I have spent some time thinking about how to write down the semantics as concisely as possible.
I occurred to me that SC is not compatible with AOT expansion of libraries. For example, consider the following sample library:
(define-library (bar)
(export bar)
(import ---)
(begin
(define-syntax foo
(sc-macro-transformer
(lambda (form env)
`(define-syntax ,(close-syntax 'bar env)
(syntax-rules ()
((_) ,(capture-syntactic-transformer (lambda (env) ---))))))))
(foo)))
The expansion of this library will include a definition of a syntax-rules macro `bar`. The expansion of this macro includes the form returned by `capture-syntactic-transformer`. This form, however, is an object existing only at expansion time of the library because it encloses a procedure `(lambda (env) ---)`, which only exists during expansion.
Thus, the Scheme system cannot expand the library `(bar)` ahead of time. In other words, SC doesn't allow for phase separation. Even worse, `eval` could import and use this library, Thus, strictly speaking, not even AOT compilation is possible. (A way out here would be to work with separate expansions of `(bar)` during compilation and runtime, but the paper [1] shows that this would lead to inconsistencies).
Does anyone have an opinion about that? Three resolutions are possible:
(1) There's a flaw in my argument above.
(2) We accept the fact that SC is not compatible with phasing and AOT expansion/compilation.
(3) We restrict the uses of the form returned by `capture-syntactic-transformer`.
As for (3), what would you suggest?
Marc
--
[1] Dybvig/Ghuloum: Implicit Phasing for R6RS Libraries