我很惊讶在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 "!!!"))