szymanowski
szymanowski

Reputation: 1379

Why does `(def ^:private name 1 ) eval to (def namespace/name 1)?

Why does this:

`(def ^:private name 1 )

evaluate to:

(def namespace/name 1) 

and not to this:

(def ^:private namespace/name 1) 

i'm just trying to write a little macro:

(defmacro def- [name val] `(def ^:private ~name ~val))

but it expands to:

(macroexpand-1 `(def- foo 12))
=> (def namespace/foo 12)

Upvotes: 2

Views: 138

Answers (1)

guilespi
guilespi

Reputation: 4702

Because clojure defmacro loses metadata, since ^ is a reader macro.

And :private is symbol metadata, so it's lost.

Look at the answer to the question on the first link for a solution.

Upvotes: 2

Related Questions