Fork me on GitHub

@reefersleep The HoneySQL library is written as .cljc files and has test runners for both .clj and .cljs


Exactly what I was looking for, right in my .m2. Another reason to be happy about honeysql 🙂


@reefersleep I also have several .cljc projects. - - I generally use the cognitect-labs test runner for running JVM tests and cljs-test-runner by @olical for running CLJS tests in node.


I thought you might chime in 😊 thanks! Same as @U04V70XH6, it seems. And it worked out fine for me, too!


I see Sean also uses that in HoneySQL

🍻 6
Adriaan Callaerts10:11:06

question: in an effort to do some meta-programming, I am building an abstraction which needs to get a function from a namespace, but the names of the namespace and function are dynamic. Eg, I turned what used to be #'ns-name/fn-name into (var (symbol dynamic-ns-name dynamic-fn-name)) which I thought would work, but doesn't. Can someone spot my mistake?

Adriaan Callaerts10:11:39

In this example, ns-name and fn-name would be hardcoded in various places but always follow a fixed pattern, so I'd derive the dynamic-ns/fn-name from some other input and then "import" the function based on that derived name.


var will work only if symbol can be resolved. if namespace is not loaded yet it will break. Instead you could try to use requiring-resolve which will dynamically require corresponding namespace and resolve var (requiring-resolve (symbol dynamic-ns-name dynamic-fn-name))

Adriaan Callaerts10:11:05

ok, let me give that a try

Adriaan Callaerts11:11:35

that did the trick. thanks!


cool) but I was wrong about the reason why var is not working. The var is not a function but instruction to compiler to resolve symbol and only symbol to var for example (var (symbol "clojure.core" "apply")) will throw ClassCastException trying to cast clojure.lang.PersistentList into clojure.lang.Symbol the only valid form for var is (var apply) where argument is a symbol

Adriaan Callaerts11:11:56

yes, that was the exception I got but the documentation on var didn't give me the context that it can't be used as a runtime function

Adriaan Callaerts11:11:16

So thanks for clarifying that!


happy friday y'all, I have a question about reify - I'm trying to use instance? to verify that the object returned by reify is an instance of the protocol it reifies. It seems like that's not possible, because, well, it isn't. Is there a predicate, or other means I can use to determine which protocols are implemented by this object?


looking at the reify doc-string, it will always implement clojure.lang.IObj but doesn't mention any other features of the type of the object returned


Always paste the code you typed. instance? should work


user=> (defprotocol MyProtocol (a-meth [this]))
user=> (def impl (reify MyProtocol (a-meth [this] :a-result)))
user=> (instance? MyProtocol impl)
Execution error (ClassCastException) at user/eval196 (REPL:1).
class clojure.lang.PersistentArrayMap cannot be cast to class java.lang.Class (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; java.lang.Class is in module java.base of loader 'bootstrap')
user=> (satisfies? MyProtocol impl)
user=> (a-meth impl)


(Clojure 1.10.1)


@j0ni for protocols you can use satisfies?


thank you @borkdude, for releasing me from this rabbit hole

👍 3
Ben Sless21:11:37

Be aware that satisfies has terrible performance. A work around is adding a method to the protocol, IFoo, foo?, which returns true for your objects and by extending the protocol to Object and nil, false for everything else.


@UK0810AQ2 thanks for the heads up. It's ok for my use case, in a :ret for a fdef - only gets called in test


anyone here played with Loom's continuations yet? Or any channels specific to it?

Ben Sless04:11:37

Hey Will :) There's #teknql but he focused more on fibers usage You could also try #java I'll reply to you by email later today, tldr I probably got some stuff wrong. From what I saw it's common to have one ContinuationScope and not open a new one every time


hey Ben, no rush! 😄 yeah I was hoping to see what other people are building on it and what techniques are falling out. that makes sense to me