This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-05
Channels
- # announcements (8)
- # babashka (6)
- # beginners (55)
- # biff (8)
- # calva (11)
- # cider (4)
- # clj-kondo (6)
- # cljdoc (23)
- # cljs-dev (22)
- # clojure (89)
- # clojure-brasil (3)
- # clojure-europe (47)
- # clojure-indonesia (1)
- # clojure-nl (1)
- # clojure-spec (3)
- # clojure-uk (5)
- # clojurescript (67)
- # community-development (2)
- # conjure (29)
- # cursive (2)
- # datalog (29)
- # datomic (41)
- # defnpodcast (4)
- # emacs (15)
- # google-cloud (5)
- # holy-lambda (6)
- # hyperfiddle (3)
- # introduce-yourself (8)
- # jobs (1)
- # malli (19)
- # meander (41)
- # nrepl (1)
- # off-topic (30)
- # pathom (22)
- # polylith (30)
- # releases (1)
- # remote-jobs (4)
- # sci (4)
- # shadow-cljs (1)
- # spacemacs (7)
- # specter (3)
- # tools-build (16)
- # tools-deps (2)
Does anyone have info on the significance of :topo
vs :bfs
sort orders in b/compile-clj
?
they take the set of namespaces in your project and order them for compilation
:topo will create a graph of namespace dependencies, topologically sort them, and then compile in reverse order (so least depended on to first)
:bfs is basically breadth-first-search on namespace name
And why would one choose either of those? (perhaps clearer if worded "choose one over the other")
certain orderings will cause problems with protocols, in particular compiling a namespace that extends a protocol first it will walk the require and compile the namespace that defines the protocol, then the implementation, then later it will encounter the definition namespace again, which will make the prior definition class stale
so you almost always want to compile in :topo order, which is the default
the other one existed first, and so I kept it with an option
and left room for some future option that I have not yet conceived of
you can also of course explicitly declare a list of namespaces to compile which will do neither of these
@alexmiller Does specifying only a top level namespace have the same effect as specifying a top level namespace + one of its dependencies when compiling with topo, or will it compile the dependency namespace twice? (if so, why would you ever want to compile a namespace twice?)
it will never compile twice - compilation is a side effect of load, and load keeps tracks of what namespaces have been loaded (and thus compiled)
I'm not sure if that answers your question
it will compile twice because compile-clj calls compile directly which doesn't check the var where load libs are stored
oh, that's true. but the second time, I think load will just load the already compiled class, which is newer than the source