Re: Serializing Clojure objects

2008-12-03 Thread Rich Hickey
On Tue, Dec 2, 2008 at 6:38 PM, Chouser <[EMAIL PROTECTED]> wrote: > > On Tue, Dec 2, 2008 at 3:52 PM, Mark Volkmann <[EMAIL PROTECTED]> > wrote: > > > > (def my-string (print-dup [1 2 3])) > > (def my-data (read my-string)) > > > > Can you give a simple example of serializing and deserializing a

Re: Serializing Clojure objects

2008-12-02 Thread Chouser
On Tue, Dec 2, 2008 at 3:52 PM, Mark Volkmann <[EMAIL PROTECTED]> wrote: > > (def my-string (print-dup [1 2 3])) > (def my-data (read my-string)) > > Can you give a simple example of serializing and deserializing a > Clojure collection? For "serializing" you have a couple options: (def my-string

Re: Serializing Clojure objects

2008-12-02 Thread Mark Volkmann
On Tue, Dec 2, 2008 at 12:52 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > On Dec 2, 7:02 am, Parth Malwankar <[EMAIL PROTECTED]> wrote: >> Tayssir John Gabbour wrote: >> > Hi! >> >> > How should I approach serialization? I made a little test function >> > which serializes and deserializes Clojur

Re: Serializing Clojure objects

2008-12-02 Thread Parth Malwankar
On Dec 2, 11:52 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > As part of AOT I needed to enhance print/read to store constants of > many kinds, and restore faithfully. This led to a new multimethod - > print-dup, for high-fidelity printing. You can get print-dup behavior > by binding *print-dup*:

Re: Serializing Clojure objects

2008-12-02 Thread Rich Hickey
On Dec 2, 7:02 am, Parth Malwankar <[EMAIL PROTECTED]> wrote: > Tayssir John Gabbour wrote: > > Hi! > > > How should I approach serialization? I made a little test function > > which serializes and deserializes Clojure objects. It works for > > strings, integers, symbols, LazilyPersistentVectors

Re: Serializing Clojure objects

2008-12-02 Thread Jeff Rose
I've been working on the same issue. So far it has mostly been just researching various options, but I can give you my two cents... It really depends on your goals and constraints. I have narrowed down to two major families of serialization for storage and networking. One is the JSON/YAML/X

Re: Serializing Clojure objects

2008-12-02 Thread Tayssir John Gabbour
JBossSerialization looks nifty, though I haven't tried it yet: http://www.jboss.org/serialization/ Thanks to everyone who responded! (I've just been immersing myself in Externalizable, object versioning, etc; and your thoughts have been helpful.) All best, Tayssir On Dec 2, 9:57 am, Tayssir J

Re: Serializing Clojure objects

2008-12-02 Thread Dakshinamurthy Karra
Don't forget XMLEncoder/XMLDecoder. They come in pretty handy when you want to serialize objects that (already) follow bean conventions. -- KD Dakshinamurthy Karra (blog: http://blog.marathontesting.com) (daily dose: http://twitter.com/marathontesting) On Tue, Dec 2, 2008 at 4:06 PM, Tayssir

Re: Serializing Clojure objects

2008-12-02 Thread Parth Malwankar
Tayssir John Gabbour wrote: > Hi! > > How should I approach serialization? I made a little test function > which serializes and deserializes Clojure objects. It works for > strings, integers, symbols, LazilyPersistentVectors and.. oddly.. > PersistentHashMaps that have exactly one element. (My C

Re: Serializing Clojure objects

2008-12-02 Thread Tayssir John Gabbour
Interesting, thanks for the new perspective! Using YAML seems more flexible than what I was thinking, particularly since Clojure apparently doesn't make me worry too much about the specific kind of sequence/map I'm using. (Yeah, I have an app which sends serialized objects all over the place, and

Re: Serializing Clojure objects

2008-12-02 Thread Luc Prefontaine
I use YAML to serialize. I needed a simple way to pass Maps, Lists and Vector between java, Ruby and Clojure components. I change the classes of Clojure in the YAML output to java.util.Map, List and so on to remove dependencies on Clojure classes while retaining the ability to walk through the str

Re: Serializing Clojure objects

2008-12-02 Thread Tayssir John Gabbour
On Dec 2, 9:57 am, Tayssir John Gabbour <[EMAIL PROTECTED]> wrote: > (defn my-identity "Copies obj through serialization and > deserialization." > [obj] > (let [byte-out (new java.io.ByteArrayOutputStream) > obj-out (new java.io.ObjectOutputStream byte-out)] > (try (.writeObject o

Serializing Clojure objects

2008-12-02 Thread Tayssir John Gabbour
Hi! How should I approach serialization? I made a little test function which serializes and deserializes Clojure objects. It works for strings, integers, symbols, LazilyPersistentVectors and.. oddly.. PersistentHashMaps that have exactly one element. (My Clojure is about a month old.) But for ot