2009/1/26 Stephen C. Gilardi <squee...@mac.com> > > On Jan 25, 2009, at 5:51 PM, wubbie wrote: > > I saw dorun and doall in core.clj as follows: > That is, doall just calls dorun. > My question is, how come doall does force eval and dorun does not. > thanks in advance, > > > Both force evaluation. Immediately before either returns, there is a fully > realized sequence in memory. >
Are you sure ? I think the point of dorun is to prevent this case : with dorun, the elements of the sequence can be garbage collected once dorun goes on with the rest of the sequence, thus preventing to blow up the memory. > > The difference is in their return value: > > - dorun returns nil. A call to dorun indicates: > > "all the work I want done is done in the evaluation of the elements of the > sequence, I don't plan to work with the entire sequence after it's realized" > > - doall returns the head of the realized sequence. A call to doall > indicates: > > "not only do I want the entire sequence realized, I also want to use the > resulting sequence subsequently" > > It's good form to save or otherwise use the value returned by doall. > > --Steve > > --~--~---------~--~----~------------~-------~--~----~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---