Thanks Dave! Seems like different people expect slightly different behavior.
On Friday, January 4, 2013 9:34:38 PM UTC+6, daveray wrote: > > I don't know if it will answer your history question, but there was a > fairly long discussion about this last year: > > > https://groups.google.com/forum/?fromgroups=#!searchin/clojure/let-else/clojure/1g5dEvIvGYY/EWjwFGnS-rYJ > > > Cheers, > > Dave > > On Fri, Jan 4, 2013 at 7:23 AM, Edward Tsech <edt...@gmail.com<javascript:>> > wrote: > > Sorry guys, I forget to mention that it should behave like "let" in > Clojure > > or like "let*" in Scheme. > > > > I mean e.g.: > > (if-let* [x 1 y nil z (inc y)] > > (+ x y z) > > 0) ; => 0 > > ;; (inc y) shouldn't be evaluated here. > > > > Which means "and" doesn't work there. > > In terms of implementation I mean smth like that: > > > > (defmacro if-let* > > ([bindings then] > > `(if-let* ~bindings ~then nil)) > > ([bindings then else] > > (if (seq bindings) > > `(if-let [~(first bindings) ~(second bindings)] > > (if-let* ~(drop 2 bindings) ~then ~else) > > ~else) > > then))) > > > > But anyway I'm more interested in history of that behavior rather than > > implementation. > > Because for me it seems logical if "let" support more than two forms > > "if-let" also could do that. > > And I'd like to understand: "Am I wrong or it's just historical reason?" > > > > Ed > > > > On Friday, January 4, 2013 1:29:41 PM UTC+6, Andy Fingerhut wrote: > >> > >> I don't know the history of the answer to "why", except perhaps as > hinted > >> by Evan's answer, which is that it becomes implicit how to combine the > >> results of the multiple values to get the final true/false for the if > >> condition. You imply "and", which is a perfectly reasonable choice. > >> > >> My main reason for responding is to let you know that if you really > want > >> such behavior, macros let you roll your own without much trouble. > >> > >> Andy > >> > >> On Jan 3, 2013, at 10:24 PM, Edward Tsech wrote: > >> > >> Hey guys, > >> > >> if-let and when-let macros support only 2 forms in binding vector: > >> > >> (if-let [x 1 y 2] > >> ...) > >> java.lang.IllegalArgumentExcepdtion: if-let requires exactly 2 forms in > >> binding vector(NO_SOURCE_FILE:1) > >> > >> Why doesn't "if-let" support any even amount of binding forms as "let" > >> does? > >> > >> e.g. > >> (if-let [x 1 y 2 z 3] > >> (+ x y z) > >> 0) ; => 6 > >> > >> (if-let [x 1 y nil z 3] > >> (+ x y z) > >> 0) ; => 0 > >> > >> Thanks! > >> > >> > > -- > > 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<javascript:> > > 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 <javascript:> > > 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