Looking at the clojure docs, it doesn't appear to be defined whether binding is a parallel (all vars are computed based on the initial state) or sequential (vars are computed using the new values for vars used in the same binding vector). A quick test shows that it appears to be parallel:
(binding [a 1 b a] [a b]) => [1 nil] Reviewing the implementation in clojure.contrib makes it seem that is indeed true. It looks like all of the new values for the binding forms are computed before the pairs are added to a hash that is sent to pushThreadBindings. Whether this is the desired behavior is another question entirely. In any case, the fact that it is not documented seems like a bug, especially since this behavior is different from let (as you point out). Tom On Jul 11, 9:01 pm, bgray <graybran...@gmail.com> wrote: > Is this behavior expected from binding? > > user=> (def a nil) > #'user/a > user=> (def b nil) > #'user/b > user=> (binding [a 1 b (+ a 1)] a) > java.lang.NullPointerException (NO_SOURCE_FILE:0) > user=> (binding [a 1 b (+ a 1)] b) > java.lang.NullPointerException (NO_SOURCE_FILE:0) > user=> (let [a 1 b (+ a 1)] a) > 1 > user=> (let [a 1 b (+ a 1)] b) > 2 > > Thanks, > Brandon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---