Just to confirm, (t2 0 (range 1000000)) -- using doseq instead of dorun -- does NOT run out of memory, correct?
On Wed, Sep 11, 2013 at 8:59 AM, Brian Craft <craft.br...@gmail.com> wrote: > This appears to have no effect on the problem. I tested with > jdbc/transaction, and with Sean's simple example: > > user=> (defn f [g] (g)) > #'user/f > user=> (defn t1 [n c] (f (fn [] (dorun (map identity c))))) > #'user/t1 > user=> (t1 0 (range 1000000)) > java.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0) > user=> (defn t2 [n c] (f (fn [] (doseq [x c] (identity x))))) > #'user/t2 > user=> (defn t1 [n c] (f (^:once fn* [] (dorun (map identity c))))) > #'user/t1 > user=> (t1 0 (range 1000000)) > java.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0) > > > > On Wednesday, September 11, 2013 7:39:48 AM UTC-7, Christophe Grand wrote: >> >> ^:once on fn* (not fn, the fn macro doesn't propagate metadata) instructs >> the commielr to clear closed-overs ASAP. It follows that you can't call such >> a function twice because it forgets its closed-overs. >> >> >> On Wed, Sep 11, 2013 at 4:36 PM, Brian Craft <craft...@gmail.com> wrote: >>> >>> ugh. Can't find documentation for this. What does it do? >>> >>> On Wednesday, September 11, 2013 2:22:56 AM UTC-7, Christophe Grand >>> wrote: >>>> >>>> >>>> On Wed, Sep 11, 2013 at 6:00 AM, Brian Craft <craft...@gmail.com> wrote: >>>>> >>>>> (defmacro transaction >>>>> [& body] >>>>> `(transaction* (fn [] ~@body))) >>>>> >>>>> I'm not sure how to avoid that. The anonymous function created here >>>>> doesn't take parameters. >>>> >>>> >>>> The fix for this is: >>>> (defmacro transaction >>>> [& body] >>>> `(transaction* (^:once fn* [] ~@body))) >>>> >>>> It should be the default for all one-shot fns. >>>> >>>> Christophe >>>> >>>> -- >>>> On Clojure http://clj-me.cgrand.net/ >>>> Clojure Programming http://clojurebook.com >>>> Training, Consulting & Contracting http://lambdanext.eu/ >> >> >> >> >> -- >> On Clojure http://clj-me.cgrand.net/ >> Clojure Programming http://clojurebook.com >> Training, Consulting & Contracting http://lambdanext.eu/ > > -- > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.