1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-19 03:00:25 +02:00

only bend hygiene in macro-introduced output, not for explicit @/@@

* module/ice-9/psyntax.scm
* module/ice-9/psyntax-pp.scm
* module/ice-9/boot-9.scm (make-module-ref): We were so almost there
  with what we had, sniff. The deal is that
    (begin (load "foo.scm") ((@@ (foo) bar)))
  would expand to
    (begin (load "foo.scm") (bar))
  because bar was unbound at expansion time, and make-module-ref assumed
  it was like the else in a cond. But it shouldn't have, because we
  /explicitly/ asked for the @@ var -- so now if we see a @ or @@, we
  never drop it. @@ introduced by hygiene can be dropped if it doesn't
  reference a var, though.

  Practically speaking, this means tagging all modules in psyntax with
  their intent: public or private (corresponding to @ or @@), hygiene
  (introduced by a macro), or bare (when we don't have a module). I'm
  not sure when we'd see a bare.

  The implementation is complicated by the need to support the old
  format and the new format at the same time, so that psyntax-pp can be
  regenerated.
This commit is contained in:
Andy Wingo 2009-04-24 13:13:29 +02:00
parent 384e92b3ae
commit a2716cbe1e
3 changed files with 50 additions and 49 deletions

View file

@ -132,15 +132,19 @@
(define (module-add! module sym var)
(hashq-set! (%get-pre-modules-obarray) sym var))
(define sc-macro 'sc-macro)
(define (make-module-ref mod var public?)
(cond
((or (not mod)
(equal? mod (module-name (current-module)))
(and (not public?)
(not (module-variable (resolve-module mod) var))))
var)
(else
(list (if public? '@ '@@) mod var))))
(define (make-module-ref mod var kind)
(case kind
((public #t) (if mod `(@ ,mod ,var) var))
((private #f) (if (and mod (not (equal? mod (module-name (current-module)))))
`(@@ ,mod ,var)
var))
((bare) var)
((hygiene) (if (and mod
(not (equal? mod (module-name (current-module))))
(module-variable (resolve-module mod) var))
`(@@ ,mod ,var)
var))
(else (error "foo" mod var kind))))
(define (resolve-module . args)
#f)