[racket-dev] question, issue(?) with the scope of identifiers passed into define-syntax-rule

From: Thomas Lynch (thomas.lynch at reasoningtechnology.com)
Date: Thu Jan 15 00:12:41 EST 2015

I have a simple syntax rule:

  Welcome to Racket v5.2.1.
  racket@> (define-syntax-rule (with-tables stem body ...)
          [table-publication (string-append stem "_publication")]
          [table-author (string-append stem "_author")]
          [table-bridge-publication-author (string-append stem
          [table-unique-counters (string-append stem "_unique_counters")]
      body ...

Which works fine when I don't reference the environment defined by the let:

  racket@> (with-tables "x" "hello")


However when I pass it an identifier corresponding to one of the variables
defined in the let:

  racket@> (with-tables "x" table-author)
  reference to undefined identifier: table-author
  stdin::1167: table-author

The identifier passed in doesn't seem to be part of the local let context,
but carried in a different context, or perhaps it was evaluated as an
operand.  I didn't expect either of those.  Can someone point me at a
description of the expected behavior, or give me a tip here on what is
happening and why.

... in Wolfram language there is a 'Hold' operator for situations like
this.  Apparently inside the macro we have to do some evaluation to handle
the work of the macro,  is that why the operand is evaluated?

Thanks in advance for explaining the evaluation/context model here.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20150115/4fa56075/attachment-0001.html>

Posted on the dev mailing list.