diff options
author | scgilardi <scgilardi@gmail.com> | 2008-05-25 14:23:14 +0000 |
---|---|---|
committer | scgilardi <scgilardi@gmail.com> | 2008-05-25 14:23:14 +0000 |
commit | e3282d82bc43ce64b12668dc7dedce4eca89363a (patch) | |
tree | a59bf55ff283e36063f8441f484fda79db64f439 | |
parent | 3b1f6ff5ab1e33022cac5dfffc29d01f4c61f209 (diff) |
def.clj add defunbound, defunbound- (and re-indented)
-rw-r--r-- | def.clj | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -20,11 +20,18 @@ (defmacro defvar "Defines a var with an optional intializer and doc string" ([name] - (list `def name)) + (list `def name)) ([name init] - (list `def name init)) + (list `def name init)) ([name init doc] - (list `def (with-meta name (assoc (meta name) :doc doc)) init))) + (list `def (with-meta name (assoc (meta name) :doc doc)) init))) + +(defmacro defunbound + "Defines an unbound var with optional doc string" + ([name] + (list `def name)) + ([name doc] + (list `def (with-meta name (assoc (meta name) :doc doc))))) (defmacro defmacro- "Same as defmacro but yields a private definition" @@ -36,6 +43,11 @@ [name & decls] (list* `defvar (with-meta name (assoc (meta name) :private true)) decls)) +(defmacro defunbound- + "Same as defunbound but yields a private definition" + [name & decls] + (list* `defunbound (with-meta name (assoc (meta name) :private true)) decls)) + (defmacro defstruct- "Same as defstruct but yields a private definition" [name & decls] @@ -46,10 +58,10 @@ as another with the exception of :namespace, :name, :file, :line, and optionally :doc which are those of new var." ([name orig] - `(let [v# (def ~name ~orig)] - (. v# (setMeta (merge (meta #'~orig) (meta #'~name)))) - v#)) + `(let [v# (def ~name ~orig)] + (. v# (setMeta (merge (meta #'~orig) (meta #'~name)))) + v#)) ([name orig doc] - `(let [v# (def ~name ~orig)] - (. v# (setMeta (merge (meta #'~orig) (assoc (meta #'~name) :doc ~doc)))) - v#))) + `(let [v# (def ~name ~orig)] + (. v# (setMeta (merge (meta #'~orig) (assoc (meta #'~name) :doc ~doc)))) + v#))) |