Fork me on GitHub
#clojurescript
<
2021-08-02
>
Asko Nōmm03:08:40

I have a question regarding Clojure(Script) regexes, which is that the following regex works fine in Clojure, but not in ClojureScript:

#"<(?!\/?(a|em|i|strike|u|strong|b)(?=>|\s.*>))\/?.*?>"
In ClojureScript it gives an error: SyntaxError: Unexpected token ‘?’ So are CLJ and CLJS regexes different? And if so does anyone know in what way?

Russell Mull03:08:35

Not a cljs expert, but since I'm around: I believe cljs regexes are native Javascript regexes (per https://cljs.github.io/api/syntax/regex). clj regexes are native Java regexes. The two are indeed different. Don't know how off the top of my head, but searches for java vs. js regex will probably be fruitful.

jkxyz08:08:34

Yes ClojureScript regexes are just JavaScript regexes. I find https://regex101.com/ useful for validating regexes. It lets you switch between different languages’ implementations and gives you useful errors. There’s also https://github.com/lambdaisland/regal which provides consistent semantics between Clojure and ClojureScript

Asko Nōmm14:08:28

Thanks guys! Based on your tips I managed to get it working.

borkdude18:08:26

Is:

(js/process.argv.slice 2)
considered valid CLJS instead of (.slice js/process.argv 2) ?

borkdude19:08:28

and is an official CLJS website?

borkdude19:08:18

just double checking :)

p-himik19:08:03

IIRC CLJS compiler itself uses such syntax in some places.

borkdude19:08:28

oki doki then

valtteri19:08:10

I vaguely recall js/x.y.z syntax being called a “mishap” in some conversation. But it will never go away… as one would expect 😉

thheller19:08:46

yeah its valid

Felipe Cortez22:08:41

wow, I was going to ask something exactly like that. I'm using a lib that has some nested objects, toyed around with the requires and nothing worked until I tried shaka-player/net.NetworkingEngine.RequestType.LICENSE. looks very weird having lots of dots to the right of the slash, but it's the only thing that worked

henryw37414:08:18

just be aware that syntax doesn't generally work with advanced compilation https://clojure.atlassian.net/browse/CLJS-3315 . not likely to be an issue on node ofc

p-himik14:08:39

Oh, that's interesting! @U05224H0W is that issue relevant for shadow-cljs?

thheller17:08:19

no, should be fine

👍 3
henryw37417:08:09

Pretty sure it was a shadow build where I first saw the problem

henryw37417:08:05

I assumed it was a compiler problem, not shadow

thheller17:08:11

it might be a problem when inside a core.async go. that loses type hints all over the place

thheller17:08:22

regular code should be fine

henryw37418:08:40

Wasn't core async. I'll make see the repro build sometime soon

henryw37418:08:44

*Make a repro build

henryw37415:08:52

repro containing one build using cljs.build.api and one using shadow - both show the problem: https://github.com/henryw374/data_readers.cljc-testing/tree/master/dot-test

p-himik16:08:05

Indeed, can reproduce it with the latest [email protected]

thheller06:08:49

ah just foo.bar yeah thats a problem. the initial question here was about js/foo.bar which should be fine

thheller06:08:26

as well as some-npm-alias/foo.bar. just a bare foo.bar is a problem which needs to be fixed from the compiler side

henryw37408:08:46

ah, quite a subtle distinction then. I've just stopped using any foo.bar style for now.

thheller08:08:36

yeah I'm using it only for js/ stuff too

v3ga19:08:18

Would you recommend reagent/reframe or Helix… for longevity. Also I’m not all that experienced with JavaScript. I know enough to know what’s going on and I have some ver pay basic experience with reframe. I’m wondering if I’d learn more by using helix and having to work through the react tutorials to really get a grip on what’s taking place?

raspasov22:08:35

Helix + React tutorials is a good place to go.

👍 5
v3ga14:08:12

Thanks, I forgot I asked this. I believe so as well. Just so I’m in control and aware of whats taking place.