Clojure

hash-maps print-dup as literal, thus can be read as array-maps

Details

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

Description

Per Rich in CLJ-799: "The point of print-dup is type preservation"

user=> (hash-map :k :v)
{:k :v}
user=> (type *1)
clojure.lang.PersistentHashMap
user=> (binding [*print-dup* true] (print-str *2))
"{:k :v}"
user=> (read-string *1)
{:k :v}
user=> (type *1)
clojure.lang.PersistentArrayMap

The cause is due to RT.map conditionally creating an array-map if the size is within the PersistentArrayMap.HASHTABLE_THRESHOLD.

Activity

Alexander Taggart made changes -
Field Original Value New Value
Summary hash-maps print-dup as literal, but can be read as array-maps hash-maps print-dup as literal, thus can be read as array-maps
Aaron Bedra made changes -
Fix Version/s Approved Backlog [ 10034 ]
Waiting On richhickey
Rich Hickey made changes -
Waiting On richhickey
Alex Miller made changes -
Fix Version/s Approved Backlog [ 10034 ]
Fix Version/s Backlog [ 10035 ]
Alex Miller made changes -
Fix Version/s Backlog [ 10035 ]
Alex Miller made changes -
Labels print

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: