#clojure logs

2012-10-28

00:03muhoouse ALL the cores!
00:03tomojI wonder what's a good way to deal with learning that two datomic entities actually represent the same entity. then later learning that that was an error
00:35Sgeo@mail `fogus If I buy your book from B&N, how do I get the ePub version?
00:35SgeoWhat's the correct command?
00:45xeqi$mail Sgeo maybe this one?
00:45lazybotMessage saved.
00:46SgeoThanks
00:46Sgeo$mail `fogus I bought your book on B&N. Is it possible, from that, to get the ePub version? (Preferably before the physical book arrives, because it might be a while due to hurricane)
00:46lazybotMessage saved.
01:04S11001001Sgeo: if you mean joy, you need the code in the leaflet in the physical book
01:05S11001001Sgeo: also, there's a major sale on manning.com for next few days; buy direct from them and it adds to your account right when you buy
01:07SgeoS11001001, too late
01:07S11001001Sgeo: today and tomorrow dead trees (including ebook), tuesday ebooks, wednesday everything
01:07Sgeolazybot, mail
01:07S11001001Sgeo: can't cancel an order on bn?
01:07SgeoS11001001, I can, but why bother?
01:07SgeoS11001001, also, easier for me to pay for stuff on B&N than elsewhere (long story)
01:08S11001001Sgeo: to be able to get the ebook right away
02:47SgeoDoes forcing a lazy sequence mutate stuff?
02:47SgeoSuppose I have (def nums (range))
02:47SgeoI do something like (doseq [i nums] (println i))
02:48SgeoHmm, bad example
02:48Sgeo(def nums (range some-really-large-number-such-that-holding-onto-the-entire-seq-at-once-will-run-out-of-memory-but-the-number-itself-isnt-that-big))
02:48Sgeo(doseq [i nums] (println i))
02:48SgeoWhen everything is done printing, will I have run out of memory?
02:49SgeoOr will nums be not forced?
02:52tomojif nums isn't forced, what would print?
02:53tomojyou will run out of memory
02:55tomoj#'nums holds a reference to the head of the seq, so none of the seq can be garbage-collected
02:56tomojhttp://programming-puzzler.blogspot.com/2009/01/laziness-in-clojure-traps-workarounds.html
02:56tomojthat is interesting in comparison to rx
02:56tomojreminiscent of hot vs cold observables
03:13Sgeorx?
03:15scottjSgeo: probably reactive extensions on .net
03:18tomojand/or js
04:49sheldonelsis there a way to recurse without naming a function? like, to just recall the function you're in at the moment
04:50rodnaphsheldonels: recur?
04:54Sgeosheldonels, ##(doc loop)
04:54SgeoOh, you probably want recur
04:54SgeoIgnore me
04:54SgeoBut the two go togethre
04:54Sgeotogether
04:54SgeoBut you can recur without loop
04:54SgeoOk, I'm shutting up.
04:55sheldonelsheh, no worries
04:55sheldonelsbeen reading about recur since rodnaph mentioned it, the docs are above my functional grade I think
04:56sheldonelsboth the explanation on special forms and the examples are confusing, but I think I'll get it eventually
04:57rodnaphsheldonels: u don't have to think about special forms any differently than functions, it's just an implementation detail.
04:58Sgeorodnaph, that... seems like that could cause some harm, saying that
04:59sheldonelsok, not sure I'll grasp this without some help, the docs say (recur exprs*)
04:59sheldonelsEvaluates the exprs in order, then, in parallel, rebinds the bindings of the recursion point to the values of the exprs.
04:59Sgeosheldonels, first: Do you know what tail-call recursion means?
04:59sheldonelsis this like saying recur can mutate the things passed into the function above it?
04:59sheldonelsnot really
05:00rodnaphSgeo: well, maybe "don't worry about it for now" is better advice.
05:00sheldonelsI know clojure doesn't do it fully as a result of the jvm, and that other lisps do
05:00Sgeorodnaph, that seems like it would be better for special forms v. macros
05:00sheldonelsheh, I'm ok with that, if it's something for later, for now I should just name my functions for recursion purposes
05:00rodnaphyes, i almost said macros, but that would have probably just led to more questions, when it wasn't what was trying to be understood. but anyway...
05:01SgeoLet's pretend for the moment that Clojure has it
05:01SgeoAnd I want to define a factorial function
05:01sheldonelsok
05:01Sgeo(defn factorial [n] (* n (factorial (dec n))))
05:01sheldonelsyep
05:01Sgeo(dec is a function that returns its argument - 1
05:02SgeoWhen I call (factorial 5), it needs to do (* 5 (factorial 4))
05:02sheldonelslike -- in imperative langs, yep
05:02SgeoAnd that factorial 4 needs to do 4 * factorial 3
05:02SgeoAnd so forth
05:02sheldonelsgotcha
05:02SgeoNone of these can return until the one at the bottom returns
05:02SgeoOh, pretend that (factorial 0) returns 1, forgot to do that lol
05:02sheldonelsyep, so it's kinda like a stack of function calls
05:02SgeoYes.
05:03sheldonelsand the stack has to get bigger with each recursion
05:03SgeoYes.
05:03sheldonelsuntil some limit
05:03SgeoSo, with a large enough n, my function will crash.
05:03sheldonelsor your computer explodes :)
05:03SgeoAnd will use a lot of memory even if it doesn't crash.
05:03sheldonelsyep, the usual worry with recursion style programming
05:03SgeoNow, let's define factorial differently:
05:04Sgeo(Pretending that Clojure has tail-call optimization, which it doesn't)
05:04Sgeo(defn factorial [acc n] (if (== n 0) acc (factorial (* acc n) (dec n))))
05:05SgeoLet's look at what happens with (factorial 1 2)
05:06SgeoIt will call (factorial (* 1 2) (dec 2)), which is (factorial 2 1)
05:06SgeoAnd the function will return that
05:06SgeoBut since the function is going to return that, if Clojure was smart, it doesn't need to keep track of where it's coming from
05:06SgeoThe stack of function calls doesn't need to grow
05:07SgeoDoes this make sense?
05:07sheldonelskinda, just mulling over the brackets a bit still
05:08sheldonelsin your example, you're calling 1 2
05:08sheldonelswhy is 1 there as well
05:08SgeoIt's the accumulator, the trick I'm using in order to avoid needing to grow the function stack
05:09SgeoWhen n is 0, I just return the accumulator, which will be the answer.
05:09sheldonelsright, a way to sum up each step
05:09SgeoWell, multiply up each step, but yes
05:10sheldonelsand that's the key to avoiding needing to keep track of each step in a stack right, cause it's a passed along value
05:10sheldonelsthink I got it
05:10Sgeo:)
05:10sheldonelsactually, still not sure how that form wouldn't have a stacked effect
05:11sheldonelsit still needs to call over and over right
05:11sheldonelsand wait for the 0 condition it unwind
05:11SgeoIt is getting called over and over, but since the result of the call is the result of the function, it doesn't need to bother storing where it's calling from
05:12SgeoThere's no multiplication that it still needs to do as it unwinds, so it doesn't need to bother with growing the stack
05:12sheldonelsright
05:12sheldonelsgotcha
05:12SgeoTail-call optimization refers to whether the language is smart enough to detect this. Clojure is not.
05:13SgeoHowever, Clojure provides a form called recur, that you would use in place of that inside factorial call
05:13Sgeo(defn factorial [acc n] (if (== n 0) acc (recur (* acc n) (dec n))))
05:14sheldonelsmakes a whole lot more sense now, thanks
05:14SgeoYou're welcome
05:15sheldonelsso using recur is a good idea whenever you can if I'm reading the docs right, as it's the only non stacked recursion available?
05:15SgeoBut note that you can ONLY use recur in places where it will be the return value of the enclosing ... function or loop form.
05:15Sgeosheldonels, there's another form of non stacked recursion, but it's more annoying to use
05:15sheldonelsheh, fair enough
05:16sheldonelsI'm ok with skipping the annoying parts :)
05:16SgeoWell, if you're interested, look up trampoline
05:16SgeoIt does things you can't do with recur
05:20SgeoAnd with recur you should probably look at loop
05:20sheldonelswill do
05:20sheldonelsit's quite a tough thing at first, all this recursion. my first time learning a functional language. so used to imperative style stuff.
05:21SgeoI should note that often you can avoid using recur, since there are easier ways to loop. recur is mainly for when you need explicit recursion, there are functions that are implemented using it but are easier to use than using recur directly.
05:21sheldonelsin your 2nd example using recur, the named fn wouldn't necessarily need a name right? recur can just work out to rerun the function/loop it's in?
05:22sheldonelssure, I've been working through 4clojure.com to try learn
05:22SgeoRight
05:22sheldonelsI think they purposefully are sidestepping those easier ways to help the learning process
05:22sheldonelslike some of the questions disallow certain functions that would make the answers trivial
05:23sheldonelsI'm about to try do a function to count the things in a sequence, going to see if I can do it with recur now
05:23SgeoAwesome
05:23SgeoAfter you do that, see if you can find a way to do it without recur.
05:29sheldonelsheh, no luck working it out, maybe without recur will be easier
05:30rodnaphdoes anyone know with aleph, if i can use a single (wrap-ring-handler) for all my compujure routes, or if it needs to be done once for each route. doesn't seem to work, but wanna see if that i'm doing *should* work befroe investigating further...
05:32Sgeosheldonels, hmm.
05:32sheldonelsyep, got it
05:32hiredmanrodnaph: a single wrap-ring-handler should work, but it tends to eat exceptions, so you should wrap your routes in something that deals with them somehow (prints them out or whatever)
05:32sheldonelsnamed functions I guess are easier for my tiny brain!
05:32sheldonelswhy is recursion so hard, stupid thing
05:32sheldonelsheh
05:33sheldonelswith recur, I'm getting a "Can only recur from tail position"
05:33Sgeosheldonels, you can't try to "do stuff" like multiply the result of a recur
05:34sheldonelsis that cause of similar to your first factorial example, I can't use this construct unless the value it returns doesn't get reused in the function it's called from?
05:34SgeoIt can only go back up to the enclosing function or loop
05:34sheldonelsright
05:34Sgeosheldonels, yes
05:35sheldonelsis the factorial example doable with recur without an accumulator? I don't think so, just checking
05:35SgeoI don't believe so
05:46sheldonelsno luck with the recur version, I need an accumulator, but can't default it to 0 it seems
05:46sheldonelsif I make it optional, then I get a really weird error
05:46sheldonelsand default makes it mismatch the argument count
05:46sheldonelsI guess recur can only do runtime matching arguments
05:48sheldonelsanyone know why I would be getting this error? https://gist.github.com/3968185
05:50rodnaphlooks like the destructuring is causing problems as you recurse maybe?
05:51sheldonelsI'm not even seeing a long anywhere there, is it something internal as part of recur maybe?
05:51rodnaphor the (next l) actually. l is a long correct?
05:52rodnaph`(next [1 2 3])
05:52sheldonelsa list
05:52rodnaphoops
05:52sheldonelsthe idea is to count the items in the list
05:52sheldonelsusing an accumulator so that I can recur
05:52rodnaphyah, but (next 1) doesn't make sense (and will give that error)
05:53rodnaph(next) needs to take a collection, not a single long
05:53sheldonelsright, I thought (next '(1 2 3)) gives '(2 3)
05:53rodnaphyes it does
05:53sheldonelsl is my list I think, unless I messed up the syntax somewhere
05:53sheldonels(next l) should be l minus 1 item
05:54rodnaphwell, l is not a list in some call (that's what the error is saying)
05:54sheldonelsright, I see
05:54sheldonelsthanks :)
05:57sheldonelsah well, I give up, at least I got it working without recur
05:58sheldonelsthanks for all the help rodnaph, Sgeo. cya around.
05:58rodnaphgood luck!
06:10andrewmcveigh&(= (
06:10lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
06:10andrewmcveigh (fn c [l & [a]] (if l (recur (next l) (+ (if a a 0) 1)) 0))
06:10andrewmcveigh'(1 2 3 3 1)) 5)
06:11andrewmcveigh&((fn [l & a] (if l (recur (next l) (+ (if a a 0) 1)) a)) '(1 2 3 3 1))
06:11lazybot⇒ 5
06:20samrattab-completion isn't working with emacs-live + evil-mode. Any ideas on how to fix it?
07:02rodnaphtrying to create a websocket server with aleph - can anyone help?
07:48mklappstuhlgfredericks, any advice regarding my question from yesterday?
07:50mklappstuhlI want to simulate a fictional stock portfolio and I'm wondering which data structures to use to create the portfolio...
07:50mklappstuhlI have some ideas here: https://github.com/mklappstuhl/computational-investing.clj/blob/master/src/mklappstuhl/stock_utils/simulate.clj
07:50mklappstuhlAny feedback would be greatly appreciated :
08:34mklappstuhlI want to simulate a fictional stock portfolio and I'm wondering which data structures to use to create the portfolio...
08:34mklappstuhlI have some ideas here: https://github.com/mklappstuhl/computational-investing.clj/blob/master/src/mklappstuhl/stock_utils/simulate.clj
08:34mklappstuhlAny feedback would be greatly appreciated :)
09:44sheldonels((fn f [x] (if x (conj (rest x) (first x)) nil)) '(1 2 3 4)) trying to switch around rest and first to reverse the list, conj doesn't work with the first param being an item rather than a collection, anyone know of something I can use to get a new item added to a collection at the far end?
09:59AimHeresheldonels, you could just use the reverse function
10:02AimHereOh, he's gone
10:29ambrosebsIf anyone was thinking of contributing to Typed Clojure, some small jobs https://github.com/frenchy64/typed-clojure/wiki/Small-Jobs
10:43edmund__ambrosebs: was reading your dissertation this am. Very nice work.
10:44edmund__its a nice way for me to learn about this whole typing jiggery-poke
10:44ambrosebsedmund_: thanks!
10:44ambrosebsditto for me :)
10:45ambrosebsLearnt a lot this year hehe
10:45ambrosebsHow are you finding it? Any confusing bits?
10:46ambrosebsI didn't get a chance to run it by anyone but my supervisor...
10:46ambrosebsI can still correct it before December.
10:47edmund__well, I'm not academically able in CS
10:47edmund__but this is good as the new concepts you introduce are clear to me
10:48edmund__i did have a question on listing 1.9
10:48ambrosebsThe target audience is basically people familiar with popular programming languages.
10:48edmund__the (if a a 0)
10:49ambrosebsyep
10:49ambrosebsjust a regular if?
10:49edmund__should it be (if a a nil) perhaps
10:49ambrosebslook at the return type of num-vec2
10:49tmciverambrosebs: where can one read this dissertation?
10:49edmund__the else branch returns a nil and you say that the type of the else branch collapses (U nil Number) to nil
10:50edmund__whereas 0 is Number
10:50edmund__I'm probably being dumb though :)
10:51ambrosebsah it's a bit hard to read.
10:52ambrosebsSimilarly, following the else branch refines the type of -->"a"<-- to nil from (U nil Number)
10:52edmund__aaaaaaaah
10:52edmund__yes
10:52tmciverambrosebs: Ah, was looking for your disseration; found it.
10:52edmund__not the type of the function
10:52edmund__quite right ;)
10:52ambrosebstmciver: cool, corrections welcome!
10:53edmund__i'm confused about the ... type
10:53ambrosebsedmund__: I'll reword it.
10:53edmund__but that needs further work from me :)
10:53ambrosebsedmund__: where does it come up first?
10:53ambrosebsListing 1.8?
10:54edmund__pg 11
10:54edmund__yeah 1.8
10:54edmund__i just need to digest a bit what it meas
10:54edmund__s/meas/means
10:54ambrosebsyea, it's tough to get your head around it at first.
10:54edmund__and how Type b ... b interacts with Type a
10:55edmund__all new stuff to me
10:55ambrosebsI don't think there's anything notable about that interaction.
10:55edmund__what would be uber cool for the Conj is if you gave a handson session where we go through some examples of using TC
10:56edmund__i imagine your talk will be more technically focussed
10:56ambrosebsthe interesting bit is between b ... b and (U nil (Seqable b)) ... b
10:56edmund__yeah, let me think about that for a bit and get back to you with questions
10:56edmund__but, this is really interesting work and something that I hope you continue with
10:56edmund__you doing further studies ?
10:57ambrosebsI still haven't worked out exactly what I'm talking on. But my Conj proposal says I'm talking about practical features.
10:57edmund__aaah well, in that case :)
10:57edmund__its always easier to reason from concrete to abstract
10:57ambrosebsI'm giving an Unsession talk on the theory.
10:58ambrosebswhich is the day after
10:58edmund__perfect: pretty exciting stuff.
10:59ambrosebsI know right! ;)
10:59edmund__i still have to get my talk into any sort of shape. EEEP
11:01ambrosebsI'm giving a 20m seminar on Thursday for my degree. Hopefully will kickstart the work (although writing a dissertation sure helps)
11:01edmund__good luck with that - you'll kill
11:01ambrosebs:)
11:04usertest
11:06edmund__user: pass
11:06user:)
11:29solussdI've been playing around with Clojure-py the past couple of days. Any insight on why it appears to be about 20x slower than python?
11:31goraciohi ther here is the problem - i try (def thing (func)) func takes some time to do stuff and then i use thing and it appears unbound - how to handle this stuff ?
11:38goracioso any thoughts ?
11:38solussdgoracio: could you upload the actual usecase to refheap?
11:40goraciosolussd: well it's pretty simple - i want define thing and then use it but to defining thing takes some time so when i use it compiler says that it is ubound
11:41solussdgoracio: it shouldn't be, so there must be something weird going on in your code. :)
11:41goraciosolussd: so function took some time to execute and it appears that thing wasn't defined cause compiler doesn't wait
11:43goraciosolussd: for example (def thing (func)) will compiler wait for results that func will return or may be will not ever
11:44solussdso, does this leave blah unbound? : (def blah (#(do (Thread/sleep 5) "hi")))
11:44solussdit will wait
11:45goraciohmm
11:45tmcivergoracio: I had a problem like this when trying to def a var to a jetty server. But since the 'create server' function never really returns (the server is running), the server var was unbound. I think you simply can't use the var until the function returns. Perhaps you need a Future, or something.
11:47goraciotmciver: yes func is communicating with the db server and waits results from it but func is returning something for sure
12:58erwagasoreI am using require instead of use in my namespace, something like this : (ns mynamespace (:require [ring.adapter.jetty :refer [run-jetty]]))
12:59erwagasoreIs something like this possible: (ns mynamespace (:require [ring.util.response :refer :all :exclude [not-found]])
12:59erwagasore?
13:09erwagasoreor something like this: (ns mynamespace (:require [ring.util.response :refer :all [not-found :as nf]]))
14:22TimMcI think there might be a rename...
14:23TimMcMaybe that's only with use.
14:32devnAnyone know where (raise) went in clojure.contrib.condition? Is there an analagous form in slingshot?
15:10hyPiRionTimMc: Yeah, there's rename
15:11hyPiRion&(require '[clojure.pprint :refer [cl-format] :rename {cl-format fmt}])
15:11lazybot⇒ nil
15:11hyPiRion&(fmt true "~{~A~^, ~}~%" [1 2 3])
15:11lazybot⇒ 1, 2, 3 nil
15:25hiredmandnolen: does the clojurescript compiler (outside of google closure) do any constant propagation? I am seeing (def ^:export m 1) (defn f [] (g m)) turn 'm' in to the constant 1 in the generated js
15:25hiredmanwhich means I cannot fiddle the exported value m and get a different result
15:30dnolenhiredman: it does not, that would be gclosure
15:30dnolenhiredman: I think you'll see that with even simple optimizations
15:32tomojis there a problem doing `:where [$a _ :foo ?foo-a] [(foo ?foo-a) ?foo)] [$b _ :foo ?foo-b] [(foo ?foo-b) ?foo]` ?
15:34hiredmandnolen: that is kind of a drag
15:36tomojshouldn't it be ^:dynamic ?
15:36tomoj(and would that make a difference?)
15:40gfrederickstomoj: probably depends on if it makes a difference in the generated JS, rather than just compiler warnings
15:42dnolenhiredman: yeah it's annoying, perhaps it can be defeated w/ a JS object? (def ^:export props (jsobj "m" 1)) ?
15:47hiredmandnolen: I'll try that next time
15:50gfredericksif the jsobj idea didn't work that would say bad things about the correctness of atoms I would think
15:51dnolenhiredman: hmm there's probably a way for us to avoid ugly hacks like that if we expose more hooks to closure annotations http://developers.google.com/closure/compiler/docs/js-for-compiler
15:52dnolenhiredman: ^:expose I think
15:55hiredmandnolen: maybe :export should just imply expose
15:57dnolenhiredman: that might be true, http://dev.clojure.org/jira/browse/CLJS-410
16:08tomojseems joining on the output of a db fn like that is O(n^k)
17:20mklappstuhl I want to simulate a fictional stock portfolio and I'm wondering which data structures to use to create the portfolio...
17:20mklappstuhlI have some ideas here: https://github.com/mklappstuhl/computational-investing.clj/blob/master/src/mklappstuhl/stock_utils/simulate.clj
17:20mklappstuhlAny feedback would be greatly appreciated :)
17:21mklappstuhlbasically I try to wrap "buy" functions in a list...
17:21mklappstuhlBut I think there might be better tools in clojure to do it ..
17:26technomancyhuh: https://twitter.com/atosborne/status/180246603586736128
17:30etherealGwhat's the difference between sequential and iseq?
17:30amalloy&(map (juxt sequential? seq?) '[[1 2 3] (1 2 3)])
17:30lazybot⇒ ([true false] [true true])
17:31amalloytechnomancy: isn't that just optimizing refer :all? i can see it speeding up the refer-clojure that happens in every namespace, but not much else. given that, why not just cache the mappings for clojure.core, and have it take roughly zero time for the case that's actually slow?
17:31frio&(sequential [1 2 3 4 4])
17:31lazybotjava.lang.RuntimeException: Unable to resolve symbol: sequential in this context
17:31frio&(sequential? [1 2 3 4 4])
17:31lazybot⇒ true
17:32friohrm
17:33bbloomin short: sequential means it has a well defined order. It's a sequence if it's a head/tail cons-style data structure, and "seqable" implies that it can be coerced to a sequence via the seq function
17:33bbloomvectors are sequential, but not sequences
17:33bbloomlists are sequential and are actually sequences
17:33technomancyamalloy: yeah, probably makes more of a difference with :refer :all
17:34amalloytechnomancy: no, i mean it looks to me like that code is only used at all for refer/all
17:34etherealGgotcha, so sequential? is the right thing to use for code that you want to be collection agnostic?
17:34etherealGif you need to check the incoming data for being able to do things like filters etc.
17:35amalloyif you need to filter, just call filter and break if an exception happens
17:35technomancyyou can filter over lots of nonsequentials
17:36bbloometherealG: generally, you simply coerce to a sequence and test against nil
17:37bbloometherealG: er, sorry, misunderstood your question, yeah, you're right
17:37Sgeo,(for [[k v] {:a 1 :b 2}] [v k])
17:37clojurebot([1 :a] [2 :b])
17:38bbloom,(seq {:a 1 :b 2})
17:38clojurebot([:a 1] [:b 2])
17:38bbloom,(sequential? {:a 1 :b 2})
17:38clojurebotfalse
17:38bbloometherealG: see that ^^ maps aren't sequential, but they are seq-able
17:39bbloomsome canonical linearization of maps exists :-)
17:39Sgeo,(seq {:a 1 :b 2})
17:39clojurebot([:a 1] [:b 2])
17:39Sgeohmm
17:40Sgeo,(find [2 1 0] 0)
17:40clojurebot[0 2]
17:40Sgeoawesome
17:40Sgeo,(class (find [2 1 0] 0))
17:40clojurebotclojure.lang.MapEntry
17:42amalloy&(-> (iterate #(find % 0) [0 0]) (nth 1000))
17:42lazybot⇒ [0 0]
18:05dnolenbbloom: hrm, it seems like we still have some let cases to address? http://dev.clojure.org/jira/browse/CLJS-411
18:06bbloomdnolen: give me a moment & i'll take a look
18:08bbloomneither of those throw an assertion error for me
18:09bbloomdnolen: what's the problem exactly?
18:14ForSparePartsIf I compile some Clojure AOT using gen-class, will I still be able to do REPL-state stuff with the compiled code? Say, accessing def'd stuff in the clojure code that Java is invoking?
18:16ForSparePartsAnd a related question: what's the best way to pull data out of a Clojure map (with flexible structure) in Java code? I'd rather not have a chain of type casts several lines long, but I'm also a little concerned that using the RT package would have performance implications
18:16ForSpareParts(I'm trying to make a simple game, and parsing/compiling on every line seems like a bad choice)
18:40AtKaaZis there a git library for clojure?
18:40AtKaaZif not, what would be the way to run a command and get back its output?
18:41AdmiralBumbleBeeconch is good for that
18:41AdmiralBumbleBeeno idea if there's a git library
18:42AtKaaZthank you, I'll check that
18:43tomojcodeq just uses Runtime.exec :O
18:44Apage43https://github.com/clj-jgit/clj-jgit
18:45AtKaaZhmm, I'm getting cannot resolve dependency conch/conch , maybe I'll try using Runtime.exec
18:45tomojit's just conch
18:46tomojhttps://clojars.org/conch
18:46amalloytomoj: conch is an alias for conch/conch; that's what lein does if you omit a groupid
18:46AtKaaZyeah but that's what it says, probably resolves to that when namespace not specified
18:46tomojorite
18:46AtKaaZwait, do I need the clojars plugin?
18:47AtKaaZor lein knows to look there
18:47dnolenbbloom: you're right, not a problem
18:47bbloomdnolen: good news! the unmanaged vars really do look nice huh? :-)
18:48dnolenbbloom: they do :)
18:48amalloyAtKaaZ: you could try jgit, though i don't know how easy it is to use
18:50AtKaaZdon't mind if I'll give it a try
19:00AtKaaZamalloy: this seems useful: https://github.com/clj-jgit/clj-jgit
19:01bbloomdnolen: i might be doing something wrong, but i've got a relatively simple cljs-build setup going on and i'm getting a warning trying to use defprotocol
19:01bbloomWARNING: Use of undeclared Var cps/-return at line 3 src/cps.cljs
19:01bbloomwhere line 3 is the -return form here:
19:01bbloom(defprotocol IContinuation
19:01bbloom (-return [_ result])
19:01bbloom (-raise [_ error]))
19:01bbloomany ideas what might be causing that?
19:03amalloybbloom: related to return being a javascript keyword?
19:03bbloomamalloy: i thought that might be it, but the - is converted to a _ also the next line gives a similar warning:
19:03bbloomWARNING: Use of undeclared Var cps/-raise at line 3 src/cps.cljs
19:03bbloomraise isn't a keyword
19:13dnolenbbloom: hmm I don't know.
19:14dnolenbbloom: it's only supposed to issue that warning if it encounters a symbol that hasn't been declared or def'd
19:14bbloomdnolen: could it have something to do with a cli (non cljs) namespace of the same name?
19:15dnolenbbloom: oh hmm, it looks like you've aliased a namespace to cps and are using -return in a different namespace?
19:16dnolenbbloom: if so it should have analyzed the other namespace first and picked up those protocol definitions
19:16bbloomdnolen: i have cps.clj and cps.cljs -- the former for compile time & macros, the later for runtime stuff
19:16dnolenbbloom: so is cps/-raise something emitted by the macro?
19:16bbloomdnolen: nope
19:17bbloomdnolen: https://github.com/brandonbloom/cljs-cps/
19:18bbloomdnolen: if you look at the bottom of cps.clj, you'll see all my compile time tests… i've started on test.cljs, which is going to be the runtime tests
19:18bbloomdnolen: you'll also see how pretty an AST transform can be :-)
19:19dnolenbbloom: yes that looks pretty cool. dunno about the issue tho, minimal case would be helpful.
19:19dnolenbbloom: I would look more closely myself but busy w/ some other things atm.
19:19bbloomok, ill try to figure it out
19:19bbloomi've got to run now
20:06AtKaaZtype hint for array of String?
20:07AtKaaZI hope it's not this {:tag "[Ljava.lang.String;"}
20:13Sgeo,(class (string-array))
20:13clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: string-array in this context, compiling:(NO_SOURCE_PATH:0)>
20:13Sgeo,(class (object-array))
20:13clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core$object-array>
20:13Sgeo,(class (object-array 0))
20:13clojurebot[Ljava.lang.Object;
20:13Sgeo...what
20:13SgeoI have no idea what's going on
20:29dnolenAtKaaZ: that is correct, ^"[Ljava.lang.String;"
20:29AtKaaZyep thanks
20:31wingythe Java interop comes handy dealing with external services who only have Java SDK
20:32wingyhow do i use maven projects in my project.clj?
20:40amalloysame way you use clojure projects, which are published via maven
20:41akhudekwingy: just add to the dependencies something like [group-id/artifact-id "version"]
20:41akhudekif the group and artifact id are the same, like for many clojure projects, you can just use [artifact-id "version"]
20:46wingyakhudek: it says i have to add their repository at http://x.github.com/x/releases
20:46dnolenbbloom: ok, I bendlas found a legitimate issue http://dev.clojure.org/jira/browse/CLJS-411
20:47akhudekwingy: you can specify extra repositories in lein with :repositories (see https://github.com/technomancy/leiningen/blob/preview/sample.project.clj#L161)
20:49wingyakhudek: ok thx
20:58bendlasbbloom: hi I had wondered about your IRC handle
20:58bendlasdnolen: yeah, sorry for the miscommunication
21:00meredyddHey
21:01meredyddAnyone around and interested in giving me feedback on a new function-call mocking library?
21:01meredyddgithub.com/meredydd/expect-call
21:01meredydd(Hmm, that's not clickable in XChat. http://github.com/meredydd/expect-call)
21:16AtKaaZ,(assert false)
21:16clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.AssertionError: Assert failed: false>
21:17AtKaaZdoes this work regardless of the -ea jvm option?
21:17AtKaaZin other words, is it unlike the assert used in java?
21:18AtKaaZI believe the answer is yes but still, I'd prefer this to be documented
21:23amalloy&(macroexpand-1 '(assert false))
21:23lazybot⇒ (clojure.core/when-not false (throw (new java.lang.AssertionError (clojure.core/str "Assert failed: " (clojure.core/pr-str (quote false))))))
21:30TimMcThe question is really whether Clojure assertions are enabled iff Java assertions are enabled at macro-expand time.
21:31Sgeo(source assert)
21:31Sgeo&(source assert)
21:31lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
21:31Sgeo,(source assert)
21:31clojurebotSource not found
21:31TimMc,(apropos 'source)
21:31clojurebot(*source-path* source source-fn resource)
21:32TimMc,(apropos 'assert) bah
21:32clojurebot(assert *assert*)
21:32AtKaaZ&*clojure-version*
21:32lazybot⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil}
21:32gfredericksTimMc: it's based on the *assert* var, ain't it?
21:32AtKaaZ&(use 'clojure.repl)
21:32lazybot⇒ nil
21:33AtKaaZ&(source source)
21:33lazybot⇒ Source not found nil
21:33Sgeohttp://clojuredocs.org/clojure_core/clojure.core/assert
21:33SgeoIt only returns code when *assert* is truthy
21:34gfredericks(set! *assert* :falsy)
21:34AtKaaZ,(binding [*assert* false] (assert false))
21:34clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.AssertionError: Assert failed: false>
21:34gfredericksAtKaaZ: it was truthy at compile-time
21:35SgeoThe binding occurs at runtime, but the macro is expanded at macroexpand time
21:35AtKaaZmakes sense
21:35gfredericksyou can (binding [*assert* false] (eval '(assert false)))
21:35Sgeo,(alter-var-root #'*assert* (constantly false)) (assert false)
21:35clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
21:36AtKaaZ,(binding [*assert* false] (eval '(assert false)))
21:36clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
21:36AtKaaZoh right, eval
21:36gfrederickswhat happens if you take a val and put it on computers?
21:37AtKaaZthe computer believes?
21:37gfredericksno, you get an e-val!
21:37AtKaaZnice
21:48callenyou know, I put up a pull request fixing that irritating SANBOX DENIED typo ages ago
21:50AtKaaZin what way?
21:51AtKaaZoh i see, typo :)
22:01TimMccallen: I've grown fond of it.
22:09jimdueySgeo: Hi
22:12SgeoHi jimduey
22:13jimdueySaw your comment about m/do being a macro.
22:13jimdueyI was actually pleased that it was the only one I needed to be a macro. :)
22:13jimdueyAnd that's because it deals with binding values to symbols, which can only be done using a macro.
22:13SgeoActually, the thing with it is that its name is the same as the name of a special form
22:14jimdueyAh. That I understand.
22:14SgeoWhich means you can't actually use it in, you can only refer to it with a qualified name, either fully qualified or alias, like m/do
22:14jimdueyGood point.
22:16TimMcOK, what's the point of this? https://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj#L85
22:16jimdueyNot sure what else to call it, since 'do notation' is the term in Haskell.
22:16jimdueyRegardless, thanks for carrying the monad flag in Clojure land. :)
22:16TimMc(binding [foo foo] ...) seems like a no-op -- is there a point to creating a new dynamic scope level?
22:17Sgeohttp://ideone.com/JQz5VF
22:17Sgeojimduey, you're welcome
22:18SgeoA way to get special forms to be namespaced like the rest of clojure.core would be nice
22:23SgeoI really should work on fixing delimc
22:23SgeoAlthough I think it might be harder than I originally thought
22:23SgeoI forgot how I came to that conclusion though
22:26tomojwhat's wrong with delimc?
22:27Sgeotomoj, it doesn't work unless you use it, bringing all its symbols directly into the current namespace
22:27SgeoDue to it being a port from CL -> Clojure, and the subtle difference between CL symbols and Clojure symbols+namespaces
22:28SgeoThere might be more issues due to that difference, I'm not sure
22:28SgeoErm, Clojure symbols+vars
22:28tomojI see
22:31jimdueyIf you do :exclude some symbols from clojure.core, you can always get at them again by fully qualifying their names. clojure.core/do etc.
22:33Sgeojimduey, the point is that :exclude on do flat out does not work.
22:33SgeoAn unqualified do always refers to the core do, under all circumstances.
22:34jimdueyso it is. I'll just hang up my keyboard and go to bed now. :)
22:38ivan<Sgeo> An unqualified do always refers to the core do, under all circumstances. <- only in list head position, maybe obvious
22:38SgeoOh, erm, yes
22:38Sgeo,(let [do 5] (do do))
22:38clojurebot5
22:38gfredericksis (do do) ever not funny??
22:38lazybotgfredericks: What are you, crazy? Of course not!
22:38Sgeo,(let [+ 5] (+ +))
22:38clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
22:40gfredericks,(let [+ partial] (+ + + + + + + +))
22:40clojurebot#<core$partial$fn__2495 clojure.core$partial$fn__2495@39ff48d8>
22:43callenTimMc: ugh.
22:48muhoowait, how is that even possible
22:48muhoo,(5 5)
22:48clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
22:48muhooright.
22:48muhoo,(let [do 5] (do do))
22:48clojurebot5
22:48muhoo????
22:51Sgeomuhoo, do is a special symbol
22:51SgeoUnqualified, it always refers to the same thing in head form
22:52SgeoSo, the (do do) is the special form do with lexically scoped variable do
22:52Sgeo,(special-symbol? 'do)
22:52Sgeo&(special-symbol? 'do)
22:52lazybot⇒ true
22:54Sgeo,(let [-> 5] (-> ->))
22:54Sgeo&(let [-> 5] (-> ->))
22:54lazybot⇒ 5
22:55Sgeoo.O what
22:56Sgeo&(let [-> inc] (-> 5))
22:56lazybot⇒ 5
22:56Sgeo&(special-symbol? '->)
22:56lazybot⇒ false
22:57metellus,(let [+ -] (+ 5 3))
22:57Sgeo&(let [+ -] (+ 5 3))
22:57lazybot⇒ 2
22:57metellus&(let [inc 5] (inc inc))
22:57lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
22:58xeqi&(let [-> 5] ->)
22:58lazybot⇒ 5
23:00SgeoGoing to try it at the REPL, maybe clojail's weird?
23:01Sgeouser=> (let [-> inc] (-> 5))
23:01Sgeo6
23:02Sgeo(do do) still does its thing, though
23:03Sgeo&*clojure-version*
23:03lazybot⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil}
23:03SgeoRaynes, hello
23:03gfrederickslazybot: quit being weird
23:04SgeoIt's probably Clojail
23:05SgeoWhy is clojurebot broken?
23:05Sgeo,5
23:05xeqi,asdf
23:06xeqi,(5 5)
23:06xeqihmm, muhoo got it to work earlier :p
23:09gfredericks&(let [-> 8] ->)
23:09lazybot⇒ 8
23:10gfredericks&(let [-> :foo] (-> {}))
23:10lazybot⇒ {}
23:10gfredericksin clojail, all clojure macros are special forms :)
23:11SgeoYes. As far as I'm concerned, this is a bug.
23:13AtKaaZwhat's the safest way to make sure a bunch of statements get executed?
23:16Sgeohm?
23:16clojurebotbenchmarking is https://github.com/hugoduncan/criterium
23:17AtKaaZI guess dorun will do...
23:21SgeoAtKaaZ, what do you mean by "a bunch of statements"?
23:22AtKaaZforms
23:22AtKaaZwith side effects
23:23SgeoYou don't need to wrap them in anything unless you're doing them in a for otherwise involving laziness
23:23AtKaaZthey are in a true branch of an if
23:23SgeoAh
23:23AtKaaZbut I used dorun
23:23SgeoYou probably want do
23:24Sgeoif takes three things: A test, ONE form for the true branch, and optionally, ONE form for the false branch
23:24AtKaaZjust that I was wondering if somehow it would trigger the dorun [n coll] instead of dorun [coll]
23:24Sgeodo will let you combine multiple forms into 1 form
23:25Sgeo(if true (do (println "Hello") (println "There")) (println "This is in the else"))
23:25Sgeodorun is specifically for realizing lazy collections
23:26AtKaaZwhat would be the difference between do and dorun there? assuming the first println is something like (.delete fFile)
23:26AtKaaZfor some reason I was unsure that do will cause the side effects to happen, but it kind of makes sense, since the forms are evaluated before being passed to the do (so to speak)
23:28Sgeodorun is not intended to group multiple forms together. It is intended to fully realize a lazy sequence and induce any side-effects in that sequence by doing so
23:28SgeoWhy do you think that the side effects might not happen
23:31AtKaaZI just cannot imagine all possible variants and therefore I chose to be unsure :) but if do was a macro then I'd be unsure, I guess since it's a function the passed forms are all evaluated prior to executing the do
23:31AtKaaZwhich returns last
23:31tomojit's not a function
23:31AtKaaZspecial form?
23:31tomojit's a special form
23:31AtKaaZok
23:31AtKaaZso in theory it can act like a macro then?
23:32SgeoYes.
23:32SgeoBut macros can evaluate the forms they're given if they choose
23:32SgeoBut the do special form always evaluates its forms, assuming that the do itself is evaluated
23:33AtKaaZalright
23:34AtKaaZ,(= (ifn? 'do) (special-symbol? 'do))
23:34clojurebottrue
23:35zackzackzackWhat does the syntax ::foo mean?
23:36Raynes&::foo
23:36lazybot⇒ :clojure.core/foo
23:36AtKaaZ,:foo
23:36clojurebot:foo
23:37AtKaaZ,::foo
23:37clojurebot:sandbox/foo
23:37zackzackzackSo a namespaced keyword of sorts?
23:39AtKaaZprefixing it with the current namespace
23:39AtKaaZ,*ns*
23:39clojurebot#<Namespace sandbox>
23:39zackzackzackAhhh
23:39zackzackzackThat makes sense
23:42SgeoOh hey clojurebot's back
23:42Sgeo,(let [-> inc] (-> 5))
23:42clojurebot6
23:43SgeoI don't think I'm going to forget which one uses Clojail now
23:50flying_rhinohello guys
23:51zackzackzackflying_rhino, hi
23:53RaynesSgeo: Yeah, I noticed that a while back. Haven't had time to investigate.
23:53flying_rhinohow 'scriptable' (for lack of a better word) is clojure? For example, I wonder if I can load clojure code as a replacement for XML. I also wonder if I can have REPL inside application, so I can try things out without recompliling.
23:54Raynesflying_rhino: You can absolutely have an embedded repl.
23:54RaynesYou can even run an nrepl server in there and attach/detach from it as you please.
23:54zackzackzack,(println "Say hello clojurebot")
23:54clojurebotSay hello clojurebot
23:54RaynesThere is actually a thing, drawbridge I think, for talking to nrepl servers deployed in web apps.
23:55zackzackzackflying_rhino, this irc room has an embedded repl named clojurebot
23:55RaynesAlso lazybot
23:55Raynes&(+ 3 3)
23:55lazybot⇒ 6
23:57flying_rhinocan I keep that repl sandoxed so if it crashes it doesn't crash my whole app?
23:57flying_rhinosome sort of task manager thing where I can kill threads that get stuck?
23:58zackzackzackRaynes, clojail would work for that, right?
23:58zackzackzackhttps://github.com/flatland/clojail
23:58RaynesI don't think that's the kind of sandboxing he wants.
23:58zackzackzackYeah, you've written it be pretty strong