[plt-scheme] checking my macro understanding.

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Feb 9 17:12:03 EST 2007

At Thu, 8 Feb 2007 12:45:14 -0800, John Clements wrote:
> Broadly, if I want to expand into a module form, I need to be careful  
> to defeat hygiene wherever I want to embed code that refers to macros  
> that are imported into the module.  Is this correct?

Yes.

Generally, I would discourage anyone from writing a macro that expands
into `module'. Although expanding to `module' might make sense to
implement a special kind of REPL, it's not going to play right with
module loading via `require'. Also, you have to deal with the existing
context on identifiers inserted by the macro, as in the example.


>From an off-list discussion, it sounds like you're creating a reader
extension that produces a `module' form. That's a perfectly good idea.
For example, `#honu ...' is converted by the reader to `(module ...)'.

Depending on how you implement such a reader, it may be tempting to
generate parts of the reader's result using #' --- but don't do that.
Syntax objects produced by a reader shouldn't have any lexical
bindings. Instead, always create syntax objects with
`datum->syntax-object' using #f as the first argument.


Matthew



Posted on the users mailing list.