我感到惊讶的是,在 dev/user.clj 中的这段代码在启动时没有运行
(ns user) ; user ns is loaded by REPL startup
(println "Evaluating dev/user.clj")
(when-not (resolve 'xxx)
(def xxx 1)
(println "defing xxx"))
这对我来说是有效的
(defonce yyy (let [tmp 1] (println (str "deffing yyy as " tmp))
tmp))
在 clojurians 中也有人建议类似的做法
[https://clojurians.slack.com/archives/C053AK3F9/p1683882344251029][Slack]
(ns user)
(when-not (resolve 'xxx)
(intern 'user 'xxx 42)
(prn "!!!"))