Clojure is quite elegant, but it's not always unsurprising. Even if one surprising behavior around lazy-seq realization is changed, others are likely to continue to occur.
The solution to this is to not write code that implicitly relies on a specific timing of lazy realization. If you need results to be calculated in a certain scope, force them, and if you need results to be maximally lazy in order to have correct code, then either force results not to chunk (there are code examples for a "dechunk" function on the net) or refactor to a form that doesn't rely on maximal laziness for correctness. As far as I know, chunked sequences are not likely to leave the language any time soon, and the behavior we see here will inevitably happen with chunked inputs. On Thursday, February 12, 2015 at 7:28:13 PM UTC-8, Jorge Marques Pelizzoni wrote: > > Anyway, I would be in awe that being Closure such an expressive and > elegant language its user base is really ok with an state of affairs in > which: > > (def primes (cons 2 (lazy-seq (filter #(prime? primes %) (drop 3 > (range)))))) > > does not mean what it obviously should and above all means something > different from: > > (def primes (cons 2 (lazy-seq (filter #(prime? primes %) (iterate inc > 3))))) > > YES. I've just found out that it is (drop 3 (range)) that makes a > difference there. > > Even this will not work anymore: > > (def primes (cons 2 (for [n (drop 3 (range)) :when (prime? primes n)] n))) > > I really hope the actual developers of the language feel differently. At > least there's evidence to support that. > > Cheers, > > Jorge. > > Em sexta-feira, 13 de fevereiro de 2015 00:39:03 UTC-2, Justin Smith > escreveu: >> >> Considering for the sake of argument the possibility that it is a >> legitimate bug, and not a result of misusing the language features, it is a >> family of bug that will be more common than most, because it reflects a >> style of programming that is rare in real Clojure code. >> >> But it isn't a bug. >> >> >>>> -- 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.