On Tue, Sep 4, 2012 at 2:23 PM, Stephen Compall
<stephen.comp...@gmail.com> wrote:
> 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.

But that is a hypothetical, yes? You're not suggesting that take-while
actually does that, right?

> It might mean something somewhere in between.  I am basing
> this only on what the docstring says. [1]

That commit also added "pred must be free of side-effects" to `filter`
and replaced lazy-cons with lazy-seq (which suggests lazy-seq changed
its semantics along the way since (lazy-seq :a [:b]) just yields (:b)
these days but clearly needed to behave more like cons back then?).

I think calling `pred` out of linear order is a far less likely
intended freedom than those of calling `pred` more than once on a
given element or calling `pred` on more elements that strictly needed.
Either way, it's all a bit of a moot point: the docstring says - for
take-while and filter - that the predicate should be free of
side-effects and I think that makes it clear that using a predicate
with side-effects can legally lead to "undesirable" behavior (such as
being called more times than you might expect). So the OP should
consider that possibility in their code.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

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

Reply via email to