Clojure's sequences are lazy - but is there anything that guarantees *how* lazy they are?
To give a concrete example - given an infinite lazy sequence of promises: (def promises (repeatedly promise)) If, in one thread I do: (doseq [p (map deref promises)] (println p)) And in another thread, I call deliver on various elements of promises, will promises always be printed as soon as they're available? Or can things block for longer than they theoretically might because a later (undelivered) promise in the sequence is being realized? I've been doing some experiments, and in practice the above works just fine - promises are printed as soon as they theoretically might be. If, however, I put a "flatten" in place of the map then I seem to have to deliver one more promise before the first is printed. What I'm interested in here aren't practicalities. I'm interested in what Clojure and its libraries guarantee (if anything) about laziness. Is there an upper bound on how much of a sequence will be realized? -- paul.butcher->msgCount++ Snetterton, Castle Combe, Cadwell Park... Who says I have a one track mind? http://www.paulbutcher.com/ LinkedIn: http://www.linkedin.com/in/paulbutcher MSN: p...@paulbutcher.com AIM: paulrabutcher Skype: paulrabutcher -- -- 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.