This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-08
Channels
- # announcements (2)
- # asami (2)
- # babashka (7)
- # beginners (59)
- # cider (12)
- # cljdoc (1)
- # cljs-dev (18)
- # clojure (23)
- # clojure-europe (15)
- # clojure-losangeles (1)
- # clojure-nl (2)
- # clojure-uk (5)
- # clojured (16)
- # clojurescript (22)
- # core-typed (8)
- # cursive (3)
- # datomic (24)
- # events (2)
- # fulcro (4)
- # gratitude (1)
- # helix (13)
- # hoplon (18)
- # integrant (2)
- # introduce-yourself (1)
- # jobs-discuss (1)
- # joyride (5)
- # minecraft (1)
- # off-topic (76)
- # pathom (18)
- # podcasts (8)
- # polylith (11)
- # remote-jobs (4)
- # rewrite-clj (22)
- # sci (4)
- # shadow-cljs (152)
- # sql (4)
- # tools-build (26)
- # tools-deps (34)
Given the code here: https://github.com/clojure/clojurescript/blob/b236032061bc3c68c18adab4e5bcc3e47404d65c/src/main/clojure/cljs/core.cljc#L2697, does that mean I can use (alenght x) to call anything x that can be called with x.length() ?
x.length
not x.length()
. its a property, not a function call. technically the a*
functions are meant for arrays and there are some warnings when used on something not an array
Why does this throw?
(str/replace "// foo" #"(\/\/).*" "") => Execution error (SyntaxError) at (<cljs repl>:1). Invalid regular expression flags
The regex works in JS:
"// foo".replace(/(\/\/).*/, "") => ''
it works fine for me in a CLJS repl here: https://clojurescript.io/
During regular compilation, for some reason those \
get escaped once more. Then that RegEx string gets embedded in /.../
as a JS RegEx literal - and those /
you had there originally are now treated as boundaries of the JS RegEx literal.
Why that escaping happens in the first place, I do not know.
Thanks @U2FRKM4TW! Makes sense. I'm cooking a PR converting a Clojure library to cljc
, and ran into this. I've removed the escaping, for now, as I can't see why they would be needed. But I might find out once I file the PR. 😃
Very interesting that it works there, @UEJUEMGHF! I am curious as to what different paths the reading takes.
(i'm super new to clojure and possibly wrong but) is escaping with \ necessary in a clojure regex?
I don't think so. This is not my code, so I don't know why they are escaped. It works fine in Clojure, btw.
it isn’t necessary, no. Only when you need to escape regex characters themselves, e.g. \. to represent a dot.
Hello, is this expected to work:
• set! a object method m
with a new function
• pass this object to a javascript library that is excpected to call m
• the library in question will call the function overriden with set!, not the original one
Are you sure?
From what I understand about this answer it shouldn't: https://clojurians.slack.com/archives/C03S1L9DN/p1652707760445009?thread_ts=1652454308.301139&cid=C03S1L9DN
Well, that's a different question altogether. Your question in this thread talks about a JS object and a known field name. And if it's fed to a third-party library, that field name would be in the externs. Your question in the linked thread is about modifying CLJS objects where names could be minified and where you would rely on the exact way things are munged.
Oh yeah I understand.
Okay so the issue should me on my side then, I will double check my code