Idiomatic Clojure Function Alias

What would be the most idiomatic way to function alias in Clojure? And is there a difference in deadlines between the two approaches?

Example taken from Om (Clojurescript, but the syntax in Clojure will 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)
+4
source share
1 answer

I prefer from defto defn.

Version defn

  • has a built-in function call that may or may not be canceled;
  • limited to arity 1, while the version defhas all the attributes of the original.
+7
source

Source: https://habr.com/ru/post/1619537/


All Articles