> However, my problem is still not resolved because in all the suggestions
> above, I still need to explicitly pass all the arguments to mysyn such as:
> (mysyn 1 2 3). Is there a way to pass a list l by its name and not its
> values.
> For instance, If l is '(1 2 3)
> I want to be able to call the macro as (mysyn l) and not (mysyn 1 2 3). Is
> this possible?
Yes, it is possible, but not precisely in the way you describe. Macros run at
compile-time, so if you create a definition (which exists at runtime), it will
not be available when the macro runs (simply because that code has not been run
yet!). However, you can define arbitrary values at compile-time using
define-syntax, not just macros, and you can use this with the
syntax-local-value function to access the value.
Try something like this:
(define-syntax (mysyn stx)
(syntax-case stx ()
[(_ els-id)
(with-syntax ([(el ...) (syntax-local-value #'els-id)])
#'(begin (displayln el) ...))]))
(define-syntax l '(1 2 3))
(mysyn l)
Notice (define-syntax l ...) and the call to syntax-local-value.
--
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.