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