Fork me on GitHub
#babashka
<
2021-09-03
>
Adam Stokes12:09:12

I was looking at the dad source code and was curious; is this the right part of the code that allows you to set dad as your shebang line and parse whatever is after it? https://github.com/liquidz/dad/blob/master/src/dad/core.clj#L93-L101 Im basically looking to do something similar

Adam Stokes12:09:41

I see it calls a reader implementation that has a few functions defined, it looks like those are what is exposed if you use dad as your shebang

Adam Stokes12:09:30

Also, when I was doing something similar in perl I used https://metacpan.org/pod/Import::Into which basically allowed me to take functions from other libraries and import them into my "namespace" that would be automatically exported to the DSL

Adam Stokes12:09:36

I know babashka does this but it looks like you define those implementation files; do they just wrap the functions you want and pass on the args?

borkdude13:09:25

@adam.stokes This is not the dad channel and dad isn't something I developed, so I don't know, but perhaps the author is on Slack here somewhere

Adam Stokes13:09:02

Fair enough, in babashka, can you point me to the code that handles parsing the forms when using bb as your shebang

Adam Stokes13:09:27

Figured it was similar in nature since they both use sci

borkdude13:09:08

@adam.stokes A shebang is part of a shell implementation like bash, it just invokes a binary with that name

Adam Stokes13:09:10

From what I can tell you dont import the functions you want into your namsespace

borkdude13:09:20

and then that binary should decide how to deal with the arguments.

Adam Stokes13:09:34

Yep, that's the part im looking into

Adam Stokes13:09:50

does it just do some evaling on the remaining items when called from a script?

borkdude13:09:57

ok, in babashka this is pretty simple, it just uses slurp + SCI's eval-string*

Adam Stokes13:09:50

ok cool, was hoping it was something like that; and for exporting functions from other libraries to be used in this environment, is it just a matter of wrapping those functions in my own namespace?

borkdude13:09:53

see babashka.impl.main.clj

borkdude13:09:24

when you want to use other libraries in the SCI ctx, see the SCI docs

Adam Stokes13:09:34

Thanks will read up on that

borkdude13:09:51

The SCI docs are probably the best place to start with all of this

borkdude13:09:57

and then look at babashka etc. as examples

Adam Stokes13:09:07

Awesome, I'll take that approach, thanks again

borkdude13:09:06

@adam.stokes There's also a #sci channel for SCI questions, might you have any

🙏 2