Reputation: 53
What's the best way to rename Clojure's special forms?
For example, if I preferred defvar over def or defun over defn, what would be the best way to go about it?
Upvotes: 1
Views: 147
Reputation: 3538
While I perfectly agree with amalloy's answer it may be interesting to see the quick and dirty solution. You can forward the macro call by taking all the arguments of the original call and constructing another macro call using the genuine Clojure version.
(defmacro defvar [& xs] `(def ~@xs))
(defmacro defun [& xs] `(defn ~@xs))
Upvotes: 5
Reputation: 91897
Just use def
and defn
instead. You can define macros that forward to the underlying special forms, but it's in much better taste to just use the same primitives everyone else does.
Upvotes: 8