I am deeply puzzled abouth the behavior of *.toString* invocation on a lazy 
sequence.

==> (.getClass (map println (range 100)))
clojure.lang.LazySeq
==> (.toString (map println (range 100)))
*;;* *integers 0..100 printed*
"clojure.lang.LazySeq@590b4b81"

It should be obvious from the output, but for the record: *LazySeq* doesn't 
override *toString*, so just the basic Java method is called. How can this 
possibly cause the sequence to be realized?

Beyond my curiosity, however, what possible purpose could such behavior 
serve?

-marko



On Thursday, March 21, 2013 7:54:39 PM UTC+1, Razvan Rotaru wrote:
>
> Hi,
>
> I'm curious, why doesn't toString of clojure.lang.LazySeq return the 
> entire sequence as a String, and returns the Java pointer instead? I find 
> it annoying when I do this:
>
>
> user> (str (map + [1 2 3]))
> "clojure.lang.LazySeq@7861"
>
>
> What's the reason behind this decision? Shouldn't toString trigger the 
> evaluation of the sequence? Doesn't it do that for other values, like 
> numbers and vectors?
>
> Is there an alternative to the code above (preferably simple and elegant), 
> which will return the etire sequence?
>
>
> Thanks,
> Răzvan
>

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


Reply via email to