On Fri, Nov 7, 2008 at 4:22 PM, James Reeves <[EMAIL PROTECTED]> wrote: > > A few questions. First, isn't the syntax for dotimes: > > (dotimes i 10 > (prn i))
You're absolutely right. Sorry about that. > And in which case, your vector syntax could be misleading, because it > seems to imply you're assigning i to 10: > > (dotimes [i 10] > (prn i)) Vectors are also used for "for": (for [i (range 10)] (* 2 i)) Here i is not bound to the seq (range 10) but to each of the numbers in turn. While on the other hand, "let" and "binding" indeed only bind to the specified value. So the vector syntax itself doesn't give you enough information, you need to look at the macro name too. If the macro is named "dotimes" don't expect it to bind to just the final value. > Second, with your patch, is the following valid: > > (doseq [i (range 10) > j (range 10)] > (prn i) > (prn j)) > > And if it is, what does it do? Does it iterate through all > permutations of i and j, or does it zip i and j together? It behaves the same as "for" does, that is with j in an inner loop. It also supports :while and :when as "for" does. > Third, even if doseq allows for multiple local vars, you'd still have > problems with when-let and if-let. For instance: > > (when-let [x (foo) > y (bar)] > (prn x) > (prn y)) > > Under what conditions is the body evaluated? If x OR y is true, or if > x AND y is true, or if the last value of the let clause, y, is true? Currently everything after (foo) in your example is ignored, but that doesn't seem very good. My first inclination is to disallow it -- add a check to make sure only one binding pair is given. Alternatively it could act as if it were nested, as "for" (and now "doseq") do, in which case it would act like an "and", and both x and y would be bound to non-false values. --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---