On Sun, Nov 29, 2009 at 11:09:00PM -0800, David Brown wrote: >All of the persistent classes in Clojure, including continuations >claim to implement Serializable. Not sure how well it actually works, >but if implemented, it should be possible to send a closure even to a >different machine.
Playing with this a little, at least my simple test cases seem to work, but only for function defined in AOT code. If it's dynamically written code, the readObject raises a ClassNotFoundException. However, things like hash maps, vectors, and lists raise exceptions about not being serializable, so it's not really all that useful. It'd be an interesting project. The persistent types should be fairly easy to serialize. Using mutable things wouldn't work, though. David ;;; This example only works if the code is AOT compiled. (ns play (:import [java.io ObjectOutputStream FileOutputStream ObjectInputStream FileInputStream])) (defn ww [thing] (with-open [fd (ObjectOutputStream. (FileOutputStream. "sample.bin"))] (.writeObject fd thing))) (defn rr [] (with-open [fd (ObjectInputStream. (FileInputStream. "sample.bin"))] (.readObject fd))) (defn incer [x] (fn [y] (+ x y))) ; Write a function out. ;(ww (incer 10)) ; Exit the session, restart, and load the function back in and execute ; it. ;((rr) 8) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en