mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
psyntax no longer attempts to track (current-module)
* module/ice-9/psyntax.scm: Revert tracking of the current module while expanding toplevel sequences. Better to preserve lexical scoping (relative to the module of the original expression) and allow for @@ to override it. * module/ice-9/psyntax-pp.scm: Regenerated. * test-suite/tests/syncase.test: Test module-changing with @@.
This commit is contained in:
parent
27cbec84da
commit
f2d126801c
3 changed files with 8036 additions and 8213 deletions
File diff suppressed because it is too large
Load diff
|
@ -1021,34 +1021,13 @@
|
|||
|
||||
(define chi-top-sequence
|
||||
(lambda (body r w s m esew mod)
|
||||
;; Expanding a sequence of toplevel expressions can affect the
|
||||
;; expansion-time environment in several ways -- by adding or changing
|
||||
;; top-level syntactic bindings, by defining new modules, and by changing
|
||||
;; the current module -- among other ways.
|
||||
;;
|
||||
;; Of all of these, changes to the current module need to be treated
|
||||
;; specially, as modules have specific support in the expander, for
|
||||
;; purposes of maintaining hygiene. (In contrast, changes to parts of the
|
||||
;; global state that are not specifically treated by the expander are
|
||||
;; visible by default, without special support.)
|
||||
;;
|
||||
;; So, the deal. In the expression, (begin (define-module (foo)) (bar)),
|
||||
;; we need to expand (bar) within the (foo) module. More generally, in a
|
||||
;; top-level sequence, if the module after expanding a form is not the
|
||||
;; same as the module before expanding the form, we expand subsequent
|
||||
;; forms in the new module.
|
||||
(build-sequence s
|
||||
(let dobody ((body body) (r r) (w w) (m m) (esew esew) (mod mod)
|
||||
(module (current-module)) (out '()))
|
||||
(let dobody ((body body) (r r) (w w) (m m) (esew esew)
|
||||
(mod mod) (out '()))
|
||||
(if (null? body)
|
||||
(reverse out)
|
||||
(let* ((first (chi-top (car body) r w m esew mod))
|
||||
(new-module (current-module)))
|
||||
(dobody (cdr body) r w m esew
|
||||
(if (eq? module new-module)
|
||||
mod
|
||||
(cons 'hygiene (module-name new-module)))
|
||||
new-module (cons first out))))))))
|
||||
(dobody (cdr body) r w m esew mod
|
||||
(cons (chi-top (car body) r w m esew mod) out)))))))
|
||||
|
||||
(define chi-install-global
|
||||
(lambda (name e)
|
||||
|
|
|
@ -108,12 +108,14 @@
|
|||
'foo)))
|
||||
|
||||
(with-test-prefix "changes to expansion environment"
|
||||
(pass-if "expander detects changes to current-module"
|
||||
(pass-if "expander detects changes to current-module with @@"
|
||||
(compile '(begin
|
||||
(define-module (new-module))
|
||||
(define-syntax new-module-macro
|
||||
(lambda (stx)
|
||||
(syntax-case stx ()
|
||||
((_ arg) (syntax arg)))))
|
||||
(new-module-macro #t))
|
||||
(@@ (new-module)
|
||||
(define-syntax new-module-macro
|
||||
(lambda (stx)
|
||||
(syntax-case stx ()
|
||||
((_ arg) (syntax arg))))))
|
||||
(@@ (new-module)
|
||||
(new-module-macro #t)))
|
||||
#:env (current-module))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue