FWIW, Brian and I were looking at this off-list and we changed (dorun (map identity matrix)) to (doseq [x matrix] (identity x)) and that seemed to work just fine - even in Brian's more complicated case. Given that dorun specifically says it doesn't hold on to the head, I would have expected the two to behave identically.
I also suspected the closure over the matrix argument as being the root cause but was puzzled when using doseq instead made the problem go away... Sean On Tue, Sep 10, 2013 at 7:34 PM, Armando Blancas <abm221...@gmail.com> wrote: >> Can anyone explain to me what's happening here? Something about creating a >> anonymous function? > > > The problem is not creating the anonymous function but that it closes over > the matrix argument. The closure passed on to blah will keep a reference to > matrix until blah returns. This won't happen if the anonymous function takes > the matrix as a parameter: > > (defn blah [func v] (func v)) > (defn load-exp [matrix] > (blah > (fn [m] (dorun (map identity m))) matrix)) > > > -- > -- > 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.