Keyword not serializable

7 views
Skip to first unread message

Chris Kent

unread,
Jul 24, 2009, 7:06:50 PM7/24/09
to Clojure
Hi

Are there any fundamental reasons why the Keyword class shouldn't be
serializable? I've been playing around with Clojure and Wicket and
it's not possible to use maps containing Keywords in Wicket page
classes. Wicket pages are serialized and stored in the session
between requests and this fails if the page refers to any Keywords.
Using Keywords in maps is common in Clojure (and in clj-record in
particular) and it would be a really useful change.

I'd be happy to supply a (very small) patch if people think it's a
good idea.

Thanks
Chris

Chas Emerick

unread,
Jul 30, 2009, 10:03:46 PM7/30/09
to Clojure
It turns out that a framework we've been using is able to serialize
*any* Java class, whether it implements Serializable or not -- so,
we've been happily serializing keywords without them explicitly
supporting it for some time.

However, making Keyword formally Serializable has other benefits,
specifically that a proper patch would ensure that deserialized
Keywords are interned as one would expect out.

So, I may make a run at this sooner rather than later...

- Chas

On Jul 24, 7:06 pm, Chris Kent <cjk...@gmail.com> wrote:
> Hi
>
> Are there any fundamental reasons why the Keyword class shouldn't be
> serializable?  I've been playing around with Clojure and Wicket and
> it's not possible to use maps containingKeywordsin Wicket page
> classes.  Wicket pages are serialized and stored in the session
> between requests and this fails if the page refers to anyKeywords.
> UsingKeywordsin maps is common in Clojure (and in clj-record in

Chris Kent

unread,
Jul 31, 2009, 1:47:01 PM7/31/09
to Clojure
Great. As far as my (possibly flawed) understanding goes it should be
pretty simple. Make it implement Serializable and add a readResolve
method that returns intern(sym). sym will have already been interned
by its own readResolve method.

Chas Emerick

unread,
Aug 13, 2009, 10:58:46 PM8/13/09
to Clojure
On Jul 31, 1:47 pm, Chris Kent <cjk...@gmail.com> wrote:
> Great.  As far as my (possibly flawed) understanding goes it should be
> pretty simple.  Make it implementSerializableand add a readResolve
> method that returns intern(sym).  sym will have already been interned
> by its own readResolve method.

No, you're exactly right. I've opened a ticket for this enhancement/
fix, including a patch:

http://www.assembla.com/spaces/clojure/tickets/174

You can use the patch on your own right away if you're building
clojure from source.

Cheers,

- Chas

bradford cross

unread,
Aug 14, 2009, 3:18:56 PM8/14/09
to clo...@googlegroups.com
the serializeability issues also come up with cascading/hadoop.

Chas Emerick

unread,
Aug 16, 2009, 10:17:34 AM8/16/09
to clo...@googlegroups.com
Indeed -- well, the patch file is there in assembla if you need keyword serializability right now.  Otherwise, I can't imagine it'll be long before it's brought into the github HEAD (though I'm certain Rich has more pressing things to handle).

- Chas
Reply all
Reply to author
Forward
0 new messages