This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-28
Channels
- # announcements (2)
- # babashka (15)
- # beginners (13)
- # chlorine-clover (17)
- # cider (14)
- # clj-kondo (1)
- # cljfx (3)
- # clojure (21)
- # clojure-australia (2)
- # clojure-europe (3)
- # clojure-nl (4)
- # clojurescript (25)
- # core-async (7)
- # cursive (8)
- # datomic (4)
- # defnpodcast (17)
- # events (1)
- # honeysql (5)
- # jobs-discuss (18)
- # pathom (8)
- # polylith (6)
- # reagent (2)
- # reveal (1)
- # shadow-cljs (2)
- # spacemacs (12)
- # tools-deps (13)
- # xtdb (2)
Hey all - curious if this is a bug, or behavior, that anyone here has encountered before?
(map (fn [e_i e-i] [e_i e-i])
[1 2 3] [4 5 6])
;;=> ([4 4] [5 5] [6 6])
it’s exactly what would happen if I had used the same arg name - I had forgotten that, of course, dashes get mapped to underscores
Definitely ClojureScript-specific behavior, but makes sense if all of these local names must become mapped to legal JavaScript names. I suppose there are techniques that could generate guaranteed-unique names, but they would have to change some names, which for non-local names would make cljs/js interop more tricky, I would guess.
Same thing happens for Clojure namespace names -> file names for require
, and for Java class names generated from Clojure names.
We fixed something like this in Clojure back around 1.6
I started an rn app (written in cljs) and uses shadow repl to connect to it. When typing (prn ns), it gives nil. Why nil instead of some namespace?
I believe this is specific to ClojureScript; as per the CLJS docs about *ns*
:
Var bound to the current namespace. Only used for bootstrapping.
Try creating a scratch.cljc file like this; and then load it in another namespace; if you call (shared.scratch/macro-1) from that namespace, you should get the desired result.
@UGC0NEP4Y you have to use a macro; the example above works.
in the REPL the prompt prints it. in Cursive it is shown at the bottom right in the REPL input window. otherwise a quick trick is just evaling ::foo
, that'll give you :cljs.user/foo
or so
I meant you need to use a macro if you want to figure out which ns you’re “in” at runtime; otherwise during development, depends on the editor, yeah
FWIW *ns*
is a binding which are problematic in CLJS due to the async nature. It is also normally a clojure.lang.Namespace
instance which CLJS doesn't have. so it is better to just not have it or rely on it 🙂