dan.ml.901
2021-9-4 20:46:56

string literals that match a regexp


dan.ml.901
2021-9-4 20:47:08

specifically, I want to match on identifiers that contain the / character


sorawee
2021-9-4 23:22:42

Identifier is like abc in (define abc 1) and string literal is like "def" in (displayln "def"). So do you want to match against for/list or "4 / 2 = 2"?


sorawee
2021-9-4 23:29:58

#lang racket (require syntax/parse/define) (begin-for-syntax (define-syntax-class my-class (pattern x:id ; match against an id #:do [; this is x as a symbol (define as-symbol (syntax-e #'x)) ; this is x as a string (define as-string (symbol->string as-symbol))] #:fail-unless (regexp-match #px"./." as-string) "must have / in the middle of an identifier name"))) (define-syntax-parser test [(_ x:my-class) #''yes] [_ #''no]) (test hello/world) ;=> yes (test hello/world/) ;=> yes (test hello/) ;=> no (test hello) ;=> no (test /hello) ;=> no


dan.ml.901
2021-9-4 23:47:29

ah that’s perfect, thank you!


dan.ml.901
2021-9-4 23:47:41

i wanted to match against for/list which this does


jestarray
2021-9-5 01:27:55

do you guys know if ben greemans transiently typed racket is going to ship ? https://youtu.be/uAWcdD40hiI


samth
2021-9-5 01:38:02

@ben definitely plans to


shu--hung
2021-9-5 01:40:37

shu--hung
2021-9-5 01:41:15

integrating back into the main repo is surely a different kind of task


jestarray
2021-9-5 02:05:46

seems like he had a newborn according to his youtbe channel, so his hands are probably tied, also congratz btw