This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-30
Channels
- # admin-announcements (1)
- # adventofcode (2)
- # announcements (2)
- # babashka (60)
- # beginners (48)
- # cherry (1)
- # cider (16)
- # clj-kondo (4)
- # clojure (53)
- # clojure-belgium (3)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-poland (1)
- # clojure-uk (6)
- # clojuredesign-podcast (19)
- # clojurescript (39)
- # community-development (12)
- # cursive (4)
- # datalevin (7)
- # datomic (23)
- # honeysql (14)
- # hyperfiddle (3)
- # instaparse (3)
- # lsp (3)
- # malli (10)
- # off-topic (34)
- # overtone (8)
- # polylith (2)
- # re-frame (9)
- # reitit (3)
- # releases (1)
- # squint (16)
- # timbre (7)
- # wasm (2)
- # xtdb (8)
Hi! I'm new to bb and to clojure, and kinda still green to programming in general. Came here after discovering Janet, super stoked about both! I've been a prolog person for some time and am mighty keen on diving into core.logic. Is this available in babashka? or just from graalvm? Both?
Currently bb doesn't support loading core.logic from source and it's also not built-in. You can just use regular JVM Clojure to try out projects that don't work with bb. Bb only supports a subset (albeit a large subset) of Clojure
Thanks! Any plans to incorporate in the future? I suppose that's unlikely, cause not super commonly needed for a scripting lang?
I haven't really heard of anyone using core.logic for anything but personal growth. I thought I could use it to find combinations of X for a set of predicates Y, but it turned out (very early on, before even getting to any of the logic that I had planned to implement) that my set of X was way too large for core.logic to ever return a result, it just stalled forever. I had (naively) assumed that the results would be lazy, but they're eager. So I concluded (perhaps wrongly) that core.logic is only really good for those cases where you know in advance how many results there are, or when you know the result, like those logic riddles where "Jane has a hat that is not red, Jeff has a hat with a trim etc etc, who has which hat?". Which, in my view, is close to useless. Well, except for toying and experimenting, or if you would like a really odd syntax and adapting a whole different mindset for expressing small combinatoric sets. I'd love to be proven wrong.
I'm having trouble with dynamic bindings.
(require '[babashka.cli :as cli])
(require '[clojure.string :as str])
(require '[taoensso.timbre :as timbre])
(import 'java.time.format.DateTimeFormatter
'java.time.LocalDateTime)
(def ^:dynamic *foo* "foo root value")
(defn clone-and-build-repo []
(println "(stdout) start, nothing should go to stdout")
(let [writer ( "/tmp/bindproblem.txt")]
(with-open [out-writer writer]
(binding [*out* out-writer
*foo* "foo inside binding"]
(timbre/info "out:" *out*)
(timbre/info "foo inside binding:" *foo*)
(try
(timbre/info "this should go to the file " )
(println "this too")
(throw (new Exception "an error im trhowing"))
(catch Exception e
;;*out* seems to revert to default value here?
(binding [*out* out-writer]
(timbre/info "foo inside catch:" *foo*)
(timbre/info "out:" *out*)
(timbre/error e " not going to the file? it should!" ))
)))))
(println "(stdout) ... until now")
(println "(stdout) start file content")
(println (slurp "/tmp/bindproblem.txt"))
(println "(stdout) end file content")
)
( clone-and-build-repo)
```
the out binding doesnt work inside the catch statement, I find it odd.
the foo binding seems to work though
Can you: 1 make a smaller repro if possible 2 test if the same works differently JVM Clojure and then come back?
you can print the dependencies used in bb with bb print-deps
to create a clojure project with deps.edn
thanks
behaviour is same in clojure
so I guess my mind is too small to comprehend dynamic bindings
can you still make a smaller repro is possible? then it will also become easier to understand with less dependencies :)
this is smaller
(require '[taoensso.timbre :as timbre])
(def ^:dynamic *foo* "foo root value")
(defn clone-and-build-repo []
(println "(stdout) start, nothing should go to stdout")
(let [writer ( "/tmp/bindproblem.txt")]
(with-open [out-writer writer]
(binding [*out* out-writer
*foo* "foo inside binding"]
(timbre/info "foo inside binding:" *foo*)
(try
(timbre/info "this should go to the file " )
(println "this too")
(throw (new Exception "an error im trhowing"))
(catch Exception e
;;*out* seems to revert to default value here?
(timbre/info "foo inside catch:" *foo*)
(timbre/info "out:" *out*)
(timbre/error e " not going to the file? it should!" )
)))))
)
( clone-and-build-repo)
smaller still?
aha, timbre seems to be wonky
this works as expected:
(def ^:dynamic *foo* "foo root value")
(defn clone-and-build-repo []
(println "(stdout) start, nothing should go to stdout")
(let [writer ( "/tmp/bindproblem.txt")]
(with-open [out-writer writer]
(binding [*out* out-writer
*foo* "foo inside binding"]
(println "foo inside binding:" *foo*)
(try
(println "this should go to the file " )
(println "this too")
(throw (new Exception "an error im trhowing"))
(catch Exception e
;;*out* seems to revert to default value here?
(println "foo inside catch:" *foo*)
(println "out:" *out*)
(println " not going to the file? it should!" e )
)))))
)
( clone-and-build-repo)
I can rip out timbre from my main program. Still, weird why timbre should do this
I can't access files with a german umlaut in the file-path. Is this on purpose? Am i doing something wrong?
(fs/parent (fs/file "absolute-file-path-with-umlaut-äüöß"))
> Malformed input or input contains unmappable characters
(.exists (io/file "absolute-file-path-with-umlaut-äüöß"))
> false (even so the file exists. it's true for files that exist and do not contain a umlaut).
babashka 1.3.186, linuxin clojure:
(.exists ( "path-with-ö"))
true
works fine over here (on mac):
$ bb -e '(prn (fs/file "absolute-file-path-with-umlaut-äüöß"))'
#object[java.io.File 0x197c140 "absolute-file-path-with-umlaut-äüöß"]
~ $ bb -e '(prn (fs/file "absolute-file-path-with-umlaut-äüöß"))'
#object[java.io.File 0x74d4c381 "absolute-file-path-with-umlaut-????"]
the umlauts are replaced with "?"
most likely this is due to system language encoding. You might need to set file.encoding=UTF-8
can you also try:
bb -e '(prn (fs/exists? (fs/file "absolute-file-path-with-umlaut-äüöß")))'
like this?
~ $ bb -Dfile.encoding=UTF-8 '(prn (fs/file "absolute-file-path-with-umlaut-äüöß"))'
#object[java.io.File 0x5d285dbb "absolute-file-path-with-umlaut-????"]
bb -e '(prn (fs/exists? (fs/file "absolute-file-path-with-umlaut-äüöß")))'
> false
its the same. I first tried in emacs and then on the terminal.
I just figured it out: I because i installed bb with nix. When i install bb with yay (babashka-bin from AUR)everything works fine.
I did reproduce that its not a problem with yay inside docker but i didn't get to reproduce the nix bb install inside docker.
I would like to make something like a set of queues, but im out of inspiration how to do it properly. At the moment im using a simple futures based thing, that runs 10 builds in paralell, and then and then proceeds with the next 10 builds. I would rather split this into a queue for cloning things(this is the brittle step) and then build things as soon as the clone is done, also with a limit of maybe 32 in parallell. so its like 2 threadpools or something. But i dont know what threadpool/blocking queue, or whatever that works well with babashka? any hints would be apreciated
For the latter ^, you could probably do it with 2 pipelines, 1 for cloning, and 1 for building: https://clojuredocs.org/clojure.core.async/pipeline-blocking And https://clojuredocs.org/clojure.core.async/pipeline-async An alternative would be 2 Executors , one which submits jobs to the other. https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool-int- https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html#submit
thanks