ClojureScript 101
21–30 of 45 posts
Re: ClojureScript 101
#22Hey swannodette, just curious about why you ended the tag in your tutorial. Was this deliberate?
Anyway, I thought this was great, so I tried doing it inside of a go block, like so: (go (while true) (. js/console (log (And this yielded a compiler warning: WARNING: Use of undeclared Var async-tut1.core/log at line 50 src/async_tut1/core.cljs
So there seems to be a problem with namespace resolution and the go macro? Or maybe a bug with "." in particular? Works fine when I do (.log js/console (Either way, I would try to be consistent about your notation throughout the article. Either use (.log js/console ...) or use (. js/console (log ...)).
Core.async in the browser is a ton of fun otherwise! Kudos.
Re: ClojureScript 101
#23Hey swannodette, just curious about why you ended the tag in your tutorial. Was this deliberate?
Hmm, I seem to have found a limitation/bug in go blocks. I didn't know about the nifty "." syntax for calling methods on js objects, eg: (. js/console (log "hi")). Anyway, I thought this was great, so I tried doing it inside of a go block, like so: (go (while true) (. js/console (log ( And this yielded a compiler warning: WARNING: Use of undeclared Var async-tut1.core/log at line 50 src/async_tut1/core.cljs So there…
Re: ClojureScript 101
#24Hey swannodette, just curious about why you ended the tag in your tutorial. Was this deliberate?
Hmm, I seem to have found a limitation/bug in go blocks. I didn't know about the nifty "." syntax for calling methods on js objects, eg: (. js/console (log "hi")). Anyway, I thought this was great, so I tried doing it inside of a go block, like so: (go (while true) (. js/console (log ( And this yielded a compiler warning: WARNING: Use of undeclared Var async-tut1.core/log at line 50 src/async_tut1/core.cljs So there…
(go (while true) (. js/console log (<! clicks)))
Re: ClojureScript 101
#25Re: ClojureScript 101
#26Recreated in pure js with ES6 generators — http://andreypopp.com/posts/2013-11-09-recreating-core-async...
Re: ClojureScript 101
#27Since this is supposed to be a 101 tutorial, could you please add (maybe in a later episode) some info on debugging and on parsing the stack trace. When I add the text 1+" to core.clsj and have auto compile running, I get a gigantic stack trace but none of the entries points me to the line where the error occured. I wonder how people are supposed to handle a code base bigger than a few lines of code and I stop follow…
The top few lines of the stack trace have the most information. Entering some blank space or clearing your terminal will make it easier to find the top.
The errors are often caught way down in Java land so you can be left trying to map Java errors and types into your own code - I've learned to ignore 80%+ of the trace for this reason.
There's a bit of a learning curve to figure out what this can't be cast to that might mean, both for Java types and Clojure types. For example a missing opening paren may give a (roughly) "number can't be cast to sequence" error. A missing closing paren will generally throw an End Of File (EOF) error.
A lot of the time you can get a line number from the top entry in the stack trace, they'll be in parentheses and aren't labeled terribly well - but once you find it once you'll know where it is forever.
Sometimes, in certain situations - especially with macros that call across files (like for testing) - the stack trace might be completely unhelpful.
I'm definitely hopeful that this situation will improve in the future (and maybe we can get an Edwin style debugger? Please?) In the meantime we can use tools to help us at least keep our braces organized since that's half the difficult to trace problems right there. For Emacs some swear by paredit, I'm still working on my system but it includes electric-parens, rainbow-parens (so helpful!) and auto-closing parens.
Also, it's not as robust as Emacs but Lighttable offers some decent parentheses handling out of the box (I went back to Emacs after Lighttable was making connections to outside servers that I at least didn't mean to ask it to and didn't have time to deal with. Other than that Lighttable was great).
Re: ClojureScript 101
#28Since this is supposed to be a 101 tutorial, could you please add (maybe in a later episode) some info on debugging and on parsing the stack trace. When I add the text 1+" to core.clsj and have auto compile running, I get a gigantic stack trace but none of the entries points me to the line where the error occured. I wonder how people are supposed to handle a code base bigger than a few lines of code and I stop follow…
Re: ClojureScript 101
#29Hey swannodette, just curious about why you ended the tag in your tutorial. Was this deliberate?
Hmm, I seem to have found a limitation/bug in go blocks. I didn't know about the nifty "." syntax for calling methods on js objects, eg: (. js/console (log "hi")). Anyway, I thought this was great, so I tried doing it inside of a go block, like so: (go (while true) (. js/console (log ( And this yielded a compiler warning: WARNING: Use of undeclared Var async-tut1.core/log at line 50 src/async_tut1/core.cljs So there…