Don't call filter for side effects, don't rely on when side effects will or will not happen, but yeah, your filter predicate can have side effects. On Wed, Sep 2, 2015 at 9:13 AM James Elliott <brunch...@gmail.com> wrote:
> Indeed, that would make sense for filter, but since filterv immediately > puts them all into a vector, I was particularly puzzled by the warning on > its doc string. > > In my case I am not relying on the side effects for anything, I merely > cannot guarantee there are none (and even if chunking were an issue, the > list is immediately fully consumed). So I tentatively think I am ok, but it > is still an unsettling warning. > > > On Wednesday, September 2, 2015 at 11:06:01 AM UTC-5, Raymond Huang wrote: > >> I believe the reason it's not recommended is because it returns a lazy >> chunked sequence. This means that it's not guaranteed to eagerly perform >> your side-effects, unless you wrap it in `doall`. >> > On Wed, Sep 2, 2015 at 8:48 AM, James Elliott <brun...@gmail.com> wrote: >> > I notice that the documentation for filter and filterv are emphatic that >>> the predicate you are using be free of side effects. Why is that so? For >>> example, I would like to use filterv to collect a list of lighting >>> effects which respond false to a protocol method which asks whether >>> they have finished. In the implementation of that method, the effects are >>> free to update their internal state based on the current show state and >>> time, when deciding whether or not they are finished, and so I can’t >>> guarantee there will be no side effects while filtering the effects. Does >>> that mean I can’t use filterv? If not, why not? Looking at the source, >>> I see no obvious problems. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> >> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. >> >> >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > 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. > -- 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.