[racket] hygienic read-macros (was: module-level definitions vs. local definitions and how binding works)

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jul 29 06:45:41 EDT 2014

At Mon, 28 Jul 2014 23:45:13 -0400, "Alexander D. Knauth" wrote:
> So since “no-lambda.rkt” doesn’t have to provide lambda for #λ to
> work, why would you have to provide GENSYM? That’s (part of) what I’m
> trying to figure out. Why does one work and the other not work?

If I understand, you're asking about the

 require: namespace mismatch;
  reference to a module that is not available
   reference phase: 0
   referenced module: ....

error that you get with a GENSYM example, particularly in contrast to
the absence of that error when referencing `lambda` instead.


Normally, you get access to `lambda` to a `require` chain that causes
the module providing `lambda` to be instantiated along with the module
that contains the `lambda` reference.

When your reader creates a `lambda` identifier with lexical context,
things also work out, but only the module providing `lambda` happens to
be referenced through `require`s from the referencing module, anyway.

No such `require` chain happens to be around to reach the
implementation of GENSYM when you get the error above. That is, the
module is unavailable because there was no `require` chain to make it
available.


The disconnect between binding and instantiation is the key problem
with a reader that produces a syntax object with context. We don't yet
know how to connect them (at the right phase).



Posted on the users mailing list.