[racket] Submodules vs hygiene

From: Brian Mastenbrook (brian at mastenbrook.net)
Date: Tue Oct 21 14:19:35 EDT 2014

I am more than a little confused by the behavior of macros that expand to submodules. In the following example, I don't have any introduced names, but the `x' binding created by the submodule is not usable from the enclosing module. What confuses me even further is that if I (require (rename-in 'mod [name name])) instead, it works; I would expect that to always be a no-op. Can anyone explain this behavior?

#lang racket

(define-syntax foo
  (syntax-rules ()
    ((_ mod name)
     (begin
       (module mod racket/base
         (define name 1)
         (provide name))
       (require 'mod)
       name))))

(foo m x)

==> x: unbound identifier in module in: x

--
Brian Mastenbrook
brian at mastenbrook.net
http:/brian.mastenbrook.net/



Posted on the users mailing list.