This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-06
Channels
- # announcements (3)
- # aws (3)
- # babashka (9)
- # beginners (87)
- # calva (3)
- # chlorine-clover (7)
- # cider (6)
- # clj-kondo (1)
- # cljs-dev (31)
- # cljsrn (7)
- # clojure (26)
- # clojure-berlin (5)
- # clojure-europe (84)
- # clojure-nl (3)
- # clojure-uk (13)
- # clojurescript (39)
- # core-async (4)
- # core-logic (3)
- # cursive (3)
- # datomic (10)
- # devcards (5)
- # duct (2)
- # emacs (3)
- # events (1)
- # fulcro (6)
- # jobs (4)
- # kaocha (12)
- # london-clojurians (1)
- # off-topic (21)
- # other-languages (2)
- # pathom (5)
- # pedestal (1)
- # re-frame (1)
- # reitit (3)
- # remote-jobs (6)
- # reveal (6)
- # sci (34)
- # shadow-cljs (99)
- # tools-deps (99)
I am refreshing my memory on how self-host macros work… is it supposed to be acceptable to have a x.cljs
file that :require-macros
a x.cljc
file, or does one have to put everything into a single cljc
file?
context is that i am looking for the least-invasive way to get reagent’s macros to work in self-host
since they are part of the public api, it’s not an option to move them to other macro-specific namespaces
should be fine to have them separate. even .clj
should be fine as long as it doesn't do anything java specific?
eg. reagent.core/with-let
and reagent.ratom/with-let
should both remain in the same ‘place’ api-wise
compiling/recompiling I get different results, macros are not always resolved when I expect them to be
so i was wondering if the cljs & cljc passes could be clobbering each other somehow, or the compiler state for the namespaces is being corrupted
reagent’s macros currently do not work on selfhost, for reasons I don’t understand. I also thought that .clj
namespaces should be ok as long as they don’t do interop
but we get a ra is not defined
error here: https://github.com/reagent-project/reagent/blob/master/src/reagent/core.clj#L10
there is also this - https://github.com/mhuebert/shadow-bootstrap-example/blob/8ca524a5794ba42f9cbaec71c6121b4db2a4f6c6/src/userland/macros_2.cljc#L2
I was surprised to find that if I would :require-macros
a cljc namespace that does not self-require, I can’t use the macros from within it
it might be that some of the bootstrap index data does not look exactly like the self-host compiler needs it to look
because its generated by shadow-cljs and some of the ns-related metadata looks different
the CLJ-side dependencies aren't followed when constructing the bootstrap index and compiling macros
at least thats how I remember it. so everything in the macro ns itself is directly loaded but its dependencies are not.
so macro namespaces themselves are fine but macro namespaces with dependencies don't work
I’ve written this failing test - https://github.com/clojure/clojurescript/compare/master...mhuebert:cljc-macros-require-test
(defmacro current-ns-str
"simple macro that returns info only available at compile time"
[]
;; no-op is just to test re-use of macros from other namespaces
`(userland.macros-2/no-op
~(name (.-name *ns*))))
this seems to work. using the fully qualified symbol to the alias doesn't need to be resolved.