Fork me on GitHub
#babashka
<
2020-04-01
>
borkdude09:04:30

$ ./bb '(with-open [os (.ByteArrayOutputStream.)] (bencode/write-bencode os {"greeting" "Good morning"}) (str os))'
"d8:greeting12:Good morninge"

👋 4
borkdude09:04:25

ClojureScript podcast episode about babashka and the Small Clojure Interpreter: https://twitter.com/borkdude/status/1245286719240404992

🎉 16
clj 8
tvaughan14:04:27

I'm working with Fulcro which requires its network traffic to be encoded in transit. This prevents me from (easily) using restclient.el to test api endpoints. Would it be possible (I assume after having written some non-trivial emacs lisp) to replace restclient.el with a combination of babashka, babashka.curl, and jet? I understand I could do this in clojure but I don't want to have to connect to a clojure repl. I want to write my queries in edn, have them automatically converted to transit, and then have the response decoded to edn and pretty-printed. Does this make sense? Is this feasible?

borkdude14:04:43

@tvaughan since the latest release, babashka also includes transit

borkdude14:04:35

I think using that and babashka.curl you can make it work

👍 4
tvaughan14:04:39

Ah ok. Cool! That makes things much easier

deep-symmetry17:04:30

Sorry if this is a weird question, but is there a way to make the cljs.pprint namespace available to code running inside SCI?

borkdude17:04:23

@deep-symmetry what about:

cljs.user=> (require '[cljs.pprint :as pprint])
nil
cljs.user=> (sci/eval-string "(pprint (range 30))" {:bindings {'pprint pprint/pprint}})
(0
 1
 2
 3
 4
 5

deep-symmetry17:04:14

Ok, something like that could work, I was aiming for cl-format but could bind that. Is there a way to bind the namespace so the hosted code can require it if they want it, though?

deep-symmetry17:04:59

Or does tree-shaking make that an impossible idea?

borkdude17:04:36

cljs.user=> (sci/eval-string "(require '[clojure.pprint :refer [pprint]]) (pprint (range 30))" {:namespaces {'clojure.pprint {'pprint pprint/pprint}}})
(0
 1
 2
?

deep-symmetry17:04:17

Ah, cool. So as long as I enumerate the functions I want, they get copied down, perfect.

deep-symmetry17:04:43

As an aside, SCI is proving a perfect weapon in my effort to induce someone to learn a little Clojure. 😉

borkdude17:04:38

yeah, as long as you hold a map somewhere with a reference to that function (the sci opts in this case) Google Closure won't tree-shake it