I’d write this. Not sure if there’s a better way.
(define-syntax (foo stx)
(syntax-case stx ()
[(_ (key val ...) ...)
(andmap identifier? (syntax->list #'(key ... {~@ val ...} ...)))
#'(quote (list ((quote key) (quote val) ...) ...))]))
--
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 racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/D76D1CBC-BF78-493F-89B9-9498D615A5E7%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Also note that with syntax/parse, it becomes much easier:
(require (for-syntax syntax/parse))
(define-syntax (foo stx)
(syntax-parse stx
[(_ (key:id val:id ...) ...)
#'(quote (list ((quote key) (quote val) ...) ...))]))
On Jun 18, 2019, at 9:03 PM, Sorawee Porncharoenwase <sorawe...@gmail.com> wrote:Also note that with
syntax/parse, it becomes much easier:(require (for-syntax syntax/parse)) (define-syntax (foo stx) (syntax-parse stx [(_ (key:id val:id ...) ...) #'(quote (list ((quote key) (quote val) ...) ...))]))