There's a patch there but I think it's too simplistic. It should only wrap the body of loop in a function to preserve bindings if other fns are discovered that close over them so as to avoid introducing a perf hit.
David On Thu, Sep 22, 2011 at 8:46 AM, David Nolen <dnolen.li...@gmail.com> wrote: > It's a known issue: > > http://dev.clojure.org/jira/browse/CLJS-39 > > David > > On Wed, Sep 21, 2011 at 2:34 PM, Eric Harris-Braun < > zippy.314....@gmail.com> wrote: > >> Check out this little bit of code: >> >> (doseq [hid ["a" "b" "c"]] >> (goog.dom.appendChild (goog.dom.$ "some-element-id") >> (goog.dom.createDom "div" (.strobj {"id" hid}) (str "Test-"hid))) >> (goog.events.listen (goog.dom.$ hid) goog.events.EventType.CLICK, >> (fn [e] (js/alert hid)))) >> >> What I want it do to is add in a few div's that when clicked on simply >> alert with the value their id value. That doesn't actually happen, >> what happens is that they all alert with the "c" ie. the last value in >> the list. This code, on the other-hand works: >> >> (defn hidfn [hid] >> (fn [e] (js/alert hid)) >> ) >> (doseq [hid ["a" "b" "c"]] >> (goog.dom.appendChild (goog.dom.$ "the-receptor") >> (goog.dom.createDom "div" (.strobj {"id" hid}) (str "Test-"hid))) >> (goog.events.listen (goog.dom.$ hid) goog.events.EventType.CLICK, >> (hidfn hid))) >> >> Shouldn't the clojurescript compiler detect that the usage of "hid" in >> the function in the first case requires the creation of an anonymous >> function to close around that value? Why do I have to do it manually? >> >> -- >> 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 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