Re: [racket-users] [racket users] Detecting characters in symbols in macros

2020-12-09 Thread Sam Tobin-Hochstadt
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

[racket-users] [racket users] Detecting characters in symbols in macros

2020-12-09 Thread Kevin Forchione
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