Until recently I was using the following snippet for writing a map on a
file...basically I was using spit/slurp. Nothing easier
(defn data-string
Writes the object b on a file f on disk as a string.
[b fname]
(io! (spit fname b)))
(defn string-data
Read the file f back on memory safely (#=
*print-dup* tries to preserve type information. That's why it emits
constructor functions with #=.
You can still use 'pr' with *print-dup* set to false, which is the default.
You get machine-readable data of the correct abstract type, e.g.
list/vector/map/set, but you lose type information
aaa ok I see...
so I can have my cake and eat it too? :-)
I'm just surprised cos slurp/spit has never failed me before and I've
tried with maps, vectors lists but everyone is suggesting it is wrong
practice...
anyway, thanks for taking the time...
Jim
On 20/11/12 19:58, Stuart Sierra
`spit` calls `str` on its argument, which has the same behavior as `print`
or `println` with regard to quoting strings:
user= (println I say, \Hello, World!\)
I say, Hello, World!
nil
To preserve data in its `read`able form, you need `pr` or `prn`:
user= (prn I say, \Hello, World!\)
I say,