Ok, so *if* this is intended behavior, what have people been doing to bind variables dependant on other bindings? I can't be the first to run into this.
Thanks! Brandon On Jul 12, 12:05 am, Tom Faulhaber <tomfaulha...@gmail.com> wrote: > 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- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---