Fork me on GitHub
#clojure
<
2018-07-21
>
dominicm13:07:55

native interop is hard 😧 Just functions wouldn't be so bad, but typedefs complicate things significantly. I'm trying JNAerator at the moment, but I'm not getting quite what I would expect, less than things.

hoff13:07:42

is there a way i can instrument all my functions with spec when running leiningen test?

jumar15:07:08

@U5NEPT90U we have a test profile in project.clj with following injections

:injections   [(require 'clojure.spec.test.alpha)
                                             (clojure.spec.test.alpha/instrument)
                                             (.println System/err "Instrumented specs")]

hoff16:07:25

this doesn't instrument anything for me. the code runs, but apparently the specs haven't been defined yet at the point where instrument is called.

hoff16:07:22

i have specs organized in separate files. so for foo.clj there is foo_spec.clj. and foo.clj contains the line (load "foo_spec") so the specs live in the same namespace.

hoff16:07:49

foo_spec.clj doesn't have its own namespace declaration

xiongtx19:07:23

Is there a way to refer to a generated class inside of the namespace that generates it using shorthand? E.g.

(ns forkjoin.tasks.FibonacciTask
  (:gen-class
   :extends java.util.concurrent.RecursiveTask
   :init init
   :constructors {[Long] []}
   :state state))

(defn -init [n]
  [[] n])

(defn -compute
  [^forkjoin.tasks.FibonacciTask this]
  (let [n (.state this)]
    (if (<= n 1)
      n
      (let [f1 (forkjoin.tasks.FibonacciTask. (dec n))
            f2 (forkjoin.tasks.FibonacciTask. (- n 2))]
        (.fork f1)
        (+ (.compute f2) (.join f1))))))
Instead of forkjoin.tasks.FibonacciTask, could FibonacciTask be used somehow?

quoll21:07:10

Try adding (:import [forkjoin.tasks FibonacciTask]) to the end of your ns definition

xiongtx05:07:37

Ah yes, gen-class takes precedence so we can :import. Thanks!

👍 4
Al Baker23:07:56

is friend depracated in favor of buddy these days?