Thank you very much to all!
Now I completely understand the metadata behavior with the reader. I'll try
to adopt eastwood, thanks for the suggestion.
Is clearly that the documentation confuses a little bit.
Cheers!
Andrey
2015-05-05 23:25 GMT+02:00 James Reeves ja...@booleanknot.com:
The
The Eastwood [1] Clojure lint tool has a few warnings in it that warn about
unused metadata in your code.
The :unused-meta-on-macro warns about metadata on macro invocations, which
is usually ignored by Clojure [2].
The :wrong-tag warns about unused type tag metadata on Vars, and
+1 to Eastwood. It is great.
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from
What you wanted here was
(meta '^:abc some-symbol)
It's a little weird but the reader attaches the metadata to the symbol. Then
the quote just evaluates directly to the same symbol, so the metadata is
preserved.
I agree that metadata can be confusing though. Especially around where AND
From your comments, I suspect this may be a source of confusion as well:
When you have something like (defn ^{:doc Increments} a-fn [x] (+ x 1))
the metadata is attached to the symbol at read time. However, during the
compilation process, the metadata on the symbol is transferred to the Var
In reference to [1]:
I do feel like the metadata loss on many macros is undesirable though and I
wish it were addressed. It certainly feels unhygienic, just in a new sense
of the term.
[1] https://github.com/jonase/eastwood#unused-meta-on-macro
--
You received this message because you are
I expect because 'some-symbol is shorthand for (quote some-symbol), so
you're attaching the metadata to a list that disappears once it's evaluated.
- James
On 5 May 2015 at 22:43, Andy- andre.r...@gmail.com wrote:
Frankly, I would've (meta ^:abc 'some-symbol) expected to work. Maybe
somebody
Because ' is a reader macro which expands to the list (quote some-symbol),
so the metadata is applied to the list, and not the symbol. You can verify
this in the REPL - (meta (quote ^:abc 'some-symbol))
On Tuesday, May 5, 2015 at 5:43:19 PM UTC-4, Andy- wrote:
Frankly, I would've (meta ^:abc
In addition to James comment: IMO clojure.org/metadata should be clearer
about this. It's mentioned more clearly on the reader page:
http://clojure.org/reader#The%20Reader--Macro%20characters
The metadata reader macro first reads the metadata and attaches it to the
next form read (see with-meta
Hi!
I have some trouble with clojure metadata / reader and I do not know if I'm
doing something wrong.
I have this code:
(defn some-func [])
(def func ^:abc some-func)
(assert (= (meta func) {:abc true}))
(def data [[:bar (with-meta some-func {:abc true})]
[:baz ^:abc some-func]])
When dealing with metadata, it's important to understand the difference
between these two expressions:
^{:foo :bar} baz
(with-meta baz {:foo :bar})
The first expression attaches metadata to the 'baz' symbol at compile time.
The second expression attaches metadata to the data held in
Thanks to both for the responses, but I stil not clearly understand.
The documentation says very clearly that:
In addition to with-meta, there are a number of reader macros (The Reader:
Macro Characters) for applying metadata to the expression following it:
^{:doc How obj works!} obj - Sets the
The documentation is rather misleading, as it implies that obj can be a
symbol. However, because ^ is a reader macro, it is applied to obj before
it is evaluated.
Clojure maps, vectors and sets all evaluate to themselves, so attaching
metadata to the unevaluated expression via the ^ reader macro,
Frankly, I would've (meta ^:abc 'some-symbol) expected to work. Maybe
somebody else can weigh in on why this one is a no-go.
On Tuesday, May 5, 2015 at 5:01:19 PM UTC-4, Andrey Antukh wrote:
Thanks to both for the responses, but I stil not clearly understand.
The documentation says very
14 matches
Mail list logo