Fork me on GitHub

Hi I'm running into a difference between clojurescript 1.9.89 (on node) and clojure 1.8.0 with pr-str and regexps. Before I dig in deeper, does this look like it's something worth investigating?

cljs.user=> (pr-str #"(?m)//.*")
user=> (pr-str #"(?m)//.*")


( it appears to do the same in chrome)


@snoe: AFAIK regexps are different between Clojure and ClojureScript, and that’s by design


so printing them may lead to different output and that is also by design


@darwin is there somewhere I can read about that design? I feel that this is sort of breaking the code as data idiom.


this is literally breaking code, because you cannot copy&paste Clojure code with regex operations and expect it to work under CLJS without changes (and vice versa)


maybe read this[1], I don’t have any pointers from the top of my head:


I wasn’t there when ClojureScript was designed, but it never claimed to be 100% implementation of Clojure, it is a dialect, and we all have to accept differences which would be impractical or impossible to implement under javascript


for example: Java regexes would be impractical (slow), threads impossible


I understand there are differences but I'm referring to the inability to (cljs.reader/read-string (pr-str #"//")) and get back #"//" in cljs -- whereas that works in clojure


to me that's more fundamental then the jvm or js regex implementation


ok, this is maybe a different thing, that may be a bug


FYI: here is the line responsible for printing: it seems to rely on grabbing javascript source for regex object


so I agree the mapping may not be precise 1:1, on reading side it is converted by re-pattern call, and on writing side it is converted by printing .source of the regexp object


ok, I did some tests, this is a bug IMO: (cljs.reader/read-string (pr-str #"/“)) => #”\/“ the problem is on printing side, taking .source gives us raw javascript version of the regexp which is not strictly the same as clojure version in double-quotes, for example in this case, forward slashes get escaped


great thanks for the confirmation @darwin