tl;dr :  Why is the following an error?

#lang at-exp racket
(define a "this")
@pregexp{^@a}  ;; Should produce #px"^this" but errors out
@pregexp{@(~a "^" a)}  ;; This works but is clumsy

Long version:

The at-exp language
(http://www.greghendershott.com/2015/08/at-expressions.html and
https://docs.racket-lang.org/scribble/reader-internals.html) allows
for (among other things) more convenient construction of regexen, like
so:

(pregexp "\\d\\d\\.\\d\\d") ;; base racket. Ugh.
@pregexp{\d\d\.\d\d}      ;; at-exp...ah, much better

I started to reply to Ken MacKenzie's recent post about string
prefixes with a suggestion that, although string-prefix was what he
wanted in this case, a regex would be a more general solution.  When I
went to test the code I was suggesting, I was surprised to find it
didn't work as expected.  I thought maybe "^@" was a function or
special form in Racket, but a quick search of the docs revealed
nothing.  I tried various forms of quoting inside the at-exp but
nothing worked.

What am I missing?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to