ClojureScript

cljs.core/into doesn't preserve metadata

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

cljs.core/into doesn't preserve metadata:

(meta (into ^{:foo :bar} [] [1 2 3])) ;; => nil

Activity

Hide
Chas Emerick added a comment -

Confirmed. Both TransientVector and TransientHashMap need to have meta fields added that are passed on when instances are made persistent!.

Show
Chas Emerick added a comment - Confirmed. Both TransientVector and TransientHashMap need to have meta fields added that are passed on when instances are made persistent!.
Hide
Kevin Marolt added a comment -

Not sure what's the preferred way to handle this. The transients in Clojure don't support metadata either. Instead, Clojure simply uses

(defn into
  "Returns a new coll consisting of to-coll with all of the items of
   from-coll conjoined."
  {:added "1.0"
   :static true}
  [to from]
  (if (instance? clojure.lang.IEditableCollection to)
    (with-meta (persistent! (reduce conj! (transient to) from)) (meta to))
    (reduce conj to from)))

See also [#CLJ-916] into loses metadata.

Show
Kevin Marolt added a comment - Not sure what's the preferred way to handle this. The transients in Clojure don't support metadata either. Instead, Clojure simply uses
(defn into
  "Returns a new coll consisting of to-coll with all of the items of
   from-coll conjoined."
  {:added "1.0"
   :static true}
  [to from]
  (if (instance? clojure.lang.IEditableCollection to)
    (with-meta (persistent! (reduce conj! (transient to) from)) (meta to))
    (reduce conj to from)))
See also [#CLJ-916] into loses metadata.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: