load-node and store-node are custom functions that rely on two other custom
functions serialize and deserialize:
(defn serialize
"Serializes value, returns a byte array."
[v]
(let [buff (java.io.ByteArrayOutputStream. 1024)]
(with-open [dos (java.io.ObjectOutputStream. buff)]
(.writeObject dos v))
(.toByteArray buff)))
(defn deserialize
"Accepts a byte array, returns deserialized value."
[bytes]
(with-open [dis (java.io.ObjectInputStream.
(java.io.ByteArrayInputStream. bytes))]
(.readObject dis)))
On Saturday, April 7, 2012 4:50:00 PM UTC+1, Aaron Cohen wrote:
>
> On Sat, Apr 7, 2012 at 11:41 AM, Steven Obua wrote:
>
>> ------------------------------------------------------------------------------------------------------------------------------(defrecord
>>
>> M-Node [leaf content])
>>
>> (def n (M-Node. false ""))
>>
>> (if (:leaf n) "boom" "ok") ;; returns "ok"
>>
>> (def n (load-node (store-node n))) ;; load-node and store-node are just
>> java serialization/deserialization
>>
>>
> Where is load-node coming from? It should be canonicalizing booleans when
> it deserializes, or else it's buggy.
>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en