Fork me on GitHub

Is there any design coordination between the clojure core team and the CLJS core team? E.g. now there is a 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


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


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


just got added yesterday


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


@alexmiller clojure.math is probably worth considering, a la clojure.string given Math is a thing in JS -

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


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


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


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


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


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