Fork me on GitHub
#babashka
<
2020-12-10
>
mozinator208:12:54

Anyone have a clue why I get error Could not resolve symbol: clojure.lang.PersistentList ? When doing

(def rop-dep '{:deps {rop/rop {:mvn/version "0.4.1"}}})
  (def cp (-> (sh "clojure" "-Spath" "-Sdeps" (str rop-dep)) :out s/trim))
  (add-classpath cp)
  (require '[rop.core :as rop])

borkdude09:12:42

This is because not all classes are explicitly available for interop in babashka, they have to be manually added. Which library is this? (I'll be back in a bit)

🙏 1
borkdude09:12:14

@mozinator You're welcome to post an issue about this.

👍 1
mozinator209:12:04

Maybe the rop and cats library might be too heavyweight for babashka scripts anyway. I found this solution to error handling which seems to cover most of what I need https://adambard.com/blog/acceptable-error-handling-in-clojure/

mozinator209:12:21

@borkdude what are your criteria for adding libraries to the included libraries in babashka ?

borkdude09:12:03

camel-snake-kebab has been asked at least one time before. I'm willing to add it if more people ask for it in an issue.

borkdude09:12:08

But since that lib can also be ran from source, there might not be a need to include it in babashka proper. This can be discussed in an issue though. So making an issue would be the first step.

👍 2
borkdude09:12:40

I was trying out slingshot btw:

$ bb -e "(require '[slingshot.slingshot :as s]) (s/try+ (s/throw+ {:type ::foo}) (catch [:type ::foo] [] 1)))"
----- Error --------------------------------------------------------------------
Type:     java.lang.ClassNotFoundException
Message:  clojure.lang.RT
Location: <expr>:1:40

----- Context ------------------------------------------------------------------
1: (require '[slingshot.slingshot :as s]) (s/try+ (s/throw+ {:type ::foo}) (catch [:type ::foo] [] 1)))
                                          ^--- clojure.lang.RT
I'm not sure why this error appears, since I see no mention of clojure.lang.RT in the source code of slingshot

borkdude09:12:36

I'll also make an issue for that.

borkdude09:12:01

Ah, found the issue. Not sure why this is happening.

$ bb -e '(alength (into-array []))'
----- Error --------------------------------------------------------------------
Type:     java.lang.ClassNotFoundException
Message:  clojure.lang.RT
Location: <expr>:1:1

----- Context ------------------------------------------------------------------
1: (alength (into-array []))
   ^--- clojure.lang.RT
`

borkdude09:12:45

Maybe this uses reflection in Clojure?

(defn alength
  "Returns the length of the Java array. Works on arrays of all
  types."
  {:inline (fn [a] `(. clojure.lang.RT (alength ~a)))
   :added "1.0"}
  [array] (. clojure.lang.RT (alength array)))

borkdude09:12:39

yap:

user=> (. clojure.lang.RT (alength (into-array [])))
Reflection warning, NO_SOURCE_PATH:1:1 - call to static method alength on clojure.lang.RT can't be resolved (argument types: unknown).
0

borkdude20:12:34

https://www.thoughtworks.com/podcasts/future-clojure#trans > Obviously, you have ClojureScript compiling JavaScript, which was something that we started and led at the beginning, but is now led primarily outside of Cognitect by David Nolan and others. And then, a variety of other dialects and things that people are doing like the babashka for shell scripting in Clojure and those kinds of things.

babashka 10
borkdude22:12:46

https://twitter.com/borkdude/status/1337164427095924737 <- the com.stuartsierra/dependency lib works with bb

🎉 4