This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-01
Channels
- # atom-editor (11)
- # babashka (25)
- # beginners (142)
- # boot (9)
- # calva (3)
- # cider (19)
- # clara (15)
- # clj-kondo (6)
- # cljs-dev (20)
- # clojars (11)
- # clojure (164)
- # clojure-dev (9)
- # clojure-europe (6)
- # clojure-italy (17)
- # clojure-nl (3)
- # clojure-spec (19)
- # clojure-sweden (10)
- # clojure-uk (23)
- # clojurescript (34)
- # code-reviews (31)
- # conjure (20)
- # cursive (14)
- # datomic (54)
- # emacs (1)
- # fulcro (51)
- # graalvm (24)
- # graphql (6)
- # helix (3)
- # jobs (3)
- # kaocha (1)
- # malli (2)
- # meander (15)
- # off-topic (81)
- # pathom (2)
- # re-frame (43)
- # reagent (26)
- # reitit (1)
- # releases (1)
- # sci (12)
- # shadow-cljs (29)
- # sql (22)
- # timbre (3)
- # tools-deps (15)
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
yeah, but in general you don't know and people will come to you on a daily basis to add more, is my experience 😉
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?
Btw, this is pretty cool: this company uses sci to let non-developers write scripts: https://twitter.com/jacquesdp/status/1278242112501358597
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
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?
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
Maybe there is someone who can explain this better than I do, I'm afk now, getting late here
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