#clojure logs

2010-01-02

00:38technomancyit looks like the version number on master is still 1.1.0-master-SNAPSHOT
00:42devlinsftechnomancy: What should the master branch be? 1.2.0-alpha-snapshot?
00:43technomancydevlinsf: I suppose it will be changed to 1.2.0-master-SNAPSHOT once the "new" branch gets merged to master.
00:44devlinsfRight, no sense worry 'bout it until then
01:06replacaI love the fact that the "Common Lisp Quick Reference" is 52 pages long!
01:09technomancyreplaca: and the spec is longer than most scheme implementations. =)
01:10replacait's an amazing thing. Kind of reminds me of a muscle car
01:12technomancyI dunno, I get more of a Howl's Moving Castle vibe
01:13technomancyI think it comes from the way it bends over backwards to support VAX filesystems
01:13replacawell, in those days most Lisp programmers were working on non-unix file systems
01:14replacaTops-10 and Tenex were as significant as VMS
01:14technomancyI guess you kind of had to be there?
01:14replaca:-)
01:47replacatechnomancy: when I use :main in project.clj does it call (defn -main [] ...) in my namespace?
01:54_mstCL's pathnames were somewhat traumatising :)
04:54neotykHi, how do I generate documentation from my *.clj files?
04:54neotykand happy new year as well :)
06:35spuzI'm having trouble getting the clojure.test is macro working...
06:36lisppaste8spuz pasted "Test test" at http://paste.lisp.org/display/92910
06:37spuzanyone have any idea why I cannot import the is macro?
06:38spuzI'm running with the latest clojure.jar built from the master branch
06:40pjacksonspuz: try (:use [clojure.test :only (deftest- is)])
06:41spuzpjackson: nope, same problem
06:41spuz"java.lang.ClassNotFoundException: clojure.test (repl-1:3)"
06:49hoeckspuz: and when using `clojure.test/is' instead of `is'?
06:52spuzhoeck: I still get ClassNotFoundException on the import
06:53hoeckspuz: and when typing (use 'clojure.test) at the repl?
06:53spuzhoeck: that appears to work...
06:55spuzI don't understand why require doesn't work...
06:56hoeckspuz: require just loads the required namespace, but doesn't import any symbols
06:56hoeckso after requiring, you refer to `is' as clojure.test/is
06:56spuzhoeck: ok
06:57spuzso if I want to import the symbols, I need to use 'use'?
06:58hoeckcorrect
06:59hoeckand namespaces must have at least two elements, so its better to have my.test than just test
07:08woobyhello, i'm attempting to use file-seq and json-str to create a json object representing the file tree of a directory
07:08woobybut i'm not sure exactly what file-seq is handing me back, looks like a flat list of File objects
07:09woobyi haven't worked with trees in clojure yet and am a bit befuddled, any help greatly appreciated
07:12hoeckwooby: yes, file-seq returns a sequence of all nodes in a tree
07:12woobyoh i get it
07:13hoeckits defined on top of tree-seq
07:15hoeckif you want the structure of the directory, you can use java.io.File, esp. the .listFiles method
07:15woobygotcha
07:16woobyso the only reason file-seq is defined on top of tree-seq
07:16woobyis so it knows which types of nodes to list the contents of
07:16woobythank you, my mind has expanded a tiny bit
07:17hoeckwooby: right
07:29lisppaste8pjackson pasted "what is the difference?" at http://paste.lisp.org/display/92911
07:32hoeckpjackson: map is lazy
07:33pjacksonhoeck: ahhhh, of course. Just as the docs say. Thanks for looking.
07:33hoeckpjackson: doall is your friend then :)
07:34pjacksonTa
07:41spuz,(concat (butlast "hello") (last "hello"))
07:41clojurebotDon't know how to create ISeq from: java.lang.Character
07:41spuzhow can I make that expression work?
07:46hoeck,(concat (butlast "hello") (list (last "hello")))
07:46clojurebot(\h \e \l \l \o)
07:48spuzhoeck: ah, list thanks.
09:04dabdnewbie 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?
09:06dabdIt returns the error: #<CompilerException java.io.FileNotFoundException: /home/dabd/< (No such file or directory) (NO_SOURCE_FILE:0)>
09:07rhickey,(doc clojure.xml/parse)
09:07clojurebot"([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"
09:07rhickeydabd: "String naming a URI" is the key
09:08dabdrhickey: thx. I was looking for a way to parse directly from a string
09:09hiredman,(import '(java.io ByteArrayInputStream))
09:09clojurebotjava.io.ByteArrayInputStream
09:10hiredman,(-> "<?xml version='1.0'?><foo>hello></foo>" .getBytes ByteArrayInputStream. clojure.xml/parse)
09:10clojurebot{:tag :foo, :attrs nil, :content ["hello>"]}
09:11dabdhiredman: thx
11:51chouserrhickey: does the agent error handling proposal sound good still?
11:51chouseris there any reason to hold off implementing it? More input from clojure-dev first?
11:53chouserI mean any reason besides that I really should by writing English about Clojure instead of writng Clojure based on some English.
11:55rhickeyB2 looks ok - only pending decision is "default to :continue when a handler is provided" ?
11:57chouserthis morning, that doesn't sound like very much magic to me
11:57chousersounds handy
11:57rhickeyme too
11:58rhickeychouser: "is there any reason to hold off implementing it?" seems not - go for it!
12:44solussdkonr`: is http://onclojure.com/ yours?
12:45konr`solussd: nope
12:50noiditechnomancy, are there any plans for adding nailgun support to leiningen?
12:52hiredmanis nailgun up on clojars yet?
12:53hiredmanhttp://clojars.org/lein-nailgun
12:53hiredmanclojurebot needs a clojars search plugin
12:54the-kennyhiredman: I think noidi want to run leiningen inside a nailgun server, for faster startup etc.
12:54noidiyeah
12:54noidi2.7 seconds of overhead for test runs is way too much
12:55hiredmanmmm
12:55noidiusing nailgun it goes down to 0.15 s or so
12:55hiredmannoidi: you could just run your tests from a repl
12:55noidiI'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:56hiredmanleiningen + nailgun is going to have problems with that use
12:56noidiwhy is that?
12:57hiredmanI doubt it will reload your class or clj files with each run
12:57noidithe tests can be required with :reload-all
12:57hiredmanok
12:58noidiit'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:59hiredmanleiningen + nailgun + classloader craziness
13:03hiredmanbasically dynamic binding for classloaders
13:04hiredmanhmmm
13:19pjacksontechnomancy: clojure-test-mode fills a big gap for me; thanks.
13:24noidihow do other leiningen users run their unit tests?
13:25noidithe only reason I'm messing around with nailgun is that I find "lein test" too slow
13:25noidiif there's an easy workaround, I'd love to hear about it
13:38arohnerhas anyone gotten a debugger to work on JDK 6 in OSX?
13:39arohnerjswat 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:43spuzarohner: have you tried CCW?
13:43spuz~ccw
13:43clojurebotccw is http://github.com/laurentpetit/ccw
13:44spuzhttp://code.google.com/p/counterclockwise
13:44arohnerspuz: no, what it is it?
13:44arohnera plugin for an IDE?
13:44spuzyes, for Eclipse
13:44arohnerI'll check that out, thanks
13:53noidi[noid@thinkpad hello]$ time lein test
13:53noidireal 0m2.923s
13:54noidinoid@thinkpad hello]$ time lein ng-test
13:54noidireal 0m0.141s
14:20lisppaste8wooby pasted "resource.clj" at http://paste.lisp.org/display/92927
14:20woobytrying proxying for the first time, and running into an issue here... thanks in advance
14:22arohnerwooby: can you please annotate with the whole stacktrace?
14:22chouserwooby: your definition for 'childeren' will expand to something like (file-filter (.listFiles file))
14:23chouserwooby: I don't think java.io.FileFilter implements clojure.lang.IFn, so you won't be able to call it.
14:23chouserdid you perhaps want (.listFiles file file-filter)?
14:24woobychouser: sure did! thank you
14:25woobyalso, i had my .hidden logic backwards
14:27arohnerok, netbeans can set breakpoints correctly in clojure code, just not my own
14:27arohnerif I point netbeans at the source for clojure, contrib, or swank, breakpoints work correctly
14:27arohnerI point it at my own source tree, and it can't find the source
14:27arohnerand I'm not doing anything strange with my own source
14:27chouserhm. have you tried AOT-compiling your code?
14:28arohnerno
14:28arohnerbut I'm not pointing netbeans at the AOT versions of anything else
14:28arohneroh, but the AOT is in the classpath...
14:28arohnerthanks for the suggestion. I'll try it
14:28chouserjust a stab in the dark. hope it helps
14:34arohnerhrm, even if I have non-AOT code, I can set a breakpoint manually, by breaking on the ns$fo_1234.invoke()
14:34arohnernetbeans just can't find the source file
14:35arohneryup, after AOT, netbeans found the source
14:35arohnerchouser: thanks!
14:35neotykhiredman: can you describe what is to be done for clojars search plugin on bot integration side? I would love to give a try
15:06lisppaste8wooby pasted "resource.clj" at http://paste.lisp.org/display/92930
15:07woobyso the problem there with build-dir-tree is that it's including 'resources' as a key in the hash tree
15:07woobyso 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:07woobythank you as always in advance
15:57ordnungswidrighi all
16:16CalJunior1I have this in clojure: (def foo (Foo.))
16:17CalJunior1now how do I do this: foo.bar = something
16:20Spockz|lapthat smells like state... I'm not sure it can be done? (just reading in though)
16:22The-KennzSpockz|lap: Foo. is the syntax for calling a java-constructor
16:22The-KennzCalJunior1: set! imo wait
16:23The-KennzCalJunior1: Try (set! foo/bar something)
16:23The-Kennzhttp://clojure.org/java_interop#toc20
16:24Spockz|lapoh
16:24CalJunior1.(doc set!)
16:24The-Kennz,(doc set!)
16:24clojurebotTitim gan éirí ort.
16:24CalJunior1ah thanks
16:25CalJunior1uhm ...
16:27CalJunior1I get "no such namespace foo"
16:29The-Kennzhm.. try (set! (. foo bar) something) then (where foo is the object and bar the field
16:30CalJunior1success!
16:30CalJunior1thanks
16:30The-Kennz(.bar foo) should work too
16:31The-KennzYou're welcome
16:31ordnungswidrigwho knows why searching for "compojure" on clojars will not show "org.clojars.liebke/compojure" ?
16:31The-Kennzordnungswidrig: The search needs some work.. you can improve it ;)
16:31ordnungswidrigThe-Kennz: I'd love to.
16:32ordnungswidrigThe-Kennz: give me a hint
16:32The-Kennzordnungswidrig: http://github.com/ato/clojars-web/blob/master/src/clojars/search.clj
16:33ordnungswidrigThe-Kennz: As far as I can see ...liebke/compojure should be found, right? So it's an issue regarding index freshnes?
16:34The-Kennzordnungswidrig: hm.. looks so
16:38ordnungswidrigThe-Kennz: When you delete the documents from the index first in index-jar you're only taking into account "name" and "group"
16:38ordnungswidrigThe-Kennz: so there is only one version queriable?
16:38The-Kennzordnungswidrig: It's not my code, sorry :) It's ato's
16:38ordnungswidrigThe-Kennz: oh, ok.
16:39The-Kennz(I'm "the-kenny" on github ;))
16:39ordnungswidrigThe-Kennz: should have switched on brain first. sorry :) Is github issues the right place to report this?
16:40The-Kennzordnungswidrig: there's no other way for reporting issues mentioned - As far as ato isn't here, I would report it on github
16:43CalJunior1is 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:43CalJunior1does every field require a call to (set!)
16:44CalJunior1?
16:48The-KennzCalJunior1: There's doto, or you can build something with map
16:49The-Kennz(map #(set! (. %1 obj) %2) fields values)
16:49The-Kennzuhm.. (map #(set! (. obj %1) %2) fields values)
17:01CalJunior1 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:02The-Kennz(field1 field2) isn't a list. Clojure tries to call the function "field1". Use either [field1 field2] of (list field1 field2)
17:03CalJunior1of course
17:03The-KennzOhh forgot something
17:03The-Kennzmap *is* lazy
17:04ordnungswidrigbrb
17:04The-Kennztry wrapping the while map-stuff in an (doall
17:05ordnungswidrigre
17:11CalJunior1now have (doall (map #(set! (. obj %1) %2) [field1 field2] [value1 value2])) but get: unable to resolve symbol: field1 in this context.
17:12CalJunior1not sure what you mean by "while map"
17:15The-Kennzoh sorry, just ignore the while
17:15The-Kennzuhm.. you have to replace field1, value1 etc. with actual fields and values
17:16The-Kennzand I'm not even sure if it's possible to do it like this
17:16CalJunior1yes I did replace them with actual fields and values
17:17CalJunior1I'll give doto a spin. although I've only seen it used for calling methods rather than assigning values to fields.
17:25Chousuke. does not take a variable name
17:25Chousukeit takes an actual field name
17:25Chousukeso %1 or any variable will never work
17:32CalJunior1Chousuke: thanks. is there an elegant way to do this rather than have a (set! (. obj field) value) call for every field?
17:33Chousukeyou could write a macro for it.
17:33Chousuke(set-fields! obj field value field2 value2) etc.
17:35CalJunior1could this be done in a general way. so with a variable number of fields?
17:35Chousuke(defmacro set-fields [obj & fvs] `(do ~@(map (fn [[f v]] (list `set! f v)) (partition 2 fvs))))
17:35Chousukenot tested
17:35CalJunior1thanks
17:35Chousukehm.
17:36Chousukeactually taht doesn't work. I forgot the syntax for set.
17:37Chousuke(defmacro set-fields [obj & fvs] `(do ~@(map (fn [[f v]] (list `set! (list '. obj f) v)) (partition 2 fvs)))) that ought to work
17:40lisppaste8ska2342 pasted "Dynamically call def from the REPL" at http://paste.lisp.org/display/92935
17:40ska2342how would you dynamically create a few refs? I don't like the eval in my paste
17:41Chousukewhat for? can't you use a macro?
17:41arohneris there a way to get the "pointer" to an object?
17:41arohneri.e. a unique id
17:41ska2342I could even just type those two, but it's for demo purposes
17:42The-Kennzarohner: .hashCode on any java object?
17:42Chousukewell, eval is the only way to do defs dynamically at runtime
17:43Chousukebut most of the time that makes no sense anyway
17:43Chousukehow are you going to use those defs?
17:43The-Kennzarohner: (.hashMap [1 2 3])
17:43arohnerThe-Kennz: these could potentially be two different clojure maps with the same contents
17:43arohner,(.hashCode [1 2 3])
17:43clojurebot30817
17:43arohner,(.hashCode [1 2 3])
17:43clojurebot30817
17:44ska2342Chousuke: 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:44Chousukewell, you'll need either eval or a macro
17:44ChousukeI guess you might be able to simulate def using some java interop as well
17:44Chousukebut that's probably even uglier than eval :P
17:45arohnerChousuke: yeah, it would probably look like Compiler.eval(LispReader.read("(def a 1)"))
17:45arohner:-)
17:45ska2342Chousuke: I seem to remember doing sth like this with CL and without eval. Used intern at that time, IIRC. Anyway, thanks.
17:45The-Kennz,(.hashCode (vec (list 1 2 3)))
17:45clojurebot30817
17:46arohnerska2342: intern will work, but it's more limited than def
17:46ska2342arohner: didn't get intern to work.
17:47arohner,(intern (find-ns 'user) 'foo 42)
17:47clojurebotDENIED
17:47arohneranyways, that works for me
17:47ska2342back in a minute...
17:50ska2342arohner: I need to /create/ the symbol, it's not fix
17:51Chousukeska2342: intern creates vars
17:51Chousukeand it's a function, so you can just do (intern somens (symbol whatever) value)
17:53ska2342Chousuke: maybe lazyiness is killing me? The following works but not within a dotimes (intern (find-ns 'user) (symbol (str "refi" 99)) 99)
17:53Chousukedotimes is not lazy.
17:56lisppaste8ska2342 annotated #92935 "Without eval" at http://paste.lisp.org/display/92935#1
17:57ska2342Chousuke: Fine, found a way now. Can't say why I didn't find that earlier this day. Again, thanks.
18:07arohneraha! System/identityHashCode
18:07arohner(System/identityHashCode [1 2 3])
18:07arohner,(System/identityHashCode [1 2 3])
18:07clojurebot4467348
18:07arohner,(System/identityHashCode [1 2 3])
18:07clojurebot13419636
18:19mitkokHey, guys. Does anyone use vimclojure ?
18:23ordnungswidrighow can I return a list from a #() ?
18:23Chousuke#(list whatever)?
18:24ordnungswidrigChousuke: doh
18:30arohnerordnungswidrig: for extra credit: #(identity '(1 2 3))
18:30arohnerI use that with vectors
18:30arohner#(identity [1 2 3])
18:32Chousuke(fn [] [1 2 3]) fewer characters ;P
18:33technomancyyeah, any time you find yourself asking "how do I do $TASK with #()", the answer is usually "by not using #()"
18:35arohneryeah, but #(identity breaks the flow less than (fn [], for my eyes
18:35ikitatHow do you add a docstring to a let/lambda?: (def foo (let [...] (fn [] ...)))
18:36arohnerikitat: fns don't have metadata, and hence, docstrings, yet
18:36arohnervars and collections have metadata
18:37technomancy,(isa? clojure.lang.IMeta #())
18:37clojurebotfalse
18:38technomancysad but true
18:38technomancyis IMeta going to be implemented in terms of protocols eventually?
18:38arohnerI expect everything to be implemented in terms of protocols eventually
18:40technomancyand using protocols means that you can make final classes implement them, correct?
18:40technomancyso regexes can be callable?
18:41arohneryes, one of the goals of protocols is to make final classes participate in them
18:41arohneryou'd need a function to do that, I believe
18:41technomancy(10 :hours)
18:42technomancyarohner: not if callable is a protocol
18:42arohnertrue
18:42arohneryeah, if IFn is a protocol...
18:42technomancyright, that'd be the one
18:43technomancyI'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:44technomancygranted making numbers IFns probably doesn't
18:44technomancy...belong in core, but it's a neat idea
18:45arohneryeah, 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:45arohnerI've seen some broken-ass Rails code where two different libraries patched Integer in different ways. not fun.
18:46ikitatSo where does the docstring go on a defn?
18:46The-Kennzikitat: It's saved in the metadata of the symbol
18:46The-Kennz(meta (var +))
18:47The-Kennz,(meta (var +))
18:47clojurebot{: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:47arohnerit's saved in the metadata of the var
18:47arohnervar != symbol
18:47The-KennzYou're right, sorry
19:00neotyk technomancy: thanks for merge and push
19:05technomancyyeah, thanks for the patch
19:05technomancyI don't feel too thrilled about supporting domain-style groupIds, but that was definitely broken
19:09chouser(-> 2 hours ago)
19:13technomancyoh... nice compromise
19:14chouserit does take more space, with the () and -> instead of just dots
19:16technomancyanother crazy idea I had while driving the other day: derefing a namespace would give you a set of its vars. yes?
19:17Chousukethat sounds like a "just because I can" feature :/
19:17technomancyyeah, I guess you don't have an actual ns object that often
19:17chousertreating them as the mutable bag of values that they really are may not be desirable.
19:17Chousukenever 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:18replacatechnomancy: 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:20chouserif you use -jar, it ignores -cp
19:20chouser:-P
19:20replacaahh, is there a way to run the jar and not be completely standalone?
19:21chouserI think you have to include it on the classpath and then name the class whose "main" method you want to run.
19:21replaca(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:21replacaahh, ok
19:21replaca:(
19:21replacathx
19:22chouserthere may be other tricks. I don't know java all that well.
19:22technomancyyup, just an unfortunate property of the lousy java command-line launcher
19:23technomancybut that's why uberjars contain all their deps... they pretty much have to
19:23replacayeah, it just takes a long time when I'm rebuilding to do the uberjat each time
19:24technomancyreplaca: you know you can open jars in Emacs, right?
19:24technomancyand edit the clj files inside
19:24replacaI've also noticed that weird files get compiled to classes
19:24technomancydoesn't help with AOT, but still
19:24replacatechnomancy: that's just sick!
19:24technomancygood sick or bad sick? =)
19:24chouservim too
19:24ikitat(let [..] (defn foo "A reasonable way to document a closure?" [] ...))
19:24replacaI think bad sick, unless git can also work inside the jar
19:25technomancyyou'd have to unpack the jar over your git project tree
19:25replacayeah, a little scary
19:25technomancynot tricky or anything, but it would be easy to make a change and forget about it
19:25replacayeah, that's what I mean. Interesting though.
19:26technomancyit's awesome for just crazy experimenting, but it's not what you'd call a best practice
19:27replacathe 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:27replacaI don't understand what the compiler is doing since I reference a lot of other things from clojure.contrib
19:28technomancythat's wacky
19:28replacaAny thoughts?
19:28ikitatreplaca probably from closures running at compile time?
19:28replacaso my classes/ dir has two subdirectories: autodoc/ and clojure/ which is weird
19:29technomancyreplaca: actually it makes sense since examples/json.clj is not AOT'd in the contrib jar
19:29technomancyreplaca: compile will compile all the ns's dependencies that aren't already compiled
19:29replacaso AOT also AOTs any non-AOTed dependencies?
19:29replacaahh, ok, that makes sense
19:29technomancyright
19:30replacacool, thanks.
19:30chouserikitat: no, that's no good.
19:30technomancyI wonder if leiningen should have a mechanism for making sure your jar only includes .class files from your own project...
19:30ikitatjust from a style standpoint?
19:30ikitatit seems to work
19:30chouser(defn foo ...) makes a namespace-global, even though it looks from that structure like it would be local inside that 'let'
19:31replacatechnomancy: could be. I'm not sure I understand all the implications of carrying parts of other projects just by reference.
19:32replacabut I don't see why you'd want to. Might be tricky to figure out though.
19:32replacaThough I did see you scan for namespaces
19:33replacatechnomancy: on another subject, I've come to completely agree with you on (file ...) and (mkdir ...)
19:33ikitatchouser, 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:34replacaI was doing some work there last night and decided that (make-parents ...) and (file-str ...) are somewhhat flawed
19:35technomancyreplaca: actually leiningen doesn't scan for namespaces to compile anymore by default
19:35technomancyyou need to explicitly state which ones you want AOT'd
19:36technomancythough you can also set it to :all for the old behaviour
19:36replacaikitat: (let [...] (defn ...) (defn ...)) can be useful to give funcs some shared state
19:36technomancyyeah, make-parent seemed like an odd combination of cross-concerns
19:36neotyktechnomancy: regarding replaca -cp -jar question, manifest can containclass-path entries to lib/*
19:36ikitatreplaca, with the added bonus of adding docstrings to a closure
19:37replacaikitat: if you want the closure to be globally named, yeah
19:40neotykhow do I (doc ns)?
19:41neotyk,(doc clojure.contrib.gen-html-docs)
19:41clojurebotjava.lang.ClassNotFoundException: clojure.contrib.gen-html-docs
19:46technomancy,(doc (the-ns 'clojure.contrib.gen-html-docs))
19:46clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
19:46technomancy,(:doc (meta (the-ns 'clojure.set)))
19:46clojurebotnil
19:47technomancy,(:doc (meta (the-ns 'clojure.core)))
19:47clojurebot"Fundamental library of the Clojure language"
19:48neotykthanks
19:48replaca,(doc clojure.core)
19:48clojurebotjava.lang.ClassNotFoundException: clojure.core
19:49replacaseems like that should work
19:50neotyk,((:doc (meta (the-ns 'clojure.contrib.gen-html-docs)))
19:50clojurebotEOF while reading
19:50neotyk,(:doc (meta (the-ns 'clojure.contrib.gen-html-docs)))
19:50clojurebotjava.lang.Exception: No namespace: clojure.contrib.gen-html-docs found
19:51technomancyneotyk: it'll need to be required first; not sure if clojurebot has all that stuff on its classpath
19:52neotykroger
19:53neotykslime in emacs is best repl ever
19:57hamzaguys, 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:06chouserhm, it's got a byte-array ctor
20:25chouser,(use '[clojure.contrib.seq-utils :only [partition-all]])
20:25clojurebotnil
20:25chouser,(BigInteger. (byte-array (for [bitseq (partition-all 8 [1 0 1 1])] (byte (apply + (map bit-shift-left (reverse bitseq) (range 0 8)))))))
20:25clojurebotjava.lang.Exception: Unable to resolve symbol: byte-array in this context
20:25chouserhmph. in 1.1, that returns 11
20:32chouser,((fn bit-int [bitseq] (apply + (map bit-shift-left (reverse bitseq) (iterate inc 0)))) [1 0 1 1])
20:32clojurebot11
20:34hamzachouser: thanks a lot.
20:40chouserthat's one of the very few times I've used reverse in Clojure
20:41optimizeris anyone here using clojure on xmonad; and running into swing/awt/gui problems?
20:43replacachouser: compared to cl/scheme where you use reverse all the time
20:43optimizerafter building clojure, how do I get a '/usr/bin/clojure' that runs cloujure?
20:43optimizeri don't wnat to type java -cp .... clojure.main
20:43technomancyoptimizer: =(
20:44chouserreplaca: right, which is why I mentioned it. Clojure's vectors building on the right almost completely remove the need for reverse.
20:44replacaoptimizer: it seems that others have had probs with xmonad, too.
20:44optimizerwhoa, am i being stalked across channels?
20:44chouseroh, and lazy seqs that sorta build to the right also
20:45hamzaoptimizer: http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Shebang_Scripting_in_Clojure
20:45optimizerhamza: nice; thanks
20:55optimizerhttp://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Shebang_Scripting_in_Clojure <-- i don't understand how this works
20:55optimizeris there something easier
20:57optimizerwoot, i have something better
20:57optimizer:-)
20:58replacaoptimizer: github.com/jochu/clojure-extra
20:58replacahas a shell script to run clojure with customization
20:58replacagives you both a repl and can run scripts
20:59pjacksonDid that hurt?
20:59replacapjackson: ?
20:59pjackson"optimizer QUIT"
21:00replacaoh, I have quits blocked :-)
21:02pjacksonSounds like you're in denial.
21:02replacawhenever possible
21:06polypusis there something like (index-of :bar [:foo :bar]) -> 1
21:08polypus~ping
21:08clojurebotPONG!
21:09chouser,(.indexOf [:foo :bar] :bar)
21:09clojurebot1
21:10polypusahh, ty, not a java hacker. i guess that's idiomatic?
21:10polypusin clojure i mean
21:11kcompt,(.indexOf [:foo :bar] :bar)
21:11clojurebot1
21:11kcomptjust testing/learning
21:11replacapolypus: I think the rule in Clojure is: "If chouser says it, it's idiomatic." :-)
21:11polypus:)
21:13polypus,(.indexOf [:foo :bar] :dog)
21:13clojurebot-1
21:13polypussee a nice clojure function would return nil here
21:14_mstdo the java interfaces come with any guarantee? I'd be nervous I was relying on an implementation detail for that sort of interop
21:18polypus_mst: i have a feeling .indexOf is probably as likely to changeas anything in the core clojure api
21:18polypuschange as*
21:18_mstyeah, that's probably true
21:25chouser.indexOf is unlikely to go away -- it's defined by the Java Collection interface
21:25chouserwhich is also why it returns -1 instead of nil
21:26chouserI 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_mstis it? I couldn't see it here: http://java.sun.com/javase/6/docs/api/java/util/Collections.html
21:27_mstthe clojure docs do explicitly mention implementing the Collections interface, so I'd be comfortable calling any of those, yeah
21:36chouserhmph
21:37chouser_mst: that's what I get for reciting "facts" from memory
21:37_mstsorry to be so pedantic :)
21:38chouserjava.util.List
21:52timothypratleyI'm trying to run the contrib tests and it fails on test_datalog - am I using the wrong branch or something?
22:08chousertimothypratley: clojure master and contrib master test out fine for me.
22:08timothypratleyhmmm thanks must be something I'm doing wrong.
22:09chousercontrib builds ok but fails on "ant test_contrib"?
22:09polypuschouser: 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:10devlinsfpolypus: There's such a thing in contrib
22:10polypusdevlinfs: ty. in seq-utils?
22:10devlinsfindexof?
22:11devlinsfYeah, it's a quick hack off of indexed
22:11polypusk i'l have a look
22:11devlinsf(filter (comp pred second) (indexed coll))
22:11devlinsfYou can take it from there
22:13devlinsfActually, positions will do the job entirely