Matthias thank you for fielding my question, though two things are not clear. I hope you or someone might clarify.
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. 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? 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? On Thu, Jan 15, 2015 at 4:12 AM, Matthias Felleisen <matth...@ccs.neu.edu> wrote: > > You want something like this: > > (define-syntax (with-tables stx) > (syntax-case stx () > [(with-tables stem body ...) > (let ([table-author (datum->syntax stx 'table-author)] > ;; ... ditto for other identifiers for which you wish to break > lexical scope > ) > #`(let ([table-publication (string-append stem "_publication")] > [#,table-author (string-append stem "_author")] > [table-bridge-publication-author (string-append stem > "_bridge_publication_author")] > [table-unique-counters (string-append stem > "_unique_counters")]) > body ...))])) > > (with-tables "x" table-author) > > ;; --- > > To achieve this with syntax-rules would be, well, hard. > > ;; --- > > The accepted way of writing this macro is: > > (define-syntax (with-tables stx) > (syntax-case stx () > [(with-tables stem (table-author > ;; ... add other names you wish to bind in body > ) > body ...) > #`(let ([table-publication (string-append stem "_publication")] > [table-author (string-append stem "_author")] > [table-bridge-publication-author (string-append stem > "_bridge_publication_author")] > [table-unique-counters (string-append stem > "_unique_counters")]) > body ...)])) > > (with-tables "x" (table-author) table-author) > > > >
____________________ Racket Users list: http://lists.racket-lang.org/users