So the question is: can you add an entire namespace at once using ns-publics
?
Yes, but I don't need to use ns-publics if there's a better way.
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.
{: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 useSorry for poor formatting, on my phone at the moment
Ah, I see, use :namespaces not :bindings
yes, :bindings
is just a short-hand for {:namespaces {'user ...}}
I suppose I would need to add something like "(require 'json)" to the top of the file coming in, to use your example @ddouglass
Yep
you could also just add everything to the user namespace, if that fits your use case
or just eval "(require '[json :refer :all])
before evaluating something else
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.
Thanks @borkdude for all you hard work, and the latest ClojureD presentation which sparked my interest in making this new native binary version!
@hairfire That sounds like a cool project. Let me know if you run into trouble.
Hey @borkdude, is http://ko-fi.com the best way to make a one-time contribution?
yep, thanks :)
@hairfire I now enabled one time amounts on Github sponsors too. I didn't know this was possible, TIL.