Fork me on GitHub
#clojure
<
2016-02-12
>
michaellopez00:02:00

Here’s another - lets you run code in your slides https://github.com/MysteryMachine/jobim

jstokes00:02:32

does anyone know of a way to work with clojure dependencies from source? if im working a lib and an app at the same time

jstokes00:02:57

i usually do the lein install and reload dependency/restart repl route

jaen00:02:15

Checkouts, I think.

jaen00:02:22

Both boot and lein support those.

jstokes00:02:28

interesting.. thanks @jaen, i knew there must be something i was missing

isaac_cambron02:02:33

yup, checkouts is definitely what you want

jtackett02:02:24

Hey anyone know the best way to find a memory leak in clojure?

jtackett02:02:31

looks like I have one in my API

jtackett02:02:40

@anthgur: you might know this ^^^

anthgur02:02:09

have you tried using a JVM profiler?

jtackett03:02:38

@anthgur: actually just found it on my own

jtackett03:02:45

simple mistake by one of our other engineers

jtackett03:02:50

gotta love clojure

jtackett03:02:58

now I’m looking for an online database that provides an API

karol08:02:38

@jtackett: for the future cases there is simple profiler bundled with jdk (in the bin directory) called jvisualvm

meow08:02:37

@karol: Having no prior experience with Java I was unaware of this. Thank you for point it out.

kul09:02:33

hey boot users is boot.core available inside a pod?

kul09:02:37

a simple require fails inside a pod

kul09:02:59

with no such file / ns found error

martinklepsch09:02:04

@kul: it's not. boot.core is where state is stored and pods can't have access to that state/modify it

martinklepsch09:02:34

@kul: also there's #C053K90BR, just FYI simple_smile

kul09:02:51

thanks i will take it over there

jaen13:02:24

On a scale of Rich Would Do It to Totally Unidiomatic how bad is formatting lets like so (if the value I have to bind is so long it would make the code drift too much to the right)?

(let [new-fields
        (dispatch-method
          (:aggregate/fields aggregate)
          event state)]
  #_"rest of code")
compared to more standard way of formatting:
(let [new-fields (dispatch-method (:aggregate/fields aggregate)
                                   event state)]
  #_"rest of code")

jaen13:02:39

I'm unsure about that; I like how it save space

jaen13:02:49

But I don't know how people would look at it

robert-stuttaford13:02:29

totally readable to me. emacs’ cider would line the binding and the form up vertically, if you let it indent for you

dm313:02:51

looks very strange to me (the first one)

jaen13:02:32

Yeah, it looks strange to me as well; but on the other hand I want to avoid the march of the code to the right

jaen13:02:46

I split that out from a bigger function, but it still feels too wide

jaen13:02:56

When formatted the traditional way

dm313:02:05

(let [new-fields (dispatch-method 
                    (:aggregate/fields aggregate)
                     event state)]
  #_"rest of code")

rm13:02:54

for the first, I'd do this:

(let [new-fields
      (dispatch-method
        (:aggregate/fields aggregate) event state)]
  #_"rest of code")

rm13:02:32

because new-fields and (dispatch-method ...) are parts of one vector

dm313:02:55

guess it doesn't really matter

jaen13:02:58

@dm3: I kind of don't like putting the first param on new line, but the way you wrote it looks quite sensible, I guess

jaen13:02:28

@rm: hmm, but if there's more bindings, it would be harder to tell which form binds to which name if they are not indented IMO

jaen13:02:36

And yeah, I agree it's kind of a bikeshed

jaen13:02:52

But was curious what are people's opinions over here

akiva13:02:35

I’d be fine with it. It’s perfectly readable even if it isn’t canon.

sveri14:02:07

Hi, I am looking for a solution to multiple when-lets?

sveri14:02:13

I mean, are there any?

jaen14:02:42

Would be interested also, happens I want one from time to time

jaen14:02:12

I guess sometimes some-> could work, but certainly not in all cases

jcromartie14:02:38

good morning

dm314:02:39

@sveri - something like

(when-lets [x true, y false] [x y])
? If so, there's an example here: https://github.com/ptaoussanis/encore/blob/master/src/taoensso/encore.cljx#L165

sveri14:02:35

@dm3 yes, that looks good, I give it a try, thank you

sveri14:02:55

works nicely, exactly what I want

jcromartie14:02:57

look for when-not-let in my upcoming library "core.blimey"

sveri14:02:13

upcoming?

jcromartie14:02:41

it's a work in progress

jcromartie14:02:34

including many handy macros like (don't ...)

jcromartie14:02:43

which doesn't execute the body in order

akiva14:02:38

Sorry but that library name is hilarious. Penfold lives on.

jaen14:02:10

So can-odd? is it's complement?

jcromartie14:02:11

of course not don't be ridiculous

jaen14:02:39

Drats, and here I thought I was onto something

Chris O’Donnell14:02:55

@jaen: In the sente source code he has some let bindings like you asked about (binding on one line and the value on the next) and he put an empty line in between each of these. I found it very easy to parse.

jaen14:02:39

Yeah, make-channel-socket! seems to be doing something like that

jaen14:02:10

Though I'm not sure if that's readable to me, but maybe due to the sheer size of the function, rather than formatting of the let

jaen14:02:20

I always found sente a kind of confusing

jaen14:02:43

Mostly due to the the variable names reminiscent of Systems Hungarian somewhat though

Chris O’Donnell14:02:02

Yeah, that is an enormous function. I remember having to scroll up and down to figure out where the let bindings end and the body begins.

jaen14:02:28

But I think I like how he laid out destructuring in the argument vector

jaen14:02:33

That certainly feels quite readable (to me that is)

pguillebert15:02:20

wouldn't thread macros help ?

pguillebert15:02:00

(grmbl, disregard. lagging again)

naomarik17:02:45

is it possible to eval the arguments of a macro before it gets passed into it? i'm attempting to call a clojure macro from clojurescript

Lambda/Sierra18:02:06

@naomarik: No, by definition. Macros execute at compile time. By the time your clojurescript code (compiled into JavaScript) is running, the macro no longer exists.

naomarik18:02:27

ahh.. is there a way to pass in a variable in my clojurescript to the macro as an argument?

naomarik18:02:38

passing in a string literal gives me what i want, anything else doesn't seem to work for this

naomarik18:02:08

i guess the next question would be to see if it's possible to include a clojure function that wraps a macro into clojurescript simple_smile just last night i found it's possible to include clojure macros in clojurescript, mind was blown simple_smile

devon18:02:02

Not sure if I completely understand, you can pass in a variable, but if it's something that's not defined at compile time, it can't use it to change what the macro compiles to, you can just place the symbol into new form. For example:

user=> (defmacro foo [thing] `(if ~thing (println "hello") (println "goobye")))
#'user/foo
user=> (macroexpand '(foo bar))
(if bar (clojure.core/println "hello") (clojure.core/println "goobye"))
Note the ~thing which means "don't evaluate this"

bfabry18:02:28

a string literal exists at compile time, that's why it worked. if the value only exists at runtime by definition the macro has no access to it as stuart said

bfabry18:02:25

(defmacro foo [x] (.length x))
=> #'com.zendesk.dataflow.Main/foo
(foo "foo")
=> 3
(def bar "foo")
=> #'com.zendesk.dataflow.Main/bar
(foo bar)
java.lang.IllegalArgumentException: No matching field found: length for class clojure.lang.Symbol

jr21:02:43

I’m trying to understand the semantics of context switching in a go routine. Is there a difference between (go (<! (async-foo))) and (go (blocking-foo)) where the underlying IO adapter blocks for blocking-foo and puts an async result with async-foo?

bfabry21:02:15

yes, you definitely do not want to do the second one. go blocks are executed on a shared limited size thread pool, so if they get blocked by something other than a core.async operation that thread pool can be potentially exhausted. if they're blocked by a core async op, like <! then they relinquish the thread and its put back in the pool

jr21:02:36

perfect that’s what I thought. thank you

jr21:02:24

as in <! and >! are “cues” for context switching

bfabry21:02:32

you could turn (blocking-foo) into a core-async compatible thing with (thread (blocking-foo)) which will spawn a thread to do the io waiting for you