This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-12
Channels
- # announcements (2)
- # babashka (26)
- # beginners (48)
- # calva (32)
- # cider (23)
- # clj-kondo (61)
- # cljfx (3)
- # clojure (93)
- # clojure-australia (2)
- # clojure-europe (23)
- # clojure-losangeles (1)
- # clojure-nl (5)
- # clojure-uk (4)
- # clojurescript (46)
- # cloverage (9)
- # code-reviews (1)
- # copenhagen-clojurians (1)
- # cursive (39)
- # data-science (6)
- # datahike (8)
- # deps-new (8)
- # depstar (2)
- # etaoin (1)
- # fulcro (2)
- # funcool (2)
- # graalvm (5)
- # jackdaw (3)
- # java (17)
- # jobs-discuss (43)
- # kaocha (2)
- # leiningen (25)
- # malli (8)
- # minecraft (1)
- # missionary (8)
- # observability (6)
- # off-topic (37)
- # other-languages (12)
- # practicalli (1)
- # reagent (4)
- # releases (78)
- # remote-jobs (1)
- # sci (9)
- # shadow-cljs (13)
- # spacemacs (6)
- # sql (1)
- # tools-deps (30)
- # xtdb (3)
Hello! When requiring clojure namespace A from Java (and I assume it works the same in the REPL) that itself requires a clojure namespace B, what happens to A when namespace B is modified and reloaded?
and also, what if I load namespace C that also depends on namespace B, but namespace B has changed since when namespace A was loaded
on your first question - nothing
on the second question, C will use the updated version of B
I was kind of assuming you had done the first thing before the second, but a namespace will not be reloaded unless you explicitly request it to be - either by a direct load or by using the require :reload / or :reload-all for all transitive namespaces
as a general thing, loaded code refers to other code via their var, and if the other code is reloaded, the var will be dereferenced to the new impl. that's generally how reloading works in Clojure at the repl etc
(caveat, there are things the can make this not true - capturing the deref'ed value of a var, compiling with direct linking etc)
so unless I required B from A with :reload, even if C is loaded with the new version of B, A will continue to use the old version of B?
yes, reload only happens if requested
alright, thank you @alexmiller 🙂
does anyone have a clear understanding of why module-path and class-path are different values?
like - if i were to just duplicate what is on the classpath to the module path what would the downside be
they are different approaches to declaring what classes are available to the JVM
classpath (the "old" approach) is file-oriented and everything "merges" into one file tree conceptually
the module-path chunks classes into modules and modules declare dependencies on other modules (and define additional visibility boundaries)
I think the vision of modules (Java 9+) is that you specify everything as modules (so no classpath) but the reality is that not everything is a module. there are some rules to treat jars as automatic modules, but the middle place is kind of a messy world