Welcome! Please see the About page for a little more info on how this works.
Applying meta to a lazy-seq causes realization:
(def x (vary-meta (lazy-seq (prn :realized)) assoc :foo :bar))
This might be surprising, so modify docstring of lazy-seq to mention it.
Comment made by: alexmiller
I think it's likely that seq() is called here so that the old LazySeq instance and the new one share the sequence. Otherwise the pre-meta and post-meta versions would be performing the same function calls on the same inputs but would be disconnected, which seems bad.
I'm not really sure where this would be documented. Maybe on the http://clojure.org/metadata page?
Comment made by: mpenet
That would make sense yes and on the docstring of lazy-seq as well.
I added a sentence to the metadata page and updated the description to be more applicable here to a docstring change.
Comment made by: michaelblume
With this patch, with-meta doesn't realize the seq, but realization still only happens once -- would this be an acceptable approach?