#clojure logs

2014-07-01

00:29fowlslegsDoes anyone know how to find out for what range of values the minimal binary representation of a java.math.BigInteger is less than 512 bits?
00:44cespareHow could I return a clojure vector from a function implemented in Java? Or alternatively, what type could I return that would be most efficient to call vec on in a clojure wrapper function?
00:45dat_eye_sockethiredman, I came to apologize.
00:45dat_eye_socketAbout 6 years back or something, I was sceptical about having an actual list datatype instead of just working with cons cells.
00:46dat_eye_socketI realized about 3 years back I think how wrong that idea of mine was and that an actual list datatype is one of the few things CLojure has one up on on Scheme.
00:46dat_eye_socketWell, not apologize, that's stupid
00:46dat_eye_socketbut admit I was wrong
00:46kristofdat_eye_socket: What do you mean an "actual list datatype" instead of cons cells?
00:47dat_eye_socketkristof, in common lisp and scheme, there is no list datatype, interestingly enough.
00:47dat_eye_socketThere is a datatype called pair, which is basically a vector of length 2, both slots can contain anythinhg
00:47dat_eye_socketwhich is used to make ad-hoc lists.
00:47kristofdat_eye_socket: That's not an ad-hoc list, that's a list. :)
00:47dat_eye_socketAnd list? as a praedicate actually has to test the structure, walking from left to right.
00:47dat_eye_socketAn ad-hoc list is a list.
00:48dat_eye_socketIt would also be a list if you used [1 [2 [3 [4 []]]]] in Clojure with vectors
00:48dat_eye_socketBut it would still be ad hoc.
00:48dat_eye_socketthe point is, that in clojure, list? runs in constant time and is an actual tag and there is a guarantee that the cdr of te cell is also a list
00:48kristofA vector isn't the concatenation of smaller fixed sized arrays, so that isn't quite accurate.
00:48dat_eye_socketThe above isn't a vector.
00:49dat_eye_socketWell, it's that too.
00:49kristofOh, I see what you mean.
00:49dat_eye_socketBut it's mostly a datastructure with two cells, what I used it atl.
00:49kristofSo clojure boxes its data structures?
00:49dat_eye_socketYou need a minimum of two cells in a datastructure to make your list.
00:49dat_eye_socketkristof, all datastructures in clojure are Java objects, so yes.
00:50dat_eye_socketThe thing is, in clojure to guarantee something is structurally a list, one only needs constant time.
00:50dat_eye_socketIn Scheme and Common lisp one needs linear time, which is why often it is not checked before application and you just have faith.
00:51dat_eye_socketThis is explicitly allowed by the standard.
00:51kristofdat_eye_socket: I see what you're saying and I don't question that you probably find this useful, but I can't think of a case where I'd be passed a tree instead of a linked list and would need to explicitly check for something like that.
00:52dat_eye_socketkristof, well, people make errors is what I mean.
00:52dat_eye_socketIn any case, you do need to somerimes ask list? in CL or Scheme
00:52dat_eye_socketAnd that is linear, in Clojure it is constant
00:53kristofdat_eye_socket: I'm pretty sure that listp in common lisp is constant time. It just checks to make sure that the first element is a cons type.
00:54dat_eye_socketkristof, isn't that pairp?
00:54kristofIt's actually consp, I was mistaken
00:54dat_eye_socket(listp (cons 1 2)) => true
00:54kristofEven so, when I use listp, I'm checking to see if something's NOT a list, not if it is one.
00:54dat_eye_socketOh wow
00:55dat_eye_socketThat is pretty bad.
00:55dat_eye_socketSomething can be not a list, such as (cons 1 2)
00:55kristofcons 1 2 is a list
00:55kristof:)
00:55dat_eye_socketAh, oh well, in Scheme it is not.
00:55kristofOnly familiar with common lisp, sorry.
00:55dat_eye_socketIT's only a list in scheme if it's an empty list or a cons cell whose cdr is a cons.
00:55dat_eye_socketwhose cdr is a list*
00:56kristofA dotted pair is kind of a list! Sort of. :P
00:56dat_eye_socket(1 . (2 . (3 . 4))) doesn't count
00:56dat_eye_socketWell, many functions which assume nil termination don't work on it I guess.
00:56kristofWell that's why people use pairs only when they know ahead of time that they're expecting a pair. :)
00:57dat_eye_socketWhat if you make some kind of other data structure from a pair that is not a list.
00:57kristofThat sounds complicated, which falls under "know ahead of time"
00:57dat_eye_socketBut I certainly like that in clojure every time you cons it verifies that the last element is a list as well.
00:57dat_eye_socketHmm.
00:58dat_eye_socketCommon lisp was never one for type safety as much as Clojure and Scheme are though.
00:58dat_eye_socketI like my functions to barf as early as possible when I made an error some-where and the type is wrong.
00:59kristofI'm not sure what you're talking about.
00:59pdkcl typedefs are pretty much for optimization
01:00kristofWhat I meant was that if you cons anything to anything, you construct cells. You don't need to "guarantee" that the last element is a list.
01:01dat_eye_socketkristof you do need a proper list, how do you wish to otherwise disambiguate the case that the last element of a list is simply a cons cell
01:02kristofOh, that's what you mean.
01:02dat_eye_socketlists can contain cons cells. Say you have an improper list and you want its last element to be a cons cell.
01:02dat_eye_socketThat's am ambiguity then
01:07kristofI suppose
01:20cj3kimHi. How do I drop any value in a vector? On a side note, how come my loop function doesn't work? https://gist.github.com/cj3kim/79e8f67ee0d0f1f613ac
01:25gfixlercj3kim: dissoc?
01:26gfixleror subvec? http://stackoverflow.com/questions/1394991/clojure-remove-item-from-vector-at-a-specified-location
01:26cj3kimi tried subvec gfixler
01:26gfixlerno luck?
01:27cj3kimit simply returns the dropped values
01:28gfixlerthere aren't enough parentheses in your gist example
01:36TEttingercj3kim: ##(let [v [10 11 12 13 14]] (concat (subvec v 0 5)(subvec v 5)))
01:36lazybot⇒ (10 11 12 13 14)
01:36cj3kimthanks
01:36TEttingercj3kim: ##(let [v [10 11 12 13 14]] (concat (subvec v 0 2)(subvec v 2)))
01:36lazybot⇒ (10 11 12 13 14)
01:36cj3kimsolved :)
01:36TEttingerwait crap
01:36TEttingercj3kim: ##(let [v [10 11 12 13 14]] (concat (subvec v 0 2)(subvec v 3)))
01:36lazybot⇒ (10 11 13 14)
01:36TEttingerthere we go
01:36TEttingerneeds to have the second subvec incremented
01:47cespareHow could I return a clojure vector from a function implemented in Java? Or alternatively, what type could I return that would be most efficient to call vec on in a clojure wrapper function?
01:52cesparefor instance, right now my java function returns an ArrayList but doing (into [] array-list) is slower than I'd like and also increases with the size of the ArrayList.
01:53cespareSo I'd like to do better than that.
02:00TEttinger,(class [])
02:00clojurebotclojure.lang.PersistentVector
02:03TEttingercespare: there's a bit of an example in the src https://code.google.com/p/clojure/source/browse/trunk/src/jvm/clojure/lang/PersistentVector.java#339
02:04cespareTEttinger: ah, ok. Right now my java code makes an ArrayList, adds some items, and returns it -- I guess I can just use a PersistentVector from the beginning.
02:04cespareor a transient and return v.persistent()
02:04TEttingerer, https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentVector.java#L736 is newer
02:15cespareWhy does (= s "") take ~50ns? I can't seem to find a faster way to check if a string is empty.
02:19ddellacostacespare: not positive but I believe (.isEmpty "") is going to be the fastest
02:20TEttinger(.isEmpty s) you mean?
02:20Frozenlo`,(time (clojure.string/blank? ""))
02:20clojurebot"Elapsed time: 0.044849 msecs"\ntrue
02:20cespareddellacosta: ah yeah perfect. about 6ns
02:20cespareI had been trying (= s "") and (= 0 (count s))
02:21ddellacostacespare: yeah, in general you're probably going to want Java for that kind of stuff, if you're trying to squeeze out the last bit of performance possible
02:21TEttingercount would have to do a lot more steps, right? since strings aren't exactly seqs, they just convert to them
02:21ddellacostaTEttinger: yeah, I think everything else is handling a lot of edge cases. If you know you have a string, then best to just go low-level
02:22cespareTEttinger: I guess? Speed seemed almost identical to (= s "") for some variously sized strings.
02:22TEttingerhuh
02:22cesparei didn't do an exhaustive test though.
02:22TEttingermaybe it does an element-wise compare
02:23cespareddellacosta: yup, I'm writing gross java-clojure (lots of java calls and transients) and i'll probably try writing the function in java as well after I benchmark.
02:23cespareit's pretty small and self-contained.
02:23clojurebotCool story bro.
02:23cesparehaha
02:24ddellacostacount has to perform dynamic dispatch, that's going to make it slower right off the bat.
02:25ddellacostaer, sorry, that's not the right way to put it
02:27blur3dI’m trying to convert a 4 byte array into a float in clojure. I’m guessing Java interop would be the best way. How do I convert the following java into clojure
02:27blur3dbyte[] bytes = { }
02:27blur3dfloat f = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getFloat();
02:34blur3dI think I got most of it worked out
02:34mangeblur3d: Something like (let [bytes (byte-array [0 0 0 0])] (.. (java.nio.ByteBuffer/wrap bytes) (order java.nio.ByteOrder/LITTLE_ENDIAN) getFloat)) ?
02:34blur3d(import [java.nio ByteBuffer])
02:35blur3d(.getFloat (. ByteBuffer wrap (byte-array [0 0 0 89])))
02:35blur3dmange: thanks, I’ll give it a go… I’m not too familiar with java or interop
04:49sveriHi, I am trying to setup a websocket connection with http-kit and it fails because it gets server error 500 as a response: http://pastebin.com/qZX3ceBT Any Ideas what might be wrong here?
05:02sverinever mind, seems like I missed some ring middlewares, just dont know which one yet
05:18asmalaI’m looking for resources on Clojure web app deployment. After a couple of hours of googling, I found the “DevOps Done Right” video by Vince from Room Key, but not much else. Any tips?
05:20asmalaThe app in question would be a fairly simple all-Clojure stack, running a single-page ClojureScript app on the front-end and using Datomic for storage
05:57augustlasmala: the story is pretty similar to all JVM web apps
05:57augustlasmala: you can choose between embedding jetty or creating a war for a container :)
06:00asmalaaugustl: thanks, good point. I could just start looking resources for Java deployments. Ideally though I’d like to see something along the lines of “Use Pallet for config management, with a local VirtualBox testing environment and a CloudFormation-driven production/staging environment. And here’s how:”
06:07ddellacostaasmala: unfortunately I don't think there's many great resources for this yet out there. I've had trouble myself getting pallet going from scratch. In my day job we simply have some scripts that get things up and running.
06:08ddellacostaasmala: of course, Heroku makes it pretty nice to deploy clojure web apps if that's a solution you can consider.
06:11asmaladdellacosta: yes, that could work. I’m familiar with it from my previous life doing (primarily) Rails apps. I feel drawn to AWS, though, given the more flexible scalability scenarios and DynamoDB for Datomic.
06:12ddellacostaasmala: I mean, it's been about six months since I tried using Pallet seriously. And my issues at that point mostly had to do with the fact that I'm trying to deploy from Asia...I think. Not that that's a ringing endorsement or anything, but probably still work trying to get Pallet going if you want to use AWS.
06:12asmaladdellacosta: haha, gotcha. Thanks for the heads up though.
06:13ddellacostaasmala: np. Have you tried the pallet tutorial, btw? Seems like it could be pretty nice (it's nicer than last time I tried it): http://palletops.com/pallet/doc/first-steps/
06:14asmalayeah, I checked it out earlier today. looks like a good starting point
06:15ddellacostaasmala: well, I wish you luck--and I would add, if you *do* get through deploying with AWS via Pallet, documenting what you've done for the community would be super appreciated, I'm sure!
06:15asmaladdellacosta: aye, definitely planning on a post or three if/when I figure out a good way to do it
08:15ssiderisclgv: shouldn't be too hard
08:16clgvssideris: well in my vision it should be directed toward replacing LaTeX and compiling to plain TeX
08:16ssideriserm, that *does* sound a bit harder
08:16clgvssideris: so that it has a backwards compatible layer for the transition phase
08:17ssiderisbut why would you do it like that, what's wrong with latex?
08:17clgvssideris: you didnt use it that much right?
08:18clgvssideris: it has no proper modularity concept. latex packages can be incompatible with each other and in fact are incompatible often
08:18ssiderisclgv: I wrote my whole PhD in latex, so yes, I've used it a bit :-)
08:18clgvvisualizations, pseudocode or other stuff may work in articles but suddenly dont in beamer
08:22clgvssideris: well than you should have experienced the pain ;)
08:23clgvssideris: and for visualizations or animations you actually program in LaTeX but that's painful as well
08:23clgv+can
08:28ssiderishm, maybe I was a bit conservative with my packages etc, but I don't remember a painful experience
08:31clgvssideris: than you were lucky ;)
08:31clgv*then
08:33ssiderisit looks like I was
08:33ssiderisso are you starting with the DSL?
08:33clgvI am using TikZ a lot for visualizations. anything that goes beyond a for loop is just painfull
08:34clgvprobabaly not since I got no time. that PhD document isnt writing itself meanwhile ;)
08:40ssiderisPhDs are the main target demographic for latex :-)
09:00n|kHi there! The VimClojure plugin should automatically add closing brackets by default, shouldn't it?
09:02ambrosebsn|k: no, there's a separate paredit plugin I think
09:02n|kambrosebs: I see, thanks!
09:04n|kambrosebs: yeah, the paredit plugin did the trick
09:11dave-7Hi, I'm new to clojure and running through the basic om tutorial at the moment. I'm at the part where you add an event listener to the input field, and I'm not sure what the 'e' argument is to handle-new-contact-change (the event listener). Is it some kind of a ref to the input field's dom node?
09:12mnngfltgHello. I'm trying "lein repl" but my core.clj is located in `subdir/src/myproject/core.clj` rather than `src/myproject/core.clj`. But leiningen doesn't find my source file.
09:13mnngfltgI've tried :source-paths ["turbod/src"] in project.clj, but it didn't make a difference
09:16nikolapdave-7: I believe that's an event object every handler receives as an argument (i.e. https://facebook.github.io/react/docs/events.html)
09:16mnngfltgDoes anyone have an idea? It gives me: Could not locate myproject/core__init.class or myproject/core.clj
09:19mnngfltgOh! Now I made it work with ["myproject/src"]. Strange.
09:21dave-7That makes sense, thanks nikolap!
09:22jonathanjhrm, where can i put resources for tests (like files) and how do i reference that path from my tests?
09:26nikolapdave-7: sure thing! it may be worth noting that you can always do a (.log js/console some-var) to dump the thing to the browser console. if it's a Clojure data structure, dumping (pr-str some-var) might be more useful. :)
09:27dave-7mnngfltg: I think lein only checks the folders you supply to :source-paths and one layer deeper. (ie. if :source-paths is "some/dir/", putting core.clj in "some/dir/" or "some/dir/here" will work, but putting it in "some/dir/here/again" won't.)
09:28mnngfltgdave-7: got it
09:29mnngfltgIt's a bit surprising that `lein` doesn't have real documentation, just a sample project.clj file.
09:30bhaumanmnngfltg: there is documentation
09:31bhaumanmnngfltg: look in the doc directory on github
09:32hyPiRiondave-7: lein checks the source paths and all the subdirectories recursively
09:32bhaumanmnngfltg: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md
09:32mnngfltgbhauman, thanks, I'll have a look
09:41blur3dHow would you extend a multi-method that is private and part of a dependancy using defmethod? Is it possible, or would it have to be public?
09:42silasdavislooks like reverse on a vector does not call rseq
09:42silasdavisis there any reason why that is?
09:42blur3dhere is some example code http://pastebin.com/2hFtfDT1
09:42silasdavis(reduce1 conj () coll)
09:42silasdavisis implementation
09:45fowlslegs,'((biginteger 8))
09:45clojurebot((biginteger 8))
09:45alandipertblur3d, i'd be very surprised if it wasn't possible
09:45fowlslegsHow could I rewrite this such that it returns '(8)?
09:46fowlslegsNevermind
09:46dave-7hyPiRion: thanks
09:46blur3dyeah, I’m just not sure how multimethods work across namespaces, nor how private effects them
09:53alandipertblur3d, https://gist.github.com/alandipert/a383318cff6f21d309a3 - the trick is the @#' to locate and deref the private Var
09:54blur3dalandipert: nice :) thanks
09:56blur3dI always find it insane how function programming can solve everything
09:56blur3dmake you wonder where we went so wrong, and why OO is what it is
10:47FrozenlockIs there a way to prevent cljs stuff to be included in a uberjar? Getting an extra 13mo from google is really annoying.
10:49perplexahai. when i have a function x and i want to override that function in a different function, how would i do that? cos just saying (let [x (newx "arg")]) would make x not callable.
10:49perplexaand i end up getting null pointer exceptions ofc ;x
10:50Frozenlockperplexa: I'm not sure of what you are trying to do, but [x #(newx "arg")] should be callable.
10:51perplexaFrozenlock: yeah, thanks
10:52fowlslegsCan someone tell me what the funk is going on here?
10:52fowlslegs,((fn [funk] (funk (biginteger 1) (biginteger 2))) '.xor)
10:52clojurebot2
10:52fowlslegs,(.xor (biginteger 1) (biginteger 2))
10:52clojurebot3
10:53cbpthe first one is equivalent to ##(:a {} :default)
10:53lazybot⇒ :default
10:53cbpbut with a symbol instead of keyword
10:54cbp,('.xor {} :default)
10:54clojurebot:default
10:54cbpyou cant pass methods around as functions
10:54cbpyou need to wrap them in a function
10:55fowlslegs,((fn [funk] (funk (biginteger 1) (biginteger 2))) #(.xor % %2))
10:55clojurebot3
10:56fowlslegsNow that's fuuuunnnnnnkkkkkyyy!
10:56fowlslegsYou're welcome for being the cheeziest human being on Earth. And thank you cbp.
10:57silasdavisI didn't know symbols were ifn...
11:01Glenjawork,(doc memfn)
11:01clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. name may be type-hinted with the method receiver's type in order to avoid reflective calls."
11:33pjstadigare there API docs for ClojureScript anywhere?
11:46Frozenlockpjstadig: sure, it's #clojure :-p
11:52quangquachia /msg NickServ identify 05051989
11:54vermaI wonder if there's a better way of doing this: https://gist.github.com/verma/304538e144216453809a
11:54vermabasically I am iterating over a list of strings (and then over each character) and mapping it into a tile-set and blitting it out
11:54vermalooks ugly as hell
11:55vermaI need to keep track of rows and columns because I need them to figure where the destination for blit is, wonder if there's a cleaner way for doing this
11:58pjstadigFrozenlock: if only it was
12:02cbpverma: change (iterate inc 0) for (range), combine both doseqs and change (get symbols c) for (symbols c)
12:11arrdempuredanger: I agree that the "namespace" and "name" of a Var is chasing a pointer the wrong way, however there are cases in which it's valuable to do so especially when Bronsa and I are playing with resolving and manipulating bindings.
12:12arrdempuredanger: I mean thanks to Bronsa I've got snippets for doing this that work (obviously) but since the printing format of a Var shows name and namespace I would have expected that those values would be trivially exposed via name and namespace.
12:20puredangerarrdem: I understand what you're saying and think it's a reasonable question
12:21mnngfltgWhen running a webserver with compojure in the REPL, I cannot seem to re-run (defoutes); the changes don't take effect unless I restart the REPL. Is there a workaround for this?
12:21koreth_Is there a good way to make Leiningen execute code before the REPL starts accepting user input but after the NREPL service is started? :init seems to be run before NREPL and anything long-running in there causes Leiningen to time out and exit.
12:22cbpmnngfltg: make sure the ring handler gets the var, as in (serve #'my-routes ..)
12:23Frozenlockmnngfltg: Like cbp said (jetty/run-jetty #'app ...
12:27johnwalkerhas clojure seen performance improvements with java 8?
12:29mnngfltgcbp, Frozenlock, hmm, I don't get it
12:29mnngfltghttps://www.refheap.com/87732 -- it doesn't work that way
12:29puredangerjohnwalker: yes. I usually see about 5-10% improvement on Java 8.
12:30mnngfltgAhh.. I need to reload (def app ...) as well as (defroutes ...)
12:30mnngfltgI guess I'm not clear on how the vars/macros/functions interact :)
12:32johnwalkerpuredanger: thanks. what parts of clojure do you think got faster?
12:33puredangerjohnwalker: I don't think any specific thing got faster, just that java 8 is generally faster on things most programs do (constructing and allocating objects, optimizing locks and locals, etc)
12:33mnngfltgOr I can simple re-evaluate the current buffer, which also works.
12:33mnngfltgThanks! :)
12:34puredangerjohnwalker: you might find these graphs interesting http://jafingerhut.github.io/clojure-benchmarks-results/Clojure-expression-benchmark-graphs.html
12:34puredangerjohnwalker: take them with the usual grain of micro benchmarking salt
12:34johnwalkerright
12:35johnwalkerthanks again :)
12:35johnwalker(inc puredanger)
12:35lazybot⇒ 2
12:35johnwalkerwow that should be a lot higher. does it reset nightly?
12:35puredangerha, no I don't hang out here much
12:35puredangerI usually just read the logs :)
12:35johnwalkerlol
12:39Frozenlockpuredanger: Wow... so much data pron
12:42puredangeryeah. I consider the 32-bit stuff to be noise - we really don't care for Clojure. Most of the intermediate releases are uninteresting but admittedly, they do tell a story that is sometimes important.
12:46puredangerand as always props to Andy Fingerhut for maintaining those tests
12:46mdrogali`He's a champ.
12:47hyPiRionpuredanger: I think both you and Andy do an amazing job.
12:47puredangerwell thank you but the difference is that I'm paid for it and he's not so props to him
12:51hyPiRionheh, I just wanted to say thank you for the work you're doing. I feel many people don't know how important the work you two do is.
12:52bbloomhyPiRion: dammit, you can thank puredanger by letting him be modest
12:52bbloom:-)
12:53vermacbp, nice, thanks, how do I combine doseqs?
12:53hyPiRionOkay okay, sorry :p
12:53mdrogalishyPiRion: When do I get a copy of your thesis? ;)
12:54mdrogalisCome back I want to read your freakin' paper! :P
12:54arrdemmdrogalis: I thought it was done already..
12:54cbpverma: ##(doseq [x [[1 2] [3 4]] y x] (print x))
12:54lazybot⇒ [1 2][1 2][3 4][3 4]nil
12:54cbper print y
12:54cbpyou get the point :-P
12:54mdrogalisarrdem: *Shrug*
12:54vermacbp, trying :P
12:55vermacbp, hmmm, that form is new to me :P
12:56vermacbp, checking docs
12:57vermacbp, oh that's badass
12:58verma##(doseq [x [[1 2] [3 4]] y x] (print y))
12:58lazybot⇒ 1234nil
12:58vermacbp, naice .. trying
12:59dave-7I'm having some trouble getting secretary going. I've included the dependency in project.clj and restarted the server, so it's got the files, but when I run it through lighttable it tells me "Could not locate secretary/core__init.class or secretary/core.clj on classpath:"
12:59symfrogHas anyone attempted to use closure IframeIo for file uploads? I am using it and everything is working fine except timeouts and connection refused scenarios are not triggering registered events (goog.net.EventType.TIMEOUT) even after setting a timeout interval with setTimeoutInterval.
13:00hyPiRionmdrogalis: It is done, I just want to finish moving, and make some parts of the thesis independent of other papers behind paywalls
13:01hyPiRionI don't like paywalls.
13:01mdrogalishyPiRion: Got it :)
13:01mdrogalisWhere're you moving?
13:02hyPiRionmdrogalis: moving from Trondheim to Oslo (cities in Norway)
13:03mdrogalishyPiRion: Cool :D
13:04alexhbg2hi
13:05{blake}I have a structure of {:parent ({:child ...stuff1...}{:child ...stuff2...}{:child ...stuff3...})} and I want to turn that to {:parent :child (...stuff1... ...:stuff2... ...:stuff3...)}.
13:05{blake}(Is that "slurping"?)
13:06alexhbg2Could someone explain this code to me: (defmacro defscreen [n & {:keys [] :as options}]
13:06alexhbg2dont understand whats going on insde the [ ] brackets
13:07aperiodic{blake}: no, slurping is reading bytes in from a resource such as a file or InputStream
13:07{blake}aperiodic, thanks!
13:07aperiodicsorry, not bytes, a string
13:07aperiodic{blake}: also the thing you want to turn your map into is not a valid map, so that might be difficult
13:09{blake}aperiodic, Well, I have a map of sequences where child sequences have common keys, and I want to draw that key up, but keep the sequences beneath it. This is so I can use "get-in".
13:09hyPiRion{blake}: is ##(let [m {:parent '({:child :foo} {:child :bar} {:child :baz})}] (update-in m [:parent] (partial map :child))) sufficient?
13:09lazybot⇒ {:parent (:foo :bar :baz)}
13:10{blake}hyPiRion, heh...I don't know. Let me grok it. (What's the ## for?)
13:10silasdavisI'm using ordered-map from https://github.com/amalloy/ordered, wondering if it will work with clojurescript
13:10hyPiRion{blake}: ## is to make lazybot evaluate it
13:10silasdavisdoes anyone have an idea?
13:10aperiodicalexhbg2: it's a destructuring statement, that assumes all arguments besides the first are key-value pairs that make up a map named `options`. the empty keys binding is pointless and should be omitted
13:10hyPiRionso ##(+ 1 2) makes lazybot print 3
13:10lazybot⇒ 3
13:10silasdavisI've not really used clojurescript before
13:11{blake}hyPiRion, Duh. Thanks. =P
13:11hyPiRionnp
13:11aperiodicalexhbg2: also, in my experience the "rest args as implicit map" pattern is more trouble than it's worth and you should just pass around options maps explicitly
13:13alexhbg2aperiodic: cheers. this is from the play-clj source code. but being new to clojure im just trying to understand it
13:13{blake}hyPiRion, My starting point is a vector of maps, where any given value of a key may itself be a vector of maps.
13:13aperiodicalexhbg2: you can read more about destructuring here: http://clojure.org/special_forms#binding-forms
13:14{blake}hyPiRion, So I can't enumerate the children explicitly, and I'm applying this recursively.
13:14alexhbg2thanks!
13:14{blake}"In any case where there are multiple maps containing the same key, draw that key up and turn the values for that key into a single sequence."
13:16{blake}So I can say "get-in :grandparent :parent :child" and get back a sequence of all values for that branch.
13:16{blake}I'm positive this is easy; I'm either looking at it wrong or just ignorant of the right...thing.
13:17aperiodicyou can use a very slightly modified version of what hyPiRion used above
13:17{blake}Update-in, maybe where I take the existing value and add to it?
13:17aperiodicalthough it may be more appropriate to use group-by here
13:17{blake}aperiodic, Oh, yeah, group-by...that might do it.
13:25{blake}OK, I think I need to take a step back. I have some XML I'm simplifying with this: https://www.refheap.com/87735
13:26{blake}Wait...okay, I could group-by the results of this by pulling off the keys of the resultant sequences. I think that'll work.
14:15jjcomerIf you make a blocking call in a go-block do the underlying mechanics of async kick in or does it actually tie up the thread?
14:15timjjcomer: there are no "underlying mechanics of async"
14:15tbaldridgejjcomer: you will block the thread.
14:16tbaldridgeThe only "async" ops are alt!, >! <! and put!
14:16jjcomerperfect, that answers my question
14:35_99hats_09:21 <koreth_> Is there a good way to make Leiningen execute code before the REPL starts accepting user input but after the NREPL service is started? :init seems to be run before NREPL and anything long-running in there causes Leiningen to time out and exit.
14:35koreth__99hats_: I am writing a Leiningen plugin to do this, having found no better approach. Luckily it's a really simple plugin.
14:36_99hats_Hi folks! Abt how long does it take to go through Clojure Koans? (n00b)
14:45puredangerthe koans live on within you forever
14:46_99hats_puredanger: good answer ;)
14:46puredangerseriously though, an experienced Clojurist could probably do them in 20 minutes or so? (anyone?)
14:46puredangerand depending on your noobiness and how much time you spend seeking your answer, maybe an hour or two
14:47puredangercertainly I see many people asking here, google group, and stack overflow about the questions
14:48_99hats_that's helpful, I was afraid it was 10-20 hours of material
14:48puredangerI have no idea if any of those times is actually reasonable. surely someone here has done them recently?
14:48puredangerno, I don't think so
14:48amalloyjust looking over them for the first time ever i'd say puredanger has underestimated the time for newcomers and for experienced users
14:49koreth_Definitely not 10-20 hours unless you get stuck on a concept at some point. I did them after learning the basics of the language elsewhere and it took me a couple hours.
14:49puredangeramalloy: it's been a while and I would not be surprised at that :)
14:49Raynesis cider-show-error-buffer an illusion or something?
14:49RaynesIt appears to do exactly nothing when I change its value.
14:50cbpRaynes: when it's t and you get an exception a buffer appears
14:50puredangerkoreth_: thanks, that's a helpful benchmark
14:50Raynescbp: When it's nil and I get an exception a buffer appears.
14:50RaynesSo
14:50Raynes:(
14:50puredangerDoes http://clojurescriptkoans.com/ have everything from Clojure Koans?
14:51RaynesI posit that it doesn't give a shit what I think.
14:51_99hats_Yes, thanks puredanger koreth amalloy
14:52RaynesOh there we go.
14:52Raynescbp: I had an older version of cider hanging around in a sekrit directory deep within the bowels of hell.
14:53RaynesNow it isn't even producing a repl after cider-jack-in.
14:53RaynesSo that's cool.
14:53Raynesamalloy: I'm suddenly missing SLIME, man. It's crazy.
14:54technomancythe cider from marmalade is pretty stable
14:54RaynesI think that's what I have.
14:54Raynesso (setq cider-show-error-buffer nil) = works
14:54Raynes(setq cider-show-error-buffer 'except-in-repl) does not.
14:55technomancyRaynes: I have that version but that var doesn't exist here
14:55technomancyso I'd guess you're on something newer
14:58Raynestechnomancy: Well, using your version sure wouldn't help then.
14:58RaynesSince it doesn't even have the var I need to tweak.
14:59Raynestechnomancy: How do I figure out which repo I got cider from, out of curiosity?
14:59RaynesOnce installed package-list-packages no longer shows me where it came from.
14:59RaynesI'm sure that's a feature.
15:00technomancyRaynes: the best way to know for sure is to never put melpa on your list of sources
15:00Raynestechnomancy: What's wrong with melpa?
15:00technomancyfor real?
15:01Raynestechnomancy: I literally know nothing about it other than it gives me packages that I need.
15:01technomancyRaynes: it's basically just all snapshots, all the time
15:01RaynesWell, that's cool, since I needed a snapshot in this case.
15:02technomancyexcept now everything you install will use the bleeding edge version
15:02technomancyiirc there's no way to say you want melpa but just for a single package
15:02Raynestechnomancy: Except not really because I also have marmalade and for new packages it shows me where I'm getting it from.
15:02Rayneswat
15:02DerGuteMoritztechnomancy: there is actually
15:03technomancyDerGuteMoritz: oh, is that new?
15:03Raynestechnomancy: Yeah, I can get packages from either source.
15:03technomancywithout that ability it's completely nuts to use melpa
15:03Raynestechnomancy: https://dl.dropboxusercontent.com/s/y738qlow36vjwgz/2014-07-01%20at%2012.02%20PM.png
15:03technomancyhttp://blog.jorgenschaefer.de/2014/06/the-sorry-state-of-emacs-lisp-package.html
15:03technomancyRaynes: oh fancy; they must have added that ~recently
15:04technomancythat's a relief
15:04DerGuteMoritztechnomancy: you need the "melpa" package which provides package-archive-exclude-alist and package-archive-enable-alist
15:04RaynesI'm using a nightly Emacs build technomancy
15:04RaynesBecause I live on the edge
15:04Frozenlockbold
15:04technomancyhttp://p.hagelb.org/candle.gif
15:07johnwalkeri'm also on nightly cider, but i'm not experiencing the problems you described Raynes
15:08johnwalkeryou can always try el-get
15:08johnwalker:)
15:09RaynesYeah, no.
15:09Raynesjohnwalker: I have 20140624.1355
15:10Raynesjohnwalker: Can you confirm you have the same snapshot, because this definitely is broken.
15:10jcromartieAny opinions on whether core.async is "production ready"?
15:10jcromartieor just used in production at all?
15:10Raynes(setq cider-show-error-buffer 'except-in-repl) is what I'm talking about, to be clear.
15:10RaynesIt does not function as intended. Setting it to nil works fin.
15:10Raynesfine*
15:10tbaldridgejcromartie: many people are currently using it in production
15:11jcromartietbaldridge: well it's your baby so of course you'd say that :)
15:11tbaldridgejcromartie: probably the fastest adoption of any Clojure contrib project I'm aware of
15:11jcromartiethat's awesome
15:11amalloyjcromartie: when something breaks in production it's more likely to be your fault than that of core.async
15:11johnwalkerahh, you said the repl did not appear on jack-in
15:11jcromartieyeah
15:12Raynesjohnwalker: That went away second try.
15:12amalloymuch more likely, i might even say
15:12tbaldridgejcromartie: when core.async doesn't work it doesn't work all the time. I'd have problems suggesting putting a library into production that suffers from lots of heisenbugs
15:12Farehi
15:12jcromartiethat's good
15:12tbaldridgejcromartie: and if you wait for stuff to be "production ready" you really shouldn't be using reify/defprotocol either ;-)
15:12jcromartie:)
15:12tbaldridgethose were alpha until 1.6
15:12Farecan someone help me understand source code directory structure for java and/or clojure ?
15:13johnwalkerel-get does not give me 20140624/etc but i can confirm that i am on the latest from github
15:13Faredo I really need to create one directory per package name component?
15:13RaynesOh, if you're using el-get then we can't really compare.
15:13Faremost code seems to, but some code seems to do just fine without
15:13RaynesD'oh well
15:13johnwalkerno, we can compare
15:13RaynesThis is good enough
15:13jcromartieI'm trying to grok the use cases, because my code is OBVIOUSLY heavy in async stuff, but I am not sure where channels and go blocks would apply..
15:13jcromartieIt seems to be a big paradigm shift.
15:13amalloyFare: yes
15:13johnwalkeri will check if that setting is broken
15:14Fareamalloy: yes I need to? Why?
15:14amalloybecause that's the way the compiler knows where to find a file when you type (require 'foo.bar.baz)
15:14Fareand how does the code that doesn't do it?
15:14amalloyit looks for foo/bar/baz.clj
15:14johnwalkerok, that setting works for me
15:15Fareso I need those directories for clojure code? Do I need them for java code?
15:15TimMcFare: Example of code that doesn't do that?
15:15Fareand what if my git repo has several projects? do I need to repeat this hierarchy for each project?
15:15johnwalkerwhen 'except-in-repl evaluation outside the repl creates a popup buffer with the stacktrace
15:15sritchieFare: yup :)
15:16johnwalkerwhen it's nil, an error line shows up in the repl
15:17amalloyFare: yes, you need directories for everything. the jvm loves directories
15:17amalloyas for code that doesn't do that, who knows? if you have a specific example that confuses you, feel free to link to it
15:18johnwalkerthe last commit for my cider build is
15:18johnwalkerTue Jun 24 23:55:08
15:18johnwalkerso it's confirmed that we're on the same build
15:21johnwalkerRaynes: so i have no idea what the problem migh tbe
15:22Raynesjohnwalker: with 'except-in-repl, if I'm inside the repl I get a line in there + a buffer popup.
15:22Faremaybe the code that didn't "just" had very short package names, and/or got by by explicitly invoking the compiler with proper invocation.
15:23FareCan I share the same directory structure between multiple "projects" or is there a reason not to?
15:23Farewhere "projects" are separate for dependency purposes.
15:24sorbus_I'm reading through Joy of Clojure. can someone tell me what #( does as I can't find an explanation in the book, and net searching isn't helping
15:24amalloyit's not clear what you're suggesting, Fare
15:24amalloy,'#(+ % :test)
15:24clojurebot(fn* [p1__25#] (+ p1__25# :test))
15:24amalloyoops. well, that function doesn't succeed for any input, but it shows what #(...) expands to
15:25mockersorbus_: http://aphyr.com/posts/303-clojure-from-the-ground-up-functions
15:26johnwalkerRaynes: i get only the line, but no popup
15:26Farecom/example/ contains projecta/ projectb/ projectc/ that are distinct for the sake of dependencies.
15:26Raynesjohnwalker: Then I guess my computer is broken.
15:26RaynesI can consistently reproduce this issue over restarts, etc.
15:26mockersorbus_: #(+ % 1) is equivalent to (fn [x] (+ x 1))
15:26sorbus_ah right, many thanks
15:27amalloyFare: but where would you put project.clj? if you put it above com/ then there's only one project, and if you put it under project[abc]/, then the com/example/ structure doesn't exist in any interesting way
15:27Faremocker: is p1__25# always equal to p1__25# ? When or when not? What is the scope of gensyms?
15:28johnwalkerlol
15:28Fareamalloy: could I put it in projecta/ and have it specify :source-paths ["../../"] :test-paths ["../../"] or something like that?
15:29amalloythat sounds weird as shit
15:29johnwalkerone thing you might try is re byte-compiling your cider
15:29amalloyi would advise against trying to play tricks - just use the same directory structure across your N projects
15:29Farewould it be a problem because some jar file generator would end up putting all the files in all the jars?
15:30TimMcFare: What benefit are you trying to achieve?
15:34FareTimMc: sanity in not having to reproduce three-level deeps directories all the time for a single file?
15:37amalloyif creating two directories every time you start a project is the biggest challenge to your sanity that programming offers you, i'd say you're probably not going to be put into an asylum anytime soon
15:38cespareI have a helper function in java. What package name should I give it? The associated clojure code is in mylib.core
15:38cespareJust wondering about conventions.
15:39johnwalkeryou can always automate that shit with bash
15:40TimMcFare: lein new and mkdir -p have worked fine for me.
15:40johnwalkerbut i don't think it will be better than mkdir -p
15:40johnwalker^^
15:40TimMcFare: The only thing I've had trouble with is changing package names.
15:41Fareamalloy: the problem is not creating the directories but constantly switching between them, duplicating or merging them back when grouping or not grouping files together.
15:41amalloyhuh, this is a funny quirk i didn't know about:
15:41amalloy,(let [x 1] do x)
15:41clojurebot1
15:41johnwalker,do
15:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:42johnwalker,(let [x 1] for x)
15:42clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/for, compiling:(NO_SOURCE_PATH:0:0)>
15:42mattmoss,(let [x 1] x)
15:42clojurebot1
15:43johnwalkerwhy does that work?
15:43johnwalkeris it because do is a special form?
15:43mattmossThe [x 1] in the let binds 1 to x for the duration of the x.
15:44tbaldridgejohnwalker: probably a bug, do is not a macro, it's a special form
15:44tbaldridge,(let [x 1] fn* 1)
15:44clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: fn* in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:44johnwalker,(let [x 1] try 1)
15:44clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: try in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:44tbaldridge,(let [x 1] do 1)
15:44clojurebot1
15:44tbaldridge,do
15:44clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:44johnwalker._.
15:44mattmoss,(let [x 1 y 2] (+ x y))
15:44clojurebot3
15:44johnwalkerwat
15:44tbaldridgewaaaaaaat
15:45johnwalkerhttps://www.destroyallsoftware.com/talks/wat
15:46bbloomi seem to remember do being MORE broken in the past, but got fixed to some extent at some point
15:46mattmoss,(let [x 1] (do x))
15:46clojurebot1
15:47Fareis that on purpose, or would a contrib be accepted that did?
15:47Fares/contrib/patch/
15:47dbasch,(let [do 1] do)
15:47clojurebotnil
15:47johnwalkerhahahahahahhaha
15:47tbaldridgeFare: what do you mean? does not handle tab width
15:48johnwalker(inc dbasch)
15:48lazybot⇒ 7
15:48bbloomtbaldridge: i assume he means tab = 1 char
15:48TimMcFare: Are you asking for tabs to be reconciled with spaces? Won't happen.
15:48dbasch(inc wat)
15:48lazybot⇒ 1
15:48johnwalker(inc wat)
15:48lazybot⇒ 2
15:48mattmoss,(+(+)(+))
15:48clojurebot0
15:48bbloomtbaldridge: rather than N columns
15:48Bronsauhm I believe I might have sent a patch for the do issue
15:48tbaldridgebbloom: Fare: yeah, that sounds like a bad idea
15:49Bronsayeah http://dev.clojure.org/jira/browse/CLJ-1216
15:49vermacbp, your suggestions worked great
15:49bbloomtbaldridge: tabs are kinda a bad idea in general
15:49TimMcFare: No matter what behavior you're seeing or desiring, I'm sure the answer would be "don't use tabs".
15:49vermacbp, thanks
15:49johnwalkerlol that's just crazy Bronsa
15:49dbasch,(let [do 1] (println do) do)
15:49clojurebot1\n1
15:50mattmoss,(let [your-mother "nice"] (do your-mothing))
15:50clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: your-mothing in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:50dbasch,(= (let [do 1] (println do) do) (let [do 1] do))
15:50clojurebot1\nfalse
15:50mattmossI can't even type.
15:50dbasch^ that's a wat
15:50mattmoss,(let [your-mother "nice"] (do your-mother))
15:50clojurebot"nice"
15:50Bronsadbasch: the compiler reads (let [do 1] do) as (let [do 1] (do))
15:50FareTimMc: not if I'm reading Python code where tab is explicitly declared to be of width 8.
15:51dbaschBronsa: but why?
15:51johnwalkeroh god
15:51tbaldridgeFare: but...why does that matter this is Clojure, not Python
15:51johnwalkerthis is an eich language isn't it
15:51johnwalker*hides*
15:51bbloomFare: the push back reader is not a public API
15:51bbloomFare: it exists for reading clojure code
15:52tbaldridgeoh he's using the PushbackReader? yeah don't do that.
15:52tbaldridgego find/write your own
15:52Faretbaldridge, in what language to write a python parser, better than clojure?
15:52Fareok, wrote my own.
15:52bbloomFare: are you doing that for fun? or do you need it for something? may be much easier to shell out to python 3's ast library & slurp in the result as json or similar
15:53tbaldridgeFare: and if I were going to parse something like that I'ld be highly tempted to either use Jython to parse, or a parser generator (like Instaparse)
15:54Faretbaldrige: instaparse won't easily handle either the indentation or the layering on top of a lexer that does.
15:55FareThose I suppose the lexer could use magic escape characters for the purpose of encoding indentation.
15:55bbloomFare: instaparse can parse things other than strings. you can use it to create a "lexer"
15:55Bronsadbasch: tldr the current implementation in the compiler can't distinguish "synthetic" do's from actual do's
15:55dbaschinteresting
15:55TimMcFare: In this case I would suggest pre-processing tabs into 8 spaces.
15:56FareTimMc: except you should only pre-process those that appear outside strings.
15:56TimMcFare: How about just those in leading whitespace?
15:56Farehow do you know it's not part of a multi-line string?
15:56bbloomFare: do you care?
15:57Farebbloom: some
15:57bbloommultiline strings w/ leading whitespace probably ALSO want tabs to be spaces
15:57bbloomdoesn't python chop leading whitespace inside strings?
15:57Farebbloom: I don't know. Does it?
15:57TimMcFind out.
15:57FareI will.
15:57bbloomFare: not in my repl, but i thought it did in code files
15:58TimMcFare: I'd be curious, actually.
15:59bbloomseems it doesn't
15:59bbloom*shrug*
15:59bbloompeople using multi-line strings who care about tabs vs spaces are just asking for trouble
15:59bbloomuse a data file dammit people
15:59tbaldridge"use data for everything", there, fixed it for ya
16:01TimMcew
16:03scottjtbaldridge: do you happen to know if this approach to speeding up clojure startup time got much discussion offline by cognitect people? it got almost no replies online from what I could see https://github.com/galdolber/clojurefast
16:03tbaldridgescottj: https://github.com/clojure/clojure/tree/fastload
16:04scottjtbaldridge: thanks
16:04tbaldridgescottj: also, https://github.com/clojure/clojure/tree/direct
16:04tbaldridgescottj: there's some talking happening now about how much it matters (good or bad) and how this all relates to maven.
16:06hiredmanit really only matters for aot'ed code, which is often broken anyway, because aot
16:10tbaldridgehiredman: true, but it's a design goal Rich has aimed for from the beginning with this feature
16:10scottjit seems pretty important for android apps, but I haven't seen the numbers for rich's implementation
16:10hiredmantbaldridge: it seems like it would be better to file the rough edges off of aot before adding more features
16:11hiredmanscottj: adroid apps require aot compilation, clojure's current aot implementation is something of a slow motion train wreck
16:11dgleesonhello all, I'm writing an api. I'd like to use different middleware depending on the resource. Example /resource1 might get wrap-middleware1 and /resource2 might get /wrap-middleware2. I can't seem to find any clear information on the internet on how to do this. Does anyone have any suggestions? maybe point me in a direction?
16:12hiredmanall kinds of gotchas and things that work differently from in the repl or if you load a file
16:13hiredmanI mean, cool, new features, piled on top of a feature that #clojure general advises people not to use, great!
16:15whodidthisdgleeson: http://weavejester.github.io/compojure/compojure.core.html#var-routes
16:16tbaldridgehiredman: I think the idea goes a bit further than that though. For example, shipping versions of Clojure that boot to the repl faster. By doing things like disabling redeffing clojure.core
16:16tbaldridgeredeffing stuff in clojure.core
16:18tbaldridgesure that breaks some test frameworks, but those people can either use the "normal" version of clojure, or use a different way of testing that doesn't involve redef'ing ^:static defns
16:19hiredmantbaldridge: *shrug* it still seems like optimizing things while there is plenty of broken cruft, but I am sure it is more interesting to work on than trying to fix stuff
16:25tbaldridgehiredman: I hear that. If I had my way we'd work on switching over to tools.analyzer before tweaking much else on the compiler, but that's just me.
16:25seangrov`tbaldridge: Is that likely to happen? It'd be fantastic
16:26tbaldridgeseangrov`: I know of no such plans. The first step is to prove that tools.analyzer stuff isn't too slow to be used for normal compilation.
16:27tolitiusis there a maven plugin/way to build clojurescript? build team needs everything based on maven, (can't use lein)
16:27tbaldridgeMaking a case to switch is easier if you can say "it produces faster code" or "it compiles only 2x slower than the existing compiler". Extensibility/maintainability is hard to argue for if the better designed code is 10x slower.
16:28tbaldridge(or whatever the performance diff is, Bronsa would know the answer there).
16:29seangrov`tbaldridge: Good point. So it's not beyond belief, but unlikely to happen any time soon, and with no hurry to do so
16:29dgleesonwhodidthis: I looked at that, and I'm having a hard time deciphering how I might apply that stuff. I think that is why I am asking.
16:30tbaldridgeseangrov`: exactly
16:32whodidthisdgleeson: write a separate handler for /resource1 and /resource2 and combine them with that, im not sure if there are any more concise way
16:32johnwalkerif an agent has ten actions enqueued and shutdown-agents is called
16:33johnwalkerwill those ten actions be processed ?
16:34johnwalkerif they aren't processed, is there an agent-shutdown-handler?
16:34brunovjohnwalker: from the docs "Running actions will complete, but no new actions will be
16:35brunovaccepted". My interpretation is that enqueued actions will be processed. This would be like calling shutDown() on the executor.
16:35brunovAs opposed to shutDownNow(), which is more drastic and will even interrupt running Runnables
16:36johnwalkeri also think thats what is meant there
16:37johnwalkerstill, a shutdown handler would be extremely useful for cleanup
16:38brunovjohnwalker: confirmation! Under the hood it's calling ExecutorService#shutdown(), which says "Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down."
16:38johnwalkernice!
16:43johnwalker(inc brunov)
16:43lazybot⇒ 1
16:44brunovgracias!
16:45amalloy(dotimes [_ 1e5] (shutdown-agents)) ;; just in case
16:47johnwalkerlol why
16:47johnwalkerjust to make sure they're all dead?
16:47brunov"Invocation has no additional effect if already shut down." I think amalloy is joking
16:48puredangerscottj: (and others), if there are questions re the fastload or direct branches, I have been working with Rich on testing some of it and could tell you what I know
16:50puredangerfastload is primarily designed to defer var loading and cache classes with the goal of reducing load times. I have tested a large set of public projects (and some private ones) and generally find it's about 10% faster but on a couple it's significantly better. this really affects any code, whether AOT'ed or not.
16:51puredangerIn some very narrow benchmarks, I have found that fastload actually makes var invocation slower in very hot loops as you have put a lazy check in the middle of the code path
16:54puredangerthe direct branch at turning var invocation into static method calls (like the old ^:static), but for everything. If you have those method calls in a hot code path, this is faster than current invocation through var. One of the limiting factors in the branch as it stands is that it does not handle direct linking of self calls (eg. a fib that calls itself) and from what I've seen that's limiting a variety of hotspot inlin
16:54puredangerpossibilities. probably the next thing to come.
16:57tbaldridge(inc puredanger)
16:57lazybot⇒ 3
16:57tbaldridgeonly 3, too low!
16:57tbaldridgeonly 3, too low!
16:57tbaldridge(inc puredanger)
16:57lazybot⇒ 4
16:57puredangerthe direct linking can happen during AOT or can happen outside AOT. Linking decisions can potentially be made at several points. There's a lot of research to be done on how and when it's useful to choose that linking.
16:59puredangera namespace for example could choose to direct link into Clojure, direct link calls within its own namespace, or even direct link all but a few vars that are left open for dynamic extension
17:00puredangereven if you use a Clojure that is direct linked at build time (we would need to produce multiple variants of the clojure jar), you could still use for example with-redefs to monkey patch core in your scope (but only in calls into Clojrue fns; calls from core to core could not be affected).
17:01tbaldridgepuredanger: which is kindof asking for trouble, IMO
17:01puredangerin some cases, it could be a feature :)
17:01tbaldridge"redefing may or may not work...."
17:01tbaldridgebut yes, I agree, make all of that switches and then allow people to tune them. More knobs are always better
17:02arrdemtbaldridge: yeah that's one of the things I've kinda been stressed by... one you say "oh redefining has all these caviats" it starts making sense to just say "one def one binding".
17:02tbaldridgeexcept perhaps when it comes to the JVM GC
17:02Farebetter have a clear semantics for what is bound early or late, like Erlang.
17:02puredangerthere is potentially dizzying variations but in reality most are not used or useful in practice
17:02Farethen implementations can optimize or not optimize, at their leisure
17:03tbaldridgearrdem: I agree, and I think the community at large is slowly starting to agree that with-redefs is of-the-devil.
17:03puredangerI have run direct on about 25 oss projects and only found a handful of cases where code would need adjustment (or just wouldn't work with the direct linked version of Clojure)
17:03technomancywith-redefs outside tests anyway
17:04arrdemtbaldridge: I mean.. either it's a language feature (and I have enjoyed being able to crowbar into the core some days) or it isn't and we can play more tricks.
17:04amalloypuredanger: that seems like a weird position to be in, as a library developer. i can't make my library depend on dynamic calls to clojure.core, because i may be included in an app that has a static core; but i shouldn't link statically either, because the app that uses me may depend on rebinding core stuff
17:04amalloyso i'm almost stuck calling core dynamically (ie, slowly), but not able to take advantage of the flexibility that could afford me
17:04puredangeryes, one of the many thorny things to think about
17:05puredangerif we produced multiple clojure jars (clojure and clojure-prod) and gave library developers the tools to build their own, would that be a positive direction?
17:05puredangeror a nightmare
17:05puredangerand what happens when you mix and match
17:06puredangereven in the direct linked case, the paths for dynamic invocation WILL still exist in the compiled code
17:06puredangerthat was an early design question
17:07puredangerso the choice is really at compile time
17:12bbloompuredanger: have you looked at racket's units?
17:12puredangernope
17:12bbloompuredanger: http://docs.racket-lang.org/guide/units.html
17:13amalloypuredanger: i don't understand what you mean by "even in the direct linked case, the paths for dynamic invocation WILL still exist in the compiled code". if i choose to include static-core, what code for dynamically calling "vars" in core will still exist, if it doesn't even really have vars?
17:13bbloompuredanger: they are similar to ML's modules
17:14bbloomi mention them here b/c they are essentially a mechanism of static typing that would enable consumers of code to declare what bits are static/dynamic
17:14scottjpuredanger: thanks for the info! have you done any testing on android to see how much it improves startup time there? the clojurefast blog post had really impressive numbers for ios http://gal.dolber.com/post/78110050703/reduce-startup
17:15bbloompuredanger: in short, signatures : modules :: protocols : types
17:15bbloompuredanger: but there is / can-be an explicit linking phase
17:15puredangeramalloy: in the compiled class representing say, "range" there will be both an "invoke" (current method) and an "invokeStatic" (additional static method). your library code can decide (through knobs TBD) whether to make a static or dynamic call to range. If you are using a direct linked version of core, it might have internal static calls from some other function to range - you could not change that (b/c it's already
17:15puredangercompiled)
17:16puredangerscottj: have done no work re android
17:16bbloompuredanger: the overview paragraph on that page contains this statement:
17:16bbloom"a unit’s imported variables can be partially linked with the exported variables of another unit prior to invocation"
17:16puredangerscottj: there's no reason someone couldn't try the fastload branch for it
17:16amalloygot it, thanks
17:17puredangerbbloom: (not ignoring you btw, just many threads here)
17:17bbloompuredanger: no worries. i understand that i've basically given you homework ;-)
17:17puredangeryeah, totally
17:17puredangerthere may be some other person directing my efforts as well. ...
17:19bbloompuredanger: it's an avenue worth exploring, considering namespaces are already reified, it wouldn't be too much of a stretch to capture some or all of the bindings in a namespace statically as a value, and merge them
17:19bbloomthen compile against that
17:19arrdemthis being exactly what Mike Anderson and I are doing in our respective projects..
17:20puredangeris reading
17:21bbloompuredanger: worth noting that racket's units are much more featureful than you really need here... they also address dynamic contracts
17:33puredangeras usual, the people of #clojure are kind and wise. 5 stars, will visit again.
17:34puredanger(inc bbloom)
17:34lazybot⇒ 34
17:34puredangerand go <insert name of soccer team country>
17:35johnwalkercome back soon puredanger :)
17:35bbloompuredanger: awesome. i've wanted a proper modularity construct for some time. getting you to read about units is a significant small win
17:35puredangerI inserted it at the end of my infinite list of things to learn more about
17:35puredanger(see what I did there)
17:36bbloomcreated a type error?
17:36clojurebotIt's greek to me.
17:36bbloomthere's no append operation for infinite seqs :-P
17:36johnwalkeri'm pretty sure oracle did that with tco
17:36puredangerbbloom: it'll be in clojure 1.8
17:37bbloompuredanger: you can't promise that
17:37bbloompuredanger: don't even thunk it
17:38puredangerI added it to the end of the infinite list of 1.8 features
17:38puredangerthis is kind of like the reverse time travel paradox
17:51ShayanjmSo I'm still trying to work my way around clojure - and I was wondering if anyone could take a second to review some of my code? https://github.com/shayanjm/Sentimental/tree/develop/src/sentimental
17:52ShayanjmEssentially, I want to know if I'm writing things in an idiomatic "clojure-ish" way
18:00amalloyShayanjm: https://github.com/shayanjm/Sentimental/blob/develop/src/sentimental/core.clj#L41 should be a function, not a macro. i don't like the repetition in https://github.com/shayanjm/Sentimental/blob/develop/src/sentimental/core.clj#L29-L32, and would write instead https://www.refheap.com/18bffe0e1342c905555eccbfb
18:01amalloythe (new foo) syntax is rather unusual, so https://github.com/shayanjm/Sentimental/blob/develop/src/sentimental/nlp.clj#L10 should be (StanfordCoreNLP. props)
18:02amalloyand you should import the classes, even if you only use them once: seeing edu.stanford.nlp.pipeline scattered throughout the "real" code is distracting
18:02amalloyhttps://github.com/shayanjm/Sentimental/blob/develop/src/sentimental/nlp.clj#L18 is a bad way of writing (seq glob)
18:04ShayanjmThanks for the feedback amalloy. Looking through the code and fixing :)
18:04amalloyit's a little worrying that https://github.com/shayanjm/Sentimental/blob/develop/src/sentimental/utils.clj#L3 will run forever if n is negative, or not an integer
18:05Shayanjmamalloy: so the reason why I needed that is because for whatever reason, I ocassionally get null pointer exceptions with the update-sentiments method (I think it has something to do with the data coming in from NYT)
18:05Shayanjmif I re-run the function, it usually executes fine
18:05ShayanjmI couldn't come up with a more elegant solution than having a maximum cap on recurs
18:06amalloyi'm not arguing that you shouldn't have that function; that's not my problem
18:06amalloyi'm pointing out that if your n is negative or not an integer, it runs forever
18:06amalloybecause (zero? n) is never true
18:06ShayanjmHow do you suggest I handle that best?
18:07amalloysimplest would be to check (pos? n) instead, or to complain if someone gives you anything but a positive integer
18:08Shayanjmgotcha
18:11Shayanjmamalloy: I'm trying to plug in the imports, but I think I'm getting the syntax wrong. specifically: https://github.com/shayanjm/Sentimental/blob/develop/src/sentimental/nlp.clj#L20-L21
18:11Shayanjmwhen I try importing the CoreAnnotations class and accessing the nested SentencesAnnotation class - I get a Runtime exception
18:12amalloyyou need to import edu.stanford.nlp.ling.CoreAnnotations$SentencesAnnotation
18:12Shayanjmahhh the whole thing?
18:12amalloy"nested" classes in java are just ordinary, distinct classes to the jvm
18:13ShayanjmI see. And then how do I access it in the code?
18:13amalloyCoreAnnotations$SentencesAnnotation
18:13ShayanjmJust AnnotatedTree?
18:13Shayanjmerr, SentencesAnnotation**
18:13Shayanjmkk
18:13amalloyit's "just" a class named CoreAnnotations$SentencesAnnotation in the package edu.stanford.nlp.ling
18:14amalloyShayanjm: the definition of find-sentiment is a little worrying: you say it returns a seq of ints, but https://github.com/shayanjm/Sentimental/blob/develop/src/sentimental/nlp.clj#L24 suggests there can be nils in the seq as well
18:14ShayanjmYeah. So I'm still trying to figure out if I want to keep that functionality or not
18:15ShayanjmI did think about that. The reason why I'd like to persist it is in the case of an article not actually containing text
18:15Shayanjm(NYT occasionally has 'video-only' article bodies)
18:15ShayanjmIn the presentation-layer, I was planning on just defaulting nil values to '2' (a 'neutral' sentiment)
18:16amalloywhy not just remove them? is (nil nil nil nil) more informative than ()?
18:17ShayanjmMm, yes, because then position is retained
18:17Shayanjmi'll be mapping the resultant values to titles, abstracts, etc. of the respective articles
18:18Shayanjmso without explicitly building a map of the result values, having a bunch of seqs that correspond with each other is useful
18:18dbaschShayanjm: then your docstring is wrong. IMHO you should keep the docstring, and default to neutral
18:19amalloyew. a bunch of seqs corresponding to each other by index is not very nice, if you can instead have a seq of tuples. ie, instead of [(1 2 3) (a b c)], prefer building [(a 1) (2 b) 3 c)]
18:19amalloyskipping my silly typo, of course
18:20ShayanjmThat makes sense
18:20ShayanjmOkay but I'm just failing on importing it seems
18:21Shayanjmhttps://www.refheap.com/87748
18:21FrozenlockDamnit...
18:21FrozenlockI hate the web
18:23amalloyShayanjm: i think you don't want those []s in your import list
18:24ShayanjmAha! Thanks amalloy :)
18:31dbaschShayanjm: this line (if (and (not (nil? glob)) (> (count glob) 0))
18:32dbaschcould be (if (and glob (pos? glob))
18:32dbaschsorry, pos count glob
18:33Shayanjmdbasch: just fixed thanks :)
18:34dbaschShayanjm: you probably don't need the and because (count nil) is 0
18:34{blake}I am close (thanks to all for help) but stuck. My code to simplify my XML works but I want common tags to be expressed as single keys with a sequence of values. Given a sequence of maps, I find I can "apply merge-with into" to unite siblings at the top level, but can't figure out how to apply it to all the children.
18:34{blake}This https://www.refheap.com/87749 details with code and example output.
18:35{blake}Seems like I should be able to put that "apply merge-with into" into my "simplify-xml" routine somewhere but no dice.
18:36amalloydbasch: i already told him that line could just be (if (seq glob)
18:37dbaschamalloy: didn't see that, I had one eye on the world cup :P
18:40amalloydbasch: yeah, i got up at the end of the game to go join the crowd in my office
18:41seangrov`amalloy dbasch: well, at least we can breath again
18:42dbaschseangrov`: I'm not getting very excited by the world cup. International soccer has reached the point of quasi-randomness
18:42nullptrquasi-randomness ~= competitiveness
18:43dbaschnullptr: no, it's more about the fact that it's much easier to lose a game because of a single mistake than to win it on merit
18:45dbaschsorry to derail the topic, let's go back to clojuring :P
18:45amalloythere are a lot of fields where merit is mainly the absence of isolated mistakes
18:50{blake}Knife-throwing, e.g.
18:54hiredmanseems like that might an artifact of an asymmetry between offense and defense
18:56hiredmanif scoring were easier, then it would be easier to make up for a mistake (missing a chance to score, or letting an opponent score)
19:07dbaschamalloy: what makes soccer different is that some mistakes have a probabilistic chance of costing you, depending on the referee's subjectivity
19:08dbasche.g. stepping on an opponent's foot in the penalty box because you were a few milliseconds late can be a penalty or not, at the ref's discretion
19:09dbaschprofessional coding is mostly about the absence of mistakes, despite what most tech interviews test for
19:12{blake}I've been known to piss more than a few people by suggesting that if they don't like debugging, they shouldn't put so many bugs in their code.
19:14dbasch{blake}: even though your comment is tongue-in-cheek, we all know that a substantial portion of bugs are simply missing checks
19:15{blake}dbasch, It is TIC, but also true. Yeah, missing checks, misunderstood scope, and sloppiness, etc. It makes a lot of sense for a programmer to take responsibility for these things.
19:16{blake}(It is a little bit like saying "First, solve AI..." of course.)
19:26AndIrchello
19:43ttasteriscohey dbasch, a blog post of yours is #1 in HN
19:44dbaschttasterisco: thanks, I wasn't expecting that one to make it to HN
19:44dbaschttasterisco: it's not even very good
19:46Lanny"Netscape has been effectively dead so long that younger generations may think it was a brand of milk chocolate"
19:46ttasteriscobtw, typo: "the original people where leaving"
19:47Lannyis that a pun on nestle?
19:47ttasteriscoor hershey's :p
19:47dbaschthanks ttasterisco
19:48Frozenlockdbasch: I once asked the interviewers why they had chosen me over other candidates for the interview.
19:48dbaschLanny: I vaguely remember but I think that was the intent :)
19:48dbaschFrozenlock: that should be an easy question to answer
19:48FrozenlockRight?
19:48FrozenlockBy the answer they gave, I quickly realized they didn't put much thought at all into it...
19:48ttasteriscoFrozenlock: what was their answer?
19:49FrozenlockAs generic as you can get. Paraphrasing "well, we still haven't read your resume... but HR selected you..."
19:50amalloyLanny: it made me think of nescafe
19:51dbaschI hope I never need funding from Marc Andresseen
19:51ttasteriscolol
19:51ttasteriscoyou mean from A16Z, cause Ben's there too
19:53ttasteriscodbasch: what were you doing in Pittsburgh at the time? CMU?
19:53dbaschttasterisco: yes
20:05bbloomamalloy: on my TODO list of random projects to do at some point for my own edification is a propAgator library... i'm considering bumping it to the top of the queue, since i screwed up the spelling again recently.... maybe i can beat this error out of myself by typing it a bunch
20:07amalloyit sounds like you're going into business selling stuffed alligators for use in movies or something
20:08amalloyget it? gator props. who doesn't love puns, right?
20:08LannyI chuckled
20:08bbloom:-P
20:25johnwalkerwhats the difference between #^ and ^ in typehinting?
20:28amalloyjohnwalker: #^ is very old and should no longer be used, but is equivalent
20:28amalloyclojurebot: #^ is very old and should no longer be used, but is equivalent to ^
20:28clojurebotYou don't have to tell me twice.
20:28amalloy~#^
20:28clojurebot#^ is very old and should no longer be used, but is equivalent to ^
20:28amalloyhurrah
20:29johnwalkerthanks amalloy
20:31ttasteriscowhy should #^ no longer be used?
20:32cbpbecause ^ is now a thing and its like one less character
20:35Lannyyou can still use #^ if you don't caret about the one additional caretacter
20:36Lannywow, tough audience
20:41amalloyLanny: your joke was just too meta
20:41Lannyheh
21:08Shayanjmout of curiousity: how many of you guys write clj/cljs at your day job?
21:09ttasteriscowhy are you assuming everyone has a job :(
21:11Shayanjm*out of curiousity: how many of you (employed) people write clj/cljs at your day job?
21:13LannyI managed to sneak clojure into my day job, but it probably only makes up like 20% of the code I write
21:14zanesIf you have an iterator the traversal of which may trigger an exception, is it idiomatic to interact with it as a seq?
21:14zanesHope that made sense.
22:09technomancyzanes: (map (partial / 4) [1 3 2 0])
22:09technomancythat is to say, exceptions can strike anywhere
22:09zanesFair enough.
22:10FrozenlockGet checked, not just old people get exceptions.
22:10zanesWhat I’m trying to do is implement exponential back off in response to rate-limiting exceptions from an API while preserving the seq abstraction.
22:10zanesIt’s getting a little ugly, so I was wondering whether what I was doing was still idiomatic.
22:11Lannynot everyone has access to good exception catching facilities Frozenlock, check your privilage
22:12Frozenlock:-p
22:13technomancyif you have pattern matching available you could use an option type =)
22:13technomancyit's not terribly idiomatic, (and super annoying without pattern matching) but it's a lot nicer than exceptions
22:13zanesI considered that. It felt cleaner somehow to just slow down the realization of the seq.
22:14zanesThis keeps downstream consumers from knowing about rate-limiting exceptions at all.
22:14zanesBut the implementation was a little hairy for me.
22:22akurilinquick question: what's your guys' take on mocking db calls when testing Ring apps that mostly do CRUD? Do you generally tend to err on the side of writing integration tests?
22:26mangezanes: Were you meaning something like this? https://www.refheap.com/87751
22:28zanesmange: Yep. I wound up with something like this: https://gist.github.com/zane/58e3c77951eaa5159f26
22:29zanesakurilin: If you have the leeway to use Datomic you can even unit test hitting the database!
22:30zanesI prefer to avoid integration tests as much as possible.
22:31mangeAh, okay. That's a bit more special-purpose. I was wondering if you could use something like ribol (https://github.com/zcaudate/ribol) to make it so the consumer can choose the strategy on failure, but I don't really have the time/energy/inclination to look into that now.
22:31dbaschzanes: you don't need the nil https://gist.github.com/zane/58e3c77951eaa5159f26#file-gistfile1-clj-L8
22:32akurilinzanes: any particular reason why?
22:32zanesdbasch: Just change that to a when-let?
22:32dbaschzanes: sure
22:32zanesakurilin: Because they’re slow, brittle, and tend to make the rest of my test suite less useful.
22:32dbaschzanes: the only advantage of a when-let being the implicit do
22:33zanesOh, that’s interesting. I thought single-armed ifs were kind of distasteful.
22:33akurilinzanes: do you mock db calls or how do you avoid that?
22:34zanesmange: I hadn’t heard of ribol. Thanks!
22:34zanesakurilin: Pretty much.
22:34akurilinzanes: don't you find mocks also very brittle though?
22:35zanesIt sounds like you have a good handle on the tradeoffs here. :)
22:35akurilinI don't, what's why I'm curious what others have chosen for their projects
22:36akurilinI've been seesawing back and forth between the two approaches for years
22:43rufoaI've noticed that in the context of destructuring, ":as" and ":keys" are referred to as "directives" rather than "keywords". Is there a semantic difference between the two?
22:44dnolen_ClojureScript 0.0-2261 out, murmur3 hashing landed (hard dep on 1.6.0)
22:44rufoait seems directive is also used to describe :use, :gen-class etc inside an (ns) macro
22:46Frozenlockdnolen_: thanks!
22:48FrozenlockAt which point does a .edn file 'database' can't do the job anymore? I always use a database backend, but for small project I think I might as well keep everything dead simple...
22:50technomancyFrozenlock: depends on so many factors
22:51technomancyatoms or refs? read/write ratio, cost of update function, variability of cost of update function, concurrency of updates, etc
22:58FrozenlockOk, I'll rephrase my question. I would like to store users info (maps of ~10 fields per user). Would the Universe hate me for using a simple file for say 0-100 users?
22:59FrozenlockI used to store an elisp 'database' this way up to hundreds/low-thousands of element without much trouble. /cowboy
23:01technomancythat seems reasonable. clojars uses in-memory maps for users with a very low level of writes.
23:02Frozenlocknice, thanks!
23:04pandeiroanyone use archiva? i'm trying it out for the first time but can't get the URL right (?)
23:36bbloomamalloy_: ERROR: Propegator not defined
23:36bbloomamalloy_: i made it ~2 hours without seeing that error....