#clojure logs

2009-12-28

00:02KirinDaveCan it be done without adding a stack frame?
00:02leif-p,(reduce (fn [acc x] [x acc]) [] (reverse [1 2 3])) ;closer
00:02clojurebot[1 [2 [3 []]]]
00:03ozarusanHmmm, how about without reverse?
00:14leif-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
00:16_mst,((fn step [[x & xs]] (if xs (vector x (step xs)) [x])) [1 2 3 4])
00:16clojurebot[1 [2 [3 [4]]]]
00:16_msthm :/
00:23ozarusanstack overflow
00:29tolstoyIf 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"?
00:29tolstoyI thought macros left all argument unevaluated.
00:30tolstoyIf that's true, how to you reference a symbol in a macro? Hm. ~name? Just name?
00:31technomancytolstoy: something is not an argument to the macro
00:31technomancyerhm; never mind
00:32technomancytolstoy: depends on the body of foo.
00:32technomancywhat do you have so far?
00:32mitchellhtolstoy: Run a 'macroexpand on the macro to see what its generating
00:32tolstoyI don't want something to be evaluated.
00:32tolstoyOkay, I'll do that.
00:33mitchellhIf 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
00:33tolstoyI have something like: (defmacro defthing [name value] `(intern (symbol "ns") name (some-fn ~value)))
00:34tolstoyTo be used (defthing name (function or-value or-whatever)).
00:34tolstoyI guess I can just look at the source of def.
00:34tolstoy(This is sorta a dumb use case, but it's just to demo that such things are possible.)
00:35lisppaste8_mst pasted "[1 [2 [3 [4]]]]" at http://paste.lisp.org/display/92709
00:36technomancytolstoy: should work if you change it to (quote ~name)
00:37technomancysince intern is not a macro, it's going to eval its args
00:38tolstoyI keep getting an "unable to resolve symbol" in the line where I use the macro, rather than the usual test.clj:0.
00:40ozarusan,(dorun (step (range 1111111) identity))
00:40clojurebotjava.lang.Exception: Unable to resolve symbol: step in this context
00:40ozarusanjava.lang.StackOverflowError
00:42_mstguess my nested fns consume just as much stack :)
00:46tolstoyOk. I think it's the value part of what I'm doing, so that's a relief. Macros work like I expect them too.
01:11tolstoyInteresting. (def foo.bar "value") is okay.
01:12tolstoyBut foo.bar at the repl is looking for class.
01:12tolstoyI think I missed that in the literature somewhere.
01:14tolstoy" '.' has special meaning - it can be used one or more times in the middle of a symbol to designate a fully-qualified class name..."
01:38replacatechnomancy: do you know why slime/contrib isn't part of the elpa package?
01:52technomancyreplaca: elpa is a lot easier if each package is a single file
01:52technomancyin the interests of Getting Stuff Done I didn't feel up to the task of submitting each thing in contrib separately
01:52technomancythough there's no reason someone else couldn't do it
01:52technomancyI just haven't missed the rest of it much myself, so I haven't bothered
01:54replacatechnomancy: ok, I see
01:55replacatechnomancy: they should probably be coordinated, though, and relative position might enter into it
01:55technomancyreplaca: what in particular do you like from contrib?
01:55technomancythere's a lot of disjointed stuff in there
01:55technomancymuch like our own contrib. =)
01:55replacatechnomancy: fuzzy tabs
01:56unfo-is there a (nightly?) .jar distribution of clojure-contrib or do I need to compile it myself?
01:56replacatechnomancy: it's not a big deal - I got hte files myself the old fashioned way, but it just makes me nervous
01:57technomancyreplaca: if it's just a single file it's pretty easy to submit as its own package
01:57technomancyhttp://tromey.com/elpa/upload.html
01:58replacatechnomancy: 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/
01:58replacatechnomancy: what gives there?
01:59technomancyreplaca: so if you invoke it from proj/src/my/ns.clj then the default value it shows at the prompt is proj/src/?
02:00replacaI'm invoking it from proj/project.clj
02:00replacaThe (interactive ...) is explicitly adding src/
02:01technomancythat's strange; I can't reproduce it
02:01replacabut then lower down, it's trying to tack lib/, etc., on to that
02:01replaca1.0.1 is the latest?
02:01technomancymore or less
02:01replacaare you running 22 or 23?
02:02technomancyI've got one more bugfix before pushing out 1.0.2
02:02technomancy23
02:02replacahmm, me too
02:02technomancyso if you elisp-eval (locate-dominating-file default-directory "src") from project.clj, what do you get?
02:03replacathe src/ dir
02:03technomancythat must be a bug in Emacs
02:04technomancylocate-dominating-file should never return a path that's not an ancestor of its argument.
02:04technomancyif I'm understanding what you're saying correctly anyway
02:05replacabut src/ *is* it's argument and that's what it's returning. Or do you mean it should always go to arg/..?
02:07technomancyif you're invoking the function from proj/project.clj, then the default-directory argument should just be "proj/"
02:09replacayeah, but I think it looks *in* that directory for "src", cause it wants to return "src"
02:09replacaotherwise it will go up and up until it finds "src"
02:09technomancy"Stop at the first parent directory containing a file NAME, and return the directory."
02:10technomancyit doesn't want to return src, it wants to return the directory containing src.
02:10replacahmm, my doc is different: "Look up the directory hierarchy from file for a file matching regexp.
02:10replaca"
02:10technomancywhat version?
02:11replaca23.1. What are you?
02:11technomancy23.1.90.1
02:11technomancycompiled... yesterday?
02:11replacaHow do I get that long a version string?
02:11technomancythat's kind of a crappy thing to change in between point releases. =(
02:11technomancyM-x emacs-version
02:11replacayeah!
02:11replacaAh, 23.0.60.1
02:12replacaWhich was emacs-snapshot on Ubuntu whenever I pulled it
02:13technomancyoh, ok. so that's from before the actual release of 23
02:13technomancyit's a prerelease
02:13technomancyso in that case it's not unreasonable that they changed the behaviour
02:13replacaDo they do it where xx.1.xx is their first real release>
02:13replaca?
02:14technomancyyeah
02:14technomancyit's kind of idiosyncratic
02:15replacato say the least! Makes sense once you know it.
02:15replacaI'm kind of new to emacs. Didn't start with it until '85. :-)
02:16technomancyso back when the GNU implementation was what, a whole year old?
02:17replacasomething like that. ported it to 68k Unix system 5
02:17technomancynice!
02:18replacaI'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
02:19replacafinally giving in to elpa, maven, etc. since that all seems to be part of where we're going.
02:19replacabut there are a lot of moving parts!
02:20tolstoyClojure is moving toward maven?
02:20technomancytolstoy: maven as a repository format
02:20technomancynot necessarily maven the build tool
02:21technomancyreplaca: package.el definitely needs work
02:21tolstoyAh, phew. ;).
02:21technomancybut it makes life a lot easier both for users and maintainers
02:21technomancyeven more so once it gets integrated into Emacs proper
02:22replacatechnomancy: yeah, I love the idea. I hope it catches on with everyone.
02:23technomancyit's still in its infancy
02:24replacait's hard to teach an old dog new tricks.
02:24replacaThat's emacs's biggest prob
02:24replaca(CL, too)
02:24technomancyemacs' biggest problem is politics
02:25technomancythey want to limit package.el so it can only be used with packages for with the FSF owns the copyright
02:25replacawell, yeah, that's *why* it's hard to teach the old dog new tricks. The tech isn't too hard.
02:26replacahmmm, that's not very "open"
02:26technomancyit's impossible, of course
02:26technomancyjust wish more of the decisions could be made on technical merit
02:27replacaor user convenience
02:28replacabut when you deal with RMS, you're dealing with an ideologue. Not all bad, but sometimes annoying
02:30technomancyI 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.
02:30replacaagreed
02:36KirinDavetechnomancy: man the gpl is the second largest source of heartache in the programmer world.
02:36KirinDavetechnomancy: Shortly behind Microsoft.
02:37somniumis there anything equivalent to ruby's __FILE__ for .clj files?
02:39somniumhmm, I guess after compilation it wouldnt work even if it existed
02:49replacasomnium: well, if you know a function name, you can look on its metadata and find the file
02:51somniumreplaca: yeah, but when it gets jarred it'll break (for what I was thinking of)
02:52somniumreplaca: handy to know for the future though
02:52chouser*file* is relative to the classpath, I think.
03:04somniummaven/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
03:05somniumsome xml file I need to add? or make my own pom?
03:06replacasomnium: I think you might need to set a :src in project.clj, but I haven't walked that road yet
03:13somniumreplaca: 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
03:21piccolinoDoes anyone understand the new defprotocol/deftype stuff?
03:23piccolinoSpecifically, protocols appear to require you to have at least one argument for methods, but in deftype it appears you can leave out the argument...
03:28somniumpiccolino: 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)
03:28somniumalso see http://www.assembla.com/wiki/show/clojure/Datatypes (in particular reify)
03:28piccolinoYeah, I've been going over that page and the one on Protocols over and over for about half an hour.
03:28piccolinoI'm trying to define a protocol that has a method with two method signatures: one arg and two args.
03:29piccolinoThen 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.
03:31somniumtry: (defprotocol A (foo ([obj a] [obj a b]))) (deftype B [x] A (foo ([a] ...) ([a b] ...)))
03:32somniummight need to be (deftype ... A (foo [a] ()) (foo [a b] ()) if that doesnt work
03:34piccolinoHm, but I'm trying to have one of the foo functions not need an arg when you call it.
03:35replacasomnium: yeah, :source-path is what I was thinking of. But like I said, I haven't tried that yet
03:36replacaIs the pom broken or the jar?
03:37somniumreplaca: I think the pom, because I the jar ant produces is fine, bit the one clojars sends has that bloody "/main/" prefix
03:38somniumpiccolino: then (defprotocol ... (foo [obj])) and (deftype ... (foo [])) no?
03:38piccolinoOh yeah, but I want (foo ([obj] [obj a])).
03:39somniumpiccolino: you can always do extend-type or extend-protocol unless youre really after the porformance kick
03:39piccolinoI can do (deftype ... (foo [] ...)), but not (deftype (foo [a] ...))
03:39replacasomnium: hmm, out of my depth on that one, but I'm sure I'll be swimming in that pool pretty soon
03:40somniumpiccolino: for every arity on the protocol the arity within the deftype body should be one less
03:40piccolinosomnium: Yeah, that's what's not working for me.
03:41piccolinoIt gives me: error: java.lang.IllegalArgumentException: Can't define method not in interfaces:
03:41somniumpiccolino: btbh, I always used extend-protocol, ^^ was just my understanding
03:41somniumpiccolino: can you paste the protocol and the type?
03:42piccolinoSure
03:42somniumreplaca: and I was almost starting to like maven...
03:43piccolinohttp://gist.github.com/264592
03:43vu3rddHi folks: Trying to install slime/swank on a new Debian installation
03:44vu3rddIt works fine on another setup. But on this particular setup, I get te "connection refused error"
03:44vu3rddshown here: http://paste.lisp.org/display/92713
03:44vu3rddI get the *inferior-lisp* prompt but not the SLIME prompt
03:44vu3rddany idea what is wrong here?
03:45somniumpiccolino: what about (position ([] ...) ([newpos] (...))), same error?
03:45LauJensenvu3rdd: 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
03:47vu3rddLauJensen: yes, I saw your excellent screencast. I am not using the elpa. I prefer to install the packages manually
03:47LauJensenOk
03:47piccolinosomnium: I updated the gist.
03:48vu3rddLauJensen: Just wanted to say a big thanks for the earlier screencast too.
03:48LauJensenGlad you liked them :)
03:49vu3rddI had an earlier Ubuntu installation and another debian installation where I am using the setup.
03:49vu3rddI simply copied the files (swank-clojure, slime, clojure-mode) from there
03:50piccolinohttp://www.assembla.com/wiki/show/clojure/Protocols shows the overloaded protocol methods being written out twice in a deftype or reify.
03:51somniumpiccolino: hmm, I guess Im out of my depth
03:51piccolinoDoh.
03:51piccolinoWell thanks for the try.
06:48adityo~max people
06:48clojurebotmax people is 240
06:50vu3rddLauJensen: I figured out that my slime connection problem is because the swank is getting bound to a IPv6 port.
06:51vu3rddand slime is trying to connect to 127.0.0.1 which was an ipv4 address
06:51vu3rddvery strange
07:48noidiI can't seem to get "lein test" to work
07:49noidirunning it in a new project gives me: java.lang.Exception: No such var: clojure.test/successful?
07:50noidiand in the leiningen git version: org.apache.tools.ant.ExitException: Permission (java.lang.RuntimePermission exitVM) was not granted.
07:51noidiI thought it might be caused by OpenJDK, but switching to the Sun JDK didn't help
07:51noidiany idea what might be wrong?
07:54fliebelHey
07:56noidiokay, "lein test" seems to work in the "stable" git branch
08:00noidi"A build tool for Clojure designed to not set your hair on fire."
08:00noidithere's still some work left before that goal's met :)
08:40fliebelHow would I convert a file path to a relative path? Like: same dir = filename, parent dir = ../filename, etc.
08:50chopmofliebel: You mean convert an absolute path to a relative one? Why was it absolute in the first place?
08:52fliebelchopomo: 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.
08:52chopmofliebel: Doesn't sound impossible to me...do you know the absolute path of both files?
08:53fliebelchopomo: I do, but I'd have to generate a path for every file to every file.
08:54chopmofliebel: OK, I see. Not sure I understand your problem fully, but I found something on StackOverflow that might be relevant: http://bit.ly/1b1BO2
08:55fliebelchopomo: I'm writing a static site generator, I need the urls to work wherever the files are placed.
08:56fliebelon 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.
08:57chopmofliebel: As in <a href="../foo.html"> ?
08:57fliebelyea...
08:58fliebelthat would work wherever the files are
09:30chopmoIs there any way to unload a function definition using Emacs/Slime? When I move a function, I get "already defined" errors.
09:31chopmoMore 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.
09:48Chousukethere's ns-unmap
09:49fliebelwhat is the advantage of those unchecked functions? speed?
09:50unfo-yes. and the downside is possibly corrupt logic/data
09:51fliebelwhat does "subject to overflow" mean?
09:51chouserif the number gets too big or too small, it may wrap around
09:52chouserClojure's normal math functions are careful to avoid that
09:52fliebelhmm, that sounds like fun… :)
09:53unfo-fliebel, for example the sum of the first 100k numbers is: 5000050000; but if you use unchecked addition you get 705082704
09:53unfo-which is awfully wrong
09:53fliebelhaha
09:53unfo-(example from Programming Clojure, p. 91)
09:53unfo-good book so far :)
09:54unfo-my friend bought the ebook for me as an xmas present ^^
09:54unfo-but now for something completely different ->
09:54chopmoChousuke: Cool, thanks
10:25dabdI'm looking at the implementation of the fn 'keyword' http://github.com/richhickey/clojure/blob/6109d41a975bf24b17681342591116a9897e4a27/src/clj/clojure/core.clj#L386
10:26dabdand it calls intern which must accept at least two args but the implementation is calling with just one arg
10:26dabdfor the arity 1 case of course
10:27dabdcould this be a bug?
10:29the-kennyIt doesn't call intern, it calls the static method intern of clojure.lang.Keyword
10:30dabdthe-kenny: thx
10:31dabdif I call (keyword "abc") in which ns is the keyword interned?
10:32the-kennydabd: http://github.com/richhickey/clojure/blob/6109d41a975bf24b17681342591116a9897e4a27/src/jvm/clojure/lang/Keyword.java
10:36chouserthat is, the nil "namespace"
10:41dabdchouser: the keyword gets interned in the namespace named "nil"?
10:51samlcan I see what macro is? like, meaning of ' #' ...etc
10:51unfo-excuse me but wtf ^ that Keyword.java from line 92 -> :D
10:52chouserthere's actually just a single ConcurrentHashMap for interning all keywords
10:52unfo-couldn't you just make the last form the norm? the (Object arg1, Object arg2, Object... args)
10:53chouserthe 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:53chouserunfo-: performance! that's the signature of all Clojure fns.
10:54chousersaml: you can use macroexpand to see what any macro call expands to. I'm not sure if that's what you're asking.
10:54samlchouser, thanks
10:54unfo-chouser, oh.. never would've thought it was due to performance :D
10:54saml,(macroexpand ')
10:55clojurebotUnmatched delimiter: )
10:55chouserhm.. for reader macros, sometimes just quoting the form will show you what it becomes.
10:55chouser,''foo
10:55clojurebot(quote foo)
10:55the-kenny'#'
10:55the-kenny,'#'
10:55chouser,'#'foo
10:55clojurebotEOF while reading
10:55clojurebot(var foo)
10:57fliebelYou know… I was wondering why apply isn't a macro, (apply str ["hello " "world"]) could be transformed into (str "hello " "world")
10:57chouserfliebel: sometimes you want it to be a fn.
10:57chouser(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:57chouser,((partial apply str) ["hi " "world"])
10:57clojurebot"hi world"
10:58fliebelchouser: but that is true for all macros...
10:58chouserfliebel: exactly. yet another reason they should be avoided except when required.
10:58fliebelsometimes I wish the best of all macros: -> was a function.
10:59samlattr-map? is metadata macro thingy?
10:59samlin (doc defn)
10:59fliebelchouser: so why don't we write -> as some reduce magic? I did that a while back.
10:59chouser_fogus_: can I write my own reverse? :-P
11:00chouserfliebel: 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:00fliebelchouser: that would mean duplicating half the core...
11:01samlhow do you execute system commands and get stdout/err ? use java? or is there builtin library?
11:01fliebelsaml: 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:02clojurebot(4 3 2 1)
11:02_fogus_:-)
11:02chouser_fogus_: woo! constant time!
11:02chousersorta
11:02_fogus_sorta?
11:03samlhow do you navigate through library?
11:03fliebelsaml: You mean this? http://clojure.org/api
11:03samlhttp://richhickey.github.com/clojure-contrib/index.html ?
11:03chouserwell, 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:03samloh ok. so no way to do it in repl
11:04fliebelsaml: maybe with loaded-libs and doc
11:05fliebelHow 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:07bagucodeHello all
11:07fliebelhey
11:08bagucodeI got a classloader/dynamic code gen question :)
11:09chouser,((fn step [s] (when (seq s) (lazy-seq (list (first s) (step (rest s)))))) [1 2 3 4])
11:09clojurebot(1 (2 (3 (4 nil))))
11:09fliebelIs 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:09chousersaml: find-doc will search all loaded libs
11:09samloh coolz
11:10bagucodeI'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:10saml(use 'clojure.contrib.shell-out) fails for me
11:10konrIs Clojure metadata like CL's plist of a symbol?
11:11samloh darn I was doing (use 'clojure-contrib.shell-out)
11:12_fogus_chouser: step will blow the stack given some large sequence no?
11:13chouser_fogus_: nope
11:13chouser_fogus_: because it's wrapped in lazy-seq
11:15chouserbagucode: I think each expression at the repl is eval'ed with a new classloader
11:15dabdchouser: 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:15chouserbagucode: maybe try using (.getParent (clojure.lang.RT/baseLoader))
11:15chouserdabd: that's right.
11:15chouser,(namespace :foo)
11:15clojurebotnil
11:15chouser,(namespace ::foo)
11:15clojurebot"sandbox"
11:16chouser,(namespace :bar:foo)
11:16clojurebotnil
11:16chouser,(namespace :bar/foo)
11:16clojurebot"bar"
11:16chouserok, gotta do more vacuuming. guests tomorrow... :-)
11:17dabdI 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:20fliebelYou know what would be usefull? a ->-like macro that lets you fill in arguments in any position like anonymous functions.
11:23lpetitfliebel: this has been contributed to the ml recently, it was called -$>
11:27bagucodechouser: 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:37fliebellpetit: show me! :D
11:38chouserbagucode: doesn't sound completely insane... :-)
11:40lpetitfliebel: there it is : http://groups.google.com/group/clojure/browse_thread/thread/2cc0f1f1abe6e1de/c9f55d412d785580?lnk=gst&amp;q=Generalizing+-%3E+%26+-%3E%3E#c9f55d412d785580
11:40fliebelthanks :)
11:47yasonQ: was there a built-in function to enumerate a sequence? Something akin to Python's enumerate() ?
11:48fliebellpetit: Do you know where I can find the mentioned implementation of Andrew?
11:48chouseryason: seq-utils indexed
11:49lpetitfliebel: in the first message of the thread, I guess
11:49fliebelah, I read it wrong... I thought he was referring to another implementation.
11:51lpetitfliebel: the thread is pretty long, so maybe I missed something
11:52fliebellpetit: 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:52fliebeland maybe % is better than $ since that is already used in anonymous functions.
11:53devlinsf$ is also used in inner classes
11:53chouserfliebel: I would be surprised to see something like this in core
11:53chouserdoesn't mean it won't happen, of course.
11:54noidiyason, here's one way:
11:54noidi,(map vector [:foo :bar :baz] (iterate inc 0))
11:54clojurebot([:foo 0] [:bar 1] [:baz 2])
11:54fliebelchouser: but this could replace both -> and ->>!
11:54chouserfliebel: yes, with something uglier. ;-)
11:55lpetitchouser: I guess it has its place in contrib, though ?
11:55chousermuch lower bar to get into contrib. I would be a bit surprised if it *doesn't* show up there in some form.
11:56devlinsffliebel: I did some work in this area recently. It's easy for hofs, but a nightmare for a macro
11:56fliebeldevlinfs: how do you mean?
11:56devlinsfYou could assume a different sign, though... hmmm
11:56devlinsfWell, take partial for example
11:56devlinsfYou KNOW that the first argument must implement IFn
11:56devlinsfSo, what if the first argument is an integer?
11:56devlinsfYou could assume that the integer specifies the index to use
11:57devlinsfchouser: Now that I think of it, -?> might not be as ugly as you think
11:57fliebelchouser: I think using _ looks cool, like *here is an empty space, fill it in!*
11:57chouserdevlinsf: I'm thinking mainly of its usage. Ugliness of implementation is entirely insufficient to rule out a feature. :-)
11:58devlinsfchouser: (-?> idx value (normal-stuff...))
11:59samlhow can I see if a directory/file existis?
11:59chouserthe 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:59devlinsfHmmm... good point
11:59devlinsfData is rarely in the middle
12:00lpetitdevlinsf: -?> is an already taken symbol in c.c.core :-p
12:00chousersaml: (.exists (java.io.File. "/tmp"))
12:00yasonchouser: indexed sounds good, thanks
12:00devlinsfOH
12:00samlchouser, ah thanks. /me reads java interop
12:00yasonnoidi: something like I cooked up already except that iterate is more elegant :)
12:00devlinsflpetit: Thanks
12:00fliebelchouser: but something in a let is not mutable, so you can't thread, right?
12:01chouserfliebel: I don't see what any of these have to do with mutability.
12:01fliebelchouser: how would you use let to replace ->?
12:02chouser,(-> 2 (- 5) (- 10))
12:02clojurebot-13
12:02chouser,(->> 2 (- 5) (- 10))
12:02clojurebot7
12:02chouser,(let [n (- 2 5)] (- 10 n))
12:02clojurebot13
12:04fliebelah, I thought you where going to do some magic, like defining 2 in the let and then threading it through the rest.
12:09samldoes your emacs auto complete java code ?
12:09saml.nextInt ..etc
12:14devlinsfHey, how does one pronounce -> and ->> anyway?
12:15rhickeydevlinsf: I usually say 'thread' or 'pipe'
12:15rhickeyI prefer thread, and both are overloaded
12:15devlinsfOkay. So -> "First Thread" and ->> "Last Thread" would be good?
12:16rhickey->> is more like a pipe that ->, but both thread an rgument
12:16rhickeythread-first, thread-last
12:16noidiyason, http://richhickey.github.com/clojure-contrib/seq-utils-api.html#clojure.contrib.seq-utils/indexed
12:16devlinsfrhickey: Okay
12:16devlinsfthread-first & last it is
12:17noidioops, you got the answer already
12:17bagucodesaml: 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:17samlbagucode, thank you
12:18fliebelHow do I create those random names in a macro?
12:18chouser(gensym "random-name")
12:18chouser,(gensym "random-name")
12:18clojurebotrandom-name4858
12:18chouser,`random-name#
12:18clojurebotrandom-name__4859__auto__
12:18fliebelchouser: thanks
12:19noidihow can I see the full stack traces of exceptions? I mean the parts hidden by "... 40 more"
12:19bagucodeclojurebot: what is lisp-paste?
12:19clojurebotthis is not allegro
12:19bagucodehehe
12:19bagucodeAnyone got the paste link? Or know how to ask the bot?
12:20rhickeylisppaste8: url
12:20lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:20chousernoidi: usually that's a cue to skip up to the previously-printed cause.
12:20drewrnoidi: in slime? hit 1 until you get to the exception you want
12:20bagucoderhickey: thanks
12:21lisppaste8bagucode pasted "dynamic bytecode loading" at http://paste.lisp.org/display/92724
12:22bagucoderhickey: 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:23bagucoderhickey: I'm playing with clojure.asm and I don't know how the ClassLoader hieriarchy fits together
12:23rhickeybagucode: 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:24noidichouser, ok, thanks
12:24rhickeyIt's quite critical to asses whether anyone needs to see your classname directly, or only the names of interfaces it implements
12:24rhickeyideally, it will only be the latter
12:25fliebelWhere is # defined? I want to look how % is replaced by the value.
12:26the-kennyfliebel: I think it's a reader macro
12:26fliebelthe-kenny: I know that, but where are those defined? or is that geeky java stuff?
12:26bagucoderhickey: 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:27the-kennyfliebel: I think so. Somewhere in Reader.java
12:27fliebel:(
12:27devlinsfthe-kenny: LispReader.java
12:27bagucoderhickey: To the users of the native methods I mean
12:27fliebelthe-kenny: Is there a way I can turn an ordinary list into a # macro(and have the heavy lifting done for me)?
12:28the-kennyfliebel: I don't know, but you could use fn
12:29rhickeybagucode: why do you want to do this dtynamically>
12:29rhickey?
12:31fliebelthe-kenny: but than I end up with an undefined %
12:32the-kennyyeah, sure. % are special in #
12:32bagucoderhickey: 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:32bagucodeissues when playing with the repl. I want the generated classes visible to all clojure code that would want to use them.
12:32rhickeyfliebel: http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/LispReader.java
12:33rhickeybagucode: dynamically and max perf are in conflict
12:33fliebelrhichey: thanks :)
12:34bagucoderhickey: 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:34replacarhickey: lines # are easy: just go to the line and click. You addr bar will have the URL.
12:35chouser,(-> "devlinsf: -> is awesome" Exception. throw)
12:35clojurebotjava.lang.Exception: devlinsf: -> is awesome
12:36rhickeyreplaca: that's not working for me
12:36devlinsfchouser: Flattery will get you everywhere :)
12:36devlinsfOh.. oops read that wrong. Now I look dumb
12:36chouserdevlinsf: it's ok. I nearly wrote what you thought I did anyway. :-)
12:37bagucoderhickey: Also, to be more specific; "max performance" is just minimum overhead per call into native code
12:37devlinsfHmm... I think I'm going to use a temperature converter
12:37jweissi'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:38devlinsfchouser: Did you get my "same" message?
12:39rhickeybagucode: 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:40chouserjweiss: you have to convert to tail-recursive form first, which can be a bit tricky for tree-navigation cases like this.
12:40rhickeybagucode: you are better off generating stubs once and statically using them
12:40jweisschouser: i thought i did, but i still get the compile error that the recur has to be in tail position
12:41chouserjweiss: you might consider solving the deep-recursion problem using lazy seqs instead, perhaps with tree-sew
12:41chousertree-seq
12:41rhickeybagucode: just take your generated bytes and dump into classfiles
12:41lisppaste8jweiss pasted "untitled" at http://paste.lisp.org/display/92725
12:41chouserI have a nice writeup about tail position in the book. That is not yet available. :-(
12:42chouserah, interesting. 'doseq' always returns nil, so nothing you can put in it is in the tail position.
12:43jweisschouser: i'm not even sure whether recur can be used in a loop. can it?
12:43jweissi mean, calling recur to the top of the fn multiple times within the same fn call
12:44chouserjweiss: recur can be used in a 'loop', but not usefully in the body of a 'doseq' or 'for'.
12:44chousersure, you can have (if predicate (recur this-thing) (recur that-thing))
12:44jweisschouser: yeah, but it only will do one of those recurs, not both
12:45fliebelHow can I do something for every & value in a macro? like `(do (map #(str %) ~@value))
12:45chouserright. you can only put 'recur' where you the return value of the fn would go.
12:45jweisschouser: i see
12:45chouserfliebel: just ~value
12:46fliebelchouser: that evaluates the value, but I want to wrap every value in some other function.
12:47fliebelchouser: 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:47fliebelso more like (str ~@value) would result into (str value1) (str value2)
12:48bagucoderhickey: 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:54ericthorsenIs there a branch of clojure-contrib that is tracking the clojure new branch?
12:56rhickeyericthorsen: the latest contrib works with new and all tests pass
12:57ericthorsenrhickey: hmm...time to delete and start fresh
12:57rhickeyjust ant clean in contrib
13:01noiditechnomancy, 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:02noidiI'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:03noidiI was wondering if there's something wrong with my setup instead of leiningen
13:04replacarhickey: really? Did you click on the line number itself? On my system that's a link to itself.
13:05rhickeyreplaca: yes, that works in safari, but not in the Fluid app I've created for github. Thanks, I saw the #L1234 format
13:05technomancynoidi: looks like a bug from a recent patch someone submitted; thanks for letting me know.
13:08replacarhickey: 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:09noiditechnomancy, another issue I had was that "lein test" threw java.lang.Exception: No such var: clojure.test/successful?
13:10technomancynoidi: that would be from an outdated version of clojure
13:10noidithat happens with the version downloaded by "lein deps"
13:10technomancyI'll see if I can take a look later then.
13:12noidithanks
13:13noidiI "fixed" it by changing "successful?" on the last line of test.clj to "~''succesful?", but that seems like a kludge
13:14replacatechnomancy: do I need to add swank to my project.clj to get swank-clojure-project to work?
13:14the-kennyreplaca: Add it as a "dev-dependency"
13:15replacahmmm, that seems weird
13:15noidior maybe that's fine, I don't know, but the extra quote seems a bit weird to me :)
13:15replacathe-kenny: thanks
13:16the-kennyreplaca: It's included while developing but not when creating a jar etc.
13:17replacathe-kenny: yeah, but why should I need it there? swank ought to be separate from the project...
13:17replacathe-kenny: (that's really a rhetorical question by the way)
13:17the-kennyreplaca: But the jar needs to be loaded on the clojure side
13:18the-kennyreplaca: swank-clojure is split in two parts - a clojure part and an elisp part
13:18replacathe-kenny: yeah, I know that, but that reality doesn't need to be part of the project setup that leiningen does
13:19replacathe-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:19the-kennyreplaca: hm.. that's an argument
13:20replacathe-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:21the-kennyreplaca: You can always copy swank-clojure.jar to lib/ :)
13:21replacathe-kenny: that seems very 20th century :-)
13:22replacathe-kenny: slime knows where it is already since you can run slime without any special setup
13:24noidireplaca, but you need a version of swank that's compatible with the version of clojure that the project uses
13:24noidiwhich might not be the clojure version launched by M-x slime
13:25chouserfliebel: perhaps (let [xs [1.0 2.0 3.0]] `(+ ~@(for [x xs] `(int ~x))))
13:26fliebelchouser: maybe… I'll have a look at it
13:27fliebelIn the meanwhile It's complaining about this: `(let [value (atom ~value)]) I think it does not like defining user/value in a let :(
13:27fliebeljava.lang.Exception: Can't let qualified name: user/value
13:28chouserright. use value# instead
13:28Chousukefliebel: looks like you need a gensym
13:28replacanoidi: 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:29fliebelchousuke: but I need the generated thing later on, but then it returns a different one of course.
13:29Chousukefliebel: in another syntax-quote form? :/
13:29Chousukefliebel: then you need to use gensym directly
13:29fliebelchousuke: yea, I'm concatenating them :D
13:30Chousuke,(let [foo (gensym)] [`(bar ~foo) `(zonk ~foo)])
13:30clojurebot[(sandbox/bar G__4869) (sandbox/zonk G__4869)]
13:30fliebelhmmmm, that looks good
13:31replacaalso, 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:31replacabut I do understand the power of it
13:34fliebelchousuke: whoa, I got it working! but it's a mighty hack… different forms of quoting and unquoting all over the place…
13:35fliebelIt's like my own -$> but with %, quite hacky, but the whole purpose of a macro is hiding ugliness I guess...
13:35noiditechnomancy, 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:39fliebel(maze-thread 1 (inc %) (str "aap" % "noot")) => "aap2noot"
13:40chousernow you just need to support %2, %3, etc. where the number indicates how many forms back to look get the value to insert
13:41fliebelchouser: uuuhm, good idea… how? :D
13:41chouserack, no, a horrible idea!
13:41chouser:-)
13:42_fogus_so then would you have to use %-2 to look ahead?
13:42_fogus_I'm confused!
13:42fliebelmaybe you're right....
13:42chouserhehe
13:44fliebelHere it is: http://gist.github.com/264840
13:44chouseroh, that's not bad at all.
13:45chouseryou should use ` instead of ' in most of those cases.
13:45fliebelchouser: thanks :)
13:45fliebelchouser: ` causes more havoc than it solves I think.
13:45chouserit really doesn't.
13:46fliebelI'll try...
13:46chouseryours is non-hygenic. if someone were to have a local named 'atom' when they use your macro, things would break in exciting ways
13:46chouserusing `atom instead would avoid that.
13:46fliebelthat is true… one moment
13:48fliebelchouser: java.lang.Exception: Can't use qualified name as parameter: user/%
13:48fliebelI can't go on and use a gensym for that one...
13:49chousernope, '% is correct there
13:50fliebelthat turns into (quote user/%)
13:51fliebel~'% :D
13:51clojurebotaber sicher, fliebel!
13:52fliebelchouser: http://gist.github.com/264840
13:53fliebelI think it's quite clean indeed… if people understand ~'% :P
13:53chouser:-)
13:55fliebelSo 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:56chouserfliebel: an alternate implementation: (defmacro maze-thread [& xs] `(let [~'% ~@(interpose '% xs)] ~'%))
13:58fliebelchouser: that is one hell of an one-liner! :P It took me a while before I relaized how it works.
13:59Chousukefliebel: ~' is idiomatic clojure for "WARNING: evil macro trickery"
13:59Chousuke(sometimes evil macro trickery is necessary)
13:59fliebelhaha
14:00wooby1hello, would anyone happen to know if there's something like strtol in contrib?
14:01fliebelI do like chouser s implementation, that should end up in contrib somewhere…
14:01samlis it ok to (defn f [{a :a, b :b}] ..) forcing people to pass a map?
14:02chousersaml: for functions where it makes sense, sure.
14:03fliebelchouser: do you mind if I paste you thing in a (private) gist to have it handy when I need it?
14:03chouserfliebel: sure, go for it.
14:03chouserfliebel: actually, that accomplishes the same thing as one of the first clojure macros I ever wrote.
14:03chouserI wonder if I can find that somewhere.
14:04rhickeyfliebel: when do you need it? I see this get discussed often but rarely with compelling use cases
14:04samli want to write (checkout {:repo-url "http://github.com/project..&quot;, :to-dir "C:/home/repo" ..})
14:04fliebelI think it's cool to have a positioned thread, or whatever you call it :)
14:05chousersaml: 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:05chouserfliebel: Mine was named >>_, using _ as the insertion point. I used it maybe once or twice before abandoning it.
14:05samlchouser, thanks
14:06fliebelchouser: I thought about using _ because it looks cool, but I think % is more consistent with lambdas
14:08chouserah, there it is. at the bottom of the page: http://clojure-log.n01se.net/date/2008-04-14.html#22:58
14:10chouserso 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:11fliebelchouser: 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:14samlshould I prefer to use defstruct?
14:14samlthan to list or map?
14:14fliebelHow do things end up in contrib?
14:15chouserdefstruct is for memory and performance -- use it you need more of either, otherwise don't bother.
14:15samlah i see. i thought it's for making code clearer
14:15chouserfliebel: http://clojure.org/contributing
14:16chousersaml: well, there is that. I guess I haven't used it for that, but I know some people do.
14:17samlIn 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:18chousersaml: yes, that's not uncommon.
14:18samli should read more clojure code
14:21Chousukesaml: except it would be called *base-dir*
14:21samloh i see
14:22fliebelChousuke: Is that considered functional to do?
14:22fliebelI've been passing around vars like hell, defining them somewhere would make life easier I guess...
14:23Chousukewell, yeah.
14:23fliebelIs that a good idea or is that ruining what Clojure is all about?
14:24Chousukeif 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:24Chousukeif you use alter-var-root! a lot, then it's certainly not idiomatic :P
14:24fliebelnah, it's not going to change during one run of the applications, so I guess it all right.
14:25KirinDave1Man, people are coming up to me asking for clojure optimization tips. Like I effing know.
14:26KirinDave1And worst of all, 7/10 times it's basically a thinly veiled excuse to show off how slow they think java is. :\
14:26fliebelCan I def to another namespace? like (def blah/var "hello!")
14:26ChousukeI haven't actually tried that, but I don't think so.
14:27Chousukeyou can switch your namespace temporarily though.
14:27Chousukebut that's hacky.
14:27fliebelhmhm
14:28fliebelI 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:29Chousukeperhaps you could write an init function that takes a map of configuration values and uses alter-var-root! to set the vars?
14:29fliebelIf I do it the other way around, the core would be tightly coupled with the bootrstrapper.
14:29fliebelhmmm
14:30Chousukeit's side-effecty but as long as it's clearly advertised as such I don't think it's a problem :)
14:30fliebelhmmm
14:30fliebelI'll try
14:33fliebelHow would I use alter-var-root for that? don't know about it...
14:36Chousuke(def *something* nil) (alter-var-root! *something* "blah") ; *something* is set to "blah"
14:36Chousukehm
14:37Chousuke(constantly "blah") even
14:37Chousukesince it's alter
14:37Chousukeit takes a function that transforms the old value
15:03kotarakHi. Did anyone try to upload to Clojars via the ant scp task?
15:04kotarakIt works for my own server, but not for clojars.
15:05fliebel,(concat #{:a :b :c} #{:d :e}) ;How can I make something similar return a set?
15:05clojurebot(:a :c :b :d :e)
15:05kotarak,(into #{:a :b :c} #{:d :e})
15:05clojurebot#{:a :c :b :d :e}
15:05fliebelthanks
15:08rrc7czwhat 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:09samlwhen 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:09chouserrrc7cz: essentialy no difference.
15:09fliebelrrc7cz: nothing I guess
15:10kotaraksaml: (defn fn-in-other-module [] (binding [first-module/*a-constant* different-value] stuff-here))
15:10rrc7czbut from what I've read, "do"s were meant to warn of side effects. Why not force a do in this example?
15:10chouserfn's have implicit "do" for the body.
15:10rrc7czi see
15:11samlkotarak, oh coolz! thanks
15:11samloh wait. i need to do that for every function in the other module
15:11kotaraksaml: yep. And every thread.
15:12samlmaybe i need some sort of object. o = new MyObject(param1, param2); o.func1() o.func2()
15:13samlsince module isn't first class object in clojure
15:13samloh clojure lets me create my own object?
15:13samlin the end, i need to use defstruct i think
15:13kotaraksaml: defstruct does not define objects.
15:14kotarakAt least not in the java sense.
15:14kotarakYou'll need gen-class, but I doubt your approach won't end up ugly.
15:14kotarakMaybe you have an example what you are trying to do?
15:15saml(defstruct constants :base-dir :base-url) (defn f [x constants] ...) and in other module, (f 42 (struct constants "C:/home" "http://google.com&quot;))
15:16kotaraksaml: yeah, that looks more promising.
15:17unfo-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:18unfo-i.e. is # short-hand for something I could call explicitly with a param of (str "Hello my name is" name)
15:21unfo-ah nvm! found re-pattern in the api right next to re-find :)
15:23Chousuke#"foo" actually produces a Pattern object at compile-time (or read-time)
15:24Chousukeso it's not quite identical to re-pattern, but I guess it doesn't have to be for your use case. :)
15:24unfo-yeah, assumed as much since re-find works as well with re-pattern as with #""
15:24unfo-yeah. don't need to be identical. Good enough if it works :)
15:25unfo-1) make it work 2) revise what i've learned 3) make it pretty
15:26samlhow can I get user's home directory?
15:26samloh use java! hah
15:27saml(.. System (getProperty "user.home"))
15:28fliebelWhat is the correct looping function for looping over one sequence and appending to another?
15:28kotaraksaml: (System/getProperty "user.home")
15:28kotarakfliebel: reduce with vectors.
15:28samlkotarak, ah thanks.
15:28fliebelkotarak: thanks
15:29kotarak,(reduce (fn [v x] (conj v (inc x))) [] (list 1 2 3 4 5))
15:29clojurebot[2 3 4 5 6]
15:29noiditechnomancy, 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:31noiditechnomancy, if I comment out "(.setFailonerror java true)" in compile.clj:114, everything works
15:33saml(defstruct SomeCamelcase ...) this is not conventional naming, right? All I see is all (defstruct some-name-like-this ...)
15:34samlif I do (defstruct foo ..) (defn a-function [foo ;I'm not sure what to name the parameter. i'm expecting struct foo
15:34samlbut, I can do (defstruct Foo ... ) (defn a-function [foo] ...)
15:34Chousukeyou could name the struct base <foo> or something
15:35Chousukeor you could just not use a struct at all :)
15:35saml<oh-did-not-know-this-was-valid-name>
15:35Chousuke(just a plain map)
15:35Chousukesaml: most characters are valid in names
15:36samlah thanks Chousuke
15:37Chousuke,(let [フォー "this code is not very readable to most people"] フォー); I wonder if clojurebot uses UTF-8
15:37clojurebot"this code is not very readable to most people"
15:40kotarakChousuke: it does, it shows japanese here.
15:40samlcan slime or swank compile and load a toplevel def and all its dependencies?
15:40fliebelcool… I'm going to look up some weird names for my functions :D
15:40saml(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:40kotarakChousuke: ah sorry, the actually wasn't clojurebot. :P
15:41kotaraksaml: how should it know?
15:41Chousukekotarak: looks like it worked though.
15:42samlkotarak, repl should keep track of..... oh right
15:44fliebelHmm, I got some circular trouble...
15:45fliebelns1 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:46fliebelHow can I solve that?
15:47jneirammm with ns0?
15:48the-kennywith avoiding circular dependencies? :)
15:48fliebelhow?
15:48rrc7czis there a nicer way to drop-last than (reverse (rest (reverse [1 2 3])))?
15:49Chousukethere's butlast
15:49rrc7czperfect, thank you
15:50chouseralso drop-last and take-last.
15:52polypus~ping
15:52clojurebotPONG!
16:13fliebelWhy is the clojure wiki hanging on the session page four hours every time I load it?
16:22tolstoyIs there a nice solution for clojure for, say, XPathing through XML? (value-of "/foo/bar/baz") or something?
16:22the-kennytolstoy: there is something in contrib
16:22the-kennytolstoy: Called "zip-filter"
16:23tolstoyHm. Okay. I'll take a look.
16:24the-kennyI don't know about the performance, but it's almost like xpath and very cool
16:25the-kenny(Xpath with clojure-syntax)
16:26tolstoyThat does seem nice. I seemed to have missed that module when I last looked.
16:26tolstoyPerformance doesn't matter for me: I'd like to use it for unit testing a web service.
16:27the-kennyah ok
16:30tolstoyI'm glad I don't have to write some sort of tree walker. I mean, fun, I guess, but....
16:32the-kennyclojure.zip exists for editing and walking trees :)
16:53mebaran151hey, what would be a natural representation in Clojure of a web of a nodes?
17:07tolstoyI wonder why clojure.xml.parse doesn't take a plain old string?
17:10the-kennyhm.. what does it take?
17:10tolstoyinput stream, url.
17:10tolstoyBut duck-streams to the rescue.
17:17tolstoyOops. duck-streams NOT to the reque.
17:17tolstoyEr, rescue.
17:21unfo-tolstoy, thanks for that clojure.xml.parse (parsing is next on my todo for my current pet project) :-)
17:21unfo-(send :channel "good night!")
17:23tolstoyI hope you can get it working. I can't get the right combo or require or use or what have you.
17:23samlwhat do you use for unit test? is, fact?
17:24tolstoy#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: parse for class com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl>
17:28rrc7czHow can this be explained? (println x "-" (empty? x) "-" (count x) "-|" (first x) "|-" (count (first x))) -----> "() - false - 1 -| |- 0"
17:29rrc7czstr puts a space between all of the elements, so it's actually "()-false-1-||-0"
17:30rrc7czso somehow the lazyseq is (), but it's not empty, having 1 element of 0 length and apparently invisible
17:31defnfliebel: how goes the utterson hacking?
17:32fliebeldefn: great, although my once so clean design is starting to look like a mess :P
17:32fliebeldefn: still busy?
17:33tolstoywhere in zip-filter does it describe what a "loc" is?
17:33defnfliebel: i just got back today, hopefully i can mess with it later tonight
17:33fliebeldefn: I just wrote a tag page plugin, but due to some circular stuff I can't get hold of some variables.
17:33fliebeldefn: so to compile the jar you have to remove the tag plugin.
17:34defnnod, okay
17:34defnhave you submitted a pull request?
17:34fliebeldefn: I'm looking forward to your stuff.
17:34defni can pull in your changes if youd like
17:34defnfliebel: me too! :)
17:34fliebeldefn: Not recently, shall I send you one?
17:37fliebeldefn: 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:37tolstoyAnyone know of any examples out there for zip-filter?
17:38defnfliebel: im no expert on this stuff either, but we can incrementally improve things as we go
17:38the-kennytolstoy: Wait
17:39fliebeldefn: I think that is a good plan. If I don't do that my applications tend to get messier over time.
17:40tolstoythe-kenny: Cool. All I see are the abstract descriptions. No idea what the real params are. ;) Waiting for the a-ha.... ;)
17:40the-kennybah.. just broke something in my running emacs
17:40fliebeldefn: a good start would be rethinking the structure and control flow of the application.
17:40fliebeldefn: I don't know what time it is over there, but I need some sleep now.
17:41KirinDave_Grrgh
17:41KirinDave_Annotations annotations, everywhere.
17:41KirinDave_Such a pain in the ass.
17:46fliebelbye everyone!
17:49samlhow can I grep a line from a string?
17:49the-kennytolstoy: Sorry for taking so long: http://codepad.org/5SiGXqBk
17:49the-kennysaml: line-seq
17:49the-kenny,(doc line-seq)
17:49clojurebot"([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
17:49samlthe-kenny, thanks
17:50the-kennyuh, that's from a reader. Use duck-streams then
17:51the-kennytolstoy: Same with require's: http://codepad.org/oHQ4xxVy
17:51the-kennyoh btw.. please ignore my developer key for youtube in the url :)
17:53samlstring is not lazy right?
17:53saml(sh "tail" "-F")
17:54samli want to do something with the output .. where sh is from clojure.contrib.shell-out
18:01LicenserGood evening my lispy freinds? How is the world of paranthethes (I never can spell that) going today?
18:03defnParentheses are opening and closing just as they do in any language
18:04Licenserglad to hear!
18:08LicenserSo 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:13defncouchdb, clojureql
18:15mebaran151clojureql is definitely nice
18:16mebaran151I've uploaded some bindings for BerkeleyDB and am currently wrapping Neo4j right now
18:24tolstoythe-kenny: Thanks for the examples. I'm still trying to figure 'em out. ;)
18:26tolstoythe-kenny: How do you create a path? :foo:bar:baz for <foo><bar><baz>?
18:26the-kennytolstoy: No :foo:bar is the element bar in the xml-namespace foo
18:27the-kennytolstoy: (xml-> xml :foo :bar :baz) would be the path you've mentioned
18:27tolstoy"xml" would be the result of clojure.xml/parse?
18:28tolstoyI see you've got xml-zip.
18:28the-kennyno, the result from (clojure.zip/xml-zip (clojure.xml/parse ...))
18:28tolstoyOk.
18:29the-kennythe whole zip-filter stuff operates on trees generated by clojure.zip
18:31ieureI really wish there was some sort of documentation on zip-filter. I have no idea how that stuff works.
18:31tolstoyGotcha.
18:31tolstoyYeah, it's pretty tough.
18:32tolstoyProbably really easy to use, once you know a key piece of information.
18:32the-kennyahh found examples in the code: http://github.com/richhickey/clojure-contrib/blob/81b9e71effbaf6aa2945cd684802d87c762cdcdd/src/clojure/contrib/zip_filter/xml.clj#L90
18:32the-kenny(Mentioned in the doc for xml->)
18:34tolstoyHm. But no example of (text loc).
18:34tolstoyHow to I get an "loc" I can pass to text?
18:36tolstoyI guess you use xml-> to get to some place in the tree, then pass the results of that to text?
18:40Licenserdefn mebaran151 thanks for the suggestions, I'll look into it. So I won't touch BDB .
18:40Licenserp
18:41mebaran151haha
18:41LicenserBDB stands for Breaking DB not Berkeley DB
18:41tolstoySo, zip-filter is like that arrows thing in Haskell, eh?
18:41mebaran151it definitely isn't as polished as ClojureQL, but it's a nice fit for clojure
18:42mebaran151sometimes it's nice to think of things as a series of string tuples and saves as writing a series of string tuples
18:42the-kennytolstoy: yes, you use :something to get to the element and do further examining with the provided functions
18:42LicenserIt 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:44tolstoythe-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:45the-kennytolstoy: group and thumbnail are elements, not tags. The purpose of this is to get the attribute "url" of all :media:thumgnail tags
18:46tolstoySorry, I meant elements. I guess I've seen people use those words intechangeably.
18:50the-kennytolstoy: Maybe it's easier to understand if you look at the xml behind the url
18:51tolstoyOkay. I have doc <foo><bar><baz> and (xml-> dom :foo) gets me nil.
18:53tolstoyOkay. 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:00chouserI think xml-> starts within the document element.
19:02tolstoyI'm about to paste in the examples in the source code. Frustrating! ;)
19:03lisppaste8tolstoy pasted "xml zip-filter?" at http://paste.lisp.org/display/92754
19:04tolstoythe-kenny: Can you tell me why the stuff in http://paste.lisp.org/display/92754 ends up "nil"?
19:06the-kennytolstoy: hm.. not sure - Does it work when you the xfilter/tag=-stuff with just :baz?
19:06tolstoyI changed xml1-> to xml, and now I get an empty list.
19:07tolstoyBoth with :baz and (xfilter/tag= "baz") or (xfilter/tag= :baz). Odd.
19:07the-kennyhm. wait
19:08lisppaste8the-kenny annotated #92754 "untitled" at http://paste.lisp.org/display/92754#1
19:08the-kennytolstoy: try it like this
19:09tolstoyThat worked.
19:10tolstoyWhere as :foo :bar :baz didn't.
19:10the-kennyYeah, you have to specify the full path, omitting the "root" element
19:10tolstoyAh.
19:10the-kenny(in this case foo
19:10tolstoyNow I understand chouser's comment.
19:11the-kennyahh me too :D
19:12tolstoyOkay, one last question: how do you get all the attributes for a given element?
19:12tolstoyIs (xml-> :bar :baz) suppose to return a list of "baz" nodes?
19:13the-kennyYes
19:16tolstoyAlrighty. Thanks the-kenny! I think I have enough to ox-blinder my way through it. ;)
19:18mebaran151Licenser, I myself have put using BDB in maintenance after finding neo4j with Lucene quite a bit better and less likely to wedge itself
19:18mebaran151the bdb code demanded that I always think about unwedging the database
19:18Licenser^^
19:19LicenserI generally don't like BDB any more since it twice nearly fried my mail server :P
19:19mebaran151oh yeah, it's not a very trustworthy rascal
19:19mebaran151I wish the JVM had a simple efficient library for persisting btrees to disk
19:19mebaran151BDB is the closest I could find
19:29defnhmmm -- i have a problem with: (file-str (java.io.File. "/home/myuser/") "/src/etc")
19:31technomancydefn: try java-utils/file instead of file-str
19:31danlarkinfile-str takes a string and returns a File
19:31srnm(file-str "~/src/etc") should work...
19:44technomancyany idea why contrib's logging would use java.util.logging even though commons logging is present?
19:45technomancyoh... yuck. AOT strikes again. =(
19:56optimizeris clojure close to having recursive repls on exceptions yet?
19:58defnoptimizer: i think it does?
19:58technomancyoptimizer: you have to insert them manually right now
19:58defnactually nevermind, im thinking of some elisp i was writing
19:58mebaran151I'm getting the strangest error on loading a file
19:58optimizerinsert them manually?
19:58optimizerwhy can't it be automated?
19:59optimizerthis makes no sense
19:59mebaran151it complains it can't make an ISeq from symbol
19:59mebaran151but every time I load the file, the line number gets one higher
19:59defnbtw 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:59defnmebaran151: do you have your code up anywher?
19:59defnanywhere*
19:59mebaran151user=> (load "./src/com/bebop/appledelhi2")
19:59mebaran151java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (appledelhi2.clj:1)
19:59mebaran151user=> (load "./src/com/bebop/appledelhi2")
19:59mebaran151java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (appledelhi2.clj:2)
19:59mebaran151user=> (load "./src/com/bebop/appledelhi2")
19:59mebaran151java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (appledelhi2.clj:3)
19:59mebaran151user=> (load "./src/com/bebop/appledelhi2")
19:59technomancyoptimizer: well that functionality is quite new and hasn't been included in clojure yet
19:59mebaran151(sorry about the flood)
20:00mebaran151I'm not sure what part to paste
20:00technomancyoptimizer: it can be automated, it's just that nobody's done it yet
20:00optimizertechnomancy: is this in clojure proper or enclojure?
20:00Chousukemebaran151: I would guess it's because of the repl
20:00technomancyoptimizer: it's not anywhere yet
20:01technomancyoptimizer: just here: http://georgejahad.com/clojure/debug-repl.html
20:01devlinsfhttp://groups.google.com/group/clojure/browse_thread/thread/8d77ad0da8d190c8/e39b59fd19cc5675
20:01Chousukemebaran151: it might be taking the line number from the repl and not the file, for some reason.
20:01mebaran151https://gist.github.com/016734cc1df33129811e
20:02mebaran151I can't find the syntax error for the life of me
20:03ChousukeI think you need to do (:require (com.bebop.appledelhi2 [neo4j :as neo4j]))
20:03mebaran151that's strange: it's always worked before up to this very minute
20:03Chousukehm.
20:03technomancyany contribbers want to check out https://www.assembla.com/spaces/clojure-contrib/tickets/53 ? =)
20:05mebaran151nope that didn't fix it
20:05optimizerwhich editor has best clojure interface?
20:05optimizerwhich editor has best clojure _interaction_
20:06Chousukeprobably emacs, but then again, I haven't tested others :P
20:06mebaran151also, I can only get the netbeans repl to launch about 50 percent of the time
20:06mebaran151though when it works I love it to pieces
20:09mattreplre: http://www.assembla.com/spaces/clojure-contrib/tickets/44 is there a problem with not AOT compiling clojure.contrib.logging?
20:10mebaran151I wish clojure had better error report for ns macros
20:11technomancymattrepl: dang; I just opened a dupe of that ticket
20:12technomancymattrepl: my patch just adjusted build.xml to skip AOT of logging.clj though
20:13mattreplthat seems best to me, I'm not sure why one would be opposed to shipping logging.clj
20:15mebaran151(ns com.bebop.appledelhi2) even a simple ns declaration like this seems to make the repl increment that same error
20:18defnoptimizer: emacs for sure. you can make a mock repl with vim, but it just ain't the same
20:18defnoptimizer: textmate has a clojure bundle, but its indentation and highlighting isnt great, and it doesnt have paredit
20:18optimizerdoes clojure by any chacne have it's own editor in clojure?
20:18optimizerthat'd be really cool
20:18defnemacs + paredit + swank-clojure = win
20:19defnoptimizer: i dont know of any clojure editors written in clojure, but clojure is a lisp, and emacs is elisp
20:19defnso it's closer than say, vim
20:19mebaran151optimizer, mocking a basic ide in clojure is on my todo list actually
20:23chouserthere have been a few
20:24chouserwaterfront is the most complete, I believe.
20:40defnrandom question: anyone here familiar with the google search appliance?
20:41optimizerdoes it run clojure?
20:43defnoptimizer: lol no -- im just curious what kind of protection they have to protect their algorithms
20:46optimizeri hear that if you try to open the box; it triggers a nuclear explosion
20:47chouserthat should do it
20:47optimizerisn't page rank; along with techniques to speed it up fairly well known?
20:47optimizeri've always felt the power of google is there ability to deal with hard distriuted systems problems
20:48optimizerand retaining smart engineers
20:50defnoptimizer: some of it is well known, but i dont believe the subtle tuning they do is common knowledge
20:51defnotherwise there wouldnt be an entire SEO industry that popped up overnight
20:51optimizeri can't iagine any of that in google search appliance
20:51optimizerit's supposed to be able to deal with documents
20:51optimizerwhich are likely not liked
20:51optimizerand "honest", not "optimized"
20:52optimizeralternatively, work @ google :-)
21:06arohnerdoes paredit have a "comment s-expr" command?
21:06arohnerjust ";" doesn't do what I'd expect
21:08the-kennyarohner: Yes, mark the sexp and press M-;
21:09arohnerthe-kenny: thanks. I saw M-; but I was trying it with the cursor at the beginning, rather than marking it
21:21arohnerlisppaste8: url
21:21lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
21:23lisppaste8arohner pasted "deftype merge explosion" at http://paste.lisp.org/display/92759
21:23arohnerok, I just pasted but I don't see it...
21:24arohnermerge explodes on deftypes that implement IPersistentMap