I was just grousing about all the extra backwhacking of regexes in lisps, and like ... why don't lisps have #// regex readers? This seems like a neat and simple solution to that problem. Just turn #/regex/ into (make-regexp "regex-with-doubled-backslashes") and everybody's happy.
Conversation
Notices
-
Embed this notice
Ethan Blanton (elb@social.sdf.org)'s status on Friday, 06-Dec-2024 04:03:01 JST Ethan Blanton -
Embed this notice
screwlisp (screwtape@mastodon.sdf.org)'s status on Friday, 06-Dec-2024 04:02:58 JST screwlisp @elb
Proximally, I was thinking recently it was because #/ was the character dispatch macro in zetalisp in the early 80s. Now it's #\, but I had to add #/ as the "zetalisp character dispatch macro" to run some zetalisp code recently. So there's a reason to choose something else. Also ~/foo:bar/ is a format control in lisp (call the exported bar from foo on the output stream).
To my knowledge, it's encouraged to use the unused bracket characters for this kind of stuff.
@tfb @pymander -
Embed this notice
Thomas (tfb@functional.cafe)'s status on Friday, 06-Dec-2024 04:02:59 JST Thomas @pymander @elb IME the result of sexpr regexp systems like rx is no clearer than normal regexp syntax, just much less concise
-
Embed this notice
Erik L. Arneson :emacs: (pymander@fosstodon.org)'s status on Friday, 06-Dec-2024 04:03:00 JST Erik L. Arneson :emacs: -
Embed this notice
Ethan Blanton (elb@social.sdf.org)'s status on Friday, 06-Dec-2024 05:23:41 JST Ethan Blanton @screwtape
I could easily be sold on some syntax other than #//, just so long as my regexps don't turn into \\\\(\\\\) all over the place!
@tfb @pymander -
Embed this notice
screwlisp (screwtape@mastodon.sdf.org)'s status on Friday, 06-Dec-2024 05:23:41 JST screwlisp @elb
I guess it's kind of similar to format control strings, isn't it, because they have many similar attributes to regex control strings. Ie
CL-USER> (format t "\"\\\"~%")
"\"
CL-USER> (format t "~s~%" "\\")
"\\"
CL-USER> (format t "~a~a~a~%" #\" #\\ #\") -
Embed this notice
screwlisp (screwtape@mastodon.sdf.org)'s status on Friday, 06-Dec-2024 05:38:13 JST screwlisp I was kind of hoping there would be a nice series expression that just "was regex", but I didn't find it yet.
(require :series)
(series::install)
(let ((to-filter #z(a b c d e))
(filters (series '(b d))))
(collect
(choose
(#Mmember to-filter filters)
to-filter)))
(series::install :remove t)
There are only five candidate decades for someone to have written it in, I'll find it eventually.. -
Embed this notice
Ethan Blanton (elb@social.sdf.org)'s status on Friday, 06-Dec-2024 05:38:14 JST Ethan Blanton @screwtape Yeah, probably a generalized robustly-quoted string syntax and passing it to the regexp compilation function would be fine, and it would also solve other string quoting struggles.
@tfb @pymanderscrewlisp repeated this.
-
Embed this notice