#clojure logs

2013-02-11

00:03tomojwow
00:03tomojI assumed you had some crazy error while committing, your test is nuts
00:05noncomno, still, i don't get it.
00:05noncom)
00:06ivanis this one of those bugs where you write over the file before reading the entire file?
00:07noncomwhat i don't get in particular - is how it is first said that refs track a single location (contrasting them with vars) and then it is said that refs track multiple locations and agents - don't
00:07technomancya ref tracks a location
00:08technomancymultiple refs track multiple locations at the same time
00:08technomancymultiple agents track multiple locations independently
00:08technomancy"coordinated, synchronous change" <- what dosync is
00:09clj_newb_234anyone here also use scala? I'm trying to see if there is a way to take advantage of (1) clojure's persistent data structures + (2) clojure's macros, and yet (3) scala's type system
00:10noncomi use scala
00:10technomancyclj_newb_234: using clojure macros from scala doesn't make sense
00:10technomancydata structures would though: https://github.com/codahale/yoink
00:11noncomwhat kind of profit are you expecting from using them this way?
00:12noncomi think that scala is still too restrictive with it's syntax and some simple things require a lot of boilerplate. i think that's where clojure can be well used to reduce the amount of code.
00:13noncomtechnomancy - the statements about multiple refs and multiple agents do not seem mutually exclusive. i still can't see the difference.
00:14noncomi'm sorry)
00:14technomancynoncom: the difference is dosync works on refs only
00:14noncomoh!
00:15noncomnow i see)
00:15noncomagent's can't be synchronized with dosync and act independently in time..
00:15technomancyright-o
00:16noncomthank you! i think that the official docs need to be more explicit on this..
00:17technomancythe official docs could use a lot of things; more clarity not being on the list
02:24nonubyis this idiomatic, is there a simpler way https://www.refheap.com/paste/11165
02:37cmdrdatsnonuby: you could: (reduce min (flatten (map :rates sample_data)))
02:39metellus~flatten
02:39clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
02:40cmdrdatsye, i was about to say - you could probably use apply concat
02:40metellusor mapcat
02:41cmdrdats(reduce min (mapcat :rates sample_data))
02:41cmdrdatsnice - I didn't know about mapcat :) that's very handy
02:41josteinkcompletely offtopic: is it just me going crazy or has chrome lately started NOT autocompleting adresses in the "awesome bar"?
02:42metelluscmdrdats: I only know about it from people doing ~flatten in here
02:42metellusjosteink: not for me.. did you clear your history recently?
02:42josteinkmetellus: what I mean is I may start typing "cale"
02:42cmdrdatsmetellus: a useful learning experience - now I know too :D
02:43josteinkmetellus: but instead of completing, in the bar, to calendar.google.com, it's just one of 200 items in a list which I need to select
02:43clojurebotlist* doesn't actually make a `list?`
02:43josteinkmetellus: it USED to complete in the bar, so I just needed to type "cale<enter>"
02:44metellusno idea, sorry
02:47josteinkhm
03:12nonubycmdrdatas, wouldnt (apply min (mapcat :rates sample_data)) be better? reduce will call min n times?
03:43WokenFurydoes clojure have a wrapper around java's ReentrantLock? I need a lock where one thread will do work and other threads can check the lock status and cancel their work instead of blocking/retrying
07:48pjstadigWokenFury: no wrapper, but you should be able to use ReentrantLock in that way
07:48WokenFurypjstadig: yep, implemented already. works well
07:49pjstadighehe
07:49pjstadigyeah sorry, i guess you asked like 4hr ago :)
07:51WokenFury:)
09:38jsabeaudrySomehow my uberjar does not work this morning, even old versions in git, all of a sudden it cannot find my main class
09:41jsabeaudryim very scared about the implications of this
09:53Blazeixhi, i need to run a function on certain values in a map. i have this implementation: https://www.refheap.com/paste/11168
09:53Blazeixi'm pretty new to clojure, is that a idiomatic way to do it?
09:54Blazeixthe idea is you'd call it like (map-selected-values mymap #(Integer/parseInt %) :key1 :key2)
09:58BronsaBlazeix: (defn map-selected-vals [m f & ks] (into {} (for [k ks] (update-in m [k] f))))
09:58hyPiRionBronsa: what
09:58Bronsamhm, no wait
09:59Bronsa (defn map-selected-vals [m f & ks] (into {} (reduce #(update-in %1 [%2] f) m ks)))
09:59Bronsathis
09:59ljos(reduce #(update-in m [%] f) ks)
09:59hyPiRionYou don't need the {}
09:59ljosno need for {}
10:00ljosoh.. a small mistake (reduce #(update-in %1 [%2]) m ks)
10:01Blazeixoh, cool. let me digest that a little bit
10:02aroemersForgot the function f: (reduce #(update-in %1 [%2] f) m ks)
10:02Blazeixright
10:02ljosoh yeah. that last one is correct.
10:02ljosalways something.
10:02aroemersheh
10:17Blazeixok, i understand it now, thanks everyone
10:17Blazeixa common thread in my clojure learning is that i need to better grok reduce
10:22pbuckley,(clojure.string/replace (str "{\"top-key\":{\"first-key\":\"" "first-val" "\",\"second-key\":\"" "second-val" "\"}}") #"\\" "")
10:22clojurebot"{\"top-key\":{\"first-key\":\"first-val\",\"second-key\":\"second-val\"}}"
10:22pbuckley,(clojure.string/replace (str "{\"top-key\":{\"first-key\":\"" "first-val" "\",\"second-key\":\"" "second-val" "\"}}") "\\" "")
10:22clojurebot"{\"top-key\":{\"first-key\":\"first-val\",\"second-key\":\"second-val\"}}"
10:23pbuckleyanyone know how to replace a backslash in a string using clojure?
10:23pbuckleyor, alternately, use double quotes in a string without backslash-escaping them?
10:24joegalloi think you're being confused by the printed behavior
10:25joegallo,"\""
10:25clojurebot"\""
10:25pbuckleyah, so when I print it out, it escapes it
10:25joegallo(.indexOf "\"" \\)
10:25joegallo,(.indexOf "\"" \\)
10:25clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: indexOf for class java.lang.String>
10:25joegallo,(.indexOf "\"" (str \\))
10:25clojurebot-1
10:25pbuckleybut it isn't really escaped when I use it unprinted
10:25joegallothere isn't a backslash in the string "\"" there's a single character, a double-quot.
10:25joegallodouble-quote.
10:26pbuckleyok cool, thanks joegallo
10:26alexnixoncan anyone confirm exactly why the implementation of 'drop' ( https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2568-L2578 ) pulls out the "step" function into a let binding? I suspect it's to avoid unnecessarily nesting a bunch of lazy-seq calls, but I'm unsure if there are locals-clearing/head retention issues being worked around too.
10:28DerGuteMoritzalexnixon: to avoid retention of the head I think, yep
10:31DerGuteMoritzthough I think this could be achieved with (loop ...) as well
10:35DerGuteMoritzah no, forget that last statement :-)
10:36DerGuteMoritzor actually
10:37clgvalexnixon: to have it private, I think. there is no other effect there
10:38alexnixonclgv: I mean why is the step function pulled out *at all*. You could write 'drop' with it in-line.
10:38clgvalexnixon: the author may have thought that it's better readable
10:38DerGuteMoritzyou need a recursion target
10:38DerGuteMoritza tail recursion target
10:39alexnixonDerGuteMoritz: a fn definition is a recur target
10:39DerGuteMoritzand yeah ((fn [n coll] ...)) would also work but is not as nice
10:39gfrederi1ksbut you can't do it from within a lazy-seq
10:39DerGuteMoritzyep I mean that's the reason for having the fn at all
10:39DerGuteMoritzbut loop would work, too here... and then you could even do it inline
10:40gfredericksdrop is defined before loop apparently, but that's not too meaningful
10:41DerGuteMoritzhmm looking at take-last below it looks like it retains the head of coll
10:41pbuckleyjoegallo it seems that printing behavior also pollutes when I try to exec the string
10:42DerGuteMoritzat least while the loop is executing
10:43joegallohow are you trying to exec the string? maybe you should be pr-str'ing it before hand or something like that.
10:44pbuckleyI'm trying to exec like this: (. (Runtime/getRuntime) exec curl-command)
10:45joegalloright... but where did curl-command come from?
10:46alexnixonDerGuteMoritz: I don't think the head is being retained there as 's' will be cleared on each recur
10:46pbuckley(str "curl -H 'Accept: application/vnd.example.v1' -H 'Content-type: application/json' -X POST -d '" "{\"top-key\":{\"first-key\":\"" "first-val" "\",\"second-key\":\"" "second-val" "\"}}" "' " my-url)
10:47pbuckleyso you're saying it should be a pr-str instead of str?
10:47joegallonot necessarily
10:48pbuckleyexec doesn't seem to like pr-str
10:48pbuckleyI was trying to just quickly test something calling out to the system command using curl, but it looks like it's just too tricky with the backslashes involved
10:49pbuckleyI can use clj-http, which I probably should have done in the first place
10:50bordatoueHello, is there a cons equivalent in clojure similar to lisp
10:51joegallopbuckley: (slurp (.getInputStream (. (Runtime/getRuntime) exec "echo \"foo\""))) works fine for me.
10:54sh10151https://github.com/Chouser/clojure-jna is very old, is there some better way to do simple JNA calls in Clojure?
10:55pbuckleyjoegallo: well, by some definitions of "works" - your backslash is still in the command that is exec'd
10:56joegallono, no it isn't.
10:56pbuckleysince I'm trying to pass json parameters to a rails app, it chokes on the backslashes and doesn't recognize the json as json
10:56pbuckleywhen I run the same command from the shell without backslashes, it is fine
10:57joegalloyou are in java string
10:57joegallostrings
10:57dakronepbuckley: you'll have much more luck doing it with clj-http rather than shelling out to curl
10:57joegalloif i want to run `echo "foo"` at the command line, i need to represent that in a java string as "echo \"foo\""
10:57pbuckleyyeah, shelling out to curl is a dead end I've been chasing down for too long
10:58pbuckleyjoegallo: you may be correct, but I'm not seeing it, and I don't think it's worth the time trying to figure out
10:58pbuckleylesson learned, don't try using backslashes in strings and clojure
10:58joegalloOMG
10:59llasram...
10:59danielglauserbordatoue: There are two, cons and conj. http://clojuredocs.org/clojure_core/clojure.core/conj http://clojuredocs.org/clojure_core/clojure.core/cons
10:59DerGuteMoritzalexnixon: s will, but coll won't
10:59DerGuteMoritzalexnixon: only an issue if you pass in a seq already, of course
11:00alexnixonDerGuteMoritz: so is this naive implementation bad?: https://www.refheap.com/paste/11171
11:01clgvalexnixon: it is slow
11:02clgvalexnixon: and allocates more lazy-seq objects
11:02alexnixonclgv: I understand the allocation issue - is that the only downside?
11:03clgvalexnixon: well, what is its advantage?
11:05alexnixonclgv: I'm not contesting the current implementation, just trying to to understand why it is so. If there are reasons beyond extra allocations then that's interesting.
11:06clgvalexnixon: well, it is faster just to discard the top n elements and then return the rest
11:06DerGuteMoritzit's not fully lazy in fact then
11:06alexnixonclgv: yep, makes sense.
11:07DerGuteMoritzbut due to chunking you can't rely on full laziness anyway
11:07clgvDerGuteMoritz: it is fully lazy^^
11:07alexnixonDerGuteMoritz: it is lazy - 'step' isn't called unless you realize the first item in the returned seq
11:07clgvoh right, not when chunking ;)
11:08DerGuteMoritzalexnixon: yeah but then it realizes the dropping in full
11:09DerGuteMoritzah wait :-)
11:09pbuckleydakrone: thanks, clj-http works great
11:09DerGuteMoritzyeah alright, you can't drop more lazily, of course
11:09alexnixon:-)
11:11clgv;)
11:11bordatouedanielglauser: I am looking for a lisp equivalent of cons such that cons of two number would give me a pair both the cons you have mentioned requires some col
11:12DerGuteMoritzbordatoue: Clojure doesn't have pairs
11:13DerGuteMoritzbordatoue: you can use (vector 1 2) or [1 2] instead
11:13bordatoueDerGuteMoritz: does it have somethign i can invoke car and cdr
11:13DerGuteMoritzbordatoue: no, it doesn't have car and cdr either
11:13danielglauserbordatoue: Ah. Thinking back to my Scheme days (15+ yrs ago) I believe cons would give you a pair. Folks typically just use a vector in Clojure.
11:14danielglauser,(first [1 2])
11:14clojurebot1
11:14bordatouethanks DerGuteMoritz & danielglauser
11:14DerGuteMoritzyw
11:15danielglauser,(rest [1 2])
11:15clojurebot(2)
11:15Bronsa;(second [1 2])
11:15Bronsa,(second [1 2])
11:15clojurebot2
11:16llasram&(fnext [1 2]) ;; for completeness
11:16lazybot⇒ 2
11:16frozenlockOne can add metadata in an atom--> (atom a 10 :meta {:some-key some-value}), but how can you change it with reset! ?
11:18llasramfrozenlock: I don't believe you can
11:18frozenlockOh...
11:19frozenlockMy first reflex in this case would be to use `def' inside a function instead of an atom, but I'm pretty sure the clojure's gnome will burn me for this. Suggestions?
11:19frozenlocks/gnome/gnomes
11:19Bronsa,(alter-meta! (atom 10 :meta {:foo 1}) update-in [:foo] inc)
11:19clojurebot{:foo 2}
11:20frozenlockBronsa: And this solves everything. Thank you :)
11:21llasramCool. I didn't realize metadata on reference types other than vars worked that way. Makes sense though
11:21llasram(inc Bronsa)
11:21lazybot⇒ 3
11:22llasramfrozenlock: OOC, what are you doing with updating metadata on an atom?
11:23frozenlockllasram: I have a java objects that needs to be recreated once in a while. I store the configs in the meta data in order to be able to retrieve them and recreate it with the same configs. Although now that I think about it, I could simply use a second atom.
11:25frozenlockI don't know why I keep doing crazy stuff when the solution is so simple.
11:33sh10151anyone use lein-daemon? I'm getting null pointer exceptions from it, and I can't tell why -- I'm sure it's something silly
11:34sh10151at leiningen.daemon_starter$daemon_starter.doInvoke(daemon_starter.clj:13)
11:34sh10151looking at the code i think it's something in my :daemon param in project.clj? can't really tell...
11:39sh10151arohner: oh hi, I was just thinking about you.
11:39bordatoueis there any way to identify a function
11:39sh10151arohner: I think I must be doing something silly with lein-daemon
11:39bordatoueis there a function type
11:40sh10151arohner: Most basic setup I can think of has a null pointer exception sometime after "waiting for pid file to appear" -- at leiningen.daemon_starter$daemon_starter.doInvoke(daemon_starter.clj:13)
11:41jkkramerbordatoue: ##(fn? map)
11:41lazybot⇒ true
11:41bordatoueokay, how do i identify a function and a macro programically
11:42bordatoue##(fn? (defmacro something [] nil))
11:42lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
11:43rplacabordatoue: look at the metadata on the function and you'll see {:macro true}, iirc
11:44jkkramer,(:macro (meta #'for))
11:44clojurebottrue
11:44bordatouewhat is the point of having fn? if i accidently pass in a macro
11:44rplacabordatoue: a macro *is* a function
11:44rplacathat takes code in and produces different code out
11:45jkkramerand you can't normally pass around macros
11:45jkkramer,(fn? for)
11:45clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/for, compiling:(NO_SOURCE_PATH:0)>
11:45bordatouerplaca: but fn? doesn't report it as a fn
11:45gfredericks,(fn? @#'for)
11:45clojurebottrue
11:46bordatoueokay, my error
11:46calisWhat Emacs setup are clojure hipsters using nowadays? Starter kit, prelude, Emacs Live... ?
11:47bordatouegfredericks: why do we need sharp quote for macros not functions when passing to fn?
11:48gfredericksbordatoue: @#' is a hack for getting the function underlying a macro
11:48gfredericksnot normally useful
11:49llasram&`@#'for
11:49lazybot⇒ (clojure.core/deref (var clojure.core/for))
11:49gfredericks,(reduce @#'or [false true false])
11:49clojurebotnil
11:49edmund_woah... wash your mouth out dude.
11:49llasram^^ Er, if that helps
11:49llasramheh
11:50HolyJakcalis: A question I'd also like answered. I guess every true Emacs geek uses his/her own setup. I, as a newbie, use Prelude and am planning on trying https://github.com/overtone/emacs-live once I get Emacs 24.3
11:51HolyJakOne Emacs & Clojure hipster's setup is here: https://github.com/bodil/emacs.d
11:51HolyJakI guess you could also find Rich Hickey's emacs setup somewhere
11:52edmund_HolyJak: i'm a huge emacs live fan
11:53technomancycalis: I recommend starting your own and stealing liberally from the popular setups
11:53technomancyif you add things one-by-one you'll have a better understanding of where various pieces come from
11:53llasram(inc technomancy)
11:54lazybot⇒ 46
11:54technomancy80-90% of the good stuff is available in independent packages anyway
11:54pimeysI'm still having this test of replacing vim with emacs+evil here at work
11:55pimeysbut somehow it still doesn't work like I want it to work
11:55pimeysand some modes somehow dismiss the evil mode completely :P
11:55technomancythe thing about something as invasive as evil is that it doesn't compose well
11:55pimeysyep
11:56pimeysthe thing would be to learn to use emacs without evil
11:56pimeysand then I start to wonder what's the profit
11:56pimeysI really like emacs, how it uses elisp for plugins etc.
11:56TimMc&(@#'for nil nil `[a (range)] `[a (inc a)])
11:56lazybot⇒ (clojure.core/let [iter__4468__auto__ (clojure.core/fn iter__15780 [s__15781] (clojure.core/lazy-seq (clojure.core/loop [s__15781 s__15781] (clojure.core/when-let [s__15781 (clojure.core/seq s__15781)] (if (clojure.core/chunked-seq? s__15781) (clojure.core/let ... https://www.refheap.com/paste/11174
11:56pimeysbut the editor itself doesn't work for me, I need the command mode to be fast
11:57technomancywell I haven't used vim, but from what I've heard most of the benefits of text objects you get for free in lisps with paredit anway
11:57pimeysif I started learning an editor now, it would be emacs
11:57pimeysbut 15 years of vim history is not something you can change
11:58llasramInduced amnesia
11:58pimeysand there's still lots of things I love in vim, although for clojure emacs seems to be better
11:58pimeysfor slime etc.
11:59pimeysand with ruby, vim just rocks
11:59hashbang1pimeys: you can bring some of that functionality into vim with tpope's foreplay, and are a number of slime-ish plugins for vim with screen or tmux
11:59pimeysI've tested those, the problem is vim itself
12:00pimeysmaybe just using an external REPL
12:00arkxEvil worked well for me. evil-paredit makes it work better with paredit as well, so you can gradually move to that.
12:00arkxnrepl.el rather than slime for me, though.
12:01pimeysand for every plugin I install I need to figure out the good command mode configuration
12:01pimeysby default they have bindings with C or M
12:01pimeysarkx: btw, long time no see :)
12:01arkxWe talked here just last week :P
12:01arkxSame topic even.
12:02pimeysbut in real life I haven't seen you since TKK
12:02pimeysfreshman year
12:02arkxBut yeah, glad to see you've found Clojure as well
12:02pimeysstill in reaktor?
12:02arkxYup.
12:02arkxCoding Clojure at work currently. :)
12:02pimeysnice
12:03pimeysit's very easy language actually, after Ruby
12:03pimeysbut still using Ruby for work
12:03pimeysmaybe I'll start doing evaluators with clojure and do real work with other languages :D
12:03iwohey, does anyone know why, often when i use nrepl, i get suddenly kicked into nrepl-error buffer and i can't focus any other window?
12:03iwoi'm using emacs live
12:04iwoit seems like sudden nrepl gets into an error state and i can't continue because the nrepl-error window is forever stealing focus
12:04iwoeven though nrepl-error is blank, and i haven't even executed anything
12:04mathmonkeyHi
12:04technomancyiwo: does emacs-live bring in nrepl-autocomplete?
12:04iwoi start typing into the nrepl prompt and suddenly it breaks
12:05technomancyI've heard of that package causing problems like that
12:05iwotechnomancy: i'm pretty sure it does, yes
12:05hashbang1pimeys: i'm in a similar boat so i'm interested in potentially making the leap to emacs. I have a lot of time invested in vim, and evil-mode has been disappointing. I'm thinking I might just want to start from scratch and learn the default emacs keybindings instead.
12:05technomancyiwo: thanks for bringing up a great example of why it's better to add in packages by yourself so you can have a better understanding of how to debug them when problems arise. =)
12:06iwoalso, has anyone else experienced strange formatting in nrepl in emacs? like you execute a function and see loads of whitespace, as if many newline chars have been printed?
12:06pimeyshashbang1: I'm just afraid of doing that, I've gained so much speed with command mode, and I don't know is the tradeoff to emacs worth it
12:06arkxI'm curious as to why evil-mode seems disappointing to others making the transition to emacs.
12:06iwotechnomancy: :P
12:06pimeysarkx: maybe with configuration you can make it work like vim
12:06arkxWhat doesn't work? I was really impressed by how well it matched real vim, compared to say IntelliJ IDEA or Eclipse plugins.
12:07pimeysbut, the biggest thing is that it's only the default vim stuff that is there
12:07arkxThose are always terrible.
12:07pimeysfor new plugins, you have to write the workflow yourself
12:07pimeysthe bindings etc
12:07gfredericksarkx: I have a friend who switched with evil and still uses it
12:07pimeysI'm missing stuff like ysiw" :)
12:07hiredman.win 5
12:08iwoi seem to have the same problem as this guy http://clojure-log.n01se.net/date/2013-01-19.html#10:15a
12:08arkxOf course the plugin ecosystem is different between vim and emacs, but I found the core vim text editing functionality well implemented
12:08pimeysthe thing is, that I need more than the core
12:08floatbothhi everyone
12:08pimeysso, it's better to learn emacs than use a vim layer on top of it
12:08arkxpimeys: do you use paredit?
12:09pimeysof course
12:09floatbothI have a weird problem
12:09HolyJakiwo, technomancy: regarding nrepl-autocomplete. that is why I wait for Emacs 24.3, I believe I have read somewhere that prior to that there might be some issues with te completion
12:09hashbang1pimeys: i'm thinking so. Otherwise I'm just going to keep wanting to shoehorn my vim experience into other editors, which will just lead to frustration.
12:10floatbothhttps://github.com/myfreeweb/swaggerator/blob/master/src/swaggerator/validator.clj – this works when not AOT-compiled
12:10floatbothwhen it is, this is the stack trace:http://mfwb.us/9obI
12:10pimeysone thing that annoys me also is that when doing :some_command, ESC doesn't cancel it
12:11pimeysit does nothing
12:11pimeyssmall stuff, maybe that's fixable with configuration
12:11pimeysis it the C-g?
12:11arkxI moved quite naturally to using both vim *and* emacs keybindings where they didn't conflict
12:11hashbang1pimeys: ugh yeah i was doing that too, i think its c-g
12:14floatbothgoogle finds nothing for exceptions listed in http://mfwb.us/9obI
12:17arkxhttps://github.com/timcharper/evil-surround
12:18arkxBut yeah, some friction is to be expected, obviously. I'm happy I kept going, it doesn't need to be either-or when it comes to editors. :P (Heresy I know.)
12:21TimMcfloatboth: I don't see any obvious problems. Try doing a binary search -- remove half the code and see if the exception persists.
12:26floatbothoh wait, no, the problem is not in this namespace, it's in https://github.com/myfreeweb/swaggerator/blob/master/src/swaggerator/core.clj – using the controller macro from an AOT compiled namespace throws this exception
12:32floatbothhttps://github.com/myfreeweb/swaggerator/blob/master/src/swaggerator/core.clj#L48 – something's wrong in this macro, but it only blows up after AOT compilation
12:34llasramfloatboth: Superficial question -- why does the macro need to call `eval` vs just return a form to be evaluated?
12:37floatbothI don't know how else can I do this
12:38floatbothI want to evaluate the body in a binding with some transients and call persistent! to get the results for metadata
12:40floatbothIf I just put everything inside a backquote and don't eval, it still doesn't work from AOT-compiled namespaces AND it doesn't pass the tests
12:41llasramfloatboth: I was going to ask about that too... There's no way for the dynamic variables to end up taking on anything other than their initial empty values... Unless you're altering the current binding for the earmuffed vars in the code you eval?
12:42floatboththe code I eval alters them and I call persistent! on them and I assign them to the result of the evaluation
12:42llasram~transients
12:42clojurebottransients are not mutable data structures: http://technomancy.us/132 or at least as far as you're concerned.
12:42floatbotheverything works unless I use it from an AOT-compiled namespace
12:43llasramI think everything *appears* to work
12:43llasramAnd something about AOT-compilation is surfacing that some bits are broken
12:44llasramWhen you eval in macro-expansion, you are inserting the literal generated value for the next round of evaluation as if it had been produced by the reader
12:44llasramSometimes that's what you want, but usually not
12:45TimMcOof, that-ll do it.
12:45TimMc*that'll
12:46hiredmanthat code is almost definitely not using transients correctly
12:47hiredmanhttps://github.com/myfreeweb/swaggerator/blob/master/src/swaggerator/core.clj#L39 definitely not
12:47hiredmanI would run, not walk, away from swaggerator
12:48llasramCalm down, hiredman. Bugs exist to be fixed :-)
12:48floatbothhow do I use them correctly?
12:49llasramfloatboth: Just like Clojure persistent structures. The only difference is that there's no guarantees about the old versions remaining unmodified
12:49SegFaultAXReally? "swaggerator"?
12:49hiredmanllasram: bugs are one thing, not knowing how to use language features is another
12:51TimMcllasram: I think there's an implied "in its current state" -- which I would agree with.
12:51hiredmanfloatboth: http://clojure.org/transients
12:52floatbothahh, "not designed to be bashed in-place"
12:52ivansomeone oughta write a kibit rule for that
12:52floatbothshould I use atoms?
12:53TimMcivan: Detect transient ops in non-terminal position of do blocks?
12:54ivanTimMc: I suppose that would catch most of them
12:54llasramfloatboth: If you can't achieve what you're trying to achieve by producing functional values, then that's usually approach
12:54TimMcYou'd have to look for implicit do-blocks, e.g. doto, fn body, let body, when body...
12:54llasrams,approach,the approach,
12:56floatbothusing atoms doesn't fix the problem
12:56floatbothwhat the hell does "No matching ctor found for class clojure.lang.AFunction$1" mean anyway
12:58joegallothere's no such constructor for the first (or maybe it's second) anonymous class defined inside .../clojure/lang/AFunction.java
12:59bbloomfloatboth: you're trying to instantiate a non-class object
12:59bbloomer no rather i mean:
12:59bbloomfloatboth: you're passing the wrong arguments
13:00floatbothI mean I'm not calling any constructors… explicitly, at least
13:00llasramI'm about ~90% certain that you get there error when you try to re-eval an anonymous function which is a closure
13:00bbloomfloatboth: provide more context, ie what code is failing
13:01floatbothmore context: https://github.com/myfreeweb/swaggerator/blob/master/src/swaggerator/core.clj#L48
13:02rmrfchikhi. where I can in clojure sources a code which match java overloaded methods?
13:05rmrfchikah, Reflector.java
13:06llasramfloatboth: I know it's invasive, but I'm pretty certain your problems here trace to your use of `eval` w/in macros
13:08llasramSomeone correct me if I'm wrong, but I think the static initializer generated for AOTed namespaces is built from the post-macro-expansion code
13:09llasramIf your macros are returning things other than forms to be re-consumed by the compiler, then all sorts of craziness breaks loose
13:11floatbothyeah, I'm sure it's this too
13:11floatbothbut I don't know how to do this without eval
13:11dabdI am trying to get nrepl to work on Emacs for Win. When I run M-x nrepl-jack-in from a source file it opens an empty *nrepl* buffer but there is no listener. Any help please?
13:12TimMcfloatboth: What's the goal?
13:13floatbothto evaluate code inside a binding (to an atom), return the result of evaluation (which changes the atom) with the value of the atom as metadata
13:13Raynes$latest lein-ring
13:14lazybot[lein-ring "0.8.2"] -- https://clojars.org/lein-ring
13:14gtrakfloatboth: really you should fix that use of transients, just because it's totally wrong. Who's to say some other weirdness isn't contributing to the problem?
13:14floatbothgtrak: I have changed it to atoms, just not pushed to github. doesn't fix the problem though
13:15floatboththere's no exception if I just use one backquote and no eval, but it doesn't do the right thing then
13:15gtrakwhy are you interning?
13:16floatbothgtrak: where?
13:16gtrak66
13:16gtrak(intern *ns* n ...
13:16gtrakthat looks weird to me
13:17floatboththat's not related to the problem
13:17gtrakwhy not just say `(def ~n (controller ~url ~desc ~@body) ?
13:17floatbothjust a weird habit, why not indeed
13:18gtrakit's also semantically different
13:19gtrakI only use macros like that when they return a value, I would shy away from anything that does side effects at compile-time?
13:20TimMcfloatboth: You have a habit of using intern and eval in macros? D-:
13:20gtrakb/c I'm just not sure what that means at run-time
13:20floatbothTimMc: yes :D
13:20bbloomgtrak: anything that defs is a side effect at compile time
13:20gfredericksare there any examples of legitimate side-effecting macros?
13:20gtrakbbloom: there's a difference between expanding to a def and doing a def
13:21gfredericksignoring trivial side-effects like gensym
13:21dabdis there a way to do conditional compilation. I have a var that is a path that depends on the platform if on Win it has some value if on Linux it has another one. Any way to do this?
13:21bbloomgtrak: gfredericks: defmethod doesn't expand to a def
13:21gfredericksgtrak: they're both at compile time
13:21bbloom$source defmethod
13:21lazybotdefmethod is http://is.gd/SK2aTC
13:22gfredericksdefmethod doesn't side-effect
13:22gtrakgfredericks: gen-class?
13:22TimMcbbloom: It still doesn't appear to be a side-effecting macro.
13:22bbloomgfredericks: oh, you mean the macro side effects, not the result of it? i see
13:22bbloomi misunderstood
13:22gfredericksbbloom: yeah
13:22gfredericksgtrak: that does seem to be the case, yes; cool, thanks
13:23TimMcgen-class isn't actually a var, is it?
13:23gfredericksI'm wondering about the absoluteness of claiming "Macros should always be pure functions"
13:23TimMcOh weird, it's declared but I don't see a definition.
13:23gfredericks,#'gen-class
13:23bbloomgfredericks: in theory there could be memoization & other internal side effects
13:23bbloomgfredericks: dynamic code loading, etc
13:24gfredericks"Macros should usually always be pure functions"
13:24TimMcgfredericks: There's also referential transparency to consider.
13:24clojurebot#'clojure.core/gen-class
13:24gfredericks,#'unquote
13:24clojurebot#'clojure.core/unquote
13:24gfredericks,unquote
13:24clojurebot#<Unbound Unbound: #'clojure.core/unquote>
13:25llasramgen-class is very weird in how it does it's work during macro-expansion. I'm not clear on why it does that though -- I use a wrapped version which works just fine acting at code-execution-time
13:25TimMc(defmacro maybe [expr] (when (odd? (System/currentTimeMillis)) expr))
13:26TimMcOr it could go out and check a server to see if the client has paid up.
13:26gfredericksmost of my macros go out and check a server to see if the client has paid up.
13:26gfredericks(defmacro had-the-client-paid-up-at-compile-time? ...)
13:27cemericklynaghk: every day that passes, I want elision of nested expressions in cljx more...
13:28cemerickare you as opposed as you were last fall? (https://github.com/lynaghk/cljx/issues/5 FWIW)
13:29TimMcfloatboth: Get your code working without any transients, eval, or side-effecting macros. If your code is still not working when AOT'd, bring it 'round again.
13:29floatbothalmost got it
13:34pbuckleyif I want to map a function that takes two arguments to a collection, should I use walk to make every item in the collection have the two arguments?
13:35pbuckleythe first argument is constant, it isn't changing
13:35pbuckleyit just seems I'm not doing this right because of how convoluted I seem to be getting
13:35progohow about partial
13:35alexnixonpbuckley: (map (partial f 42) coll), where '42' is your constant
13:36pbuckleythanks progo and alexnixon, I think that's what I was looking for
13:36progoyou should have known lambdas as the other way to solve the situation, but partial is the clearest one
13:51banjoDoes anyone know if the major clojure conferences (e.g., Clojure/West) are effective places for a startup to find and hire good clojure people?
13:51banjoOr is job searching/recruitment strongly de-emphasized?
13:52technomancybanjo: I wouldn't say it's discouraged. it used to be easier a couple years ago when there were fewer jobs; these days a bigger portion of attendees are already working in clojure.
13:52gtrakbanjo: folks have booths and sponsor things like drinkups
13:53ro_sttechnomancy: job well done on 2.0.0 :-)
13:53technomancyro_st: thanks! happy to have it out.
13:54marcellusthecatanyone have any experience and/or example projects using sandbar? seems like a pretty cool lib with solid documentation that hasn't really got much attention?
13:54banjotechnomancy: I see, at this point are there many more companies recruiting than there are engineers job searching?
13:54ro_stmarcellusthecat: all the cool kids use lib-noir nowadays
13:54TimMctechnomancy: I suspect there's a feedback effect; employees are more likely to get a travel/fee reimbursement if their job involves Clojure...
13:55marcellusthecatro_st: That's what i use now but it doesn't have any higher level form managment stuff, trying to figure out if it's worth exploring more
13:55danielglauserbanjo: Depends on what you are looking for and how much location matters but there are quite a few Clojure user groups with people looking for Clojure gigs. Hint, I run one http://www.meetup.com/denofclojure/
13:56danielglauserbanjo: I know a couple of folks up in Boulder who are actively looking for work
13:56technomancybanjo: just my suspicion, but I think TimMc is right that the conference is likely to draw attendees whose work will cover the expenses.
13:56headshotdanielglauser: you in colo?
13:56danielglauserheadshot: Yessir
13:56headshoti'm in foco
13:57gfredericksfocorado?
13:57marcellusthecati've been regurgitating the same form validation stuff from that noir-messageboard project, keep feeling like it's time for something new
13:57danielglauserheadshot: foco?
13:57headshotfort collins
13:57headshotfort chronic
13:57gfredericksFort, Co.
13:57danielglauserheadshot: Nice!
13:58TimMcbanjo: Have you looked at Functional Jobs? I don't know what their fees are like, but it's a known place for job-seekers to look.
14:00banjodanielglauser: Makes sense, and thanks for the group. If your friends are looking and you wouldn't mind referring them feel free to pm me.
14:00danielglauserheadshot: a long way to travel but we do get folks from the Springs too. Come on down sometime.
14:00amalloyi was hoping foco was like "faux colorado", slang for some nearby state that wishes it could be colorado
14:00headshotheh
14:00banjoTimMc: I haven't, thanks for the reference.
14:01danielglauserbanjo: If you don't mind send me some info via the meetup and I'll announce the position. I don't think it will get very far without even a brief description.
14:01headshotdanielglauser: what's the meetup url?
14:01headshotthat posted earlier?
14:01danielglauserheadshot: http://www.meetup.com/denofclojure/
14:02banjodanielglauser: Thanks, will do.
14:03llasramThat was exciting. Setting RET to paredit-newline in paredit's keymap stops RET from triggering evalulation in nrepl.el
14:03llasramI of course thought the particular command I was running was just mysteriously hanging everything
14:04llasrams,command,form,
14:04llasramCool story, me
14:06arrdem/wc[A/join #yacc
14:09headshotdanielglauser: thanks
14:10amalloyllasram: i think folks who use paredit in the repl bind S-RET or C-RET to send the current input
14:11dabdI am getting a blank *nrepl* buffer with no listener. But if I run lein repl on the command line it works fine. Any tips?
14:12dabdEmacs shows nothing useful on the Messages buffer
14:16lynaghkcemerick: I'm not super-opposed to the nested cljx expression rewrites
14:16lynaghkcemerick: it's not something I really want to get in the habit of, but I haven't been doing a ton of cross-platform code lately so I can't really speak for the needs of that (very tiny) community.
14:17lynaghkcemerick: before we go about implementing it in cljx, though, I'd rather see if we can merge with the lein-dalap guys
14:18lynaghkcemerick: since I do still firmly believe that having several community projects on this very tiny problem domain is goofy.
14:18cemericklynaghk: well, I've turned it on in a org.clojars.cemerick fork, if only to see if chaos ensues
14:18cemerickIf only to eliminate the :require-macros crazy, I'll be happy
14:19cemerickthough protocol/type impls are brutal at the moment
14:19cemericklynaghk: the dalap stuff is very different; strictly clj -> cljs, not clj <- cljx -> cljs
14:20lynaghkcemerick: in theory shouldn't the cljs compiler itself be able to figure out the require-macros nonsense?
14:20lynaghkcemerick: yeah, sure. Still, I'd rather talk with them and see if their needs can be addressed by a modification of cljx and convince them to shut down their project
14:21cemericklynaghk: yeah, almost surely; speculatively require, look up the var, invoke as macro if it's there and marked as such
14:21lynaghkcemerick: it seems like their main issue is that they want easier REPL editing and nicer transform rules
14:22cemerickThat sort of magic seems to be frowned upon in general, witness having to require namespaces and then import types defined therein
14:22cemericklynaghk: I agree on both points; the former I get around via a cljx nrepl middlware
14:22cemerickmiddleware*
14:23lynaghkcemerick: true. The require-macros doesn't bother me a ton, though it is annoying to have a separate my-project.macros clojure namespace for my ClojureScript projects.
14:23lynaghkcemerick: you and your fancy "nrepl" =P
14:23cemerickcore.logic as the front-end is not super-fun, in the end
14:24cemerickcool, but way more brain work than I'd like in that spot
14:24lynaghkcemerick: yeah, I hear you on that---I wouldn't be surprised if I have spent more time fighting/contributing to core.logic in my grammar of graphics project than I've spent with graphics stuff
14:24cemericklynaghk: the require-macros stuff gets really gnarly if the macros are emitting calls to regular fns that really really should just be in a regular ns
14:24cemericknot project.fns-separated-for-no-good-reason
14:25lynaghkcemerick: the simplest extension mechanism would be just a user-supplied transformation function that gets any annotated forms?
14:25dnolenlynaghk: hehe :)
14:26lynaghkdnolen: spent about two hours last night with the new constraint stuff--basically everything gets much more verbose when I try to replace the sketch/hacky partial-maps stuff with proper explicit constraints
14:26cemericklynaghk: approximately; the closer it is to something familiar (macroexpansion), the better
14:26dnolenI'd rather just see people fight for feature expressions than continuing to pursue this stuff
14:26lynaghkdnolen: I may just end up doing a lot of form-walking of the rewrite rules and then generating constraint maps from that.
14:26lynaghkdnolen: yes!
14:27lynaghkdnolen: re: feature expressions, we would still need to figure out all of these issues. We're just doing it now via lein plugins on github, which is a lot more efficient than JIRA.
14:28rplaca~.
14:28clojurebotTitim gan éirí ort.
14:28dnolenlynaghk: right, I wasn't sure unifier was something you would actually use as interface, rather it gives you hook for defining something higher level.
14:28bbloomdnolen: I've moved into my new place in NYC. we should get together sometime soon to hack on clojurescript
14:28dnolenbbloom: yes!
14:28lynaghkdnolen: yep. I'll keep you posted
14:28lynaghkbbloom: noooo, now who will I visit to hack cljs when I'm in Seattle?
14:29bbloomlynaghk: i'm sure somebody in the clj user group up there does some cljs, ask technomancy who he might know
14:30bbloomdnolen: i'll email you
14:30technomancylynaghk, bbloom: hm, I don't know anyone from Seajure who's using cljs
14:31technomancyoh cbilson showed a little mobile dev demo using cljs and one of those JS cross-platform app thingies once
14:31technomancynot sure if he uses it much or if that was just messing around
14:32lynaghktechnomancy: oh, I'd be up to chat about that since that's what I've been up to lately
14:34bbloomlynaghk: honestly, i hacked up a browser-like environment with Apache Batik's SVG DOM so that I could have faster iteration on clj rather than cljs
14:34bbloomlynaghk: i'm mostly concerned with getting the data representations & algorithms right for what i'm working on
14:34bbloomthen i'll port to cljs
14:38bbloomi'm a few weeks behind on progress though... this move sucked away a ton of time....
14:40llasramamalloy: Oh yeah, I figured it out, and C-RET works. I just spent a while not knowing what was happening
15:01cemericklynaghk: not sure if you meant it or not, but cljx 0.2.1 hasn't been deployed to clojars
15:06SurlyFrogI'd like to split a file into several smaller ones. I can do a `(with-open [rdr ….] (let [seq (line-seq rdr)] …) but I'm trying to figure out how to take n lines at a time, write them to a new file, while maintaining the list of newly created files so I can return it from my function. Any suggestions?
15:07TimMcSurlyFrog: You can use a local atom.
15:08TimMc(let [ret (atom [])] (with-open ...) @ret)
15:08SurlyFrogTimMc: yeah, I thought about that. Is that the only way given Clojure's laziness?
15:08lynaghkcemerick: I did not; must've slipped through the cracks when I was traveling. It's deployed now.
15:09TimMcSurlyFrog: It's not so much about laziness as about management of state and mutation.
15:09TimMcThis function would be entirely eager, yes?
15:09lynaghkbbloom: I've looked at batik, but use too much CSS for it to be worthwhile---maybe when I have time I'll throw all of the appropriate phantomjs bits into a JAR.
15:10bbloomlynaghk: the style engine works
15:10SurlyFrogTimMc: yes, I need it to process the file, so I have to force evaluation of the lazy-seq returned by `line-seq`
15:10timcharperIn leinengen 1.x, I remember dependencies being stored local to the project (./lib/*.jar). With leinengen 2.x, they are stored in ~/.m2 . I have a case where uberjar is not working, and an internal maven repository is not easily available to my Amazon EC2 compute cluster. I'd like to run `lein deps` and have it install it local to the project, so I can rsync up my code and all dependencies. Does anyone know if there is an
15:10timcharperplugin to do so ?
15:11bbloomlynaghk: it was just a bitch to figure out how to activate it
15:11lynaghkbbloom: ohhh, interesting. I'll have to look into it
15:11TimMctimcharper: In lein 1.x they were already in m2, just copied from there to ./lib/
15:11bbloomlynaghk: just skip the docs and go to the source
15:11lynaghkbbloom: also benchmark phantomjs vs. batik for that use case.
15:12TimMctimcharper: I'd try really hard to solve the uberjar issue, if possible.
15:12timcharperTimMc: okay. Is there an option in lein 2.x to copy from m2 to lib and have it work such that when I invoke the code in the compute cluster it won't attempt to download them?
15:12bbloomlynaghk: well phantom is headless & i needed an interactive display. batik has an event model too
15:13timcharperTimMc: That's my hunch, but trying to crunch for a deadline tomorrow, so the optimization problem is pushing for immediate results over sustainability right now. :(
15:13bbloomlynaghk: haven't really perf tested at all yet, but it's been fast enough for my needs (for now)
15:13timcharperTimMc: My hunch being that I should try really hard and fix the uberjar issue :)
15:14SurlyFrogDoes a `with-open` return anything? If I have a `let` form inside it, will it return the value of my let?
15:15technomancytimcharper: you can set :local-repo to a relative path to have it download everything it needs into the project dir
15:15technomancybut fixing the uberjar is a better idea
15:15amalloySurlyFrog: Try It And See
15:16lynaghkbbloom: it has an event model too, damn. I guess it basically comes down to the featureset and how much of a pain it is to get phantomjs working and deployed around.
15:16lynaghkbbloom: thanks for the infos.
15:16TimMcSurlyFrog: According to the source, yes.
15:16timcharpertechnomancy: Thanks! :local-repo sounds like the hack I seek. I'll give uberjar a bit more effort before succumbing.
15:16lynaghkbbloom: any of your batik-from-Clojure usage open source?
15:16SurlyFrogthanks
15:16TimMctimcharper: If it's really a crunch, make sure to give yourself time to get local-repo working, just in case...
15:17TimMctimcharper: Is it an AOT issue?
15:17timcharperit's most likely a "I'm a retard" issue.
15:17TimMcThat's software for ya.
15:17sh10151Is it legit to use Clojure agents to make a simple work queue, even though I don't really care about sharing state among the threads?
15:17bbloomlynaghk: not yet, but i just pasted the most important file to here: https://www.refheap.com/paste/11180
15:17timcharperTimMc: lol
15:19llasramsh10151: Depends on the problem you want to solve. The stuff in java.util.concurrent is pretty awesome, so you could just actually use a *BlockingQueue and be done with it
15:20timcharperTimMc: I'm specified my :main namespace such that `lein run` will invoke the desired -main function. That works. When I run `lein uber jar`, and then invoke the produced standalone jar with java -jar project-0.x-standalone.jar, I am presented with the following error: Exception in thread "main" java.lang.NoClassDefFoundError: concentro/sim/cor
15:20sh10151llasram: That's my initial impression -- I've done a lot of Java. I just don't want to do something that Clojure experts will look at me funny for.
15:20technomancytimcharper: are you AOTing the gen-class namespace?
15:21technomancyit used to be magically implied with :main, but that was removed
15:21lynaghkbbloom: awesome, thanks. I might rip some of this into the c2po clojure demo (in my copious-amounts-of-spare-time =P)
15:21timcharperTimMc: Opening the jar reveals that the namespace concentro/sim/core has been compiled and included
15:21sh10151llasram: problem is very standard "listen to a message queue, dispatch workers to process requests but also keep listening for more messages"
15:21bbloomlynaghk: feel free
15:21bbloomi've also got a half dozen branches lying around with other things related to this, so let me know if you run into problems
15:22technomancytimcharper: so java claims the .class file doesn't exist, but opening the jar claims otherwise?
15:22llasramsh10151: BlockingQueue sounds perfect then to me. Heck, clojure.core uses it
15:23timcharpertechnomancy: right, that seems to be the case. I open it and this file is present: concentro/sim/core$_main.class (btw, my error, when pasting, was truncated and was missing the trailing e.)
15:23timcharperjava -jar concentro-0.2.0-standalone.jar
15:23timcharperException in thread "main" java.lang.NoClassDefFoundError: concentro/sim/core
15:24technomancywhat about just concentro/sim/core.class?
15:24timcharpertechnomancy: I'm not sure as to whether or not we are AOTing the gen-class namespace, and shamefully, less sure as to what that means.
15:24technomancyok, you should have :aot [concentro.sim.core] in project.clj
15:28hiredmantechnomancy: itym #{concentro.sim.core}, obviously it should be a set
15:29technomancyheh; sure
15:31timcharpertechnomancy, TimMc : not in there either. I just asked to my colleague, the author of said project I'm trying to deploy to the cloud, and he said he understands why uberjar isn't working, and that it will be some work to get it working. So I'm going to wave a white flag on uberjar and pursue the hopefully quicker :local-repo option :) Thank you so much for both of your help!
15:33timcharper(he was previously not available, otherwise I would have asked him first :) )
15:34TimMctimcharper: Is it an AOT issue? I wrote lein-otf to deal with this kind of thing.
15:34TimMc(You can have an executable jar that compiles on the fly instead of ahead of time.
15:34TimMc)(
15:34TimMcgrah)
15:39timcharperTimMc: turning on AOT didn't seem to help. My collegue doesn't seem to think that's the problem. :gen-class was not in my target namespace's declaration.
15:39timcharperTimMc: Trying to turn that on now
15:40timcharperand that appeared to be it. lein uberjar is working now!
15:40TimMc\o/
15:41TimMcYep, it's a bit of unavoidable redundancy right now.
15:41TimMcI wonder if kibit could catch some of these scenarios.
15:50ivandoes anyone use http://gittup.org/tup/ for building Java things?
15:51mattmossI've used it a little for C++, not java.
15:54ivanI need some thing for building Java things that is not Maven, or if not that, some way to build all those Maven plugins everyone uses from source
15:55p_lGradle seems pretty nice
15:55llasramivan: lein is working for us
15:57thorwildoes some-> have some problem with anonymous fns?
15:58TimMcthorwil: Yes, stitching macros and reader sugar often don't play well together.
15:58TimMc&(macroexpand-1 '(-> 5 #(do)))
15:58lazybot⇒ (fn* 5 [] (do))
15:59TimMc&(macroexpand-1 '(-> 5 (#(do))))
15:59lazybot⇒ ((fn* [] (do)) 5)
15:59thorwil&(some-> 1 identity)
15:59lazybotjava.lang.RuntimeException: Unable to resolve symbol: some-> in this context
15:59TimMcWell, #(do) is a silly example, but you get the idea.
16:02brehautha, pythons 'input' function does read eval. how odd
16:02thorwiland *poof* goes my ticket to a concise solution. ty
16:05thorwilactually no, all it takes is an extra () around the (fn)
16:05TimMcYep.
16:10TimMc&(->> 5 #'+)
16:10lazybot⇒ #'clojure.core/+
16:10TimMc&(->> 5 (#'+))
16:10lazybot⇒ 5
16:11SurlyFrogWould somebody like to take a quick look at a small piece of code and critique it?
16:12gfredericksclojurebot: list?
16:12clojurebotlist* doesn't actually make a `list?`
16:12gfredericks^ the '*' points to a footnote: * not actually a list
16:12TimMchaha
16:13seangroveIn emacs, if I have an nrepl session running but I've killed the buffer with the repl input, how can I get it back?
16:13TimMc"Some restrictions may apply. Not valid in all VMs. Void where prohibited."
16:13seangroveI've just been restarting the whole process so far
16:13SurlyFrogIt's here if anyone has a moment. http://pastebin.com/KwX6Vyhz The goal is to take a large file, and break it into several new temporary files which can be processed further.
16:16TimMcSurlyFrog: I might've used vec + dorun + map myself.
16:16SurlyFrogTimMc: how so? `dorun` instead of `reduce`?
16:17TimMc(vec (dorun (map #(seq-out % dir) (partition-all count seq))))
16:18amalloyTimMc: (vec (dorun ...))?????
16:18TimMcerk
16:18TimMcdoall
16:18arkxWhy not (mapv ...)?
16:18TimMc&(doc mapv)
16:18lazybot⇒ ------------------------- clojure.core/mapv ([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]) Returns a vector consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each co... https://www.refheap.com/paste/11183
16:18amalloyTimMc: just throw away the doall part: (vec ...) is equivalent but faster
16:18TimMcamalloy: Oooh, good point.
16:18SurlyFrogI get confused by `doall`, `doseq`, etc.
16:18TimMcamalloy is my kibit
16:19TimMcI highly recommend it.
16:19SurlyFrogSo simply calling `vec` on the lazy sequence created by map will force realization of it?
16:20amalloyi don't see where you're suggesting he use vec anyway though, TimMc. in split-file?
16:20TimMcamalloy: The last line, yes.
16:21amalloyyeah. i guess that line is just (mapv #(seq-out % dir) (partition-all count seq))
16:24SurlyFrogamalloy: that works and is a bit easier to read. Thanks, to you and TimMC
16:24SurlyFrogfor taking the time to look at it
16:51cemericklynaghk: not sure if you've been following the topic, but this works (gnarly, but produces cljx output with forms on the "correct" lines): https://github.com/cemerick/cljx/commit/079f1c890be1857dc68d4183249dd342712c4ef2
16:52cemericker, https://github.com/cemerick/cljx/commit/c331257 I mean
16:53lynaghkcemerick: have you needed to debug the cljx output very often?
16:53lynaghkcemerick: if you think that's useful feel free to push it upstream.
16:54cemericklynaghk: sure; stack traces, certainly. Source maps soon, hopefully.
16:54frozenlockIs there any advantages in using cljx instead of lein-cljsbuild crossovers?
16:54cemerickI mean, both point to the line number in the .clj/.cljs file fine, but reading the output there is horrid.
16:55lynaghkfrozenlock: cljx does rewrites to certain protocol names automatically, which is nice
16:56lynaghkcemerick: good point re: stacktraces. go for it, and thanks.
16:56cemerickfrozenlock: and you can write rules to e.g. transform Clojure-style catch/throw forms to something reasonable in ClojureScript
16:56cemericketc etc
16:57cemericklynaghk: ok; I'll just need to twiddle the commit order to cherry-pick that bit, and fill in the same treatment for sets, vectors, etc.
16:57frozenlockOh interesting. I'll keep that in mind if I ever need to write clojure code that interops with js/jvm.
17:00lynaghkfrozenlock: The motivating use case for me was C2, which has a lot of mathy transformation type stuff that wanted to be on both platforms
17:05gfredericksis c3p0 (the connection pooling lib used by korma) reputable?
17:08technomancygfredericks: gave me nothing but trouble
17:08gfrederickstechnomancy: dangit.
17:24tolsenHello. I am having trouble doing some println debugging. I can't seem to get the following to print before the exception is thrown: (map (fn [x] (println "HELLO") (throw (RuntimeException.))) (range 1 10))
17:27dnolen_tolsen: you need wrap in doall, map is lazy
17:28tolsenweird. that feels almost out-of-order lazy as my println comes before the throw in the fn
17:32morphlingtolsen|away: seems unlikely. You could try to flush the output stream?
17:33morphlingtolsen|away: also, if that helps, println apparently calls prn, which observes *flush-on-newline*
17:36tgoossensHi. I just started planning on organising a clojure meetup in belgium. Any advice?
17:40frozenlocktgoossens: Yes, do it in Canada =D
17:40tgoossenshaha
17:55ppppaulfrozenlock, already exists
17:55ppppaulin toronto, at least
18:06frozenlockppppaul: Any recordings?
20:30frozenlock*cricket*
20:33Hodapp*wombat*
20:39rbarraud*echidna*
20:40mattmosso_O
20:41Raynes*hedgehog*
20:42metellusnone of those animals would wear earmuffs.
20:42RaynesI bet Sonic would if it were really cold.
20:44ivan*-XX:+PrintCompilation*
20:45mattmoss(binding [*hedgehog* 'sonic] (do ...)) ?
20:45ivanheard in #jruby the -XX:+TieredCompilation -XX:TieredStopAtLevel=1 settings took another second off the time
21:58technomancylein uses tieredcompilation
21:58technomancyI haven't looked into the other one though
22:00technomancyholy smokes; 0.7s shaved off
22:04ivanhotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp also suggests some alternate tweaks
22:04ivanI wonder if TieredStopAtLevel can be raised after it starts
22:13matthavenerivan: crazy, just googled what you were talking about
22:14matthavenerivan: jruby guys searching for fastest: https://gist.github.com/teohm/4343392
22:14ivannuts
22:14ivan-noverify is indeed a big help
22:16ivanwhat's -X-C?
22:19ivanoh, the -X options there are not passed to java
22:22technomancynoverify is redundant if you use bootclasspath iirc
22:22ivanright, assuming you put everything into bootclasspath
22:22technomancythough you might be able to use noverify for the project-level JVM
22:24technomancyhm; doesn't seem to have an effect
22:30warzis clutch the suggested couchdb client lib? it looks good, just a few months without any commits, so figure id ask
22:33ivanuser> (.getDiagnosticOptions (sun.management.HotSpotDiagnostic.))
22:33ivanUnsatisfiedLinkError sun.management.Flag.initialize()V sun.management.Flag.initialize (Flag.java:-2)
22:33ivanI was hoping to use that to change TieredStopAtLevel
22:41djwonkHello, does someone remember the business-focused report that recommends adopting Clojure?
22:42ivanThoughtWorks Tech Radar
22:42djwonkI can't remember if it was O'Reilly Radar or Garner...
22:42djwonkivan: thanks! Thoughtworks
22:42djwonkGarner -> Gartner
22:44SurlyFrogIs there a Clojure equivalent to Common Lisp's `with-standard-io-syntax`? I want to dump Clojure data into files and read it back, but using clojure.java.io/reader seems to interpret each line as a string.
22:44epitronJennifer Gartner
22:44ivanheh
22:45yogthosSurlyFrog: something like this ? http://clojuredocs.org/clojure_core/clojure.core/read
22:46SurlyFrogyogthos: basically, but I need to be able to move through the file line-by-line.
22:47yogthosSurlyFrog: read reads by form since a form could span multiple lines
22:48SurlyFrogyogthos: yeah, just saw that…..hmmm, maybe that has to be the way....
22:49SurlyFrogActually, is there a way to read through two files, line by line? I can do it with a `map` over two line-seqs, but that only works if the two files have the same number of lines. What I need is some sort of loop/recur/cond form.....
22:51yogthosSurlyFrog: so what are you trying to do with the contents?
22:51SurlyFrogmerge them into a single, sorted file.
22:52yogthosyou could read both then concat and sort
22:52yogthosyou could also use reduce
22:52tomoj(fn [& seqs] (->> seqs (map #(concat % (repeat nil))) (apply map vector) (take-while #(not-every? nil? %)))) ?
22:52SurlyFrogThey could be *really* big, so I don't want to read them all into memory.
22:52yogthos(reduce (fn [[f1 f2]] ...) [f1 f2])
22:53yogthosyou could iterate as well
22:53SurlyFrogI haven't looked at iterate, let me check that out...
22:53cemerickis anyone else seeing a suspicious 60s delay in the jvm exiting after running `lein cljsbuild once`?
22:54yogthosso you'd iterate over the accumulator and the function called at each step could be reading the files
22:55SurlyFrogIt says the function passed to iterate must be free of side effects. I'd be reading a value from both files, then writing them into a third, sorted file.
22:57yogthosif you're just reading and writing without doing anything in memory loop might actually be the way to go
22:58tomojSurlyFrog: to be clear that fn was for you
22:58SurlyFrogtomoj: oh, I didn't know that.
22:58tomoj&((fn [& seqs] (->> seqs (map #(concat % (repeat nil))) (apply map vector) (take-while #(not-every? nil? %)))) [1 2 3] [4 5] [6])
22:58lazybot⇒ ([1 4 6] [2 5 nil] [3 nil nil])
22:59tomojthat's one way to get map but running out at the longest instead of the shortest
23:00tomojor is that not the problem with using map for that
23:00yogthostomoj: sounds like the data might be to big to keep in memory as well
23:01tomojno problem then, map is lazy
23:03yogthosgood point, if it got consumed as it maps should be fine
23:04amalloyif his plan is to merge two sorted files into a larger sorted file, none of these "one item from each' approaches work at all
23:05XorlevDo you guys have any tips for keeping data structures straight as program complexity grows? In more static languages, types are rather explicit but they're a lot less so in Clojure.
23:05yogthosXorlev: naming conventions help
23:06yogthosXorlev: for example in the standard lib if a function takes a map it's usually denoted as m, key values as k v, etc
23:07XorlevPseudo-hungarian approach then... okay, I think I could deal with that. How about things like maps -- what keys does it need to actually be useful? Or is that when you'd define a protocol instead?
23:08SurlyFrogtomoj: thanks, that works!
23:08tomojI'm surprised
23:09tomojI thought amalloy was right
23:09SurlyFrogwell, it solves the problem I asked about, amalloy just pointed out another issue :-)
23:09tomojah, yes :)
23:09yogthoshehe
23:09yogthosXorlev: documentation is often used to help figure out what's what, for example https://github.com/ring-clojure/ring/blob/master/SPEC
23:10SurlyFrogIs there not a disk-based merge sort already canned someplace?
23:10amalloyi mean, the whole thing is easily modeled as (write-to-file "out" (lazy-merge-sort (read-file "in1") (read-file "in2")))
23:11yogthosXorlev: in general it helps to add docs inline to the functions inline as well
23:11amalloyall of those functions already exist
23:11amalloyunder some name or other
23:11yogthosa lot of time solving a problem is a game of finding the right functions to glue together :P
23:12Xorlevyogthos: Thanks for the link to the ring docs, that makes a lot of sense :) I'm embarking on my first non-trivial Clojure application. Have a great night/day
23:12yogthosXorlev: good luck :)
23:12SurlyFrogyeah….I know, I just haven't found what I was looking for.
23:12yogthosXorlev: my biggest advice is to keep the functions short and readable :P
23:13XorlevThat's something I've noticed...Clojure forces you away from monolithic functions.
23:13XorlevOr into catchy hard-to-decompress one-liners. Not sure what's worse.
23:13yogthosSurlyFrog: might be useful :) https://github.com/chrismgray/clojure-heap-sort
23:14yogthosXorlev: you have to have a bit of discipline when writing stuff, if something is hard to read it probably should be refactored
23:15spjt_anyone bored and want to do a code review of my first clojure program? :)
23:15yogthosXorlev: while it's often tempting to write really dense code, it's really best not to
23:15yogthosspjt_: could take a look :P
23:15XorlevPeople make the same mistakes with Scala. Some library authors, even
23:15SurlyFrogyogthos: it looks like that does everything in memory
23:16spjt_yogthos: http://pastebin.com/g83F3bGF
23:16spjt_yogthos: It's for a school assignment but I've already turned it in.
23:16yogthosXorlev: I find one thing I do is write a solution first, and then refactor it to clean it up after
23:16spjt_yogthos: It generates a list of primes between prime-min and prime-max. It's very slow.
23:16yogthosXorlev: with a repl it's pretty natural to do, and because you're working with an AST, you can just rip out nodes and make them into standalone functions
23:17yogthosspjt_: gotcha :)
23:18Xorlevyogthos: I'll give that a try. Thank you so much :)
23:18yogthosXorlev: no prob :)
23:19yogthosspjt_: are the agents part of the requirement? :)
23:19spjt_yogthos: It has to be multithreaded.
23:20spjt_yogthos: It does "efficiently" distribute the workload over multiple cores, at least in the sense that it heats up the CPU good (all cores running at 100%) but it still takes a long time.
23:21yogthosspjt_: generating primes is slow business, hence why encryption still works :P
23:21spjt_yogthos: My general question which I've never really seen addressed is the relative efficiency of the different data structures in Clojure (e.g. I use sets for the "small primes" and a list for the "large primes")
23:22spjt_yogthos: It's all anecdotal but the people who used C++ said they got "4 seconds" whereas mine takes around 70 seconds, of course given whatever computer they have and I have, which I have no idea.
23:23yogthosspjt_: yeah there's some variation there
23:23yogthosspjt_: also did you run with the -server flag?
23:23yogthosspjt_: and you might want to try multiple runs to let it warm up
23:23yogthosspjt_: I mean within the same jvm session
23:23spjt_yogthos: The best I can say is that the clojure program took 70 seconds of wall time and 250 seconds of CPU time on a 4-core CPU :)
23:24yogthosyou could fiddle with partition sizes as well
23:24spjt_yogthos: I did fiddle with that, 100K gave the best results
23:24yogthosah :)
23:25spjt_That was part of the problem, I couldn't figure out how to compile it or use -server flags
23:26spjt_i guess i figured out -server
23:26ivanhow do I call a static method on a package-private class?
23:26yogthosspjt_: you can add :jvm-opts ["-Xmx1g" "-server"] in your project.clj
23:27spjt_project.clj?
23:27clojurebotunquote in project.clj is an escape hatch
23:27spjt_server definitely helps
23:27yogthosspjt_: if you use leiningen to build https://github.com/technomancy/leiningen
23:28spjt_yogthos: I couldn't use leiningen, it had to compile and run from a shell script on a server without clojure installed
23:28yogthosspjt_: ah gotcha
23:28spjt_yogthos: It runs in 51s with -server, though.
23:29yogthosspjt_: some tricks here https://groups.google.com/forum/?fromgroups=#!topic/clojure/yPaQN7JuKFY
23:29yogthosspjt_: significant improvement :P
23:30yogthosspjt_: this should help as well -Xincgc : enable incremental garbage collector
23:30yogthosalthough that might be enabled by default now?
23:31spjt_I probably could have used knowing how to compile without leiningen
23:31technomancyspjt_: for wringing the last bits of perf out of Clojure this is a pretty good overview: http://meshy.org/2009/12/13/widefinder-2-with-clojure.html
23:31technomancyif you're I/O bound anyway; for numerics it'll be different
23:32tmciverspjt_: you may also want to check out ##(doc pmap)
23:32lazybotjava.lang.SecurityException: You tripped the alarm! pmap is bad!
23:32spjt_I don't think it was IO bound
23:32tmciverhmm
23:33yogthostechnomancy: that's pretty thorough link, I'm bookmarking that for future reference :)
23:33yogthos&(doc pmap)
23:33lazybotjava.lang.SecurityException: You tripped the alarm! pmap is bad!
23:34yogthosaww
23:34technomancylazybot: I am disappoint
23:34spjt_my program may not have been the fastest, but I'll bet it was the shortest :)
23:34nightfly&(doc #'pmap)
23:34yogthosspjt_: and pretty readable to boot :P
23:34lazybotjava.lang.SecurityException: You tripped the alarm! pmap is bad!
23:35tmcivermaybe something like (pmap check-prime (range max-prime)) where check-prime could create a map with a key indicating if the value was prime. Then you could filter that.
23:35spjt_yogthos: yeah, I could have made it about 1/3 the size by composing all the functions. I also noticed after I wrote it that I could have just wrote 1E7 instead of (Math/pow 10 7) :)
23:37spjt_It's my first clojure program, so I'm not expecting anything too spectacular
23:37yogthostmciver: might be better to partition first (pmap check-primes (partition-all 1000 (range max)))
23:38spjt_In my programming languages class we had to give a talk to convince the class to do one language or another, I failed and we're doing Haskell
23:39yogthosspjt_: haskell is good for you :P
23:39tmciveryogthos: is pmap not parallelized for a single collection. I've never actually used it. :)
23:39spjt_Haskell isn't good for me
23:39yogthostmciver: I've used it once in production so far :)
23:40yogthosspjt_: most ideas translate well to clojure, if you get good at haskell you'll grok clojure better as well
23:40spjt_I'd think lisp is best for teaching people used to imperative programming how to do functional programming in a controlled environment because there's none of the "what does :!:@-> mean"
23:41yogthosspjt_: well lisp does have really simple syntax going for it
23:41TimMcspjt_: Don't be too sure. :-P
23:41TimMc~rest
23:41clojurebotrest is easy to write without alphanumerics: https://www.refheap.com/paste/5980
23:41yogthosspjt_: I don't know why so many people are averse to it
23:41TimMcYou can still have line noise in a Lisp!
23:41tmciverTimMc: cut it out.
23:41TimMchaha
23:41tmciver:)
23:42yogthosmacros can certainly get pretty impenetrable :P
23:42abp` That's how I program all day long.
23:42nightflyspjt_: Yeah, I had several false starts at learning functional programming with Haskell. Clojure was fairly simple to get into.
23:42yogthosTimMc: and that is pretty epic :P
23:42spjt_I ended up learning functional programming with Scala because, well, if I couldn't do it functional, I could at least do it.
23:43yogthossolvip: I started with Scala, but I found I just kept going back to what I know
23:43yogthoserr spjt_ not solvip :)
23:43yogthosspjt_: so then I jumped into deep end with haskell and eventually it started making sense :) after that I moved to clojure and stayed with it :)
23:44spjt_My project last summer was to learn a functional language, and Scala ended up winning mostly because I could fall back on imperative when I couldn't figure out how to do it functional
23:45spjt_when I came back to Clojure after that it all made a lot more sense.
23:46yogthosspjt_: I find scala to be very busy, it seems to take c++ approach of just throwing every language concept into a cauldron :)
23:47spjt_yogthos: yeah, but sometimes that means "I know how to do it in X language, and here it is" :)
23:48spjt_I could definitely see scala in the wrong hands being far, far worse than PHP
23:48yogthosspjt_: what I found really neat is that by not making an arbitrary distinction between how you treat logic and data you get all these nice things by default
23:48yogthosspjt_: what I mean is when you have first class functions, you can pass them as parameters
23:49yogthosspjt_: all of a sudden all these visitor patterns, and dependency injection, etc. disappear, you just pass a function in
23:49spjt_you can do that in almost any language if you try hard enough
23:49yogthosspjt_: nice and simple, by capturing scope and returning functions you can make equivalent of constructors with closures, but you're not introducing any special cases
23:50spjt_the worst is anonymous classes in java, they make me want to cry
23:50yogthosspjt_: the thing that's appealing is that you just use simple and consistent rules to do all this stuff a lot of languages create special cases for
23:51yogthosspjt_: half the frameworks in java are there to compensate for language deficiencies :)
23:51yogthosspjt: there was an amusing article on that http://www.grahamlea.com/2013/02/a-new-java-library-for-amazing-productivity/
23:52spjtwe use "java" at my job, i need to convince them to use clojure, after all, "it works with java"
23:52yogthosspjt: it can be done, took me 2 years but we actually moved to clojure on my team :)
23:52spjtit might take me two years to figure out how to compile clojure
23:52yogthosspjt: I found you have to be very patient about it :)
23:53yogthosspjt: leiningen ;)
23:53spjtyeah, leiningen probably won't be as much of a problem at work as it is in class
23:54yogthosspjt: and if a place is really conservative there's maven :)
23:54spjtthe thing about that is there's a difference between people writing it and people reading it
23:55spjtPeople would see my Scala code and just be? "wtf"
23:55yogthosspjt: but there is a really good case to be made, it runs on the same infrastructure, you can use the same build tools, same build servers, same deployment options, even same IDE
23:55yogthosspjt: the only thing that changes is the language
23:55spjtbad scala looks like java, good scala looks nothing like it
23:56yogthosspjt: scala does seem to be picking up in popularity, I'd certainly rather work with it than java
23:58spjthow much of that is java programmers who like not having to put in semicolons
23:59yogthosspjt: can hope it's the gateway drug :P