Fork me on GitHub
#babashka
<
2020-09-04
>
borkdude06:09:09

Thanks @goomba! Yes, #spire is a sister project by @retrogradeorbit based on the same interpreter #sci

Crispin12:09:12

huh. that's surprising

borkdude12:09:31

You can also use that for limiting the memory: -Xmx30m

borkdude12:09:30

$ bb -Xmx0m -e "(+ 1 2 3)"
java.lang.OutOfMemoryError: Garbage-collected heap size exceeded.
$ bb -Xmx5m -e "(+ 1 2 3)"
6

😆 3
metal 6
lread21:09:07

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?

borkdude21:09:54

yes please!

borkdude21:09:48

hmm:

user=> (version-compare "1.0-alpha5" "1.0-alpha14")
java.lang.StackOverflowError

lread21:09:43

hmmm…

borkdude21:09:24

$ bb -e "(use 'version-clj.core) (version->seq \"1.0.0-SNAPSHOT\")"
----- Error --------------------------------------------------------------------
Type:     java.lang.StackOverflowError
Location: version_clj/split.clj:63:5

borkdude21:09:47

Did it work for you though?

lread21:09:58

yeah, it passed my little tests, lemme check more

lread22:09:13

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

lread22:09:20

And setup my bb cp like so:

export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {version-clj {:mvn/version "0.1.2"}}}')

borkdude22:09:45

let me try again

borkdude22:09:33

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"]]

lread22:09:08

I can replicate your stack overflow with use

borkdude22:09:24

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 :)

borkdude22:09:33

Thanks for discovering this :)

borkdude22:09:59

I would appreciate an issue and I'll try to fix it in the next cycle of babashka

borkdude22:09:06

if you don't beat me to it.

borkdude22:09:40

I think I know what it is

lread22:09:44

Oh interesting, version-clj is uses .cljx files.

borkdude22:09:02

split is private, but bb currently doesn't honor private

borkdude22:09:19

so if you use use, it will overwrite things that it shouldn't

borkdude22:09:26

this is my guess, but I'd have to look into it

borkdude22:09:16

What I usually do for libraries like this is copy the tests to test-resources and add it to the lib tests script

borkdude22:09:25

so they will be tested on CI

borkdude22:09:29

like a smoke test

lread22:09:45

that’s smart

borkdude22:09:47

such a PR would also be welcome for this lib

borkdude22:09:57

I have to call it a night now. thanks!

lread22:09:13

g’night, I’ll make an issue in babashka.

borkdude22:09:59

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)

lread22:09:19

I’ll hold off on adding to libraries docs until this is fixed. Note that I won’t get to it immediately.

lread22:09:42

hey, go to sleep!

borkdude22:09:56

No problem, I'll fix it when I finish some clj-kondo business in the coming week

borkdude22:09:25

I want to introduce something in clj-kondo so it can scan libraries for config and hook code

borkdude22:09:36

so library authors can distribute those themselves