#clojure logs

2010-08-04

00:00rhudsonThere are over 500 symbols defined in core; it's hard to work them all into conversation
00:07pdkyou can work them into song then
00:09lancepantzhah, we learned this dumb song in high school to memorize all the capitals in south america
00:09lancepantzmaybe we can make something like that
00:13rhudsonhttp://www.youtube.com/watch?v=lhilwBnniBk
00:14rhudson(Tom Lehrer's Elements song)
00:25technomancyclojurebot: package.el is part of Emacs now: http://repo.or.cz/w/emacs.git/blob_plain/HEAD:/lisp/emacs-lisp/package.el
00:25clojurebot'Sea, mhuise.
00:25technomancyhiredman: how do you set a term to be an alias for another?
00:26notsonerdysunnyuser> (let [a [1 2 3 4 5]]
00:26notsonerdysunny (amap a idx ret (inc (ret idx))))
00:26notsonerdysunnyI get unable to find method aclone for this .. can anybody help me to resolve this?
00:27technomancynotsonerdysunny: it's not clear what you're trying to do.
00:28notsonerdysunnyI just want to learn to use amap
00:29technomancyamap is for working with Java arrays, which are not the same as clojure vectors.
00:29notsonerdysunnyoh ic
00:29technomancy,(map inc [1 2 3 4 5]) ; regular map works with vectors.
00:29clojurebot(2 3 4 5 6)
00:30notsonerdysunnyyea I know the one you just said
00:30notsonerdysunnybut I didn't realize amap works only for java-arrays
00:30notsonerdysunnyis there a common convention followed for functions that work only for java-structures
00:31technomancythe common convention is that they are all listed on http://clojure.org/java_interop =)
00:32notsonerdysunny:) thanks
00:32technomancyyou can always tell when something is a Java method because it starts with a . and uses camelCase: (.isDirectory (java.io.File. "/"))
00:32technomancybut there aren't enough clojure functions designed to work with java data structures to merit a convention like that
00:33notsonerdysunnyoh ic
00:33notsonerdysunnyI really like your leiningen tool .. its awesome ... thanks for such a great tool...
00:33technomancyglad it's useful.
00:41notsonerdysunnyI just find accessing the elements of n-dimensional clunky .. would you have a suggestion for this .. currently i try something like (-> myarray (nth index1) (nth index2))
00:41notsonerdysunnywould you have a better suggestion
00:42notsonerdysunny*n-dimensional vector
00:44tomoj-> (get-in [[0 1] [2 3]] [1 0])
00:44sexpbot=> 2
00:48notsonerdysunnythanks tomoj
00:52pdk(doc filter)
00:52clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects."
00:52pdk(doc get-in)
00:52clojurebot"([m ks] [m ks not-found]); Returns the value in a nested associative structure, where ks is a sequence of ke(ys. Returns nil if the key is not present, or the not-found value if supplied."
00:56pdk(doc mapcat)
00:56clojurebot"([f & colls]); Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection."
00:57pdk(doc repeat)
00:57clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
01:02pdk(list :test)
01:02pdk,(list :test)
01:02clojurebot(:test)
01:22dsophmm (read-lines "foo") works but (take 10 (read-lines "foo")) doesnt..
01:23dsoparg my bad
01:41tomojcareful with read-lines
01:41tomoj(take 10 (read-lines "foo")) will leave the stream open if the file has more than 10 lines
01:57pdk(doc cons)
01:57clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
01:58pdk,((1))
01:58clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
01:58pdk,'((1))
01:58clojurebot((1))
01:59pdk,'((1 2))
01:59clojurebot((1 2))
02:01pdk,(list '(1 2))
02:01clojurebot((1 2))
02:11daakuanyone know of a library to make dealing with temporary directories easier? (like cleaning up after itself)
02:31daakuseems awesome and terrible at the same time: (.getAbsolutePath (doto (java.io.File/createTempFile "tmp" (str (System/nanoTime))) (.delete)))
02:40tomojwhy use nanoTime?
02:41daakutomoj: because that's what the stackoverflow post used in the java example :)
02:41daakuis it expensive?
02:41tomojI'd expect it to be very cheap
02:41tomojjust seems strange
02:42daakutomoj: i agree, nuked it
02:43bobo_only reason i have ever read about using nanoTime, is that currentTimemilis doesnt always have a 1ms resolution, so can give inacurate numbers when benchmarking
02:43tomojI mean, it seems strange to stick a time in there at all
02:44tomojsince createTempFile already ensures uniqueness
02:44daakuyeah, it's just prefix/suffix
02:44bobo_yes indeed, that makes it realy weird.
02:44daakubut oddly it requires a minimum number of characters (in the prefix anyways)
02:46daakuanyone have recommendations for reading/video for clojure "patterns"? i've gotten a bunch of basics down, but still struggling with the mindset
02:53BahmanHi all!
02:55bobo_daaku: not sure its entierly what you wanted, but the sicp lectures are great, and the book. its not clojure, but lisp
02:56daakubobo_: are you talking about these: http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/ ?
02:56bobo_well, yes. there is a newer version somewhere i belive though
02:57bobo_although i realy like that version aswell. its abit of humor to watch computer science from the 80:s
02:58daakuheh
03:00bobo_i think i saw solutions to all the assignments from the book written in clojure on github aswell
03:01daakui found these: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/ -- but i'm not sure if they're newer since the other one's are only via torrent
03:02daakucool, i'll look for that on github
03:02daakui think i came across those at some point
03:02daakuthanks bobo_, you gave me more than enough material :)
03:06bobo_:-)
03:27raekdaaku: as for pattern, I've been looking for some material on that too. one thing that seems to come up repeatedly, is to divide the program into a functional layer, which only operates on immutable data and produces new immutable data, and a "state" layer, where you model how the entities of your program interacts and change over time using clojure's concurrency primitives (var/atom/ref/agent)
03:33raekdaaku: I also recommend the Programming Clojure book by Stuart Halloway, where he not only give a great overview of the language, but also writes about ways of designing programs
03:53zmila(type :>)
03:53zmila,(type :>)
03:53clojurebotclojure.lang.Keyword
04:05esj(map greet #clojure)
04:10LauJensen(-> "jse" reverse greet)
04:10LauJensenWelcome to Geekville! :)
04:13esjlol
04:13javehello
04:13esjso youve turned me into the johannesburg stock exchange.
04:13esjnot sure how i feel about that
04:13javedoes lein support downloading source jars from clojar?
04:14esjno idea, don't use it
04:14tomojwhat is a "source jar"?
04:15javewell, a bundling of the source for a project
04:15javein maven
04:15tomojoh
04:15javesince lein is aparently maven based I thought it might be possible
04:15tomojthe clojure jars on clojars all have the clj source files anyway
04:15javeah
04:16javethats better
04:16esj:)
04:16javeI would like to have something like the jumpt-to-tag functions in emacs work for lein projects
04:16lpetit(str "hello, " (apply str (interpose ", " clojurians)) "!")
04:17tomojjave: it already does
04:17LauJensentomoj: not the aot compiled ones
04:17esjoh dear, what have i done....
04:17tomojLauJensen: huh?
04:17LauJensenthey dont pack the source
04:17tomojhow did they make those?
04:18LauJensenI dont know with lein, but for the previous version of cql, I built it with Clojuresque, which at that time defaults to AOT
04:18javeso, for aot compiled jars, its the same as for plain java jars then? you would need a src jar?
04:18tomoje.g. won't `lein jar` include both the AOT and the clj sources?
04:19LauJensentomoj: yes it will, compiles first then zips
04:19LauJensens/zips/'zips'/
04:19sexpbottomoj: yes it will, compiles first then 'zips'
04:20tomojok, well, M-. will work for _almost_ every jar on clojars, anyway
04:21javethats very nice, ill try it out
04:21LauJensentomoj: yea it should
04:22javeis there any interest in integrating more with the emacs 24 functionality?
04:22tomojlike what?
04:22javelike publishing on elpa.gnu.org, hooking into semantic
04:24tomojpublishing clojure things on elpa?
04:24javeI'm not so familiar with slime yet, so I'm just asking dumb questions
04:25tomojif there is anything new coming for clojuremacsers from emacs 24, I think it would come through slime
04:25bozhidarwell, there is ongoing work
04:25bozhidarno make clojure support part of SLIME central
04:25bozhidarwhich would be nice
04:26javewell, to have slime published on elpa.gnu.org, copyright would have to be asigned to fsf I believe
04:26bozhidarbut Emacs 24 won't feature by itself anything of particular value to clojure developers
04:26javeno but it could
04:26bozhidarmaybe clojure-mode will be promoted to emacs proper, but other than that I doubt anything related will be included
04:28bozhidarjave: no, it just has to be licensed under a GPL compatible license
04:29javethe elpa.gnu.org repos will probably have slightly different rules than the current elpa
04:29javeafaik
04:29javeit will be possible to hook in 3rd part repos though
04:30bozhidarmaybe, but I don't think that would a particularly good idea
04:30bozhidarand I really hope they rework seriously elpa
04:30bozhidarbefore they include it
04:30bozhidarbecause in the moment it's mostly useless
04:30javeits already included
04:31javegood idea or not, its a policy decision
04:31bozhidarhaving it in the bzr repo and releasing it are two different things :-)
04:31bozhidara package manager that cannot track package updates...
04:31javewell, granted
04:32bozhidarto me the most important planned feature is concurrency support
04:32javeit will be interesting
04:32javeI have an imagemagick branch I hope wil lbe merged
04:33javeand the embeddeb widget thing, but that is a long way of merging
04:33bozhidaryes, any gtk improvements are welcome as well
04:33bozhidarthe dvcs enhancements seems promising as well
04:34bozhidarI'm currently using magit, but if Emacs offered something nice built-in I'd probably would have used it
04:35javemaybe you could offer an email for the dev list which magit features should be replicated in vc
04:35javeI have a tendency to jump out to the shell
04:35DeranderI use the shell because I already know how git works there
04:36javesame here
04:36Deranderdoes magit actually add any features?
04:36raekaren't most clojure jars source-only? (since AOT'ed code is -- in worst case -- only compatible with the clojure version it was built with)
04:36bozhidarDerander: it cannot add features, but it makes some things more pleasant to use
04:37bozhidarI personally like a lot the staging/unstaging in magit
04:37bozhidardiff's are also nicer
04:37bozhidarwhen I'm in Emacs I really hate to exit it to do stuff...
04:38javemaybe the concurency support wil render eshell more usable, itd integrate better with emacs
04:38bozhidargranted, I'm not magit expert it seems to me it implements a fair amount of git features
04:38SlantLink to the best way to get a clojure environment up on my box?
04:38Slant(surprised this isn't in the topic)
04:40bozhidarSlant: IDE/Emacs/Vi(m)?
04:40SlantVim.
04:40bozhidarthe "best" way is quite subjective you know :-)
04:40bozhidarsec
04:40SlantDetermined to make that uphill fight.
04:41SlantI do know that emacs is the most common way to write lisp.
04:41bozhidarSlant: http://kotka.de/projects/clojure/vimclojure.html
04:41SlantBut, screw it, worth an attempt. :-)
04:41Slantbozhidar, thanks.
04:41bozhidarSlant: you're welcome
04:42SlantShould I be pulling down the straight clojure jar, or playing with leningen?
04:45bozhidarSlant: lein is highly recommended
04:45bozhidarif you'll be building projects, that is
04:46SlantI will be building projects. :-D
04:46bozhidarmaven has a clojure plugin
04:47bozhidarwhich offer similar stuff
04:47bozhidarand maven 3 has even native clojure support
04:47bozhidarvia the polyglot subproject
04:47SlantI have zero experience with the Java ecosystem. This is all exploratory. :-)
04:47SlantI'm familiar with the fact that Maven is a Java build tool.
04:48SlantThat's about it. ;-)
04:48javeyesterday I noticed something odd in the conjure tutorial. it was something like: (hiccup/h (:text "lala")). that didnt work but didnt produce an error. (hiccup/h "lala") worked, but (hiccup/h :text "lala") didnt. what am I missing?
04:53hoeckjave: if hiccup/h is a plain function, then calling (hiccup/h (:text "lala")) will evaluate to (hiccup/h nil), and in clojure, (str nil) is the empty string
04:54hoeck,(:foo "bar")
04:54clojurebotnil
04:54javehoeck: so its a typo then?
04:55javebut why doe (:foo "bar") evaluate to anytjing?
04:55raek,(get "bar" :foo)
04:55clojurebotnil
04:55raek,(get "bar" 0)
04:55clojurebot\b
04:56raek:foo is not a key of "bar"
04:56raek"bar" has keys 0, 1 and 2
04:56raekget returns nil if the key is not present
04:56hoeckjave: probably yes
04:56javeuhm I sort of dimly see it now. its not like in elisp or so
04:57raek(:key m) does (get m :key)
04:57javeI see.
04:57jave
05:01lpetit,(:foo {})
05:01clojurebotnil
05:01lpetit,(:foo "")
05:01clojurebotnil
05:02lpetit,(doc get)
05:02clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
05:05raek,(:foo {} :not-found) ; hrm, can one do this?
05:05clojurebot:not-found
05:06raekapparently!
05:18AWizzArdCan someone please try this: (.exec (Runtime/getRuntime) "program") where "program" is any application. And then you kill the JVM that started this Process. Is now "program" still running or was it killed too? On Windows I tried it with notepad which is not killed.
05:18AWizzArdI would like to start the process in such a way that it is dependend on my JVM.
05:18bozhidarI doubt that this is possible
05:19bozhidarafter all the process is running
05:19bozhidaroutside the JVM...
05:19bozhidaryou could add a shutdown hook
05:19bozhidarto the jvm that kill the process
05:20bozhidarI'm not sure if the hook will get executed if you interrupt the jvm, though
05:20AWizzArdIt depends on how I kill the jvm.
05:20AWizzArdsigterm seems to be caught by the shutdown hook, while a hard kill isn't.
05:22bozhidaryes, this is natural
05:22bozhidarmost likely the jvm implements some signal handlers
05:23bozhidarbut you cannot handle a SIG_KILL for instance
05:23bozhidar:-)
05:37notsonerdysunny(doc ns)
05:37clojurebot"([name docstring? attr-map? references*]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class ...), when supplied, default
05:42defn,(:foo {:foo "bar"} :not-found)
05:42clojurebot"bar"
05:42defn,(:foo {:bar "bar"} :not-found)
05:42clojurebot:not-found
05:42defnraek: oooh, cool. thanks
05:45lpetit,(:foo nil :nf)
05:45clojurebot:nf
05:46lpetit,(get nil :nf)
05:46clojurebotnil
05:46lpetit,(get nil :foo :nf)
05:46clojurebot:nf
05:46defnheh
05:55notsonerdysunnygoogle code search still does not have clojure!!!!
05:56defnnotsonerdysunny: http://getclojure.org:8080/examples/concat
05:56defnnotsonerdysunny: i dont know how helpful that will be, but it sort of works for finding examples of code
05:57defnreplace concat with the function you're looking for
05:58defnand click the code to see the result
05:58defnnoidi: also check out clojuredocs.org
05:59defnoops, looks like he left..
06:04LauJensendefn: still a good tip, hadn't seen getclojure:8080 before
06:05defnLauJensen: I really need to get back on developing it
06:05defnI sort of hit a brick wall and now I feel sort of overwhelmed by my own code
06:05defnI am having trouble breaking it out into separate functionality
06:05LauJensenouch - Dont hear of a lot of Clojure devs going through that
06:06defni dont like how it is basically a long core.clj
06:07defnsplitting it out i think has mainly been part of a lack of knowledge about using use and require
06:07LauJensenoh - I haven't seen the code, how long is core?
06:07defna few hundred lines
06:08defn250
06:08LauJensenk, thats not bad. Perhaps you need to add a few abstractions, keep them in core and move the rest out into some backend logic namespace(s)
06:08defni guess it's not that big, but there are things lumped in -- i wish i could just make core.clj the bones and then have functionality split out
06:08defnyeah LauJensen i was just thinking that as i wrote that last line
06:09defnmy abstractions just aren't strong enough i suppose
06:10esjYou must become like the Cheshire Cat - you need to work on your dissolving powers ;P
06:10defn:)
06:11defn"Can you stand on your head?"
06:11xkbIn java I use interfaces quite often to introduce abstractions; how would you do it in Clojure?
06:11LauJensendefn: think in terms of DSL then, which fns best describes the work being done.
06:11defnLauJensen: good advice
06:11LauJensenxkb: In this case Im only thinking of some descriptive fns
06:13esjxkb: Protocols and Datatypes are the closest thing I'd suggest.
06:13xkbah interesting
06:14xkbyou quite quickly run into this, when developing something "larger"
06:14esjyes, I've recently learnt that its a good place to start
06:15notsonerdysunnydefn .. My irc client crashed .. can you repost the link?
06:16xkbohhh defprotocol is really nice indeed
06:17raekclojure seems to make a diffrence between things that do stuff and things that are just data
06:18notsonerdysunnydefn .. I found it on the clojure-logs .. nice set of examples...
06:18raekthe "interface" of the data often is something like "x is a map with key :y, which is a sequence of y-things"
06:19raekbut the interface of doer-stuff is more similar to classic OO
06:30LauJensenraek: typically called 'dumb code', the getters and setters which we free from
06:30LauJensen(i mean, free from having to write)
06:30xkbhehe
06:31xkbususally interface don't have getters and setters hopefully ;)
06:32LauJensenhehe, true, not the interface. I meant the typical doer-stuff in OO
06:32esjxkb: or you run screaming !
06:32xkbthat's missing a 's
06:32xkbRight now I'm writing an agregator for several bookservices like LibraryThing
06:32xkband an interface for querying any book service at all would be useful :)
06:33xkbso that other people in the future can add new book services like amazon or whatever
06:42javexkb: sounds interesting
06:42javeI'm working on a family library system
06:42xkbah interesting!
06:42xkbI started with librarything as a source for books
06:43xkbthey have a very easy API
06:43xkbAnd I map it to a very simple datastructure, store that in BigTable
06:44javecool
06:44javeI'm not storing only books, but also a lot of different media
06:44xkbIn the future I want to implement several mapping/corelation algorithms
06:44xkbjave: aha, like DVD's n stuff?
06:45javeI will be interested to have a look at your system when you have something
06:45javeI'm storing dvd rips, comics, books, photos, games etc
06:46javemusic of course also
06:46xkbjave: my/our system will be open source, it'll be on google code eventually
06:47javecool mine also if I will ever something that is not completely lame
06:47xkbhehe
06:47xkbI know the problem, at the start so much keeps changing
06:47xkband it's quite hackisch
06:47javeatm is mostly a plain fs interface
06:48javemy aim is to use xattr for tag storage, indexed by maybe virtuoso, and implement some clojure stuff to query it
06:49javebasically I just want a wiki were pages are virtual in the sense that they are created from media entries
07:53bortrebwhat's the best way to do optional keyword arguments for a function?
07:53Chousukein 1.2, use the new destructuring syntax
07:55bortrebso do I end up calling it like (foo 5 :option 6) or (foo 5 {:option 6}) ??
07:56bortreb(foo 5 {:option 6}) looks kinda ugly to me
07:56danielfmbortreb: there's an example here: http://github.com/clojure/clojure/blob/1.2.x/changes.txt
07:57Chousukebortreb: the former
07:58Chousukeif you need to do it in 1.1, you can do it manually using let in the function.
08:01bortrebthanks for the example!
08:06bortrebhmmmm
08:09bortrebbut what if I want to accept an arbitray number of strings followed by optional keyword modifiers? is that possible? something like (shell-command "ls" "-a" "-h" :dir (file-str "/")) is what i'm trying to write.
08:10danielfmbortreb: then your function signature would be something like (defn foo [str1 str2 strN & {:keys [a b c]}] ...)
08:11danielfmi guess :)
08:12bortrebbut it needs to have an arbitray number of strings at the start..... I guess there's no real good way for clojure to know where the strings end and the keywords begin...
08:14rhudsonRight. You can look at the source of clojure.java.shell/sh, which takes just such an arg list.
08:14danielfmbortreb: as a last resort you could have a function (defn foo [& opts] ...) and inside you just (apply hashmap opts) and parse the stuff you get
08:15danielfmbortreb: oh, nevermind.. it wont work with that abitrary strings thing
08:15rhudsonIt calls a parse-args local function, which uses (split-with string? args) to find the split
08:15bortrebI want to do
08:15bortreb(defn gggv ([{:keys [dir]} & commands]) ([& commands]) )
08:15bortrebbut clojure won't let me :(
08:17LauJensenbortreb: {:keys} lets you destructure a map (singular), with '& commands' you're saying that you'll be accepting multiple maps
08:18LauJensen,(let [{:keys [dir]} {:dir 1 :dor 2}] dir)
08:18clojurebot1
08:18LauJensenfor multiple maps, you might want to go with something like
08:18LauJensen,(map :dir '({:dir 1 :dor 2} {:dir 2 :dor 3}))
08:18clojurebot(1 2)
08:18LauJensenAs I suspect you'll want to do some work with the data
08:20bortrebooh the split-with string? is a really good idea
08:20bortrebthat's just what I need; thanks.
08:23BahmanHi all!
08:25LauJensenBahman: Hey
08:25BahmanYo LauJensen!
08:34AWizzArdbozhidar: The solution to my previous challenge is http://yajsw.sourceforge.net/
08:35bozhidarAWizzArd: that's yet another project name that I hate ;-)
08:36bozhidarwasn't there something like jservice?
08:37AWizzArdThere are several of those, but yajsw looks really nice
08:38bozhidaryes, I've browsed through the features and they look impressive
08:38bozhidarthe use of groovy in the implementation is refreshing as wel
08:39bozhidars/wel/well/
08:39sexpbotthe use of groovy in the implementation is refreshing as well
08:39bozhidargood bot :-)
08:47AWizzArdyes, very nice feature set - seems you can make your Clojure app within 3 hours into a service, which runs on Win, Linux, OSX with auto-start, restart, etc.
08:49raekhrm, is EPL + LGPL possible?
08:49samlhey, write json transformation library for me . something like xsl for xml. but for json.
08:49samli'll come back in an hour. this is high priority for business
08:49raekshould be alright, right?
08:50Kaaliraek: IIRC EPL and LGPL are not compatible
08:50samli don't know. licenses are hard. write a program that asks you questions and give you license suggestions
08:51cemericksaml: I think you've confused #clojure with rentacoder ;-)
08:51KaaliBut if the code you release are all under EPL, and just use LGPL libraries, that might be fine.
08:52cemerickraek: I think it depends on the direction of the dependencies.
08:52raekdirection?
08:52cemerickyeah, if you're releasing an EPL project that depends on LGPL libs vs. an LGPL project that depends on EPL libs
08:52raekcan I combine LGPL'ed code and EPL'ed into one program?
08:52raekah, the license of the resulting prograM
08:53cemerickright
08:53KaaliAccording to http://www.gnu.org/licenses/license-list.html, EPL is not compatible with GPL.
08:53cemerickI try to stay away from anything *GPL, just because even LGPL is slightly murky for any commercial redistribution.
08:54raekKaali: yes, but the LGPL s less restrictive
08:54greghyet more murky. :)
08:54raekGPL does not want to be linked with other licenses
08:54Kaaliraek: But just for library use, which is not really well defined.
08:55KaaliMost people I know interpret LGPL as code that can be dynamically linked to your software, even if it's proprietary.
08:55cemerickraek: there's no bsd or EPL or CDDL equivalent lib?
08:55raekI just looked at the yajsw page
08:55raekjust wanted to check whether it would be usable in a EPL'ed program
08:57KaaliUsing it as an library is in the gray area, but the purpoted use (I guess), but just don't combine the code to be a bit more on the safe side.
08:57raekthere's http://commons.apache.org/daemon/ also, which has the Apache license
08:57cemerickThat's what tomcat uses, to good effect. *shrug*
08:58raekI hope that using the documented api of a library is "library use"
08:58raekI would not add features to yajsw itself
09:00raeksomeone should make a license compability graph
09:00raekthat includes more than just any<->gpl
09:00greghI don't think you can represent that in three dimensions
09:00AWizzArdYes, only that the apache daemon requires a few hundred man hours of work to match the feature set
09:01teeshHi, I am just starting off with clojure... trying to parse a XML file using lazy-xml and getting a classcast exception when using with the pull parser.
09:01AWizzArdhttp://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License#Differences_from_the_GPL
09:02teeshThese are my deps from lein:[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
09:02teesh [org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]
09:02teesh [xpp3/xpp3 "1.1.4c"]
09:02teesh [xpp3/xpp3_xpath "1.1.4c"]
09:03AWizzArdFrom the wikipedia entry I see it as: if we use yajsw (lgpl) in our proprietary Clojure programs, then this should be fine.
09:03raekyeah, my thought too
09:04AWizzArdWe are not changing the sources that ship with yajsw and use those.
09:04AWizzArdWe only use what came in the .jar file, without modifying it.
09:04KaaliJust remember to use it as a library, not as source files.
09:04teeshIs this the correct place to ask for help on clojure-contrib exceptions?
09:04Kaali(not a lawyer)
09:05raekteesh: yes, I think so
09:06raekit would be helpful to know what exception was thrown and what its message was
09:06raeki.e. which class could be casted to what class?
09:07teeshI am getting a classcastexception from clojure.contrib.lazy_xml$parse_seq_pull.invoke(with_pull.clj:55)
09:07AWizzArdBtw, anyone here using a fresh Contrib? If so, can you please test: (do (require 'clojure.contrib.io) (clojure.contrib.io/append-writer "/xyz.txt"))
09:09teeshAWizzard: I am getting a Cannot change an open stream to append mode. [Thrown class java.lang.Exception]
09:09AWizzArdexactly
09:09teeshAwizzard: mine is org.clojure/clojure-contrib "1.2.0-SNAPSHOT"
09:10AWizzArdThe cause of this in my (a few weeks old) clojure-contrib.jar from http://build.clojure.org/ is that there is a binding problem.
09:11AWizzArdA function binds *append* to false and can pass every assert, but then returns a BufferedOutputWriter or something similar. This moves out of an inner binding into one in which *append* is set to true and does the assertion test again, which then fails.
09:11AWizzArdteesh: how old is your clojure-contrib.jar?
09:13teeshteesh: yesterday
09:13teeshAwizzard: yesterday
09:16AWizzArdgood, then I will create a ticket for that
09:47teeshhi Can someone please help with a classcastexception in lazy-xml (from contrib) when using with xmlpull parser?
09:54raekteesh: what does the exception say?
09:56raek,(first 1)
09:56clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
09:57raek,(+ "a")
09:57clojurebotjava.lang.ClassCastException
09:57dnolenteesh: might be helpful if you paste the code and the stacktrace
09:57raekanyway, it should say somewhere what classes it tried to cast from and to
10:22pdk(doc do)
10:22clojurebotPardon?
10:22pdk,(do 1 2)
10:22clojurebot2
10:29pdk,'(list 1 (+ 1 2))
10:29clojurebot(list 1 (+ 1 2))
10:30pdk,'(list 1 ,(+ 1 2))
10:30clojurebot(list 1 (+ 1 2))
10:30pdk,`(list 1 ,(+ 1 2))
10:30clojurebot(clojure.core/list 1 (clojure.core/+ 1 2))
10:30pdkerrgh
10:30raek,`(list 1 ~(+ 1 2))
10:30clojurebot(clojure.core/list 1 3)
10:30pdk!
10:30pdkavast ye
10:30raekcomma is whitespace in clojure... :)
10:31pdk,{:ain't :that, :the :truth}
10:31clojurebotjava.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 5
10:31pdkgod damn it clojurebot dont ruin my jokes
10:42teeshok...finally got a full stacktrace:
10:42teeshCaused by: java.lang.ClassCastException: null
10:42teesh at java.lang.Class.cast (Class.java:2990)
10:42teesh clojure.lang.Reflector.boxArg (Reflector.java:364)
10:42teesh clojure.lang.Reflector.boxArgs (Reflector.java:397)
10:42teesh clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:55)
10:42teesh clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28)
10:42teesh clojure.contrib.lazy_xml$parse_seq_pull.invoke (with_pull.clj:55)
10:42teesh clojure.contrib.lazy_xml$parse_seq.invoke (lazy_xml.clj:49)
10:42teesh clojure.contrib.lazy_xml$parse_trim.invoke (lazy_xml.clj:109)
10:42teesh user$zip_file.invoke (NO_SOURCE_FILE:8)
10:42teesh clojure.lang.AFn.applyToHelper (AFn.java:163)
10:43teeshThis is the exception http://clojure.pastebin.com/hS5bevyz for my code http://clojure.pastebin.com/ik3u2CHz
10:44teeshcan some please help?
10:44teesh*can someone please help?
10:44raekthe topmost line seems to be missing...
10:45teeshraek: I have update the stack trace http://clojure.pastebin.com/2piL692M
10:49raekteesh: what happens if you do a (load "lazy_xml/with_pull") ?
10:50raekor maybe (load "clojure/contrib/lazy_xml/with_pull")
10:51teeshraek: the first errored the second worked
10:51raekko
10:51raek*ok
10:52raekthe exception originates from here: http://github.com/clojure/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/lazy_xml/with_pull.clj#L55
10:52raekI don't know anything about xpp
10:52teeshraek: yes, I saw that :) but could not figure out beyond that
10:53raekbut I guess the .setInput method takes an arg of a type that the object that was passed was not
10:54teeshraek: I am a newbie to clojure, if I understand L55 correctly it calls setInput on the newPullParser created using XmlPullParserFactory/newInstance?
10:54raeksomething like that
10:55raekit calls factory.newPullParser()
10:55raekwhat do you pass as input to the parser?
10:56raekit looks like it accepts a java.io.Reader
10:56teeshits a file
10:56raeka File ?
10:56teeshoh.. ok
10:56teeshgot it I think
10:56raekyou can use clojure.java.io/reader to get a reader easily
11:04LauJensenjust a note, Enlive makes (non-namespace requiring) xml parsing a breeze
11:06LauJensenfor instance, here's 2 small functions which rip an entire wordpress blog into clojure data: http://github.com/LauJensen/bestinclass.dk/blob/master/src/bestinclass/wordpress.clj#L36
11:09raekI saw you blog post on that... very interesting!
11:10raekis enlive a template library for XML/HTML?
11:10raekor what is its main purpose?
11:29pdk,(`(~(+ 1 2) 4))
11:29clojurebotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn
11:30pdk,`((~(+ 1 2) 4))
11:30clojurebot((3 4))
11:32LauJensenraek: I missed your question due to a netsplit. Enlive is 2 things. CSS selectors which you can apply on (malformed) HTML, and templates/snippets which you can use to transform html (sorta like a better version of Pure). Enlive Templates have generated every single page on bestinclass.dk, enlive selectors has pulled out all the data from the old wordpress based site
11:33raekah, ok
11:33raekit uses tagsoup, right? it's an awesome lib
11:33LauJensenthats right
11:33raekI will certainly use enlive next time I need to scrape some HTML
11:34LauJensenyea its the best in the world for that I think
11:34raekthere are such neat libs for everything in clojure...
11:35LauJensentrue
11:44teeshraek: thanks for your help - I have solved my problem:
11:45raekto be able to make an irc bot that prints the titles for urls in less that 10 lines of code is simply amazing...
11:45raekteesh: np.
11:46teeshthis is my working code
11:46teeshhttp://clojure.pastebin.com/88eqT7yc
11:47pdk,(partition nil)
11:47clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$partition
11:48pdkwhat library are you using for irc interface in clojure
11:52dsophow do I count how many iterations in a doseq already happened?
11:53pdk(doc doseq)
11:53clojurebot"([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
11:53pdk(doseq [i [:x :y :z] counter (range 3)] (prn (str i counter)))
11:53pdk,(doseq [i [:x :y :z] counter (range 3)] (prn (str i counter)))
11:53clojurebot":x0" ":x1" ":x2" ":y0" ":y1" ":y2" ":z0" ":z1" ":z2"
11:53pdkumm
11:54pdkguess it nests each seq-expr there
12:02nipra,(for [x [:a :b :c] y [0 1 2]] [x y])
12:02clojurebot([:a 0] [:a 1] [:a 2] [:b 0] [:b 1] [:b 2] [:c 0] [:c 1] [:c 2])
12:02pdkguess that nests too
12:02niprapdk, like `for'
12:02pdk(doc for)
12:02clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test. (
12:03opqdonut,(map vector [:a :b :c] [0 1 2])
12:03clojurebot([:a 0] [:b 1] [:c 2])
12:03pdksimplest way i can think of is turning your doseq loop into a recursive function to iterate over the list and adding a counter as an extra argument to it that you keep track of
12:03raekpdk: irclj
12:04pdknot to be confused with ircle
12:04raekpdk: http://raek.se/trattern.clj <-- my micro-bot
12:04raekhalf of the code is for the cond-re macro
12:24defnooo, neato
12:25defni wonder if there is support for an admin function yet
12:25defnI wrote something that checks your nick before executing xyz
12:25BahmanHi all!
12:27Raynesdefn: ? :o
12:29defnRaynes: i was just wondering if you made some auth system for bot admins
12:30RaynesI believe we talked about that a while back. It wouldn't be hard to add a makeshift admin system similar to sexpbot's (sexpbot has a horrible privileges system -- you're either an admin or you aren't), but it feels like that is something that should probably be worked out by the user.
12:30RaynesPrivilege systems can be very specialized.
12:30RaynesBut a simple admin vs not-admin system would be easy to throw in.
12:41hippondogWhat is a "form"?
12:46kencauseyhippondog: form n. 1. any object meant to be evaluated. 2. a symbol, a compound form, or a self-evaluating object. 3. (for an operator, as in ``<<operator>> form'') a compound form having that operator as its first element. ``A quote form is a constant form.''
12:46kencauseyfrom http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_f.htm
12:47kencauseyclojure is not of course Common Lisp, but I'm certain the meaning is the same
12:47kencauseyexcept perhaps defintion 3
12:48hippondoghmm.
12:55slyrus_I seem to be having trouble with protocol methods with optional arguments. I have to define (foo [arg1] ...) and (foo [arg1 & more-args]) in order to call the 1-arg form.
12:55slyrus_is that expected?
12:58Drakesonis there global variable like *in*, *out* that shows the environment variables? (I want to use binding on it)
12:59rhudsonDrakeson, try (System/getenv)
13:00Drakesonrhudson: (binding [(System/getenv) {}] do-stuff) would not work.
13:02rhudsonThere's a clojure.java.shell/with-sh-env, but that's only for shells. Not sure there's a way to override the current process's env
13:03slyrus_is it possible that protocol methods don't support & args?
13:05raekslyrus_: yes, protocols methods cannot be variadic, afaik
13:05slyrus_Oh, bummer.
13:06raekok, maybe not "variadic", but having a & parameter
13:06raekyou can still have multiple arities, of course
13:14slyrus_it would be nice if defprotocol would bounce arglists with & them then
13:19slyrus_and while I'm griping... Why doesn't print return the value of the thing it's printing? a macro to do same is trivial enough, but I'm used to print returning the thing it's printing (not the printed form of said thing, of course)
13:24raekI don't know about the rationale about that. maybe it's that way to make the side-effect more explicit or something. also, you wouldn't need a macro for that
13:24raek(defn trace-value [x] (do (println x) x))
13:27Kaali,(print-str "foo")
13:27clojurebot"foo"
13:28KaaliQuite common to separate string and stream output.
14:14TakeVIs 1.2 about to be released? I noticed that the github repo hasn't been updated in about five days.
14:16LauJensenTakeV: They keep saying 'soon'
14:19TakeVLauJensen: Ah, cool.
14:20LauJensenWe'll see
14:26pdktakev expect to see it come out in a bundle pack with dnf at a retailer near you
14:37scottjI have a lot of functions that return static pages for compojure and I'd like them to execute during development so if I change a subfunction the ones that use it get updated, but during production it seems that they should just execute once. Has anyone done this? Did you use something like memcached or something at the clojure level?
14:41LauJensenscottj: Depending on how far in the process you are I can let you in on a pro tip. If you build your website using Moustache for routing and Enlive for templating, you can separate all of your page generation into a namespace of its own. Then when you define your routes do it like so (app (wrap-reload '[some.ns.with.templates]) "welcome" handler ...), that way, if you save an html or clj file affected a view, it will be updated during
14:41LauJensendevelopment.
14:42LauJensenI cant advice for Compojure in its current state, but theres a #compojure channel (which is a little more tahn half dead) and then a pretty active google group where I will recommend you to post the question
14:49scottjwell, compojure uses ring too. are your static pages strings or functions? If functions, I don't see how what you mention keeps them from executing on every request
14:50LauJensenEnlive uses statemachines internally
14:51LauJensenAnd yes, the wrap-reload is a ring middleware, so you can use that as well
14:53TakeVpdk: I'm afraid I don't know what "dnf" is.
14:53rhickeygot homemade IPersistentMaps? please try latest rev on github. Fixing record equiality meant introducing a MapEquivalence marker class - you must implement in order to be = to maps (APersistentMap does this)
14:54pdkhttp://en.wikipedia.org/wiki/Duke_nukem_forever now you do
14:54TakeVpdk: Ah, yes...
14:56LauJensenrhickey: Does that means this will be false from here on out? (= {:a 5 :b 10} {:b 10 :a 5})
14:56TakeV(let [coll [1 1]] (identical? (nth coll 0) (nth coll 1)))
14:56TakeV,(let [coll [1 1]] (identical? (nth coll 0) (nth coll 1)))
14:56clojurebottrue
14:56rhickeyLauJensen: why would it?
14:57LauJensenrhickey: ah sorry I misread your sentence
14:57TakeVWait, those both point to the same thing? Or am I missing something on how identical? works?
15:01hoeck,(let [coll [200 200]] (identical? (nth coll 0) (nth coll 1)))
15:01clojurebotfalse
15:02hoeckTakeV: the jvm caches some small integers, in the range of -126 to 127 or so
15:02qbgrhickey: Nice!
15:04TakeVhoeck: Ah, I see. Thank you.
15:39akhudekis it possible to destructure metadata?
15:40akhudeksomething like (let [[a b :meta m] (with-meta [a b] {:some-data 1})] m)
15:40akhudekwhere m would be the metadata for the vector [a b]
15:41LauJensenAFAIK not in one go
15:41LauJensen(let [{:keys [metadata]} (meta (with-meta {:a 5} {:metadata 1}))] metadata)
15:44akhudekhm, ok. I have a few functions that break up a data structure while passing on metadata to sub-structures and being able to bind the metadata right in the function arguments would make them more concise.
15:45akhudekguess I'll have to either live with it or refactor the code in some way
15:46LauJensenor make a new 'let'
16:03AWizzArdrhickey: do Records fall under "homemade IPersistentMaps"?
16:04rhickeyAWizzArd: no
16:06AWizzArdrhickey: btw, would there be performance hits if binding would inherit lets behaviour and allow for sequential binding, so that (binding [x 1, y (inc x)] [x y]) ==> [1 2] ?
16:07AWizzArdI am not suggesting to change the behaviour of binding, but I am curious why it binds its forms in parallel, unlike let.
16:08rhickeyAWizzArd: I'm not particularly interested in enhancing binding
16:12AWizzArdI don't suggest to change/enhance is... I am just curious what led to your descision to give binding the behaviour that it now has vs. a similar one to let.
16:20qbgThe way binding works makes its implementation simpler
16:22AWizzArdok
16:23qbgSequential bindings probably wouldn't be much better anyways
16:25qbgThe difference would only be apparent if one value depended a previous one, which for dynamically bound variables sounds like madness to me...
16:26AWizzArdIt's okay the way it is. I just was surprised when I saw that some bindings did not get the expected values. Today another workmate stumbled upon this.
16:29LauJensenAWizzArd: I think he's dodged that question for months now, I doubt you'll get an answer :)
16:52patrkrisis there anyway, besides nailgun, that clojure programs could be made suitable for use as command line utillities? i'm thinking about the amount of time it takes for java to start, which is unacceptable in many cases I believe
16:54qbgWhat is wrong with nailgun?
16:55patrkrisqbg: i can't think of a specific problem right now, but couldn't it turn out problematic that you need to have a server running?
16:55lancepantzpatrkris: it's not possible without a persistent jvm running
16:56lancepantzthe jruby guys all have the same complaint
16:56qbgUse a java machine ;)
16:56patrkrislancepantz: yeah, you're right - I've read that too
16:56lancepantzif you're looking for a scripting list, you may want to check out newlisp
16:56patrkrisit seems that programs compiled for mono starts pretty damn quickly - perhaps when clojure-in-clojure is realized, it will be possible to target mono?
16:57lancepantzit's half retarded, but it starts up pretty quickly
16:57patrkrislancepantz: heh, half-retarded doesn't cut it :9
16:57patrkris:)
16:57qbgThe CLISP implementation of CL also starts up fast
16:58rhudsonBut if the script is implementing something that takes many seconds to run, the JVM startup isn't a deal killer
17:00dnolenpatrkris: you might want to look at cake, it uses peristent vms, per project as well as a global one
17:00patrkrisrhudson: right - and I've used clojure with success to write a few command-line utils, which was a pleasant experience
17:00patrkrisdnolen: thanks
17:01technomancydalvik? ={
17:01technomancy=)
17:01patrkrisdnolen: sorry, do you have a link for cake?
17:01lancepantzhttp://github.com/ninjudd/cake
17:01patrkristhanks
17:02lancepantzpatrkris: try sudo gem install cake
17:02lancepantzthat is if you have ruby on your system
17:02danlarkinplease please don't use cake
17:03dnolentechnomancy: turns out my issue last night was a project.clj that was pre lein deps deps, eesh
17:03dnolendanlarkin: why not?
17:06drewrthe question is rather why *would* you use cake?
17:07danlarkin#1. the code is ugly #2. it is "compatible" with lein, which means, invariably, that there will be sliiight differences in how they handle project.clj which will be a _nightmare_ for everyone. #3. it's distributed as a rubygem? what?! #4. clojure does not need two functionally equivalent build tools
17:07danlarkinthat was to dnolen, not drewr
17:08drewrand why would you want to persist jvm's across projects?
17:08ninjuddcan't argue with that
17:10lancepantz1) sorry, we're learning 2) we're making an effort to keep it compatible 3) it's easier for people to install 4) it's a dependency based task model, lein isn't
17:11dnolendanlarkin: I don't really see a problem with it. The persistent vm stuff solves integration with simpler editors.
17:11ninjudddrewr: the jvm isn't persistent across projects
17:11dnolenlein offers nothing there
17:11qbgIs there something like cake autotest for lein?
17:11lancepantzdrewr: jvms do not persist across projects, i think you misunderstood something
17:11lancepantzqbg: not that i know of
17:12drewrI was responding to dnolen's "it uses peristent vms, per project as well as a global one"
17:13technomancyqbg: yeah, I think deview does that.
17:13danlarkinWhat does cake do that couldn't have been implemented as a patch (or plugin) to leiningen
17:13dnolendrewr: because you don't want to use swank
17:13ninjudddanlarkin: startup quickly
17:14danlarkinninjudd: because of a persistent JVM? Why couldn't that be written as a lein plugin? In fact.. hasn't it been?
17:15wiresare there any libraries on top of clojure that allow you to express and work with types? like in haskell?
17:15ninjudddanlarkin: not that i know of
17:15dnolendanlarkin: it also uses a fairly fancy socket, uses ruby cause bash scripting is teh suck, has very good symbol completion
17:15dnolennone of which require you to install Emacs or and IDE
17:15dnolensomething a good chunk of the population doesn't care to do
17:16dnolenget over it
17:16danlarkinI don't want to have an internet argument
17:16danlarkinthat wasn't my intention
17:16lancepantzdanlarkin: lein seems to be married to hooks to accomplish task dependencies, it's not a task dependency model
17:17tomojdanlarkin: there's a persistent jvm for lein? :D
17:17technomancytomoj: lein interactive. it's like 25 LOC
17:17lancepantzwe're not trying to fracture the community, but we just couldn't do what we wanted with lein
17:18qbgwires: There is http://clojure.github.com/clojure-contrib/types-api.html, but that may not be what you want
17:18lancepantztechnomancy: lein interactive looks like it's restarting the ant project jvm everytime i run a a new task?
17:18danlarkinI don't have a problem with 2+ clojure build tools per se, I am just seeing a future where people have to write project.cljs in a crazy way because they want more than one build tool to be able to parse it
17:18technomancylancepantz: right, but it's forking from a persistent JVM, so it's negligible time.
17:19ninjuddtechnomancy: not true
17:19technomancywell it depends on your project of course, but the overhead of the new JVM itself is trivial.
17:19ninjuddtechnomancy: dive into how the ant Java task starts the new JVM. it is starting an entirely new process
17:21technomancymeh. the point is it's fast.
17:21wiresqbg: thanks, that's a start. i'm looking for something other that ADT though; e.g. define two functions and then get the type of a composed function, stuff like that- i'm not completely shure when I see a typesystem what it can express or not, i'm no expert
17:22ninjuddtechnomancy: we just timed it this morning, it took 5+ seconds for our project
17:23qbgwires: Heavy typing isn't very idiomatic clojure
17:24danlarkinregardless of how fast (or slow) the lein interactive mode starts up new tasks -- surely we agree that it /could/ be changed to be faster. It doesn't necessitate writing a new build tool (unless I'm missing the point)
17:24tomojwhere is this "lein interactive"? having trouble googling
17:24tomojoh, in edge lein, I see
17:25technomancydanlarkin: how else will new developers get to appreciate the tenacity and thoroughness with which Debian has mangled the installation process of rubygems?
17:25ninjudddanlarkin: that's not why we wrote cake, it's just something we added after the fact
17:25wiresqbg: yes. i'm not looking in particular for typing of clojure in general but i need to work with types themselves, or rather typed values.
17:26danlarkinninjudd: I'm sorry if I'm coming off too interrogative, that isn't my intention at all.
17:26danlarkinwhy did you write cake though?
17:26ninjuddalso, you don't have to use gem to install it, there are two other installation methods.
17:27technomancyah, that's good.
17:27ninjuddthe main reason we wrote it is because we wanted a dependency-based build tool
17:28ninjuddwe wrote it before lein hooks came about, but i'm still of the opinion that dependency-based tasks are easier to use and more powerful than hooks
17:28wiresqbg: in any case, thanks for the hint
17:29ninjuddi actually wrote the first version of cake as a proof of concept to show technomancy... to illustrate how i thought dependencies should be handled in lein
17:29ninjuddbut he chose to go a different direction with hooks
17:31dnolencake also has the most sane Clojure REPL at the moment
17:32pdkwhere's the homepage for cake
17:32lancepantzhttp://github.com/ninjudd/cake
17:33tomojyou think it's saner than slime, or do you mean standalone?
17:33dnolentomoj: standalone
17:33danlarkinin what sense is it more sane than java -jar clojure.jar clojure.main?
17:34tomojstandalone completion does sound awesome, didn't know that existed
17:34danlarkin(serious question)
17:34dnolendanlarkin: you have to use it
17:34dnolenclojure REPL has problems w/o jline, with jline you still have problems
17:34lancepantzdanlarkin: readline support, tab completion, no startup times
17:34danlarkinoh, well I guess you don't need to specify a class with -jar, but you get the idea
17:34patrkrisi'm not an expert in any of this, but what are the advantages of tasks over hooks in this case?
17:34pdknot 100% sure on what you mean by readline support but the startup delay for clojure on console is annoying
17:35lancepantzpatrkris: http://martinfowler.com/articles/rake.html is a good primer
17:35patrkristhanks
17:36danlarkindidn't the author of rake come out and say that his dependency model was a bad idea, and if he had to do it over again he'd not do it again?
17:36lancepantzbut the idea is that if you have 2 different tasks with the same dependency, A, and a 3rd task dependent on each of them, A would be ran twice
17:36technomancy,(doc memoize)
17:36clojurebot"([f]); Returns a memoized version of a referentially transparent function. The memoized version of the function keeps a cache of the mapping from arguments to results and, when calls with the same arguments are repeated often, has higher performance at the expense of higher memory use."
17:37lancepantzdanlarkin: possibly, but the same model exists in ant and maven
17:37technomancydanlarkin: that was the append-on-redefine behaviour specifically.
17:39danlarkinit's important to keep in mind, I think, that clojure is not ruby, and the JVM is dissimilar in a lot of ways to the VMs of scripting languages, and we shouldn't try to treat it as such
17:41lancepantzdanlarkin: i don't follow, do you mean in reference to the repl or task dependencies?
17:42danlarkinI mean as a philosophy
17:42lancepantzi don't disagree
17:44danlarkintrying to get around JVM boot times smells to me like trying to shoehorn clojure into a role it isn't intended to fill. Why are you rebooting the JVM frequently? I hardly ever do, and when I do it's mostly because I did something stupid or need to change my classpath
17:44dnolendanlarkin: sure, but cake's persistent REPL you can always connect back always is arguable *more* Lispy , not less, like connect from many different terminals, again without futzing around with swank or slime
17:45ninjuddtechnomancy: do you have a link for that? i can't find anything about it on his blog (http://onestepback.org/)
17:45technomancyno, just discussions at seattle.rb
17:46technomancyit's one of the main complaints about rake
17:46lancepantzdanlarkin: that's probably a result of my not using clojure-test-mode in emacs, so i was had to wait for the jvm to boot to run my tests
17:47drewryou could have just run (run-tests)
17:48lancepantzso i should use lein but not its test task?
17:48technomancyforms starting with "def" generally mean "give this var a new value." places where it doesn't mean that (defmethod) often cause confusion.
17:48lancepantzor type that over and over in my swank repl?
17:48technomancylancepantz: "lein test" is generally meant for sanity checks (on a clean JVM) right before you check in.
17:49drewryou can use `lein test` to run the whole suite in a repeatable manner, but don't use it for quick feedback
17:49danlarkinnot to pick nits, but how is that different than typing "cake test" over and over
17:49drewrwhen you're in clojure world, just use functions
17:49lancepantznow i just start autotest and it watches for a touched file
17:49drewryour repl is already a command line
17:49lancepantzwhen a file is touched my tests are ran
17:49lancepantzi keep it open in a window on my second monitor
17:49lancepantzit's pretty cool
17:50drewryou're trying to bring ruby world to clojure world and worlds are colliding
17:50lancepantzapparently
17:51lancepantzi'm just trying to optimize my workflow, i don't think your suggestions do that
17:51danlarkinI do not intend this to come off as condescending, but I think you aren't understanding that there are better ways to do this in clojure
17:53lancepantzno its ok, i take no offense, i just don't understand what that better way is
17:53danlarkinyeah I just don't want this to devolve into internet argument time, which wouldn't help anyone. I'm glad we can keep it productive
17:54drewrlancepantz: I don't know your workflow, but off-hand I'd say write a function that loads your code, runs the tests, plays a golf-clap.wav, whatev
17:55drewryou could have it block, waiting for modifications to a file, and then call
17:55danlarkinso In Emacs Land™ we just use clojure-test-mode to run, tweak, run, tweak, all inside the same jvm (running through lein swank). If you don't want to use emacs I'm sure there's a similar workflow
17:57DrakesonDoes clojure.main differentiate between loading foo.clj and running (as a script) foo.clj? How could foo.clj know which case it is, and behave accordingly?
17:57technomancynobody's really taken charge of making nailgun integrate with lein; probably because the vimclojure author uses gradle.
17:58ninjuddi didn't realize the motto of the clojure community was: There's Only One Way to Do Things
18:00dnolenninjudd: it's not, keep up the good work
18:02danlarkinregardless of the merit of this persistent jvm stuff (which I don't get, I guess, but I'm willing to concede), I am still worried about two build tools with different philosophies trying to use the same project description file (project.clj)
18:02tomojDrakeson: what's the difference between loading foo.clj and running it as a script?
18:02tomojoh, I see what you're asking maybe
18:03technomancyDrakeson: no, still waiting for ticket #315 to get merged.
18:03dnolendanlarkin: having used both I haven't found this to be a problem in practice. Because I'm not usually building *other* people's projects. I'm just including them as deps. lein and cake work pretty much the same way there, that's a good thing.
18:03danlarkindnolen: they work pretty much the same *today*
18:04lancepantzi can see it getting troublesome with the additions of tasks to project.clj, i do have some concerns there
18:04danlarkinthey'll undoubtedly diverge, and then it's awful party for everybody
18:04technomancydanlarkin: polyglot maven has already gone down that road
18:04danlarkinand that was a huge mistake too
18:05danlarkinluckily that remains unreleased
18:05ninjuddi would encourage everyone to put their deftask calls in build.clj rather than project.clj
18:05dnolendanlarkin: projects that want to interoperate will use the compatible subset or provide different build files. or people will submit them.
18:05lancepantztasks between the two projects are pretty unreconcilable though, so that problem is most likely going to exist anyways
18:06danlarkin"compatible subset" is a bad road to go down, imo
18:06lancepantzif people actually end up using cake, it may make sense to standardize task definitions between the two projects
18:06Drakesontechnomancy: thanks, that's cool. what is holding it back?
18:06technomancyDrakeson: patches take a loooooong time to get applied.
18:06technomancyI have learned this the hard way
18:06lancepantzbut i'm honestly not sure people are going to use cake instead of lien
18:07technomancyeven if the original author of the lib being patched says to apply it =(
18:07Drakesontechnomancy: btw, could something be done about *env* ?
18:07Drakeson(binding [*env* {"PWD}
18:07Drakesonoops!
18:07rhudsonDrakeson: basically the JVM doesn't support that.
18:07Drakesonas in, (binding [*env* {"PWD" "some/other/place"}] (do-stuff))
18:08dnolenlancepantz: TextMate people will I guarantee that
18:09dnolenwhich means pretty much any Ruby shop that wants to integrate Clojure that doesn't use Emacs
18:09danlarkinlancepantz: when you make code public, people are probably going to use it. Being unsure about whether people will use your code is a bad reason to have that code potentially screw you in the future if you do
18:10Drakesoncurrently, I am working around that limitation in a most ugly way. (interning *env* and wrapping all my filesystem path calls in something that looks at (*env* "PWD"))
18:11lancepantzit's in sync with lein's project.clj now, if people use cake, i'll keep it in sync
18:11Drakesonas in, (spit (fs-path :home "some/place") stuff).
18:11DrakesonCan I intern something in clojure.core ?
18:12technomancyDrakeson: yes, but the correct question is "May I?"
18:13Drakesonoh, I just thought you might have already came up with a solution :D
18:13danlarkinlancepantz: I understand that you think you'll be able to keep them in sync, but what if they diverge incompatibly. Then it's a mess
18:14lancepantzso what is the solution?
18:14danlarkindon't share the same project description file between two build tools
18:14ninjuddlancepantz: i'm not so sure keeping them in sync is important, the point of being compatible is so that people who use lein now can try cake with minimal effort
18:15ninjuddyour readme for your project should explain which build tool should be used for hacking your project
18:16tomojmaybe it would be better to provide something that generates a cake.clj (or whatever) from a project.clj
18:16tomoj?
18:16ninjuddif i am hacking on a project that uses lein, i will use lein. if i'm hacking on a project that uses cake, i'll use cake. other than that, it doesn't really matter
18:17ninjuddboth push jars to clojars, like dnolen said, that is the important thing
18:18lancepantzi don't think thats a bad idea tomoj, but, i am a fan of being able to use either with no additional overhead
18:19tomojyour additional overhead is in the future when things go awry :)
18:19lancepantzlein seems to be pretty mature, and technomancy seems hesitant to do breaking changes, so i dont think it will be difficult to keep them in sync, i could very well end up being horribly wrong though
18:19ninjuddtomoj: that doesn't really solve the problem though. now users have to keep both project.clj and cake.clj in sync
18:20tomojnow users should just pick one and stick with it
18:20tomojsimilarly we can now either have a pom.xml, a project.clj, or try to keep them in sync
18:21lancepantzanyways, i have to get some work done, thanks for all the feedback
18:22ninjuddwhat about adding a key to you defproject, something like :lein version or :cake version? i'd be happy to print a warning if you try to run cake on a project.clj that explicitly specifies the lein version it depends on...
18:23lancepantzi'm sorry if we're doing something bad by fracturing the community, we built cake for ourselves inline with our philosophies- if we could have patched lein to achieve what we wanted, we would have
18:23ninjuddor i could just print a warning if you use an option that isn't supported
18:25ninjuddthe way i see it, the more cool projects there are in clojure, the better. people should use what they like. competition is good for the community. if cake's purpose is to make lein better, then everyone benefits. but there is room for more than one build tool, and i'll never beg someone not to use lein
18:25danlarkinI don't doubt your intentions are pre
18:25danlarkinpure, rather
18:27tomojI'd be happier if project.clj was a fallback for cake
18:28tomojif they're really in sync and as long as this is true, I guess it doesn't matter to me, though
18:33ninjuddtomoj: i just want people to be able make projects that work with both cake and lein if they want
18:34tomojhmm
18:35tomojI get no output on `cake help`
18:36ninjuddtomoj: hmm, how did you install?
18:36tomojgem install
18:37lancepantzwhat about cake version?
18:37tomojseems like the project.clj's are already out of sync
18:37lancepantzlol
18:37tomojif I add swank-clojure to my :dev-dependencies, then no output from `cake help`
18:37tomojotherwise, it's fine
18:37tomoj0.3.4, btw
18:38ninjuddtomoj, do you mind sending me your project.clj so i can debug?
18:40ninjuddtomoj: or file an issue on github
18:41tomojand now I'm swapping
18:41tomojwheee
18:41tomojtoo much cake
18:42tomojninjudd: https://gist.github.com/e2477a167f2fb81b5660
18:42tomojthat's the one I was trying to be evil
18:42tomojis :source-path respected?
18:44ninjuddtomoj: that project.clj seems to work for me
18:44ninjuddbut i'm on 0.3.5-SNAPSHOT
18:45tomojeven this one https://gist.github.com/5d2895a87239adc019ef doesn't work for me on 0.3.4 :(
18:45ninjuddi'm installing 0.3.4 with gem now to test
18:47tomojI'm installing from master to test :)
18:47ninjuddtomoj: yep, you're right. looks like a problem with the gem install
18:47tomojI think somehow 0.3.4 spawned very many jvms
18:48tomojover 2GB of memory in jvms
18:48ninjuddhow many different projects did you run it in?
18:48tomojjust one
18:50ninjuddps x | grep cake | wc
18:50tomojhmm, even on master I get no output sometimes from `cake help`
18:51tomojright now that's "5 71 2114", killed all the ones that were making me swap
18:52tomojok, now it seems to be working
18:53ninjuddone is the grep... what is -Dcake.project for each of the others?
18:53ninjuddps aux | grep cake
18:53tomojbut :source-path isn't respected, so the project.clj's are already out of sync
18:53tomojall the same
18:54tomojtwo for bake, two for cake
18:54tomojeach (bake and cake) has an 'sh -c java ...' and a 'java ...'
18:54ninjuddah, so only two JVMs
18:54ninjuddthat's right
18:55tomojyep
18:55tomojI killed the ones that were making me swap
18:55tomojmaybe I wasn't waiting long enough for the servers to come up?
18:55tomojif I can repro again on master I'll let you know
18:55ninjuddok, thanks
18:56tomojclutch for example is incompatible with cake
18:56ninjuddthe JVM should start up within 5 seconds
18:56tomojbut I guess :source-path is pretty uncommon
18:57ninjuddyeah, we chose to leave out customized source paths until someone requests them
18:58tomojI took "compatible with leiningen project.clj" to mean "compatible with sample.project.clj"
18:58technomancyninjudd: I delayed on that a long time too. =\
18:59technomancynever did get a good reason as to why they should be supported.
18:59ninjuddtechnomancy: good for you ;)
18:59tomojclutch uses it because they're using maven as well
18:59technomancyso customize it in pom.xml =)
18:59tomojheh
19:01tomojgot my `ps x | grep cake | wc -l` up to 15 by just running `cake help` over and over
19:04ninjuddhmm, what platform are you on?
19:04ninjuddjust ran 'cake help' 100 times and i still only have 2 JVMS
19:05tomojubuntu 10.04
19:05tomojdid you try it from scratch?
19:05ninjuddyou mean in a new project?
19:05tomojwith no jvms already up, I mean
19:05ninjuddyes
19:05tomojhmm
19:05ninjuddbut in the same project
19:06ninjuddi'll log in to an ubuntu server and give it a try
19:06ninjuddi'm on OSX
19:06tomojI'm guessing the first `cake help` somehow returns before the server is really up, so the second creates another
19:07ninjuddare you running them in the same shell?
19:07tomojyeah
19:07ninjuddi bet you're right, the timeout may be too slow for your machine
19:08ninjuddit currently waits 10 seconds for the JVM to come up
19:08tomojah
19:09tomojyeah, netbook :(
19:15ninjuddtomoj: yeah, that is it, i lowered to timeout to 2 and reproduced the problem on my machine
19:15ninjuddtomoj: thanks for helping me figure it out!
19:16tomojsure, don't want people swapping because of their build tool :)
19:17lancepantztomoj: but that's part of our philosophy!
19:17lancepantzif your computer sucks, we're going to disk baby
19:17lancepantzbringing it down
19:47SlantI'm having an issue with my classpath, but I can't figure out how it's choking. http://quad.pastebin.com/UY6aBp1g
19:47SlantI'm do a lein run script/run.clj
19:48Slanthttp://quad.pastebin.com/mgEy9htE
19:48SlantThat's the traceback.
19:48SlantIt looks like a classpath issue.
19:48SlantBut I don't see why it isn't picking up jetty.
19:49SlantI've done "lein deps"
20:10tomojSlant: when you run with a filename, it doesn't use your classpath
20:11tomojtry defining a function which starts the server instead of doing it in the toplevel in that file, and then use `lein run your-namespace your-function` instead, like the example at http://github.com/sids/lein-run
20:15Slanttomoj, using that method, then, do I have to put all scripts under src/ to be picked up?
20:16tomojyeah, I guess so
20:16tomojseems like lein-run should be patched so that it loads the file in the project's jvm
21:48pdk(doc prof)
21:48clojurebot"clojure.contrib.profile/prof;[[name & body]]; If *enable-profiling* is true, wraps body in profiling code. Returns the result of body. Profile timings will be stored in *profile-data* using name, which must be a keyword, as the key. Timings are measured with System/nanoTime."
21:56Raynes,(clojure-version)
21:56clojurebot"1.2.0-master-SNAPSHOT"
22:08leimyFor clojure programming. Eclipse or Emacs?
22:08RaynesEmacs is awesome.
22:08ninjuddi'm partial to emacs
22:09leimySo I should get the clojure mode stuff and swank-clojure?
22:12tomojif you already are comfortable with emacs, there's really no contest
22:12leimythat's what I figured
22:12leimybut I didn't use ELPA (I think that's what it's called) and I wanted to get swank-clojure working :-)
22:13leimythe docs seem to assume that's the only way to go.
22:13tomojsome instructions here http://github.com/technomancy/swank-clojure
22:13tomojoh
22:13tomojyeah, I don't know how to do it the non-ELPA way :(
22:13leimyheh
22:13leimyit's just that I have a lot of elisp I've already installed for myself here locally
22:13leimyand a nice .emacs.d structure
22:13leimyI don't want to throw it out for some packaged solution just yet :-)
22:14tomojelpa won't mess that up
22:14leimybut I would if someone said ELPA kicks ass! :-)
22:14RaynesELPA is the easiest way for Emacs beginners, and that is the priority.
22:14tomojcertainly doesn't kick ass
22:14leimymakes sense
22:14tomojif you already have slime installed, I don't think the elpa way will work anyway
22:14leimydidn't think so. I do have slime
22:14leimyand it's hooked to SBCL
22:14leimywell via my configs it is.
22:15tomojhmm
22:15tomojwell, does it really even matter?
22:15tomojyou don't need swank-clojure.el
22:15leimyIf I want to do live interaction with the clojure REPL via slime I do don't I?
22:16tomojjust clojure-mode, which is easy to install, then try M-x slime-connect ing to a lein swank
22:16leimyah
22:16leimyhmmm
22:16tomojno, you don't
22:16leimyI guess I need a lein swank instance
22:16tomoj(at least.. with the ELPA way you don't. but I don't see why it shouldn't work with your own slime)
22:16leimyIsn't that a part of swank-clojure though?
22:17tomojyou need swank-clojure in your lein project's :dev-dependencies
22:17tomojyou don't need any swank-clojure stuff in emacs though
22:17leimySee I'm really new to clojure... I don't even know about the project setup stuff yet.
22:17leimyso it seems I must learn clojure to learn to use clojure :-)
22:17tomojhttp://github.com/technomancy/leiningen
22:17tomojreally simple install
22:17leimyCool
22:17leimythanks for the help so far by the way!
22:18tomojthen you can `lein new fooproject` and edit your project.clj to look like https://gist.github.com/83edb6c1401297c39b53
22:18tomoj`lein deps`, `lein swank`, and then M-x slime-connect
22:19tomojgood luck
22:20tomojthere's also cljr (http://github.com/liebke/cljr) for non-project-oriented work
22:20tomoj(and it can also start swank servers)
22:22leimyAh I've got a bit to learn about lein. This is really neat.
22:24SlantDoes cljr support the same clojars that lein does?
22:24SlantYes.
22:25tomojafaik there is only one clojars
22:25tomojwell, I guess you can run your own
22:56technomancyleimy: swank is pretty different in clj-land from CL since you can't alter the load-path at runtime, but the main difference you have to remember is just to use M-x slime-connect instead of M-x slime
22:56technomancyas long as you've got that down you're clear for working on lein-based projects
23:01technomancyso Clojure's reader doesn't honor non-breaking spaces
23:01technomancytrying to decide if I should report that as a bug or just suck it up.
23:03rhudsonWhere/how were you trying to use a non-breaking space?
23:04technomancyoh man, I was afraid you were going to ask that.
23:05technomancyso here's the deal
23:05rhudsonconfession is good for the soul
23:05technomancywine strips off quotes from its arguments. so when you say java -cp [...] clojure.main -e "(use 'leiningen.core)(-main)" it sees "(use" and "'leiningen.core)(-main)" as two separate args.
23:06technomancybut bash doesn't treat non-breaking spaces as whitespace. so if I used one of those to separate the args, it would be treated as a single token.
23:06technomancyand Clojure should be able to DTRT
23:06technomancybut it doesn't. because it uses Character/isWhitespace, which is as old as the hills. and also stupid.
23:07rhudsonnice try
23:07technomancygruesome details: http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Character.html#isWhitespace(char)
23:07technomancyit would have been super-slick if it had worked.
23:08technomancyof course, if ticket #315 were applied it wouldn't be necessary. but that's been open since April. =(
23:08rhudsonI saw a mention of that earlier today. How would I go look at that?
23:09technomancy,ticket #315
23:09clojurebotjava.lang.Exception: Unable to resolve symbol: ticket in this context
23:09technomancy~ticket #315
23:09clojurebot{:url http://tinyurl.com/37u5rdb, :summary "Add support for running -main namespace from clojure.main without AOT", :status :test, :priority :normal, :created-on "2010-04-25T03:04:43+11:00"}
23:09rhudsonAnyway, if you're trying to work around wine, couldn't you just as well use some non-whitespace character & replace it once you got into clojure?
23:09technomancyanyway, the patch is there ready to be applied; unless you've got commit rights there's not much you can do.
23:10technomancyI could if I AOT'd a -main instead of using clojure.main, but I was trying to avoid that.
23:13technomancynormally I don't complain about patches taking a long time to be applied, but in this case the patch was written by the author of clojure.main... taking someone's lib and putting it in your software and then refusing to apply their fixes is not so great. =\
23:14rhudsonyow
23:22technomancyanyway, you should all explore the Unicode character plane in your free time; it's very rewarding.
23:23rhudsonI've browsed it a lot; yeah, it's pretty fascinating
23:32technomancy~ticket #419
23:32clojurebot{:url http://tinyurl.com/28ngbwe, :summary "LispReader uses Character.isWhitespace rather than Character.isSpaceChar", :status :new, :priority :lowest, :created-on "2010-08-04T22:31:13-05:00"}
23:32technomancyfor better or worse.
23:55SlantThe difference between :require and :use is the latter binds the variables in the loaded namespace into the current namespace, right?
23:55SlantWhereas in require, you have to refer to the referred.namespace/method ?
23:56RaynesPretty much.
23:57RaynesIn require, you can use :as to create a qualifier. For example (in (ns ..)) (:require [referred.namespace :as rn]) and then you can use stuff in referred.namespace like so: rn/method
23:57SlantGotcha.
23:57RaynesIt also works outside of the ns form, of course (require '[referred.namespace :as rn])