This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-09
Channels
- # aleph (16)
- # bangalore-clj (1)
- # beginners (57)
- # cider (4)
- # clara (1)
- # cljs-dev (25)
- # cljsrn (12)
- # clojure (76)
- # clojure-dusseldorf (2)
- # clojure-italy (41)
- # clojure-russia (4)
- # clojure-spec (3)
- # clojure-uk (122)
- # clojurescript (101)
- # cursive (8)
- # data-science (30)
- # datomic (2)
- # emacs (2)
- # figwheel (10)
- # fulcro (53)
- # garden (5)
- # gorilla (6)
- # hoplon (1)
- # jobs (1)
- # juxt (14)
- # leiningen (12)
- # om (1)
- # om-next (1)
- # onyx (21)
- # pedestal (40)
- # perun (5)
- # portkey (2)
- # re-frame (16)
- # reagent (1)
- # ring-swagger (3)
- # rum (6)
- # shadow-cljs (239)
- # spacemacs (10)
- # specter (9)
- # uncomplicate (2)
- # unrepl (1)
- # vim (13)
- # yada (16)
has there been prior discussion (perhaps for planck and lumo) about allowing people to write macros for self-host in ordinary cljs namespaces, giving macro behaviour like in Clojure? eg.: https://www.maria.cloud/gist/65446d9a1cbe9ae23a7d04580917c1fc?eval=true
@mhuebert Yes. The "official" stance of the compiler is that it is doing nothing to prevent end-users from doing this, but it won't support it or guarantee that it will continue to work if users do that. It was covered in the penultimate point in the FAQ here https://github.com/clojure/clojurescript/wiki/Bootstrapped-ClojureScript-FAQ#with-bootstrapped-clojurescript-can-we-now-have-namespaces-that-mix-both-macros-and-functions
@mfikes you have self-host experience: a :require
in a macro namespace, does that resolve to a .cljs file or .clj file?
most cases seem to resolve to a .cljc file which when gets compiled with :cljs
conditionals
but this file https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.clj#L11 is itself a .clj
file and refers to another .clj
file via :require
given that the file also has a :require
for [
which can’t work (and is not used anyways)
@thheller You are suppose to first see if a .cljs
file exists, then a .cljc
file. The rules are here https://github.com/clojure/clojurescript/blob/85b882b728984734793d635c923bfab0f71ba00f/src/main/cljs/cljs/js.cljs#L83-L87
I think you can't really say that you are in a macro namespace just by looking at the namespace itself. (It depends on how it is being consumed.)
yeah, my question is for the general case. just js.clj was the first example I found
Hah. Yes, when dealing with macros and self-host, it can get convoluted very quickly and it is a battle to keep the mental model simple.
When I first struggled with it, that's when the compilation stage nomenclature was introduced here https://clojurescript.org/about/differences#_macros and here https://clojurescript.org/about/differences#_namespaces in an attempt to provide some end-user digestible rules.
so :require
in the compilation stage then resolves to .clj
files if I understand everything correctly
@mfikes thanks for the pointer. So the issue is that if we added support for clojure-style macros in self-host, they wouldn't be compilable with existing building tools / jvm compiler
@mfikes Exactly. The intent is to essentially avoid a fork between JVM and self-host codebases.
"must use at least version X of build tool to use macros in ClojureScript namespaces" would be something less than a fork I think