#clojure logs

2009-08-25

00:59lowlycoderanyone got experience with clojure on hadoop?
00:59lowlycodermake that clojure / hadoop / ec2 :-)
01:20tomojlowlycoder: I saw some code someone had written somewhere
01:20tomojmaybe on the group
01:20tomojhttp://github.com/stuartsierra/clojure-hadoop
01:22lowlycoderthat name looks familiar from googling around
01:22lowlycoderi had imagined this would be a bigger deal somehow :-)
01:22lowlycoderyou know, after learning clojure; it's a lot less impressive than I thought it would be
01:22lowlycoderthere's some minor changes, but no mind blowing magic
01:34rathorelowlycoder: in what sense?
01:41tomojmaybe the persistent collections aren't mind blowing, but they're still awesome
01:43JAS415mindblowing
01:44JAS415i feel like lispers always explain lisp as if its mindblowing, but really its not mindblowing on the surface, its kind of mindblowing after 3-6 months of hacking it
01:44clojurebot"if you never learnt Lisp, then you never learned to program" -- some rant on some blog somewhere
01:44JAS415like you can come to clojure or CL and treat it like c or python and kind of go 'meh' and not be that impressed
01:46tomojhomoiconicity blew my mind
01:47JAS415yeah that's the mindblowing part
01:47JAS415although i guess the mindblowing part is what you can do with it
01:47JAS415not so much the homiconicity itself
01:48dosyncfor me it was lazy sequences.
01:48tomojcode that writes code is just plain awesome. I love recursive/self-referential stuff like that
01:48tomojoh yeah, I remember having my mind blown when I created a sequence of all the integers
01:50dosynci am pretty sure the STM will blow my mind away too, once i grok its possibilities. For now, "snapshot isolation" just seems like something that is nice to have. :)
01:51dosyncLook at this post for eg. http://groups.google.com/group/comp.lang.lisp/msg/a86c91091ae16970
02:50tomojI can't seem to get ns syntax right
02:50tomoj(use (clojure.contrib.pprint :only [:cl-format]))
02:50tomojwhat's wrong?
02:52hiredman:use and
02:55mikem`_should it be (use '[clojure.contrib.pprint :only [cl-format]])
02:55tomojit's in ns, so no quoting necessary I think
02:55tomojoh, the error I'm getting now is that cl-format is not public
02:55tomojthat's odd
02:56mikem`_tomoj: ah, you're right :) as hiredman says, you need :use, though
02:56tomojgot that
02:56tomojnow this illegal access error, hmm
02:56tomojcl-format is clearly public
02:57tomojif I (use 'clojure.contrib.pprint) at the repl, I can use cl-format
02:57tomojbut (:use [clojure.contrib.pprint :only [:cl-format]]) in ns won't compile
02:57dosyncno : before cl-format
02:58tomojoh, d'oh
02:58tomojthanks
03:00RaynesI just spent 20 minutes trying to figure out why I couldn't use anything from clojure-contrib, before I realized that I never built it. :|
03:00Raynes/fail
03:25LauJensenTop of the morning gents
03:26cgrandmoin
03:27LauJensencgrand: tres bon, si'l voi plait, qui qui madam
03:29gkotu vas bien ?
03:36dcooper8git clone git://github.com/kevinoneill/clojure-contrib.git
03:36dcooper8does not seem to work
03:37dcooper8is there a "standard" location for clojure-contrib?
03:37hiredmanyes
03:37hiredman~contrib
03:37clojurebotcontrib is http://github.com/richhickey/clojure-contrib/tree/master
03:37hiredmanthe kevinoneill repos were unofficial github mirrors when clojure was using svn
03:38dcooper8that is from http://riddell.us/tutorial/clojure/clojure.html
03:39hiredmanthen it's old
03:46dcooper8should i be able to:git clone
03:46dcooper8git clone http://github.com/richhickey/clojure-contrib/tree/master
03:46dcooper8?
03:46dcooper8if i try that, i'm getting a corrupted file error
03:47hiredmangit clone git://github.com/richhickey/clojure-contrib.git
03:53dcooper8thanks, got it.
06:14alinphi
06:14alinpwhat's the best way to add an element to end of a sequence ?
06:15alinpI'm missing something about cons/conj since it adds the element as the 1st in the given coll
06:15clojurebot(conj {:a 1} (when true {:b 2}))
06:15liwpit depends on the collections type
06:16liwpif the collection is a list, the new element will be added to the front since that's an O(1) operation
06:16alinpok .. so how can I add it to the end ?
06:16alinpif the coll is a list
06:17liwpyou really shouldn't since it's an O(n) operation
06:17liwpcan you use vectors instead of lists?
06:17liwpwith a vector conj adds the element to the end
06:17alinpyeah, I think so
06:18liwp,(conj [1] 2)
06:18clojurebot[1 2]
06:18liwp,(conj '(1) 2)
06:18alinp,(conj [2 3 4] 1)
06:18clojurebot(2 1)
06:18alinpyeah
06:18clojurebot[2 3 4 1]
06:18alinpthanks
06:18liwpno worries
06:19Neronusquick to write and not so efficient if you want to stay with lists: (reverse (conj (reverse list) x))
06:19liwpif you really want to deal with lists a common idiom is to build the list back-to-front and then reverse the list before returning it
06:20liwpso you get o(1) adds and then a single O(n) reverse
06:25Neronushttp://paste.lisp.org/display/86002 Something like that
06:25Neronusbut I don't think that that is more efficient than my solution above
06:26liwpNeronus: yeah, it's basically the same thing, i.e. iterate through the list, conj an element, and reverse it
06:27liwpso in general it's just a bad idea to use lists if you need to append to the collection
06:29Neronusyeah. Great for using them as stacks, though. Can be used for queues to (i.e. add last), but this isn't that easy
06:30Neronusna, sorry, the last one is only true when using modifiable cons cells
06:30Neronusbtw, a short benchmark shows, that the version I pasted is a little faster (about 50 msecs on my PC)
06:31liwpNeronus: there's a cool functional queue by Chris Okasaki which is also the basis of the PersistentQueue in Clojure
06:31liwpbasically you have a pair of lists, you conj to the second list in order to append to the queue
06:31liwpyou dequeue by taking the head of the first queue
06:32liwpfirst list even
06:33liwpand when the first list is empty when doing a dequeue you take the second list, reverse it, and create a new pair with the reversed list and a new empty list
06:33liwpif that makes any sense ;)
06:34NeronusIt isn't slower if I modify clojure.core/reverse to use loop/recur instead of reduce
06:34liwpyour benchmark?
06:35liwphow long is you list in the test?
06:35NeronusI defined a list of a million zeroes and added a one to the end
06:35liwphmmm
06:36liwpAFAICT (reduce) calls into the Java reduce function that the PersistentList implements, so you'd expect the reduce implementation to be faster...
06:36liwpso how long does it take to add an element to a 1M element list?
06:41Neronusliwp: reduce calls a java reduce function for chunked sequences, and list aren't chunked. If the collection isn't chunked, it uses loop/recur
06:42NeronusAbout 600 msecs for me
06:42liwpoh, ok
06:43liwpoh yeah, that's right
06:46liwpNeronus: do you use slime?
06:46Neronusliwp: Yupp
06:46liwphow do you fix your repl after you've printed 1M integers in it and it's abysmally slow? ;-)
06:46liwpI'm assuming it's the size of the buffer that's causing problems
06:47liwpsince my irc buffer is fine
06:47Neronusliwp: I restart the repl
06:47Neronusthat is, I close the buffer
06:47liwpyeah, that's what I've done in the past. There should be a better way though...
06:48liwpthat's better!
07:13LicenserI like the 'what you're doing wrong' part of the video
07:19tomojliwp: M-x slime-repl-clear-buffer
07:19tomojliwp: which for me is C-c M-o
08:07raphinouI've posted about my use of clojure with Jwt at: http://www.nsa.be/index.php/eng/Blog/Using-Jwt-yes-it-s-a-J-with-Clojure
08:08raphinouFor those who were here the last days, it's for this post that I had problems implementing 2 nested interfaces having the same name ;-)
08:08raphinoufeddback welcome
08:10liwptomoj: thanks! I'll try that the next time I do something stupid
08:17AWizzArdHello rhickey. Do you accept Contributor Agreements also when they are sent via fax?
08:18rhickeyAWizzArd: not so far, no
08:19fsmHi AWizzArd
08:20fsmI made some changes to my project according to your suggestions from a while ago
08:20AWizzArdAh, hi fsm, I got your message and already looked at your code. It is really nice.
08:20AWizzArdAnd hard to believe btw that you are a raytracing newbi...
08:22fsmStill plenty of room for improvement, but in that field there is infinite room for improvement.
08:23fsmNow, I search for some kind of trick to eliminate nested if statements
08:23carkfsm : have you tried taking advantage of the easy parallelism of clojure to speed up rendering ?
08:23fsmI have several algorithms that depend on exiting as early as possible for speed, which makes nested code
08:23fsmcark: yes, it was possible to make it multi-threaded with about 8 lines of code
08:24carkhehe nice =)
08:24fsmi am using atoms, i think if i changed to pmap most of that would go away (?)
08:24carkatoms ?
08:24carkoh
08:24fsmagents*
08:25carki don't know, agents are very often the way to go, i don't have time to dig in your code togive pertinent advice
08:25fsmit was really a matter of adding 'start' and 'end' co-ordinates to my rendering function, a minor change
08:26fsmbut now, i wish for some kind of 'lazy let' so that variables are only computed if they are referenced
08:26carkas for the nested if thing, you might want to look into the maybe monad, though that will make a lot of function calls (slow)
08:27fsmyes, i think that is what i was looking at in haskell
08:27fsmthe problem is, I have millions of tiny operations, that are easily overwhelmed by a little overhead
08:27fsmbut that is why people write these things in C
08:27carkor you could make some kind of macro for that...
08:28fsmi am going to look at the maybe stuff, the code might become slower, but i might learn something.
08:29fsmthe promise of having code that describes the problem rather than the solution is very interesting
08:29Neronusfsm: Are the many nested ifs in one function? I guess you know about cond? If this isn't the solution, then I don't understand the problem
08:30carkcond exits as soon as it reaches a true condition
08:30fsmThe problem is, I may have e.g. 8 variables in a function, which are moderately expensive to calculate. After calculating the 2nd, 4th, and 6th (for example) i test the results so far and see if i can exit, to boost speed
08:30Neronusbtw: is that your raytracer http://code.google.com/p/cray/?
08:30fsmyes, that's it
08:30Neronusnice :)
08:30fsmthanks
08:31fsmI didn't code in any lisp type languages before, so the code is a little rough... but it is getting better.
08:32tomojhrmm
08:32fsmanyway, right now i have to do 3 levels of nested if and let, for those type of routines
08:32Neronusfsm: What about delay and force? wouldn't lazy variables help?
08:32tomojah, delay and force look cool
08:33fsmthat looks interesting, there are plenty of things I don't know about that are already there
08:33tomojyou could write a lazy-let that replaces all instances of the symbols in the body with (force <the-symbol>) and puts delay around the bindings, right?
08:34tomojthough that means every access to those variables is a function call :(
08:34fsmfor now, i have wrapped some of my calculations in anonymous functions, that kind-of gives me what i want (cuts down on nesting)
08:34fsmbut the cost is another function call, so it is only good for expensive calculations
08:34Chousukeyou could perhaps write some kind of an extension to let like (something [a (foo) b (bar) {:guard (= a b) :or value-if-guard-fails} c (more a b)] ...)
08:35fsminteresting, that kind of thing is a good way to go up a gear in learning
08:36Chousukeremember, macros let you have any kind of syntax for anything you want, as long as its made of clojure data structures. :)
08:37Chousukethe only problem is writing the macro.
08:37tomojbut at macro-time there's no way to know if a variable will be referenced :(
08:38ChousukeI mean, with-open or something is easy, but... if you like a challenge, try a (c++ "int main() { return 0; }") D:
08:39Chousuketomoj: referenced?
08:40Chousukeall you need to do is generate the needed checks.
08:40tomojreferring to something fsm said above
08:40ChousukeI mean, it doesn't matter if the macro expands into a mess of nesting ifs
08:40tomojsomething like (lazy-let [a (foo) b (bar)] (if true a b)) would never call bar
08:40fsmyes, my issue is more with my knowledge level than any issues with the language
08:41fsmmacros are like having 26 letters of the alphabet, and deciding to write a book
08:41Chousukeheh.
08:41tomojlike I said I think you can get that by replacing a and b in the body with (force a) and (force b) and wrapping the foo/bars in delay, but that means every access to a is a function call
08:41Chousukefundamentally, macros aren't so magical.
08:42Chousukethey're merely functions that transform a data structure to another. pretty common, right?
08:42AWizzArdIs there a way to declare the return values of functions?
08:42fsmalternatively, like sitting in front of google.com, you can search for anything you can imagine, you just have to have a good imagination
08:42Chousukethe magic comes from the fact that the output data structure happens to be code.
08:42fsmi am going to try that force/delay and i am going to look at how let is implemented
08:43Chousukefsm: force and delay will only help with very expensive computations though.
08:43carki'd go for macros
08:43Chousukefsm: they have their own overhead.
08:43carkjust make a macro that expand into your nested ifs
08:43carkthere will be no overhead, and you get readable code in the end
08:44Chousukemacros are useful if you can find a repeating pattern in your code
08:44fsmit is interesting to see what affects performance and what does not
08:44Chousukeif the ifs don't have a pattern, then it's a bit more difficult I suppose.
08:44fsmi am now at the point where about half my CPU time is in calculating dot products, and i think that is limited by the jvm
08:45Chousukeare you using clojure vectors or arrays or something java?
08:46fsmi am using double-arrays, once Rich & co put the pieces together for me about how to avoid boxing/unboxing
08:46fsm(actually just changed to floats, which was worth another 30% boost)
08:46fsmit is interesting that sometimes where you are tempted to use macros, the code runs slower
08:47fsmapparently the jvm hotspot stuff is clever, and/or it is more important to stay in cache
08:47Chousukeheh
08:47Chousuketoo much inlining can harm performance because code doesn't fit in cache.
08:48Chousukeso it may actually be faster to do lots of function calls than to inline the function at the call sites.
08:49tomojI am glad I don't need to understand that stuff :)
08:49fsmsomeone posted the link on hacker news the other day, and i got a couple thousand visits
08:49fsmthere is quite some interest in clojure i guess
08:49Chousukeof course, hotspot is designed to let you stop worrying about such things.
08:50Chousukeideally, you just write functions and use them normally and hotspot inlines them if needed
08:50liwpChousuke: also, the JVM will only optimise code below a certain size, so if you function is too large HotSpot will ignore it.
08:50liwpBut I have no idea how this applies to code generated by the Clojure compiler...
08:53fsmanyway, the main thing is I am confident that clojure is not causing any particular performance drop over java, having looked through the profiling results
08:53NeronusWell, as clojure functions are (I believe static) java functions, and at least my clojure functions are pretty short (especially to some java methods I've seen and written), my guess would be, that functions generated by clojure tend to be pretty short
08:55Chouserfsm: what was the popular link?
08:55fsmoriginally, it was http://tu.be/tracer but it is now hosted at cray.googlecode.com
08:56liwpNeronus: sounds reasonable. So is each clojure function compiled into a Java class with a static member function and that function implements the clojure function?
08:56Chouserah, your ray tracer. very good.
08:56fsmI think someone was watching the clojurebot's del.icio.us feed
08:56Chousera clojure function is compiled to a Java class with an instance function named 'invoke'
08:56clojurebotclojure is a language to use if you want to up your game
08:57liwpChouser: and there is one class per clojure function?
08:57Neronusliwp: That's what I imagined, but I wouldn't bet my life on it. OTOH, clojure functions implement clojure.lang.IFn, so I guess they are instances of some kind :)
08:57Chousereach different-arity body in the fn becomes a matching-arity overload of the 'invoke' method
08:58liwpok
08:58Chouserthere is one class per fn, one instance of it per closure
08:58Chouserthe class ctor takes args for the values it closes over
08:59tomojso an anonymous function in a loop means a fn class is instantiated each time through?
09:00carkjust like in c# =)
09:00tomojer, actually I guess there's only one closure there?
09:00cark~function is also <Chouser> there is one class per fn, one instance of it per closure
09:00clojurebotAlles klar
09:00tomojwell... now I'm confused
09:00AWizzArdChouser: do you know if it is possible to declare/type-hint the return value of a function?
09:01ChousukeI suppose in a loop you'd be generating multiple closures :/
09:01ChouserAWizzArd: (defn #^ReturnType foo [])
09:01tomojbut e.g. map with an anon function is just one closure
09:01Chouser,(let [fns (for [i (range 3)] (fn [j] (+ i j)))] ((second fns) 3))
09:01clojurebot4
09:02AWizzArdChouser: good, thanks.
09:02Chouserthere we have one class for (fn [j] ...), with three instances stored in the fns seq
09:03Chouserthe ctor to that class takes a single arg, the value of i for that instance.
09:03Chouserhere's an implementation detail I learned recently. I wouldn't bet on this working in future until you hear otherwise:
09:03Chouser,(let [fns (for [i (range 3)] (fn [j] (+ i j)))] (.i (second fns)))
09:03clojurebot1
09:04liwpheh
09:04Chouserthe closed-over value is currently stored in a public field with the same name as the local you closed over
09:05liwpsounds like something that will not work in the future with all likelyhood ;_)
09:15fsmok, i changed from agents to pmap
09:16fsmnow, the overhead of parralelizing my code is barely more than adding a setting for number of cores, and adding the letter p
09:19fsmand, any possible thread-unsafe code is confined to one line
09:22fsmthere are obvious possibilities in increasing developer mean time to heart attack
09:24AWizzArdCan one make doseq or map work with a java.util.Enumeration?
09:24Chouser,(doc enumeration-seq)
09:24clojurebot"([e]); Returns a seq on a java.util.Enumeration"
09:25AWizzArdthx
09:26konrwhat do you use as shortcuts to evaluate form, evaluate file, open repl, etc?
09:29AWizzArdin Emacs?
09:30konror in any editor... I want to bind my keys in vi, but not sure what to
09:30mikemkonr: for vim, you want to check out vimclojure
09:30mikem~vimclojure
09:30clojurebotvimclojure is http://kotka.de/projects/clojure/vimclojure.html
09:31konrmikem: haha, I use it, but it doesn't set keybindings
09:31mikemkonr: it does for me... have you looked in the docs?
09:32mikemkonr: by default each command is preceded by <leader>, which in vim by default is \ (backslash). so to start the REPL, for instance, I type \sr
09:33konrmikem: hmm, it also does that for me, but isn't it a little inconvenient to type three keys [\ e t] to do that? I'm considering changing that to C-something
09:41mikemkonr: there's a blurb in the doc file (~/.vim/doc/clojure.txt) about mapping commands to keys but first prepending them with <Plug>Clojure. have a look
10:14konrmikem: thanks, I'll take a look!
10:50ankouhi is Programming Clojure still a beta book or is it finally finished?
10:51Chouserankou: you can buy it in book stores
10:52ankouI would prefer to have it as an ebook
10:53Neronusankou: Chouser provided the answer: You can buy it in stores, ergo it is no beta book anymore
10:53ankoumakes sense, thanks
11:04krumholt__ankou, you can buy it in pdf format
11:04ankouI just did it:)
11:04weissjanyone know if it's still being updated?
11:07liwpdoes anyone heard anything of this: Definitive Guide to Clojure (The Definitive Guide) by Luke VanderHart
11:07liwpI didn't know that there was another clojure book in the works...
11:10ChouserI seen the web page for that, plus heard about 1 or 2 more in the works besides.
11:10ChouserI had seen
11:18ChouserLicenser_: in what way is clojure bundled tightly with XML?
11:33leafwhi, any alive
11:34leafwI would like to understand the following destructuring: [k & ks :as keys] keys
11:34leafwthis is a slot in a let declaration in the first part of Rick's talk on clojure for lispers
11:35leafwso what is ":as keys" doing?
11:35Chouser,(let [[k & ks :as keys] (range 5)] {:k k :ks ks :keys keys})
11:35clojurebot{:k 0, :ks (1 2 3 4), :keys (0 1 2 3 4)}
11:35leafwaha
11:36leafwit preserves the whole, beyond the destructuring part.
11:36leafwthanks Chouser.
11:36leafwa pointer to the whole, rather.
11:36Chouser:as binds something to the whole original collection
11:36Chouserright
11:36Chouser,(let [[k & ks :as keys] '[a b c d e]] {:k k :ks ks :keys keys})
11:36clojurebot{:k a, :ks (b c d e), :keys [a b c d e]}
11:37Chousernote it doesn't even call seq on the collection before it binds
11:37leafwaha, so its the exact thing.
11:37Chouserright
11:37leafwmakes sense.
11:37leafwi.e. what I'd expect.
11:58LicenserChouser: sorry I was ofline
12:03LicenserLike the biggest part of the libraries on the clojure page is 'Category: xml'
12:05Licenserand in a lot of places I found mentioned that Clojure is good for working together nicely with XML
12:05Chousukethat has little to do with Clojure itself. It just shows people need XML tools :)
12:06rsynnottlots of them, to try to make working with xml a little less hideous
12:06ChousukeI think Clojure is just pleasant for XML work because it's easy to build a DSL for representing XML as clojure data structures.
12:07Chousukeand because it's so easy, everyone has their own :P
12:07Chouserthe jvm ships with an xml parser with a horrible api, so it's natural to provide a nice api wrapper around it
12:08Chousukebesides, XML is not that bad.
12:08Chousukesure, it's overused and abused (ant...) but it's pretty good still.
12:09Chouserbetter than everyone rolling their own packed binary format
12:09Chousukeyou have a way for describing your data in a way that lets you to stop worrying about writing a checker for well-formedness etc.
12:10ChousukeI don't know if there are any tools for writing schemas for json or validating against such, but I'm not aware of any :/
12:10Chousukefor XML, you have eleventy billion implementations.
12:16ChousukeApparently I can't use them from my reader, even though it's clojure.lang.reader :/
12:19ChousukeI guess I could make a macro using reflection to get around pesky access restrictions.
12:20LicenserI find XML hugely overused
12:20Licenserit is often used when other things are way simple
12:20carkhum by the way ... how do i do this : i have a with-something macro, and it's supporting with-something* function, the function is declared private. when i call the with-something macro from another namespace, i get an error
12:20carkbecause the function is private
12:20Licenserlike ant, or the java web application stuff, tomcat etc
12:21carkso the question is this : how would i go about calling this private function from my macro
12:22OlafG26784859392Hey people
12:22rottcoddcark: I think this works (#'ns/fn args)
12:23carkah thanks i'll give it a try
12:23OlafGThat's better
12:24OlafGI need some help
12:25rsynnottChousuke: none of which work properly ;)
12:25rsynnott(I'm thinking particularly of SOAP, here)
12:26OlafGI want to run a clojure script
12:26OlafGbut I'm not sure how to install it correctly on ubuntu server
12:46ChouserOlafG: fetch the clojure jar, then: java -cp clojure.jar clojure.main your-script.clj
12:47OlafGYeah, I found a guide
12:47OlafGand, you're the guy I'm looking for
12:47OlafGhehe, I want to use your irssi to html script
12:47weissjin a related question, how to i run the repl and have it automatically load a file without havnig to first call (load-file) at the prompt
12:48OlafGChouser: Can't seem to be able to download it from github though :/
12:48carkweissj : clojure automatically loads user.clj from the classpath
12:49weissjcark: so my file has to be named user.clj? or maybe i can just put the load-file call there?
12:49carkeither way =)
12:49weissjcark: cool
12:51Chousukehmm
12:51Fossihi
12:52ChousukeI somehow managed to get them unbalanced.
12:52Fossidoes somebody know a quick way of adding a java classpath to swank? i'm sick of having to put them in my .emacs
12:52Chousukealso, symbol resolution is insane business.
12:52FossiChousuke: C-SPC right C-X or such ;)
12:53OlafGargh
12:53Fossiat least with CUA you can force fix them
12:53Fossi(and also break them quite easily)
12:53Chousukehm
12:53ChousukeI force-inserted a rebalancing paren and deleted the extra sexp :P
12:54Fossito the point that i think about mapping everything to sexp handling and get rid of backward-kill-word and left/right and so on
12:54Fossiit's annoying
12:54OlafGwow, clojure sounds like complicated shit
12:54krumholt__is there a way that load-file will not load a file form by form? i want to write a function foo that uses a function bar. now i have to defn bar above foo or the file will not load. is there another way of loading the file?
12:54FossiOlafG: it's the shit. might get compilicated if you want to ;)
12:55OlafGHehe, firstly I just want to run a script, but not sure if I can mange even that:P
12:55carkkrumholt__ : you can use declare
12:55carkthough that's not exactly what you asked
12:55rhickeyNice: https://jira.terracotta.org/jira/browse/CDV-1171
12:57krumholt__cark, then i would still have to declare every function. i want load-file to figure out the order of evaluation for me :)
12:57ChouserOlafG: you're having trouble downloading clojure.jar or the irssi stuff?
12:57OlafGirssi stuff
12:57OlafGalso, last time i tried I couldnt run it
12:57Fossiso i guess that's a no then for my emacs/swank question? :(
12:58carkkrumholt__ : what if you have mutually recursive functions ?
12:58Chouserwell, I put it up on github more for transparency and backup purposes than with the thought that anyone else would want to use it.
12:58OlafGoh, haha, was googling for a way to convert irssi logs to html
12:58carkkrumholt__ : anyways i guess you could read form by form do your ordering then evaluate ...but it seems fragile
13:00rhickey:( https://jira.terracotta.org/jira/browse/CDV-1238
13:00ChouserOlafG: it may be useful to you as a starting point, but it's not packaged up or particularly pretty. You'll probably have to adjust the code at least a little.
13:00OlafGOh
13:00carkkrumholt__ : you would need a code walker, and macroexpansion ... which might not work if the macros are not defined yet
13:01Chouserrhickey: that should be too terrible for Clojure code, should it? who uses 'identical?' on strings?
13:01krumholt__cark, i guess my question just was. is there already a way to do it or do i have to do it myself
13:02rhickeyChouser: symbols and keywords do
13:02OlafGChouser: Do you know another way to convert them to html and maybe split them? I really liked the splitting thing
13:02carkkrumholt__: i think you'll have to do it yourself
13:03rhickeyprobably only an issue for the few symbols/keywords created in the Java code with string literals, relying on the interning
13:03clojurebotfor is a loop...in Java
13:04cemerickrhickey: all strings going into Symbol are interned, so this shouldn't be an issue, should it?
13:05rhickeySymbol.create allows you to create a symbol from a known-interned string
13:05cemerickah, I've never used create
13:06cemerickI'd say, drop Symbol.create...two extra intern calls aren't going to hurt anything?
13:06rhickey59 uses in Clojure impl
13:07rhickeyeasy enough to make create call intern anyway
13:07cemerickeven so -- I can imagine most people not knowing/caring what string interning is, and using Symbol.create.
13:08liwp`is there an (all?) predicate in core?
13:08liwp`or contrib
13:09cemerick,(doc every?)
13:09clojurebot"([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
13:09liwp`thanks
13:10Chousuke,(identical? `+ `+)
13:10clojurebotfalse
13:10Chousukehmm, good. :P
13:11Chousukethough I'm still not sure if I'm creating symbols properly in my resolve-symbol function :/
13:11rhickeyhttps://www.assembla.com/spaces/clojure/tickets/182
13:11Chousukeit feels very hacking to create symbols and then use str on those symbols when feeding them as parameters to (symbol ...)...
13:11Chousukehackish
13:12rhickey,(symbol 'foo)
13:12clojurebotfoo
13:12cemerickrhickey: what sort of API compat are you assuming on the Java back-end? e.g. you might as well eliminate Symbol.intern AFAIC
13:13Chousukerhickey: oh, it works on symbols too. duh. I wonder why I thought it would need strings :/
13:14rhickeycemerick: I don't want to eliminate anything at the moment
13:15Chousukehttp://gist.github.com/174831 here's what I have right now. it seems to produce the correct results for most things.
13:17rhickeyVery pretty Tom - thanks! http://richhickey.github.com/clojure-contrib/
13:18rhickeyWhat do we need to do the same for Clojure core API docs?
13:20weissjhas anyone had any experience trying to attach eclipse debugger to clojure's jvm?
13:23rhickeyweissj: while it should 'just work', there can be issues in that these IDE debuggers presume the code will be Java - but give it a try, Clojure does support JSR-45, you might need to tell the debugger where the Clojure source is. JSwat works w/o any explicit Clojure support, and NB+enclojure, IntelliJ+LaClojure have explicit support
13:24weissjrhickey: ok, i'll give it a try and post the results here
13:24weissji can't deal with netbeans, it runs too slow on this machine
13:28replacarhickey: no problem!
13:29replacarhickey: I need to think about the core stuff a little bit more. Mostly, I just need to parameterize a bunch of stuff, but there'll be some magic getting and running the right version
13:29replacarhickey: I'll prototype on a fork, then we can discuss
13:37weissjhm, i am not able to set breakpoints in clojure files in eclipse ui. is there some other way to set them?
14:06alrex021I am trying to give clojure-maven-plugin 1.0 a spin but am struggling a bit to get it to work. (Example thats in git is our of date and doesn't run my end) Anyone using v1.0 of the plugin?
14:11fdaoudalrex021: I managed to get something to work
14:12alrex021fdaoud: I just changed the plugin info to point to new groupId etc... that seems to be going..
14:12fdaoudright
14:12fdaoudI don't think I needed to do anything else special
14:14alrex021I now get "2 required artifacts are missing. ... 1) com.theoryinpractise:clojure-maven-example:jar:1.0-SNAPSHOT 2) org.clojure:clojure-contrib:jar:1.0-SNAPSHOT"
14:15alrex021no 1 seems to be referring to the example itself
14:18fdaoudalrex021: right, I changed that to something like hello/hello
14:21LauJensenCan new new be used to extend existing classes?
14:21fdaoudalrex021: I also think that the plugin is fussy about the namespace, the name of the source file, and the directory where the file is located
14:23ChouserLauJensen: that's all it can do
14:23LauJensenChouser, extend something like JLabel by adding/overriding methods ?
14:24Chouserit can't add methods
14:25Chouseroh... "you can add new (e.g. helper) methods not in any super, must have different name (can't add overloads to supers). No way to call those from outside the methods other than via reflection"
14:26LauJensenOk, So no means yes :)
14:26Chouserbut no way to supply args to the parent class' ctor
14:27LauJensenk - I dont recall ever having had that need
14:28ChouserI've used that feature of proxy several times, but there are often other ways to solve such problems.
14:29LauJensenInterop tends to get messy... when I do it
14:31LauJensenMy return from using new new, would that then be this potentially anonymous class that I can interact with throughout my code?
14:35Chouseryes
14:35alrex021fdaoud: I got my own example to work now. Just need to add diff remote repo as maven default didn't seem to have org.clojure artifacts.
14:37LauJensenNew new will really put me back in business with my JMonkeyWrappers. I choked on the interop
14:39ChouserLauJensen: nearly anything you will be able to do with newnew you can already do with proxy, except on the performance front.
14:39fdaoudalrex021: which repo did you use? i think i found it on tapestry
14:39LauJensenChouser - I cant remember what exactly it was, but I got very far with proxy, and then this...
14:39LauJensen~proxy
14:39clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
14:39Chouseryeah. I'm not sure how much newnew will help you there.
14:40alrex021fdaoud: http://tapestry.formos.com/maven-snapshot-repository/
14:40LauJensenIf I can both add and override methods, It'll get me where I need to go
14:40Chouserin fact, it may be worse. newnew is primarily about creating new clojure stuff that runs very fast. proxy is primarily about java interop.
14:41ChouserI think it's more likely that proxy will gain more interop features than that newnew will.
14:43LauJensenHmm.. The main archetecture of JMonkey, is that you get a few basic classes that you extend into objects that govern every part of the game, ie weatherobject, physicsobjects, vehicleobject and so on. Proxy couldnt do it and I didnt have the patience for gen-class.
14:46ChouserI think it would be possible for proxy to provide a thread-safe way to call superclass methods, like gen-class :exposes
14:47Chouserwell, both :exposes and :exposes-methods
14:48Chouserthat would reduce proxy's tendency toward betrayal a bit
14:48Chouserproxy's pattern for doing init and post-init is already better than gen-class'
14:52LauJensenok... I really wouldnt know :)
15:16Fossi"This kind of lexical intercourse" <3 graham
15:27hiredmanholy dependency downloads batman
15:28hiredmanrunning ant in a checkout of clojureql's repo downloads ivy, then uses ivy to download clojure, clojure-contrib, apache derby, etc
15:30hiredmanjava.lang.Exception: Unable to resolve symbol: lazy-cons in this context (backend.clj:81)
15:30hiredman:(
15:31hiredmanah, old clojureql jar hanging around
15:37Fossirecently i had a case where i had a pattern for map entries: key and some rather largish codeblock that only differed in a few spaces
15:38Fossiis there a way to capture that into a macro without wrapping the whole or leaving the key part out?
15:38Fossii can't return 2 distinct values from macros or is there a way?
15:40tomojFossi: huh? what do you want to do
15:40ChouserI don't understand what you're trying to do. You're right that a macro can only return a single form, but often you can use (do first-thing second-thing)
15:40Fossilet me try to scetch that up
15:40Fossilisppaste8: url
15:40lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
15:44lisppaste8Fossi pasted "untitled" at http://paste.lisp.org/display/86027
15:44Fossiit was a little more bloated on the right, but something along those lines
15:44Fossiand i have a whole bunch more of those handlers
15:46Fossiand i wanted to keep the "token" along with the handler in the definition although it wouldn't really be needed in any of the cases (yet)
15:47Chouserhandle-stuff is a fn -- you want to call the same one for each value, just with different args?
15:50Fossiactually, the handle-stuff isn't even in there
15:51Chouserok. well, anyway, I doubt you need a macro
15:52Chouserhow about (-> (add-handler "token1" render-func1 :option1 true) (add-handler ...))
15:52Chouserer
15:52Fossiwell, ok, might work with a function as well
15:52Chouser(-> {} (add-handler "token1" render-func1 :option1 true) (add-handler ...))
15:52Chouserthere
15:52Fossiyeah, that's what i meant with "wrapping the whole"
15:53Fossiit changed the structure of the code
15:53Fossii didn't want to do that
15:53Fossi*changes
15:53Chouserthen (defn add-handler [the-map token-key render & options] (assoc the-map token-key {:render-func render-func ...})
15:54Chouseroh, you want to keep { ... } around the whole thing?
15:54Fossithat's why i suspected a macro might help. to generate something in that place without changing the map structure
15:55Fossiwell, it's pretty much random, so i might actually, practically change it later, but i wanted to know whether it's possible somehow
15:56Fossibut if i can only return a list from a macro or function i don't see how
15:56Fossi*single
15:56Fossii guess i could wrap the whole into another macro
15:57Chouserit's an interesting thought. one could almost wish for a defsplicemacro that always returns a seq of things to be spliced in.
15:58Fossii think the wrapping macro idea would work without changing the structure too much
15:58Chouserwell, you wouldn't need your own wrapping macro. -> already exists and would suffice in this case I believe.
15:59Fossiie, just having a macro around that changes {(macrocall) (macrocall)} into {(first (macrocall)) (rest (macrocall))...
16:00Chousuketoo bad you can't just do `{~(generate-code) ~(generate-code)} :/
16:00Fossiah. well -> wouldn't let me keep the 'mappiness'
16:00Fossii guess
16:01Fossii now realize this would be a really stupid place to do this anyway ;D
16:01Chousuke,`{1 ~@(list 1 2 3)}
16:01clojurebot{1 1, 2 3}
16:01Chousuke,`{~@(list 1 2 3 4)}
16:01clojurebot1
16:01Chousukereader problem :/
16:02Fossihmmm. interesting idea though
16:02Chousuke,{1}
16:02clojurebotjava.lang.ArrayIndexOutOfBoundsException: 1
16:02Chousukehmm
16:02Fossigotta love those error messages
16:03Chousuke:)
16:03Fossiat first you go "wtf"
16:03Fossithen it's "WTF?!!!"
16:03Chousukethe implementation just shines through a bit :P
16:03Fossiand after a while it's just "oh, i forgot a value in some map. ah, there it is"
16:04Fossi"a bit" ;D
16:07FossiChousuke: so, why exactly doesn't that work?
16:10ChousukeFossi: I'm not sure.
16:10Fossiit almost seems to do what i want
16:11ChousukeFossi: probably because in {~@(whatever)} the map only has one element so it can't be read in the first place, but in {1 ~@(whatever)} there are two elements so the map can be read before the splicing happens.
16:11Chouserwell, you're still wrapping the whole thing, if only in a `
16:12Fossiagreed, but it seems there is no way without wrapping the whole
16:15hiredmando clojureql calls need to be wrapped with something besides with-connection?
16:15hiredmanI run my insert-into statement, get {:table jobs, :columns (:name), :env ("Rascals")} back, but the table appears to be empty
16:19Fossin8
16:40wavisterdoes memoize use soft references?
16:41hiredman~def memoize
16:41cark~def memoize
16:41cark!
16:41hiredmanugh
16:41hiredmanchrome does not like github
16:41carkworks for me
16:41hiredmanlooks like it uses a normal persistaent map
16:43alrex021in clojure is there a way to get the name of function that we are currently in? (Something like in java ..this.getClass().getName())?
16:43wavisteryup... ok. but that's cool. i could re implement that with a weak map or something
16:47Chouseralrex021: for logging or something?
16:47alrex021yes, exactly, very simple logging using println to be exact
16:48alrex021I'm in -main, so want to print .... (println fn-name " .... ")
16:48alrex021or any other func for that matter
16:49ChouserI can't think of any way to get that currently
16:51alrex021No worries, I take its something you wouldn't want to perhaps do often in fp. I'm curious to know though how does logging framework, if currently any, handle this?
16:51Chousernot all code has a top-level fn name that would mean anything
16:52Chouseryou can get the current file name
16:52Chouser,*file*
16:52clojurebot"NO_SOURCE_PATH"
16:53Chouser,(.getLineNumber (first (.getStackTrace (Exception.))))
16:53clojurebot0
16:54Chouserthat could get you a line number at runtime.
16:54ChouserI suppose between the two, you might be able to find the .clj source and construct an appropriate name
16:55alrex021Chouser: thanks
17:42krumholt__there is no difference between a struct and a map or is there? a struct is just a nice way if you have to create a similar map over and over again?
17:43citizen428i'm trying to download a file via http from within my clojure program... i was thinking duck-streams, but i can't seem to figure it out. any pointers?
17:46replacacitizen428: there's a nice example on the doc for http-agent for doing an http download with duck streams
17:47replacahttp://richhickey.github.com/clojure-contrib/http.agent-api.html
17:47citizen428replaca: really? i have looked for something like that half the day... :( thanks a lot!
17:48Chouserkrumholt__: a struct is a kind of map. other kinds of maps include hash-maps and sorted-maps.
17:48replacacitizen428: np
17:49ChouserI do wish for better string and char literals. Perhaps I should give some thought to what they would be...
17:53krumholt__Chouser, so they are all maps with different implementations? but they do the same thing. should this bother me in any way?
17:54Chouserkrumholt__: they each have their own benefits and drawbacks, but all provide a common interface and make a common set of promises. This should make you joyful. :-)
17:55Chouserfor example, you can use assoc to insert a key/value into any of them, they will all do this persistently -- a common interface with a common promise
17:55krumholt__Chouser, so in the end i coult just change (def foo (hashmap ...)) to (def foo (sorted-map ..)) and everything still works. ok then i will worry about what the benefits of each map type are later
17:55Chouserthat's right.
17:56krumholt__thanks
17:57Chouserwell, everything that's promised will work. From the docs, "Hash maps require keys that correctly support hashCode and equals. Sorted maps require keys that implement Comparable, or an instance of Comparator."
17:57Chouserlots of objects provide both and so can be keys of either.
17:57krumholt__i use keywords as keys
17:58Chouserthose will work great in hash maps, sorted maps, struct maps, and array maps. :-)
17:59krumholt__ok thanks :)
18:24mudphonehey folks, anyone know what the type hint is for a String array?
18:24mudphoneor better yet, where I can find a comprehensive list of type hints?
18:28krumholt__i would guess you can type hint every java class?
18:29mudphonewell, my questions is... for example, for an array of bytes, the type hint is #^bytes
18:29mudphoneI want to know what the type hint syntax is for a String[]
18:29hiredman,(class (into-array ["foo" "bar"]))
18:29clojurebot[Ljava.lang.String;
18:29mudphone#^Strings
18:29hiredmanmudphone: why are you type hinting an array of strings?
18:30hiredmanno
18:30hiredman#^bytes and such are special cases hardwired into the compiler
18:31mudphonewe're calling a Java library
18:31mudphonehiredman: thanks, but why do you ask? Is it a bad idea?
18:32mudphonethe library takes a String[] as one of its arguments
18:32mudphonewe're wrapping it
18:32hiredmanmudphone: just pass it a String[]
18:32hiredmanno need for type hinting
18:33mudphoneWon't it use reflection to make the Java call then?
18:33hiredmanmudphone: I am pretty sure it won't
18:33mudphonewe profiled our process and saw a lot of time in reflection (in general)
18:33hiredmanyou can set *warn-on-reflection* and see
18:34hiredmanthe reflection stuff happens because the type signauter for clojure Fn's is all based on Object
18:34hiredmanbut jave methods have specific type signatures so reflection should not be needed
18:34mudphonefot the *warn-on-reflection* setting, where do we set that? and trigger it?
18:35mudphonehiredman: hmm
18:35hiredman(set! *warn-on-reflection* true)
18:35hiredman,(doc *warn-on-reflection*)
18:35clojurebot"; When set to true, the compiler will emit warnings when reflection is needed to resolve Java method calls or field accesses. Defaults to false."
18:35mudphonedo we have to compile to see that? or just run as normal?
18:35mudphone(ie ahead of time)
18:36hiredmanno, you don't need to do aot compiling
18:36hiredmanjust keep in the mind warning happens at compile time (when code is loaded) as opposed to when it is running
18:36mudphoneso you just see standard output then?
18:37mudphoneah
18:37hiredmanp=> (defn f [x] (.toString x))
18:37hiredmanReflection warning, NO_SOURCE_PATH:234 - reference to field toString can't be resolved.
18:37mudphoneso, for example, eval-ing the buffer in emacs will give you your warning?
18:37hiredmandunno, don't use emacs
18:37mudphonewhat editor do you use?
18:37hiredmanvim
18:38mudphoneah
18:42hiredman~performance
18:42clojurebotTitim gan éirí ort.
18:42hiredmanbah
18:43hiredman~performance is <reply>http://clojure.org/java_interop#toc46
18:43clojurebotOk.
18:43mudphonehiredman: thanks, it gives the warning in via the slime repl (in emacs), in case you ever come to the dark side
18:45jfieldswhat would I used in clojure to create a single result from a seq. I'm looking for something similar to Ruby's inject.
18:46mudphonereduce?
18:46mudphone,(doc reduce)
18:46clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the r
18:46jfieldscool. thanks.
18:47hiredmaninject is such a weird name for that
18:47clojurebotfor is not a loop
18:48hiredmanclojurebot: shut it
18:48clojurebotTitim gan éirí ort.
19:03bitbckthiredman: That's why it's aliased as #reduce in Ruby 1.9... thankfully.
19:03bitbckt(and finally)
19:37lowlycoderis there a good example of a clojure server serving clojure repls over tcpip anywhere?
19:51tomojlowlycoder: well have you seen http://richhickey.github.com/clojure-contrib/server-socket-api.html ?
19:51tomojnot an example,but..
19:51carkdoesn't swank just do that ?
19:52tomojif you run your code inside emacs, I guess?
19:52carkyou can use swank without emacs
19:53tomojI'd love to see an example of that too, then :)
19:55mikemthere's also the nailgun server that comes with vimclojure
19:55bryteisehttp://blog.asymmetrical-view.com/2009/08/20/emacs-slime-remote-repl.html
19:55lowlycodertomoj: nice; thanks
19:55lowlycoderi find nailgun/vimclojure to be unstable
19:56lowlycoderthe code is so short and elegant, there must be a catch
19:56tomojbryteise: awesome, thanks
20:24carkdid compojure's redef eventually make it to contrib ?
20:42Chousershould clojure finger-trees be designed with an eye toward IEditableCollection?
20:42clojurebotclojure is like life: you make trade-offs
20:42Chousershould they produce seqs with chunks of 2 to 4, or just non-chunked seqs?
22:11hiredman~ping
22:11clojurebotPONG!
22:19hiredmanclojurebot works on a newer fnparse, if anyone cares
22:19dmixI can't get slime to work with swank for some reason, when I hit M-x slime I get this error (in aquamacs): http://gist.github.com/175252 this is my .emacs http://gist.github.com/175255
22:21hiredmanlooks like swank is not on your classpath
22:21JAS415yep
22:21dmixhow do I add it to my classpath?
22:21hiredman~classpath
22:21clojurebotclasspath is (System/getProperty "java.class.path")
22:22dmix"/Users/dmix/src/swank-clojure:/Users/dmix/Library/Clojure/lib/clojure.jar:/Users/dmix/Library/Clojure/lib/jline.jar:/Users/dmix/Library/Clojure/lib/clojure-contrib.jar"
22:22dmixer
22:22dmixso it is in the classpath
22:22dmixswank-clojure
22:23JAS415so you can add it to the .clj or i think there is an emacsen way to do it
22:23hiredmanuh
22:23hiredmanwhat is in /Users/dmix/src/swank-clojure?
22:23dmixhiredman: swank-clojure.el swank/ etc
22:24hiredmanjust because you have some directory that has "swank" in it's name on your classpath it does not mean swank is on you classpath
22:24hiredmanwhat is in swank/
22:24dmixa bunch of clj's
22:25dmixie swank.clj
22:25hiredmanthat sounds good
22:26hiredmanmaybe add a "/" after swank-clojure
22:26JAS415can't you do wildcards
22:27hiredmanJAS415: if he has JDK1.6 he can
22:27JAS415I have one that is '~/hacking/clj/current-work/*:'
22:27JAS415it loads all of my 'current work'
22:27JAS415although right now that's a mash of things
22:28JAS415so could do same with swank folder
22:28JAS415needs the : after the * though, for some reason..
22:32dmixalright, got it working, I cloned the latest git swank-clojure and put it in a new folder, then added it to the class path
22:32dmixthanks btw
23:27djkthxis there a short-hand for defining a case-insensitive regex using the # reader macro?
23:35hiredman,(re-find #"(?i)foo" "FOO")
23:35clojurebot"FOO"
23:35hiredman(?i) means case insensative in java regexs
23:36djkthxah, interesting
23:36djkthxi was always used to seeing it like /asdf/i
23:36djkthxthanks!
23:49mebaran151I can't seem to get the new enclojure plugin to work: it can't find clojure contrib pretty print even thought clojure contrib is in my classpath
23:49mebaran151anybody have any tips?
23:51hiredmandid you compile clojure contrib properly?
23:58mikemhiredman: do you mean compiling it like so: ant -Dclojure.jar=../clojure/clojure.jar
23:59hiredmanyes