teach duck-streams to read clojure forms
I'd like an easy way to consume a text file written in Clojure syntax as pure data: as a sequence of Clojure data structures without evaluation. This allows Clojure to be used where property files, XML or JSON might otherwise be chosen.
Leave a comment
on 2010-04-13 00:06 *
By technomancy
You can do this by composing read-string and slurp*, is that good enough?
Well, more-or-less. The intent of my patch was to allow a file containing multiple forms to be read lazily (i.e. one form at a time). The (read-string (slurp* x)) solution is eager.
That said, I'd like to withdraw the patch because I'm not really happy with the fact that the implementation fails to close the underlying file if the sequence is not consumed fully. (This is a more general problem with lazy sequences based on resources not managed by the GC.)
That said, I'd like to withdraw the patch because I'm not really happy with the fact that the implementation fails to close the underlying file if the sequence is not consumed fully. (This is a more general problem with lazy sequences based on resources not managed by the GC.)