What would be the most idiomatic way to alias a function in Clojure ? And is there any difference in terms of execution between those two approaches ?
Example taken from Om (Clojurescript, but the syntax in Clojure would be the same):
(defn query->ast
"Given a query expression convert it into an AST."
[query-expr]
(parser/query->ast query-expr))
(def query->ast
"Given a query expression convert it into an AST."
parser/query->ast)
I prefer def
to defn
.
The defn
version
def
version has all the arities of
the original.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With