"use" = "rely on" In your example, func relies on a variable which is (presumably, based on its use in other-func) intended for dynamic binding. Therefore, func is impure.
It is idiomatic to name such variables with earmuffs, e.g. *forty-two*. Stu > On 17 July 2010 23:57, Laurent PETIT <laurent.pe...@gmail.com> wrote: >> Hi, >> >> 2010/7/17 Paul Richards <paul.richa...@gmail.com> >>> >>> The "Programming Clojure" book states: "Functions that use dynamic >>> bindings are not pure functions.." (P2.0, page 174). >>> >>> I do not understand why this must be the case, can someone explain why? >> >> Because then the result of the function does not *only* depend on its input >> arguments. >> > > Hm, I'm still a little confused.. > > Are you saying that if a function make use of any value which is def'd > from outside, then it is not pure functional? > > In this small example: > > (def forty-two 42) > > (defn func [] (* forty-two forty-two)) > > (defn other-func [] (binding [forty-two 6] (func))) > > > In this example, which of these functions would be considered side > effect free, and which would be considered pure functional? Is it the > case that both are side effect free, but only "other-func" is pure? > (This would seem to go against what the book says) > > According to the book "other-func" is impure (since it uses "binding" > - aka dynamic bindings).. Yet in this example it seems more pure than > "func". > > > -- > Paul Richards > @pauldoo > > -- > 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 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