guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bindings for free identifiers in (ice-9 syncase)


From: Julian Graham
Subject: bindings for free identifiers in (ice-9 syncase)
Date: Thu, 19 Mar 2009 11:16:12 -0400

Hi Guilers,

Alright, I've been banging my head against this for several weeks now
and only just had the time to sit down and research this: If you use a
symbol in an `(ice-9 syncase)' macro definition that's bound in the
lexical closure in which that definition lives, then that binding
should be the one that gets used at transformation time.  At least,
that's how I interpret the following bit of R5RS:

"If a macro transformer inserts a free reference to an identifier, the
reference refers to the binding that was visible where the transformer
was specified, regardless of any local bindings that may surround the
use of the macro."

...but that's not what Guile seems to do.  (I'm fiddling around in
1.9.0 HEAD, because the VM is awesome and because there are some
already-committed syncase fixes that have been useful to me...)  If
you create the following module:

(define (foo-module)
  #:use-module (ice-9 syncase)
  #:export-syntax (foo-macro))

(define (foo-function) (display "Hello, world!"))

(define-syntax foo-macro
  (lambda (stx)
    (syntax-case stx ()
      ((_) (syntax (foo-function))))))

...and then import `(foo-module)' into the REPL or somewhere else,
evaluating `(foo-macro)' throws an error because `foo-function' can't
be found.  What am I doing wrong?


Regards,
Julian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]