#clojure logs

2014-11-13

00:00danielcompton,(require '[clojure.data.fressian :as fr])
00:00clojurebot#<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/data/fressian__init.class or clojure/data/fressian.clj on classpath: >
00:53kenrestivohuh, learning interesting things about jna. seems like it just puts the args onto a stack and hopes for the best.
00:53kenrestivoif the types are wrong, oh well.
00:57danielcomptonandyf, found another bug here http://dev.clojure.org/jira/browse/DFRS-7
01:22amalloydanielcompton: your description there of changes you could make to hide the bug is super-unclear: i *think* i know what you mean by "remove a map pair from the map", and "change the vector key [3] for a keyword" is unambiguous but rather difficult to parse
01:39rritochAre there snapshots released of clojure 1.7 for use with leiningen?
01:41justin_smithrritoch: yes, they are on maven
01:41seancorfield1.7.0-alpha3 is the latest
01:42seancorfieldWe're about to push that to production
01:42rritochCool, thanks
01:44rritochOk, where is the best place to track? https://clojars.org/org.clojure-android/clojure/versions ?
01:44rritocherr, that is definatly the wrong link
01:45rritochWill they all show at http://mvnrepository.com/artifact/org.clojure/clojure ?
01:45swedishf1shrritoch: thank goodness it wasn't something else :p
01:52rritochjustin_smith: As a followup regarding subinterfaces, you were right that using $ would allow me to refrence them, but there were still other issues I had to deal with since deftype doesn't support extends... I ended up using gen-class accross-the-board
01:53rritochhttps://github.com/rritoch/clj-grid-core/blob/master/src/com/vnetpublishing/clj/grid/lib/grid/webapp/filter_registration.clj
01:54justin_smithrritoch: remember I also mentioned proxy, which does support extending a class
01:54justin_smithhttp://clojuredocs.org/clojure.core/proxy
01:59rritochjustin_smith: Would proxy have access to private methods of the class that called proxy?
02:00rritochjustin_smith: In javaland it's possible to pass a self variable into proxy-like strucures via a static variable
02:01rritochjustin_smith: The reason I ask is that there are 2 methods being exposed in the servlet wrapper that I would prefer to be private, but these filter registrations need to be able to access them.
02:02rritochjustin_smith: the getFilterMaps and addFilterMap methods
02:05rritochjustin_smith: Well either way, the gen-class's are working for now. Eventually the entire thing is going to be refactored anyhow, right now I'm simply implementing whatever works.
02:24rritochAnyhow, now that I can implement these subinterfaces there's no need for any java code, and I should be able to use it to deliver static content from OSGi modules. I'm also considering adding a separate servlet for handling .clj script delivery. It would be a short-circuit to bypass all OSGi support code until it's actually needed (as a fallback).
04:46kenrestivoso, using gloss, how might it be possible to convert 0xff to a byte-buffer? i.e. (gloss.core.formats/to-byte-buffer 0xff)
04:47kenrestivothanks to signedness, 0x7f is the maximum :-/
04:48kenrestivoah, nevermind, i can blow off gloss, and use jna/make-cbuf, and it doensn't give me grief.
05:08mnngfltgTurns out I need a nested when-let quite often: (when-let [a (f1) b (f2 a)) -- Is there something people commonly use in this situation?
05:08mnngfltg(To explain: it should short-circuit for each binding-pair if the expression given is nil)
05:19raspasovmnngfltg: this is something I've realized sometimes as well, would be cool to see a macro solution to this!
05:27mnngfltgraspasov, this is quite similar to the idea: https://brehaut.net/blog/2011/error_monads
05:48yogsotothHi could someone explain me why in the example of kafka consumer here: https://github.com/pingles/clj-kafka
05:48yogsotoththere is a "shutdown" function?
05:49yogsotothmy google fu is weak concerning (with-resource)
05:53mnngfltgyogsototh, speculation: the `consumer` is to be used only once, so you can pro-actively close the consumer when you're ready?
05:53schmiryogsototh: https://github.com/pingles/clj-kafka/blob/93a89f41bb09b6167d559b3f90ee2053fbb54b43/src/clj_kafka/core.clj#L17
05:53schmirit's being called after body has executed
05:54yogsotothmnngfltg, schmir: thanks!
05:55mnngfltgschmir, ah that's not really obvious, with-resource needs a doc string
05:55yogsotothI thought with-resource was a basic clojure macro not a clj-kafka one
05:56schmiryeah, when you first look at the code it looks like someone forgot to put parentheses around shutdown
05:57mnngfltgyogsototh, that's the problem with (use ...)
06:18palhi, any idea why my compojure app returns 500 error on http://localhost:8080/app whereas http://localhost:8080/app/ works fine? is if fixable?
06:22rritochmnngfltg: Here is a macro that does the when-let recursion for you
06:22rritoch,(defmacro when-and-let [bnds & body] (loop [a (partition 2 bnds) b (cons 'do body)] (if (empty? a) b (recur (butlast a) (cons 'when-let (conj (list b) (vec (last a)))))))
06:22clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
06:22rritoch,(defmacro when-and-let [bnds & body] (loop [a (partition 2 bnds) b (cons 'do body)] (if (empty? a) b (recur (butlast a) (cons 'when-let (conj (list b) (vec (last a))))))))
06:22clojurebot#'sandbox/when-and-let
06:22schmirpal: compojure distinguishes between these two urls
06:23rritoch,(when-and-let [a "A" b "B" c "C"] (println c))
06:23clojurebotC\n
06:23rritoch,(when-and-let [a "A" b nil c "C"] (println c))
06:23clojurebotnil
06:23schmirpal: you have to explicitly handle both cases
06:24mnngfltgrritoch, great!
06:24Kototamaschmir: how to I match the one without a slash?
06:25rritochmnngfltg: It is lacking any sanity check though, in other words it doesn't verify you passed the correct number of args... It may be a useful improvement to this macro, but either way, it seems to work.
06:25KototamaI have something like (context "app" (GET "/" ...
06:25mnngfltgKototama, do you proxy the request?
06:25Kototamano
06:26Kototamajust running it under tomcat
06:26schmirKototama: (GET "/app" ....)
06:27mnngfltgKototama, just remember there is not GET "", the root always has a "/"
06:28Kototamabut why do I get an internal server error when not typing / then?
06:31mnngfltgKototama, maybe it's related to tomcat
06:45CookedGryphonDoes the cast function automatically type hint things too?
06:47CookedGryphonI'm having trouble with a function that returns an object (android getService) which you should expect to be of a certain type (in this case AccountManager)
06:47CookedGryphonand I can't seem to fix the reflection warning
06:47dysfun_what have you tried?
06:48CookedGryphonso I'm using neko which wraps that with a macro, and (.getAccountsByType ^AccountManager (get-service :account) "com.google") gives a warning
06:48CookedGryphonobviously without the ^AccountManager you get the warning too
06:49dysfun*nod*
06:49CookedGryphonthen I thought, as it *is* actually returning an Object, perhaps I need to do something more, so I tried (.getAccountsByType (cast AccountManager (get-service :account) "com.google")
06:49CookedGryphonbut that gives me a slightly different warning, target class is unknown
06:50dysfunsorry, i have nothing useful to add
07:12andyf_CookedGryphon: Is get-service a macro ?
07:13CookedGryphonandyf_: yes, it is
07:13CookedGryphonis that the issue?
07:13andyf_If so, by default Clojure eliminates type hints on macro invocations
07:13andyf_unless you write the macro very specially
07:13CookedGryphonaha, I was considering removing the usage of this anyway
07:13CookedGryphonand calling it directly
07:13andyf_workaround: Use a type-hinted let binding around the form, e.g. (let [^Type x (get-service ...)] (form with x in it))
07:14andyf_I wouldn?t normally know that, but recently finished writing a linter for Eastwood that would warn about that.
07:14andyf_(the useless type hint)
07:16andyf_If it is a Leiningen project, it is pretty easy to try it out.
07:16andyf_And now, even if it isn't, you can invoke it from the REPL
07:16andyf_Like just about any lint tool, there will be some useless warnings.
07:16dysfun*nod*
07:18dysfunheh, i have to fix the syntax errors in the code i'm writing first
07:20andyf_Unlike most lint tools, it doesn't handle syntax errors gracefully
07:26dysfunhrm, 7 warnings
07:26dysfunnot too bad
07:27dysfunbut then again, the codebase isn't that big (yet)
07:27andyf_more importantly, are they actually signs of problems in the code, or just noise?
07:27dysfuni'm working through them
07:29dysfunwhat's "unlimited use" mean?
07:31dysfunoh, i get it, as in (:use
07:31andyf_simply that there is a :use inside of an ns form that does not do :refer or :only - https://github.com/jonase/eastwood#unlimited-use---use-statements-that-do-not-explicitly-limit-the-symbols-they-refer
07:32andyf_There are links to more details on each linter (except 1 or 2 of the) here in the docs https://github.com/jonase/eastwood#whats-there
07:32andyf_I will probably add URLs to the more detailed docs in the warnings themselves at some point.
07:33dysfunwell i've just been through the entire list and i don't think any of the recommendations were unreasonable
07:33dysfunpeople may disagree with the house style, but *shrug*
07:33andyf_The :unlimited-use thing is a personal preference, really. Some people really don't like them.
07:34andyf_It has turned up actual bugs in some programs.
07:34dysfunwell i don't like it with third party modules, but local stuff where you can just open the file, i think it's okay
07:35andyf_Linters can be disabled by putting an :eastwood key with an options map in your .lein/profiles.clj file or your project's project.clj file, if you wish. e.g. :eastwood {:exclude-linters [:unlimited-use]}
07:36andyf_There isn't yet a way to disable individual warnings by annotating source code, but that should be added in a future release.
07:37dysfunwhat's the non-deprecated ring.middleware.file-info ?
07:39clgvhumm, eastwood can't handle the threading macros...
07:40dysfunoh it raised one of those for me, but i took it as more suggestive
07:40dysfunin which case, it has a point
07:40clgvnot really
07:40dysfunmade me look at it again and mentally verify it
07:40clgvit spams me with warnings inside of threading macros
07:40dysfuni can see that would get annoying after a while though
07:43clgvwasn't there some analyzing tool using tools.analyzer.jvm as well?
07:44CookedGryphonjust using eastwood for the first time on my codebase, what's this wrong-tag return type of function on arg vector should be fully qualified or may cause exception if called from another namespace about?
07:44clgvoh eastwood does but does not say so in its project.clj
07:44CookedGryphonis that a clojure bug, or just some non-obvious behaviour
07:44andyf_sorry, been debugging for a few mins. reading
07:45andyf_clgv: It does have issues with threading macros and the suspicous-expression linter. Should be able to fix that in the next release
07:46clgvandyf_: that would be great :)
07:46andyf_clgv: Eastwood does use tools.analyzer.jvm
07:46clgvandyf_: why is it not in the project.clj?
07:46andyf_CookedGryphon: Links to more docs on all of the linters are here in the readme: https://github.com/jonase/eastwood#whats-there
07:46clgvoh what? "copieddeps ..." :O
07:47andyf_Click on a [more] link there and you'll see a longer explanation. Some people call it a bug, Rich doesn't.
07:47andyf_clgv: By doing the copieddeps thingy, it avoids Eastwood's dependencies conflicting with the project's dependencies that you are linting.
07:47CookedGryphonandyf_: ah yes, thanks, sorry I've come to expect READMEs to be uselessly short :P
07:48clgvandyf_: ok, that's a leiningen infrastructure problem, I guess
07:48andyf_clgv: Before I did that, any project that depended upon a too-different version of core.cache or core.memoize would cause exceptions to be thrown, unrelated to your program
07:49andyf_clgv: Not really a Leiningen thing -- Eastwood must eval your code in the same JVM where Eastwood is running in order to do its thing
07:49andyf_At least, that is how it is implemented. It would be a lot more work to *not* eval your code.
07:49clgvandyf_: oh right
07:50andyf_CookedGryphon: Eastwood's docs are perhaps too long, but hopefully the links to sections on different linters should help.
07:50andyf_and it might be educational on some deep dark corner of Clojure you've never realized before.
07:51andyf_clgv: Here is what the dependencies would look like without copieddeps hack: https://github.com/jonase/eastwood/blob/master/copy-deps-scripts/deps/project.clj
07:51clgvandyf_: is listing the licenses of all dependencies mandatory in general?
07:52andyf_clgv: I was being squeaky clean there. I doubt anyone would raise a stink.
07:53clgvok ;)
08:07clgvhmmm `apply` should have inline arities...
08:07clgvoh wait, that wont help either
08:26Kototamamnngfltg: having (GET "/app") (context "/app" (GET "/")) may fix the problem, i need to test in tomcat now
08:27samfloreshow can I make something like a blocking take (<!!) in ClojureScript?
08:28samflores(I know it would freeze my app)
08:28agarman@sam
08:28agarman@samflores how would you ever unblock?
08:31samfloresIt would block after getting something from the channel, right?
08:31samflores*unblock
08:31agarmanon a single thread how does something get put on the channel?
08:31agarmanwhen you're holding the only thread
08:32samfloresI was thinking on something diferent than "hold the thread" but achieving the similar results
08:32samfloreslike a state machine doing nothing (looping forever) until it gets something
08:33mavbozosamflores: like jQuery.ajax{"async" : true} ?
08:33samflores(sorry if it sound stupid, I have almost no idea how core.async works on cljs) :p
08:33mavbozosorry
08:33samfloresyep. something like that
08:34clgvsamflores: why does <! not suffice?
08:35mavbozosamflores: for example, set async to false on jquery.ajax request
08:38agarmansamflores: are you wanting a general blocking take (not just a synchronous ajax request)?
08:38samfloresI'm using chord (https://github.com/james-henderson/chord) to establish a ws connection and I'd like to block (ws-ch) until the server server response arrive (success or fail)
08:39clgvsamflores: I guess the proper way is to do this fully async so just use <! inside a `go` block
08:39samfloresthat's how I'm using it now
08:40clgvand the problem is?
08:45samfloreskeeping in sync other parts of the application that depends on the connection being established
08:49clgvsamflores: you can just use a channel to communicate that the connection was established
08:50samfloresclgv, yeah I know that... I was just wondering whether that's the only way.
08:51samfloresthanks you all
09:07mnngfltgKototama, did you find the issue?
09:13razum2umwhy keywordize-keys slows it down so much? https://www.refheap.com/ebe1d78863a178e23c27da0fa
09:15mnngfltgrazum2um, I heard a rumor that creating keywords is a slow operation in clojure
09:15mnngfltg(although one that will be optimized for 1.7)
09:18razum2ummnngfltg: hm, dont see it https://www.refheap.com/fc4cd52ed9a0d2683397df7dc
09:19Bronsarazum2um: that's not the same at all, in the first example you're creating the keywords one time only at compile time
09:19perplexahmmm i have a (mapv (fn [a] (future ...))) that runs into a race condition on hadoop. so my temporary workaround is to have each future sleep 100msec more than the previous, how would i do that?
09:19Bronsarazum2um: in the second example you're creating them 1e4 times at runtime
09:20razum2umBronsa: but is there any good way to get records from parsed json which parsed results in stringified keys? I know this keys already
09:22Bronsarazum2um: if you already know the keys, looking up in a {"key" :key" ..} map might be faster than creating a new keyword everytime
09:22mgaarerazum2um: the slowness comes from the fact that keywordize-keys calls (keyword ) on all the string keys, which is slow. One way to do what you want, where you know the keys in advance, is replace that with a map lookup
09:22clgvperplexa: race condition? you should probably do some kind of coordination then
09:23perplexaclgv: you would assume that YARN's FairScheduler is safe against race conditions.
09:23perplexathere's nothing i can do about it right now.
09:24Bronsarazum2um: try replacing keywordize-keys with clojure.set/rename-keys
09:24clgvperplexa: but the timeout quickfix seems pretty esoteric
09:24CookedGryphonin cider/emacs, is there something to find what calls this, etc
09:25perplexaclgv: that is true. the scheduler still throws java.util.ConcurrentModificationException and i can't wait until it is fixed in YARN and from the logs i can tell that the futures hammer the application master all at the same msec, randomly causing that exception
09:26perplexathere's already similar bugs in YARN-1692
09:27perplexai run on 2.5.0, which is supposed to have the fix, though. so it's most likely still not fixed at some point. but i need a dirty hack around the problem asap.
09:27perplexai just have no idea how i'd have an incremental value in (map ..) - i probably don't at all, huh?
09:30Glenjaminperplexa: like map-indexed?
09:31perplexaGlenjamin: oh nice! except it is lazy :( mapv-indexed doesn't exist
09:31Glenjamin,(mapv list [:a :b :c] (range))
09:31clojurebot[(:a 0) (:b 1) (:c 2)]
09:32Glenjaminmap stops at the shortest seq
09:32Glenjaminso (range) will give you a counter
09:33perplexanice, thanks!
09:33perplexa(inc Glenjamin)
09:33lazybot⇒ 8
09:34degI'm trying to get cider working, and am stuck.. Probably more of an emacs question, but hoping someone here can give me a hand.
09:35Glenjaminthere's a cider channel now, but i've forgotten the name
09:36degThanks. Looks like it is #clojure-emacs
09:37razum2umBronsa: rename-keys is twice as slow as the keyworded hash insertion. I just wonder, why isn't there a core macro for fast keywordize-keys based on known keys and lookup
09:50Bronsarazum2um: often keywordizing leads to more problem than it's worth
09:51Kototamamnngfltg: nope
09:53Kototamahttps://stackoverflow.com/questions/11055608/tomcat-is-not-adding-trailing-slash-to-web-apps-context maybe because the mapping generated by ring-uberwar is /* instead of / ? I need to explore further
10:08razum2umBronsa: I thought I'd use a value list but it's not working this way (apply Rec. [1 2])
10:09justin_smithyou can't apply a constructor
10:09Bronsarazum2um: use the ->Rec ctor
10:09Bronsarazum2um: "Rec." is meaningless, (Rec. ..) is clojure syntax that macroexpands to (new Rec ..)
10:09razum2umthank, apply to -> works
10:10Bronsa,(macroexpand-1 '(String. ""))
10:10clojurebot(new String "")
10:10justin_smith,(macroexpand-1 '(apply String. [""])) ; doesn't work
10:10clojurebot(apply String. [""])
10:12Kototamamnngfltg: yeah so the solution on the stackoverflow works
10:13Kototamai'll open a ticket on lein-ring
10:13mnngfltgKototama, looks like a tomcat problem mainly right?
10:13mnngfltgbut opening a ticket is useful anyway, for further reference
10:14Kototamai'm not an expert, but it seems lein-ring should generate <url-pattern>/</url-pattern> instead of <url-pattern>/*</url-pattern>
10:14Kototamabut maybe they do that for a good reason, we will see
10:17mnngfltgright
10:22Kototamahere we go https://github.com/weavejester/lein-ring/issues/139
10:31mdrogalisbbloom_: I swear GitHub just changed their Clojure syntax highlighting *again*
10:31llasrammdrogalis: Hey, it seems to be mostly working!
10:32jeremyheilermdrogalis: i noticed that meta maps are grayed out a bit
10:32jeremyheilerthought that was nice
10:33mdrogalishttp://i.imgur.com/qbLRsxE.png
10:33mdrogalisWhat happened to numbers?! D:
10:33llasramHmmmm
10:33jeremyheilerew
10:33justin_smithmdrogalis: clearly numbers are very important, and likely errors
10:33mdrogalisMy whole program is an error.
10:33justin_smithso they are highlighting them, to let you know you probably used them accidentally
10:33llasramYeah, and I'm getting some weird highlighting of namespaced symbols which have the same basename as core symbols
10:34justin_smith(inc mdrogalis)
10:34lazybot⇒ 7
10:34justin_smithI know that feeling
10:37mavbozoconceptually, Java reference and C pointer are same right? It's just something that points to another thing
10:37puredangeranyone here both know Eastwood well and going to the Conj?
10:37puredangerI think that would be a cool unsession
10:38justin_smithmavbozo: you can use addition to get the "next item" from a pointer
10:38justin_smithmavbozo: I don't think java references provide or support anything like that
10:39justin_smithof course they are implemented as pointers, but loops are implemented as goto, in both cases what we have to work with is more restricted
10:41dbaschalso java references are tracked by garbage collectors
10:41jeremyheilermavbozo: also, java references are pass-by-value, so if you pass a reference into a method, that reference cannot be destroyed.
10:41jeremyheilerby that method
10:41andyf_puredanger: I guess it wouldn't be so cool if it were done via remote video :)
10:41puredangerthat would be harder to arrange :)
10:42mavbozojustin_smith: you can get "next item" from C pointer by addition? Don't you get the next thing in memory address after the thing that is pointed by that pointer?
10:42puredangerandyf_: do you know anyone else that would be a good candidate? you should submit a talk on it for Clojure/West
10:42justin_smithdbasch: indeed, references are a more restricted concept (in a good way) that provide a lot of certainty that a pointer cannot
10:42dbasch(dec pointers)
10:42lazybot⇒ -1
10:43dbaschdec pointers should segfault
10:43andyf_puredanger: Sean Corfield uses it for linting production code. Not sure if he is going. Nicola I'm guessing has class in Italy, but I don't know for sure.
10:43andyf_Jonas Enlund. hiredman likes to use it.
10:45justin_smithmavbozo: right, the next item in memory, it's an operation defined and frequently used in c, and a reference has no corresponding operation
10:45dbaschmavbozo: the c compiler knows what you declared the pointer to be, so when you do p++ it increments it by the size of the type
10:46andyf_puredanger: Clojure/West talk sounds like a good idea. Probably not the right time to ask where/when it will be, a few days before the Conj :)
10:46puredangerandyf_: I don't think Sean or Jonas will be there. hiredman= Kevin right?
10:46andyf_puredanger: Kevin Downey, I believe.
10:46mavbozoso, in general, there are symbols, references, values, and boxes which contain values
10:46mavbozothose concepts are applicable to any programming languages
10:47puredangerandyf_: <unconfirmed>c/w will probably be Portland in mid-April</unconfirmed>
10:47puredangerwe are trying to lock down contracts so we can make that official next week at the conj
10:47dbascha typical error in C is incrementing the pointer when you wanted to increment the pointed value, or viceversa
10:47mavbozofor example, in clojure, "+" is a symbol which names a reference, in this a var +
10:48mavbozowhich points to values a function in clojure.core
10:48puredangerhiredman: any interest in leading an Eastwood unsession at the conj? just an idea
10:48mavbozo*which points to a value that is a function + in clojure.core
10:49mavbozobecause var in a reference in clojure, var is reference right?
10:49andyf_hiredman: If it helps at all, I have some slides I could spiff up from a talk almost a year ago, plus add some notes.
10:49clojurebotPardon?
10:53justin_smithmavbozo: everything in the jvm that is not a primitive is a reference type
10:53justin_smiththough there has been talk of implementing value types...
10:59justin_smithmavbozo: and there is some subtlety (and some oddness) to be found in the jvm's model of things. For example everything that is not a primitive is an object (an instance of some class), and every executable method must belong to some object.
11:02justin_smithwait, sorry, the methods only belong to classes
11:03mavbozojustin_smith: and in clojure, we only deal with values and reference types (var, atom, agent, refs) right?
11:03justin_smithin this sense C, which supports function pointers, and does not assign ownership of functions to datatypes, is closer to being a functional language than java is. But we find our way by making "functions" that are classes with .invoke methods
11:04justin_smithmavbozo: local bindings are not any of those
11:04justin_smith,(let [a 0] a)
11:04clojurebot0
11:04justin_smitha is not a var, atom, agent, or ref in that context
11:04justin_smithit is a binding
11:05justin_smithor, basically equivalent: ##((fn [a] a) 0)
11:05lazybot⇒ 0
11:05justin_smithonce again, a is not any of those reference types
11:06mavbozojustin_smith: wait, there are more reference types?
11:06justin_smithno, a is not a reference type in either of those cases
11:06justin_smithin your code, it is a binding
11:07justin_smithwhen compiled, it is substituted appropriately, but what it is substituted with is an implementation detail
11:10andyf_justin_smith: I haven't read enough compiled byte code to be authoritative, but isn't such a binding usually a pointer/reference on the stack or in a register, rather than in a class or object somewhere? (exception: when you successfully type hint the bound name to a primitive type)
11:10justin_smithandyf_: I thought it was a slot in the compiled object that is the function
11:11justin_smithandyf_: I could be wrong
11:11stuartsierraIt varies depending on context.
11:11justin_smithso "implementation detail" is safe
11:11stuartsierraClosed-over locals become instance fields in the function's class.
11:12stuartsierraOther locals just become method-local variables in Java bytecode.
11:12stuartsierraMaybe there is some optimization there, I'm not sure.
11:13Bronsastuartsierra: no that's pretty much it
11:14clgvyou get to see a lot final vars when you use a java decompiler ;)
11:14puredangerand locals clearing
11:15clgvyeah locals clearing is the confusing stuff when you see decompiled clojure for the first time
11:15justin_smithclgv: var in the java, not clojure sense, right?
11:15gfredericks(defn ^:public ^:static ^:void main [^String[] args] ...)
11:15puredangerclgv: I find it clearer to read the bytecode itself usually but I may be warped
11:16gfrederickspuredanger: and you edit your files with M-x butterfly?
11:16puredangerI use that to edit my butterflies
11:16stuartsierrahttp://xkcd.com/378/
11:17justin_smithpuredanger: sometimes the reduced ambiguity of a weak language is refreshing
11:17puredanger(inc stuartsierra)
11:17lazybot⇒ 14
11:17justin_smithit reduces ambiguity
11:17gfrederickshuh. does C-x M-c M-butterfly even make sense?
11:17justin_smithof course not
11:17stuartsierraTry `M-x butterfly` some time though.
11:17gfredericksclojurebot: reduced ambiguity |reduces| ambiguity
11:17clojurebotIn Ordnung
11:17clgvjustin_smith: yes
11:18gfredericksstuartsierra: I tried it and was too scared to answer the question
11:18clgvpuredanger: I am not fluent in bytecode, so I prefer the pseudo java view ;)
11:18TimMcgfredericks: It has side effects either way you answer it!
11:19gfredericksTimMc: C-g
11:19TimMcmu
11:21mavbozoDo you really want to unleash the powers of the butterfly? (yes or no) , I answer no. I am too affraid of the side effects
11:22gfredericksvote NO to unleashing the powers of the butterfly!
11:24mavbozojustin_smith: thank you for your exposition about reference in clojure and java
11:24justin_smithnp
11:25justin_smithmavbozo: lucily, most of the time, you can deal with clojure code in terms of immutible values and pure functions, but that other stuff helps when the abstractions leak
11:27justin_smith(big leakages include stack traces, profiling one's code, and random corner cases of the language)
11:28hiredmanpuredanger: are you thinking BoF sort of unsession or short presentation sort of unsession?
11:28puredangerbof
11:28puredangerwell, whatever really
11:28puredangerI just think it would be cool for more people to know about it
11:28hiredmansure, I can facilitate the heck out of that
11:28puredangercan you add a session here? https://github.com/cognitect/clojure-conj/wiki/Clojure-conj-2014-Unsessions
11:29mavbozojustin_smith: i am in a middle of trying to applying my understanding on general notion of symbol, reference, value, and box which contain value
11:29mavbozojustin_smith: to clojure, and java
11:30puredangermavbozo: you might like this: https://www.youtube.com/watch?v=8NUI07y1SlQ
11:30mavbozojustin_smith: maybe .NET next
11:31mavbozopuredanger: i'll watch it. thx.
11:31ennHello ... I have a pre-condition check in a clojure.test :each fixture. When it fails, there is nothing in the output to identify which test the fixture was running for. Is there any way to get this information?
11:31justin_smithenn: (test/testing "context of contained code" ...)
11:32justin_smithenn: oh wait
11:32justin_smiththat doesn't help in a precondition
11:33justin_smithenn: I would write a precondition test as a function, and call it inside each test to reduce ambiguity
11:33justin_smithenn: alternatively you could try to get a name from the f that the precondition is wrapping I guess...
11:35ennjustin_smith: we tried that, the name is nil, unfortunately
11:35ennI guess the answer is "don't use fixtures for that" :)
11:35andyf_hiredman: Feel free to ask me any questions you might have, here or email is fine, or we could even arrange a phone call if that would help. Then I'll tell you all the stuff that you have to ask Bronsa :)
11:35justin_smithenn: deftest creates a function, you should be able to get *something* from that function or its metadata
11:36justin_smithenn: even the ugly-ass printed version of a function often has something close to its own name inside
11:36justin_smith,(fn foo [])
11:36clojurebot#<sandbox$eval25$foo__26 sandbox$eval25$foo__26@1a05f56>
11:36ennjustin_smith: I think it's an anonymous function, though
11:36justin_smithenn: so was foo
11:37stuartsierraclojure.test generates anonymous functions to wrap fixtures around tests.
11:37justin_smithstuartsierra: ahh, so there would be no meaningful metadata or name hidden in that function value
11:39puredangerstuartsierra: if those anonymous functions had names, their class would also contain the name
11:39stuartsierraYes but it would always be the same name.
11:40puredangerwell that wouldn't help much
11:41hiredmanpuredanger: done
11:41justin_smithyeah, nothing useful there https://www.refheap.com/93295
11:42puredangerhiredman: thanks!
11:43hiredmanandyf_: those slides you mention would be super, although I vaguely think I've seen an eastwood slide deck somewhere before
11:45hiredmanandyf_: oh, yeah, I see you say you gave that talk, so I must have seen them, I am thinking for a bof style session no slides, but I should make sure I know what I am talking about
11:49andyf_hiredman: Sure. They were hastily constructed, but I could write down a few notes to go with them.
12:13lostmanhi all. I'm wondering whether there's such thing in clojure as 'reverse destructuring'. more often than not I have a variable that I want to put in a map under the key that's the same as variable name: (let [x 33] {:x x}). is there any shorthand for that? I don't like spelling things twice
12:14llasramlostman: Not in core, but it's a trivial macro I'm sure has been written many times
12:15llasramlostman: something like https://gist.github.com/llasram/9510281
12:15justin_smithit is implemented in flatland/useful also
12:15llasramwell there you go
12:16lostmancool, thx
12:16vermawhat do I need to do to get clojuredocs examples stuff to show in lein repl?
12:17EvanRim using prismatic/schema to describe some records defined by some real life committee, and sure seems like "required key by default" is the opposite of what i want
12:17EvanReven the very few fields which are listed as required are in practice possibly missing
12:18andyf_verma: There is a client that still works here: https://github.com/jafingerhut/cd-client
12:19andyf_verma: I believe the API that it uses with ClojureDocs.org web site is an old still-supported one, as in the queries still work against the server, but I think it is returning examples from a snapshot in time a month or two ago.
12:19vermaandyf_: hmm thanks!
12:19vermaandyf_: it integrates with my repl/
12:19andyf_verma: There is a Github issue open for ClojureDocs.org to update the data retrieved via this API, but I don't know when that might happen.
12:19EvanRluckily i have a keyboard macro to wrap every field in (s/optional-key
12:21andyf_verma: It also has instructions for downloading and storing a local 'snapshot' file of all the data (which isn't very big - couple megabytes I think) that you can use with the same commands at the REPL, even without a live Internet connection
12:22vermaandyf_: nice!
12:22vermaEvanR: ) ;; sorry OCD :P
12:25GlenjaminEvanR: (defn optional-keys [m] (into (empty m) (for [[k v] m] [(s/optional-key k) v])))
12:30EvanRGlenjamin: good call, always wonder if things like this are acceptable
12:37TimMc,(+ 1 2)))))
12:37clojurebot3
12:42Bronsaandyf_: with the last commit t.a no longer supports clojure 1.4. Is that an issue for eastwood?
12:43andyf_Bronsa: I haven't tested it with Clojure 1.4 in a while -- some other dependency might be forcing >= 1.5.1 already.
12:43Bronsaok then I won't worry about that.
12:43andyf_I'm happy making the next release require 1.5.1 or above
12:44Bronsaandyf_: I needed to use reduced/reduced? and that's a 1.5.0 feature
12:44andyf_Bronsa: No gray area in that needed<---->wanted zone there? :)
12:47Bronsaandyf_: :P
12:48Bronsaandyf_: I *needed* reduced/reduced? to implement a feature I *wanted*
12:50EvanRis it possible to write a schema which is like sch1 OR sch2
12:51EvanReither
12:57bbloom_ mdrogalis heh, they did
12:57bbloom_seems like the identifier pink is less bright
12:57bbloom_slightly less ugly, but slighly worse contrast
12:57bbloom_weeee
12:59bbloom_mavbozo: not really
12:59bbloom_mavbozo: you can also differentiate a pointer from a pointee, you can't differentiate a reference from a referand
12:59bbloom_justin_smith: they absolutely do not
12:59bbloom_not the least of why is b/c the GC can move them on you
13:00justin_smithbbloom_: what do not what?
13:01justin_smithoh, something about pointers from above?
13:01bbloom_mavbozo: yes
13:02EvanRwhat is #' in (recursive #'ExampleRecursiveSchema)
13:02mi6x3mhey clojure, can you suggest some strategy of running acceptance tests with leiningen?
13:02justin_smith,'#'foo ; EvanR
13:02clojurebot(var foo)
13:02EvanRvar eh
13:03EvanR,(var foo)
13:03clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: foo in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:03EvanRdoes not compute
13:03EvanR,'(var foo)
13:03clojurebot(var foo)
13:03justin_smith,(var +)
13:03clojurebot#'clojure.core/+
13:04justin_smithtechnomancy: estikes is spamming
13:06justin_smithmi6x3m: since an acceptance test is a black box test, couldn't you use a standard clojure.test/deftest with use-fixtures defined for the appriate setup and teardown?
13:07mi6x3mjustin_smith: I use leiningen in a separate clojure project currently, yes
13:08mi6x3mjustin_smith: I mean I use expectations sorry
13:08mi6x3mbut the framework is of no importance at all
13:08mi6x3mI just thought there's some leiningen task like Maven's verify that's dedicated to such actions
13:08justin_smithlein test
13:08justin_smithmaybe expectations has its own variant, lein test is for clojure.test
13:09justin_smithor do you mean the specific logic of only deploying if tests pass?
13:10mi6x3mjustin_smith: well in a maven lifecycle you have separate phases: "test" and "verify"
13:10mi6x3mtest would be for unit and integration tests
13:10justin_smithOK, I'm not familiar
13:10mi6x3mverify for acceptance tests etc. QA tasks
13:12EvanRverify means qa?
13:12EvanRseems like this terminology would be misleading
13:12mi6x3m"verify - run any checks to verify the package is valid and meets quality criteria"
13:13mi6x3mcould be, yes, my terms are perhaps unprecise :)
13:13EvanR"its broken" "no, its verified"
13:13EvanR"oh, ok then"
13:14EvanRmore like tested again in other ways
13:21justin_smithmi6x3m: I am not sure how this is organized, but a naive thought is to make two different testing targets - :unit and :qa - and then one stage would be "lein test :unit" and the other would be "lein test qa"
13:22justin_smithmi6x3m: see here https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L212 and here https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L323
13:22justin_smithfor a deploy task that depends on a specific test selector, and the definition of selectors
13:23mi6x3myes this is actually a good idea
13:23mi6x3mhave another folder wit htests and run them under a different task
13:26jkj_i'm having difficulties wrapping my head around building a converyor system on core.async
13:27jkj_if only i could find examples of systems, not just usage of the library
13:27justin_smithwhat is a converyor?
13:27jkj_justin_smith: well.. multiple pieces of code forming a "production line" which the data goes through
13:28justin_smithconveyor?
13:28jkj_justin_smith: "how to wire the channels together" - i might form the question :(
13:28jkj_oops
13:28jkj_:)
13:28jkj_even
13:28Glenjaminyou could have a series of components which all have input & output channels
13:28jkj_justin_smith: yes. sorry. cannot see my own typos
13:28Glenjaminthen some top-level function which wires them together
13:29justin_smithjkj_: ever use max/msp or puredata? the visual patch language is a great metaphor to help think of how a channel using codebase would work
13:29engblomIf anyone want to be a "Clojure Lint", please comment on: http://pastebin.com/iig0d3V7 . I would especially want comments on input-move as I think it is ugly in current state.
13:30jkj_justin_smith: haven't. have to take a look
13:30justin_smithjkj_: blog post with an image of a simple puredata visual program https://nicholasbuer.wordpress.com/category/pure-data-and-arduino-term-3/
13:30jkj_justin_smith: thank you
13:31justin_smithjkj_: the boxes are units that do some kind of processing (like a go block), the lines are channels of data (like chan) that come out the bottom of one box, and go into the top of another
13:31justin_smithnot that you need to learn puredata before using core.async, but I found the metaphor helped me conceptualize it
13:32jkj_alright
13:32jkj_that does help
13:33engblomIs there a good lint tool similar to hlint for Haskell? Kibit is very limited, I hope to find something better.
13:33jkj_i could be very clear about the different modules in the code
13:33justin_smithengblom: eastwood is pretty good
13:34jkj_justin_smith: do you think the channels in between should be named and well declared? or should they just be implicit thing when you layer channely things
13:34vermajustin_smith: you know if eastwood does cljs?
13:34justin_smithverma: no idea...
13:34justin_smithI don't think so
13:35justin_smithjkj_: channels are useful to have names for in a local scope, indicating how they are used
13:35bbloom_i know coffeescript has that
13:36bbloom_i wonder what they call it
13:36justin_smithie. is it the result channel from a go block, an input queue, a place where you put tasks, an abort message
13:36engblomI get "Subprocess failed" when running Eastwood. Somehow it is not working for my project. It begins, but fails while analyzing.
13:36justin_smith*a source of an abort message (or a startup message, or whatever)
13:36bbloom_http://coffeescript.org/#try:%7Bx%7D
13:36bbloom_the docs don't seem to mention it though...
13:37justin_smithengblom: any other context information? my first suspicion is that if eastwood crashes, you are likely doing something very odd in your namespace definitions
13:39justin_smithengblom: this can equally be caused by exceedingly clever code (like core.typed or potemkin) or by sketchy code
13:39engblomjustin_smith: "Constant value is discarded inside null: nil (nil value is returned by comment and gen-class expressions)"
13:40engblomThe code is the one I linked to a little while ago
13:40Bronsaengblom: which version of eastwood are you using?
13:40Bronsaverma: eastwood does not do cljs yet
13:41justin_smithengblom: so for this namespace, right? http://pastebin.com/iig0d3V7
13:41engblomBronsa: 0.1.3
13:41vermaBronsa: ok, thanks
13:41Bronsaengblom: try 0.1.5 out
13:41engblomjustin_smith: Yes
13:41vermamost of my clojure dev is in clojurescript, it'd be nice :D
13:42justin_smithengblom: for starters, don't use clojure.string/join directly, require clojure.string (probably with an :as string) - namespaces are available if someone else already required them, but relying on it implicitly is bad form
13:43justin_smithengblom: guessing that eastwood doesn't like the empty :gen-class in the ns decl, does it run OK if you take that out?
13:43engblomBronsa: 0.1.5 is not crashing. It is working, however it does not complain anything
13:43justin_smithoh, n/m then
13:43engblomjustin_smith: The new Eastwood is not complaining
13:43justin_smithright, thus my n/m
13:44Bronsayeah this was fixed in the new version
13:44justin_smithhmm, I would have hoped eastwood would complain about usage of a namespace that isn't in your :require block
13:46kenrestivo"i know what you're thinking. did he use one namespace, or two? well, in all the confusion i've kind of lost track myself..."
13:47justin_smithdo you feel lucky?
13:47Bronsajustin_smith: the problem with that is that once ns is macroexpanded away, it's unrecognizable
13:48justin_smithBronsa: the usage of clojure.string without requiring it?
13:48Bronsayeah
13:48Bronsabut maybe andy has already some infrastructure in place for parsing manually the ns form, idk
13:49bbloom_EvanR: it's worth noting that `either` has some serious problems in terms of understandability of errors
13:49bbloom_EvanR: if you can, prefer "if" and "cond" (i think they are called)
13:49justin_smithahh, and because of macroexpansion you could get qualified symbols from namespaces you did not explicitly require
13:49Bronsajustin_smith: right
13:49Glenjamincan you do the check before macroexpansion?
13:49EvanRbbloom_: that sucks
13:50justin_smithBronsa: a top level superficial analysis could catch x.y/z in the literal form and say you should use :import or :require or :use. Maybe.
13:50Bronsajustin_smith: that has the high risk of reporting false positives
13:50justin_smithabsolutely
13:51Bronsa(some-macro x.y/z) where some-macro returns nil
13:51Bronsajustin_smith: not saying it can't be done -- probably by plugging into the macroexpander it could be possible
13:51Bronsabut it's not trivial
13:52justin_smithright
13:52GlenjaminBronsa: wouldn't that still be reasonable to call an error that a linter should warn on?
13:53Glenjamineven if it doesn't break, it's potentially confusing code?
13:53engblomNow I have slightly changed it. It is passing both kibit and eastwood but still I think the input-move function is very ugly: http://pastebin.com/u4YLNi9e
13:54Glenjaminengblom: i'd extract (and (neg? row) (>= row (count heaps)) into a fn
13:54justin_smithengblom: since the only thing done to create new-heaps is an assoc, I would suggest merging the let clauses and just accepting you do an assoc but don't read the result if the first illegal-move check fails
13:54Bronsaengblom: yeah eastwood can only warn you about wrong/suspicious stuff, it can't really judge the idiomaticity of your code
13:55BronsaGlenjamin: there are a lot of macros that expand into (some.ns/foo ..) where some.ns is not requried by your ns
13:55GlenjaminBronsa: does eastwood not lint before macroexpansion?
13:55BronsaGlenjamin: warning in that case would create a very low signal-to-noise ratio
13:56BronsaGlenjamin: it does both depending on the linter, but even doing that before macroexpansion has its problems
13:56justin_smithyeah, a linter that reports non-errors undermines its own utility - users get annoyed and stop using it
13:56Glenjamin"this could be misleading" is reasonable for a linter imo
13:56Glenjaminespecially since eastwood is easy to confifgure
13:57justin_smithGlenjamin: in my experience, I keep improving until the linter shuts up - if I can't or perfectly good code gets a warnign, I won't use the linter
13:57BronsaGlenjamin: well open an issueq then I guess, maybe andy has an idea on how to implement this in a reasonable way
13:58GlenjaminI don't really have a stake in this, was just interested in the rationale
13:59Glenjaminjustin_smith: If I fail a lint warn I tend to go check the docs to see why it's considered bad, then see if I care
13:59GlenjaminThis is learned behaviour from jslint
13:59EvanRjslint, in which most of the time its "i dont care"
13:59justin_smithGlenjamin: yeah, I actually clean up the code until jslint stops warning, maybe that's weird though
14:00engblomjustin_smith: By merging the let clauses you might end up in a situation where you use assoc with an index out of range. Do you mean I should wrap it with try-catch?
14:00GlenjaminI once spent half a day doing that, and ended up with something I thought was less readable, threw away the changes and deleted jslint
14:01GlenjaminNowadays I use eslint with a smallish config
14:01Glenjamin,(assoc nil nil nil)
14:01clojurebot{nil nil}
14:01GlenjaminNo harm done :)
14:02EvanRmost of the options in jslint are completely arbitrary stylistic preferences of dcrockford
14:02justin_smithengblom: you can use (delay ...) and then deref it, or define it as illegal (and (neg? row) (>= row (count heaps))) new-heaps (and (not illegal) (assoc heaps row amount))
14:02justin_smithGlenjamin: I think this is assoc with vector/index
14:02justin_smith,(assoc [] 1 :a)
14:02GlenjaminOh
14:02clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
14:03justin_smithGlenjamin: I missed that on my first read too
14:03GlenjaminSo input-move does IO & validation
14:03GlenjaminAnd the game loop
14:03GlenjaminMaybe try and split into those separate tasks
14:03justin_smithyeah, that's a good point
14:04justin_smithone function for each of those concerns makes sense
14:07jeremyheilerbbloom_: that was me yesterday...
14:07TimMc:-(
14:07TimMcIs this the fact that you can't just re-eval defmulti?
14:07Bronsajust put a (def foo) before (defmulti foo ..)
14:07llasram(inc Bronsa)
14:07lazybot⇒ 71
14:08llasramThat's totally what I do
14:08kenrestivo*cough* clojure.tools.namespace.repl/reload *cough*
14:08kenrestivoer, refresh, but yeah, that
14:11jeremyheilerbbloom_: I think if you define the dispatch function separate, and pass it in as a var, it'll re-eval fine.
14:14andyfjustin_smith: earlier you said about eastwood: "justin_smith: hmm, I would have hoped eastwood would complain about usage of a namespace that isn't in your :require block"
14:14justin_smithyes, I did
14:14andyfMy question: Doesn't Clojure itself fail on such a require?
14:14andyfe.g. if you try 'lein check', assuming Leiningen
14:14justin_smithandyf: he was using clojure.string/join
14:14Bronsaandyf: no, if the namespace has already been loaded by another namespace foo.bar/baz will work
14:14andyfMeaning (:use clojure.string/join) in the ns form?
14:15justin_smithandyf: no, referring to it by its fully qualified name
14:15Bronsaandyf: "(ns foo) clojure.string/join"
14:15justin_smithlein repl already loaded it?
14:16justin_smithmaybe clojure.string is a special case that doesn't get caught - I have had this issue with clojure.pprint/pprint though - things work in my repl, then I try to deploy and everything falls apart
14:16andyfIf in a REPL then it depends on the complete history and a bunch of other stuff. If you do 'lein check' there are fewer things to differ
14:16justin_smiththough maybe lein check would catch that one
14:16justin_smithright
14:16bbloom_you have to ns-unmap it to redefine the dispatch fn
14:16bbloom_a behavior for which i see no good reason...
14:16bbloom_Bronsa: is this just a bug? is there any reason not to *fix* this?
14:17andyfI know there are lint tools that can give better syntax errors than compilers for the same language, but Eastwood is not intended to be such a lint tool.
14:17justin_smithandyf: my thought was, even if you know contextually the other ns is loaded, referring to it by its full name should be worthy of a warning at least
14:17justin_smithandyf: OK
14:17Bronsabbloom_: no the defonce behaviour of defmulti is intended behaviour AFAIK
14:17Bronsatechnomancy: estikes is the usual spammer
14:17llasramOne wonders why protocols don't have the same behavior then however
14:18justin_smithandyf: Bronsa did explain how that would be hard to do in practice thanks to macroexpansion, which I had not considered
14:18bbloom_jeremyheiler: 9 times out of 10 my dispatch fn is a keyword
14:18BronsaI honestly have no idea *why* that's the case and would prefer if it hadn't defonce semantics
14:19Bronsait might have to do with defmethod caching
14:19llasramBronsa: Just make it not defonce in your implementation
14:19llasram:-D
14:19clojurebotExcuse me?
14:19Bronsallasram: I'm not reimplementing the whole clojure runtime :)
14:19andyfa guideline I've been following is: if the compiler has an error or warning message for it already, consider it done and don't try to duplicate it.
14:19hiredmanpeople complained about the way it was
14:19hiredmanso it got changed
14:19engblomI made a new version: http://pastebin.com/85wB7mNF . I still have a slight repeat I would want to get rid of there in input-move
14:19andyfTry to catch things the compiler will not.
14:19llasramclojurebot: :-D is happiness
14:19clojurebotIk begrijp
14:20llasramBronsa: I know that you're *starting* small...
14:20bbloom_Bronsa: why?
14:20justin_smithandyf: so in general I should be running lein do check, eastwood maybe
14:20Bronsahiredman: give us the names. there's some murdering I need to do
14:21TimMcclojurebot: ☃ is a good check for UTF-8 support
14:21clojurebotYou don't have to tell me twice.
14:21bbloom_hiredman: huh?
14:21TimMcclojurebot: ☃
14:21hiredmanI think the complaint was something like: "hey, if I redef a defmulti and don't reload other namespaces that define methods I don't get my methods"
14:21clojurebot☃ is a good check for UTF-8 support
14:21hiredmanwhich is crazy
14:21andyfjustin_smith: I would recommend that order
14:21Bronsabbloom_: I'm agreeing with you that the defonce semantics are bad, what are you asking me?
14:22bbloom_Bronsa: you've answered my questions
14:23kzarDumb question possibly but how can I access my clojurescrpt namespace from javascript? (I'm trying to debug something in the console)
14:24BobSchackkzar: (ns foo.bar) should be foo.bar in the console
14:24kzarBobSchack: I tried that but it doesn't seem to work
14:25BobSchackwhat optimization level are you using?
14:25kzarBobSchack: Whatever is the default I think
14:26hiredmangoogle groups are the worst
14:28BobSchackkzar: you should be able to access the namespace directly with out any difficulty if you have the optimizations :none or :whitespace, (possibly even :simple)
14:29kzarBobSchack: Aha, I had an element with the ID of foo so foo returned some kind of React component / HTML element and therefore foo.bar was undefined
14:29kzarHTML element* (I guess that's something kioo does?)
14:30hiredmanhttps://groups.google.com/d/msg/clojure/MXf8zWAv3vI/JTGF1qxWKpMJ here I am repeating what I said, but still can't find the original thread that prompted the change to defonce like
14:30BobSchackOh HTML element id's are autmatically inserted to the global namespace in broswers
14:31kzarBobSchack: Oh, I did not know that
14:33danielcomptonamalloy_: thanks, I'll reword it
14:33Bronsapuredanger: https://github.com/clojure/build.ci/commit/4bf095a16caec1844192d35f1cd167766e114841 I'll need a hudson rebuild when you have time
14:34puredangerBronsa: ok
14:39engblomWhat do you think about this: (when (= "y" (prompt "Do you want to play again? y/n:")) (-main)
14:40engblomIs it a problem to recurse in main like this?
14:41Bronsaengblom: no, -main is just a regular function
14:41justin_smithengblom: probably use (recur) unless you want to blow the stack after N games
14:41danielcomptonamalloy_: I'd edit the ticket but I don't have permission in Jira
14:41engblomBronsa: Isn't java having a problem with recursion? As clojure is having loop/recur)
14:42justin_smith engblom: we don't have automatic tco
14:42justin_smithengblom: (recur) works in functions too
14:42Bronsaengblom: yeah use recur as justin_smith suggested
14:45engblomMay I get help first with this short function before I try to rewrite -main? I would want to make prompt-int to use loop/recur: http://pastebin.com/THZYdYCN
14:45TEttingerhey engblom
14:45TEttingerI'll take a look
14:45engblomTEttinger: Hello and thanks!
14:45justin_smithengblom: you can't recur inside catch
14:46dbaschI believe what engbloom wants is to recur if the evaluation of the try-catch doesn’t yield an integer
14:46justin_smithengblom: instead (let [input (try (Integer. (prompt msg)) (catch Exception _ nil))] (or input (recur)))
14:47justin_smithdbasch: right
14:47justin_smithjust saying that particular point doesn't work for recurring
14:47justin_smithneed to recur from outside the catch
14:48dbaschyep
14:48justin_smiththe nil there is optional - it would also work with (catch Exception _) but that's a bit odder to read
14:51engblomjustin_smith: How is that (or ...) working as it is only having one expression?
14:51justin_smithengblom: it has two
14:52justin_smith,(or nil :OK)
14:52clojurebot:OK
14:52engblomYes, you are right
14:53justin_smithanother thought - when looping and catching exceptions, you probably want to narrow down and catch the explicit exception type
14:53justin_smithotherwise a program can get stuck sometimes
14:53justin_smithie. what if you tried to interrupt
14:54justin_smith,(try (Integer/parseInt "not a number") (catch Exception e (class e)))
14:54clojurebotjustin_smith: Cool story bro.
14:54justin_smiththat returns java.lang.NumberFormatException
15:01engblomIs it possible to catch two different exceptions with one (catch ...)?
15:01engblomWith some kind of (or ...)?
15:03justin_smithengblom: you can have multiple catch blocks in one try
15:07dbaschengblom: you mean two different subclasses of Exception?
15:07jkj_does saving in http://cljsfiddle.net/ work for anybody?
15:08dnolen_jonasen: ^
15:09engblomdbasch: Yes
15:09annelies¡Hola!
15:09engblomIf either of those two exceptions are thrown I want to do the same stuff.
15:10jonasenjkj_: seems not. I get transactor-not-available
15:10jonasenjkj_: I can take a look at this over the weekend but not before unfortunately
15:10amalloyengblom: not with the built-in try/catch, but it's easy to build your own numerous ways
15:11amalloyfor example, (letfn [(handle [e] (...))] (try (f) (catch IllegalArgumentException e (handle e)) (catch IllegalStateException e (handle e))))
15:11jkj_jonasen: thanks. no worries
15:12dbaschengblom: you can also catch Exception and then see if it’s one of many subclasses
15:12justin_smithamalloy: alternately (try (foo) (catch Exception e (if (contains my-handled e) (handle e) (throw e))))
15:12dbasch(assuming you want to catch *only* those classes)
15:12jonasenThe box I run it on has way too little memory for datomic...
15:12justin_smithwhere by contains I mean contains? and my-handled is a set of Exception subtypes
15:14dbaschjustin_smith: you can leave out the contains? too
15:14justin_smithdbasch: of course, but I like to make it explicit when it's not a set literal
15:14amalloyi saw a gist on /r/clojure from someone (AeroNotix?) to do this sort of thing pretty recently, which you can look at for inspiration, although i would suggest just doing it with built-ins
15:14amalloyjustin_smith: dbasch: you also need to call (class e)...
15:15dbaschamalloy: yes, I’d have my-handled be a function
15:15amalloya downside of that approach is that you have to catch and rethrow exceptions, instead of just letting the jvm do its thing
15:15justin_smithamalloy: ah right, good call, thanks
15:15AeroNotixhttps://github.com/AeroNotix/crap/blob/master/src/crap/exceptions.clj#L32-L36
15:15AeroNotixhere's a macro to do it
15:15justin_smithyes, definitely a downside
15:16dbaschI never liked checked exceptions. In clojure I almost never use anything other than Exception
15:17justin_smithdbasch: I like knowing the difference between "eof on file" and "out of memory while allocating buffer to read file" - but of course the usage of an "exceptional state" to communicate the former is not uncontroversial
15:19justin_smithdbasch: I thought "checked exceptions" meant the compiler side construct where you get an error if you don't handle specific declared exception types when making a call - thanks to not using javac we don't have to deal with those at all
15:19amalloyAeroNotix: if you are interested in some nitpicking, it is rather strange to have gen-catch take & body, and then have every call to it use apply; just make it take the body as a single argument
15:19dbaschjustin_smith: yes, that’s what I meant
15:19dbaschand one of the best things about not using Java
15:19justin_smithright, OK
15:19AeroNotixamalloy: put your comments on github. I'm doing a release right now but I am more than happy to hear your comments.
15:19AeroNotixthanks!
15:19justin_smithdbasch: so I just misunderstood
15:20dbaschI hated it when you had to add a bunch of exceptions to the signature of my methods so that they would compile
15:21justin_smithdbasch: or even worse, when library writers deal with said issue by doing a try/catch and you get an exception caught in a place that is not at all useful to your top level code
15:21justin_smithor worse yet silently ignored so you have no idea what broke
15:22justin_smiths/ignored/discarded
15:22dbaschcatch {} is one of the worst programming sins imaginable
15:23SagiCZ1dbasch: not if you use try catch as control flow..
15:23SagiCZ1riiiight?
15:23justin_smithrofl
15:23dbasch~guards
15:23clojurebotSEIZE HIM!
15:23amalloyspeaking of funny checked exceptions, i discovered only the other day that java.lang.AutoCloseable was added in java 7, as like a radioactive version of java.io.Closeable
15:23justin_smith~gourds
15:23clojurebotSQUEEZE HIM!
15:23amalloyvoid close() throws Exception
15:24SagiCZ1why would you call it radioactive?
15:24dbaschthrow new Exception(“Don’t close me bro!”)
15:25amalloySagiCZ1: because it can blow up in all kinds of exciting ways
15:25dbaschclass PandoraBox implements UnCloseable
15:26SagiCZ1amalloy: great!
15:27amalloySagiCZ1: i actually only thought of the pun after you asked me. i really called it radioactive because it's even more dangerous to handle
15:27amalloybristles with menacing spines, etc
15:28SagiCZ1one would think that higher version means safer, better, faster..
15:28justin_smithamalloy: I think we have our origin story for PLT HULK
15:28dbasch“or to throw no exception at all if the close operation cannot fail.” <- this doesn’t make sense to me
15:29justin_smithhttps://twitter.com/plt_hulk
15:29jkj_amalloy: do you get AutoCloseable? the documentation is kinda not clear about it... _Auto_closeable... "A resource that must be closed"
15:29dbaschit’s autocloseable but you can optionally close it yourself?
15:29jkj_"A resource that must be closed when it is no longer needed."... "must"
15:30justin_smithjkj_: but who carries the weight of that "must" - the runtime? the programmer? the end user?
15:31gfredericks"The Weight of that Must" would be a great name for a Java book
15:31jkj_ah. actually there is more in the close method docs.. "This method is invoked automatically on objects managed by the try-with-resources statement."
15:31hiredmanamalloy: in java 7+ closeable extends autoclosable too
15:31amalloyhiredman: indeed, as well it should if autocloseable is going to exist
15:31TimMcgfredericks: Or wine-making.
15:32jkj_i have a file handle leak problem with a netflow analyser thing that uses nio and mmap... have to figure out how to make sure things are closed
15:32llasramOh -- everything that is Closeable is also AutoCloseable?
15:32jkj_happen to know is this try-with-resources is any ways visible in clojuresphere?
15:33jkj_+thing
15:33llasramWhat does it mean for something to be AutoCloseable but not Closeable?
15:33stuartsierrajkj_: no
15:33engblomhttp://pastebin.com/0svgfzpP <- How do I make that one to throw something not generic, so I still can interrupt with ctrl-c?
15:33llasramOh, narrows the scope of the checked Exception
15:33dbaschllasram: that you can’t call close it manually I guess
15:33hiredmanwith-open should just work though, it will reflectively call the autocloseable .close method I think
15:34dbaschbut also AutoCloseable doesn’t make sense, it should be AutoClosing
15:34amalloyllasram: if it's autocloseable it can throw any type of exception at all
15:34amalloycloseable can only throw java.io.IOException
15:35amalloyother implementations of autocloseable can be narrowed to further specify what they might throw
15:35llasramamalloy: Got it -- I'd glanced away for the beginning of the discussion
15:35llasramBut since any method could really throw any exception *shrug*
15:35llasramIt's just being honest!
15:35dbaschllasram: no, only unchecked exceptions
15:36SagiCZ1i want something like 'every?' but one predicate returning true is enough... is it some?
15:36justin_smithengblom: of you really must use an exception to indicate an illegal move, you could reify Throwable or proxy Exception
15:36stuartsierraSagiCZ1: `some` without the `?` is what you want
15:36amalloydbasch: no, you can cheat anything in
15:36llasramdbasch: Checked exceptions are a fiction of the Java compiler. Any method you invoke could ultimately reach JVM bytecode which throws any exception
15:36dbaschamalloy: true
15:37amalloywhich is what clojure.lang does all over
15:37SagiCZ1stuartsierra: thanks, thats confusing
15:37stuartsierrayep
15:37llasramThe good old "chuck" pattern
15:38jkj_oh the autoboxin exceptions
15:38amalloyiirc http://james-iry.blogspot.com/2010/08/on-removing-java-checked-exceptions-by.html is the technique clojure.lang uses to throw checked exceptions without declaring them, if anyone is interested
15:39stuartsierra"sneaky throw" in the source
15:39justin_smithengblom: or you could throw an applicable exception - IllegalStateException? dunno about that one though
15:39puredangerdanielcompton: yt? afaict you have all the necessary groups to edit jira issues
15:40jkj_a quick core.async question: how do i (chan 1 FOO) so that [:a :b], [c: :d :e], etc.. become just :a, :b, :c, :d ....
15:40jkj_or that is more of a trans* question
15:40puredanger(mapcat identity) ?
15:41TimMcThe trickier part (shown in the blog post) is *catching* sneaky-thrown exceptions.
15:41stuartsierrajkj_, puredanger: just `cat` should do it
15:41puredangeroh yeah, what he said
15:42amalloycats are famous for shirking responsibility, though. don't count on what a cat should do
15:42engblomIs there a list of all throw-able exceptions somewhere?
15:42jkj_stuartsierra, puredanger: thanks... still not quite clear on the detail of mappings and cattings
15:42jkj_amalloy: :D
15:42amalloyengblom: the set is unlimited
15:42justin_smith$javadoc Exception
15:42lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/Exception.html
15:42TimMcengblom: You mean all subclasses of Throwable in the current JVM?
15:42dbaschengblom: do you mean in the java library?
15:43postpunkjustinengblom: I'm a huge fan of the Slingshot library, which lets you throw whatever you want!
15:43stuartsierraLargely superseded by ex-info.
15:44amalloystuartsierra: well. i'm a fan of ex-info, but i don't know that i'd say slingshot supersedes it
15:44justin_smithengblom: the above javadoc link has the direct subtypes of Exception that come with the lang, but subclassing (ie. with proxy) is pretty normal, and in clojure slingshot as mentioned above is quite popular
15:44amalloyer, the other way around
15:44stuartsierraJust throw ex-info.
15:44dbaschengblom: what’s the motivation for your question?
15:44amalloyex-info is a low-level tool for throwing maps; slingshot is sugar around catching them
15:44engblomThat javadoc link seem to be what I want
15:44stuartsierrasugar is bad for your teeth
15:44amalloyi don't really care for slingshot, but it provides a lot of stuff that is not in ex-info
15:45engblomdbasch: I need to throw something that do not sound to strange.
15:45dbaschengblom: what’s the context? It won’t sound strange if the context is right.
15:45gfredericksamalloy: stuartsierra: thus I made catch-data
15:45gfredericksmuch lighter-weight than slingshot
15:45dbaschengblom: e.g. IllegalArgumentException, UnsupportedOperationException, IllegalStateException, all those are self-explanatory
15:45amalloyyou can suggest not using slingshot (i do too), but it really is not superseded by ex-info/ex-data
15:45amalloy$google gfredericks catch-data
15:45lazybot[gfredericks/catch-data · GitHub] https://github.com/gfredericks/catch-data
15:46stuartsierraI'm just cranky today.
15:46technomancyamalloy: throw+ is superseded; try+ isn't
15:46dbaschLineUnavailableException sounds ancient
15:47gfredericksPunchCardBentException
15:47engblomdbasch: IllegalStateException is what I want :)
15:47justin_smithAmbiguousAbacusBeadPositionException
15:47amalloytechnomancy: welllllll, throw+ includes some misfeatures that are happily not included in ex-info
15:47amalloyit looks like gfredericks has decided to include them in throw-data, though
15:47TimMc"Java is unable to process this integer; it contains too many holes."
15:48gfredericksamalloy: eh?
15:48TimMcamalloy: Locals grabbing?
15:48amalloygfredericks: locals
15:48gfredericksI added that later; easy to remove, and not the point of the lib
15:48amalloyit is *so bad* to implicitly save all the locals in the exception
15:49hiredmanMUST NOT bad or SHOULD NOT bad?
15:49amalloyi guess i would have to say SHOULD NOT
15:49engblomNow I have a new version. Any comments are welcome: http://pastebin.com/F0a6WRVV
15:51gfredericksamalloy: just so I can win this conversation I'm going to go remove that misfeature right now
15:51technomancynice
15:51amalloygfredericks: oh interesting, you save them in the metadata instead of the map itself. that is actually only half as bad
15:51justin_smithengblom: I guess the string in (IllegalStateException. "Illegal move") helps as a comment, but due to being right next to the clause that catches it, we can easily see that the string doesn't really <do> anything
15:51gfredericksamalloy: for printing you mean?
15:51amalloyyou still have the head-holding issue, but you don't have a printing problem anymore, right
15:51{blake}I always strive to be half as bad.
15:51gfredericksI hadn't thought of that; got lucky I guess
15:52amalloyi remember i had a terrible time tracking down an issue in some code i took over, where i added an infinite seq in the lexical scope of an existing throw+
15:52technomancytalk about a heisenbug
15:52amalloyand then like...all my exceptions turned into OutOfMemoryError inside of print-method or something
15:53technomancyliterally doesn't manifest until observed
15:53gfredericksit'd be cool to have some sort of opt-in where you can list locals you want to include
15:53justin_smithExceptionInceptionException
15:53engblomjustin_smith: Thanks, I removed it.
15:53amalloygfredericks: oh! the syntax for it could be like (throw-data {:x 1 :locals {:y 2}})!
15:53amalloyer, (throw-data {:x 1 :locals {:y y}})
15:54amalloyspeaking of, a slight endorsement: (flatland.useful.map/keyed [x y z]) expands to {:x x :y y :z z}. a handy tool for any occasion!
15:54gfrederickshaha
15:55gfredericksamalloy: your point being it's easy enough that it doesn't deserve any help?
15:55amalloyyes
15:55gfredericksyou macro minimalists!!
15:55TimMc:unsyms
15:55gfredericks:unkeys
15:55amalloyunless you make it completely implicit, in which case you run into the problems already mentioned
15:55amalloyTimMc: keyed does that too, actually
15:56TimMcI guess it would be :unkeys
15:56amalloy(keyed :syms [x y z])
15:56TimMc(keyed :enums [oh god why])
15:57amalloy(keyed :my-car [those hooligans])
15:57TimMctechnomancy: estikes is spamming :-(
15:57amalloya kinda weird reverse-polish there
15:58TimMcI don't understand why they have to be in a channel in order to spam... maybe it helps them avoid detection?
15:58amalloyTimMc: to detect active users, i imagined
15:58amalloy"so and so is talking right now, let's PM them"
15:58technomancythat's my guess
15:58amalloy#clojure really just has the one persistent spammer
15:58TimMcAh, right -- increase the hit rate to reduce total volume.
15:59justin_smithamalloy: I wonder what the clickthrough rate is on that stupid link
15:59amalloyhah, i hadn't looked at the source for keyed in a while: https://github.com/flatland/useful/blob/develop/src/flatland/useful/map.clj#L15-L17 is vintage amalloy, using comp, partial, juxt, and identity all in close proximity
16:00TimMchiredman and Raynes should get their bots coordinated so that if someone not active in the channel sends both the same link, they are kicked.
16:00gfredericksthey could send a fax to technomancy
16:00amalloyTimMc: we'll get right on that as soon as you get someone to give lazybot and clojurebot ops
16:00dbaschprogramming language channels are terrible targets for spammers
16:00RaynesWe'd just fight over who sends the fax and never actually do it.
16:00TimMcamalloy: We need a third bot.
16:00RaynesBut he'd have to actually speak to me for that to happen, so none of this is feasible anyways.
16:00Raynes:p
16:01amalloysome sort of technomancer?
16:01technomancyso... how much would it cost to ddos the spammer
16:01TimMctechnomancy: They might be stealing service from someone innocent.
16:01amalloytechnomancy: in money, or moral turpitude?
16:01technomancyTimMc: then the innocent person would find out
16:01kitia_maybe just use an aws
16:01gfredericksamalloy: feature removed
16:01amalloy(inc gfredericks)
16:02lazybot⇒ 103
16:02TimMcturpitude is the name of my next clojure project
16:02danielcomptonpuredanger: it's working now
16:02gfredericksspeaking of :keys catch-data was a good opportunity to add an additional special key to map destructuring
16:02puredangerdanielcompton: good, sorry for the delay. the perms are pretty broad which is why they're not enabled automatically.
16:03puredangerdanielcompton: that could probably be adjusted, but the time to make implement and debug that vastly outweighs the manual work required currently
16:03danielcomptonpuredanger: just working on a post to the mailing list about that now
16:04amalloygfredericks: you're talking about the :ex key?
16:05amalloygfredericks: actually, why is throw-data a macro now? it could become a function now that you're not saving locals
16:06puredangerdanielcompton: the combination of the defaults + adding groups on CA (which Andy Fingerhut does currently) covers virtually everything. Andy or I make a few additional adjustments occasionally, but it's not worth overhauling the world
16:08gfredericksamalloy: uuuhm
16:08gfredericksamalloy: less stacktrace polution?
16:09gfrederickswho on earth is going to use a function like that in a higher-order-way anyhow
16:09gfredericksbring me that person and I shall ask him or her what he or she is up to
16:10TimMccomp
16:10gfredericks(comp launch-missiles throw-data)
16:11TimMc"*then* we launch ze missiles"
16:11gfredericksI try to keep imperative stuff and point-free stuff like totally separate
16:13amalloygfredericks: for sure it is hard to imagine someone using throw-data not in call position
16:13amalloy(map throw-data list-maybe-containing-errors)?
16:13amalloyobviously terrible
16:15TEttingertechnomancy: what is the main class for a lein-generated uberjar? I'm having terrible trouble getting a JRE bundler (libgdx's packr project) to do anything once it bundles an uberjar
16:15technomancyTEttinger: clojure.main if you don't set :main
16:15TEttingeris the main class the same as in Manifest.MF ?
16:16dbaschseeing Manifest.MF always makes me smile
16:16technomancyManifestfile
16:17TEttinger:main perlin.core.desktop-launcher :aot :all
16:17TEttingerso that would become perlin.core.desktop_launcher , right?
16:23danielcomptonAre there three different types of map: PersistentHashMap, PersistentArrayMap, and PersistentTreeMap?
16:24dnolen_danielcompton: yes, though the concrete implementations shouldn't matter for most code
16:24danielcomptondnolen_: I'm working on fressian encoders so I wanted to make sure I got all of them
16:25amalloydanielcompton: there are arbitrarily many though, of course
16:25dnolen_danielcompton: then I would check for IPersistentMap
16:25amalloyanyone can implement that interface
16:25amalloyevery defrecord creates a new thing that's a map
16:26puredangerdanielcompton: presuming Zach's unrolled collections stuff makes it into 1.8, there will be many concrete impls of the collections
16:33donbonifaciois there a func to compare keywords and strings? like (= "p1" :p1)
16:34puredangerI think name handles both?
16:34puredanger,(name "abc")
16:34clojurebot"abc"
16:34puredanger,(name :abc)
16:34clojurebot"abc"
16:34donbonifacioyes, but I don't want to be calling name. wel, I'll just create my own that wraps name
16:37anneliesStop calling me names!
16:43GlenjaminIs the truffle/graal stuff useful for clojure at all?
16:47amalloyhuh. the clojure compiler's interaction with synthetic bridge methods surprised me. background: hbase has an interface Query, containing: public Query setFilter(Filter f), and a class Get which implements that while narrowing the return type: public Get setFilter(Filter f)
16:48amalloyif you write (.setFilter ^Get g f), you get a reflection warning: there's actually two methods with the same name and args, one of which is "synthetic". but if you change it to (.setFilter ^Get g ^Filter f), the compiler is perfectly content, even though that didn't actually narrow things down at all: there are still two exact matches
16:49amalloyfurthermore, it's happy with (.setFilter ^Get g nil)
16:51amalloythere's always more to learn. i never did really understand bridge methods
17:03stuartsierraNo one understands bridge methods.
17:04stuartsierraE.g. http://dev.clojure.org/jira/browse/CLJ-1243
17:04amalloystuartsierra: after reading a few unhelpful blog posts, i found http://stackoverflow.com/a/5007394/625403 fairly helpful
17:13ro6I want to do something a bit unusual with nREPL and I'm wondering if anyone can help me figure it out. I need to remote debug an application running on a remote machine where I don't have control over what ports are open...
17:15ro6we use Pubnub for communicating with the client applications normally, because that works over the standard ports and I'm wondering if there might be some way to use the nREPL protocol over a Pubnub channel
17:15puredangerI have been working off and on for a while on improving vec and comparing its performance vs (into []) in the scope of CLJ-1546
17:16puredangerI just dropped a comment there that might update the folk wisdom of "into is faster than vec" for 1.7 http://dev.clojure.org/jira/browse/CLJ-1546?focusedCommentId=36428&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-36428
17:17puredangerassuming the patch makes it into 1.7, which I do expect
17:18puredangerI should probably write about a blog about this and share some of the data and other info I have, but I don't have time so I am just dropping it here :)
17:18cflemingpuredanger: That's interesting, thanks. I was wondering about that after seeing that Kibit suggests converting (into [] ...) into (vec ...)
17:19puredangerI don't think that advice was unambiguously true even before this patch
17:19cflemingpuredanger: I'm hopeful that a lot of these small optimisations, and things like ztellman's unrolled collections, will improve Clojure's speed pretty significantly for common use cases.
17:20cflemingpuredanger: No, it seemed like slightly overenthusiastic advice to me, I must admit.
17:21puredangerI think Zach's stuff is far more important than this, which is unlikely to be felt until IReduce things are more common. but I do think his can make significant changes. I am excited to dive into it for 1.8.
17:22hiredmanpuredanger: it would nice to have a blog post or something clarifying or just describe the intent behind all the Reduce interfaces and protocols
17:22hiredmanlike, should people still use CollReduce?
17:22puredangermaybe post-conj I'll have time to do some of that
17:23puredangerabsolutely, you should use CollReduce. It's the primary open system for reducible collection.
17:23hiredmanso what the heck is with Reduce and ReduceInit?
17:23puredangerIReduce is a fast path for things that we can change (thus closed)
17:24puredangerfor example, we want ArrayList to be reducible so CollReduce (the protocol) allows to extend to types we don't own
17:24puredangerIReduce is a marker for things we do own, like PersistentList, PersistentVector, Range, etc
17:24hiredmanso if I am implementing something I can (and should?) use IReduce (or should I use ReduceInit?)
17:24puredangerif you can implement IReduce, then do so
17:25puredangerIReduceInit and IReduce now split the arities of reduce (with or without and initial value)
17:25puredangerIReduce extends IReduceInit and has both
17:25hiredmanI see
17:25puredangerI think Rich regrets combining them originally
17:26puredangerI'm not sure that I have it totally sorted in my head which you should prefer if implementing something right now
17:26hiredmanI can imagine, dealing with both when implementing coll-reduce is a drag
17:27cflemingI'd love to see a blog post with some guidance on this, I've never dug into the implementation of all this and it's very confusing from a user POV
17:27puredangersure, would love to do it
17:28hiredmanhttp://www.youtube.com/watch?v=PHVeyo4W18U
17:28hiredmanor the opposite or whatever
17:29nickmbaileywhats the idiomatic way to do a non lazy (concat…)? just (apply conj…)?
17:30puredangerhiredman: more the opposite I think :)
17:31dnolen_nickmbailey: into works pretty well
17:31dnolen_nickmbailey: assuming you have vectors off course
17:31nickmbaileyahh
17:31dnolen_nickmbailey: if you have seqs, there's no option beyond concat
17:32nickmbaileywell, apply conj still works with seqs right?
17:32hiredmannickmbailey: why not just use concat and doall?
17:32puredangeryou could transduce a cat right?
17:33puredanger(I realize that sounds like a bad intro to a joke)
17:33dnolen_,(conj '(1 2 3) 4)
17:33clojurebot(4 1 2 3)
17:33annelies> Transduction is the process by which DNA is transferred from one bacterium to another by a virus.
17:33dnolen_nickmbailey: ^
17:33anneliespuredanger: out of luck; cats aren't bacteria
17:33nickmbaileyhiredman: that would work too, but into works in this case
17:34puredanger,(transduce cat conj '((1 2 3) (4 5 6) (7 8 9)))
17:34clojurebot[1 2 3 4 5 ...]
17:36dnolen_puredanger: oh heh, yeah now that conj returns [] for arity zero - hadn't thought of that
17:36dnolen_,(conj)
17:36clojurebot[]
17:36puredangeryou can get a list too if you like
17:36puredanger,(transduce cat conj '() '((1 2 3) (4 5 6) (7 8 9)))
17:36clojurebot(9 8 7 6 5 ...)
17:36puredangerha :)
17:37dnolen_ah right
17:37puredanger,(transduce cat conj #{} '((1 2 3) (4 5 6) (7 8 9)))
17:37clojurebot#{7 1 4 6 3 ...}
17:37puredangerconj is fun
17:38anneliesWhat's the difference between transduce cat conj and into?
17:38dnolen_annelies: into will try to use transients
17:39annelieslemme google that
17:39dnolen_annelies: into is now actually defined in terms of transduce
17:39dnolen_well the arity where given an xform anyway
17:39anneliesAh, I see.
17:45anneliesI'm gonna sleep. Byebye!
17:46danielcomptonpuredanger: thanks for your feedback on the list, I wasn't trying to disrespect Rich's wishes, just trying to offer other ways to create a patch
17:47mikerodWould it be considered safe/fine to embed a var object into code generated during macroexpansion?
17:48mikerode.g. say the macro is: (defmacro embed-var [x] `(list ~(resolve x)))
17:48mikerodcalled like: (embed-var my-testing-var-name)
17:49mikerodseems fine in returning: (#'user/my-testing-var-name)
17:50mikerodI'm contrasting this to the embedding something like (Object.) into the code returned from macroexpansion
17:50mikerodwhich doesn't have a clean reader-literal format
17:54tuft_does anyone know where i can get the user/clojuredocs function mentioned here: https://github.com/technomancy/leiningen/issues/594 ?
18:02vermaI am writing a 3D engine for a specific purpose using clojurescript (displaying point clouds for next iteration of http://plas.io), what the engine renders is completely controls by a state, which is a hash-map, indicating, what cameras are loaded, what point clouds are loaded, what the eye position is, where the camera is looking and other things needed for a scene to render.
18:03vermathe user sends down a state, which I convert into a runtime-state
18:04puredangerdanielcompton: no worries :)
18:04vermabasically the user says, I want buffer x to be added to the scene, this buffer X translates to an action which downloads the buffer and adds it to the scene.
18:04vermawhenever the runtime state changes a re-render is triggered.
18:05muckhi
18:05vermasince buffer loads are async, I have a cursor (loosely based on om cursors), which can be transacted into, which casuses the re-render
18:05danielcomptonpuredanger: The Clojure community really does appreciate your work, thanks for everything you do
18:06vermathere may be renders queued up for rendering while I am changing things with the run-time state, which will reflect during the next render cycle
18:07vermanow, underneath all this, the calls eventually go to webgl, the problem is that some state updates delete buffers
18:08vermabut the state already queued up for rendering may still refer to it
18:08hiredmansounds like you get to write a gc!
18:08verma:(
18:08hiredmana simple mark and sweep is easy as pie
18:09hiredmanhttps://github.com/hiredman/kvgc/blob/master/src/com/manigfeald/kvgc.clj
18:09vermachecking
18:10vermahiredman, nice!
18:11vermahiredman, "Because one day my processes will loose these bonds of physical machinery, to compute using transcendent nominal mechanics outside the boundaries of electrical components so cruelly referred to as being random access, and it seems like having a garbage collector when that happens would be nice."
18:11vermanice!
18:11hiredman:)
18:11vermaok, I can probably use that as inspiration to write something similar
18:12vermathanks!
18:12hiredmanyeah, I very pleased with how it turned out, I ended up using it to do gc of stuff out of embedded sql databases for another project
18:12hiredmanbut I guess I never pushed the releases to clojars or something
18:14verma(inc hiredman)
18:14lazybot⇒ 61
18:15hiredmanhttps://github.com/hiredman/graph/blob/master/src/com/manigfeald/graph/gc.clj using the protocol there to gc parts of representations of graphs out of a derby database
18:25amalloymikerod: i wouldn't recommend it, even if it does happen to work. why would you want to?
18:26mikerodamalloy: I'm just trying to decide if it was a good or acceptable practice or not
18:26mikerodif an object has a reader printable representation then it is acceptable in generated code though I take it
18:26mikerod?
18:27mikerodIn this case specifically, I was reviewing some code that was wrapping resolved vars into function calls (they were bound to functions)
18:27mikerodso like (defmacro call-var [var-sym] `(~(resolve var-sym)))
18:27mikerodit was not this simple. I just ripped off all the rest of what happened there.
18:28mikerodThe resolved vars are used elsewhere in the macro, but I wasn't sure if the suggestion should be to leave the var-sym as-is and not call the resolved var in the code returned.
18:28mikerode.g. (defmacro call-var [var-sym] `(~var-sym))
18:29amalloyi would much prefer the latter of those two
18:29amalloyif nothing else, what if var-sym is a macro?
18:29amalloythat is, it resolves to a macro
18:31amalloyeg, compare ##[(or 1 2) (#'or 1 2)]
18:31lazybot⇒ [1 nil]
18:33mikerodamalloy: ah yes, I've seen that before due to the "hidden" first 2 args
18:33mikerodSo it is bad to call a macro by its acutal var then
18:33mikerodactual*
18:33mikerodCompiler can't detect it I suppose?
18:34mikerodI see it is just returns the var and then the var is invoked as a fn.
18:34amalloydetect what? maybe you call the macro through its var on purpose; it shouldn't stop you. instead, just don't write code that does things you don't want to do
18:35kzarIs it possible to transform an element based on it's one of it's attributes using kioo?
18:35kzarI want to assign a class if a attribute has a certain value
18:36kzarOh I guess I could just have two transforms, one to remove the class for all the elements and one to add the class in for the elemnt with the attribute I'm looking for... Sorry - dumb question
18:37mikerodamalloy: So macros should be called only through their symbols is what I'm saying
18:37mikerodfor normal behavior
18:37amalloyyes
18:38mikerodinteresting
18:38razum2umcan I manually resolve an url to get matching compojure's handler?
18:38mikerodwell thanks for the ifo!
18:38amalloyfunctions really should too; vars do some things that would surprise you
18:38mikerodinfo
18:38mikerodhmm I see
18:38mikerodmakes sense then
18:38amalloymikerod: for fun, try this: (defn foo [& args] (first args)) (apply foo (range)) (apply #'foo (range))
18:39amalloy(i have a patch filed to fix this behavior, which IMO is a bug, unlike the macro var thing that i consider a feature)
18:41amalloyspeaking of which, if this behavior bothers anyone, go upvote http://dev.clojure.org/jira/browse/CLJ-1423
18:54{blake}OK, I'm going cuckoo trying to figure out how to make compojure routing work with a context.
18:54{blake}I've got a simple example: https://www.refheap.com/93325
18:54{blake}And I think I understand what's happening (as explained there) but not why, or how to fix.
19:00amalloy{blake}: wrap-context does "hide" the context, because that's the only way it would be useful at all; i think you have to emit a link that contains the context in it. ie, instead of /linked, you have to emit a link to /hello/linked
19:01gfredericksor "linked" might work too?
19:01amalloygfredericks: sure, relative links will be fine
19:01amalloyassuming you never need an absolute link
19:01{blake}amalloy: OK, so, I clearly don't know what's what. Because I want my code to be agnostic as to where it is.
19:01mikerodamalloy: that is interesting
19:01mikerodI'll have to look closer at the Compiler to see what is going on there
19:02{blake}I started with relative links, but maybe I screwed them up.
19:02amalloy{blake}: indeed, you should be agnostic; you can *find out* where it is by looking at the :context of the request, or something like that
19:02{blake}Because that's the obvious handing.
19:02amalloymikerod: it's not the compiler; it's c.l.Var
19:02vermaswap! says that the passed function should be free of side effects, I get that, if I am holding a pointer to a resource and I want to transactionally release it, what's the best way?
19:02{blake}amalloy: Yeah, I went that route, too: Wrapping the route in the context.
19:02amalloy{blake}: huh?
19:03amalloythat's fine for handling requests, but you have to also look at what the context is before you emit any absolute links
19:03{blake}amalloy: Created a middleware that took the context and prepended the uri with it.
19:03gfredericksverma: agents are okay for side-effects
19:03gfredericksI don't quite understand what you're doing though
19:04amalloyverma: you can swap with a function that doesn't actually do side effects, but instead returns whether it's okay to do side effects
19:05vermagfredericks, I want to release a webgl texture which is a part of a state controlled/driven 3D engine
19:05vermaamalloy, hmmm interesting
19:05amalloysomething like (let [r (swap! resource (fn [r] (if (:cleaned? r) (dissoc r :okay-to-clean) (assoc r :okay-to-clean true, cleaned? true))))] (when (:ok-to-clean r) (cleanup! r)))
19:06amalloythis guarantees that no matter how many threads are running this code at once, exactly one of them gets the ok-to-clean signal
19:06amalloymodulo awful typos like okay/ok
19:07hiredman,(doc compare-and-swap!)
19:07clojureboteval service is offline
19:07hiredmanjerk
19:07hiredman(doc compare-and-swap!)
19:07clojurebotTitim gan éirí ort.
19:07mikerodamalloy: I still don't understand why `(macroexpand-1 '(#'or 1 2))` ;= ((var or) 1 2)
19:08vermaamalloy, makes sense, thanks
19:08mikerodWhen digging through some Compiler#analyzeSeq
19:08hiredman(doc compare-and-set!)
19:08clojurebot"([atom oldval newval]); Atomically sets the value of atom to newval if and only if the current value of the atom is identical to oldval. Returns true if set happened, else false"
19:08mikerodohhh
19:08amalloyoh, hiredman is probably right. CAS makes more sense than my swap nonsense
19:08amalloyalthough mine is clever
19:09mikerodI do understand it now
19:09mikerodand for the apply thing, I'll look at c.l.Var
19:10vermaamalloy, I do feel your case applies more for my case, I wouldn't know what the oldval is, I need to figure what it is going to be, so I need a function instead of an old val
19:10amalloyverma: well, the idea with CAS is you deref it first
19:11amalloyderef, construct a candidate new value, and then attempt to CAS it
19:11amalloyif the CAS succeeds, you go ahead with your side effects
19:11amalloyif it doesn't, someone else must have gotten to it
19:11vermanice
19:12{blake}OK, so I now have "/" GET "linked" and another "/linked".
19:12{blake}That is I took out the slash before "/linked" in the HREF.
19:12{blake}This works locally.
19:13{blake}It creates this HTML: <a href="linked"> click</a>
19:14{blake}With the deployed WAR, it's still looking for "localhost:8080/linked" instead of "localhost:8080/hello/linked".
19:15{blake}(I started by deleting the slash in (GET "/linked") but that doesn't work locally.
19:26erikcwI have a tree shaped data structure that I need to walk until I find a specific branch (identified as a map containing the key :id). I’ve played with clojure.walk, but can’t seem to make it stop and return the branch when it is found (it just keeps going to the bottom of the tree) — am I using the wrong tool?
19:27dbascherikcw: what’s wrong with recursively traversing the tree yourself until you find it?
19:28erikcwdbasch: Nothing — just wanted to know if it was possible with clojure.walk.* or zippers, or some other Clojure goodie…
19:28dbaschbtw, if you need to traverse the tree perhaps that’s the wrong structure for what you have
19:28hiredmansure zippers will do it
19:28hiredmanclojure.walk not so much
19:28cflemingjustin_smith: You're working on updating lazybot, right?
19:29NoCreativityHello
19:29erikcwhiredman: Thanks — I’ll go read up
19:29justin_smithcfleming: I patched lazybut up to work with clojure 1.7, and the latest irclj, yes
19:29cflemingjustin_smith: Are you accepting feature requests?
19:29amalloy~lazybot is a lazybut
19:29clojurebot'Sea, mhuise.
19:29dbaschalthough it may be harder with zippers than just traversing the tree yourself
19:30NoCreativityI'm having some problems trying to consume a :edn type request. does anybody has samples of a POST|PUT request that consumes :end? Thanks in advance
19:30justin_smithcfleming: well, feel free to submit on noisesmith/lazybot if you like (or on raynes/lazybot and I will likely find it there too)
19:30cflemingjustin_smith: There's a ton of useful information in here, which never makes it out and isn't really archived in any useful form.
19:30justin_smithor discuss here less formally of course :)
19:30Raynescfleming: Well, we're all accepting feature requests.
19:30RaynesLazybot isn't an abandoned project.
19:30erikcwdbasch: I’m stuck with a tree. It is actually a Reagent “component” data structure
19:30cflemingI know it's logged, but trawling through there is a pain.
19:31justin_smithcfleming: ahh, publishable knowledge db
19:31Raynes:)
19:31cflemingRaynes: Great :)
19:31amalloyi am accepting feature requests but just proxying them to Raynes
19:31RaynesI'm accepting feature requests and proxying them to justin_smith.
19:32RaynesWe have a knowledge database thing that sucks.
19:32cflemingI think it would be useful to have a command to give a range of timestamps, and perhaps the people involved in the conversation and a subject line, and take those items and publish them somewhere.
19:32justin_smithamalloy: I assume that thing with privmsg triggers wasn't solved
19:32amalloyjustin_smith: i didn't touch it, no
19:32technomancyRaynes: hm; how do you teach lazybot facts?
19:32amalloy$learn technomancy super-smart
19:32lazybotMy memory is more powerful than M-x butterfly. I won't forget it.
19:32amalloy$whatis technomancy
19:32lazybottechnomancy is super-smart
19:32RaynesExcuse me.
19:32RaynesBy knowledge base, I mean: "key value store"
19:32technomancycool. can that be invoked inline like eval can?
19:33RaynesNo.
19:33RaynesAdding inline invocations is harder than adding commands.
19:33amalloytechnomancy: once upon a time, there was a feature that any lazybot command could be invoked inline
19:33RaynesAnd more likely to cause painful plugin interactions.
19:33technomancysure, and more likelihood of accidental triggering
19:33cflemingMight get a little unwieldy, something like /store 13:27:58 13:32:17 justin_smith cfleming Raynes amalloy "lazybot archiving"
19:33justin_smithamalloy: I got that fixed, but it is not yet re-enabled I don't think
19:34cflemingMaybe it could just publish gists or something
19:34Raynesjustin_smith: Oh, I can reenable that.
19:34Raynescfleming: We don't do gists here son.
19:34amalloyjustin_smith: the embedded plugin is enabled right now
19:34justin_smithRaynes: amalloy: that's just a question of including the plugin in the config, yeah
19:34justin_smithamalloy: oh!
19:34justin_smithOK
19:34RaynesYou in the wrong place
19:34cflemingRaynes: refheaps, I mean.
19:34RaynesDamn right.
19:34RaynesThis guy knows what's up.
19:34cflemingDon't know what I was thinking.
19:35cflemingAnyway, I think that would be really useful - there's a lot of knowledge dumped here that never gets out
19:35dbaschRaynes: github is making refheap seem prettier every day :P
19:35technomancyoh maaaaan. I saw some pretty hideous clojure highlighting earlier today
19:35RaynesI haven't updated refheap's pygments in like two years.
19:35technomancyred background on numeric literals; just the worst
19:36technomancyRaynes: like a google groups competitor, not getting worse over time may be all you need for a competitive advantage.
19:36amalloytechnomancy: i can't imagine what rule they're applying that makes that seem like a good idea
19:36justin_smithdoes $#ping#$ work?
19:36anybotjustin_smith: Ping completed in 0 seconds.
19:36justin_smith@part #clojure
19:36anybotBai!
19:37justin_smithRaynes: do you have a different symbol setup for embedded commands?
19:37RaynesDo I? Good question.
19:37amalloyi don't think it's even configurable
19:38dbaschRaynes: I was thinking exactly what technomancy said
19:38justin_smithamalloy: you're totally right, it isn't
19:38technomancylike when librelist came out I was like "what is the point of this; who needs it" and then google groups got worse with every passing year, and now I'm like "this is so cool"
19:38Raynesjustin_smith: It isn't configurable.
19:38RaynesJust to be clear.
19:39justin_smithright
19:40technomancyhttps://github.com/technomancy/atreus/blob/master/atreus.rkt#L157
19:41technomancyred background on *brackets*
19:41hiredmanhah, oh lord
19:41technomancyhttp://p.hagelb.org/sound-of.gif
19:42amalloyi wonder if the red brackets are the styling for "syntax error" and they're just no good at parsing clojure
19:42technomancyamalloy: well
19:42technomancythat's not clojure
19:42technomancybut yeah
19:47justin_smithRaynes: amalloy: weird, git tells me that your embedded.clj is the same as mine, but it clearly is not working with lazybot
19:48dbaschtechnomancy: it looks much better if you tell them it’s clojure, I wonder why they have such crappy highlighting for Racket. https://gist.github.com/dbasch/0a45cae2409e5e965641
19:49technomancytruly inscrutable
19:59kenrestivo##(doc compare-and-swap!)
19:59lazybotjava.lang.RuntimeException: Unable to resolve var: compare-and-swap! in this context
20:00caternlibrelist is cool thanks for mentioning it
20:00amalloycompare-and-set!
20:00technomancycatern: it's got its problems, but it's much better than the alternatives
20:00caternwell, i host my own mailing lists :)
20:01caternbut it looks like something i can recommend to others
20:01technomancycatern: the main problem is you can't have a "welcome" type page explaining what the mailing list is about and how to join
20:01technomancywhich is pretty annoying, but
20:01technomancyat least it's not google groups
20:03caterntechnomancy: as in you don't want to have to throw that page up somewhere yourself? because surely most open source projects already have websites
20:03catern(oh wait, they have github pages now. well, anyway)
20:03kenrestivo*cough* gnu mailman *cough*
20:03technomancycatern: well, you can't just point someone at the archives without some explanation
20:04technomancyyou need one page to explain it and a separate page for the HTML archives. having them in one place would be better, or at least the ability to link from the archives to the primary web site
20:04technomancykenrestivo: I don't trust myself with port 25
20:04caternah. hmm. true.
20:06technomancycatern: also it's abandonware, but that is not as bad a problem as you'd expect
20:06danielcomptoncfleming: why did you decide to host the cursive list yourself?
20:06danielcomptoncurious
20:06cflemingdanielcompton: Because I pretty much hate Google groups
20:07danielcomptoncfleming: bahaha
20:07cflemingdanielcompton: Plus, control your data etc etc
20:07dbaschgoogle groups have become what yahoo groups used to be
20:07cflemingdanielcompton: I'm gradually degooglifying my life
20:07technomancy(dec google)
20:07lazybot⇒ 1
20:08cflemingdanielcompton: I looked at librelist but it explicitly states it's for OSS projects only
20:08caternopinions are divided it appears
20:08cflemingdanielcompton: I like the look of Lamson (which LL is based on) but I couldn't get it working when I tried.
20:09danielcomptonthey all look like a bag of hurt to run yourself
20:12cflemingIn the end I settled on mlmmj, which I really like
20:12cflemingDoes everything I want, and nothing that I don't.
20:12dbaschyou could have a subreddit, I think you can have a subreddit for anything
20:12technomancyheh
20:12dbascheven things that should not exist
20:12amalloysubreddits are as cheap as uh...core.async channels
20:12cflemingActually, I'd like a web archive, but I'll roll that myself one day.
20:13technomancyhttps://www.reddit.com/r/MenonUnstableLadders/
20:13technomancyhttps://www.reddit.com/r/bezels
20:13dbaschtechnomancy: http://www.reddit.com/r/ooer
20:13cfleming"Too much champher, not enough bezel?"
20:13cflemingI thought I had first world problems.
20:14amalloydbasch: http://www.reddit.com/r/wowthissubexists/ (no guarantees about whether this is safe for work, although it claims to be)
20:14technomancydbasch: O_O
20:15danielcomptonNOT GOOD WITH SOCKS PLZ HALP???
20:15lazybotdanielcompton: Yes, 100% for sure.
20:15cfleminglazybot is so obliging.
20:15dbaschhttp://www.reddit.com/r/shittyprogramming
20:17danielcomptonJust add this line at the beginning of main():double speed;that will tell the compiler that you want it extra fast. It should produce a notable improvement in execution speed.
20:18amalloydanielcompton: long time; since i heard that joke
20:18kenrestivoin cisco, land, there was "> ip enable more bandwidth", IIRC
20:19danielcomptonhttp://i.imgur.com/Me04jVB.jpg
20:21dc_ danielcompton: lmao
20:22dc_if i'm using java interop and i want to import java packages, how to i ensure that they're in my classpath when i run my code?
20:23dc_i've imported a library with lein that uses these same java packages
20:23kenrestivoit may pull them in transitively. try lein tree and see?
20:23TimMcdanielcompton: ...
20:23TimMcIt's brilliant.
20:24TEttingerdc_: how are you running your code? lein uberjar should pack those java packages into the jar
20:24dc_and the JAR that contains these packages is referenced in my :resource-paths and :jvm-opts in project.clj
20:24dc_kenrestivo: k, i'll try that
20:24danielcomptondc_: lein tree :deps to show the transitives
20:24amalloylein deps :tree
20:24danielcomptonlein derps :tree
20:24danielcomptonwhat amalloy said
20:27dc_TEttinger: `lein uberjar` successfully compiled the classes and packed them into a jar, but i'm still having trouble running the repl
20:28dc_or actually, it ran in the console
20:35dc_also, i'm working with the aparapi-matrix library, which integrates with the java aparapi lib for matrix ops using the GPU. but when i enter the REPL and enter my namespace, none of the methods i've defined are recognized.
20:36dc_instead i get a wierd error that says i have a compilation error in a temp file
20:36dc_like this one: /private/var/folders/tv/cj4wg9x57xjbd2w91cp5r77c0000gn/T/form-init8574980338355462022.clj:1:1062
20:36dc_what does that mean?
20:38dbaschdc_: refheap the whole error
20:39amalloydc_: (ns foo) doesn't load any of the code defined in foo; that's the job of (require 'foo). it just puts you into the namespace foo so that you can start defining it
20:40dc_dbasch amalloy: it started working. using `lein uberjar` and `lein run` must have done something. now i can access the methods in my core namespace inside the repl
20:41dc_thanks for helping though
20:43dc_this aparapi-matrix library seems awesome though
20:44dc_so far it seems to be working well with core.matrix, but i haven't tried much more than the aparapi-matrix examples
23:37smnirventhis probably isnt the appropriate forum for this question, but does anybody know what happened to clojure-fill-docstring in clojure-mode?
23:37justin_smithsmnirven: if nobody here knows, you may want to try #clojure-emacs
23:38smnirvenperfect