Fork me on GitHub

@quoll I don't know exactly what you're trying to do but confirming results via string conversion probably will be fraught


Actually… I am trying to do something unrelated. I’m trying to build a function compatible math namespace for ClojureScript. I got caught out because I thought I was losing the sign from -0, but on further investigation I learned that it just wasn't being printed at the repl and I was fine


Moved into a thread so I don’t mess up the main channel discussion


After trying similar things on node and NOT losing the sign (according to the repl) it confused me for a long time, before using the ArrayBuffer trick to assert that the bit pattern was the same. (I already had a buffer for another purpose, so I went that way instead of thinking to ask Math.sign). It was when I realized that it was just the printing at the cljs repl where the info was lost that I thought you'd want to know.


Math.sign() is a thing in JS - perhaps that's a better for the assertion you want to make?


Not trying to do something. It was about identifying a difference in platforms. I know that it's not a goal to make them operate identically (which isn't possible) but given that node printed the difference at the prompt I thought it worth identifying

👍 1

@danielcompton @borkdude I suppose Clojure encountered the same problem and relaxed the case for kwargs? we probably just need to call a non-checking constructor?


happy to just fix this up - since if it works in Clojure that is a regression


@quoll I'm just saying the printing is one thing - what you have is another


@dnolen the relaxation is just because of the new support in 1.11 for passing either trailing keywords or a trailing map


if CLJS would support that, then this would also supported


@borkdude so you're saying before 1.11 it failed?


(I should double check, which I'm doing now)


Clojure 1.10.1
user=> (defn f1 [a b & {:keys [c]}] [a b c])
user=> (f1 1 2 [])
Execution error (IllegalArgumentException) at user/f1 (REPL:1).
No value supplied for key: []


interestingly @quoll the ability to roundtrip -0.0 is not even possible in JavaScript anyway


i.e. JSON.stringify(-0.0) => "0"


my theory is that the printing has always been wrong - and the it can only be corrected at the JS REPL


actually fixing string serialization would probably lead to too much breakage

👍 2

Yes, I was disappointed to see that conversion to a string lost the sign. I was left wondering what Node uses when it prints the number at the prompt


right I'm saying it's a magical thing most likely - i.e. nothing we can get at from the JS RT


even if there was such a thing


if it was Node-specific - not going to use it


Yes, it's a repl thing, which isn't a significant use case for cljs


still in end - I don't think the printing matters here - if you're looking at numerics - everything should work as expected


you just can't use printing to check the results

👍 1