Fork me on GitHub
#clojure
<
2017-02-11
>
weavejester00:02:13

@alexmiller Ah, there is? I’ll take a look at the Compiler.

weavejester00:02:56

@bronsa metadata on fns has overhead? Even if you don’t read it?

bronsa00:02:08

it makes the fn a variadic one

bronsa00:02:19

and adds some overhead per invokation

weavejester00:02:13

There should be a way around that, though, surely...

arrdem00:02:23

Unless you run Jaunt’s dev branch, in which case all your fns are several bytes fatter and implement the metadata stuff themselves 😛

weavejester00:02:45

Jaunt is something I haven’t looked at for a while

arrdem00:02:59

It’s dead, Jim

bronsa00:02:59

user=> (defn fn->ns-name [obj] (clojure.lang.Compiler/demunge (first (str/split (.getName (class obj)) #"\$"))))
#'user/fn->ns-name
user=> (fn->ns-name (fn []))
"user"

arrdem00:02:01

It was only ever me, and I had a bunch of unstable idea(s) with no sounding board. Then I got an all python job and here we are.

bronsa00:02:01

this should work fine

dpsutton00:02:36

> If you want a Clojure compatible language, you're gonna have to use Clojure. haha

arrdem00:02:29

I stand by that statement

arrdem00:02:53

but I also wasn’t willing to charge off into the sunset and refactor all of core because I wanted CIDER to still work

weavejester00:02:03

It’s a shame, but entirely understandable.

dpsutton00:02:40

what's the biggest challenge with that? cider-nrepl?

dpsutton00:02:48

or was cider-nrepl running in jaunt as well?

arrdem00:02:15

I think I have upstreamed patches on cider-nrepl for better Jaunt support

weavejester00:02:17

@bronsa Thanks. I should be able to write a function for grabbing all active multimethods, finding their namespaces, and then adding something that clears out any that are slated for reload.

dpsutton00:02:25

oh wow. was it elisp (CIDER) -> clojure (cider-nrepl) -> jaunt backend?

dpsutton00:02:32

yeah i think i've seen a few tickets mentioning jaunt

dpsutton00:02:41

looking back through old tickets

sova-soars-the-sora01:02:21

``
(def nf-atom (atom { :blurbs [ {:bid     172
                                :content "B172"
                                :link "" }
                               {:bid     182
                                :content "B7517"
                                :link "" }
                               {:bid 333
                                :content "S221"
                                :link "" }
                              ] } ))
``

sova-soars-the-sora01:02:00

Say I want to grab the map containing :bid 333

sova-soars-the-sora01:02:27

I could use a good primer on how-to-atom-attribs

arrdem01:02:35

well so deref will get a value out of an atom, :blurbs will get the elements out of your mapping and filter could be used to select an element if you have a predicate function on :bid.

sova-soars-the-sora01:02:21

oh, filter is a new word for me. Thanks @arrdem I'll do more investigating

rparra02:02:18

why is (apply str (butlast “hello:”)) correct but (-> "hello:" butlast #(apply str %)) is not? What am I missing?

pbostrom02:02:01

@rparra it has to do with macro expansion... #(apply str %) gets expanded to (fn [x] (apply str x)), and the -> macro expands everything as (fn (butlast "hello:") [x] (apply str x)), which is invalid Clojure syntax

rparra02:02:31

thanks for such a clear explanation. I found this example useful too: https://clojuredocs.org/clojure.core/-%3E#example-572e46e1e4b039e78aadabfc

rparra02:02:16

thanks to your example, I can understand why the extra parens pair works 🙂

isaac_cambron05:02:25

@rparra consider (->> "hello:" butlast (apply str)) to avoid creating and executing that funtion

danielstockton07:02:56

Can anyone give me advice on how to profile my code?

zane07:02:37

I've heard good things about YourKit.

danielstockton08:02:43

Ok, thanks, probably best if I just pick one and try it so let's try this one.

danielstockton08:02:41

Hmm seems to be a paid product. I'd prefer something open source or at least free 😛

robert-stuttaford08:02:29

@U0DHDNZR9 JMC, built into Oracle Java 8. basically gives you YourKit. run jmc and attach to a process, start recording, do stuff, inspect results

danielstockton11:02:09

@U0509NKGK Thanks, I remember hearing about that before but I forgot, think it's what I wanted to hear again. Tend to prefer built-in simple stuff.

danielstockton11:02:21

Ah, it is an Oracle add-on though.

danielstockton12:02:52

I've been trying to VisualVM, connecting via jmx and running bits of code through cider. It seems to hang and then crash with an error 😞

danielstockton07:02:54

VisualVM, tufte...?

triss14:02:58

hello clojure people. what’s the neatest way to fill a vector of vetors with a random integer in your opinion?

triss14:02:07

i usually end up with something horrible like this monstrosity: (vec (repeatedly n #(vec (repeatedly n (fn [] (rand-int n))))))

pesterhazy14:02:51

looks good to me?

triss14:02:30

aesthetically it bothers me

triss14:02:47

especially when i start using more interesting things for n

triss14:02:21

and i seem to do it quite a bit these days

triss14:02:39

maybe i need to look at matrix/incanter for helpers

pesterhazy14:02:42

(partition 5 (repeatedly 25 #(rand-int 25)))

pesterhazy14:02:03

vectors: (->> #(rand-int 25) (repeatedly 25) (partition 5) (map vec) vec)

triss14:02:05

nice… but not vectors

pesterhazy14:02:39

you're welcome

sveri14:02:47

Hi, using sente I always wondered if I have to handle the :chsk/ws-ping message somehow? It seems like I can just ignore it, at least in the sente context

bcbradley15:02:55

I need to call a function with side effects once every N seconds

bcbradley15:02:23

how would I do that without spinlocking a thread?

pesterhazy15:02:14

A separate thread, Thread/sleep?

Alex Miller (Clojure team)16:02:32

Java has a ScheduledExecutor for this

dominicm19:02:21

Bit confused about clojure.zip/path, I was expecting to get something like [:foo :bar 0] but I've got what looks like a "history" of positions, is there some way I can convert between the two?

hiredman19:02:09

you can a list of zippers

hiredman19:02:54

or "locs" in the parlance of clojure.zip

dominicm19:02:43

@hiredman Not sure I understand, I was hoping to get [:foo :bar 0] for {:foo {:bar [:baz]}} where my current location was :baz

hiredman20:02:34

Right, what paths returns is a list of zipper locations, the same thing you see at each step if you did a bunch of z/down calls

hiredman20:02:10

And the way you extract your values from the is via z/node

hiredman20:02:53

But you'll need to know how to extract the information you want from each node

dominicm20:02:06

@hiredman oh, I think I see now. I'm not interested in the paths for information extraction, I need to determine the correct order to call a function on certain nodes (`[:foo :bar]` depends on [:foo :baz], so I must call (f m (get-in m [:foo :baz])) before (f new-m (get-in new-m [:foo :bar])))

mobileink20:02:43

licensing question. if i crib a few lines of code from clojure.core, do i need to include the copyright thing? if i write 99% of the code but 1% is cribbed from clojure.core, ??? i can see sth like "portions copyright Rich Hickey" or some such, but i'm unsure of the legal requirements, obligations, etc.