This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-22
Channels
- # announcements (6)
- # babashka (8)
- # beginners (136)
- # cider (5)
- # cljs-dev (1)
- # cljsrn (1)
- # clojure (198)
- # clojure-argentina (4)
- # clojure-australia (1)
- # clojure-europe (25)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-poland (1)
- # clojure-spec (4)
- # clojure-uk (4)
- # clojuredesign-podcast (4)
- # clojurescript (36)
- # conjure (11)
- # data-science (1)
- # datomic (6)
- # defnpodcast (1)
- # deps-new (5)
- # emacs (7)
- # events (1)
- # fulcro (10)
- # graalvm (9)
- # graalvm-mobile (10)
- # helix (9)
- # introduce-yourself (1)
- # jackdaw (1)
- # jobs-discuss (5)
- # kaocha (6)
- # lsp (10)
- # malli (11)
- # missionary (28)
- # off-topic (2)
- # pathom (24)
- # pedestal (7)
- # portal (1)
- # re-frame (12)
- # reagent (2)
- # reitit (1)
- # remote-jobs (1)
- # sci (7)
- # shadow-cljs (6)
- # sql (6)
- # tools-deps (10)
- # vim (9)
- # xtdb (19)
$ planck
ClojureScript 1.10.339
cljs.user=> ([1 2] nil)
1
cljs.user=> (get [1 2] nil)
nil
FWIW, in JVM Clojure ([1 2] nil)
returns
Execution error (IllegalArgumentException)…
Key must be integer
Does anyone know if there is an equivalent library (or builtin) to https://github.com/clojure-goes-fast/clj-java-decompiler for ClojureScript which emits the javascript generated from a particular s-expression? Having that tooling available is really nice for both performance optimization and understanding the compiler. I appreciate that whatever is generated is then transformed through the Closure compiler for further optimization but I still think it would be useful. Anyone aware of anything in that vein?
% clj -A:cljs -M -m cljs.main -r
ClojureScript 1.10.773
cljs.user=> (set! *print-fn-bodies* true)
true
cljs.user=> (defn foo [x] (inc x))
#'cljs.user/foo
cljs.user=> foo
#object[cljs$user$foo "function cljs$user$foo(x){
return (x + (1));
}"]
cljs.user=>
oh interesting I was not aware of that, I will experiment with that, thank you!
Oh so that's only how it prints the function, is there a way to access that data?
(to run it through a pretty printer say?)
Oh ... it's literally just calling str on the function itself. So that's all that is needed to get the value. That makes perfect sense but was not at all apparent. Anyway thank you for your help!
I built this a while ago https://code.thheller.com/demos/shadow-grove/
there is something like https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L173-L177
When connecting to a REPL for the first time, I’d like to make a best-effort test to detect if the REPL is a CLJS one or CLJ. I’m having difficulty working out how to do this - my CLJS-fu is too weak to figure out the var reification issues. I had planned to use `(when-let [core (find-ns 'cljs.core)] (ns-resolve core 'clojurescript-version))` - this works in Clojure but not in CLJS (no ns-resolve). If I just do `(when (find-ns 'cljs.core) cljs.core/clojurescript-version)` then that fails to compile in Clojure. I’ve tried various permutations using var and the like with no success. Is there something I could use for this?
I’d rather not use reader conditionals if possible since that will fail when connecting to older Clojure systems.
How hacky do you want to be? For example (mod 5 0)
throws an error in clj but returns NaN in cljs.
The NaN behavior is in the docstring too. So this isn’t undocumented behavior.
Sure, but I don’t care about that distinction as much. This is for Cursive, so e.g. I don’t want to be setting things like locals clearing for CLJS REPLs.
I also need to detect Babashka as a REPL server type, so things like the mod hack start getting very fiddly very fast - I’d rather something a bit more definitive like *clojurescript-version*
if I can make it work.
Would (resolve 'cljs.core/*clojurescript-version*)
not work? Seems to work in my repls. Returns nil in clj and something in cljs
Ohhh, you know what? I did some initial testing using an in-browser CLJS REPL, and that doesn’t work there. But I think I can live with not supporting self-hosted CLJS for now.
That does work in Planck and Lumo, though - maybe http://clojurescript.io is funky for some reason.
Yeah, it fails in http://clojurescript.net, too. Still, I’m not too worried about that, I think we have a winner. Thanks!
don't use those pages. they are severely outdated and do not reflect the current state of CLJS