Welcome! Please see the About page for a little more info on how this works.

0 votes
in Metadata by
edited by

The documentation for metadata https://clojure.org/reference/metadata contains a confusing sentence which I think it grammatically incorrect.

The sentence is: One consequence of this is that applying metadata to a lazy sequence will realize the head of the sequence so that both objects can share the same sequence.

Can someone please explain grammatically correctly what the 2nd sentence in the 3rd paragraph means?

What are the two objects (both) in question and which sequence is shared between these two objects?

Since the sentence is ambiguous, I'm not 100% sure what it means. But here is my attempt to correct the sentence. Please feel free to correct my incorrect-correction.

That said, metadata and its relationship to an object, A, is immutable - an object, B, with different metadata is a different object. One consequence of this is that applying metadata to A (if A is a lazy sequence) will realize the head of the sequence so that objects A and B can share the same meta-data.

Additional discussions can be found here https://clojurians.slack.com/archives/C03S1KBA2/p1625827141061700

1 Answer

0 votes
by

There is a collision over uses of the word "sequence" referring to distinct things. A tiny experiment suggests that it means "...so that both objects can share the same tail":

clj꞉user꞉> 
(def A (map inc (range)))
#'user/A
clj꞉user꞉> 
(def B (with-meta A {:foo "baz"}))
#'user/B
clj꞉user꞉> 
(identical? A B)
false
clj꞉user꞉> 
(identical? (rest A) (rest B))
true
by
How can we get this fixed in the documentation?
by
Clojure web site issues/prs should be filed at https://github.com/clojure/clojure-site/issues
...