#clojure logs

2012-08-30

00:04XPheriorAh I'm an idiot. Trying to dispatch with (type) was dumb
00:04mattmoss,(let [t java.util.Timer] (new t))
00:04clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: t, compiling:(NO_SOURCE_PATH:0)>
00:04mattmossIs there a way to do that?
00:05cshellcshell?
00:05clojurebotI don't know anything about cshell.
00:06jeremyheiler,(let [o Object] (.newInstance o))
00:06clojurebot#<Object java.lang.Object@b27d661>
00:07mattmossah
00:07mattmossthanks jeremy
00:07jeremyheilernp
00:11amalloymattmoss, jeremyheiler: that's really just going to lead to unpleasant surprises in a minute. newInstance only works for a zero-arg constructor
00:13jeremyheileramalloy: yeah yeah...
00:13mattmossamalloy: Yeah, noticed that... amongst other things. I was really hoping that there was some way to take the info from clojure.reflect and act upon it. Maybe there is, I haven't found info yet. Or maybe I just need to write it myself.
00:13jeremyheilerim curious what (new ..) actually does
00:16jeremyheileri mean, there's only to options, right? either it generates the proper bytecode, or it reflectively grabs the constructor and instantiates it.
00:18jeremyheileryep, it does the latter.
00:19mattmossWhere are you seeing that?
00:19jeremyheilerhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L2365
00:19djanatynclojure just helped me on my stats homework packet :)
00:19jeremyheilernice!
00:20djanatynI had to get a random sample of answers for a question
00:20djanatyn(defn rand-bool [] (case (int (rand int)) 0 true 1 false))
00:20mattmossGotcha. Now I know where more things are located in clojure source! :)
00:21djanatyn(repeatedly 60 rand-bool) ;; my results ;)
00:21jeremyheilermattmoss: haha yeah, it's a bit difficult sometimes
00:21djanatynI'm taking AP Stats this year, so I'm going to use clojure whenever I can
00:22djanatynI used haskell pretty frequently in my calculus class last year to make things easier
00:22hiredmanjeremyheiler: it does either, depending on if the proper types are known, and if the compiler is generateing bytecode or just evaling simple expressions at the repl
00:23hiredmanmore complex expressions are always compiled
00:23hiredmanbut if the type not determinable at compile time the emitted bytecode will use reflection
00:29jeremyheilerhiredman: looking at it more closely, i see what you're saying. good stuff.
00:34casionanyone know of an example of handling and processing soundfiles in clojure (that's not overtone)?
00:34casionI've asked before and I either lost the links or no one had any at the time
00:34brehaut ~anyone
00:35brehautclojurebot: you are dead to me
00:35clojurebotExcuse me?
00:35dansalmoanyone know the regex for clojure.string/split to split a string at "<" but not at "<:"
00:35casionmy google-fu has failed me in this regard
00:35hiredman~anyone
00:35clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
00:35cshelllol
00:35dansalmothx
00:36dansalmowhat is the regex for clojure.string/split to split a string at "<" but not at "<:"
00:36casionI actually just want to know if anyone knows of an example haha
00:37brehautnegation is a bag of hurt in regexp, but something like #"<[^:]"
00:38brehaut#"<([^:]|$)" perhaps
00:38hiredmanls
00:38lazybotbin boot dev etc lib lost+found selinux usr
00:38brehautlol
00:38mattmosscd etc
00:40amalloybrehaut, dansalmo: #"<(?!:)"
00:40dansalmoThx brehaut, the 2nd one seems to work. The first one did catch < at the end of the string.
00:40casion~regex
00:40clojurebotSometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.
00:40brehautamalloy: huh. good to know
00:41amalloybrehaut: yours consumes the character after the <, whereas mine doesn't
00:42dansalmoamalloy: that works even better, does not take out character after <:
00:42brehautamalloy: yeah, i realised that, but without knowing about magic negation operators, its not really possible
00:43amalloyyeah
00:43pyrtsaIt's called a (negative) look-ahead btw.
00:43pyrtsaNo magic. :)
00:43amalloywell, it's magic like negative look-ahead and capture groups that make regex impls hundreds of times slower than they could be
00:44brehautand also makes them irregular in many cases
00:44dansalmoI see that now in the docs, never would have guessed I needed X, via zero-width negative lookahead
00:45pyrtsaI thought that were look-behinds that are problematic, but I agree.
00:46aaelonyI seem to misunderstand swap! for an atom holding a map. (def x (atom {:a {} :b [] })) and (update-in @x [:a :a1] {} 123) give what I want, but (swap! x (update-in @x [:a :a1] {} 123)) yields nil ?!! perplexed… https://www.refheap.com/paste/4728
00:48mattmoss,(let [x (atom {:a {} :b []})] (swap! x update-in [:a :a1] {} 123))
00:48clojurebot{:a {:a1 123}, :b []}
00:49aaelonythanks! so no paren before update-in...
00:49mattmossswap! doesn't take the new value... but a function
00:49aaelonya-ha!! thanks again :)
00:49mattmossand swap! will call that function with (deref x) as the first param and the other args to swap! as additional params
00:51aaelonycool
00:53l1xo hai
00:54l1xwhat is a good pattern to return a sequence (exact type doesnt matter) from a fn which has loop or recurn inside (eg. you are iterating over certain things and producing partial results)
00:57emezeske_l1x: The first example on this page is pretty typical: http://clojuredocs.org/clojure_core/clojure.core/loop
00:57emezeske_l1x: When you call recur, pass in the partial results, and keep appending to that
00:57emezeske_l1x: Once the termination condition is reached, just return that result
00:58l1xthanks, i try to implement it
01:09l1xi guess i cant use recur without loop this way
01:10emezeske_l1x: What are you trying to do?
01:10l1xrewrite this to return you a []
01:10l1xhttps://gist.github.com/3506753
01:13emezeske_l1x: So it's working how you want it, but is returning a seq instead of a vector?
01:13l1xit is printing now
01:14l1xi just would like to return a sequence instead, type does not matter
01:14emezeske_Oh I see
01:15l1xhttps://gist.github.com/a905f1fd2e2b6965accc
01:15l1xmore like https://gist.github.com/3522630
01:16l1xbut it just return an empty []
01:18emezeske_I think it's possible to do what you want with recur
01:19emezeske_I'm finishing something up right now, but in a minute I'll take a stab at helping
01:21l1xthanks a million
01:31emezeske_l1x: Okay, let's see.
01:33emezeske_l1x: Does this do the job? https://gist.github.com/3522797
01:34emezeske_l1x: I removed the ->> macro just for my own benefit (I found it easier to write without it).
01:34l1xhaha i did the same :D
01:34emezeske_l1x: The main thing is that instead of using "when", it uses "if"
01:34l1xi dont get the ->> yet
01:35emezeske_So basically, my solution just keeps concating the row onto a result, which is initially set to []
01:35l1xok so this was the missing point for me
01:35emezeske_Then, when (seq rows) is not truthy, it returns that whole concated result
01:35l1xthat you have mutable data in clojure and you can just concat into it
01:35emezeske_It's not mutable :)
01:36emezeske_That's the great thing, concat is returning a totally new list of values
01:36emezeske_Notice that the new list returned by concat is passed into recur
01:36emezeske_So it is being passed into the function as the "result" argument
01:37emezeske_On each recursive call to spiral-print, result gets longer and longer
01:38l1xhmm
01:38emezeske_But it's not actually being mutated, it's a whole new list each time
01:38emezeske_Consider (let [x [1 2 3]] [(concat x [4]) (concat x [5])])
01:38l1xoch i see
01:38emezeske_,(let [x [1 2 3]] [(concat x [4]) (concat x [5])])
01:38clojurebot[(1 2 3 4) (1 2 3 5)]
01:39emezeske_^ Notice that the second result is *not* (1 2 3 4 5)
01:39emezeske_,(let [x [1 2 3]] [(concat x [4]) (concat x [5]) x])
01:39clojurebot[(1 2 3 4) (1 2 3 5) [1 2 3]]
01:43l1xthank you very much emezeske_
01:45UrthwhyteEvening
01:47amalloyemezeske_: you want into, not concat
01:47emezeske_amalloy: For what?
01:47amalloyhttps://gist.github.com/3522797
01:48emezeske_concat works fine
01:48emezeske_Does into have an advantage?
01:48amalloyconcat will fail here if the matrix is too large
01:48amalloyyou're building up (concat (concat (concat ...)))
01:49emezeske_I guess I need to look at the source for concat and into to understand
01:50Scriptor`is the advantage here due to into using transients?
01:50emezeske_Wow, concat is way more complicated than into
01:51emezeske_amalloy: Are there situations where concat is better?
01:52Scriptor`emezeske_: concat is lazy, for one thing
01:53emezeske_I see. into is probably much much faster, being implemented in terms of reduce?
01:54Scriptor`emezeske_: there's also the fact that it uses transients, which means it does some mutating underneath
01:55emezeske_Ahh, I see what amalloy is talking about with (concat (concat (concat))) -- it's a big deeply nested lazy-seq
01:56Scriptor`,(let [foo []] (conj! foo 1) foo)
01:56clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.ITransientCollection>
01:56Scriptor`,(let [foo (transient [])] (conj! foo 1) foo)
01:56clojurebot#<TransientVector clojure.lang.PersistentVector$TransientVector@6da6d943>
01:56emezeske_Whereas into will keep returning a longer flat list
01:56Scriptor`,(let [foo (transient [])] (conj! foo 1) (persistent! foo))
01:56clojurebot[1]
01:56Scriptor`there we go
01:57emezeske_Oh, wild
01:57Scriptor`yep, it actually mutates the collection being conj'd onto, which normal conj doesn't
01:57Scriptor`most of the time you'll never use this
01:57emezeske_I thought you had to just drop into dealing with arrays directly to do that
01:57emezeske_Very cool
01:58Scriptor`however, in very few cases you'll never need all the intermediary collections that might be built up by doing (reduce conj foo bar)
01:59l1xemezeske_: https://gist.github.com/3522630
01:59emezeske_Yeah, I could see that being a nice way to optimize a slow inner loop
01:59l1xi put there some dbg stuff
01:59emezeske_l1x: Nice.
01:59Scriptor`yep, clojure.org has a much better explanation than I can give http://clojure.org/Transients
01:59emezeske_Scriptor`, amalloy: thanks for the info.
01:59l1xthe results are in the comment section
02:00l1xso, result is kinda growing with the iterations
02:00l1xbut it seems to me like mutable variable...
02:01emezeske_,(let [x [1 2 3]] [(into x [4]) (into x [5]) x])
02:01clojurebot[[1 2 3 4] [1 2 3 5] [1 2 3]]
02:01emezeske_Examine that ^
02:01emezeske_Notice that x is "intoed" a couple times, but its value stays the same
02:02Scriptor`yep, that's the idea, you won't ever notice the mutability, because it's wrapped up inside into
02:02l1xoch i see
02:02Scriptor`so into doesn't mutate anything you pass it, it only mutates the collections it generates inside itself to get the final (immutable) result
02:02l1xso it does some magic inside into?
02:03l1xi guess it dereferences the original set and creates a new one
02:05l1xhttps://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L6070
02:05l1xok guys, thanks everyone, great success
02:07amalloyScriptor`: using conj! for side effects is a disaster - never do it; always use the result produced by conj!, even though it's generally the same collection you passed in
02:07amalloyconj! and disj! are *allowed* to mutate the collection and return it, but they are not *required* to, and in fact don't
02:07amalloy(or rather, don't always)
02:08Scriptor`amalloy: right, just demonstrating how it worked by mutating transient values
02:09emezeske_amalloy: Is deeply nesting lazy-seqs a bad idea in the general case?
02:10emezeske_amalloy: Now that I'm thinking about it, it doesn't seem like it's ever really what you want to do
02:10amalloywell, it causes a stackoverflowerror, so that sounds like a bad idea
02:10emezeske_For some value of "deeply" yes
02:11emezeske_I'm just trying to come up with a rule of thumb about when not to nest lazy-seqs
02:11emezeske_I guess the rule is "if you want a thing to be able to grow aritrarily long/big/deep"
02:11amalloyanytime you can't guarantee an upper bound on the depth seems reasonable
02:12emezeske_Yeah, that sounds good
02:12emezeske_I guess recur implies unbounded depth.
02:12emezeske_(Kind dumb to use recur and then still overflow the stack)
02:17john2xwhat would be the clojure equivalent of this: `String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", Calendar.getInstance())`? I'm trying (String/format "…" (Calendar/getInstance)) but it returns "java.util.GregorianCalendar cannot be cast to [Ljava.lang.Object"
02:29john2xhmm my bad.. it seems Processing has it's own String class..
03:09lpetitHello there
03:10lpetitOn the Getting Started page for Counterclockwise, there is an old section related to how to install labrepl. But labrepl seems a little bit outdated, and so it is a shame that people are not exposed to more recent versions of clojure, libraries, etc.
03:11lpetitMy intent is to just drop this section, cutting the Getting Started page by a half (making it less frightening, btw).
03:11lpetitObjections ?
03:13Rayneslpetit: I don't use CCW, but it sounds like a good plan. I'll note however that someone recently forked labrepl and added tryclojure integration to it.
03:13RaynesNot sure if that's worth looking at or not.
03:13RaynesBut it's a consideration.
03:15lpetitRaynes: interesting. I think I'll still just drop it for now. I can always revive it by finding the text in the wiki history, right?
03:15clgvdamn. too late to hear the "good plan"...
03:15RaynesIndeed.
03:15clgvlpetit, Raynes: good morning
03:16lpetitclgv: hello
03:17lpetitclgv: I just added a (dissoc project-map :hooks) code when Counterclockwise interacts with leiningen so that the bug you mentioned the other week goes away.
03:17clgvlpetit: ah good. as a temporary fix until there is time to implement support for more leiningen features, right?
03:18clgvlpetit: with leiningen2-preview10 I could fix it via moving the :hooks to a profile, since technomancy fixed it the same day, I reported it <3
03:19lpetitclgv: the problem is that I wanted quick user feedback (for the class path) when the user changes project.clj. Thus Ive made ccw keep leiningen project maps live and in the same process as eclipse. For other Leiningen features, though, I intend to just launch separate jvms every time the users triggers a command
03:20clgvlpetit: thats probably a good idea
03:20lpetitclgv: would be interesting to see if that solves the problem and if I can then remove the hack. Please ping me when you've tested it ok (or not)
03:21clgvlpetit: can do
03:21lpetitkewl
03:22clgvlpetit: is thursday your regular CCW-Day? ;)
03:24lpetitclgv: yep
03:24clgvlpetit: I had not much backup data for that guess. only 2 data points ;)
03:25lpetitclgv: I also wrote about it publicly here & there
03:26clgvlpetit: ah ok. didnt read that yet ^^
03:27lpetitclgv: working on CCW each thursday (except during holidays ;) ) all year 2012, thanks to Relevance sponsoring me.
03:27clgvlpetit: I read about the sponsoring, though. that's really great. I think users of CCW noticed that regular day^^
03:28lpetitclgv: I hope so :)
03:28lpetitclgv: did you find time to test the beta ?
03:28ejacksonbonjourLaurent
03:29clgvlpetit: not yet. I was always too tired in the evenings :/
03:29clgvlpetit: the project of another laurent keept me busy ^^
03:29lpetitejackson: Hallo Freunde
03:30lpetitclgv: ?
03:30clgvlpetit: I am using JPPF (jppf.org) for task computation distribution for my clojure algorithms
03:31clgvlpetit: the main (or even sole) maintainer is also a laurent it seems^^
03:31lpetitha :)
03:41n00b6502q1 does clojure have LLVM backend q2 how much do clojure and commonlisp diverge
03:43clgvn00b6502: afaik currently, there is no LLVM backend - although some were discussing that idea on the mailing list
03:44n00b6502q3 clojure/android .. anyone done it ?
03:46clgvn00b6502: there is a google summer of code project dedicated to clojure on android
03:56clgvlpetit: btw. does the leiningen classpath container work together with project references?
03:56lpetitclgv: not yet
03:56lpetityou mean, if it finds the dependency in the workspace, then it should use it instead?
03:57clgvlpetit: yes. similar to leiningen's "checkouts" feature but on eclipse level
03:57clgvlpetit: without leiningen classpath container the project references worked ^^
03:57lpetitclgv: this is a feature I want to add. Chas has been asking for it for a long time. Just need more thursdays :)
03:58clgvlpetit: ok I rename wednesday to "almost thursday" for you ;) :P
03:58lpetitclgv: I was not sure about the semantics, also.
03:58lpetitclgv: ok, let's talk offline about the billing "detail" :)
03:58clgvlpetit: hm yeah I know that problem^^
04:00lpetitclgv: semantics = how should we "match" a project in the workspace with a dependency ? Should we bring in the version number in the match? Or just match groupId/artifactId ?
04:02clgvlpetit: well, we got the project referenced (as usual in eclipse), so we have the project.clj. I would "match" on groupId/artifactId only. since you explicitly decided to set the project as reference
04:04lpetitclgv: Oh, I was thinking about something more "magic", more like was m2e does for maven : the class path container for leiningen dependencies can declare projects (not just jars), so I intended to do this referencing automatically (maybe a global flag preventing this feature, also)
04:04clgvlpetit: but it's hard to tell if that has annoying consequences in every day development in other scenario then the one I have currently
04:05lpetitclgv: what about my last suggestn?
04:05clgvlpetit: oh, I haven't thought that far. could that magic not be build upon the classic scenario I just described?
04:06lpetityou mean, just have leiningen class path container drop dependencies for projects that are explicitly added by the user in the projects tab ?
04:06clgvlpetit: if there is a switch for the "magic part" then you can turn it off at debugging times when you do not trust it
04:07clgvlpetit: yeah that would work.
04:07lpetitclgv: I guess both approaches aren't exclusive, really. Not sure if we need both, though
04:07clgvlpetit: another idea is that you do the "magic way" but have a dialog to override decisions of it
04:09lpetitThat's possible, there's a way to "customize" class path containers in a per-project way. But the results of the customization will live in the .classpath file (that's what the "class path container" framework does), so it'll be probably shared among developers if checked in the scm
04:09Apage43so, assuming I'm going to be blogging with some snippets of Clojure littered about, what doesn't suck terribly for highlighting it?
04:10clgvApage43: you could integrate github pastes if you have an account there
04:10Apage43that might be what I wind up doing
04:11Apage43I wish I could avoid HTML surgery to get the final post though :/
04:12clgvlpetit: humm, having this decision in scm is probably not that optimal.
04:12lpetitclgv: that's why I mentioned it
04:13clgvlpetit: is it possible to have the overriding settings int the ".settings" folder?
04:14lpetitclgv: by not using the default mechanism, probably
04:14clgvlpetit: hm you would violate the regular semantic to classpath containers then, right?
04:15lpetitmaybe not. But he, we're not there yet, so maybe we should postpone digging deeper for another time
04:17clgvlpetit: right. I just have to decide for myself whether my main project should move to leiningen support without project references
04:18lpetitclgv: it's a shame that the ability to disable a dependency from the dependencies automatically listed by a class path container is not just an out of the box feature of Eclipse :-(
04:19clgvlpetit: maybe thats no requirement for java/eclipse projects..
04:19lpetityep
04:20lpetitclgv: oh, I can see that leiningen2 has changed quite a lot with the recent releases. I guess I will stop for a while doing bug corrections for ccw support until it has stabilized more (your patch will be included in next beta, tho)
04:21clgvlpetit: what lein2 preview did CCW 0.9.0 base on?
04:22lpetitclgv: preview 6 I guess
05:06naegis there someting like a while with bindings? want to create a game loop which repeatedly asks for user input and changes a board according to that input
05:09naegoh yeah, loop :)
06:01naeghow can I force the output of a single print?
06:14ejacksonnaeg, do ?
06:16naegejackson: didn't work, but (flush) did
06:17naegalso, one more small thing before my connect four is finished - what's the best way to read in a single integer from the user?
06:17naegcurrently doing it like this: (dec (read-string (str (first (read-line)))))
06:18naeg(dec because if user choses column 1 it's vector 0)
06:18lazybot⇒ -1
06:20ejacksonnaeg: didn't know that one, thanks.
06:24raeknaeg: you can use read
06:25clgv(dec because if user choses column 1 it's vector 0)
06:25lazybot⇒ -2
06:26clgvlol haha. karma ^^
06:26naegraek: I guess I can skip over just using the first number - user input is error prone anyway
06:29naegclgv: what's that about anyway?
06:29nbeloglazovclgv, don't be mean
06:29nbeloglazov(inc because if user choses column 1 it's vector 0)
06:29lazybot⇒ -1
06:31clgvlol
06:31clgv$karma because if user choses column 1 it's vector 0
06:31lazybotbecause has karma 0.
06:31clgv$karma "because if user choses column 1 it's vector 0"
06:31lazybot"because has karma 0.
06:31clgv(karma because if user choses column 1 it's vector 0)
06:31nbeloglazov:)
06:31clgvhmm seems not very consistent
06:36Raynesnaeg: Are you reading raw user input?
06:36Raynesnaeg: Make sure you do (binding [*read-eval* false] (code that does the reading here)) if so, otherwise users will be able to execute arbitrary code in your application.
06:38naegRaynes: I actually just wanted to write a little game loop for experimenting my checking algorithm for connect four
06:39naegwhat do you think about my connect four checking algorithm? https://gist.github.com/3520562
06:39naeg(farely new to clojure)
06:42hyPiRionnaeg: First thing I notice is that you have empty-board as a function. It could just be a def, couldn't it?
06:43naeghyPiRion: I actually planed to make it more flexible about the board dimensions, but didn't do so yet
06:43hyPiRionah, figures.
06:48hyPiRion(not= (get-in ... a) ... ) could be replaced as (apply not= (map #(get-in board %) [a b c d]))
06:48hyPiRionat line 59
06:48naeghyPiRion: very nice, thanks
06:48hyPiRionand from there on, you see that you could just remove the destructuring
06:49naeghyPiRion: wouldn't that result in nested #()?
06:50hyPiRionah, I meant that (fn [[a b c d]] ... ) could be replaced by (fn [coll] ...) instead
06:50naegoh, yeah
06:52naeglooks a lot better with apply now
06:56hyPiRionOh and yeah
06:56hyPiRion,(= (apply concat (for [y (range 6)] (for [j (range 4)] (for [i (range 4)] [y (+ i j)])))) (for [y (range 6), j (range 4)] (for [i (range 4)] [y (+ i j)]))))
06:56clojurebottrue
06:57hyPiRionusually, patterns of 3 or more of the same function/macro can be compacted in some way
06:58hyPiRionit's not always obvious how to do it though, so if it's evident what you're trying to achieve, it doesn't really matter that much
07:02clgvnaeg: yeah should read more about `for`. you can write really compact "complex iterations" with it
07:03clgve.g. ##(for [x (range 5) y (range 5) :when (< x y)] [x y])
07:03lazybot⇒ ([0 1] [0 2] [0 3] [0 4] [1 2] [1 3] [1 4] [2 3] [2 4] [3 4])
07:03clgvas a small example ^^
07:04naegclgv: I know about :when and :while if you mean that, but it doesn't come in handy here, does it?
07:04clgvnaeg: no. but you can and should reduce the nested `for` forms to one^^
07:04naegclgv: for the diags? I'll see what I can do
07:05naegbtw, is that "idiomatic" with the (def player) and just chose the symbol by number? Couldn't think about a better way
07:05mindbender1naeg: where does get-y come from
07:06naegmindbender1: it's defined above? or do you mean why I actually need it?
07:06mindbender1I meant definition
07:07clgvnaeg: you probably dont need the indirection from player to symbol. you could directly represent the player with the symbol. how about using keywords and nil for the board? :X :O nil
07:07naegmindbender1: line 10-14?
07:07clgv(str :X nil :O)
07:07clgv&(str :X nil :O)
07:07lazybot⇒ ":X:O"
07:08naegclgv: I wanted to put it into one place (like a constant) so when I decide to change the representation, I only have to do it at that def
07:08clgvnaeg: ok, if it is really worth it for you. keep it ^^
07:08mindbender1naeg: I can't see a def for get-y
07:08naegotherwhise you have to do it for insert, empty-board, get-y, ...
07:09mindbender1my repl has an error on it
07:09naegmindbender1: maybe reload the page? I can see it at line 10
07:09clgvnaeg: it's inner state of your game. you could also only change it in the output function if you just want to change the output the user sees ;)
07:09mindbender1naeg: ok seen it now
07:11naegclgv: seems more "functional"? just putting nil :1 :2 or :X :O and print as "X" and "O"
07:12clgvnaeg: well, I dont think you would change that inner representation of this game in other (oop) languages often, as well
07:13clgvnaeg: an interesting goal for your game would be, that your implementation is such that you can easily let 2 AIs play against each other as well as human and AI mixed.
07:14naegclgv: https://github.com/naeg/clj-connect-four
07:14naeghad that in mind too ;)
07:14clgvok^^
07:15clgvnaeg: how about a reinforcement learning AI? ;)
07:17naegclgv: maybe one day, but I have enough learning to do with my ideas already^^
07:17naegclgv: for the insert, just take player-number (either 1 or 2) and do (keyword player-number)?
07:18naeg(keyword (str player-numer))
07:20naegnah, well I guess I'll leave the board representation as it is. It's not about that anyway, it's about the checking algorithm (want to compare it to a bit-board solution and maybe core.logic)
07:24naegthanks to all of you
07:25nkkarthikdoes clojurescriptone tutorial work with lein 2?k
08:08mindbender1nkkarthik: It has not been updated for lein 2
08:09nkkarthikmindbender1: yeah I guess so... thank you
08:09nkkarthikfrom emacs can we jack-in into cljsbuild repl-launch?
08:13xeqinkkarthik: with nrepl.el and https://github.com/cemerick/piggieback you can get a cljs-repl
08:13nkkarthikxeqi: oh I will look into that... thank you
08:36cshellHas anyone been able to connect to a remote repl from La Clojure?
08:37cemerickI didn't realize La Clojure had remote REPL capability at all…
08:38cshellYeah, that appears to be the case
08:38cshellI wonder how hard it would be to add
08:38cshellIs there a java/clojure api for connecting/interacting with a remote repl?
08:38cemerickDepends on what REPL backend is being used.
08:39cshellWhat's the most common REPL back end?
08:39cemerickLast I looked, La Clojure just piped through to a terminal REPL; lifting that into something network-capable isn't pretty.
08:39cshellyes, that is the current state
08:40cshellbut it would be valuable, right?
08:40cemerickcshell: http://github.com/clojure/tools.nrepl is what Leiningen, ccw, nrepl.el, etc use.
08:40cemerickYes, if you can somehow get La Clojure to use nREPL, that'd be great.
08:41cshellOkay cool, thanks for the link - maybe I'll try to get it working sometime soon - the hardest part will be navigating the plugin api for intellij - it's the worst thing about it
08:42clgvis there some clojure notation for "pure thread-local storage" without the capabilities of binding?
08:43cemerickcshell: note that nREPL includes a Java API, which might be helpful if La Clojure is implemented in Java: https://github.com/clojure/tools.nrepl/blob/master/src/main/java/clojure/tools/nrepl/Connection.java
08:44cshellawesome, yeah that is exactly what I was looking for
08:56jowagHi, which is more idiomatic, (apply conj {} kv-seq), or a (reduce conj {} kv-seq) ?
08:57cshelljowag: good, question
08:57jowagchouser: Hi, which is more idiomatic, (apply conj {} kv-seq), or a (reduce conj {} kv-seq) ?
08:58chouserreduce
08:58cshelldoes the first one work?
08:58jowagin Clojurescript, reduce is faster, dunno about vanilla clojure
08:59jowag,(reduce conj {} [[1 2][3 4][5 6]])
08:59clojurebot{5 6, 3 4, 1 2}
08:59jowag,(apply conj {} [[1 2][3 4][5 6]])
08:59clojurebot{5 6, 3 4, 1 2}
08:59cshellnice
09:00chouserhttp://clojure-log.n01se.net/date/2009-01-12.html#13:48
09:01cshellwow didn't know about that log
09:01xeqi,(into {} [[1 2][3 4][5 6]])
09:01clojurebot{1 2, 3 4, 5 6}
09:01chousercshell: smile, you're being logged right now.
09:02chouserNote the date on that -- over 3.5 years ago.
09:02jowagchouser: thanks, that settles it
09:02cshellchouser: haha, good thing I've limited my worst comments to private chats with clojurebot
09:06jowagxeqi: thanks, seems like into is the best choice for this particular task
09:39nkkarthikClojureScript cljsbuild repl-listen... getting JS errorNo *print-fn* fn set for evaluation environment... what could be done?
09:52nkkarthikI got it... I cannot use (print "foo") I suppose
09:55dnolennkkarthik: that doesn't really make sense at least IME. print should work just fine.
09:57nkkarthikdnolen: hmm... I have no clue why it is happening...
09:57nkkarthikI had only two lines (ns try.core) (print "hello")
09:57dnolennkkarthik: did you try println?
09:57nkkarthikdid cljsbuild once... loaded the index.html with the generated js file and it shows that error
09:58nkkarthikoh... didn't... just removed that line and it worked
09:58dnolennkkarthik: oh if you're trying to use browser repl then you need to include it in your ns.
09:58nkkarthikactually I didn't needed any print (though I thought it would print to console)
09:58dnolennkkarthik: *print-fn* needs to be set since we really can't make any assumptions about where you are runnign js
09:59dnolennkkarthik: in the browser it's console.log but that's not necessarily true in Rhino, or JSC, or SpiderMonkey JSShell etc.
09:59nkkarthikah... what could be a decent default for firefox?
09:59dnolennkkarthik: if you want that to work just (set! *print-fn* (fn [x] (.log console x)))
09:59dnolennkkarthik: do that in your file.
10:00dnolenafter that line print/println will work.
10:01nkkarthikdnolen: cool... I will try that... thank you for the help
10:12nkkarthikcan nrepl.el jack-in to use clojurescript repl? tried piggieback but getting some errors
10:13cemericknkkarthik: Did you tweak your project.clj to add the piggieback middleware?
10:14nkkarthikcemerick: yeah... it said nrepl middleware not found
10:15cemerickInteresting.
10:15nkkarthikthese are the things I added
10:15cemericknkkarthik: which version of Clojure and Leiningen?
10:15nkkarthik :injections [(require 'cemerick.piggieback)]
10:15nkkarthik :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
10:15nkkarthikclojure 1.4.0
10:15nkkarthikLeiningen 2.0.0-preview7 on Java 1.6.0_18 OpenJDK 64-Bit Server VM
10:16cemericknkkarthik: ah, ok: that Leiningen configuration requires a minimum of preview9, I think.
10:16nkkarthiksorry... that's just output redirected to here...
10:17cemerickIt says Leiningen master in the README, but I think that was just prior to preview9.
10:17nkkarthikcemerick: oh ok... I will upgrade now and let you know
10:18dnolenfor those following CLJS feedback on this would be appreciated - http://dev.clojure.org/jira/browse/CLJS-340
10:23dnolenplease check out the patch & comment on the ticket. would like to move forward on this one.
10:26evalifoohello
10:26evalifoois there any work done to get closure bindings for clojure ?
10:26nkkarthikcemerick: hey... nrepl started with latest leiningen
10:26nkkarthikcemerick: next I tried to start browser repl with
10:26cemericknkkarthik: Fabulous. :-)
10:30nkkarthikcemerick: you are awesome... thank you very much for giving us piggieback
10:30cemericknkkarthik: Just a bit of glue :-) Glad it worked for you.
10:31nkkarthikcemerick: you can rhyme too :)
10:31uvtcNo more rhyming. I mean it.
10:31nkkarthikor maybe rap
10:32cemerickI don't really have that great a flow, probably because I rarely get a chance to blow.
10:33cemerickuvtc: You should be happy for some rhyming; just imagine how irritating it'd be if we were all miming.
10:33nkkarthikha ha ha... cool bro
10:33cemerickI'll be here all night folks, tip your waitresses. :-P
10:33casionthat sounded sincere :P
10:33uvtcProbably it's no harm. ... It adds a certain charm.
10:35uvtccasion: (Princess Bride reference :) )
10:36casionah, never saw it
10:37casioncmon nkkarthik you can use any words, take your pick
10:37uvtcnkkarthik, are there compiler errors ahead?
10:38hyPiRion,(require '[clojure.string :refer [join]])
10:38clojurebotnil
10:39algernonoh, compiler errors! / in my heart, they'll send tremors / for when I see one, I need to squish / and accidentally step on a fish.
10:39hyPiRion#poetry is over there, guys.
10:39nkkarthikuvtc: :)
10:39gfredericks"me fancy pants make me fancy prance"
10:40technomancyclojurebot: java.util.concurrent?
10:40clojurebotjava.util.concurrent is "When I find myself in times of trouble / Prof. Doug Lea comes to me / Coding lines of wisdom / j.u.c."
10:40llasramniiice
10:40gfredericksif you want to include slashes in your poem do you have to escape them?
10:40gfrederickswhat is the standard escape mechanism in poetry?
10:41llasramgfredericks: You escape them with newlines
10:41gfrederickslol
10:41nkkarthikha ha ha
10:41hyPiRiongfredericks: \n works fine
10:42llasramAnyone have any insight into why `clojure.java.io/Coercions` doesn't include an `as-uri`?
10:44llasramMy understanding is that java.net.URL has (used to have?) some serious issues, and java.net.URI is generally the way to go. But maybe I'm mistaken?
10:45clgvllasram: doesnt URL has a toURI method?
10:50llasramclgv: It does at that, so I suppose one can easily implement `as-uri` in terms of `as-url`
10:50clgvllasram: I'd think so
10:50llasramI just don't quite understand the reasoning, given that classes have differences which are orthogonal to the URI/URL distinction
10:51llasramAnd the URL class really does seem to be completely broken: the .equals method (a) *resolves the hosts* of the URLs, and (b) considers them equal if they resolve to the same IP
10:51llasramAnd .hashCode also does host resolution
10:51llasramI'd really just rather never create one of these beasts :-)
10:52uvtcpjstadig: Informative talk (Laziness, the Good, Bad, & Ugly). Thanks. :) Too bad infoq doesn't show the code demo below where the slides would normally go. Aside: I'm glad I could hear the questions asked at the end. Sometimes those don't get recorded well.
10:52pjstadigyeah :(
10:53clgvllasram: sometimes they are created for you, cf. clojure.java.io/resource
10:53pjstadigi wanted to do something different with live coding, but it doesn't translate so well into video without videoing the projection screen
10:53pjstadigthanks the feedback :)
10:53casionoh, a new clojure talk
10:54casionI needed something to listen to, yay
10:54llasramclgv: Fair enough. Although those are file: URLs, which are probably fine. I'm probably just over-thinking this
10:54uvtcpjstadig: Yeah, seems like there should be a solution there. A way to do live coding and have it translated into slides ...
10:56uvtcMaybe an Emacs command to htmlize the current screen and send it directly as the "next slide".
10:57casionyou could setup something with org-babel pretty easily I think
10:58casionI don't know how people handle slides though, is there a way to update a presentation without reloading it?
10:59pjstadiguvtc: the code from the pres is available
10:59pjstadighttps://github.com/pjstadig/laziness
10:59scriptorhow do people typically embed code in slides anyway?
11:00uvtcI think it's great how infoq displays slides in sync with the talk.
11:00uvtcpjstadig: thanks.
11:01nDuff....so -- I have a delay that throws an exception in an external atom is nil. That works fine -- but when trying to eval it again, its locals have been cleared.
11:02nDuff...hrm, looks like CLJ-232
11:02nDuff...except that's marked fixed.
11:11lpetitShould something like (:foo (Object.)) have thrown an exception in my face, I would have not wasted a lot of debugging time :-/
11:13nDuffI'm seeing behavior that strikes me as a potential bug in Clojure 1.4 -- can anyone comment? https://gist.github.com/9a1fa25f9a7429b6def7
11:14clgvlpetit: yeah. you can do that with symbols as well
11:15lpetitclgv: well, I don't like it :)
11:15clgvlpetit: I had that several times myself :/
11:16hyPiRionnDuff: That's expected behaviour, I believe.
11:16hyPiRionA delay just delays the computation, and saves the result from it later on.
11:17hyPiRionWhen the delay throws an exception, nothing (nil) is returned.
11:17nDuffhyPiRion: Let me come up with a better test case -- that's not what it's actually doing.
11:18nDuffhyPiRion: ...the real case I'm trying to simplify from clearly demonstrates that the code inside the delay is executing again, but with locals cleared.
11:20ystaelI have a question about type annotation metadata and how to get at it once it's created
11:21ystaelI'm trying to add support for exposing operations to clojure/java.jmx, and I thought it might be nice to support type annotations on signatures to expose parameter types through JMX (for non-Clojure JMX clients)
11:21ystaelBut I clearly don't understand where the annotation metadata "goes" once it's defined
11:22hyPiRionnDuff: ah.
11:22nDuffhyPiRion: Just updated with a new reproducer.
11:22clgvystael: the "type hint" is stored in the metadata attribute :tag
11:23ystaelIf I do: (defn foo [^Long a] (* 2 a)) what object is the metadata attached to?
11:23clgvystael: its attached to symbol a
11:23ystaeli.e., (meta WHAT) should contain {:tag Long} ?
11:23clgv,(meta ^Long a)
11:23clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
11:23clgv,(meta ^Long 'a)
11:23clojurebotnil
11:23clgvnot that easy
11:24clgv,(meta (read-string "^Long a"))
11:24clojurebot{:tag Long}
11:24clgv,(pr (meta (read-string "^Long a")))
11:24clojurebot{:tag Long}
11:24ystael,(do (defn foo [^Long a] (meta 'a)) (foo 3))
11:24clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
11:25clgvystael: no, that is not possible. you can only access that metadata in a macro on compile time
11:25ystaelah ha! that's the problem
11:26ystael^ is processed by the reader and what is floating around in the *source chewed by my macro* is a symbol that has metadata on it
11:26ystaelbut it does not survive until the actual code runs
11:26ystaelcorrect?
11:27clgvystael: ok, I checked. it is still present in (-> #'foo meta :arglists)
11:28clgvystael: try the following to see it (binding [*print-dup* true] (-> #'foo meta :arglists pr))
11:28ystaelclgv: yeah, (-> #'foo meta :arglists first first meta) ;; => {:tag Long}
11:28hyPiRionclgv: Seems like it loses its environment
11:29hyPiRionsorry, I meant nDuff
11:29nDuffShoot.
11:30nDuffLooks like it only happens with slingshot's throw+
11:30nDuffworks fine with (throw (Exception. "foo"))
11:30ystaelclgv: but this doesn't work with letfn?
11:30ystael,(binding [*print-dup* true] (letfn [(foo [^Long a] (* a 2))] (-> 'foo meta :arglists pr)))
11:30clojurebotnil
11:30clgvystael: humm maybe not
11:31ystaelmakes sense because 'foo there is just a symbol, the fn is not bound to it until run tiem
11:31clgv(binding [*print-dup* true] (letfn [(foo [^Long a] (* a 2))] (-> foo meta pr)))
11:31clgv,(binding [*print-dup* true] (letfn [(foo [^Long a] (* a 2))] (-> foo meta pr)))
11:31clojurebotnil
11:32ystaelbut if i chew that letfn-body up in a macro, the metadata should be visible in the arg symbol there
11:32ystaelwhich is what i want to do
11:33hyPiRionnDuff: hm.
11:34clgvystael: yeah in a macro you have the metadata on the symbols
11:37ystaelclgv: cool, thanks much for your help
11:37hyPiRion,(let [b (fn [s a] (let [d (delay (if (nil? @a) (throw (Exception.)) s)) c (atom nil) f (b "foo" c)] (try @f (catch Exception _ (swap! c not) @f)))
11:37clojurebothyPiRion: Cool story bro.
11:37clgvystael: pr with *print-dup* set to true often helps ^^
11:39hyPiRionclojurebot: So you don't like try catch, eh.
11:39clojurebotCool story bro.
11:40clgvhyPiRion: try lazybot^^
11:40hyPiRion&(try 0 (finally 1))
11:40lazybot⇒ 0
11:40hyPiRion&(let [b (fn [s a] (let [d (delay (if (nil? @a) (throw (Exception.)) s)) c (atom nil) f (b "foo" c)] (try @f (finally (swap! c not) @f)))
11:40lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
11:41clgvso it's not clojurebot's fault. he is just too lazy to give you the reason for not evaluating ;)
11:41hyPiRionclgv: it is
11:41hyPiRion,(try 0 (finally 1))
11:41clojurebothyPiRion: Cool story bro.
11:42hyPiRionWell, and I had some semantics messed up
11:43clgvah lol. well maybe it's philosophical: don't try - just do!
11:43hyPiRion&(let [b (fn [s a] (let [d (delay (if (nil? @a) (throw (Exception.)) s))] (fn [] @d))) c (atom nil) f (b "foo" c)] (try (f) (finally (swap! c not) (f))))
11:43lazybotjava.lang.NullPointerException
11:43hyPiRionYeah, there we go. It loses its environment.
11:44hyPiRionit's a hellhole though, better clean the thing up a bit.
11:48hyPiRionInteresting.
11:49hyPiRion&(let [a (atom false), b "foo", d (delay (if @a (/ 0 1) b))] (try d (finally (swap! a not) d)))]
11:49lazybot⇒ #<Delay@57d10: :pending>
11:49hyPiRion&(let [a (atom false), b "foo", d (delay (if @a (/ 0 1) b))] (try @d (finally (swap! a not) d)))]
11:49lazybot⇒ "foo"
11:51uvtcHow can I get every item in a coll *except* for the nth one? (I'd actually like a way to get both at the same time: the n'th, and everything but the n'th). Currently I'm using shuffle then first & rest.
11:52uvtc(Er, I mean, I'm using `shuffle` because the n'th I want is a random n'th.)
11:52lotiajava interop question. any pointers to syntax help on how I'd import multiple java classes within a namespace definition
11:52uvtc(In this particular case, anyway.)
11:56clgvuvtc: well use a set - randomly draw one element and remove it from the set
11:59uvtc,(let [s #{:a :b :c :d}] [(first s) (rest s)])
11:59clojurebot[:a (:c :b :d)]
12:00uvtcclgv: Nice. Thanks. :)
12:00jeremyheiler_hyPiRion: The delay was forced in the try, so that makes sense.
12:01jeremyheiler_&(let [a (atom false), b "foo", d (delay (if @a (/ 0 1) b))] (try d (finally (swap! a not) @d)))
12:01lazybot⇒ #<Delay@135f562: 0>
12:01clgvuvtc: just to be exact, that's not what I meant
12:02uvtcclgv: can you give me an example?
12:03clgv,(let [s #{:a :b :c :d} i (rand-int (count s)) e (nth s i)] [e (disj s e)])
12:03clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: PersistentHashSet>
12:03clgv,(let [s #{:a :b :c :d} i (rand-int (count s)) e (nth (seq s) i)] [e (disj s e)])
12:03clojurebot[:b #{:a :c :d}]
12:03clgv,(let [s #{:a :b :c :d} i (rand-int (count s)) e (nth (seq s) i)] [e (disj s e)])
12:03clojurebot[:a #{:c :b :d}]
12:04arkhwould anyone know why raynes conch has a 'read-line' function missing in the clojars jar but it's present on his github repo?
12:04clgvuvtc: it works. but might perform good or bad depending on its context
12:04uvtcclgv: thanks!
12:06jeremyheiler_arkh: How are you determining that it's missing?
12:07arkhjeremyheiler_: I did a wget on the clojars jar (the same URL lein used) and compared conch.core to his github repo. read-line doesn't exist in the jar
12:08arkhjeremyheiler_: and caused me errors and consternation ;)
12:08nDuffhyPiRion: Are you running with this one yourself, or should I submit your reproducer as part of a CLJ ticket?
12:09arkhjeremyheiler_: I'm using 0.2.1
12:10jeremyheiler_arkh: It seems the read-line function didn't appear until 0.2.4
12:11jeremyheiler_At least, that is the version number in project.clj when read-line was committed.
12:12arkhjeremyheiler_: oh - I blindly followed the readme.md instructions on his master branch. Thank you for finding that!
12:12jeremyheiler_Yeah, so actually that means read-line didn't appear until 0.3.0
12:12lpetitCan this be simplified ?
12:12lpetit#(let [comparator (serverrepl/textmate-comparator prefix)]
12:12lpetit (comparator (:completion %1) (:completion %2)))
12:14clgvlpetit: if you need to sort something there would by sort-by - but it seems there is no compare-by
12:14lpetitAssume I have a comparator c1. And I want it to apply only on the :completion key of its inputs.
12:15lpetitclgv: I need some kind of higher level functions which would take the target function (the comparator), then argument transformation functions.
12:16lpetitSo that it could be called like: (adapt-arguments c1 :completion :completion) -> then calls to it would be equivalent to calls to (comparator (:completion %1) (:completion %2))
12:17clgvlpetit: you probably have to write that one yourself.
12:17lpetitclgv: so I will just use the code shown above for now on :)
12:33lpetitclgv: there were are, https://gist.github.com/3532443
12:33clgvlpetit: that pattern looks strangely familiar
12:34lpetitclgv: I first wrote the generic function (the last line), then added special cases for 1 & 2 arguments functions so that it goes generally fast (e.g. for my comparator which takes 2 arguments)
12:35clgvlpetit: ah right map&co do the same^^
12:35lpetitSo I had first a clear version made of 4 lines, and now I have a one line version plus an obscure helper function of 20 lines :)
12:37technomancyis there a good thrush-friendly idiom for "call update-in on this map with this key path, but only if the key is already present?
12:37technomancy"
12:38clgvlpetit: arg the symbol-issue ('symbol anything) bit me just now :(
12:39lpetitclgv: corrected in the beta I will release soon
12:39clgvlpetit: no I meant, I had a similar error to what you mentioned with keywords before ;)
12:40lpetitah :)
12:42clgvwell. next try. I hope there won't emerge an error.log this time ^^
12:46clgvhah. works! :)
12:47hyPiRionjeremyheiler_: Yeah, I screwed up a lot in that test. It's better when you can def and so forth in an actual repl.
12:47jeremyheiler_ah ok
12:48jeremyheiler_I opened the logs and saw the rest of your conversation with nduff, and realized what was going on
12:50gzmaskhumm... newbie question folks, ['a 'b :name 12.5] in this vector, what are the 'a and 'b? are they lists?
12:50hyPiRionnDuff: I'll have a better look at it now, as the code I used here didn't really make sense at all.
12:51clgvgzmask: symbols
12:51mattmoss,(class 'a)
12:51clojurebotclojure.lang.Symbol
12:51clgv&(map type ['a 'b :name 12.5] )
12:51lazybot⇒ (clojure.lang.Symbol clojure.lang.Symbol clojure.lang.Keyword java.lang.Double)
12:51thorbjornDX,(class '(a))
12:51clojurebotclojure.lang.PersistentList
12:51mattmossYa, realize that 'a is shorthand for (quote a)
12:54gzmaskmattmoss: (quote a) is no eval ?
12:54mattmossgzmask: Yeah, I guess you could say that it prevents eval.
12:55shaungilchristwow lazy-seq stuff is rad
12:55mattmossSo... (1 2 3) the compiler will attempt to eval as calling function "1" with args 2 and 3.
12:55mattmossWhere as '(1 2 3) is a sequence/list of 3 items.
12:55mattmoss,(1 2 3)
12:55clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
12:55mattmoss,'(1 2 3)
12:55clojurebot(1 2 3)
12:55gzmaskmattmoss: oh i see, that's how lisp preserves a list
12:56mattmossAnd (quote (1 2 3)) = '(1 2 3)
12:56hyPiRionAnd by using this, we can generate code on the fly:
12:56hyPiRion,(cons '+ (1 2))
12:56clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
12:57hyPiRion,(cons '+ (list 1 2))
12:57clojurebot(+ 1 2)
12:57mattmosshmm...
12:57mattmoss,((cons '+ (list 1 2)))
12:57clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn>
12:57jsnikerisWhat's a good way to coerce parameters using ring? E.g. "1" -> 1, "2012-08-30" -> java.util.Date. Is it better to do this in a handler or using middleware?
12:57gzmask,((cons '+ '(1 2)))
12:57clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn>
12:58mattmossgzmask: Ignore what I typed... was experimenting, and added extra ( )
12:58mattmosshyPiRion: So how would you then evaluate the result of your cons?
12:58hyPiRionmattmoss: usually, you'd use eval to evaluate a list
12:59gzmask,(cons '+ '(1 2))
12:59clojurebot(+ 1 2)
12:59mattmossIs eval "evil" in clojure as compared to other langs?
12:59mattmoss,(eval (cons '+ '(1 2)))
12:59clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
12:59`fogusMoar evil!
12:59mattmosslol
12:59gzmasklike js?
12:59mattmossApparently it's evil here.
12:59nDuffmattmoss: Not as much as some, but it's still better avoided.
12:59hyPiRion~evil
12:59clojurebotevil is DENIED
12:59S11001001mattmoss: eval is evil in clojure, as with all reasonable lisps
12:59S11001001jsnikeris: handler
13:00jsnikerisS11001001: That's what I'm thinking. So basically every parameter handles coercing the parameters it expects, right?
13:00hyPiRionmattmoss: It's "evil" in the sense that we have discovered that it will lead to bugs, and that you will become frustrated at your code if you're using it
13:00S11001001jsnikeris: yes
13:00jsnikerisS11001001: thanks!
13:01mattmossIt's just... I'm hooking up a Java lib that involves calling lots of camel-case g/setters, originating from clojure maps with typical dashified keywords.
13:01`fogusA slightly less-evil eval --> https://github.com/fogus/evalive
13:01gzmask,(eval (cons '+ '(1 2)))
13:01clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
13:01mattmossSo I tried various ways to use macros with (defn dash-to-camel [] ...) etc, but could not figure out how to generate the calls into java without going to reflection.
13:02mattmossAnd granted, reflection might be the proper way to do it rather than messin' with macros.
13:02hyPiRiongzmask: clojurebot and lazybot doesn't allow eval, because it may run dangerous code.
13:02S11001001mattmoss: I've written this before, without reflection: (bean-set! jobj {:a b, :c d}) => do setA(b), setC(d) on jobj
13:02gzmaskhyPiRion: yea, i figured. it's da evil here...
13:03mattmossS11001001: Is that in contrib? Hadn't seen that...
13:04uvtc`fogus: Egads, scary icon graphic for evalive. :)
13:04mattmossAlthough I did find this: http://pastebin.com/DbBdFxmG
13:05`fogusuvtc: Helps to highlight the level of evil we're dealing with
13:05uvtchahaha
13:05S11001001mattmoss: that's not my version; I don't have it around right now, but you have to exploit all the compile-time knowledge you can get your hands on to implement it
13:06S11001001mattmoss: in particular, it's possible to implement a version that can sometimes avoid reflection even if the map you provide isn't literal, but much harder to do so
13:07S11001001mattmoss: the simple implementation strategy relies on the presence of a map literal to compile out the reflection
13:07rbxbx`fogus nice reference :)
13:07mattmossWell, now that I am recalling the work I did at 2am last night... reflection might not be so bad. I'm using that anyway to determine what getters and setters exist.
13:08mattmossAlthough clojure.reflect doesn't seem to have an included way to call a method from clojure.reflect.Method info.
13:13Frozenlo`Did I imagine this, or there's a way for a function to have different behavior depending on the type of argument?
13:13S11001001Frozenlo`: sure
13:13S11001001,(doc case)
13:14clojurebot"([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are not evaluated. They must be compile-time literals, and need not be quoted. If the expression is equal to a test-constant, the corresponding result-expr is returned. A single default expression can foll...
13:14mattmossPerhaps Frozenlo` is thinking of multimethods?
13:14S11001001mattmoss: perhaps you should try writing this function: (setters cls) => (fn [arg] (case arg :a #(.setA % %), :bob #(.setBob % %), ...); then, write a :inline (see core.clj) for it that exploits a direct `cls' reference
13:14SegFaultAX|work2What's the best way to split a number into its digits?
13:14SegFaultAX|work2Eg (digits 1234) => (1 2 3 4)
13:14Frozenlo`isn't case the same thing as cond?
13:15S11001001no
13:15S11001001Frozenlock: (if (string? it) do-something do-something-else) :)
13:15mattmossS11001001: Thanks... good idea. I'll take a look at it.
13:15S11001001SegFaultAX|work2: str, then map subtracting 32, with coercions as needed
13:16FrozenlockS11001001: Thanks!
13:16SegFaultAX|work2,(map #(Integer/parseInt %) (str 1234))
13:16clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String>
13:16SegFaultAX|work2,(map #(Integer/parseInt (str %)) (str 1234))
13:16clojurebot(1 2 3 4)
13:17SegFaultAX|work2That's the best way?
13:17S11001001,(map #(- (int %) 32) (str 1234))
13:17clojurebot(17 18 19 20)
13:17S11001001well, not 32, 48 I guess
13:17mattmoss,(clojure.string/split (str 1234) #"[0-9]")
13:17clojurebot[]
13:17mattmossoops, doh
13:18mattmossignore me
13:18S11001001,(map #(- (int %) 48) (str 1234567890))
13:18clojurebot(1 2 3 4 5 ...)
13:18S11001001SegFaultAX|work2: no need for the str-again-and-parse roundtrip
13:18mattmoss,(map #(- (int %) \0) (str 1234567890))
13:18clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number>
13:18mattmossI lose!
13:18S11001001mattmoss: you forgot the coercion
13:19mattmossYa.
13:19mattmossToo much time spent in C++-/Ruby-/whatever-land.
13:20FrozenlockWhat is the prefered way between multi and protocols?
13:21technomancymultimethods
13:21S11001001multimethods
13:21technomancyunless it's a performance bottleneck
13:22FrozenlockThanks, I'll try it immediately.
13:22technomancy"The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet."
13:24dnolenFrozenlock: if you predict you and your consumers are not going to call your fn from an inner loop, multimethods are nice. you wouldn't want first to be a multimethod. But the chances that you're something as critical as first is probably pretty low.
13:24dnolenyou're writing I mean.
13:28shaungilchristso I am coming from the land of backbone apps, I would like to transition entirely to using clojurescript and cljs-isms is the pinot/ibdknox libs my best bet?
13:29dnolenshaungilchrist: there isn't really a backbone equivalent for CLJS yet.
13:31dnolenshaungilchrist: well not completely true, CLJSOne tries to be something of a complete solution ... though the branch that's more to up to date with CLJS hasn't been merged to master.
13:32shaungilchristinteresting, I will check it out again - had issues w/ my lein version last time I tried it
13:34dnolenemezeske: heh still no feedback tho I think you're patch looks pretty good to me.
13:34emezeskednolen: Cool. Did the IWriter protocol come out like you were expecting?
13:35dnolenemezeske: I think it's pretty nice!
13:35emezeskednolen: The fact that it writes straight to stdout is pretty cool
13:35gzmask_why vimclojure always cause me vim to quit with ABRT?
13:35emezeskednolen: It was pretty silly to print to a buffer and then print that before
13:36lpetitNew Counterclockwise Beta released.
13:36dnolenemezeske: and it can easily be redirected to anything that implements IWriter
13:36emezeskednolen: Yep!
13:40dnolenemezeske: perhaps my only reservation now is the name of the protocol IPrintWriter ... perhaps simply IWritable is better?
13:42FrozenlockOk so I want to try (defmulti foo class) in cljs, but when I try (class "sad") in my repl I get an error. Is class defined in cljs?
13:43dnolenFrozenlock: it is not
13:43dnolenFrozenlock: but you do have type
13:43emezeskednolen: Hmm, yeah, I wasn't super happy with IPrintWriter
13:44emezeskednolen: Really, it should just be IPrintable :)
13:44lpetitclgv: ^^
13:44dnolenemezeske: I'm actually warming up to writable since it's more generic and better communicates that it works with IWriter
13:44dnolenIWritable I mean
13:44borkdudelpetit nice, any new cool features?
13:45lpetitborkdude: since last beta ? or last stable ?
13:45emezeskednolen: I kind of feel like the "print" part is important, as that implies (to me) pr-style formatting
13:45borkdudelpetit ehm, since like six weeks ago :)
13:46Frozenlockdnolen: So (defmethod foo (type "") [s] :a-string) would be idiomatic cljs?
13:46emezeskednolen: E.g. technically you can't juse pass an IWritable instance to IWriter's -write, which is what I think those names would imply
13:46emezeskejust*
13:46dnolenFrozenlock: no (defmethod foo String [s] :astring)
13:46lpetitborkdude: well, I fixed something like 10 bugs, enhanced a little bit the code completion, integrated some pull requests. But nothing brand new. Worth the upgrade, I think.
13:47hyPiRionOkay, can people try this code? https://www.refheap.com/paste/4740
13:47hyPiRionApparently, the delay loses its closure/environment and NPE all the way.
13:47lpetitborkdude: http://code.google.com/p/counterclockwise/issues/list?can=2&amp;q=status%3Afixed
13:48dnolenemezeske: hmm, because you need the surrounding setup ... IPrintWithWriter?
13:48hyPiRionInterestingly only parts of it though.
13:49dnolenFrozenlock: actually (defmethod foo js/String [s] :astring)
13:49Frozenlockdnolen: My REPL goes crazy
13:49FrozenlockAh
13:49nsxthas fleetdb been superseded by another project?
13:49jmlI'm trying to find an example of using :expose with gen-class (for protected attributes), but am not having much luck. anyone know of any?
13:50Frozenlockdnolen: And for map that would be cljs.core/ObjMap ?
13:50emezeskednolen: IPrintWithWriter is better than IPrintWriter I think.
13:50dnolenFrozenlock: yes, though you probably don't need cljs.core/ObjMap since cljs.core is implicitly used
13:50FrozenlockOh right!
13:51dnolenemezeske: cool mind updating the patch with that?
13:51FrozenlockYay it works :D
13:51emezeskednolen: No problem, I can do that this evening
13:51dnolenemezeske: thx!
13:51FrozenlockThanks!
13:52dnolenFrozenlock: np
13:55SegFaultAX|work2Can there be multiple :when contraints in a for form?
13:55hyPiRionSegFaultAX|work2: Try it out
13:55hyPiRion,(for [x (range 10) :when (odd? x) :when (even? (+ x 1))] x)
13:55clojurebot(1 3 5 7 9)
13:55SegFaultAX|work2,(for [x (range 3) y (range 3) :when (even? x) (odd? y)] [x y])
13:55clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: for requires an even number of forms in binding vector in sandbox:>
13:56SegFaultAX|work2Ohh, I have to supply :when multiple times.
13:56scriptoris there a function like reduce but which takes a seq of functions, and iterates through that seq as it goes through coll?
13:57scriptorso something like (reduce '(+ *) [1 2 3])
13:57scriptorwhich would result in 9
13:58gzmaskfunctors...
13:58hyPiRionscriptor: Can you give another example?
13:58SegFaultAX|work2,(reduce (comp + *) [1 2 3])
13:58clojurebot6
13:59scriptorSegFaultAX|work2: nope, it has to go through the functions one by one
13:59shaungilchristwould it cycle through the functions if the seq had more items?
13:59SegFaultAX|work2scriptor: I'm not even sure what you're asking for.
13:59nDuff...so you want a stateful reducer?
13:59scriptorshaungilchrist: possibly, I was thinking of just passing in something like (cycle [+ *])
13:59scriptornDuff: yes, basically
13:59SegFaultAX|work2I think you want applicative functors.
13:59shaungilchrist(* (+ 1 2) 3) is what he is asking for
14:00hyPiRionoh.
14:00scriptorI figured it would be a allow for an interesting way to do player moves in a game
14:00gzmaskyea, haskell has this as adaptive functors. I am new to clojure so i don't know what this is
14:01scriptor(stateful-reduce (cycle [player1 player2] (board) [move1 move2 move3 …])
14:02scriptorwhere player1 and player2 are functions that take a move and a game board, and return the next game board
14:05scriptorSegFaultAX|work2, gzmask: any links for reading up on them?
14:05scriptorfound the haskewllwiki for applicative functors
14:05gzmasksorry, it should be applicative functors
14:06SegFaultAX|work2scriptor: I don't know if such a thing exists in Clojure. But the applicative style makes this sort of thing quite simple.
14:06zerokarmalefttechnomancy: ping
14:06hyPiRion,(let [(f1 [x y] (if (empty? y) x #(f2 (+ x (first y)) (rest y))))) (f2 [x y] (if (empty? y) x #(f1 (* x (first y)))))] (trampoline x 1 [2 3]))
14:06clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>
14:07hyPiRionoh darnit.
14:07mattmosslolz
14:07mattmossNeed paredit for irc?
14:07mattmossOr irc in your emacs?
14:07hyPiRionWhy doesn't M-x package-list-packages work in irssi?
14:08scriptorshouldn't be hard to enable paredit in erc
14:08SegFaultAX|work2mattmoss: That's actually possible.
14:08ghadishaybananyone used christophe grand's regex library?
14:10mattmossSegFaultAX: What *isn't* possible in emacs?
14:10hyPiRionTHERE
14:10hyPiRion,(letfn [(f1 [x y] (if (empty? y) x #(f2 (+ x (first y)) (rest y)))) (f2 [x y] (if (empty? y) x #(f1 (* x (first y)) (rest y))))] (trampoline f1 1 [2 3]))
14:10clojurebot9
14:10mattmossI mean, when I woke up this morning, emacs was in the kitchen grinding beans and making coffee. Seriously.
14:11pjb3How are people doing environment specific configuration in Clojure apps?
14:11pjb3I'm doing something right now with env var
14:11pjb3and the loading different DB configuration based on that
14:11technomancyzerokarmaleft: hello
14:12pjb3one thing I'd like to do is when I run "lein test" have it default to the test environment
14:12ghadishaybanpjb3: you can slurp from classpath/resources
14:12zerokarmalefttechnomancy: when running `lein repl` standalone, repl-port gets left behind after the server shuts down...should that get cleaned up afterwards?
14:12ghadishayban(-> path slurp read-string)
14:13pjb3ghadishayban: yeah, but I'm trying to figure out how to read the appropriate files so I can connection to a different DB for test and dev
14:13pjb3and CI, prod, etc.
14:14SegFaultAX|work2zerokarmaleft: That is annoying, isn't it?
14:14technomancyzerokarmaleft: I guess so
14:14technomancytarget should always be on gitignore, so no one should ever notice, but it might as well get deleted
14:14amalloyscriptor: that's not hard to write as an ordinary reduce
14:15amalloy&(reduce (fn [acc [f x]] (f acc x)) 0 (map vector (cycle [* +]) [1 2 3]))
14:15lazybot⇒ 6
14:16hyPiRion&(reduce (fn [acc [f x]] (f acc x)) 1 (map vector (cycle [* +]) [1 2 3])) ;?
14:16lazybot⇒ 9
14:17zerokarmaleftif `lein repl` is launched outside of a git repo (e.g. ~/), then it seems reasonable to delete it
14:17amalloy&(reduce (fn [acc [f x]] (f acc x)) 1 (map vector (cycle [+ *]) [2 3])) is probably most like what he actually said, since we have to fake the reduce1 behavior
14:17lazybot⇒ 9
14:17technomancyzerokarmaleft: oh, absolutely
14:18technomancybest to do it in either case; wasn't thinking about outside a project
14:19zerokarmalefttechnomancy: should i file an issue?
14:19technomancysure
14:20hyPiRionI can agree with this
14:20zerokarmaleftok
14:20hyPiRionI just did `find -name repl-port | wc -l` and ended up with 15.
14:20technomancypatch would be great; shouldn't be difficult at all
14:21scriptoramalloy: was there a design reason why reduce doesn't multiple collections in the same way map does?
14:21scriptor*doesn't do
14:21zerokarmalefttechnomancy: i'll take a crack at it
14:21hyPiRionscriptor: the optional argument would be hard to find then.
14:21hyPiRion,(doc reduce)
14:21clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...
14:22scriptorah, good point
14:32pjb3Is there a way to have lein run a function when the repl is loaded?
14:33borkdudelistening to the podcast with cemerick and Raynes now
14:33cemerickborkdude: :-)
14:34cemerickThat's http://mostlylazy.com/2012/08/30/episode-7-anthony-grimes-tools-and-projects-minimum-viable-snippets/ for anyone interested.
14:34shaungilchristamalloy: your solution to scriptors quandry is awesome. so clean! I had a solution twice as long :-(
14:36technomancycemerick: for the record, you have "download the mp3" and "or download the mp3 directly" links that both go to the same place
14:36shaungilchristI think I have correctly used it to make: (defn reduce-cycle [fns a-seq] (reduce (fn [acc [f x]] (f acc x)) (first a-seq) (map vector (cycle fns) a-seq))) so (reduce-cycle [* +] [1 2 3]) works as expected.
14:36cemericktechnomancy: where? I only see one download link
14:38technomancycemerick: http://p.hagelb.org/mostly-lazy.png
14:38cemerickah
14:38cemericktechnomancy: Maybe you don't have flash installed? The first download link might be a fallback for the player that usually goes there.
14:38technomancyyeah, I don't have flash
14:41SegFaultAX|work2Is there a function to make "2" \2?
14:41hyPiRionget
14:41hyPiRion,(get "2" 0)
14:41clojurebot\2
14:42metellus,(char "2")
14:42clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>
14:42cemerickSegFaultAX|work2: just first will do
14:42SegFaultAX|work2Lame. The switching between chars and strings annoys me.
14:42SegFaultAX|work2(Sometimes)
14:42rbxbx,(first "2")
14:42clojurebot\2
14:42Urthwhytesrs are just char vectors aren't they?
14:43rbxbxthat feels somewhat hacky though. Not that the other solutions don't.
14:44hyPiRionWell, you can to .charAt
14:44cemerickUrthwhyte: Clojure Strings are JVM/Java Strings.
14:44erideris there a way to use the repl to lookup methods in java.lang.Integer
14:44hyPiRion,(.charAt "2" 0)
14:44clojurebot\2
14:44Urthwhyteahh, of course
14:44UrthwhyteJust started playing with Clojure a bit yesterday
14:45gfrederickserider: you can use the java reflections API but that can be a bit cumbersome at a repl
14:45cemerickerider: good code completion is a wonderful thing :-)
14:46amalloyerider: (clojure.java.reflect/reflect Integer), i think
14:47amalloybut really, just use javadoc if you're at the repl - reflect is more machine-friendly
14:47eriderok I will try the javadoc then thanks
14:48eriderbut I wanted to be able to use the repl like with (doc)
14:48duck1123,(get "2" 0)
14:48clojurebot\2
14:48cemerick,(->> (clojure.reflect/reflect Integer) :members (filter :return-type) (map :name) sort)
14:48clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.reflect>
14:48cemerickmeh
14:48cemerick,(require 'clojure.reflect)
14:48clojurebotnil
14:48cemerick,(->> (clojure.reflect/reflect Integer) :members (filter :return-type) (map :name) sort)
14:48clojurebot(bitCount byteValue compare compareTo compareTo ...)
14:49cemerickerider: You could put that in a function somewhere if you really wanted to do that regularly.
14:50eridercool thanks
15:05uvtcWhat's a good practice for loading some input data from a my-proj/resources/input-data.clj file within my src/my-proj/core.clj? I'm currently using `(load-file "resources/input-data.clj")`and referring to the symbols in input-data.clj directly, as if they were defined right there in my core.clj...
15:06uvtc... but I'm not sure I like referring to symbols that just appear out of the aether like that. :)
15:06gfredericksuvtc: make the file contain actual top-level data structures rather than deffing
15:07gfredericksand then use read-string or some variant thereof
15:07gfredericksperhaps also with clojure.java.io/resource to find the file
15:07uvtcgfredericks: which file? The input-data.clj file? It already contains top-level data structures: `(def foo 3)`...
15:07gfredericksuvtc: change it to {:foo 3}?
15:08gfredericksthen you can merely read it instead of evalling it
15:09uvtcgfredericks: So, something like `(def stuff (read-string (slurp "resources/input-data.clj")))`?
15:10gfredericksyeah that should work
15:10uvtcgfredericks: thanks.
15:10gfredericksor if you like being silly, (->> "resources/input-data.clj" slurp read-string (def stuff))
15:10gfredericksdo the 1.4 data readers imply that read-eval will be off by default eventually?
15:12thorbjornDXI have an easy question: how do I reload clj source files when in a repl? I've tried require and use, and (source myfunc) shows new code, but seems to run as if nothing changed. I'm getting confused :(
15:13S11001001thorbjornDX: (require blah :reload)
15:13gfredericksthat's weird that source would have updated o_O
15:13S11001001thorbjornDX: doesn't percolate new exports to existing :users though
15:14thorbjornDXS11001001: okay, thanks
15:14clojurebotI'm no man, and she's no lady!
15:14S11001001gfredericks: I think it's based on file/line loc reading, not direct meta
15:14gfredericksah ha
15:14gfredericksI'm sure that's the case now that you mention it
15:33muhoothere has got to be a better way to do this: https://www.refheap.com/paste/4744
15:34amalloy((useful.fn/knit keyword identity) (.split #" = " l))?
15:37muhooamalloy: thanks!
15:37pandeirothat useful lib is pretty cool
15:37pandeiroi started studying it last night
15:40muhooah, juxt would work there too
15:41cemericknDuff: (first (sort …))?
15:41amalloy&(doc max-key)
15:41lazybot⇒ "([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest."
15:42amalloyi suppose you're right that Comparable would be more general, and i'm sure haskell does it that way. i imagine max uses numbers so that it can use jvm primitives
15:45cemerick(max "b" "c" "a") => "a" feels too much like PHP bad juju to me.
15:46lynaghkcemerick: re: your tweet; have you seen https://github.com/edgecase/dieter
15:46cemericklynaghk: oh, I had not!
15:46lynaghkcemerick: I keep wanting some unified thing that will handle HAML+SASS in JVM world, but like you I keep restraining myself
15:47lynaghkcemerick: I've never used it, but it looks like it'd be a good starting point if I ever want to bite the bullet and say goodbye to "bundle exec".
15:47cemericklynaghk: so assume I'm an idiot (hah!), and explain why dieter isn't that?
15:47uvtc,(max "a" \b "c")
15:47clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number>
15:47jowagmuhoo: (update-in (clojure.string/split l #" = ") [0] keyword)
15:47uvtc,(int \b)
15:47clojurebot98
15:47amalloycemerick: meh. that's just guilt by association; max can perfectly reasonably be typed to accept Comparable. in haskell it's max :: (Ord a) => a -> a -> a
15:47muhoojowag: rock star
15:48lynaghkcemerick: oh, it might be. I'm a precompile everything-in-advance kind of guy, and dieter looks like middleware
15:49lynaghkcemerick: before clojure I used quite the elaborate haml+sass+Jammit custom Rakefile getup. Now I just use guard and don't worry so much about asset optimization because almost all of Keming's projects are for our client's internal use
15:50amalloyin java it'd have to be something dreadful like: public static <T extends Comparable<? super T>> T max(Collection<T> coll)
15:50mattmossoh boy that looks fun
15:50muhoobecause i am insane, i'm doing embedded development on a beaglebone with clojure. all looks well except nrepl keeps timing out
15:51cemericklynaghk: I may need to investigate it further. I definitely want something that's live, and something that'll play nice with cljs, too.
15:51cemerickMight need to lower expectations :-P
15:51cemerickmuhoo: Sounds very cool. Does it time out after some period of time, or straight away?
15:51muhooafter a few minutes
15:52cemerickhrm, that's interesting
15:52muhooif i'm doing stuff. remember, it could take a minute for a form to compile
15:52muhoojava 97% CPU
15:52cemerickmuhoo: which client?
15:52muhoonrepl.el
15:53muhooi'm ssh tunnelling. i'll have to try it without ssh, and also sniff the wire and see what's going on.
15:53muhoobut thanks for nrepl! i
15:53lynaghkcemerick: what's with the live-recompile requirement? I mean, things like SASS are handwritten by humans, so they should only have to be compiled once after changes, no?
15:54cemericklynaghk: Yeah, but do I want to switch to the console after twiddling a file?
15:54cemerickI suppose if I can kick off a recompile through the REPL, then that'd be acceptable.
15:56cemerickmuhoo: I don't have any thoughts off the top of my head re: the timeouts. Let me know if you run into anything I can help with.
15:56lynaghkcemerick: yeah. definitely have some autoreload. I just mean it should be in a lein plugin (like lein cljsbuild) rather than in the architecture of the compiler itself (e.g., compiler only works as ring middleware).
15:57cemerickah, sure
15:57cemerickI still haven't started using cljsbuild, so we'll see how that mixes in.
15:58weavejesterIMO things like SASS and Clojurescript would be best dealt with by caching middleware rather than external processes.
15:58cemerickBoth have their place, I think.
15:59cemericke.g. if you're hoping to wrap up a war, then compiling SASS at runtime is a no-go.
15:59weavejesterHm? Why?
16:00cemerickWell, assuming you don't want to make sure you have a ruby stack around, etc.
16:00weavejesterOh, right.
16:00cemerickSASS will probably work with JRuby, but…
16:00weavejesterI'd forgotten SASS was Ruby.
16:00cemericksomeone's got to actually wire that up.
16:01weavejesterLESS and Clojurescript are both Javascript though, and can be compiled with Clojure
16:01lynaghkcemerick, weavejester: I'm biased as a clientside-app guy, but if everything is static (i.e., you can compile in advance) then you can use awesome things like S3 and, um, rsync.
16:01emezeskeweavejester: I run my cljs web app on google app engine, which does not have access to local files, so it's not possible to run the ClojureScript compiler there
16:01emezeskeweavejester: I know other cloud providers have similar restrictions
16:01cemerickThere's also something to be said for having a known-good binary; an oddball environment problem could botch your compilation, etc.
16:02emezeskeweavejester: Plus, I don't want to run a compiler as part of my production server (for dev I think middleware is great)
16:02pandeiroweavejester: are the instructions for better indentation for compojure macros on the wiki current?
16:02weavejesterlynaghk: You could do that anyway, I think.
16:03pandeiroit's not working for me when i include that code in my my-clojure.el which gets called in init.el
16:03cemerickI think both LESS and Sass are unfortunate; I'm mostly being led around by the nose by Foundation.
16:03weavejesterpandeiro: They're what I use in my init.el
16:03lynaghkcemerick: SASS is a lifesaver compared to writing plain CSS. Also you can use things like Compass, which are great as soon as you need to start using vendor prefixes.
16:03pandeiroweavejester: let me move them to init.el and test... do you use clojure-mode btw?
16:03weavejesterpandeiro: Yep
16:04akhudekIn my experience compiling everything before hand is a must.
16:04akhudekDeploying as a war or jar is just too useful to give up.
16:04arohnercemerick: lynaghk: we use dieter. it's immature, but it kinda works for now
16:04cemerickheh "kinda works"
16:04Raynescemerick: We're like legendary and stuff.
16:04pandeiroweavejester: define-clojure-indent is undefined for some reason... any idea what i do?
16:04weavejesterYou can still deploy as a war or a jar if you compile dynamically. Just have the files as resources and cache the compiled results.
16:05RaynesWe should co-host that thing.
16:05weavejesterpandeiro: How did you install clojure-mode? Through marmalade/packages?
16:05RaynesOr not. Mostly not.
16:05cemericklynaghk: The concept is great, but mucking around with js and ruby-based preprocessors really harshes my buzz. :-P
16:05arohneroh, and rhino is incredibly slow, for the JS compilation. we're working on packaging v8 as a jar.
16:05cemerick(Leaving aside syntactic quibbles, etc)
16:05pandeiroweavejester: yep
16:06cemerickRaynes: I thought it came out great :-)
16:06akhudekweavejester: but what do you gain by compiling dynaically?
16:06xeqicemerick: do you keep d/l or listening stats for mostlylazy?
16:06weavejesterpandeiro: Did you (require 'clojure-mode) before (define-clojure-indent …)?
16:06akhudekI understand that watch mode is nice for dev, but I can't see a point for production
16:06pandeiroweavejester: ah i think maybe it only loads clojure-mode conditionally
16:06cemerickxeqi: There's ~500 subscribers last I looked.
16:07weavejesterakhudek: Why have two different systems for dev and production?
16:07lynaghkcemerick: you might find the Gemfile and Guardfile and such in this repo useful: https://github.com/lynaghk/vcf
16:07weavejesterpandeiro: I'll edit the wiki page to include the (require 'clojure-mode)
16:07lynaghkit's pretty standard setup for our projects; SASS+HAML for CSS and HTML, plus guard for auto reload and such.
16:08pandeiroweavejester: cool, i never explicitly require clojure mode. i will do that in my-clojure.el and then add the indent code below it. thanks a lot
16:09XPheriorHowdy folks. I wrote a library for generating test data based on abstract specifications. Hope someone finds it useful :) https://github.com/MichaelDrogalis/zombie
16:09weavejesterpandeiro: My fault really; I forgot I needed to mention that.
16:09weavejesterMy view on precompiling is that if dynamic compiling is good enough for Clojure, it's good enough for everything else ;)
16:10weavejesterIt's also nice to have dev mode as close to production as possible.
16:10borkdudedoes autocomplete already work in lighttable?
16:11ohpauleezweavejester: playing devil's advocate - in one case you're optimizing for developer happiness, in another case your' optimizing for user happiness
16:11ohpauleezre: one for dev one for prod
16:11cemerickweavejester: If Sass, etc. were implemented in a straightforward JVM library, I'd probably agree.
16:11akhudekweavejester: dynamic compiling isn't always good enough for clojure. We have a command line clojure app that we completely AOT compile.
16:12akhudekIronically, the app itself is a compiler.
16:12akhudekAlso, the problem was startup time.
16:12akhudekNot a big deal for web stuff though.
16:12weavejesterohpauleez: User happiness is just speed, right? Which for compiled code means just a good cache. You don't even need to worry about expiring it.
16:13emezeskeweavejester: Hitting a URL in a clojure webapp that requires clojure compilation adds milliseconds to the request time
16:13emezeskeweavejester: Hitting a URL that requires clojurescript compilation could add 30 seconds easily (for advanced mode)
16:13weavejestercemerick: Yeah, I might not do it with Sass, but I might for Clojurescript and LESS
16:13emezeskeweavejester: So you have to worry about sending warmup requests to those servers before they serve users, etc
16:14weavejesteremezeske: Yes, but you can cache, and precompile on the initialization function.
16:14emezeskeweavejester: Right, I'm just pointing out that you are essentially just precompiling your code in prod anyway
16:15emezeskeweavejester: Thereby negating any benefits of having it as a middleware (other than "it's the same as in dev")
16:15weavejesteremezeske: Oh, absolutely. It's the same effect, but it means you don't need separate tools.
16:15weavejesteremezeske: And reload middleware and so forth will work with it.
16:16pandeirohow can i quickly eval a app.repl namespace with utility functions when i begin my SLIME repl?
16:16pandeiro(i don't really want them to be namespaced, i just want them available in user>)
16:16pandeiro...along with basic things like (use 'clojure.repl)
16:16emezeskeweavejester: Sure. I don't think it's a terrible idea, I just want to point out why someone might choose not to do it.
16:17weavejesteremezeske: It's not going to be for everyone, I agree. And it's not going to work with all libraries.
16:17arohnerpandeiro: (in-ns 'user) (use 'foo.bar)
16:18amalloyuse the lein2 :user profile, right?
16:18ohpauleezweavejester: Assuming user happiness is just speed is unrealistic. If your only quality attribute is latency sensitivity, you have it easy. I often find there are tangible requirements for reliability, dependability, availability, maintainability. Removing moving pieces, pushing for static solutions (ie: macro-level immutability) is often an easy way to achieve these things
16:19ohpauleezand allows you to push all things static to a CDN
16:19ohpauleezbuying back the latency guarantees
16:19pandeiroamalloy: haven't used the profiles yet, i will look into that; arohner: thanks, still doesn't load everything, ie (use 'clojure.repl) that is inside 'foo.bar
16:20ohpauleezbut, I'm just playing the advocate here, I've rolled both systems before
16:32pandeirocould anyone point me to an example of using lein2 profiles for auto-loading code into a slime repl session? is that a use-case?
16:38nbeloglazovpandeiro: this is my profile: https://www.refheap.com/paste/4750 I use injections for autoloading
16:49pandeironbeloglazov: awesome, thank you.. where could i have learned about this :injections key??
16:49lazybotpandeiro: Definitely not.
16:50technomancyis anyone using java 7 because they need specific features, or is it more just because it's the latest version?
16:50nbeloglazovpandeiro: from here https://github.com/technomancy/leiningen/blob/master/sample.project.clj
16:59S11001001technomancy: symlinking!
17:01technomancyS11001001: for a production app?
17:05S11001001technomancy: might have been handy for leiningen before local-repo-classpath
17:07amalloytechnomancy: forkjoin, right?
17:08technomancyamalloy: that's been backported though IIRC
17:08amalloysure, there's a jsr for it
17:08amalloyor whatever the verbiage is; a jar that works in jre 6
17:08amalloyalso there must be people using it because they want try-with-resources
17:10xeqiinvoke-dynamic?
17:11S11001001now that I can switch on strings, I don't need jvm alternatives anymore, back to Java
17:12hiredmantechnomancy: the back port just means a roughly comparable java level api, I expect forkjoin on java7 to outperform the backport
17:12nbeloglazovS11001001: did you often need to switch strings before?
17:13S11001001nbeloglazov: </sarcasm> :]
17:13nbeloglazovoh, stupid me :\
17:14S11001001You know how software reviewers sometimes say the UI "feels snappier"? And you don't believe it, and you don't believe they know what they're talking about?
17:14S11001001I've heard that about Java 7.
17:21akhudektechnomancy: I've just recently updated to Java 7 simply because it's the latest version.
17:23ohpauleeztechnomancy: garbage collection improvements and fork/join
17:30SegFaultAX|work2What's the best way to do a "get-keys" function like: (get-keys {:a "foo" :b "bar"} [:b :a]) => ["bar" "foo"]
17:30SegFaultAX|work2But actually, the keys are strings, so juxt won't fit.
17:32jkkramer,(map {:a "foo" :b "bar"} [:b :a])
17:33clojurebot("bar" "foo")
17:33metellus,(map {"a" "foo" "b" "bar"} ["b" "a"])
17:33clojurebot("bar" "foo")
17:34SegFaultAX|work2I forgot maps were functions of their keys.
17:34SegFaultAX|work2Thanks.
17:56hyPiRionman.
18:01coredhello
18:01coredis there an standard way for project organization for a web app in Clojure?
18:03technomancycored: not really
18:06coredwell, I'm battling with a lot of problems with the Rails way of structuring things in the Ruby world
18:06coredmost web apps even when they are not using Rails are structure that way
18:06coredwhich in most cases I don't think is right, was wondering if Clojure was the same
18:07brehautcored: people structure web apps like any other program in clojure; as it demands
18:07hyPiRionSo, can anyone explain to me what's going on here?
18:07hyPiRion&(let [d (let [y (delay 0)] (delay (if (zero? @y) (/ 0 0) (/ 1 1))))] (try @d (finally @d)))
18:07lazybotjava.lang.NullPointerException
18:07hyPiRion&(let [d (let [y (delay 0)] (delay (if (zero? @y) (/ 0 0) (/ 1 @y))))] (try @d (finally @d)))
18:07lazybotjava.lang.ArithmeticException: Divide by zero
18:07technomancycored: it's much less of an issue in clojure since jump-to-definition is so easy to implement
18:07brehautcored: but a common small site might have a model/data ns, a routes ns and an html generation ns
18:07technomancyif you want to know where something is, just point to it and jump; you can follow a codebase that's much more spread out with ease
18:08coredbrehaut: I see
18:08coredtechnomancy: did not get the part of jump-to-definition :-)
18:09technomancycored: I mean most tools support navigating the codebase with ease rather than falling back to grep
18:10technomancywith ruby often answering "where is this defined" is tricky; with clojure it's trivial.
18:12devinushow would you guys do this: https://gist.github.com/3542598
18:14coredtechnomancy: get you now
18:14metellusdevinus: I don't understand what the function is supposed to do
18:14nDuffdevinus: ...so, it's not completely obvious from knowing your inputs and your desired outputs what the relationship between those is. Is this something like a topological sort?
18:14coredtechnomancy: oh, I thought that Clojure was also dynamic and I think that the problem with finding definitions in Ruby is because it's dynamic ature
18:15amalloyhyPiRion: i don't understand the NPE at all
18:15devinusnDuff: i read the wikipedia entry on a topological sort and i don't think it's exactly like that
18:15nDuffdevinus: Generally speaking, an English-language problem description is more useful than a code on.
18:15devinusbut it sounds a lot like that
18:15nDuffs/on/one/
18:16technomancycored: no, it's hard in Ruby because Ruby is dynamic *and* object-oriented *and* supports monkeypatching.
18:16devinusnDuff: basically i have injections i need to sort and i'm prototyping it in clojure
18:16devinusevery injection is a tuple (name, before, after)
18:16technomancyjust using dynamic types doesn't pose any difficulties by itself
18:16brehauttechnomancy: and doesnt require you to declare that you are introducing a name?
18:16technomancythat too
18:17nDuffdevinus: ...that sounds very much like what a topological sort is good for.
18:17coredtechnomancy: but wait a sec, I think I read somewhere that you can do that in Lisp, the monkeypatching that's it and Clojure is a Lisp dialect
18:17devinusnDuff: i need ['a 'b' nil] to come before ['b nil nil]
18:17nDuffdevinus: ...also like something you could use core.logic for.
18:17brainproxysimplest way to decode/encode a string w.r.t. base64?
18:17devinusi'd rather not use core.logic right now :( i can only prototype it in clojure
18:17metellus,(filter identity (sort-by first [['b 'c nil] ['a 'b nil] ['d nil 'c] ['c nil nil] ['e nil 'd]]))
18:17clojurebot([a b nil] [b c nil] [c nil nil] [d nil c] [e nil d])
18:17devinusi then have to implement it in JS
18:17metelluserr, that filter identity is left over from something else
18:18technomancycored: it's technically possible to do monkeypatching-ish things in Clojure, but it's not done in practice because people recognize the fact that it's horribly problematic
18:18metellus,(sort-by first [['b 'c nil] ['a 'b nil] ['d nil 'c] ['c nil nil] ['e nil 'd]])
18:18clojurebot([a b nil] [b c nil] [c nil nil] [d nil c] [e nil d])
18:18devinusmetellus: pretend they dont sort lexigraphically
18:18devinusbecause in reality they dont
18:18coredtechnomancy: got it
18:18devinusa-d was prob bad symbols
18:18devinusto use
18:19devinuslexicographically*
18:19metellushow do they sort?
18:19devinusby my description
18:19devinuseach tuple is (name, before, after)
18:20devinusand a tuple can't have both a before and after
18:20devinusthat's a rule i've already built in
18:22amalloydevinus: so transform to name/after pairs first; having to deal with name and either before or after makes the problem harder
18:25amalloyor perhaps mash it up into a map like '{a #{b c}, d #{e}}. then build a Comparator that looks through that map
18:25amalloyand use that comparator in a call to sort
18:27devinusbut can it be done in one pass?
18:34hyPiRionamalloy: I found an earlier issue about delays aggressively clearing locals, so I'm fairly certain that's the issue.
18:36hyPiRion&(let [d (let [y (delay 0)] (delay (prn y) (if (zero? @y) (/ 0 0) (/ 1 1))))] (try @d (finally @d)))
18:36lazybotjava.lang.NullPointerException
18:47TimMcWell. That was irritating.
18:48TimMcApparently Tor relays are exit nodes by default. Got klined by freenode for the day. >_<
18:50amalloyTimMc: you must have had an unusually productive day
18:51amalloyalso: my non-exit tor node worked great for a month, and now doesn't seem to want to turn back on
19:13TimMcamalloy: It's true, I did!
19:15azkeszCan I have the following without using (force nn) but just nn? (def nn (delay (let [ff (future (do (Thread/sleep 2000) (println "done")) 100)] (do (println "main done") @ff) )))
19:17andersfanyone familiar with net.cgrand.regex? how would i go about matching a union of character sets?
19:23azkeszcan I have a variable that evaluates only when first used? without having to dereference it or use force on it?
19:23andersffound it; net.cgrand.regex.charset/+ if anyone should care..
19:34azkeszok i can only do it with macro but then I have to call it as a function ie. (nn), is there something like lazy variable like lazy-seq?
19:36ohpauleezazkesz: You could just use promises
19:36ohpauleeztypically in clojure, the type of interaction you're looking for comes from deref'ing
19:36azkeszis it possible to see the last element of a lazy sequence, as it is (assuming it's a call to a function) i imagine an infinite lazy sequence which had like 10 elements evaluated and the 11th is the one i want to see like an expand macro sort of thing?
19:37azkeszohpauleez, ok i'll check
19:37dnolenazkesz: you will still need to deref even w/ promises.
19:37amalloysee clojure.tools.symbol-macrolet though
19:38azkeszdnolen, it's ok I guess, I just wanted to know if it's possible to do just nn instead of @nn and have the same effect(delayed evaluation)
19:38amalloy(let [x-delayed (delay (println 1))] (symbol-macrolet [x `@x-delayed] (foo x)))
19:38amalloyor something roughly like that; i don't recall the syntax
19:39azkeszamalloy, where should I look for clojure.tools.symbol-macrolet ?
19:39amalloyer, clojure.tools.macro/symbol-macrolet
19:40xeqican you change lein-cljsbuild to use target/out/ instead of out/ for compiling?
19:40azkeszfound it, https://github.com/clojure/tools.macro/
19:41azkesz,(macroexpand-1 (take 1 (range)))
19:41emezeskexeqi: You can change that with the clojurescript compiler's :output-dir option
19:41clojurebot(0)
19:41emezeskexeqi: It's not specific to lein-cljsbuild, but you can change it with that too: https://github.com/emezeske/lein-cljsbuild/blob/master/sample.project.clj#L101
19:42xeqiemezeske: hmm, I have an out/ and a .lein-cljsbuild-compiler-0/, let me remove them and see which one comes back
19:44xeqiemezeske: I must of done something weird before, now I only have the .lein-cljsbuild-compiler-0/ which is good enough
19:44xeqithanks
19:45emezeskexeqi: Good deal!
19:54azkeszhow can I make 'let' not deref my future here? (def nn (let [ff (future (do (Thread/sleep 2000) (println "done")) 100)] (println "main done") ff))
19:54azkesz,(def nn (let [ff (future (do (Thread/sleep 2000) (println "done")) 100)] (println "main done") ff))
19:54clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
19:54azkesz,(let [ff (future (do (Thread/sleep 2000) (println "done")) 100)] (println "main done") ff)
19:54clojurebot#<SecurityException java.lang.SecurityException: no threads please>
19:57azkeszoops, nvm I'm missing something else,
19:57rlbdenied from the sandbox -- sniff...
19:57amalloyrlb: you can play in the sandbox if you want. but stay away from the sanbox
19:58azkeszI see that even this will cause the future to be executed: (def nn (future (do (Thread/sleep 2000) (println "done")) 100))
19:58azkeszI thought it will only do so when dereferenced, @nn
19:58tomojwould it be possible to set up a binding for one of your own vars in a repl session?
19:58tomojnrepl middleware maybe?
19:59tomoj(doc future)
19:59clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block, unless the variant of deref with timeout is used. See also - realized?."
19:59azkeszok then it's the do
19:59tomojmaybe you want delay?
20:00azkeszwell i misunderstood future, for starters:)
20:01azkeszI thought it was doing the eval on the first deref
20:01azkesztomoj, you're right but then I have to use force
20:01tomoj@ works too
20:02devthanyone know of a lib to execute a fn at specific times (e.g. noon every M-F)?
20:02azkesztomoj, awesome
20:02amalloycron
20:02SegFaultAX|work2Am I wrong for hating that in the stdlib, the parameters to a function go on a new line?
20:02casiondevth: why not use your os's facilities for this task?
20:02tomojazkesz: delay doesn't start a new thread though, unlike future
20:03SegFaultAX|work2(defn foo [a b] looks so much nicer than (defn foo\n[a b] IMHO
20:03devthsure, but is there an existing interface to cron from clj?
20:03azkesztomoj, yes I figured... but at least I know that i misunderstood future:)
20:04devthfound some old clj-sys and cron4j so far
20:05devthit's from within a chatbot, so it's already running 24h/day
20:10azkeszthanks guys: tomoj, amalloy, dnolen, ohpauleez
20:10ohpauleezno problem! I hope you found something that worked for you
20:12SegFaultAX|work2I'm really addicted to 4clojure right now.
20:12SgeoThe reverse state monad relies on laziness
20:14SegFaultAX|work2Sgeo: Is declare lexically scoped?
20:14Sgeo,(doc declare)
20:15clojurebot"([& names]); defs the supplied var names with no bindings, useful for making forward declarations."
20:15SegFaultAX|work2Sgeo: It doesn't say. But if it is could you use it to forward declare your let bindings?
20:16SegFaultAX|work2I'm struggling with how you'd implement letrec.
20:16SegFaultAX|work2,(let [foo #(add1 %) add1 #(+ % 1)] (foo 1))
20:16clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: add1 in this context, compiling:(NO_SOURCE_PATH:0)>
20:17SegFaultAX|work2,(let [foo #(add1 %) add1 #(+ % 1)] (add1 1))
20:17clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: add1 in this context, compiling:(NO_SOURCE_PATH:0)>
20:17amalloy&(doc letfn)
20:17lazybot⇒ "Macro ([fnspecs & body]); fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+) Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body."
20:18SgeoBut they have to be function specs :/
20:18SegFaultAX|work2Is letfn not deprecated?
20:18SgeoMaybe I want recursively defined lazy sequences or delays or something
20:19SegFaultAX|work2Sgeo: Just use mutually recursive functions.
20:23SegFaultAX|work2,(letfn [(foo [n] (lazy-seq (cons n (bar (inc n))))) (bar [n] (lazy-seq (cons n (foo (inc n)))))] (take 10 (foo 1)))
20:23clojurebot(1 2 3 4 5 ...)
20:34erider,([1 2 3 4 5] 3)
20:34clojurebot4
21:00gfredericksdoes cljs support (:require foo :refer [...])?
21:06dnolengfredericks: I don't think it supports that, but it does support the :refer ns directive
21:07tomojI thought :require/:refer was supported
21:07tomojbut it's (:require [foo :refer [...]])
21:14gfredericksI'm having issues with namespaces being written to the output JS file out of order
21:14gfrederickshow would I debug such a thing?
21:17dnolengfredericks: this sounds like a problem others have encountered
21:17gfredericksoh nevermind. I remembered that when I've seen this before it helps to restart lein-cljsbuild
21:17gfredericksand that worked
21:17dnolengfredericks: let me know if that doesn't work
21:18gfredericksdnolen: sorry for the quasi-false alarm
21:30tomojcemerick: is it possible to get extra bindings into the session with an nrepl middleware?
21:33tomojbesides creating a changed copy of the session middleware..
21:34tomojoh, I think I see how
21:39cemericktomoj: You mean default set!-able vars?
21:40tomojno, project-specific set!-able vars
21:41cemerickNothing comes to mind immediately. Same "problem" exists with all REPLs: only vars with a dynamic binding can be set!'d.
21:42cemericktomoj: can you describe your use case?
21:43cemerickoh, with a middleware!
21:43cemerickYeah, that's easy :-)
21:44tomojwriting a library involving learning experiments. most functions (currently, at least) take a first arg which has experiment hyperparameters and state
21:44cemericktomoj: sorry, I didn't read your first message closely enough, I guess.
21:44tomojif I don't change that I'd probably let them optionally get the experiment from a dynamic binding
21:45tomojbut in-experiment would be more convenient at the repl than with-experiment
21:46cemericktomoj: I didn't really grok that. :-)
21:48akhudektomoj: could you use a -> like method to implement with-experiment?
21:48cemerickAnyway, a middleware that :depends on the "clone" op (so it'll be "below" the session middleware) that makes sure that any message going by has bindings in its :session for the vars you care about will work.
21:48cemerickBut, my sense is that REPL middleware is the wrong level at which to tackle this.
21:50cjfriszGood night...does vimclojure-easy install vim-minibufexpl?
21:50cjfriszAnd why is it such a horrid plugin?
21:50cjfriszCompletely interrupts a reasonable workflow
21:52tomojcemerick: the use cases are those where you have a dynamic var in your project that you want bound to one value for relatively long periods of time in the repl
21:53tomojso like we have in-ns at the repl and don't have to wrap every line in (with-ns ...)
21:54tomojwhether I should have a dynamic var for this actual use case in my project, I don't know
21:56cemericktomoj: right, that's where I was about to go. alter-var-root or just an atom is easier, and probably just as effective.
21:57cemerickNo other REPL (AFAIK) currently allows for additional set!-able vars; that you *could* make it happen with nREPL maybe isn't a good enough reason to do so, though.
21:58cemerickit certainly seems like something that could cause some degree of trouble; e.g. REPL interactions that you'd expect to work would not within a REPL environment that didn't have the middleware, etc.
21:59tomojyeah, I didn't think about other people seeing the function that set!'s and not realizing some extra middleware is required
22:05tomojI don't think I even need an atom or alter-var-root
22:08amalloy(inc emacs)
22:08lazybot⇒ 1
22:08cjfrisz~emacs
22:08clojurebotemacs is an out-moded belief system
22:09cjfriszI think clojurebot must be broke
22:10casionit'd be awesome if there was some sort of modal alternative to emacs
22:10casionwith it's own scripting language as well
22:11gfredericksmy vimmy coworker has become totally sold on evil-mode over the last week
22:11hoover_dammnice!
22:11cjfriszI was trying to work on my vim chops by doing some of my Clojure stuff in it
22:11cjfriszI found the whole experience very...unpleasant
22:12casionwhen I first tried clojure, I tried in vim… despite being an emacs user
22:12cjfriszSome goofy minibuffer explorer plugin got installed somehow (hell if I installed anything vim-related) and made saving and closing buffers really awful
22:12casionneedless to say, I gave up and didnt think about clojure for a year after
22:12cjfriszcasion: That makes me sad
22:13gfrederickscasion: that sounds a bit like "I installed windows so I could try out grep"
22:13cjfriszcasion: stock vim is *reaaly* *bad* at Lisp
22:13KhaozHi. I'm learning clojure through some online beginners tutorials, but i want to buy a book to complement my studies. I'm between Programming Clojure and Cojure Programming.
22:13casionKhaoz: do you know any other languages
22:14uvtc10 minutes of Vim and I'm accidentally putting ":wq" all over the place for the rest of the day.
22:14casioncjfrisz: yep. I use vim sometimes without issue… for C, and that's about it
22:14cjfriszI cut my teeth on emacs, but I can certainly appreciate how compact the controls are
22:14cjfriszAnd how lightweight it is
22:14Khaozcasion: i have some skills with java (i need java on my soa day job :) ) and also some knowledge on python and perl
22:14casionI've been using emacs for a good while, and never touched lisp until clojure
22:15cjfriszBut I spend 95%+ of my time writing lisp variants
22:15casionKhaoz: get clojure programming then IMO
22:16casionit has some examples in python, and assumes more java knowledge than programming clojure I think, which gets you going a bit faster
22:16casionthat's assuming you have the prerequisite knowledge to work with it
22:16KhaozI think that i have
22:17Khaozi'm a programmer since 99
22:17casionKhaoz: and the author(s) here right now
22:17casionso you could always just ask directly
22:20Khaozcasion: thank you very much
22:20casionsure, they're both awesome books
22:20Khaozmy kindle have a new book on in :)
22:20casionyeah, I have both on my dx (and paper)
22:20casionit's pretty fantastic
22:20Khaozmy main problem are with expressions like ^{:a 1 :b 2} [1 2 3]
22:21casionif you have a smaller kindle, programming clojure doesnt display very well
22:21casionerrr
22:21casionclojure programming doesnt.
22:21Khaozi want to compare this kind of thing with other languages
22:21casionprogramming clojure looks good on the small kindle
22:21Khaozbut well, i will finish the beginning guides. Probably i will get a better picture about everything
22:24Khaozand about my kindle, it's a 6", so it's small.
22:24tmciverKhaoz: it's not the size that matters, it's how you use it. ;)
22:25Khaozcasion: but thank you again. Probably i will get both.
22:25casiongreat idea :)
22:25Khaoztmciver: hahahahahhahahaha
22:25casionfwiw though, reading clojure programming on the 6" kindle is nearly impossible
22:25casionthere's times where you'll end up with 3-4 consecutive pages with code cut across a page
22:26casionI had to reformat it with calibre
22:26uvtcThere's a neat bit of styling for Scheme code blocks in html that I've seen on the Chicken wiki: http://wiki.call-cc.org/man/4/faq#how-can-i-add-compiled-user-passes . Hover the mouse over the parens in the code example.
22:28uvtcAuto-electric paren matching? Need to look into how that's done. Would be neat to have that for Clojure snippets.
22:29brehautuvtc: i had a look at trying to get something like that working with the JS SyntaxHighlighter package
22:29brehautbut it was going to require too much mucking about in the plumbing
22:29uvtcAh.
22:29uvtcWould be very cool, IMO.
22:30brehautive seen a slightly nicer version which just highlights the characters that are in the expression under the cursor, rahter than coloring the brackets
22:30uvtcOooh. :)
22:30uvtcCan you remember/find the link?
22:31casionthat'd be nice to have emacs
22:31brehautit was over a year ago sorry
22:31clojurebotshut up |is| <reply>My new year's resolution is to remember that not every message with "is" in it is addressed to me.
22:31KhaozIt's a little bit late here in Brazil, so i'm going to sleep. Thank you guys. Hope to be able to code in clojure and contribute with something soon :)
22:31brehauti think with a bit of dedication you could do just the brackets in the JS lib, it'd be a bit wonky though
22:31casiongood luck Khaoz
22:31cjfriszAnybody else wish that nREPL in emacs would do stack traces the same way as Swank?
22:31cjfriszI find it just unpleasant enough that I've kept on using Swank
22:32casioncjfrisz: yes! god damnit yes
22:32casionI switched to nrepl.el and that is alraedy annoying me
22:33cjfriszI really want to like nrepl
22:33cjfriszAnd I'm pretty sure that's the one thing holding me back
22:33casionI became quite used to it in swank-clojure, I automatically jump my hands to 1234567890 when do anything
22:33casionwhen I do*
22:34cjfriszIf I remember correctly, the other aspects of it are very pleasant
22:34casionI'm going to try ritz tomorrow
22:34cjfriszcasion: I'm not familiar
22:34amalloycasion: emacs already has that
22:34casioncjfrisz: https://github.com/pallet/ritz
22:34casionamalloy: has what?
22:35amalloythe paren highlighting, i mean
22:35casionamalloy: I meant the highlight coed in current statement
22:35casionI know about rainbow delimiters and such
22:35amalloyobviously
22:35amalloyM-x show-paren-mode
22:35casionthat exists? hum
22:36amalloyand M-x customize-face show-paren-match face
22:36amalloyplus, some kind of var to toggle whether it lights just parens or the whole xpr
22:36amalloypersonally either would drive me crazy
22:37casionhum
22:37casionthat is neat… and far more distracting thatn I expected
22:37casionthan you
22:37casionthank*
22:37casionmaybe useful for browsing code, but I don't think I could live with that when writing
23:02cjfriszIs it weird that 'def' returns the value of its init argument, or is does it just seems weird because it's different from Scheme?
23:05cemerickcjfrisz: def returns the var it is defining
23:05cemerickThough you shouldn't be caring about return values of vars in general anyway.
23:05cemericks/of vars/from def
23:05cjfriszcemerick: Good point
23:06cjfriszcemerick: I only care in that I'm writing a source-to-source compiler and trying to preserve semantics
23:08cjfriszcemerick: I'm just kind of used to things like 'def' returning void
23:10dnolenfinally one of the absolutely most annoying bugs in CLJS resolved - http://dev.clojure.org/jira/browse/CLJS-180
23:10cjfriszA wild dnolen appears!
23:17tomojhooray
23:17tomojthanks
23:36cemerickIt seems that web apps are still often built with static resources baked into each project, instead of bundled up into dependencies. Any rationale for this, since serving classpath resources is so damn easy with ring?
23:37brehautcemerick: so that you can push them out to a more lightweight webserver?
23:37brehaut(such as an nginx gateway)
23:38cemerickSure, but you can pull assets from the classpath like nothing.
23:38cemerickWhy not take advantage of versioned dependencies?
23:38brehautperhaps i did not understand the question
23:39cemerickCommon practice is to download e.g. jquery vX.Y.Z, drop it into /resources/public, and serve away.
23:40cemerickRather than put that rev of jquery (or whatever) into a jar deployed with the right version number to e.g. an s3 maven/lein repo.
23:40cemerickSo N projects have N copies of jquery, etc. All the same downsides of putting jars into git apply AFAICT.
23:41brehautright
23:41wmealing_so, oracle released the java patch
23:41wmealing_http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
23:41cemerickFor example, I started using foundation; so, I get my build of it, drop it into /resources/asset-deps/ of a new project, stamp it with v3.0.9-1 (the -1 so I can version my custom builds of the framework), and deploy to my s3p repo.
23:42wmealing_known about it for 4 months.. now only releases
23:42cemerickThen I just add a route to my app: (route/resources "/" {:root "asset-deps"})
23:42Frozenlo`After zyzanie https://github.com/Frozenlock/zizanie, here comes siren! https://github.com/Frozenlock/siren !!
23:42cemerickAnd any other static assets I have on my classpath under that asset-deps prefix get served automagically, and bumping the rev is easy as a project.clj edit.
23:43Frozenlo`I'm starting to like cljs :D
23:43dnolenFrozenlock: glad to hear it
23:43Frozenlockdnolen: I could not have done without your help, of course :P
23:44Frozenlock*it
23:44xeqi1) it's easier to drop in the file then jar it; 2) seting up a server to serve static files without hitting the whole web stack is easier than something like varnish
23:45brehautcemerick: well, i know that nginx serving static files is bloody fast, vs forwarding the request to my jvm http server to then run through ring, resources handling, and back out
23:46brehautcemerick: i do horrible dropping built JS blobs into git because its easy, even though its horrible
23:47brehautcemerick: but surely you could easily make a lein build process that produes static resources based on project.clj deps and puts them outside of the jvm server
23:47cemerickbrehaut: quite, yes
23:48cemerickxeqi: "it's easier to drop the jar file in git than to put it in a repo" :-)
23:48xeqinever said they were good reasons
23:48cemerickheh
23:48cemerickfair enough
23:49cemerickEven if/when I have a site that needs a CDN, etc., I sure don't want to have a separate deployment process for assets. Let the proxy/CDN come to you for the files.
23:50devn'lo
23:51brehautcemerick: that does make sense
23:52brehautcemerick: whats stopped me is the 101 shitty tools for building various resources that arent hosted in the JVM
23:54cemerickfair point
23:54cemerickback to the WTF Sass et al. thread :-P
23:54brehauti guess it depends how sharp your yak razor is ;)
23:54brehautha yes
23:55cemerickah, ok
23:56brehautsass and less are both just better kinds of horrible unfortunately
23:56cemerickbrehaut: so if you're using Sass and such, you're probably trying to gather *everything* up into the "top level" of your app in terms of assets, so that js and css minifiers can create a minimum of prepared files.
23:56brehautright
23:57cemericki.e. the more modular asset dependencies are, the harder it is to get everything into place for the command-line-based toolchains
23:59cemerickhah, right, so e.g. Foundation vendors jquery and modernizr into its repo, so if you were rolling it into your Sass compilation, you wouldn't have separate deps for those libraries anyway
23:59brehautha
23:59brehaut(inc modernizr)
23:59lazybot⇒ 1