Fork me on GitHub
#clojure-dev
<
2021-11-03
>
seancorfield17:11:49

I often see requests for a way to set *warn-on-reflection* true globally and, looking through the Clojure source, I see there's a clojure.compile.warn-on-reflection JVM option but it only seems to apply to clojure.lang.Compile/main. Is there a specific reason why there's no global way to set that variable? I seem to recall Leiningen has a way to set "globals" but that's just for the context of anything it executes (so binding works in that situation). I know you can do this for a REPL with it set "globally":

clj -M -e '(set! *warn-on-reflection* true)' -r
but that doesn't work if you're trying to use aliases that contain :main-opts since they don't combine.

hiredman18:11:09

alter-var-root

Alex Miller (Clojure team)18:11:29

I don't think there's a good reason this doesn't exist, it's an artifact of history. there is perhaps a thought process that it is only useful during compilation, and compilation is only the "only" job when running the (fairly obscure) Compile program. (Compile is primarily used for building Clojure itself.) I don't think that thought process matches today's reality.

Alex Miller (Clojure team)18:11:45

I don't think this is any conceptually different than other compiler system properties https://clojure.org/reference/compilation#_compiler_options

Alex Miller (Clojure team)18:11:58

and it would make sense to have it

seancorfield18:11:15

Haha... no wonder it sounded like such a good idea! 🙂

10