Hello,
It's simple enough to write a macro that defines something.
(define-syntax-rule (my-define name binding)
(define name binding))
But what if I would like to define multiple things? I.e.
(define-syntax-rule (my-multiple-define name ... binding ...)
(define name binding) ...)
The above is no good, because define-syntax-rule expects only one body to be
returned, not multiple. Wrapping the defines in begin wouldn't work, because
then they'd only be able to be accessed in the scope of that begin (when, in
actuality, I want the rest of the code to access them, like they would be able
to in the first example).
Similarly, if I "upgrade" the syntax-rule to define-syntax, we run into the
same problems. I thought that the following would work,
(define-syntax (my-multiple-define stx)
(syntax-case stx ()
[(_ name1 name2 binding1 binding2)
#'(define name1 binding1)
#'(define name2 binding2)]))
but it looks like this only returns the last syntax object, not both of them.
(Note, my actual goal here is to define something, then define a syntax rule
afterwards like
(define-syntax (my-multiple-define stx)
(syntax-case stx ()
[(_ x y z)
#'(define x y)
#'(define-syntax-rule (z *stuff*)
*some random body to the syntax-rule*)]))
, so the solution of using define-values to do all the defines in one step
won't work for me.)
I'd be satisfied either with knowing how to make a macro expand into multiple
syntax objects (so that one macro can expand into both defines), or with
someone letting me know how to define something, then define a syntax rule
afterwards using only one syntax object (like wrapping them in a begin but that
bumps the definitions inside to the outer scope).
Many thanks in advance!
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.