Fork me on GitHub
#cljs-dev
<
2022-01-14
>
borkdude14:01:24

@quoll has been doing a lot of hard work on https://github.com/quoll/cljs-math any thoughts on how to proceed with clojure.java.math and cljs.math @dnolen @alexmiller? Thought I'd chip in here since it would be pity if quoll's work in aligning CLJ and CLJS would be overlooked.

Alex Miller (Clojure team)14:01:20

as of 1.11.0-alpha4, it's now clojure.math

Alex Miller (Clojure team)14:01:02

I'm not expecting any additional major changes to it at this point

Alex Miller (Clojure team)14:01:47

and also, we added clojure.core/abs (in core because it has full polymorphic type support like the other numeric functions in core)

borkdude14:01:16

Ah I didn't notice that, thanks!

quoll15:01:21

@dnolen did mention that he would be prepared to align my work with ClojureScript. It was late in the year, and I was about to be offline for several weeks, so I had not planned on working on this until January. So itโ€™s probably a good thing that you prompted me ๐Ÿ™‚ The delay has been good though. @mfikes Has helped me to make it better, ensuring that the compiler would be generating better code in many cases.

๐ŸŽ‰ 9
borkdude16:01:12

Would it be beneficial in some way if clj-kondo (optionally) suggested to write cljs.core/Var instead of cljs.core.Var? The latter is supported by CLJS but clj-kondo had some problems with it which I'm fixing right now and I wondered if one is preferred over the other.

borkdude16:01:18

Also in CLJ this isn't supported:

user=> (ns foo)
nil
foo=> (defprotocol Foo)
Foo
foo=> (ns bar)
nil
bar=> (satisfies? foo/Foo 1)
false
bar=> (satisfies? foo.Foo 1)
Execution error (NullPointerException) at bar/eval169 (REPL:1).

lilactown16:01:27

i think clj-kondo ought to warn in that case. is it hard to discern between that and accessing JS properties like that, a la window.console.log?

borkdude16:01:02

Shouldn't you write js/window.console.log then anyway?

borkdude16:01:47

cljs.user=> (def cljs #js {:core #js {:Var 1}})
#'cljs.user/cljs
cljs.user=> cljs.core.Var
1
cljs.user=> cljs.core/Var
cljs.core/Var

lilactown16:01:03

yeah i would normally do that in that specific case. trying to construct a case when i wouldn't ns qualify it

lilactown16:01:42

(def lib-obj (some-js-lib/Foo.))

(prn lib-obj.bar)
is something I see sometimes when using JS libs

borkdude16:01:00

yeah, also see my artificial example above

lilactown16:01:36

yeah interesting that the obj syntax shadows the ns. makes sense i guess