Fork me on GitHub
#clojurescript
<
2022-07-08
>
cheewah15:07:18

how can i get the correct value of 4503599627370495 for cljs?

; cljs
(unsigned-bit-shift-right 9007199254740991 1)
2147483647
; clj
(unsigned-bit-shift-right 9007199254740991 1)
4503599627370495
(`9007199254740991` is the 2^53-1 max safe integer in js)

p-himik16:07:00

Perhaps if you use js/BigInt and plain bit-shift-right, because >>> is not supported for js/BigInt and because >>> clamps its operands to 32 bits.

cheewah16:07:44

(bit-shift-right (js/BigInt 9007199254740991) (js/BigInt 1))
#object[BigInt 4503599627370495]
@U2FRKM4TW it works, thanks 😉

👍 1
Matej Ć arlija17:07:24

Hi, newb here, done some Javascript and Angular professionally, learned some Clojure for fun, what do you need to learn realistically to build Cljs apps (in addition to Clojure / Clojurescript 🙂 ) - mostly Reagent and Re-frame or?

Edward Ciafardini18:07:01

The 3rd edition of “web development with Clojure” will give you a good start

kennytilton19:07:29

For re-frame, these read-to-go projects are a great leg up: https://github.com/PEZ/rn-rf-shadow Agreed on Helix as a path to RN without necessarily using reagent/re-frame: https://github.com/lilactown/helix

Matej Ć arlija16:07:23

Thank you all!

👍 1
colliderwriter18:07:15

@matejsarlija1 Post-newb here. My highly opinionated answer: you need https://shadow-cljs.github.io/docs/UsersGuide.html and either reagent / re-frame or helix / keechma-next

zimablue19:07:17

hi, there's this comment in a clojurescript library but I don't understand why, is it because the macro is in some sense running "in clojure"? ;; we would like to just identify defui methods with metadata, ;; but since macros in clojure script won't have access to that metadata ;; we have to keep track elsewhere ;; this is the elsewhere

p-himik19:07:17

Macros are indeed run at the compile time.

p-himik19:07:38

And at the compile time, there's only CLJ, there's no CLJS (with the exception of bootstrapped CLJS).

zimablue19:07:31

and metadata somehow doesn't cross the boundary? because the metadata is attached in the 'cljs runtime' (??) or 'cljs namespace' and the clj-macro-compiler time has no access to that? if all the code is cljc-able then one could get around this by running everything through cljc imports so that the clj compile time will have access to the identical metadata? if that makes sense

zimablue19:07:59

like it's only a problem if one needs to do a cljs-only thing if that workaround works?

zimablue19:07:12

if the clj macros are doing a side effect like storing a load of state in an atom, that atom would be accessible in clj but not cljs, the macro needs some way to 'export' that atom to clojurescript? like clojure macros can fuck with runtime state but clojurescript macros naively can't?

phronmophobic19:07:15

(I'm the author of the referenced library). The metadata is only required at compile time. It's not needed at runtime. If I remember correctly, I think the issue is that the cljs compiler keeps some of the metadata (like :name ), but not all of the metadata. Specifically, the code uses :arglists . That was a while ago and it's possible the situation has changed since then.

phronmophobic20:07:15

I tried printing out meta data during compilation. It seems like all the bookkeeping could be done solely with meta data, but it's been a while since I wrote that code so there may be some other detail I'm forgetting.

zimablue20:07:21

interesting, I wasn't criticizing just trying to learn by asking about something I didn't understand

phronmophobic20:07:43

no offense taken!

phronmophobic20:07:03

that code is inherently tricky and supporting clj, cljs, bootstrapped cljs, native image, and sci (clj,cljs,native image) also makes it more tricky.