functional.cafe is one of the many independent Mastodon servers you can use to participate in the fediverse.
functional.cafe is an instance for people interested in functional programming and languages.

Server stats:

218
active users

Public

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.

Someone do this for #Emacs #lisp stat, please.

Public

@elb You might also enjoy the `rx` macro in #emacs!

@pymander @elb IME the result of sexpr regexp systems like rx is no clearer than normal regexp syntax, just much less concise

Public

@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

Quiet public

@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

Quiet public

@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~%" #\" #\\ #\")

I guess it's hard to do, isn't it.
@tfb @pymander

Quiet public

@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 @pymander

Quiet public

@elb

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 (scan '(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..

@tfb @pymander

Quiet public

@tfb, this might also depend on the level of verbosity used. e.g. you can write either "bol" or "line-start". (xr supports three levels of verbosity, iirc.)

@pymander @elb

Quiet public

@mekeor I don't find reading regexps in their conventional notation difficult. The difficulty for me is remembering the weird edge cases of things, how greedy/nongreedy variants interact ... generally, running the regexp in my head, not parsing it

@pymander @elb