Reputation: 6290
New to clojure and i'm wondering.. can i define a var as both ^:private and ^:const?
So for instance, would it make sense to do the following:
(def ^:private ^:const everything 42)
Upvotes: 1
Views: 606
Reputation: 91577
Yes, on any sufficiently modern Clojure version.
long ago the metadata keywords didn't "roll up" but that was fixed years ago.
the ^:keyword
reader-macro is just a syntactic shorthand for ^{:keyword true}
user> (def ^:private ^:const everything 42)
#'user/everything
user> (meta #'everything)
{:const true, :private true, :line 241457, :column 7, :file "*cider-repl api*", :name everything, :ns #namespace[user]}
is the same as:
user> (def ^{:private true :const true} everything 42)
#'user/everything
user> (meta #'everything)
{:private true, :const true, :line 241816, :column 7, :file "*cider-repl api*", :name everything, :ns #namespace[user]}
Upvotes: 1