#clojure log - May 07 2014

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:08 Jaood: so why does lein repl switches you to the core.clj namespace in the the app template and not in the library template?

0:08 gtrak: Jaood: the :main controls this

0:09 or :init-ns

0:09 if there's no -main

0:09 in repl-options

0:09 https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L308

0:11 Jaood: gtrak: oh I see, thanks

0:26 rhg135: So I have some shared state, a map, and need to use it concurrently to perform io, so can't swap!, any ideas?

0:26 gtrak: rhg135: you'll have to be more specific.

0:27 rhg135: How so?

0:27 gtrak: I don't know :-)

0:27 rhg135: I figured it was a dead end

0:27 gtrak: I guess, what's in the map, what's the IO?

0:27 what needs to be concurrent?

0:28 rhg135: The io is a async put!

0:29 gtrak: async put from the map, or into the map?

0:29 rhg135: This is for an irc/xmpp server

0:29 A channel in the map

0:30 gtrak: so, you're doing put! into a channel, what's the map got to do with it?

0:31 rhg135: I need to access and update it but do io meanwhile

0:31 gtrak: you need change the channel out, or something else?

0:32 rhg135: Yes

0:33 gtrak: is there supposed to be some kind of coordination or synchronization? Ie does the thing that puts have an opinion about what channel it ends up going on?

0:34 err.. I guess, what's it supposed to do..

0:34 if you want to distribute requests across a bunch of channels, you could just use a lazy sequence.

0:34 rhg135: I'm probably doing it wrong but the channel writes to a client

0:36 gtrak: now that sounds like a lookup table of ID->client-channel.

0:36 rhg135: Basically

0:36 gtrak: so.. you don't need to be swapping out channels, just adding or removing them.

0:37 rhg135: It's actually bigger

0:37 gtrak: if each client has a unique id.

0:37 rhg135: It has chat channels too

0:37 And they do

0:40 If this was sequential I could use a reduce, that concurrency

0:41 gtrak: yea, I guess the intrinsic structure of it isn't obvious to me.

0:42 rhg135: I think I know how, when I get to my computer I'll paste it

0:48 {:users {:an-user {:chan <ch> :timeout <number> :channels ["#clojure"]}}} ; state, gtrak

0:49 gtrak: my suspicion is you're trying to do something manually that could be better expressed as go-loops.

0:50 or some other kind of built-in glue.

0:51 rhg135: I am but I'm struggling with managing this state

0:51 gtrak: you shouldn't have to look up channels to put! every time, it sounds like a job for tap and mult.

0:52 or the pub/sub stuff.

0:52 rhg135: Hmm

0:52 I didn't know

0:54 Any good examples?

0:55 gtrak: haven't used it myself, but I found this: https://github.com/halgari/clojure-conj-2013-core.async-examples/blob/master/src/clojure_conj_talk/core.clj#L394

0:55 I've had to stare at the source to get anywhere in core.async.

1:37 Mongey: Hey, can someone help explain how this piece of code works?

1:37 https://gist.github.com/Mongey/adbdd1519549ece3c313

1:38 arrdem: ,([1 2 3 4] 2)

1:38 clojurebot: 3

1:38 arrdem: wat

1:38 Mongey: is that a hint?

1:38 Mongey: a hint ?

1:39 arrdem: Mongey: what do count, range, map om/build and comment-data do as functions?

1:40 Jaood: Mongey: what don't you understand about the code?

1:42 Mongey: Jaood: what the "#(" infront of the om/build does

1:42 arrdem: in fairness explicit types would make that a little easier to understand, but only bearly.

1:42 *barely.

1:42 Mongey: #() creates an anonymous and presumably partially applied function

1:42 ,(#(+ 1 %1) 2)

1:42 clojurebot: 3

1:43 arrdem: ,(#(into [] [%]) 1 2 3 4)

1:43 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: sandbox/eval77/fn--78>

1:43 arrdem: crud.

1:43 Mongey: ok, I guess that makes sense.

1:43 arrdem: Oh. % == %1

1:44 ,(#(+ % 1) 1)

1:44 clojurebot: 2

1:44 arrdem: yep.

1:44 Jaood: Mongey: yeah, what arrdem , its syntax for function literals

1:44 *said

1:45 Mongey: and then % is the first argument ?

1:46 Jaood: yes

1:46 MarlaBrown: (d/q '[:find ?nick ?channel ?text :in $ ?nick :where [?m :message/author ?nick] [?m :message/text ?text] [?m :message/channel ?channel]] (d/db @conn) "Jaood")

1:46 #{["Jaood" "#clojure" "*said"] ["Jaood" "#clojure" "Mongey: yeah, what arrdem , its syntax for function literals"]}

1:46 arrdem: well... strictly only argument.

1:46 * MarlaBrown goes back to the corner

1:46 gws: Mongey: one confusing thing might be the use of comment-data as a function - when you do that its argument must be an integer and it's the key into the vector you want to retrieve

1:46 arrdem: MarlaBrown: wat

1:47 MarlaBrown: i c u writing datomic queries...

1:47 gws: ,(["foo" "bar"] 0)

1:47 clojurebot: "foo"

1:47 gws: Mongey: ^

1:48 Mongey: I see

1:48 MarlaBrown: its more like a function being called on a value than a "query" ;)

1:50 arrdem: heh

1:51 Jaood: arrdem: why does a CinC still doesn't exist if there already is a Clojure compiler to bootstrap it? or it ain't that easy? :)

1:51 arrdem: Jaood: CinC does exist... it''

1:51 it's just tools.analyzer and tools.emitter.jvm

1:51 and my yet to be named GSoC compiler...

1:52 which I actually should talk to tb and bronsa about naming...

1:52 Mongey: makes sense now, thanks

1:52 Jaood: oh haven't seen those, can you resume what each one of those do? :)

1:53 arrdem: "resume"?

1:53 Jaood: I guess one emits java bytecode and the other is the parser?

1:53 Jaood: forgot the word, not a native english speaker

1:54 maybe 'explain' would had been better

1:54 arrdem: tools.reader is a lexer/parser, tools.analyzer is a metadata analysis framework and tools.emitter and tools.emitter.jvm are bytecode generators

1:55 Jaood: 'explain' or 'revise' would have been legitimate, although 'revise' would be a relatively archaic word choice.

1:55 'review' could have made sense too.

1:55 Jaood: arrdem: thanks

1:56 irctc: hey all... for anyone who uses incanter here... trying to do a simple x y axis plot with dates... using time-series-plot but the formatting of the dates on the x-axis is really unexpected. would someone mind enlightening me as to what's wrong with this code here?

1:56 http://postimg.org/image/kra5hs4yl/

1:56 Jaood: arrdem: so you are going create a standalone compiler out of those tools?

1:56 irctc: mail

1:57 arrdem: Jaood: out of the reader and analyzer at least. I'll be building a very different emitter I suspect.

1:58 Jaood: arrdem: so the compiler won't need to rely on ASM anymore right?

2:00 arrdem: Jaood: my compiler will probably still use ASM unless someone convinces me to extend my existing bytecode library to emit jvm bytecode. My goal is to build an alternate compiler which performs some relatively aggressive optimization and analysis at the expense of generating very different bytecode than standard Clojure.

2:00 where the tools.emitter.jvm system strives for bite-for-byte parity in emitted code.

2:01 Jaood: interesting, good luck then!

2:08 amalloy: tools.emitter.jvm aims for byte-compatibility? i thought bronsa was touting its ability to not emit unnecessary casts

2:09 arrdem: amalloy: that may be the case, but the point is that it's shooting to be a stable drop in replacement for the existing compiler that behaves almost identically besides being written in Clojure. Or at least that's my understanding.

2:13 Jaood: arrdem: is the reason bytecode backward compability?

2:32 sm0ke: hey i have a profile in lein :foo with :test-paths ["foo"] and /foo is a top level directory, but when i do `lein with-profile dev,foo test` even the regular tests are also running

2:36 jeremyheiler: sm0ke: the test command automatically merges in the test profile

2:38 sm0ke: hurm

2:40 https://github.com/dakrone/cheshire/blob/master/project.clj

2:40 this seems to be working

2:40 jeremyheiler: a shot in the dark, but maybe try `lein with-profile -test,dev,foo`

2:40 sm0ke: dont know how

2:40 the benchmark profile in that

2:41 seems to run only benchmark tests with mucking around with anything else

2:41 without*

2:43 weird i doubt if it has something to do with selectors

2:43 even the benchmark tests are not anootated ^:benchmark

2:43 impossibru!!

2:44 foofoobar: Hi. I'm doing clojure koans: "Higher-order functions take function arguments": (= 25 (___ (fn [n] (* n n))))

2:44 How to solve this?

2:45 arrdem: I'd use #(% 5) for _

2:46 MarlaBrown: (find-partial "solve" (d/db @conn))

2:46 #{["foofoobar" "#clojure" "How to solve this?"]}

2:46 arrdem: MarlaBrown: you keep doing that...

2:46 MarlaBrown: i need sleep

2:46 * MarlaBrown goes to bed

2:46 arrdem: MarlaBrown: coffee?

2:46 or that... I should do that too.

2:46 * arrdem checks that his own shady logging engines are still at play

2:47 foofoobar: arrdem, ah, an anonymous function, thanks for the hint!

2:47 MarlaBrown, what should this tell me?

2:48 MarlaBrown: foofoobar: the nsa is everwhere man

2:48 prism + datomic == love

2:48 arrdem: and if the NSA isn't listening then some other jackarse is for their own entertainment :P

2:48 MarlaBrown: :thumbsups:

2:48 arrdem: I need to get an emacs plugin to render those as glyphs

2:49 * arrdem hits the sack

2:49 MarlaBrown: clojure needs an emoji reader macro

2:50 arrdem: I'm a fan of this...

2:51 MarlaBrown: #/smile/

2:51 arrdem: ha

2:51 well what you could do is #emoji :smile:

2:51 ,:smile:

2:51 clojurebot: #<RuntimeException java.lang.RuntimeException: Invalid token: :smile:>

2:51 arrdem: or not...

2:52 MarlaBrown: dispatch macro needs a leading character

2:52 arrdem: you could totally do #emoji "smile", and maybe #emoji smile

2:52 sm0ke: arrdem: no you cant

2:53 #my/emoji "simle" is possible though

2:53 smile*

2:53 MarlaBrown: #emo/ji smile

2:53 arrdem: oh. right. סּ_סּ

2:54 sm0ke: #emo/ji ":P"

2:54 arrdem: pls can make this a thing and add clojurebot support for it

2:54 will gladly put 10kDOGE bounty on it :P

2:54 or I should say ###emo/ji "=D"

2:55 funny... lazybot shoulda seen that one.

2:56 sm0ke: hmm ## '?

2:56 lazybot: ⇒ ?

3:06 MarlaBrown: watcher.core=> #emo/ji hearteyes

3:06 "😍"

3:06 my poor project

3:09 arrdem: :bowtie:

3:09 :D

3:10 foofoobar: arrdem, again stuck: "Numbers are not the only things one can reduce": (= "longest" (reduce (fn [a b] (if (< __ __) b a)) ["which" "word" "is" "longest"])))

3:11 arrdem: foofoobar: what is a string?

3:11 foofoobar: a char sequence?

3:11 arrdem: Bingo! How do we get the length of a sequence?

3:12 foofoobar: count

3:12 arrdem: Right. that should be all you need.

3:12 foofoobar: ah, got it working :)

3:12 Nice, thank you!

3:13 I thought doing something like (< "foo" "foobar") aready compares the lengths

3:14 arrdem: :-1:

3:14 bracki: Having a hard time with: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol

3:15 What is usually calling this? I can't neither repl,run nor uberjar

3:15 s/ll/us/

3:17 All I do is try to (:use clj_finagle.core).

3:18 Can anybody spot what's wrong here: https://github.com/jcrean/clj-finagle/blob/master/src/clj_finagle/core.clj#L31?

3:18 arrdem: ,(println ":wink:")

3:18 clojurebot: :wink:\n

3:20 devurandom: Hello!

3:21 I still have to get used to thinking in Clojure:

3:21 beamso: lein try clj-finagle downloads teh intarwebs

3:22 wink: o_O

3:23 devurandom: I have an (atom {:foo {:bar {:some data}}}) and I want to update it by adding something for every element of :foo :bar, so that it looks like: (atom {:foo {:bar {:some data :more date}}})

3:23 How do I do that properly?

3:24 jeremyheiler: devurandom: what do you mean by "for every"?

3:24 MarlaBrown: watcher.core=> (println "not sure if I" #emo/ji heart " you, or think you smell like" #emo/ji poop)

3:24 not sure if I 😍 you, or think you smell like

3:25 devurandom: Sorry, actually it is (atom {:foo {:bar {:some data} :baz {:other data}}}) -> (atom {:foo {:bar {:some data :more data} :baz {:other data :even more}}})

3:25 MarlaBrown: it truncated my emoji

3:25 :(

3:26 devurandom: jeremyheiler: :foo contains lots of keys, and for each I have already set some data. Now I want to add other data (that is used by another part of the program) to the existing keys.

3:26 beamso: bracki: at a guess the defn for processor is lower in the source code than the defn for rpc-service-impl

3:27 devurandom: I did something like (swap! the-atom assoc :foo (map (fn [k v] ... new-v) (:foo the-atom)), but that does not seem to do what I want.

3:28 jeremyheiler: devurandom: maybe get all the keys and reduce over them, updating the atom on each step?

3:28 (reduce (fn ...) the-atom (keys you want to update))

3:30 devurandom: Hm. the-atom contains the :foo key in the first level, and what I want to update is the map inside :foo. Can I update iterate over all keys in (:foo the-atom) and update them with what you wrote?

3:31 jeremyheiler: (keys (:foo @the-atom)) will get you the keys you want

3:31 well, at least all teh keys in teh :foo map

3:33 amalloy: devurandom: (swap! the-atom update-in [:foo] (fn [foo] (reduce ...)))

3:36 arrdem: w00t managed to get the "standard" github emoji installed into erc-smiley :D

3:45 devurandom: amalloy, jeremyheiler: Thanks!

3:46 MarlaBrown: erc-smiley?

3:46 ah emacs

3:52 foofoobar: (= (repeat 100 :foo) (take 100 (iterate __ :foo))))

3:52 Which functions combines them ?

3:52 Glenjamin: ,(doc iterate)

3:52 clojurebot: "([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"

3:52 TEttinger: so identity?

3:53 Glenjamin: ,(= (repeat 100 :foo) (take 100 (identity :foo))))

3:53 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>

3:53 Glenjamin: ,(= (repeat 100 :foo) (take 100 (iterate identity :foo))))

3:53 clojurebot: true

3:53 Glenjamin: typo :)

3:54 foofoobar: ,(doc identity)

3:54 clojurebot: "([x]); Returns its argument."

3:54 foofoobar: oh, simple.

4:21 roelof: how can I destruct this the right way: http://pastebin.com/dTnKbazt

4:26 maxthoursie: roelof: seems you got some unbalanced paranthisis there?

4:26 roelof: maxthoursie: sorry what do you mean with that ?

4:29 maxthoursie: reiddraper: there's too many square brackets

4:29 sorry, wrong completion

4:30 roelof: ^

4:33 roelof: maxthoursie: oke , I think the problem is in the let part. I have to destruct two variables rectangle and point. Maybe use two times let ?

4:33 maxthoursie: roelof: no need for that

4:33 roelof: (let [[[xr1 yr1] [xr2 xr2]] rectangle

4:33 [xp yp] point]

4:34 roelof: yep, that part I mean

4:34 maxthoursie: roelof: that's rewritten in a way that works

4:34 roelof: I think I have done something wrong there but I have no idea what

4:35 maxthoursie: roelof: hm so how would you write it with two lets?

4:36 roelof: oke, I see where i go wrong. the first [ has to be when all variables are decontruct

4:37 maxthoursie: roelof: also, double check your var nams, xr2 appears twice

4:38 roelof: oke, done that but still a problem. When I do (contains-point? (rectangle [0 0] [2 2]) (point 1 1)) it must be true and my form says false

4:39 found it another variable error

4:40 maxthoursie: good

4:43 clgv: roelof: if you want that function to be robust you should sort x and y coordinates of the rect each

4:45 roelof: clgv: I see what you mean. How can I implent sort into it . Im trying to learn clojure by the iloveponies github lessons

4:47 maxthoursie: roelof: you could just (sort [xr1 xr2)) and deconstruct that

4:48 roelof: In this case just using an or to also check for the (< xr2 xp xr1) case is simpler

4:49 clgv: roelof: for two values just via `if` ;)

4:49 roelof: oke , thanks for the little lesson

4:49 clgv: but maybe the suggested solution via `or` is shorter

4:50 ,(let [a 2, b 1, [a b] (if (< a b) [a b] [b a])] (println a b))

4:50 clojurebot: 1 2\n

4:51 clgv: roelof: one option for inline sorting. ^^

4:52 roelof: oke, I see how it works

4:52 maxthoursie: roelof: to make it readable, I would go with a helper function

4:52 roelof: (defn within [a b p] (or (< a p b) (> a p b)))

4:54 roelof: oke, Im now at a exercise where I must check if a rectangle is in another rectangle. I destruct it and I think now I see a lot of and for this

4:56 I have to check for every point of the smaller rectangle if its true or false and I can use the fuction I wrote containspoint ?

4:56 maybe a cond ?

4:57 maxthoursie: roelof: just play with it

4:59 roelof: I know, I m thinking aloud sorry

4:59 maxthoursie: np

5:54 dhruvasagar: Hey guys, can someone recommend a good web framework ? I am looking at Luminus & Noir

5:55 maxthoursie: dhruvasagar: My recommendation would actually be to start with something basic like only ring+compojure

5:55 dhruvasagar: Then you will know what you want after a while

5:55 dhruvasagar: maxthoursie: hmm and that would be good because i'd learn the internals ?

5:57 maxthoursie: also, would you recommend a good book for clojure ?

5:57 maxthoursie: s/would/could

5:57 maxthoursie: dhruvasagar: well, internals feels like a harsh word, basics maybe. Most web stuff in clojure is based on ring

5:58 dhruvasagar: I like The Joy of Clojure since it focus more on how to think than how to do

5:58 dhruvasagar: maxthoursie: cool, I think I already have that book, i'll read it :)

5:59 maxthoursie: thanks

5:59 maxthoursie: np

6:05 sm0ke: :D

6:06 systemfault: I bought JoC… I hated reading it :P

6:06 maxthoursie: systemfault: why?

6:06 locks: systemfault: :O

6:07 systemfault: maxthoursie: The content is very good but there are way too much explainations… to me, it was boring.

6:07 clgv: dhruvasagar: in case you are knew to lisp start with "clojure programming" or "programming clojure (2nd edition)" - read the example chapters to see which writing style you like more

6:08 *new

6:08 maxthoursie: systemfault: well, I can agree with that it was slow at times

6:10 locks: _slow_?

6:10 did you know Lisp already?

6:13 Morgawr: my favorite clojure books are Clojure programming and The Joy of Clojure

6:14 I also read High Performance Clojure Programming (or something like that) which is really good, goes very deep into the tuning of clojure (and also java/jvm) programs and how to get the most juice out of the CPUs

6:14 systemfault: Morgawr: I should buy Clojure Programming.

6:14 Morgawr: I have it on my bookshelf and often go back to it to read a few paragraphs of stuff I forgot or I want to know more about, it's good

6:17 clgv: systemfault: are you sure? if you found JoC slow, I cant imagine what you say about the "Clojure Programming"

6:18 Morgawr: maybe just give it a quick look and check the index of the chapters and read a few pages in and see if it suits you before buying it

6:18 systemfault: Ah :/

6:18 Morgawr: I mean, we have the ~internet~

6:18 * Morgawr winks

6:22 maxthoursie: I find it slow when they just walk through every part of the lib like a reference manual. For me it's how to think in fp and organize code and such which is really new and hard to lookup

6:23 Morgawr: I personally find quick blog posts and videos of conference talks to be more suited for that kind of approach, I prefer to use books as quick reference and additional support to language feature and APIs

6:23 but this is just personal preference

6:23 maxthoursie: I like it better when functions are introduced when needed by a larger example, than just linearly by namespace

6:24 Morgawr: Interesting, I tend to find the opposite. Reference type stuff is easy for me to look up on the internets. How to think is harder

6:26 clgv: maxthoursie: then the writing approach of "Clojure Programming" suits you, right?

6:27 maxthoursie: clgv: Yes, I liked that one

6:27 Keep mixing it up with the M-t version though

6:27 clgv: "M-t"?

6:28 maxthoursie: as in the emacs command

6:28 that is swap words

6:28 Morgawr: I found "programming clojure" to be pretty poor imo compared to the others, but I didn't read it whole (only a few chapters here and there)

6:28 clgv: lol. emacs shortcuts as abbreviation for words in a sentence...

6:29 Morgawr: it also works in bash to swap characters :P

6:29 maxthoursie: Morgawr: I agree, that's the book I've liked the least, but also didn't read it.

6:29 fully

6:29 clgv: I'd describe the wrinting style of "Programming Clojure" as much more technical...

6:30 but you are able to read through it in approx. 3-4 days and have learned the most important basics.

6:33 maxthoursie: Isn't that true for most of the books on clojure?

6:37 mengu: i've read programming clojure probably 3 times

6:37 and on the 4th time, i got it

6:37 but that's just me, an idiot, who takes his time to grasp things :-)

6:39 locks: mengu: so a normal person then :P

6:39 mengu: well, on the 4th time, i sat down and said to myself; i'm going to understand this book now. :-D

6:50 clgv: maxthoursie: I could only read the first book fulltime, so I dont know ;)

6:53 maxthoursie: I've read five books on clojure, and it starts to feel like they're all the same

6:57 sw1nn: mpenet: I'm looking at hayt - what's the preferred way to handle clj 'kebab' style keyword identifiers. It looks to me that the CQLEntities for Keyword needs a tweak? Here's a gist showing my experiments: https://gist.github.com/6193e97b421e8d317e72

6:58 maxthoursie: sw1nn: how do you get a cider-scratch buffer?

6:59 sw1nn: maxthoursie: M-x cider-scratch

6:59 maxthoursie: I don't have that, version?

7:00 sw1nn: CIDER 0.7.0alpha (package: 20140505.1132)

7:00 it claims C-j evals last sexp, but I don't have that, haven't investigated.

7:01 dhruvasagar: clgv: thanks

7:01 sw1nn: so I use C-x, M-e

7:01 maxthoursie: seems like I'm on cider 0.5

7:02 clgv: maxthoursie: well would be odd if it were different, then some books would tell you bullshit ;)

7:02 maxthoursie: clgv: haha, well, in a way that's true.

7:07 mpenet: sw1nn: the cql spec wants quotes around identifiers with -

7:07 sw1nn: hayt does this for you if you just use a string

7:07 sw1nn: mpenet: yes, but the keyword handling in CQLEntitie protocol doesn't put them in

7:07 mpenet: (select :meta-data (columns "a-b" "b-c") (where [[= "a-b" "foo"]])) should do it

7:07

7:07 hmm

7:08 sw1nn: mpenet: is there a downside to doing it for keywords too?

7:08 maxthoursie: sw1nn: works great, thanks for the tip

7:08 mpenet: sw1nn: perf hit for the most common case imo

7:09 sw1nn: mpenet: most common case is to use strings for column names? really? would have thought keywords would be more common?

7:09 mpenet: no, I mean double quoting always

7:09 ex you could have an id that's namespaced foo.bar

7:10 foo."bar-baz"

7:10 etc

7:10 sw1nn: mpenet: ah, hadn't thought of that.

7:10 mpenet: I did took some liberties in the name of performance too, kw are the most common, kw including dashes not so much

7:11 just quote them when it's the case and you ll be good

7:11 (->raw (select :meta-data (columns "a-b" "b-c") (where [[= "a-b"

7:11 "foo"]])))

7:11 "SELECT \"a-b\", \"b-c\" FROM meta-data WHERE \"a-b\" = 'foo';"

7:12 also CQLEntities follows the definition of the CQL spec to the letter, it's used in tons of places, so I aimed for a behavior that matches best (imho) the spec

7:13 I mean cql-identifier

7:14 sw1nn: keywords with dashes are very common in my code, maybe I'm odd in that regard?

7:15 mpenet: well, let's just say it's not so common in CQL usually, it's very clojure-like mostly

7:15 mostly because it forces to use quoting, and people are lazy :)

7:16 but you can extend the protocol for your use I guess, it should do no harm

7:17 sw1nn: so, summary is 'using identifiers with - is not common for CQL, so choose clojure keywords without dashes or make sure you quote before passing to hayt"?

7:17 mpenet: anyway, thanks for the help

7:17 mpenet: yes, the short version is when using clj keywords as cql identifiers no quoting happens, ever

7:19 might be of interest : http://cassandra.apache.org/doc/cql3/CQL.html#identifiers

7:21 maxthoursie: deobalds: did you get cider 0.7.0 to work? I'm running into the same problem as you did on the 1:st of may

7:21 devurandom: I have a (def state {:foo {[1 2] :bar [3 4] :baz}}) and want to access (-> state :foo [x y]), but it does not work this way (no item ... in vector of length 2). How does it work?

7:24 emlyn: devurandom: I think you want (get-in state [:foo [x y]])

7:25 devurandom: what you have expands to ([x y] (:foo state))

7:26 joelkuiper: Hey! I'm trying to dynamically load a file (outside of classpath) and refer to a specific var in it

7:26 maxthoursie: devurandom: and a vector is not a function

7:26 deobalds: maxthoursie: Nope. :( Sadly, we just rolled everyone back to 0.6.0.

7:26 maxthoursie: deobalds: how do you downgrade with package-install?

7:27 joelkuiper: What I do right now is slurp the file then load-string and then (var-get (intern (symbol "the persumed namespace") (symbol "var")))

7:27 is that the best way to do it?

7:27 devurandom: emlyn, maxthoursie: Thanks!

7:28 joelkuiper: It's basically my code, so it can be assumed safe. By naming convention I ensure that the path of the file and the ns are the same (such that intern knows the ns where to look)

7:33 deobalds: maxthoursie: Again, sadly... we just copied over someone's emacs.d who hadn't upgraded yet. :/

7:33 maxthoursie: deobalds: yupp, doesn't seem to be another way

7:33 joelkuiper: this is what I mean: https://gist.github.com/joelkuiper/e9d34f3053fa795a5cd3

7:34 (loading a var from a file)

7:34 maxthoursie: deobalds: successfully downgraded manualy. Thanks for your info.

7:36 joelkuiper: "concrete use case, I have some third-party definable processing stuff that I wish to call, without knowing beforehand which are availabel

7:36 so they are put in some resource folder

7:36 and I attempt to load them at runtime with some naming conventions

7:38 (by third-party I mean trusted third-party, so whatever is in those files I assume safe)

7:56 clgv: joelkuiper: whats wrong with "load-file"?

7:58 f3ew: What's the clojure equivalent of Perl's Data::Dumper?

7:58 deobalds: maxthoursie: How did you downgrade manually, out of curiosity?

7:58 maxthoursie: deobalds: I had an old copy of my .emacs.d, just as you said

8:01 * f3ew needs to do the equivalent of Dumper(@_)

8:03 broquaint: f3ew: pprint? http://clojuredocs.org/clojure_core/clojure.pprint/pprint

8:04 ssideris: f3ew: pprint for pretty output, pr-str for everything in one line. Those can be eval'ed in after they've been written out to strings, but this is not best practice. Check clojure.edn

8:06 * f3ew found pr-str, now to figure oout what arguments are being passed into this function

8:06 f3ew: out*

8:06 Is there the equivalent of @_?

8:06 ssideris: nope

8:06 you can pass any data structure to pr-str

8:07 ,(pr-str [1 2 3 #{10 20}])

8:07 clojurebot: "[1 2 3 #{20 10}]"

8:07 joelkuiper: Right so I updated the thing; but I feel it's completely stupid https://gist.github.com/joelkuiper/e9d34f3053fa795a5cd3

8:07 ssideris: it just turns it into a string that can later be read by clojure.edn/read-string

8:07 f3ew: Lovely. How do you figure out what is being passed to a function (I'm trying to write an input parser, and I don't quite grok where the hook in this code fits in)?

8:08 The point of trying to dump the input is so that I can actually see WTF is happening

8:08 ssideris: f3ew: https://github.com/clojure/tools.trace

8:09 using this will allow you to say deftrace instead of defn when defining your function, which will print out all input params and the result every time the function is called

8:11 systemfault: Looks awesome, thanks ssideris :) (Still learning)

8:11 ssideris: no prob

8:12 do you have a REPL?

8:12 systemfault: f3ew: Must be quite a jump from Perl to Clojure :/

8:12 ssideris: I can't believe I used to like Perl. No disrespect f3ew

8:13 systemfault: perl has map()!

8:13 systemfault: awesome! What are you waiting for to write a blog called “Perl is a functional programming language” and post it on HN? ;)

8:15 broquaint: It's not really a functional language but functional techniques can be applied - http://hop.perl.plover.com/

8:15 ssideris: broquaint: I was about to mention that book :-)

8:30 devurandom: Thanks again everyone for your tremendously useful help! My app runs now nicely, after porting it from JS! :)

8:31 Of course, I assume there are still lots of things that can be improved, once I know Clojure better.

8:32 CookedGryphon: Has anyone here used jayq? I'm getting issues with No such namespace $

8:32 anybody got ideas as to what that means?

8:34 beamso: have you included jquery?

8:34 CookedGryphon: yes, in a script tag

8:35 when I put it in :externs I got all sorts of warnings as it tried to parse the jquery file

8:35 ssideris: CookedGryphon: I haven't used it, but interestingly, this commit seems to be about $ as a namespace: https://github.com/ibdknox/jayq/commit/297fbf394e91a89d3ebe75f60363b8d1492621c4

8:36 CookedGryphon: ssideris: interesting, I noticed that commit but didn't actually look at it

8:36 I assumed it had made it into the latest release

8:36 as it was so long ago, and the current project.clj says the same version I got from clojars

8:37 but looking at the source on my machine, that doesn't appear to be the case

8:37 beamso: jquery is in the page before jayq?

8:38 CookedGryphon: beamso: yeah

8:38 does clojurescript know not to munge my calls out to jquery?

8:38 beamso: no idea

8:38 http://hugoduncan.org/post/clojurescript-libs-with-js-dependencies/

8:41 jcromartie: what is a good naming convention for reference type variables

8:41 like, delay, future, atom, etc.

8:42 like, if I had (let [x (some-expensive-op)] …) and I changed it to (let [x (delay (some-expensive-op))] …)

8:42 I would want to change the name x

8:42 but to what?

8:42 x-ref?

8:43 CookedGryphon: ssideris: so I built from master and that seems to do away with the warnings interestingly

8:43 clgv: well they are IDerefs ro "ref would fit if it is not misinterpreted to refer to a "ref" only

8:44 jcromartie: yeah

8:52 ssideris: CookedGryphon: hm, good to know... maybe you should insist that the developers release a new version

8:52 CookedGryphon: ssideris: yeah, I'll file an issue

9:33 mdrogalis: Howdy folks. I'm working on a project that needs to include a dependency in a Leiningen project. I'm not allowed to have the source to the dependency for legal reasons. Whenever I include the jar in the project file, it's unable to resolve it's dependencies. How does one work around that?

9:34 agarman: what dependency?

9:34 mdrogalis: Client's in-house library. Nothing public.

9:35 Can't use an uberjar since that's not meant for Maven.

9:35 agarman: k, you need to put the jar into a local repos

9:35 mdrogalis: agarman: Indeed. I've installed it into .m2

9:36 agarman: the path has to be correct

9:36 mdrogalis: agarman: I'm sorry, which path?

9:36 agarman: the path in .m2

9:37 mdrogalis: agarman: Right, it's successfully installed with the appropriate group, artificat id, version, and packaging parameters.

9:40 Huh, fixed it. I decompressed the jar, moved the pom.xml file and replaced the one in .m2. *Shrug*

9:40 Perhaps I hit a bug or something. Thanks!

9:42 mskoud: I'm using a future to repeat a task every 5 seconds (while true (do xx sleep)), but after some days the future has stopped. Will an exception in the future stop it? How can i detect if a future stops?

9:44 agarman: exception in the do will break your while loop and percolate up to the future

9:44 breaking the future

9:45 mdrogalis: mskoud: If you're running a process for days on end, you might want to use something more robust for daemons.

9:45 justin_smith: mskoud: you can call done? to see if a future has completed

9:45 also agents have some built in features for specifying an error handling function

9:45 agarman: or just deref and see if you have an exception

9:46 justin_smith: agarman: well the deref will block if the future has not completed

9:46 mskoud: the future never ends, its a loop which sleeps for some secs and do some work and repeat.

9:46 justin_smith: mskoud: it will end and done? will return true if an exception breaks the while loop

9:47 mskoud: yes right.

9:47 but i would need to deref within regular intervals to check if it return an exception.

9:48 maybe futures it not the way to go.

9:51 ssideris: mskoud: because futures run in separate threads, you wont see the exception

9:51 mskoud: you, that probertly what happened. Will try to catch the exceptions, and see it that solves it.

10:00 agarman: justin_smith if you want to restart a failed future, deref that returns would be a good watch-dog

10:01 ,@(future (throw (Exception. "foo")))

10:01 clojurebot: #<SecurityException java.lang.SecurityException: no threads please>

10:02 agarman: exception isn't lost, it'd be in the future as the result

10:04 irq0: is there a way to attach metadata to multimethods and retriving it from all methods?

10:12 visof: how can i write this java code as clojure new TripleString(x.toString(), y.toString(), z.toString()); ?

10:13 broquaint: visof: (TripleString. (.toString x) (.toString y) (.toString z))

10:16 justin_smith: or even (TripleString. (str x) (str y) (str z)) I think

10:17 yeah, str calls toString when called with a single arg (returning "" on nil)

10:18 TEttinger: ,(.toString nil)

10:18 clojurebot: #<NullPointerException java.lang.NullPointerException>

10:18 TEttinger: so that's a reason to use str

10:20 visof: broquaint: what if i want to set values like this this.header = header; ?

10:20 broquaint: how can i do this in clojure

10:22 i want to convert much of this java code to clojure https://www.refheap.com/85214

10:24 is this possible?

10:24 ToxicFrog: visof: if "this" is a java object, I think you use set! for it? I haven't done much java interop. If you're replacing it with a clojure map or similar, use assoc.

10:25 bbloom: visof: that sort of constructor is trivial:

10:26 (deftype PlainHeaderIterator [header pattern pos])

10:26 (defn plain-header-iterator [header pattern] (PlainHeaderIterator. header pattern 0))

10:29 CookedGryphon: In clojurescript, should I be able to pr-str anything, like i can in clojure?

10:30 I'm trying to log stuff out as clojure data rather than javascript objects, so I just called pr-str on it, but I'm getting a "no protocol method imapentry.-key for type string

10:30 nillkill: quick question for anyone, if I were trying to convert this function https://github.com/apache/incubator-storm/blob/master/storm-core/src/clj/backtype/storm/command/list.clj#L21-L38 from printing to returning a map of information {:name “blah” :status “blah}, why does this code seem to only return the last element https://gist.github.com/msukmanowsky/84239439070b17fca2c6

10:32 visof: bbloom: i just wanted to rewrite this method to get only first match

10:32 not list of results

10:32 cshell: Is there a leiningen plugin for scp’ing an uberjar/artifact over and calling a startup/bounce script?

10:34 ToxicFrog: ,(into {} (map identity [{:a 1 :b 2} {:a 2 :b 2}]))

10:34 clojurebot: {:b 2, :a 2}

10:34 ToxicFrog: nillkill: ^

10:34 map returns a seq of maps; into then adds them to {} in sequence, each one overwriting the previous.

10:34 Because they all have the same keys.

10:35 justin_smith: you may want merge-with

10:35 depends on the shape you want for the output

10:35 ToxicFrog: Yeah, the most straightforward conversion is just to return that seq.

10:35 You say you want "a map of information", but keyed by what? id?

10:35 nillkill: ah, so something like this? (into {} (map identity #({:id (.get_id %) :name (.get_name %)…

10:36 well basically i get a list of topology information objects

10:36 thrift ones

10:36 which i’d want to convert into a map that has keys :id, :name, :status, etc

10:36 mapping to fields on those objects

10:36 ToxicFrog: Right, you already have that part working.

10:36 BobSchack: CookedGryphon: what datastructure are you trying to log?

10:36 ToxicFrog: But you have *a seq* of these individual maps.

10:37 CookedGryphon: BobSchack: If I knew that I wouldn't need to log it :P

10:37 BobSchack: I think it's a map of keyword to js objects

10:37 but possibly not

10:37 justin_smith: nillkill: nitpick - #({... }) is usually wrong, that is trying to call the map literal as a function

10:38 nillkill: yeah, i’m starting to see that :)

10:38 ahh so sorry what i really want is a list/vector of maps

10:38 so (into [] (...)

10:40 ssideris: or even (vec (...))

10:40 nillkill: yeah, that should be fine too

10:40 justin_smith: ,(group-by :id [{:a 0 :b 1 :id 0} {:a 2 :b 2 :id 1} {:a 3 :id 22}]) nillkill: this can be useful too

10:40 clojurebot: {0 [{:id 0, :b 1, :a 0}], 1 [{:id 1, :b 2, :a 2}], 22 [{:id 22, :a 3}]}

10:40 justin_smith: then you can do :id based lookup

10:41 nillkill: ahh, that’s really cool justin

10:41 ToxicFrog: <3 group-by

10:42 BobSchack: CookedGryphon it sounds like you're trying to use string as a map

10:44 It's saying it can't find the -key method for the IMapEntry protocol for the string type. Here's the protocol (https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L265)

10:44 CookedGryphon: BobSchack: yeah, i see that's the error

10:44 I don't get how doing str on something should give me that error

10:45 as if I remove the str and just log x, it's fine

10:46 BobSchack: can you show me the code?

10:47 nillkill: so sorry guys, still not clear on the best way to convert the list of topologies into maps themselves. Is therea more idiomatic way to do https://gist.github.com/msukmanowsky/84239439070b17fca2c6 ? This raises the clojure.lang.ArityException as i understand #({:id (.get_id %)}) expands to (fn [%] ({:id (.get_id %)}))

10:47 justin_smith: cshell: I was wrong, lein deploy is only for putting jars into repos

10:48 cshell: justin_smith: no worries - I haven’t seen a good one for ssh deploying combined with any type of startup/shutdown command

10:48 justin_smith: cshell: what about spawning a simple shell script as an injection for a specific profile?

10:49 cshell: justin_smith: Yeah, that would work - I was looking at that or something like conch (shell abstraction)

10:49 justin_smith: I have used jenkins, where jenkins calls lein to build the jar, and then executes the commands to put it on prod and restart the server

10:49 cshell: justin_smith: so the script to scp and any other remote commands goes into jenkins?

10:49 justin_smith: cshell: the commands were entered as one of the steps in the jenkins deploy config

10:50 cshell: justin_smith: ah, cool!

10:50 justin_smith: I mean jenkins is a whole other can of worms and may be more than you need, just mentioning that is what I used.

10:51 jenkins can watch your master branch, and push a deploy to production whenever master updates and tests pass

10:51 cshell: justin_smith: it makes sense - what were youusing to stop any existing deployment?

10:51 justin_smith: a kill of some kind?

10:51 CookedGryphon: BobSchack: 'fraid not, it's proprietary and I can't produce a trivial example, I'll keep looking, I'm probably just doing something daft

10:52 justin_smith: cshell: for that part I had a couple of scripts, one sec and I'll share

10:56 cshell: https://www.refheap.com/85216 this is three scripts - they are imperfect, but are a good start I think

10:56 compile / deploy / run

10:56 the run script handles both starting and stopping

10:56 clgv: CookedGryphon: try-catch around the reported location? (provided that exists in CLJS)

10:57 justin_smith: cshell: I think if two deployments tried to happen at once things may get messy - that is left as an exercise (or maybe just "don't do that")

10:57 cshell: justin_smith: cool, this is really hepful, thanks!

10:58 ~justin_smith++

10:58 clojurebot: Huh?

10:59 cshell: guess that’s only in #java

11:00 justin_smith: we use inc here

11:00 but thanks

11:00 cshell: ~inc justin_smith

11:00 clojurebot: No entiendo

11:00 justin_smith: (inc juxt)

11:00 lazybot: ⇒ 9

11:01 cshell: (inc justin_smith)

11:01 bbloom: (inc notation-of-the-gods)

11:01 lazybot: ⇒ 41

11:01 justin_smith: you would think that function would be more popular

11:01 lazybot: ⇒ 1

11:01 CookedGryphon: interesting, so I have done the old comment out bits and see if it still works trick, and it always seems to be something to do with where i'm doing a clojure.set/union

11:02 ssideris: nillkill: what you wrote is the equivalent of (vec (map (fn [x] ({:id (.get_id x)})) topologies))

11:02 CookedGryphon: is there some gotcha with sets in clojurescript?

11:02 ssideris: this will try and call the map as a function: ({:id (.get_id x)})

11:02 maps are functions, but I don't think that's what you're trying to do in this case, right?

11:03 cbp: (inc tree-seq)

11:03 lazybot: ⇒ 1

11:04 nillkill: ssideris: basically trying to do something similar to (vec (map bean topologies)) but specify the exact fields i want

11:05 cshell: , ({:id (.get_id x)})

11:05 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>

11:05 ssideris: how about (vec (map #(select-keys (bean %) [:k1 :k2]) topologies))

11:05 cshell: ({:id :a})

11:05 ssideris: but bean is a bit slow because of reflection I think

11:05 nillkill: yeah, i’d prefer not to use that

11:05 cshell: ,({:id :a})

11:05 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap>

11:06 nillkill: was just trying (vec (map (fn [topology] {:id (.get_id topology)})))

11:06 ssideris: so you can just do: (vec (map (fn [x] {:id (.get_id x)}) topologies))

11:06 justin_smith: ,(map #(select-keys (bean %) [:namespace :name]) [:foo/bar :this/that :other :east/west])

11:06 clojurebot: ({:name "bar", :namespace "foo"} {:name "that", :namespace "this"} {:name "other", :namespace nil} {:name "west", :namespace "east"})

11:06 cshell: ssideris: you have to pass an argument to the map if you’re using it as a function

11:06 justin_smith: nillkill: ^^ if you are just getting things from the bean

11:06 ssideris: cshell: I'm not

11:06 cshell: and that's not what nillkill wants

11:07 he's just confused by the #() syntax

11:07 justin_smith: ssideris: fair point about bean being slow

11:07 nillkill: the (fn [x] …) option works great

11:07 yeah, i’m def confused about anonymous functions

11:07 figured that would’ve been equivalent to (fn [x] …) in this case

11:07 anyway, that works perfectly

11:07 thanks ssideris, cshell and justin_smith

11:07 justin_smith: ,(#(do {:name (.name %)}) :hi) there is also this

11:07 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: name for class clojure.lang.Keyword>

11:07 justin_smith: oops!

11:08 ssideris: nillkill: here it is with an anonymous function instead: (vec (map #(hash-map :id (.get_id %)) topologies))

11:08 justin_smith: ,(#(do {:name (.getName %)}) :hi) this I mean

11:08 clojurebot: {:name "hi"}

11:08 ssideris: the literal {} syntax won't play well with #()

11:08 bbloom: ,(macroexpand '#(inc %))

11:08 clojurebot: (fn* [p1__153#] (inc p1__153#))

11:08 bbloom: ^^ that should make it quite clear

11:08 nillkill: yeah, was trying to read up on this http://stackoverflow.com/questions/2020570/common-programming-mistakes-for-clojure-developers-to-avoid

11:09 bbloom: ,(macroexpand '(fn [%] (inc %)))

11:09 clojurebot: (fn* ([%] (inc %)))

11:09 nillkill: yep, that’s a lil tricky :)

11:09 bbloom: anonymous, single-expression fns are extremely common

11:10 nillkill: would you guys normally use #() in this case? or just (fn [x] …)? Just curious

11:11 bbloom: ,(#(-> {:x %}) 5)

11:11 clojurebot: {:x 5}

11:11 bbloom: i've see that, which is both clever and horrifying :-P

11:11 ssideris: nillkill: depends, but I would definitely use (hash-map) and (vector) instead of {} and [] in an anonymous function

11:11 bbloom: but yeah, i'd probably write:

11:11 justin_smith: nillkill: fn nests, #() cannot, so I start with fn and then substitute #() where it can make things cleaner

11:11 bbloom: ,(#(hash-map :x %) 5)

11:11 clojurebot: {:x 5}

11:11 nillkill: ahh makes sense, good point justin_smith

11:12 justin_smith: ,(#(do {:x %}) 5)

11:12 clojurebot: {:x 5}

11:12 justin_smith: is that so terrible?

11:12 ssideris: justin_smith: when I see a (do) I usually immediately think that there are side-effects in the code, so it can be misleading

11:13 bbloom: agreed, do == side effects

11:13 i'd much rather #(-> than #(do

11:13 visof: this.header = header translated to (set! (.this header) header) ?

11:13 justin_smith: there aren't many places a side effect would hide in there, but OK

11:14 ssideris: justin_smith: yeah, if it's a tiny {:x 5} there aren't many places, but you could have more

11:14 justin_smith: but considering -> and do are equally verbose, I can stick with ->

11:16 nillkill: thanks again guys

11:18 visof: how can rewrite this full method in clojure https://www.refheap.com/85218 ?

11:18 using java

11:19 java from clojure

11:19 i did this but even not working https://www.refheap.com/85215

11:20 justin_smith: well, that's a start, but you need some more code at the bottom of plain-header-iterator

11:20 or wait no, you transcribed it wrong

11:20 the type and the function should not have the same name

11:21 and "this" is totally invalid there

11:24 visof: justin_smith: so how can i fix this sample?

11:25 justin_smith: quoting bblooom above: (deftype PlainHeaderIterator [header pattern pos])

11:25

11:25 (defn plain-header-iterator [header pattern] (PlainHeaderIterator. header pattern 0))

11:26 then you would put the rest of your code at the end of that defn

11:26 visof: i don't want to use PlainHeaderIterator. i need to modify it

11:27 justin_smith: OK, the version above is valid clojure code, the version in that refheap you last pasted is not

11:28 you may want to check out an introductory book like "Programming Clojure"

11:29 visof: ok

11:30 justin_smith: cann't you help to rewrite this java code to clojure code but with only return first match not all

11:31 bbloom: visof: please forgive my directness, but nobody wants to write your code for you. you've got to at least show some basic effort to understand on your own before asking for help

11:31 visof: ok

11:34 ssideris: visof: the idiomatic way to do this sort of thing in clojure would be to use (lazy-seq), but this is slightly more advanced as a technique

11:35 visof: but in essence, you'd have a lazy-seq that would return you triples on demand

11:41 coventry: My browser repl is working fine, but when I paste the connection string into the js console, I get "Blocked a frame with origin "http://localhost:61318" from accessing a cross-origin frame." Anyone come across this? I'm working from the mies-om template, serving it to localhost:8000 using python -m SimpleHTTPServer.

11:42 This is with austin 0.1.4 and clojurescript r2156.

11:47 cbp: You might be trying to do AJAX from a server that's different from the one youre querying?

11:48 probably from :61318 you have some ajax that tries to fetch from :8000

11:48 You'd have to enable cross-origin resource sharing on :8000

11:50 coventry: The crazy thing is, this doesn't seem to break anything that I've noticed so far. I'm bringing in a javascript library which could be trying to do that. I'll try taking it out.

11:52 CookedGryphon: BobSchack: I worked out the issue

11:52 BobSchack: I was binding [*print-length* 10] (.log js/console (str x))

11:53 BobSchack: which apparently results in that no implementation of protocol for string error, take out the binding print length and it works as expected

11:54 BobSchack: really that is weird behavior. It should probably get a ticket if that is reproducible

11:55 I get that too

11:56 CookedGryphon: BobSchack: yeah, fairly sure that's a bug. Is *print-length* implemented in cljs? I just tried it on clojurescript.net and get *print-length* not declared ^:dynamic

11:58 what did you try as your minimal example? And what version of cljs are you on? Do you want to file it or shall I?

11:58 BobSchack: (binding [*print-length* 10] (pr-str #js {:foo "bar"}))

11:58 is a minimal case

11:58 it only does it for map data structures

11:59 CookedGryphon: don't think you even need the #js, do you?

11:59 i was getting it on plain cljs data structures

11:59 BobSchack: ooop yep you can take out the #js and it still gets the error

12:00 I'm trying this out with version 2173

12:01 Could you file the bug?

12:01 bbloom: wishful thinking: does anybody know of a swing UI hex debugger that I can use to quickly inspect an nio ByteBuffer or similar?

12:02 coventry: cbp: I get the error even with the minimal changes necessary to use the browser repl with the mies-om template. https://www.refheap.com/85222

12:02 CookedGryphon: bbloom: bbloom I have a function that implements print string for a bytebuffer

12:03 bbloom: CookedGryphon: do you mind sharing? i've seen a few random things in my quick googling, but most are kinda awful

12:04 CookedGryphon: bbloom: 2 seconds I'll gist it

12:04 (no guarantees its any better than the other things you've seen though :P)

12:05 justin_smith: ,(String. (.getBytes "hello"))

12:05 clojurebot: "hello"

12:05 bbloom: CookedGryphon: if not, i'll write a better one and share it with you :-P

12:05 CookedGryphon: bbloom: https://gist.github.com/AdamClements/9441ad39254b91a8718b

12:05 justin_smith: or do you not mean the kind of thing returned by getBytes?

12:05 CookedGryphon: is what I've been doing, you just need to print the ints as hex instead

12:06 bbloom: hm, ok. i'm looking for something more like a hexdump

12:06 https://en.wikipedia.org/wiki/Hex_dump

12:06 CookedGryphon: yeah, I was using it for fairly small bytebuffers and just wanted them inline when i pprinted maps with them in etc

12:06 bbloom: yeah, my byte buffers are fairly large

12:07 hence my original question for some kind of launchable hex editor. features like search would be greatly appreciated

12:08 cbp: coventry: I Guess it's probably an austin issue

12:08 CookedGryphon: BobSchack: just heading out for a bit, but I will file a bug. Just need to reset my jira password because I seem to have forgotten it!

12:09 BobSchack: CookedGryphon: thanks

12:19 bbloom: CookedGryphon: justin_smith: this seems to get the job done good enough to unblock me: https://gist.github.com/brandonbloom/4b8278edaafccb72ccc1

12:21 BobSchack: bbloom: just curious what are you working on that you need this for?

12:21 coventry: cbp: Yeah, maybe. Thanks for looking.

12:21 justin_smith: bbloom: hah, nice

12:22 bbloom: BobSchack: working with a binary format

12:22 cbp: So I have this thing where I query a database, create a promise and once the database responds i deliver the result on the promise. Which works but now I need to deliver partial results. What's the answer here? A lazy seq thing of delays?

12:23 arrdem: partial results?

12:23 coventry: core.async?

12:23 clojurebot: core.async is not Go

12:23 cbp: yes as in the database says here is a part of the result, come back to me when you want more

12:24 arrdem: Ah.

12:24 Yeah... I'd say deliver a lazy sequence that has another agent/worker for the next thunk of the query

12:24 as it's next

12:32 cbp: Yes that's it

12:33 (inc arrdem)

12:33 lazybot: ⇒ 26

12:34 arrdem: yay, validation to go with the coffee!

12:34 ghaz: Anyone have an idea why calling enable-console-print! isn't allowing println to print to console in clojurescript any more?

12:44 amontalenti: I have a lein project where org.clojure/tools.cli is installed at latest (0.3.1) version. Yet, when I look at the "cli" namespace, I only see one function, "cli". When I check "lein deps :tree", it lists the correct version. Somehow, it seems like an old version is getting into my classpath. Anyone know how I can debug this situation?

12:45 technomancy: amontalenti: is it a plugin or a regular lein project?

12:45 amontalenti: technomancy, regular lein project, afaict

12:45 technomancy: you can check the :file metadata on the var to see where it's coming from

12:47 amontalenti: technomancy, I try (meta cli) on the namespace and I get "nil"?

12:47 llasram: amontalenti: Are you using speclj?

12:47 technomancy: try it on the var

12:48 amontalenti: technomancy, you mean like cli/cli? also nil

12:48 justin_smith: #'cli

12:48 #'cli/cli

12:49 amontalenti: technomancy, "clojure/tools/cli.clj"

12:50 technomancy: amontalenti: oh right, then call clojure.java.io/resource on that

12:50 amontalenti: => (clojure.java.io/resource (:file (meta #'cli)))

12:51 #<URL jar:file:/home/pixelmonkey/.m2/repository/org/clojure/tools.cli/0.3.1/tools.cli-0.3.1.jar!/clojure/tools/cli.clj

12:51 actually looks legit to me, no?

12:51 technomancy: so you're using the version you expect, yeah

12:51 justin_smith: (-> #'cli meta :file io/resource) even

12:51 amontalenti: odd

12:51 technomancy: http://p.hagelb.org/mrfp.gif

12:51 amontalenti: haha, I appreciate the tips -- I'm new here.

12:52 technomancy: that one was for justin_smith

12:52 amontalenti: so, I guess if I'm insane, I could go unzip this jar, eh?

12:52 see what the heck is going on?

12:52 llasram: amontalenti: What do you mean that you only "see" the `cli` function?

12:53 Are the new functions not in the namespace?

12:53 amontalenti: llasram, exactly

12:53 justin_smith: amontalenti: many editors can open the jar without explicitly unzipping it

12:53 amontalenti: I run (require '[clojure.tools.cli :as cli]) and then cli/cli is all that's available (also confirmed with (ns-publics cli))

12:53 but parse-opts is supposed to be there, and a few others

12:54 I confirmed this by doing load-file on a copy-pasta'ed version of the same module from github

12:54 justin_smith: amontalenti: have you checked (ns-publics 'clojure.tools.cli) ?

12:54 amontalenti: technomancy, insanity -- I unzipped the jar and the parse-opts function is there.

12:55 justin_smith, yes: {cli #'clojure.tools.cli/cli}

12:56 fwiw, this is happening to someone else on my team, too, with same project -- so it's not just me :)

12:56 technomancy: you could check your classpath for collisions, though if resource claims to find the right thing you should be good; that's what the compiler uses

12:56 justin_smith: amontalenti: I wonder if you are getting a version that is aotd into another dep?

12:56 technomancy: ooooh

12:56 I bet that's it

12:57 justin_smith: (dec aot)

12:57 lazybot: ⇒ -1

12:57 technomancy: justin_smith: wouldn't that change the :file metadata on teh var though?

12:57 justin_smith: hmm...

12:57 I don't see how else you would be getting the wrong version, but that is definitely weird...

12:59 amontalenti: interesting technomancy, I dropped one of my dependencies (not tools.cli) and now i can see parse-opts

12:59 the dependency was apache storm 0.9.1

13:00 nillkill: i figured apache storm might be interfering…does the order of deps in project.clj affect things?

13:01 justin_smith: you can use an :exclusions clause on a dep

13:01 but that won't help if aot was the problem - in that case tell storm to stop aot compiling deps

13:01 amontalenti: haha, nice -- so looks like we have an upstream bug of sorts

13:01 OK

13:02 we'll file a ticket and see how that goes, we can probably live without the new version of tools.cli in meanwhile

13:03 technomancy, thanks for your help -- we're actually using lein for a Python interop project with Storm called streamparse you can check out -- https://github.com/Parsely/streamparse -- lein makes our lives much easier for this, so thanks for your great work on it!

13:03 technomancy: cool; glad it's (mostly) working for you

13:04 nillkill: you can expect more questions from amontalenti and myself :)

13:04 technomancy: hopefully you can stamp out the pernicious use of AOT

13:04 amontalenti: well, we'd be in a deeper classpath hell than this little problem without it

13:04 PigDude: what is the idiomatic way to make a function accept more than one type? like a function that operates on a byte array but can also accept a string and call .getBytes on it

13:04 is it to pass the argument through another funciton, like ensure-byte-array?

13:04 technomancy: PigDude: if you have a large number of cases a multimethod is a good way

13:05 if there's only two or three, something like ensure-byte-array is fine

13:05 PigDude: hm ok

13:05 at that, how do i tell the difference between a byte array and a string?

13:06 technomancy: ...?

13:06 justin_smith: ,(string? (.getBytes "hello"))

13:06 clojurebot: false

13:06 PigDude: ok, thanks justin_smith

13:06 mdrogalis: cemerick: Can you tldr what Quilt is? :) Can't find a description anywhere.

13:07 justin_smith: ,(= (class (.getBytes "hello")) (Class/forName "[B")) PigDude

13:07 clojurebot: true

13:07 PigDude: justin_smith: and that's just (instance? String)

13:08 justin_smith: my background (js py erl) this sort of explicit class/bases testing is not so common

13:08 justin_smith: PigDude: yeah, but I find it more readable (every basic clojure type has a predicate like that)

13:08 PigDude: justin_smith: oh, i agree!

13:09 technomancy: just don't use clojure.core/list?

13:09 PigDude: why's that?

13:10 justin_smith: because many things you would consider a "list" are not things "list?" returns true for

13:10 PigDude: ,(map list? [() {} #{} []])

13:10 clojurebot: (true false false false)

13:10 PigDude: looks normal to me

13:10 justin_smith: ,(list? (cons :a (list :b :c)))

13:10 clojurebot: false

13:10 justin_smith: that's weird ^

13:10 technomancy: http://p.hagelb.org/lies.gif

13:10

13:10

13:10 PigDude: ok, that is weird

13:10 hyPiRion: ,(list? (list* :a :b (list :c))) ; even better

13:10 clojurebot: false

13:10 justin_smith: ,(class (cons :a (list :b :c)))

13:10 clojurebot: clojure.lang.Cons

13:11 PigDude: a wart@!

13:11 :)

13:11 technomancy: anyone tells you there's a language that doesn't have them, you can refer to the previous gif

13:13 seangrove: technomancy: Stop trolling

13:14 technomancy: http://p.hagelb.org/scott-pout.png

13:14 seangrove: how can (rest ...) take 1ms in cljs...

13:14 err, 2ms

13:15 Time to try advanced compilation again

13:16 bbloom: seangrove: what are you taking the rest of?

13:16 manutter: quick hoplon question: I want to write a client that monitors log messages coming in over a message queue, with a scrollback of, say, 5000 lines. it seems like if I were going to use hoplon and castra, I'd be sending 5K lines of log entries over the wire every few seconds, since it transmits the full state every time.

13:16 Is that right, and is there a better way?

13:16 bbloom: seangrove: could be reading 30ish objects via chunking

13:16 seangrove: bbloom: Not sure, Just woke up and reading the flame graph from last night

13:17 mynomoto: manutter: there is a #hoplon channel. But you can manage the state anyway you want using hoplon and castra.

13:18 manutter: mynomoto: Thanks, didn't know about #hoplon, I'll move my question over there

13:19 seangrove: These people have to be stopped https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers

13:22 llasram: seangrove: ?

13:22 jcromartie: seangrove: as something I read today said: "A modern Web page is a catastrophe."

13:24 seangrove: llasram: The data is copied, not shared between web workers, in order to prevent you from accidentally shooting yourself in the foot because of concurrency issues. If GC is your problem, that's just madness. Serializing + deserializing perf hit as well. If you're using immutable datastructures, it's also just completely wasteful

13:25 bbloom: Are games generally single-threaded?

13:25 llasram: Interesting

13:25 bbloom: seangrove: nope

13:26 seangrove: llasram: Also, transfeable objects. Completely destroys the idea of immutable data structures - "here's the data you need, and I can no longer use it here"

13:26 bbloom: seangrove: big titles usually have threads for at least gameplay, graphics, and networking

13:26 jcromartie: depends on the game

13:26 I'd say generally they are

13:26 if you were to sample the average video game

13:26 bbloom: jcromartie: that's simply not correct

13:26 arrdem: jcromartie: maybe your average 2d side scroller...

13:26 jcromartie: and the "average game" over time is a 2d side scroller :)

13:26 more or less

13:27 bbloom: the xbox 360, for example, has 6 cores, 5 of which are available to game engines... you basically have to be multi threaded

13:27 well 3 cores, 2 threads per core

13:27 arrdem: well... if you don't multithread you've just shot yourself in the face performance wise for no reason.

13:28 seangrove: bbloom: Yeah, I was wondering, since maybe I was missing something fundamental about this web-worker concurrency model

13:28 llasram: I mean, the Atari 2600 didn't even have a separate graphics controller. Just the 6502 updating registers at the TV refresh rate

13:28 So *totally* single-threaded

13:29 arrdem: and that's fine when your render engine consists of xoring in 2d sprites

13:29 bbloom: even if you don't core your game multi-threaded, most modern games use at least one library like Havok which can do multithreaded physics

13:29 s/core/code

13:29 jcromartie: An immense number of games have and are being made. Most of them are really simple.

13:29 That's all I'm saying.

13:30 The vast majority of modern 3D games, and especially AAA blockbusters are obviously multi-threaded.

13:30 bbloom: jcromartie: seangrove isn't interested in the long tail of random little games made, he's interested in the architecture of real time systems

13:30 jcromartie: But the 5000 HTML5 Tetris clones made today won't be.

13:30 :)

13:30 ok

13:30 got it

13:31 seangrove: jcromartie: Sorry, wasn't quite as obvious to me as it should have been ;)

13:34 bbloom: seangrove: anyway, games tend to pipeline multiple frames, rather than utilize significant intraframe parallelism

13:35 timothyw: Is there a Clojure lib for doing XML digital signatures?

13:36 mdeboard: http://docs.oracle.com/javase/7/docs/technotes/guides/security/xmldsig/XMLDigitalSignature.html ? :D

13:36 CookedGryphon: BobSchack: Bug filed: http://dev.clojure.org/jira/browse/CLJS-804 add any details you think I have missed

13:36 timothyw: @mdeboard thanks

13:43 ssswdon: is there a way to remove a key from a map that has no value

13:44 Morgawr: you mean a key that has no value?

13:44 ssswdon: yes

13:45 arrdem: ,(doc dissoc)

13:45 clojurebot: "([map] [map key] [map key & ks]); dissoc[iate]. Returns a new map of the same (hashed/sorted) type, that does not contain a mapping for key(s)."

13:45 Morgawr: ssswdon: http://stackoverflow.com/questions/3937661/remove-nil-values-from-a-map this might be helpful

13:45 ssswdon: thanks

13:50 stompyj: I’m devising my own “keep it real” time architecture

13:50 it uses culture sourced filtering

13:52 justin_smith: stompyj: it should have a #YOLO data constructor that throws a ShitJustGotTooReal exception

13:53 stompyj: hahahahahahahahahaha

13:54 roelof: hello, I have this definition : (def little-schemer {:title "The Little Schemer" :authors [friedman, felleisen]})

13:54 now i want to add a author to it

13:55 ssswdon: @Morgawr Oh yeah I am doing this in a macro, when ever I access the key it throws an exception https://www.refheap.com/85230

13:55 roelof: So I do http://pastebin.com/VjbpwX9B

13:55 justin_smith: ssswdon: & keys needs pairs

13:56 roelof: but now I see this error message : ArityException Wrong number of args (0) passed to: PersistentVector clojure.lang.AFn.throwArity (AFn.java:437)

13:56 ambrosebs: ,(def little-schemer {:title "The Little Schemer" :authors [friedman, felleisen]})

13:56 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: friedman in this context, compiling:(NO_SOURCE_PATH:0:0)>

13:56 ambrosebs: ,(def little-schemer {:title "The Little Schemer" :authors '[friedman, felleisen]})

13:56 clojurebot: #'sandbox/little-schemer

13:56 roelof: what did I do wrong or what did I misunderstood

13:56 ambrosebs: ,(update-in little-schemer [:authors] conj 'ambrosebs)

13:56 clojurebot: {:title "The Little Schemer", :authors [friedman felleisen ambrosebs]}

13:57 roelof: oke, the whole file is this http://pastebin.com/6VbDJprx

13:57 ToxicFrog: roelof: ((conj schrijver new-author)) evaluates (conj schrijver new-author) and then calls the result with no arguments, which is probably not what you wanted.

13:57 ssswdon: justin_smith - I was just wondering if there is a way to filter out bad data in the macro

13:57 ToxicFrog: (assoc book :authors (conj schrijver new-author)) I expect would work, although using update-in is better.

13:58 justin_smith: ssswdon: the error is happening in the arg parsing, & keys will always require an even arg count, period

13:59 ssswdon: justin_smith - what if I changed the approach on the function signature like processing the params differently

14:00 roelof: ToxicFrog: when I only did (conj schrijver new-author) on (add-author little-schemer {:name "Gerald J. Sussman"}) I did get the right output. See => [{:birth-year 1944, :name "Daniel Friedman"} {:name "Matthias Felleisen"} {:name "Gerald J. Sussman"}]

14:00 ToxicFrog: I think the problem is somewhere in the assoc function but I do not see where

14:00 justin_smith: ssswdon: well you could not use & keys and take the args in some other way

14:01 ssswdon: ok. let me think about this a bit

14:02 justin_smith: one option would be to take multiple arities instead of keyword args

14:02 roelof: ToxicFrog: you right the extra () around the conj were the culprit

14:12 kevinfish: Hi everyone. Total clojure noob here. I'm trying the "try luminus" stuff on this page: http://www.luminusweb.net/ and I got this message: fish@spanker ~/work/clojure $ lein new liminus myapp

14:12 Failed to resolve version for liminus:lein-template:jar:RELEASE: Could not find metadata liminus:lein-template/maven-metadata.xml in local (/home/fish/.m2/repository)

14:12 any help?

14:15 PigDude: what is the function for a while look w/ let bindings?

14:15 it was like if-let, but looping

14:15 amalloy: loop

14:15 PigDude: i thought there was something w/ let bindings, but like if-let, so if the binding is falsy it terminates

14:15 amalloy: kevinfish: you spelled "liminus" wrong. it's luminus

14:16 PigDude: no

14:16 PigDude: hm ok

14:16 kevinfish: amalloy: ahh, thx :)

14:16 amalloy: you can't really write a while-let macro that's functionally pure, because the value it checks will never change

14:18 therik: PigDude: do loop?

14:20 PigDude: therik: not quite

14:20 TravisD: Anyone here use the Atom text editor?

14:23 justin_smith: TravisD: some folks on #clojure-social were complaining about it

14:23 TravisD: ah, maybe I'll move the conversation over there :)

14:43 seangrove: bbloom: js-obj bash-in-place approach is fast enough for now, able to move on to the next pieces. Probably drop down into straight-js for the next version, and then maybe... c => asm.js for the final version?

14:43 bbloom: seangrove: *shrug*

14:48 seems like overkill

14:49 seangrove: Yeah, I hope so

15:01 bbloom: i'm really amused by this thread: http://lambda-the-ultimate.org/node/4950

15:01 type theory addicts rediscovering the benefit of first-class interfaces

15:06 amalloy: it seems i don't know enough type theory to get the joke

15:07 ataggart: Anyone know off-hand why the EdnReader would complain about "No reader function for tag" despite *data-readers* containing the tag?

15:08 Bronsa: ataggart: the edn reader doesn't use *data-readers*

15:09 ataggart: you have to pass the data readers as an argument to the edn/read function

15:10 ataggart: orly!

15:10 thanks, off to try it out

15:10 bbloom: amalloy: not a joke really

15:11 amalloy: a "type class" is just a dictionary of methods, just like a protocol implementation

15:11 ataggart: "When not supplied, only the default-data-readers will be used." RTFM...

15:11 bbloom: amalloy: but b/c it's resolved at type level, there are restrictions on the polymorphic dispatch

15:12 amalloy: by encoding your type class as a record, you're effectively creating an object-oriented thing you can pass around

15:12 they then call this "value level programming" b/c they have this artificial bifurcation of their language in to the term and the type sublanguages

15:13 instead of just having a single-level language to begin with

15:13 which, btw, does not preclude static checking at all

15:13 this is the *actually interseting* motivation for dependent types, rather than being able to check things like the length of a vector statically

15:16 PigDude: what is the threading function that stops on nil?

15:16 alejandro: PigDude some-> I think

15:17 PigDude: thanks alejandro :)

15:18 bbloom: tpope: seems like repeat.vim doesn't work for cpp anymore

15:19 Glenjamin: bbloom: if i'm following this correctly, equivalent concepts in clojure are passing around maps of functions, and reify ?

15:19 bbloom: Glenjamin: i won't say equivalent, but definitely related

15:19 Glenjamin: with most of the oddness of phrasing in the post coming from the need to describe type-check-time and run-time separately

15:19 bbloom: Glenjamin: objects basically *are* maps of functions

15:20 Glenjamin: depends what level of abstraction you're thinking at, but yeah, i guess so

15:21 bbloom: Glenjamin: it's a map of functions plus a data payload. what i'd call "interface passing style" in the linked blog post is basically passing the object's method table separate from the object's data values

15:21 it's definitely simpler/preferable to have those be distinct to start with, but if you've already got a concept that glues them together, reify lets you just skip the data payload part

15:21 modulo lexical closures, of course

15:21 Glenjamin: in my mental model, a class is a map of functions, an object is a map of values bound to a map of functions - but an interface is more like a set of keys

15:22 bbloom: yeah, you've got it right... i wasn't being clear when i said interface i meant it in the broader context of languages, not the java sense.... in the broader context a "first class interface" is basically a map of fns

15:23 Glenjamin: right, yeah

15:23 i find my javascript looks a lot like this these days

15:23 maps of functions with mostly implicit interfaces between components

15:24 the comments here are interesting, mostly focusing on how to do efficient comparison when you don't know the real "type"

15:25 anyway, i try not to think about type systems

15:25 bbloom: i think the comparison stuff is just an example of an interface for which there may be multiple definitions for any given type

15:26 Glenjamin: there's always the temptation to specialize when you know the concrete types

15:26 breaks the abstraction a bit, but obviously tends to be faster

15:29 bbloom: it's not about perf, it's about semantics: are numbers ordered or do they have an ordering? what about users?

15:29 numbers have a natural order, but you could imagine an alternative ordering (ie inverse order)

15:29 Glenjamin: mm, i see

15:29 bbloom: users can have many orders: by name, by id, by join date, etc

15:29 hence sort and sort-by

15:30 applies to much more than orders, but that's the canonical example

15:30 Glenjamin: so potentially reverse-int is a type, that overloads the comparison operators

15:30 bbloom: well, that's one way to look at it

15:31 Glenjamin: type GolfScore = reverseOrder<int> sorta thing

15:31 bbloom: something like that

15:32 but the other way to think about it is type T is Ordered and there exists an Ordering on type T

15:32 in scala for example: http://www.scala-lang.org/api/current/index.html#scala.math.Ordered and http://www.scala-lang.org/api/current/index.html#scala.math.Ordering

15:38 AWizzArd: Leiningen: Can I unlist specific files from :resource-paths?

15:38 Have Leiningen not putting them inside a .jar?

15:40 llasram: AWizzArd: Check out `:jar-exclusions`

15:40 justin_smith: AWizzArd: do they need to be in a folder in the :resource-paths ?

15:40 AWizzArd: llasram: that’s probably it, thx

15:40 justin_smith: I just want to exclude my externs.js from going into the server.jar

15:54 Glenjamin: does anyone know why "Only long and double primitives are supported" ?

15:54 gtrak: Glenjamin: there's no advantage to using ints on modern system.

15:54 systems...

15:54 and also the hashcodes don't line up.

15:55 Glenjamin: assuming a 64bit jvm, or just in general?

15:55 gtrak: not sure about 32, but definitely 64

15:55 jcromartie: that's too bad, reaelly

15:55 really

15:55 bbloom: modern x86 chips are like 80bits internally or something weird like that

15:55 gtrak: you can still use them, you're just going against the grain a little.

15:55 martinklepsch: whats the best way to get leiningen2 on ubuntu?

15:55 jcromartie: I don't lament the deprecation (more or less) of int

15:55 but the loss of the name

15:55 gtrak: martinklepsch: download the shell script and put it in ~/bin

15:56 Glenjamin: it let me hint ints in defrecord, but not on functions

15:56 i guess i can see why that would work

15:56 gtrak: huh? I'd expect that to work.

15:56 Glenjamin: anyway, longs are fine, makes sense really

15:57 sorry, ^int, not ^ints

15:57 i did ^int more than once, forgot ^ints was a thing

15:57 martinklepsch: gtrak: isn't there some other way? find that cumbersome

15:57 justin_smith: perhaps the optimization layer that knows how to keep something unboxed doesn't really generalize to float / int and only does double / long

15:57 gtrak: I find that to be the easiest and most fool-proof way.

15:58 Glenjamin: i happen to know all of my numbers in this app are small enough to be short, and i'm loading loads of them

15:58 but i guess if i really wanted to optimise to that level i'd use something else

15:58 justin_smith: it kind of makes sense - the point is that you are using a primitive datum instead of an Object, and an int doesn't provide any savings that a long would not given data layout

15:58 gtrak: martinklepsch: it'll already be on the path, you just might have to login again if the directory doesn't already exist.

15:59 justin_smith: Glenjamin: with ints[] you can definitely take advantage of that

15:59 but on a 64 bit machine, the smallest an isolated datum is going to be is 64 bits iirc

16:02 dbasch: Glenjamin: if you really need to optimize for space, you can pack them into byte arrays, even with delta encoding

16:03 Glenjamin: i *think* i'm ok for space at the mo

16:03 got a few maps, roughly 7 million records

16:03 with 3 longs in each

16:05 i'm looking at optimising the arithmetic at the mo

16:05 just got confused when i tried to annotate some ints

16:17 PigDude: what's the idiom for a string of repeating chars? it can't be this can it? (str (into [] (repeat n c)))

16:17 bbloom: ,(apply str (repeat 10 \!))

16:17 clojurebot: "!!!!!!!!!!"

16:18 PigDude: thanks bbloom

16:19 expez: Why isn't :include-macros true the default?

16:19 bbloom: expez: b/c it throws an error if there is no matching macro file

16:20 expez: oh!

16:20 amalloy: Glenjamin: how sure are you that arithmetic on a short is faster than on a long?

16:20 Glenjamin: i'm not, i was thinking about space in that case

16:20 but realistically, that's probably not an actual concern

16:21 amalloy: i apparently misunderstood "i think i'm ok for space" and "looking at optimizing the arithmetic"

16:21 Glenjamin: was thinking aloud a bit: maybe i could use shorts -> i'm probably ok for space -> back to looking at arithmetic

16:24 gfredericks: I've always been a bit hazy on which primitives actually save space

16:24 e.g., do booleans take 64 bits to store?

16:25 what about boolean arrays?

16:26 amalloy: technomancy: i'd just like to say i'm super pleased with user profiles, and your suggestion that i use my own "swank" profile which is only active when i jack-in. it's so nice to have no.disassemble and criterium always present but not even load them when doing, eg, lein run

16:26 justin_smith: gfredericks: I think any of them will take up 64 bits on their own just because data alignment. But in an array they will be much different.

16:26 "This data type represents one bit of information, but its "size" isn't something that's precisely defined."

16:26 http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

16:26 gfredericks: justin_smith: you know for sure that all primitive arrays are maximally compact?

16:27 justin_smith: gfredericks: I don't think java defines any such guarantee

16:27 Glenjamin: oh, i didn't event realise java had a short primitive!

16:27 technomancy: amalloy: yaaay

16:27 http://p.hagelb.org/power.gif

16:27 amalloy: gfredericks: i was actually looking through the code for System/arraycopy recently. i can tell you that byte[]s, at least, are stored one byte each

16:27 justin_smith: gfredericks: but unlike the standalone value, which will be 64 bit aligned, the ones in the array *can* take up less space

16:27 Glenjamin: "The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation."

16:27 amalloy: and of course this is for my particular jvm

16:27 gfredericks: amalloy: phew; byte[] is so common I'd be appalled by anything else

16:28 Glenjamin: i'm now dangerously tempted to change all these ^long fields to ^byte, they're all under 30

16:28 gotta stop getting sidetracked on this

16:28 amalloy: Glenjamin: but ask yourself, why?

16:28 the arithmetic on them is probably slower

16:29 Glenjamin: ah, good point

16:29 arithmetic first, space later

16:29 gfredericks: when reading the jvm spec I learned that ints are first class, longs are second class, and shorts/bytes are third class; at least wrt the available bytecodes.

16:29 justin_smith: yeah, likely they get promoted to long before ops, then converted back again

16:29 Glenjamin: my current task is exploring optimisations that can be made be writing this process in clojure vs the current approach

16:29 gfredericks: who the hell knows what the jit does with da numbers

16:29 amalloy: justin_smith: that's certainly what clojure does. i don't know about on the jvm

16:30 see https://www.refheap.com/6a808f3be0a0e1bcd16044b35 if you're curious

16:31 (it does something similar even if you set *unchecked-math*)

16:32 Glenjamin: there's some stuff about this in https://www.youtube.com/watch?v=iQwQXVM6oiY

16:41 bjeanes: That was a great talk

16:53 {blake}: I cannot seem to figure out how to iterate over a set.

16:53 Or how to convert it into a seq.

16:53 Or whatever it takes to say "Do this for everything in the set."

16:54 llasram: ,(map inc #{1 2 3 4})

16:54 clojurebot: (2 5 4 3)

16:54 {blake}: What have I done that this isn't working for me?

16:55 llasram: The only guess I have off the top of my head is "actually have something other than a set" :-)

16:55 Oh, or "have set, but set is empty"

16:55 {blake}: Yeah, gotta be. I sometimes...do things...to my REPL...that it never is right again after.

16:56 justin_smith: or you are mapping, but not using the results, so no action, because laziness

16:57 ,(do (map println (range)) :done)

16:57 clojurebot: :done

16:57 Glenjamin: {blake}: got some sample code?

16:58 {blake}: Nah, I got it. I've redefined a function with a variable.

16:58 It's actuall in the iloveponies Clojure course.

16:58 It has you define "authors" as a function. Then later it defs "authors" as a set.

16:59 Gotta be one of my top 10 worst Clojure errors, because for a moment, I think I don't know =anything=.

16:59 Glenjamin: eugh, (empty) returning nil is really annoying

17:00 makes (transient (empty coll)) produce a confusing null pointer error when the data goes wrong

17:01 justin_smith: ,(empty)

17:01 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/empty>

17:01 justin_smith: ,(empty nil)

17:01 clojurebot: nil

17:02 Glenjamin: ,(doc empty)

17:02 clojurebot: "([coll]); Returns an empty collection of the same category as coll, or nil"

17:02 nullptr: ,(empty [])

17:02 clojurebot: []

17:03 justin_smith: ,(empty 42)

17:03 clojurebot: nil

17:03 nullptr: ,(empty [nil])

17:03 clojurebot: []

17:03 Glenjamin: ,(empty (java.util.HashMap.))

17:03 clojurebot: nil

17:03 Glenjamin: or the fun one:

17:03 ,(empty (transient {}))

17:03 clojurebot: nil

17:10 sdegutis: Is there an extraordinarily better way to do this? (for [[k _] pairs] (get another-map k))

17:11 justin_smith: (select-keys a (keys b))

17:11 sdegutis: Precise! Gratitude!

17:12 amalloy: errr, that assumes the input is a map, and returns a map; sdegutis's original worked on a seq of pairs, and returned a seq of pairs

17:12 sdegutis: All these assumptions hold.

17:12 justin_smith: I assumed maps, yeah

17:12 sdegutis: Oh, but wait! They do not hold. Oh no.

17:12 Never mind.

17:13 I'll leave this code as it is.

17:13 amalloy: sdegutis: a more conservative simplification would be (map (comp another-map first) pairs)

17:14 sdegutis: I will try this out, thank you.

17:15 My data is structured such that I have a map whose keys are ordered via /another/ map, the second of which values can be sorted.

17:15 Thus my insanity.

17:15 Glenjamin: i also have a similar system

17:15 although my lookup map is just a vector

17:16 so its { sort-val => key } and { key => actual val } ?

17:41 rhg135: good afternoon everybody

17:42 sdegutis: What do you mean? Do you wish me a good afternoon, or mean that it is a good afternoon whether I want it or not; or that you feel good this afternoon; or that it is an afternoon to be good on?

17:43 technomancy: amontalenti: hey, just saw your bug report on storm.

17:43 cbp: rhg135: what is there important

17:43 technomancy: amontalenti: FWIW my suspicion is that it's not actually a version range but AOT that is problematic

17:43 but I can't make head or tail of the storm git repo to tell what's going on there

17:43 rhg135: idk just being polite :D

17:43 technomancy: and I don't feel like figuring out how to comment on the apache jira to mention it there

17:45 gtrak: sdegutis isn't used to that

17:46 sdegutis: Sorry, we just recently read a book, that's all.

17:55 Glenjamin: anyone know if there's an equivalent to :test-selectors at the repl?

17:55 can't seem to see it in clojure.test api docs

17:56 technomancy: Glenjamin: there's not; clojure.test is monkeypatched up the wazoo

17:56 gtrak: Glenjamin: you could always look at how lein does it.

17:56 probably more trouble than it's worth :-)

17:56 technomancy: it's such a nuisance to get changes into clojure.test that everyone just hacks around it.

17:56 gtrak: staring at it now

17:57 technomancy: it's not good

17:57 Glenjamin: hooray for core

17:57 where things cannot change, but everyone uses them

17:58 amalloy: sounds like a description of clojure: things never change, but it turns out changing things isn't important anyway

17:58 technomancy: There's Always alter-var-root!™

17:58 Glenjamin: more standard libraries in general

17:59 amalloy: it was an immutability joke, guys

17:59 apparently not a good one, but it's too late to change it now

17:59 Glenjamin: hahha

17:59 technomancy: heh

17:59 gtrak: amalloy: my response did not change.

17:59 except for this one. damn.

18:00 We just have lossless change.

18:00 amalloy: you gotta always be on the lookout for immutability jokes

18:00 gtrak: more things change.

18:00 with immutability.

18:01 that's why there's GC pressure.

18:01 bbloom: amalloy: good save with the self-deprecating immutability joke

18:02 amalloy: no such thing as too many immutability jokes

18:02 hiredman: amalloy: yeah, if you don't pay close attention you may miss things never changing

18:13 whodidthis: whats the deal with hyphen and cljs, sometimes i get weird errors with file not found and stuff :( should i avoid names with hyphens in em

18:13 bbloom: whodidthis: you only need to be concerned with leading hyphens. otherwise, more info needed to help you debug

18:14 Glenjamin: bah, sort-of got test-vars working but it's really low level :s

18:14 alter-var-root it is!

18:16 whodidthis: ive had some warnings before with hyphen names on cljsbuild but was working fine, now figwheel has some issue and suggests replacing hyphens with underscores. was just wondering if thats a common practice

18:26 bbloom: argh, how do you search for tickets about the ".." function

18:26 i'm wondering if it is possible to type hint intermediate expressions in a .. chain

18:32 PigDude: does clojure.test have lazy tests? this makes it easy to build tests in other places. basically the runner knows the difference between a plain 'assert' and a 'lazy-assert' which is a function. so if the test fails, you get the correct line location

18:33 used w/ macros, that is

18:33 (i'm used to this in erlang's eunit)

18:34 technomancy: PigDude: clojure.test doesn't usually use assert

18:34 try clojure.test/is

18:34 PigDude: it's made simpler because the test is data. which i can do w/ a macro, but didn't want to reinvent the wheel

18:34 technomancy: is/assert/anything...

18:34 technomancy: I still don't get the distinction

18:34 PigDude: technomancy: so in eunit you have ?assertEqual and ?_assertEqual. the second macro gives you a function instead of a plain assertion

18:35 technomancy: you can call is anywhere

18:35 PigDude: like if clojure.test understood to run a function like #(is (= ...))

18:36 maybe i am just seeing this from the erlang point of view, but right now my unit tests have lots of duplication

18:36 is it common to create utility macros in unit tests to perform common comparisons and such?

18:36 technomancy: I think there's actually a multimethod underlying the implementation of the c.t/is macro

18:36 so you can improve your reporting by adding a method body to that macro

18:37 gtrak: 'is' kinda sucks, since file-and-line is at the point of definition.

18:37 so you have to use macros, or throw exceptions.

18:37 technomancy: usually I try to keep the `is` call inside the deftest and have helpers return values to compare

18:37 gtrak: I thought about how to work around this limitation.. but it'd be kinda dirty.

18:38 PigDude: the feature's described on http://www.erlang.org/doc/apps/eunit/chapter.html , see "Underscore-prefixed macros create test objects"

18:38 amalloy: bbloom: i don't think you can

18:39 bbloom: amalloy: that's what i concluded, but i wanted to report a bug... but i don't know what to call that dopey function :-P

18:39 amalloy: but there shouldn't be a need to, right? if the inputs are hinted, the compiler can infer the types of intermediate results (unless you have a function returning Object that you happen to know will be, say, a List)

18:40 bbloom: amalloy: yeah, it's precisely that last case i had

18:40 needed a downcast

18:41 amalloy: bbloom: trying to stick typehints in the middle of macroexpansions is pretty delicate anyway

18:41 PigDude: how do you prevent your tests frmo having lots of duplication? does somebody have an example? i was looking at clojure.test.generative but didn't need something that powerful

18:41 also it seemed to be difficult to get working

18:41 amalloy: because the forms get torn apart and reassembled with ~@, without copying the metadata

18:42 eg, (-> foo (.bar) ^List (identity) (.size)) might work, but then again probably it doesn't

18:44 PigDude: ah it looks like clojure.test/are is useful

18:47 m1dnight_: So I'll be doing my thesis on Clojure (and other languages)

18:47 I'm so excited \i/

18:47 \o/ even

18:47 bbloom: amalloy: it's ok, i just did some ugly verbose let shit & it feels appropriately java-ish

18:48 nullptr: bbloom: don't forget to wrap it up in a factory or two

18:49 bbloom: nullptr: way ahead of you

18:53 nillkill: quick question, i’m trying to disable all logging via (require '(clojure.tools [logging :as log])). I have a lein project with a /resources dir that contains log4j.properties and has log4j.rootLogger=OFF set yet i’m still seeing info logging come through, any ideas?

19:02 seancorfield: I think log4j.properties has to be in the classes/ folder?

19:03 technomancy: no, resources/ is fine

19:03 seancorfield: Hmm, ok, that's on the classpath?

19:03 nillkill: yeah it is

19:03 just double checked

19:03 ahh i think i may know

19:04 project that i’m using may not be using log4j :)

19:05 seancorfield: That was going to be my second suggestion.

19:05 visof: ,(str ""hello"")

19:05 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: hello in this context, compiling:(NO_SOURCE_PATH:0:0)>

19:05 seancorfield: Also, if "OFF" the right value? I thought that had to be a level, like FATAL?

19:05 visof: ,(str "\"hello\"")

19:05 clojurebot: "\"hello\""

19:05 nillkill: think it’s using slf4j https://gist.github.com/msukmanowsky/61353bba590d256a740a

19:06 visof: is there away to convert ""hello"" to "\"hello\"" without needing to write \ ?

19:06 ,(escape ""hello"")

19:06 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: escape in this context, compiling:(NO_SOURCE_PATH:0:0)>

19:07 visof: ,(str "\"hello\"" {\"})

19:07 clojurebot: #<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>

19:07 visof: ,(escape "\"hello\"" {\"})

19:08 clojurebot: #<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>

19:08 visof: ,(clojure.string/escape "\"hello\"" {\"})

19:08 clojurebot: #<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>

19:08 visof: ,(clojure.string/escape "\"hello\"" {\\"})

19:08 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading string>

19:08 amalloy: visof: no, you cannot write ""hello"" and then do anything with it, because it is not a value

19:09 visof: amalloy: well, what i have dirty strings in a file and need to handle them?

19:09 nillkill: seancorfield: tried with log4j.rootLogger=ERROR, no difference

19:10 dbasch: nillkill: it’s probably not log4j, it could be another logger library such as apache commons logging

19:11 nillkill: dbasch: doesn’t seem like it from lein deps :tree https://gist.github.com/msukmanowsky/61353bba590d256a740a

19:12 seancorfield: nillkill: http://logback.qos.ch/translator/

19:12 dbasch: nillkill: [commons-logging "1.1.1"]

19:12 seancorfield: Note that as a result of this migration, log4j configuration files will no longer be picked up. If you need to migrate your log4j.properties file to logback, the log4j translator might be of help. For configuring logback, please refer to its manual.

19:12

19:12 that's assuming log4j-over-slf4j which I see in the dependencies

19:16 nillkill: dbasch & seancorfield: hmm tried a commons-logging.properties file as well as logback.xml, neither seemed to stop it

19:17 dbasch: nillkill: what does the output look like?

19:18 nillkill: dbasch: https://gist.github.com/msukmanowsky/61353bba590d256a740a

19:18 sparsej just calls lein run under the hood

19:22 bankqian: ls

19:22 lazybot: bin boot data etc home lost+found media root selinux srv sys tmp usr var

19:22 amalloy: wow, lazybot ls'ed him right out of his shell

20:00 PigDude: why does taking from this sequence return the same things every time?

20:00 ,(let [printables (map char (range 33 127)) random-printables (repeatedly #(nth printables (long (rand (count printables)))))] [(take 10 random-printables) (take 10 random-printables)])

20:00 clojurebot: [(\K \/ \I \N \f ...) (\K \/ \I \N \f ...)]

20:01 amalloy: PigDude: sequences are immutable: they never change

20:02 bbloom: PigDude: it's random-printables that doesn't change

20:02 TEttinger: because random-printables is defined once, yeah

20:02 amalloy: if you want to randomly generate a different sequence, you need to start over with a new one, not re-read the same one

20:02 PigDude: what do i need to change to get a sequence of random characters i can take from?

20:02 TEttinger: you can make it a fn and call it

20:02 bbloom: change your (def random-printables ...) to (defn random-printables [] ...) and then call it each time (random-printables)

20:02 PigDude: bbloom: i see, i thought that taking from it caused the function to be called, but that makes sense i guess?

20:03 turbofail: it only runs the computation needed to generate a particular sequence element once

20:03 bbloom: PigDude: taking from it causes any lazy thunks to be called, but they are memoized & never called again

20:03 PigDude: i see

20:04 that makes more sense :)

20:04 turbofail: that said if you need more random numbers you could always just take more elements from the sequence

20:04 TEttinger: ,(let [printables (map char (range 33 127)) random-printables (fn [] (repeatedly #(rand-nth printables)))] [(take 10 (random-printables)) (take 10 (random-printables))])

20:04 clojurebot: [(\( \} \G \. \p ...) (\p \c \D \z \T ...)]

20:05 PigDude: oh, there's rand-nth, not bad

20:59 danneu: If I've defined (defmethod command :look), what's a simple way to make :l delegate to :look without passing through the `defmulti` dispatcher machinery?

21:01 amalloy: danneu: without passing through the dispatcher machinery? what does that mean?

21:02 are you thinking something like this? (defn handle-look [args] ...) (defmethod command :look [args] (handle-look args)) (defmethod command :l [args] (handle-look args))

21:12 danneu: amalloy: is there a way to call the :look defmethod directly?

21:12 amalloy: no

21:17 ashtonkemerling: Afternoon folks.

21:18 danneu: yo

21:19 coventry: ,(do (defmulti t identity) (defmethod t :foo [x] x) ((:foo (.getMethodTable t)) :bar)) ;; <- danneu. Pretty horrible, though.

21:19 clojurebot: :bar

21:19 ashtonkemerling: What the hell?

21:19 coventry: I'm committing perversions with clojurebot.

21:19 ashtonkemerling: Are you trying to break it?

21:21 danneu: coventry: great, thanks

22:35 bbloom: *sigh* hacker news upvotes a "lisp" that "compiles to c++" ... meanwhile, it's literally a transpiler so shallow that it has EXPLICIT RETURNS

22:36 jeremyheiler: lol

22:36 bbloom: i really need to blackhole news.ycombinator.com and save my sanity

22:36 jeremyheiler: i use lobste.rs

22:37 bbloom: i have an account there, but i forget it exists

22:37 i still navigate to reader.google.com by accident a few times per week

22:37 jeremyheiler: haha

22:37 bbloom: my fingers hate my productivity

22:53 seangrov`: bbloom: But have yout not yet realized that really, c++ is just a bit of syntax mangling away from being a very pleasant platform - mind-bending semantics ignored?

Logging service provided by n01se.net