Fork me on GitHub
#cljs-dev
<
2021-11-24
>
borkdude13:11:29

Is there any design coordination between the clojure core team and the CLJS core team? E.g. now there is a clojure.java.math namespace added and @quoll remarked that it would be great if this was just clojure.math which is like clojure.string a compatible namespace (with host-specific behavior, e.g. javascript regexes are not java regexes) between the two

dnolen13:11:59

a couple of times - but most of the stuff is simple and doesn't require much coordination

dnolen13:11:11

I suppose clojure.math might be useful - but I'm not sure what's there - I haven't followed this change

borkdude13:11:25

just got added yesterday

dnolen13:11:22

ah just exporting java.lang.Math - yeah could do the same for JS math object

dnolen13:11:26

@alexmiller clojure.math is probably worth considering, a la clojure.string given Math is a thing in JS - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math

Alex Miller (Clojure team)13:11:55

Sounds like @quoll was looking at that, and given feedback that it's feasible and makes sense, would consider that

quoll14:11:27

I am hoping to have an initial cut done in the next couple of days. I’m working today, and tomorrow is a “no computer” day, but I’m making good progress. I’m having to reimplement a couple of things from the JDK sources that are done in native code, but it has all been going smoothly so far

quoll13:11:35

There are some limitations. Long on the JVM has a larger range, so some of the behaviors differ on Longs, though it looks like Double can be made to behave identically

quoll14:11:29

e.g. (Math/abs Long/MIN_VALUE) on the JVM results in Long/MIN_VALUE which is negative, because Long/MIN_VALUE is one less than the negation of Long/MAX_VALUE, so that magnitude can’t be represented as a positive number. However, on JavaScript: • that’s outside of the range of safe integer values and can’t be stored anyway (it gets saved as an integer that’s rounded up by 192) • (= js/Number.MIN_SAFE_INTEGER (- js/Number.MAX_SAFE_INTEGER)) is true

quoll14:11:19

i.e. integers at the boundaries behave quite differently, and get auto-promoted into inaccurate values when they overflow

borkdude13:11:30

I think people should just be aware that when using CLJS you're dealing with the host environment limitations of JS vs JVM. This is similar to regexes: CLJS doesn't try to make them the same as on the JVM, nor should it.

👍 3