we have the #graalvm folks and others to thank 🙂
Thanks @goomba! Yes, #spire is a sister project by @retrogradeorbit based on the same interpreter #sci
Can be handy to know: https://twitter.com/borkdude/status/1301836039129104385
huh. that's surprising
You can also use that for limiting the memory: -Xmx30m
$ bb -Xmx0m -e "(+ 1 2 3)"
java.lang.OutOfMemoryError: Garbage-collected heap size exceeded.
$ bb -Xmx5m -e "(+ 1 2 3)"
6
Heya! I wanted to compare some versions in a babashka script and discovered that https://github.com/xsc/version-clj works with babashka. Worth adding to https://github.com/borkdude/babashka/blob/master/doc/libraries.md#libraries?
yes please!
will do!
hmm:
user=> (version-compare "1.0-alpha5" "1.0-alpha14")
java.lang.StackOverflowError
hmmm…
$ bb -e "(use 'version-clj.core) (version->seq \"1.0.0-SNAPSHOT\")"
----- Error --------------------------------------------------------------------
Type: java.lang.StackOverflowError
Location: version_clj/split.clj:63:5
Did it work for you though?
yeah, it passed my little tests, lemme check more
I was testing from the bb repl like so:
> bb --repl
Babashka v0.2.0 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (require '[version-clj.core :as ver])
nil
user=> (ver/version->seq "1.0.0-SNAPSHOT")
[(1 0 0) ["snapshot"]]
user=> (ver/version-compare "1.0-alpha5" "1.0-alpha4")
1
user=> (ver/version-compare "1.0-alpha4" "1.0-alpha5")
-1
And setup my bb cp like so:
export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {version-clj {:mvn/version "0.1.2"}}}')
let me try again
this indeed seems to work:
$ bb -e "(require '[version-clj.core :as ver])" -e '(ver/version->seq "1.0.0-SNAPSHOT")'
[(1 0 0) ["snapshot"]]
I can replicate your stack overflow with use
But this doesn't:
$ bb -e "(use '[version-clj.core])" -e '(version->seq "1.0.0-SNAPSHOT")'
There may be a bug in the implementation of sci's use :)Thanks for discovering this :)
I would appreciate an issue and I'll try to fix it in the next cycle of babashka
if you don't beat me to it.
I think I know what it is
Oh interesting, version-clj is uses .cljx
files.
split is private, but bb currently doesn't honor private
so if you use use, it will overwrite things that it shouldn't
this is my guess, but I'd have to look into it
What I usually do for libraries like this is copy the tests to test-resources and add it to the lib tests script
so they will be tested on CI
like a smoke test
that’s smart
such a PR would also be welcome for this lib
I have to call it a night now. thanks!
g’night, I’ll make an issue in babashka.
here’s the issue: https://github.com/borkdude/babashka/issues/565
Thanks. Meanwhile I made a small repro which may be similar:
(ns foo
(:refer-clojure :exclude [+]))
(defn- + [& xs]
(apply + xs))
(ns bar (:use foo))
(+ 1 2 3)
I’ll hold off on adding to libraries docs until this is fixed. Note that I won’t get to it immediately.
hey, go to sleep!
No problem, I'll fix it when I finish some clj-kondo business in the coming week
I want to introduce something in clj-kondo so it can scan libraries for config and hook code
so library authors can distribute those themselves