function | since v0.0-927 | clojure.core/alter-meta! | Edit |
(alter-meta! iref f & args)
(alter-meta! data f & args)
Alter the metadata of data
to be (apply f its-current-meta args)
.
Metadata of vars cannot be altered since they are statically determined at compile-time.
Metadata of symbols and collections can be altered:
(def a ^:foo [1 2 3])
(meta a)
;;=> {:foo true}
(alter-meta! a assoc :bar true)
(meta a)
;;=> {:foo true, :bar true}
Metadata of vars cannot be altered:
(def a [1 2 3])
(meta #'a)
;;=> {:arglists (), :test nil, :name a, :column 1, :line 1, :file "", :doc nil, :ns cljs.user}
(alter-meta! #'a assoc :bar true)
(:bar (meta #'a))
;;=> nil
Atomically sets the metadata for a namespace/var/ref/agent/atom to be: (apply f its-current-meta args) f must be free of side-effects
(defn alter-meta!
[iref f & args]
(set! (.-meta iref) (apply f (.-meta iref) args)))