On Tue, 2012-09-04 at 09:48 -0700, Sean Corfield wrote: > Stephen, could you elaborate on this?
Requiring pred to be free of side effects provides many invariants about it to the `take-while' implementation; the legality of out-of-order calling is just one of them. > My reading of the side-effect-free restriction was just that the > predicate may be called on more elements than end up in the result, > perhaps due to chunking or whatever. I don't know what the original intent of the docstring was. Perhaps it was merely written that way because it was shorter; perhaps a precise explanation of how pred would be called was considered too much for doc purposes. It might mean something somewhere in between. I am basing this only on what the docstring says. [1] I can imagine a few alternative `take-while's that could effectively exploit out-of-order calling. [2] But even aside from reordering, I can't even name every potentially useful freedom we have given `take-while' by making pred pure, much less every way of using those freedoms. I cannot say what new ideas may be incorporated into take-while in the future by taking advantage of purity. But I _can_ imagine my frustration, painstakingly tracking down bugs in my own software, induced by nothing but my own failure to follow this documented contract as a take-while caller. > or is just one of those 'guilty by omission' situations? If that is what you mean by this, then yes. [1] I can, however, say that the documented invariant was added in Rich Hickey's a8307cc8, back in 2008. [2] Describing such examples would be rather esoteric for this thread, I feel. -- Stephen Compall "^aCollection allSatisfy: [:each | aCondition]": less is better than -- 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