Fork me on GitHub
#cljs-dev
<
2021-11-28
>
dnolen15:11:53

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

quoll15:11:45

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

quoll15:11:11

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

quoll15:11:49

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.

dnolen15:11:23

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

quoll15:11:30

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
dnolen15:11:33

@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?

dnolen15:11:46

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

dnolen15:11:13

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

borkdude15:11:29

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

borkdude15:11:00

if CLJS would support that, then this would also supported

dnolen15:11:13

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

borkdude15:11:01

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

borkdude15:11:00

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

dnolen15:11:36

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

dnolen15:11:46

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

dnolen15:11:08

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

dnolen15:11:41

actually fixing string serialization would probably lead to too much breakage

👍 2
quoll15:11:53

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

dnolen15:11:20

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

dnolen15:11:42

even if there was such a thing

dnolen15:11:53

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

quoll16:11:37

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

dnolen16:11:53

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

dnolen16:11:58

you just can't use printing to check the results

👍 1