#clojure log - Jan 02 2010

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

0:38 technomancy: it looks like the version number on master is still 1.1.0-master-SNAPSHOT

0:41 * technomancy just added the 1.1.x branch to build.clojure.org, so 1.1.0 is available from that repo now

0:42 devlinsf: technomancy: What should the master branch be? 1.2.0-alpha-snapshot?

0:43 technomancy: devlinsf: I suppose it will be changed to 1.2.0-master-SNAPSHOT once the "new" branch gets merged to master.

0:44 devlinsf: Right, no sense worry 'bout it until then

1:06 replaca: I love the fact that the "Common Lisp Quick Reference" is 52 pages long!

1:09 technomancy: replaca: and the spec is longer than most scheme implementations. =)

1:10 replaca: it's an amazing thing. Kind of reminds me of a muscle car

1:12 technomancy: I dunno, I get more of a Howl's Moving Castle vibe

1:13 I think it comes from the way it bends over backwards to support VAX filesystems

1:13 replaca: well, in those days most Lisp programmers were working on non-unix file systems

1:14 Tops-10 and Tenex were as significant as VMS

1:14 technomancy: I guess you kind of had to be there?

1:14 replaca: :-)

1:47 technomancy: when I use :main in project.clj does it call (defn -main [] ...) in my namespace?

1:54 _mst: CL's pathnames were somewhat traumatising :)

4:54 neotyk: Hi, how do I generate documentation from my *.clj files?

4:54 and happy new year as well :)

6:35 spuz: I'm having trouble getting the clojure.test is macro working...

6:36 lisppaste8: spuz pasted "Test test" at http://paste.lisp.org/display/92910

6:37 spuz: anyone have any idea why I cannot import the is macro?

6:38 I'm running with the latest clojure.jar built from the master branch

6:40 pjackson: spuz: try (:use [clojure.test :only (deftest- is)])

6:41 spuz: pjackson: nope, same problem

6:41 "java.lang.ClassNotFoundException: clojure.test (repl-1:3)"

6:49 hoeck: spuz: and when using `clojure.test/is' instead of `is'?

6:52 spuz: hoeck: I still get ClassNotFoundException on the import

6:53 hoeck: spuz: and when typing (use 'clojure.test) at the repl?

6:53 spuz: hoeck: that appears to work...

6:55 I don't understand why require doesn't work...

6:56 hoeck: spuz: require just loads the required namespace, but doesn't import any symbols

6:56 so after requiring, you refer to `is' as clojure.test/is

6:56 spuz: hoeck: ok

6:57 so if I want to import the symbols, I need to use 'use'?

6:58 hoeck: correct

6:59 and namespaces must have at least two elements, so its better to have my.test than just test

7:08 wooby: hello, i'm attempting to use file-seq and json-str to create a json object representing the file tree of a directory

7:08 but i'm not sure exactly what file-seq is handing me back, looks like a flat list of File objects

7:09 i haven't worked with trees in clojure yet and am a bit befuddled, any help greatly appreciated

7:12 hoeck: wooby: yes, file-seq returns a sequence of all nodes in a tree

7:12 wooby: oh i get it

7:13 hoeck: its defined on top of tree-seq

7:15 if you want the structure of the directory, you can use java.io.File, esp. the .listFiles method

7:15 wooby: gotcha

7:16 so the only reason file-seq is defined on top of tree-seq

7:16 is so it knows which types of nodes to list the contents of

7:16 thank you, my mind has expanded a tiny bit

7:17 hoeck: wooby: right

7:29 lisppaste8: pjackson pasted "what is the difference?" at http://paste.lisp.org/display/92911

7:32 hoeck: pjackson: map is lazy

7:33 pjackson: hoeck: ahhhh, of course. Just as the docs say. Thanks for looking.

7:33 hoeck: pjackson: doall is your friend then :)

7:34 pjackson: Ta

7:41 spuz: ,(concat (butlast "hello") (last "hello"))

7:41 clojurebot: Don't know how to create ISeq from: java.lang.Character

7:41 spuz: how can I make that expression work?

7:46 hoeck: ,(concat (butlast "hello") (list (last "hello")))

7:46 clojurebot: (\h \e \l \l \o)

7:48 spuz: hoeck: ah, list thanks.

9:04 dabd: newbie question: why does (clojure.zip/xml-zip (clojure.xml/parse "<?xml version='1.0'?><foo>hello></foo>")) fail if the documentation for clojure.xml/parse states that it accepts a string?

9:06 It returns the error: #<CompilerException java.io.FileNotFoundException: /home/dabd/< (No such file or directory) (NO_SOURCE_FILE:0)>

9:07 rhickey: ,(doc clojure.xml/parse)

9:07 clojurebot: "([s] [s startparse]); Parses and loads the source s, which can be a File, InputStream or String naming a URI. Returns a tree of the xml/element struct-map, which has the keys :tag, :attrs, and :content. and accessor fns tag, attrs, and content. Other parsers can be supplied by passing startparse, a fn taking a source and a ContentHandler and returning a parser"

9:07 rhickey: dabd: "String naming a URI" is the key

9:08 dabd: rhickey: thx. I was looking for a way to parse directly from a string

9:09 hiredman: ,(import '(java.io ByteArrayInputStream))

9:09 clojurebot: java.io.ByteArrayInputStream

9:10 hiredman: ,(-> "<?xml version='1.0'?><foo>hello></foo>" .getBytes ByteArrayInputStream. clojure.xml/parse)

9:10 clojurebot: {:tag :foo, :attrs nil, :content ["hello>"]}

9:11 dabd: hiredman: thx

11:51 chouser: rhickey: does the agent error handling proposal sound good still?

11:51 is there any reason to hold off implementing it? More input from clojure-dev first?

11:52 * rhickey rereads the wiki...

11:53 chouser: I mean any reason besides that I really should by writing English about Clojure instead of writng Clojure based on some English.

11:55 rhickey: B2 looks ok - only pending decision is "default to :continue when a handler is provided" ?

11:57 chouser: this morning, that doesn't sound like very much magic to me

11:57 sounds handy

11:57 rhickey: me too

11:58 chouser: "is there any reason to hold off implementing it?" seems not - go for it!

12:44 solussd: konr`: is http://onclojure.com/ yours?

12:45 konr`: solussd: nope

12:50 noidi: technomancy, are there any plans for adding nailgun support to leiningen?

12:52 hiredman: is nailgun up on clojars yet?

12:53 http://clojars.org/lein-nailgun

12:53 clojurebot needs a clojars search plugin

12:54 the-kenny: hiredman: I think noidi want to run leiningen inside a nailgun server, for faster startup etc.

12:54 noidi: yeah

12:54 2.7 seconds of overhead for test runs is way too much

12:55 hiredman: mmm

12:55 noidi: using nailgun it goes down to 0.15 s or so

12:55 hiredman: noidi: you could just run your tests from a repl

12:55 noidi: I'm hacking leiningen to use nailgun now, but I'm not familiar with the project so this can be considered a prototype at best :)

12:56 hiredman: leiningen + nailgun is going to have problems with that use

12:56 noidi: why is that?

12:57 hiredman: I doubt it will reload your class or clj files with each run

12:57 noidi: the tests can be required with :reload-all

12:57 hiredman: ok

12:58 noidi: it's not a perfect solution, since the code might depend on symbols that only exist in the running VM but not in the source code, but that problem exists even when running the tests from the repl

12:59 hiredman: leiningen + nailgun + classloader craziness

13:03 basically dynamic binding for classloaders

13:04 hmmm

13:19 pjackson: technomancy: clojure-test-mode fills a big gap for me; thanks.

13:24 noidi: how do other leiningen users run their unit tests?

13:25 the only reason I'm messing around with nailgun is that I find "lein test" too slow

13:25 if there's an easy workaround, I'd love to hear about it

13:38 arohner: has anyone gotten a debugger to work on JDK 6 in OSX?

13:39 jswat 4.5 doesn't display breakpoints or the current position in .clj files. netbeans 6.8 sort of works, but then I can't set breakpoints in my files, because they're "outside of any class"

13:43 spuz: arohner: have you tried CCW?

13:43 ~ccw

13:43 clojurebot: ccw is http://github.com/laurentpetit/ccw

13:44 spuz: http://code.google.com/p/counterclockwise

13:44 arohner: spuz: no, what it is it?

13:44 a plugin for an IDE?

13:44 spuz: yes, for Eclipse

13:44 arohner: I'll check that out, thanks

13:53 noidi: [noid@thinkpad hello]$ time lein test

13:53 real 0m2.923s

13:54 noid@thinkpad hello]$ time lein ng-test

13:54 real 0m0.141s

14:20 lisppaste8: wooby pasted "resource.clj" at http://paste.lisp.org/display/92927

14:20 wooby: trying proxying for the first time, and running into an issue here... thanks in advance

14:22 arohner: wooby: can you please annotate with the whole stacktrace?

14:22 chouser: wooby: your definition for 'childeren' will expand to something like (file-filter (.listFiles file))

14:23 wooby: I don't think java.io.FileFilter implements clojure.lang.IFn, so you won't be able to call it.

14:23 did you perhaps want (.listFiles file file-filter)?

14:24 wooby: chouser: sure did! thank you

14:25 also, i had my .hidden logic backwards

14:27 arohner: ok, netbeans can set breakpoints correctly in clojure code, just not my own

14:27 if I point netbeans at the source for clojure, contrib, or swank, breakpoints work correctly

14:27 I point it at my own source tree, and it can't find the source

14:27 and I'm not doing anything strange with my own source

14:27 chouser: hm. have you tried AOT-compiling your code?

14:28 arohner: no

14:28 but I'm not pointing netbeans at the AOT versions of anything else

14:28 oh, but the AOT is in the classpath...

14:28 thanks for the suggestion. I'll try it

14:28 chouser: just a stab in the dark. hope it helps

14:34 arohner: hrm, even if I have non-AOT code, I can set a breakpoint manually, by breaking on the ns$fo_1234.invoke()

14:34 netbeans just can't find the source file

14:35 yup, after AOT, netbeans found the source

14:35 chouser: thanks!

14:35 neotyk: hiredman: can you describe what is to be done for clojars search plugin on bot integration side? I would love to give a try

15:06 lisppaste8: wooby pasted "resource.clj" at http://paste.lisp.org/display/92930

15:07 wooby: so the problem there with build-dir-tree is that it's including 'resources' as a key in the hash tree

15:07 so i very cheesily wrap it with dir-tree to tease out the files inside, is there a better way to do something like this? seems non-good but i can't figure out another way

15:07 thank you as always in advance

15:57 ordnungswidrig: hi all

16:16 CalJunior1: I have this in clojure: (def foo (Foo.))

16:17 now how do I do this: foo.bar = something

16:20 Spockz|lap: that smells like state... I'm not sure it can be done? (just reading in though)

16:22 The-Kennz: Spockz|lap: Foo. is the syntax for calling a java-constructor

16:22 CalJunior1: set! imo wait

16:23 CalJunior1: Try (set! foo/bar something)

16:23 http://clojure.org/java_interop#toc20

16:24 Spockz|lap: oh

16:24 CalJunior1: .(doc set!)

16:24 The-Kennz: ,(doc set!)

16:24 clojurebot: Titim gan éirí ort.

16:24 CalJunior1: ah thanks

16:25 uhm ...

16:27 I get "no such namespace foo"

16:29 The-Kennz: hm.. try (set! (. foo bar) something) then (where foo is the object and bar the field

16:30 CalJunior1: success!

16:30 thanks

16:30 The-Kennz: (.bar foo) should work too

16:31 You're welcome

16:31 ordnungswidrig: who knows why searching for "compojure" on clojars will not show "org.clojars.liebke/compojure" ?

16:31 The-Kennz: ordnungswidrig: The search needs some work.. you can improve it ;)

16:31 ordnungswidrig: The-Kennz: I'd love to.

16:32 The-Kennz: give me a hint

16:32 The-Kennz: ordnungswidrig: http://github.com/ato/clojars-web/blob/master/src/clojars/search.clj

16:33 ordnungswidrig: The-Kennz: As far as I can see ...liebke/compojure should be found, right? So it's an issue regarding index freshnes?

16:34 The-Kennz: ordnungswidrig: hm.. looks so

16:38 ordnungswidrig: The-Kennz: When you delete the documents from the index first in index-jar you're only taking into account "name" and "group"

16:38 The-Kennz: so there is only one version queriable?

16:38 The-Kennz: ordnungswidrig: It's not my code, sorry :) It's ato's

16:38 ordnungswidrig: The-Kennz: oh, ok.

16:39 The-Kennz: (I'm "the-kenny" on github ;))

16:39 ordnungswidrig: The-Kennz: should have switched on brain first. sorry :) Is github issues the right place to report this?

16:40 The-Kennz: ordnungswidrig: there's no other way for reporting issues mentioned - As far as ato isn't here, I would report it on github

16:43 CalJunior1: is there a way to set a bunch of instance fields in one go. for example (set! (. foo bar blah blegh) 1 2 3) doesn't seem to be valid.

16:43 does every field require a call to (set!)

16:44 ?

16:48 The-Kennz: CalJunior1: There's doto, or you can build something with map

16:49 (map #(set! (. %1 obj) %2) fields values)

16:49 uhm.. (map #(set! (. obj %1) %2) fields values)

17:01 CalJunior1: The-Kennz: so this would be (map irc://irc.freenode.net/#(set! (. obj %1) %2) (field1 field 2) (value1 value2))? it's not working for me.

17:02 The-Kennz: (field1 field2) isn't a list. Clojure tries to call the function "field1". Use either [field1 field2] of (list field1 field2)

17:03 CalJunior1: of course

17:03 The-Kennz: Ohh forgot something

17:03 map *is* lazy

17:04 ordnungswidrig: brb

17:04 The-Kennz: try wrapping the while map-stuff in an (doall

17:05 ordnungswidrig: re

17:11 CalJunior1: now have (doall (map #(set! (. obj %1) %2) [field1 field2] [value1 value2])) but get: unable to resolve symbol: field1 in this context.

17:12 not sure what you mean by "while map"

17:15 The-Kennz: oh sorry, just ignore the while

17:15 uhm.. you have to replace field1, value1 etc. with actual fields and values

17:16 and I'm not even sure if it's possible to do it like this

17:16 CalJunior1: yes I did replace them with actual fields and values

17:17 I'll give doto a spin. although I've only seen it used for calling methods rather than assigning values to fields.

17:25 Chousuke: . does not take a variable name

17:25 it takes an actual field name

17:25 so %1 or any variable will never work

17:32 CalJunior1: Chousuke: thanks. is there an elegant way to do this rather than have a (set! (. obj field) value) call for every field?

17:33 Chousuke: you could write a macro for it.

17:33 (set-fields! obj field value field2 value2) etc.

17:35 CalJunior1: could this be done in a general way. so with a variable number of fields?

17:35 Chousuke: (defmacro set-fields [obj & fvs] `(do ~@(map (fn [[f v]] (list `set! f v)) (partition 2 fvs))))

17:35 not tested

17:35 CalJunior1: thanks

17:35 Chousuke: hm.

17:36 actually taht doesn't work. I forgot the syntax for set.

17:37 (defmacro set-fields [obj & fvs] `(do ~@(map (fn [[f v]] (list `set! (list '. obj f) v)) (partition 2 fvs)))) that ought to work

17:40 lisppaste8: ska2342 pasted "Dynamically call def from the REPL" at http://paste.lisp.org/display/92935

17:40 ska2342: how would you dynamically create a few refs? I don't like the eval in my paste

17:41 Chousuke: what for? can't you use a macro?

17:41 arohner: is there a way to get the "pointer" to an object?

17:41 i.e. a unique id

17:41 ska2342: I could even just type those two, but it's for demo purposes

17:42 The-Kennz: arohner: .hashCode on any java object?

17:42 Chousuke: well, eval is the only way to do defs dynamically at runtime

17:43 but most of the time that makes no sense anyway

17:43 how are you going to use those defs?

17:43 The-Kennz: arohner: (.hashMap [1 2 3])

17:43 arohner: The-Kennz: these could potentially be two different clojure maps with the same contents

17:43 ,(.hashCode [1 2 3])

17:43 clojurebot: 30817

17:43 arohner: ,(.hashCode [1 2 3])

17:43 clojurebot: 30817

17:44 ska2342: Chousuke: I know it's stupid. Don't worry, really, just to demo the capabilites. Didn't find a way w/o eval and wasn't lucky.

17:44 Chousuke: well, you'll need either eval or a macro

17:44 I guess you might be able to simulate def using some java interop as well

17:44 but that's probably even uglier than eval :P

17:45 arohner: Chousuke: yeah, it would probably look like Compiler.eval(LispReader.read("(def a 1)"))

17:45 :-)

17:45 ska2342: Chousuke: I seem to remember doing sth like this with CL and without eval. Used intern at that time, IIRC. Anyway, thanks.

17:45 The-Kennz: ,(.hashCode (vec (list 1 2 3)))

17:45 clojurebot: 30817

17:46 arohner: ska2342: intern will work, but it's more limited than def

17:46 ska2342: arohner: didn't get intern to work.

17:47 arohner: ,(intern (find-ns 'user) 'foo 42)

17:47 clojurebot: DENIED

17:47 arohner: anyways, that works for me

17:47 ska2342: back in a minute...

17:50 arohner: I need to /create/ the symbol, it's not fix

17:51 Chousuke: ska2342: intern creates vars

17:51 and it's a function, so you can just do (intern somens (symbol whatever) value)

17:53 ska2342: Chousuke: maybe lazyiness is killing me? The following works but not within a dotimes (intern (find-ns 'user) (symbol (str "refi" 99)) 99)

17:53 Chousuke: dotimes is not lazy.

17:56 lisppaste8: ska2342 annotated #92935 "Without eval" at http://paste.lisp.org/display/92935#1

17:57 ska2342: Chousuke: Fine, found a way now. Can't say why I didn't find that earlier this day. Again, thanks.

18:07 arohner: aha! System/identityHashCode

18:07 (System/identityHashCode [1 2 3])

18:07 ,(System/identityHashCode [1 2 3])

18:07 clojurebot: 4467348

18:07 arohner: ,(System/identityHashCode [1 2 3])

18:07 clojurebot: 13419636

18:19 mitkok: Hey, guys. Does anyone use vimclojure ?

18:23 ordnungswidrig: how can I return a list from a #() ?

18:23 Chousuke: #(list whatever)?

18:24 ordnungswidrig: Chousuke: doh

18:30 arohner: ordnungswidrig: for extra credit: #(identity '(1 2 3))

18:30 I use that with vectors

18:30 #(identity [1 2 3])

18:32 Chousuke: (fn [] [1 2 3]) fewer characters ;P

18:33 technomancy: yeah, any time you find yourself asking "how do I do $TASK with #()", the answer is usually "by not using #()"

18:35 arohner: yeah, but #(identity breaks the flow less than (fn [], for my eyes

18:35 ikitat: How do you add a docstring to a let/lambda?: (def foo (let [...] (fn [] ...)))

18:36 arohner: ikitat: fns don't have metadata, and hence, docstrings, yet

18:36 vars and collections have metadata

18:37 technomancy: ,(isa? clojure.lang.IMeta #())

18:37 clojurebot: false

18:38 technomancy: sad but true

18:38 is IMeta going to be implemented in terms of protocols eventually?

18:38 arohner: I expect everything to be implemented in terms of protocols eventually

18:40 technomancy: and using protocols means that you can make final classes implement them, correct?

18:40 so regexes can be callable?

18:40 * technomancy seems to remember reading that somewhere but can't recall where or attest to its accuracy

18:41 arohner: yes, one of the goals of protocols is to make final classes participate in them

18:41 * technomancy has a few crazy ideas for making numbers callable

18:41 arohner: you'd need a function to do that, I believe

18:41 technomancy: (10 :hours)

18:42 arohner: not if callable is a protocol

18:42 arohner: true

18:42 yeah, if IFn is a protocol...

18:42 technomancy: right, that'd be the one

18:43 I've always thought it's an inherent limitation of lisp that having the function first would make dynamic OOP tricks like 2.hours.ago impossible, but with protocols that's no longer true.

18:44 granted making numbers IFns probably doesn't

18:44 ...belong in core, but it's a neat idea

18:45 arohner: yeah, as long as it doesn't involve monkey patching Integer for everyone. though knowing rhickey's taste, he probably wouldn't make that possible

18:45 I've seen some broken-ass Rails code where two different libraries patched Integer in different ways. not fun.

18:46 ikitat: So where does the docstring go on a defn?

18:46 The-Kennz: ikitat: It's saved in the metadata of the symbol

18:46 (meta (var +))

18:47 ,(meta (var +))

18:47 clojurebot: {:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 654, :arglists ([] [x] [x y] [x y & more]), :inline-arities #{2}, :inline #<core$fn__4742 clojure.core$fn__4742@235085>, :doc "Returns the sum of nums. (+) returns 0."}

18:47 arohner: it's saved in the metadata of the var

18:47 var != symbol

18:47 The-Kennz: You're right, sorry

19:00 neotyk: technomancy: thanks for merge and push

19:05 technomancy: yeah, thanks for the patch

19:05 I don't feel too thrilled about supporting domain-style groupIds, but that was definitely broken

19:09 chouser: (-> 2 hours ago)

19:13 technomancy: oh... nice compromise

19:14 chouser: it does take more space, with the () and -> instead of just dots

19:16 technomancy: another crazy idea I had while driving the other day: derefing a namespace would give you a set of its vars. yes?

19:17 Chousuke: that sounds like a "just because I can" feature :/

19:17 technomancy: yeah, I guess you don't have an actual ns object that often

19:17 chouser: treating them as the mutable bag of values that they really are may not be desirable.

19:17 Chousuke: never a good thing to have too many of those. then you'll hit yourself when you realise you might want deref on namespaces to mean something more useful.

19:18 replaca: technomancy: how do I run a jar (not an uberjar) that I build with lein? I tried java -cp lib -jar autodoc.jar but that didn't seem to do it.

19:20 chouser: if you use -jar, it ignores -cp

19:20 :-P

19:20 replaca: ahh, is there a way to run the jar and not be completely standalone?

19:21 chouser: I think you have to include it on the classpath and then name the class whose "main" method you want to run.

19:21 replaca: (I guess I could specify the main func on the command line, but that kind of obviates the point of marking the main func)

19:21 ahh, ok

19:21 :(

19:21 thx

19:22 chouser: there may be other tricks. I don't know java all that well.

19:22 technomancy: yup, just an unfortunate property of the lousy java command-line launcher

19:23 but that's why uberjars contain all their deps... they pretty much have to

19:23 replaca: yeah, it just takes a long time when I'm rebuilding to do the uberjat each time

19:24 technomancy: replaca: you know you can open jars in Emacs, right?

19:24 and edit the clj files inside

19:24 replaca: I've also noticed that weird files get compiled to classes

19:24 technomancy: doesn't help with AOT, but still

19:24 replaca: technomancy: that's just sick!

19:24 technomancy: good sick or bad sick? =)

19:24 chouser: vim too

19:24 ikitat: (let [..] (defn foo "A reasonable way to document a closure?" [] ...))

19:24 replaca: I think bad sick, unless git can also work inside the jar

19:25 technomancy: you'd have to unpack the jar over your git project tree

19:25 replaca: yeah, a little scary

19:25 technomancy: not tricky or anything, but it would be easy to make a change and forget about it

19:25 replaca: yeah, that's what I mean. Interesting though.

19:26 technomancy: it's awesome for just crazy experimenting, but it's not what you'd call a best practice

19:27 replaca: the other thing I noticed is that I have a file that includes clojure.contrib.pprint.examples.json and that gets compiled into my classes directory (?!) rather than just referenced from c.c.jar

19:27 I don't understand what the compiler is doing since I reference a lot of other things from clojure.contrib

19:28 technomancy: that's wacky

19:28 replaca: Any thoughts?

19:28 ikitat: replaca probably from closures running at compile time?

19:28 replaca: so my classes/ dir has two subdirectories: autodoc/ and clojure/ which is weird

19:29 technomancy: replaca: actually it makes sense since examples/json.clj is not AOT'd in the contrib jar

19:29 replaca: compile will compile all the ns's dependencies that aren't already compiled

19:29 replaca: so AOT also AOTs any non-AOTed dependencies?

19:29 ahh, ok, that makes sense

19:29 technomancy: right

19:30 replaca: cool, thanks.

19:30 chouser: ikitat: no, that's no good.

19:30 technomancy: I wonder if leiningen should have a mechanism for making sure your jar only includes .class files from your own project...

19:30 ikitat: just from a style standpoint?

19:30 it seems to work

19:30 chouser: (defn foo ...) makes a namespace-global, even though it looks from that structure like it would be local inside that 'let'

19:31 replaca: technomancy: could be. I'm not sure I understand all the implications of carrying parts of other projects just by reference.

19:32 but I don't see why you'd want to. Might be tricky to figure out though.

19:32 Though I did see you scan for namespaces

19:33 technomancy: on another subject, I've come to completely agree with you on (file ...) and (mkdir ...)

19:33 ikitat: chouser, I am trying to define a function in my namespace named foo, but I want it to close over what is defined in the let

19:34 replaca: I was doing some work there last night and decided that (make-parents ...) and (file-str ...) are somewhhat flawed

19:35 technomancy: replaca: actually leiningen doesn't scan for namespaces to compile anymore by default

19:35 you need to explicitly state which ones you want AOT'd

19:36 though you can also set it to :all for the old behaviour

19:36 replaca: ikitat: (let [...] (defn ...) (defn ...)) can be useful to give funcs some shared state

19:36 technomancy: yeah, make-parent seemed like an odd combination of cross-concerns

19:36 neotyk: technomancy: regarding replaca -cp -jar question, manifest can containclass-path entries to lib/*

19:36 ikitat: replaca, with the added bonus of adding docstrings to a closure

19:37 replaca: ikitat: if you want the closure to be globally named, yeah

19:40 neotyk: how do I (doc ns)?

19:41 ,(doc clojure.contrib.gen-html-docs)

19:41 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.gen-html-docs

19:46 technomancy: ,(doc (the-ns 'clojure.contrib.gen-html-docs))

19:46 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol

19:46 technomancy: ,(:doc (meta (the-ns 'clojure.set)))

19:46 clojurebot: nil

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

19:47 clojurebot: "Fundamental library of the Clojure language"

19:48 neotyk: thanks

19:48 replaca: ,(doc clojure.core)

19:48 clojurebot: java.lang.ClassNotFoundException: clojure.core

19:49 replaca: seems like that should work

19:50 neotyk: ,((:doc (meta (the-ns 'clojure.contrib.gen-html-docs)))

19:50 clojurebot: EOF while reading

19:50 neotyk: ,(:doc (meta (the-ns 'clojure.contrib.gen-html-docs)))

19:50 clojurebot: java.lang.Exception: No namespace: clojure.contrib.gen-html-docs found

19:51 technomancy: neotyk: it'll need to be required first; not sure if clojurebot has all that stuff on its classpath

19:52 neotyk: roger

19:53 slime in emacs is best repl ever

19:57 hamza: guys, what would be an elegent way of turning a vector of bits [1 0 1 1] to a number, i am turning this in to string they create a BigInteger from it but it is kind of ugly?

20:06 chouser: hm, it's got a byte-array ctor

20:25 ,(use '[clojure.contrib.seq-utils :only [partition-all]])

20:25 clojurebot: nil

20:25 chouser: ,(BigInteger. (byte-array (for [bitseq (partition-all 8 [1 0 1 1])] (byte (apply + (map bit-shift-left (reverse bitseq) (range 0 8)))))))

20:25 clojurebot: java.lang.Exception: Unable to resolve symbol: byte-array in this context

20:25 chouser: hmph. in 1.1, that returns 11

20:32 ,((fn bit-int [bitseq] (apply + (map bit-shift-left (reverse bitseq) (iterate inc 0)))) [1 0 1 1])

20:32 clojurebot: 11

20:34 hamza: chouser: thanks a lot.

20:40 chouser: that's one of the very few times I've used reverse in Clojure

20:41 optimizer: is anyone here using clojure on xmonad; and running into swing/awt/gui problems?

20:43 replaca: chouser: compared to cl/scheme where you use reverse all the time

20:43 optimizer: after building clojure, how do I get a '/usr/bin/clojure' that runs cloujure?

20:43 i don't wnat to type java -cp .... clojure.main

20:43 technomancy: optimizer: =(

20:44 chouser: replaca: right, which is why I mentioned it. Clojure's vectors building on the right almost completely remove the need for reverse.

20:44 replaca: optimizer: it seems that others have had probs with xmonad, too.

20:44 optimizer: whoa, am i being stalked across channels?

20:44 chouser: oh, and lazy seqs that sorta build to the right also

20:45 hamza: optimizer: http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Shebang_Scripting_in_Clojure

20:45 optimizer: hamza: nice; thanks

20:55 http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Shebang_Scripting_in_Clojure <-- i don't understand how this works

20:55 is there something easier

20:57 woot, i have something better

20:57 :-)

20:58 replaca: optimizer: github.com/jochu/clojure-extra

20:58 has a shell script to run clojure with customization

20:58 gives you both a repl and can run scripts

20:59 pjackson: Did that hurt?

20:59 replaca: pjackson: ?

20:59 pjackson: "optimizer QUIT"

21:00 replaca: oh, I have quits blocked :-)

21:02 pjackson: Sounds like you're in denial.

21:02 replaca: whenever possible

21:06 polypus: is there something like (index-of :bar [:foo :bar]) -> 1

21:08 ~ping

21:08 clojurebot: PONG!

21:09 chouser: ,(.indexOf [:foo :bar] :bar)

21:09 clojurebot: 1

21:10 polypus: ahh, ty, not a java hacker. i guess that's idiomatic?

21:10 in clojure i mean

21:11 kcompt: ,(.indexOf [:foo :bar] :bar)

21:11 clojurebot: 1

21:11 kcompt: just testing/learning

21:11 replaca: polypus: I think the rule in Clojure is: "If chouser says it, it's idiomatic." :-)

21:11 polypus: :)

21:13 ,(.indexOf [:foo :bar] :dog)

21:13 clojurebot: -1

21:13 polypus: see a nice clojure function would return nil here

21:14 _mst: do the java interfaces come with any guarantee? I'd be nervous I was relying on an implementation detail for that sort of interop

21:18 polypus: _mst: i have a feeling .indexOf is probably as likely to changeas anything in the core clojure api

21:18 change as*

21:18 _mst: yeah, that's probably true

21:18 * devlinsf is now in love w/ protocols

21:25 chouser: .indexOf is unlikely to go away -- it's defined by the Java Collection interface

21:25 which is also why it returns -1 instead of nil

21:26 I wouldn't consier it particularly idiomatic, at least not common. On the other hand, it's succinct and gets the job done, so... *shrug*

21:26 _mst: is it? I couldn't see it here: http://java.sun.com/javase/6/docs/api/java/util/Collections.html

21:27 the clojure docs do explicitly mention implementing the Collections interface, so I'd be comfortable calling any of those, yeah

21:36 chouser: hmph

21:37 _mst: that's what I get for reciting "facts" from memory

21:37 _mst: sorry to be so pedantic :)

21:38 chouser: java.util.List

21:52 timothypratley: I'm trying to run the contrib tests and it fails on test_datalog - am I using the wrong branch or something?

22:08 chouser: timothypratley: clojure master and contrib master test out fine for me.

22:08 timothypratley: hmmm thanks must be something I'm doing wrong.

22:09 chouser: contrib builds ok but fails on "ant test_contrib"?

22:09 polypus: chouser: succinct until you want to start using it like so: (or (.indexOf [:foo :bar] x) 0) where a clojure fuction index-of would probably return nil when x was not in the collection, and you'd get the default 0. as it stands i have to check for the special case of -1 and it gets ugly

22:10 devlinsf: polypus: There's such a thing in contrib

22:10 polypus: devlinfs: ty. in seq-utils?

22:10 devlinsf: indexof?

22:11 Yeah, it's a quick hack off of indexed

22:11 polypus: k i'l have a look

22:11 devlinsf: (filter (comp pred second) (indexed coll))

22:11 You can take it from there

22:13 Actually, positions will do the job entirely

Logging service provided by n01se.net