print-dup form unreadable for sorted sets and maps

Description

print-dup for sorted sets and maps presume a nonexistent static create method that takes an IPersistentCollection

Printing

Can't read back

Possible Fixes

  • add create methods taking IPersistentVector to collections

  • emit something different from print-dup

Environment

Clojure 1.6.0
Clojure 1.7.0-alpha5
Clojure 1.7.0-beta3

java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

Activity

Show:
Alex Miller
May 19, 2015, 10:55 PM

It's trying to invoke PersistentTreeSet.create(ISeq) with ["123"]. It's not clear to me where the vector comes from?

Nikita Prokopov
May 19, 2015, 11:04 PM

It’s a particular case of CLJ-1461. Vector comes from reading output of print-dup:

I already have a patch for PersistentTreeSet (attached here). Can look into CLJ-1461 later.

import
July 6, 2016, 5:29 AM

Comment made by: mikerod

This won't work for sorted sets (or maps) that are defined with a custom Comparator though via fn's like sorted-set-by etc. I think the round-trip print to read result would then be confusing and incorrect right?

Even more troublesome to me here is that I see no clear way to make print-dup capable of handling the case of a custom Comparator correctly. Arbitrary functions are black boxes and we have no generally, effective way to print-dup them (based on my research I assume this to be correct). We can always make special wrapped fn's for that, but again, not general.

Assignee

Unassigned

Reporter

Nikita Prokopov

Labels

None

Approval

Triaged

Patch

Code and Test

Affects versions

Priority

Minor
Configure