Fork me on GitHub
#clojure
<
2017-12-25
>
qqq00:12:20

https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool(int) [service (java.util.concurrent.Executors/newFixedThreadPool 24)] that is something that should, in theory, be a queue with 24 worker threads right? "ps aux | grep java" is only showing a single thread, "top" is only showing < 100% utilization, iknstead of 2400% utilization

andy.fingerhut02:12:59

Are you sending it 'jobs' that take significantly longer to execute than the overhead of starting and finishing the jobs? Sending it really tiny jobs might not get you any actual parallelism

qqq02:12:57

Each jobs takes 10-20 seconds to execute.

qqq02:12:24

Turns out, I was mis-reading the output of TOP. On per process, it' sshowing full usage (i..e 2400%), but on the top overall usage, it's showing 99% (i.e. 2400 / 2400).

qqq08:12:34

is it possible to: 1. pass an anonymous function to a macro and 2. evaluate the function at MACRO EXPANSION time in particular, I want to do: (defmacro foo [ .... ] ....) (foo (fn [x] (println (+ 1))) ...)

qqq08:12:44

and I want the function evaluated at macro expansion time

carkh08:12:29

you're actually passing a list to your macro ... that might require a call to eval

qqq08:12:32

yeah, I have this weird situation where foo behave as follows: (foo f1 f2 data) where data is interpreted as data however, I want to parameterize foo by passing it functions f1, f2, that modify the behaviour of foo -- is this possible ?

slipset09:12:22

Sounds like (def bar (partial foo f1 f2)) (bar data)

carkh10:12:00

maybe i lack imagination, but i can't imagine a case where some client code would use a macro, parameterizing it with a function... So I guess you're writing a macro that itself calls a macro. In that case you would want the outer macro calling into functions that build the code rather than callinbg into macros, so you're out of the macro system as soon as you enter the outer level

carkh10:12:58

in 10 (?) years since i started playing with clojure, i wrote maybe 5-10 macros and most were of the def-thing kind...thinly wrapping a function call.

carkh10:12:53

then again, i had my macro abuse period earlier with common lisp =)

carkh10:12:57

macros are a code smell (most of the time)

carkh10:12:41

that's to say, are you really sure you want a macro? and if so, can you simplify it so that it's only a wrapper around your data orienbted or function oriented underlying system

qqq10:12:25

I'm writing macros to help me generate clojure bindings to an java api

qqq10:12:07

There are alot of functions to bind. I want to pass it two functions, c-name and j-name, which decides how the functions are named, for example, I want

qqq10:12:44

(make-bind c-name j-name foo bar cat dog)
to bind cu-foo to java.jcuda.JCublas2/cublasFoo cu-bar to java.jcuda.JCublas2/cublasBar ...

qqq10:12:18

so I have c-name be a function (s -> (symbol (str "cu-" s))) and j-name something to append the java.jcuda.JCublas2/cublas and capitalize the symbol

qqq10:12:41

but now, I want the cname and j-name to be functions rather than hard coded, because I also will be binding jcudafft, jcuda/cudnn / ...

carkh17:12:06

Looks like a fine occasion for macros indeed. I would take it in reverse order, by first gathering/processing a list of symbol names then feeding that into a def-bindings macro

gklijs12:12:38

@qqq can't you turn the macro into a function returning a map (of functions)?

niels13:12:22

During cider debugging, is there a way for it to keep refreshing local variables every step ( the l key) ?

niels13:12:53

(visually)

a.espolov20:12:36

Guys how can I call the base method of a class on an object?

noisesmith20:12:26

by making a class that calls the superclass' method right?

noisesmith20:12:27

maybe I don't understand what you're asking for

souenzzo21:12:07

Why I can't (> #inst"2017" #inst"2018") in clojure? It works on cljs. And on clojure, I can compare inst via sort..

bronsa21:12:23

the fact that it works on cljs is just because javascript can do > with Dates and cljs's > delegates to javascript's >

bronsa21:12:33

clojure's > is defined only in terms of numbers

bronsa21:12:48

the fact that it works in cljs is an accident of the implementation

juhoteperi21:12:17

I don't remember if #inst in Cljs emits js/Date or goog.date.DateTime or UtcDateTime, if latter, it shouldn't be comparable by default, but if cljs-time.extend ns is loaded, that will extend IComparable to DateTime and UtcDateTime

juhoteperi22:12:42

#inst creates JS Date, so cljs-date.extend won't affect that

qqq22:12:22

http://www.jcuda.org/jcuda/jcublas/doc/jcuda/jcublas/JCublas2.html#cublasSgemm(jcuda.jcublas.cublasHandle, int, int, int, int, int, jcuda.Pointer, jcuda.Pointer, int, jcuda.Pointer, int, jcuda.Pointer, jcuda.Pointer, int) is there a way to call 'resolve' or some other function, and get taht function as a result ?

qqq22:12:36

i.e. I want something that will take "jcuda.jcublas.JCublas2/cublasSgemm", and return that function

synthomat22:12:27

Hm, could somebody explain me the difference between merge and into? does the latter have side effects?

synthomat22:12:08

nope, apparently not

synthomat22:12:32

into supports a transducer…

bronsa22:12:25

@qqq no, java methods are not first class in clojure

juhoteperi22:12:41

@synthomat merge is only for maps, into works for any collection

bronsa22:12:02

you could do that via reflection if you wanted to but it doesn't sound like a particularly good idea

synthomat22:12:56

@juhoteperi hmm, but merge does merge vectors as well. kind of

noisesmith22:12:42

this works accidentally and isn't an intended feature

synthomat23:12:26

alrighty; thanks!

synthomat22:12:05

but yeah, merge source calls the parameter & maps

qqq22:12:26

@bronsa: so the only three ways to get a java method are: 1. type it out literally in clojure code 2. have a macro generate it at macro expansion time 3. get it via reflection ?

bronsa22:12:23

yes, 1&2 are equivalent, I dont know how else you'd expect to do it

bronsa22:12:43

"either statically(1,2) or programmatically(3)" make a total set

qqq22:12:04

lol, it has been said that genius is rephrasing the question so the answer is obvious