*print-dup* and subvec

13 views
Skip to first unread message

Carson

unread,
Mar 17, 2011, 6:04:42 AM3/17/11
to clo...@googlegroups.com
In Clojure 1.2, I tried this:

(read-string
    (binding [*print-dup* true]
        (print-str (subvec [1 2 3] 1))))

But I get a java.lang.IllegalArgumentException: No matching method found: create

I had something else print-dup'ed out onto disk and when I read it back in it gave me that error.  I just search and replaced clojure.lang.APersistentVector$SubVector/create with vec in the file and then it was okay, I guess.

What's going on?

Thanks,
Carson

Stuart Sierra

unread,
Mar 17, 2011, 8:51:28 AM3/17/11
to clo...@googlegroups.com
`print-dup` on any collection type generates code to call the `create` method of the collection's class.  `APersistentVector$SubVector` is missing a `create` method.

-Stuart Sierra

Carson

unread,
Mar 19, 2011, 1:44:15 AM3/19/11
to clo...@googlegroups.com
Thanks Stuart.  Is that a bug that will be fixed in 1.3?  I was under the impression that we can rely on print-dup for serialization.  Am I wrong about that?

Carson

Stuart Sierra

unread,
Mar 19, 2011, 9:39:41 AM3/19/11
to clo...@googlegroups.com
It's a bug: I just created CLJ-761.

In general, print-dup should work for serialization, but there are cases where it doesn't work: defrecords, for example, though that may be fixed in the next release.

-Stuart Sierra
Reply all
Reply to author
Forward
0 new messages