#clojure log - Dec 28 2009

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

0:02 KirinDave: Can it be done without adding a stack frame?

0:02 leif-p: ,(reduce (fn [acc x] [x acc]) [] (reverse [1 2 3])) ;closer

0:02 clojurebot: [1 [2 [3 []]]]

0:03 ozarusan: Hmmm, how about without reverse?

0:14 leif-p: (defn foo [acc v] (if (= 1 (count v)) (vec v) [(first v) (foo acc (rest v))])) ; got rid of empty vec, don't know how to get rid of stack frame

0:16 _mst: ,((fn step [[x & xs]] (if xs (vector x (step xs)) [x])) [1 2 3 4])

0:16 clojurebot: [1 [2 [3 [4]]]]

0:16 _mst: hm :/

0:23 ozarusan: stack overflow

0:29 tolstoy: If I have a macro, (defmacro foo [name val] ...) then I want to use it like: (foo something "other"), how come I get a ClassNotFound exception for "something"?

0:29 I thought macros left all argument unevaluated.

0:30 If that's true, how to you reference a symbol in a macro? Hm. ~name? Just name?

0:31 technomancy: tolstoy: something is not an argument to the macro

0:31 erhm; never mind

0:32 tolstoy: depends on the body of foo.

0:32 what do you have so far?

0:32 mitchellh: tolstoy: Run a 'macroexpand on the macro to see what its generating

0:32 tolstoy: I don't want something to be evaluated.

0:32 Okay, I'll do that.

0:33 mitchellh: If you're getting an error on the macroexpand, then its trying to evaluate something within the template, which is probably not what you want. In that case, it'd be best for you to paste so we can try to help

0:33 tolstoy: I have something like: (defmacro defthing [name value] `(intern (symbol "ns") name (some-fn ~value)))

0:34 To be used (defthing name (function or-value or-whatever)).

0:34 I guess I can just look at the source of def.

0:34 (This is sorta a dumb use case, but it's just to demo that such things are possible.)

0:35 lisppaste8: _mst pasted "[1 [2 [3 [4]]]]" at http://paste.lisp.org/display/92709

0:36 technomancy: tolstoy: should work if you change it to (quote ~name)

0:37 since intern is not a macro, it's going to eval its args

0:38 tolstoy: I keep getting an "unable to resolve symbol" in the line where I use the macro, rather than the usual test.clj:0.

0:40 ozarusan: ,(dorun (step (range 1111111) identity))

0:40 clojurebot: java.lang.Exception: Unable to resolve symbol: step in this context

0:40 ozarusan: java.lang.StackOverflowError

0:42 _mst: guess my nested fns consume just as much stack :)

0:46 tolstoy: Ok. I think it's the value part of what I'm doing, so that's a relief. Macros work like I expect them too.

1:11 Interesting. (def foo.bar "value") is okay.

1:12 But foo.bar at the repl is looking for class.

1:12 I think I missed that in the literature somewhere.

1:14 " '.' has special meaning - it can be used one or more times in the middle of a symbol to designate a fully-qualified class name..."

1:38 replaca: technomancy: do you know why slime/contrib isn't part of the elpa package?

1:52 technomancy: replaca: elpa is a lot easier if each package is a single file

1:52 in the interests of Getting Stuff Done I didn't feel up to the task of submitting each thing in contrib separately

1:52 though there's no reason someone else couldn't do it

1:52 I just haven't missed the rest of it much myself, so I haven't bothered

1:54 replaca: technomancy: ok, I see

1:55 technomancy: they should probably be coordinated, though, and relative position might enter into it

1:55 technomancy: replaca: what in particular do you like from contrib?

1:55 there's a lot of disjointed stuff in there

1:55 much like our own contrib. =)

1:55 replaca: technomancy: fuzzy tabs

1:56 unfo-: is there a (nightly?) .jar distribution of clojure-contrib or do I need to compile it myself?

1:56 replaca: technomancy: it's not a big deal - I got hte files myself the old fashioned way, but it just makes me nervous

1:57 technomancy: replaca: if it's just a single file it's pretty easy to submit as its own package

1:57 http://tromey.com/elpa/upload.html

1:58 replaca: technomancy: another question: swank-clojure-project seems to want to suggest that the dir you're interested in is proj/src, but that doesn't work, you just want proj/

1:58 technomancy: what gives there?

1:59 technomancy: replaca: so if you invoke it from proj/src/my/ns.clj then the default value it shows at the prompt is proj/src/?

2:00 replaca: I'm invoking it from proj/project.clj

2:00 The (interactive ...) is explicitly adding src/

2:01 technomancy: that's strange; I can't reproduce it

2:01 replaca: but then lower down, it's trying to tack lib/, etc., on to that

2:01 1.0.1 is the latest?

2:01 technomancy: more or less

2:01 replaca: are you running 22 or 23?

2:02 technomancy: I've got one more bugfix before pushing out 1.0.2

2:02 23

2:02 replaca: hmm, me too

2:02 technomancy: so if you elisp-eval (locate-dominating-file default-directory "src") from project.clj, what do you get?

2:03 replaca: the src/ dir

2:03 technomancy: that must be a bug in Emacs

2:04 locate-dominating-file should never return a path that's not an ancestor of its argument.

2:04 if I'm understanding what you're saying correctly anyway

2:05 replaca: but src/ *is* it's argument and that's what it's returning. Or do you mean it should always go to arg/..?

2:07 technomancy: if you're invoking the function from proj/project.clj, then the default-directory argument should just be "proj/"

2:09 replaca: yeah, but I think it looks *in* that directory for "src", cause it wants to return "src"

2:09 otherwise it will go up and up until it finds "src"

2:09 technomancy: "Stop at the first parent directory containing a file NAME, and return the directory."

2:10 it doesn't want to return src, it wants to return the directory containing src.

2:10 replaca: hmm, my doc is different: "Look up the directory hierarchy from file for a file matching regexp.

2:10 "

2:10 technomancy: what version?

2:11 replaca: 23.1. What are you?

2:11 technomancy:

2:11 compiled... yesterday?

2:11 replaca: How do I get that long a version string?

2:11 technomancy: that's kind of a crappy thing to change in between point releases. =(

2:11 M-x emacs-version

2:11 replaca: yeah!

2:11 Ah,

2:12 Which was emacs-snapshot on Ubuntu whenever I pulled it

2:13 technomancy: oh, ok. so that's from before the actual release of 23

2:13 it's a prerelease

2:13 so in that case it's not unreasonable that they changed the behaviour

2:13 replaca: Do they do it where xx.1.xx is their first real release>

2:13 ?

2:14 technomancy: yeah

2:14 it's kind of idiosyncratic

2:15 replaca: to say the least! Makes sense once you know it.

2:15 I'm kind of new to emacs. Didn't start with it until '85. :-)

2:16 technomancy: so back when the GNU implementation was what, a whole year old?

2:17 replaca: something like that. ported it to 68k Unix system 5

2:17 technomancy: nice!

2:18 replaca: I'm sort of just updating my whole world since I've been hacking Clojure on a variaton of my hacked sbcl slime setup since I started

2:19 finally giving in to elpa, maven, etc. since that all seems to be part of where we're going.

2:19 but there are a lot of moving parts!

2:20 tolstoy: Clojure is moving toward maven?

2:20 technomancy: tolstoy: maven as a repository format

2:20 not necessarily maven the build tool

2:21 replaca: package.el definitely needs work

2:21 tolstoy: Ah, phew. ;).

2:21 technomancy: but it makes life a lot easier both for users and maintainers

2:21 even more so once it gets integrated into Emacs proper

2:22 replaca: technomancy: yeah, I love the idea. I hope it catches on with everyone.

2:23 technomancy: it's still in its infancy

2:24 replaca: it's hard to teach an old dog new tricks.

2:24 That's emacs's biggest prob

2:24 (CL, too)

2:24 technomancy: emacs' biggest problem is politics

2:25 they want to limit package.el so it can only be used with packages for with the FSF owns the copyright

2:25 replaca: well, yeah, that's *why* it's hard to teach the old dog new tricks. The tech isn't too hard.

2:26 hmmm, that's not very "open"

2:26 technomancy: it's impossible, of course

2:26 just wish more of the decisions could be made on technical merit

2:27 replaca: or user convenience

2:28 but when you deal with RMS, you're dealing with an ideologue. Not all bad, but sometimes annoying

2:30 technomancy: I am even a huge fan of the GPL, but pushing FSF-owned packages exclusively is so far beyond that and teeters into the realm of actively harmful.

2:30 replaca: agreed

2:36 KirinDave: technomancy: man the gpl is the second largest source of heartache in the programmer world.

2:36 technomancy: Shortly behind Microsoft.

2:37 somnium: is there anything equivalent to ruby's __FILE__ for .clj files?

2:39 hmm, I guess after compilation it wouldnt work even if it existed

2:49 replaca: somnium: well, if you know a function name, you can look on its metadata and find the file

2:51 somnium: replaca: yeah, but when it gets jarred it'll break (for what I was thinking of)

2:52 replaca: handy to know for the future though

2:52 chouser: *file* is relative to the classpath, I think.

3:04 somnium: maven/lein/clojars question: I want to put a java lib on clojars, it has src path /src/main/com..., ant jar produces a jar with path "/com/...", I did lein pom and pushed to clojars, but the jar I get from clojars has path "/main/com..." and nothing works

3:05 some xml file I need to add? or make my own pom?

3:06 replaca: somnium: I think you might need to set a :src in project.clj, but I haven't walked that road yet

3:13 somnium: replaca: is :src a flag? I cant seem to find a list of options, I was using :source-path from the javac plug-in but it only seems to work for compilation

3:21 piccolino: Does anyone understand the new defprotocol/deftype stuff?

3:23 Specifically, protocols appear to require you to have at least one argument for methods, but in deftype it appears you can leave out the argument...

3:28 somnium: piccolino: the protocol-fn is first class and dispatches on the type of the first argument, in deftype extending a protocol-fn creates a method on a class, so this is implicit. (I think I read something to this effect on the mailing list)

3:28 also see http://www.assembla.com/wiki/show/clojure/Datatypes (in particular reify)

3:28 piccolino: Yeah, I've been going over that page and the one on Protocols over and over for about half an hour.

3:28 I'm trying to define a protocol that has a method with two method signatures: one arg and two args.

3:29 Then in the deftype, I try to implement those methods, but I can't do both. One should have no args in the deftype and the other just never works.

3:31 somnium: try: (defprotocol A (foo ([obj a] [obj a b]))) (deftype B [x] A (foo ([a] ...) ([a b] ...)))

3:32 might need to be (deftype ... A (foo [a] ()) (foo [a b] ()) if that doesnt work

3:34 piccolino: Hm, but I'm trying to have one of the foo functions not need an arg when you call it.

3:35 replaca: somnium: yeah, :source-path is what I was thinking of. But like I said, I haven't tried that yet

3:36 Is the pom broken or the jar?

3:37 somnium: replaca: I think the pom, because I the jar ant produces is fine, bit the one clojars sends has that bloody "/main/" prefix

3:38 piccolino: then (defprotocol ... (foo [obj])) and (deftype ... (foo [])) no?

3:38 piccolino: Oh yeah, but I want (foo ([obj] [obj a])).

3:39 somnium: piccolino: you can always do extend-type or extend-protocol unless youre really after the porformance kick

3:39 piccolino: I can do (deftype ... (foo [] ...)), but not (deftype (foo [a] ...))

3:39 replaca: somnium: hmm, out of my depth on that one, but I'm sure I'll be swimming in that pool pretty soon

3:40 somnium: piccolino: for every arity on the protocol the arity within the deftype body should be one less

3:40 piccolino: somnium: Yeah, that's what's not working for me.

3:41 It gives me: error: java.lang.IllegalArgumentException: Can't define method not in interfaces:

3:41 somnium: piccolino: btbh, I always used extend-protocol, ^^ was just my understanding

3:41 piccolino: can you paste the protocol and the type?

3:42 piccolino: Sure

3:42 somnium: replaca: and I was almost starting to like maven...

3:43 piccolino: http://gist.github.com/264592

3:43 vu3rdd: Hi folks: Trying to install slime/swank on a new Debian installation

3:44 It works fine on another setup. But on this particular setup, I get te "connection refused error"

3:44 shown here: http://paste.lisp.org/display/92713

3:44 I get the *inferior-lisp* prompt but not the SLIME prompt

3:44 any idea what is wrong here?

3:45 somnium: piccolino: what about (position ([] ...) ([newpos] (...))), same error?

3:45 LauJensen: vu3rdd: If this is your first installation, you might want to check out my screencast showing off an install on a clean ubuntu if you haven't already

3:47 vu3rdd: LauJensen: yes, I saw your excellent screencast. I am not using the elpa. I prefer to install the packages manually

3:47 LauJensen: Ok

3:47 piccolino: somnium: I updated the gist.

3:48 vu3rdd: LauJensen: Just wanted to say a big thanks for the earlier screencast too.

3:48 LauJensen: Glad you liked them :)

3:49 vu3rdd: I had an earlier Ubuntu installation and another debian installation where I am using the setup.

3:49 I simply copied the files (swank-clojure, slime, clojure-mode) from there

3:50 piccolino: http://www.assembla.com/wiki/show/clojure/Protocols shows the overloaded protocol methods being written out twice in a deftype or reify.

3:51 somnium: piccolino: hmm, I guess Im out of my depth

3:51 piccolino: Doh.

3:51 Well thanks for the try.

6:48 adityo: ~max people

6:48 clojurebot: max people is 240

6:50 vu3rdd: LauJensen: I figured out that my slime connection problem is because the swank is getting bound to a IPv6 port.

6:51 and slime is trying to connect to which was an ipv4 address

6:51 very strange

7:48 noidi: I can't seem to get "lein test" to work

7:49 running it in a new project gives me: java.lang.Exception: No such var: clojure.test/successful?

7:50 and in the leiningen git version: org.apache.tools.ant.ExitException: Permission (java.lang.RuntimePermission exitVM) was not granted.

7:51 I thought it might be caused by OpenJDK, but switching to the Sun JDK didn't help

7:51 any idea what might be wrong?

7:54 fliebel: Hey

7:56 noidi: okay, "lein test" seems to work in the "stable" git branch

8:00 "A build tool for Clojure designed to not set your hair on fire."

8:00 there's still some work left before that goal's met :)

8:40 fliebel: How would I convert a file path to a relative path? Like: same dir = filename, parent dir = ../filename, etc.

8:50 chopmo: fliebel: You mean convert an absolute path to a relative one? Why was it absolute in the first place?

8:52 fliebel: chopomo: I realize I want something impossible. I need to have the relative path between 2 files, since they need to reference each other while their containing dir is going to be moved around.

8:52 chopmo: fliebel: Doesn't sound impossible to me...do you know the absolute path of both files?

8:53 fliebel: chopomo: I do, but I'd have to generate a path for every file to every file.

8:54 chopmo: fliebel: OK, I see. Not sure I understand your problem fully, but I found something on StackOverflow that might be relevant: http://bit.ly/1b1BO2

8:55 fliebel: chopomo: I'm writing a static site generator, I need the urls to work wherever the files are placed.

8:56 on the file system only absolute paths or relative paths work, on the web only base-related or relative paths work, so I need the relative one.

8:57 chopmo: fliebel: As in <a href="../foo.html"> ?

8:57 fliebel: yea...

8:58 that would work wherever the files are

9:30 chopmo: Is there any way to unload a function definition using Emacs/Slime? When I move a function, I get "already defined" errors.

9:31 More precisely, when I move a function to a new namespace and then :use that NS, I get an IllegalStateException because the old method definition is still in effect.

9:48 Chousuke: there's ns-unmap

9:49 fliebel: what is the advantage of those unchecked functions? speed?

9:50 unfo-: yes. and the downside is possibly corrupt logic/data

9:51 fliebel: what does "subject to overflow" mean?

9:51 chouser: if the number gets too big or too small, it may wrap around

9:52 Clojure's normal math functions are careful to avoid that

9:52 fliebel: hmm, that sounds like fun… :)

9:53 unfo-: fliebel, for example the sum of the first 100k numbers is: 5000050000; but if you use unchecked addition you get 705082704

9:53 which is awfully wrong

9:53 fliebel: haha

9:53 unfo-: (example from Programming Clojure, p. 91)

9:53 good book so far :)

9:54 my friend bought the ebook for me as an xmas present ^^

9:54 but now for something completely different ->

9:54 chopmo: Chousuke: Cool, thanks

10:25 dabd: I'm looking at the implementation of the fn 'keyword' http://github.com/richhickey/clojure/blob/6109d41a975bf24b17681342591116a9897e4a27/src/clj/clojure/core.clj#L386

10:26 and it calls intern which must accept at least two args but the implementation is calling with just one arg

10:26 for the arity 1 case of course

10:27 could this be a bug?

10:29 the-kenny: It doesn't call intern, it calls the static method intern of clojure.lang.Keyword

10:30 dabd: the-kenny: thx

10:31 if I call (keyword "abc") in which ns is the keyword interned?

10:32 the-kenny: dabd: http://github.com/richhickey/clojure/blob/6109d41a975bf24b17681342591116a9897e4a27/src/jvm/clojure/lang/Keyword.java

10:36 chouser: that is, the nil "namespace"

10:41 dabd: chouser: the keyword gets interned in the namespace named "nil"?

10:51 saml: can I see what macro is? like, meaning of ' #' ...etc

10:51 unfo-: excuse me but wtf ^ that Keyword.java from line 92 -> :D

10:52 chouser: there's actually just a single ConcurrentHashMap for interning all keywords

10:52 unfo-: couldn't you just make the last form the norm? the (Object arg1, Object arg2, Object... args)

10:53 chouser: the key is a Symbol object, which has a namespace part and a name part. if you don't specify a namespace when interning a keyword, the namespace part of the symbol used is just null a.k.a. nil

10:53 unfo-: performance! that's the signature of all Clojure fns.

10:54 saml: you can use macroexpand to see what any macro call expands to. I'm not sure if that's what you're asking.

10:54 saml: chouser, thanks

10:54 unfo-: chouser, oh.. never would've thought it was due to performance :D

10:54 saml: ,(macroexpand ')

10:55 clojurebot: Unmatched delimiter: )

10:55 chouser: hm.. for reader macros, sometimes just quoting the form will show you what it becomes.

10:55 ,''foo

10:55 clojurebot: (quote foo)

10:55 the-kenny: '#'

10:55 ,'#'

10:55 chouser: ,'#'foo

10:55 clojurebot: EOF while reading

10:55 (var foo)

10:57 fliebel: You know… I was wondering why apply isn't a macro, (apply str ["hello " "world"]) could be transformed into (str "hello " "world")

10:57 chouser: fliebel: sometimes you want it to be a fn.

10:57 (partial apply str)

10:57 _fogus_: Here's a fun little problem that is surprisingly tricky: How to get from [1 2 3 4 ...] to [1 [2 [3 [4 [...]]]]] without using (reverse) and without trashing the stack?

10:57 chouser: ,((partial apply str) ["hi " "world"])

10:57 clojurebot: "hi world"

10:58 fliebel: chouser: but that is true for all macros...

10:58 chouser: fliebel: exactly. yet another reason they should be avoided except when required.

10:58 fliebel: sometimes I wish the best of all macros: -> was a function.

10:59 saml: attr-map? is metadata macro thingy?

10:59 in (doc defn)

10:59 fliebel: chouser: so why don't we write -> as some reduce magic? I did that a while back.

10:59 chouser: _fogus_: can I write my own reverse? :-P

11:00 fliebel: it's often useful to have both options available -- macro and non-macro.

11:00 _fogus_: chouser: Only if it runs in constant time. ;-)

11:00 fliebel: chouser: that would mean duplicating half the core...

11:01 saml: how do you execute system commands and get stdout/err ? use java? or is there builtin library?

11:01 fliebel: saml: there is something in contrib, or you have to construct a reader and a whole lot of java mess.

11:02 _fogus_: ,(let [my-reverse rseq] (my-reverse [1 2 3 4]))

11:02 clojurebot: (4 3 2 1)

11:02 _fogus_: :-)

11:02 chouser: _fogus_: woo! constant time!

11:02 sorta

11:02 _fogus_: sorta?

11:03 saml: how do you navigate through library?

11:03 fliebel: saml: You mean this? http://clojure.org/api

11:03 saml: http://richhickey.github.com/clojure-contrib/index.html ?

11:03 chouser: well, rseq is constant time, but of course using it is still linear. I guess that's about as constant-time as you get. hm.

11:03 saml: oh ok. so no way to do it in repl

11:04 fliebel: saml: maybe with loaded-libs and doc

11:05 How do I escape an url or some html with Compojure?

11:06 _fogus_: chouser: You mean the difference between O(n) and O(2n)?

11:07 bagucode: Hello all

11:07 fliebel: hey

11:08 bagucode: I got a classloader/dynamic code gen question :)

11:09 chouser: ,((fn step [s] (when (seq s) (lazy-seq (list (first s) (step (rest s)))))) [1 2 3 4])

11:09 clojurebot: (1 (2 (3 (4 nil))))

11:09 fliebel: Is there any api documentation on Compojure? I can't find anything except for tutorials, but that is a very scattered way of looking for information, and only covers the basics.

11:09 chouser: saml: find-doc will search all loaded libs

11:09 saml: oh coolz

11:10 bagucode: I'm toying around with clojure.asm and I made a simple class and managed to load it using defineclass on the classloader that clojure.lang.RT.baseLoader returns. But it seems that code that I write at the repl after that has no clue that the class exists. It looks like it is not in the same classloader heriarcy? Anyone have an idea what cloassloader one should use for stuff like that?

11:10 saml: (use 'clojure.contrib.shell-out) fails for me

11:10 konr: Is Clojure metadata like CL's plist of a symbol?

11:11 saml: oh darn I was doing (use 'clojure-contrib.shell-out)

11:12 _fogus_: chouser: step will blow the stack given some large sequence no?

11:13 chouser: _fogus_: nope

11:13 _fogus_: because it's wrapped in lazy-seq

11:15 bagucode: I think each expression at the repl is eval'ed with a new classloader

11:15 dabd: chouser: I think I got the idea: :abc resolves to the empty or nil namespace and ::abc resolves to the current namespace. This is different from CL where all keywords have their own package or namespace. Now I think I got the idea. thx

11:15 chouser: bagucode: maybe try using (.getParent (clojure.lang.RT/baseLoader))

11:15 dabd: that's right.

11:15 ,(namespace :foo)

11:15 clojurebot: nil

11:15 chouser: ,(namespace ::foo)

11:15 clojurebot: "sandbox"

11:16 chouser: ,(namespace :bar:foo)

11:16 clojurebot: nil

11:16 chouser: ,(namespace :bar/foo)

11:16 clojurebot: "bar"

11:16 chouser: ok, gotta do more vacuuming. guests tomorrow... :-)

11:17 dabd: I am writing some multimethods that dispatch on a value read from a properties file. Currently I'm using the string value read from the properties file directly so my methods like like (defmethod foo "some_val" [...] etc.). Is there any advantage in converting the string values to keywords and dispatching on keywords? thx

11:19 _fogus_: chouser: duh! of course.

11:20 fliebel: You know what would be usefull? a ->-like macro that lets you fill in arguments in any position like anonymous functions.

11:23 lpetit: fliebel: this has been contributed to the ml recently, it was called -$>

11:27 bagucode: chouser: Two consecutive getParent calls seemed to do the trick! I wonder if that's always the depth of the hierarchy though? Maybe a safer way to do it would be to call getParent in a loop until you reach the highest DynamicClassLoader?

11:37 fliebel: lpetit: show me! :D

11:38 chouser: bagucode: doesn't sound completely insane... :-)

11:40 lpetit: fliebel: there it is : http://groups.google.com/group/clojure/browse_thread/thread/2cc0f1f1abe6e1de/c9f55d412d785580?lnk=gst&q=Generalizing+-%3E+%26+-%3E%3E#c9f55d412d785580

11:40 fliebel: thanks :)

11:47 yason: Q: was there a built-in function to enumerate a sequence? Something akin to Python's enumerate() ?

11:48 fliebel: lpetit: Do you know where I can find the mentioned implementation of Andrew?

11:48 chouser: yason: seq-utils indexed

11:49 lpetit: fliebel: in the first message of the thread, I guess

11:49 fliebel: ah, I read it wrong... I thought he was referring to another implementation.

11:51 lpetit: fliebel: the thread is pretty long, so maybe I missed something

11:52 fliebel: lpetit: no, you did not, I did… but I'd like to find out about other implementations and the possibility that this gets into contrib or core.

11:52 and maybe % is better than $ since that is already used in anonymous functions.

11:53 devlinsf: $ is also used in inner classes

11:53 chouser: fliebel: I would be surprised to see something like this in core

11:53 doesn't mean it won't happen, of course.

11:54 noidi: yason, here's one way:

11:54 ,(map vector [:foo :bar :baz] (iterate inc 0))

11:54 clojurebot: ([:foo 0] [:bar 1] [:baz 2])

11:54 fliebel: chouser: but this could replace both -> and ->>!

11:54 chouser: fliebel: yes, with something uglier. ;-)

11:55 lpetit: chouser: I guess it has its place in contrib, though ?

11:55 chouser: much lower bar to get into contrib. I would be a bit surprised if it *doesn't* show up there in some form.

11:56 devlinsf: fliebel: I did some work in this area recently. It's easy for hofs, but a nightmare for a macro

11:56 fliebel: devlinfs: how do you mean?

11:56 devlinsf: You could assume a different sign, though... hmmm

11:56 Well, take partial for example

11:56 You KNOW that the first argument must implement IFn

11:56 So, what if the first argument is an integer?

11:56 You could assume that the integer specifies the index to use

11:57 chouser: Now that I think of it, -?> might not be as ugly as you think

11:57 fliebel: chouser: I think using _ looks cool, like *here is an empty space, fill it in!*

11:57 chouser: devlinsf: I'm thinking mainly of its usage. Ugliness of implementation is entirely insufficient to rule out a feature. :-)

11:58 devlinsf: chouser: (-?> idx value (normal-stuff...))

11:59 saml: how can I see if a directory/file existis?

11:59 chouser: the times when I want to chain things, and nesting is unacceptable, and neither -> nor ->> is sufficient is already quite rare. At that point I've never minded using 'let' to give a step a name and use it.

11:59 devlinsf: Hmmm... good point

11:59 Data is rarely in the middle

12:00 lpetit: devlinsf: -?> is an already taken symbol in c.c.core :-p

12:00 chouser: saml: (.exists (java.io.File. "/tmp"))

12:00 yason: chouser: indexed sounds good, thanks

12:00 devlinsf: OH

12:00 saml: chouser, ah thanks. /me reads java interop

12:00 yason: noidi: something like I cooked up already except that iterate is more elegant :)

12:00 devlinsf: lpetit: Thanks

12:00 fliebel: chouser: but something in a let is not mutable, so you can't thread, right?

12:01 chouser: fliebel: I don't see what any of these have to do with mutability.

12:01 fliebel: chouser: how would you use let to replace ->?

12:02 chouser: ,(-> 2 (- 5) (- 10))

12:02 clojurebot: -13

12:02 chouser: ,(->> 2 (- 5) (- 10))

12:02 clojurebot: 7

12:02 chouser: ,(let [n (- 2 5)] (- 10 n))

12:02 clojurebot: 13

12:04 fliebel: ah, I thought you where going to do some magic, like defining 2 in the let and then threading it through the rest.

12:09 saml: does your emacs auto complete java code ?

12:09 .nextInt ..etc

12:14 devlinsf: Hey, how does one pronounce -> and ->> anyway?

12:14 * chouser never communicates with anyone about Clojure except via text.

12:15 rhickey: devlinsf: I usually say 'thread' or 'pipe'

12:15 I prefer thread, and both are overloaded

12:15 devlinsf: Okay. So -> "First Thread" and ->> "Last Thread" would be good?

12:16 rhickey: ->> is more like a pipe that ->, but both thread an rgument

12:16 thread-first, thread-last

12:16 noidi: yason, http://richhickey.github.com/clojure-contrib/seq-utils-api.html#clojure.contrib.seq-utils/indexed

12:16 devlinsf: rhickey: Okay

12:16 thread-first & last it is

12:17 noidi: oops, you got the answer already

12:17 bagucode: saml: Nope, emacs doesn't know java by default. There are some rather big and clunky java IDE packages for it, I think called JDE. I just use the online javadoc at suns java site to look stuff up and then some general autocomplete for emacs that can autocomplete stuff I have typed before.

12:17 saml: bagucode, thank you

12:18 fliebel: How do I create those random names in a macro?

12:18 chouser: (gensym "random-name")

12:18 ,(gensym "random-name")

12:18 clojurebot: random-name4858

12:18 chouser: ,`random-name#

12:18 clojurebot: random-name__4859__auto__

12:18 fliebel: chouser: thanks

12:19 noidi: how can I see the full stack traces of exceptions? I mean the parts hidden by "... 40 more"

12:19 bagucode: clojurebot: what is lisp-paste?

12:19 clojurebot: this is not allegro

12:19 bagucode: hehe

12:19 Anyone got the paste link? Or know how to ask the bot?

12:20 rhickey: lisppaste8: url

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

12:20 chouser: noidi: usually that's a cue to skip up to the previously-printed cause.

12:20 drewr: noidi: in slime? hit 1 until you get to the exception you want

12:20 bagucode: rhickey: thanks

12:21 lisppaste8: bagucode pasted "dynamic bytecode loading" at http://paste.lisp.org/display/92724

12:22 bagucode: rhickey: Would that (my paste) be an acceptable way of doing class loading from a byte array and have it visible in the clojure runtime?

12:23 rhickey: I'm playing with clojure.asm and I don't know how the ClassLoader hieriarchy fits together

12:23 rhickey: bagucode: visible to what other code? That's the general problem, the JVM offers no standard way to do that and make the results visible to all classloaders

12:24 noidi: chouser, ok, thanks

12:24 rhickey: It's quite critical to asses whether anyone needs to see your classname directly, or only the names of interfaces it implements

12:24 ideally, it will only be the latter

12:25 fliebel: Where is # defined? I want to look how % is replaced by the value.

12:26 the-kenny: fliebel: I think it's a reader macro

12:26 fliebel: the-kenny: I know that, but where are those defined? or is that geeky java stuff?

12:26 bagucode: rhickey: What I'm trying to do is dynamically create stub classes for importing native functions via JNA so the generated classes will probably not implement any interfaces and contain only static methods so they need to be visible I think?

12:27 the-kenny: fliebel: I think so. Somewhere in Reader.java

12:27 fliebel: :(

12:27 devlinsf: the-kenny: LispReader.java

12:27 bagucode: rhickey: To the users of the native methods I mean

12:27 fliebel: the-kenny: Is there a way I can turn an ordinary list into a # macro(and have the heavy lifting done for me)?

12:28 the-kenny: fliebel: I don't know, but you could use fn

12:29 rhickey: bagucode: why do you want to do this dtynamically>

12:29 ?

12:29 * rhickey can never remember how to do line#s in github source urls

12:31 * devlinsf would like an awesome example of ->

12:31 fliebel: the-kenny: but than I end up with an undefined %

12:32 the-kenny: yeah, sure. % are special in #

12:32 bagucode: rhickey: The idea is to create a clojure library for using JNA with maximum performance and only clojure code required. You can already use JNA dynamically but not with as much performance. There is this thing called direct mapping in JNA that requires a class static block, that's why I thought of using asm and generating classes with static blocks (<clinit> methods) for the bindings. I have tested it and it works. But I had some classloa

12:32 issues when playing with the repl. I want the generated classes visible to all clojure code that would want to use them.

12:32 rhickey: fliebel: http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/LispReader.java

12:33 bagucode: dynamically and max perf are in conflict

12:33 fliebel: rhichey: thanks :)

12:34 bagucode: rhickey: If you generate the bindings on every call yes, but what I mean by dynamically in this context is simply to do it without any java code whatsoever

12:34 replaca: rhickey: lines # are easy: just go to the line and click. You addr bar will have the URL.

12:35 chouser: ,(-> "devlinsf: -> is awesome" Exception. throw)

12:35 clojurebot: java.lang.Exception: devlinsf: -> is awesome

12:36 rhickey: replaca: that's not working for me

12:36 devlinsf: chouser: Flattery will get you everywhere :)

12:36 Oh.. oops read that wrong. Now I look dumb

12:36 chouser: devlinsf: it's ok. I nearly wrote what you thought I did anyway. :-)

12:37 bagucode: rhickey: Also, to be more specific; "max performance" is just minimum overhead per call into native code

12:37 devlinsf: Hmm... I think I'm going to use a temperature converter

12:37 jweiss: i'm trying to write a function is-member? [user group] to determine if the user is a member of a group, and groups can also contain groups. i know how to write this using normal recursion, but i wanted to try it with 'recur', but i'm not having any luck.

12:38 devlinsf: chouser: Did you get my "same" message?

12:39 rhickey: bagucode: but you move the perf problem to the next stage - the caller that has to be compiled against a named static method. Any system you use for doing this dynamically will run aground in certain situations, e.g. under OSGi etc

12:40 chouser: jweiss: you have to convert to tail-recursive form first, which can be a bit tricky for tree-navigation cases like this.

12:40 rhickey: bagucode: you are better off generating stubs once and statically using them

12:40 jweiss: chouser: i thought i did, but i still get the compile error that the recur has to be in tail position

12:41 chouser: jweiss: you might consider solving the deep-recursion problem using lazy seqs instead, perhaps with tree-sew

12:41 tree-seq

12:41 rhickey: bagucode: just take your generated bytes and dump into classfiles

12:41 lisppaste8: jweiss pasted "untitled" at http://paste.lisp.org/display/92725

12:41 chouser: I have a nice writeup about tail position in the book. That is not yet available. :-(

12:42 ah, interesting. 'doseq' always returns nil, so nothing you can put in it is in the tail position.

12:43 jweiss: chouser: i'm not even sure whether recur can be used in a loop. can it?

12:43 i mean, calling recur to the top of the fn multiple times within the same fn call

12:44 chouser: jweiss: recur can be used in a 'loop', but not usefully in the body of a 'doseq' or 'for'.

12:44 sure, you can have (if predicate (recur this-thing) (recur that-thing))

12:44 jweiss: chouser: yeah, but it only will do one of those recurs, not both

12:45 fliebel: How can I do something for every & value in a macro? like `(do (map #(str %) ~@value))

12:45 chouser: right. you can only put 'recur' where you the return value of the fn would go.

12:45 jweiss: chouser: i see

12:45 chouser: fliebel: just ~value

12:46 fliebel: chouser: that evaluates the value, but I want to wrap every value in some other function.

12:47 chouser: If I knew the values I'd just do it for every one of them, but I want to do that to the rest of them.

12:47 so more like (str ~@value) would result into (str value1) (str value2)

12:48 bagucode: rhickey: Yeah perhaps. I don't have a clue about that OSGi stuff. It's a later problem anyway, I got some other stuff to iron out too.

12:54 ericthorsen: Is there a branch of clojure-contrib that is tracking the clojure new branch?

12:56 rhickey: ericthorsen: the latest contrib works with new and all tests pass

12:57 * technomancy was very glad to see the contrib version number start matching clojure's version

12:57 ericthorsen: rhickey: hmm...time to delete and start fresh

12:57 rhickey: just ant clean in contrib

13:01 noidi: technomancy, running "lein test" gives me "org.apache.tools.ant.ExitException: Permission (java.lang.RuntimePermission exitVM) was not granted." Any idea what might be wrong?

13:02 I've tried to look into it, and it seems that Ant's Java task is run with the exitVM permission revoked, which causes the System/exit in leiningen's test.clj to fail

13:03 I was wondering if there's something wrong with my setup instead of leiningen

13:04 replaca: rhickey: really? Did you click on the line number itself? On my system that's a link to itself.

13:05 rhickey: replaca: yes, that works in safari, but not in the Fluid app I've created for github. Thanks, I saw the #L1234 format

13:05 technomancy: noidi: looks like a bug from a recent patch someone submitted; thanks for letting me know.

13:08 replaca: rhickey: ahh. I don't know about fluid. I could have just told you the answer, of course :-). But I can never remember either without following that procedure.

13:09 noidi: technomancy, another issue I had was that "lein test" threw java.lang.Exception: No such var: clojure.test/successful?

13:10 technomancy: noidi: that would be from an outdated version of clojure

13:10 noidi: that happens with the version downloaded by "lein deps"

13:10 technomancy: I'll see if I can take a look later then.

13:12 noidi: thanks

13:13 I "fixed" it by changing "successful?" on the last line of test.clj to "~''succesful?", but that seems like a kludge

13:14 replaca: technomancy: do I need to add swank to my project.clj to get swank-clojure-project to work?

13:14 the-kenny: replaca: Add it as a "dev-dependency"

13:15 replaca: hmmm, that seems weird

13:15 noidi: or maybe that's fine, I don't know, but the extra quote seems a bit weird to me :)

13:15 replaca: the-kenny: thanks

13:16 the-kenny: replaca: It's included while developing but not when creating a jar etc.

13:17 replaca: the-kenny: yeah, but why should I need it there? swank ought to be separate from the project...

13:17 the-kenny: (that's really a rhetorical question by the way)

13:17 the-kenny: replaca: But the jar needs to be loaded on the clojure side

13:18 replaca: swank-clojure is split in two parts - a clojure part and an elisp part

13:18 replaca: the-kenny: yeah, I know that, but that reality doesn't need to be part of the project setup that leiningen does

13:19 the-kenny: imagine I'm developing with slime/swank and you're using netbeans. Why would you want my dev-dependency in your project file

13:19 the-kenny: replaca: hm.. that's an argument

13:20 replaca: the-kenny: or (more likely) I want to hack on someone else's project who develops in vim. I need to edit their project.clj to get swank to run. Now I've got one more thing to integrate. Ugh!

13:21 * replaca feels like his "patches welcome" list is getting longer :-)

13:21 the-kenny: replaca: You can always copy swank-clojure.jar to lib/ :)

13:21 replaca: the-kenny: that seems very 20th century :-)

13:22 the-kenny: slime knows where it is already since you can run slime without any special setup

13:24 noidi: replaca, but you need a version of swank that's compatible with the version of clojure that the project uses

13:24 which might not be the clojure version launched by M-x slime

13:25 chouser: fliebel: perhaps (let [xs [1.0 2.0 3.0]] `(+ ~@(for [x xs] `(int ~x))))

13:26 fliebel: chouser: maybe… I'll have a look at it

13:27 In the meanwhile It's complaining about this: `(let [value (atom ~value)]) I think it does not like defining user/value in a let :(

13:27 java.lang.Exception: Can't let qualified name: user/value

13:28 chouser: right. use value# instead

13:28 Chousuke: fliebel: looks like you need a gensym

13:28 replaca: noidi: yeah, I guess. I was thinking of that too, but certainly defaulting to your normally installed slime seems reasonable (to me). At least more reasonable than inferior lisp just erroring out and hanging slime :)

13:29 fliebel: chousuke: but I need the generated thing later on, but then it returns a different one of course.

13:29 Chousuke: fliebel: in another syntax-quote form? :/

13:29 fliebel: then you need to use gensym directly

13:29 fliebel: chousuke: yea, I'm concatenating them :D

13:30 Chousuke: ,(let [foo (gensym)] [`(bar ~foo) `(zonk ~foo)])

13:30 clojurebot: [(sandbox/bar G__4869) (sandbox/zonk G__4869)]

13:30 fliebel: hmmmm, that looks good

13:31 replaca: also, I'm not sure how excited I am by this idea that every project lives in a completely separate universe. Seems a little weird when you have a lot of small projects (on the way to making clojure work even less well as a scripting language, for example).

13:31 but I do understand the power of it

13:34 fliebel: chousuke: whoa, I got it working! but it's a mighty hack… different forms of quoting and unquoting all over the place…

13:35 It's like my own -$> but with %, quite hacky, but the whole purpose of a macro is hiding ugliness I guess...

13:35 noidi: technomancy, you were right, the error with "successful?" does not apper with the latest git versions of clojure, but the version downloaded by "lein deps" does not work

13:39 fliebel: (maze-thread 1 (inc %) (str "aap" % "noot")) => "aap2noot"

13:40 chouser: now you just need to support %2, %3, etc. where the number indicates how many forms back to look get the value to insert

13:41 fliebel: chouser: uuuhm, good idea… how? :D

13:41 chouser: ack, no, a horrible idea!

13:41 :-)

13:42 _fogus_: so then would you have to use %-2 to look ahead?

13:42 I'm confused!

13:42 fliebel: maybe you're right....

13:42 chouser: hehe

13:44 fliebel: Here it is: http://gist.github.com/264840

13:44 chouser: oh, that's not bad at all.

13:45 you should use ` instead of ' in most of those cases.

13:45 fliebel: chouser: thanks :)

13:45 chouser: ` causes more havoc than it solves I think.

13:45 chouser: it really doesn't.

13:46 fliebel: I'll try...

13:46 chouser: yours is non-hygenic. if someone were to have a local named 'atom' when they use your macro, things would break in exciting ways

13:46 using `atom instead would avoid that.

13:46 fliebel: that is true… one moment

13:48 chouser: java.lang.Exception: Can't use qualified name as parameter: user/%

13:48 I can't go on and use a gensym for that one...

13:49 chouser: nope, '% is correct there

13:50 fliebel: that turns into (quote user/%)

13:51 ~'% :D

13:51 clojurebot: aber sicher, fliebel!

13:52 fliebel: chouser: http://gist.github.com/264840

13:53 I think it's quite clean indeed… if people understand ~'% :P

13:53 chouser: :-)

13:55 fliebel: So what do I do with it? Put it on a mailing list? Get it in contrib? Put it on my blog? Use it privately? Forget it?

13:56 chouser: fliebel: an alternate implementation: (defmacro maze-thread [& xs] `(let [~'% ~@(interpose '% xs)] ~'%))

13:58 fliebel: chouser: that is one hell of an one-liner! :P It took me a while before I relaized how it works.

13:59 Chousuke: fliebel: ~' is idiomatic clojure for "WARNING: evil macro trickery"

13:59 (sometimes evil macro trickery is necessary)

13:59 fliebel: haha

14:00 wooby1: hello, would anyone happen to know if there's something like strtol in contrib?

14:01 fliebel: I do like chouser s implementation, that should end up in contrib somewhere…

14:01 saml: is it ok to (defn f [{a :a, b :b}] ..) forcing people to pass a map?

14:02 chouser: saml: for functions where it makes sense, sure.

14:03 fliebel: chouser: do you mind if I paste you thing in a (private) gist to have it handy when I need it?

14:03 chouser: fliebel: sure, go for it.

14:03 fliebel: actually, that accomplishes the same thing as one of the first clojure macros I ever wrote.

14:03 I wonder if I can find that somewhere.

14:04 rhickey: fliebel: when do you need it? I see this get discussed often but rarely with compelling use cases

14:04 saml: i want to write (checkout {:repo-url "http://github.com/project..", :to-dir "C:/home/repo" ..})

14:04 fliebel: I think it's cool to have a positioned thread, or whatever you call it :)

14:05 chouser: saml: yep, makes sense. Another option is to conver the list of args to a map on inside your fn. (fn checkout [& args] (let [arg-map (apply array-map args)] ...))

14:05 fliebel: Mine was named >>_, using _ as the insertion point. I used it maybe once or twice before abandoning it.

14:05 saml: chouser, thanks

14:06 fliebel: chouser: I thought about using _ because it looks cool, but I think % is more consistent with lambdas

14:08 chouser: ah, there it is. at the bottom of the page: http://clojure-log.n01se.net/date/2008-04-14.html#22:58

14:10 so there's a use case that -> didn't solve, but with the new (Foo.) and (.foo) syntaxes, -> would work fine. And ->> would have always sufficed for that particular example.

14:11 fliebel: chouser: I agree, but I need to write complex nested code where things need to be at the back, front and in the middle in the same piece.

14:14 saml: should I prefer to use defstruct?

14:14 than to list or map?

14:14 fliebel: How do things end up in contrib?

14:15 chouser: defstruct is for memory and performance -- use it you need more of either, otherwise don't bother.

14:15 saml: ah i see. i thought it's for making code clearer

14:15 chouser: fliebel: http://clojure.org/contributing

14:16 saml: well, there is that. I guess I haven't used it for that, but I know some people do.

14:17 saml: In Java, I usually have Constants class that has many static finals. Constants.PI ... is it normal to have (def BASE_DIR "C:/") in clojure?

14:18 chouser: saml: yes, that's not uncommon.

14:18 saml: i should read more clojure code

14:21 Chousuke: saml: except it would be called *base-dir*

14:21 saml: oh i see

14:22 fliebel: Chousuke: Is that considered functional to do?

14:22 I've been passing around vars like hell, defining them somewhere would make life easier I guess...

14:23 Chousuke: well, yeah.

14:23 fliebel: Is that a good idea or is that ruining what Clojure is all about?

14:24 Chousuke: if they're just constants I don't think there's a problem at all. If you use dynamic binding, it's somewhat further from the functional ideal (though still lispy)

14:24 if you use alter-var-root! a lot, then it's certainly not idiomatic :P

14:24 fliebel: nah, it's not going to change during one run of the applications, so I guess it all right.

14:25 KirinDave1: Man, people are coming up to me asking for clojure optimization tips. Like I effing know.

14:26 And worst of all, 7/10 times it's basically a thinly veiled excuse to show off how slow they think java is. :\

14:26 fliebel: Can I def to another namespace? like (def blah/var "hello!")

14:26 Chousuke: I haven't actually tried that, but I don't think so.

14:27 you can switch your namespace temporarily though.

14:27 but that's hacky.

14:27 fliebel: hmhm

14:28 I got one ns with all the functions in it and one that is "bootstrapping", it would make sense to have all the vars defined in the core.

14:29 Chousuke: perhaps you could write an init function that takes a map of configuration values and uses alter-var-root! to set the vars?

14:29 fliebel: If I do it the other way around, the core would be tightly coupled with the bootrstrapper.

14:29 hmmm

14:30 Chousuke: it's side-effecty but as long as it's clearly advertised as such I don't think it's a problem :)

14:30 fliebel: hmmm

14:30 I'll try

14:33 How would I use alter-var-root for that? don't know about it...

14:36 Chousuke: (def *something* nil) (alter-var-root! *something* "blah") ; *something* is set to "blah"

14:36 hm

14:37 (constantly "blah") even

14:37 since it's alter

14:37 it takes a function that transforms the old value

15:03 kotarak: Hi. Did anyone try to upload to Clojars via the ant scp task?

15:04 It works for my own server, but not for clojars.

15:05 fliebel: ,(concat #{:a :b :c} #{:d :e}) ;How can I make something similar return a set?

15:05 clojurebot: (:a :c :b :d :e)

15:05 kotarak: ,(into #{:a :b :c} #{:d :e})

15:05 clojurebot: #{:a :c :b :d :e}

15:05 fliebel: thanks

15:08 rrc7cz: what is the difference between (fn [x] (println "I'm a side-effect") (* x x)) and (fn [x] (do (println "I'm a side-effect") (* x x)))?

15:09 saml: when I require a module, can I pass parameters? in my module, (def *a-constant* "some defaulat value") and I use *a-constant* through out the module. but, in other module, when i import it, i want *a-constant* to be different

15:09 chouser: rrc7cz: essentialy no difference.

15:09 fliebel: rrc7cz: nothing I guess

15:10 kotarak: saml: (defn fn-in-other-module [] (binding [first-module/*a-constant* different-value] stuff-here))

15:10 rrc7cz: but from what I've read, "do"s were meant to warn of side effects. Why not force a do in this example?

15:10 chouser: fn's have implicit "do" for the body.

15:10 rrc7cz: i see

15:11 saml: kotarak, oh coolz! thanks

15:11 oh wait. i need to do that for every function in the other module

15:11 kotarak: saml: yep. And every thread.

15:12 saml: maybe i need some sort of object. o = new MyObject(param1, param2); o.func1() o.func2()

15:13 since module isn't first class object in clojure

15:13 oh clojure lets me create my own object?

15:13 in the end, i need to use defstruct i think

15:13 kotarak: saml: defstruct does not define objects.

15:14 At least not in the java sense.

15:14 You'll need gen-class, but I doubt your approach won't end up ugly.

15:14 Maybe you have an example what you are trying to do?

15:15 saml: (defstruct constants :base-dir :base-url) (defn f [x constants] ...) and in other module, (f 42 (struct constants "C:/home" "http://google.com"))

15:16 kotarak: saml: yeah, that looks more promising.

15:17 unfo-: if I want to do a (re-find #"Hello my name is John" str) -- how would I be able to get John from another string?

15:18 i.e. is # short-hand for something I could call explicitly with a param of (str "Hello my name is" name)

15:21 ah nvm! found re-pattern in the api right next to re-find :)

15:23 Chousuke: #"foo" actually produces a Pattern object at compile-time (or read-time)

15:24 so it's not quite identical to re-pattern, but I guess it doesn't have to be for your use case. :)

15:24 unfo-: yeah, assumed as much since re-find works as well with re-pattern as with #""

15:24 yeah. don't need to be identical. Good enough if it works :)

15:25 1) make it work 2) revise what i've learned 3) make it pretty

15:26 saml: how can I get user's home directory?

15:26 oh use java! hah

15:27 (.. System (getProperty "user.home"))

15:28 fliebel: What is the correct looping function for looping over one sequence and appending to another?

15:28 kotarak: saml: (System/getProperty "user.home")

15:28 fliebel: reduce with vectors.

15:28 saml: kotarak, ah thanks.

15:28 fliebel: kotarak: thanks

15:29 kotarak: ,(reduce (fn [v x] (conj v (inc x))) [] (list 1 2 3 4 5))

15:29 clojurebot: [2 3 4 5 6]

15:29 noidi: technomancy, I checked the leiningen repo with "git bisect", and the commit that causes "org.apache.tools.ant.ExitException: Permission (java.lang.RuntimePermission exitVM) was not granted." is f96399603619b0f807e5af86f4fc4601c97c0cdc

15:31 technomancy, if I comment out "(.setFailonerror java true)" in compile.clj:114, everything works

15:33 saml: (defstruct SomeCamelcase ...) this is not conventional naming, right? All I see is all (defstruct some-name-like-this ...)

15:34 if I do (defstruct foo ..) (defn a-function [foo ;I'm not sure what to name the parameter. i'm expecting struct foo

15:34 but, I can do (defstruct Foo ... ) (defn a-function [foo] ...)

15:34 Chousuke: you could name the struct base <foo> or something

15:35 or you could just not use a struct at all :)

15:35 saml: <oh-did-not-know-this-was-valid-name>

15:35 Chousuke: (just a plain map)

15:35 saml: most characters are valid in names

15:36 saml: ah thanks Chousuke

15:37 Chousuke: ,(let [フォー "this code is not very readable to most people"] フォー); I wonder if clojurebot uses UTF-8

15:37 clojurebot: "this code is not very readable to most people"

15:40 kotarak: Chousuke: it does, it shows japanese here.

15:40 saml: can slime or swank compile and load a toplevel def and all its dependencies?

15:40 fliebel: cool… I'm going to look up some weird names for my functions :D

15:40 saml: (defn f ...) (defn g (f ...)) when I do C-c C-c at g, it does not automatically load f if f is modified since..

15:40 kotarak: Chousuke: ah sorry, the actually wasn't clojurebot. :P

15:41 saml: how should it know?

15:41 Chousuke: kotarak: looks like it worked though.

15:42 saml: kotarak, repl should keep track of..... oh right

15:44 fliebel: Hmm, I got some circular trouble...

15:45 ns1 uses ns2, and ns 2 also uses ns1, but since ns2 is loaded before ns1 has run, ns2 can't access the functions in ns1.

15:46 How can I solve that?

15:47 jneira: mmm with ns0?

15:48 the-kenny: with avoiding circular dependencies? :)

15:48 fliebel: how?

15:48 rrc7cz: is there a nicer way to drop-last than (reverse (rest (reverse [1 2 3])))?

15:49 Chousuke: there's butlast

15:49 rrc7cz: perfect, thank you

15:50 chouser: also drop-last and take-last.

15:52 polypus: ~ping

15:52 clojurebot: PONG!

16:13 fliebel: Why is the clojure wiki hanging on the session page four hours every time I load it?

16:22 tolstoy: Is there a nice solution for clojure for, say, XPathing through XML? (value-of "/foo/bar/baz") or something?

16:22 the-kenny: tolstoy: there is something in contrib

16:22 tolstoy: Called "zip-filter"

16:23 tolstoy: Hm. Okay. I'll take a look.

16:24 the-kenny: I don't know about the performance, but it's almost like xpath and very cool

16:25 (Xpath with clojure-syntax)

16:26 tolstoy: That does seem nice. I seemed to have missed that module when I last looked.

16:26 Performance doesn't matter for me: I'd like to use it for unit testing a web service.

16:27 the-kenny: ah ok

16:30 tolstoy: I'm glad I don't have to write some sort of tree walker. I mean, fun, I guess, but....

16:32 the-kenny: clojure.zip exists for editing and walking trees :)

16:53 mebaran151: hey, what would be a natural representation in Clojure of a web of a nodes?

17:07 tolstoy: I wonder why clojure.xml.parse doesn't take a plain old string?

17:10 the-kenny: hm.. what does it take?

17:10 tolstoy: input stream, url.

17:10 But duck-streams to the rescue.

17:17 Oops. duck-streams NOT to the reque.

17:17 Er, rescue.

17:21 unfo-: tolstoy, thanks for that clojure.xml.parse (parsing is next on my todo for my current pet project) :-)

17:21 (send :channel "good night!")

17:23 tolstoy: I hope you can get it working. I can't get the right combo or require or use or what have you.

17:23 saml: what do you use for unit test? is, fact?

17:24 tolstoy: #<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: parse for class com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl>

17:28 rrc7cz: How can this be explained? (println x "-" (empty? x) "-" (count x) "-|" (first x) "|-" (count (first x))) -----> "() - false - 1 -| |- 0"

17:29 str puts a space between all of the elements, so it's actually "()-false-1-||-0"

17:30 so somehow the lazyseq is (), but it's not empty, having 1 element of 0 length and apparently invisible

17:31 defn: fliebel: how goes the utterson hacking?

17:32 fliebel: defn: great, although my once so clean design is starting to look like a mess :P

17:32 defn: still busy?

17:33 tolstoy: where in zip-filter does it describe what a "loc" is?

17:33 defn: fliebel: i just got back today, hopefully i can mess with it later tonight

17:33 fliebel: defn: I just wrote a tag page plugin, but due to some circular stuff I can't get hold of some variables.

17:33 defn: so to compile the jar you have to remove the tag plugin.

17:34 defn: nod, okay

17:34 have you submitted a pull request?

17:34 fliebel: defn: I'm looking forward to your stuff.

17:34 defn: i can pull in your changes if youd like

17:34 fliebel: me too! :)

17:34 fliebel: defn: Not recently, shall I send you one?

17:37 defn: It would be great if you could improve and clean up my code a bit… I'm doing everything I can, but I am a beginner after all...

17:37 tolstoy: Anyone know of any examples out there for zip-filter?

17:38 defn: fliebel: im no expert on this stuff either, but we can incrementally improve things as we go

17:38 the-kenny: tolstoy: Wait

17:39 fliebel: defn: I think that is a good plan. If I don't do that my applications tend to get messier over time.

17:40 tolstoy: the-kenny: Cool. All I see are the abstract descriptions. No idea what the real params are. ;) Waiting for the a-ha.... ;)

17:40 the-kenny: bah.. just broke something in my running emacs

17:40 fliebel: defn: a good start would be rethinking the structure and control flow of the application.

17:40 defn: I don't know what time it is over there, but I need some sleep now.

17:41 KirinDave_: Grrgh

17:41 Annotations annotations, everywhere.

17:41 Such a pain in the ass.

17:46 fliebel: bye everyone!

17:49 saml: how can I grep a line from a string?

17:49 the-kenny: tolstoy: Sorry for taking so long: http://codepad.org/5SiGXqBk

17:49 saml: line-seq

17:49 ,(doc line-seq)

17:49 clojurebot: "([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."

17:49 saml: the-kenny, thanks

17:50 the-kenny: uh, that's from a reader. Use duck-streams then

17:51 tolstoy: Same with require's: http://codepad.org/oHQ4xxVy

17:51 oh btw.. please ignore my developer key for youtube in the url :)

17:53 saml: string is not lazy right?

17:53 (sh "tail" "-F")

17:54 i want to do something with the output .. where sh is from clojure.contrib.shell-out

18:01 Licenser: Good evening my lispy freinds? How is the world of paranthethes (I never can spell that) going today?

18:03 defn: Parentheses are opening and closing just as they do in any language

18:04 Licenser: glad to hear!

18:08 So in this great days where actual work is far from me, I decided to invest some time to some adventures into the Clojure Database world. Now deciding that I wonder what if people have any good or bad experience, recommendation and hints for me on my jurney. I already figured that while mongodb is nice, they are surprisingly stubborn about making it non x86 compatible so it's not an option :/

18:13 defn: couchdb, clojureql

18:15 mebaran151: clojureql is definitely nice

18:16 I've uploaded some bindings for BerkeleyDB and am currently wrapping Neo4j right now

18:24 tolstoy: the-kenny: Thanks for the examples. I'm still trying to figure 'em out. ;)

18:26 the-kenny: How do you create a path? :foo:bar:baz for <foo><bar><baz>?

18:26 the-kenny: tolstoy: No :foo:bar is the element bar in the xml-namespace foo

18:27 tolstoy: (xml-> xml :foo :bar :baz) would be the path you've mentioned

18:27 tolstoy: "xml" would be the result of clojure.xml/parse?

18:28 I see you've got xml-zip.

18:28 the-kenny: no, the result from (clojure.zip/xml-zip (clojure.xml/parse ...))

18:28 tolstoy: Ok.

18:29 the-kenny: the whole zip-filter stuff operates on trees generated by clojure.zip

18:31 ieure: I really wish there was some sort of documentation on zip-filter. I have no idea how that stuff works.

18:31 tolstoy: Gotcha.

18:31 Yeah, it's pretty tough.

18:32 Probably really easy to use, once you know a key piece of information.

18:32 the-kenny: ahh found examples in the code: http://github.com/richhickey/clojure-contrib/blob/81b9e71effbaf6aa2945cd684802d87c762cdcdd/src/clojure/contrib/zip_filter/xml.clj#L90

18:32 (Mentioned in the doc for xml->)

18:34 tolstoy: Hm. But no example of (text loc).

18:34 How to I get an "loc" I can pass to text?

18:36 I guess you use xml-> to get to some place in the tree, then pass the results of that to text?

18:40 Licenser: defn mebaran151 thanks for the suggestions, I'll look into it. So I won't touch BDB .

18:40 p

18:41 mebaran151: haha

18:41 Licenser: BDB stands for Breaking DB not Berkeley DB

18:41 tolstoy: So, zip-filter is like that arrows thing in Haskell, eh?

18:41 mebaran151: it definitely isn't as polished as ClojureQL, but it's a nice fit for clojure

18:42 sometimes it's nice to think of things as a series of string tuples and saves as writing a series of string tuples

18:42 the-kenny: tolstoy: yes, you use :something to get to the element and do further examining with the provided functions

18:42 Licenser: It is, in itself, not very nice in my eyes. Twice BDB's horrible or not existing backwards compatibility nearly killed a database I had in it...

18:44 tolstoy: the-kenny: So, in your example http://codepad.org/oHQ4xxVy, you're finding the tag :group, and then within that, the tag :thumbnail, and finally applying attr to the tag :url, within thumbnail, right?

18:45 the-kenny: tolstoy: group and thumbnail are elements, not tags. The purpose of this is to get the attribute "url" of all :media:thumgnail tags

18:46 tolstoy: Sorry, I meant elements. I guess I've seen people use those words intechangeably.

18:50 the-kenny: tolstoy: Maybe it's easier to understand if you look at the xml behind the url

18:51 tolstoy: Okay. I have doc <foo><bar><baz> and (xml-> dom :foo) gets me nil.

18:53 Okay. Looked at the xml. That's what I thought was happening. Now to figure out why I get NPEs and nils and so on in similar circumstances.

19:00 chouser: I think xml-> starts within the document element.

19:02 tolstoy: I'm about to paste in the examples in the source code. Frustrating! ;)

19:03 lisppaste8: tolstoy pasted "xml zip-filter?" at http://paste.lisp.org/display/92754

19:04 tolstoy: the-kenny: Can you tell me why the stuff in http://paste.lisp.org/display/92754 ends up "nil"?

19:06 the-kenny: tolstoy: hm.. not sure - Does it work when you the xfilter/tag=-stuff with just :baz?

19:06 tolstoy: I changed xml1-> to xml, and now I get an empty list.

19:07 Both with :baz and (xfilter/tag= "baz") or (xfilter/tag= :baz). Odd.

19:07 the-kenny: hm. wait

19:08 lisppaste8: the-kenny annotated #92754 "untitled" at http://paste.lisp.org/display/92754#1

19:08 the-kenny: tolstoy: try it like this

19:09 tolstoy: That worked.

19:10 Where as :foo :bar :baz didn't.

19:10 the-kenny: Yeah, you have to specify the full path, omitting the "root" element

19:10 tolstoy: Ah.

19:10 the-kenny: (in this case foo

19:10 tolstoy: Now I understand chouser's comment.

19:11 the-kenny: ahh me too :D

19:12 tolstoy: Okay, one last question: how do you get all the attributes for a given element?

19:12 Is (xml-> :bar :baz) suppose to return a list of "baz" nodes?

19:13 the-kenny: Yes

19:16 tolstoy: Alrighty. Thanks the-kenny! I think I have enough to ox-blinder my way through it. ;)

19:18 mebaran151: Licenser, I myself have put using BDB in maintenance after finding neo4j with Lucene quite a bit better and less likely to wedge itself

19:18 the bdb code demanded that I always think about unwedging the database

19:18 Licenser: ^^

19:19 I generally don't like BDB any more since it twice nearly fried my mail server :P

19:19 mebaran151: oh yeah, it's not a very trustworthy rascal

19:19 I wish the JVM had a simple efficient library for persisting btrees to disk

19:19 BDB is the closest I could find

19:29 defn: hmmm -- i have a problem with: (file-str (java.io.File. "/home/myuser/") "/src/etc")

19:31 technomancy: defn: try java-utils/file instead of file-str

19:31 danlarkin: file-str takes a string and returns a File

19:31 srnm: (file-str "~/src/etc") should work...

19:44 technomancy: any idea why contrib's logging would use java.util.logging even though commons logging is present?

19:45 oh... yuck. AOT strikes again. =(

19:56 optimizer: is clojure close to having recursive repls on exceptions yet?

19:58 defn: optimizer: i think it does?

19:58 technomancy: optimizer: you have to insert them manually right now

19:58 defn: actually nevermind, im thinking of some elisp i was writing

19:58 mebaran151: I'm getting the strangest error on loading a file

19:58 optimizer: insert them manually?

19:58 why can't it be automated?

19:59 this makes no sense

19:59 mebaran151: it complains it can't make an ISeq from symbol

19:59 but every time I load the file, the line number gets one higher

19:59 defn: btw technomancy -- rudel is working pretty well now -- i was asking you about it the other day, basically i just needed to compile emacs23 from source since the ubuntu package doesnt include cedet for some reason

19:59 mebaran151: do you have your code up anywher?

19:59 anywhere*

19:59 mebaran151: user=> (load "./src/com/bebop/appledelhi2")

19:59 java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (appledelhi2.clj:1)

19:59 user=> (load "./src/com/bebop/appledelhi2")

19:59 java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (appledelhi2.clj:2)

19:59 user=> (load "./src/com/bebop/appledelhi2")

19:59 java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (appledelhi2.clj:3)

19:59 user=> (load "./src/com/bebop/appledelhi2")

19:59 technomancy: optimizer: well that functionality is quite new and hasn't been included in clojure yet

19:59 mebaran151: (sorry about the flood)

20:00 I'm not sure what part to paste

20:00 technomancy: optimizer: it can be automated, it's just that nobody's done it yet

20:00 optimizer: technomancy: is this in clojure proper or enclojure?

20:00 Chousuke: mebaran151: I would guess it's because of the repl

20:00 technomancy: optimizer: it's not anywhere yet

20:01 optimizer: just here: http://georgejahad.com/clojure/debug-repl.html

20:01 devlinsf: http://groups.google.com/group/clojure/browse_thread/thread/8d77ad0da8d190c8/e39b59fd19cc5675

20:01 Chousuke: mebaran151: it might be taking the line number from the repl and not the file, for some reason.

20:01 mebaran151: https://gist.github.com/016734cc1df33129811e

20:02 I can't find the syntax error for the life of me

20:03 Chousuke: I think you need to do (:require (com.bebop.appledelhi2 [neo4j :as neo4j]))

20:03 mebaran151: that's strange: it's always worked before up to this very minute

20:03 Chousuke: hm.

20:03 technomancy: any contribbers want to check out https://www.assembla.com/spaces/clojure-contrib/tickets/53 ? =)

20:05 mebaran151: nope that didn't fix it

20:05 optimizer: which editor has best clojure interface?

20:05 which editor has best clojure _interaction_

20:06 Chousuke: probably emacs, but then again, I haven't tested others :P

20:06 mebaran151: also, I can only get the netbeans repl to launch about 50 percent of the time

20:06 though when it works I love it to pieces

20:09 mattrepl: re: http://www.assembla.com/spaces/clojure-contrib/tickets/44 is there a problem with not AOT compiling clojure.contrib.logging?

20:10 mebaran151: I wish clojure had better error report for ns macros

20:11 technomancy: mattrepl: dang; I just opened a dupe of that ticket

20:12 mattrepl: my patch just adjusted build.xml to skip AOT of logging.clj though

20:13 mattrepl: that seems best to me, I'm not sure why one would be opposed to shipping logging.clj

20:15 mebaran151: (ns com.bebop.appledelhi2) even a simple ns declaration like this seems to make the repl increment that same error

20:18 defn: optimizer: emacs for sure. you can make a mock repl with vim, but it just ain't the same

20:18 optimizer: textmate has a clojure bundle, but its indentation and highlighting isnt great, and it doesnt have paredit

20:18 optimizer: does clojure by any chacne have it's own editor in clojure?

20:18 that'd be really cool

20:18 defn: emacs + paredit + swank-clojure = win

20:19 optimizer: i dont know of any clojure editors written in clojure, but clojure is a lisp, and emacs is elisp

20:19 so it's closer than say, vim

20:19 mebaran151: optimizer, mocking a basic ide in clojure is on my todo list actually

20:23 chouser: there have been a few

20:24 waterfront is the most complete, I believe.

20:40 defn: random question: anyone here familiar with the google search appliance?

20:41 optimizer: does it run clojure?

20:43 defn: optimizer: lol no -- im just curious what kind of protection they have to protect their algorithms

20:46 optimizer: i hear that if you try to open the box; it triggers a nuclear explosion

20:47 chouser: that should do it

20:47 optimizer: isn't page rank; along with techniques to speed it up fairly well known?

20:47 i've always felt the power of google is there ability to deal with hard distriuted systems problems

20:48 and retaining smart engineers

20:50 defn: optimizer: some of it is well known, but i dont believe the subtle tuning they do is common knowledge

20:51 otherwise there wouldnt be an entire SEO industry that popped up overnight

20:51 optimizer: i can't iagine any of that in google search appliance

20:51 it's supposed to be able to deal with documents

20:51 which are likely not liked

20:51 and "honest", not "optimized"

20:52 alternatively, work @ google :-)

21:06 arohner: does paredit have a "comment s-expr" command?

21:06 just ";" doesn't do what I'd expect

21:08 the-kenny: arohner: Yes, mark the sexp and press M-;

21:09 arohner: the-kenny: thanks. I saw M-; but I was trying it with the cursor at the beginning, rather than marking it

21:21 lisppaste8: url

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

21:23 arohner pasted "deftype merge explosion" at http://paste.lisp.org/display/92759

21:23 arohner: ok, I just pasted but I don't see it...

21:24 * arohner pasted http://paste.lisp.org/display/92759

21:24 arohner: merge explodes on deftypes that implement IPersistentMap

Logging service provided by n01se.net