sci

https://github.com/babashka/SCI - also see #babashka and #nbb
ikitommi 2020-07-01T11:07:52.120800Z

for ultimate small code size: for the niche case where sci eval strings are known in advance, sci could be used to list all the used vars (somehow?) and emit code to include just those. Related to https://github.com/borkdude/sci/issues/357

ikitommi 2020-07-01T11:08:28.121600Z

not sure how useful that would be, but.. possible

borkdude 2020-07-01T11:10:13.122300Z

yeah, but in general you don't know and people will come to you on a daily basis to add more, is my experience 😉

borkdude 2020-07-01T11:10:54.122700Z

but if you have any concrete ideas about this, post away in #357 🙂

borkdude 2020-07-01T11:11:42.123700Z

having sci optional with dynaload is already a good step. maybe when entering sci for more power and luxury, people don't care as much about bundle size anyway?

borkdude 2020-07-01T11:16:22.124700Z

Btw, this is pretty cool: this company uses sci to let non-developers write scripts: https://twitter.com/jacquesdp/status/1278242112501358597

borkdude 2020-07-01T11:28:38.125900Z

I think the option to programmatically create the namespaces.cljc file (to limit access to core vars) is an interesting one. What would happen btw if you right now would include sci.impl.namespaces.cljc in your own project and just edited, ripped out the vars you don't need? I guess that would already work as of now

Patrick Farwick 2020-07-01T21:35:37.128800Z

so lvh helped me a bit yesterday getting the binding in specter to work in a single eval statement. (Has to do with how crazy specter is under the hood it seems, select being a macro, select* being a function) (sci/eval-string "(select [:a] {:a 1 :b 2 :c 3})" {:bindings {'select sr/select*}}) So am I correct in the fact that the bindings will work on the eval-string but not in the functions called in the eval string?

borkdude 2020-07-01T21:41:08.132200Z

A few things: 1. :bindings is really just a shorthand for :namespaces {'user ...} so as soon as namespaces come into play, it's really better to not use :bindings anymore 2. a macro is just a function that takes an s-expression and produces an s-expression which will then in turn be evaluated. you have to bind all the vars that can be references in such resulting s-expression. Use macroexpand to inspect the expansion and you'll hopefully see what I mean 3. (non-macro) functions are just opaque objects, they take input and produce output, but hold on to everything needed to do so (i.e. a closure), so they don't have the problem that macros have

borkdude 2020-07-01T21:42:48.133Z

Maybe there is someone who can explain this better than I do, I'm afk now, getting late here

Patrick Farwick 2020-07-01T22:06:20.134200Z

No worries, I feel like you said something similar yesterday and maybe it just hasn't totally clicked yet. Sorry if that was frustrating! Have a good night

borkdude 2020-07-01T22:07:03.134600Z

Not frustrating at all, it's just getting late here