The main use I've had for with-meta is in macros, to attach e.g. type
hints to a symbol that's going into the macro expansion. There, the ^
reader macro adds the metadata too early rather than with-meta adding
it too late: ^ hints some symbol in the macro body and the compiler
will apply the type h
2010/11/22 Mike K
> In "Programming Clojure" Stuart Halloway says:
>
> It is important to note that the metadata reader macro is not the same
> as with-meta. The metadata reader macro adds metadata for the
> compiler, and with-meta adds metadata for your own data:
>
> (def ^{:testdata true} foo (
I think it is due to the fact that [1 2 3] is self-evaluating.
If you were to write
(defn f [x] ^{:order :ascending} x)
(f [1 2 3])
the data would be on x in the compiler but never on [1 2 3]
with-meta would do the right thing.
On Mon, Nov 22, 2010 at 3:57 PM, Mike K wrote:
> In "Programmin
In "Programming Clojure" Stuart Halloway says:
It is important to note that the metadata reader macro is not the same
as with-meta. The metadata reader macro adds metadata for the
compiler, and with-meta adds metadata for your own data:
(def ^{:testdata true} foo (with-meta [1 2 3] {:order :ascen