#clojure logs

2009-11-22

00:04JAS415what are you looking to do?
00:05hiredmanparse sublists out of a list
00:16JAS415,(def positions)
00:16clojurebotDENIED
00:16JAS415,clojure-contrib.seq-utils/positions
00:16clojurebotjava.lang.ClassNotFoundException: clojure-contrib.seq-utils
00:17JAS415that's strange
00:17hiredmanJAS415: clojure.contrib
00:21JAS415ah
00:25JAS415hmm need to update my contrib
00:36lisppaste8JAS415 annotated #90883 "little updated" at http://paste.lisp.org/display/90883#1
00:38JAS415is shorter anyway
00:57qedJAS415: nice
00:58qedJAS415: efficiency or not, that is way cleaner
01:04JAS415yeah, clojure-contrib is both huge and awesome
02:58technomancyanyone else noticing ns metadata disappearing for AOT'd namespaces?
02:58technomancy(except clojure.core, since it adds in metadata after the fact with alter-meta!)
03:22kzarHow can I access the three values of something like this? #<Color java.awt.Color[r=255,g=255,b=255]>
03:24hiredmankzar: thats from the .toString method of Color
03:24_ato(.getRed color)
03:24hiredmanI would call bean on it and see what you get
03:24_atokzar: http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html
03:26kzarcool beans, I like that bean command
03:26kzarthanks everyone
03:26kzar,(:red (bean (new Color 250 251 252)))
03:26clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: Color
03:30kzarso that page said there's a contructor that takes an alpha channel parameter, a float between 0 and 1. It is OK if I pass 0 or 1 but if I pass something like 0.2 I get an error "No matching ctor found for class java.awt.Color"
03:40kzaroh I think I see
03:41kzarsorry that was dumb, the constructor either took all floats or all ints, I tried to pass mostly ints but a float alpha channel. So there wasn't a matching constructor.. ctor stands for contructor
04:05technomancybrowsing the github clojure projects... I am really curious what this one does: http://github.com/zahardzhan/leica
04:06_atoha, google translate says "Multi-swing for datakoda and fayloobmennikov local dsvload.net."
04:06_atothat's just as meaningless as the russian
04:08kzarseems to be a scraper downloader for some site "data.cod.ru"?
04:11hiredman_looks like some kind of client for http://translate.google.com/translate?js=y&amp;prev=_t&amp;hl=en&amp;ie=UTF-8&amp;u=http%3A%2F%2Ftime.cod.ru%2F&amp;sl=ru&amp;tl=en&amp;swap=1
04:13hiredmanclojurebot: translate from ru leica
04:13clojurebotleica
04:14hiredmanclojurebot: translate from ru Лейка
04:14clojurebotLake
04:14hiredmancode be a pun
04:14hiredmancod and lake
04:15hiredmanbut I think cod are a salt water fish
04:15hiredmancould
04:22FigsHi
04:24FigsI'm trying to do a bit of string processing work in clojure, but I'd rather like to keep my algorithms generic since I expect I will want to use them on lists at a later point; after I perform an operation like (drop 3 "hello"), I wind up with a result like (\l \o). How can I convert this back to a string from a lazyseq for printing or other use?
04:25kzar,(apply str (drop 3 "hello"))
04:25clojurebot"lo"
04:26FigsWhy does (apply str ...) give the correct result, but (str ...) does not?
04:26FigsDoes it change the order of evaluation?
04:27hiredmanbecause str on a single object just calls .toString on that object
04:27hiredman,(str '(\a \b \c))
04:27clojurebot"(\\a \\b \\c)"
04:27twbrayFigs: apply de-listifies a list and feeds it to a function as args
04:27hiredman,(.toString '(\a \b \c))
04:27clojurebot"(\\a \\b \\c)"
04:27kzarI think it's because it does something like (str (str \l) \o)
04:27hiredmannope
04:27kzarok whoops
04:27kzarso what does it do?
04:28hiredmanstr on multiple objects uses a StringBuilder
04:28hiredman~def str
04:28twbray,(str '("foo" "bar" "baz"))
04:28clojurebot"(\"foo\" \"bar\" \"baz\")"
04:28twbray,(apply str '("foo" "bar" "baz"))
04:28clojurebot"foobarbaz"
04:29hiredman,(.toString '("foo" "bar" "baz"))
04:29clojurebot"(\"foo\" \"bar\" \"baz\")"
04:30kzarso (apply str (drop 3 "hello")) is like doing (str \l \o) ?
04:30_atoyep
04:30kzargotya ok
04:30Figs,(str \l \o)
04:30clojurebot"lo"
04:30Figsah, I see.
04:30twbray,(. "hello" substr 3)
04:30clojurebotjava.lang.IllegalArgumentException: No matching method found: substr for class java.lang.String
04:31twbray,(. "hello" substring 3)
04:31clojurebot"lo"
04:31hiredman:(
04:31hiredman(.substring "hello" 3)
04:32twbrayhiredman: I prefer my flavor, but tastes vary.
04:32hiredmantwbray: .substring is the prefered syntax
04:32twbrayhiredman: Not disputing your right to prefer it :)
04:33FigsThere's a parsec-like library for clojure, as I recall... does it handle processing lists as well as strings?
04:33twbrayI'm coming from Java & Ruby, so I think like "foo".substring 3, that O-O stuff infects your brain after a while
04:34FigsI can't remember the name of it
04:35FigsOh, nevermind. I found it. It's just called parser.
04:36hiredmantwbray: the naked . syntax doesn't distinguish between static and instance methods
04:36twbrayhiredman: Well, it's visually obvious
04:37twbray,(. java.nio.charset.Charset forName "UTF-8")
04:37clojurebot#<UTF_8 UTF-8>
04:39twbrayhiredman: I'm only a Clojure n00b, but as a person coming from javaland, the naked . gives me a mechanical pattern for transforming back & forth between Java & clojure calls with things being in the same order
04:40twbrayso it feels comfy. But once again, I'm just getting started here.
04:44hiredman*sigh*
04:45hiredmanI don't understand how "I'm just getting started" is an acceptable response to "this is a better way to do it"
04:48FigsI'm having an extremely hard time in general debugging clojure programs and handling errors. What is the recommended way of dealing with exceptions and debugging with regards to clojure?
04:50hiredmandon't do things that cause exceptions
04:50hiredmanif you do do something that might cause an exception, handle it as close to the possible source as possible
04:51hiredmanread the stack trace, it contains useful information
04:51hiredmanand be liberal with with the printlns
04:51FigsI need exceptions, or an exception-like mechanism for indicating parsing errors, and possibly trying different alternatives in certain cases.
04:52_atokeep your functions small and develop them interactively
04:52hiredmanFigs: sounds like you want to use exceptions for flow control. :(
04:53FigsI would like a way to tell which parser failed.
04:53FigsExceptions were the first thing that came to mind
04:53maaclhiredman: its a acceptable response when you answer newbie questions by knocking their non-ideomatic style instead of trying to help them with their actual problem
04:53_atoFigs: there's a couple of libraries in contrib for dealing with errors
04:53_atohttp://richhickey.github.com/clojure-contrib/error-kit-api.html
04:54_atohttp://richhickey.github.com/clojure-contrib/condition-api.html
04:55hiredmanmaacl: style helps other people read your code, and as a newbie, if you have a problem, you might want someone else to take a look at your code and be able to read it
04:56FigsThe alternative to exceptions in my case would be to pass along an error result.
04:56FigsOr use a library, I think ;)
04:57hiredmanis it actually an exceptional situation for a parsing strategy to fail?
04:58FigsPossibly, since more functions may be provided by a user later.
04:58maaclhiredman: sure style is important, but addressing the question first would be more helpful. Adding a "and btw you might want to consider..." after helping out would be much more effective
04:59maaclhiredman: putting style first is like trying to teach yoga breathing techniques to a drowning person
04:59hiredman*snort*
04:59_ato,[)
04:59clojurebotUnmatched delimiter: )
04:59_ato^ parse failure, exception
04:59_atoseems a reasonable usage to me
05:00hiredman_ato: but there is only one parser in this case
05:00hiredmanit sounds like he has multiple parsers and if one fails to fall over to another
05:01hiredmanputting style first is like requiring people use proper spelling before you review their english paper
05:01FigsThere are several cases that can occur; one of which is exceptions during development (which I am currently dealing with), one of which is parser-failure after consuming input which should usually, but not always exit the parser to a handler at some point -- it is possible that an alternative parsing strategy is specifiable for back-tracking; this is something I am still experimenting with.
05:02chr`hiredman: You used the term "yak shaving" yesterday?
05:03hiredman~yak shaving
05:03clojurebotfastest sheers on IRC
05:05hiredmansometimes people have a problem, and they pastebin code, and it's formated like C, every ( or ) on its own line, I call up the paste, because I plan to have a look and see if I can help, but I just won't make the effort to try and read lisp formatted like C
05:10hiredman
05:25maaclhiredman: fair enough, but that type of thing is to be expected from newbs...
05:26maaclhiredman: recommendable that you want to helpful, but knocking style even though you clearly do it to help, might be worse than no help at all
06:02FigsWhen should I use a :kw instead of a 'symbol ?
06:06ChousukeFigs: I'd rather ask the other way around
06:09Chousukethe most common use of keywords is as map keys, and unless you need to attach metadata to the keys themselves, there's usually no reason to use symbols for that purpose.
06:13FigsSo, use keywords unless I'm doing something funky with metadata?
06:15ChousukeFigs: generally, yes.
07:40gerry`hello
08:23gerry`i'm reading docs for golang, i find go abit like clojure, especially go struct vs clojure deftype, go interface vs clojure protocol
08:25gerry`both not oop
08:45djorkhmm, clojure doesn't seem to be well-suited to printing cycles on the repl :P
09:01the-kennydjork: hm?
09:04djorkself-referential structures
09:04djorkprint forever
09:06the-kennydjork: There's *print-limit*. I think that would help
09:52jmorrisonHi clojure folks. I want to read the Java code of Clojure but right now I'm seeing tree, tree - not "forest". Can someone recommend a reading order?
09:52the-kennyAre the slides for the Presentations (especially clojure concurrency) available somewhere?
09:53jmorrisonand what is the distinction between IThing ATHing and Thing - which sort of code goes where?
09:53Bjering_the-kenny: http://clojure.googlegroups.com/web/ClojureConcurrencyTalk.pdf
09:53the-kennyBjering_: Awesome, thank you.
09:54Bjering_the-kenny: If you watch it at blip.tv this link is below the view windown, in light grey text.
09:54the-kennyBjering_: Ahhh I didn't see this
09:54Bjering_np, same thing happend to me, I didnt see it either until after I had seen it all
09:55rhickeyjmorrison: I recommend looking at: http://clojure.googlegroups.com/web/tutorial.pdf
09:56rhickeyjmorrison: at around slide 33 begins a breakdown of the many abstractions of Clojure, serves as a roadmap to the Java side
09:56rhickeyshould help with everything except the compiler
09:57jmorrisonrhickey, thanks immensely, I am looking at that now
10:28KjellskiHi all =)
10:29KjellskiI was just wondering how extreme the difference between (last (map #(+ 1 %) (range 20000000))) and (last (pmap #(+ 1 %) (range 20000000))) is... the pmap just makes sense when calculation function dominates the whole procedure right?
10:45carkKjellski : yes
10:48Kjellskicark I was just wondering how extreme the difference on my Dualcore is... Have you tried that?
10:49KjellskiAnyone with a good and performing example of a map and pmap comparison on a dualcore, just to show the performance?
10:49carkthat's very dependant on your function, there is not much sense in benchmarking this
10:50carkbut yes it works !
10:53carkmhh for instance i made this toy test doing genetic programming a while back, the fitness function was very slow, pmap got me a 6x increase in performances on 8 cores. But i couldn't assert the slowdown was due to pmap limitations or some other ocntention in my program
10:54carkor was it 4x increase ... i can't remember now =/
10:54carkanyways it works
11:23Kjellskicark : hmm... but everything that shows pmap helps is a bit complicated for just showing it... right?
11:40tmountainif I get a sharp-quoted symbol back from ns-resolve, can someone tell me how to retrieve the associated value?
11:41tmountain(ns-resolve 'my-namespace 'my-var) => #'my-namespace/my-var
11:42tmountainwith a regular symbol, I can just eval, but I'm thinking there's probably a better way?
11:47tmountainah, nm, var-get seems to work
12:07jweiss anyone here use emacs/paredit? it doesn't work right w clojure for me. (map inc |[1 2 3]) and run paredit-wrap-round gives (map inc ([1 ) 2 3])
12:12ogriselhello all, I am new to clojure and I have a question regarding the parsing of large XML files: I can use the xml-zip API to lazily parse the interesting tag content of wikipedia XML dump file: http://github.com/ogrisel/corpusmaker/blob/master/corpusmaker.clj
12:13ogriselhowever the API is keeping references to the root node (I guess) and hence the GC cannot collect the parse tree, even though it is of no usee to me
12:14ogriselis there a way to scan through a potentially infinite XML stream without such a memory exhaustion problem?
12:16tomojmaybe I'm misunderstanding the question
12:16tomojbut, if you're building a zipper out of it, you'll need to keep it all around
12:18ogriselyes, you are right, I used the zipper because of the nice XPATH like syntax, but I guess I can do something similar directly with the lazy-xml seq
12:18tomojhmm, I guess components in your zipper could be lazy leqs
12:18tomojer, seqs
12:22tomojdo you run out of heap space when calling zip/xml-zip?
12:23tomojlazy-xml supposedly works well with zip-filter.xml.. hmm
12:23ogriselI get the GC taking 100% of CPU time for nothing
12:24ogriselI mean the CPU can no longer be used to do something
12:24ogriseland the used heap is reaching to the max heap (1GB)
12:27chouseryeah, lazy-xml makes no attempt to let go of the root of the tree
12:31Anniepooanybody know why this page ends rendering abruptly at remove-ns ?
12:31Anniepoohttp://clojure.org/api
12:31ogriselok thx chouser for confirming this
12:32chouserogrisel: I just saw a blog post in the last couple days of someone using a third-party cml parser along with xpath strings to work with xml files larger than memory
12:32Anniepoothe html source doesn;'t show anything obvious
12:32ogriselchouser: I am really interested :)
12:34tomojwould using the pull parser help?
12:35chouserneither sax nor a pull parser holds the whole stream
12:36chouserthe problem with lazy-xml here is it produces a tree compatible with what clojure.xml produces
12:36chouseras a tree, it allows you to walk it in any direction
12:37chouserit's lazy in that it doesn't parse content before you need it, but once it's parsed it stays in the tree
12:38chouserthis article (which I'm having trouble finding) worked for certain kinds of xml content and used the knowledge that the this kind of document is essentially a long list of elements
12:38chouserthat allows it to know which "root" nodes you won't need again, and which are items you're iterating past.
12:41ogriselchouser: I am thinking of building the zipper below the root, do you think that could help?
12:41ogriselby skiping explicitly the root
12:41ogriselyes you are right
12:42ogriselthe pattern you describe looks exactly like what I am looking for
12:44ogriselhaha I was googling and I thought I found it but found that instead: http://clojure-log.n01se.net/
12:44ogriselgoogle stackoverflow
12:44ogrisel#fail
12:45vyrhickey: As BILFP user group, we would like to be listed in the Clojure user groups page. I sent a mail (http://groups.google.com/group/clojure/browse_frm/thread/a60c0de0ae258f59#) to the ml for this, but no replies yet. Are the some sort of requirements to be able to be a Clojure user group?
12:50ogriselhum, even (count (:content (lxml/parse-trim "/path/to/enwiki-20090902-pages-articles.xml"))) fails with a heap space error
12:50AnniepooI want a (functional ) macro that evaluates it's arguments but doesn't allow any (clojure world) side effects
12:50AnniepooThat is, when it returns there are no changes in clojure'
12:50Anniepooany mutable clojure structure.
12:55ogriselchouser: I think i found it: http://github.com/marktriggs/xml-picker-seq
12:59rhickeyvy: ok, you are all set on: http://clojure.org/community
13:02vyrhickey: Thanks.
13:03aravindhi
13:03chouserogrisel: that's it!
13:04ogriselI wonder why it's not based on a modern XPP though
13:04ogriselbut at least it will give me guidance
13:05aravindwhats the right way to implement a lookup table (or map) in any kind of functional program? Say I wanted to build a lookup table t, but elements in t depend on other elements in t.. none of the lisps give you an easy way to change an entry. Its always return a new entry leaving the old one intact.
13:05ogriselthx for your help chouser and tomoj
13:06ogriselaravind: why don't you use the default map implementation of clojure?
13:06durka42what's the easiest way to get apache to execute a clojure script in response to an http request?
13:07aravindogrisel: umm how, the map just specifies the collection once, and you are done.
13:07aravindyou can't go back and change it in the map
13:08ogriselyou can "add" a new element that gives you a new map that shares most of it's content with the previous instance
13:08aravindright, so do you just have to keep calling def on the map over and over again?
13:09ogriselhttp://clojure.org/api#assoc
13:09AnniepooThis should be simple, but I'm on about my third day looking for it
13:09aravindogrisel: I know about assoc, but like I said it just gives you a new map. Doesn't change entries in the original map.
13:10ogriseldo you really need it to be mutable? if so use a java HashMap
13:11aravindogrisel: well.. I am more like trying to figure out how folks do things like that in functional programs..
13:11Anniepoo@durka42 http://robert.zubek.net/blog/2008/04/26/clojure-web-server/
13:11ogriselthey prefer to use immutable maps I guess :)
13:12aravindand from the looks of it, it appears that they don't, hehe
13:12hoeck1aravind: use a ref or atom to keep an updated version of the map
13:12ogriselin scala you have mutable maps in the language but then you leave the functional realm of scala
13:13durka42Anniepoo: i suppose. i was hoping i could just do it from apache
13:13Anniepoogoogle webjure or compojure
13:14Anniepooor you could use cgi
13:14aravindhoeck1: you would have to do that, to build any sort of changing table/map, right?
13:15jweissaravind, do you really need it to be mutable? it's not like clojure reallocates memory each time you create a new map from and old one (say, with assoc)
13:15hoeck1aravind: yes, at least if you want to get the concurrency benefits of clojure
13:16aravindjweiss: well, if you don't do that.. how do you build a lookup table (and one where you have to refer back to random elements in the table) to build new ones?
13:16hoeck1aravind: you may also use a plain java hashmap, but then you are in charge of enforcing the concurrency policy
13:17aravindhoeck1: I am trying to digest basic functional programming, so I am not worried about concurrency right now.
13:17jweissaravind: i'm not sure what the difference is between a lookup table, and clojure map
13:17aravindjweiss: same thing.
13:18jweissaravind: perhaps you're wanting to not pass the map around to different functions? you want each function to just have a reference to the map?
13:18jweissthen it's not really functional programming, but yeah, then use an atom
13:19qedive accidentally done this a couple of times -- either in clojure mode or in the slime repl ive hit something where it takes me to the documentation for a function, so if im at the end of when-not_, it will take me to that spot in the clojure core code
13:19qedanyone know what that is?
13:20hoeck1qed: maybe slime-edit-definition, m-. ?
13:20qedwoohoo! thanks hoeck1
13:21aravindjweiss: yeah, something like that (okay, I will look it up)
13:21aravindthanks for the help folks.
13:23the-kennyWhy is it sooo hard to get swank-clojure running with clojure.jar in ~/Development/clojure/? It was hard with an old version, but almost impossible with the newest from git... (I don't want to use elpa)
13:39the-kennyah.. finally got it working.
13:39the-kenny(A bit hacky, tough...)
13:40the-kennyOkay, I've to do some homework now..
13:45the-kennyhm... swank-clojure-project isn't working for me.
13:48the-kennyAh, looks better now.
13:48the-kennyIt should be mentioned that ido.el is required
13:58lispnikis it possible to use gen-class to create classes with static fields?
14:01kzarSo I'm reading about functional programming, I had a question though. Supposing you write some computer game, would the game loop be recursive? I thought you could have a game-loop function that when called with no args made some up and then called itself again. Then each time you could call on the loop's variablles but instead of changing them just pass the return value to the the next call to game-loop?
14:02kzarwhoops I meant "you could call the game logic function on the loops variables"
14:07krumholt__kzar you could do that. there is also while in clojure
14:08krumholt__,(doc while)
14:08clojurebot"([test & body]); Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become false/nil. Returns nil"
14:09kzarkrumholt__: But supposing you needed to change some of the tiles on the world, normally I would have a global 2d array for the world and in the game-loop I could call all the logic functions which could change the world when needed.
14:10kzarkrumholt__: but if you're trying to avoid doing it that way I'm not sure how you could use a while loop?
14:11rlb`kzar: you might want to check out rhickey's "ant demo" video. Though that's particularly focused on fine-grained parallelism (w/o locks).
14:11rlb`kzar: it does maintain a "world array", etc.
14:12krumholt__kzar, ok i think i understand. you could make your game loop a function that as an argument takes the 2d field and will recursivly call itself with a changed 2d field
14:15rlbkzar: note that in clojure, you'll need to use loop/recur or you may run out of stack.
14:15kzarok I'll have another look at that ants code and try and understand it
14:15rlbkzar: if I recall correctly, it maintains an array of ant agents -- that may be more than you'd need.
14:16tomojanyone have an idea about how to take a clojure.test test function and make it bail out on failure?
14:16tomojmaybe make a special version of is which throws an exception on failure, and catch that up above? :/
14:18tomojI wrote a macro that takes a body like (foo) (bar) (baz) and rewrites it to (when (foo) (when (bar) (baz))), but that will break if one of the body forms is not an is assertion
14:18tomoj(and returns false/nil)
14:29technomancyI'm working on my JRuby adapter for Clojure and running into some odd exceptions.
14:30technomancyhttp://p.hagelb.org/clojure-gem-error.html
14:30technomancyworks with 2 threads, blows up with 3
14:31technomancy(I'm giving a lightning talk about this at ~3pm PST at JRubyConf)
14:34technomancyI'm getting NativeException: clojure.lang.LockingTransaction$RetryEx: null when I run a simple alter inc on an integer ref in more than 2 threads at a time.
14:34technomancy(where my inc is implemented in Ruby, but whatever.)
14:35rhickeytechnomancy: if JRuby is getting in the way of exception flow that will mess up transactions, which use exceptions for retries
14:36technomancyI see; it's probably wrapping them in a Ruby exception type.
14:36rsynnotttechnomancy: What is your adapter going to do, exactly?
14:37technomancyseems likely since commute works fine with ten threads
14:37rhickeyLockingTransaction$RetryEx is definitely a retry exception (i.e. not an error)
14:38rhickeybut if it gets wrapped, it will not be detected as a retry in the transaction loop, and will flow out
14:39kzarrlb: So I was reading about agents and how that ant demo works. I like them but I was thinking is it the right model for tetris? I wasn't sure if having a new agent for every tile would really be the right approach?
14:45rlbAh, I didn't realize that's what you're working on, and no, I wouldn't be likely to pick fine-grained agents for that.
14:47technoma`conference wifi; sorry
14:47rlbI'm not sure you need much concurrency wrt tetris, though, do you?
14:47kzarI got the basic game working, the pieces move down and turn and they stack together blah blah but not I'm trying to re-jig the code so that it's more functional
14:48kzarrlb: Well I don't need concurrency but I don't need tetris either
14:50kzarI'm just making it as a way to learn about clojure really. I figured I should make it more functional than was confortable for me
14:50rlbkzar: I mostly mentioned the demo because (iirc) it manages a 2-d world state, but the rest may not be relevant to you.
14:51rlbAnyway, passing the world via loop/recur should work fine
14:52kzaryea I think you're right, I'm going to give it a shot
15:03krumholt__what happens to clojurebot if i eval a recursive function that loops endlessly?
15:03the-kennykrumholt__: Just try it
15:03the-kenny:D
15:03krumholt__the-kenny, i don't wan't to break something
15:04the-kennyhm... I'm sure hiredman has programmed some timeouts or so.
15:04technomancyrsynnott: so with what I've got you can use JRuby blocks and lambdas in transactions as well as access to the persistent data structures
15:05technomancyrhickey: luckily headius is here at the conf and interested in what I'm doing, so with that in mind I will see if I can get some hints from him about how to deal with the wrapping. =) thanks.
15:05HunnerAny idea what colorscheme this is? http://kotka.de/projects/clojure/vimclojure.html
15:12jweissHunner: i asked the same question a couple days ago. I've been waiting for that guy to show up here so i can ask him, but meanwhile i gave up on vim-clojure and moved to emacs
15:12jweisshis nick is kotarak
15:13jweissstill i like that color scheme a lot
15:14Scriptor*realized
15:14jweissi hated emacs since college, but now that i'm giving it a 2nd chance, i see the beauty of it
15:14HunnerScriptor: syntax/clojure.vim
15:14Hunnerit's in vimclojure
15:15Scriptoror not
15:15the-kennyHunner: Just show the how awesome slime is :)
15:15the-kennyOr org-mode, or artist-mode
15:15Hunneryeah, I haven't compared slime and slimv yet
15:15Hunnerthe-kenny: don't start :)
15:15the-kenny:p
15:16Scriptorhmm, I still don't seem to be able to get good syntax highlighting with vimclojure
15:16jweissScriptor: it was working for me, although a bit nonsensical. i got at least 4 different colors for various fns, not sure what the rhyme or reason was
15:17ScriptorI don't get any colors for defn
15:17Scriptorand for some reason 'return' gets highlighted
15:17jweissScriptor: worked for me when i followed the instrux here: http://kotka.de/projects/clojure/vimclojure.html
15:17_atoI like zenburn for both emacs and vim (though I chane the background to be a bit darker) http://slinky.imukuppi.org/zenburn/
15:18Scriptorjweiss: right, that's what I did as well
15:18jweissScriptor: maybe you have to enable 256 color mode for your terminal
15:18ScriptorI think it's mistakingly using another language's syntax
15:19Scriptorit should use vimclojure for any .clj files, right?
15:19Scriptorother languages work fine
15:19rlbAny thoughts about how to structure a clojure app that needs to communicate bidirectionally over a socket, where there may be multiple "senders" in the app? Note that there isn't a tight coupling between socket input and output.
15:20rlbCould have an agent to manage the outgoing socket, or a transaction protected "outgoing" queue and a thread to manage the output.
15:20the-kennyrlb: I think I would do it exactly like that. (But I'm not very experienced...)
15:21the-kennyha.. If I think what a pain in the *ss something like this would be in C++ or so..
15:21rlbHmm -- though it might consume more threads, the agent might be easier. Otherwise I'd have to arrange for the sender thread to block when the outgoing queue was empty, etc.
15:24_atothe-kenny: re scriptjure + couchdb: yeah it worked pretty well. I ended up switch to the Clutch lib rather than clojure-couchdb, I got fed up with all the exception throwing clojure-couchdb does. The great thing about Clutch is implements a view server so you can actually just use native clojure code instead of translating to javascript
15:26the-kenny_ato: Yeah, Clutch is cool too, but I like the simplicity of clojure-couchdb.
15:26_atohehe, Clojure has kind of spoiled me I much prefer (get-document) to return nil when there's no doc instead of blowing up :)
15:29technomancy_ato: wait, clutch is a view server _and_ a client?
15:30rlbHmm, not sure clojure even has that kind of blocking (block until changed)?
15:31_atotechnomancy: yeah
15:34_atotechnomancy: just add [query_servers] clojure = java -jar .../clutch-standalone.jar to couchdb config and suddenly you cuse clojure views. It's really nice
15:35danlarkin_ato: does that keep the jvm running between requests?
15:36_atodanlarkin: yes
15:38danlarkinthat's pretty neat
15:45qedHmmm I didn't expect that to happen...
15:45qed(in-ns 'myapp)
15:45qed(clojure.core/use 'clojure.core)
15:45_atoyou could even use nailgun so that it shared the same JVM as your app, reducing memory usage and also allowing sharing state between the views and the reset if your app if you wanted to
15:45qedhangs my slime repl
15:46qedIs that weird?
15:50qedAnyone have this problem?
15:50spuzIs there a way to tell whether or not a function returns a primitive type or not?
15:51spuzCalling class on an int appears to autobox it into an Integer
15:51spuz,(class (int 0))
15:51clojurebotjava.lang.Integer
15:53_atoqed: works for me :\
15:54qedweird
15:54hiredmanspuz: functions cannot return a primitive
15:54hiredmanint supperficially looks like a function, but it is a cast
15:55qedit hangs me again
15:55spuzhmm
15:55qed_ato: any ideas on troubleshooting this? Are you running 1.1.0?
15:55spuzwhat if I say (let [x (inc (int 0))] ...) is x still a primitive after it gets incremented?
15:55hiredmanqed: use refer, not use
15:55qedwhy does that fix it?
15:59hiredmanqed: not sure, but use will load a namespace and then refer it, but core is already loaded
16:03qedhiredman: ah, so im trying to load 'clojure.core from 'clojure.core, which is screwing it up?
16:05ordnungs`re
16:06_atoqed: is there a reason you need to (use 'clojure.core) or a re you just experimenting with the namespace functions?
16:06qedexperimenting with namespaces
16:06hiredmanqed: I don't know the exact mechanics
16:06qedper S. Halloway's book
16:07qedp65 has this example of (in-ns 'myapp), he then goes on to explain that we automatically get access to Java, but not to clojure, so we need to load it manually by doing (clojure.core/use 'clojure.core)
16:09_atoqed: oh and yeah I am on clojure 1.1
16:10qedthat's really weird, maybe it's our version of swank-clojure or slime that's making the difference
16:11qedim bleeding edge on all of it
16:18defnHow do I edit my SLIME prompt?
16:46hiredmanclojurebot: FAQ #1?
16:46clojurebotExcuse me?
17:02ordnungswidriganybody using a macbook pro for java/clojure development. Does the ssd make a difference?
17:05qedordnungswidrig: the ssd is going to make a noticeable difference for all sorts of stuff
17:05qedim not sure why you're asking specifically about clojure
17:07_atoordnungswidrig: I'm using a regular macbook (2nd gen) with an SSD and it makes a huge difference, particularly to startup-times for large applications and the OS itself
17:07ordnungswidrigqed: I meant the typical clojure dev workflow: no fat ide like eclipse/intellij but a litte aquamacs and repl in a terminal lurking around.
17:08defni use a T61P laptop that my work provided, my setup is fine
17:08_atofor emacs it's not going make that much difference as emacs is pretty fast normally anyway
17:08defneven with a fat IDE, a new MBP should be fine
17:08defnif you want to run Microsoft Word, on the other hand
17:08defnbetter get that SSD
17:09ordnungswidrigdefn: whoo, I think I might be forced to use that. Or openoffice. Don't know if a ssd matters for openoffice.
17:10ordnungswidrigdefn: I'd say yes. But the 270€ on top could be invested for other nice things as well.
17:11rysThe T61p is the best laptop I've ever owned
17:13ordnungswidrigbetter go to bed, now. Thanks for you comments.
17:14defnrys: it's a great laptop yeah
17:15rysThe only thing that bugs me is the battery life, even with a 9-cell
17:15defni got lucky, the time i started this job meant getting the shiny t61p and not the crappy t60
17:15defnyeah my battery just died and i had to order a new one, those 9 cells are junk
17:17rlbSo wrt clojure libs, are prefix names or generic names (which rely on the namespace) preferable? i.e. for a mpd lib, would you expect (mpd-foo bar) or just (foo bar)?
17:19tomojI would expect just foo
17:20tomojbecause I can do (mpd/foo bar) if I want
17:26jweissanyone here use emacs/paredit? it doesn't work right w clojure for me. (map inc |[1 2 3]) and run paredit-wrap-round gives (map inc ([1 ) 2 3])
17:27opqdonutlooks like paredit isn
17:27opqdonut't aware of []
17:27opqdonuttry looking at the customizeable vars it has
17:27opqdonuti've only used paredit with common lisp
17:31jweissopqdonut: what customizable vars
17:32mrSpecCould you help me with Macro? I dont know why this one is not working:
17:32lisppaste8mrSpec pasted "Macro - ActionListener" at http://paste.lisp.org/display/90922
17:33opqdonutjweiss: M-x customize
17:34jweissopqdonut: forgive my emacs newbness. i get a list of categories, which one would paredit be under
17:35hiredmanmrSpec: maybe unquote height and width
17:35qedhttp://vimeo.com/7722342
17:35hiredman~'.addActionListener
17:35clojurebotIt's greek to me.
17:35hiredmaner
17:35hiredman~'.addActionListener can just be .addActionListener
17:35clojurebotTitim gan éirí ort.
17:36hiredmanclojurebot: buzz off
17:36clojurebotexcusez-moi
17:36mrSpecok I'll try
17:36hiredmangpanel should be unquoted too
17:37mrSpecunquoted? could you tell something more? there is no quote before g-panel :S
17:38hiredmanthe whole doto form is quote
17:38hiredmanquoted
17:38hiredmansyntex-quoted to be exact
17:38hiredmansyntax
17:38hiredman`(doto …)
17:38qedmrSpec: `() is a syntax quote
17:38mrSpecah
17:39qedmrSpec: in syntax quoted things you'll find ~ and ~@ generally
17:40hiredmanhttp://clojure.org/reader#toc2
17:40qedlike `(a ~b (~@c))
17:40mrSpecah, so I should add ~ before gpanel?
17:40qedmaybe.... i didnt see your code
17:40mrSpechiredman: thanks
17:41qed~ defers the evaluation of the thing it's appended to
17:41clojurebotHuh?
17:41hiredmanqed: woa, no
17:41hiredmanunquoting does the opposite of defer
17:41qederr it specifically evaluates what it applies to
17:42qedhehe, just learned this yesterday so bear with me :)
17:43qedmrSpec: http://clojure-log.n01se.net/date/2009-11-21.html#i56 -- that's _ato patiently explaining syntax quote, unquote, and unquote splicing to me
17:45mrSpecqed: thx, I'll take a look
17:47qedmrSpec: for my own edification ill re-write some of what _ato showed me
17:48qed,'(foo (+ 1 2))
17:48clojurebot(foo (+ 1 2))
17:48qed,`(foo ~(+ 1 2))
17:48clojurebot(sandbox/foo 3)
17:48qed,`[1 2 3 4 ~(+ 2 3) 6 7]
17:48clojurebot[1 2 3 4 5 6 7]
17:49qed(defmacro m3 [x] `(foo ~@x))
17:50qed(m3 [1 2 3]) => (foo 1 2 3)
17:50qedanyway, ill quit for the time being, but seeing those helped me quite a bit
17:51mrSpecok, thx ;)
17:51qedthis one was particularly fun to think about:
17:52qed,'`(evil (~test ~@fish))
17:52clojurebot(clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/evil)) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list test) fish)))))
17:52qed_ato++
17:55DrakesonDo you know a pretty way to provide remote clojure calls to command line utilities? The invokation could look like this: $ clojure-run "(+ 1 2 3)"
17:56mrSpechah I've found another bug... I cant have button "button1" and macro "button1" in Clojure?
17:56hiredmanwhat do you mean?
17:56_atoDrakeson: alias clojure-run="java -server -jar .../clojure.jar -e"
17:57mrSpec(defmacro button ...) and (let [button (new Jbutton )] (button button)) Something like that
17:58hiredman
17:59Drakeson_ato: nah! note that I want *remote* calls. I don't want to run a new instance of jvm.
17:59carkmrSpec : that's not a bug, clojure is a lisp1
17:59carklook it up
17:59mrSpeccark: bug in my program ;)
17:59hiredmanactually, depending on details of clojure's compilation model that I am not familar with, that might work
17:59technomancyDrakeson: you want nailgun
17:59mrSpecI've just read that clojure is a lisp1 :/
17:59hiredmannot entirely sure how macro's work with lexical scope issues
17:59Drakesontechnomancy: please, no!
17:59_atoDrakeson: yeah, setup nailgun and then: alias clojure-run="ng clojure.main -e"
18:01joshua-choiHey, how can you get the name of a Var?
18:02_ato,(:name (meta #'inc))
18:02clojurebotinc
18:02joshua-choiExcellent, thank you.
18:02_atojoshua-choi: ^
18:02_ato:)
18:02Drakesonapt-cache search nailgun --> nil. (debian unstable).
18:04Drakeson(I know about http://martiansoftware.com/nailgun/index.html, but it is too much a hassle)
18:05_atoDrakeson: wget http://sourceforge.net/projects/nailgun/files/nailgun/0.7.1/nailgun-src-0.7.1.zip/download && tar -zxvf nailgun-src-0.7.1.zip && cd nailgun-src && make && cp ng ~/bin
18:05_atoerr
18:05_atounzip not tar
18:06hiredmanfreebsd's tar handles zip files :P
18:51mitkokHey, guys. Anyone using slime under Ubuntu, but installed from source, no *.deb package.
18:51technomancymitkok: slime upstream broke a few things on us; best to install via elpa: http://tromey.com/elpa
18:53mitkoktechnomancy: ok, thanks
19:04mitkoktechnomancy: I've just installed clojure, clojure-mode, swank-slojure, slime, slime-mode via elpa, but now when I execute slime it gives me an error : Could not find the main class: clojure.main. Program will exit.
19:19technomancymitkok: with M-x slime? are there jars in the ~/.swank-clojure dir?
19:20mitkoktechnomancy: actually, I clojure was not installed, but only the modes through elpa package manager. I ran clojure-install and everything works fine :)
19:21joshua-choiQuick question: how do you get the name of a namespace? (I'm trying to get the namespace-qualified symbol of a Var.)
19:22hiredmanjoshua-choi: vars have two public fields, ns and sym
19:22hiredman,(.ns (var +))
19:22clojurebot#<Namespace clojure.core>
19:22technomancy,(meta (the-ns 'clojure.core))
19:22clojurebot{:doc "Fundamental library of the Clojure language"}
19:22hiredman,(.sym (var +))
19:22clojurebot+
19:22hiredman,(.ns (var +))
19:22clojurebot#<Namespace clojure.core>
19:22hiredman,(name (.ns (var +)))
19:22clojurebotjava.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.Named
19:22hiredman:|
19:23hiredman,(symbol (str (.ns (var +))) (.sym (var +)))
19:23clojurebotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String
19:23hiredman,(symbol (str (.ns (var +))) (name (.sym (var +))))
19:23clojurebotclojure.core/+
19:23hiredman,(resolve (.ns (var +)) (.sym (var +)))
19:23clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$resolve
19:24hiredman:|
19:24hiredmananyway
19:24joshua-choiThat's what I need
19:24joshua-choiThanks a lot
19:25chouser(
19:25chouser,(ns-name *ns*)
19:25clojurebotsandbox
19:25hiredmanah
19:25chouserbut that doesn't really help
19:26hiredmananyway, it would be great if namespaces where Named
19:26chouservars too
19:26hiredmanhmmm
19:26joshua-choiYeah, it would
19:26hiredmanI suppose
19:26joshua-choiBut ns-name is better than str, so thanks too
19:26hiredmanand return nil if unamed?
19:26chouserI'd be happy to have 'name' work on most vars and return nil for unnamed ones
19:26chouseryeah
19:27chouserwhat's named now. just keywords and symbols?
19:27hiredmanI believe so
19:28hiredmanyes
19:28chouserboth already support unqualified names. I guess "no name at all" stretches that a bit further
19:28hiredmanhuh
19:28hiredmanthis thing that implements Named is not named...
19:29chouseryeah, I think that's why rhickey has resisted so far.
19:29hiredmanIMightHaveAName
19:37hiredmanclojurebot: naked dot is <reply>http://groups.google.com/group/clojure/msg/8fc6f0e9a5800e4b
19:37clojurebotOk.
19:49defn,(doc drop-last)
19:50clojurebot"([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"
21:43zaphar_psdoes clojure-contrib have a foldl and foldr implementation?
21:45_atofoldl is just reduce isn't it?
21:45_atonot sure if there's a foldr
21:46defnYou could make one
21:46zaphar_ps_ato: yeah actually it is :-)
21:47zaphar_pshadn't quite triggered that.
21:47zaphar_psdefn: I did actually
21:47defnhttp://gist.github.com/96861
21:47zaphar_psit's an easy fn to write
21:47defnThere's another one if you like :)
21:48JAS415couldn't you just reverse and then do the reduce
21:49defnfoldr isn't lazy
21:49defnin the above implementation
21:49JAS415isn't tail recursive either i dont think
21:49zaphar_pscorrect on both accounts
21:52defnHow do you do something like (Random. nextInt 10) in one line?
21:52zaphar_psdefn: that looks like one line to me
21:52defnnot working for me for some odd reasno
21:52defnmight just be my repl
21:52JAS415what does that produce?
21:53defnan exception
21:53JAS415,(Random/nextInt 10)
21:53clojurebotjava.lang.Exception: No such namespace: Random
21:53zaphar_psI get IllegalARgumentException
21:53JAS415,(rand-int 10)
21:53clojurebot2
21:53defnYou need to (import '(java.util.Random))
21:53JAS415,(rand-int 10)
21:53clojurebot0
21:53hiredman(import '(java.util Random))
21:53defnerr ty
21:54_ato,(.nextInt (java.util.Random.) 10)
21:54clojurebot9
21:54zaphar_pseven with import I still get Illegal Argument
21:54defn_ato: so you would just do:
21:54zaphar_pshrmm
21:54defn,(.nextInt (Random.) 10)
21:54clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: Random
21:55_ato,(import 'java.util.Random)
21:55clojurebotjava.util.Random
21:55JAS415whats the difference between that and rand-int?
21:55defn,(.nextInt (Random.) 10)
21:55clojurebot7
21:55defnthere we are
21:56_ato~def rand-int
21:56JAS415,(Random/nextInt 10)
21:56clojurebotjava.lang.IllegalArgumentException: No matching method: nextInt
21:56JAS415ah i see
21:59defnIf you think that's good, wait til you try slime ;)
21:59zaphar_psheh
21:59zaphar_psI did try slime but emacs just doesn't fit me very well
22:00zaphar_psthus my pleasure concerning vimclojure
22:02JAS415emacs has a steep learning curve, but i had emacs running compojure and i was refreshing my browser from inside emacs
22:03JAS415which was a big efficiency boost over clicking refresh
22:03JAS415and that's all because of the scripting aspect i guess
22:03zaphar_psJAS415: alt-tab ctrl-r
22:04JAS415i was just doing ctrl-x p
22:04JAS415i guess that works too though
22:04zaphar_psnot sure the difference in keystrokes is all that noticeable
22:05zaphar_psbut yeah I already have years invested in vim and just don't feel like tackling the emacs learning curve
22:05JAS415yeah
22:05zaphar_psdespite my enjoyment of list and clojure
22:05JAS415if you are already good with what you have use it
22:43efarrarhello, anybody using the latest vim-clojure with gorilla?
22:44efarrarhi yacin
22:51zaphar_psefarrar: define latest version?
22:52zaphar_pshead won't even compile for me
22:52efarrareh, any version will do i guess
22:52zaphar_psbut that last release tag does
22:52zaphar_pswhat did you want to know?
22:52efarrari can type \sr all day long but no gorilla
22:52efarrarfiletype sets correctly
22:52zaphar_psdoes \ef work
22:53efarraryes
22:53zaphar_psand I assume you started your nailgun server
22:53zaphar_psif ef works then of course you did
22:53efarraryes
22:53zaphar_psdoes it give any error message?
22:53efarraroh really?
22:53efarrarno it just catches the "s" key
22:54zaphar_psthats weird
22:54efarrarand deletes a character and enters insert
22:54zaphar_psI've never had it partially work
22:54zaphar_psI've had it fail totally or not fail at all but never a single command
22:54efarraroh wait
22:55efarraref does not work, it does whatever \e does
22:55zaphar_psahhh ok
22:55efarraror rather, "e"
22:56zaphar_psthen what has happened is the plugin hasn't actually loaded
22:56efarrarok
22:56zaphar_psif you look in the .vim/autoload/vimclojure.vim file you'll see a bunch of commands
22:57zaphar_psif you try to execute any of them they probably will give you an error that it cant' find them
22:57zaphar_psfor some reason it hasn't actually loaded the plugin file.
22:57zaphar_psAs for why I'm not sure what the reason is.
22:58zaphar_psI had an error in mine that caused it
22:58efarrari'll read back through the install
22:58zaphar_psthe other reason might be because it can't find the nailgun server also
22:58zaphar_pshope that helps
22:59zaphar_psefarrar: if you have to try putting some echomsg lines in the initbuffer function in the vimclojure.vim file
22:59zaphar_psthat will at least tell you if it's trying to load but can't find the namespace of the file because of a nailgun server error
23:00defnGood god I am blowing through this Clojure book
23:00defnThis is the first time in my entire life I've actually read an entire programming book
23:00defnas in cover to cover
23:00zaphar_psdefn: heh
23:01zaphar_psthe only programming book I've ever read cover to cover was the camel book
23:01zaphar_psand that was a long long time ago
23:01catfishlardefn: I have not read it. Is it well written or is it just beacsue clojure is interesting
23:01defnThe thing that has me reading so closely is all the Java interop stuff, and there seems to be so many little nuggets of goodness buried in some of the sections
23:02defncatfishlar: I'd say both
23:02defnThe layout so far has me really into it -- it starts like most programming books with boring examples about writing hello world, etc., but once he gets into the Java interop stuff it gets really interesting
23:02catfishlarI just got finished watching Rich's keynote from Nov 12 and I was taking notes like a mad man. The guy is so Lucid about his message.
23:03defnthe performance stuff in the Clojure book has been some of the stuff I've been missing
23:03defnand that was laid out really nicely
23:04defnPart of it with this book I think also has a lot to do with the fact that there is ONLY ONE clojure book on the market
23:04defnwith other established languages it's easy to jump around the web finding this and that
23:05defnThis is partially true for clojure, but not to the extent of say Ruby
23:05defnso having a sort of guide book is really nice and relaxing in a way
23:08JAS415i think in a couple years it will be better
23:08defnClojure or the book?
23:08JAS415i think there is at least one more clojure book coming out soon
23:08JAS415oh sorry, just the size of library and information
23:09defnoh sure
23:09defnit takes time
23:09defnand yeah there's a book coming out from Apress
23:09defnbut this is a great book, FWIW
23:10JAS415clojure looks like it will just continue to get better as well, fwiw
23:12defnyeah for sure
23:12defnI'm excited for the future :)
23:13defnI'm done reading for the day -- I just got to Creating Java Proxies and am suddenly bored
23:15chouserand two from Manning