Dear Stephen, Works fine, and thanks for the explanation too.
Kind regards, Tim On 3 Sep 2013, at 05:32, Stephen Chang <[email protected]> wrote: > If you change datum->syntax's first argument to #'argument, then it > does what you want. > > In general if you want the identifiers created by datum->syntax to be > visible to the user, you need to supply a piece of syntax that you got > from the user. That's why calling "long" directly works but not if > it's called via "short". > > > > On Mon, Sep 2, 2013 at 8:08 PM, Tim Jervis <[email protected]> wrote: >> Hello, >> >> I have been trying to create a macro to make some arbitrary definitions, >> with success. The following defines a structure (posn) and a value (val): >> >> (define-syntax (long syntax-object) >> (syntax-case syntax-object () >> [(_ argument) >> (let ([make-id (lambda (x) (datum->syntax syntax-object x))]) >> (with-syntax ([posn (make-id 'posn)] >> [val-s (make-id 'val)]) >> #'(begin (printf "\tfrom the \"long\" macro, defining a structure >> and a value\n") >> (struct posn (x y)) >> (define val-s 12))))])) >> >> >> So: >> >> (long argument) >> >> >> defines posn and val. >> >> However, if I happen to use this macro indirectly, the definitions aren't >> visible. For example, if I define: >> >> (define-syntax (short syntax-object) >> (syntax-case syntax-object () >> [(_ argument) >> #'(long argument)])) >> >> >> and then call >> >> (short argument) >> >> >> posn and val are not defined, even though the text in the printf buried in >> the first macro does appear. >> >> I tried this in Dr Racket. >> >> Can anyone tell me where I'm going wrong? >> >> Kind regards, >> >> >> >> Tim >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> Tim Jervis http://timjervis.com/ ____________________ Racket Users list: http://lists.racket-lang.org/users

