Fork me on GitHub
#sci
<
2021-06-24
>
borkdude21:06:30

So the question is: can you add an entire namespace at once using ns-publics?

hairfire21:06:15

Yes, but I don't need to use ns-publics if there's a better way.

hairfire21:06:14

My use case is: I have several functions defined, I read in a file containing Clojure code that only uses those functions, and I want to load-string on file.

Darin Douglass21:06:15

{:namespaces {'io {'file #(apply files/resolve lh %&)}
                                                      'json (ns-publics 'clojure.data.json)
                                                      'str (ns-publics 'clojure.string)
                                                      'tools (ns-publics 'lh.sci-tools)
                                                      'user {'slurp slurp}}}
Is what I use

Darin Douglass21:06:26

Sorry for poor formatting, on my phone at the moment

hairfire21:06:02

Ah, I see, use :namespaces not :bindings

borkdude21:06:52

yes, :bindings is just a short-hand for {:namespaces {'user ...}}

hairfire21:06:10

I suppose I would need to add something like "(require 'json)" to the top of the file coming in, to use your example @ddouglass

borkdude21:06:32

you could also just add everything to the user namespace, if that fits your use case

borkdude21:06:05

or just eval "(require '[json :refer :all]) before evaluating something else

hairfire21:06:39

I've written a C++ code generator for our embedded development team that takes as input a file of text, which looks a lot like Clojure, loads it, analyzes it, and ouputs the C++ code. To date it required devs to have Java on their machines (e.g., Linux, Windows). I want to use "sci" so I can provide native binaries. It looks like "sci" is going to do the trick.

👍 4
hairfire21:06:21

Thanks @borkdude for all you hard work, and the latest ClojureD presentation which sparked my interest in making this new native binary version!

👍 2
borkdude21:06:38

@hairfire That sounds like a cool project. Let me know if you run into trouble.

👍 2
hairfire22:06:40

Hey @borkdude, is http://ko-fi.com the best way to make a one-time contribution?

borkdude22:06:27

yep, thanks :)

👍 2
borkdude20:06:22

@hairfire I now enabled one time amounts on Github sponsors too. I didn't know this was possible, TIL.