AWK is imperative though, since as you process lines, you can mutate the vars you defined in BEGIN, and then use those at the END. So not exactly like a reduce, even though you could probably do a kind of reduce
Where can I find a documentation of all the options and keywords that can be used in project.clj
? For example I would like to know all the keywords and their uses in the :dependecies
vector. For example:
[<http://my.org/mylib|my.org/mylib> "1.0.0" :scope "runtime"] ;; what does :scope do and what are the values allowed
I always look at this: https://github.com/technomancy/leiningen/blob/master/sample.project.clj Not sure if it covers all your needs though.
lein help sample
scope is an idea from maven that says when different deps are used
In maven, the main values used are compile, run, test, and provided
It’s mostly used in lein to mark test-only deps and provided deps (needed to run but won’t be published as transitive deps - it’s the users responsibility to ensure that)
Should I distribute my library aot-compiled if I'm able to ensure that the only compiled code in the jar is from my lib and not clojure or other deps?
Some discussion here: https://clojureverse.org/t/deploying-aot-compiled-libraries/2545 tl;dr: probably don't do that.
imo, no
in some narrow cases, distributing both a source and a compiled version of your library (I'm in favor of using a classifier for this) is possibly useful
but in that case the source and compiled versions can both end up in your classpath so it's good to understand the implications of that for others
well we try hard to maintain both but we don't do anything to guarantee the latter
you have to think about both forward and backward compatibility too
a lib compiled with clojure version N may not work at runtime if you are using clojure version N-1
(although I would expect it to work with clojure version N+1)
in general I think it's far safer to think about neither though and distribute source :)
Thanks for explanation!
and if you're after startup time improvements, I'd recommend https://clojure.org/guides/dev_startup_time as an approach to thinking about that
Yeah, I'm aware of that! I thought it might be useful to have stuff like this baked in a library like cljfx where startup time matters a lot. The thing about cljfx is that it loads namespaces dynamically to not load the whole javafx at the start, so it's not easy to compile it completely as one might try with (compile 'cljfx.api)
gotcha
If you can guarantee its only from your lib, it should be fine. Its not as good as source, because of the "byte-code" compatibility thing, though most likely it will be. But, I still think you shouldn't. The person making an app with cljfx, if they want their app to start faster, they can do a full AOT of their app before distribution.
I'd say the only thing I include compiled in a lib are gen-classes and other such thing which is meant to be consumed from Java. Since you kind of have too, otherwise a Java app cannot use your lib.
Will it this full AOT go through every ns in a dependency? The problem here is that a lot of cljfx nses are loaded dynamically, so (compile 'cljfx.api)
won't be enough
Hey team, lein + nrepl question (putting it here as I guess it relates to both, so am not sure if an individual channel makes sense)
we are trying to set up drawbridge. When we try to connect to it,
lein repl :connect <http://localhost:3010/nrepl>
We get the following error:
WARNING: update already refers to: #'clojure.core/update in namespace: clj-http.client, being replaced by: #'clj-http.client/update
clojure.lang.Compiler$CompilerException: Syntax error compiling new at (drawbridge/client.clj:36:5).
#:clojure.error{:phase :compile-syntax-check, :line 36, :column 5, :source "drawbridge/client.clj", :symbol new}
at clojure.lang.Compiler.analyzeSeq (Compiler.java:7114)
....
Caused by: java.lang.ClassNotFoundException: clojure.tools.nrepl.transport.FnTransport
at java.net.URLClassLoader.findClass (URLClassLoader.java:435)
clojure.lang.DynamicClassLoader.findClass (DynamicClassLoader.java:69)
java.lang.ClassLoader.loadClass (ClassLoader.java:589)
clojure.lang.DynamicClassLoader.loadClass (DynamicClassLoader.java:77)
java.lang.ClassLoader.loadClass (ClassLoader.java:522)
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:427)
Based on the FntTransport
text, I intuited that perhaps there was some versioning issue. I tried down-versioning to
We are using nrepl 0.6.0, and nrepl/drawbridge 0.2.1, and lein 2.9.3, but had no luck.
Any help on how I could debug this further greatly appreciateddrawbridge depends on the old version of nrepl (seen from the clojure.tools.nrepl.transport namespace). From 0.3 and on nrepl moved to new coordinates nrepl rather than clojure.tools.
^ Curious, it seems like in drawbridge's project.clj they use nrepl 0.6.0 see: https://github.com/nrepl/drawbridge/blob/master/project.clj#L7
i don't know. but something involved is looking for the old nrepl
you could try lein deps :tree
and see if anything involved uses the old nrepl
It will AOT everything that is loaded when loading your namespaces
So like:
(if true
(require 'a)
(require 'b))
Will compile a, but not b.So its ok to have a "dynamic load", but if the load branch is not taken when doing the AOT, then it won't be compiled.
So ya, your scenario is a bit tricky
You could try to have an environment flag or a dynamic binding that if set to true will force "load" everything, if false will lazy load them "as needed" maybe.
So when someone does AOT, they can set it to true to force load it all and get it all compiled
Or, actually, I think an easy way for you to do it. Just have a namespace that all it does is require everything in cljfx
And then when someone AOTs, they can specify that namespace explicitly. Though.... I'm just not sure if Clojure will find your source if its inside a Jar hum..