#clojure logs

2009-08-12

00:58Anniepoohas clojure.contrib.http.agent been removed for some reason?
01:01hiredmanlooks like it is still there
01:02Anniepoovewwwy wierd
01:05Anniepoook, I do an update on trunk and half my clojure.contrib source packages are deleted
01:06Chouserif you don't have local changes, you might want to do a fresh checkout into a new directory.
01:07hiredmansounds like the wrong trunk
01:07Anniepooah, somehow I'm not on a class only trunk
01:08Anniepoo8cD sources now on github
01:08hiredman"wrong trunk"
01:10Anniepoo8cD shoulda quit my ide before doin that!
01:11AnniepooDarn! now I gotta install git to get a new clojure.contrib jar
01:12hiredmanyou can just grab a tarball of the source from github
01:23Anniepooany idea how long 'Hardcore Archiving Action' should take?
01:29Anniepoowell, it should be able to archive in 6 minutes, yes?
01:31Anniepoogithub's archiving is borked. Somebody willing to email me a clojure.contrib jar file so I can continue work?
01:35hiredmanhttp://www.thelastcitadel.com/lab/clojure-contrib.jar
01:35hiredman(complete with all kinds of nasty trojans and spyware)
01:36AnniepooLOL
01:36Anniepoothanks
01:36Anniepoocause github's still waiting
01:37Anniepoodon't know if there's anything else in the distro
01:38Anniepoobut I need to write some code, not play with git
02:22Anniepooshit! no binary.
02:37Anniepoois http-agent not ready for prime time?
02:38Anniepoothrew this exception No matching method found: setFixedLenghtStreamingMode
02:38Anniepoonote the misspelling
02:46arbschtthat seems to be an error in http.connection
02:48Anniepoohmm
02:50Anniepoothis code is only about 6 weeks old
02:50AnniepooI'm probably the first user
02:52Anniepooguess I'll move it to a GET and just slurp an URL
03:31Anniepoois there a simple way to curl a URL?
03:32andyfingerhutShell out to curl, perhaps? Maybe not want you want to do, though.
03:33Anniepoono, I want some (slurp-url "http://www.somebody.com") whose value is a string that is the body of the page
03:37jd8hh57AnniePoo: not sure how old or relevant this is, but about halfway down here: http://gnuvince.wordpress.com/2008/10/31/fetching-web-comics-with-clojure-part-1/
03:37Anniepooyah, fetch-url
03:37jd8hh57there is a 'fetch-url' function
03:37Anniepoodidn't want to use my own if there was a lib version
03:37jd8hh57ok - you already knew :) sorry.
03:37Anniepooit's cool
03:37jd8hh57ahh!
03:38Anniepoowhat would be ideal would be if (slurp "http://www.foo.com") did the right thing
03:38Anniepooif there's no protocol, assume it's a filename
03:42Anniepoooh, poo....
04:04Anniepoodarn!
04:05hiredmanhttp://gist.github.com/119375
04:09Anniepoothanks
04:18AWizzArdcgrand: do you know how I can call the compiler from within Java on a string which contains clojure code?
04:19AWizzArdsuch as clojure.lang.Compiler.execute("(println 10)");
04:24cgrandAWizzArd: sure
04:25cgrandclojure.lang.Compiler.eval(clojure.lang.RT.readString("(println 10)"))
04:25AWizzArdCould you show an example call, for example on how calling this example string "(println 10)"?
04:26AWizzArdah good, thanks.. so far I wrote the strings to disk first and called loadFile
04:28cgrandfunny you asked how to do that because I was just working on something related. Are you looking over my shoulder? :-)
04:42AWizzArdcgrand: it was an "accident". I am developing a lib for Clojure which will allow its use in a nice Framework which currently only accepts Java. To allow the users of my lib to write Clojure instead I need to compile their code.
04:42AWizzArdcgrand: but while starring at Compiler.java I noticed your name there on github, so I asked :)
04:44AWizzArdanother way to inject Clojure into a Java program dynamically could be to put it as an anon function into some vector and have the Java code .invoke from the right index from that vector instead.
04:47AWizzArdbtw cgrand, as you also know about how Clojure maps are implemented.. would it help if the user could specify an initial size for the map? In a classic implementation with array buckets under the hood it prevents from copying the map when more elements get added.
04:56AnniepooIf I do what you said, cgrand, to eval something, then do I get all the current context?
04:57Anniepoonever mind, I see.
04:58Anniepoonight all, that convinced me I'm inserting, not removing, bugs
05:30AWizzArdclojure: paste
05:30AWizzArdclojurebot: paste
05:30clojurebotlisppaste8, url
05:30lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
05:43lisppaste8AWizzArd pasted "Try/Catch challenge in with- macros" at http://paste.lisp.org/display/85244
05:50AWizzArdcemerick: do you have an idea how to handle that challenge?
05:53cemerickThe problem being, you don't want two printlns given an error?
05:54AWizzArdI want the macro to return what the body returns
05:54AWizzArdThe macro will always execute its finally block and return what that returns.
05:55AWizzArdI currently work with an atom to go around that problem
05:56cemerickI guess I'm not following what's wrong with your with-resource.
05:56cemerickit's < 6AM here :-P
05:57AWizzArd*g*
05:58AWizzArdwhen I have a let inside my with-resource macro and want with-resource to return what the let returns, then this won't work.
05:58AWizzArdBecause with-resource will run the finally block.
05:58AWizzArdMy second with-resource macro causes a problem.
06:02cemericknothing ever gets returned from a finally block.
06:02lisppaste8cemerick annotated #85244 "no return value from finally" at http://paste.lisp.org/display/85244#1
06:03AWizzArdhmm ok, i didn't know that
06:03cemerickso the value of ~@body will be the return value of a standard with-resource
06:03cemerick(outside of an exception)
06:04AWizzArdoh good, then you already helped me, thanks :-)
06:06alinphi
06:06alinp(defn my-test
06:06alinp([] (println "none"))
06:06alinp([a] (println "one arg"))
06:06alinp([a b] (println "two args")))
06:06alinpis this some sort of pattern matching in clojure ?
06:06alinpor is more like method overloading ?
06:07alinpif not (not a pattern matching), how can this be done ?
06:09AWizzArdYou want to know how to do pattern matching?
06:09alinpyep
06:09alinpis this the way ?
06:09alinpthat I paste above
06:10AWizzArdPM is currently not directly supported by Clojure. You can implement your own pattern matcher. Clojure however comes close to the expressivity of pattern matching with multi methods.
06:11alinpok, thanks for that, I know about multi methods
06:11alinpso, what means the piece of code that I paste ?
06:11alinpemulates somehow the method overloading ?
06:11arbschtarity overloading
06:11alinpok... yeah
06:11alinpthanks arbscht
06:17cemerickalinp: note that destructuring is deeply supported:
06:18cemerick,(let [{a :a b :b} {:a 5 :b 6} [x y] (range 2)] [a b x y])
06:18clojurebot[5 6 0 1]
06:24angermanhow would i create an InputStream from a String?
06:26alinpangerman: ByteArrayInputStream str = new ByteArrayInputStream("blabla".getbytes());
06:26alinp:)
06:27alinpofc, you will specify also the encoding for getBytes() method
06:27alinpuse clojure facilities to call this java code
06:27alinps/code/api/
06:28angermanhmm
06:29alinpsorry, can't say something about that; maybe it is
06:31arbschtduck-streams works with file-like things mostly
06:46cgrandAWizzArd: re maps: an initial size wouldn't help for persistent maps, not even for transient maps. But some of the perf improvements (in my fork of clojure) are related to transient nodes whose size allow for some growth without copying.
06:47osaundersHow can I recursively call a function without repeating its name?
06:48osaundersSeems like that's what recur should do only it never seems to work.
06:50arbschtosaunders: can you provide an example where recur fails?
06:51osaundershttp://pastebin.com/m1eb222d4
06:52osaundersSays too many arguments, expecting 1.
06:52osaundersI can see what it's trying to do.
06:52carkyou have to understand that each arity is a separate function
06:53carkso in arity 1 you just call sum-event-fibo
06:53carkand use recur in arity 4
06:53osaundersEven so that doesn't satisfy my requirement.
06:54carkwhat is you requirement ?
06:54carkyour*
06:54osaundersTo recurse without repeating name.
06:54carkyes it does
06:55carkuse recur in place of sum-even-fibo in arity 4
06:58osaundersBut then I have to use full name in arity 1.
07:00osaunders...which is why my requirement isn't satisfied.
07:00arbschtyes, because you are trying to call a different function :)
07:01osaundersIt's the same definition though.
07:01carkwhen using recur, the goal is not to avoid repeating the name of the function
07:01carkrecur is about doing tail recursion
07:02carkyour arity 1 function is only being called once
07:02carkso recur is useless there
07:02osaundersI understand that.
07:02osaundersI just don't want to have to repeat the name of the function.
07:02osaundersBecause then if I choose to change the name I have to update it in several places.
07:02carkwell i guess you're out of luck then =)
07:02osaundersYeah, Clojure fail.
07:03arbschta 'reinvoke' operator would be nice
07:03arbschtpost a message to the mailing list
07:04osaundersHm.
07:04carkwell you can always (declare sum-event-fibo) then (def curr-function sum-even-fibo) and finally use curr-function for your recursion
07:04carkor make a defn macro
07:05osaundersYeah.
07:06tomojinteresting. if you change the name of the function without changing it in the reinvoke and just re-compile, it would compile and work fine
07:06tomojthen if you change the behavior of the function you would get weird results
07:06tomojI sometimes think slime should be able to wipe the namespace clean and recompile
07:08tomojbut that would mean any vars would get washed away too.. hmm
07:34carkanybody used memcached with clojure ?
07:34cgrandosaunders: http://pastebin.com/f742c10d3
07:35osaunderscgrand: TY
07:53AWizzArdcgrand: that sounds interesting
08:13angermanargs! (apply recur (map #(.get csvr %) (range 0 8))) I cannot call apply on recur ..
08:16cemerickis anyone here familiar with the GPL, etc.?
08:18angermanhmm so apply is not a macro ...
08:19angermancemerick: what's the question?
08:20cemerickConsider a library dual-licensed under GPL v2 and a proprietary license. I'd like to publish an extension to this library, but not under GPL (anything bsd-esque would be fine) -- is it simply enough to not include the GPL library or its sources e.g. when I push to github, and have users of my extension obtain the base library independently?
08:21cemerickI've been ready the GPL FAQ for about 20 min, and couldn't take much more :-P
08:21tomojangerman: even if it were a macro, wouldn't the fact that recur has to be in tail position make what you're trying to do impossible?
08:22tomojcemerick: if you're not distributing the GPL'd code, the license doesn't matter at all, does it?
08:23cemericktomoj: that's my understanding and intuition, but I've generally only trafficked in proprietary licenses, and my light reading of the GPL and its FAQ makes me nervous in general.
08:23angermancemerick: well as long as it's your code, you can always license it to a third part (or yourself) using a different license
08:23tomojthey can't say "if you write code which happens to work well with my code, you must use such and such license"
08:24angermanand the GPL basically sais if you make any derivation of the work you have to share it with the rest of the world
08:25angermantomoj: well what I try to do is write "less" :)
08:25angermanrecur is still in tail position but I'm not so much into expanding the (.get csvr 0) ... (.get csvr 7)
08:25tomojoh, yes, I see
08:26cemerickangerman: to be clear, the only way that this extension "derives" from the GPL library is that needs to be built against it. It's not like I'm changing the library's implementation in some way.
08:26tomojI was confused for a second about what apply does
08:27cemerickAnother point is that we've never accepted the GPL for this library; we've purchased the commercial license for it. Not sure if that affects things.
08:27tomojif copyright law gives bob influence over people who write separate code that requires bob's code to function, that's crazy
08:27tomojbut copyright law is crazy I suppose
08:27angermancemerick: if you've purchased a different license for it, the GPL has nothing to do with it.
08:28angermanI think the "whole" link against something is why we have the LGPL
08:28angermanthen again, I'm not a lawyer
08:29cemerickangerman: OK, for me perhaps, but if someone who wants to contribute back to my extension, and who uses the base library under the GPL, they'd be barred from doing so (I think)
08:29AWizzArdangerman: you can write your own macro which will expand into (recur (.get csvr 0) (.get csvr 1) ... (.get csvr 7))
08:29cemericktomoj: I'm pretty pissed that I have to think about this at all. If only we just had bsd-esque and commercial licenses, I'd know my ass from my elbow.
08:30AWizzArd(map-recur #(.get csvr %) (range 8))
08:31Chousukecemerick: you could mail the FSF and ask them.
08:32cemerickChousuke: heh. I *definitely* don't trust them for legal advice.
08:32cemerickI think I'll head to stackoverflow, there's some body of license-related questions there.
08:32tomojhmm.. I wonder why clojure-test-mode still refers to clojure.contrib.test-is
08:33angermanAWizzArd: I tried to, but failed to write a "working" macro
08:33Chousukeangerman: could you use clojure.template? :)
08:34Chousukeor clojure.contrib.template if you're stuck with 1.0
08:35angermanChousuke: how would that help? isn't that a html template library?
08:35Chousukeno.
08:35Chousukeit's for "code templates"
08:35AWizzArdChousuke: so, macros for the poor? :-)
08:36angermanso I don't have to use apply :/
08:38angermanAWizzArd: how would you write that macro?
08:38Chousukehmm
08:40angerman(defmacro foo [f coll] (cons 'recur `(map ~f ~coll)))
08:40angermanhmm that seems to do it ...
08:41angermanhmm ok, not really :(
08:41Chousukehttp://gist.github.com/166483
08:42tomojwhy does your function take 8 arguments?
08:42AWizzArdno, that's not it. Sorry, have no time now. But an alternative could be to have that function which you want to recur taking &rest arguments.
08:42Chousukethe gen must produce fragments of code, of course. so in your case it needs to be (fn [x] `(.get csvr ~x)(
08:42Chousukeoops
08:42Chousuke)*
08:44Chousukeand naturally both gen and source need to be known at compile-time, so you can't pass function parameters to it or anything :/
08:44tomojwhy not just (recur (map #(.get csvr %) (range 8)) ?
08:45Chousuketomoj: because that would call recur with a single argument. angerman apparently has 8
08:46tomojChousuke: yep, that's what I'm wondering about
08:46angermanwell, using recur in combination with loop so
08:46angermanI guess I could so the destruction in the loop head ... but that would be kinda funny
08:46clojurebotthat is not what I wanted
08:47febelingwhen I use add-classpath in repl, and watch the classpath via contrib.clojure.classpath, it doesn't change. does that make sense?
08:49Chousukefebeling: toying with the classpath at runtime is dubious activity anyway, so it's no wonder if unexpected things happen :)
08:50febelingok :)
08:53cemerickHere's my licensing question, for those that are interested: http://stackoverflow.com/questions/1265993
08:54cemericksorry for the OT distraction :-)
08:56angermanwhy does the subs not do neg end?
08:56angerman(defn substr [s start end] (subs s start (if (< end 0) (+ (.length s) end) end)))
08:56angermanthat was kindof a hickup right now
08:56Chousukeprobably because subs is just a wrapper for .substring
08:57tomojhow can you do something like ruby's File.dirname(__FILE__)? java?
08:57Chousukelook at metadata?
08:57Chousuke,(:file ^#'+)
08:57clojurebot"clojure/core.clj"
08:58Chousukeor is that what you wanted
08:58tomoj__FILE__ means the current source file
08:59tomojwell, path to the current source file from the cwd
09:04tomoj(defn foo []) then (:file ^#'foo) works, but that seems silly
09:06Chousuke,^*ns*
09:06clojurebotnil
09:06Chousuke,^#'*ns*
09:06clojurebot{:ns #<Namespace clojure.core>, :name *ns*, :doc "A clojure.lang.Namespace object representing the current namespace.", :macro false, :tag clojure.lang.Namespace}
09:06Chouser,*source-path*
09:06clojurebot"NO_SOURCE_FILE"
09:06Chousukehmm, no file data :(
09:06Chousukeah.
09:06Chouser,*file*
09:06clojurebot"NO_SOURCE_PATH"
09:06Chouserthat seems ... backwards
09:06Chousuke... yes.
09:08Chouseralso, those are vars, not any kind of reader magic, so it may be a bit tricky to get the results you want (depending on what you want, I suppose)
09:08tomojgreat, *file* looks good
09:08tomojyeah at first I tried putting that in a defn
09:09tomojbut I don't need that anyway, just trying to autoload some clj's in a dir
09:16AWizzArdangerman: I would have to think about it, but the macro could look like (defmacro map-recur [f coll] `(recur ~@(map (fn [x] `(~f ~x)) (eval coll))))
09:16AWizzArdbut as Chousuke already mentioned in his example: eval will be needed during macroexpansion time.
09:17AWizzArdfor some cases this won't be possible.. you should think about having your fn to accept a &rest parameter.
09:29ole3hello, is it possible to access X11 from clojure?
09:30Chouserole3: sure, at many levels.
09:32Chouserswing (or some other high-level toolkit), xlib (via JNA or JNI), or talk the X protocol directly on the socket (either TCP or unix sockets)
09:34ole3Chouser: I have an written an specialized window manager for my application, in C, I would like to have it in clojure to configure it at runtime
09:36Chouserole3: ok, then I'd recommend using JNA to either interact with the xlib library or to interact with the X server's unix socket directly.
09:43pdoAnybody know how to read the kth bit of an integer in Clojure? e.g. like (ldb (byte 1 k) int) in CL?
09:48AWizzArdpdo: http://java.sun.com/javase/6/docs/api/java/lang/Integer.html
09:48tomoj,(bit-test 12345 3)
09:48clojurebottrue
09:48AWizzArdor toBinaryString could be interesting
09:48AWizzArd,(Integer/toBinaryString 127)
09:48clojurebot"1111111"
09:49hiredmankeep in mind toBinaryString doesn't pad with leading zeros
09:50pdoThanks tomoj
09:50ole3Chouser: thank you, I will try to talk to the unix domain socket directly.
09:52Chouserole3: abrooks has looked some at writing a wm in Clojure, and concluded the xlib libarary would be more trouble than its worth, so I think you're on a good track.
09:53Chouserole3: I would recommend using JNA over any of the Java unix socket libs I've seen out there.
09:53tomojthis might be relevant http://sourceforge.net/projects/escher/
09:53tomojseems dead
09:57ChouserFor JNA you might like http://github.com/Chouser/clojure-jna -- also that has an example of using open, close, read, and select on a unix file descriptor.
10:18osaundershttp://www.theonion.com/content/node/33930
11:13AWizzArdAny Swing user here who knows by heart how to scroll down (max) in a JTextArea?
11:15Chousermaybe: (.setCaretPosition pane (.getLength (.getDocument pane)))
11:17Chouseroh, that's probably a JTextPane
11:18AWizzArdI can try that
11:25drewrwhere's stuartsierra?
11:26Chouser~seen stuartsierra
11:26clojurebotstuartsierra was last seen parting #clojure, 9717 minutes ago
11:33drewrtrying to figure out an issue with c.c.http
11:34AWizzArdChouser: Good idea with setCaretPosition. Btw, this also works: (.setCaretPosition log-area (count (.getText log-area)))
11:43febeling_is there a short way to make a HashMap a clojure map?
11:43Chouser(into {} your-hash-map)
11:44febeling_Chouser: thanks :)
11:49angermanhas anyone experience with a html template lib for clojure?
11:49tomojenlive
11:49tomojwell.. it's probably not what you're thinking of
11:51tomojwith enlive you just have html in the template and programmatically transform it
11:53Neronusin stringtemplate, the html-code is in a file of its own and you can give StringTemplate that file and e.g. a map, and it will transform that file, substituting variables as defined in the map
11:56angermantomoj: yep I saw enlive, looked interesting.
11:56angermandoes stringtemplate support tempalte inheritance_
11:57angermanif there was a port of something like jinja2 that would be awesome.
11:57angermanthe only thing I hate about template engines is the lack of streaming :) but that's something not to be solved easily :)
11:58Neronusangerman: What do you mean by template inheritance?
12:00angermanNeronus: well with jinja2 you can have a master template and setup a derived template that inherits all the base from the master and substitues certain parts with custom content.
12:01angermanNeronus: basicall you mark a part of the html and overwrite it in the subtemplate. that way you usually have a master file and for every view a seperate file that derives from the master.
12:02Neronusangerman: Nope, I don't think that that is supported; Templates are pretty much functions, which map a set of variables to a string, depending on the template; they can of course call each other
12:03NeronusActually, I think they StringTemplate templates are somewhere on Chomsky level 1
12:04angermanhmm. so if i once find some spare time I'll port jinja
12:04angermanso for now I'll go with hand crafted vectors of vectors and feed them into the (html fn from compojure
12:05NeronusWhatever floats your boat :)
12:05angermanNeronus: I've so much legacy templates that use django/jinja template system...
12:06NeronusIn that case it would probably be a good idea; but why switch to clojure if you've got a running system there?
12:07cemerickwhat ever happened to kid? It looks like its site is mostly hosed.
12:09angermanNeronus: well, it's getting painful. And as I started using tons of lambdas in python I figured I could switch straight to a functional language
12:38cgrandangerman: you can define your own inheritance system on top of enlive
12:43tomojenlive is pretty interesting for templating
12:43tomojI don't think I've really wrapped my head around it yet
12:43tomojif you had designers, the templates they made for enlive could just me html mockups, right?
12:44tomojs/me/be/
12:52ole3Chouser: thanks for your clojure-jna package, it works like a charm.
13:08Chouserole3: great!
13:53tomojanyone know of a webrat for clojure
13:55tomojguess I can just write a tiny wrapper around htmlunit
13:55angermantomoj: I might be interested in what you come up with :)
13:56angermanhow would I create a few Exception Classes on the fly?
13:57Chousukeproxy Exception?
13:57angermanChousuke: how would I name it
13:57Chousukeyou wouldn't. :p
13:58Chousukethough I guess catching it would be a bit difficult then
13:58angermanChousuke: well I want to throw a NotFoundException and an OutOfDateException
13:58tomojangerman: what do you mean by "on the fly"?
13:58tomojthat doesn't need to be on the fly, then, right?
13:58angermantomoj: well, not really "on the fly"
13:59tomojgen-class ?
13:59Chouseryou need this for java interop, or will you be throwing and catching all within clojure code?
14:00tomojhow would you do it just within clojure code?
14:00tomojstill need a classname for catch, right?
14:01angermanChouser: inside clojure
14:01Chouseryou might be able to use clojure features to achieve your goals.
14:01Chouserlike dynamically binding a function (instead of catch) and then calling it (instead of throw)
14:02angermanI could jsut return nil
14:02angermanthough that makes it hard to distinguish what went wrong
14:02angermanI could use a return-ref as param, that would look wrid though I guess
14:04angermanhmm. okay I use a global ref as a stack and push my errors ontop of it
14:04angermanon return of (nil, I'll have to pop the last value of the stack and work my way down from there
14:04angermanstill not perfect
14:06angermanI'm pretty sure that's not perfect with threads though...
14:06Chouserwell, you can use gen-class to define and exception type, AOT compile it and you're good to go.
14:06Chouseran exception
14:07Chouseryou could also look at the 2 or 3 options in contrib
14:07Chouserthe Right Way to handle error conditions hasn't quite been pinned down yet. ;-)
14:07angermanChouser: it's a functional language so returning nil+x would be great, can I add metadata to nil?
14:08angermanthat would probably be the best solution.
14:08tomojisn't nil just nil?
14:09angermanso I end up with (if (nil? (fn-call)) {do some handling on the metadata} {procede with what ever you wanted anyway}) {stuff that's executed anyway}
14:09tomojI mean, when you're returning nil, you're not returning a new nil object
14:09tomojyou're just returning the one and only nil
14:09tomoj(and so you can't change it's metadata, even if it could have metadata)
14:09angerman,(with-meta nil {:err 'NotFound})
14:09clojurebotjava.lang.NullPointerException
14:10angermantomoj: I don't need to change it's metadata. I just need to know why the functioncall failed
14:10tomojright
14:10angerman,(with-meta 'nil {:err 'NotFound})
14:10clojurebotjava.lang.NullPointerException
14:11tomojadding metadata to nil is not a way to do that, that's what I'm saying
14:12angermantomoj: hmm
14:12angermantomoj: what's so bad about adding metadata to nil?
14:12tomojit's impossible
14:12tomojit wouldn't make sense even if it were possible
14:12tomojand it seems ugly to me
14:13angermanabout the ugliness ... that's subjective :) But as it's not possible it's kinda bad. And I'm not going to gen-class Nil and use that.
14:14tomojwhat the heck IS nil anyway
14:14tomoj,(class nil)
14:14clojurebotnil
14:14Chousukeit's java null
14:14cemericknil is Java's null
14:15tomojI see
14:15Chousukeit's one of the "special" symbols, along with true and false.
14:16Chousuke,(symbol? 'true)
14:16clojurebotfalse
14:20Chouser(binding [*do-error* (fn [details] handle-error-details)] (if-let [val (fn-call)] succeeded-so-use-val) proceed-in-either-case))
14:37tomojif *do-error* is buried somewhere deep inside there, seems problematic
14:38tomojI guess if you use it intelligently it would work
14:42Chouseryou could name it better, have mutliple by various names, etc.
14:42Chouserjust another option...
14:48tomojI just mean, it needs to be in tail position, right?
14:48tomojotherwise the code will keep on chugging after you handle-error-details
14:48Chouserah. yeah, you may still want to return nil after calling the fn
14:49Chouseror the *do-error* could itself throw an exception. It could be generic since it would have already dealt with the specifics before throwing.
14:49tomojah, yeah
14:49tomojthat makes sense
14:50ChouserI guess that's essentially what error-kit is doing internally anyway, but it has a bunch of other questionable bells and whistles.
15:18angerman:( once again I'm missing a map-filter :/
15:20tomojhuh?
15:21angermanok, I fail to see what hindered me from getting it to work last time
15:21angermanmaybe I'm just adapting to clojure :)
15:29cemerickangerman: just (map blah (filter blah ...)), right?
15:29cemerick:-)
15:31angermanwell as I already had a list of maps, it was even simpler :)
15:31hiredman(comp (partial map blah) (partial filter blah))
15:54b4taylorSay, how do I write a type hint for a char[]?
15:55Chouserif you're lucky, #^chars
15:55b4taylorooohhh
15:55angermanhmm somehow I feel like java is faster then python ,)
15:56technomancyworth going back just for that.
15:56b4taylortechnomancy: Yeah, but what about ther overall performance of the 64-bit JVM versus the 32-bit one.
15:56b4taylorAlso, nailgun?
15:57Chouserb4taylor: yeah, #^chars seems to work
15:57technomancyb4taylor: I deploy on 64 bit servers, but for dev work startup is far more important.
15:57b4taylorChouser: Yeah, but it's not acomplishing what I need.
15:57b4taylorI'm doing it in a stupid way, there must be a more direct way.
15:57technomancynailgun solves a small portion of the startup problems. it's great for that, but people act like it's magic boot-time pixie dust.
15:57b4taylorI have a list of chars, I want to print them out with no spaces inbetween.
15:58Neronusb4taylor: (apply str list)
15:58hiredmanhow big of a list?
15:58b4taylor28
15:58hiredman*snort*
15:58hiredmanyeah, apply str
15:58cemericktechnomancy: what's the issue with startup time on 64-bit? More alloc going on at init?
15:58hiredman,(map char (range 80 108))
15:58clojurebot(\P \Q \R \S \T \U \V \W \X \Y \Z \[ \\ \] \^ \_ \` \a \b \c \d \e \f \g \h \i \j \k)
15:59technomancycemerick: no, the client JVM is only implemented in 32-bit.
15:59hiredman,(apply str (map char (range 80 108)))
15:59clojurebot"PQRSTUVWXYZ[\\]^_`abcdefghijk"
15:59cemerickoh, I see
15:59b4taylorhiredman: Thanks.
15:59b4taylorThat worked.
16:00b4taylorI keep forgetting about apply.
16:00cemericktechnomancy: is that a permanent situation (e.g. it's -server from here on out?)
16:00technomancycemerick: I suppose so; I've heard nothing about porting client mode to 64-bit
16:01technomancyI guess it's a holdover from the days when 64-bit was for big-iron servers only.
16:01cemerickand here I thought they had reimplemented client in terms of server, just with different params/config
16:01cemericknot sure where I got that idea
16:17hiredmanI had forgotten about this
16:18angermanso I cannot just define defmethod without having a defmulti?
16:18hiredmanthe github api returns time zones like -07:00 where java expects -0700
16:18hiredmanangerman: nope
16:24cemerickangerman: without defmulti and a dispatch fn, a method is just a fn
16:27hiredmanclojurebot: ping?
16:27clojurebotPONG!
16:28arohnerangerman: the defmethods correspond to return values of defmulti
16:28arohner* to return values of the dispatch function defined by your defmulti
16:31angermanI've got it though the defmulti now. but ... well :)
16:32arohnerright, you call them (my-multi :selector [args]), :-)
17:06durka42what did the google group ever do to you
17:08ChouserIf you don't know, then I won't burden you with the knowledge. :-)
17:12cemerickChouser: now I just feel silly trying to help out :-(
17:25wavisteri'm trying to use jedit to evaluate lines of clojure code similarly to how it does with beanshell. I'm getting an ExceptionInInitializationError caused by a NullPointerException in clojure.core. I don't get what it's doing. Would someone take a look? http://code.bulix.org/b4yfpw-71986
17:26hiredmanok
17:27hiredmanwavister: need the code that caused it
17:27hiredmannot just the exception
17:27wavisterthe code is just Class.forName("clojure.main")
17:27hiredmanbut a NullPointerException means you are calling a method on something that is null
17:28wavisteryeah, it's coming from java.util.Properties called by clojure.core
17:29wavisterdo you think it's looking for core.clj in the file system and not finding it...
17:29hiredmanno
17:29hiredmanI think core.clj is looking for the file containing the version information and not finding it
17:30hiredman~def *clojure-version*
17:31hiredmanchrome has a lot of trouble with github's line number anchors
17:33wavisterwould there be a system variable i need to set in the jedit environment to help it find said file?
17:34wavisterwhere is it anyway? inside the clojure jar?
17:34hiredmanyeah
17:34hiredmanmight be some kind of classloader issue
17:34Chouserif you used the normal ant build for to make the clojure.jar, then yes
17:34Chouserhiredman: ooh, good point.
17:34Chouseryou'd think I would have learned by now to suspect classloaders first...
17:35wavister... i hate classloaders
17:35hiredmanclojurebot should start sending notices for commits again
17:36wavisteri did use ant to make clojure.jar, too
17:38wavisterwell for now maybe i'll just not use jedit for evaluating clojure code in-buffer
17:53drewr,(partition 10 (range 5))
17:53clojurebot()
17:54drewrhow do I get that to return (0 1 2 3 4)?
17:54drewrIOW, the last partition is what's left in the seq
17:55Chouser,(clojure.contrib.seq-utils/partition-all 10 (range 5))
17:55clojurebot((0 1 2 3 4))
17:56drewrI just saw the pad arg too
17:56Chouseroh. yeah, I wouldn't rely on that.
17:56drewr,(partition 10 1 [] (range 5))
17:56clojurebot((0 1 2 3 4))
17:56drewrhm, ok
17:57Chouserhttp://www.assembla.com/spaces/clojure/tickets/120-GC--Issue-116--partition-with-pad
17:58Chouser"I’m now convinced we are cramming 2 functions into one, and would prefer to see this new functionality as a new function: take-subs" -- rhickey
17:58hiredmanclojurebot: ticket #120
17:58clojurebot{:url http://tinyurl.com/nlu9vk, :summary "GC Issue 116: partition with pad", :status :test, :priority :low, :created-on "2009-06-17T21:19:42+00:00"}
18:06osaundersHow can I generate a descending range lazily?
18:07hiredman,(range 20 0)
18:07clojurebot()
18:07osaundersFor that matter, how it is that range is lazy?
18:07hiredmanclojurebot: you stink
18:07clojurebotIt's greek to me.
18:07hiredman,(iterate dec 10)
18:07clojurebotEval-in-box threw an exception:java.lang.OutOfMemoryError: Java heap space
18:07hiredman,(take 10 (iterate dec 10))
18:07clojurebot(10 9 8 7 6 5 4 3 2 1)
18:07hiredmanosaunders: because it is
18:07Chouser,(range 20 0 -1)
18:07clojurebot(20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1)
18:08hiredmanChouser: figures
18:08osaundersChouser: ahh
18:08osaundersFrom range: (take-while (partial (if (pos? step) > <) end) (iterate (partial + step) start))))
18:08hiredmanboth interate and take-while are lazy
18:08hiredman~def range
18:09osaundersAh, the clue is in take-while.
18:09osaundersOK.
18:15osaundersIs there an efficient way of generating a Fibonacci seq?
18:15osaundersBecause the implementations I've seen/done require a lot of recursion and calculate right from the back every time. Even if you just need the 20th number or something.
18:15hiredmando you need a Fibonacci seq for something?
18:16osaundershttp://projecteuler.net/index.php?section=problems&amp;id=2
18:16osaundersI've solved it but I'm just wondering about efficiency.
18:17hiredmanactually there have been some fib seqs posted to the group
18:17Chouserhttp://clojure-euler.wikispaces.com/Problem+002
18:17Chouserthere's a few
18:18osaundersI love that there's a function called lazy-cat
18:18Chouserme too
18:22osaunders,(drop 1 '(1 2 3))
18:22clojurebot(2 3)
19:26hiredmanhttp://www.brool.com/index.php/pattern-matching-in-clojure yay macros!
19:31replaca^^ wow, that's nice. I've been meaning to write that for a while
22:01mebaran151what's the best way to save an anonymous fn?
22:02arbschtsave?
22:13ckyI presume mebaran151 meant, how to serialize/persist/pickle/whatever it.
22:13ckySo it can be loaded back in for a future session.
22:15mebaran151cky, exactly
22:15mebaran151as in serialize to bytes
22:15mebaran151that I could put in a BerkeleyDB and pull out again
22:17ckyI don't know any Clojure, so I can't answer that question, but hopefully someone else can. :-)
23:17andyfingerhutIs there already a transcript of any of Rich Hickey's Clojure talks posted somewhere? If not, I was considering typing some up for at least the one for Lisp programmers.
23:45tomojandyfingerhut: are they online?
23:47liebketomoj: http://clojure.blip.tv/
23:47andyfingerhutYep, those are the ones I'm thinking of.
23:48andyfingerhutThey are fine to watch and listen to, but sometimes a transcript can be nice.
23:48Chouserthey're getting outdated
23:49andyfingerhutThey're not completely up to date, I agree, e.g. lazy-cons instead of lazy-seq, a mention of ad hoc hierarchies but not in the example, since it was too recently added, no transients, etc. etc.
23:49andyfingerhutStill great stuff in there, though.
23:50andyfingerhutLots of good rationale targeted at people who know Common Lisp or Scheme for what is different and why.
23:50andyfingerhutIt didn't take me long in writing Clojure before I forget what is missing in Common Lisp, e.g. easy maps and vectors.