#clojure log - Aug 12 2009

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

0:58 Anniepoo: has clojure.contrib.http.agent been removed for some reason?

1:01 hiredman: looks like it is still there

1:02 Anniepoo: vewwwy wierd

1:05 ok, I do an update on trunk and half my clojure.contrib source packages are deleted

1:06 Chouser: if you don't have local changes, you might want to do a fresh checkout into a new directory.

1:07 hiredman: sounds like the wrong trunk

1:07 Anniepoo: ah, somehow I'm not on a class only trunk

1:08 8cD sources now on github

1:08 hiredman: "wrong trunk"

1:10 Anniepoo: 8cD shoulda quit my ide before doin that!

1:11 Darn! now I gotta install git to get a new clojure.contrib jar

1:12 hiredman: you can just grab a tarball of the source from github

1:23 Anniepoo: any idea how long 'Hardcore Archiving Action' should take?

1:29 well, it should be able to archive in 6 minutes, yes?

1:31 github's archiving is borked. Somebody willing to email me a clojure.contrib jar file so I can continue work?

1:35 hiredman: http://www.thelastcitadel.com/lab/clojure-contrib.jar

1:35 (complete with all kinds of nasty trojans and spyware)

1:36 Anniepoo: LOL

1:36 thanks

1:36 cause github's still waiting

1:37 don't know if there's anything else in the distro

1:38 but I need to write some code, not play with git

2:22 shit! no binary.

2:37 is http-agent not ready for prime time?

2:38 threw this exception No matching method found: setFixedLenghtStreamingMode

2:38 note the misspelling

2:46 arbscht: that seems to be an error in http.connection

2:48 Anniepoo: hmm

2:50 this code is only about 6 weeks old

2:50 I'm probably the first user

2:52 guess I'll move it to a GET and just slurp an URL

3:31 is there a simple way to curl a URL?

3:32 andyfingerhut: Shell out to curl, perhaps? Maybe not want you want to do, though.

3:33 Anniepoo: no, I want some (slurp-url "http://www.somebody.com") whose value is a string that is the body of the page

3:37 jd8hh57: AnniePoo: not sure how old or relevant this is, but about halfway down here: http://gnuvince.wordpress.com/2008/10/31/fetching-web-comics-with-clojure-part-1/

3:37 Anniepoo: yah, fetch-url

3:37 jd8hh57: there is a 'fetch-url' function

3:37 Anniepoo: didn't want to use my own if there was a lib version

3:37 jd8hh57: ok - you already knew :) sorry.

3:37 Anniepoo: it's cool

3:37 jd8hh57: ahh!

3:38 Anniepoo: what would be ideal would be if (slurp "http://www.foo.com") did the right thing

3:38 if there's no protocol, assume it's a filename

3:42 oh, poo....

4:04 darn!

4:05 hiredman: http://gist.github.com/119375

4:09 Anniepoo: thanks

4:18 AWizzArd: cgrand: do you know how I can call the compiler from within Java on a string which contains clojure code?

4:19 such as clojure.lang.Compiler.execute("(println 10)");

4:24 cgrand: AWizzArd: sure

4:25 clojure.lang.Compiler.eval(clojure.lang.RT.readString("(println 10)"))

4:25 AWizzArd: Could you show an example call, for example on how calling this example string "(println 10)"?

4:26 ah good, thanks.. so far I wrote the strings to disk first and called loadFile

4:28 cgrand: funny you asked how to do that because I was just working on something related. Are you looking over my shoulder? :-)

4:42 AWizzArd: cgrand: it was an "accident". I am developing a lib for Clojure which will allow its use in a nice Framework which currently only accepts Java. To allow the users of my lib to write Clojure instead I need to compile their code.

4:42 cgrand: but while starring at Compiler.java I noticed your name there on github, so I asked :)

4:44 another way to inject Clojure into a Java program dynamically could be to put it as an anon function into some vector and have the Java code .invoke from the right index from that vector instead.

4:47 btw cgrand, as you also know about how Clojure maps are implemented.. would it help if the user could specify an initial size for the map? In a classic implementation with array buckets under the hood it prevents from copying the map when more elements get added.

4:56 Anniepoo: If I do what you said, cgrand, to eval something, then do I get all the current context?

4:57 never mind, I see.

4:58 night all, that convinced me I'm inserting, not removing, bugs

5:30 AWizzArd: clojure: paste

5:30 clojurebot: paste

5:30 clojurebot: lisppaste8, url

5:30 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

5:43 AWizzArd pasted "Try/Catch challenge in with- macros" at http://paste.lisp.org/display/85244

5:50 AWizzArd: cemerick: do you have an idea how to handle that challenge?

5:53 cemerick: The problem being, you don't want two printlns given an error?

5:54 AWizzArd: I want the macro to return what the body returns

5:54 The macro will always execute its finally block and return what that returns.

5:55 I currently work with an atom to go around that problem

5:56 cemerick: I guess I'm not following what's wrong with your with-resource.

5:56 it's < 6AM here :-P

5:57 AWizzArd: *g*

5:58 when I have a let inside my with-resource macro and want with-resource to return what the let returns, then this won't work.

5:58 Because with-resource will run the finally block.

5:58 My second with-resource macro causes a problem.

6:02 cemerick: nothing ever gets returned from a finally block.

6:02 lisppaste8: cemerick annotated #85244 "no return value from finally" at http://paste.lisp.org/display/85244#1

6:03 AWizzArd: hmm ok, i didn't know that

6:03 cemerick: so the value of ~@body will be the return value of a standard with-resource

6:03 (outside of an exception)

6:04 AWizzArd: oh good, then you already helped me, thanks :-)

6:06 alinp: hi

6:06 (defn my-test

6:06 ([] (println "none"))

6:06 ([a] (println "one arg"))

6:06 ([a b] (println "two args")))

6:06 is this some sort of pattern matching in clojure ?

6:06 or is more like method overloading ?

6:07 if not (not a pattern matching), how can this be done ?

6:09 AWizzArd: You want to know how to do pattern matching?

6:09 alinp: yep

6:09 is this the way ?

6:09 that I paste above

6:10 AWizzArd: PM is currently not directly supported by Clojure. You can implement your own pattern matcher. Clojure however comes close to the expressivity of pattern matching with multi methods.

6:11 alinp: ok, thanks for that, I know about multi methods

6:11 so, what means the piece of code that I paste ?

6:11 emulates somehow the method overloading ?

6:11 arbscht: arity overloading

6:11 alinp: ok... yeah

6:11 thanks arbscht

6:17 cemerick: alinp: note that destructuring is deeply supported:

6:18 ,(let [{a :a b :b} {:a 5 :b 6} [x y] (range 2)] [a b x y])

6:18 clojurebot: [5 6 0 1]

6:24 angerman: how would i create an InputStream from a String?

6:26 alinp: angerman: ByteArrayInputStream str = new ByteArrayInputStream("blabla".getbytes());

6:26 :)

6:27 ofc, you will specify also the encoding for getBytes() method

6:27 use clojure facilities to call this java code

6:27 s/code/api/

6:28 * angerman had hope to find something in the duck-stream contrib, ...

6:28 angerman: hmm

6:29 alinp: sorry, can't say something about that; maybe it is

6:31 arbscht: duck-streams works with file-like things mostly

6:46 cgrand: AWizzArd: re maps: an initial size wouldn't help for persistent maps, not even for transient maps. But some of the perf improvements (in my fork of clojure) are related to transient nodes whose size allow for some growth without copying.

6:47 osaunders: How can I recursively call a function without repeating its name?

6:48 Seems like that's what recur should do only it never seems to work.

6:50 arbscht: osaunders: can you provide an example where recur fails?

6:51 osaunders: http://pastebin.com/m1eb222d4

6:52 Says too many arguments, expecting 1.

6:52 I can see what it's trying to do.

6:52 cark: you have to understand that each arity is a separate function

6:53 so in arity 1 you just call sum-event-fibo

6:53 and use recur in arity 4

6:53 osaunders: Even so that doesn't satisfy my requirement.

6:54 cark: what is you requirement ?

6:54 your*

6:54 osaunders: To recurse without repeating name.

6:54 cark: yes it does

6:55 use recur in place of sum-even-fibo in arity 4

6:58 osaunders: But then I have to use full name in arity 1.

7:00 ...which is why my requirement isn't satisfied.

7:00 arbscht: yes, because you are trying to call a different function :)

7:01 osaunders: It's the same definition though.

7:01 cark: when using recur, the goal is not to avoid repeating the name of the function

7:01 recur is about doing tail recursion

7:02 your arity 1 function is only being called once

7:02 so recur is useless there

7:02 osaunders: I understand that.

7:02 I just don't want to have to repeat the name of the function.

7:02 Because then if I choose to change the name I have to update it in several places.

7:02 cark: well i guess you're out of luck then =)

7:02 osaunders: Yeah, Clojure fail.

7:03 arbscht: a 'reinvoke' operator would be nice

7:03 post a message to the mailing list

7:04 osaunders: Hm.

7:04 cark: well you can always (declare sum-event-fibo) then (def curr-function sum-even-fibo) and finally use curr-function for your recursion

7:04 or make a defn macro

7:05 osaunders: Yeah.

7:06 tomoj: interesting. if you change the name of the function without changing it in the reinvoke and just re-compile, it would compile and work fine

7:06 then if you change the behavior of the function you would get weird results

7:06 I sometimes think slime should be able to wipe the namespace clean and recompile

7:08 but that would mean any vars would get washed away too.. hmm

7:34 cark: anybody used memcached with clojure ?

7:34 cgrand: osaunders: http://pastebin.com/f742c10d3

7:35 osaunders: cgrand: TY

7:53 AWizzArd: cgrand: that sounds interesting

8:13 angerman: args! (apply recur (map #(.get csvr %) (range 0 8))) I cannot call apply on recur ..

8:16 cemerick: is anyone here familiar with the GPL, etc.?

8:18 angerman: hmm so apply is not a macro ...

8:19 cemerick: what's the question?

8:20 cemerick: Consider a library dual-licensed under GPL v2 and a proprietary license. I'd like to publish an extension to this library, but not under GPL (anything bsd-esque would be fine) -- is it simply enough to not include the GPL library or its sources e.g. when I push to github, and have users of my extension obtain the base library independently?

8:21 I've been ready the GPL FAQ for about 20 min, and couldn't take much more :-P

8:21 tomoj: angerman: even if it were a macro, wouldn't the fact that recur has to be in tail position make what you're trying to do impossible?

8:22 cemerick: if you're not distributing the GPL'd code, the license doesn't matter at all, does it?

8:23 cemerick: tomoj: that's my understanding and intuition, but I've generally only trafficked in proprietary licenses, and my light reading of the GPL and its FAQ makes me nervous in general.

8:23 angerman: cemerick: well as long as it's your code, you can always license it to a third part (or yourself) using a different license

8:23 tomoj: they can't say "if you write code which happens to work well with my code, you must use such and such license"

8:24 angerman: and the GPL basically sais if you make any derivation of the work you have to share it with the rest of the world

8:25 tomoj: well what I try to do is write "less" :)

8:25 recur is still in tail position but I'm not so much into expanding the (.get csvr 0) ... (.get csvr 7)

8:25 tomoj: oh, yes, I see

8:26 cemerick: angerman: to be clear, the only way that this extension "derives" from the GPL library is that needs to be built against it. It's not like I'm changing the library's implementation in some way.

8:26 tomoj: I was confused for a second about what apply does

8:27 cemerick: Another point is that we've never accepted the GPL for this library; we've purchased the commercial license for it. Not sure if that affects things.

8:27 tomoj: if copyright law gives bob influence over people who write separate code that requires bob's code to function, that's crazy

8:27 but copyright law is crazy I suppose

8:27 angerman: cemerick: if you've purchased a different license for it, the GPL has nothing to do with it.

8:28 I think the "whole" link against something is why we have the LGPL

8:28 then again, I'm not a lawyer

8:29 cemerick: angerman: OK, for me perhaps, but if someone who wants to contribute back to my extension, and who uses the base library under the GPL, they'd be barred from doing so (I think)

8:29 AWizzArd: angerman: you can write your own macro which will expand into (recur (.get csvr 0) (.get csvr 1) ... (.get csvr 7))

8:29 cemerick: tomoj: I'm pretty pissed that I have to think about this at all. If only we just had bsd-esque and commercial licenses, I'd know my ass from my elbow.

8:30 AWizzArd: (map-recur #(.get csvr %) (range 8))

8:31 Chousuke: cemerick: you could mail the FSF and ask them.

8:32 cemerick: Chousuke: heh. I *definitely* don't trust them for legal advice.

8:32 I think I'll head to stackoverflow, there's some body of license-related questions there.

8:32 tomoj: hmm.. I wonder why clojure-test-mode still refers to clojure.contrib.test-is

8:33 angerman: AWizzArd: I tried to, but failed to write a "working" macro

8:33 Chousuke: angerman: could you use clojure.template? :)

8:34 or clojure.contrib.template if you're stuck with 1.0

8:35 angerman: Chousuke: how would that help? isn't that a html template library?

8:35 Chousuke: no.

8:35 it's for "code templates"

8:35 AWizzArd: Chousuke: so, macros for the poor? :-)

8:36 * angerman has some real need to for a in-place opperator

8:36 angerman: so I don't have to use apply :/

8:38 AWizzArd: how would you write that macro?

8:38 Chousuke: hmm

8:40 angerman: (defmacro foo [f coll] (cons 'recur `(map ~f ~coll)))

8:40 hmm that seems to do it ...

8:41 hmm ok, not really :(

8:41 Chousuke: http://gist.github.com/166483

8:42 tomoj: why does your function take 8 arguments?

8:42 AWizzArd: no, that's not it. Sorry, have no time now. But an alternative could be to have that function which you want to recur taking &rest arguments.

8:42 Chousuke: the gen must produce fragments of code, of course. so in your case it needs to be (fn [x] `(.get csvr ~x)(

8:42 oops

8:42 )*

8:44 and naturally both gen and source need to be known at compile-time, so you can't pass function parameters to it or anything :/

8:44 tomoj: why not just (recur (map #(.get csvr %) (range 8)) ?

8:45 Chousuke: tomoj: because that would call recur with a single argument. angerman apparently has 8

8:46 tomoj: Chousuke: yep, that's what I'm wondering about

8:46 angerman: well, using recur in combination with loop so

8:46 I guess I could so the destruction in the loop head ... but that would be kinda funny

8:46 clojurebot: that is not what I wanted

8:47 febeling: when I use add-classpath in repl, and watch the classpath via contrib.clojure.classpath, it doesn't change. does that make sense?

8:48 * angerman doesn't think that live-changing of the classpath works well

8:49 Chousuke: febeling: toying with the classpath at runtime is dubious activity anyway, so it's no wonder if unexpected things happen :)

8:50 febeling: ok :)

8:53 * angerman would think though that toying with the cp on the repl could be handy at times

8:53 cemerick: Here's my licensing question, for those that are interested: http://stackoverflow.com/questions/1265993

8:54 sorry for the OT distraction :-)

8:56 angerman: why does the subs not do neg end?

8:56 (defn substr [s start end] (subs s start (if (< end 0) (+ (.length s) end) end)))

8:56 that was kindof a hickup right now

8:56 Chousuke: probably because subs is just a wrapper for .substring

8:57 tomoj: how can you do something like ruby's File.dirname(__FILE__)? java?

8:57 Chousuke: look at metadata?

8:57 ,(:file ^#'+)

8:57 clojurebot: "clojure/core.clj"

8:58 Chousuke: or is that what you wanted

8:58 tomoj: __FILE__ means the current source file

8:59 well, path to the current source file from the cwd

9:04 (defn foo []) then (:file ^#'foo) works, but that seems silly

9:06 Chousuke: ,^*ns*

9:06 clojurebot: nil

9:06 Chousuke: ,^#'*ns*

9:06 clojurebot: {:ns #<Namespace clojure.core>, :name *ns*, :doc "A clojure.lang.Namespace object representing the current namespace.", :macro false, :tag clojure.lang.Namespace}

9:06 Chouser: ,*source-path*

9:06 clojurebot: "NO_SOURCE_FILE"

9:06 Chousuke: hmm, no file data :(

9:06 ah.

9:06 Chouser: ,*file*

9:06 clojurebot: "NO_SOURCE_PATH"

9:06 Chouser: that seems ... backwards

9:06 Chousuke: ... yes.

9:08 Chouser: also, those are vars, not any kind of reader magic, so it may be a bit tricky to get the results you want (depending on what you want, I suppose)

9:08 tomoj: great, *file* looks good

9:08 yeah at first I tried putting that in a defn

9:09 but I don't need that anyway, just trying to autoload some clj's in a dir

9:16 AWizzArd: angerman: I would have to think about it, but the macro could look like (defmacro map-recur [f coll] `(recur ~@(map (fn [x] `(~f ~x)) (eval coll))))

9:16 but as Chousuke already mentioned in his example: eval will be needed during macroexpansion time.

9:17 for some cases this won't be possible.. you should think about having your fn to accept a &rest parameter.

9:29 ole3: hello, is it possible to access X11 from clojure?

9:30 Chouser: ole3: sure, at many levels.

9:32 swing (or some other high-level toolkit), xlib (via JNA or JNI), or talk the X protocol directly on the socket (either TCP or unix sockets)

9:34 ole3: Chouser: I have an written an specialized window manager for my application, in C, I would like to have it in clojure to configure it at runtime

9:36 Chouser: ole3: ok, then I'd recommend using JNA to either interact with the xlib library or to interact with the X server's unix socket directly.

9:43 pdo: Anybody know how to read the kth bit of an integer in Clojure? e.g. like (ldb (byte 1 k) int) in CL?

9:48 AWizzArd: pdo: http://java.sun.com/javase/6/docs/api/java/lang/Integer.html

9:48 tomoj: ,(bit-test 12345 3)

9:48 clojurebot: true

9:48 AWizzArd: or toBinaryString could be interesting

9:48 ,(Integer/toBinaryString 127)

9:48 clojurebot: "1111111"

9:49 hiredman: keep in mind toBinaryString doesn't pad with leading zeros

9:50 pdo: Thanks tomoj

9:50 ole3: Chouser: thank you, I will try to talk to the unix domain socket directly.

9:52 Chouser: ole3: abrooks has looked some at writing a wm in Clojure, and concluded the xlib libarary would be more trouble than its worth, so I think you're on a good track.

9:53 ole3: I would recommend using JNA over any of the Java unix socket libs I've seen out there.

9:53 tomoj: this might be relevant http://sourceforge.net/projects/escher/

9:53 seems dead

9:57 Chouser: For JNA you might like http://github.com/Chouser/clojure-jna -- also that has an example of using open, close, read, and select on a unix file descriptor.

10:18 osaunders: http://www.theonion.com/content/node/33930

11:13 AWizzArd: Any Swing user here who knows by heart how to scroll down (max) in a JTextArea?

11:15 Chouser: maybe: (.setCaretPosition pane (.getLength (.getDocument pane)))

11:17 oh, that's probably a JTextPane

11:18 AWizzArd: I can try that

11:25 drewr: where's stuartsierra?

11:26 Chouser: ~seen stuartsierra

11:26 clojurebot: stuartsierra was last seen parting #clojure, 9717 minutes ago

11:33 drewr: trying to figure out an issue with c.c.http

11:34 AWizzArd: Chouser: Good idea with setCaretPosition. Btw, this also works: (.setCaretPosition log-area (count (.getText log-area)))

11:43 febeling_: is there a short way to make a HashMap a clojure map?

11:43 Chouser: (into {} your-hash-map)

11:44 febeling_: Chouser: thanks :)

11:49 angerman: has anyone experience with a html template lib for clojure?

11:49 tomoj: enlive

11:49 well.. it's probably not what you're thinking of

11:50 * Neronus uses stringtemplate. While it's not strictly for clojure, it's for java, which is good enough :)

11:51 tomoj: with enlive you just have html in the template and programmatically transform it

11:53 Neronus: in stringtemplate, the html-code is in a file of its own and you can give StringTemplate that file and e.g. a map, and it will transform that file, substituting variables as defined in the map

11:56 angerman: tomoj: yep I saw enlive, looked interesting.

11:56 does stringtemplate support tempalte inheritance_

11:57 if there was a port of something like jinja2 that would be awesome.

11:57 the only thing I hate about template engines is the lack of streaming :) but that's something not to be solved easily :)

11:58 Neronus: angerman: What do you mean by template inheritance?

12:00 angerman: Neronus: well with jinja2 you can have a master template and setup a derived template that inherits all the base from the master and substitues certain parts with custom content.

12:01 Neronus: basicall you mark a part of the html and overwrite it in the subtemplate. that way you usually have a master file and for every view a seperate file that derives from the master.

12:02 Neronus: angerman: Nope, I don't think that that is supported; Templates are pretty much functions, which map a set of variables to a string, depending on the template; they can of course call each other

12:03 Actually, I think they StringTemplate templates are somewhere on Chomsky level 1

12:04 angerman: hmm. so if i once find some spare time I'll port jinja

12:04 so for now I'll go with hand crafted vectors of vectors and feed them into the (html fn from compojure

12:05 Neronus: Whatever floats your boat :)

12:05 angerman: Neronus: I've so much legacy templates that use django/jinja template system...

12:06 Neronus: In that case it would probably be a good idea; but why switch to clojure if you've got a running system there?

12:07 cemerick: what ever happened to kid? It looks like its site is mostly hosed.

12:09 angerman: Neronus: well, it's getting painful. And as I started using tons of lambdas in python I figured I could switch straight to a functional language

12:38 cgrand: angerman: you can define your own inheritance system on top of enlive

12:43 tomoj: enlive is pretty interesting for templating

12:43 I don't think I've really wrapped my head around it yet

12:43 if you had designers, the templates they made for enlive could just me html mockups, right?

12:44 s/me/be/

12:52 ole3: Chouser: thanks for your clojure-jna package, it works like a charm.

13:08 Chouser: ole3: great!

13:53 tomoj: anyone know of a webrat for clojure

13:55 guess I can just write a tiny wrapper around htmlunit

13:55 angerman: tomoj: I might be interested in what you come up with :)

13:56 how would I create a few Exception Classes on the fly?

13:57 Chousuke: proxy Exception?

13:57 angerman: Chousuke: how would I name it

13:57 Chousuke: you wouldn't. :p

13:58 though I guess catching it would be a bit difficult then

13:58 angerman: Chousuke: well I want to throw a NotFoundException and an OutOfDateException

13:58 tomoj: angerman: what do you mean by "on the fly"?

13:58 that doesn't need to be on the fly, then, right?

13:58 angerman: tomoj: well, not really "on the fly"

13:59 tomoj: gen-class ?

13:59 Chouser: you need this for java interop, or will you be throwing and catching all within clojure code?

14:00 tomoj: how would you do it just within clojure code?

14:00 still need a classname for catch, right?

14:01 angerman: Chouser: inside clojure

14:01 Chouser: you might be able to use clojure features to achieve your goals.

14:01 like dynamically binding a function (instead of catch) and then calling it (instead of throw)

14:02 angerman: I could jsut return nil

14:02 though that makes it hard to distinguish what went wrong

14:02 I could use a return-ref as param, that would look wrid though I guess

14:04 hmm. okay I use a global ref as a stack and push my errors ontop of it

14:04 on return of (nil, I'll have to pop the last value of the stack and work my way down from there

14:04 still not perfect

14:06 I'm pretty sure that's not perfect with threads though...

14:06 Chouser: well, you can use gen-class to define and exception type, AOT compile it and you're good to go.

14:06 an exception

14:07 you could also look at the 2 or 3 options in contrib

14:07 the Right Way to handle error conditions hasn't quite been pinned down yet. ;-)

14:07 angerman: Chouser: it's a functional language so returning nil+x would be great, can I add metadata to nil?

14:08 that would probably be the best solution.

14:08 tomoj: isn't nil just nil?

14:09 angerman: so I end up with (if (nil? (fn-call)) {do some handling on the metadata} {procede with what ever you wanted anyway}) {stuff that's executed anyway}

14:09 tomoj: I mean, when you're returning nil, you're not returning a new nil object

14:09 you're just returning the one and only nil

14:09 (and so you can't change it's metadata, even if it could have metadata)

14:09 angerman: ,(with-meta nil {:err 'NotFound})

14:09 clojurebot: java.lang.NullPointerException

14:10 angerman: tomoj: I don't need to change it's metadata. I just need to know why the functioncall failed

14:10 tomoj: right

14:10 angerman: ,(with-meta 'nil {:err 'NotFound})

14:10 clojurebot: java.lang.NullPointerException

14:11 tomoj: adding metadata to nil is not a way to do that, that's what I'm saying

14:12 angerman: tomoj: hmm

14:12 tomoj: what's so bad about adding metadata to nil?

14:12 tomoj: it's impossible

14:12 it wouldn't make sense even if it were possible

14:12 and it seems ugly to me

14:13 angerman: about the ugliness ... that's subjective :) But as it's not possible it's kinda bad. And I'm not going to gen-class Nil and use that.

14:14 tomoj: what the heck IS nil anyway

14:14 ,(class nil)

14:14 clojurebot: nil

14:14 Chousuke: it's java null

14:14 cemerick: nil is Java's null

14:15 tomoj: I see

14:15 Chousuke: it's one of the "special" symbols, along with true and false.

14:16 ,(symbol? 'true)

14:16 clojurebot: false

14:20 Chouser: (binding [*do-error* (fn [details] handle-error-details)] (if-let [val (fn-call)] succeeded-so-use-val) proceed-in-either-case))

14:37 tomoj: if *do-error* is buried somewhere deep inside there, seems problematic

14:38 I guess if you use it intelligently it would work

14:42 Chouser: you could name it better, have mutliple by various names, etc.

14:42 just another option...

14:48 tomoj: I just mean, it needs to be in tail position, right?

14:48 otherwise the code will keep on chugging after you handle-error-details

14:48 Chouser: ah. yeah, you may still want to return nil after calling the fn

14:49 or the *do-error* could itself throw an exception. It could be generic since it would have already dealt with the specifics before throwing.

14:49 tomoj: ah, yeah

14:49 that makes sense

14:50 Chouser: I guess that's essentially what error-kit is doing internally anyway, but it has a bunch of other questionable bells and whistles.

15:18 angerman: :( once again I'm missing a map-filter :/

15:20 tomoj: huh?

15:21 angerman: ok, I fail to see what hindered me from getting it to work last time

15:21 maybe I'm just adapting to clojure :)

15:29 cemerick: angerman: just (map blah (filter blah ...)), right?

15:29 :-)

15:31 angerman: well as I already had a list of maps, it was even simpler :)

15:31 hiredman: (comp (partial map blah) (partial filter blah))

15:54 b4taylor: Say, how do I write a type hint for a char[]?

15:55 Chouser: if you're lucky, #^chars

15:55 b4taylor: ooohhh

15:55 angerman: hmm somehow I feel like java is faster then python ,)

15:56 * technomancy switched to a 32-bit machine, and yowza the client JVM boots really quickly.

15:56 technomancy: worth going back just for that.

15:56 b4taylor: technomancy: Yeah, but what about ther overall performance of the 64-bit JVM versus the 32-bit one.

15:56 Also, nailgun?

15:57 Chouser: b4taylor: yeah, #^chars seems to work

15:57 technomancy: b4taylor: I deploy on 64 bit servers, but for dev work startup is far more important.

15:57 b4taylor: Chouser: Yeah, but it's not acomplishing what I need.

15:57 I'm doing it in a stupid way, there must be a more direct way.

15:57 technomancy: nailgun solves a small portion of the startup problems. it's great for that, but people act like it's magic boot-time pixie dust.

15:57 b4taylor: I have a list of chars, I want to print them out with no spaces inbetween.

15:58 Neronus: b4taylor: (apply str list)

15:58 hiredman: how big of a list?

15:58 b4taylor: 28

15:58 hiredman: *snort*

15:58 yeah, apply str

15:58 cemerick: technomancy: what's the issue with startup time on 64-bit? More alloc going on at init?

15:58 hiredman: ,(map char (range 80 108))

15:58 clojurebot: (\P \Q \R \S \T \U \V \W \X \Y \Z \[ \\ \] \^ \_ \` \a \b \c \d \e \f \g \h \i \j \k)

15:59 technomancy: cemerick: no, the client JVM is only implemented in 32-bit.

15:59 hiredman: ,(apply str (map char (range 80 108)))

15:59 clojurebot: "PQRSTUVWXYZ[\\]^_`abcdefghijk"

15:59 cemerick: oh, I see

15:59 b4taylor: hiredman: Thanks.

15:59 That worked.

16:00 I keep forgetting about apply.

16:00 cemerick: technomancy: is that a permanent situation (e.g. it's -server from here on out?)

16:00 technomancy: cemerick: I suppose so; I've heard nothing about porting client mode to 64-bit

16:01 I guess it's a holdover from the days when 64-bit was for big-iron servers only.

16:01 cemerick: and here I thought they had reimplemented client in terms of server, just with different params/config

16:01 not sure where I got that idea

16:17 * hiredman punches github again

16:17 hiredman: I had forgotten about this

16:18 angerman: so I cannot just define defmethod without having a defmulti?

16:18 hiredman: the github api returns time zones like -07:00 where java expects -0700

16:18 angerman: nope

16:24 cemerick: angerman: without defmulti and a dispatch fn, a method is just a fn

16:27 hiredman: clojurebot: ping?

16:27 clojurebot: PONG!

16:28 arohner: angerman: the defmethods correspond to return values of defmulti

16:28 * to return values of the dispatch function defined by your defmulti

16:31 * angerman just though he could have called them like (my-method :selector [args])

16:31 angerman: I've got it though the defmulti now. but ... well :)

16:32 arohner: right, you call them (my-multi :selector [args]), :-)

17:06 * Chouser glares at the Google Group.

17:06 durka42: what did the google group ever do to you

17:08 Chouser: If you don't know, then I won't burden you with the knowledge. :-)

17:12 cemerick: Chouser: now I just feel silly trying to help out :-(

17:12 * cemerick is blissfully naive

17:25 wavister: i'm trying to use jedit to evaluate lines of clojure code similarly to how it does with beanshell. I'm getting an ExceptionInInitializationError caused by a NullPointerException in clojure.core. I don't get what it's doing. Would someone take a look? http://code.bulix.org/b4yfpw-71986

17:26 hiredman: ok

17:27 wavister: need the code that caused it

17:27 not just the exception

17:27 wavister: the code is just Class.forName("clojure.main")

17:27 hiredman: but a NullPointerException means you are calling a method on something that is null

17:28 * hiredman waits for someone to commit something to github

17:28 wavister: yeah, it's coming from java.util.Properties called by clojure.core

17:29 do you think it's looking for core.clj in the file system and not finding it...

17:29 hiredman: no

17:29 I think core.clj is looking for the file containing the version information and not finding it

17:30 ~def *clojure-version*

17:31 chrome has a lot of trouble with github's line number anchors

17:33 wavister: would there be a system variable i need to set in the jedit environment to help it find said file?

17:34 where is it anyway? inside the clojure jar?

17:34 hiredman: yeah

17:34 might be some kind of classloader issue

17:34 Chouser: if you used the normal ant build for to make the clojure.jar, then yes

17:34 hiredman: ooh, good point.

17:34 you'd think I would have learned by now to suspect classloaders first...

17:35 wavister: ... i hate classloaders

17:35 hiredman: clojurebot should start sending notices for commits again

17:36 wavister: i did use ant to make clojure.jar, too

17:38 well for now maybe i'll just not use jedit for evaluating clojure code in-buffer

17:53 drewr: ,(partition 10 (range 5))

17:53 clojurebot: ()

17:54 drewr: how do I get that to return (0 1 2 3 4)?

17:54 IOW, the last partition is what's left in the seq

17:55 Chouser: ,(clojure.contrib.seq-utils/partition-all 10 (range 5))

17:55 clojurebot: ((0 1 2 3 4))

17:56 drewr: I just saw the pad arg too

17:56 Chouser: oh. yeah, I wouldn't rely on that.

17:56 drewr: ,(partition 10 1 [] (range 5))

17:56 clojurebot: ((0 1 2 3 4))

17:56 drewr: hm, ok

17:57 Chouser: http://www.assembla.com/spaces/clojure/tickets/120-GC--Issue-116--partition-with-pad

17:58 "I’m now convinced we are cramming 2 functions into one, and would prefer to see this new functionality as a new function: take-subs" -- rhickey

17:58 hiredman: clojurebot: ticket #120

17:58 clojurebot: {:url http://tinyurl.com/nlu9vk, :summary "GC Issue 116: partition with pad", :status :test, :priority :low, :created-on "2009-06-17T21:19:42+00:00"}

18:06 osaunders: How can I generate a descending range lazily?

18:07 hiredman: ,(range 20 0)

18:07 clojurebot: ()

18:07 osaunders: For that matter, how it is that range is lazy?

18:07 hiredman: clojurebot: you stink

18:07 clojurebot: It's greek to me.

18:07 hiredman: ,(iterate dec 10)

18:07 clojurebot: Eval-in-box threw an exception:java.lang.OutOfMemoryError: Java heap space

18:07 hiredman: ,(take 10 (iterate dec 10))

18:07 clojurebot: (10 9 8 7 6 5 4 3 2 1)

18:07 hiredman: osaunders: because it is

18:07 Chouser: ,(range 20 0 -1)

18:07 clojurebot: (20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1)

18:08 hiredman: Chouser: figures

18:08 osaunders: Chouser: ahh

18:08 * Chouser shrugs

18:08 osaunders: From range: (take-while (partial (if (pos? step) > <) end) (iterate (partial + step) start))))

18:08 hiredman: both interate and take-while are lazy

18:08 ~def range

18:09 osaunders: Ah, the clue is in take-while.

18:09 OK.

18:15 Is there an efficient way of generating a Fibonacci seq?

18:15 Because the implementations I've seen/done require a lot of recursion and calculate right from the back every time. Even if you just need the 20th number or something.

18:15 hiredman: do you need a Fibonacci seq for something?

18:16 osaunders: http://projecteuler.net/index.php?section=problems&id=2

18:16 I've solved it but I'm just wondering about efficiency.

18:17 hiredman: actually there have been some fib seqs posted to the group

18:17 Chouser: http://clojure-euler.wikispaces.com/Problem+002

18:17 there's a few

18:18 osaunders: I love that there's a function called lazy-cat

18:18 Chouser: me too

18:20 * osaunders begins motion to add smelly-dog

18:22 osaunders: ,(drop 1 '(1 2 3))

18:22 clojurebot: (2 3)

19:26 hiredman: http://www.brool.com/index.php/pattern-matching-in-clojure yay macros!

19:31 replaca: ^^ wow, that's nice. I've been meaning to write that for a while

22:01 mebaran151: what's the best way to save an anonymous fn?

22:02 arbscht: save?

22:13 cky: I presume mebaran151 meant, how to serialize/persist/pickle/whatever it.

22:13 So it can be loaded back in for a future session.

22:15 mebaran151: cky, exactly

22:15 as in serialize to bytes

22:15 that I could put in a BerkeleyDB and pull out again

22:17 cky: I don't know any Clojure, so I can't answer that question, but hopefully someone else can. :-)

23:17 andyfingerhut: Is there already a transcript of any of Rich Hickey's Clojure talks posted somewhere? If not, I was considering typing some up for at least the one for Lisp programmers.

23:45 tomoj: andyfingerhut: are they online?

23:47 liebke: tomoj: http://clojure.blip.tv/

23:47 andyfingerhut: Yep, those are the ones I'm thinking of.

23:48 They are fine to watch and listen to, but sometimes a transcript can be nice.

23:48 Chouser: they're getting outdated

23:49 andyfingerhut: They're not completely up to date, I agree, e.g. lazy-cons instead of lazy-seq, a mention of ad hoc hierarchies but not in the example, since it was too recently added, no transients, etc. etc.

23:49 Still great stuff in there, though.

23:50 Lots of good rationale targeted at people who know Common Lisp or Scheme for what is different and why.

23:50 It didn't take me long in writing Clojure before I forget what is missing in Common Lisp, e.g. easy maps and vectors.

Logging service provided by n01se.net