<div dir="ltr">Matthias thank you for fielding my question, though two things are not clear. I hope you or someone might clarify. <div><br></div><div>Firstly, is there a reason to prefer the macro you present over the first one given in the original post. I believe they both work. Neither uses the more elegant syntax-rule.</div><div><br></div><div>Secondly, and this is the question I'm really getting at, is there a reason that the operands given to syntax-rules must have identifiers within lexical scope at the point of the macro call, rather than lexical scope at the point of their use within the macro? <br><br>Off hand the latter seems to be the proper behavior for a macro, i.e. perhaps this is a bug? Can anyone here tell me why it behaves like this?<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 15, 2015 at 4:12 AM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
You want something like this:<br>
<br>
(define-syntax (with-tables stx)<br>
(syntax-case stx ()<br>
[(with-tables stem body ...)<br>
(let ([table-author (datum->syntax stx 'table-author)]<br>
;; ... ditto for other identifiers for which you wish to break lexical scope<br>
)<br>
#`(let ([table-publication (string-append stem "_publication")]<br>
[#,table-author (string-append stem "_author")]<br>
<span class=""> [table-bridge-publication-author (string-append stem "_bridge_publication_author")]<br>
[table-unique-counters (string-append stem "_unique_counters")])<br>
</span> body ...))]))<br>
<br>
(with-tables "x" table-author)<br>
<br>
;; ---<br>
<br>
To achieve this with syntax-rules would be, well, hard.<br>
<br>
;; ---<br>
<br>
The accepted way of writing this macro is:<br>
<br>
(define-syntax (with-tables stx)<br>
(syntax-case stx ()<br>
[(with-tables stem (table-author<br>
;; ... add other names you wish to bind in body<br>
)<br>
body ...)<br>
#`(let ([table-publication (string-append stem "_publication")]<br>
<span class=""> [table-author (string-append stem "_author")]<br>
[table-bridge-publication-author (string-append stem "_bridge_publication_author")]<br>
[table-unique-counters (string-append stem "_unique_counters")])<br>
body ...)]))<br>
<br>
</span>(with-tables "x" (table-author) table-author)<br>
<br>
<br>
<br>
</blockquote></div><br></div>