#clojure logs

2015-03-25

00:42elvis4526Is it possible to always use the latest version of a given lib in project.clj ?
00:43elvis4526instead of always manually identifying the desired version.
00:45elvis4526Found it. You can use "LATEST" as the version.
00:45elvis4526is it a good practice in general ?
00:49gwselvis4526: not in my experience, better to specify the dependencies explicitly and use something like https://github.com/xsc/lein-ancient periodically
00:49mrcheekselvis4526:What will you answer if a release is unstable and breaks an existing working application "I use the latest?" ->.
00:56elvis4526Got it thanks
00:58underplankHi all. Im messing around with building a proxy using compujure and ring.
00:58underplankIm looking at the incoming request and the :body key has a HttpInput class.
00:59underplankI’ve read that I should just be able to slurp this. and that seems ok. But if its empty I get and exception.
00:59underplankIs there an easy way to check if its empty before I slurp it?
01:00amalloyunderplank: someone else has already slurped it; these streams are not "reusable". probably it is some middleware reading the body to parse out form params or something
01:01underplankhmm.. so is my best bet to just catch that exception? and mark it as an emtry string?
02:34elvis4526is it possible to use clojurescript from clojure ?
02:50Kneivaelvis4526: what would you do with that?
02:54Seylerius,(defn dedup [seqq] (if (= (first seqq) (second seqq)) (dedup (next seqq)) (concat [(first seqq)] (dedup (next seqq)))))
02:54clojurebot#'sandbox/dedup
02:55Seylerius,(dedup [1 2 2 3 3])
02:55clojurebot#error{:cause nil, :via [{:type java.lang.StackOverflowError, :message nil, :at [clojure.lang.RT seq "RT.java" 487]}], :trace [[clojure.lang.RT seq "RT.java" 487] [clojure.lang.RT next "RT.java" 647] [clojure.core$next__4063 invoke "core.clj" 64] [clojure.core$second__4069 invoke "core.clj" 96] [sandbox$dedup invoke "NO_SOURCE_FILE" 0] ...]}
02:55Seylerius,(defn dedup [seqq] (if (= (first seqq) (second seqq)) (dedup
02:55Seylerius (rest seqq)) (concat [(first seqq)] (dedup (rest seqq)))))
02:55clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
02:56Seylerius,(defn dedup [seqq] (if (= (first seqq) (second seqq)) (dedup (rest seqq)) (concat [(first seqq)] (dedup (rest seqq)))))
02:56clojurebot#'sandbox/dedup
02:56elvis4526Kneiva: I was just rendering if this was possible
02:56Seylerius,(dedup [1 2 2 3 3])
02:56clojurebot#error{:cause nil, :via [{:type java.lang.StackOverflowError, :message nil, :at [clojure.lang.PersistentList$EmptyList first "PersistentList.java" 158]}], :trace [[clojure.lang.PersistentList$EmptyList first "PersistentList.java" 158] [clojure.lang.RT first "RT.java" 625] [clojure.core$first__4061 invoke "core.clj" 55] [sandbox$dedup invoke "NO_SOURCE_FILE" -1] [sandbox$dedup invoke "NO_SOURCE_FIL...
02:56elvis4526like for hiccup and garden
02:56SeyleriusAch.
03:11amalloySeylerius: you're missing a base case, for if the coll is empty
03:25Ricardo-ArgesMorning
03:26Ricardo-ArgesIs there any particular convention for when a function starts with an underscore?
03:28Ricardo-ArgesLike question mark for predicates.
04:56zotg'morning. i'm working on translating some code from cljs -> clj, and it makes heavy use of mutable data. in one case, there's a deftype which includes 2 ^:mutable fields, which I initially changed to ^:volatile-mutable, only to find that doing so isn't trivial. is re-wrapping everything as atoms the best alternative? the code in question is here: https://github.com/tonsky/datascript/blob/master/src/datascript/impl/entity.cljs#L65 and my brok
04:56zotany wisdom, thoughts or smart-ass-ery is appreciated :)
04:58ordnungswidrigzot: that's not trivial but I guess an atom might be the best to use. For performance you can later still migrate to volatiles.
04:59zotyeah, that was my thinking; but just so that i know — why doesn't normal access work when it's a vol-mut? or am i doing something stupid to make that also fail?
05:04ordnungswidrigzot: I've got no experience with vol-muts :-(
05:22Seylerius,((fn dedup [seqq] (if (not (empty? seqq)) (if (= (first seqq) (second seqq)) (dedup (rest seqq)) (concat [(first seqq)] (dedup (rest seqq)))) (seqq))) [1 1 2 3 3 2 2 3])
05:22clojurebot#error{:cause "clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IFn", :via [{:type java.lang.ClassCastException, :message "clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IFn", :at [sandbox$eval25$dedup__26 invoke "NO_SOURCE_FILE" 0]}], :trace [[sandbox$eval25$dedup__26 invoke "NO_SOURCE_FILE" 0] [sandbox$eval25$dedup__26 invoke "NO_SOURCE_FILE" 0] [sandbox...
05:23TEttinger,(defn dedup [seqq] (if (not (empty? seqq)) (if (= (first seqq) (second seqq)) (dedup (rest seqq)) (concat [(first seqq)] (dedup (rest seqq)))) seqq))
05:23clojurebot#'sandbox/dedup
05:24TEttinger,(dedup [1 1 2 2 3 3 3 2 3 ])
05:24clojurebot(1 2 3 2 3)
05:26SeyleriusLol. That's all I needed: to remove a set of parens.
05:32TEttingerI think that might be handled better with reduce than recursion
05:32TEttinger,(defn dedup [seqq] (if (not (empty? seqq)) (if (= (first seqq) (second seqq)) (dedup (rest seqq)) (concat [(first seqq)] (dedup (rest seqq)))) seqq))
05:33oddcullythe curse of the lispaneer... to few or to many
05:33clojurebot#'sandbox/dedup
05:33TEttinger,(apply dedup (range 1000))
05:33clojurebot#error{:cause "Wrong number of args (21) passed to: sandbox/dedup", :via [{:type clojure.lang.ArityException, :message "Wrong number of args (21) passed to: sandbox/dedup", :at [clojure.lang.AFn throwArity "AFn.java" 429]}], :trace [[clojure.lang.AFn throwArity "AFn.java" 429] [clojure.lang.AFn invoke "AFn.java" 140] [clojure.lang.AFn applyToHelper "AFn.java" 403] [clojure.lang.AFn applyTo "AFn.ja...
05:33TEttinger,(dedup (range 1000))
05:33clojurebot(0 1 2 3 4 ...)
05:33TEttingeraw
05:33TEttinger,(dedup (repeat 1000 1))
05:33clojurebot(1)
05:34TEttinger,(dedup (repeat 100000 1))
05:34clojurebot#error{:cause nil, :via [{:type java.lang.StackOverflowError, :message nil, :at [clojure.core$repeat$fn__4585 <init> "core.clj" 2865]}], :trace [[clojure.core$repeat$fn__4585 <init> "core.clj" 2865] [clojure.core$repeat invoke "core.clj" 2861] [clojure.core$repeat$fn__4585 invoke "core.clj" 2865] [clojure.lang.LazySeq sval "LazySeq.java" 40] [clojure.lang.LazySeq seq "LazySeq.java" 49] ...]}
05:34TEttingerthere we gi
05:34TEttingergo
05:36deadghostso for clojure web security there's friend and buddy
05:36deadghostluminus uses buddy
05:37deadghostdoes anyone have any opinions on these before I blindly pick one
05:38TEttinger,(defn dedup2 [coll] (if (seq coll) (reduce #(if (= %2 (last %1)) %1 (conj %1 %2)) coll)))
05:38clojurebot#'sandbox/dedup2
05:38TEttinger,(dedup2 [1 2 3 1 1 1 1 1 2 2 2 3 2 3 2 2])
05:38clojurebot#error{:cause "Don't know how to create ISeq from: java.lang.Long", :via [{:type java.lang.IllegalArgumentException, :message "Don't know how to create ISeq from: java.lang.Long", :at [clojure.lang.RT seqFrom "RT.java" 506]}], :trace [[clojure.lang.RT seqFrom "RT.java" 506] [clojure.lang.RT seq "RT.java" 487] [clojure.lang.RT next "RT.java" 647] [clojure.core$next__4063 invoke "core.clj" 64] [cloj...
05:39Glenjamin,(defn distinct-consequtive [sequence] (map first (partition-by identity sequence))) ; nicked from http://clojuredocs.org/clojure.core/distinct
05:39clojurebot#'sandbox/distinct-consequtive
05:39TEttingerah, that's better Glenjamin
05:40Glenjamini take no credit
05:41TEttinger,(defn dedup2 [coll] (if (seq coll) (reduce #(if (= %2 (last %1)) %1 (conj %1 %2)) [(first coll)] (rest coll))))
05:41clojurebot#'sandbox/dedup2
05:41TEttinger,(dedup2 [1 2 3 1 1 1 1 1 2 2 2 3 2 3 2 2])
05:41clojurebot[1 2 3 1 2 ...]
05:41TEttinger,(dedup2 (repeat 100000 1))
05:41clojurebot[1]
05:41TEttingeryessss
05:42TEttinger,(distinct-consequtive (repeat 100000 1))
05:42clojurebot(1)
05:46ordnungswidrig,(distinct-consequtive [1 1 2 2 1 nil nil false false true true])
05:46clojurebot#error{:cause "Unable to resolve symbol: distinct-consequtive in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: distinct-consequtive in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: di...
05:47Glenjaminsounds like the repl reset
05:47Glenjamin,(defn distinct-consequtive [sequence] (map first (partition-by identity sequence))) ; nicked from http://clojuredocs.org/clojure.core/distinct
05:47clojurebot#'sandbox/distinct-consequtive
05:47ordnungswidrig ,(defn distinct-consequtive [sequence] (map first (partition-by identity sequence)))
05:47clojurebot#'sandbox/distinct-consequtive
05:47ordnungswidrig,(distinct-consequtive [1 1 2 2 1 nil nil false false true true])
05:47clojurebot(1 2 1 nil false ...)
05:47TEttingerhuh, it did it with a " ," at the start
06:31patrkrishello. I have a project with a src directory, and within it, I have a user.clj file used in the REPL. how do I exclude this file completely when running lein jar/uberjar? maybe I shouldn't even place the file in my src directory?
06:32justin_smithpatrkris: :uberjar-exclusions maybe?
06:32justin_smithpatrkris: you can always have a different :source-paths for dev profile, and keep user.clj in a different directory, yeah
06:33patrkrisjustin_smith: ah yeah, of course. I will move user.clj somewhere else. thanks
06:33justin_smithpatrkris: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L388 - it looks like you can exclude it by regex too, but I think a separate dir is cleaner, yeah
06:34patrkrisjustin_smith: I triede skipping by regex, and it does exclude the file from the jar, but still compiles the namespace and adds the resulting class file
06:35justin_smithahh, you may need to exclude the class too, or of course just use separate paths, that's cleaner anyway
06:38patrkrisyeah, separate paths it is
06:38patrkris:)
06:38patrkristhanks again
07:14dysfunwhy are all the line numbers on compile errors off by a few lines?
07:15dysfunin this case, it complained about line 65 when it meant line 71
07:17justin_smithdysfun: is it complaining about your original file, or one of those /tmp/form-init... things/
07:25dysfunmy original file
07:25dysfunit's when the files get loaded by autotest
07:33dysfunis there a workaround to be able to assign metadata to a keyword?
07:34dysfuni need a sentinel value and it seemed like a sensible option, but i also need to pass metadata
07:35dysfuncurrent option seems like defining a type, but not keen on that
07:35justin_smithdysfun: anonymous var? an atom holding the keyword as its value?
07:36dysfunatom i was considering too
07:36dysfunsod it, i'll use an atom
07:38justin_smithalso, the atom itself can be the sentinal (checked by equality) and instead of metadata, it can actually hold the data
07:39dysfunwhat are the rules for equality of atoms, then? ref matching?
07:39justin_smithidentity
07:39justin_smith,(= (atom 1) (atom 1))
07:39clojurebotfalse
07:39justin_smiththat's why it's useful as a sentinal that holds a value
07:39dysfun,(let [a (atom 1)] (= a a))
07:39clojurebottrue
07:40dysfuncool. thanks
07:43dysfunugh. i'm going to have to shove this into the dynamic binding hackery i'm doing with other stuff in order to make it safe to use several at once
07:56noncomhi,l anyone familiar with clj-http here?
07:57justin_smithI use it.
07:57noncomi am trying to port a http request from curl to clj-http and not getting much success with it..
07:57justin_smithany particular aspect?
07:57noncomlook here http://support.hockeyapp.net/kb/api/api-apps the one at the bottom of the Upload App section
07:57noncomthe error in the response is "415 Unsupported Media Type"
07:59justin_smithI assume the @ is special, and tells curl to provide the file?
08:00noncomyes
08:00noncomhere is what i send: https://www.refheap.com/98864
08:01justin_smithdoesn't it need the zip too?
08:02justin_smithI'm guessing the error is more about the data that API expects
08:02noncomthe dsym.zip? no, it is optional..
08:02justin_smithoh, OK
08:02noncomyes, the error with the data type.. i just don't know how to make it the correct data type i think..
08:02noncomdo i link the file correctly at all?
08:03justin_smithyes, that is how it should be provided
08:03justin_smiththough io/file will totally let you reference a non-existent file
08:03justin_smith(in case you wanted to write / create it)
08:03justin_smithoh wait
08:03justin_smiththe file has to go in :multi-part
08:04justin_smithnoncom: search for "file" down from this link https://github.com/dakrone/clj-http#usage
08:05justin_smithso :multi-part is a separate heading, alongside :form-params
08:05noncomah..
08:05noncomwith :name "ipa" i guess..
08:06justin_smithyeah, I think so
08:06justin_smithone great thing about clj-http is the examples are pretty comprehensive
08:07noncombut you see, i am not a great expert in http..
08:07noncomi know it is simple, but still cen't get used to the multipart things..
08:08justin_smithyeah, multipart trips me up too
08:08justin_smiththough I also don't need it very often
08:09noncomthat's the problem :) i use them once a year, and each time is like the fist time
08:09f3ewWhat are the currently recommended books for clojure?
08:09justin_smith~books
08:09clojurebotbooks is programming clojure
08:09justin_smiththere are more
08:09justin_smith~books
08:09clojurebotbooks is programming clojure
08:10justin_smithsometimes I really don't like the factoid system
08:10noncomyeah :)
08:10f3ewjustin_smith: I'll take the one, as long as it's reasonably good
08:10justin_smithyeah
08:11justin_smiththat's probably the best beginner one, it's the one from o'reilly
08:11justin_smiththere are also some decent online intros, clojure for the brave and true, and aphyr's clojure from the ground up series
08:13f3ewYeah, I'm learning Clojure for Riemann
08:13Ricardo-ArgesCan anyone comment on if liberator is still acive?
08:13f3ewand I'm missing the ability to just push a print statement in for debugging
08:15justin_smithf3ew: oh yeah, that's from aphyr isn't it
08:15dysfuncan i get an anonymous dynamic var?
08:16justin_smithdysfun: that's what with-local-vars does, kind of, but then everything needs to be inside its body
08:16dysfunyes, that's not possible
08:17dysfuni don't need mutability, i just need dynamic scope
08:17dysfunand the ability to hold metadata
08:17dysfunotherwise i'm going to have to rewrite all my code to pass around a context object and it was nice and clean...
08:18hyPiRionWhat's the point of an anonymous var then? How do you think you could reference it?
08:18dysfunRicardo-Arges: yes, it seems to be quite active
08:18dysfunwell ideally i'd like to create a lexical with dynamic scope heh
08:18Ricardo-ArgesThanks dysfun. Was looking at the repo but most of the activity seemed to be on the documentation branch. Lots of unmerged, uncommented pull requests.
08:18Ricardo-ArgesSo I was wondering.
08:19dysfunthere seem to be lots of users too
08:19f3ewjustin_smith: yes
08:20Ricardo-ArgesProbably yogthos' fault. At least I heard of it initially from his book.
08:22justin_smithf3ew: I encourage learning some clojure, but it can also be helpful to use a profiler to see exactly what's happening when the error occurs
08:25f3ewI would prefer to know what I'm doing before using tools though :)
08:25justin_smithyup, fair enough :)
08:25f3ewI'm cargo culting stuff at the moment, and I don't like that :)
08:26noncomjustin_smith: tried making multipart - still the same error: "415 Unsupported Media Type"
08:27justin_smithf3ew: fwiw, clojure has a repl that can bootstrap quickly from cargo cult stuff if you use it right. Break things down into the innermost forms, try variations on them to see if the things you expect to work, do, and the things you expect to fail, fail.
08:27justin_smithit can be very informative
08:30justin_smithnoncom: that's odd - do you need to provide a content-type or content-disposition or anything?
08:32noncomprobably.. i just dont know what does curl put there..
08:32noncomwhat content type..
08:33justin_smithnoncom: that's probably not it at all
08:40noncomuhh.. maybe i am dense, but i really feel like http is coming from the past century
08:41justin_smithnoncom: what I would do next is make a simple http endpoint that allows file upload, and verify it works from a browser, and then make it work from clj-http
08:41justin_smithit's a bit roundabout, but that eliminates a point of failure
08:41justin_smithand it's easier when you can debug from both ends
08:43f3ewnoncom: it is :)
08:44noncomyeah, well, will then be hunting the actual request-response things.. try to figure out what it should be. curls has a -verbose key, so it will be of aid too...
08:46justin_smithnoncom: there is also tcpdump, you could compare dumped post requests coming from your own code vs. curl
08:49jonathanjwhere could i ask questions about gloss?
08:49justin_smithjonathanj: ztellman is known to hang out here from time to time, and there are definitely people here who use gloss
08:49justin_smith$seen ztellman
08:50lazybotztellman was last seen quittingQuit: ["Textual IRC Client: www.textualapp.com"] 2 weeks and 2 days ago.
08:50justin_smithoh, it's been that long!
08:51anewoot, the cider clj-debugger is making leaps
08:58jonathanjdoes gloss have any kind of validation/assert stuff built into it that i can't seem to find in the documentation?
09:00jonathanjfor example, specifying an upper limit on a length-prefixed value
09:06acron^how do I reference a public field on a class in Java?
09:06acron^(StringEncoder. CharsetUtil.UTF_8) gives me "class not found: CharsetUtil.UTF_8"
09:07acron^UTF_8 is just a static field on CharsetUtil
09:11acron^Got it....
09:11acron^CharsetUtil/UTF_8
09:11acron^it's that easy
09:46J_Arcaneomg i am so dumb. I spent nearly the last two hours to come up with this, when a simple zip map of tails and inits does the same thing: https://www.refheap.com/98870
09:49jonathanjthere's not a gloss mailing list is there? (i couldn't find one)
09:50jonathanjshould i just post to the clojure mailing list with my gloss question?
09:55pkugis there a shorter way to filter out the subsequences of length < 2, than doing a filter with #() macro comparing 'count' ?
09:56noncomjonathanj: you can also try to pm zach
09:56noncomlike on github
09:56noncomi did this once
09:57noncompkug: i can't think of any//
10:05jonathanjyou could (ab)use `second` as your pred
10:06jonathanj,(filter second [[] [1] [1 2] [1 2 3]])
10:06clojurebot([1 2] [1 2 3])
10:06noncomwow
10:06jonathanjof course that's prone to being wrong:
10:07jonathanj,(filter second [[] [1] [1 nil] [1 2 3]])
10:07clojurebot([1 2 3])
10:07hyPiRionyeah, that's not good
10:07hyPiRion,(filter nnext [[] [1] [1 nil] [1 2 3]])
10:07clojurebot([1 2 3])
10:08pkugCan somebody take a look and give me some feedback/critics on the style and code https://gist.github.com/pkug/ebf4e31e470a53c48ef4 ? it's my solution to https://www.4clojure.com/problem/53
10:08hyPiRion,(filter next [[] [1] [1 nil] [1 2 3]]) ;; this should work?
10:08clojurebot([1 nil] [1 2 3])
10:08noncompkug: use ->
10:09noncomor i mean ->>
10:09pkugis it possible to automatically convert to that style?
10:12noncomnot sure.. i know of no automatic means for that
10:13noncompkug: also, if you're not after a one-liner specifically, probably a let statement with named steps would help.. but that is more a question of style than correctness
10:18jonathanjis there something that lets me (map) over a map but only transform the values?
10:19jonathanjthere's map-vals in the plumbing library i think?
10:19the-kenny(zipmap (keys m) (map ... (vals m)))
10:42jonathanjis cider still the way to go for clojuring in my emacs?
10:42aneyes
10:44mpenetthe-kenny: while this works on the current version, there is no guarantee that keys and vals return the same order
10:44sobelso, i want a vector, but (conj nil ...) produces a list. i hacked it with (conj [] ...). is this gross, is there a much better way?
10:45the-kennympenet: I know
10:45mpenetI'd rather use reduce-kv
10:45mpenetit's probably faster too
10:47Glenjamini tend to use either reduce-kv or (into {} (for
10:48hyPiRionmpenet: there's a guarantee on that actually
10:48hyPiRionrhickey verified it in a Jira issue some months ago
10:49mpenetoh really?
10:50kungiDoes lein uberjar porform clean befora a build?
10:50mpenetah yes, kinda new CLJ-1302
10:50MorgawrHas anybody else experienced massive memory leaks (or what I assume are memory leaks) in very long lasting lein cljs autobuild processes (or clojure repls in general)? I'm not sure if it's because I suspend a lot of times across multiple days with my laptop, but I've had this happen so many times
10:51MorgawrI usually keep a repl open and a lein cljsbuild auto running 24/7 because it's faster than closing/opening them when I am working
10:51Morgawrand after a day I see that together they are consuming around 4-5GB of ram
10:51Morgawreven if I am not using them at all
10:51MorgawrI have to kill them and restart them and then they go back to using whatever normal (or what I consider to be normal) ram usage
10:52MorgawrI've tried looking around for bug reports or other people mentioning it but I couldn't find much, I'm curious to see if I'm the only one that experienced something like this
10:53gfredericksif a ring response is associated with resources that need to be cleaned up after the response is done, is there any reason I can't just make a wrapped InputStream that does cleanup on .close?
10:53gfredericksI feel like there was something about this that didn't work but I can't remember what
10:53the-kennygfredericks: I did that for a project
10:53the-kenny(to delete temporary-files)
10:54Morgawrsobel: (into [] ...) will make sure to return a vector
10:55gfrederickshmm
11:01idnarI think (vec ...) is a better spelling of that?
11:04Morgawridnar: I was under the impression that it's more idiomatic to use (into <collection> ...) because it're more 'standardized' across different collection types, but speed-wise I'm not sure which one is faster and which one is not
11:04Morgawr,(time (into [] (take 10000 (repeat 1))))
11:04clojurebot"Elapsed time: 486.975998 msecs"\n[1 1 1 1 1 ...]
11:04Morgawr,(time (vec (take 10000 (repeat 1))))
11:04clojurebot"Elapsed time: 303.064245 msecs"\n[1 1 1 1 1 ...]
11:04MorgawrWell there you go :)
11:04the-kennyMicrobenchmarks don't say anything.
11:04MorgawrI know :P
11:05Morgawrit was just my curiosity
11:05idnarheh
11:08sobelvec it is
11:09idnar,(time (take 10000 (repeat 1)))
11:09clojurebot"Elapsed time: 0.050243 msecs"\n(1 1 1 1 1 ...)
11:09idnarah
11:11idnarso I think one "nice" thing is that if you pass a Java array to vec, it'll just alias it instead of copying it (but that's not so nice if you modify the array later)
11:27irctc__hi all, question, why does (with-meta list {:a 1}) blow up my repl?
11:39{blake}irctc__: I get "UnsupportedOperationException".
11:40Bronsairctc__: attaching metadata to function objects is not a good idea. `list` is not implemented like a normal function for bootstrapping purposes
11:42susejadvice please if clojure is a good first programming language for a 40 year old noob?
11:56oddcullysusej: what other languages are in your selection?
11:59susejoddcully: I tried python and ruby, but after i followed a very short tutorial, clojure made more sense to me. I know html/css and the very basics of javascript.
12:01nullptrsusej: you might consider clojurescript, through which can leverage the javascript knowledge you've already gained
12:02patrickgombertsusej: there is a language called scheme which is used in a book called Structure And Interpretation Of Computer Programs. I’d recommend installing scheme and going through the book if you’re up for it.
12:02patrickgombertbut scheme is a lisp dialect so if clojure makes sense then scheme will make sense as well :)
12:02susejnullptr: but don't I need to know clojure to start playing with clojurescript?
12:04susejpatrickgombert: I would go through the book if it cement my knowledge
12:06nullptrsusej: no, much of the language is the same, so if you become proficient with one the other should feel quite natural
12:07nullptrthe major differences are in the things you interact with outside the language (javascript vs. jvm)
12:08noncomi have not revisited clojurescript for a long time already.. and i am wondering, is it still a common case, when you get errors, they are shown in the autogenerated javascript and you have to deal with the headache to projecting them on the cljs source?
12:08noncomor are there sourcemaps already and good debugging?
12:09noncomin other words, can i forget about js when in cljs, like i forget about js when in coffeescreept?
12:09Jaoodthere are sourcemaps
12:10Jaoodsusej: I would suggest http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/index.html, then you can move to clojure if you really wish, it would be easy
12:10noncomand the second question - is there still a penalty of having to download many kilobytes of cljs interpreter on every cljs-enabled page?
12:13susejJaood: Thank you.
12:16nullptrnoncom: source maps have improved dramatically. there is no such thing as a cljs interpreter -- cljs compiles to javascript and is interpreted as such. using {:optimizations :advanced} causes the base bits of cljs (like persistent collections) to be represented very efficiently, so that isn't a practical concern.
12:17nuwanda_nullptr: I wouldn't say it isn't a practical concern, if js size is a huge concern then cljs will likely be a problem. I agree in the vast majority of cases it's a non-issue.
12:18susejJaood: Is clojure that that book teaches?
12:19nullptrnuwanda_: for all but the most trivial applications (vanilla js, no dependencies at all), the benefits of advanced compilation (especially with the new modules capability) outweigh the cost that cljs adds to the base
12:19nuwanda_nullptr: sure, I agree
12:21nullptri just built a cljs app that prints 'hi' to the js console, with advanced compilation it's 1,435 bytes
12:21Jaoodsusej: no, it uses Racket, which is also a lisp, but the important point is that the book will teach you much more than just learning the syntax and semantics of some language, transitioning to Clojure after going through that book is trivial.
12:23Jaoodsusej: one thing that can may hold you down in Clojure is the Java baggage
12:28susejJaood: I plan to learn clojure then clojurescript to build web apps. I "know" that clojure runs on JVM, but I have faith that ĩ will get the hang of that eventually.
12:30jehow can I tell the Java environment that my Clojure function can throw a specific exception (so the Java IDE knows)?
12:34justin_smithje: we don't do checked exceptions - is it just a preference thing that you want to declare it?
12:36jejustin_smith: I'm writing a lib in Clojure and I am pretty sure that my Java colleagues will ask why their IDE doesn't tell them that this function can throw an exception... thats the problem I'm trying to solve? Was that an answer to your question?
12:37jein Java I think one would write something like: public void myMethod() throws Exception {}
12:37justin_smithje: OK, yeah. I don't even know how you would declare a checked exception from Clojure, and now that I think of it I have never seen this question before even. I'm sure there is some way to do it.
12:38justin_smithunless it's the case that it would require some byte code emitting that Clojure isn't at all set up to do
12:38justin_smithje: yeah, the problem is that clojure doesn't compile to java, it compiles to byte code
12:38justin_smithso knowing the java syntax doesn't really help much
12:38hyPiRionOh, bypassing sneakyThrow? Not sure that's possible actually.
12:39hyPiRionor the compiled variant thereof
12:39jejusting_smith: just wrote the Java code to make my question more clear
12:39justin_smithhyPiRion: oh, clojure uses a hacked variant of throw to avoid the checked exceptions?
12:39Glenjamindo java people still use checked exceptions?
12:39justin_smithje: oh, yeah, that makes sense, sure
12:39Glenjamini thought that had fallen out of favour
12:39justin_smithGlenjamin: I guess some people expect it
12:40hyPiRionjustin_smith: the java parts of Clojure
12:40justin_smithhyPiRion: ahh, OK
12:41hyPiRionjustin_smith: https://github.com/clojure/clojure/blob/433ff95e237d0ec2bbd8b872b997b69a2b3cca81/src/jvm/clojure/lang/Util.java#L228-L245
12:43jeso I guess the conclusion is that it isn't possible, but thanks for the quick reply :-)
12:45justin_smithje: there might be a way to do it
12:46justin_smithit's a rarely asked question
12:47jejustin_smith: uhh interesting
12:48BinaryResultjust a reminder, Disco Melee is hiring clojure devs https://docs.google.com/document/d/1GvnrSCUbYgbY9XdFs_DUx-0QZG2bIYT8Mbr0zdpTeew/edit?usp=sharing
12:50justin_smithje: what hyPiRion pointed out prevents clojure's java code from using checked exceptions, but that doesn't mean one couldn't hypothetically make the compiler emit one... That's my take at least.
12:55jejustin_smith: I think this is currently a bit out of my league, I'll live without for now but thanks for your time
12:56patrickgombertMy understanding is that checked exceptions don’t make it to bytecode, so there can’t be checked exceptions in whatever clojure emits
12:56patrickgombertthey’re a java construct not a jvm construct
12:56patrickgombertalso, I could be totally wrong
12:56nullptrif your java colleagues are expecting/wanting checked exception, clojure adoption might be a bit of an ... umm ... uphill battle
13:02N8Dawg@Bronsa there are reasons you'd want to add metadata to functions, what if i want the function form attached to the function?
13:03BronsaN8Dawg: not saying one shouldn't do it -- just that it's generally not a good idea. Usually better to attach that metadata to the var instead
13:05Bronsapatrickgombert: it's actually possible to compile the checked exceptions in the method signature of the emitted bytecode, it's just that the vm verifier ignores it
13:06patrickgombertBronsa: is that the default?
13:06patrickgombertor is it just for IDEs and such to make sense of it
13:08Bronsapatrickgombert: I believe it's there for tools/javac (like the vararg attribute)
13:38Bronsahttp://i.imgur.com/m5nAEoH.png seeing this makes me sad
13:39Glenjaminit possibly reflects an increase in userbase
13:39Glenjaminthat that's one positive
13:39justin_smithBronsa: maybe that's a sign of how ambitious 1.7 has been?
13:42mpenetIt's 1.6 birthday the day after tomorrow!
13:44mpenetBronsa: tons of tickets are waiting with patches tho, the whole process (triage, vetting, etc) takes a long time
13:44mpenetand probably too few people hold the reins
13:45Bronsampenet: I know that too well, unfortunately
13:45Glenjaminfrom the outside it sometimes looks like the process is designed to deter contribution
13:45mpenetit's demotivating yeah
13:47hiredmanthe whole thing is some kind of negative spiral, you don't want to release with outstanding issues, so you invest a lot of time fixing issues so you can make a release, and the more time you spend fixing issues the more time there is for new issues to be opened
13:47mpenetand some tickets in limbo have some very nice patches ready
13:48mpenetex the work from ztellman on collections
13:48hiredmanthe perfect is the enemy of my friend's bridges
13:48mpenethiredman: true
13:48mpenetI am all for short release cycles personnally
13:50hiredmanztellman's collection work is a great example, this is good stuff that was defered because the 1.7 release will happen real soon now
13:51mpenetfunny that we're reaching the 1 year mark now
13:51mpenetgiven the comments on this ticket
13:51hiredmanand, like, we are getting a socket repl in core
13:52mpenet:]
13:55mpenetactually 1.6 release date was exactly 1 year ago! not a few days off
13:55mpenetanyway...
14:00hiredmanI have a patch from july of last year, which had the fix version moved from 1.7 to 1.8 in october
14:05hiredmanthe comments on ztellman's patch for holding off till the 1.8 release are something like "we've decided to hold off on anything not entirely baked for 1.7" but then months later the socket repl stuff hits jira apparently out of the blue
14:06hiredmanwith, as far as I know, no design discussion in the wiki
14:11wagjofyi Dunaj has incorporated ztellman's tuples into the core
14:11hiredmanwhich is not to say that design discussion didn't happen, it must have, but it happened behind a door somewhere, so of course the first reaction to it is wtf
14:13wagjohttp://www.dunaj.org/dunaj.coll.tuple.api.html
14:14Bronsawagjo: afaik the proposal in the clj jira is about making those tuples an optimization over persistentvector rather than just adding as another available collection
14:14hiredman(and specifically for socket repl, "what about nrepl?")
14:15Bronsawagjo: does dunaj implement it this way?
14:15wagjoBronsa: I know, tuples are used heavily internally in Dunaj to improve performance
14:16Bronsanice
14:16wagjoin Dunaj, (class (vec [1 2 3])) returns dunaj.coll.tuple.Tuple3
14:16wagjoI left [] literal a persistent vector for backwards compatibility, but otherwise tuples are used whenever possible
14:17justin_smithwagjo: oh, that's your project? cool stuff. I've been impressed by all the things I have seen so far.
14:17wagjo(class (first {:foo 1 :bar 2}))
14:17wagjoreturns tuple too
14:17Bronsawagjo: I believe the proposal is to make [] literals use tuples aswell
14:18wagjojustin_smith: thank you
14:18Bronsajust like {} literals use PAMS
14:18wagjoBronsa: I hope they will get incorporated into Clojure too, but for now I left [] literals intact in Dunaj
14:19hiredmanhttp://dev.clojure.org/jira/browse/CLJ-1610
14:19hiredman(speaking of maps)
14:19wagjoZach has a proposal for 'associative tuple' too
14:19wagjoI haven't included in in Dunaj though
14:19mpenetyes in jira he's talking about other collection types as well
14:19wagjohiredman: exactly :)
14:20mpenet-> Voted (15)
14:25bacon1989is there a broader article on Dunaj? I don't really see the reasons for it
14:25wagjobacon1989: see http://www.dunaj.org/rationale.html
14:26arrdemIdle idea, has anyone looked at the socket REPL patches to see if they have to be in core for some reason?
14:27bacon1989I see, but all I see are the shortfalls involved in fragmenting away from the clojure.core
14:34wagjobacon1989: I agree that there are shortcomings, but in my opinion benefits outweighted them.
14:35wagjobacon1989: Rich stated in 2012 that we need reducible I/O sources and so far nobody released something usable.
14:37wagjobacon1989: some things cannot be done gradually through patches as they are hard to evaluate until they are done completely
14:38wagjobacon1989: and how else can you evaluate a synergistic effect if not through a Clojure fork?
14:50justin_smitharrdem: my totally naive hunch is that since clojure is at its heart truly a repl, there are core changes that would make it more elegant, even if the feature itself could be outside core
14:56bacon1989wagjo: good point, I can see it as a good prototype maybe. It suggests there will be backwards compatibility with existing code.
14:57bacon1989Not that I wouldn't use it, if it became the new standard
14:57justin_smithmaybe it could end up being like the arch / debian split - one which gets features first, the other rarely if ever breaks
14:58wagjobacon1989: there already is backwards compatibility, All described in Dunaj is already implemented, and is nearly feature complete
15:11sobelhmm. clojure is already a small enough branch in the broader java ecosystem. not sure i'd want to venture even farther off the beaten path.
15:17xemdetiadunaj.org is marked as suspicious by my stuff lol
15:18sobelheh
15:46mikerodIn a profiler if I see clojure.lang.Compiler.access$100 - what is this?
15:46mikerodI get that $100 part means it is probably some anonymous inner class. I don't get what the "access" part is I don't think
15:49Bronsamikerod: that's javac magic for accessing private fields of outer clases from inner classes
15:52hiredmanif you are profiling and seeing bits from the compiler in your profile, that would be a red flag for me that I was profiling incorrectly
15:54justin_smithor, a sign that you can likely fix your performance issue by not using eval
15:54puredangerhiredman et al, re the discussion a couple hrs ago on jira and planning decisions. decisions are made every week on this stuff - sometimes decisions are made with one expectation of near-term events and then things change. It is thus inevitable that decisions made at one point in time are at odds with decisions made at other points in time.
15:54hiredmanI would generally be profiling the sort of steady state of the app, while compilation happens at the start (unless you are calling eval all over the place)
15:55puredangerno one is more acutely aware of the status of the issues in jira and the timeline of the releases than me
15:57puredangerand it is simply incorrect that there are zillions of patches just "ready to commit". look at the many revisions of any patch that goes into the release to see that that isn't true.
15:58joshhartiganis there a way for me to mute the 'welcome message' of `lein repl`
15:59gfredericksI think lein repl-options has that
15:59gfredericks(the project.clj key)
16:00joshhartiganthank you
16:00puredangerre the tuples thing in particular, I sat down with Zach at the Conj and we did a surface review of his patch and found a half dozen things that needed to be changed plus there is some integration work that is not addressed in the patch at all. it's great stuff and I look forward to integrating it. I wish it was in now, but adding that to the release would not have sped anything up.
16:01hiredmanpuredanger: sure, thank you for your hardwork, I am not questioning that, I am sort of as a step back at the meta level, the way things are done from my perspective seems to result in a number of undesirable properties, regardless of the high quality way it is done
16:02puredangerif the issue is getting smaller things into the release stream faster, then I think that's a reasonable complaint
16:03puredangerI don't actually think most companies or projects integrate major releases more than twice / year. I personally would like to be doing 2 per year. Or 1 big / 1 small per year.
16:05hiredmanpuredanger: have you guys considered declaring some kind of feature freeze in preparation for a release? sometimes it seems like that is the intent behind decisions on some patches, but then new features land anyway
16:06wagjobeta release is a feature freeze AFAIK
16:06puredangerwell like I said, things change sometimes
16:06puredangergenerally once we go beta, we do not add new new features
16:08hiredmanit just seems like the longer it takes to cut 1.7, the more ideas / features / bugs / etc will be reported, and if that work in turn effects the scope of 1.7 …
16:09puredangerwelcome to my life :)
16:10puredangerbut you need to flip perspective and ask whether we are continuing to build a great language with high quality and most needed things fixed
16:10puredangerwhile there is an insatiable desire for more, I think we are
16:10wagjoit seems to me that outstanding issues with transducers (e.g. transformation to lazy seqs) are what keeps 1.7 from releasing
16:11puredangerI think reader conditionals has been more of a long pole than that
16:11wagjowell yeah, I'm actually surprised that the decision has been made so soon :)
16:13puredangernot having feature expressions / reader conditionals ready was the major thing that delayed a beta and feature freeze
16:13wagjopuredanger: you guys are doing a great work. The quality of releases wrt the backwards support for existing code is amazing
16:14puredangerit's important, and hard.
16:14gfrederickspuredanger: I am curious about what the most regretted features/details are from that perspective
16:15puredangernot sure what you mean
16:15puredangeryou mean things we'd change if we could?
16:15gfredericksthings you would jump at the chance to remove if not for backward compatibility
16:15puredangerthere's a zillion little things
16:16gfredericksI can never tell when looking at some old obscure feature if rich still thinks it's a good idea or not
16:16hiredman(changes.md has something like 19 bug fixes, all not in a release yet)
16:17puredangersome of the stuff I've been working on lately with 1603 and 1515 have really highlighted some murkiness around the contract of what a sequence function returns
16:17puredangerI think it would be best if most sequence functions were seqable -> seqable
16:18puredangerbut many are effectively seqable -> seq which greatly increases the set of commitments on the return
16:19anti-freezeSo, I'm trying to figure out why it takes > 5 minutes for lein repl to get started and visual VM is crashing on me while I'm profiling
16:19anti-freezeSeems like something to do with sun.rmi.transport.tcp.TCPTransport
16:19puredangeranti-freeze: have you tried just taking thread dumps while it's starting? ctrl-\ on *nix or ctrl-break on win
16:20justin_smiththere's also jstack
16:20puredangeryes, or jstack if multiple jvms involved
16:21anti-freezeWould you care to see the thread dump?
16:22anti-freezehttps://www.refheap.com/98885
16:22sdegutisGiven a [1,2,7,9,8,5,1,0,1], what's a splendid way to return both how many items are odd and how many aren't in one fell swoop?
16:23justin_smith,(map (comp count val) (group-by odd? [1,2,7,9,8,5,1,0,1]))
16:23clojurebot(6 3)
16:23ordnungswidrignice
16:23wagjopuredanger: well the IReduceInit is a great step towards cleaning collection internals, hope you'll find a way to integrate it with existing contracts
16:23sdegutisThanks justin_smith.
16:23Bronsapuredanger: dunno if I already asked you but – suppose I stumble upon a ticket that's obviously no longer relevant (no longer reproducible/things changed, e.g. clj-273 from today), is it ok for me to close it or should I just comment on it and let you or other screeners close it?
16:23ordnungswidrigjustin_smith: but you cannot be sure on the order of the result
16:23sdegutisjustin_smith: I was trying to figure out a way using juxt.
16:24ordnungswidrig,(map (comp count val) (group-by odd? [2,1,7,9,8,5,1,0,1]))
16:24clojurebot(3 6)
16:24sdegutisBut it didn't work out.
16:24justin_smithordnungswidrig: oh, yeah :)
16:24puredangerwagjo: I think there is great regret on following CL re reduce vs reduce with initial value. hard to undo now though.
16:24ordnungswidrig,(map (juxt (comp count val) key) (group-by odd? [1,2,7,9,8,5,1,0,1]))
16:24clojurebot([6 true] [3 false])
16:24justin_smithsdegutis: ordnungswidrig has a good point
16:24puredangerBronsa: I'd prefer to close it - what you did there was great
16:24Bronsaok
16:24sdegutisordnungswidrig: very true
16:25puredangerBronsa: but even if you did, I would have checked it either way so it's not a huge deal
16:25sdegutisI was thinking something with (juxt filter remove) and count.
16:25sdegutisBut meh.
16:26justin_smith,(reduce (fn [[odd even] n] (if (odd? n) [(inc odd) even] [odd (inc even)]) [0,0] [1,2,7,9,8,5,1,0,1])
16:26clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
16:26justin_smithoops
16:26ordnungswidrigsdegutis: that would work but traverse the fn twice. I'm sure another way would be to use transducers ...
16:26justin_smith,(reduce (fn [[odd even] n] (if (odd? n) [(inc odd) even] [odd (inc even)])) [0,0] [1,2,7,9,8,5,1,0,1])
16:26clojurebot[6 3]
16:26sdegutisAh.
16:26sdegutisOops, did I just nerd snipe?
16:26justin_smiththat does less extra work than the others too
16:26justin_smithnerd snipe?
16:27mikerodBronsa: thanks I should have considered that. inner class java magic of course makes sense now.
16:27ordnungswidrig,(->> [1 2 7 9 8 5 1 0 1] (map odd?) frequencies)
16:27clojurebot{true 6, false 3}
16:28ordnungswidrig,(->> [1 2 7 9 8 5 1 0 1] (map odd?) frequencies ((juxt [true false|)))
16:28clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
16:28mikerodhiredman: the issue is actually the Clojure compiler is hanging for very long times during a macro expansion for me
16:28mikerodand only in some strange edge case that I'm trying to narrow down to
16:28mikerodso I am needing to look closely at the Compiler's path it is taking in my profiling.
16:29hiredmanI guess, or run screaming from the macro?
16:29mikerodAnd in reality, a lot of the time when I've worked with Clojure I've found paying close attention to the Compiler's stack to be useful - but that is because I've worked a lot in the world of macros and even sometimes - though rarer - eval
16:30mikerodhiredman: the macro seems harmless and works most of the time though, so I just was shooting for an understanding
16:30mikerodadding a type hint is the culprit :)
16:30mikerodwas hoping to at least understand if I'm hitting a compiler bug or something
16:30hiredmanI guess?
16:30mikeroda type hint + cond->
16:30mikerodvery weird, hopefully I can recreate at some point
16:32hiredmanI just, I dunno, in five years of writing clojure for work that hasn't come up for me, so it makes we wonder about why that could be, and I can only assume we have differing ideas of what a harmless macro is?
16:33hiredmanor just how much macros and eval are needed?
16:33hiredmanor I dunno
16:33ordnungswidrighmm, I think macros might be overused in this case...
16:36hiredmanon the other hand I suspect I have horrified many without using a macro or eval, so whatevs
16:37puredangerBronsa (or anyone) - I'd love a simple test to repro the regression in http://dev.clojure.org/jira/browse/CLJ-1681 . It's not just a nil in the arg list - I think it's more subtle than that but I haven't had a chance yet to dig in.
16:39ordnungswidrighiredman: :-)
16:39mikerodhiredman: I think I can agree with you that generally if I'm profiling for performance problems I shouldn't be analyzing Clojure compiler speed. So maybe I just misinterpreted your statement
16:39mikerodIf it is coming down to eval or macro expansion speed - clearly you're off the deep-end
16:40idnarI'm writing a defthingy type macro; in it, I see that ~name is something like #<Unbound Unbound: #'some-ns/some-name> which I guess is some kind of symbol thing
16:40mikerodwhat I'm observing is a macro that works fine
16:40idnarhow do I get just "some-name" out of that?
16:40mikerodbut occasionally it gets some input and the compiler hangs for thousands of seconds
16:40mikerodit looks to be in an endless loop, but it terminates eventually
16:40mikerodand removing a type-hint makes it fast again - but adds reflection warnings
16:40Bronsapuredanger: I have a repro case, I just need to find a method in the java stl to use
16:41mikerodor I can leave the type-hint aand alter the macro to not expand to a use of cond-> and it is fine.
16:41mikerodSo I'm just trying to narrow down to a reproducing simpler case and see if I'm hitting a compiler edge case, defect, bad macro etc.
16:41puredangerBronsa: that was what I ran into as well. do you need multiple methods with same arity but differing types?
16:42Bronsapuredanger: yes, and I think i found one
16:43hiredmanmikerod: that does sound interesting though
16:44amalloymikerod: i imagine you can't share the macro definition?
16:44Bronsa,*warn-on-reflection*
16:44clojurebotfalse
16:44Bronsa,(set! *warn-on-reflection* true)
16:45clojurebot#error{:cause "Can't change/establish root binding of: *warn-on-reflection* with set", :via [{:type java.lang.IllegalStateException, :message "Can't change/establish root binding of: *warn-on-reflection* with set", :at [clojure.lang.Var set "Var.java" 221]}], :trace [[clojure.lang.Var set "Var.java" 221] [sandbox$eval47 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6784] ...
16:45Bronsaoh well
16:45Bronsa(defn f [a] (.divide 1M a nil)) is a repro case
16:45mikerodamalloy: trying to get a shareable version of it
16:46puredangerBronsa: sounds good. would like a patch on there with a test and seemed like a ternary if could have simplified the change quite a bit.
16:49Bronsapuredanger: don't think a ternary would help -- that would make it x.foo? (x.bar() == null? "null" : x.bar().baz()) : "unknown"
16:49puredangeryeah, I guess there's 2 levels there
16:50Bronsathe if is also nice since we can avoid calling .getJavaClass() twice
16:51puredangerdon't care - in a warning
16:51Bronsaoh, right
16:51puredangerwhat if it was ( (arg.hasJavaClass() && arg.getJavaClass() != null) ? arg.getJavaClass().getName() : "unknown" )
16:52puredangerprinting null for a type seems wrong to me
16:52puredangerthe instance is null, could be any type, so "unknown" seems fine
16:53puredangerI'm just trying to get a super simple patch I can screen here
17:04gfrederickswhat's the correct way to make a reducible thing in 1.6?
17:04gfredericksI implemented clojure.core.protocols/CollReduce and that seemed to work
17:05amalloygfredericks: i think that is the way
17:10gfrederickskthx
17:16puredangerthat is a way
17:17gfredericksI tried implementing clojure.lang.Reduce but clojure.core/reduce did not respect that
17:17puredangerif it's a Java class that you can affect directly, extend IReduceInit or IReduce. otherwise extend CollReduce
17:18puredangergfredericks: you mean IReduce?
17:18gfredericks,(reduce conj [] (reify clojure.lang.IReduce (reduce [_ f start] "TWELVE")))
17:18clojurebot"TWELVE"
17:18gfrederickshm
17:18gfredericks&(reduce conj [] (reify clojure.lang.IReduce (reduce [_ f start] "TWELVE")))
17:18lazybot⇒ "TWELVE"
17:18puredangerthere have been changes in reduce in alpha5 around this
17:18gfredericks&*clojure-version*
17:18lazybot⇒ {:major 1, :minor 7, :incremental 0, :qualifier "alpha1"}
17:18Bronsa(inc puredanger)
17:18lazybot⇒ 38
17:18gfredericksyeah on my 1.6 it fails
17:18puredangerbut CollReduce is currently ambiguous in that it catches more than one interface and classes implementing multiple will go an arbitrary path
17:19gfrederickswith not being able to create an ISeq
17:19puredangerin particular things that are IReduce, Iterable, and a seq are a bit of a muddle
17:20puredangerI've talked to Rich about it a bit and we still might adjust some things there before 1.7 releases
17:21Bronsapuredanger: the special casing there is just to pick the fastest path right?
17:21puredangerright now reduce and transduce explicitly check for and use the IReduce paths if they exist before even hitting CollReduce
17:21puredangeryeah, it's all trying to take care of these overlapping cases
17:22puredangerthis is the part of protocols and interface extension that requires some care
17:23gfrederickspuredanger: I assume mixing CLJ-1237 would just make it too complicated?
17:24puredangerpersonally I'd like to have a preference mechanism for protocols like multimethods but Rich has said no to that for now at least
17:24puredanger1237 is, I think, a consequence of various things
17:24Bronsapuredanger: that would be really nice, yeah
17:24puredangerin particular use of concat
17:25gfrederickssure
17:25puredangerala Stuart's "concat bomb"
17:25puredangerso just don't use concat :)
17:26puredangerall of the examples in that ticket I would do in different ways now using into or cat transducers
17:26gfredericks~concat is considered a cat
17:26clojurebotA nod, you know, is as good as a wink to a blind horse.
17:26puredangerclojurebot contains multitudes
17:27gfredericksyeah it's not hard to avoid once you know to avoid it
17:27puredangerif you find yourself ever doing "apply concat" then …. don't
17:28winkclojurebot highlights me a lot lately
17:28puredangerheh
17:28Glenjaminhrm, i did apply concat for something recently...
17:28Glenjamini think it was kwargs
17:28gfrederickspuredanger: that's interesting you put it that way because the classic concat bomb is via "reduce concat" and "apply concat" fixes it
17:29puredangerwell that would replace one with many
17:29gfredericks,(->> (range 100000) (map list) (reduce concat) (first))
17:29puredangerI mean many with one
17:29clojurebot#error{:cause nil, :via [{:type java.lang.StackOverflowError, :message nil, :at [clojure.core$seq__4079 invoke "core.clj" 135]}], :trace [[clojure.core$seq__4079 invoke "core.clj" 135] [clojure.core$concat$fn__4166 invoke "core.clj" 689] [clojure.lang.LazySeq sval "LazySeq.java" 40] [clojure.lang.LazySeq seq "LazySeq.java" 49] [clojure.lang.RT seq "RT.java" 485] ...]}
17:29gfredericks,(->> (range 100000) (map list) (apply concat) (first))
17:29clojurebot0
17:29puredangerso I guess maybe that's not a good formulation
17:31puredangermaybe: don't use concat such that it may be applied an arbitrary number of times?
17:31hiredmanonly be as lazy as you need to be
17:32puredangeror don't be recursively lazy ;)
17:32Glenjaminhas anyone played much with the not-lazy-by-default dunaj stuff?
17:39jdeisenbergI am having problems installing the Cursive plugin with the latest IntelliJ community edition (14.1)
17:39jdeisenbergOr rather, it's installed, but I don't see its settings anywhere in the "settings" dialog.
17:40surrealanalysisI’m playing around with Overtone, but for some reason “kill” doesn’t seem to be loaded into the repl - is there anything I need to do to get it going? Right now I’m only :use-ing overtone.live and a sampled-piano
17:40cflemingjdeisenberg: They're under "Other settings" at the moment, I haven't updated them for the new v14 settings setup yet
17:42jdeisenbergI'm looking at Other settings/ default settings/ Tools -- nothing seems to be there.
17:45zotso i've just scraped together a quick hack interval tree built on sorted-set-by; it took some trial and error (ie, misunderstanding subseq). anybody care to give it a look, and see if I'm setting myself up for tears? https://gist.github.com/benfleis/6bafac50007625aebcef
17:46wagjoGlenjamin: have you? they may be a bit unintuitive to use as they no longer cache computed values
17:46jdeisenbergcfleming: Cursive does not show up under Other settings/configure plugis
17:46Glenjamini haven't had a chance to try it out yet, only read some of the guides
17:47Glenjaminsounds very interesting, it's great to see some experimentation around the core platform
17:49jdeisenbergcfleming: I uninstalled and reinstalled plugin from http://cursiveclojure.com/plugins-14.xml
17:52gfredericksI'm playing around with using CollReduce to represent the results of db queries
17:52hiredman++
17:52gfredericksand I'm not sure which of the various reducey paradigms would apply
17:53gfrederickse.g., if I want to map the results
17:53gfredericksdo I want the map transducer?
17:53gfredericksor some kind of function that takes the reducible and returns another reducible?
17:53gfrederickswhich is different from the transducer since that deals with reducing-functions instead of reducible quasicollections
17:53hiredman(which is clojure.core.reducers/map)
17:54gfrederickshiredman: does that do reducible->reducible without mucking with forkjoin?
17:54hiredmangfredericks: yes
17:54gfredericks(and is it "lazy" in the sense of not doing anything immediately?)
17:54hiredmanforkjoin only happens if you call fold
17:54hiredmangfredericks: yes
17:54hiredmanhttp://ce2144dc-f7c9-4f54-8fb6-7321a4c318db.s3.amazonaws.com/reducers.html
17:54gfredericksthis must be exactly what I want then
17:55gfrederickshiredman: thanks
17:56hiredmantransducers are, I think, strictly better than reducers
17:56cflemingjdeisenberg: You need to change the plugin repo for v14.1: https://cursiveclojure.com/userguide/
17:56wagjoGlenjamin: thank you, I hope Dunaj's experiments will pave the way for feature enhancements in Clojure. Or at least show which way not to go :)
17:57jdeisenbergcfleming: Ah. missed the extra .1
17:57hiredmanbut transducers are more about composing collection operations in to a single operation than passing collections through it, which is a different headspace than you will be in from seqs
17:58hiredmanreducers can do the more familiar apply function, get a new result, apply another function, etc
17:59gfrederickshiredman: yeah I couldn't figure out a natural code structure to use with transducers
18:04hiredmanI haven't used transducers in anger yet, but I have to think the style of build "super operations" could easily lead to sort of layering violations, so the right pattern might be transducer super ops within a "layer", and some abstract reducible thing (CollReduce, IReduceInit, etc) between or something
18:05dnolenBronsa: did CLJ-1677 make into tools.reader?
18:06dnolenBronsa: https://github.com/clojure/clojure/commit/3d216d45b63781586bb79144268bb2fb88dd6f28
18:07puredangerhiredman: transducers do not currently a) work specially with kv stuff or b) do the parallel fold/reduce stuff
18:07Bronsadnolen: no -- I don't think we need it. starting line/col can be changed by using the type ctors rather than the factory functions
18:07hiredmanpuredanger: right
18:07puredangerso transducers are not a superset of reducers capabilities or "strictly" better
18:07puredangeryet
18:07hiredmanpuredanger: the lack of specialness around k/v stuff seems like a feature to me :)
18:08puredangeryes and no :)
18:08puredangerthe specialness avoids intermediate objects so …
18:09dnolencfleming: ^ Bronsa's answer about CLJ-1677 might be interesting to you
18:09Bronsadnolen: I'd take a patch if you need it though
18:09dnolenBronsa: don't need it, but cfleming might
18:09hiredmanhttps://github.com/aphyr/tesser is really neat if you are in to folds
18:09cflemingdnolen: Yeah, thanks - I'll have a go at using that
18:10puredangerhiredman: if use transduce or eduction, you'll get a reducible result which might be useful for the next application
18:10hiredmanpuredanger: ah
18:11puredangerbut you are then explicitly materializing in that step
18:11hiredmanthat may be for the best
18:11puredangerin some cases, yes. depends.
19:35warzhi all. im new to both clojure and emacs. is there a way, in emacs, to bring up the defintion of a function? i realize this is likely difficult, since emacs just seems to operate on files and doesn't quite have a concept of a whole project, etc. (at least in my limited exposure)
19:35warzlike with compojure and ring, i find myself having several chrome tabs open for each project's repo on github, and im constantly going to each functions code
19:36justin_smithwarz: with cider it's M-.
19:36justin_smithwarz: also - here is a trick you can use: go to the top level of the project, and open not any file, but just the directory
19:37justin_smiththen that will open the dired view
19:37justin_smithnext, move the cursor to one of your folders, and type the letter "i"
19:37justin_smiththat will show all files in that directory below the parent
19:42warzhrm, ok i dont think im using cider. i followed the tutorial here: http://www.braveclojure.com/basic-emacs/
19:43warzim familiar with cider too, but i see no ref to it in this
19:43warzmaybe i should try using cider, since it seems to be more common
19:43justin_smithwarz: OK, that's fine, the dired think should work
19:43justin_smithwarz: cider can be a pain in the ass, it has great features, but it breaks a lot
19:46warzdired mode seems pretty powerful, nice
19:49warzoh thats cool, that "i" command
19:49SparkySparkyBoomhiya folks
19:51justin_smithwarz: also, in any emacs window, you can run "M-x describe-mode" to see all the key shortcuts
19:51SparkySparkyBoomis there anything like clojure's thread-first but for java methods that return void?
19:51justin_smithSparkySparkyBoom: maybe you want doto
19:51justin_smithor ..
19:51SparkySparkyBoomthank you
19:52SparkySparkyBoomi just didn't want to repeat the instance variable while setting several internal vars
19:53justin_smithyeah, doto would be the one for that
19:55elvis4526Hello! Put bluntly, what is the difference between (use) and (require) ?
19:55justin_smithelvis4526: require is more more likely to lead to sanity.
19:55hiredman~use
19:55clojurebotOnly use :use with :only.
19:56hiredmanwell, that is outdated
19:56justin_smiththey both modify the current namespace to make another namespace available (and load the other namespace if it hasn't been loaded yet)
19:56hiredmanuse is for all intents and purposes deprecated (I dunno if it is actually marked as such)
19:56elvis4526From what I understand, (:use compojure.route) "import" everything in compojure.route
19:57elvis4526from compojure.route (sorry)
19:57justin_smithexactly
19:57elvis4526What I wouldn't want this ?
19:57justin_smithwell, import is its own thing (it's for classes), but that's the general idea
19:57hiredmanimporting everything like that makes it hard to figure out where parts of functionality come from
19:57justin_smithelvis4526: require is more selective, and if used properly (especially with the :as argument) leads to namespaces that are much easier to refactor
19:59hiredmanit used to be require was to make sure another namespace was loaded, and use was to make the functionality from the other namespace available in the current one without having to namespace qualify the names
20:00elvis4526got it thanks
20:00hiredmanand it proceeded that way for a time, and it was noticed that when using use, because it brought in everything, it made it annoying to read larger code bases, and some rough concensus was reached that require is superior
20:01hiredmanrequire was then enhanced so it now has all the functionality of use, but with better defaults
20:02hiredmanso require can :as, which lets you give a whole namespace a short alias, or :refer [...] which lets you bring in only selected bits, or :refer :all, which acts like use
20:03hiredmanrequire with :refer [...] is the same as the :only option for use that clojurebot mentioned
20:08elvis4526ty
20:09elvis4526Other question: Is there any rules concerning when it is "approriate" to close a sexp ?
20:09elvis4526wait i'll pastebin you something
20:09justin_smithelvis4526: as in formatting rules?
20:09elvis4526yeah
20:09justin_smithno dangling closing brackets
20:10elvis4526http://pastie.org/10053832#5
20:10elvis4526for instance at the end
20:10elvis4526is it okay if I close them all on the same line ?
20:10justin_smithall the close brackets should be on the same line as "js"
20:10elvis4526Oh really?
20:10justin_smithyeah
20:11justin_smithalso, line 3 shouldn't be empty
20:11justin_smiththat rule isn't as strict though
20:11elvis4526Later if I wanna add something after, let's say [:head
20:11elvis4526it's a lot easier when closing brackets are on seperate line
20:11elvis4526I can spot right away where to add it
20:11justin_smithelvis4526: hopefully your editor can handle such a complex operation
20:12elvis4526yeah I should definetly install paredit...
20:12justin_smithelvis4526: many of us use structured editing (eg. paredit)
20:12justin_smithyeah
20:21ambrosebswhich version of asm is clojure.asm?
20:23Bronsaambrosebs: 4.1
20:23ambrosebsand more importantly do I want to use it for bytecode manipulation?
20:23Bronsaambrosebs: in clojure 1.7 at least
20:23ambrosebsI want to add a field to a existing classes
20:23ambrosebsok
20:26hiredmanthe version of asm in clojure, at least at one time, was a stripped down version
20:27ambrosebsright maybe I'll start out with the official asm jar instead
20:27geolCan someone please tell me how to define implement a protocol for anything which implements IMap
20:28hiredmanwhat is IMap?
20:28geolmap? uses (satisfies? IMap)
20:29hiredmannot in clojure
20:29hiredmanyou must be talking about clojurescript
20:29geolInteresting. I'm in CLJS land
20:30geolShould I be in another group?
20:30hiredmanI dunno, people do ask cljs questions here
20:30amalloygeol: here is fine, but you should at least clarify when you are asking questions that aren't actually abotu clojure
20:30justin_smithgeol: so, instead of using IMap you want to make another protocol that will be extended to IMap?
20:30geolyes, that's the idea
20:31geolI'm writing a custom zipper and extend-type seems ugly
20:31justin_smithgeol: in that case, make the protocol like usual, and then extend IMap to that protocol
20:31geolreally! huh, thanks.
20:40geol@justin_smith: mind looking at this please... I'm not having much luck. https://gist.github.com/olivergeorge/33cc516026bc57abd0bd
20:43justin_smithgeol: you are using functions in there that IMap doesn't define
20:50Bronsageol: you can't extend a protocol to a protocol
20:51geol@Bronsa: ah, that's what I was guessing. thanks.
20:51geol@justin_smith: I think I had the IMap and IFieldZipper backwards... but I suspect also it's not possible. thanks for your help.
20:51Bronsageol: also you don't need to use "@" when talking to somebody in IRC :)
20:52geoloops!
20:52justin_smithBronsa: oops, I totally forgot about the not extending protocols to protocols thing
20:53Bronsajustin_smith: it's kind of unfortunate that we can't do that
20:53justin_smithgeol: wouldn't it suffice to write your zipper function such that it calls the protocol methods in the protocols you are targeting?
20:55geolI think I understand. Effectively a switch statement on (map?) and (coll?)... yes, i think that works.
20:57justin_smithgeol: you could even use a multimethod, which can be made to dispatch on class
20:57geoljustin_smith: yes, I considered that. For now my (cond (map? x)...) approach is probably all I need
20:57geolThanks for the help
21:18gfredericksdeleting 185 LOC of clojure is like deleting 2000 LOC of java
21:19Shayanjmtrue that
21:39ShayanjmNeed some advice re: how to approach this problem properly. I'm trying to generate x-y coordinates (corresponding to center points of circles) in a certain configuration. Here's a diagram (sorry if it's messy) of what the configuration looks like: http://puu.sh/gPNn8/474f8f7f7f.jpg
21:39ShayanjmIn that image I've also written the proposed output that a function would generate given a start point {:x x :y y}, and number of layers n. At n = 0, for instance, it would return [[start-point]]. At n = 1, it would return [[start-point] [x-y coords of circles in layer 1]].
21:40ShayanjmI know how to calculate the vector for the next layer given the previous one, but I don't know how to properly string it all together to return one large vector of all layer coords
21:40Shayanjmany direction would be great :)
21:44justin_smithShayanjm: you could use iterate to generate the consecutive layers, and just grab the last layer you are interested in
21:44justin_smith,(nth (iterate inc 0) 100)
21:44clojurebot100
21:45Shayanjmjustin_smith: the function I wrote to generate the next layer requires the previous layer as input
21:45Shayanjmmy brain just can't
21:45justin_smithShayanjm: that's what iterate does
21:45Shayanjmseriously?
21:46Shayanjmoh fantastic
21:46mavbozo,iterate
21:46clojurebot#object[clojure.core$iterate "clojure.core$iterate@8445e42"]
21:46mavbozo,(doc iterate)
21:46clojurebot"([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"
21:46justin_smithShayanjm: ^ that describes what you need, right?
21:47justin_smithyou just take the nth from that
21:47Shayanjmyup that's excellent
21:47justin_smithor you could take from it until the vector has N items
21:47justin_smithor whatever
21:47Shayanjmthanks justin_smith - this solves it i think
22:01Shayanjmjustin_smith: I'm getting a null pointer exception when i try to use iterate
22:01Shayanjmgisting, 1 min
22:01justin_smithShayanjm: that indicates to me that at some point your function returns nil?
22:02Shayanjmjustin_smith: it should not
22:03turbofailthat's the beauty of nil though. it shows up whether it should or not
22:03Shayanjmjustin_smith: https://gist.github.com/shayanjm/51cd5cbfc7e030798b3f
22:04justin_smithShayanjm: why do you give it hash-maps in the examples that work, and a vector in the example that doesn't work?
22:04justin_smithmaybe you wanted a hash map inside that vector?
22:04Shayanjmsorry it was a typo
22:04Shayanjmi edited the gist
22:05ShayanjmI passed it a hash map in reality
22:05justin_smithShayanjm: you function does not take the same kind of data it returns
22:05justin_smiththere is an extra () around the output
22:05Shayanjmoooooh
22:05justin_smithto use iterate, it has to take exactly the sort of data it returns
22:05Shayanjmyou're right
22:06justin_smithalso I think that list outside is totally pointless
22:06ShayanjmIt probably is. is it better to use lists then?
22:06justin_smiththat's not what I said
22:06Shayanjmor sequences*
22:07justin_smithI'm just saying the extra () is doing nothing, so stripping it in generate-next-layer (or not generating that outer list) should just fix things
22:07ShayanjmOops I misread what you said, I thought you meant vector when you said list (python on the brain)
22:07Shayanjmyeah the extra () was an accident
22:07justin_smithor, if it really needs to be there, you can change it to (iterate (comp generate-next-layer first) ...)
22:21elvis4526How do you render an attr without any value in hiccup ?
22:21elvis4526like <mytag attr>
22:22justin_smithelvis4526: that should be equivalent to <mytag attr=true>
22:22justin_smithright?
22:22elvis4526ahhh makes sense
22:27elvis4526{:attr true} makes it attr="attr"
22:33justin_smithelvis4526: I was going by this http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#boolean-attributes
22:33justin_smithelvis4526: so yeah, attr="attr" is correct, looking at that page
22:37elvis4526oh cool
22:37elvis4526thanks