I want to be able to read and write a clojure object, which contains
functions, from/to a file.

The structure looks something like this: { :s "my-string" :f (fn[x]
(inc x) }

Reading is easy: (load-file ...) works fine. The tricky part is
writing it back to the file. (pr ...) gives something like this: "{:s
"my-string", :f #<user$fn__895 user$fn__...@2dc62dc6>}" which cannot
be subsequently read.

The only workaround I found is this:
I quote the function in the file (which means that it needs to
explicitly eval-ed when called).
Then, I save it like this:  (assoc my-map :f (cons 'quote (list (my-
map :f))))

Although this works it seems a bit cumbersome. I am pretty sure there
is a better way to do it. Any ideas?


Thanks,
-Itay

PS: This issue has been also mentioned at the  "Persistent storage"
discussion last week.






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to