> First of all, thanks a lot for ClojureScript. A lot of interesting new stuff > to learn and it has been very educational to read the ClojureScript source > code. > > The following had me scratching my head for far too long. I translated some > quite simple code from the closure book (the one with the bird on the cover) > and I couldn’t get it to work. The problematic part of the program was the > following js function: > > example.main = function() { > var root = goog.dom.getElement('root'); > root.addEventListener('click', example.click, false /* capture */); > root.addEventListener('mouseover', example.mouseover, false /* capture > */); > root.addEventListener('mouseout', example.clearHighlight, false /* capture > */); > }; > > which I translated to: > > (defn ^:export main [] > (let [root (dom/getElement "root")] > (doto root > (.addEventListener 'click' click false) > (.addEventListener 'mouseover' mouseover false) > (.addEventListener 'mouseout' clear-highlight false)))) > > No compile-time errors, warnings or runtime errors. And no events fired. Can > you spot the mistake? It’s kind of a special case but I wonder if it would > be possible for the compiler to generate a warning. It’s a mistake that I > think experienced javascript developers might have a hard time to spot. > > Thanks, > Jonas > > > (The problem, of course, is that ‘click’ is a string in javascript but > evaluates to the symbol click’ in clojurescript so it’s easy to make > copy-paste errors)
Thanks, that's something ClojureScript programmers should watch out for. In Clojure though, one always uses double-quotes for strings because the single quote is a reader macro in Clojure (and other Lisps). TL; DR - Always use double quotes to denote strings in ClojureScript; single quotes have special meaning in Clojure (and hence ClojureScript). Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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