Fork me on GitHub
#clojure
<
2016-10-29
>
yonatanel08:10:19

A clojure promise implements IFn and when invoked as a function (`(p value)`) will behave just like calling (deliver p value). Is there a special reason for this design?

amacdougall16:10:45

Extremely minor question: anyone have a coding style or even a preference about when and where to use ; vs ;; comments? For instance, in JS, Java, and so on, inline comments (`// do the thing`) are frequently highlighted differently from doc comments (`/ Complex explanation with usage examples and whatnot. */`).

josh.freckleton16:10:15

@amacdougall I use ;; for normal indentation-level comments, and ; for inline comments. It's also "a thing" to use ;;;, and ;;;; for different usages, according to different style guides, but, i don't really pay attn to that.

josh.freckleton16:10:48

and I use ;x50 for sortof page breaks

josh.freckleton16:10:40

also, there's (comment ...) which is useful, as well as the reader macro #_(...)

josh.freckleton16:10:53

comment keeps my code colored interestingly, so quicker to read something which I want present in the code, eg for debugging, and I want to be able to execute individual lines out of it, but I don't want it to run on compile (eg when I'm testing db-accessing fns)

josh.freckleton16:10:55

#_ is for just knocking out big chunks of code and whereas comment evaluates to nil, #_ is removed at compile time, so {:a #_(remove me) :Apple} is valid, where as the comment version of it would not be

josh.freckleton16:10:32

(way more than you wanted to know, I'm sure. I just got done playing a touch-typing game and am residually in the mood to type a whole bunch I guess 😉 )

roelofw16:10:26

Can I ask here also questions about the cursive plugin

roelofw16:10:01

I have installed it but when I want to make a repl with new run configuration I do not see anty clojure choice

roelofw16:10:11

anyone a idea what went wrong ?

amacdougall16:10:38

Thanks for the tips! I've been using #_ from time to time, yeah.

matan17:10:41

just curious, why does clojure (1.8) crash on null pointer exception when you forget to use do a la http://stackoverflow.com/questions/6234018/executing-multiple-statements-in-if-else-without-nullpointer-exception

roelofw17:10:55

Someone knows how long it take to get a licence when buying a licence for Cursive ?

matan17:10:04

You would kind of think there'd be a specific error message

jrheard18:10:30

@matan - in that situation, the user is calling (nil nil), so i can kinda see why it throws that exception. i agree that it’s a somewhat hostile error message, though. maybe “nil is not a function” would be more useful?

jrheard18:10:57

(i’m absolutely not part of the clojure team, just some schmo spitballing ideas)

sandqvist18:10:27

@roelofw Ask in #cursive , Colin reads it.

amacdougall18:10:23

Hey, here's one that is really confusing me... I've got a random-walk algorithm which is creating a maze by wandering around a grid creating links between cells. When I run the algorithm from the REPL, it runs like greased lightning. But when I run the same thing as part of a clojure.test test, it's much much slower.

amacdougall18:10:01

...waaaait... let's see what happens if I remove the (clojure.spec.test/instrument).

amacdougall18:10:45

Nope, no change, even after killing and cleaning the test environment.

amacdougall18:10:35

(deftest test-generate
  (let [grid (g/create-grid 10 10)
        maze (aldous-broder/generate grid)
        ; getting to this line takes several seconds
...but in the REPL...
(aldous-broder/generate (g/create-grid 50 50))
...is running the algorithm over vastly more cells, but takes just a few seconds. The (10 10) version is instant.

amacdougall18:10:55

Is the test environment doing anything else which might be slowing me down?

amacdougall18:10:41

I mean, in the meantime I used :test-selectors to just skip that test when I'm not specifically tinkering with it. It's not part of the chain for any other code, so I'm not worried about it breaking incidentally.

jrheard18:10:31

that’s odd

jrheard18:10:59

i wonder if it’s possible to send your test to a REPL connected to your browser and use eg the chrome devtools profiler on it to see what’s happening

jrheard18:10:26

that’s probably what i would do because i like playing with the devtools profiler, but i haven’t ever sent a test to it so i don’t know whether that’s easy or hard

jrheard18:10:38

um right, forgot what channel i was in

jrheard18:10:52

not sure what to do in the context of clojure