These are excellent tips. On Sun, Nov 9, 2014 at 4:46 PM, Asim Jalis <[email protected]> wrote: > Hi Glenn, > > I ran into that problem several times. Initially I just gave up. In a second > iteration I tried to debug the problem by reducing program to get a minimal > repro of the issue. This proved to be a great learning experience. Here are > the issues I discovered: > > 1. A big source of problems was the :optimizations :advanced. Disabling this > started producing much more readable messages. > > 2. To use jQuery and other external libraries in the browser I needed to > declare them using :externs in the project.clj. > > 3. To use macros in ClojureScript I had to use :require-macros inside (ns > foo) instead of :require. > > By avoiding these gotchas I have been able to avoid the cryptic “TypeError: > Cannot call method 'call' of undefined”. > > The upshot is that it does get better. Just hang in there. > > Good luck! > > Asim > > > On Sun, Nov 9, 2014 at 11:07 AM, Glen Mailer <[email protected]> wrote: >> >> Hi Everyone, >> >> I'm new to ClojureScript, but I've been doing Clojure for a while, and >> this was something that's been catching me out a lot. >> >> In Clojure, attempts to use an undefined var result in a compiler error, >> whereas in CLJS they are left to fail at runtime. Presumably this is to play >> nicely with the more dynamic JavaScript environment. >> >> However, because function calls expand to >> >> namespace.whatever.func.call(null, //... >> >> Then if i've typoed my function call or mixed something up somewhere, I >> get the rather cryptic >> >> TypeError: Cannot call method 'call' of undefined >> >> >> I'm finding this is especially awkward if i'm passing functions around or >> there's a few invocations on the same line, and it's not obvious which one >> of the function calls is actually the bad one. >> >> >> >> Is this something that happens less once you get used to ClojureScript? >> Are there some tricks I can do to avoid making these mistakes? >> Would it be possible to tweak the compiler to warn about undefined "var" >> usage? >> If compile-time warnings are too restrictive, would it be possible to have >> a compilation mode where i get something like >> safeCall(namespace.whatever.func, "namespace.whatever.func", // .... >> which can tell me what the invocation looked like that failed? >> >> >> >> I hope that makes sense! >> >> Cheers >> Glen >> >> -- >> Note that posts from new members are moderated - please be patient with >> your first post. >> --- >> You received this message because you are subscribed to the Google Groups >> "ClojureScript" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/clojurescript. > > > -- > Note that posts from new members are moderated - please be patient with your > first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/clojurescript.
-- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
