Here's an example:
#lang racket
(require (for-syntax syntax/parse))
(define-syntax (foo stx)
(syntax-parse stx
[(_ arg:id)
#:when (regexp-match "[$]" (symbol->string (syntax-e #'arg)))
#'1]
[(_ arg) #'2]))
(foo $abc)
(foo abc)
That prints 1 followed by 2.
Sam
On Wed, Dec
Hi guys,
Is there a way to detect a character in a symbol in a macro so that one branch
of the syntax-parse would be chosen or discarded based on that?
Here’s roughly what I’m getting at….
#lang racket
(require (for-syntax syntax/parse))
(define-syntax (foo stx)
(syntax-parse stx
[(_ arg
2 matches
Mail list logo