Re: pr-str captures stdout- Is this intentional or a bug?
I think it's an illusion from being lazy ? = (def k (pr-str (vec (for [x (range 5)] (do (pr x) x) 01234 #'datest1.ret/k = k [0 1 2 3 4] On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out.
Re: pr-str captures stdout- Is this intentional or a bug?
actually replacing vec with dorun or doall, would've been a better example :) On Sat, Feb 9, 2013 at 7:42 PM, AtKaaZ atk...@gmail.com wrote: I think it's an illusion from being lazy ? = (def k (pr-str (vec (for [x (range 5)] (do (pr x) x) 01234 #'datest1.ret/k = k [0 1 2 3 4] On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out.
Re: pr-str captures stdout- Is this intentional or a bug?
here's a simpler example: = (map println '(1 2 3)) (1 2 nil 3 nil nil) = (dorun (map println '(1 2 3))) 1 2 3 nil On Sat, Feb 9, 2013 at 7:44 PM, AtKaaZ atk...@gmail.com wrote: actually replacing vec with dorun or doall, would've been a better example :) On Sat, Feb 9, 2013 at 7:42 PM, AtKaaZ atk...@gmail.com wrote: I think it's an illusion from being lazy ? = (def k (pr-str (vec (for [x (range 5)] (do (pr x) x) 01234 #'datest1.ret/k = k [0 1 2 3 4] On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out.
Re: pr-str captures stdout- Is this intentional or a bug?
I agree when you print to stdout you'd expect lazily evaluated output to be mangled in. However, it would seem more natural to me that if you print something to a string it is counter intuitive for incidental writes to stdout to be redirected to the string, as well- There is also nothing in the documentation that suggests this would happen. Also, it would be technically relatively easy to change this. On Saturday, February 9, 2013 12:46:08 PM UTC-6, AtKaaZ wrote: here's a simpler example: = (map println '(1 2 3)) (1 2 nil 3 nil nil) = (dorun (map println '(1 2 3))) 1 2 3 nil On Sat, Feb 9, 2013 at 7:44 PM, AtKaaZ atk...@gmail.com javascript:wrote: actually replacing vec with dorun or doall, would've been a better example :) On Sat, Feb 9, 2013 at 7:42 PM, AtKaaZ atk...@gmail.com javascript:wrote: I think it's an illusion from being lazy ? = (def k (pr-str (vec (for [x (range 5)] (do (pr x) x) 01234 #'datest1.ret/k = k [0 1 2 3 4] On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com javascript:wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out.
Re: pr-str captures stdout- Is this intentional or a bug?
do you mean that, when the string it outputted like: = (println k) (012340 1 2 3 4) nil = (prn k) (012340 1 2 3 4) nil the side effects of evaluating k being mixed into the output could affect you (other than just visually in the repl) ? if ie. you redirect *out* to some file with the purpose of saving and later restoring that? Well, I don't actually like this myself (ever since I've encountered the map println example I've given) but I ignored it because people didn't seem to find it a big deal and nothing I could do about it + it only affected me in viewing REPL output. But I'm not sure if it is clear to you what is happening (perhaps I misunderstand what you're saying), it's only when showing the value of the string (k in this case) that the text shown is mixed, but the value of k is accurate, as seen below: On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) = (= [0 1 2 3 4] k) true On Sat, Feb 9, 2013 at 8:03 PM, Conrad drc...@gmail.com wrote: I agree when you print to stdout you'd expect lazily evaluated output to be mangled in. However, it would seem more natural to me that if you print something to a string it is counter intuitive for incidental writes to stdout to be redirected to the string, as well- There is also nothing in the documentation that suggests this would happen. Also, it would be technically relatively easy to change this. On Saturday, February 9, 2013 12:46:08 PM UTC-6, AtKaaZ wrote: here's a simpler example: = (map println '(1 2 3)) (1 2 nil 3 nil nil) = (dorun (map println '(1 2 3))) 1 2 3 nil On Sat, Feb 9, 2013 at 7:44 PM, AtKaaZ atk...@gmail.com wrote: actually replacing vec with dorun or doall, would've been a better example :) On Sat, Feb 9, 2013 at 7:42 PM, AtKaaZ atk...@gmail.com wrote: I think it's an illusion from being lazy ? = (def k (pr-str (vec (for [x (range 5)] ** (do (pr x) ** x) 01234 #'datest1.ret/k = k [0 1 2 3 4] On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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=enhttp://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+u...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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
Re: pr-str captures stdout- Is this intentional or a bug?
On Sat, Feb 9, 2013 at 8:22 PM, AtKaaZ atk...@gmail.com wrote: do you mean that, when the string it outputted like: = (println k) (012340 1 2 3 4) nil = (prn k) (012340 1 2 3 4) nil the side effects of evaluating k being mixed into the output could affect you (other than just visually in the repl) ? if ie. you redirect *out* to some file with the purpose of saving and later restoring that? Well, I don't actually like this myself (ever since I've encountered the map println example I've given) but I ignored it because people didn't seem to find it a big deal and nothing I could do about it + it only affected me in viewing REPL output. But I'm not sure if it is clear to you what is happening (perhaps I misunderstand what you're saying), it's only when showing the value of the string (k in this case) that the text shown is mixed, but the value of k is accurate, as seen below: On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) = (= [0 1 2 3 4] k) true OOps, I pasted the wrong one here (from the vec form) But looks like I was wrong, and you were correct!! = (def k (pr-str (for [x (range 5)] (do ;(pr x) x #'user/k = k (0 1 2 3 4) = (= (0 1 2 3 4) k) true = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = (= (0 1 2 3 4) k) false On Sat, Feb 9, 2013 at 8:03 PM, Conrad drc...@gmail.com wrote: I agree when you print to stdout you'd expect lazily evaluated output to be mangled in. However, it would seem more natural to me that if you print something to a string it is counter intuitive for incidental writes to stdout to be redirected to the string, as well- There is also nothing in the documentation that suggests this would happen. Also, it would be technically relatively easy to change this. On Saturday, February 9, 2013 12:46:08 PM UTC-6, AtKaaZ wrote: here's a simpler example: = (map println '(1 2 3)) (1 2 nil 3 nil nil) = (dorun (map println '(1 2 3))) 1 2 3 nil On Sat, Feb 9, 2013 at 7:44 PM, AtKaaZ atk...@gmail.com wrote: actually replacing vec with dorun or doall, would've been a better example :) On Sat, Feb 9, 2013 at 7:42 PM, AtKaaZ atk...@gmail.com wrote: I think it's an illusion from being lazy ? = (def k (pr-str (vec (for [x (range 5)] ** (do (pr x) ** x) 01234 #'datest1.ret/k = k [0 1 2 3 4] On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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=enhttp://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+u...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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
Re: pr-str captures stdout- Is this intentional or a bug?
On Sat, Feb 9, 2013 at 8:25 PM, AtKaaZ atk...@gmail.com wrote: On Sat, Feb 9, 2013 at 8:22 PM, AtKaaZ atk...@gmail.com wrote: do you mean that, when the string it outputted like: = (println k) (012340 1 2 3 4) nil = (prn k) (012340 1 2 3 4) nil the side effects of evaluating k being mixed into the output could affect you (other than just visually in the repl) ? if ie. you redirect *out* to some file with the purpose of saving and later restoring that? Well, I don't actually like this myself (ever since I've encountered the map println example I've given) but I ignored it because people didn't seem to find it a big deal and nothing I could do about it + it only affected me in viewing REPL output. But I'm not sure if it is clear to you what is happening (perhaps I misunderstand what you're saying), it's only when showing the value of the string (k in this case) that the text shown is mixed, but the value of k is accurate, as seen below: On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) = (= [0 1 2 3 4] k) true OOps, I pasted the wrong one here (from the vec form) But looks like I was wrong, and you were correct!! = (def k (pr-str (for [x (range 5)] (do ;(pr x) x #'user/k = k (0 1 2 3 4) = (= (0 1 2 3 4) k) true = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = (= (0 1 2 3 4) k) false = (= (012340 1 2 3 4) k) true so it's not exactly like the example that I've given... I'll have to investigate more On Sat, Feb 9, 2013 at 8:03 PM, Conrad drc...@gmail.com wrote: I agree when you print to stdout you'd expect lazily evaluated output to be mangled in. However, it would seem more natural to me that if you print something to a string it is counter intuitive for incidental writes to stdout to be redirected to the string, as well- There is also nothing in the documentation that suggests this would happen. Also, it would be technically relatively easy to change this. On Saturday, February 9, 2013 12:46:08 PM UTC-6, AtKaaZ wrote: here's a simpler example: = (map println '(1 2 3)) (1 2 nil 3 nil nil) = (dorun (map println '(1 2 3))) 1 2 3 nil On Sat, Feb 9, 2013 at 7:44 PM, AtKaaZ atk...@gmail.com wrote: actually replacing vec with dorun or doall, would've been a better example :) On Sat, Feb 9, 2013 at 7:42 PM, AtKaaZ atk...@gmail.com wrote: I think it's an illusion from being lazy ? = (def k (pr-str (vec (for [x (range 5)] ** (do (pr x) ** x) 01234 #'datest1.ret/k = k [0 1 2 3 4] On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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=enhttp://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+u...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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
Re: pr-str captures stdout- Is this intentional or a bug?
So, I basically thought that this is what's happening in your case also (but it's not!): = (map println '(1 2 3)) (1 2 nil 3 nil nil) = (= '(nil nil nil) (map println '(1 2 3))) 1 2 3 true ;so your case is different due to pr-str and pr = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) = (= (012340 1 2 3 4) k) true Sorry for the noise, indeed it seems like pr-str is just redirecting *out* until done using with-out-str. This is certainly much more severe that I thought initially. = (def k (pr-str (for [x (range 5)] (do (pr x) (println nothing) x #'user/k = k (0nothing\r\n1nothing\r\n2nothing\r\n3nothing\r\n4nothing\r\n0 1 2 3 4) = (= (0nothing\r\n1nothing\r\n2nothing\r\n3nothing\r\n4nothing\r\n0 1 2 3 4) k) true This is so bad :) On Sat, Feb 9, 2013 at 8:26 PM, AtKaaZ atk...@gmail.com wrote: On Sat, Feb 9, 2013 at 8:25 PM, AtKaaZ atk...@gmail.com wrote: On Sat, Feb 9, 2013 at 8:22 PM, AtKaaZ atk...@gmail.com wrote: do you mean that, when the string it outputted like: = (println k) (012340 1 2 3 4) nil = (prn k) (012340 1 2 3 4) nil the side effects of evaluating k being mixed into the output could affect you (other than just visually in the repl) ? if ie. you redirect *out* to some file with the purpose of saving and later restoring that? Well, I don't actually like this myself (ever since I've encountered the map println example I've given) but I ignored it because people didn't seem to find it a big deal and nothing I could do about it + it only affected me in viewing REPL output. But I'm not sure if it is clear to you what is happening (perhaps I misunderstand what you're saying), it's only when showing the value of the string (k in this case) that the text shown is mixed, but the value of k is accurate, as seen below: On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) = (= [0 1 2 3 4] k) true OOps, I pasted the wrong one here (from the vec form) But looks like I was wrong, and you were correct!! = (def k (pr-str (for [x (range 5)] (do ;(pr x) x #'user/k = k (0 1 2 3 4) = (= (0 1 2 3 4) k) true = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = (= (0 1 2 3 4) k) false = (= (012340 1 2 3 4) k) true so it's not exactly like the example that I've given... I'll have to investigate more On Sat, Feb 9, 2013 at 8:03 PM, Conrad drc...@gmail.com wrote: I agree when you print to stdout you'd expect lazily evaluated output to be mangled in. However, it would seem more natural to me that if you print something to a string it is counter intuitive for incidental writes to stdout to be redirected to the string, as well- There is also nothing in the documentation that suggests this would happen. Also, it would be technically relatively easy to change this. On Saturday, February 9, 2013 12:46:08 PM UTC-6, AtKaaZ wrote: here's a simpler example: = (map println '(1 2 3)) (1 2 nil 3 nil nil) = (dorun (map println '(1 2 3))) 1 2 3 nil On Sat, Feb 9, 2013 at 7:44 PM, AtKaaZ atk...@gmail.com wrote: actually replacing vec with dorun or doall, would've been a better example :) On Sat, Feb 9, 2013 at 7:42 PM, AtKaaZ atk...@gmail.com wrote: I think it's an illusion from being lazy ? = (def k (pr-str (vec (for [x (range 5)] ** (do (pr x) ** x) 01234 #'datest1.ret/k = k [0 1 2 3 4] On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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=enhttp://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the
Re: pr-str captures stdout- Is this intentional or a bug?
OK, if I follow your posts correctly you now agree with me that this is unpleasant behavior :-) On Saturday, February 9, 2013 1:35:48 PM UTC-6, AtKaaZ wrote: So, I basically thought that this is what's happening in your case also (but it's not!): = (map println '(1 2 3)) (1 2 nil 3 nil nil) = (= '(nil nil nil) (map println '(1 2 3))) 1 2 3 true ;so your case is different due to pr-str and pr = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) = (= (012340 1 2 3 4) k) true Sorry for the noise, indeed it seems like pr-str is just redirecting *out* until done using with-out-str. This is certainly much more severe that I thought initially. = (def k (pr-str (for [x (range 5)] (do (pr x) (println nothing) x #'user/k = k (0nothing\r\n1nothing\r\n2nothing\r\n3nothing\r\n4nothing\r\n0 1 2 3 4) = (= (0nothing\r\n1nothing\r\n2nothing\r\n3nothing\r\n4nothing\r\n0 1 2 3 4) k) true This is so bad :) On Sat, Feb 9, 2013 at 8:26 PM, AtKaaZ atk...@gmail.com javascript:wrote: On Sat, Feb 9, 2013 at 8:25 PM, AtKaaZ atk...@gmail.com javascript:wrote: On Sat, Feb 9, 2013 at 8:22 PM, AtKaaZ atk...@gmail.com javascript:wrote: do you mean that, when the string it outputted like: = (println k) (012340 1 2 3 4) nil = (prn k) (012340 1 2 3 4) nil the side effects of evaluating k being mixed into the output could affect you (other than just visually in the repl) ? if ie. you redirect *out* to some file with the purpose of saving and later restoring that? Well, I don't actually like this myself (ever since I've encountered the map println example I've given) but I ignored it because people didn't seem to find it a big deal and nothing I could do about it + it only affected me in viewing REPL output. But I'm not sure if it is clear to you what is happening (perhaps I misunderstand what you're saying), it's only when showing the value of the string (k in this case) that the text shown is mixed, but the value of k is accurate, as seen below: On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com javascript:wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) = (= [0 1 2 3 4] k) true OOps, I pasted the wrong one here (from the vec form) But looks like I was wrong, and you were correct!! = (def k (pr-str (for [x (range 5)] (do ;(pr x) x #'user/k = k (0 1 2 3 4) = (= (0 1 2 3 4) k) true = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = (= (0 1 2 3 4) k) false = (= (012340 1 2 3 4) k) true so it's not exactly like the example that I've given... I'll have to investigate more On Sat, Feb 9, 2013 at 8:03 PM, Conrad drc...@gmail.com javascript:wrote: I agree when you print to stdout you'd expect lazily evaluated output to be mangled in. However, it would seem more natural to me that if you print something to a string it is counter intuitive for incidental writes to stdout to be redirected to the string, as well- There is also nothing in the documentation that suggests this would happen. Also, it would be technically relatively easy to change this. On Saturday, February 9, 2013 12:46:08 PM UTC-6, AtKaaZ wrote: here's a simpler example: = (map println '(1 2 3)) (1 2 nil 3 nil nil) = (dorun (map println '(1 2 3))) 1 2 3 nil On Sat, Feb 9, 2013 at 7:44 PM, AtKaaZ atk...@gmail.com wrote: actually replacing vec with dorun or doall, would've been a better example :) On Sat, Feb 9, 2013 at 7:42 PM, AtKaaZ atk...@gmail.com wrote: I think it's an illusion from being lazy ? = (def k (pr-str (vec (for [x (range 5)] ** (do (pr x) ** x) 01234 #'datest1.ret/k = k [0 1 2 3 4] On Sat, Feb 9, 2013 at 7:30 PM, Conrad drc...@gmail.com wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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
Re: pr-str captures stdout- Is this intentional or a bug?
For those reading this, the issue is NOT that output in the REPL looks funny. The problem is that if, for instance, you put debug code into a chunk of code that makes use of pr-str your debug code is actually WRITTEN TO THE STRING. This is because pr-str works by using with-out-str. This seems clumsy and is undocumented IMHO and I am wondering if other people feel the same. On Saturday, February 9, 2013 12:30:20 PM UTC-6, Conrad wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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/groups/opt_out.
Re: pr-str captures stdout- Is this intentional or a bug?
these examples to illustrate what you are saying: = (= (debug 1\r\n2 nil 3) (pr-str (lazy-seq (list 2 (println debug 1) 3 true = (= (1\r\n) (pr-str (lazy-seq (println 1 true On Sat, Feb 9, 2013 at 10:57 PM, Conrad drc...@gmail.com wrote: For those reading this, the issue is NOT that output in the REPL looks funny. The problem is that if, for instance, you put debug code into a chunk of code that makes use of pr-str your debug code is actually WRITTEN TO THE STRING. This is because pr-str works by using with-out-str. This seems clumsy and is undocumented IMHO and I am wondering if other people feel the same. On Saturday, February 9, 2013 12:30:20 PM UTC-6, Conrad wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out.
Re: pr-str captures stdout- Is this intentional or a bug?
There's nothing wrong with pr-str. Debug output should go to stderr. user= (def k (pr-str (for [x (range 5)] (do (.println *err* x) (.println *err* nothing) x 0 nothing 1 nothing 2 nothing 3 nothing 4 nothing #'user/k user= k (0 1 2 3 4) On Saturday, February 9, 2013 2:41:23 PM UTC-8, AtKaaZ wrote: these examples to illustrate what you are saying: = (= (debug 1\r\n2 nil 3) (pr-str (lazy-seq (list 2 (println debug 1) 3 true = (= (1\r\n) (pr-str (lazy-seq (println 1 true On Sat, Feb 9, 2013 at 10:57 PM, Conrad drc...@gmail.com javascript:wrote: For those reading this, the issue is NOT that output in the REPL looks funny. The problem is that if, for instance, you put debug code into a chunk of code that makes use of pr-str your debug code is actually WRITTEN TO THE STRING. This is because pr-str works by using with-out-str. This seems clumsy and is undocumented IMHO and I am wondering if other people feel the same. On Saturday, February 9, 2013 12:30:20 PM UTC-6, Conrad wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out.
Re: pr-str captures stdout- Is this intentional or a bug?
this makes it a little more obvious maybe? = (pr-str (seq (println 1))) 1 nil = (= nil (pr-str (seq (println 1 1 true = (pr-str (lazy-seq (println 1))) (1\r\n) = (= (1\r\n) (pr-str (lazy-seq (println 1 true On Sun, Feb 10, 2013 at 1:55 AM, Armando Blancas abm221...@gmail.comwrote: There's nothing wrong with pr-str. Debug output should go to stderr. user= (def k (pr-str (for [x (range 5)] (do (.println *err* x) (.println *err* nothing) x 0 nothing 1 nothing 2 nothing 3 nothing 4 nothing #'user/k user= k (0 1 2 3 4) On Saturday, February 9, 2013 2:41:23 PM UTC-8, AtKaaZ wrote: these examples to illustrate what you are saying: = (= (debug 1\r\n2 nil 3) (pr-str (lazy-seq (list 2 (println debug 1) 3 true = (= (1\r\n) (pr-str (lazy-seq (println 1 true On Sat, Feb 9, 2013 at 10:57 PM, Conrad drc...@gmail.com wrote: For those reading this, the issue is NOT that output in the REPL looks funny. The problem is that if, for instance, you put debug code into a chunk of code that makes use of pr-str your debug code is actually WRITTEN TO THE STRING. This is because pr-str works by using with-out-str. This seems clumsy and is undocumented IMHO and I am wondering if other people feel the same. On Saturday, February 9, 2013 12:30:20 PM UTC-6, Conrad wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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=enhttp://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+u...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out.
Re: pr-str captures stdout- Is this intentional or a bug?
OK, that viewpoint does sound reasonable- Thanks. On Saturday, February 9, 2013 6:55:32 PM UTC-6, Armando Blancas wrote: There's nothing wrong with pr-str. Debug output should go to stderr. user= (def k (pr-str (for [x (range 5)] (do (.println *err* x) (.println *err* nothing) x 0 nothing 1 nothing 2 nothing 3 nothing 4 nothing #'user/k user= k (0 1 2 3 4) On Saturday, February 9, 2013 2:41:23 PM UTC-8, AtKaaZ wrote: these examples to illustrate what you are saying: = (= (debug 1\r\n2 nil 3) (pr-str (lazy-seq (list 2 (println debug 1) 3 true = (= (1\r\n) (pr-str (lazy-seq (println 1 true On Sat, Feb 9, 2013 at 10:57 PM, Conrad drc...@gmail.com wrote: For those reading this, the issue is NOT that output in the REPL looks funny. The problem is that if, for instance, you put debug code into a chunk of code that makes use of pr-str your debug code is actually WRITTEN TO THE STRING. This is because pr-str works by using with-out-str. This seems clumsy and is undocumented IMHO and I am wondering if other people feel the same. On Saturday, February 9, 2013 12:30:20 PM UTC-6, Conrad wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- 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 --- 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+u...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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/groups/opt_out.