#clojure logs

2014-05-07

00:08Jaoodso why does lein repl switches you to the core.clj namespace in the the app template and not in the library template?
00:08gtrakJaood: the :main controls this
00:09gtrakor :init-ns
00:09gtrakif there's no -main
00:09gtrakin repl-options
00:09gtrakhttps://github.com/technomancy/leiningen/blob/master/sample.project.clj#L308
00:11Jaoodgtrak: oh I see, thanks
00:26rhg135So I have some shared state, a map, and need to use it concurrently to perform io, so can't swap!, any ideas?
00:26gtrakrhg135: you'll have to be more specific.
00:27rhg135How so?
00:27gtrakI don't know :-)
00:27rhg135I figured it was a dead end
00:27gtrakI guess, what's in the map, what's the IO?
00:27gtrakwhat needs to be concurrent?
00:28rhg135The io is a async put!
00:29gtrakasync put from the map, or into the map?
00:29rhg135This is for an irc/xmpp server
00:29rhg135A channel in the map
00:30gtrakso, you're doing put! into a channel, what's the map got to do with it?
00:31rhg135I need to access and update it but do io meanwhile
00:31gtrakyou need change the channel out, or something else?
00:32rhg135Yes
00:33gtrakis 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?
00:34gtrakerr.. I guess, what's it supposed to do..
00:34gtrakif you want to distribute requests across a bunch of channels, you could just use a lazy sequence.
00:34rhg135I'm probably doing it wrong but the channel writes to a client
00:36gtraknow that sounds like a lookup table of ID->client-channel.
00:36rhg135Basically
00:36gtrakso.. you don't need to be swapping out channels, just adding or removing them.
00:37rhg135It's actually bigger
00:37gtrakif each client has a unique id.
00:37rhg135It has chat channels too
00:37rhg135And they do
00:40rhg135If this was sequential I could use a reduce, that concurrency
00:41gtrakyea, I guess the intrinsic structure of it isn't obvious to me.
00:42rhg135I think I know how, when I get to my computer I'll paste it
00:48rhg135{:users {:an-user {:chan <ch> :timeout <number> :channels ["#clojure"]}}} ; state, gtrak
00:49gtrakmy suspicion is you're trying to do something manually that could be better expressed as go-loops.
00:50gtrakor some other kind of built-in glue.
00:51rhg135I am but I'm struggling with managing this state
00:51gtrakyou shouldn't have to look up channels to put! every time, it sounds like a job for tap and mult.
00:52gtrakor the pub/sub stuff.
00:52rhg135Hmm
00:52rhg135I didn't know
00:54rhg135Any good examples?
00:55gtrakhaven'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
00:55gtrakI've had to stare at the source to get anywhere in core.async.
01:37MongeyHey, can someone help explain how this piece of code works?
01:37Mongeyhttps://gist.github.com/Mongey/adbdd1519549ece3c313
01:38arrdem,([1 2 3 4] 2)
01:38clojurebot3
01:38arrdemwat
01:38arrdemMongey: is that a hint?
01:38Mongeya hint ?
01:39arrdemMongey: what do count, range, map om/build and comment-data do as functions?
01:40JaoodMongey: what don't you understand about the code?
01:42MongeyJaood: what the "#(" infront of the om/build does
01:42arrdemin fairness explicit types would make that a little easier to understand, but only bearly.
01:42arrdem*barely.
01:42arrdemMongey: #() creates an anonymous and presumably partially applied function
01:42arrdem,(#(+ 1 %1) 2)
01:42clojurebot3
01:43arrdem,(#(into [] [%]) 1 2 3 4)
01:43clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: sandbox/eval77/fn--78>
01:43arrdemcrud.
01:43Mongeyok, I guess that makes sense.
01:43arrdemOh. % == %1
01:44arrdem,(#(+ % 1) 1)
01:44clojurebot2
01:44arrdemyep.
01:44JaoodMongey: yeah, what arrdem , its syntax for function literals
01:44Jaood*said
01:45Mongeyand then % is the first argument ?
01:46Jaoodyes
01:46MarlaBrown(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")
01:46MarlaBrown#{["Jaood" "#clojure" "*said"] ["Jaood" "#clojure" "Mongey: yeah, what arrdem , its syntax for function literals"]}
01:46arrdemwell... strictly only argument.
01:46gwsMongey: 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
01:46arrdemMarlaBrown: wat
01:47arrdemMarlaBrown: i c u writing datomic queries...
01:47gws,(["foo" "bar"] 0)
01:47clojurebot"foo"
01:47gwsMongey: ^
01:48MongeyI see
01:48MarlaBrownits more like a function being called on a value than a "query" ;)
01:50arrdemheh
01:51Jaoodarrdem: why does a CinC still doesn't exist if there already is a Clojure compiler to bootstrap it? or it ain't that easy? :)
01:51arrdemJaood: CinC does exist... it''
01:51arrdemit's just tools.analyzer and tools.emitter.jvm
01:51arrdemand my yet to be named GSoC compiler...
01:52arrdemwhich I actually should talk to tb and bronsa about naming...
01:52Mongeymakes sense now, thanks
01:52Jaoodoh haven't seen those, can you resume what each one of those do? :)
01:53arrdem"resume"?
01:53JaoodI guess one emits java bytecode and the other is the parser?
01:53JaoodJaood: forgot the word, not a native english speaker
01:54Jaoodmaybe 'explain' would had been better
01:54arrdemtools.reader is a lexer/parser, tools.analyzer is a metadata analysis framework and tools.emitter and tools.emitter.jvm are bytecode generators
01:55arrdemJaood: 'explain' or 'revise' would have been legitimate, although 'revise' would be a relatively archaic word choice.
01:55arrdem'review' could have made sense too.
01:55Jaoodarrdem: thanks
01:56irctchey 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?
01:56irctchttp://postimg.org/image/kra5hs4yl/
01:56Jaoodarrdem: so you are going create a standalone compiler out of those tools?
01:56irctcmail
01:57arrdemJaood: out of the reader and analyzer at least. I'll be building a very different emitter I suspect.
01:58Jaoodarrdem: so the compiler won't need to rely on ASM anymore right?
02:00arrdemJaood: 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.
02:00arrdemwhere the tools.emitter.jvm system strives for bite-for-byte parity in emitted code.
02:01Jaoodinteresting, good luck then!
02:08amalloytools.emitter.jvm aims for byte-compatibility? i thought bronsa was touting its ability to not emit unnecessary casts
02:09arrdemamalloy: 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.
02:13Jaoodarrdem: is the reason bytecode backward compability?
02:32sm0kehey 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
02:36jeremyheilersm0ke: the test command automatically merges in the test profile
02:38sm0kehurm
02:40sm0kehttps://github.com/dakrone/cheshire/blob/master/project.clj
02:40sm0kethis seems to be working
02:40jeremyheilera shot in the dark, but maybe try `lein with-profile -test,dev,foo`
02:40sm0kedont know how
02:40sm0kethe benchmark profile in that
02:41sm0keseems to run only benchmark tests with mucking around with anything else
02:41sm0kewithout*
02:43sm0keweird i doubt if it has something to do with selectors
02:43sm0keeven the benchmark tests are not anootated ^:benchmark
02:43sm0keimpossibru!!
02:44foofoobarHi. I'm doing clojure koans: "Higher-order functions take function arguments": (= 25 (___ (fn [n] (* n n))))
02:44foofoobarHow to solve this?
02:45arrdemI'd use #(% 5) for _
02:46MarlaBrown(find-partial "solve" (d/db @conn))
02:46MarlaBrown#{["foofoobar" "#clojure" "How to solve this?"]}
02:46arrdemMarlaBrown: you keep doing that...
02:46MarlaBrowni need sleep
02:46arrdemMarlaBrown: coffee?
02:46arrdemor that... I should do that too.
02:47foofoobararrdem, ah, an anonymous function, thanks for the hint!
02:47foofoobarMarlaBrown, what should this tell me?
02:48MarlaBrownfoofoobar: the nsa is everwhere man
02:48MarlaBrownprism + datomic == love
02:48arrdemand if the NSA isn't listening then some other jackarse is for their own entertainment :P
02:48MarlaBrown:thumbsups:
02:48arrdemI need to get an emacs plugin to render those as glyphs
02:49MarlaBrownclojure needs an emoji reader macro
02:50arrdemI'm a fan of this...
02:51MarlaBrown#/smile/
02:51arrdemha
02:51arrdemwell what you could do is #emoji :smile:
02:51arrdem,:smile:
02:51clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :smile:>
02:51arrdemor not...
02:52MarlaBrowndispatch macro needs a leading character
02:52arrdemyou could totally do #emoji "smile", and maybe #emoji smile
02:52sm0kearrdem: no you cant
02:53sm0ke#my/emoji "simle" is possible though
02:53sm0kesmile*
02:53MarlaBrown#emo/ji smile
02:53arrdemoh. right. סּ_סּ
02:54sm0ke#emo/ji ":P"
02:54arrdempls can make this a thing and add clojurebot support for it
02:54arrdemwill gladly put 10kDOGE bounty on it :P
02:54arrdemor I should say ###emo/ji "=D"
02:55arrdemfunny... lazybot shoulda seen that one.
02:56sm0kehmm ## '?
02:56lazybot⇒ ?
03:06MarlaBrownwatcher.core=> #emo/ji hearteyes
03:06MarlaBrown"😍"
03:06MarlaBrownmy poor project
03:09arrdem:bowtie:
03:09arrdem:D
03:10foofoobararrdem, again stuck: "Numbers are not the only things one can reduce": (= "longest" (reduce (fn [a b] (if (< __ __) b a)) ["which" "word" "is" "longest"])))
03:11arrdemfoofoobar: what is a string?
03:11foofoobara char sequence?
03:11arrdemBingo! How do we get the length of a sequence?
03:12foofoobarcount
03:12arrdemRight. that should be all you need.
03:12foofoobarah, got it working :)
03:12foofoobarNice, thank you!
03:13foofoobarI thought doing something like (< "foo" "foobar") aready compares the lengths
03:14arrdem:-1:
03:14brackiHaving a hard time with: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol
03:15brackiWhat is usually calling this? I can't neither repl,run nor uberjar
03:15brackis/ll/us/
03:17brackiAll I do is try to (:use clj_finagle.core).
03:18brackiCan anybody spot what's wrong here: https://github.com/jcrean/clj-finagle/blob/master/src/clj_finagle/core.clj#L31?
03:18arrdem,(println ":wink:")
03:18clojurebot:wink:\n
03:20devurandomHello!
03:21devurandomI still have to get used to thinking in Clojure:
03:21beamsolein try clj-finagle downloads teh intarwebs
03:22winko_O
03:23devurandomI 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}}})
03:23devurandomHow do I do that properly?
03:24jeremyheilerdevurandom: what do you mean by "for every"?
03:24MarlaBrownwatcher.core=> (println "not sure if I" #emo/ji heart " you, or think you smell like" #emo/ji poop)
03:24MarlaBrownnot sure if I 😍 you, or think you smell like
03:25devurandomSorry, actually it is (atom {:foo {:bar {:some data} :baz {:other data}}}) -> (atom {:foo {:bar {:some data :more data} :baz {:other data :even more}}})
03:25MarlaBrownit truncated my emoji
03:25MarlaBrown:(
03:26devurandomjeremyheiler: :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.
03:26beamsobracki: at a guess the defn for processor is lower in the source code than the defn for rpc-service-impl
03:27devurandomI 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.
03:28jeremyheilerdevurandom: maybe get all the keys and reduce over them, updating the atom on each step?
03:28jeremyheiler(reduce (fn ...) the-atom (keys you want to update))
03:30devurandomHm. 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?
03:31jeremyheiler(keys (:foo @the-atom)) will get you the keys you want
03:31jeremyheilerwell, at least all teh keys in teh :foo map
03:33amalloydevurandom: (swap! the-atom update-in [:foo] (fn [foo] (reduce ...)))
03:36arrdemw00t managed to get the "standard" github emoji installed into erc-smiley :D
03:45devurandomamalloy, jeremyheiler: Thanks!
03:46MarlaBrownerc-smiley?
03:46MarlaBrownah emacs
03:52foofoobar(= (repeat 100 :foo) (take 100 (iterate __ :foo))))
03:52foofoobarWhich functions combines them ?
03:52Glenjamin,(doc iterate)
03:52clojurebot"([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"
03:52TEttingerso identity?
03:53Glenjamin,(= (repeat 100 :foo) (take 100 (identity :foo))))
03:53clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>
03:53Glenjamin,(= (repeat 100 :foo) (take 100 (iterate identity :foo))))
03:53clojurebottrue
03:53Glenjamintypo :)
03:54foofoobar,(doc identity)
03:54clojurebot"([x]); Returns its argument."
03:54foofoobaroh, simple.
04:21roelofhow can I destruct this the right way: http://pastebin.com/dTnKbazt
04:26maxthoursieroelof: seems you got some unbalanced paranthisis there?
04:26roelofmaxthoursie: sorry what do you mean with that ?
04:29maxthoursiereiddraper: there's too many square brackets
04:29maxthoursiesorry, wrong completion
04:30maxthoursieroelof: ^
04:33roelofmaxthoursie: oke , I think the problem is in the let part. I have to destruct two variables rectangle and point. Maybe use two times let ?
04:33maxthoursieroelof: no need for that
04:33maxthoursieroelof: (let [[[xr1 yr1] [xr2 xr2]] rectangle
04:33maxthoursie [xp yp] point]
04:34roelofyep, that part I mean
04:34maxthoursieroelof: that's rewritten in a way that works
04:34roelofI think I have done something wrong there but I have no idea what
04:35maxthoursieroelof: hm so how would you write it with two lets?
04:36roelofoke, I see where i go wrong. the first [ has to be when all variables are decontruct
04:37maxthoursieroelof: also, double check your var nams, xr2 appears twice
04:38roelofoke, 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
04:39roeloffound it another variable error
04:40maxthoursiegood
04:43clgvroelof: if you want that function to be robust you should sort x and y coordinates of the rect each
04:45roelofclgv: I see what you mean. How can I implent sort into it . Im trying to learn clojure by the iloveponies github lessons
04:47maxthoursieroelof: you could just (sort [xr1 xr2)) and deconstruct that
04:48maxthoursieroelof: In this case just using an or to also check for the (< xr2 xp xr1) case is simpler
04:49clgvroelof: for two values just via `if` ;)
04:49roelofoke , thanks for the little lesson
04:49clgvbut maybe the suggested solution via `or` is shorter
04:50clgv,(let [a 2, b 1, [a b] (if (< a b) [a b] [b a])] (println a b))
04:50clojurebot1 2\n
04:51clgvroelof: one option for inline sorting. ^^
04:52roelofoke, I see how it works
04:52maxthoursieroelof: to make it readable, I would go with a helper function
04:52maxthoursieroelof: (defn within [a b p] (or (< a p b) (> a p b)))
04:54roelofoke, 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
04:56roelofI have to check for every point of the smaller rectangle if its true or false and I can use the fuction I wrote containspoint ?
04:56roelofmaybe a cond ?
04:57maxthoursieroelof: just play with it
04:59roelofI know, I m thinking aloud sorry
04:59maxthoursienp
05:54dhruvasagarHey guys, can someone recommend a good web framework ? I am looking at Luminus & Noir
05:55maxthoursiedhruvasagar: My recommendation would actually be to start with something basic like only ring+compojure
05:55maxthoursiedhruvasagar: Then you will know what you want after a while
05:55dhruvasagarmaxthoursie: hmm and that would be good because i'd learn the internals ?
05:57dhruvasagarmaxthoursie: also, would you recommend a good book for clojure ?
05:57dhruvasagarmaxthoursie: s/would/could
05:57maxthoursiedhruvasagar: well, internals feels like a harsh word, basics maybe. Most web stuff in clojure is based on ring
05:58maxthoursiedhruvasagar: I like The Joy of Clojure since it focus more on how to think than how to do
05:58dhruvasagarmaxthoursie: cool, I think I already have that book, i'll read it :)
05:59dhruvasagarmaxthoursie: thanks
05:59maxthoursienp
06:05sm0ke:D
06:06systemfaultI bought JoC… I hated reading it :P
06:06maxthoursiesystemfault: why?
06:06lockssystemfault: :O
06:07systemfaultmaxthoursie: The content is very good but there are way too much explainations… to me, it was boring.
06:07clgvdhruvasagar: 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
06:08clgv*new
06:08maxthoursiesystemfault: well, I can agree with that it was slow at times
06:10locks_slow_?
06:10locksdid you know Lisp already?
06:13Morgawrmy favorite clojure books are Clojure programming and The Joy of Clojure
06:14MorgawrI 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
06:14systemfaultMorgawr: I should buy Clojure Programming.
06:14MorgawrI 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
06:17clgvsystemfault: are you sure? if you found JoC slow, I cant imagine what you say about the "Clojure Programming"
06:18Morgawrmaybe 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
06:18systemfaultAh :/
06:18MorgawrI mean, we have the ~internet~
06:22maxthoursieI 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
06:23MorgawrI 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
06:23Morgawrbut this is just personal preference
06:23maxthoursieI like it better when functions are introduced when needed by a larger example, than just linearly by namespace
06:24maxthoursieMorgawr: 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
06:26clgvmaxthoursie: then the writing approach of "Clojure Programming" suits you, right?
06:27maxthoursieclgv: Yes, I liked that one
06:27maxthoursieKeep mixing it up with the M-t version though
06:27clgv"M-t"?
06:28maxthoursieas in the emacs command
06:28maxthoursiethat is swap words
06:28MorgawrI 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)
06:28clgvlol. emacs shortcuts as abbreviation for words in a sentence...
06:29Morgawrit also works in bash to swap characters :P
06:29maxthoursieMorgawr: I agree, that's the book I've liked the least, but also didn't read it.
06:29maxthoursiefully
06:29clgvI'd describe the wrinting style of "Programming Clojure" as much more technical...
06:30clgvbut you are able to read through it in approx. 3-4 days and have learned the most important basics.
06:33maxthoursieIsn't that true for most of the books on clojure?
06:37mengui've read programming clojure probably 3 times
06:37menguand on the 4th time, i got it
06:37mengubut that's just me, an idiot, who takes his time to grasp things :-)
06:39locksmengu: so a normal person then :P
06:39menguwell, on the 4th time, i sat down and said to myself; i'm going to understand this book now. :-D
06:50clgvmaxthoursie: I could only read the first book fulltime, so I dont know ;)
06:53maxthoursieI've read five books on clojure, and it starts to feel like they're all the same
06:57sw1nnmpenet: 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
06:58maxthoursiesw1nn: how do you get a cider-scratch buffer?
06:59sw1nnmaxthoursie: M-x cider-scratch
06:59maxthoursieI don't have that, version?
07:00sw1nnCIDER 0.7.0alpha (package: 20140505.1132)
07:00sw1nnit claims C-j evals last sexp, but I don't have that, haven't investigated.
07:01dhruvasagarclgv: thanks
07:01sw1nnso I use C-x, M-e
07:01maxthoursieseems like I'm on cider 0.5
07:02clgvmaxthoursie: well would be odd if it were different, then some books would tell you bullshit ;)
07:02maxthoursieclgv: haha, well, in a way that's true.
07:07mpenetsw1nn: the cql spec wants quotes around identifiers with -
07:07mpenetsw1nn: hayt does this for you if you just use a string
07:07sw1nnmpenet: yes, but the keyword handling in CQLEntitie protocol doesn't put them in
07:07mpenet(select :meta-data (columns "a-b" "b-c") (where [[= "a-b" "foo"]])) should do it
07:07mpenet
07:07mpenethmm
07:08sw1nnmpenet: is there a downside to doing it for keywords too?
07:08maxthoursiesw1nn: works great, thanks for the tip
07:08mpenetsw1nn: perf hit for the most common case imo
07:09sw1nnmpenet: most common case is to use strings for column names? really? would have thought keywords would be more common?
07:09mpenetno, I mean double quoting always
07:09mpenetex you could have an id that's namespaced foo.bar
07:10mpenetfoo."bar-baz"
07:10mpenetetc
07:10sw1nnmpenet: ah, hadn't thought of that.
07:10mpenetI did took some liberties in the name of performance too, kw are the most common, kw including dashes not so much
07:11mpenetjust quote them when it's the case and you ll be good
07:11mpenet(->raw (select :meta-data (columns "a-b" "b-c") (where [[= "a-b"
07:11mpenet "foo"]])))
07:11mpenet"SELECT \"a-b\", \"b-c\" FROM meta-data WHERE \"a-b\" = 'foo';"
07:12mpenetalso 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
07:13mpenetI mean cql-identifier
07:14sw1nnkeywords with dashes are very common in my code, maybe I'm odd in that regard?
07:15mpenetwell, let's just say it's not so common in CQL usually, it's very clojure-like mostly
07:15mpenetmostly because it forces to use quoting, and people are lazy :)
07:16mpenetbut you can extend the protocol for your use I guess, it should do no harm
07:17sw1nnso, 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"?
07:17sw1nnmpenet: anyway, thanks for the help
07:17mpenetyes, the short version is when using clj keywords as cql identifiers no quoting happens, ever
07:19mpenetmight be of interest : http://cassandra.apache.org/doc/cql3/CQL.html#identifiers
07:21maxthoursiedeobalds: 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
07:21devurandomI 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?
07:24emlyndevurandom: I think you want (get-in state [:foo [x y]])
07:25emlyndevurandom: what you have expands to ([x y] (:foo state))
07:26joelkuiperHey! I'm trying to dynamically load a file (outside of classpath) and refer to a specific var in it
07:26maxthoursiedevurandom: and a vector is not a function
07:26deobaldsmaxthoursie: Nope. :( Sadly, we just rolled everyone back to 0.6.0.
07:26maxthoursiedeobalds: how do you downgrade with package-install?
07:27joelkuiperWhat I do right now is slurp the file then load-string and then (var-get (intern (symbol "the persumed namespace") (symbol "var")))
07:27joelkuiperis that the best way to do it?
07:27devurandomemlyn, maxthoursie: Thanks!
07:28joelkuiperIt'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)
07:33deobaldsmaxthoursie: Again, sadly... we just copied over someone's emacs.d who hadn't upgraded yet. :/
07:33maxthoursiedeobalds: yupp, doesn't seem to be another way
07:33joelkuiperthis is what I mean: https://gist.github.com/joelkuiper/e9d34f3053fa795a5cd3
07:34joelkuiper(loading a var from a file)
07:34maxthoursiedeobalds: successfully downgraded manualy. Thanks for your info.
07:36joelkuiper"concrete use case, I have some third-party definable processing stuff that I wish to call, without knowing beforehand which are availabel
07:36joelkuiperso they are put in some resource folder
07:36joelkuiperand I attempt to load them at runtime with some naming conventions
07:38joelkuiper(by third-party I mean trusted third-party, so whatever is in those files I assume safe)
07:56clgvjoelkuiper: whats wrong with "load-file"?
07:58f3ewWhat's the clojure equivalent of Perl's Data::Dumper?
07:58deobaldsmaxthoursie: How did you downgrade manually, out of curiosity?
07:58maxthoursiedeobalds: I had an old copy of my .emacs.d, just as you said
08:03broquaintf3ew: pprint? http://clojuredocs.org/clojure_core/clojure.pprint/pprint
08:04ssiderisf3ew: 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
08:06f3ewout*
08:06f3ewIs there the equivalent of @_?
08:06ssiderisnope
08:06ssiderisyou can pass any data structure to pr-str
08:07ssideris,(pr-str [1 2 3 #{10 20}])
08:07clojurebot"[1 2 3 #{20 10}]"
08:07joelkuiperRight so I updated the thing; but I feel it's completely stupid https://gist.github.com/joelkuiper/e9d34f3053fa795a5cd3
08:07ssiderisit just turns it into a string that can later be read by clojure.edn/read-string
08:07f3ewLovely. 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)?
08:08f3ewThe point of trying to dump the input is so that I can actually see WTF is happening
08:08ssiderisf3ew: https://github.com/clojure/tools.trace
08:09ssiderisusing 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
08:11systemfaultLooks awesome, thanks ssideris :) (Still learning)
08:11ssiderisno prob
08:12ssiderisdo you have a REPL?
08:12systemfaultf3ew: Must be quite a jump from Perl to Clojure :/
08:12ssiderisI can't believe I used to like Perl. No disrespect f3ew
08:13ssiderissystemfault: perl has map()!
08:13systemfaultawesome! What are you waiting for to write a blog called “Perl is a functional programming language” and post it on HN? ;)
08:15broquaintIt's not really a functional language but functional techniques can be applied - http://hop.perl.plover.com/
08:15ssiderisbroquaint: I was about to mention that book :-)
08:30devurandomThanks again everyone for your tremendously useful help! My app runs now nicely, after porting it from JS! :)
08:31devurandomOf course, I assume there are still lots of things that can be improved, once I know Clojure better.
08:32CookedGryphonHas anyone here used jayq? I'm getting issues with No such namespace $
08:32CookedGryphonanybody got ideas as to what that means?
08:34beamsohave you included jquery?
08:34CookedGryphonyes, in a script tag
08:35CookedGryphonwhen I put it in :externs I got all sorts of warnings as it tried to parse the jquery file
08:35ssiderisCookedGryphon: I haven't used it, but interestingly, this commit seems to be about $ as a namespace: https://github.com/ibdknox/jayq/commit/297fbf394e91a89d3ebe75f60363b8d1492621c4
08:36CookedGryphonssideris: interesting, I noticed that commit but didn't actually look at it
08:36CookedGryphonI assumed it had made it into the latest release
08:36CookedGryphonas it was so long ago, and the current project.clj says the same version I got from clojars
08:37CookedGryphonbut looking at the source on my machine, that doesn't appear to be the case
08:37beamsojquery is in the page before jayq?
08:38CookedGryphonbeamso: yeah
08:38CookedGryphondoes clojurescript know not to munge my calls out to jquery?
08:38beamsono idea
08:38beamsohttp://hugoduncan.org/post/clojurescript-libs-with-js-dependencies/
08:41jcromartiewhat is a good naming convention for reference type variables
08:41jcromartielike, delay, future, atom, etc.
08:42jcromartielike, if I had (let [x (some-expensive-op)] …) and I changed it to (let [x (delay (some-expensive-op))] …)
08:42jcromartieI would want to change the name x
08:42jcromartiebut to what?
08:42jcromartiex-ref?
08:43CookedGryphonssideris: so I built from master and that seems to do away with the warnings interestingly
08:43clgvwell they are IDerefs ro "ref would fit if it is not misinterpreted to refer to a "ref" only
08:44jcromartieyeah
08:52ssiderisCookedGryphon: hm, good to know... maybe you should insist that the developers release a new version
08:52CookedGryphonssideris: yeah, I'll file an issue
09:33mdrogalisHowdy 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?
09:34agarmanwhat dependency?
09:34mdrogalisClient's in-house library. Nothing public.
09:35mdrogalisCan't use an uberjar since that's not meant for Maven.
09:35agarmank, you need to put the jar into a local repos
09:35mdrogalisagarman: Indeed. I've installed it into .m2
09:36agarmanthe path has to be correct
09:36mdrogalisagarman: I'm sorry, which path?
09:36agarmanthe path in .m2
09:37mdrogalisagarman: Right, it's successfully installed with the appropriate group, artificat id, version, and packaging parameters.
09:40mdrogalisHuh, fixed it. I decompressed the jar, moved the pom.xml file and replaced the one in .m2. *Shrug*
09:40mdrogalisPerhaps I hit a bug or something. Thanks!
09:42mskoudI'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?
09:44agarmanexception in the do will break your while loop and percolate up to the future
09:44agarmanbreaking the future
09:45mdrogalismskoud: If you're running a process for days on end, you might want to use something more robust for daemons.
09:45justin_smithmskoud: you can call done? to see if a future has completed
09:45justin_smithalso agents have some built in features for specifying an error handling function
09:45agarmanor just deref and see if you have an exception
09:46justin_smithagarman: well the deref will block if the future has not completed
09:46mskoudthe future never ends, its a loop which sleeps for some secs and do some work and repeat.
09:46justin_smithmskoud: it will end and done? will return true if an exception breaks the while loop
09:47mskoudyes right.
09:47mskoudbut i would need to deref within regular intervals to check if it return an exception.
09:48mskoudmaybe futures it not the way to go.
09:51ssiderismskoud: because futures run in separate threads, you wont see the exception
09:51mskoudyou, that probertly what happened. Will try to catch the exceptions, and see it that solves it.
10:00agarmanjustin_smith if you want to restart a failed future, deref that returns would be a good watch-dog
10:01agarman,@(future (throw (Exception. "foo")))
10:01clojurebot#<SecurityException java.lang.SecurityException: no threads please>
10:02agarmanexception isn't lost, it'd be in the future as the result
10:04irq0is there a way to attach metadata to multimethods and retriving it from all methods?
10:12visofhow can i write this java code as clojure new TripleString(x.toString(), y.toString(), z.toString()); ?
10:13broquaintvisof: (TripleString. (.toString x) (.toString y) (.toString z))
10:16justin_smithor even (TripleString. (str x) (str y) (str z)) I think
10:17justin_smithyeah, str calls toString when called with a single arg (returning "" on nil)
10:18TEttinger,(.toString nil)
10:18clojurebot#<NullPointerException java.lang.NullPointerException>
10:18TEttingerso that's a reason to use str
10:20visofbroquaint: what if i want to set values like this this.header = header; ?
10:20visofbroquaint: how can i do this in clojure
10:22visofi want to convert much of this java code to clojure https://www.refheap.com/85214
10:24visofis this possible?
10:24ToxicFrogvisof: 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:25bbloomvisof: that sort of constructor is trivial:
10:26bbloom(deftype PlainHeaderIterator [header pattern pos])
10:26bbloom(defn plain-header-iterator [header pattern] (PlainHeaderIterator. header pattern 0))
10:29CookedGryphonIn clojurescript, should I be able to pr-str anything, like i can in clojure?
10:30CookedGryphonI'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:30nillkillquick 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:32visofbbloom: i just wanted to rewrite this method to get only first match
10:32visofnot list of results
10:32cshellIs there a leiningen plugin for scp’ing an uberjar/artifact over and calling a startup/bounce script?
10:34ToxicFrog,(into {} (map identity [{:a 1 :b 2} {:a 2 :b 2}]))
10:34clojurebot{:b 2, :a 2}
10:34ToxicFrognillkill: ^
10:34ToxicFrogmap returns a seq of maps; into then adds them to {} in sequence, each one overwriting the previous.
10:34ToxicFrogBecause they all have the same keys.
10:35justin_smithyou may want merge-with
10:35justin_smithdepends on the shape you want for the output
10:35ToxicFrogYeah, the most straightforward conversion is just to return that seq.
10:35ToxicFrogYou say you want "a map of information", but keyed by what? id?
10:35nillkillah, so something like this? (into {} (map identity #({:id (.get_id %) :name (.get_name %)…
10:36nillkillwell basically i get a list of topology information objects
10:36nillkillthrift ones
10:36nillkillwhich i’d want to convert into a map that has keys :id, :name, :status, etc
10:36nillkillmapping to fields on those objects
10:36ToxicFrogRight, you already have that part working.
10:36BobSchackCookedGryphon: what datastructure are you trying to log?
10:36ToxicFrogBut you have *a seq* of these individual maps.
10:37CookedGryphonBobSchack: If I knew that I wouldn't need to log it :P
10:37CookedGryphonBobSchack: I think it's a map of keyword to js objects
10:37CookedGryphonbut possibly not
10:37justin_smithnillkill: nitpick - #({... }) is usually wrong, that is trying to call the map literal as a function
10:38nillkillyeah, i’m starting to see that :)
10:38nillkillahh so sorry what i really want is a list/vector of maps
10:38nillkillso (into [] (...)
10:40ssiderisor even (vec (...))
10:40nillkillyeah, that should be fine too
10:40justin_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:40clojurebot{0 [{:id 0, :b 1, :a 0}], 1 [{:id 1, :b 2, :a 2}], 22 [{:id 22, :a 3}]}
10:40justin_smiththen you can do :id based lookup
10:41nillkillahh, that’s really cool justin
10:41ToxicFrog<3 group-by
10:42BobSchackCookedGryphon it sounds like you're trying to use string as a map
10:44BobSchackIt'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:44CookedGryphonBobSchack: yeah, i see that's the error
10:44CookedGryphonI don't get how doing str on something should give me that error
10:45CookedGryphonas if I remove the str and just log x, it's fine
10:46BobSchackcan you show me the code?
10:47nillkillso 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:47justin_smithcshell: I was wrong, lein deploy is only for putting jars into repos
10:48cshelljustin_smith: no worries - I haven’t seen a good one for ssh deploying combined with any type of startup/shutdown command
10:48justin_smithcshell: what about spawning a simple shell script as an injection for a specific profile?
10:49cshelljustin_smith: Yeah, that would work - I was looking at that or something like conch (shell abstraction)
10:49justin_smithI 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:49cshelljustin_smith: so the script to scp and any other remote commands goes into jenkins?
10:49justin_smithcshell: the commands were entered as one of the steps in the jenkins deploy config
10:50cshelljustin_smith: ah, cool!
10:50justin_smithI mean jenkins is a whole other can of worms and may be more than you need, just mentioning that is what I used.
10:51justin_smithjenkins can watch your master branch, and push a deploy to production whenever master updates and tests pass
10:51cshelljustin_smith: it makes sense - what were youusing to stop any existing deployment?
10:51cshelljustin_smith: a kill of some kind?
10:51CookedGryphonBobSchack: '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:52justin_smithcshell: for that part I had a couple of scripts, one sec and I'll share
10:56justin_smithcshell: https://www.refheap.com/85216 this is three scripts - they are imperfect, but are a good start I think
10:56justin_smithcompile / deploy / run
10:56justin_smiththe run script handles both starting and stopping
10:56clgvCookedGryphon: try-catch around the reported location? (provided that exists in CLJS)
10:57justin_smithcshell: 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:57cshelljustin_smith: cool, this is really hepful, thanks!
10:58cshell~justin_smith++
10:58clojurebotHuh?
10:59cshellguess that’s only in #java
11:00justin_smithwe use inc here
11:00justin_smithbut thanks
11:00cshell~inc justin_smith
11:00clojurebotNo entiendo
11:00justin_smith(inc juxt)
11:00lazybot⇒ 9
11:01cshell(inc justin_smith)
11:01bbloom(inc notation-of-the-gods)
11:01lazybot⇒ 41
11:01justin_smithyou would think that function would be more popular
11:01lazybot⇒ 1
11:01CookedGryphoninteresting, 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:02ssiderisnillkill: what you wrote is the equivalent of (vec (map (fn [x] ({:id (.get_id x)})) topologies))
11:02CookedGryphonis there some gotcha with sets in clojurescript?
11:02ssideristhis will try and call the map as a function: ({:id (.get_id x)})
11:02ssiderismaps are functions, but I don't think that's what you're trying to do in this case, right?
11:03cbp(inc tree-seq)
11:03lazybot⇒ 1
11:04nillkillssideris: basically trying to do something similar to (vec (map bean topologies)) but specify the exact fields i want
11:05cshell, ({:id (.get_id x)})
11:05clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:05ssiderishow about (vec (map #(select-keys (bean %) [:k1 :k2]) topologies))
11:05cshell ({:id :a})
11:05ssiderisbut bean is a bit slow because of reflection I think
11:05nillkillyeah, i’d prefer not to use that
11:05cshell,({:id :a})
11:05clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap>
11:06nillkillwas just trying (vec (map (fn [topology] {:id (.get_id topology)})))
11:06ssiderisso you can just do: (vec (map (fn [x] {:id (.get_id x)}) topologies))
11:06justin_smith,(map #(select-keys (bean %) [:namespace :name]) [:foo/bar :this/that :other :east/west])
11:06clojurebot({:name "bar", :namespace "foo"} {:name "that", :namespace "this"} {:name "other", :namespace nil} {:name "west", :namespace "east"})
11:06cshellssideris: you have to pass an argument to the map if you’re using it as a function
11:06justin_smithnillkill: ^^ if you are just getting things from the bean
11:06ssideriscshell: I'm not
11:06ssideriscshell: and that's not what nillkill wants
11:07ssiderishe's just confused by the #() syntax
11:07justin_smithssideris: fair point about bean being slow
11:07nillkillthe (fn [x] …) option works great
11:07nillkillyeah, i’m def confused about anonymous functions
11:07nillkillfigured that would’ve been equivalent to (fn [x] …) in this case
11:07nillkillanyway, that works perfectly
11:07nillkillthanks ssideris, cshell and justin_smith
11:07justin_smith,(#(do {:name (.name %)}) :hi) there is also this
11:07clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: name for class clojure.lang.Keyword>
11:07justin_smithoops!
11:08ssiderisnillkill: here it is with an anonymous function instead: (vec (map #(hash-map :id (.get_id %)) topologies))
11:08justin_smith,(#(do {:name (.getName %)}) :hi) this I mean
11:08clojurebot{:name "hi"}
11:08ssideristhe literal {} syntax won't play well with #()
11:08bbloom,(macroexpand '#(inc %))
11:08clojurebot(fn* [p1__153#] (inc p1__153#))
11:08bbloom^^ that should make it quite clear
11:08nillkillyeah, was trying to read up on this http://stackoverflow.com/questions/2020570/common-programming-mistakes-for-clojure-developers-to-avoid
11:09bbloom,(macroexpand '(fn [%] (inc %)))
11:09clojurebot(fn* ([%] (inc %)))
11:09nillkillyep, that’s a lil tricky :)
11:09bbloomanonymous, single-expression fns are extremely common
11:10nillkillwould you guys normally use #() in this case? or just (fn [x] …)? Just curious
11:11bbloom,(#(-> {:x %}) 5)
11:11clojurebot{:x 5}
11:11bbloomi've see that, which is both clever and horrifying :-P
11:11ssiderisnillkill: depends, but I would definitely use (hash-map) and (vector) instead of {} and [] in an anonymous function
11:11bbloombut yeah, i'd probably write:
11:11justin_smithnillkill: fn nests, #() cannot, so I start with fn and then substitute #() where it can make things cleaner
11:11bbloom,(#(hash-map :x %) 5)
11:11clojurebot{:x 5}
11:11nillkillahh makes sense, good point justin_smith
11:12justin_smith,(#(do {:x %}) 5)
11:12clojurebot{:x 5}
11:12justin_smithis that so terrible?
11:12ssiderisjustin_smith: when I see a (do) I usually immediately think that there are side-effects in the code, so it can be misleading
11:13bbloomagreed, do == side effects
11:13bbloomi'd much rather #(-> than #(do
11:13visofthis.header = header translated to (set! (.this header) header) ?
11:13justin_smiththere aren't many places a side effect would hide in there, but OK
11:14ssiderisjustin_smith: yeah, if it's a tiny {:x 5} there aren't many places, but you could have more
11:14justin_smithbut considering -> and do are equally verbose, I can stick with ->
11:16nillkillthanks again guys
11:18visofhow can rewrite this full method in clojure https://www.refheap.com/85218 ?
11:18visofusing java
11:19visofjava from clojure
11:19visofi did this but even not working https://www.refheap.com/85215
11:20justin_smithwell, that's a start, but you need some more code at the bottom of plain-header-iterator
11:20justin_smithor wait no, you transcribed it wrong
11:20justin_smiththe type and the function should not have the same name
11:21justin_smithand "this" is totally invalid there
11:24visofjustin_smith: so how can i fix this sample?
11:25justin_smithquoting bblooom above: (deftype PlainHeaderIterator [header pattern pos])
11:25justin_smith
11:25justin_smith(defn plain-header-iterator [header pattern] (PlainHeaderIterator. header pattern 0))
11:26justin_smiththen you would put the rest of your code at the end of that defn
11:26visofi don't want to use PlainHeaderIterator. i need to modify it
11:27justin_smithOK, the version above is valid clojure code, the version in that refheap you last pasted is not
11:28justin_smithyou may want to check out an introductory book like "Programming Clojure"
11:29visofok
11:30visofjustin_smith: cann't you help to rewrite this java code to clojure code but with only return first match not all
11:31bbloomvisof: 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:31visofok
11:34ssiderisvisof: 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:35ssiderisvisof: but in essence, you'd have a lazy-seq that would return you triples on demand
11:41coventryMy 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&quot; 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:42coventryThis is with austin 0.1.4 and clojurescript r2156.
11:47cbpYou might be trying to do AJAX from a server that's different from the one youre querying?
11:48cbpprobably from :61318 you have some ajax that tries to fetch from :8000
11:48cbpYou'd have to enable cross-origin resource sharing on :8000
11:50coventryThe 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:52CookedGryphonBobSchack: I worked out the issue
11:52CookedGryphonBobSchack: I was binding [*print-length* 10] (.log js/console (str x))
11:53CookedGryphonBobSchack: which apparently results in that no implementation of protocol for string error, take out the binding print length and it works as expected
11:54BobSchackreally that is weird behavior. It should probably get a ticket if that is reproducible
11:55BobSchackI get that too
11:56CookedGryphonBobSchack: 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:58CookedGryphonwhat 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:58BobSchack(binding [*print-length* 10] (pr-str #js {:foo "bar"}))
11:58BobSchackis a minimal case
11:58BobSchackit only does it for map data structures
11:59CookedGryphondon't think you even need the #js, do you?
11:59CookedGryphoni was getting it on plain cljs data structures
11:59BobSchackooop yep you can take out the #js and it still gets the error
12:00BobSchackI'm trying this out with version 2173
12:01BobSchackCould you file the bug?
12:01bbloomwishful thinking: does anybody know of a swing UI hex debugger that I can use to quickly inspect an nio ByteBuffer or similar?
12:02coventrycbp: 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:02CookedGryphonbbloom: bbloom I have a function that implements print string for a bytebuffer
12:03bbloomCookedGryphon: do you mind sharing? i've seen a few random things in my quick googling, but most are kinda awful
12:04CookedGryphonbbloom: 2 seconds I'll gist it
12:04CookedGryphon(no guarantees its any better than the other things you've seen though :P)
12:05justin_smith,(String. (.getBytes "hello"))
12:05clojurebot"hello"
12:05bbloomCookedGryphon: if not, i'll write a better one and share it with you :-P
12:05CookedGryphonbbloom: https://gist.github.com/AdamClements/9441ad39254b91a8718b
12:05justin_smithor do you not mean the kind of thing returned by getBytes?
12:05CookedGryphonis what I've been doing, you just need to print the ints as hex instead
12:06bbloomhm, ok. i'm looking for something more like a hexdump
12:06bbloomhttps://en.wikipedia.org/wiki/Hex_dump
12:06CookedGryphonyeah, I was using it for fairly small bytebuffers and just wanted them inline when i pprinted maps with them in etc
12:06bbloomyeah, my byte buffers are fairly large
12:07bbloomhence my original question for some kind of launchable hex editor. features like search would be greatly appreciated
12:08cbpcoventry: I Guess it's probably an austin issue
12:08CookedGryphonBobSchack: 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:09BobSchackCookedGryphon: thanks
12:19bbloomCookedGryphon: justin_smith: this seems to get the job done good enough to unblock me: https://gist.github.com/brandonbloom/4b8278edaafccb72ccc1
12:21BobSchackbbloom: just curious what are you working on that you need this for?
12:21coventrycbp: Yeah, maybe. Thanks for looking.
12:21justin_smithbbloom: hah, nice
12:22bbloomBobSchack: working with a binary format
12:22cbpSo 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:23arrdempartial results?
12:23coventrycore.async?
12:23clojurebotcore.async is not Go
12:23cbpyes as in the database says here is a part of the result, come back to me when you want more
12:24arrdemAh.
12:24arrdemYeah... I'd say deliver a lazy sequence that has another agent/worker for the next thunk of the query
12:24arrdemas it's next
12:32cbpYes that's it
12:33cbp(inc arrdem)
12:33lazybot⇒ 26
12:34arrdemyay, validation to go with the coffee!
12:34ghazAnyone have an idea why calling enable-console-print! isn't allowing println to print to console in clojurescript any more?
12:44amontalentiI 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:45technomancyamontalenti: is it a plugin or a regular lein project?
12:45amontalentitechnomancy, regular lein project, afaict
12:45technomancyyou can check the :file metadata on the var to see where it's coming from
12:47amontalentitechnomancy, I try (meta cli) on the namespace and I get "nil"?
12:47llasramamontalenti: Are you using speclj?
12:47technomancytry it on the var
12:48amontalentitechnomancy, you mean like cli/cli? also nil
12:48justin_smith#'cli
12:48justin_smith#'cli/cli
12:49amontalentitechnomancy, "clojure/tools/cli.clj"
12:50technomancyamontalenti: oh right, then call clojure.java.io/resource on that
12:50amontalenti=> (clojure.java.io/resource (:file (meta #'cli)))
12:51amontalenti#<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:51amontalentiactually looks legit to me, no?
12:51technomancyso you're using the version you expect, yeah
12:51justin_smith(-> #'cli meta :file io/resource) even
12:51amontalentiodd
12:51technomancyhttp://p.hagelb.org/mrfp.gif
12:51amontalentihaha, I appreciate the tips -- I'm new here.
12:52technomancythat one was for justin_smith
12:52amontalentiso, I guess if I'm insane, I could go unzip this jar, eh?
12:52amontalentisee what the heck is going on?
12:52llasramamontalenti: What do you mean that you only "see" the `cli` function?
12:53llasramAre the new functions not in the namespace?
12:53amontalentillasram, exactly
12:53justin_smithamontalenti: many editors can open the jar without explicitly unzipping it
12:53amontalentiI run (require '[clojure.tools.cli :as cli]) and then cli/cli is all that's available (also confirmed with (ns-publics cli))
12:53amontalentibut parse-opts is supposed to be there, and a few others
12:54amontalentiI confirmed this by doing load-file on a copy-pasta'ed version of the same module from github
12:54justin_smithamontalenti: have you checked (ns-publics 'clojure.tools.cli) ?
12:54amontalentitechnomancy, insanity -- I unzipped the jar and the parse-opts function is there.
12:55amontalentijustin_smith, yes: {cli #'clojure.tools.cli/cli}
12:56amontalentifwiw, this is happening to someone else on my team, too, with same project -- so it's not just me :)
12:56technomancyyou 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:56justin_smithamontalenti: I wonder if you are getting a version that is aotd into another dep?
12:56technomancyooooh
12:56technomancyI bet that's it
12:57justin_smith(dec aot)
12:57lazybot⇒ -1
12:57technomancyjustin_smith: wouldn't that change the :file metadata on teh var though?
12:57justin_smithhmm...
12:57justin_smithI don't see how else you would be getting the wrong version, but that is definitely weird...
12:59amontalentiinteresting technomancy, I dropped one of my dependencies (not tools.cli) and now i can see parse-opts
12:59amontalentithe dependency was apache storm 0.9.1
13:00nillkilli figured apache storm might be interfering…does the order of deps in project.clj affect things?
13:01justin_smithyou can use an :exclusions clause on a dep
13:01justin_smithbut that won't help if aot was the problem - in that case tell storm to stop aot compiling deps
13:01amontalentihaha, nice -- so looks like we have an upstream bug of sorts
13:01amontalentiOK
13:02amontalentiwe'll file a ticket and see how that goes, we can probably live without the new version of tools.cli in meanwhile
13:03amontalentitechnomancy, 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:03technomancycool; glad it's (mostly) working for you
13:04nillkillyou can expect more questions from amontalenti and myself :)
13:04technomancyhopefully you can stamp out the pernicious use of AOT
13:04amontalentiwell, we'd be in a deeper classpath hell than this little problem without it
13:04PigDudewhat 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:04PigDudeis it to pass the argument through another funciton, like ensure-byte-array?
13:04technomancyPigDude: if you have a large number of cases a multimethod is a good way
13:05technomancyif there's only two or three, something like ensure-byte-array is fine
13:05PigDudehm ok
13:05PigDudeat that, how do i tell the difference between a byte array and a string?
13:06technomancy...?
13:06justin_smith,(string? (.getBytes "hello"))
13:06clojurebotfalse
13:06PigDudeok, thanks justin_smith
13:06mdrogaliscemerick: Can you tldr what Quilt is? :) Can't find a description anywhere.
13:07justin_smith,(= (class (.getBytes "hello")) (Class/forName "[B")) PigDude
13:07clojurebottrue
13:07PigDudejustin_smith: and that's just (instance? String)
13:08PigDudejustin_smith: my background (js py erl) this sort of explicit class/bases testing is not so common
13:08justin_smithPigDude: yeah, but I find it more readable (every basic clojure type has a predicate like that)
13:08PigDudejustin_smith: oh, i agree!
13:09technomancyjust don't use clojure.core/list?
13:09PigDudewhy's that?
13:10justin_smithbecause many things you would consider a "list" are not things "list?" returns true for
13:10PigDude,(map list? [() {} #{} []])
13:10clojurebot(true false false false)
13:10PigDudelooks normal to me
13:10justin_smith,(list? (cons :a (list :b :c)))
13:10clojurebotfalse
13:10justin_smiththat's weird ^
13:10technomancyhttp://p.hagelb.org/lies.gif
13:10technomancy
13:10technomancy
13:10PigDudeok, that is weird
13:10hyPiRion,(list? (list* :a :b (list :c))) ; even better
13:10clojurebotfalse
13:10justin_smith,(class (cons :a (list :b :c)))
13:10clojurebotclojure.lang.Cons
13:11PigDudea wart@!
13:11PigDude:)
13:11technomancyanyone tells you there's a language that doesn't have them, you can refer to the previous gif
13:13seangrovetechnomancy: Stop trolling
13:14technomancyhttp://p.hagelb.org/scott-pout.png
13:14seangrovehow can (rest ...) take 1ms in cljs...
13:14seangroveerr, 2ms
13:15seangroveTime to try advanced compilation again
13:16bbloomseangrove: what are you taking the rest of?
13:16manutterquick 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:16manutterIs that right, and is there a better way?
13:16bbloomseangrove: could be reading 30ish objects via chunking
13:16seangrovebbloom: Not sure, Just woke up and reading the flame graph from last night
13:17mynomotomanutter: there is a #hoplon channel. But you can manage the state anyway you want using hoplon and castra.
13:18manuttermynomoto: Thanks, didn't know about #hoplon, I'll move my question over there
13:19seangroveThese people have to be stopped https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers
13:22llasramseangrove: ?
13:22jcromartieseangrove: as something I read today said: "A modern Web page is a catastrophe."
13:24seangrovellasram: 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:25seangrovebbloom: Are games generally single-threaded?
13:25llasramInteresting
13:25bbloomseangrove: nope
13:26seangrovellasram: 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:26bbloomseangrove: big titles usually have threads for at least gameplay, graphics, and networking
13:26jcromartiedepends on the game
13:26jcromartieI'd say generally they are
13:26jcromartieif you were to sample the average video game
13:26bbloomjcromartie: that's simply not correct
13:26arrdemjcromartie: maybe your average 2d side scroller...
13:26jcromartieand the "average game" over time is a 2d side scroller :)
13:26jcromartiemore or less
13:27bbloomthe xbox 360, for example, has 6 cores, 5 of which are available to game engines... you basically have to be multi threaded
13:27bbloomwell 3 cores, 2 threads per core
13:27arrdemwell... if you don't multithread you've just shot yourself in the face performance wise for no reason.
13:28seangrovebbloom: Yeah, I was wondering, since maybe I was missing something fundamental about this web-worker concurrency model
13:28llasramI mean, the Atari 2600 didn't even have a separate graphics controller. Just the 6502 updating registers at the TV refresh rate
13:28llasramSo *totally* single-threaded
13:29arrdemand that's fine when your render engine consists of xoring in 2d sprites
13:29bbloomeven 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:29bblooms/core/code
13:29jcromartieAn immense number of games have and are being made. Most of them are really simple.
13:29jcromartieThat's all I'm saying.
13:30jcromartieThe vast majority of modern 3D games, and especially AAA blockbusters are obviously multi-threaded.
13:30bbloomjcromartie: seangrove isn't interested in the long tail of random little games made, he's interested in the architecture of real time systems
13:30jcromartieBut the 5000 HTML5 Tetris clones made today won't be.
13:30jcromartie :)
13:30jcromartieok
13:30jcromartiegot it
13:31seangrovejcromartie: Sorry, wasn't quite as obvious to me as it should have been ;)
13:34bbloomseangrove: anyway, games tend to pipeline multiple frames, rather than utilize significant intraframe parallelism
13:35timothywIs there a Clojure lib for doing XML digital signatures?
13:36mdeboardhttp://docs.oracle.com/javase/7/docs/technotes/guides/security/xmldsig/XMLDigitalSignature.html ? :D
13:36CookedGryphonBobSchack: Bug filed: http://dev.clojure.org/jira/browse/CLJS-804 add any details you think I have missed
13:36timothyw@mdeboard thanks
13:43ssswdonis there a way to remove a key from a map that has no value
13:44Morgawryou mean a key that has no value?
13:44ssswdonyes
13:45arrdem,(doc dissoc)
13:45clojurebot"([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:45Morgawrssswdon: http://stackoverflow.com/questions/3937661/remove-nil-values-from-a-map this might be helpful
13:45ssswdonthanks
13:50stompyjI’m devising my own “keep it real” time architecture
13:50stompyjit uses culture sourced filtering
13:52justin_smithstompyj: it should have a #YOLO data constructor that throws a ShitJustGotTooReal exception
13:53stompyjhahahahahahahahahaha
13:54roelofhello, I have this definition : (def little-schemer {:title "The Little Schemer" :authors [friedman, felleisen]})
13:54roelofnow i want to add a author to it
13:55ssswdon@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:55roelofSo I do http://pastebin.com/VjbpwX9B
13:55justin_smithssswdon: & keys needs pairs
13:56roelofbut now I see this error message : ArityException Wrong number of args (0) passed to: PersistentVector clojure.lang.AFn.throwArity (AFn.java:437)
13:56ambrosebs,(def little-schemer {:title "The Little Schemer" :authors [friedman, felleisen]})
13:56clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: friedman in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:56ambrosebs,(def little-schemer {:title "The Little Schemer" :authors '[friedman, felleisen]})
13:56clojurebot#'sandbox/little-schemer
13:56roelofwhat did I do wrong or what did I misunderstood
13:56ambrosebs,(update-in little-schemer [:authors] conj 'ambrosebs)
13:56clojurebot{:title "The Little Schemer", :authors [friedman felleisen ambrosebs]}
13:57roelofoke, the whole file is this http://pastebin.com/6VbDJprx
13:57ToxicFrogroelof: ((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:57ssswdonjustin_smith - I was just wondering if there is a way to filter out bad data in the macro
13:57ToxicFrog(assoc book :authors (conj schrijver new-author)) I expect would work, although using update-in is better.
13:58justin_smithssswdon: the error is happening in the arg parsing, & keys will always require an even arg count, period
13:59ssswdonjustin_smith - what if I changed the approach on the function signature like processing the params differently
14:00roelofToxicFrog: 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:00roelofToxicFrog: I think the problem is somewhere in the assoc function but I do not see where
14:00justin_smithssswdon: well you could not use & keys and take the args in some other way
14:01ssswdonok. let me think about this a bit
14:02justin_smithone option would be to take multiple arities instead of keyword args
14:02roelofToxicFrog: you right the extra () around the conj were the culprit
14:12kevinfishHi 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:12kevinfishFailed 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:12kevinfishany help?
14:15PigDudewhat is the function for a while look w/ let bindings?
14:15PigDudeit was like if-let, but looping
14:15amalloyloop
14:15PigDudei thought there was something w/ let bindings, but like if-let, so if the binding is falsy it terminates
14:15amalloykevinfish: you spelled "liminus" wrong. it's luminus
14:16amalloyPigDude: no
14:16PigDudehm ok
14:16kevinfishamalloy: ahh, thx :)
14:16amalloyyou can't really write a while-let macro that's functionally pure, because the value it checks will never change
14:18therikPigDude: do loop?
14:20PigDudetherik: not quite
14:20TravisDAnyone here use the Atom text editor?
14:23justin_smithTravisD: some folks on #clojure-social were complaining about it
14:23TravisDah, maybe I'll move the conversation over there :)
14:43seangrovebbloom: 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:43bbloomseangrove: *shrug*
14:48bbloomseems like overkill
14:49seangroveYeah, I hope so
15:01bbloomi'm really amused by this thread: http://lambda-the-ultimate.org/node/4950
15:01bbloomtype theory addicts rediscovering the benefit of first-class interfaces
15:06amalloyit seems i don't know enough type theory to get the joke
15:07ataggartAnyone know off-hand why the EdnReader would complain about "No reader function for tag" despite *data-readers* containing the tag?
15:08Bronsaataggart: the edn reader doesn't use *data-readers*
15:09Bronsaataggart: you have to pass the data readers as an argument to the edn/read function
15:10ataggartorly!
15:10ataggartthanks, off to try it out
15:10bbloomamalloy: not a joke really
15:11bbloomamalloy: a "type class" is just a dictionary of methods, just like a protocol implementation
15:11ataggart"When not supplied, only the default-data-readers will be used." RTFM...
15:11bbloomamalloy: but b/c it's resolved at type level, there are restrictions on the polymorphic dispatch
15:12bbloomamalloy: by encoding your type class as a record, you're effectively creating an object-oriented thing you can pass around
15:12bbloomthey 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:13bbloominstead of just having a single-level language to begin with
15:13bbloomwhich, btw, does not preclude static checking at all
15:13bbloomthis is the *actually interseting* motivation for dependent types, rather than being able to check things like the length of a vector statically
15:16PigDudewhat is the threading function that stops on nil?
15:16alejandroPigDude some-> I think
15:17PigDudethanks alejandro :)
15:18bbloomtpope: seems like repeat.vim doesn't work for cpp anymore
15:19Glenjaminbbloom: if i'm following this correctly, equivalent concepts in clojure are passing around maps of functions, and reify ?
15:19bbloomGlenjamin: i won't say equivalent, but definitely related
15:19Glenjaminwith most of the oddness of phrasing in the post coming from the need to describe type-check-time and run-time separately
15:19bbloomGlenjamin: objects basically *are* maps of functions
15:20Glenjamindepends what level of abstraction you're thinking at, but yeah, i guess so
15:21bbloomGlenjamin: 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:21bbloomit'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:21bbloommodulo lexical closures, of course
15:21Glenjaminin 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:22bbloomyeah, 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:23Glenjaminright, yeah
15:23Glenjamini find my javascript looks a lot like this these days
15:23Glenjaminmaps of functions with mostly implicit interfaces between components
15:24Glenjaminthe comments here are interesting, mostly focusing on how to do efficient comparison when you don't know the real "type"
15:25Glenjaminanyway, i try not to think about type systems
15:25bbloomi think the comparison stuff is just an example of an interface for which there may be multiple definitions for any given type
15:26Glenjaminthere's always the temptation to specialize when you know the concrete types
15:26Glenjaminbreaks the abstraction a bit, but obviously tends to be faster
15:29bbloomit's not about perf, it's about semantics: are numbers ordered or do they have an ordering? what about users?
15:29bbloomnumbers have a natural order, but you could imagine an alternative ordering (ie inverse order)
15:29Glenjaminmm, i see
15:29bbloomusers can have many orders: by name, by id, by join date, etc
15:29bbloomhence sort and sort-by
15:30bbloomapplies to much more than orders, but that's the canonical example
15:30Glenjaminso potentially reverse-int is a type, that overloads the comparison operators
15:30bbloomwell, that's one way to look at it
15:31Glenjamintype GolfScore = reverseOrder<int> sorta thing
15:31bbloomsomething like that
15:32bbloombut the other way to think about it is type T is Ordered and there exists an Ordering on type T
15:32bbloomin 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:38AWizzArdLeiningen: Can I unlist specific files from :resource-paths?
15:38AWizzArdHave Leiningen not putting them inside a .jar?
15:40llasramAWizzArd: Check out `:jar-exclusions`
15:40justin_smithAWizzArd: do they need to be in a folder in the :resource-paths ?
15:40AWizzArdllasram: that’s probably it, thx
15:40AWizzArdjustin_smith: I just want to exclude my externs.js from going into the server.jar
15:54Glenjamindoes anyone know why "Only long and double primitives are supported" ?
15:54gtrakGlenjamin: there's no advantage to using ints on modern system.
15:54gtraksystems...
15:54gtrakand also the hashcodes don't line up.
15:55Glenjaminassuming a 64bit jvm, or just in general?
15:55gtraknot sure about 32, but definitely 64
15:55jcromartiethat's too bad, reaelly
15:55jcromartiereally
15:55bbloommodern x86 chips are like 80bits internally or something weird like that
15:55gtrakyou can still use them, you're just going against the grain a little.
15:55martinklepschwhats the best way to get leiningen2 on ubuntu?
15:55jcromartieI don't lament the deprecation (more or less) of int
15:55jcromartiebut the loss of the name
15:55gtrakmartinklepsch: download the shell script and put it in ~/bin
15:56Glenjaminit let me hint ints in defrecord, but not on functions
15:56Glenjamini guess i can see why that would work
15:56gtrakhuh? I'd expect that to work.
15:56Glenjaminanyway, longs are fine, makes sense really
15:57Glenjaminsorry, ^int, not ^ints
15:57Glenjamini did ^int more than once, forgot ^ints was a thing
15:57martinklepschgtrak: isn't there some other way? find that cumbersome
15:57justin_smithperhaps the optimization layer that knows how to keep something unboxed doesn't really generalize to float / int and only does double / long
15:57gtrakI find that to be the easiest and most fool-proof way.
15:58Glenjamini happen to know all of my numbers in this app are small enough to be short, and i'm loading loads of them
15:58Glenjaminbut i guess if i really wanted to optimise to that level i'd use something else
15:58justin_smithit 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:58gtrakmartinklepsch: it'll already be on the path, you just might have to login again if the directory doesn't already exist.
15:59justin_smithGlenjamin: with ints[] you can definitely take advantage of that
15:59justin_smithbut on a 64 bit machine, the smallest an isolated datum is going to be is 64 bits iirc
16:02dbaschGlenjamin: if you really need to optimize for space, you can pack them into byte arrays, even with delta encoding
16:03Glenjamini *think* i'm ok for space at the mo
16:03Glenjamingot a few maps, roughly 7 million records
16:03Glenjaminwith 3 longs in each
16:05Glenjamini'm looking at optimising the arithmetic at the mo
16:05Glenjaminjust got confused when i tried to annotate some ints
16:17PigDudewhat's the idiom for a string of repeating chars? it can't be this can it? (str (into [] (repeat n c)))
16:17bbloom,(apply str (repeat 10 \!))
16:17clojurebot"!!!!!!!!!!"
16:18PigDudethanks bbloom
16:19expezWhy isn't :include-macros true the default?
16:19bbloomexpez: b/c it throws an error if there is no matching macro file
16:20expezoh!
16:20amalloyGlenjamin: how sure are you that arithmetic on a short is faster than on a long?
16:20Glenjamini'm not, i was thinking about space in that case
16:20Glenjaminbut realistically, that's probably not an actual concern
16:21amalloyi apparently misunderstood "i think i'm ok for space" and "looking at optimizing the arithmetic"
16:21Glenjaminwas thinking aloud a bit: maybe i could use shorts -> i'm probably ok for space -> back to looking at arithmetic
16:24gfredericksI've always been a bit hazy on which primitives actually save space
16:24gfrederickse.g., do booleans take 64 bits to store?
16:25gfrederickswhat about boolean arrays?
16:26amalloytechnomancy: 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:26justin_smithgfredericks: 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:26justin_smith"This data type represents one bit of information, but its "size" isn't something that's precisely defined."
16:26justin_smithhttp://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
16:26gfredericksjustin_smith: you know for sure that all primitive arrays are maximally compact?
16:27justin_smithgfredericks: I don't think java defines any such guarantee
16:27Glenjaminoh, i didn't event realise java had a short primitive!
16:27technomancyamalloy: yaaay
16:27technomancyhttp://p.hagelb.org/power.gif
16:27amalloygfredericks: 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:27justin_smithgfredericks: but unlike the standalone value, which will be 64 bit aligned, the ones in the array *can* take up less space
16:27Glenjamin"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:27amalloyand of course this is for my particular jvm
16:27gfredericksamalloy: phew; byte[] is so common I'd be appalled by anything else
16:28Glenjamini'm now dangerously tempted to change all these ^long fields to ^byte, they're all under 30
16:28Glenjamingotta stop getting sidetracked on this
16:28amalloyGlenjamin: but ask yourself, why?
16:28amalloythe arithmetic on them is probably slower
16:29Glenjaminah, good point
16:29Glenjaminarithmetic first, space later
16:29gfrederickswhen 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:29justin_smithyeah, likely they get promoted to long before ops, then converted back again
16:29Glenjaminmy current task is exploring optimisations that can be made be writing this process in clojure vs the current approach
16:29gfrederickswho the hell knows what the jit does with da numbers
16:29amalloyjustin_smith: that's certainly what clojure does. i don't know about on the jvm
16:30amalloysee https://www.refheap.com/6a808f3be0a0e1bcd16044b35 if you're curious
16:31amalloy(it does something similar even if you set *unchecked-math*)
16:32Glenjaminthere's some stuff about this in https://www.youtube.com/watch?v=iQwQXVM6oiY
16:41bjeanesThat was a great talk
16:53{blake}I cannot seem to figure out how to iterate over a set.
16:53{blake}Or how to convert it into a seq.
16:53{blake}Or whatever it takes to say "Do this for everything in the set."
16:54llasram,(map inc #{1 2 3 4})
16:54clojurebot(2 5 4 3)
16:54{blake}What have I done that this isn't working for me?
16:55llasramThe only guess I have off the top of my head is "actually have something other than a set" :-)
16:55llasramOh, 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:56justin_smithor you are mapping, but not using the results, so no action, because laziness
16:57justin_smith,(do (map println (range)) :done)
16:57clojurebot:done
16:57Glenjamin{blake}: got some sample code?
16:58{blake}Nah, I got it. I've redefined a function with a variable.
16:58{blake}It's actuall in the iloveponies Clojure course.
16:58{blake}It has you define "authors" as a function. Then later it defs "authors" as a set.
16:59{blake}Gotta be one of my top 10 worst Clojure errors, because for a moment, I think I don't know =anything=.
16:59Glenjamineugh, (empty) returning nil is really annoying
17:00Glenjaminmakes (transient (empty coll)) produce a confusing null pointer error when the data goes wrong
17:01justin_smith,(empty)
17:01clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/empty>
17:01justin_smith,(empty nil)
17:01clojurebotnil
17:02Glenjamin,(doc empty)
17:02clojurebot"([coll]); Returns an empty collection of the same category as coll, or nil"
17:02nullptr,(empty [])
17:02clojurebot[]
17:03justin_smith,(empty 42)
17:03clojurebotnil
17:03nullptr,(empty [nil])
17:03clojurebot[]
17:03Glenjamin,(empty (java.util.HashMap.))
17:03clojurebotnil
17:03Glenjaminor the fun one:
17:03Glenjamin,(empty (transient {}))
17:03clojurebotnil
17:10sdegutisIs there an extraordinarily better way to do this? (for [[k _] pairs] (get another-map k))
17:11justin_smith(select-keys a (keys b))
17:11sdegutisPrecise! Gratitude!
17:12amalloyerrr, 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:12sdegutisAll these assumptions hold.
17:12justin_smithI assumed maps, yeah
17:12sdegutisOh, but wait! They do not hold. Oh no.
17:12sdegutisNever mind.
17:13sdegutisI'll leave this code as it is.
17:13amalloysdegutis: a more conservative simplification would be (map (comp another-map first) pairs)
17:14sdegutisI will try this out, thank you.
17:15sdegutisMy 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:15sdegutisThus my insanity.
17:15Glenjamini also have a similar system
17:15Glenjaminalthough my lookup map is just a vector
17:16Glenjaminso its { sort-val => key } and { key => actual val } ?
17:41rhg135good afternoon everybody
17:42sdegutisWhat 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:43technomancyamontalenti: hey, just saw your bug report on storm.
17:43cbprhg135: what is there important
17:43technomancyamontalenti: FWIW my suspicion is that it's not actually a version range but AOT that is problematic
17:43technomancybut I can't make head or tail of the storm git repo to tell what's going on there
17:43rhg135idk just being polite :D
17:43technomancyand I don't feel like figuring out how to comment on the apache jira to mention it there
17:45gtraksdegutis isn't used to that
17:46sdegutisSorry, we just recently read a book, that's all.
17:55Glenjaminanyone know if there's an equivalent to :test-selectors at the repl?
17:55Glenjamincan't seem to see it in clojure.test api docs
17:56technomancyGlenjamin: there's not; clojure.test is monkeypatched up the wazoo
17:56gtrakGlenjamin: you could always look at how lein does it.
17:56gtrakprobably more trouble than it's worth :-)
17:56technomancyit's such a nuisance to get changes into clojure.test that everyone just hacks around it.
17:56gtrakstaring at it now
17:57technomancyit's not good
17:57Glenjaminhooray for core
17:57Glenjaminwhere things cannot change, but everyone uses them
17:58amalloysounds like a description of clojure: things never change, but it turns out changing things isn't important anyway
17:58technomancyThere's Always alter-var-root!™
17:58Glenjaminmore standard libraries in general
17:59amalloyit was an immutability joke, guys
17:59amalloyapparently not a good one, but it's too late to change it now
17:59Glenjaminhahha
17:59technomancyheh
17:59gtrakamalloy: my response did not change.
17:59gtrakexcept for this one. damn.
18:00gtrakWe just have lossless change.
18:00amalloyyou gotta always be on the lookout for immutability jokes
18:00gtrakmore things change.
18:00gtrakwith immutability.
18:01gtrakthat's why there's GC pressure.
18:01bbloomamalloy: good save with the self-deprecating immutability joke
18:02amalloyno such thing as too many immutability jokes
18:02hiredmanamalloy: yeah, if you don't pay close attention you may miss things never changing
18:13whodidthiswhats 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:13bbloomwhodidthis: you only need to be concerned with leading hyphens. otherwise, more info needed to help you debug
18:14Glenjaminbah, sort-of got test-vars working but it's really low level :s
18:14Glenjaminalter-var-root it is!
18:16whodidthisive 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:26bbloomargh, how do you search for tickets about the ".." function
18:26bbloomi'm wondering if it is possible to type hint intermediate expressions in a .. chain
18:32PigDudedoes 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:33PigDudeused w/ macros, that is
18:33PigDude(i'm used to this in erlang's eunit)
18:34technomancyPigDude: clojure.test doesn't usually use assert
18:34technomancytry clojure.test/is
18:34PigDudeit's made simpler because the test is data. which i can do w/ a macro, but didn't want to reinvent the wheel
18:34PigDudetechnomancy: is/assert/anything...
18:34technomancyI still don't get the distinction
18:34PigDudetechnomancy: so in eunit you have ?assertEqual and ?_assertEqual. the second macro gives you a function instead of a plain assertion
18:35technomancyyou can call is anywhere
18:35PigDudelike if clojure.test understood to run a function like #(is (= ...))
18:36PigDudemaybe i am just seeing this from the erlang point of view, but right now my unit tests have lots of duplication
18:36PigDudeis it common to create utility macros in unit tests to perform common comparisons and such?
18:36technomancyI think there's actually a multimethod underlying the implementation of the c.t/is macro
18:36technomancyso you can improve your reporting by adding a method body to that macro
18:37gtrak'is' kinda sucks, since file-and-line is at the point of definition.
18:37gtrakso you have to use macros, or throw exceptions.
18:37technomancyusually I try to keep the `is` call inside the deftest and have helpers return values to compare
18:37gtrakI thought about how to work around this limitation.. but it'd be kinda dirty.
18:38PigDudethe feature's described on http://www.erlang.org/doc/apps/eunit/chapter.html , see "Underscore-prefixed macros create test objects"
18:38amalloybbloom: i don't think you can
18:39bbloomamalloy: 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:39amalloybut 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:40bbloomamalloy: yeah, it's precisely that last case i had
18:40bbloomneeded a downcast
18:41amalloybbloom: trying to stick typehints in the middle of macroexpansions is pretty delicate anyway
18:41PigDudehow 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:41PigDudealso it seemed to be difficult to get working
18:41amalloybecause the forms get torn apart and reassembled with ~@, without copying the metadata
18:42amalloyeg, (-> foo (.bar) ^List (identity) (.size)) might work, but then again probably it doesn't
18:44PigDudeah it looks like clojure.test/are is useful
18:47m1dnight_So I'll be doing my thesis on Clojure (and other languages)
18:47m1dnight_I'm so excited \i/
18:47m1dnight_\o/ even
18:47bbloomamalloy: it's ok, i just did some ugly verbose let shit & it feels appropriately java-ish
18:48nullptrbbloom: don't forget to wrap it up in a factory or two
18:49bbloomnullptr: way ahead of you
18:53nillkillquick 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:02seancorfieldI think log4j.properties has to be in the classes/ folder?
19:03technomancyno, resources/ is fine
19:03seancorfieldHmm, ok, that's on the classpath?
19:03nillkillyeah it is
19:03nillkilljust double checked
19:03nillkillahh i think i may know
19:04nillkillproject that i’m using may not be using log4j :)
19:05seancorfieldThat was going to be my second suggestion.
19:05visof,(str ""hello"")
19:05clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: hello in this context, compiling:(NO_SOURCE_PATH:0:0)>
19:05seancorfieldAlso, if "OFF" the right value? I thought that had to be a level, like FATAL?
19:05visof,(str "\"hello\"")
19:05clojurebot"\"hello\""
19:05nillkillthink it’s using slf4j https://gist.github.com/msukmanowsky/61353bba590d256a740a
19:06visofis there away to convert ""hello"" to "\"hello\"" without needing to write \ ?
19:06visof,(escape ""hello"")
19:06clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: escape in this context, compiling:(NO_SOURCE_PATH:0:0)>
19:07visof,(str "\"hello\"" {\"})
19:07clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
19:07visof,(escape "\"hello\"" {\"})
19:08clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
19:08visof,(clojure.string/escape "\"hello\"" {\"})
19:08clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
19:08visof,(clojure.string/escape "\"hello\"" {\\"})
19:08clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
19:08amalloyvisof: no, you cannot write ""hello"" and then do anything with it, because it is not a value
19:09visofamalloy: well, what i have dirty strings in a file and need to handle them?
19:09nillkillseancorfield: tried with log4j.rootLogger=ERROR, no difference
19:10dbaschnillkill: it’s probably not log4j, it could be another logger library such as apache commons logging
19:11nillkilldbasch: doesn’t seem like it from lein deps :tree https://gist.github.com/msukmanowsky/61353bba590d256a740a
19:12seancorfieldnillkill: http://logback.qos.ch/translator/
19:12dbaschnillkill: [commons-logging "1.1.1"]
19:12seancorfieldNote 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:12seancorfield
19:12seancorfieldthat's assuming log4j-over-slf4j which I see in the dependencies
19:16nillkilldbasch & seancorfield: hmm tried a commons-logging.properties file as well as logback.xml, neither seemed to stop it
19:17dbaschnillkill: what does the output look like?
19:18nillkilldbasch: https://gist.github.com/msukmanowsky/61353bba590d256a740a
19:18nillkillsparsej just calls lein run under the hood
19:22bankqianls
19:22lazybotbin boot data etc home lost+found media root selinux srv sys tmp usr var
19:22amalloywow, lazybot ls'ed him right out of his shell
20:00PigDudewhy does taking from this sequence return the same things every time?
20:00PigDude,(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:00clojurebot[(\K \/ \I \N \f ...) (\K \/ \I \N \f ...)]
20:01amalloyPigDude: sequences are immutable: they never change
20:02bbloomPigDude: it's random-printables that doesn't change
20:02TEttingerbecause random-printables is defined once, yeah
20:02amalloyif you want to randomly generate a different sequence, you need to start over with a new one, not re-read the same one
20:02PigDudewhat do i need to change to get a sequence of random characters i can take from?
20:02TEttingeryou can make it a fn and call it
20:02bbloomchange your (def random-printables ...) to (defn random-printables [] ...) and then call it each time (random-printables)
20:02PigDudebbloom: i see, i thought that taking from it caused the function to be called, but that makes sense i guess?
20:03turbofailit only runs the computation needed to generate a particular sequence element once
20:03bbloomPigDude: taking from it causes any lazy thunks to be called, but they are memoized & never called again
20:03PigDudei see
20:04PigDudethat makes more sense :)
20:04turbofailthat said if you need more random numbers you could always just take more elements from the sequence
20:04TEttinger,(let [printables (map char (range 33 127)) random-printables (fn [] (repeatedly #(rand-nth printables)))] [(take 10 (random-printables)) (take 10 (random-printables))])
20:04clojurebot[(\( \} \G \. \p ...) (\p \c \D \z \T ...)]
20:05PigDudeoh, there's rand-nth, not bad
20:59danneuIf 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:01amalloydanneu: without passing through the dispatcher machinery? what does that mean?
21:02amalloyare you thinking something like this? (defn handle-look [args] ...) (defmethod command :look [args] (handle-look args)) (defmethod command :l [args] (handle-look args))
21:12danneuamalloy: is there a way to call the :look defmethod directly?
21:12amalloyno
21:17ashtonkemerlingAfternoon folks.
21:18danneuyo
21:19coventry,(do (defmulti t identity) (defmethod t :foo [x] x) ((:foo (.getMethodTable t)) :bar)) ;; <- danneu. Pretty horrible, though.
21:19clojurebot:bar
21:19ashtonkemerlingWhat the hell?
21:19coventryI'm committing perversions with clojurebot.
21:19ashtonkemerlingAre you trying to break it?
21:21danneucoventry: great, thanks
22:35bbloom*sigh* hacker news upvotes a "lisp" that "compiles to c++" ... meanwhile, it's literally a transpiler so shallow that it has EXPLICIT RETURNS
22:36jeremyheilerlol
22:36bbloomi really need to blackhole news.ycombinator.com and save my sanity
22:36jeremyheileri use lobste.rs
22:37bbloomi have an account there, but i forget it exists
22:37bbloomi still navigate to reader.google.com by accident a few times per week
22:37jeremyheilerhaha
22:37bbloommy fingers hate my productivity
22:53seangrov`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?