#clojure log - Nov 22 2009

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:04 JAS415: what are you looking to do?

0:05 hiredman: parse sublists out of a list

0:16 JAS415: ,(def positions)

0:16 clojurebot: DENIED

0:16 JAS415: ,clojure-contrib.seq-utils/positions

0:16 clojurebot: java.lang.ClassNotFoundException: clojure-contrib.seq-utils

0:17 JAS415: that's strange

0:17 hiredman: JAS415: clojure.contrib

0:21 JAS415: ah

0:25 hmm need to update my contrib

0:36 lisppaste8: JAS415 annotated #90883 "little updated" at http://paste.lisp.org/display/90883#1

0:38 JAS415: is shorter anyway

0:57 qed: JAS415: nice

0:58 JAS415: efficiency or not, that is way cleaner

1:04 JAS415: yeah, clojure-contrib is both huge and awesome

2:58 technomancy: anyone else noticing ns metadata disappearing for AOT'd namespaces?

2:58 (except clojure.core, since it adds in metadata after the fact with alter-meta!)

3:22 kzar: How can I access the three values of something like this? #<Color java.awt.Color[r=255,g=255,b=255]>

3:24 hiredman: kzar: thats from the .toString method of Color

3:24 _ato: (.getRed color)

3:24 hiredman: I would call bean on it and see what you get

3:24 _ato: kzar: http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html

3:26 kzar: cool beans, I like that bean command

3:26 thanks everyone

3:26 ,(:red (bean (new Color 250 251 252)))

3:26 clojurebot: java.lang.IllegalArgumentException: Unable to resolve classname: Color

3:30 kzar: so 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"

3:40 oh I think I see

3:41 sorry 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

4:05 technomancy: browsing the github clojure projects... I am really curious what this one does: http://github.com/zahardzhan/leica

4:06 _ato: ha, google translate says "Multi-swing for datakoda and fayloobmennikov local dsvload.net."

4:06 that's just as meaningless as the russian

4:08 kzar: seems to be a scraper downloader for some site "data.cod.ru"?

4:11 hiredman_: looks like some kind of client for http://translate.google.com/translate?js=y&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Ftime.cod.ru%2F&sl=ru&tl=en&swap=1

4:13 hiredman: clojurebot: translate from ru leica

4:13 clojurebot: leica

4:14 hiredman: clojurebot: translate from ru Лейка

4:14 clojurebot: Lake

4:14 hiredman: code be a pun

4:14 cod and lake

4:15 but I think cod are a salt water fish

4:15 could

4:22 Figs: Hi

4:24 I'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?

4:25 kzar: ,(apply str (drop 3 "hello"))

4:25 clojurebot: "lo"

4:26 Figs: Why does (apply str ...) give the correct result, but (str ...) does not?

4:26 Does it change the order of evaluation?

4:27 hiredman: because str on a single object just calls .toString on that object

4:27 ,(str '(\a \b \c))

4:27 clojurebot: "(\\a \\b \\c)"

4:27 twbray: Figs: apply de-listifies a list and feeds it to a function as args

4:27 hiredman: ,(.toString '(\a \b \c))

4:27 clojurebot: "(\\a \\b \\c)"

4:27 kzar: I think it's because it does something like (str (str \l) \o)

4:27 hiredman: nope

4:27 kzar: ok whoops

4:27 so what does it do?

4:28 hiredman: str on multiple objects uses a StringBuilder

4:28 ~def str

4:28 twbray: ,(str '("foo" "bar" "baz"))

4:28 clojurebot: "(\"foo\" \"bar\" \"baz\")"

4:28 twbray: ,(apply str '("foo" "bar" "baz"))

4:28 clojurebot: "foobarbaz"

4:29 hiredman: ,(.toString '("foo" "bar" "baz"))

4:29 clojurebot: "(\"foo\" \"bar\" \"baz\")"

4:30 kzar: so (apply str (drop 3 "hello")) is like doing (str \l \o) ?

4:30 _ato: yep

4:30 kzar: gotya ok

4:30 Figs: ,(str \l \o)

4:30 clojurebot: "lo"

4:30 Figs: ah, I see.

4:30 twbray: ,(. "hello" substr 3)

4:30 clojurebot: java.lang.IllegalArgumentException: No matching method found: substr for class java.lang.String

4:31 twbray: ,(. "hello" substring 3)

4:31 clojurebot: "lo"

4:31 hiredman: :(

4:31 (.substring "hello" 3)

4:32 twbray: hiredman: I prefer my flavor, but tastes vary.

4:32 hiredman: twbray: .substring is the prefered syntax

4:32 twbray: hiredman: Not disputing your right to prefer it :)

4:33 Figs: There's a parsec-like library for clojure, as I recall... does it handle processing lists as well as strings?

4:33 twbray: I'm coming from Java & Ruby, so I think like "foo".substring 3, that O-O stuff infects your brain after a while

4:34 Figs: I can't remember the name of it

4:35 Oh, nevermind. I found it. It's just called parser.

4:36 hiredman: twbray: the naked . syntax doesn't distinguish between static and instance methods

4:36 twbray: hiredman: Well, it's visually obvious

4:37 ,(. java.nio.charset.Charset forName "UTF-8")

4:37 clojurebot: #<UTF_8 UTF-8>

4:39 twbray: hiredman: 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

4:40 so it feels comfy. But once again, I'm just getting started here.

4:44 hiredman: *sigh*

4:45 I don't understand how "I'm just getting started" is an acceptable response to "this is a better way to do it"

4:48 Figs: I'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?

4:50 hiredman: don't do things that cause exceptions

4:50 if you do do something that might cause an exception, handle it as close to the possible source as possible

4:51 read the stack trace, it contains useful information

4:51 and be liberal with with the printlns

4:51 Figs: I need exceptions, or an exception-like mechanism for indicating parsing errors, and possibly trying different alternatives in certain cases.

4:52 _ato: keep your functions small and develop them interactively

4:52 hiredman: Figs: sounds like you want to use exceptions for flow control. :(

4:53 Figs: I would like a way to tell which parser failed.

4:53 Exceptions were the first thing that came to mind

4:53 maacl: hiredman: 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

4:53 _ato: Figs: there's a couple of libraries in contrib for dealing with errors

4:53 http://richhickey.github.com/clojure-contrib/error-kit-api.html

4:54 http://richhickey.github.com/clojure-contrib/condition-api.html

4:55 hiredman: maacl: 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

4:56 Figs: The alternative to exceptions in my case would be to pass along an error result.

4:56 Or use a library, I think ;)

4:57 hiredman: is it actually an exceptional situation for a parsing strategy to fail?

4:58 Figs: Possibly, since more functions may be provided by a user later.

4:58 maacl: hiredman: 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

4:59 hiredman: putting style first is like trying to teach yoga breathing techniques to a drowning person

4:59 hiredman: *snort*

4:59 _ato: ,[)

4:59 clojurebot: Unmatched delimiter: )

4:59 _ato: ^ parse failure, exception

4:59 seems a reasonable usage to me

5:00 hiredman: _ato: but there is only one parser in this case

5:00 it sounds like he has multiple parsers and if one fails to fall over to another

5:01 putting style first is like requiring people use proper spelling before you review their english paper

5:01 Figs: There 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.

5:02 chr`: hiredman: You used the term "yak shaving" yesterday?

5:03 hiredman: ~yak shaving

5:03 clojurebot: fastest sheers on IRC

5:05 hiredman: sometimes 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

5:10

5:25 maacl: hiredman: fair enough, but that type of thing is to be expected from newbs...

5:26 hiredman: 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

6:02 Figs: When should I use a :kw instead of a 'symbol ?

6:06 Chousuke: Figs: I'd rather ask the other way around

6:09 the 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.

6:13 Figs: So, use keywords unless I'm doing something funky with metadata?

6:15 Chousuke: Figs: generally, yes.

7:40 gerry`: hello

8:23 i'm reading docs for golang, i find go abit like clojure, especially go struct vs clojure deftype, go interface vs clojure protocol

8:25 both not oop

8:45 djork: hmm, clojure doesn't seem to be well-suited to printing cycles on the repl :P

9:01 the-kenny: djork: hm?

9:04 djork: self-referential structures

9:04 print forever

9:06 the-kenny: djork: There's *print-limit*. I think that would help

9:52 jmorrison: Hi 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?

9:52 the-kenny: Are the slides for the Presentations (especially clojure concurrency) available somewhere?

9:53 jmorrison: and what is the distinction between IThing ATHing and Thing - which sort of code goes where?

9:53 Bjering_: the-kenny: http://clojure.googlegroups.com/web/ClojureConcurrencyTalk.pdf

9:53 the-kenny: Bjering_: Awesome, thank you.

9:54 Bjering_: the-kenny: If you watch it at blip.tv this link is below the view windown, in light grey text.

9:54 the-kenny: Bjering_: Ahhh I didn't see this

9:54 Bjering_: np, same thing happend to me, I didnt see it either until after I had seen it all

9:55 rhickey: jmorrison: I recommend looking at: http://clojure.googlegroups.com/web/tutorial.pdf

9:56 jmorrison: at around slide 33 begins a breakdown of the many abstractions of Clojure, serves as a roadmap to the Java side

9:56 should help with everything except the compiler

9:57 jmorrison: rhickey, thanks immensely, I am looking at that now

10:28 Kjellski: Hi all =)

10:29 I 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:45 cark: Kjellski : yes

10:48 Kjellski: cark I was just wondering how extreme the difference on my Dualcore is... Have you tried that?

10:49 Anyone with a good and performing example of a map and pmap comparison on a dualcore, just to show the performance?

10:49 cark: that's very dependant on your function, there is not much sense in benchmarking this

10:50 but yes it works !

10:53 mhh 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:54 or was it 4x increase ... i can't remember now =/

10:54 anyways it works

11:23 Kjellski: cark : hmm... but everything that shows pmap helps is a bit complicated for just showing it... right?

11:40 tmountain: if I get a sharp-quoted symbol back from ns-resolve, can someone tell me how to retrieve the associated value?

11:41 (ns-resolve 'my-namespace 'my-var) => #'my-namespace/my-var

11:42 with a regular symbol, I can just eval, but I'm thinking there's probably a better way?

11:47 ah, nm, var-get seems to work

12:07 jweiss: 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:12 ogrisel: hello 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:13 however 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:14 is there a way to scan through a potentially infinite XML stream without such a memory exhaustion problem?

12:16 tomoj: maybe I'm misunderstanding the question

12:16 but, if you're building a zipper out of it, you'll need to keep it all around

12:18 ogrisel: yes, 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:18 tomoj: hmm, I guess components in your zipper could be lazy leqs

12:18 er, seqs

12:22 do you run out of heap space when calling zip/xml-zip?

12:23 lazy-xml supposedly works well with zip-filter.xml.. hmm

12:23 ogrisel: I get the GC taking 100% of CPU time for nothing

12:24 I mean the CPU can no longer be used to do something

12:24 and the used heap is reaching to the max heap (1GB)

12:27 chouser: yeah, lazy-xml makes no attempt to let go of the root of the tree

12:31 Anniepoo: anybody know why this page ends rendering abruptly at remove-ns ?

12:31 http://clojure.org/api

12:31 ogrisel: ok thx chouser for confirming this

12:32 chouser: ogrisel: 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:32 Anniepoo: the html source doesn;'t show anything obvious

12:32 ogrisel: chouser: I am really interested :)

12:34 tomoj: would using the pull parser help?

12:35 chouser: neither sax nor a pull parser holds the whole stream

12:36 the problem with lazy-xml here is it produces a tree compatible with what clojure.xml produces

12:36 as a tree, it allows you to walk it in any direction

12:37 it's lazy in that it doesn't parse content before you need it, but once it's parsed it stays in the tree

12:38 this 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:38 that allows it to know which "root" nodes you won't need again, and which are items you're iterating past.

12:41 ogrisel: chouser: I am thinking of building the zipper below the root, do you think that could help?

12:41 by skiping explicitly the root

12:41 yes you are right

12:42 the pattern you describe looks exactly like what I am looking for

12:44 haha I was googling and I thought I found it but found that instead: http://clojure-log.n01se.net/

12:44 google stackoverflow

12:44 #fail

12:45 vy: rhickey: 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:50 ogrisel: hum, even (count (:content (lxml/parse-trim "/path/to/enwiki-20090902-pages-articles.xml"))) fails with a heap space error

12:50 Anniepoo: I want a (functional ) macro that evaluates it's arguments but doesn't allow any (clojure world) side effects

12:50 That is, when it returns there are no changes in clojure'

12:50 any mutable clojure structure.

12:55 ogrisel: chouser: I think i found it: http://github.com/marktriggs/xml-picker-seq

12:59 rhickey: vy: ok, you are all set on: http://clojure.org/community

13:02 vy: rhickey: Thanks.

13:03 aravind: hi

13:03 chouser: ogrisel: that's it!

13:04 ogrisel: I wonder why it's not based on a modern XPP though

13:04 but at least it will give me guidance

13:05 aravind: whats 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:05 ogrisel: thx for your help chouser and tomoj

13:06 aravind: why don't you use the default map implementation of clojure?

13:06 durka42: what's the easiest way to get apache to execute a clojure script in response to an http request?

13:07 aravind: ogrisel: umm how, the map just specifies the collection once, and you are done.

13:07 you can't go back and change it in the map

13:08 ogrisel: you can "add" a new element that gives you a new map that shares most of it's content with the previous instance

13:08 aravind: right, so do you just have to keep calling def on the map over and over again?

13:09 ogrisel: http://clojure.org/api#assoc

13:09 Anniepoo: This should be simple, but I'm on about my third day looking for it

13:09 aravind: ogrisel: I know about assoc, but like I said it just gives you a new map. Doesn't change entries in the original map.

13:10 ogrisel: do you really need it to be mutable? if so use a java HashMap

13:11 aravind: ogrisel: well.. I am more like trying to figure out how folks do things like that in functional programs..

13:11 Anniepoo: @durka42 http://robert.zubek.net/blog/2008/04/26/clojure-web-server/

13:11 ogrisel: they prefer to use immutable maps I guess :)

13:12 aravind: and from the looks of it, it appears that they don't, hehe

13:12 hoeck1: aravind: use a ref or atom to keep an updated version of the map

13:12 ogrisel: in scala you have mutable maps in the language but then you leave the functional realm of scala

13:13 durka42: Anniepoo: i suppose. i was hoping i could just do it from apache

13:13 Anniepoo: google webjure or compojure

13:14 or you could use cgi

13:14 aravind: hoeck1: you would have to do that, to build any sort of changing table/map, right?

13:15 jweiss: aravind, 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:15 hoeck1: aravind: yes, at least if you want to get the concurrency benefits of clojure

13:16 aravind: jweiss: 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:16 hoeck1: aravind: you may also use a plain java hashmap, but then you are in charge of enforcing the concurrency policy

13:17 aravind: hoeck1: I am trying to digest basic functional programming, so I am not worried about concurrency right now.

13:17 jweiss: aravind: i'm not sure what the difference is between a lookup table, and clojure map

13:17 aravind: jweiss: same thing.

13:18 jweiss: aravind: 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:18 then it's not really functional programming, but yeah, then use an atom

13:19 qed: ive 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:19 anyone know what that is?

13:20 hoeck1: qed: maybe slime-edit-definition, m-. ?

13:20 qed: woohoo! thanks hoeck1

13:21 aravind: jweiss: yeah, something like that (okay, I will look it up)

13:21 thanks for the help folks.

13:23 the-kenny: Why 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:39 ah.. finally got it working.

13:39 (A bit hacky, tough...)

13:40 Okay, I've to do some homework now..

13:45 hm... swank-clojure-project isn't working for me.

13:48 Ah, looks better now.

13:48 It should be mentioned that ido.el is required

13:58 lispnik: is it possible to use gen-class to create classes with static fields?

14:01 kzar: So 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:02 whoops I meant "you could call the game logic function on the loops variables"

14:07 krumholt__: kzar you could do that. there is also while in clojure

14:08 ,(doc while)

14:08 clojurebot: "([test & body]); Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become false/nil. Returns nil"

14:09 kzar: krumholt__: 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:10 krumholt__: but if you're trying to avoid doing it that way I'm not sure how you could use a while loop?

14:11 rlb`: 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:11 kzar: it does maintain a "world array", etc.

14:12 krumholt__: 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:15 rlb: kzar: note that in clojure, you'll need to use loop/recur or you may run out of stack.

14:15 kzar: ok I'll have another look at that ants code and try and understand it

14:15 rlb: kzar: if I recall correctly, it maintains an array of ant agents -- that may be more than you'd need.

14:16 tomoj: anyone have an idea about how to take a clojure.test test function and make it bail out on failure?

14:16 maybe make a special version of is which throws an exception on failure, and catch that up above? :/

14:18 I 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:18 (and returns false/nil)

14:29 technomancy: I'm working on my JRuby adapter for Clojure and running into some odd exceptions.

14:30 http://p.hagelb.org/clojure-gem-error.html

14:30 works with 2 threads, blows up with 3

14:31 (I'm giving a lightning talk about this at ~3pm PST at JRubyConf)

14:34 I'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:34 (where my inc is implemented in Ruby, but whatever.)

14:35 rhickey: technomancy: if JRuby is getting in the way of exception flow that will mess up transactions, which use exceptions for retries

14:36 technomancy: I see; it's probably wrapping them in a Ruby exception type.

14:36 rsynnott: technomancy: What is your adapter going to do, exactly?

14:37 technomancy: seems likely since commute works fine with ten threads

14:37 rhickey: LockingTransaction$RetryEx is definitely a retry exception (i.e. not an error)

14:38 but if it gets wrapped, it will not be detected as a retry in the transaction loop, and will flow out

14:39 kzar: rlb: 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:45 rlb: Ah, 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:47 technoma`: conference wifi; sorry

14:47 rlb: I'm not sure you need much concurrency wrt tetris, though, do you?

14:47 kzar: I 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:48 rlb: Well I don't need concurrency but I don't need tetris either

14:50 I'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:50 rlb: kzar: I mostly mentioned the demo because (iirc) it manages a 2-d world state, but the rest may not be relevant to you.

14:51 Anyway, passing the world via loop/recur should work fine

14:52 kzar: yea I think you're right, I'm going to give it a shot

15:03 krumholt__: what happens to clojurebot if i eval a recursive function that loops endlessly?

15:03 the-kenny: krumholt__: Just try it

15:03 :D

15:03 krumholt__: the-kenny, i don't wan't to break something

15:04 the-kenny: hm... I'm sure hiredman has programmed some timeouts or so.

15:04 technomancy: rsynnott: 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:05 rhickey: 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:05 Hunner: Any idea what colorscheme this is? http://kotka.de/projects/clojure/vimclojure.html

15:12 jweiss: Hunner: 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:12 his nick is kotarak

15:13 still i like that color scheme a lot

15:13 * Hunner doesn't think he could move to emacs. All my friends would make fun of me :)

15:14 * Scriptor just realize vimclojure doesn't have built-in syntax highlighting

15:14 Scriptor: *realized

15:14 jweiss: i hated emacs since college, but now that i'm giving it a 2nd chance, i see the beauty of it

15:14 Hunner: Scriptor: syntax/clojure.vim

15:14 it's in vimclojure

15:15 Scriptor: or not

15:15 the-kenny: Hunner: Just show the how awesome slime is :)

15:15 Or org-mode, or artist-mode

15:15 Hunner: yeah, I haven't compared slime and slimv yet

15:15 the-kenny: don't start :)

15:15 the-kenny: :p

15:16 Scriptor: hmm, I still don't seem to be able to get good syntax highlighting with vimclojure

15:16 jweiss: Scriptor: 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:17 Scriptor: I don't get any colors for defn

15:17 and for some reason 'return' gets highlighted

15:17 jweiss: Scriptor: worked for me when i followed the instrux here: http://kotka.de/projects/clojure/vimclojure.html

15:17 _ato: I like zenburn for both emacs and vim (though I chane the background to be a bit darker) http://slinky.imukuppi.org/zenburn/

15:18 Scriptor: jweiss: right, that's what I did as well

15:18 jweiss: Scriptor: maybe you have to enable 256 color mode for your terminal

15:18 Scriptor: I think it's mistakingly using another language's syntax

15:19 it should use vimclojure for any .clj files, right?

15:19 other languages work fine

15:19 rlb: Any 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:20 Could have an agent to manage the outgoing socket, or a transaction protected "outgoing" queue and a thread to manage the output.

15:20 the-kenny: rlb: I think I would do it exactly like that. (But I'm not very experienced...)

15:21 ha.. If I think what a pain in the *ss something like this would be in C++ or so..

15:21 rlb: Hmm -- 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 _ato: the-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:26 the-kenny: _ato: Yeah, Clutch is cool too, but I like the simplicity of clojure-couchdb.

15:26 _ato: hehe, Clojure has kind of spoiled me I much prefer (get-document) to return nil when there's no doc instead of blowing up :)

15:29 technomancy: _ato: wait, clutch is a view server _and_ a client?

15:30 rlb: Hmm, not sure clojure even has that kind of blocking (block until changed)?

15:31 _ato: technomancy: yeah

15:34 technomancy: just add [query_servers] clojure = java -jar .../clutch-standalone.jar to couchdb config and suddenly you cuse clojure views. It's really nice

15:35 danlarkin: _ato: does that keep the jvm running between requests?

15:36 _ato: danlarkin: yes

15:38 danlarkin: that's pretty neat

15:45 qed: Hmmm I didn't expect that to happen...

15:45 (in-ns 'myapp)

15:45 (clojure.core/use 'clojure.core)

15:45 _ato: you 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:45 qed: hangs my slime repl

15:46 Is that weird?

15:50 Anyone have this problem?

15:50 spuz: Is there a way to tell whether or not a function returns a primitive type or not?

15:51 Calling class on an int appears to autobox it into an Integer

15:51 ,(class (int 0))

15:51 clojurebot: java.lang.Integer

15:53 _ato: qed: works for me :\

15:54 qed: weird

15:54 hiredman: spuz: functions cannot return a primitive

15:54 * qed restarts emacs and tries again

15:54 hiredman: int supperficially looks like a function, but it is a cast

15:55 qed: it hangs me again

15:55 spuz: hmm

15:55 qed: _ato: any ideas on troubleshooting this? Are you running 1.1.0?

15:55 spuz: what if I say (let [x (inc (int 0))] ...) is x still a primitive after it gets incremented?

15:55 hiredman: qed: use refer, not use

15:55 qed: why does that fix it?

15:59 hiredman: qed: not sure, but use will load a namespace and then refer it, but core is already loaded

16:03 qed: hiredman: ah, so im trying to load 'clojure.core from 'clojure.core, which is screwing it up?

16:05 ordnungs`: re

16:06 _ato: qed: is there a reason you need to (use 'clojure.core) or a re you just experimenting with the namespace functions?

16:06 qed: experimenting with namespaces

16:06 hiredman: qed: I don't know the exact mechanics

16:06 qed: per S. Halloway's book

16:07 p65 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 _ato: qed: oh and yeah I am on clojure 1.1

16:10 qed: that's really weird, maybe it's our version of swank-clojure or slime that's making the difference

16:11 im bleeding edge on all of it

16:18 defn: How do I edit my SLIME prompt?

16:46 hiredman: clojurebot: FAQ #1?

16:46 clojurebot: Excuse me?

17:02 ordnungswidrig: anybody using a macbook pro for java/clojure development. Does the ssd make a difference?

17:05 qed: ordnungswidrig: the ssd is going to make a noticeable difference for all sorts of stuff

17:05 im not sure why you're asking specifically about clojure

17:07 _ato: ordnungswidrig: 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:07 ordnungswidrig: qed: 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:08 defn: i use a T61P laptop that my work provided, my setup is fine

17:08 _ato: for emacs it's not going make that much difference as emacs is pretty fast normally anyway

17:08 defn: even with a fat IDE, a new MBP should be fine

17:08 if you want to run Microsoft Word, on the other hand

17:08 better get that SSD

17:09 ordnungswidrig: defn: whoo, I think I might be forced to use that. Or openoffice. Don't know if a ssd matters for openoffice.

17:10 defn: I'd say yes. But the 270€ on top could be invested for other nice things as well.

17:11 rys: The T61p is the best laptop I've ever owned

17:11 * ordnungswidrig didn't want to start a notebook war.

17:13 ordnungswidrig: better go to bed, now. Thanks for you comments.

17:14 defn: rys: it's a great laptop yeah

17:15 rys: The only thing that bugs me is the battery life, even with a 9-cell

17:15 defn: i got lucky, the time i started this job meant getting the shiny t61p and not the crappy t60

17:15 yeah my battery just died and i had to order a new one, those 9 cells are junk

17:17 rlb: So 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:19 tomoj: I would expect just foo

17:20 because I can do (mpd/foo bar) if I want

17:26 jweiss: 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])

17:27 opqdonut: looks like paredit isn

17:27 't aware of []

17:27 try looking at the customizeable vars it has

17:27 i've only used paredit with common lisp

17:31 jweiss: opqdonut: what customizable vars

17:32 mrSpec: Could you help me with Macro? I dont know why this one is not working:

17:32 lisppaste8: mrSpec pasted "Macro - ActionListener" at http://paste.lisp.org/display/90922

17:33 opqdonut: jweiss: M-x customize

17:34 jweiss: opqdonut: forgive my emacs newbness. i get a list of categories, which one would paredit be under

17:35 hiredman: mrSpec: maybe unquote height and width

17:35 qed: http://vimeo.com/7722342

17:35 hiredman: ~'.addActionListener

17:35 clojurebot: It's greek to me.

17:35 hiredman: er

17:35 ~'.addActionListener can just be .addActionListener

17:35 clojurebot: Titim gan éirí ort.

17:36 hiredman: clojurebot: buzz off

17:36 clojurebot: excusez-moi

17:36 mrSpec: ok I'll try

17:36 hiredman: gpanel should be unquoted too

17:37 mrSpec: unquoted? could you tell something more? there is no quote before g-panel :S

17:38 hiredman: the whole doto form is quote

17:38 quoted

17:38 syntex-quoted to be exact

17:38 syntax

17:38 `(doto …)

17:38 qed: mrSpec: `() is a syntax quote

17:38 mrSpec: ah

17:39 qed: mrSpec: in syntax quoted things you'll find ~ and ~@ generally

17:40 hiredman: http://clojure.org/reader#toc2

17:40 qed: like `(a ~b (~@c))

17:40 mrSpec: ah, so I should add ~ before gpanel?

17:40 qed: maybe.... i didnt see your code

17:40 mrSpec: hiredman: thanks

17:41 qed: ~ defers the evaluation of the thing it's appended to

17:41 clojurebot: Huh?

17:41 hiredman: qed: woa, no

17:41 unquoting does the opposite of defer

17:41 qed: err it specifically evaluates what it applies to

17:42 hehe, just learned this yesterday so bear with me :)

17:43 mrSpec: 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:45 mrSpec: qed: thx, I'll take a look

17:47 qed: mrSpec: for my own edification ill re-write some of what _ato showed me

17:48 ,'(foo (+ 1 2))

17:48 clojurebot: (foo (+ 1 2))

17:48 qed: ,`(foo ~(+ 1 2))

17:48 clojurebot: (sandbox/foo 3)

17:48 qed: ,`[1 2 3 4 ~(+ 2 3) 6 7]

17:48 clojurebot: [1 2 3 4 5 6 7]

17:49 qed: (defmacro m3 [x] `(foo ~@x))

17:50 (m3 [1 2 3]) => (foo 1 2 3)

17:50 anyway, ill quit for the time being, but seeing those helped me quite a bit

17:51 mrSpec: ok, thx ;)

17:51 qed: this one was particularly fun to think about:

17:52 ,'`(evil (~test ~@fish))

17:52 clojurebot: (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:52 qed: _ato++

17:55 Drakeson: Do 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:56 mrSpec: hah I've found another bug... I cant have button "button1" and macro "button1" in Clojure?

17:56 hiredman: what do you mean?

17:56 _ato: Drakeson: alias clojure-run="java -server -jar .../clojure.jar -e"

17:57 mrSpec: (defmacro button ...) and (let [button (new Jbutton )] (button button)) Something like that

17:58 hiredman:

17:59 Drakeson: _ato: nah! note that I want *remote* calls. I don't want to run a new instance of jvm.

17:59 cark: mrSpec : that's not a bug, clojure is a lisp1

17:59 look it up

17:59 mrSpec: cark: bug in my program ;)

17:59 hiredman: actually, depending on details of clojure's compilation model that I am not familar with, that might work

17:59 technomancy: Drakeson: you want nailgun

17:59 mrSpec: I've just read that clojure is a lisp1 :/

17:59 hiredman: not entirely sure how macro's work with lexical scope issues

17:59 Drakeson: technomancy: please, no!

17:59 _ato: Drakeson: yeah, setup nailgun and then: alias clojure-run="ng clojure.main -e"

18:01 joshua-choi: Hey, how can you get the name of a Var?

18:02 _ato: ,(:name (meta #'inc))

18:02 clojurebot: inc

18:02 joshua-choi: Excellent, thank you.

18:02 _ato: joshua-choi: ^

18:02 :)

18:02 Drakeson: apt-cache search nailgun --> nil. (debian unstable).

18:04 (I know about http://martiansoftware.com/nailgun/index.html, but it is too much a hassle)

18:05 _ato: Drakeson: 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 err

18:05 unzip not tar

18:06 hiredman: freebsd's tar handles zip files :P

18:51 mitkok: Hey, guys. Anyone using slime under Ubuntu, but installed from source, no *.deb package.

18:51 technomancy: mitkok: slime upstream broke a few things on us; best to install via elpa: http://tromey.com/elpa

18:53 mitkok: technomancy: ok, thanks

19:04 technomancy: 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:19 technomancy: mitkok: with M-x slime? are there jars in the ~/.swank-clojure dir?

19:20 mitkok: technomancy: actually, I clojure was not installed, but only the modes through elpa package manager. I ran clojure-install and everything works fine :)

19:21 joshua-choi: Quick question: how do you get the name of a namespace? (I'm trying to get the namespace-qualified symbol of a Var.)

19:22 hiredman: joshua-choi: vars have two public fields, ns and sym

19:22 ,(.ns (var +))

19:22 clojurebot: #<Namespace clojure.core>

19:22 technomancy: ,(meta (the-ns 'clojure.core))

19:22 clojurebot: {:doc "Fundamental library of the Clojure language"}

19:22 hiredman: ,(.sym (var +))

19:22 clojurebot: +

19:22 hiredman: ,(.ns (var +))

19:22 clojurebot: #<Namespace clojure.core>

19:22 hiredman: ,(name (.ns (var +)))

19:22 clojurebot: java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.Named

19:22 hiredman: :|

19:23 ,(symbol (str (.ns (var +))) (.sym (var +)))

19:23 clojurebot: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String

19:23 hiredman: ,(symbol (str (.ns (var +))) (name (.sym (var +))))

19:23 clojurebot: clojure.core/+

19:23 hiredman: ,(resolve (.ns (var +)) (.sym (var +)))

19:23 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$resolve

19:24 hiredman: :|

19:24 anyway

19:24 joshua-choi: That's what I need

19:24 Thanks a lot

19:25 chouser: (

19:25 ,(ns-name *ns*)

19:25 clojurebot: sandbox

19:25 hiredman: ah

19:25 chouser: but that doesn't really help

19:26 hiredman: anyway, it would be great if namespaces where Named

19:26 chouser: vars too

19:26 hiredman: hmmm

19:26 joshua-choi: Yeah, it would

19:26 hiredman: I suppose

19:26 joshua-choi: But ns-name is better than str, so thanks too

19:26 hiredman: and return nil if unamed?

19:26 chouser: I'd be happy to have 'name' work on most vars and return nil for unnamed ones

19:26 yeah

19:27 what's named now. just keywords and symbols?

19:27 hiredman: I believe so

19:28 yes

19:28 chouser: both already support unqualified names. I guess "no name at all" stretches that a bit further

19:28 hiredman: huh

19:28 this thing that implements Named is not named...

19:29 chouser: yeah, I think that's why rhickey has resisted so far.

19:29 hiredman: IMightHaveAName

19:37 clojurebot: naked dot is <reply>http://groups.google.com/group/clojure/msg/8fc6f0e9a5800e4b

19:37 clojurebot: Ok.

19:49 defn: ,(doc drop-last)

19:50 clojurebot: "([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"

21:43 zaphar_ps: does clojure-contrib have a foldl and foldr implementation?

21:45 _ato: foldl is just reduce isn't it?

21:45 not sure if there's a foldr

21:46 defn: You could make one

21:46 zaphar_ps: _ato: yeah actually it is :-)

21:47 hadn't quite triggered that.

21:47 defn: I did actually

21:47 defn: http://gist.github.com/96861

21:47 zaphar_ps: it's an easy fn to write

21:47 defn: There's another one if you like :)

21:48 JAS415: couldn't you just reverse and then do the reduce

21:49 defn: foldr isn't lazy

21:49 in the above implementation

21:49 JAS415: isn't tail recursive either i dont think

21:49 zaphar_ps: correct on both accounts

21:52 defn: How do you do something like (Random. nextInt 10) in one line?

21:52 zaphar_ps: defn: that looks like one line to me

21:52 defn: not working for me for some odd reasno

21:52 might just be my repl

21:52 JAS415: what does that produce?

21:53 defn: an exception

21:53 JAS415: ,(Random/nextInt 10)

21:53 clojurebot: java.lang.Exception: No such namespace: Random

21:53 zaphar_ps: I get IllegalARgumentException

21:53 JAS415: ,(rand-int 10)

21:53 clojurebot: 2

21:53 defn: You need to (import '(java.util.Random))

21:53 JAS415: ,(rand-int 10)

21:53 clojurebot: 0

21:53 hiredman: (import '(java.util Random))

21:53 defn: err ty

21:54 _ato: ,(.nextInt (java.util.Random.) 10)

21:54 clojurebot: 9

21:54 zaphar_ps: even with import I still get Illegal Argument

21:54 defn: _ato: so you would just do:

21:54 zaphar_ps: hrmm

21:54 defn: ,(.nextInt (Random.) 10)

21:54 clojurebot: java.lang.IllegalArgumentException: Unable to resolve classname: Random

21:55 _ato: ,(import 'java.util.Random)

21:55 clojurebot: java.util.Random

21:55 JAS415: whats the difference between that and rand-int?

21:55 defn: ,(.nextInt (Random.) 10)

21:55 clojurebot: 7

21:55 defn: there we are

21:56 _ato: ~def rand-int

21:56 JAS415: ,(Random/nextInt 10)

21:56 clojurebot: java.lang.IllegalArgumentException: No matching method: nextInt

21:56 JAS415: ah i see

21:57 * zaphar_ps thinks vimclojure may be the most well written and easiest to use vim plugin he has ever used

21:59 defn: If you think that's good, wait til you try slime ;)

21:59 zaphar_ps: heh

21:59 I did try slime but emacs just doesn't fit me very well

22:00 thus my pleasure concerning vimclojure

22:02 JAS415: emacs has a steep learning curve, but i had emacs running compojure and i was refreshing my browser from inside emacs

22:03 which was a big efficiency boost over clicking refresh

22:03 and that's all because of the scripting aspect i guess

22:03 zaphar_ps: JAS415: alt-tab ctrl-r

22:04 JAS415: i was just doing ctrl-x p

22:04 i guess that works too though

22:04 zaphar_ps: not sure the difference in keystrokes is all that noticeable

22:05 but yeah I already have years invested in vim and just don't feel like tackling the emacs learning curve

22:05 JAS415: yeah

22:05 zaphar_ps: despite my enjoyment of list and clojure

22:05 JAS415: if you are already good with what you have use it

22:43 efarrar: hello, anybody using the latest vim-clojure with gorilla?

22:44 hi yacin

22:51 zaphar_ps: efarrar: define latest version?

22:52 head won't even compile for me

22:52 efarrar: eh, any version will do i guess

22:52 zaphar_ps: but that last release tag does

22:52 what did you want to know?

22:52 efarrar: i can type \sr all day long but no gorilla

22:52 filetype sets correctly

22:52 zaphar_ps: does \ef work

22:53 efarrar: yes

22:53 zaphar_ps: and I assume you started your nailgun server

22:53 if ef works then of course you did

22:53 efarrar: yes

22:53 zaphar_ps: does it give any error message?

22:53 efarrar: oh really?

22:53 no it just catches the "s" key

22:54 zaphar_ps: thats weird

22:54 efarrar: and deletes a character and enters insert

22:54 zaphar_ps: I've never had it partially work

22:54 I've had it fail totally or not fail at all but never a single command

22:54 efarrar: oh wait

22:55 ef does not work, it does whatever \e does

22:55 zaphar_ps: ahhh ok

22:55 efarrar: or rather, "e"

22:56 zaphar_ps: then what has happened is the plugin hasn't actually loaded

22:56 efarrar: ok

22:56 zaphar_ps: if you look in the .vim/autoload/vimclojure.vim file you'll see a bunch of commands

22:57 if you try to execute any of them they probably will give you an error that it cant' find them

22:57 for some reason it hasn't actually loaded the plugin file.

22:57 As for why I'm not sure what the reason is.

22:58 I had an error in mine that caused it

22:58 efarrar: i'll read back through the install

22:58 zaphar_ps: the other reason might be because it can't find the nailgun server also

22:58 hope that helps

22:59 efarrar: if you have to try putting some echomsg lines in the initbuffer function in the vimclojure.vim file

22:59 that 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:00 defn: Good god I am blowing through this Clojure book

23:00 This is the first time in my entire life I've actually read an entire programming book

23:00 as in cover to cover

23:00 zaphar_ps: defn: heh

23:01 the only programming book I've ever read cover to cover was the camel book

23:01 and that was a long long time ago

23:01 catfishlar: defn: I have not read it. Is it well written or is it just beacsue clojure is interesting

23:01 defn: The 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:02 catfishlar: I'd say both

23:02 The 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:02 catfishlar: I 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:03 defn: the performance stuff in the Clojure book has been some of the stuff I've been missing

23:03 and that was laid out really nicely

23:04 Part 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:04 with other established languages it's easy to jump around the web finding this and that

23:05 This is partially true for clojure, but not to the extent of say Ruby

23:05 so having a sort of guide book is really nice and relaxing in a way

23:08 JAS415: i think in a couple years it will be better

23:08 defn: Clojure or the book?

23:08 JAS415: i think there is at least one more clojure book coming out soon

23:08 oh sorry, just the size of library and information

23:09 defn: oh sure

23:09 it takes time

23:09 and yeah there's a book coming out from Apress

23:09 but this is a great book, FWIW

23:10 JAS415: clojure looks like it will just continue to get better as well, fwiw

23:12 defn: yeah for sure

23:12 I'm excited for the future :)

23:13 I'm done reading for the day -- I just got to Creating Java Proxies and am suddenly bored

23:15 chouser: and two from Manning

Logging service provided by n01se.net