On Nov 19, 11:52 am, Gabi <bugspy...@gmail.com> wrote: > This would solve the "holding to the head" problem. > Many times, lazy-seq would be used without the need to get the same > cell twice. > In this case, avoiding cashing would both enhance performance and more > importantly would avoid OutOfMemoryError Exceptions like in: > > (def r (repeatedly #(rand))) > (last r) > > So, something like: > (defn lazy-seq [should_cache? &body] .. > would be beneficial (I think :)
I can see how that would be useful in some cases, but I think it also would break the contract for seqs. They are supposed to be persistent. I think a stream abstraction was considered at one point, but scrapped in favour of chunked seqs. The solution is simply to avoid defining a global reference to a seq that might grow without bounds. Instead, define a function and just create a new seq every time you want fresh values. -- Jarkko -- 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