Thanks James.  So the repl behaves differently from some compiled code - 
good to know!

I don't yet know about the "safe" issues "read-eval".  This came with the 
little template built by lein.  But I'll read up on it.

On Saturday, October 8, 2016 at 10:11:29 PM UTC-4, James Reeves wrote:
>
>
>
> On 9 October 2016 at 03:00, Phil Virgo <pwv...@gmail.com <javascript:>> 
> wrote:
>
>> WHY?  
>>
>> The following prints 1/n 2/n 3/n fine in the repl 
>>
>> (for [f [1 2 3]] (println f))
>>
>> But does nothing in this lein project (the "Hello World???" does print)
>>
>> (ns slide.core
>>   (:gen-class))
>>
>> (defn -main
>>   [& args]
>>   ;; work around dangerous default behaviour in Clojure
>>   (alter-var-root #'*read-eval* (constantly false))
>> (for [f [1 2 3]] (println f))
>>   (println "Hello, World??"))
>>
>
> The "for" macro is lazy. It only evaluates the items in the list when it's 
> consumed. You want the "doseq" macro instead, which is used for 
> side-effects.
>
> Incidentally, setting *read-eval* to false doesn't make clojure.core/read 
> safe. You should always consider clojure.core/read to be unsafe for use 
> with data from sources you don't control. Instead use something like 
> clojure.edn/read, which is designed to be safe.
>
> - James
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to