Fork me on GitHub
#clojure
<
2020-05-09
>
borkdude14:05:24

Question: what is the code equivalent for (load-string "(ns pod.borkdude.clj-kondo)")? When I use create-ns and then use require on the namespace, it throws, but not when I use the load-string snippet

bronsa14:05:34

@borkdude create-ns (+ refer-clojure) + in-ns

bronsa14:05:39

load-string pretty much is just read + eval

bronsa14:05:02

so what you're really asking is what is the functional equivalent of ns

borkdude14:05:21

but load-string also resets back to the original ns for me

borkdude14:05:31

@bronsa

user=> (binding [*ns* *ns*] (in-ns 'bar) (refer-clojure))
nil
user=> (require '[bar])
Execution error (FileNotFoundException) at user/eval156 (REPL:1).
Could not locate bar__init.class, bar.clj or bar.cljc on classpath.

bronsa14:05:10

that's due to how ns works

bronsa14:05:31

look at its macroexpansion

bronsa14:05:47

there's some bit about mutating a *loaded-libs* var

bronsa14:05:55

which short-circuits require

bronsa14:05:20

otherwise require needs a file

Amir Eldor16:05:38

Hello. What do the cool-kids use? spec or typed-clojure?

andy.fingerhut16:05:35

Coming from someone who would not describe himself as a cool kid, and also one who has not used either, spec gets asked about a lot more here than typed-clojure does, so seems to get more active use.

😂 4
☝️ 4
Amir Eldor16:05:03

I see, thanks. You are cool.

seancorfield19:05:19

@U0140AKS332 They're very different approaches. Typed Clojure is a static analysis project: you add annotations to your code and run the analyzer and it tells you whether or not it is "correctly typed". Spec is a set of tools that provide runtime checking of functions and data structures, as part of development/testing, or for data validation in production code. I wrote up all the different ways we use Spec at work https://corfield.org/blog/2019/09/13/using-spec/

✔️ 4