#clojure logs

2010-03-24

00:01psykoticseriously. torus trooper.
00:02tomojmabes: in the solitaire I know, you can only see the cards that get turned face up, not the whole deck
00:03tomojthat paper discusses "Thoughtful Solitaire" where you can see the whole deck?
00:04defnLicenser: you around?
00:06mabestomoj: right with Thoughful Solitaire you can see every card.. no matter where it is. That way you can try to strategize your moves and it leaves things less up to chance
00:10mabeshrm.. so if I rename my protocol to IStupid it works.. maybe there is an issue with the type being Card and the protocol being ICard?
00:19Raynesclojurebot: sexp > you
00:19clojurebot<monads> is "yea, though I should walk in the valley of imperative code, I shall fear no evil, for your monad comforts me" - seen in #haskell
00:19Raynessexpbot*
00:46rem7at the beginig of the "Programming Clojure" book there is an exercise where you say "hello back" to a user when he is already in a ref. You can 'alter' the ref with 'conj'... how do you do the opposite? say I wanna remove a user...
00:46technomancyrem7: depends on what's inside the ref
00:46psykoticrem7: if you use a set, you can use disj
00:47rem7another ref...
01:03rem7psykotic: thanks that worked
01:44joshua-choiIs anyone using a bare REPL with JLine and no IDE? I'm encountering a weird bug where (assuming I have a history) if I press up twice and down once, my cursor skips to the left and starts overwriting incorrectly.
01:45defnahhh, to parse 300MB of text for IP addresses and then count the number of occurrences for each unique
01:45defnany tips?
01:46joshua-choiI know how I'd try doing it in Java (with Scanners)...but I don't know if there are any better Clojure ways.
01:46defnthat's sort of the path im looking at (doing it in pure clojure)
01:46joshua-choiI should really look at clojure.contrib carefully someday
01:47defnive read through alex osbourne's widefinder 2 implementation, and while it looks like it works beautifully -- im not comfortable using that code without knowing how it all works. there is a lot of java going on which I don't fully understand
01:47defnI'm trying to do something "good enough" with just clojure and a sprinkle of java
01:48joshua-choiHave you looked at clojure.contrib.io/read-lines?
01:48joshua-choiIt seems to create a lazy sequence of a file's lines
01:48joshua-choiThough I don't know how that'll perform with 300 MB
01:50defn*nod*
01:51defnmy main problem so far has been tallying uniques
01:52defn(count (read-lines (java.io.File. "myfile"))) is enough to hang me it seems
01:52joshua-choiThat's unfortunate...I wonder why—if it's lazy, shouldn't it be fine?
01:53joshua-choiOh, you're using count.
01:53defnIs there a better way to know the length?
01:53joshua-choiWell, hang on...does count hold onto the head?
01:53Chousukeit shouldn't.
01:53joshua-choiHmm
01:53defnim running 1.1.0 FWIW
01:54defnit's definitely a lazy-seq
01:55joshua-choiHow does count work anyway? Does it increment a number while discarding each element?
01:55joshua-choiI can't tell from the source
01:58defnperhaps I need a line-seq
02:00joshua-choiWhat do you mean?
02:00defnI'm just grasping at straws here :)
02:01psykoticjoshua-choi: it's technically container specific. LazySeq does the equivalent of (loop [s (seq coll), n 0] (if s (recur (next s) (inc n)) n))
02:01defn,(< 0 (.indexOf "abc" "b"))
02:01clojurebottrue
02:01defn,(< 0 (.indexOf "abc" "q"))
02:01clojurebotfalse
02:01joshua-choiOkay, so LazySeq's count method does increment and discard.
02:02joshua-choiWhy would it hang, then?
02:02joshua-choidefn: Does your JVM run out of memory?
02:02ynefnewbie question: I want to return the number of days in a month for a given year. I already have a function called "is-leap-year?". How should I write the "(defn days-in-month [year month] ..." function? (this is not homework, btw: I'm learning Clojure by doing ProjectEuler problems)
02:03defnjoshua-choi: i think it may just break my REPL -- it's not clear what is going wrong -- I just get "Evaulation Aborted" in my REPL after awhile
02:03defnI've sent *print-length* sufficiently low to avoid the printer from going nuts and killing something
02:03defns/sent/set
02:05ynefmy idea way "make a list of numbers and for february do a (if (is-leap-year? year) (29) (28)) and return 'eval' on (nth month) on that list" -- however, that did not work, since "year" cannot be referenced at that point(?)
02:05ynefs/way/was
02:05ynef(also, pardon my English, not a native speaker)
02:06psykoticdefn: how big is 'myfile'?
02:06defn300MB
02:06joshua-choiynef: I'd (def regular-month-days {1 31, 3 31, 4 30, ...}) (defn february-days [year] ...) (defn days-in-month [year month] (or (regular-month-days month) (february-days year)).
02:07psykoticdefn: i posted my trace-seq on the mailing list. did you see that?
02:07psykoticit always use it for things like this, to monitor progress.
02:07defnpsykotic: i did not see that but i will check it out immediately
02:08psykotici'll gist it
02:08ynefjoshua-choi: that's really nice, thanks!
02:08defnpsykotic: thanks buddy
02:09noidibleh, freenode sucks
02:09noidiIrssi: Your nick is owned by (my name)
02:09noidi#clojure Cannot change nickname while banned on channel
02:09defnyeah i find that a bit annoying as well noidi
02:09noidiand I couldn't identify as myself for having the wrong nick
02:11noidifor the guy asking about his date functions, you could build the map in the function, then you could use the year variable in your map
02:11noidi(I lost my lastlog when freenode made me part the channel) :P
02:14defnpsykotic: ping me when you've gisted please
02:14psykoticok
02:15joshua-choiI am now fully convinced of the REPL's usefulness after having used it with JLine for a week
02:15joshua-choiI don't know how I survived by running tests repeatedly
02:15defnill be more convinced of the REPL's usefulness once it quits breaking on me ;)
02:16joshua-choiIs there a way to monitor the JVM's memory in realtime?
02:17defngood question
02:18bobo_jconsole/jvisualvm
02:18joshua-choiAh
02:24defnpsykotic: any luck? I can't seem to find it with google
02:24ynefnoidi: how would I do that (I'm the date function guy)? I'm a complete newbie in all things related to LISP :-)
02:24psykoticdefn: i'm having a bad internet connection right now, so gist is difficult. i'll privmsg you, it's only a few lines
02:31noidiynef, (defn days-in-month [month year] ({1 31, 2 (if (is-leap-year? year) 29 28), 3 31, ...} month))
02:31noidior something like that
02:32joshua-choiI have a question on iterate and lazy-seq, at http://github.com/richhickey/clojure/blob/49a7d6b8e14050a45df5332e768ba6647752215d/src/clj/clojure/core.clj#L2012
02:32joshua-choiiterate calls itself within a lazy-seq form. Does iterate increase the stack for every element in the sequence it's called with?
02:32noidiynef, of course you could extract the map generation into its own function and just do ((days-in-months 2010) 3)
02:37psykoticjoshua-choi: no. think about when the lazy-seq thunk is actually called.
02:37psykoticjoshua-choi: in effect, the "stack" is reified as the lists that cache the lazy-seq cells. if you throw away the head as you traverse it, there's no increasing memory consumption.
02:39joshua-choipsykotic: Yeah, I see. Thansk.
02:39joshua-choiWell, calling (->> 3 (iterate inc) (drop 100000000) first) still seems to freeze my REPL. I wonder if it's because of memory or if it's just taking a long time for some reason.
02:39psykotici can see why that isn't totally obvious because of lazy-seq's implicit thunking
02:40psykoticjoshua-choi: you're having to traverse a 100 hundred cons cells and associated lazy generation logic.
02:40psykoticerr, 100 million
02:40joshua-choiI see
02:40joshua-choiIt's because of object creation
02:41joshua-choiWait, no...um, is that right?
02:41psykoticwell, even if there was no heap allocation, you're still looking at a hundred million iterations of something
02:41psykoticeven adding a hundred million numbers takes a bit of time, and this is heavier weight
02:41joshua-choiI see
02:42joshua-choiI've been trying to figure out how to create my own lazy sequences
02:42psykoticit's not that different from creating eager sequences.
02:42joshua-choiNamely, I have a parser, and I want to be able to get a lazy sequence of all the matches inside a string.
02:42joshua-choiI don't want to have to resort to state monads.
02:43joshua-choiI'm going to sleep now. Thanks a lot for your help.
02:43psykoticsounds like... the list monad :)
02:43joshua-choiWell...
02:43joshua-choiWhat does the list monad do?
02:43psykoticthe usual parser monad is state + list, but you can retain the list part and be explicit about the state plumbing (the remaining chars to parse)
02:43psykoticit effectively does backtracking search
02:43joshua-choiOh
02:44joshua-choiYeah, that's what I'm talking about
02:44joshua-choiThough it's vectors in clojure.contrib.monads, I think
02:44psykoticclojure's for macro is basically 'do' notation for the list monad
02:44joshua-choiWait, no
02:44joshua-choiAh
02:44joshua-choiYou're talking about the seq monad
02:44psykoticyes
02:44joshua-choiWhich is...the same thing, right
02:44joshua-choi:)
02:44psykoticmodulo the abstraction, yeah,
02:44psykotici was trying to use a term you might have heard elsewhere
02:45psykoticanyway, you don't need to use the monadic magic for this, you can do it manually.
02:45joshua-choiYeah
02:45joshua-choiThough I'm going to have to sketch this out yeargh
02:45joshua-choiThanks a lot; have a good night
02:45psykoticfor example, let's say you write your parser functions as taking the sequence of outstanding characters and returning a vector of the result and the new outstanding characters (i.e. with the consumed ones unconsed)
02:45psykoticthen you can do something like this:
02:46joshua-choiHmm
02:46psykotic(for [[m s] (parse-number s)
02:46psykotic [n s] (parse-number s)]
02:46psykotic [(+ m n) s)
02:46psykoticthat would parse two successive numbers and return their sum, while consuming the parsed characters
02:46joshua-choiWhat does parse-number return?
02:47psykoticwith something like parsec in haskell, the 'threading' of the s value would be implicit (that's what the state monad does).
02:47joshua-choiAh, I never realized that
02:47psykoticlike i said, a vector of two elements: the first the integer it parsed (assuming success), and the second the remainder of the parsed string
02:47joshua-choiWell, I know about that—but I never thought about the list monad in that way
02:47psykotichehe
02:48Chousukeheh
02:48joshua-choiWell, I'm actually not seeing how your code works
02:48psykoticit annoys me when people poo poo monad. they're not some crutch, they're an abstracting way of very common boilerplate patterns like this.
02:48ChousukeI wrote a toy monad implementation which allowed extending ISeq to the monad protocol:P
02:48joshua-choiIt looks like it would return something like ([1 (3 2)] [3 (2)] [2 nil])
02:48Chousukeit was fun to write ((lift +) '(1 2) '(3 4))
02:49psykoticjoshua-choi: here's a quick example.
02:49psykoticlet's say the initial s is "42 8"
02:49ynefnoidi: when I tried that with lists (sorry for the late response) rather than a map, it didn't work -- is that because lists are evaluated immediately and maps aren't or something?
02:49psykoticafter binding [m s] (parse-number s), m would be 42 (the integer, not the string containing 42), and s would be " 8"
02:49psykoticafter binding [n s] (parse-number s), n would be 8, and s would be ""
02:49Chousukeynef: it's the other way usually.
02:49psykoticget it?
02:50Chousukeynef: lists can actually be lazy sequences, maps can't
02:51psykoticchousuke: although i think there is a map implementation in contrib that has lazy values. (lazy keys aren't useful since any operation on a map requires forcing all keys).
02:51ynefChousuke: ok, thank you :-)
02:51ynefI'm already learning a lot here :-)
02:52joshua-choiHang on, sorry. Let's say (parse-number "32 1") returns [32 " 1"]. Shouldn't the for macro iterate over both 32 and " 1"?
02:52psykoticsorry, i should emphasize that these functions actually return _seqs_ of parses
02:53psykoticso in the case of an unambiguous parse, it would return [[32 " 1"]]
02:53psykoticin which case the 'for binding' is really the same as a let
02:53psykoticbut when there are multiple parses, it tries all of them
02:53joshua-choiOh, we're dealing with ambiguous grammars now. Yay. :P
02:53psykoticwell, you mentioned you wanted to return a lazy seq of all parsers
02:54joshua-choiAh, I was unclear
02:54psykoticerr parses
02:54joshua-choiMore in the vein of regular expressions
02:54joshua-choiAs in...
02:54psykoticah. yeah, that's somewhat different. :)
02:54joshua-choi(find parse-number "32astienrat1aienrsitenst5") -> (32 1 5)
02:55joshua-choiThat would be the first step to...
02:56joshua-choisubstitutions like (substitute inc parse-number "s32arsien5##2") -> (\s 33 \a \r ...)
02:56joshua-choiSomeone actually requested that I implement something like that, like regexes
02:56psykoticright, i understand, the usual rex thing
02:56joshua-choiIt's hard, though :(
02:56psykoticwell, you can just try parsing starting at each prefix, et
02:56psykoticalthough it depends on whether you accept overlapping parses
02:57joshua-choiI don't want to do it at every character, though
02:57joshua-choiYeah, no overlapping
02:57joshua-choiI don't think that's what's usually wanted
02:57joshua-choiSo I was thinking that I'd have to use a state monad
02:57psykoticyou never _need_ to use a state monad :)
02:58psykoticusually explicit threading (e.g. the usual tail-recursive accumulator pattern) is better, if it suffices
02:58joshua-choiYeah...
02:58joshua-choiYeah.
02:58defnim getting some really radically variable (time ...) results from a function... it is operating on the same data but still manages to jump between 0.5ms to 18.0ms
02:58defneven with successive calls, so the JVM should be primsed
02:58joshua-choiAre you using -server? :P
02:58noidiynef, vectors can be used as functions, but lists can not
02:58noidi,([1 2 (+ 2 2)] 2)
02:58clojurebot4
02:58psykoticjoshua-choi: anyway, i have to do some stuff, i'm sorry i rambled on this stuff with minimal relevance to your actual problem, as it turns out
02:58noidi,((list 1 2 (+ 2 2)) 2)
02:58clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
02:58joshua-choiNo, it's fine
02:58joshua-choiYou helped a lot
02:59joshua-choiHave a good night
02:59joshua-choiIf that's where you live.
02:59psykotici'm in bali right now, it's 3 pm :)
02:59joshua-choiOkay. Good day.
02:59psykoticlater.
03:00defnfrom a performance standpoint should I be treating IPs as numbers or as strings?
03:01ChousukeI think usually they're stored as numbers, but of course you need the string representation sometimes
03:01noidinumbers are easier to validate
03:02defnim parsing from a logfile, so i need to have them as strings at first
03:02defnbut im wondering if at a certain point it makes sense to turn them into numbers
03:02Chousukeif you're going to do any processing on them, then yes.
03:03Chousukebut if you're just reading and counting occurrences or collecting other stats, maybe not.
03:03Chousukethough numbers take up less space than strings
03:03psykoticdefn: my answer would be, sequences of numbers :)
03:03Chousukepsykotic: actually an IP address is a single number. :/
03:04defnhere's basically the problem im struggling with... i have a big 300MB logfile. I go through and create a lazy-seq of lines which contain the word "Deny", now I would like to find all of the unique IPs which have been denied, so I think I am planning on creating a set which contains all of the uniques in the collection, finally, I am going to create a map where the keys are all of the elements of that resulting set
03:04psykoticChousuke: yeah, i guess storing 4 bytes is just base 256 and not much more useful than base 2 :)
03:04defnthen i am going to go back through the original data before it was turned into a set, and add up the occurrences in the map
03:04defndoes that sound like a good way to go about it or am I crazy?
03:05Chousukewhy create a set? you could just create a map.
03:05Chousukea key in a map is unique
03:05defnactually i dont think that's true
03:06Chousukeand if you need to associate data with it anyway, the set is kind of redundant.
03:06defn,{:a 1 :a 2 :b 3}
03:06clojurebot{:a 1, :a 2, :b 3}
03:06psykotiche's trying to count duplicates/uniques
03:06Chousukedefn: that's not a valid map
03:06psykotici think you want a multimap/multiset
03:06psykoticfortunately it's easy to implement by just having sequences as keys
03:06Chousukeor a map of IP -> integer
03:06psykoticerr, values
03:08defnhttp://gist.github.com/342052
03:09defnthat's pretty much as far as I've gotten -- kind of sad really heh -- whenever i add maps into the mix thing sjust get dog slow
03:15defnidk, maybe im out of my league here
03:27defnChousuke: any tips on implementing a multimap?
03:28defnohhhh!!! I think I see...
03:29defnsomething like (defn add-to-multimap [multi key val] (assoc multi key (conj (get multimap key #{}) val))) ?
03:58Mecaside from the fact that print is a bad choice is there anything wrong with: (defmacro debug-> [& xs] `(-> ~@(interleave xs (repeat 'print))))
04:05defnsorry to be a bother, but anyone have any experience with multimaps and want to help me out for a moment?
04:09MecMy net crashed, did I actually send that last question?
04:10defnMec you did
04:10defnaside from the fact that print is a bad choice...
04:11defni wish i could help you, but you seem like you're probably better off without my help :)
04:11Meclol ok
04:11MecI dont have a clue what a multimap is so we're even ;p
04:13defnMec -- im not 100% either ;)
04:13defnMec: FWIW I think it works like this...
04:13defn,{:a 1 :a 2 :b 2}
04:13clojurebot{:a 1, :a 2, :b 2}
04:14defnhaving two :a keys is a bad thing for our map, so what a "multimap" allows us to do, is to give :a the values #{1, 2}
04:14Meclooks like you might be able to just make each key a set
04:14defnMec: yeah i think that would be heavy handed though
04:15defnI'd like to keep a single unified sequence
04:15defnpreferably a map
04:19LauJensenMorning gang
04:20defnhi LauJensen
04:21defnLauJensen: I'm struggling a bit with building something in clojure which will parse a 300MB logfile for IPs in a specific context in each line in the file, and then create a map which contains the unique IPs in a map, where the value of the unique IPs == the number of times the IP occurs in the file
04:21defnthe file is approx 2,000,000 lines -- someone has suggested multimap, but im a bit fuzzy on implementation
04:22LauJensenWhich part of the implementation is tricky ?
04:23LauJensenI mean, are you designing or have you something running but needs improving?
04:23defni guess im just sort of stuck looking at stuart sierra's multimap code, not fully understanding it
04:23defnlet me show you where im at currently...
04:23LauJensenOk - I haven't checked it out myself. For 300 MB I would just go with a hash-map, would take 10 minutes to implement and 5 minutes to run
04:24defnLauJensen: http://gist.github.com/342095
04:24Mecya a map of sets, thats what i was thinking
04:25defnif you could offer a "next step" given my current code, that'd be very much appreciated, even a minor tweak -- i think i need a break
04:25LauJensenok, lemme look, M-x gist-fetch FTW!
04:26defnM-x gist-buffer :)
04:26defnerr region in this case :)
04:26MecHow come you need a multimap if youre just tracking IP and count
04:26LauJensenMec, not a map of sets, a map where the key is an int representing the IP and the value being the number of occurances
04:26LauJensenThat would be most lean I think
04:26MecYa that would just be a regular map
04:26LauJensenYep
04:27defnLauJensen: my feeling was that it would break given:
04:27defn,{:a 1 :a 2 :b 2 :c 3}
04:27clojurebot{:a 1, :a 2, :b 2, :c 3}
04:27defnthe multiple keys sort of scared me
04:27defnso i was led to multimaps/sets
04:27hiredmandefn: why would you need a multimap
04:28hiredmandefn: that is a, uh, bit of undefined behaviour in arraymap
04:28hiredmanyou should never have the same key multiple times in a map literal
04:29LauJensendefn: http://gist.github.com/342097
04:29hiredmanI'd suggest parsing using a line seq, then process the line-seq
04:29LauJensenI think you were over complicating. If you check out that simple formula, you can pass that a seq of the IPs and it will give you a map counting the number of occurances
04:30hiredman,(merge-with + {"10.0.0.1" 1} {"10.0.0.1" 1})
04:30clojurebot{"10.0.0.1" 2}
04:31LauJensendefn: and that make-seq-of-IPs could just be your re-find statement
04:31LauJensenWould that work for you ?
04:33lpetithello all
04:34LauJensenMorning lpetit
04:35lpetitMorning Lau Jensen
04:38defnLauJensen: sorry, im back -- looking...
04:43defnLauJensen: so in my code this would look something like (defn to-counted-map [] (reduce #(assoc %1 %2 (inc (get %1 %2 0))) {} (parse-outside-ips (find-lines-in-file "Deny tcp src outside" *logfile*))))
04:44defnLauJensen: that code is a lot faster than i had imagined...
04:44LauJensenSo you're up and running?
04:45defnI crashed my emacs, but it looks like it worked beautifully
04:45defnI will probably try something to increase performance somehow
04:45LauJensenGreat
04:45defnThanks much -- I'm surprised it was so simple :\
04:46LauJensen300Mb shouldn't be a problem, in my climate program (IIRC) nearly 50 GB were cooked down to a map which all came through a single reduce
04:46LauJensen(I'll admit, that could be optimized) :)
04:48defnI guess I've just seen things like ato's widefinder 2 implementation
04:48defnand it makes me want to optimize the hell out of things
04:49LauJensenI'll put my vote on the Optimize-Only-When-u-need-to strategy - its a tedious task
04:49LauJensenAnd for something which need to go very fast, you need to mutate and I'd like to avoid that 99.99% of the time
04:57defnEvaluation aborted that time...
04:58sparievis it true that with protocols it will be possible to monkeypatch existing java classes ?
04:58LauJensendefn: I think you'd want something between -Xmx768m and -Xmx1024m at the very least
04:59defnLauJensen: Xmx?
04:59psykoticspariev: no monkeypatching is involved, but there is open extensibility, yes, and in a much more controlled form than what passes for open extensibility in the ruby and javascript world.
05:00LauJensendefn: java -Xms512m -Xmx1024m -cp clojure.jar clojure.main yourscript.clj
05:00LauJensenThat'll give you 512 MB of Ram to start out with, and allow it to grow to 1 Gb
05:00defnah ha, thanks LauJensen
05:01sparievpsykotic: great! I should upgrade to 1.2 and add all c.c.strings fns to java.lang.String :)
05:03defnLauJensen: would it make sense to use something like atoms to speed this up?
05:04Meci have 2 macros: `(a b) and `(c b) is there a way to abstract out that the only difference is the first symbol (which is a macro)
05:04LauJensendefn: You're reading from a single file and everything is going through the same reduce pass, so if you want to speed it up, either paralleize that reducer pass, or make 2 - 4 chunks of the file and then finish with (merge-with + chunks)
05:05defnyeah i was thinking about chunking
05:05defnLauJensen: thanks again for all the help
05:05defni know it's sort of a boring topic :\
05:05LauJensennot at all - and it was np to help :)
05:24defnhow do i change the key in a map
05:25psykoticdefn: you can dissoc/assoc
05:26LauJensendefn: sure you need to ?
05:26defnLauJensen: well, im going to go through every value in the resulting map that we created above, and get the geolocation of the IP from a binary DB
05:27LauJensenYea?
05:27defnid'd like to have the IP, country code, and number of occurrences -- obviously i cant have all three in the map, right?
05:27defnmaybe a second map makes more sense
05:28LauJensendefn: depending a little on the size of the map, I think it makes sense to associate those data with the IP itself
05:28defncould you show me what the structure would look like in your mind?
05:29defn{{:code :ip} 5}
05:29defnsomething like that?
05:29LauJensen{:127.0.0.1 {:country "DK" :x y :z 3}}
05:30defnah right
05:30LauJensen(assoc-in m [:127.0.0.1 :country] "DK")
05:32defnLauJensen: wow you rule.
05:32LauJensenhehe :)
05:33Licenser1u
05:34defnuh oh Licenser_ is here
05:34defn;)
05:34Licenser_hi defn
05:34defngood morning
05:35sparievwhat's the most up to date tutorial on developing appengine apps with clojure/compojure ?
05:35Licenser_defn: I read your query and I know the 'problem'
05:37defnLicenser_: cool -- i figured you would since it looks related to the sandbox :)
05:41MecHow do you cast an object to a string?
05:41spariev,(str 123)
05:41clojurebot"123"
05:42Mecwell duh
05:42sparievbut it's not exactly a cast
05:42sparievmore like Java's toString()
05:50defnI keep getting a no matching method found for getCountry for class com.maxmind.geoip.LookupService
05:52LauJensenHow are you calling it?
05:53psykoticdefn: make sure you're passing the right argument. the compiler isn't very specific about what 'no match' means. it could mean no method by that name, or that the name exists but no overload of the right signature exists.
05:53Licenser_defn: the problem is that if the method you look for themself fail the sandbox nothing is found
05:54defnI (:import [com.maxmind.geoip LookupService]) (def database (LookupService. *database-path*))
05:55defnthen (defn country-code [#^String ip] (-> database (getCountry ip) (.getCode)))
05:55defnerr .getCountry ip
05:57LauJensenHave you tried manually calling (.getCountry li "Googles ip") ?
05:57defnOh yeah definitely, it runs fine in that context
05:57defn(.getCountry "200.200.200.200") => "XYZ"
05:57defnerrr (country-code "x.x.x.x") => "XYZ"
05:58defnit seems like it might be a thread issue
05:58_mstis ip definitely a string? not a keyword or something?
05:58defn_mst: could that produce a no matching method?
05:58_mstthe wrong argument type could, yep
05:59defnI mean, I created this sequence, and it doesn't seem likely
05:59LauJensendefn, that was psykotics point
05:59_mstyeah, just saw Lau's example above using a keyword. Wasn't sure if that's what you were doing too
05:59LauJensen,(name :127.0.0.1)
05:59clojurebot"127.0.0.1"
05:59defnit is a massive sequence though, it's possible one of the strings in the sequence is screwy
06:00Mecis it bad form to error check by exception rather than using if ;p
06:00LauJensen(try (get-country...) (catch Exception e "NO COUNTRY"))
06:01defnwhere are try/catch?
06:01LauJensenin cor
06:01LauJensene
06:02defn1.1.0? I don't have either of them :X
06:02LauJensen,(try (/ 5 0) (catch Exception e "Div by Zer0"))
06:02clojurebotLauJensen: Pardon?
06:02LauJenseneh
06:03LauJensenThey have been around as special forms for over a year
06:06lpetit,(doc try)
06:06clojurebotGabh mo leithscéal?
06:08defnmy mistake LauJensen && Company -- for some reason swank doesn't complete on those
06:08LauJensenok, I wonder what clojure bots problem is
06:09sparievtry is a special form
06:09psykoticLauJensen: de er skoere, de gallere
06:09lpetit,(doc def)
06:09clojurebotDENIED
06:09lpetit,(doc fn)
06:09clojurebot"([& sigs]); (fn name? [params* ] exprs*) (fn name? ([params* ] exprs*)+) params => positional-params* , or positional-params* & next-param positional-param => binding-form next-param => binding-form name => symbol Defines a function"
06:10lpetitfn is a special form, non ?
06:10Mecfn is just a macro
06:10defn,(doc pre)
06:10clojurebotI don't understand.
06:10lpetita special form currently implemented as a macro, I guess
06:11lpetit,(doc loop)
06:11clojurebot"([bindings & body]); Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein. Acts as a recur target."
06:11lpetit,(meta (var loop))
06:11clojurebot{:macro true, :ns #<Namespace clojure.core>, :name loop, :file "clojure/core.clj", :line 2985, :arglists ([bindings & body]), :doc "Evaluates the exprs in a lexical context in which the symbols in\n the binding-forms are bound to their respective init-exprs or parts\n therein. Acts as a recur target."}
06:11lpetit,(meta (var fn))
06:11clojurebot{:macro true, :ns #<Namespace clojure.core>, :name fn, :file "clojure/core.clj", :line 2931, :arglists ([& sigs]), :doc "(fn name? [params* ] exprs*)\n (fn name? ([params* ] exprs*)+)\n\n params => positional-params* , or positional-params* & next-param\n positional-param => binding-form\n next-param => binding-form\n name => symbol\n\n Defines a function"}
06:12lpetit,(source fn)
06:12clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
06:12lpetitok ok
06:12Mec,(clojure.contrib.repl-utils/source fn)
06:12clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/fn
06:13Mecweird
06:14LauJensen~source fn
06:14defn,(assoc-in {"1" 4 "2" 8} ["1" :country] "US")
06:14clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Associative
06:15defn,(assoc-in {:x 4 :y 8} [:x :country] "US")
06:15clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Associative
06:15defn,(assoc-in #{:x 4 :y 8} [:x :country] "US")
06:15clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.Associative
06:15defnbah
06:16LauJensen,(assoc-in {:127.0.0.1 {:country nil :code 404}} [:127.0.0.1 :country] "DK")
06:16clojurebot{:127.0.0.1 {:country "DK", :code 404}}
06:16LauJensenIf you're not doing a nested call, use assoc, if its a nested structure, use *-in
06:17defnwell it wasn't a nested structure, before, but now i need it to be
06:18Licenser_clicki :D
06:20licoresseI am looking for a swank-clojure library that allows me to dump strings onto a console in emacs for debugging purposes
06:20licoresseis there such a thing?
06:20LauJensen,(let [m {:127.0.0.1 5} ip :127.0.0.1] (assoc m ip {:occurences (ip m) :country "DK"}))
06:20clojurebot{:127.0.0.1 {:occurences 5, :country "DK"}}
06:22defnLauJensen: my god man i need to sleep this is getting worse and worse
06:22defni think ive done this before 3-4 times
06:22LauJensenslept?
06:22LauJensen:)
06:22defnin the last 7 days yeah ;)
06:22LauJensenOk, go to sleep, nothing worse than trying to code when the brain isn't playing along
06:23defn*nod*
06:23defnsee you all in a bit
06:23noidilicoresse, I don't have an answer for that question, but this might be relevant http://
06:23noidimeasuringmeasures.blogspot.com/2010/01/agony-of-clojurehadoop-logging-
06:23noidihttp://measuringmeasures.blogspot.com/2010/01/agony-of-clojurehadoop-logging-and-how.html
06:23licoressenodidi: thanks, I think something like that could be useful!
06:27noidilicoresse, but basically if you println from the main thread, it is shown on the slime repl in emacs, and printlns from other threads go to the terminal in which you ran "lein swank"
06:28licoresseI don't use lein swank, might be worth a try
06:28licoressebut, println does not emit anything on my repl
06:29noidilicoresse, then check the buffer called *inferior-lisp*
06:29licoressenoidi: oh, it does!
06:30licoresse:)
06:30licoressegreat!
06:31licoresseand all those exceptions! good stuff, now I am not blind
06:31noidihehe
06:31defnclojure.lang.PersistentHashMap cannot be cast to java.util.Map$Entry
06:31defnwhat could cause that?
06:36hoeckdefn: ,(key {})
06:36hoeck,(key {})
06:36clojurebotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry
06:37defncrap
06:38licoresseThis system is making me SO HAPPY!!
06:41powr-tocIs clojure.org hosted on wikispaces?
07:16MecWhats the best way to wait a certain amount of time and then do something?
07:19Mecoh nvm think i got it
07:20SynrGcurious. my jline history has some nulls in it for clojure and when i uparrow to those it messes up where jline thinks the cursor is (off by one for each null encountered)
07:20SynrGhow'd they get in there and how can i prevent this?
07:21Licenser_darn :(
07:24Licenser_hmm I've found a very sneaky problem
07:25Licenser_(read-string) only reads the first s-exp of a string, is there any way to read all of them?
07:27esjslightly off topic - but what do you guys use to format somebody else's html ? I'm trying to scrape a page and want to figure our the logical structure, but the text itself is. Emacs html mode doesn't seem to have an auto-format !
07:28Licenser_esj: I simply don't :P
07:28sparievLicenser_: maybe wrap whole string in parens ?
07:29esjLicenser_: i like your solution
07:30spariev,(read-string "(+ 1 2) (- 3 2)")
07:30clojurebot(+ 1 2)
07:30spariev,(read-string "((+ 1 2) (- 3 2))")
07:30clojurebot((+ 1 2) (- 3 2))
07:33Licenser_esj: thank you :)
07:33Licenser_spariev: but that alters the code sadly
07:37spariev,(doc read)
07:37clojurebot"([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?]); Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in* ."
07:38sparievmaybe you could try to wrap string in PushbackReader and feed it to read, then
07:39Licenser_spariev: *nods* that is my current atempt just that I have to handle the EOF error :P but thanks to your nice doc it seems I can skil this
07:39Licenser_skip
07:39noidiwhat's wrong with wrapping the string in parens?
07:40noidiit doesn't really alter the code, as you always get a list and always iterate through the items
07:40noidiso each item still appears as it was
07:41noidi,(str (read-string "foo bar"))
07:41clojurebot"foo"
07:41noidi,(map str (read-string "(foo bar)"))
07:41clojurebot("foo" "bar")
07:43Licenser_hmm I am not entirely sure what is the best aproach for a general sandbox
07:43Licenser_hmm hmm hmmm
07:43Licenser_but with () it weould try to evaluate the first expression as function
07:44sparievit just reads it, not evaluate
07:45Licenser_yes but next part is to evaluate it :P
07:46hoeckjust (map eval ....) to evaluate all toplevel forms ?!
07:48defnhttp://inspiration.sweyla.com/code/
07:48defnvery nice
07:48licoresseWhen running lein jar I get this clojure.lang.PersistentVector cannot be cast to clojure.lang.Named error, but no indication where the error occured other than inside compiler.java, is there a way to get a more descriptive message from lein, or something else?
07:49hoeckLicenser_: load does sth. along the lines of: http://gist.github.com/342217 (no need to wrap the string in parens)
07:50licoressels
07:51Licenser_hoeck: I figured to solve it on application level instead of library level
07:51Licenser_the sandbox tax a s-exp period
07:51Licenser_if you have more then on in you source you've to deal with that
07:52Licenser_since only the application can actually know how to handle this
07:52licoressemy project.clj file could have some nonsense, need to read on that...
07:57licoresseof course it was riddled with nonsense, never mind...
07:58arnihermannCan someone take a look at this macro weirdness: http://paste.pocoo.org/show/193221/
07:59arnihermannI can't figure out why it's trying to resolve a symbol
07:59arnihermannwhich is inside a map
07:59MecI'm playing around with clipboard manipulation, anyone know what might be wrong with http://gist.github.com/342221
08:00psykoticwhy does clojure does quasiquoting in the reader?
08:00psykoticit makes advanced macro-writing macros using nested quasiquotes a bit of a problem
08:00Chousukepsykotic: it's easier
08:01Chousukepsykotic: implementing syntax-quote as a macro is rather problematic
08:01Chousukepsykotic: at least, difficult enough that I gave up trying to do it :P
08:02Chousukepsykotic: I kept finding more and more corner cases.
08:02psykoticno-one said it was easy but there are papers out there like alan bawden's that everyone has read
08:02psykoticokay, maybe not everyone, but the semantics are well documented by now
08:03Chousukesyntax-quote does autogensyms and namespace resolution though.
08:03psykoticautogensyms is a 15 line macro
08:04psykoticin fact, i'm trying to implement it right now as a demonstration, and i'm running up against the apparent lack of support for properly nested quasiquotes
08:04Chousukemight be. though I ran into some nesting issues when I implemented it.
08:05Chousukenamespace resolution was horror though
08:05psykoticyeah, i can imagine that might be the tough part
08:05ChousukeI think I have that stuff on github somewhere
08:06psykoticright now i've been doing the ~'foo thing explicitly to punt on it
08:07Chousukehttp://github.com/Chousuke/clojure/blob/clojure-reader/src/clj/clojure/lang/reader/internal.clj
08:08Chousukethat probably could be simplified considerably but hm
08:08Chousukethat's just the function version that the reader uses. as a macro, it just doesn't work.
08:09arnihermanncan anyone figure out why clojure tries to resolve key in a map from inside a macro: http://paste.pocoo.org/show/193221/
08:10Chousukeyou're doing (symbol ":" ...)
08:11arnihermannah
08:11arnihermanncrap
08:11Chousukethe :y in the expansion is not a keyword, it's a symbol
08:11arnihermannI always fall into that trap
08:11arnihermannright
08:11arnihermannthanks
08:11arnihermannthis is the second time in 2 days or so
08:11arnihermannI manage to pull something like this off :)
08:11Chousukealso the double parens after the and look suspicious
08:12Chousukeit'll probably be your next error :)
08:12Chousukeyou probably meant to type (and ~@constraints)?
08:13arnihermannyup
08:13arnihermannChousuke: indeed
08:13arnihermannthanks :)
08:14hoeckMec: mind to paste more context, e.g. your imports and the Exception you get or a description of what went wrong?
08:14Mechoeck: sure 1 sec
08:17licoressemy project depends on some bitmaps, can these be included in the jar using lein?
08:18Mechoeck: http://gist.github.com/342221
08:19licoresseperhaps this is what :resources-path is used for?
08:26defnAt work on my laptop with 1/4th as much RAM and half as many cores I am able to run some code in my REPL, but when I get home and try to run the same thing I get Java Heap Space
08:27MecMust be running different jvm settings
08:28defnIs there any way to specify what slime uses?
08:29hoeckm-x customize-group swank-clojure
08:30Mecno match
08:31hoeckor m-x customize-variable swank-clojure-extra-vm-args
08:31hoeckand then set it to (list "-Xmx1G")
08:32hoeck(for 1 gig)
08:32hoeckbut works only if you start clojure from within emacs, don't know how lein handles it
08:32defn Debugger entered--Lisp error: (void-variable -Xmx1G)
08:32defnyou sure?
08:33defnoh nvm im sorry
08:33defnyou said (list "...")
08:34MecIs there any way to see if that setting is being applied?
08:34defnwe'll know on my next run ;)
08:35hoeckMec: jvisualvm show the jvm args, and maybe there is a System/getProperties entry which shows them too
08:36hoeckMec: your setContent code somehow works, at least after a call to .getContent a different Transferable is returned
08:36fogusMec: Thanks for the catch on my blog post. (that was you no?)
08:37Mecfogus: yes indeed, the same error was at the bottom but I didnt notice that one :D
08:38hoeckMec: oh, it actually works, it clears my clipboard (running jdk6 + ubuntu)
08:38Mechoeck: weird, it doesnt do anything on windows jdk6
08:38defnMec: that setting is definitely being applied
08:39defnI was barely cracking 200MB before and now it baloons up to 400 when the time is right
08:39hoeckbut it appears not to work within emacs, as emacs has its own yank-buffer and mostly ignores the clipboard or caches it
08:40Mecoh maybe thats why
08:40MecWow, it does work outside of emacs
08:40SynrGnobody have ideas about why jline in my repl has nulls at the ends of some lines, messing up cursor positioning?
08:41Mechoeck: thanks, i would have never thought to check it outside of emacs
08:41SynrGit's really annoying
08:42hoeckMec: yw
08:43Mecin a ns def can you do (import ...) or does it have to be (:import ...)
08:43hoeckSynrG: mhh, different encodings between your shell and clojure?
08:44SynrGlocale says en_CA.UTF-8 ...
08:44Chousukejava has its own encoding
08:45SynrGgnome-terminal says UTF-8 ...
08:45SynrGwhere does it determine encoding?
08:45Chousukeit's some property which I can't remember
08:45Chousukefile.encoding perhaps?
08:45Chousuke,(System/getProperty "file.encoding")
08:45clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding read)
08:45Chousukedamn :P
08:46MecMine says "Cp1252"
08:46Chousukeyou can change it on java startup via -Dfile.encoding=...
08:47SynrGmine says UTF-8
08:47SynrGso i think all is well
08:47SynrGany other ideas?
08:47SynrGwhen i check the jline history file for clojure ...
08:48SynrGsome lines have a single null at the end of them
08:48defnoh god thank you for showing me the jvm settings
08:48SynrGif i up-arrow to that line, the cursor is now off by one
08:48defnthis is so much less painful
08:48SynrGthe end of the line is the only place i have ever seen these nulls
08:48licoressedefn: when searching this channel, I saw that you had a question regarding where to put images/pictures when using leiningen, did you figure that out?
08:48SynrGand only on two out of several lines. i have no idea what might have caused them :(
08:49defnlicoresse: IIRC the resources dir is not working per technomancy
08:49licoressedefn: I see, any workarounds?
08:50defni havent looked into it to be honest, things may have changed recently
08:50defn,(first {:a 1 :b 2 :c 3})
08:50clojurebot[:a 1]
08:51licoressedefn: ok, I'll keep searching
08:51defnCan assoc/disassoc be mapped over a map?
08:52defnor does the [:a 1] upset it somehow?
08:54Mecseems like filter would be more natural, what are you trying to do?
08:55defnMec: take a very large map like: {"some-key" 5...} and turn it into {"some-key" {:count 5 :other-val 3}...}
08:57Mec(reduce (fn [m [k v]] (assoc m generate-sub-map)) {} your-large-map)
08:57defnI'm doing something like: (map #((let [mykey (first %) cnt (rest %)] (assoc % mykey {:count cnt :other-val (some-fn mykey)}))
08:59Mecok (Reduce (fn [m [mykey cnt]] (assoc m mykey {:count cnt :other-val (some-fn mykey)})) {} your-map)
08:59Mecand that will give you a resulting map, rather then a seq of maps
09:01defnMec: thanks so much that's exactly what I've been trying to put together
09:06Licenser_there we go
09:06defnMec: would it be too much to ask you to explain how that is put together? namely that destructuring...
09:06Licenser_clicky is waaay better now
09:06defnLicenser_: linki?
09:06Licenser_http://82.210.31.97:8080/
09:06Licenser_my playground!
09:07Chousuke(into {} (map (fn [[k v]] [k {:count v :upcase (.toUpperCase k)}]) {"foo" 3, "zonk" 4}))
09:07Chousuke,(into {} (map (fn [[k v]] [k {:count v :upcase (.toUpperCase k)}]) {"foo" 3, "zonk" 4}))
09:07clojurebot{"foo" {:count 3, :upcase "FOO"}, "zonk" {:count 4, :upcase "ZONK"}}
09:07Chousukeusing into is preferable to reduce because you get transients for free :)
09:08MecI thought into was only good for 2 maps
09:08Mecoh nvm, misread it
09:08Chousukeinto just conjs every item in a sequence into whatever you give as a first arg
09:09Chousukeand [k v] is a map entry
09:09Chousuke,(conj {} [:foo 'bar])
09:09clojurebot{:foo bar}
09:09sethsanyone for/against a clojure-dev discussion on reducing the difficulty getting started with Clojure?
09:09defn,(let [a [:b :c]])
09:09clojurebotnil
09:09defn,(let [a [:b :c]] a)
09:09clojurebot[:b :c]
09:09sethsthat seemed to be the main point behind the "chosen not to employ..." flashpoint
09:10sethsit seems like everyone is reimplementing bin/clj [.sh|.bat]
09:10sethsit might be nice to include a basic one (with jline!) as part of a download
09:11Mecclojure needs a simple editor written in clojure for noobies
09:11sethsMec: even before you get into the editor tho
09:11defnive heard good things about enclojure and clojurex
09:11ChousukeMec: I think that's false.
09:11ChousukeMec: good integration with existing editors is much more important.
09:11MecI've never used netbeans or enclojure or emacs, so i was kind of sunk until i spent a week learning emacs
09:12Chousukepeople are already likely to use them, and introducing another editor is just a waste of time
09:12sethsI would dearly love to see a kitchen-sink download for Clojure 1.2
09:12Licenser_the 'choosen not to employ' stuff was half bogus, I remember back when PHP was fresh it was a minor hell to get it running with apache and mysql propperly
09:12sethsincluding bin/clj with contrib & jline
09:12Chousukeif they are not using one of the well-integrated editors, then they have an incentive to learn one :)
09:12sethspossibly also copy of the docs
09:13ChousukeLicenser_: I thought it had some good points, but they were all horribly presented
09:13sethsjava -cp clojure.jar is great, but it's a little too simple maybe?
09:13Mecby all means there should be good integration, but having to learn to use a massive system just to start hacking isnt very fun
09:13Licenser_Chousuke: it had some horrible points but this one wasn't good, at least the example was very flawed
09:13Licenser_clojure apps are incredible easy to deplay way easyer then any other application I know of
09:13ChousukeLicenser_: also the fact that he announced he would ignore all replies sounded rather arrogant to me.
09:14defnI think part of the problem is that so many of the people who use currently use clojure are a) people who know how to teach themselves, hence emacs has not been a large barrier for a majority of the community. b) the tools that already existed in other editors, while somewhat quirky to setup for someone brand new to clojure, have a host of tools that is just hard to find in same mix in other editors
09:14Licenser_there is little easyer deployment as lein uberjar; java -jar app-standalone.jar
09:14sethsLicenser_: not so
09:14ChousukeLicenser_: uberjar creates bloat though ;(
09:15sethsor partly not so, Lein is still awkward on windows
09:15ChousukeLicenser_: might not be bad for a one-off deployment but it's not fit for distribution
09:15MecI'm dreading when i finally finish my program here and try to get it actually deployable
09:15Licenser_you also can just copy the content of lib
09:15defni didnt know to run standalone at first -- i think that's a bit confusing to newbies. i think it's also confusing to use java -jar xxx.jar, it seems sort of archaic even if it would be in many minds superfluous to include a bash script or something to launch java -jar app-standalone.jar
09:16Licenser_and yes lein is horrible to use on windows, but nearly everything is
09:16ChousukeLicenser_: unless, perhaps, you want to create some kind of a self-contained "platform" that is supposed to be updated as one.
09:16sethsyes, but manual dependency management is awful
09:16defn"patches welcome"
09:16ChousukeIt's sad that maven seems to be the best tool around to handle dependecies ;/
09:16defn;)
09:16Chousukeit's so damned verbose.
09:16Licenser_ Chousuke which is a good practice to guarantee compatibility and effects
09:16sethsChousuke: polyglot maven looked interesting
09:17sethshttp://polyglot.sonatype.org/clojure.html
09:17Chousukeand it fills the repository with all kinds of crap and doesn't provide means of trimming it, as far as I can tell.
09:17sethsthe "pom.xml" looks like a lein project.clj
09:17defnwhat makes dependency management so difficult -- why doesn't the clojars/lein combo work the same way things like ruby/gems/rake work?
09:17Chousukedefn: it does, doesn't it?
09:17defnwell, sort of
09:18Licenser_defn rubygems are great but also not perfect
09:18Chousukedefn: it downloads deps using maven.
09:18Licenser_one problem is that maven can be confusing
09:18chousermaven ant tasks, which is not maven itself I think
09:18Licenser_and that - as so foten - documentation is sparse for lots of stuff
09:19defnSort of ironic all the incidental complexity is in the configuration of your build environment...
09:20ChousukeI think maven should be good enough for Clojure use in the java world but some work on polyglot definitely needs to be done.
09:20sethsdefn: rake & gem would be more awkward if they were OS-specific scripts like lein
09:20Licenser_what would be good is a one shot installer for clojure that gets you running like clojure box
09:20Licenser_lein goes a long way but that it requires internet is .. ann oying
09:21sethsLicenser_: I'm all for a one shot installer, but that's a large task
09:21Licenser_yes I know but it'd be good
09:21sethsa zip file with bin/clj and contrib/jline on the classpath would be a nice midpoint
09:21Licenser_something that is like 1 file that gives you bin/clj bin/lein perhaps even emacs or something
09:22sethsClojureBox is that sort of thing for Windows
09:22Chousukea Clojure "SDK" installer could come with a dependency on maven (or bundle it) and some custom wrapper to provide access to common functionality with a more clojure-focused interface.
09:22rrc7cz-hmhas anyone looked at Ivy for dep management?
09:22sethsChousuke: I like the "sdk" term
09:22chouserjline has caused some people problems. I think a little GUI editor+REPL with contrib loaded would be nice.
09:23Licenser_well rubygems is su successfull since it lets you really manage deps with close to no hassle
09:23Chousukeseths: need something to differentiate from just installing the clojure core libraries
09:23chouserBut I need to look at labrepl -- that may be better
09:23Licenser_I still find leiningen way more complicated, error prone
09:23Chousukeseths: that would be the CRE :P
09:23sethsChousuke: CRE? sorry
09:23Chousukea pun on JRE
09:23seths:-)
09:23sethschouser: labrepl is a lein app
09:23sethsit's nice, the mini-browser demos very well
09:23defnleiningen is really nice. it's great. i think it still has a lot of potential. it just needs TLC. How long has it been around, anyhow?
09:24chouserdefn: about 3 weeks
09:24chouser:-)
09:24ChousukeI think leiningen could be retrofitted to work completely on top of maven though
09:24chouserChousuke: have you seen polyglot maven?
09:24Chousukeso even if you were to promote use of maven there's no need to just throw away lein
09:24Chousukechouser: yes
09:25cemerickah, I was about to beat that dead horse
09:25Licenser_the question is, is maven good?
09:25chouserLicenser_: perhaps. Or maybe the question is: what's better than maven?
09:25cemerickLicenser_: almost like asking, is the jvm good?
09:25ChousukeLicenser_: It's rather verbose but it's probably better than anything we can come up with by ourselves :P
09:25sethsrrc7cz-hm: never looked at Ivy, what is it built on?
09:26ChousukeLicenser_: and with polyglot people with XML-allergy can also use it.
09:26defnChousuke: you're a bigger man than i for admitting it
09:26Licenser_Chousuke: I'm not sure I'd like a gem like solution more\
09:26ChousukeI'm not really familiar with ruby gems
09:26defni've always liked ruby gems
09:26Chousukein my mind it basically does what maven does.
09:26sethsI looked at clojuresque a bit last night, not sure I like mixing Groovy into this discussion tho
09:27Licenser_Chousuke: it can do a bit more, you canspecify versions directly in your code, keeps stuff in a global place isntead of adding a gazillion libs to a folder and stuff like that
09:27SynrGnew information on my jline problem. it's not that nulls in the history cause the problem. it's that just exercising the arrow keys a lot eventually causes the problem. somehow a null is introduced, and then i'm left on a line that looks corrupted, and when i press enter on that line (which previously was valid) i get an exception
09:27sethsdefn: gems are pretty mature, even platform specific gems work out pretty well
09:27defnim far less familiar with maven than rubygems -- it was just such an easy to use thing when i started playing with gems.
09:27ChousukeLicenser_: versions how, exactly? :/
09:27SynrGso the nulls are an effect, not a cause
09:28ChousukeLicenser_: and you can have a systemwide repository with maven too
09:28Licenser_Chousuke: of a library
09:28Licenser_I can say something like (syntax m ight be off) require mylib, ">1.0.0"
09:28sethsanyone tried http://freshmeat.net/projects/rlwrap instead of jline?
09:28sattvikFor linux-based users, one very important thing is to integrate well into their chosen distribution. For Gentoo, a source-based distribution, maven has been a huge problem for integrating Java apps and libraries.
09:28ChousukeLicenser_: ah, well, that's ruby-specific I guess.
09:28Licenser_Chousuke: but as soon as I do lein deps it stuffs everything I need or it thinks I mighyt need when my grandmother dies next sunday in lib/
09:29ChousukeLicenser_: that's lein, not maven :/
09:29Licenser_Chousuke: why, I find it quite generic. if I've a library and know my application works with version 1.0.0-1.2.0 I should be able to say I tepend on this versions
09:29sattvikUltimately, Linux users probably want to install Clojure application similarly to other packages in their system.
09:30Licenser_gems allow executables
09:30Licenser_I can do say: gem install coderay
09:30Licenser_then I have a coderay executable I can use
09:30Licenser_another cool thing
09:30defngem install somegem, emacsclient "myfile.rb", require 'somegem', Blah.methods -- by contrast -- read disclojure.org, search on clojars.org, page through github, install leiningen, edit project clj, lein deps, lein repl, (use 'how.do.i.include.this.with.no.java.namespace.experience)
09:30SynrGaha! more specifically ...
09:31rrc7cz-hmseths: it's an apache project, much like Maven but without all the project management stuff. It's pure dep management. I haven't worked with it, but anyone looking for a maven alternative certainly should
09:31defnsome of that is just a part of these tools not having been around long enough, but the pain points on the clojure side far outweigh the ease of getting started with a funky library in ruby
09:31SynrG1. in repl with jline support, up-arrow twice. left-arrow to go back one character. now down-arrow, up-arrow, down-arrow again. each time i do that, the lines get progressively more corrupted.
09:32sethsrrc7cz-hm: thx, I'll check Ivy out some more
09:32rrc7cz-hmseths: the key thing is that it can draw from Maven repos natively, so it shouldn't set you back
09:32Licenser_gem list --remote alib > lists versions of this lib I can get; another nice feature
09:32SynrGcan anyone reproduce this? clojure 1.1, jline 0.9.94
09:32Licenser_I see why maven has an advantage, it lets you include java stuff too
09:33cemerickdefn: insofar as clojure is a JVM environment, that will be the case.
09:33Licenser_but it isn't nice, people want nice, one of the biggest reasons for ruby's sucecss is that a lot of stuff is just dead simple. Clojure is like that in some points but dep management is certenly not the case
09:34Licenser_I was trying to get a compojure app running yesterday I was trying like an houre to find the right versionm of the compojure jar and all the deps for it
09:34defncemerick: I disagree that some of that is necessary.
09:34Licenser_that is just a situation that is unbarable in a long run
09:34sethshmm: http://ant.apache.org/ivy/history/2.0.0/release-notes.html
09:34drewrruby's dep management is not any easier than clojure's, IMO
09:34Licenser_I want to do lein dep compojure -> gets me compojure and all the required libs for that
09:34sethsdrewr: how so?
09:34cemerickdefn: given typical tools, certainly not. Rubbing together twigs with a command line is another story.
09:34sethscemerick: lol
09:35SynrGwhatever it is, it's not just the repl. in jirb i can eventually cause the problem too.
09:35Licenser_drewr: I can do gem install rails and I get all I nee.
09:35ChousukeLicenser_: that can still be built on top of maven.
09:35sattvikI'd rather use Ivy than Maven. Maven is simply too bloated. The whole "downloading the Internet" is a bit of a put-off just to get a few JARs. And that's if your lucky. What if you are behind a firewall or proxy? Also, from a corporate development point of view, a lot of IT staff won't be happy with software that installs and updates other software automatically.
09:35cemerickseths: FYI, ivy is an evolutionary dead end, at least IMO.
09:35drewrLicenser_: I've had gem break plenty of things
09:35defncemerick: id be happy with one or two sticks.
09:36defnrubygems is just a big twig, too, after all...
09:36Licenser_drewr: sure it can happen but lein /mvn /whatever is doing it. Is just broken in that area
09:36Chousukesattvik: I don't think that'll be a problem. After all, Java is fairly successful
09:36Chousukesattvik: Java's dependency handling situation is no better, fundamentally, than Clojure's :P
09:37Licenser_I did not even know that java has a dependency handling ...
09:37sethscemerick: Ivy only offering dependency management is not valuable enough? Confused.
09:37cemerickLicenser_: it does -- maven. Seriously, it's the accepted standard.
09:38Licenser_cemerick: java is an accepted standard it stull sucks in my eyes :P
09:38defnleiningen with the ability to search and retrieve meta info on libraries, install versions from the command line, provide executables
09:38Licenser_at this note my spelling is a accepted standard and definetlyt sucks
09:38cemerickseths: No, it's not. How about handling deployment? Multiple build profiles? Massive plugin ecosystem?
09:39defnand a uniform easy-to-understand way of using libraries you download in your clojure code out of the box
09:39cemerickdefn: You're quite honestly talking about maven, as it sits today.
09:39sethsI was hoping to avoid unraveling this into a build tool discussion
09:39Licenser_All I say is, in the long or midrun, to be successful clojure needs something good to handle it's own libraries
09:39Chousukedefn: I still think all of that can be built on top of maven :P
09:39sattvikChousuke: I agree. But Java tends to live outside the ecosystem set up by Linux distributions and the like. With the Jigsaw project stuff, I hope that the situation will get much better and we can take the dependency management aspects out of build tools. Or at least, simplify the situation.
09:39defnoh -- well like i said, i dont know anything about maven, cemerick & Chousuke -- that's really what I'm looking for TBH
09:39sethsif no one hates the idea of discussing an official "clojure sdk" download with a bin/clj [bat/sh] I will post something to the dev list
09:39cemerickseths: I'm not sure how to avoid it. a la carte "systems" are painful, I don't want to deal with them anymore.
09:40sethscemerick: I wish we could all go bak to using GNU Make
09:40cemerickoh, fer sure! :-P
09:40defni am often upset that i need to open a .jar and find out how to use the library in my code -- i wish there was some way to make them more uniform. it'd be nice if other people's releases of a jar to clojars were kept in the same folder instead of being strewn about
09:40Chousukepsh, shell scripts!
09:40sethsor even "imake", an abstraction over makefiles
09:41cemerickseths: oh, you were being serious...
09:41sethscemerick: yes, I am a GNU Make fanboy. served me well on a multi-platform C++ project years ago
09:41Chousukedefn: I think that might just be lein silliness. Maven really does put the things it downloads just where you tell it to put them. that can be a private repository or a global one.
09:42sattvikThe thing I like about lein is that it has the potential to define a simple interface, the 'project.clj' file. You could then write different back-ends to handle the dependency management.
09:42cemerickseths: yeah, not sure that's an endorsement. :-)
09:42seths,#($%)
09:42clojurebotjava.lang.Exception: Unable to resolve symbol: $ in this context
09:42cemericksattvik: you're looking for polyglot maven. Regardless, don't confuse syntax and such with the platform underneath.
09:42defnChousuke: Hmm, maybe we're talking about different things?
09:42sethser
09:42seths,#(&%)
09:42clojurebotjava.lang.Exception: Unable to resolve symbol: & in this context
09:42Chousukedefn: I'm not sure. maybe :P
09:42sethssigh
09:42seths,#(%&)
09:42clojurebot#<sandbox$eval__7906$fn__7908 sandbox$eval__7906$fn__7908@15e8c9d>
09:42Licenser_Chousuke: the problem wiuht ein here is it puts the stuff it downloads in ~/.m2 and <project>/lib
09:43defnChousuke: I don't like downloading enlive [enlive "1.0"] (in my project.clj), and then finding out when i get to my repl that it's net.cgrand.enlive-html
09:43ChousukeLicenser_: why it puts things under /lib I don't understand :/
09:43defnas a newb that was an "ugh" moment for me
09:43Chousukedefn: maybe there could be a "lein describe" command
09:43defnthat'd be nice
09:43Licenser_Chousuke: even worst it does not delete old stuff
09:44mattreplthe local repo, ~/.m2, is useful for using custom builds of project dependencies
09:44cemerickdefn: clojars is certainly not the tidiest maven repo, for sure.
09:44Licenser_if you update a lib and don't delete the old one by hand it seems to randomly decide which one to use
09:44ChousukeLicenser_: that's my primary complaint about it.
09:44ChousukeLicenser_: but I suppose it wouldn't be impossible to write a mvn cutleaves plugin
09:44defnyeah it's a big annoying cemerick -- like 10 versions of compojure up there, all in different directories, you need to do different things to use them in your project, etc.
09:45Licenser_I don't mean to say how it is bad how it is, or that we need to reinvent the wheen just that there is a lot of room for improvement and a good depmanagement/build platform is incredible important
09:46cemerickdefn: See, if compojure had a regular maven pom, it would have specific and canonical coordinates, as well as a definition of where to deploy it when cgrand did a build. Just sayin.
09:46ChousukeAnother thing maven has done wrong IMO is that it defaults to downloading things from the internet.
09:46defnOn that note it's worth mentioning again that lein is really good for how young the project is.
09:46defncemerick: interesting. i like that.
09:47cemerickdefn: this is my point. All this stuff is *built already*.
09:47defnI've heard people in here from a couple different linux distro communities asking how to build a clojure package without using the internet
09:47cemerickwelcome them to the 21st century.
09:47stacktraceris there a way to say "(if x x :default)" that doesn't require repeating x?
09:47Chousuke(or x :def)
09:47defncemerick: heh i think it is the result of build guidelines they are following -- i tend to agree with you
09:48stacktracerChousuke: wow, that seems obvious now that you've said it
09:48stacktracerthanks
09:48cemerickdefn: otherwise, maven has an offline build mode (-o)
09:49defnso what is polyglot maven, how does that remove the "suck" from maven? I've heard so many snarls about maven over the last 8 months...
09:50Chousukedefn: it's really just for the xml-allergic
09:50Chousukedefn: allows you to write the pom files in any language.
09:50defni don't like XML -- noisy lisp etc. etc.
09:50defnChousuke: ah
09:51defndoes everyone need to install some thingamajig to use that functionality?
09:51Chousukewell, the polyglot plugin, probably :P
09:51defnso removing a pain point, but adding another layer of complexity
09:52Chousukebut you probably can do it by writing your pom in clojure and automatically translating it to XML
09:52cemerickdefn: try to not base your tool choices on heresay. Otherwise, you'd be avoiding the LISP relics.
09:53ChousukeI think XML is an okay format for transporting pom files but it's not a good format for editing them ;/
09:53defncemerick: you seem to get the impression that I'm not willing to use maven. Everything you've said makes a lot of sense to me, and if the XML crud is removed I think it'd be great.
09:53defnI was just echoing a sentiment I've heard many times lately
09:53defnfor sake of argument
09:53ChousukeXML is disparaged more than it deserves sometimes
09:54defnI don't have any problem with key/value pairs, but after you've seen how easy it is do build a similar datastructure with a syntax that makes it easier to edit, it does seem a bit archaic and weird
09:54cemerickdefn: Sure. I'd only say, care about what really matters. What really matters with build tools is ecosystem/community and capability. Stuff like XML vs. sexprs is not a valid discriminator given the relative importance of other factors.
09:55defncemerick: well said
09:55Chousukeits value is mostly in the vast number of tools surrounding it though. parsers, automatic syntactic and semantic validators based on schemas, XML transformers etc.
09:57defnChousuke: I think the hardest thing here is trying to find a balance between people new to clojure, and people who want to really push the envelope
10:01defnnot even to push the envelope... This is going to come off as incredibly subjective and perhaps a bit naive, but, I just feel like there are a lot of opportunities for a new language to define their own culture
10:01defns/their/its
10:02alexykI launch 8 agents on an 8-CPU box and give them chunks of a database to process. Each will hold a vector of results. How do I do a barrier sync to get all chunks when ready and concat them?
10:03sattvikIn my opinion, I think what is most helpful for people new to Clojure is to be able to install Clojure the same way they do other software. For Linux users, this means using apt-get, emerge, or whatever their distro uses. For Windows users, it means having an installer that will install a JRE, the Clojure JARs, and a link on the desktop to the REPL.
10:03cemerickdefn: given that clojure is at its roots a hosted language, it only makes sense to use the orthogonal tools provided by the given host or prevalent in the community. I presume ClojureCLR will use NAnt or whatever the build tool of choice is in .NET-land.
10:04mattreplalexyk: await? http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/await
10:04defncemerick: Is Maven a JVM build tool or a Java one?
10:05alexykmattrepl: thx!
10:05cemerickdefn: decidedly the former.
10:05defnDoes jruby use ant?
10:05alexykdefn: there'sa polyglot maven now too
10:05alexykhttp://polyglot.sonatype.org/
10:05alexykhas a clojure logo in it
10:05headiusjruby uses ant, but partly through rake+ant integration
10:06headiushopefully eventually entirely through rake
10:06cemerickdefn: I've no idea what they use. But then, they have an existing community they want to be compatible with.
10:06defnsee that seems like something we want headius, i dont know the answer...
10:07sethsok, message was posted to the dev list. Hope to provoke some useful discussion.
10:08headiusI think our next step is to do maven integration as well, but I'm partial to just using ant and structuring my projects the way I want to
10:11sattvikheadius: That's the thing. Doubtless, Maven is a powerful tool; but it's very complex. I prefer to keep things simple and transparent, and Ant provides that for me.
10:12headiusin an effort to help java folks adopt jruby, we're integrating all that crap...but I haven't swallowed the maven pill yet
10:12headiusmaybe a jruby-based maven tooling would change my mind
10:12headiusthe rake+ant stuff is really nice
10:13cemerickFunny enough, I had my own irrational maven hatred until last fall, ~ 14 months into using clojure.
10:13cemerickThat, as a way of saying, maven is a generalized build solution, not a Java-specific tool.
10:14defnheadius: that sounds like the ideal solution to me just because it lets you "ease" into ant, but it's still ant.
10:15headiusdefn: we also do two-way integration, which I don't think any other ant wrappers do
10:15defnThis discussion started on "new users". I think if new users have no prior knowledge of java they should still be able to pick things up and have some idea of what's going on
10:15headiusso you can call both ways
10:16defnheadius: cool
10:16defnheadius: did you know a lot of java prior to picking up clojure?
10:16headiusheh
10:16chouserheadius: have you ever heard of ruby?
10:17chouser;-)
10:17headiusI don't really use clojure, I'm just a spy from ruby-land
10:17headiusand yes, I've done a bit of java
10:17headiusI'm one of those rare polyglots that doesn't think java's all that bad
10:17defnheadius: I remember your from #ruby-lang sometime back -- c nutter?
10:17headiusdefn: yup
10:17defnah, good to see you again :)
10:18sattvikcemerick: The #1 problem is that it's a build tool that takes a lot of custom development to integrate it into a larger building ecosystem. Maven has been a big problem with integrating more Java packages into Gentoo. It's too difficult to get Maven's dependency management to cooperate with Gentoo's. It's probably possible to create the appropriate plugin or something like that, but it's not a project anyone has taken up.
10:18defnheadius: are you sympathetic to the "use maven, but give people an easy way to do maven without doing maven"?
10:19headiusyes
10:19cemericksattvik: Apologies ahead of time, but *everything* has trouble cooperating with Gentoo!
10:19headiusI think the danger is in straying too far from maven proper, like buildr seems to do
10:19headiusyou don't want to reimplement all of maven in another tool...it would be better to just wrap it with a better exterior
10:19defn headius has rvm caused any spike in the number of people using jruby, or has it been growing consistently regardless?
10:20headiuslike git wrappers do for git
10:20headiusdefn: hard to tell
10:20headiusjruby can be fetched from lots of locations
10:20defnheadius: ive been using jruby all the time. i dont see why id use ruby proper at this point...
10:21cemerickcemerick: More seriously, gentoo is such an edge case in so many ways. If jvm stuff can be made to work there, then so can clojure, but until that's the case, us changing any kind of approach to accommodate gentoo seems to me like a spectacular distraction.
10:22defnafter i saw your performance graphs practically a year or maybe two years ago now, i was fairly skeptical, but it's just ruby -- and it's fast. i really love it. :)
10:22Licenser_jruby runs on more platforms
10:22defncemerick: yeah i tend to agree. RHEL, Ubuntu -- those take precedent over gentoo IMO.
10:22Licenser_getting ruby run on sparc solaris is a seriouse PITA
10:23rsynnottcemerick: what, the JVM doesn't work on gentoo?
10:23headiusjruby's arguably the best windows ruby right now also
10:23cemerickrsynnott: No idea.
10:23headiusand we get the weirdest bugs
10:23cemerickFrom what I hear, a lot of stuff doesn't work on gentoo. *shrug*
10:23headiusI thought nothing would top the EBCDIC bugs until OpenVMS bugs started to show up
10:23rsynnottoh, it's just a build system impedence mismatch
10:23defnby a long shot headius. i had to slap something together on windows the other day and I use jruby. it's the default in netbeans now isn't it?
10:23headiusdefn: I think it always was
10:24defnah, either way, very cool :)
10:24sattvikcemerick: Well, I am biased, but I'd argue that's FUD. And Gentoo isn't the only the system to use source-based packages. There is BSD's ports and Macports. Java works just fine on Gentoo, and I have clojure/clojure-contrib ebuilds that work just fine, too.
10:24cemerickdefn: Windows, OS X, Ubuntu, RHEL are the key targets. Beyond that, one has to assume people know what they're doing, and are happy to fix stuff that goes awry.
10:24underdevrsynnott: i'm fond of this one lisp dialect on that runs on the jvm
10:25rsynnottsattvik: however, not all things on MacOS are expected to be built using ports
10:25SynrGheadius: hi
10:25headiusyo
10:25SynrGheadius: speaking of OpenVMS bugs :)
10:25rsynnottsattvik: is the problem just that gentoo's build system doesn't get on with maven?
10:25SynrGBen Armstrong, OpenVMS bug submitter
10:25cemericksattvik: Fair enough. Of course, macports is a horrible, miserable thing to work with. Regardless, if we have a solution that addresses the four platforms I just mentioned, but gentoo ends up being out in the cold, I can't say I'd care much. Sorry again. :-|
10:26SynrGheadius: incidentally, clojure runs on VMS too :)
10:26headiusSynrG: hah, hello there :)
10:26rsynnott(it was a java thingy)
10:26headiusyes, I'd assume clojure runs on openvms too
10:27SynrGhaven't done anything with it yet, tho. and jruby ... well, that's going to be a big project for us to make everything work. i'm just hoping Uso Thierry can do things with it before I have to dirty my hands with it
10:28headiusif I had a way to help, you know I would :) some bugs are out of my reach
10:28SynrGsure. well, with Uso interested, at least we're no longer alone like we were with the MRI port
10:29headiusI think the bugs you filed were largely in the lower-level process stuff we do, which I don't think any other JVM langs have attempted
10:29headiusit's fun and exciting to implement libc-like process control on top of java.lang.Process...no really
10:29SynrGi have since then learned a thing or two about the controls for filename handling
10:29SynrGin a different context, umm ...
10:30headiusI never knew vms, so everything in that bug was totally baffling to me
10:30headiusI think enebo understood some of it
10:30sattvikrsynnott: The problem is that Gentoo and Maven is that they both do dependency management. If you're just installing binary jars, it doesn't really matter what Maven does since you don't really need it to install programs that are built with Maven. However, since Gentoo compiles all programs, it needs to use Maven to compile. Unfortunately, Maven doesn't know about all of the jars already installed on the system and tries to download t
10:30Licenser_to distract you people: http://82.210.31.97:8080/index
10:30rsynnottsattvik: but a gentoo user could happily just install clojure outside the gentoo package management system, no?
10:31SynrGheadius: ah, solr!
10:31SynrGlucene, to be more precise
10:31rsynnottthis sounds more like a problem for the gentoo people to fix than a reason not to use maven
10:31SynrGit was misfiring on filenames with no extension
10:31cemerickrsynnott: Indeed.
10:31SynrG"filename" would end up as "filename."
10:32chouseractually, that's a problem for every runtime-specific dep manager (gems, cpan, etc.) on every distro (redhat, debian, gentoo)
10:32chouserafaik, each combination is "solved" slightly differently, to slightly different values of "solved"
10:32Mecwhat is wrong with (reduce #(assoc %1 (inc (get %1 %2))) {} coll) that im getting NullPointerException?
10:33headiusSynrG: ahh interesting
10:33SynrGheadius: anyway, your appearance here mentioning OpenVMS reminds me to revisit the bugs to see if any of what i learned with lucene can be applied to those bugs
10:33sattvikrsynnott: Yes, as with any distro, a user can do whatever they want independent of the build system. However, it'd be ideal if it could be integrated into the system.
10:33headiusSynrG: yes, it would be nice to get those resolved at some point :)
10:33headiusit was definitely path-parsing in at least one of the bugs
10:33SynrGyup
10:33headiusthe other was the use of sh to run subcommands I think
10:34SynrGmhm
10:34rsynnottsattvik: but that would be an issue important largely to people who use gentoo (which is not many), and so something that the gentoo people should sort out rather than expecting third parties to accomodate something with minimal market share
10:34Mecnvm there was a lot wrong with that, time for bed methinks
10:34SynrGheadius: hmm, and i have clojure to cross-check these things with. surely there are equivalent constructs?
10:34sattvikchouser: Exactly, there are Gentoo wrappers for dealing with CPAN, CTAN, and Ruby, at least. Maven hasn't been tackled yet.
10:35headiushttp://jira.codehaus.org/secure/IssueNavigator.jspa?reset=true&amp;jqlQuery=project+%3D+JRUBY+AND+%28summary+%7E+openvms+OR+description+%7E+openvms+OR+comment+%7E+openvms%29
10:35headiuslooks like there was at least one other person who filed openvms-related bugs
10:35SynrGheadius: speaking of jruby, you wouldn't happen to know why jline sometimes cocks up and starts dropping characters. this seems to affect both clojure and jirb on debian sid.
10:36headiusI do not...somehow I became an admin on jline though, so it's probably my fault in some way
10:36sattvikrsynnott: Perhaps, but so long as I have a voice, I'll try to push for solutions that are easy to integrate into source-based distros.
10:37SynrGheadius: my reproducible test case: start clojure repl. up-arrow a couple of times. left-arrow once. then a bunch of up/down/up-arrows until the lines start to get corrupted
10:37SynrGsame with jruby only it took a bit longer to eventually drop characters
10:38headiusI think you or someone else brought this up and it seemed to only be a problem in xterm or rxvt
10:39headiusI was able to reproduce it using OS X xterm, but not Terminal
10:39headiussome terminal emulation oddity wrt jline
10:44djpowellWith maven, if I want to do something like run a java command-line to generate a file that is required by the build, how would I go about doing it?
10:44SynrGheadius: aha. yeah, i was beginning to investigate this, but so far had only tried: gnome-terminal, lxterminal, xterm
10:44djpowellI get the feeling that it is more than one line of code?
10:44SynrGheadius: my next test was going to be in console
10:45defn,(type {:x 1})
10:45clojurebotclojure.lang.PersistentArrayMap
10:47SynrGheadius: nope. screws up in console too (TERM=linux)
10:48headiusdjpowell: it's probably eight lines of XML, knowing maven
10:48defnare big arraymaps coerced into hashmaps?
10:48defnpersistentarraymaps vs persistenthashmaps
10:49headiusgotta run, bbl
10:50Licenser_hmm now to join a list?
10:50defncons, concat?
10:50RaynesI think you want concat.
10:50Licenser_I mean like ["a" "b" "c"] -> "a,b,c"
10:51RaynesOr flatten.
10:51sattvikLicenser_: interpose?
10:51defnclojure.contrib.seq-utils
10:51defn /flatten
10:51Raynes,(apply str (interpose "," ["a", "b", "c"]))
10:51clojurebot"a,b,c"
10:52Raynes,(clojure.contrib.seq-utils/flatten ["a" "b" "c"])
10:52clojurebot("a" "b" "c")
10:52RaynesDoesn't do what he wants here.
10:52Raynes:(
10:52RaynesI mean, it wouldn't anyway without interposing ",", but still.
10:52Licenser_I like the interpose thing
10:56RaynesLicenser_: By the way, good morning (depending on what time it is wherever you live. ;))
10:56defn,(let [[x y z] ["a" "b" "c"]] (str-join "," [x y z]))
10:56clojurebotjava.lang.Exception: Unable to resolve symbol: str-join in this context
10:56alexykhow do you update a global (def *a* 1) from within a defn?
10:56Licenser_afternoon :(
10:56Licenser_:)
10:56defn,(use 'clojure.contrib.str-utils)
10:56clojurebotnil
10:56defn,(let [[x y z] ["a" "b" "c"]] (str-join "," [x y z]))
10:56clojurebot"a,b,c"
10:56Chousukealexyk: you should not
10:56Chousukealexyk: but alter-var-root
10:57alexykChousuke: ok
10:57alexykbut I won't :)
10:57Chousukeunless you mean dynamic rebinding, which is sometimes useful
10:57Chousukeusing the binding macro
10:58alexykI just want to declare some (def *agents* []) on top, and do actual (<reassign> *agents* <actual creation>) in a defn
10:58alexykso I have *agents* in the repl for inspection
10:58Chousukealexyk: that might be an okay use for alter-var-root
10:58alexykChousuke: I'm relieved :)
10:59Chousukealexyk: just make sure not to make it a habit. :P
10:59alexykI'll try :)
11:00Chousukeanother way to do it might be to write a function that returns a vector of agents and then just do (def *agents* ...) though.
11:08gkoHello
11:10lpetitchouser: the community is wanting (also has not yet understood it's what it wants) your lightweight graphical REPL (with auto-indentation, bracket matching, and code completion, of course :-) ) to be delivered as an alternative to the current clojure.main & clojure.contrib.repl_ln textual REPLS !
11:12Licenser_lpetit: tgat wouold be cool
11:13gkoHow do you define functions that calls each other? I have this exception: "Unable to resolve symbol: decode-grouped-values in this context" because some function is calling decode-grouped-values, which itself calls this function...
11:14lpetitLicenser_: yes, because the other great current approach for noobs is : everything packaged in a zip, but those zips would be no less than a hundred megabytes, and that could stop noobs too :-)
11:14Chousukegko: declare it first
11:14Chousukejust (declare foo)
11:14conradbarski...
11:15gkoChousuke: OK
11:16conradbarskiHi- Anyone know a paredit trick for changing bracket types in a complex expression? i.e. to change "(((2 2) (1 1)) 3)" to "([(2 2) (1 1)] 3)" or similar changes...
11:16gkoChousuke: thanks!
11:17foguslpetit: Have you seen the Beanshell graphical REPL? It's quite nice (caveat... I've only played with it briefly). I would love to see something like that for Clojure
11:17lpetitNo, haven't seen it
11:18lpetitfogus: quick link ?
11:18lpetit~google Beanshell graphical REPL
11:18lpetit~search Beanshell graphical REPL
11:18hiredmanoh
11:18hiredmanI need to auth clojurebot
11:19hiredman ~google Beanshell graphical REPL
11:19hiredman~google Beanshell graphical REPL
11:20clojurebotFirst, out of 248 results is:
11:20clojurebotA Taste of 2.8: The Interactive Interpreter (REPL) | The Scala ...
11:20clojurebothttp://www.scala-lang.org/node/2097
11:22_invisGuys plz tell me how to set emacs working directory
11:23lpetit~google Beanshell scripting environment
11:23clojurebotFirst, out of 4110 results is:
11:23clojurebotBshServlet and Servlet Mode Scripting
11:23clojurebothttp://www.beanshell.org/manual/servletmode.html
11:23lpetitarg
11:23cemerickmmm, I'm going to make this clojure+maven post into a screencast.
11:23_invisthanks
11:23foguslpetit: http://www.beanshell.org/manual/desktop.html
11:24lpetitfogus: thx
11:25foguslpetit: np. So you're going to write something like this for Clojure right? ;-)
11:25lpetitfogus: grmlml
11:25lpetitfogus: yes, after having finished ccw :-p
11:26foguslpetit: So you're saying there's a chance? :p
11:26lpetitfogus: If, like cats, I have several lifes :-)
11:27lpetitfogus: I guess I remember chouser talking about something like that, once
11:28lpetitfogus: something using minimal dependencies but what the plain JDK API provides (aka swing)
11:28fogusChouser's REPL-thingy could probably serve as the basis of a Beanshell-type environement
11:28fogusRight. Nothing external.
11:28lpetitfogus: so that a handful of clj files suffice to have something good enough for testing the language/working on small projects
11:30fogusMy thoughts exactly. A no-thought way for new-comers to play with Clojure out of the box, but that is more than just the raw REPL.
11:31zaphar_psany moderators for the clojure mailing list on here right now?
11:31fogusOhhh, that happens to work one all OSes. But not an IDE
11:33_invisGuys plz tell me how to set emacs working directory
11:33noidi_invis, M-x cd
11:33_invisomg
11:33noidibut in emacs the working directory is per-buffer
11:33_invisthanks
11:34noidiand the default in each buffer is the directory of the file that you've opened in that buffer
11:34_invisok
11:34RaynesYour working directory will be the directory of the file you're currently working on, afaik.
11:34noidiyes, unless changed with M-x cd
11:35noidiusually when I have to do something with a specific working directory, I just visit the directory in a new buffer with C-x C-f and then do the thing with the buffer active
11:45arohnerwhat's the difference between (foo bar) and (#'foo bar)?
11:45arohnerI'm trying to write a macro, and I think I need the first, but I'm getting the second
11:46arohneroh, that's a var...
11:48Licenser_okay anyone interested in trying to break a sandbox?
11:48zmilalpetit and fogus - this shell seems to be very similar to newLisp's GUI
11:49lpetitzmila, fogus: if only eclipse was not based on swt . Or if only the JVM shipped with both swt and swing :-)
11:51fogusSounds like a JSR is in order... then we just wait a decade or so.
11:52joshua-choiIf I have (defn f [s] (when (seq s) (lazy-seq (cons (inc (first s)) (f (nnext s)))))), does f hold onto s's head while computing?
11:53joshua-choiDo I need to surround (f (nnext s)) with a lazy-seq form too?
11:53RaynesLicenser_: Can we add lein-swank as a dev-dependency?
11:53Licenser_Raynes: of cause
11:53hiredmanclojurebot -> hornetq -> openvpn to laptop -> growl notifications of irc
11:53hiredmanready for the enterprise
11:54chouserheh
11:54RaynesLicenser_: Thank you.
11:54lpetitchouser: heh
11:54Licenser_ah nothing to thank me
11:54Licenser_:)
11:55_invisIs anyone here know why I cant slime-connect to Labrepl ??
11:55_invisHave this message: open-network-stream: make client process failed: connection refused, :name, SLIME Lisp, :buffer, nil, :host, 127.0.0.1, :service, 4005
11:56lpetitjoshua-choi: I guess your code should look like (defn f [s] (when-let [s (seq s)] .... ) , but this does not answer your question :-)
11:57lpetit,(doc nnext)
11:57clojurebot"([x]); Same as (next (next x))"
11:57lpetitjoshua-choi: I'm pretty sure your code doesn't hold onto s head
11:58Licenser_so people who are named lloyd are actually (loyd (loyd))?
11:58lpetitLicenser_: yes, they were created with the Y operator :-p
11:58Licenser_:D
11:59somniumso that's what the Y is for...
12:01joshua-choilpetit: Hopefully. But how can that be? s is referred to inside the lazy-seq code...When (f (nnext s)) is called, s is still in the lexical scope.
12:07lpetitjoshua-choi: so you created a Seq instance with an object for first ready to be computed (holding a ref to s), and an object with code for computing the next seq, also holding s. You call next/rest on the seq, and you create the next Seq instance, which will hold the (nnext s) head
12:09lpetitjoshua-choi: make the cal to (lazy-seq) be the first form of your method body, too
12:10Licenser_hey defn the way to fix the 'nothing found' problem is rather simple, if the sandbox test returns an empty list just show the other list ;)
12:10lpetitjoshua-choi: (defn f [s] (lazy-seq (when-let [s (seq s)] ...
12:10joshua-choiAh, right...the lazy-seq form returns immediately. But s is still in lazy-seq.
12:10joshua-choiWould it be better if I (let [first-thing (first s), remainder (nnext-s)] (lazy-seq (cons (inc first-thing) (f remainder))))?
12:12lpetitjoshua-choi: not needed, take a look at "take" implementation:
12:12lpetit~source take
12:12Licenser_woooh why is clojurebot pink?
12:20SynrGLicenser_: notice
12:20Licenser_SynrG: what should I notice?
12:20Licenser_ahhh sneaky pink people around!
12:20SynrG/notice #clojure feeling in the pink
12:21joshua-choiI get it now, I think. When the lazy seq evaluates itself later, whenever it's needed, it evaluates (f (nnext s)), creating another lazy sequence, but the head of s is free to drop off, since (f s) has already been called a while back.
12:25lpetityes
12:26SynrGhmm. a debian colleague just indicated she has uploaded a cute game written in haskell for debian: http://raincat.bysusanlin.com/
12:26SynrGclojure needs something like this :)
12:28somniumwow, it looks like a Miyazaki Haiyou short film
12:29somnium/s/Haiyou/Hayao
12:30SynrGnext she's packaging something by the same authors, this time in "Stackless Python using SFML" (huh?) ... anyway: http://hobocat.bysusanlin.com/
12:30SynrGsomnium: ya :)
12:31SynrGsomnium: my little girls, ages 8 and 12, really love raincat. though i don't think i could effectively use that as a hook for learning haskell :)
12:31Licenser_but we have clicki! :P
12:31somniumSynrG: I can see how that would be challenging :)
12:33somniumthat reminds me of a yegge blogpost comparing Scheme, ELisp, and CL. Scheme was a sports car with no radio or AC, ELisp was a Subaru compact, and CL was Howl's Magic Castle.
12:33ChousukeSynrG: if they manage to learn haskell, they should have little trouble in maths class ;P
12:33SynrGhehe
12:33somniumwhich raises the question, what vehicle is Clojure?
12:33SynrGLicenser_: clicki? whazzat?
12:34dpritchettCould someone help me udnerstand why (macroexpand-1 (->> 5 (- 3))) returns "-2" rather than "(- 5 3)"?
12:34Licenser_SynrG: my newest crazy inventiojn of cause!
12:34zaphar_pssomnium: the minivan
12:34zaphar_psit gets stuff done
12:34SynrGsomnium: how's moving castle, oo. nice :)
12:34dpritchett... this is in re: fogus's blog from yesterday
12:34zaphar_psand takes you places
12:34Licenser_A real wiki program (as it nearly entirely editable on the web)
12:34SynrGhowl's
12:34Chousukedpritchett: you're not quoting the expression
12:34SynrGclever. but cute?
12:34Chousukedpritchett: you're passing 2 to macroexpand
12:35Chousukedpritchett: and it returns the macroexpansion of 2, which is 2
12:35Licenser_SynrG: you can make it cute ;)
12:35Chousukeonly, with minuses
12:35dpritchettChousuke: indeed, thanks! I have read a few chapters/posts on Clojure macros but I haven't actually used enough to remember the proper syntax. Thank you!
12:35SynrG:)
12:35Licenser_just toss in a few cat pictures here and there :P
12:35SynrGhehe
12:36Chousukedpritchett: it's not really a syntax thing. macroexpand just expects clojure code as an argument, and you were passing just a number :)
12:36Licenser_SynrG: make it cute :P - since you can edit about everything it i - http://82.210.31.97:8080/index
12:36dpritchettJust out of curiosity is there ever a case where someone would want to automate the use of macroexpand to compose larger functions and *not* quote out the argument? Would it be possible for the macroexpand macro to autoquote in case of noobs forgetting?
12:37Chousukedpritchett: well, macroexpand shouldn't really be a macro because then it would have to expand itself with itself...
12:37SynrGLicenser_: a) no artistic talent here :p b) still can't see my little girls giving it rave reviews, even *with* cute cats
12:38Chousukedpritchett: better just get used to the fact that you can pass code to functions. it's neat when you *really* finally get it.
12:38dpritchettGood point Chousuke, I don't know why I thought macroexpand was itself a macro.
12:38Licenser_Meh why not? They can edit the cute cats in clojure! Making more cute and cuter cute cats!
12:39SynrG<insert joke about cute cats and tail recursion here>
12:39Chousukedpritchett: though in clojure the macroexpand function could be made a macro because it doesn't actually do the macro expansion for the compiler (there is a java method for that)... but that might someday change :)
12:39Licenser_I mean with 8 they are in the right age to learn something fundametnal like clojure!
12:39chousercan't run raincat -- maybe it's 32bit-only?
12:39SynrGhumm ... debian now has packages for 32 and 64-bit ...
12:39Licenser_SynrG: we don't have automatic tail recursion :)
13:27_invisGuys I need a correct calculus with PI, but dont know how :(
13:27_invis,(* 180.0M 3.7)
13:27clojurebot666.0
13:27_invis,(+ 180.0M 1)
13:27clojurebot181.0M
13:28chouser,Math/PI
13:28clojurebot3.141592653589793
13:28_invisi know
13:28_invisbut it will not be BigDecimal
13:28_invis,(* 5 Math/PI)
13:28clojurebot15.707963267948966
13:29_invis,(* 5.0M Math/PI)
13:29clojurebot15.707963267948966
13:29_invisso how I can take correct calculus ?
13:30chouserIt sounds like you're asking for infinite precision.
13:30_invis,(* 5.5M Math/PI)
13:30clojurebot17.27875959474386
13:30_invis,(* 5.5 Math/PI)
13:30clojurebot17.27875959474386
13:30_invisthe same result
13:31_invisnot infinite, but more correct
13:31chouserhow much more correct?
13:31_invislook
13:31chouserhttp://blog.objectmentor.com/articles/2009/08/05/generating-pi-in-clojure
13:31defnuse one of the algorithms to approximate it
13:31_invis,(* 5.5622322313254324131542313M 180)
13:31clojurebot1001.2018016385778343677616340M
13:32_invis,(Math/PI)
13:32clojurebot3.141592653589793
13:32_invis,(* 5.5M 3.141592653589793M)
13:32clojurebot17.2787595947438615M
13:32_invis,(* 5.5M Math/PI)
13:32clojurebot17.27875959474386
13:33_invisI want first
13:33chouserso you want more digits of pi than is shipped with Java or Clojure.
13:34_inviswhy
13:34chouserI gave you a link above to code that generates pi to arbitrary precisions
13:34_invissame digits in the last 2 examples
13:34chouserwhy do you want more? I have no ida.
13:34_invisI think your link will help me
13:34_invis*hope
13:35_invisafk
13:42Chousuke_invis: you can't do correct calculus with doubles because it simply doesn't have the needed precision. You need BigDecimal
13:43Chousuke_invis: and multiplying a bigdecimal with a double produces a double because it can't be guaranteed that there is no loss of precision, so the answer is given in a form that doesn't pretend to be accurate.
14:19ag90Question about apply. Can it be used on static functions from Java stdlib? I'm trying to do (apply BorderFactory/createTitledBorder (list of arguments)) but it complains about not being able to find "static field: createTitledBorder in class javax.swing.BorderFactory". Any way around this?
14:20chouserapply only works directly on clojure functions, but there are a couple ways to get what you want.
14:21chouserOne is to do something like (apply #(BorderFactory/createTitledBorder %1 %2 %3) mylist)
14:21ag90Yeah I considered that but the number of arguments is not known.
14:21chouser...where you must supply exactly the number of %'s as the size of mylist.
14:21chouserok
14:22chouserin that case you have to use reflection
14:22ag90Alright. Thanks.
14:23chousersomething like (clojure.lang.Reflector/invokeStaticMethod BorderFactory "createTitledBorder" (to-array mylist))
14:23ag90Oh yeah that would do.
14:23chouserag90: is createTitledBorder variadic itself?
14:24ag90createTitledBorder can take 0, 1, 2, 4, 5 and 6 arguments.
14:24chouserok, what I pasted above should work.
14:24ag90No wait not 0.
14:24ag90Cool
14:24ag90Thanks
14:52shalesWhat's the equivalent of a static main method in clojure?
14:54vegaishales: no such thing, is there?
14:54Chousukeyou can write a static main method :P
14:54vegaireally? Sick. :P
14:54shalesI think I'm missing something
14:54vegaiwhat?
14:54clojurebotwhat is wrong with you
14:55vegaiclojurebot: heh. Touche.
14:55Chousukeusing gen-class, you can generate a class from your namespace, and the namespace can have a function that corresponds to the main method
14:55clojurebotIt's greek to me.
14:55Chousukebut if you don't use gen-class, then clojure has no such thing as a main method :)
14:55Chousukethings are simply evaluated in order
14:55shalesI'm using leiningen to build a jar and it appears to be running the function call I have in a clj file when I run 'lein jar'
14:56shalesI was using this function call as my "main" equivalent when I ran that script
14:56Chousukethat would happen, yes
14:56shalesbut I don't understand why it runs when I use lein jar
14:56Chousukebecause the code is executed
14:56Chousukethe entire file. including the function call.
14:57shalesya, clearly, but why is executing it necessary to build a jar file?
14:57Chousukeit's necessary because to build a jar file you need to evaluate the code that makes up the jar file
14:58chouser(def foo 10) (defmacro bar [] `(list foo)) (defn bash [] (bar))
14:58ChousukeClojure differs from Java and other statically compiled languages in that in java the compiler reads code, compiles it, generates bytecode, and there is a static entry point.
14:58chouserin order to compile bash, bar must be evaluated. In order to evaluate bar, the value of foo must be evaluated.
14:58Chousukebut clojure starts by reading one expression, compiling it, executing it, then reading the next expression, compiling it, and executing it...
14:59shalesoh, I'd thought the jar would contain the clj source and that would be compiled when it was eventually run.
14:59Chousukewell, that could happen too
14:59Chousukechances are you're telling lein to precompile things
15:02shalesso is it a better to not precompile or to use gen-class with a static main method
15:02shales?
15:02chouserin general I'd recommend avoiding external side-effects in top-level code. Then you can do either.
15:03technomancyshales: it's best not to precompile unless you have a specific need that's forcing you to do it
15:03technomancybut making executable jars is a decent reason if you're distributing to end-users
15:04slyphonwow, this is bizarre, i'm getting a "wrong number of args passed to blah" exception, but i'm like, so not
15:05slyphondoes having a {} as the last argument do something funky?
15:05drewrit counts as one, so no
15:05shalesOk, but it sound like even if I'm making a exectuable jar I should still use gen-class. I'll give that a shot.
15:05kotarakslyphon: paste the code?
15:05slyphonkotarak: one sec
15:07slyphonkotarak: https://gist.github.com/b2f6b5577b32099e1062
15:07slyphoni gotta run out for lunch
15:07slyphonbbiafm
15:07slyphonkotarak: it's on line 43
15:07slyphoni'm calling it like (canonicalize-params (Date.) "12345" {})
15:08drewrslyphon: is it possible the exception is referring to something else?
15:08kotarakmost likely
15:23slyphonhrm
15:24ynefnewbie question: this works: (filter #(zero? (rem 12 %)) (range 2 (inc (/ 12 2)))) but this does not: (defn divisors [n] (filter #(zero? (rem n %)) (range 2 (inc (/ n 2))))) and then calling (divisors 12)
15:24slyphonoh, ffs
15:24ynefwhy?
15:24clojurebothttp://clojure.org/rationale
15:24slyphonkotarak: it's on line 56
15:25slyphonno, shit
15:25kotarakslyphon: the map!
15:25chouserynef: both return (2 3 4 6) for me
15:25kotarak#(lsajdflkj %1 %2) wants two arguments
15:26ynefchouser: that's really interesting, since I get something different :-/
15:26kotarakslyphon: you have to use (fn [[a b]] (... a b))
15:26slyphonoh, shit, yeah
15:26slyphonkotarak: good catch
15:26ynefchouser: nevermind, it was a problem with my eclipse plugin not reloading since I did some changes
15:26chouseror maybe #(str-join "=" %)
15:27chouserynef: np
15:27ynefthanks anyway, you helped me regain some sanity :-)
15:27slyphonchouser: oh, yeah, i'll try that
15:27slyphonchouser: yep, worked, thanks
15:27slyphonkotarak: thanks
15:28kotarakyw
15:30Raynestechnomancy: "Q: What's the difference between Ant and Maven? A: The creator of Ant has apologized."
15:30RaynesGood show.
15:31slyphonHAH
15:37RaynesYou know, Rich Hickey appreciation day is coming up soon.
15:38RaynesOh shit. We missed it.
15:38RaynesIt was the 20th.
15:38RaynesIt's hilarious how you can forget a mock holiday you yourself created
15:40shalesQuestion about work flow. I'm using emacs, swank and leiningen. I'm creating a little toy app that has a couple clojure libs and a main class. I can build a jar with lein and execute that fine. Now what is the best way to rerun and test things without building a jar?
15:41shalesI haven't figured out how to run the main function using 'java -cp ... clojure.main'
15:42kotarakclojure.main -e "(main)"
15:46shalesIf the function is namespace is this the best way? clojure.main -e "(use 'bonjure.main) (-main)"
15:46shalesis *in* a namespace
15:47Raynesclojure.main -e "(bonjure.main/-main)"
16:01ynefI get a "ClassCastException" -- is there any way of getting more details about an exception? like what caused it?
16:01ynefThis is what gives me problems: (defn abundant [limit] (filter #(> (reduce (+ (divisors %))) %) (range 3 (inc limit))))
16:01ynefI thought that would be reasonable :-)
16:02chouserreduce wants a fn -- (+ ...) probably doesn't return a function
16:03chousermaybe (apply + (divisors %)) ?
16:04chouserinstead of (reduce ...)
16:07underdevhow do i check the version of clojure that's running in a repl. I'm trying to use labrepl within emacs, but i think i'm using my original 1.1.0 clojure
16:07chouser,(clojure-version)
16:07clojurebot"1.1.0-master-SNAPSHOT"
16:07chouser^^^ that actually means something before the 1.1 release
16:07underdevnope, i'm good
16:08underdevthanks chouser
16:47raekhow can I make sure a function is always runned in a transaction?
16:47raeksimply suround its body in a dosync?
16:48raekI want to make sure that all the refs are read at the same time
16:49raekbut these functions will be building blocks that other code will use inside transactions
16:49martenhmm, is it possible to catch the exception thrown when an assertion fails?
16:50marten(try (some-fn-with-assertion) (catch Exception _ "exception occurred")) doesn't seem to cut it
16:51marten, (try ((fn [] {:pre [false]} "fn returned")) (catch Exception e "exceptioned"))
16:51clojurebotmarten: Pardon?
16:52slyphonclojurebot: who are you, richard nixon?
16:52clojurebotGabh mo leithscéal?
16:52slyphonwell, i guess he told *me*
16:53chouser(doc io!)
16:53clojurebot"([& body]); If an io! block occurs in a transaction, throws an IllegalStateException, else runs body in an implicit do. If the first expression in body is a literal string, will use that as the exception message."
16:53chouseroh, that's backwards.
16:54chouserraek: yeah, use dosync. they nest fine.
17:01shalesIf I have two namespaces, A and B, where B has a (:use A), and I move function from A to B, how do I reload these namespaces in slime?
17:02shalesI get "Name conflict" errors when I try to C-c C-k the clj file for namespace B.
17:02shalesHow do I get it to recognize the function was removed from A?
17:05Drakesonif I replace a .jar and re-evaluate the (ns ...) importing it, possibly with :reload-all, will the new .jar be used?
17:06kotarakDrakeson: no
17:06Drakesonthanks
17:06kotarakDrakeson: put the contents in a directory. files may change and the changes are picked up
17:07Drakesonput the ".class"es in a directory? e.g., jar xf foo.jar?
17:08kotarakDrakeson: the class files can be loaded only once, but clojure source files can change.
17:09Drakesonthe thing I want to reload is unfortunately java. I guess I have to suck it up and restart the vm
17:09martenshales: try (remove-ns 'A)
17:09martendestroys the entire namespace though
17:09kotarakDrakeson: that the most straight-forward thing. You could fiddle with class loaders or use jrebel & friends.
17:09kotarakshales: ns-unmap
17:12slyphonhfm, you can't do (is (not (thrown? ))) ?
17:12slyphon(is (thrown? )) works
17:13shalesmarten: thanks, getting a different compiler error now but may not be related
17:14shaleskotarak: that's for individual symbols only? does remove-ns essentially do the same thing for all of the symbols?
17:14martenoh, doh. to answer my own question, java.lang.AssertionError is not a subclass of java.lang.Exception, so catching Exception doesn't help catching failing preconditions
17:15kotarakshales: I though you just want to remove the single function from the namespace A. But now that I think about it, you'll probably have to unalias things in B two. Does (require :reload-all 'B) help?
17:16ryshmm, brain fail: how would I take every nth pair of items from a seq, until the seq is completely evaluated?
17:18kotarakrys: quick guess (take-nth 2 (partition 2 ...))
17:18kotarak,(take-nth 2 (partition 2 [1 2 3 4 5 6 7 8 9 10 11 12]))
17:18clojurebot((1 2) (5 6) (9 10))
17:19ryssweet, just what I needed
17:19rysthanks
17:25erikcw1When I try to use SLIME commands (such as C-c C-x) from aquamacs, I get "Symbol's function definition is void: lisp-eval-last-sexp". I'm using M-x slime-connect in conjunction with "lein swank". Anyone have any ideas as to why my keybinding aren't working?
17:28slyphonaquamacs is Emacs 0.22.x, i think there's a note that says the swank-clojure thing is written for 0.23.x
17:30erikcw1slyphon: I'm on emacs 23 - -I'm using 2.0
17:30erikcw1aquamacs 2.0 that is
17:30slyphonhrm
17:30slyphonweird
17:30slyphondunno then
17:37shaleskotarak: the (require :reload-all 'B) didn't work. It's as you suspected though. After moving the function foo from A to B and doing C-c C-k in A's buffer, there is still this (get (ns-refers 'B) 'foo) => #'A/foo
17:38kotarak(doc ns-unmap=
17:38clojurebotEOF while reading
17:38kotarak(doc ns-unmap)
17:38clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
17:39kotarakshales: you could simply try ns-unmap for foo in B.
17:39kotarakshales: or ns-unalias
17:40shalesyeah, I did. ns-unmap works, but it's a pain to remember what was moved and do that for each symbol
17:40kotarakI don't know whether this refers to namespace aliases, though
17:41slyphonso, with defmacro, if there's a &blah in the params, there *must* be more params?
17:43kotarakslyphon: no
17:43slyphonkotarak: https://gist.github.com/c969b7ac480d5d663e5e
17:44arohnerIs there anything I can do to reduce the occurrence of PermGen errors?
17:44slyphonarohner: yes
17:44slyphonone sec
17:45slyphonhttp://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html
17:45slyphon-XX:MaxPermSize=512M
17:46arohnerslyphon: but I'm leaking if I run out of permgen, right?
17:46slyphonhm?
17:46slyphonwell
17:46dnolenit seems like Clojure is really picking up steam in Japan from all the tweets.
17:46slyphonthere's another arg i use with jruby
17:46slyphonone sec
17:46arohnerwhat typically happens is I'll leave a repl open, and after several hours of developing, I hit the rmGen error
17:46slyphonoh
17:47slyphonwell, yeah, you're generating a lot of class garbage
17:48slyphoni use -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
17:48slyphonthat really helped with long-running jruby processes, might help with clojure
17:50kotarakslyphon: maybe something like this? http://paste.pocoo.org/show/193515
17:50arohnerslyphon: thanks!
17:50slyphonarohner: sure
17:50slyphonkotarak: ahh, that looks promising
17:51slyphonkotarak: thanks
17:51kotaraknp
17:51nossis there any killer app in clojure that is not related to being a dev tool on clojure projects?
17:53arohnernoss: you mean a killer app of clojure, aside from developing in the language?
17:53nossarohner, yeah
17:54nossim sitting here as an erlang programmer, feeling a bit skeptical about the concurrency primitives in clojure. I want to see it used in a complex app.
18:00RaynesNo.
18:00RaynesNot in the traditional "killer app" sense.
18:01RaynesI'm sure there is a complex concurrent app around somewhere though.
18:02nossany real-life things then? a web app? a wiki... etc?
18:02dnolennoss: I think Penumbra is pretty interesting, it's for OpenGL. But you can safely and *easily* update the world state from multiple threads of execution, even though OpenGL itself is single threaded. but that applies to any app reall.
18:02dnolennoss: web apps are not a good real world case since, http is stateless anyway. perhaps a complex web service, but not your average web app.
18:03nossweb apps do more than communicate over http.
18:05slyphonkotarak: works like a charm, thanks!
18:06kotarakslyphon: :)
18:11Drakesonwhat is the current way for generating a [named] class dynamically?
18:15ChousukeDrakeson: is that even possible?
18:16DrakesonI don't know how dynamic it can be.
18:16kotarakDrakeson: you can do it once, but when the class is loaded it is put in concrete. (At least this is my understanding)
18:17Drakesonthat is still [kinda] OK.
18:18kotarakDrakeson: but this is only a vague understanding on my side. Take with grain of salt.
18:34joshua-choiIs there any value in writing a Clojure parser in *pure* Clojure—that is, without any calls to Java methods—as opposed to having Java methods here and there?
18:34Chousukejoshua-choi: that would be quite the feat
18:34joshua-choiYou mean, yes?
18:35programblewhere java isnt broke, clojure doesnt fix it
18:35joshua-choiOh, "feat". I read is as fact. :)
18:35Chousukeit might be useful for non-java clojures too, so maybe. :P
18:35programbleits on the JVM, feel free to use the Java API
18:35joshua-choiChousuke: That's what I was thinking of.
18:35joshua-choiI'm wondering if it would be useful for any bootstrapping
18:36joshua-choiBut if there's no point, I won't bother, since Java methods are really fast
18:36ChousukeI wrote a reader in clojure a while back but it didn't turn out that good :)
18:36joshua-choiI have a finished product
18:36Chousukeit was pretty ad-hoc
18:36joshua-choiBut I'm wondering if it would be worth testing and debugging
18:36Chousukedoes it use only core clojure? :/
18:37Chousukeie. no external libraries
18:37joshua-choiAnd clojure.contrib.monads and clojure.template, which do not use any Java methods to my knowledge.
18:37Chousuke(java counts as core clojure :P)
18:37joshua-choiYeah...
18:38ChousukeI would really like to see any of the java parts in clojure replaced with a clojure solution, so I'm supportive
18:38joshua-choiWould a Clojure parser that uses Java methods still be useful?
18:39Chousukeprobably
18:39Chousukeit will *have* to use java methods at some point anyway
18:39Chousukewhat matters is just how well it's hidden
18:39joshua-choiWell, I'm assuming that clojure.core's functions are the bottom line
18:39joshua-choiBut that might not be a useful distinction, maybe...
18:40Chousukeyou can't do IO or string operations with just clojure.core though :)
18:40joshua-choiAt least until Clojure isn't unique to the JVM anymore
18:40joshua-choiYeah, I'm starting with strings only
18:40Chousukebut once it's mostly clojure, wrapping the java parts should be trivial if the need arises to port it to another host
18:40joshua-choiString inputs, I mean
18:40joshua-choiYeah, that's right
18:41mitkokAnyone using swank-clojure without package.el ( elpa ) ?
18:41ChousukeI think I am. :P
18:41joshua-choiIt's things like Integer/parseInt and Character.toUpperCase anyway
18:43joshua-choiWell, I'll keep the pure Clojure version around as a proof-of-concept, I guess; for showing off my library, if nothing else :)
18:43Chousukeheh.
18:44ChousukeI don't think it would hurt to ask what Rich and others think about it.
18:45Chousukeand it might turn out to be useful for IDE plugins or something
18:46Chousukebut, sleep. later.
18:46joshua-choiGood night. If it's night.
18:47RaynesNighttime is constant. Day is an illusion.
18:47joshua-choiJava question: does Character/isDigit accept non-ASCII digits such as Devanagari and fullwidth digits?
18:48joshua-choiI can't test it on my REPL
18:48DrakesonCan I access a not-AOT-compiled clojure function or class from java? (i.e., does the class have to be on the disk?)
18:48arohnermitkok: yeah, I am
18:49arohnerDrakeson: you can get at it through the var
18:49arohnerDrakeson: I don't have a running repl at the moment, but it's something like v = Var.find("foo"); v.invoke();
18:50arohnerinvoke takes the same args that the clojure fn takes
18:50Drakesonhow do I get at the namespace? Var.find("the.namespace.foo") ?
18:51kotarakOr v = RT.var("the-namespace", "the-var")
18:51Drakesonthanks
18:51mitkokarohner: Can you show how you load it, I used to load it like this: http://github.com/mitkok/emacs/blob/master/defunkt/clojure.el, but now it gives me error on (require 'swank-clojure-autoload)
18:51kotarakWhen would one use == instead of =?
18:51mitkokarohner: I'm using joshu swank-clojure and clojure-mode, not technomancy's
18:52arohnerI do (add-to-list 'load-path "~/Programming/swank-clojure")
18:52arohner(require 'slime)
18:53arohnerI have a separate script that starts up my clojure process, and then I connect through M-x slime-connect
18:53arohnerkotarak: when you want fast integer compares
18:54arohnermitkok: which slime are you using?
18:55arohnerCVS Head slime is known not to work for clojure
18:55mitkokarohner: I have a clone of git://git.boinkor.net/slime.git
18:55arohnermitkok: I'm using technomancy's github mirror of slime, and technomancy's swank-clojure and clojure-mode
18:56mitkokarohner: but doesn't these repos depend on package.el ?
18:56arohnermaybe? I don't know
18:56arohnerI think I have elpa installed, but I'm not using it for any clojure stuff
18:57mitkokbecause in the readme you have to geto the repos and install it with M-x package-install-from-buffer
19:14alexykI have a sequence of vectors, each of pairs. I can convert each into a map with (into {} v), that'll do transients for me. But what about several such v's, [v u]?
19:17_mstmaybe reduce?
19:17_mst,(reduce into {} [[[:a :b]] [[:c :d]] [[:e :f]]])
19:17clojurebot{:a :b, :c :d, :e :f}
19:19alexykI was thinking about that, should be ok
19:19alexykcan you deref in #(..) as #(.. @% ..) ?
19:19alexykor have to use (deref %) ?
19:20_mstyep, @% should work
19:26alexykhow do you destructure struct's?
19:27alexykif you do
19:28The-KennyJust like hashmaps I think
19:29_invisIn the labrepl:
19:29_invisOur first reduce example showed using reduce to perform repeated addition. But in Clojure, the + function can itself perform repeated addition! What advantages does reduce offer over implicit reduction within a funtion?
19:29_invisCould you tell me what they mean ?
19:31alexykThe-Kenny: yep. thx
19:31qbg_invis: Why would you use (reduce + coll) instead of (apply + coll)
19:31The-Kennyalexyk: structs are just maps with some special, more efficient backend
19:31qbg?
19:32_invisqbg: dont know
19:34_invisqbg: what authors mean when told What advantages does reduce offer over implicit reduction within a funtion? ??
19:36qbgI'm not sure that there is much of a difference....
19:36qbgI know why you wouldn't want to use (apply + coll) in CL, but that doesn't apply here
19:37_invisemm so why ?
19:37qbg_invis: Why in CL?
19:38_invisyes
19:38qbgCALL-ARGUMENTS-LIMIT
19:38_invisI just dont know what the difference between apply and reduce. So I dont care what to use.
19:39programbleapply is like
19:39programble(apply + (1 2 3))
19:39programblemakes
19:39programble(+ 1 2 3)
19:39clojurebot*suffusion of yellow*
19:40programble(reduce + (1 2 3))
19:40programblewould be
19:40_invis,(apply + '(1 2 3))
19:40clojurebot6
19:40programblewell
19:40programblesame in this case
19:40_invis,(reduce + '(1 2 3))
19:40clojurebot6
19:40programblebad example
19:40programblelol
19:41qbg(reduce + (1 2 3)) == (+ (+ 1 2) 3)
19:41_invis,(apply + (1 2 3))
19:41clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
19:41_invis,(reduce + (1 2 3))
19:41clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
19:41_invisyou wrong
19:42_invisI think )
19:42qbg,(reduce + '(1 2 3))
19:42clojurebot6
19:42programbleneed the '
19:42_invisso what the different with apply ?
19:42programble(reduce + '(1 2 3)) == (+ (+ 1 2) 3)
19:42_invisyes I know
19:42programble(apply + '(1 2 3)) == (+ 1 2 3)
19:42_invis:)
19:43_invisreduce is recursion that's it ?
19:43qbgI think the only real question is which one is more idiomatic
19:43_invisI ask you not about apply :0
19:43_invis*:)
19:43_invisWhat advantages does reduce offer over implicit reduction within a funtion?
19:43noss,(reduce #(list 'x %) '(1 2 3))
19:43clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--3729$fn
19:44nosshmm.
19:45qbgI'd think that explicit reduce would be more idiomatic
19:45joshua-choinoss: The function needs two arguments. If you didn't know. :)
19:46noss,(reduce #(list 'x %1 %2) '(1 2 3))
19:46clojurebot(x (x 1 2) 3)
19:48_invisis this advantage about authors told ?
19:50qbgI don't know what the authors are looking for.
19:51_invishmm ok
19:51_invisty
20:04_invis(reverse "foobar")
20:04_invisWhy is reverse's behavior the right thing to do, even for strings, and what options can/should be provided for String->String functions?
20:04_invisO_o
20:04Raynes,(apply str (reverse "foobar"))
20:04clojurebot"raboof"
20:04_invisthanks
20:05programbleraboof lol
20:05_invisthe same as reduce
20:07alexykI'm debugging agents. They have errors. How do I terminate whatever an agent was doing?
20:07alexykor reset it
20:09alexykor, how do I inspect which errors an agents has?
20:10seths,(find-doc #"agent.+error")
20:10clojurebot------------------------- clojure.core/agent-errors ([a]) Returns a sequence of the exceptions thrown during asynchronous actions of the agent. ------------------------- clojure.core/clear-agent-errors ([a]) Clears any exceptions thrown during asynchronous actions of the agent, allowing subsequent actions to occur.
20:34alexykseths: you did it again
20:34sethswow, I must have superpowers that I don't know about
20:34sethsmagic net-splitting powers
20:35alexykmagic incantation is "uh oh"
20:35alexykBill Gates rebooted the internet again
20:36sethslol
20:40defnLicenser: around still?
20:40defnLicenser: had a chance to fix that issue with walton? I'm going to work on performance for awhile tonight I think
20:53defnwhoa. i think im close to figuring out how to get circumspec working! :)
21:05sethsdefn: have you checked out labrepl?
21:05sethsit has a working config, even with file-system watchers to rerun tests after app code changes
21:06sethshttp://github.com/relevance/labrepl
21:10defnoh sweet
21:10defnthanks seths
21:12hiredmanclojurebot: ping?
21:12clojurebotPONG!
21:12hiredmanexcellent
21:12defn,(doc try)
21:12clojurebotGabh mo leithscéal?
21:13hiredmanspecial forms are special cased in the real doc function, but I haven't done it in clojurebot's doc
21:18defnoh nevermind seths -- looks like that's for netbeans only
21:18defnnvm
21:18sethsdefn: labrepl is a leiningen app
21:18defn*nod* i see that now -- i just hadnt read beyond a couple headings :)
21:18sethswhen I used it in the Clojure training course I was running it from Emacs / swank-clojure
21:18defnoh man I wish I could have went to that
21:18defnhow much $ was it?
21:18sethswe were Stu's guinea pig
21:19sethscompany paid, but at least $1500 I think, depending on alumni discount
21:19sethsanother course in May
21:19sethsStu and Rich autographed my copy of Programming Clojure :-)
21:19sethsbest training ever
21:19seths,101r3
21:19clojurebotInvalid number: 101r3
21:20qbg,3r101
21:20clojurebot10
21:20sethsah, ty
21:21alexykhow do you use doto to compress: (.print System/err s) (.flush System/err) ?
21:21qbg(doto System/err (.print s) .flush)
21:21alexykthx
21:22defnholy labrepl dependencies batman
21:23sethslol
21:23qbgNot having tried it, it doesn't look that bad...
21:23sethsmaven is your friendly internet backup tool
21:23sethsit backs up the internet to your computer
22:23qbgWhy can't I destructure in the arglist in the implementation of a protocol method in deftype?
22:25brian__hi, I am trying congomongo, I create the database , then when I do this: (insert! :robots {:name "robby"}) , i get com.mongodb.MongoException$Network: can't say something (NO_SOURCE_FILE:0)
22:26sethsqbg: I asked that to Rich
22:27shalesShould a recur work in one of the result-expr of a case? I'm getting a "Can only recur from tail position" error
22:27sethstrying to remember what he said
22:27shalesthis doesn't compile (defn foo [] (case 1 1 (recur)))
22:29sethsmy take on what he said was that the [bar baz] in (deftype Foo [bar baz]) defined a list of fields
22:30sethsit's not a function call at that moment
22:30sethsa factory method (and constructor for Java) is defined for that list of fields
22:30sethsand the factory method seems like a good place for destructuring
22:31sethsbut not sure how to add that between listing the type's fields and defining the factory function?
22:31qbgI'm talking about something like (deftype Rect [p1 p2] Shape (contains [[x y]] ...))
22:31sethsI am probably misrepresenting Rich horribly
22:31qbgI'm not sure we are talking about the same thing
22:31underdevdoes anyone know a command to clear the repl of the functions used in the current session
22:31qbg(I'm talking about the contains part)
22:31underdev?
22:32qbgunderdev: Before I've just removed all of the interned vars from the namespace
22:32sethsah, I was talking about p1 p2
22:32qbgI don't like having to do (contains [point] (let [[x y] point] ...))
22:33sethsqbg: so you want something like (deftype Rect [[x1 y1] [x2 y2]] (contains [x1 y1] ...)) ?
22:33sethsroughly?
22:34qbgNo, just destructuring in the function/whatever definition
22:34sethsah ok
22:34qbgThe arity is already known, so I don't see why it couldn't be provided.
22:34sethsI didn't ask that question :-)
22:35sethssorry for the confusion
22:35qbgno problem
22:36qbgunderdev: Something like (map #(ns-unmap *ns* %) (keys (ns-interns *ns*)))
22:52underdevqbg: thanks, i was having a collision. I just changed the namespace.
22:53underdevqbg: clever idea though~
22:54qbgActually (doseq [sym (keys (ns-interns *ns*))] (ns-unmap *ns* sym)) would be more correct
22:58defnanyone here familiar with incanter?
22:59liebkedefn: what's up?
22:59defnoh nothing really at the moment -- i was thinking about cheating and asking someone to solve my problem for me but then thought better of it
23:00liebkeah :)
23:00defnBUT...since I have the man himself here... I have a structure that looks like {"1.1.1.1" {:count 5 :country "US"}}
23:00defnonly it is much larger obviously
23:00defnim interested in graphing some of that in incanter and was wondering where a good place to start might be
23:01defnsort of an open ended question i know, but if you don't have a good answer I can experiment for a bit
23:01defn<--first time incanter user
23:02defnliebke: perhaps a more fitting question would be to ask which clojar i should be using :)
23:02liebkedefn: if you converted that structure into an array of maps, like {:count 5 :country "US"}, you'd pretty much have an incanter dataset, which you could use in bar-chart (or line-chart)
23:03liebkewhat do you mean by which clojar?
23:03defnerr, there are several incanters on clojars.org
23:03defnwas just wondering which is the "right" one
23:03defnim using [incanter "1.0-master-SNAPSHOT"] IIRC
23:03liebkeah, don't use the version on clojars, they are old. go to http://repo.incanter.org
23:04defnawesome -- thanks
23:05liebkedefn: I'm about to sign off, but if you have more questions, just send an email to the Incanter Google group
23:20brandonwis there a way to have an atom be a seq, and then change the atom such that it equals the second half of a call to split-at, while retaining the first half of split-at for something else?
23:20brandonwor should i just use a ref for that type of thing?
23:21defn(:use [clojure.contrib.duck-streams :exclude (copy)]...
23:21defnthat should work right?
23:22defncopy already refers to: #'clojure.contrib.duck-streams/copy in namespace: geoip.core
23:22brandonwi guess what i need to do isn't truly an atomic operation
23:23arohnerbrandonw: what do you mean "while retaining the first half"?
23:23brandonwi would have to do something more like a loop that continually takes the first x items out of the seq
23:23brandonwfor example
23:23brandonwsay i have an atom containing the value [1 2 3 4 5 6]
23:23arohneryou can always do (swap! atom #(split-at x %))
23:23brandonwand i want to swap! the atom to be [5 6], but then operate on [1 2 3 4] separately
23:23brandonwyes, but then i wouldn't know what the first part is
23:23arohnerah
23:23brandonwi think i do need to use a ref
23:23arohnerwhat do you want to do with the first half?
23:24brandonwi basically have a queue that i add items to
23:24brandonwand then every 'tick' i want to take the first x items and send them through a proxy
23:24brandonwand set the new queue to be the rest of the items
23:24arohnerther e two reasons to use refs over atoms: 1) you want multiple refs to have coordinated changes 2) you're doing something where the performance is important
23:24arohnererr #2 is a reason to use atoms over refs
23:24brandonwyeah, that is what i was thinking
23:25brandonwi don't think i would classify what i want to do as coordinated
23:25arohnerwhat is your proxy?
23:25brandonwsince i only need to do a single change to the value
23:25brandonwwell it is basically a vector of structs
23:25brandonwi want to take the first x maps, convert them into a string form to send over an actual network proxy
23:25arohneroh, that's important
23:26arohnerrefs and atoms are extremely likely to retry their operations
23:26defn(ns my.ns (:use [clojure.contrib.duck-streams :exclude (copy)] (incanter core charts))) -- even when excluding copy it is complaining that duck-streams already refers to copy
23:26brandonwand retain the rest of the elements for the next 'tick' (so that i never send more than a certain number at a time in order to not overload the receiver)
23:26arohnerthe things you do inside swap! or alter should be side-effect free
23:26brandonwright
23:26brandonwi am not doing the side effect in the swap
23:26brandonwonly the splitting of the partition
23:26arohneryou could send the other part to an agent
23:27brandonwbut how would i get the other part from the swap! operation?
23:27arohnerin that case, you would use a ref
23:27arohnerthe STM sends all outstanding agent sends when the transaction succeeds
23:28arohner(dosync (let [[first second] (split-at)] (alter foo (constantly second)) (send my-agent first)))
23:28brandonwif i can only do (swap! queue (second #(split-at x %)))
23:28brandonwright
23:28brandonwthat's what i was thinking
23:28brandonwso is this actually considered a coordinated change?
23:28brandonweven though i technically am only performing a single operation on the atom?
23:29arohnerif you want the agent send thing, I think you need to use a ref
23:29brandonwwell, ignoring the agent piece of it
23:29brandonwforget i said anything about a proxy or anything else
23:29arohneryes (swap! queue (second #(split-at x %))) is a single change
23:29brandonwif i had something like (swap! queue (second #(split-at x %))) to modify the queue in the atom, is there any way to retain the first piece of that split-at?
23:30arohnera second atom, but that's a little weird
23:30brandonwhow is it weird exactly?
23:31brandonwthis is my first foray into the threading pieces of clojure, i'm just trying to make sure i have the foundations right
23:31arohneractually
23:32brandonwhow would you even do it with a second atom? it seems like the process of swapping the atom means there is no way to retain the first piece of the split-at call
23:32arohner(let [[first second] (split-at...) (swap! a (constantly first)) (swap! b (constantly second)))
23:32brandonwsince the function call to swap it has to be within the context of the swap! call, and if i split them before the call to atom, then i risk the atom being modified after i bind a local var to the result sof the split-at but before i call swap!
23:33arohneris this called from multiple threads?
23:33arohnerI guess that's a bad question in clojure
23:33brandonwyes, there will be other threads
23:33arohnerif it matters, You're Doing It Wrong
23:33brandonwi should have mentioned that at the start
23:33brandonwyeah, that's true
23:34brandonwi think i'll use a ref, it seems like what i am trying to do requires a little too much coordination to fit into an atom
23:34arohneryeah
23:34brandonwi am actually porting something to clojure
23:34brandonwand realistically, i don't think the queue element limit will ever even be reached
23:35brandonwso it probably won't even matter. i might as well just skip the split and just swap! to a new emtpy seq, and pass the current value of the atom through the proxy :D
23:35brandonwbut.. i shouldn't be lazy, haha
23:35brandonwi'll do it right :)
23:40brandonwwhoaaaaa
23:40brandonwi'm a dope
23:40brandonwi just realized... it's a queue
23:40brandonwanything added after i get a value of the atom won't matter
23:41brandonwi can split it up beforehand, because as long as i only remove the number of elements in the seq i split, then it will still be consistent
23:42brandonwso i could do like you said: (let [first-piece (split-at x @atom-var)] (swap! atom-var #(drop (count first-piece) %)))
23:42brandonwand that would work perfectly
23:42defnHow would I use destructuring to get {:foo {:bar 1 :baz 2}} => [{:bar 1 :baz 2}]?
23:45defn,(let [[_ [bar baar baz baaz]] {:foo {:bar 1 :baz 2}}] bar baar baz baaz)
23:45clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap
23:45defnhmm
23:50brandonwi definitely need to learn destructuring; haven't used it much yet
23:50defnyeah im struggling with it
23:50defn:\
23:53defnit seems like this should be a lot easier than im making it
23:55brandonwi *think* (with almost no experience destructuring) that the correct way would be:
23:55brandonw,(let [{i :foo} {:foo {:bar 1 :baz 2}}] [i])
23:55clojurebot[{:bar 1, :baz 2}]
23:56defnhuh... how does that work...
23:56brandonwthe part where you add a vector to the value-- i don't think you can do that in destructuring, since a vector isn't part of the initial structure
23:56defni think you can with :ivec maybe
23:56brandonwbasically, you pull the value corresponding to the :foo key of the arg, and wrap a vector around it
23:57brandonwwhat is :ivec?
23:57brandonwhaven't heard of it
23:57defnim about to find out :)
23:57defnim just reading the special_forms doc on clojure.org
23:58defn,(let [{i :foo} :ivec {:foo {:bar 1 :baz 2}}] i)
23:58clojurebotjava.lang.IllegalArgumentException: let requires an even number of forms in binding vector
23:58defnhmm that's not it
23:59brandonwonly docs i find on :ivec is on the special forms page, and i can't figure out at all what it does
23:59brandonwi think my solution would work though
23:59defnbrandonw: i think it is short for internal vector
23:59brandonwif you have a map as an input, i'm not sure if you can destructure it into a vec, since a vec isn't part of its initial structure