A man walks into a bar and says "I used lazy evaluation and things were confusing." Bartender says "You mixed it with I/O" without bothering to look at the code. :-)
Your experiment uses pr-str, which uses a dynamically scoped resource *out* in order to create its result. Your observation uses println, which uses the same dynamically scoped resource. Mix in different evaluation strategies, and races can lead to different outcomes. Here is a much smaller example: (pr-str [1 2]) (pr-str (map #(doto % println) [1 2])) So this result is expected. Beware I/O, and in the presence of I/O be very careful in concluding that something is a value. Your quoted-pr-str is not a pure function, and so it does not make values. Regards, Stu On Sat, Sep 13, 2014 at 4:41 AM, cees van Kemenade < cees.van.kemen...@gmail.com> wrote: > > By watching (println) the experiment we influence the outcome. > Is the Schrodinger's cat present in Clojure? > > This example program that shows how printing a value can change the value > under > specific circumstances. It seems the case that it has to do with the lazy > evaluation > that happen in Clojure. Basically I map a pr-str over a list. When I print > the list > before realization it seems that println is modifies the value. > Doing a doall or turning the lazy-list into a vector makes the circumvents > the issue. > > The code showing this behavior is is attached. Loading the file will show > the issue. > I've tested it in Clojure 1.5.1, Clojure 1.6.0. > I also tested it in Clojure-clr 1.5.0, and observed the same issue. > > Please let me know whether this is expected behavior, a known issue, or a > new one. > > Cees. > > -- > 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. > -- 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.