Fork me on GitHub
#squint
<
2023-08-19
>
tianshu06:08:05

How does the REPL work? I saw there's a repl command in squint, it bring me to a REPL without any code loaded. Can I have a repl connected to the app runtime, and how it works with cherry?

borkdude06:08:17

Not yet, one of the features I want to focus on next

tianshu07:08:44

How do you think about supporting bigint notation, e.g. 1N to BigInt("1")? I want to implement it but don't know where to start.

borkdude07:08:10

Does normal ClojureScript support this?

tianshu07:08:37

No, it doesn't. In normal ClojureScript, 1N = 1.

tianshu07:08:53

But in JavaScript/TypeScript you write 1n for bigint literal.

borkdude07:08:56

I'd say just write (new BigInt 1) then?

tianshu07:08:50

Yep, currently it has to be (js/BigInt 1) . However Clojure supports BigInt by this format.

borkdude07:08:13

propose it in #C07UQ678E

borkdude07:08:52

you can also just write a function of course

tianshu07:08:35

Ah, it's not about how much characters. I'm just wondering if squint is not going to fully compatible with ClojureScript. May some changes recently added in modern JS/TS be condisidered as well.

tianshu07:08:06

I believe when ClojureScript was released, there's no such thing yet.

borkdude07:08:10

This is true, I'll consider it, you're the first to mention this syntax, I didn't know it existed

tianshu07:08:16

This is the behavior in Clojure.

Clojure 1.11.1
user=> (type 1)
java.lang.Long
user=> (type 1N)
clojure.lang.BigInt
This is the behavior in ClojureScript.
cljs.user> (type 1)
#object[Number]
cljs.user> (type 1N)
#object[Number]
cljs.user> (type (js/BigInt "1"))
#object[BigInt]

borkdude07:08:38

The difference in JVM Clojure and JS is:

user=> (+ 1 10N)
11N
Node:
> 1 + 11N
1 + 11N

> 1 + BigInt(11)
Uncaught TypeError: Cannot mix BigInt and other types, use explicit conversions

borkdude07:08:28

There might be good reasons that CLJS hasn't chosen to convert to BigInt even after it existed so code would still work in cases like this. I don't know their trade-offs. I'd suggest discussing this there first (#C07UQ678E) to get some more info

👍 2
borkdude07:09:28

Alright it seems CLJS is kinda open to 1234N now: https://github.com/clojure/clojurescript/pull/214/files I'll track that and follow up here: https://github.com/squint-cljs/squint/issues/337