Am 16.11.2011 um 17:17 schrieb Andres Gomez:
> It is very simple, its most important function is: (defn read-file
> [name] (eval (read-string (str "'(" (slurp name) ")"))))
As a minor nitpick to promote robust code… Please use something like this for reading:
(let [eof (Object.)] (take-while (complement #{eof}) (repeatedly #(read file-reader false eof))))
(str "(" ...) is so ugly and fragile. There are many files which do not end in a newline. And if the last line is a comment…
Sincerely
Meikel
(str "'(" (slurp "FILE") ")" )
produces:
==
'((def x 1) <NEWLINE>
; my comment)
==
oops.
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>