HI, On Sat, Nov 8, 2008 at 2:39 PM, verec <[EMAIL PROTECTED]> wrote:
> But then why would we want any of `doseq', `dotimes' or `doall', and > if we do, is that set complete, and with respect to what design > principle? Well, given loop/recur as a fundamental iteration form, and doall as a mechanism for forcing evaluation of the spine of a sequence, I'd say that loop/recur + doall could be used to build all the other forms. (I realize I mis-spoke in my earlier message by saying that loop/recur and reduce could be equated. That's not true, since loop/recur allows for short-circuiting, and does not require a sequence as one of its "arguments". So loop/recur is more general than reduce. Sorry about that.) I think we want a variety of forms for the same reason Common Lispers want DOTIMES, LOOP, etc. -- pragmatism. > For example, CL provides `do-symbols', `do-all-symbols' or `with- > package-iterator' as "external" iterators. > > Clojure decided that anything that could be expressed as a `seq' could > be iterated over using `doseq', so I can express the equivalent of > CL's (do-symbols ...) using clojure (doseq [n all-ns] ....) Yes, exactly -- abstract sequences are a super idea, and make a lot of special-case procedures unnecessary. > To rephrase the question differently, what could exist that is not a > clojure `seq' that we would want to iterate over? > > Clojure already answers this (partially?) by providing (dotimes ...) > (as CL does) to iterate over a zero based consecutive and finite > sequence of numbers. Though the same (dotimes ...) could be _used_ to > iterate over any finite range) I'd argue that dotimes iterates, but doesn't iterate *over* anything -- there's no Clojure sequence involved. > What are the things that one could iterate over, for which clojure > does not, currently, provide special cases à la `doseq' or 'dotimes' ? Not special cases -- dotimes doesn't traverse a sequence, and doseq can be thought of as a "map" that is evaluated immediately, for side-effects, and which discards the result of the map. (Like for-each in Scheme, compared with map in Scheme -- the former is for side-effects, the latter to produce a transformed list.) Clojure's concept of the 'seq' as the object of traversal, rather than a literal type (list, vector, etc.) is its fundamental genius, IMHO. Best, Graham --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
