#clojure log - Jun 22 2009

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

1:10 arohner: danlarkin: ping

2:44 vika23: Is there a function to convert string to numbers in clojure ?

2:45 grrrt: vika23: you could do (Integer. "123")

2:45 (java equivalent of new Integer("123") )

2:47 vika23: grrrt: Thanks a lot :)

2:47 hoeck: vika23: or (Integer/valueOf "123")

2:48 hiredman: ,(Integer/parseInt "123")

2:48 clojurebot: 123

3:08 frodef: how do I write a macro that expands to something like (let [foo bar] ~@body (zot foo)) ? I get "Can't let qualified name foo" error..

3:09 hiredman: yeah

3:09 clojure's macro system doesn't like non gensymed names because they make for unhygenic macros

3:09 so you need to replace foo with foo#

3:10 inside a syntax quote (`) foo# expands into a gensymed symbol

3:10 ,`foo#

3:10 clojurebot: foo__3466__auto__

3:10 hiredman: ,`foo#

3:10 clojurebot: foo__3470__auto__

3:10 frodef: but the same one each time?

3:10 ,`(foo# foo#)

3:10 clojurebot: (foo__3474__auto__ foo__3474__auto__)

3:10 frodef: aparently :)

3:11 hiredman: frodef: in the same syntax quote it will be the same

3:11 frodef: ok, thanks.

3:11 hiredman: `(foo# ~`foo#)

3:11 ,`(foo# ~`foo#)

3:11 clojurebot: (foo__3479__auto__ foo__3478__auto__)

3:37 grrrt: hm. I'm trying to create a function that generates a string consisting of a character c repeated n times.

3:37 I have ,(take 10 (cycle ["-"]))

3:37 but I'm not sure how to make a string from that

3:38 hiredman: apply str

3:38 grrrt: ah of course! thanks!

3:38 hiredman: you might use repeat instead of cycle

3:38 ,(doc repeat)

3:38 clojurebot: "([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."

3:38 grrrt: yes much better

3:39 hiredman: ,(take 10 (repeat \c))

3:39 clojurebot: (\c \c \c \c \c \c \c \c \c \c)

3:39 grrrt: I thought cycle was a bit strange in this case. cheers

3:40 ,(apply str (repeat 10 "-"))

3:40 clojurebot: "----------"

7:18 Lau_of_DK: Is there a demo up somewhere of a small compojure app which uses the new session middle-ware stuff?

7:37 emacsen: Chouser, you around?

7:39 opqdonut: can for iterate over two lists at the same rate?

7:39 like cl loop does

7:40 emacsen: usually if you're iterating you're doing something wrong

7:40 (not always but so many times)

7:40 Lau_of_DK: emacsen: by what logic ?

7:40 emacsen: Lau_of_DK, you can usually accomplish the same thing with a filter of one or another sort

7:40 operating on a data structure rather than iterating through results

7:41 Lau_of_DK: (filter even? (iterate inc 1)) ? :)

7:41 Sometimes it exactly what you want

7:41 emacsen: and I'm late for work so I'm gonna shower and go

7:41 Lau_of_DK: And it beats recursion

7:41 emacsen: I said usually :)

7:41 Lau_of_DK: looping is not really iterating though, and if we make that distinction I agree, usually when I loop its for some sideeffect :(

7:44 opqdonut: emacsen: iterating? wrong?

7:45 i'd just like to be able to write stuff like (map f data (range 1)) using a for

7:46 err, by (range 1) i really meant (iterate inc 0)

8:04 Lau_of_DK: Couldnt you just use apply ?

8:05 emacsen: Lau_of_DK, that was kinda my point. Oftentimes people want to use iterate but they could easily use a different style, as you said, he could probably use apply

8:05 hey pjb3

8:06 pjb3: emacsen: hey

8:06 Lau_of_DK: emacs, I kinda got your point, eventually :)

8:06 emacsen: So, since Chouser isn't here, anyone familiar with the Java "exec", as used in the shell-out contrib?

8:06 I just want to pass the program some arguments, and that causes it to fail, eg "find /home/foo"

8:06 it looks for a program named "find /home/foo"

8:07 Lau_of_DK: emacsen, check out Gitdoc on Github, its not updated, but I use that functionality

8:07 emacsen: Gitdoc?

8:07 Lau_of_DK: http://github.com/Lau-of-DK/gitdoc/tree/master

8:08 emacsen: heh, love the last commit "removed shell-out" :)

8:08 Lau_of_DK: hehe :)

8:09 it should be in engine.clj

8:09 emacsen: which file.. thank you :)

8:10 the Runtime/getRunTime part with your exec?

8:10 Lau_of_DK: http://github.com/Lau-of-DK/gitdoc/blob/26b219792b14c3535850047d3e2c2c7072e56855/src/dk/bestinclass/gitdoc/engine.clj#L137

8:10 Yea, thats what youre looking for I hope

8:11 emacsen: possibly. I'm so java ignorant I have to look up each of those :)

8:11 Lau_of_DK: I dont use a buffer at all though, like I said its outdated, but you'll get the picture, compare that to shell_out and you can make the perfect func

8:11 I gotta jet, l8r

8:11 emacsen: okay thanks

8:15 frodef: is sort and sort-by a stable sort?

8:15 maacl: Newbie question: Why does the following blow the heap: (map (fn [s](apply str s)) (selections (map char (range 97 123)) 4))

8:18 selections is the selections function from clojure.contrib.combinatorics btw

8:24 Chouser: maacl: works fine here.

8:25 It's going to print a lot if you run it at the repl, but wrapping either first or last around it works fine.

8:27 maacl: Chouser I run out of Java heap space if I run the whole thing ie java.lang.OutOfMemoryError: Java heap space

8:32 Chouser: Also if I try to do a "last"

8:32 Chouser: I don't think there's anything inherently wrong with your expression. It produces 456976 strings which isn't nothing.

8:33 jao: hi. sorry if this a FAQ, but what's the way of writing bindings to a C library in clojure? (asked by someone who knows very little java)

8:33 Chouser: but with 'last' or 'first' it should be throwing them away as fast as they're created.

8:33 jao: If you're not overly concerned with speed, I'd recomment JNA: http://github.com/Chouser/clojure-jna

8:34 jao: Chouser: aha, thanks! and if i were concerned? ;)

8:34 Chouser: jao: otherwise you'll have to use JNI, the Java Native Interface.

8:34 maacl: Chouser: I thought so, but "last" just hangs and just running it runs out of heap space

8:34 eevar2: jao: http://java.sun.com/docs/books/jni/

8:35 jao: Chouser, eevar2: i see, thanks again

8:36 Chouser: maacl: very odd. works fine here. What versions of Java and Clojure are you using?

8:36 eevar2: jao: if you're concenred with speed, you're probably better off finding a Java library which does what you want, tho

8:36 maacl: Chouser: java 1.6.0_13

8:38 Chouser: clojure 1.1 alpha

8:39 Chouser: oh, "last" actually completes - just took 4-5 mins

8:41 Chouser: maacl: 3 seconds here, on the same jvm and recent clojure

8:43 maacl: Chouser: I will update clojure and try again

8:43 Chouser: The CPU runs beserk, and no extra memory is used

8:44 Chouser: that sounds right. perhaps that's just how long it takes to compute everything you're asking for on that CPU?

8:46 maacl: Chouser: A Athlon 64 3400+? now brand new, but still?

8:46 Chouser: hmph. that's probably faster than what I'm using. weird.

8:48 rhickey: what's the code?

8:48 maacl: rhickey: (map (fn [s](apply str s)) (selections (map char (range 97 123)) 4))

8:49 rhickey: selections?

8:50 Chouser: (use '[clojure.contrib.combinatorics :only [selections]])

8:50 maacl: rhickey: from clojure.contrib.combinatorics

8:50 durka42: (doc selections)

8:50 clojurebot: "clojure.contrib.combinatorics/selections;[[items n]]; All the ways of taking n (possibly the same) elements from the sequence of items"

8:51 rhickey: maacl: how much memory are you giving the JVM?

8:52 maacl: rhickey: I haven't set any options? should I ?

8:53 rhickey Chouser: Just tried on my MacBook too - same thing

8:54 Chouser: maacl: are you loading anything else first? using an IDE?

8:54 rhickey: maacl: usually, yes, the default heap is puny use: -Xmx512m where 512 is however many mbs you want to give it

8:54 Chouser: huh. I never set a heap option.

8:55 rhickey: didn't contrib's build used to have a nice message when trying to compile saying it wasn't really without a path to clojure.jar?

8:55 Chouser: yeah

8:55 maacl: rhickey Chouser: I user emacs/slime

8:55 achim: i can reproduce with SLIME, but not in the terminal,with otherwise identical (= default) settings

8:55 Chouser: oooh, we have a culprit

8:55 rhickey: what happened to it?

8:56 maacl: Chouser: sounds like it

8:56 clojurebot: Who??

8:57 Chouser: rhickey: with the latest contrib, I get a WARNING if I don't suppot -Dclojure.jar=... on the ant command-line

8:58 rhickey: .9 secs on my machine

8:59 maacl: rhickey: from slime?

8:59 rhickey: (calling last on that map return)

9:03 my bad, old contrib

9:06 maacl: rhickey: did you get .9 from slime?

9:06 * rhickey doesn't use slime

9:07 maacl: ah

9:08 achim: i'm getting a strage exception when trying to build clojure & contrib using ant ... has anybody seen something like this before?

9:09 lisppaste8: achim pasted "exception when building via ant" at http://paste.lisp.org/display/82282

9:09 Chouser: achim: yeah

9:10 achim: http://www.assembla.com/spaces/clojure/tickets/124

9:10 compiling with Java 5, I assume?

9:13 achim: Chouser: don't think so, unless ant overrides the system default. java -version is "1.6.0_13"

9:14 rhickey: when tests burn in broken behavior:

9:14 [java] FAIL in (test-range) (sequences.clj:840)

9:14 [java] expected: (= (range 2.5) (quote (0 1)))

9:14 [java] actual: (not (= (0 1 2) (0 1)))

9:14 [java]

9:14 [java] FAIL in (test-range) (sequences.clj:840)

9:14 [java] expected: (= (range 7/3) (quote (0 1)))

9:14 [java] actual: (not (= (0 1 2) (0 1)))

9:14 clojurebot:

9:14 Chouser: oh, I guess Steve reported Java 6 failing on Leopard as well.

9:15 maacl: Chouser: confirm I got it to work from the REPL. Who should I report the error to?

9:16 Chouser: I guess that agent shutdown patch should be backed out. It was only meant to solve an annoyance -- current behavior sure seems more annoying for the poeple it affects.

9:16 maacl: for a slime bug? I don't really know, sorry.

9:17 maacl: Chouser: ok, also hard to know if it is a slime or swank-clojure bug really

9:19 achim: Chouser: ah, thanks for the pointer!

9:42 frodef: what does this mean? java.lang.NoClassDefFoundError: clojure/lang/IteratorSeq

9:42 Do I need to import some iterator-seq library?

9:46 It seems to happen when I try to access an ArrayList I get from java.

9:47 ,(seq (new java.util.ArrayList))

9:47 clojurebot: nil

9:47 frodef: I get that error..?

9:57 Chousuke: frodef: classpath problems probably :P

9:58 frodef: yes, I had messed up my jars, it seems. fixed it.

9:58 thanks.

10:11 achim: re: http://www.assembla.com/spaces/clojure/tickets/124 - if i have ant fork the JVM for compilation, it seems to work fine

10:13 granting a modifyThead permission as outlined here doesn't seem to work:http://ant.apache.org/manual/CoreTypes/permissions.html - all other permissions seem to get revoked when doing that

10:13 does anybody have a deeper understanding of the ant/java permissions scheme?

10:13 Chouser: achim: thanks a lot for looking at that. I spent 2 minutes googling and gave up.

10:29 achim: you could attach a patch to that ticket

10:29 achim: Chouser: seems to work for java 1.5/osx, 1.6/osx and 1.6/ubuntu - i'll see if i get git to make me a patch

10:30 it's a patch to a patch - how to go about this? should my patch include the other change? is there a way to do this and preserve authorship info?

10:30 Chouser: achim: there are instructions at http://clojure.org/patches

10:31 since the other patch is already committed, I think you should go ahead and patch again master

10:32 achim: Chouser: ok

10:56 dhaza: how does clojurebot prevent people from evaling evil things?

10:57 stuartsierra: ,(eval '(System/exit 0))

10:57 clojurebot: DENIED

10:57 Chouser: dhaza: a combination of a java sandbox and special form blacklisting

10:57 that was the blacklist

10:58 ,(System/exit 0)

10:58 clojurebot: java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0)

10:58 Chouser: there's the sandbox

10:58 Jonathan-Smith: (eval '(+ 2 3))

10:59 ,(eval '(+ 2 3))

10:59 clojurebot: DENIED

11:00 Jonathan-Smith: eval is denied

11:00 Chouser: indee

11:00 indeed

11:00 achim: clojure-contrib has the same compilation issue. is it okay to file contrib tickets?

11:03 Chouser: achim: I think so, but I guess file it in the contrib project.

11:07 danlarkin: arohner: sorry we keep missing eachother. Short answer (if you haven't found it already) is that keys in json objects must be strings

11:08 achim: Chouser: of course. i wasn't sure because of missing GC tickets

11:08 Chouser: achim: oh, I see. yeah, go ahead.

11:09 I'm not sure if anyone's going to bother bringing over all the closed tickets or not.

11:10 arohner: danlarkin: and that's a restriction imposed by JSON?

11:11 Chousuke: Chouser: We did that with Clojure, but I suppose it's not really needed.

11:11 Chouser: Chousuke: yes, and I'm sure it's appreciated. Clojure's history is a bit more critical than contrib's, I think.

11:11 And contrib's tickets may be brought over yet.

11:12 danlarkin: arohner: correct, to be valid json the keys must be strings. Of course, nothing stopping you from producing invalid json, but yeah that's why clojure-json prints them as strings

11:12 Chouser: But having the closed tickets a bit out of order hardly seems critical.

11:12 Chousuke: yeah.

11:13 arohner: danlarkin: is that json different from a map literal in a javascript call?

11:14 or do the JS libraries violate the spec?

11:14 danlarkin: arohner: an object literal in javascript has non-string keys

11:14 arohner: sigh. ok. I thought they were the same thing

11:15 Chouser: danlarkin: really?

11:15 danlarkin: Chouser: yep :-/ it's dumb

11:15 Chouser: what kind of object literal?

11:15 dhaza: many json libraries dont implement json correctly

11:15 which is funny, because it has one of the sparsest syntax i've seen

11:15 danlarkin: Chouser: {foo:1, bar:2}

11:16 dhaza: and the pretty graphs on json.org make it even easier

11:16 Chouser: ({foo:1, bar:2})["foo"] returns 1 for me in firefox

11:16 dhaza: Chouser, keep in mind that many implementations will try to accept malformed json if it can

11:17 Chousuke: Chouser: I think JS will allow you to access attributes using strings.

11:17 it's quite dynamic :P

11:17 danlarkin: Chouser: oh.. yes... attribute access uses strings, defining the literal object, though, uses non-strings

11:17 arohner: danlarkin: thanks for your help

11:18 dhaza: Chousuke, yes - obj["foo"] <=> obj.foo

11:18 Chouser: but if I can get and set object literals using string keys, what's the difference?

11:18 dhaza: in js

11:18 http://stackoverflow.com/questions/61088/hidden-features-of-javascript

11:19 danlarkin: Chouser: just that when you're defining the object literal in JS, you can't use string keys, you have to use symbols... {foo:1} instead of {"foo":1} like most languages

11:20 Chouser: oh, as in {"foo":1} is legal json but not legal js?

11:21 danlarkin: Chouser: correct... and the opposite is also true: {foo:1} is legal js but not json

11:22 Chouser: beautiful.

11:23 so all this time I thought I was using json so I could eval in the brower, I was only doing json-ish.

11:24 Chousuke: hm

11:24 danlarkin: eval() is a really bad javascript json parser, which is ironic of course... most javascript libraries like jquery et al. package their own json parser

11:25 Chousuke: firefox doesn't complain about {"foo":1}.foo

11:25 it gives 1

11:26 but I thought the whole point of json is that it's valid javascript.

11:26 Chouser: danlarkin: in what way is it bad? I mean, I wouldn't eval js from untrusted sources, but other than that it runs very fast and has worked fine for me.

11:26 danlarkin: Chousuke: yeah it's just trying to do the right thing IMO, other engines are less forgiving

11:27 dhaza: Chousuke, it would be nice, but it would uglify things

11:27 for example

11:27 is {false:true} a bool or a string key?

11:27 well, i guess you cant have bool keys

11:27 :(

11:28 i meant a bool or string value

11:28 danlarkin: Chouser: yeah, eval just has security implications... it's true that it's very fast

11:28 dhaza: danlarkin, i don't think that should be a concern with modern javascript engines coming to the forefront

11:28 v8/squirrelfish/etc

11:29 they compile js down to native code

11:30 ps: why are we talking about json?

11:32 Chouser: string keys appear to be allowed for object initializers, according to the ecmascript spec

11:32 http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf page 41 and 42

11:33 propertyname can be an Identifier, StringLiteral, or NumericLiteral

11:33 identifiers and numbers are converted to strings for use as the property name

11:35 danlarkin: Hmmmmm

11:42 Chouser: welp, looks like you're right!

11:42 Chouser: danlarkin: don't worry, I won't let it go to my head

11:42 * danlarkin bows his head and goes back to lurking

13:24 tsdh: Hi. Are hyphens in namespaces somehow forbidden? I have de.tsdh.utils.tgraph-inspector but the ant job fails because it cannot find de/tsdh/utils/tgraph_inspector__init.class or de/tsdh/utils/tgraph_inspector.clj.

13:25 kotarak: tsdh: - translates to _ in the filename

13:25 Chouser: (and the class name)

13:25 tsdh: So the file should be tgraph_inspector.clj, right?

13:25 kotarak: yup

13:26 tsdh: kotarak: Works! Thanks a lot.

13:26 kotarak: np

13:56 Offtopic, but.. : why do I get different git checksums for commits I pulled via githubs ForkQueue?

13:57 dysinger: ask on #github or #git ?

13:58 kotarak: k, just thought, there might be a simple answer one of the git fans could give.

14:04 dysinger: kotarak I only notice different checksums when I cherry pick

14:05 I haven't used github fork queue but about 3 times so not sure what's going on there - it should be just a merge

14:07 danlarkin: github's fork queue does a cherry pick

14:07 dysinger: there you go

14:07 kotarak: -.- That means, I get double commits, when I pull now from the master repo?

14:17 dysinger: Even if you get double commits the second commit will not add anything strange

14:20 danlarkin: right, they are idempotent!

14:20 right? I think

14:24 kotarak: I'll try and see what happens...

14:33 dhaza: the diff should fail

14:33 you can just ignore it

15:06 eliantor: hi

15:07 dhaza: howdy

15:08 eliantor: how can i change a global variable defined in another namespace?

15:08 for example *print-pretty* or *load-tests* from clojure contrib?

15:09 technomancy: ~binding

15:09 clojurebot: No entiendo

15:09 technomancy: eliantor: use binding

15:09 kotarak: (doc binding)

15:09 clojurebot: "([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before."

15:09 eliantor: so i've to wrap everithing in the binding form?

15:10 kotarak: yes

15:10 eliantor: ok thanks

15:10 kotarak: beware of thread boundaries

15:10 and lazy seqs (read map and friends)

15:11 eliantor: i knew of binding but i thought there was another way

15:11 technomancy: you can use set! and with-ns, but that's shaky

15:12 ataggart: if you def a function from inside a binding, will invokgin that function from outside the binding use the original value or the bound value?

15:12 I guess I should just try it

15:12 kotarak: ataggart: I think, the value in effect during the call.

15:13 ataggart: bindings being threadlocal, that would be my assumption as well

15:13 weissj: sorry this has probably been asked a million times, but i have searched and can't find anything: where is the equivalent of caar or cddr in clojure? there's no ffirst or rrest.

15:14 kotarak: (doc nnext)

15:14 clojurebot: "([x]); Same as (next (next x))"

15:14 Chousuke: weissj: ffirst is there :/

15:15 ataggart: so is fnext

15:15 kotarak: (doc ffirst)

15:15 clojurebot: "([x]); Same as (first (first x))"

15:15 Hun: somehow i like c[ad]{1,5}r better...

15:15 weissj: ok, sorry i was looking for rrest - so, next and rest are the same?

15:15 Chousuke: not quite.

15:16 weissj: Hun: me too. car and cdr are meaningless but you can make better complex forms out of them :)

15:16 ataggart: also, it's not arbitrary like c[a|d]r

15:16 in terms of how deep you go

15:16 Chousuke: next is equivalent to (seq (rest ..))

15:17 so it returns nil if rest returns an empty seq

15:17 Hun: weissj: and they're faster than first and rest. you know, they are hardware ;)

15:18 weissj: so, nnext is not the same as rrest. there is no rrest. so it's just missing then?

15:18 Chousuke: I'm not much of a fan of combining car and cdr though.

15:18 I find them difficult to read :/

15:18 ataggart: Hun: when does one typically use the deep c[ad]r stuff?

15:18 weissj: Hun: the hardware is so old I'm not so sure :)

15:19 Chousuke: if you're nesting a lot then you should have a more meaningful function to extract the parts you want. even if it's just an alias for caddr or something :P

15:20 Chouser: weissj: right, rest is used when you're explicitly avoiding realizing the next step of the seq. Thus rrest would almost never be used.

15:20 Hun: ataggart: i haven't used anything deeper than 3 - in this case it was an optimization for a tree i knew to be at max 3 levels deep

15:21 weissj: Chouser: i have a data type that is a name, desc, and then a seq of nested data. isn't rrest exactly what i want to get the list of nested data?

15:22 Chouser: nnext

15:22 vika23: I am trying java-gnome with clojure . There is a Window class and it has a nested interface DeleteEvent , i want to implement it. How do i use with proxy, (proxy [???] ...).

15:22 duncanm: vika23: did you check out the API docs online?

15:22 Chousuke: Window$DeleteEvent

15:22 kotarak: weissj: {:name .. :desc ... :data seq-here} is probably what you want instead of nnext...

15:23 ataggart: then (:data mymap)

15:24 vika23: Chousuke: thanks

15:25 eliantor: i'm following the example of using binding on clojure.org, but it doesn't work

15:25 it always use the bindings estabilished by def

15:26 hiredman: eliantor: pastebin

15:26 eliantor: http://clojure.org/vars what's wrong?

15:26 hiredman: lisppaste8: url?

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

15:28 hiredman: eliantor: are you doing exactly what it shows there?

15:29 lisppaste8: eliantor pasted "untitled" at http://paste.lisp.org/display/82294

15:30 eliantor: hiredman: yes

15:30 hiredman: eliantor: are you using clojure 1.0?

15:30 eliantor: hiredman: 1.1, is there a bug?

15:31 hiredman: eliantor: nope

15:32 dunno what to tell you, works perfectly with my pre-1.0 clojure and my 1.1-alpha clojure

15:32 eliantor: ...

15:32 hiredman: eliantor: restart your repl and try again

15:34 eliantor: hiredman: always the same behaviour, i'll try to update and recompile

15:36 ataggart: eliantor: are you using the 1.0.0 jar?

15:37 weissj: what's the equivalent in clojure to '#

15:37 to pass a function by name without evaluating it

15:38 kotarak: ?? You mean the Var?

15:38 #'foo

15:38 eliantor: i've updated clojure and the problem is solved, thanks

15:38 Chouser: weissj: you can just refer to a function by name

15:39 ,map

15:39 clojurebot: #<core$map__4435 clojure.core$map__4435@6f2a75>

15:39 hoeck: weissj: clojure is a lisp-1, so vars have no function and value slots

15:42 weissj: in the REPL, if my code throws an exception how can i tell where the exception was thrown from? the error message just has (repl-1:110) as the line number

15:43 the error is definitely NOT on that line: (all-subtasks-complete? x)

15:43 Chouser: (.printStackTrace *e)

15:49 weissj: Chouser: perfect thanks

15:50 ok, and if i want the exception that i throw to have a message and concat the string representation of a list, how to convert?

15:51 i want the string that print prints, but print doesn't return this string

15:51 stuartsierra: pr-str

15:52 Chouser: ,(throw (Exception. (str "This is a bad list: " (pr-str '(bad wrong icky nasty)))))

15:52 clojurebot: java.lang.Exception: This is a bad list: (bad wrong icky nasty)

15:53 Chousuke: hmm

15:53 ,(str '(foo bar))

15:53 clojurebot: "(foo bar)"

15:54 emacsen: Chouser, you still here?

15:54 Chouser: emacsen: yes

15:55 kotarak: ,(str '("foo" "bar"))

15:55 Chouser: ,(str '(foo "foo" :foo))

15:55 clojurebot: "(\"foo\" \"bar\")"

15:55 "(foo \"foo\" :foo)"

15:55 Chouser: hmm.

15:55 emacsen: Chouser, in your shell-out "sh" function, how do you pass the command arguments?

15:56 Chouser: emacsen: there are examples at the end of the file

15:56 emacsen: oh, okay, I'm just an idiot :)

15:56 Chouser: (sh "ls" "-l")

15:56 emacsen: I coulda sworn I tried that but apparently not :)

15:57 Chouser: emacsen: not at all! someday all the documentation will be full of examples, easily searchable, and cross-linked.

15:57 for now, asking here is fine. :-)

15:57 emacsen: ah. I see. I tried passing it a list

15:57 I did (sh '("ls" "-l"))

15:57 your way is better :)

15:58 Chousuke: Chouser: You dream big.

15:58 Chouser: well, maybe. if you're constructing a list of args and also want to use keyword args, you have to do something like (apply sh :out :bytes "ls" args-list) ...not sure that's ideal

15:58 bpattison: Chouser what namespace is printStackTrace in?

15:59 Chouser: Chousuke: heh. :-)

15:59 kotarak: bpattison: it's a method of the exception. (.printStackTrace *e) (note the leading dot)

15:59 Chouser: bpattison: it's not! It's a method of the Java Excpetion class.

16:00 kotarak: Is there now a Core team?

16:00 Chouser: kotarak: I don't think so.

16:01 kotarak: Chouser: I saw some committers besides Rich, no?

16:01 Chouser: the git commits give primary credit to the original patch author, so it looks like there are lots of committers now.

16:01 kotarak: Oh.

16:01 Chouser: but anyone who's signed a CA can get a patch in.

16:02 instructions here: http://clojure.org/patches

16:06 I'm not sure I said that quite right. rhickey has always taken patches from contributors, but he manually gave credit in the commit message, so his name was still the most prominent.

16:06 so other than some process techincallities the only real change is that git automatically gives primary credit to the original patch author.

16:07 vika23: how old is clojure ?

16:08 ataggart: just a couple of years

16:08 kotarak: 3.5 years, 1.5 years in the public

16:08 hiredman: ~git e54a1ff1ac0d02560e80aad460e77ac353efad49

16:08 clojurebot: created IDEA project

16:08 hiredman: bah

16:09 clojurebot: why don't you show the date?

16:09 clojurebot: why not?

16:09 kotarak: Chouser: I just thought, that there is now a team, because there are some signed-off-by things, if I saw this correctly. So I thought there is now a team of Leutnants doing some filtering for rhickey.

16:11 Chouser: kotarak: I'm doing some of the grunt work pushing patches in for him, but no patch gets in without rhickey's explicit approval.

16:11 kotarak: Yes. I wouldn't expect that there is some change w/o rhickey's approval.

16:12 ataggart: is it possible to do a no-arg defmethod ?

16:12 Chouser: ataggart: what would it dispatch on?

16:13 ataggart: well, it wouldnt need to

16:13 * Chouser considers "externel state" and panics.

16:13 ataggart: ince there could only be one

16:13 Chouser: ataggart: why make it a defmethod instead of just a defn?

16:13 ataggart: heh

16:14 I was thinking of a no-arg that called an arg'd method using a default value

16:14 Chouser: oh, I see.

16:14 Chousuke: you could use rest args for the dispatch?

16:15 ataggart: then I'd need a more funky dispatch function

16:15 right?

16:15 kotarak: One could use (fn [& args] (if (> 0 (count args)) (dispatch-somehow) :default)) as dispatch function, no? and (defmethod bla :default ([] (bla :xxx)) ...))

16:15 ataggart: somehow (my-fn) needss to get routed to the right method

16:16 ahh I see

16:16 didn't realize you could return :default from the dispatch function

16:16 though it makes perfect sense that it should work

16:17 kotarak: Haven't tried, though.

16:28 ataggart: what's the most straightforward way to dispatch on the types of more than one arg?

16:29 kotarak: ataggart: a vector (fn [&args] (vec (map type args))) (defmethod bla [Integer String] ...)

16:29 ataggart: ah excellent thx

16:31 kotarak: ataggart: note that there is no [Integer :default]. For that one needs a ::Bottom type, which one derives everything from.... (derive Object ::Bottom) (defmethod bla [Object ::Bottom] ...)

16:31 ataggart: what's the double-colon notation mean?

16:31 kotarak: namespace-qualified keyword

16:31 ataggart: ah k

16:31 kotarak: ,::foo

16:31 clojurebot: :sandbox/foo

16:32 kotarak: Keywords need to be qualified to be allowed in a derive.

16:35 stuartsierra: Things you never knew about Java: http://stackoverflow.com/questions/15496

16:43 Chouser: that's a great thread

16:47 bpattison: is there a string construct in clojure similar to python's triple quote where line break don't need to be escaped?

16:48 Chouser: line breaks in regular double-quotes don't need to be escaped.

16:48 bpattison: so I don't need "\n\n" ?

16:48 Chouser: right, you can just continue on the next line.

16:48 bpattison: ah -- okay -- great

16:49 ah. sweet

16:51 Chouser: of course python's triple-quote allows unescaped double quotes as well -- there's no way to do that in Clojure code currently.

16:52 bpattison: line-breaks is a big plus -- especially with test data

16:56 dhaza: reader macros ftw

17:00 Drakeson: is there anyone using mac? git clone git://github.com/richhickey/clojure.git and then cd clojure, and run ant. it fails.

17:01 Chouser: Drakeson: hang on a sec.

17:01 Drakeson: master~2 does not fail. apparently the commit before last is at fault.

17:01 Chouser: yes

17:03 ataggart: is there a more sensible way to do default values than: (let arg (if arg arg default-value) ...) ?

17:03 Chouser: Drakeson: http://www.assembla.com/spaces/clojure/tickets/124

17:09 Drakeson: There is a patch that allegedly resolves it. Is it a workaround until a real fixed is developed?

17:09 Chouser: Drakeson: I don't know. try a fresh pull now.

17:09 Drakeson: s/allegedly// (I tried and it works)

17:10 Chouser: I don't know enough about the issue to know if the ant fork solution is a good permanent solution or not.

17:10 Drakeson: thanks.

17:11 Chouser: For now the change that broke Compile is removed until the right way forward is decided.

17:28 lazy1: ..

17:28 Jetien: hi kotarak! sorry to bother you but i'm having problems with vimclojure again. I try to run this example http://java.ociweb.com/mark/clojure/article.html#DesktopApps and again no side-effects (no windows open, etc.) occur when this is evaluated from within vimclojure. same problem as the snake example from yesterday. do you have any hints?

17:33 kotarak: Jetien: I'm not sure, I understand, what's going on.

17:33 (doto (JFrame.) (.setVisible true)) opens a new window.

17:35 Jetien: yep, i can confirm that

17:36 i was afraid that wasn't going to work at all

17:37 kotarak: I don't know, why it sometimes doesn't work. I'm not really a Java guy...

17:38 Jetien: is there a way to debug?

17:38 kotarak: The Repl does nothing return, right? Not even nil or something.

17:40 Jetien: correct

17:40 but it should at least return something, right?

17:40 kotarak: Yeah.

17:42 Something cheesy is going here...

17:42 Jetien: is there a way to circumvent the nailgun server and use clojure directly?

17:42 kotarak: you can start a normal repl and the nailgun server from there.

17:42 So you can work directly in the clojure.main repl, but still can send forms from inside vim.

17:43 Jetien: i wonder if this solves the problem

17:44 kotarak: if so, it's a VC problem, otherwise it's maybe a deeper thing in Clojure itself.

17:45 Jetien: how do you start the ng server? (ng ?)

17:47 kotarak: com.martiansoftware.nailgun.NGServer/main

17:47 Jetien: thanks

17:47 kotarak: You probably want to do this in a separate thread. Haven't tried that manually actually.

17:48 But it should work... in theory... ;)

18:27 hircus: anyone here using Netbeans?

18:28 ataggart: I tried. Gave up.

18:28 hircus: my problem is not really with Netbeans+Enclojure, but with trying to use the generated classes from a Java project

18:29 I use Enclojure to generate a class (:gen-class) that implements an interface, yet the Java project that uses it claims that that class does not exist

18:29 (building using Ant works, though, so obviously the class does exist)

18:30 ataggart: is the dir where the classes are dumped to in the classpath for netbeans?

18:30 for the project, I mean

18:31 hircus: Enclojure creates a JAR, and the other project referenced that JAR, so yes

18:31 (Netbeans can actually build the project just fine, since that just triggers an Ant task -- but when editing the code, the part that imported the clojure class is always marked as an error

18:31 i.e. the "import com.example.myclojureclass" part

18:32 ataggart: k, my knowledge has been exhausted. sry

18:32 hircus: no prob. it's really rather bizarre

19:37 dreish: chunked branch slows down (reduce + (range 1000000)) by roughly a factor of 10.

19:46 hiredman: dreish: what about apply?

19:46 dreish: I think that was worse.

21:11 Jonathan-Smith: are there any good articles on getting data out of xml/parsed stuff using clojure?

21:12 combasa: it seems that sometimes Slime gets disconnected from the current frame with my clojure file, how can stop slime and then restart from that frame?

21:12 hmm thats probably more of an emacs question I guess

21:12 hiredman: Jonathan-Smith: you've seen clojure.xml/parse ?

21:13 oh

21:13 xml/parsed is the past tense of clojure.xml/parse then?

21:13 Jonathan-Smith: yes i've got it turned into a structure of what looks like vectors and maps

21:14 just wondering if there is a simple rule for how to traverse it

21:15 hiredman: there is xml-zip

21:15 clojure.zip/xml-zip

21:15 Jonathan-Smith: oh really?

21:15 hiredman: yeah

21:15 Jonathan-Smith: does that let you treat it like a tree or something?

21:16 hiredman: yeah

21:16 a zipper

21:16 there is also some stuff in contrib, and enlive

21:16 (doc xml1->)

21:16 clojurebot: "clojure.contrib.zip-filter.xml/xml1->;[[loc & preds]]; Returns the first item from loc based on the query predicates given. See xml->"

21:17 Chouser: dreish: Intersting -- I'm seeing more like x7 slowdown, but chunked is definitely slower than master for that expression.

21:17 hiredman: ~def xml1->

21:18 dreish: I'd believe x7. I didn't do a very careful analysis.

21:18 Jonathan-Smith: i think this filter is what i want as i want to extract a set of nodes from the xml

21:22 Chouser: I really really need to try enlive so that I can authoritatively direct people away from zip-filter.

21:42 Jonathan-Smith: i get this error:

21:42 java.lang.ClassNotFoundException: clojure.contrib.zip-filter.xml (repl-1:8)

21:42 when trying to use clojure.contrib.zip-filter.xml

21:43 i'm using clojure-dev and have looked in my sources and it is there

21:45 holmak__: You are using Eclipse?

21:46 Jonathan-Smith: yes

21:46 should i build a new clojure-contrib?

21:46 holmak__: Hm. You have to make sure clojure-contrib.jar is on the classpath, but I'm not familiar with Eclipse.

21:47 I thought clojure-dev provided clojure.jar and clojure-contrib.jar for you prebuilt, but I may be wrong.

21:48 Jonathan-Smith: it does, i can see them in the refrenced libraries section

21:50 holmak__: I can type "(use 'clojure.contrib.zip-filter.xml)" fine at the REPL on the command line, so it's definitely a legitimate library. I don't know what's going wrong in Eclipse.

21:51 Jonathan-Smith: hmm

21:51 i can do that too

21:52 hmm

21:53 it seems that if i 'use' it it works but if I 'require' it it does not work

21:53 note to self...

21:54 holmak__: require behaves strangely, I always had weird problems with it

21:54 I think the general recommendation is to stick to :use and :import, or so I've read.

21:55 grrrt: hm I tend to use require so I don't pollute my namespaces

21:55 Chouser: I've never had an issue with 'require'

21:56 I very much dislike naked use -- it makes it harder to read code because you can see names being used and not know where they're coming from.

21:56 Jonathan-Smith: is interesting because :require has been working fine with all of the Java libraries i've been been calling

21:57 holmak__: I just always have awful luck getting Java namespace stuff to work right.

21:57 Chouser: but (use '[clojure.contrib.zip-filter.xml :only [xml1->]]) or something is fine.

21:57 Jonathan-Smith: :require does do Java libraries -- it's only for Clojure namespaces.

21:57 :import is for Java classes.

21:57 Jonathan-Smith: ooh

21:58 i was trying to import clojure.contrib

22:00 Chouser: gah. :require does NOT do Java libraries. sheesh.

22:00 I only forget the word "NOT" when it's really critical

22:19 jwinter_: Does this logo look familiar to anyone else? http://en.wikipedia.org/wiki/Super_Fresh

22:20 MononcQc: jwinter, how about http://blog.plover.com/prog/haskell/logo.html

22:21 jwinter_: heh

22:25 emacsen: Chouser: any idea why w/ sh "find" seems to fail miserably?

22:26 Chouser: (sh "find" "/tmp") worked fine for me just now.

22:26 clojurebot: for is a loop...in Java

22:27 grrrt: ,(doc sh)

22:27 clojurebot: "clojure.contrib.shell-out/sh;[[& args]]; Passes the given strings to Runtime.exec() to launch a sub-process. Options are :in may be given followed by a String specifying text to be fed to the sub-process's stdin. :out option may be given followed by :bytes or a String. If a String is given, it will be used as a character encoding name (for example \"UTF-8\" or \"ISO-8859-1\") to convert the sub-process's stdout to a Stri

22:27 Chouser: clojurebot! What's a "Stri"!?

22:28 emacsen: lol... it just started working... I swear I just used the up arrow in my buffer and now it works

22:29 Chouser: hm. lovely.

22:29 emacsen: and now it fails again... maybe it's my inferior lisp

22:32 ah... the problem is my side... stupid symlinks... nevermind :)

22:36 Chouser: whew

Logging service provided by n01se.net