hi, is core.async supported on planck? I am getting namespace not found on cljs.core.async
@johanatan: There is a port called Andare that works with bootstrap ClojureScript: https://github.com/mfikes/andare
@johanatan: Quick Start https://gist.github.com/mfikes/22f553d8c9186dcc613e1263ca9deeda
And post (which probably doesn’t offer more info): http://blog.fikesfarm.com/posts/2016-05-15-bootstrap-core-async.html
@mfikes: how would I go about adding andare as a dependency?
[I'm not using lein or boot or anything as it's a pretty simple script: in fact, here's the entire project: https://github.com/johanatan/screencap ]
@johanatan: just download the JAR and use Planck's -c
option with the JAR
ahh awesome! thx!
by download, you mean clone the src and build the .jar myself? or is it hosted somewhere?
@mfikes: ^
@johanatan: It is on Clojars… hmm is there a way to just download directly from there without any other tooling?
oh, ok. i'll take a look
If you have lein
, you can make a small project.clj
file specifying [andare "0.1.0”]
just to get it
ok that would work. thx!
btw, is there an async version of sh
? i'm guessing not since there wouldn't really be any way to express that without andare
@johanatan: Also, once you set up Planck to use it you’ll definitely be interested in Planck’s ability to cache with -K
or -k /some/path/to/cache-dir
, otherwise it can take 15 seconds or so to load the core.async
namespaces
No, none of the side libraries in Planck currently offer callback-based async support.
(In fact, Andare was created after planck.http
)
But, you could imagine an async sh
which called back with the results instead of returning them
this is really nice btw. way better than using bash or python or what have you
[right]
Yes. To be honest, I never can remember how to even build up strings in Bash. In ClojureScript we all know it is done with str
🙂
haha yea
case statements are a disaster in bash too
It really makes bash utilities way more useful to me since I never learned/internalized enough bash to do anything reasonably complex. Even something as trivial as iterating over the output lines from ls
goes a long way. Especially when you can do that sort of thing to get some input data or what have you and then you’re back in Clojure.
@johanatan: That’s a cool script. Yes, you should be able to use cljs.core.async/timeout
to make your loop at the bottom sleep a bit before looping back around
@noonian: Yes. One thing that shows just how far we have come with ClojureScript (and is close to your example) is the one-liner in https://gist.github.com/mfikes/9503aa2555aac1cafaf4 where Rich’s demo involved first AOT-compiling some code and then running it in Node
Quite amazing 🙂
Ran into a little snag: having just a top-level go
routine with infinite loop inside returns immediately (whether or not it is inside a main and -m is passed).
When I do this from a regular Node.js ClojureScript project, it works as expected-- i.e., the program hangs while the go routine handles all processing rather than exiting immediately.
@mfikes: ^
@johanatan: Thanks! Fix pushed to master. Now code like the following will keep script processing “alive” until complete:
(go
(loop [n 10]
(when (pos? n)
(<! (timeout 1000))
(println n)
(recur (dec n)))))
You can brew master (see http://planck-repl.org/setup.html) or let me know if you’d just like a binary you can download.Reading @johanatan's screencap—did not realize that planck included goog.*! I realized I have a very hazy idea about the differences between Planck/JavaScriptCore and "regular Cljs"/Google Closure
@fasiha: Yeah, it is most of the Google Closure library
Uh oh, most? 🙃
If interested, here is how Planck includes stuff in its binary: http://blog.fikesfarm.com/posts/2015-07-27-island-repl.html
I've had this feeling before (the surprise at finding out google closure was included), when I found out Planck included transit
It's like Aladdin's cave
Yes, Transit is kind-of exposed by accident. I should probably just commit to it being there and list it in http://planck-repl.org/dependencies.html
I haven’t thought of a good way to cope with the fact that some of the things that Planck uses are simply available to Planck end-users.
In terms of what “most” means wrt Google Closure, stuff is pulled in intentionally here: https://github.com/mfikes/planck/blob/master/planck-cljs/src/planck/bundle.cljs
@johanatan: I don't think you have to do the stuff with st
and eval
in screencap's main.cljs
just to read in the EDN config. This seems to be sufficient: (1) add [cljs.reader]
to your requires, and (2) (def config (cljs.reader/read-string (slurp "./config.edn")))
FWIW, there is also planck.core/eval
and I’m working on adding read
if it proves to be useful: https://github.com/mfikes/planck/commit/f1b8547bf2a42bc06d04e81d52048555ba223c60
@fasiha: ahh, nice. Ya I tried to get reader to work but didn't stumble onto that particular incantation I suppose
Doesn't help that everything returned from google when searching for 'ClojureScript reader' involves the 'reader conditional'
The words 'magic' and 'Clojure' go together uncomfortably often 😕
🔮
"Any sufficiently advanced technology is indistinguishable from magic.” 🙂
@mfikes: I'm reading Clojuredocs for read
and read-string
side by side trying to understand the difference—it looks like the former consumes something not-stringy, a "push-back reader"?
@fasiha: Yes. For example, the version of read
I’ve been working on for Planck supports unread
: https://github.com/mfikes/planck/blob/f1b8547bf2a42bc06d04e81d52048555ba223c60/planck-cljs/src/planck/core.cljs#L69-L72
I'm guessing reading a Clojure expression from a stream, then unreading it (pushing it back) is useful even though I can't see how.
@fasiha: I think it is just a concession that makes a reader easier to implement. For example, when reading 17(+ 2 3)
the reader starts parsing the number at the beginning, but then it hits the (
and concludes that the number 17
has been fully parsed and simultaneously puts the (
back on the stream, unwinds the stack and continues, starting afresh with (+ 2 3)
in the stream.
@mfikes, OH that is useful, got it! Thanks for explaining