Clojure

Clojure transforms literals of custom IPersistentCollections not created via deftype/defrecord to their generic clojure counterpart

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Approval:
    Triaged

Description

user=> (class (eval (sorted-map 1 1)))
clojure.lang.PersistentArrayMap ;; expected: clojure.lang.PersistentTreeMap

Activity

Hide
Alex Miller added a comment -

Seems related to CLJ-1093.

Show
Alex Miller added a comment - Seems related to CLJ-1093.
Hide
Nicola Mometto added a comment -

The symptoms are indeed similar but there are differences: CLJ-1093 affects all empty IPersistentCollections, this one affects all {ISeq,IPersistentList,IPersistentMap,IPersistentVector,IPersistentSet} collections that are not IRecord/IType.

Show
Nicola Mometto added a comment - The symptoms are indeed similar but there are differences: CLJ-1093 affects all empty IPersistentCollections, this one affects all {ISeq,IPersistentList,IPersistentMap,IPersistentVector,IPersistentSet} collections that are not IRecord/IType.
Hide
Stuart Halloway added a comment -

Clojure never promised otherwise.

Show
Stuart Halloway added a comment - Clojure never promised otherwise.
Hide
Nicola Mometto added a comment -

I'm honestly disturbed that this is not considered a bug.
Could we have at least a documentation enhancement expliciting this behaviour? I really don't understand how one is supposed to know that this is expected behaviour.

Show
Nicola Mometto added a comment - I'm honestly disturbed that this is not considered a bug. Could we have at least a documentation enhancement expliciting this behaviour? I really don't understand how one is supposed to know that this is expected behaviour.
Hide
Nicola Mometto added a comment -

At least mentioning that there is a limited set of types that can be returned by macroexpand would be reasonable.

user=> (defmacro foo [] (sorted-map 1 1))
#'user/foo
user=> (class (foo))
clojure.lang.PersistentArrayMap
Show
Nicola Mometto added a comment - At least mentioning that there is a limited set of types that can be returned by macroexpand would be reasonable.
user=> (defmacro foo [] (sorted-map 1 1))
#'user/foo
user=> (class (foo))
clojure.lang.PersistentArrayMap
Hide
Stuart Halloway added a comment -

Hi Nicola,

The relevant doc, including enumeration of the possible types returned, is at http://clojure.org/evaluation: "Vectors, Sets and Maps yield vectors and (hash) sets and maps whose contents are the evaluated values of the objects they contain."

Show
Stuart Halloway added a comment - Hi Nicola, The relevant doc, including enumeration of the possible types returned, is at http://clojure.org/evaluation: "Vectors, Sets and Maps yield vectors and (hash) sets and maps whose contents are the evaluated values of the objects they contain."
Hide
Nicola Mometto added a comment -

OK, thanks.

I still disagree that clojure should silently coerce IPCs to generic colls (I, and others, have been bitten by this bug and have wasted hours of debugging), but at least it's coherent with the documentation.

Show
Nicola Mometto added a comment - OK, thanks. I still disagree that clojure should silently coerce IPCs to generic colls (I, and others, have been bitten by this bug and have wasted hours of debugging), but at least it's coherent with the documentation.
Hide
Daniel Compton added a comment -

It's probably worth making this point explicit in the docs, you could easily miss the implications of that section on first read.

Show
Daniel Compton added a comment - It's probably worth making this point explicit in the docs, you could easily miss the implications of that section on first read.

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: