Clojure def vs defn for a function with no arguments

后端 未结 4 1212
萌比男神i
萌比男神i 2021-02-01 01:19

I have written a program in clojure but some of the functions have no arguments. What would be the advantages of coding such functions as a \"def\" instead of a \"defn\" with no

4条回答
  •  再見小時候
    2021-02-01 01:42

    (defn name ...) is just a macro that turns into (def name (fn ...) anyway, not matter how many parameters it has. So it's just a shortcut. See (doc defn) for details.

    https://clojure.org/guides/learn/functions#_defn_vs_fn

提交回复
热议问题