(no title)
ValentinA23 | 1 year ago
Clojurescript doesn't use the same conventions in import/require statements: you're supposed to import macros using :require-macros or :refer-macros (I'm not even sure anymore). Conversely, `:refer :all` was banned in a prescriptivist attempt at fixing Clojure "mistakes", the rationale behind this decision being that with `:refer :all` it's not always obvious what namespace required symbols come from. Yet, with a REPL or a language server, it's very easy to get that info.
The point I want to make is that because of this porting Clojure code to Clojurescript implies a lot of inessential changes to the ns forms in your project. E.g: https://github.com/kachayev/muse/blob/8db4d5de82a8acccb4486c..., but I've done far worse.
It doesn't need to be that way.
masijo|1 year ago
A workaround is using Reader Conditionals (https://clojure.org/reference/reader#_reader_conditionals) and specifying platform differences where they matter, but it's awkward to say the least. What most projects do is to separate "common" namespaces and use the `.cljc` extension to indicate they're multi platform, and keep platform specific things in namespaces with `.clj`, `.cljs`, etc.
ValentinA23|1 year ago
This is exactly what I witnessed when finding the example above.
Out of frustration, I tried patching shadow-cljs one afternoon and was able to implement :refer :all as well as automatically generating :require-macros when needed to some extent, but I haven't put the time to make it work fully. I don't think this is a limitation caused by the lack of a Clojurescript compiler that can run in a Javascript runtime. In short, I don't think this is an essential limitation of the way the language is hosted within its target language, unlike things like Vars, which are not introspectable at runtime in js.
iLemming|1 year ago
j12a|1 year ago
kccqzy|1 year ago
unknown|1 year ago
[deleted]