== FILE ==
(def x 1) <NEWLINE>
; my comment
==

(str "'(" (slurp "FILE") ")" )

produces:

==
'((def x 1) <NEWLINE>
; my comment)
==

oops.


On Thu, Nov 17, 2011 at 05:32, Andres Gomez <and...@fractalmedia.mx> wrote:
> Thanks for the robustness tip, Meikel.
>
> Just a question, i dont understand what you state, i dont think it
> needs to end in a newline in order to work.
>
> On Nov 16, 5:17 pm, Meikel Brandmeyer <m...@kotka.de> wrote:
>> Hi,
>>
>> 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
>
> --
> 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
>

-- 
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

Reply via email to