Fork me on GitHub
#babashka
<
2020-05-16
>
armed05:05:27

Hi, I'm launching socket repl and load-file some script + in-ns, *file* var is nil. Am I doing something wrong or *file* is not available in repl?

borkdude06:05:10

@armed that variable is only set when evaluating a file. After that it’s available on var metadata

armed07:05:34

Hey, @borkdude thanks for great tool. I'm calling (load-file "path/to/my-file.clj") is this considered as eval?

armed07:05:34

Here is minimal example:

[email protected] in ~/Developer/tests/bb-example
$ cat src/my_file.clj
(ns my-file)

(defn my-func
  []
  (prn *file*))

(my-func)

[email protected] in ~/Developer/tests/bb-example
$ bb src/my_file.clj
"/Users/armed/Developer/tests/bb-example/src/my_file.clj"

[email protected] in ~/Developer/tests/bb-example
$ bb -cp src --repl
Babashka v0.0.94 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (load-file "src/my_file.clj")
"/Users/armed/Developer/tests/bb-example/src/my_file.clj"
nil
user=> (my-file/my-func)
nil
nil

borkdude07:05:54

@armed This is expected. The *file* var is a dynamic var which is only bound to the current file when the file is being evaluated by babashka. After that, the file value is available on var metadata. Try:

(ns my-file)
(defn my-func
  []
  (prn (:file (meta #'my-func))))
(my-func)

👍 1
armed07:05:16

Thanks. It’s clear now.

armed12:05:29

Wow, now my monorepo with 5 modules is now built with babashka + deps.tools (in parallel). Cool! Previously I was using bunch of bash scripts and was to lazy to figure out how to launch commands in parallel.

bananadance 2
jeroenvandijk12:05:12

Sci is gonna be one of the building blocks of Athens 😎

metal 1
🔥 1
borkdude13:05:21

@jeroenvandijk Do you really need sci to execute datalog queries though? As much as I like see sci being used, a datalog query is just a piece of EDN right?

jeroenvandijk13:05:47

Not for datalog itself, but we want to allow code evaluation on the platform

jeroenvandijk13:05:24

RoamResearch (the closed source inspiration) has datalog (datascript) query functionality without Sci or Clojure and the experience is pretty bad. E.g. you don’t have any sorting options or other ways to manipulate the result

jeroenvandijk13:05:31

So Sci can improve this experience

jeroenvandijk13:05:47

I’m pretty sure Roam will start using Sci at some point as well

jeroenvandijk13:05:10

Not sure if you heard about RoamResearch before?

jeroenvandijk13:05:12

https://roamresearch.com/ It’s build in Clojure(script) and they are quite succesful 🙂

borkdude13:05:31

I've heard about it

borkdude13:05:49

You might have shown it to me on the train back from ClojureD?

jeroenvandijk13:05:06

Ah yes I did! 🙂

borkdude13:05:15

pod.lispyclouds.docker: a docker pod for babashka: https://github.com/lispyclouds/pod-lispyclouds-docker

jeroenvandijk14:05:13

Is it me or would it be possible to remove some boilerplate in the main functions of the pods? The ones I’ve seen so far look pretty similar

borkdude14:05:14

Sure, there could be a library the wraps the boilerplate, but I'm not going to maintain that right now. First focus on functionality, then convenience

jeroenvandijk14:05:32

I agree, just mostly wondering if I was missing something

borkdude14:05:27

Maybe a lein template or something could also work

jeroenvandijk14:05:52

yes, indeed. No need to optimize too much. Might be a way to gather some feedback as well

nate14:05:14

Very cool to see a docker pod. Is there a list of all the pods somewhere? Seems like there's a pod explosion lately.

nate15:05:20

Awesome. Thanks!