partial returns a closure, closing over a at the time b is defined. On Wed, Jul 18, 2012 at 7:18 AM, Alice <dofflt...@gmail.com> wrote: > I'm reading Clojure Programming from O'Reilly. > > (defn a [b] (+ 5 b)) > ;= #'user/a > (def b (partial a 5)) > ;= #'user/b > (b) > ;= 10 > (defn a [b] (+ 10 b)) > ;= #'user/a > (b) > ;= 10 > > Redefining a has no effect. But, > > (defn foo [] 1) > ;= #'user/foo > (defn bar [] (foo)) > ;= #'user/bar > (bar) > ;= 1 > (defn foo [] 2) > ;= #'user/foo > (bar) > ;= 2 > > Shouldn't this also be the same? Why does (bar) evaluates 2 instead of > 1 this time? > > -- > 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