Transient Bug

41 views
Skip to first unread message

Sean Devlin

unread,
Dec 19, 2009, 9:46:44 AM12/19/09
to Clojure
Hey,
I was experimenting with transients, and they don't seem to work for
sorted collections:

user=> (transient (sorted-map 1 2 3 4))
java.lang.ClassCastException: clojure.lang.PersistentTreeMap cannot be
cast to clojure.lang.IEditableCollection (NO_SOURCE_FILE:0)

user=> (transient (sorted-set 1 2 3 4))
java.lang.ClassCastException: clojure.lang.PersistentTreeSet cannot be
cast to clojure.lang.IEditableCollection (NO_SOURCE_FILE:0)

Is this desired behavior?

Sean

David Nolen

unread,
Dec 19, 2009, 10:20:03 AM12/19/09
to clo...@googlegroups.com
IIRC, you can use transient only with maps and vectors.

David

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Stephen C. Gilardi

unread,
Dec 19, 2009, 10:23:19 AM12/19/09
to clo...@googlegroups.com

"Currently only vectors are supported, and note that not all Clojure data structures can support this feature, but most will. Lists will not, as there is no benefit to be had."

That appears a bit out of date given these grep results on master:

public class PersistentArrayMap extends APersistentMap implements IEditableCollection {
public class PersistentHashMap extends APersistentMap implements IEditableCollection {
public class PersistentVector extends APersistentVector implements IEditableCollection{
public class PersistentHashSet extends APersistentSet implements IEditableCollection {

It looks to me like PersistentTreeMap and PersistentTreeSet have just not yet been extended to support transients.

--Steve

Sean Devlin

unread,
Dec 19, 2009, 10:30:05 AM12/19/09
to Clojure
Steve,
I've been checking out the Java, and it looks the same to me. I think
this raises a couple issues:

1. Should sorted versions get transient support in 1.1?
2. The docs should be updated to reflect the 1.1 status of
transients.

Sean

On Dec 19, 10:23 am, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> > I was experimenting with transients, and they don't seem to work for
> > sorted collections:
>
> > user=> (transient (sorted-map 1 2 3 4))
> > java.lang.ClassCastException: clojure.lang.PersistentTreeMap cannot be
> > cast to clojure.lang.IEditableCollection (NO_SOURCE_FILE:0)
>
> > user=> (transient (sorted-set 1 2 3 4))
> > java.lang.ClassCastException: clojure.lang.PersistentTreeSet cannot be
> > cast to clojure.lang.IEditableCollection (NO_SOURCE_FILE:0)
>
> > Is this desired behavior?
>

> Fromhttp://clojure.org/transients:

Chouser

unread,
Dec 19, 2009, 7:50:35 PM12/19/09
to clo...@googlegroups.com
On Sat, Dec 19, 2009 at 10:30 AM, Sean Devlin <francoi...@gmail.com> wrote:
> Steve,
> I've been checking out the Java, and it looks the same to me.  I think
> this raises a couple issues:
>
> 1.  Should sorted versions get transient support in 1.1?
> 2.  The docs should be updated to reflect the 1.1 status of
> transients.

I would vote for "no" and "yes", respectively.

Adding transient support to a collection has a history of adding
bugs as well, until they're ironed out. I think 1.1 is the wrong
timeframe for that. Perhaps 1.2?

I've updated http://clojure.org/transients to reflect vectors and
hash-map support of 'transient' in 1.1.0

--Chouser

Stephen C. Gilardi

unread,
Dec 20, 2009, 11:56:13 AM12/20/09
to clo...@googlegroups.com

On Dec 19, 2009, at 7:50 PM, Chouser wrote:

> I've updated http://clojure.org/transients to reflect vectors and
> hash-map support of 'transient' in 1.1.0

Hash-sets appear to work in 1.1.0 as well.

--Steve

Sean Devlin

unread,
Dec 20, 2009, 12:18:51 PM12/20/09
to Clojure
Could we also include some words explicitly stating that the sorted
versions are not supported in 1.1.0?

Sean

On Dec 20, 11:56 am, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> On Dec 19, 2009, at 7:50 PM, Chouser wrote:
>

> > I've updatedhttp://clojure.org/transientsto reflect vectors and

Reply all
Reply to author
Forward
0 new messages