#clojure logs

2010-01-29

00:26dakronehaving some classpath problems with clojure-couchdb, not sure the best way to get it loaded, into a REPL, trying to do this: http://pastie.org/799971
00:27dakroneanyone know what I'm doing wrong?
05:19Hali_303when I do a for comprehension, the side effects of the body is not executed until the resulting list is used,right?
05:19Hali_303how to force execution of side effects?
05:20esji think do-run
05:20esjor do-walk
05:20Hali_303(I need to call a Java method for every element of a list)
05:20esjis what you're after - not ever used them
05:21esj(doc dorun)
05:21clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
05:21esjdowalk holds onto the head
05:22Chousukedoall
05:22Chousukenot dowalk :)
05:22ChousukeHali_303: if you're using for for side-effects, consider using doseq instead
05:23Hali_303thanks all, i'll try these
05:23ChousukeHali_303: it supports for-like syntax but does not generate any lazy seqs
05:23Hali_303nice
05:23RaynesI hate when people ask questions in the form of a statement.
05:23esjdo what Chousuke says, as I say, I've not actually used these
05:23Raynes"How to do this"
05:23Hali_303you mean you miss the question mark?
05:24ChousukeI sometimes simply forget the question mark :P
05:24RaynesNo, it's the 'how to' part that's silly.
05:24RaynesLike you're about to explain how to do what you mention. :p
05:24RaynesWhen in reality you're asking how to do something.
05:25RaynesAnd are you sure it isn't doseq he's looking for?
05:25RaynesI'm not sure he needs to use for at all.
05:25Chousukeright. As I suggested :)
05:25RaynesOh, I didn't see that.
05:25Raynes:p
05:51esjthe coffee on Friday is never strong enough
06:46RaynesLauJensen: I just read your Python vs Clojure comparison. Joyful read. I'm going to post it on dreamincode.net, so you might get a little attention in the comment section. ;)
06:46RaynesAt least, I'd like to post it there if it's alright with you.
06:46Raynes(A link, not the text of course.)
06:49LauJensenRaynes: Rich Hickey prefers that we avoid direct comparisons, especially those with value judgements such as the ones I make in that post, so if you want to respect his oppinion its best to leave it alone - I'm personally a little torn on the issue, because 1) I dont want to step on anybody to promote Clojure, but 2) There are people who benefit from hearing others (in this case my) experience and the resulting conclusion
06:50RaynesWell, you see, there is a little problem here. I kind of accidentally hit the post button before you replied. :|
06:50RaynesLauJensen: I'll add an explicit note about this situation.
06:51LauJensenOk :)
06:55LauJensenI'm not sure how much it will hurt, but its important to distance Rich from those kinds of posts. What has happend with most of the comparisons is that a multitude of people write counter-blogposts showing of certain feats of their language which the feel weren't represented, and I encourage that
06:56RaynesLauJensen: That's exactly what I did. I posted what you said, minus the "respect his opinion" bit, because I don't want to look like an asshole.
06:56LauJensenhehe - got link ?
06:56Rayneshttp://www.dreamincode.net/forums/index.php?showtopic=152675
06:57RaynesOf course, I added a bit myself, basically saying the same thing.
06:58RaynesIt's late, so nobody has read it yet. If you see anything in need of changing, I could do so.
06:58LauJensenLooks fine
06:59LauJensenMy last post even got linked on climateaudit.org :)
06:59RaynesHah. Nice.
06:59spariev_lol
06:59LauJensenyea :)
06:59neotykLauJensen: nice way to promote :)
07:00LauJensenYea - I got about 7300+ visits yesterday from people who were interesting in the weather report via Clojure :)
07:01RaynesHaha.
07:01LauJensenIts not _huge_ but I think its pretty good for a blog which targets such a narrow audience, lispniks on the jvm
07:01RaynesI don't believe my website has had that number of visits... Well, ever.
07:03RaynesI has a 40% off code for Joy. :D
07:03LauJensenWow you got a discount on a book that isn't written yet?! :)
07:03esjRaynes: good move. Tremendous book
07:03rsynnott"Whenever a human being exhales they emit CO2 so the Carbon Tax is in effect a tax on life." - no it isn't. *mutters*
07:03LauJensenI'm really looking forward to that book, but I wish they would pmap it and have it done by feburary
07:04esj(inc Lau)
07:04Raynesesj: I'll be purchasing the ebook version on the 1st.
07:04LauJensenrsynnott: Is there where I drop the ever powerful "yes it is" argument, or do you explain further?
07:04rsynnottheheh
07:04RaynesI never buy print non-fiction print books.
07:05rsynnottno-one is planning on taxing CO2 emissions from humans (as in, from human biological function). Anyway, not really on-topic
07:05rsynnottInteresting post, though
07:06LauJensenrsynnott: We hosted the Climate Conference here in Denmark recently, and I believe it was in that setting that the Chinese said that Climate changes could not be a separate issue from population control as every person emits CO2 - So the first talks about it have already begun
07:06LauJensenBut I agree its OT - Thats why I don't jump into the political comments - I just wanted to roll a big data set
07:06Raynes#globalwarmingnonsensenobodyintheclojurechannelbutlaujensonandrsynnottreallycaresabout ;)
07:06esjIs it an anti-pattern to have a map containing functions that operate on other members of the map ? I have this feeling I have just created an object accidentally.
07:07LauJensenesj that sounds awful
07:07esji agree
07:07esjhere's what I'm trying to do. I have a dataset, that lives in a sorted-set-by. I'd like to be able to specify verifier functions, so that when that sorted-set is conj'd to, it runs the verifiers for it
07:08esjI feel maybe I should be passing them in to the conj'ing function, and closing over them
07:08esjreturning a conj-only-this-sort-of-data function
07:08LauJensenAre you conjing from multiple functions since you cant implement the validation alongside the conj?
07:09esjyeah
07:09LauJensen(->> input (filter conjoinable?) (map my-previously-nasty-fn)))
07:09esjthis makes sense
07:10esjso the idea is to keep the dataset a dataset, and wrap functions
07:10esji was horrified when I saw what I'd done.
07:11esjthanks Lau
07:21CalJunior'(map [1 2 3] '(1))
07:21CalJunior,(map [1 2 3] '(1))
07:21clojurebot(2)
07:21CalJuniorhow do I do this in reverse?
07:22CalJuniorcall the value and get the index(/indices)
07:26mtdif I (add-classpath ...) a java source directory will clojure be able to give me line numbers for java exceptions (thrown by said java classes, of course)?
07:48djpowellhmm i have some code that does stuff with a big hashmap with loads of litle struct like maps inside. it seems to use quite a bit less memory in clojure 1.1 than 1.0 - is that expected?
08:41chouserrhickey: I keep having to moderate your messages to the group.
08:41chouserseems so silly
08:42rhickeychouser: don't worry about mine - I'll flush them through after I've posted.
08:42chouseroh, ok.
08:43rhickeyIt looks like Google has fixed the impersonation problem, and I've unmoderated MB's account since I haven't seen any spam via his name in a while
08:43chouserah, great.
08:43rhickeyNor mine, but I remain cautious
08:45AWizzArdWhen I want to dynamically create functions for which I want to type hint their parameters its done best with a macro and with-meta, yes?
08:46AWizzArdor: i basically want to do: (defn foo [(with-meta 'x {:tag String})] x)
08:46chouserThe way macros are usually used is not what I would call dynamic. Usually they're expanded at compile time.
08:47AWizzArdI just wrote a working macro for that, but it is using gensym and tags those.
08:47ampleyflyso, I'm trying to build clojure-contrib from source. all the pages I find talk about clojure-contrib.jar, but I get no such resulting file, are the pages outdated or is something wrong?
08:47AWizzArdchouser: well yes.. though as soon a jvm with clojure is running then compile time always happens during runtime.
08:47jcromartieAWizzArd: unless you AOT
08:48AWizzArdi thought aot also starts first Clojure
08:48jcromartiewhen you set out to do it, yes
08:48chouseryes, you can compile things at runtime and of course evaluate things at compile time, but that does not mean they are the same thing. The distinction is useful and practical.
08:49chouserhm.. though intertwined. perhaps I'm being pedantic.
08:49AWizzArdyes, I agree and don't want to suggest anything in this regard. I just wonder if (defn foo [#^String x] x) can be expressed by using with-meta
08:50AWizzArdI agree to what you said before, and not that you are pedantic.
08:50AWizzArd:)
08:51AWizzArdI want to generate lists and (eval them) to produce functions that are used as comparators for sorted maps/sets and are type hinted.
08:51chouserThat test, when read, produces roughly the same form as when evaluating `(defn foo [~(with-meta 'x {:tag 'String})] x)
08:51AWizzArd(compare) is nice too, but I suppose that compare needs to rely on reflection.
08:53AWizzArdAs I see it the reader is doing the necessary magic to tag x in (defn foo [#^String x] x)
08:53chouseryes
08:53AWizzArdAnd this can't be done by using with-meta without another eval
08:56AWizzArdok, then my macro is fine I think
08:56AWizzArdit works, and I only wanted to make sure that I didn't miss a more elegant solution.
08:56chouserno
08:56chouserwell, I'm not sure.
08:56chousercan you paste your code somewhere?
08:57AWizzArdUnfortunately not right now.
08:57chouserif you're building that form to pass to eval, you shouldn't need *another* eval
08:57chouserif you're building that form in a macro, you shouldn't need eval at all.
08:57AWizzArdI am not using eval. My strategy is different:
08:59AWizzArdI gensym a symbol. I tag it to be a String (for example). This symbol I insert into (fn [here] ..)
09:00AWizzArdAnd indeed, if I pass Object into my macro i get a reflection warning. If I pass in a String Clojure is silent, and my function parameters indeed have the type tags.
09:00cemerickcgrand: looks like I need to do (eval (compile-selector some-selector-binding)) in order to get the FSM for a bound selector value?
09:01mikemDoes anyone know whether Rich Hickey's presentations (clojureforjava.pdf, clojureforlispers.pdf, etc) in the Google group files section (http://groups.google.com/group/clojure/files) are liberally licensed? ie: can I re-use the material for my presentation?
09:05rhickeyso, I'm dreading pulling contrib (the version I have builds with ant just fine). What is going to happen to me?
09:05chouserrhickey: just make sure you have maven installed and a good fast internet connection
09:05jcromartierhickey: Maven is going to pull down the entire internet as a dependency at every phase.
09:06jcromartiei.e. things like *clean* is a dependency that it has to download
09:06jcromartiebut it works :)
09:06chouserrhickey: but Stuart S. fixed up the pom and the README so building it against your own clojure.jar should be no problem.
09:06chouser(once you have maven and it has fetched its copy of the internet)
09:07AWizzArdfunny :)
09:07rhickeywhat's current maven?
09:07cemerickstick with 2.2.x
09:07chouserI think readme just says you need 2-something
09:07cemerick3.x is not fully baked yet
09:10mikemrhickey: your slides at http://groups.google.com/group/clojure/files don't say how they're licensed... would I be able to use some of the contents for my presentation to a local functional programming group?
09:11rhickeymikem: with acknowledgement, sure
09:11mikemrhickey: yep, of course with acknowledgment :) thank you
09:11ampleyflydo you get the clojure-contrib.jar-file when building with maven?
09:11AWizzArdWhen I have a sorted-set/map, is there then a way to access its comparator fn?
09:12AWizzArd,(meta (sorted-map-by compare))
09:12clojurebotnil
09:13chouserAWizzArd: (.comp the-map)
09:14AWizzArdis it correct that functions don't have metadata?
09:14chousernot anymore!
09:15AWizzArdSo, I can add type hints to already existing functions?
09:17AWizzArdoh, you mean metadata for functions was removed?
09:18AWizzArd,(meta (fn [a] a))
09:18clojurebotnil
09:18chouserno, you were right that previously you could not add metadata to an existing function
09:18chouserin the master branch, you now can.
09:19AWizzArdYesterday I downloaded Clojure from http://build.clojure.org/ and that version does not give me metadata on fns yet.
09:19chouserhowever, the compiler does not appear to check the :tag of anonymous functions
09:19AWizzArd,(meta (fn xyz [a] a))
09:19clojurebotnil
09:19chouserfor me, (meta (fn [a] a)) returns e.g. {:line 36}
09:20AWizzArdyes, in my Clojure too
09:20chouserwell, that's metadata on a function.
09:20AWizzArdyes
09:21AWizzArdso, functions that were defn'ed will give me access to the arglists metadata
09:21AWizzArdrhickey: is it better to not make metadata of anonymous functions available?
09:21AWizzArdas in :arglists
09:22mikemI'm getting a "failed to validate POM for project" when trying to build clojure-contrib (latest git)
09:22rhickeyAWizzArd: what is the question?
09:22mikemI'm building against a local clojure.jar as specified in README.txt
09:22mikemany ideas?
09:23mikemAh, here's a more descriptive error: "For dependency Dependency {groupId=org.clojure, artifactId=clojure, version=1.2.0-master-SNAPSHOT, type=jar}: system-scoped dependency must specify an absolute path systemPath."
09:23AWizzArdrhickey: is there a way to do add type hints to the args of an anonymous function?
09:24mikemok, passing the absolute path to clojure.jar (not one starting with ~) works
09:24chouserAWizzArd: such a thing would do you no good without recompiling the function anyway.
09:25AWizzArdok
09:25AWizzArdand is there a way to get the arglists of an anon fn?
09:26rhickeyAWizzArd: you can add metadata to an anonymous fn like this:
09:26rhickeyuser=> (meta #^{:my :meta} (fn [x] x))
09:26rhickey{:line 2, :my :meta}
09:26chousermikem: thanks! I needed to do that too.
09:26AWizzArdthis works for me
09:26ampleyflymikem: do you also get a lot of errors after "Testing clojure.contrib.test-contrib.test-jmx"?
09:27rhickeybut using fn metadata as a reflection thing is a bad path. If we really want fn reflection then fns should directly support it. :arglists meta is for humans
09:28AWizzArdYes, that makes sense. And it would indeed be a good idea to have reflection for fns.
09:28mikemampleyfly: actually, I'm getting a ClassNotFoundException for clojure.contrib.pprint.ColumnWriter during the build
09:30chousercontrib is building and testing fine for me now
09:31AWizzArdchouser: is (= ::User (type user)) the most efficient way to check if user in a (deftype User)?
09:31cemerickmikem, chouser: a relative path will work fine, ~ is a shell expansion that java won't process
09:32chousercemerick: a relative path did not work for me
09:32cemerickhrm....or, I think it will
09:32cemericknevermind then :-)
09:33ampleyflyI think the readme says relative paths don't work
09:34mikemcemerick: yep, didn't work for me either.
09:35cemerickI think I'm remembering maven 1 and the jar override options...
09:36abrenkampleyfly: I just pulled and -contrib builds fine. What version of Java are you using?
09:38ohpauleezrhickey: I just found out you're coming to my city in April
09:38ohpauleezif you need anything before or while you're here, totally let me know
09:38rhickeyok, thanks
09:39ohpauleezalso, for all, the clojure talk I gave at Drexel yesterday went very well, they asked me to go over the scheduled time by an hour
09:40rhickeyohpauleez: cool
09:41chouserohpauleez: excellent
09:41ampleyflyabrenk: hrm, it seems I'm running java version "1.6.0_0"
09:41ampleyflyOpenJDK Runtime Environment (IcedTea6 1.6.1) (6b16-1.6.1-3ubuntu1)
09:41ampleyflyOpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
09:41mikemmy clojure-contrib build is currently suffering from this error: http://paste.lisp.org/display/94078 -- seems it was reported earlier, but I can't find an answer in my logs
09:42rhickeyfirst Clojure NYC meetup also a big success - 60+ people
09:42chouserwow
09:43abrenkampleyfly: I was using "Java HotSpot(TM) Server VM (build 14.3-b01, mixed mode)" from Sun.
09:45ampleyflyI thought I was runnig suns vm too
09:46ampleyflywell, changed it with update-alternatives --config java, no errors this time around, I still don't get a clojure-contrib.jar, but a clojure-contrib-1.2.0-SNAPSHOT.jar, is that fine?
09:53rhickeydid the contrib tests get folded together? - there used to be 2 phases of contrib tests
09:54chouserI didn't know there were 2 phases
09:56rhickeychouser: just by running ant test you got two sets of tests and results
09:56rhickeynow, since mvn package runs tests and mvn test builds, what's the difference?
09:58chouserlog says "Remove test-contrib, "mvn clojure:test" is equivalent"
09:59rhickeywhat does this mean? [WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
09:59rhickeydoes mvn have a command line switch to show me the available targets?
10:00AWizzArdrhickey: what in the thread to which you linked scares you?
10:01rhickeyjust about all of it
10:01clojurebotslime-install is an automated elisp install script at http://github.com/technomancy/emacs-starter-kit/blob/2b7678e9a331d243bf32cd8b591f826739dad2d9/starter-kit-lisp.el#-72
10:01chouserrhickey: looking at the old build.xml file, "test" appears to do test_contrib and test_datalog. "mvn ... package" reports testing datalog as well as the other namespaces, so I would assume that's sufficient.
10:09esjis it intended that (empty coll) where coll is a sorted-set-by destroys the comparator ?
10:10esj'(conj (sorted-set-by #(> %1 %2)) 1 4 2)
10:10esj,(conj (sorted-set-by #(> %1 %2)) 1 4 2)
10:10clojurebot#{4 2 1}
10:10esjbut
10:10esj,(conj (empty (conj (sorted-set-by #(> %1 %2)) 1 4 2)) 1 4 2)
10:10clojurebot#{1 2 4}
10:11chouserDid we regress? http://www.assembla.com/spaces/clojure/tickets/128
10:13chouseresj: seems to work here. what version of clojure are you using?
10:13esj{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}
10:13esjand clojurebot agrees with me.
10:13_fogus_,(for [x (range 1 11)] (/ 2520 x))
10:13clojurebot(2520 1260 840 630 504 420 360 315 280 252)
10:14_fogus_When did freenode start requiring nick registration?
10:15chouser_fogus_: a week or so ago I think. spam issue apparently.
10:15_fogus_I must have missed that memo
10:16_fogus_Today was the first day that it blocked me... I was chatting away at people here and no one would respond to me. :-(
10:16ChousukeI think it's a channel mode?
10:16chouser_fogus_: your request for memos had the old cover sheet
10:18_fogus_chouser: I guess I'll have attend the corresponding training
10:20chouser_fogus_: I signed you up for that. You're welcome. Be sure to come in by 8am on Sunday.
10:21chouserI can't remember how to figure out if a particular commit is in the history of a particular tag
10:33jcromartie_fogus_: where did blub come up?
10:33fmui think Blub is due to pg
10:34jcromartieyes it is
10:34_fogus_Apparently Clojure is Blub now. http://lambdassociates.org/blog/klambda.htm sigh
10:34somniumBlub is underrated -- it can get the job done and its not weird.
10:34RaynesI really need some food.
10:35RaynesOops, this isn't Twitter!
10:35Raynes;)
10:35_fogus_Blub has become "whatever *I* don't like"
10:36jcromartie_fogus_: When Clojure, Python and CL are Blub, you know the author is totally out of touch.
10:36chouseresj: well, I'm stumped. I can't reproduce your error with master or 1.1.0. git claims the fix is in 1.1.0.
10:37esjbizarre ! But I'm hallucinating right, because CB gave me the same answer ?
10:38chouseresj: yes, and though clojurebot claims to be running 1.1.0 snapshot, I'm never to confident.
10:38chouseresj: did you build your own clojure.jar?
10:38esjyeah
10:38esji'll repull and see what comes out
10:38esjthanks for looking at this for me chouser
10:40RaynesAnybody interested in a Wave invite?
10:41the-kennyRaynes: I can offer some of these too
10:41RaynesI have plenty go around.
10:42RaynesLike, 23.
10:43the-kennyI have 19 here
10:45Raynesthe-kenny: Heh. A couple of months ago, everybody in the channel would have been screaming "ME!!!!"
10:46the-kennyRaynes: Just write it on Twitter :p There are plenty people
10:46RaynesYeah. I don't like the people on twitter though. :|
10:51esjwho stole clojars.org ?
10:51jcromartieso I am building this web app in Clojure, using Compojure to serve up JSON
10:51jcromartieand I have got my data all relational-like
10:52jcromartieI am using sets to store records, and each record is a map
10:52jcromartieI can index the sets using watches
10:52jcromartieit seems pretty good
10:52jcromartiemuch faster than a database
10:53esjwell, until you have I/O....
10:53jcromartieI'm wondering what other people do to model their data when building an application
10:53jcromartieesj: what do you mean?
10:53esjwell, its the syncing stuff to disk that's soaks up performance
10:54jcromartieI got a pretty good solution going yesterday
10:54jcromartienot sure how it's going to scale
10:54jcromartiebut it's pretty agnostic at this point... I should be able to move it to a DB if necessary
10:54jcromartieor whatever solution
10:54jcromartiebut it's fun to build it in the first place :P
10:55esjcool
10:55RaynesHeh.
10:56Raynesthe-kenny: Tweeted it, explicitly stating that the invitations were only for my followers, and exactly 3 minutes later some random guy replies: "@IORayne yes,I need it,thank u.(jinrilidong@gmail.com)"
10:56Rayneschuckles*
10:56the-kennyRaynes: That's exactly what I experiences
10:56the-kennyexperienced
10:58alexykchouser: will Ctrl-C with break-thread and no ongoing computation kill repl itself?
10:59alexykah, it just says SIGINT
10:59alexyki.e. "not so fast"
10:59esjchouser: OK. Turns out I was lying to you, sorry. In my git pulled clojure it seems to work. In that which I pulled from clojars using leiningen it does not. I'm using the clojure jar documented on the leiningen webpage, [org.clojure/clojure "1.1.0-alpha-SNAPSHOT"] . I'll see if there are alternatives, but clojars is being a little slow right now. Thanks for the pointers.
11:00chouseralexyk: yeah, it gets a little wonkey
11:00esjboth report identical *clojure-version* however
11:01chouseralexyk: if you hit Ctrl-C while sitting at the prompt, sometimes your next operation will fail. though not always. :-/
11:01chouseroh, wait.
11:02chouser1.1.0-alpha-SNAPSHOT means *before* 1.1.0, so all bets are off
11:02esjaha !
11:03chouseras does 1.1.0-master -- alpha's actually probably older
11:03esjis there anywhere that I read this naming convention to get clued up ?
11:04chouseryou need "1.1.0" or "1.2.0-master..." to be sure of having that fix
11:05esjyeah, I've just changed to 1.1.0 and its 100%
11:05chousermaybe we should change the convention. use "1.1.0" and then "1.1.0-postrelease-SNAPSHOT" or something.
11:05chousereh. maybe not.
11:05chouseresj: great!
11:05esjanother myster solved.
11:06esjserves me right for copy-pasting the project.clj on the webpage :)
11:09cemerickrhickey: not sure if someone else addressed it, but the "Using platform encoding" means that a resource and source file encoding isn't set in the pom.
11:09cemerickstuartsierra: should add <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> to <properties>
11:11cemerickrhickey: also, maven doesn't have targets, hit has phases that build plugins can attach themselves to: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
11:12cemerickchouser: do you have greatest hits in the logs bookmarked?
11:12chouserI do not
11:12cemerickthat'd be an interesting wiki project
11:12chouserhm, it would.
11:12cemerick"The Clojure Archeology Project"
11:18stuartsierracemerick: ok, pushed
11:20arohneris github's code output broken for anyone else? I get a big string of A's where code should be
11:20zakwilsonI'm a bit confused about why I'd use atoms. It appears that everything I'd want to do with an atom could also be done with an agent without any changes in semantics. Are they smaller/faster?
11:21arohnerah, it's just chrome. FF is fine
11:22cemerick_fogus_: Being labelled as blub by Qi folk is not a horrible thing :-)
11:23arohnerzakwilson: the semantics are different. agents are async; stuff happens in another thread "later". atoms are synchronous
11:23chouserzakwilson: 'swap!' on an atom doesn't return until it's successful. 'send' and 'send-off' to an agent queue the work and return immediately, likely before that work has been done
11:23zakwilsonchouser: that's what I wanted to know.
11:24zakwilsonI somehow missed that swap! blocks.
11:40arohnerone weird thing about defprotocol maps: it's easy to do things that require your protocol, and it's easy to accidentally turn your deftype into a regular map
11:41arohneras in (my-protocol-fn obj)
11:41arohnerand then (merge {:a 1} (obj))
11:41arohnerthe return value of merge is a normal map, and now you can't call protocol functions on it
11:45esjchouser: here it is. After I figured it out from the repl.sh I saw it in the docs. lein repl uses the version of clojure in the leiningen.jar, not that spec'd in your project.clj.
11:46Raynesesj: Yeah, that bit me in the ass a few days ago.
11:48alexykis there a way to tell the repl to do some massive GC action?
11:49chouser(System/gc)
11:49chouserdunno if it's massive, and that's the extent of my knowledge. :-)
11:49arohnerthat isn't guaranteed, I believe
11:49arohnerit's a "hint"
11:49alexykok
11:49chouserI don't think the gc guarantees much of anything.
11:50alexykIDEA has this little trash bicket and when you click it, it does work every time
11:50alexykbucket
11:50rsynnottalexyk: in all JVMs? :)
11:50Raynesalexyk: You've invented a new word!
11:50RaynesI has a trash bicket!
11:54chouserrhickey's java indentation style is infecting my C++ code
11:56arohneris there a reason why (empty) can't work on deftype maps?
11:57arohnerI see its source currently throws UnsupportedOperationException. Is that because it's the smart thing to do, or just hasn't been done yet?
11:58hiredmanarohner: deftypes aren't maps
11:59arohnerhiredman: thank you for correcting that. From now on I'll refer to "deftypes that implement IPersistentMap"
11:59hiredmanarohner: :P
12:00RaynesMy deftype implements IPersistentMap because dissoc is cool. :D
12:02chousertrying to implement only 'empty' of IPersistentMap makes it mad
12:05rhickeyarohner: does your cool deftype have fields?
12:05arohnerrhickey: yes
12:05rhickeythen how could it be empty?
12:05hiredman,(empty (struct (create-struct :foo :bar) 1 2))
12:05arohnerrhickey: fair enough
12:05clojurebot{:foo nil, :bar nil}
12:06arohnerwhat I really want is for:
12:06arohner(my-protocol-fn (merge {:foo true} my-deftype))
12:06arohnerbut merge returns a normal map, rather than my deftype
12:07arohnerso I was thinking (merge (empty my-deftype) {:foo true} my-deftype))
12:07hiredmanwhy not switch the order?
12:07rhickeywhy not just (merge my-deftype {:foo true})?
12:08chouserpresumably he wants nil for non-:foo fields
12:08arohneroh right, merge doesn't do what I want here
12:08arohnerchouser: yes, that's the standard idiom I use. I forgot my deftype has {:foo nil}
12:09arohnerI want to set :foo to true if it is nil
12:12tmountainwould it be possible to rewrite this function to use recur? http://gist.github.com/289897
12:15mabesFrom what I can tell from the source of clojure.contrib.duck-streams/read-lines if an exception is thrown while reading a line the file reader is never closed.. Is that correct? http://github.com/richhickey/clojure-contrib/blob/2ae8ff46d348522efe9f96cfd31f6e9b6018cfdc/src/clojure/contrib/duck_streams.clj#L234
12:16mabesi.e. there is no try/finally form wrapping it
12:17chousermabes: I think you're right, though you could still close the reader you passed in yourself.
12:18mabeschouser: I suppose that is why the doc string is very explicit about the reader only being closed when the wntire seq is consumed. I was just wondering if with-open could be used in this context or not..
12:20chouserwith-open should be used instead of ever relying on read-lines to close the stream, IMO.
12:20chouserclosing an already-closed thing generally does no harm
12:22mabesbut read-lines only takes a filename, not a reader.. so I don't see how you could use them in conjunction
12:22chouseroh!
12:22chouseryou're right. don't use read-lines.
12:23mabesheh, ok
12:23chouseryou can use duck-streams/reader and with-open, and then line-seq
12:23mabeswell, I'm writing my own csv-lines that wraps SuperCSV so I was modeling it after read-lines when I ran into the question of exceptions. I'll probably have my csv-lines take a reader to avoid a similar problem
12:24chouser(with-open [rdr (ds/reader "foo.txt")] (vec (map ... (line-seq rdr))))
12:25mabesahh, I didn't know about line-seq.. I was only looking in duck-streams. Thanks for the tip
12:35_schulte_any recommendations for how to add a :timeout option to the shell-out sh method?
12:35_schulte_I've been playing around with the java example from http://stackoverflow.com/questions/808276/how-to-add-a-timeout-value-when-using-javas-runtime-exec but without much success
12:38hiredman~def shell-out
12:38clojurebotExcuse me?
12:38hiredmanclojurebot: do it!
12:38clojurebotdefmulti doc is ugly
12:39_schulte_def clojure.contrib.shell-out
12:40_schulte_nvrmind, just found a nice solution here http://stackoverflow.com/questions/1683680/clojure-with-timeout-macro
12:42cgrandcemerick: ping
12:52mtdcan clojure tell me from which location a java class has been loaded?
12:54the-kennymtd: Can java tell you that?
12:54the-kennyIf so, clojure can that too :)
12:56cemerickcgrand: hola :-)
12:57cemerickmtd: you can use .getResource using the classfile location (e.g. "com/foo/bar/ClassName.class") to get a URL
12:57cemerickon your classloader or a Class instance, that is
13:00the-kennyIs it possible to use the same code to access things in resources/ while I'm at a repl? (Interactive, without creating a .jar first)
13:00mtdcemerick: thanks - what am I doing wrong with (. (java.lang.ClassLoader/getSystemClassLoader) getResource "/java/lang/ClassLoader.class")
13:00the-kennyOh and.. can someone give me some code snippets? :)
13:00mtd(it evaluates to nil)
13:00cemerickthe-kenny: if resources/ is a classpath root, sure
13:00cemerickmtd: drop the leading /
13:01the-kennycemerick: I think lein adds it to the classpath
13:01cemerickI know nothing about lein, sorry.
13:01mtdcemerick: thanks (doh)
13:01arohnerhrm, merge-with doesn't work with deftype maps
13:04cgrandcemerick: so what are you trying to do with those dynamic selectors?
13:04the-kennyUhm.. I can't find resources/ in the classpath or any other property.. what does leiningen do with it?
13:07cemerickcgrand: I've been slowly glomming up a "merge-page" transformer that does the right things when composing two separate full-document snippets (e.g. rooted at <html>), and want to be able to specify where body content should be pulled from. It looks like I need to (eval (compile-selector ...)) in order to take selector values as args.
13:07arohnerreplacing (m k) with (get m k) in merge-with fixes it. should I open a bug?
13:07cemerickEh, that doesn't make a lot of sense. Pasting shortly...
13:07somniumthe-kenny: do you have a ./resources dir in project root?
13:07the-kennysomnium: Of course
13:07the-kennysomnium: But wait.. it doesn't has to do with leiningen.
13:07somniumthe-kenny: hmm, using lein-swank?
13:07the-kennyI forgot that I use swank-clojure-project, not leiningen
13:07somniumI added a line to swank-clojure-project to add it
13:07somniumah ok
13:08the-kennysomnium: Can you gist it for me?
13:08somniumsure
13:08cemericklisppaste8: url?
13:08cemerickthat bot's been dead for days
13:08cemerickcgrand: http://paste.lisp.org/display/94101
13:09cemerickcgrand: I msg'd you just to see if there was a better route I was missing.
13:10mtdIs there a recommended log4j version to use with clojure.contrib.logging? It doesn't work with 1.2.8 (old, probably): http://gist.github.com/289942
13:10cemerickmtd: 1.2.14 worked for me, last time I bothered with log4j
13:10mtdcemerick: thanks. Yeah, not my choice to use it unfort :(.
13:11somniumthe-kenny: http://gist.github.com/289943
13:11the-kennysomnium: Awesome, thanks
13:14the-kennyahhh my snippet works now.. never thought about issues with swank-clojure-project
13:15cgrandcemerick: the question is how did you fill body-selector?
13:16cemerickcgrand: fill?
13:16cgrandhow do you set the value for the :body-selector key?
13:17cgrandwhy, at runtime, have you a literal selector?
13:17cemerick(merge-html other-snippet {:body-selector [:#someid]})
13:17cemerickhrm
13:18cgrand(merge-html other-snippet (selector {:body-selector [:#someid]})) and remove the compile-selector+eval
13:19cgrandor make merge-html a macro that expands to `(merge-html* ... (selector ~selector-spec))
13:20somniumthe-kenny: do you have SBCL working with slime and clojure?
13:20the-kennysomnium: I had it working once.. But I never used it since I started with clojure
13:21cgrandcemerick: sorry pasted too fast: (merge-html other-snippet {:body-selector (selector [:#someid])})
13:21the-kennyYou have to install the swank-backend by hand if you use slime from elpa
13:21cemerickcgrand: oh, sure, I saw that -- didn't think it was too friendly to have to have selector calls everywhere
13:21cemerickthat's when I landed on the eval
13:22cemerickMaking merge-html (or any transformer, really?) a macro seems like overkill.
13:23cgrandbut is you selector written by the user or emitted by another function?
13:24somniumthe-kenny: ah, ok. Im hesitant to screw with .emacs for something Ill rarely use. Hoping for a Clojure/CL/Slime success story
13:24the-kennysomnium: Shouldn't be very hard. I can gist two utility-functions to start sbcl and clojure without a prefix argument to M-x slime
13:24cemerickcgrand: could be either. I can easily imagine one wanting to have it as an attribute in the source html snippet.
13:25the-kennyNormally you would have to do C-u <something> M-x slime RET to get a list of possible backends for slime to start
13:25somniumthe-kenny: great. Scheme (about 3 versions now) work with quack -- the more lips the merrier
13:25somniums/lips/lisps
13:25cgrandthe whole selector or a part of it? a selector can have dynamic parts?
13:26the-kennysomnium: Pushed your fix to my fork of swank-clojure :)
13:27AWizzArdIs there an ETA when build.clojure.org will be fixed again?
13:27somniumthe-kenny: technomancy has really done wonders on the readability of swank-clojure.el
13:28cemerickcgrand: probably the whole thing. e.g. {:body-selector (-> other-snippet get-body :attrs :selector read-string)}
13:30the-kennysomnium: Yeah :)
13:31cgrandcemerick: so you are putting code back in the template, no?
13:32cemerickcgrand: I'm going to say that a vector isn't code. :-)
13:32cemerickI'm not doing that right this moment, but I can imagine that being a reasonable thing to do.
13:38cgrandcemerick: I try to understand the whole picture from your paste. So, what you are trying is to have a kind of pipeline, generating an html page and then transforming it. That's right?
13:40cemerickcgrand: The fundamental objective is to have a way to compose a variety of pages together. In my case, right now, it's enough to have the pages merged in a reasonable way -- generally appending body content, appending or prepending head content. It's working pretty well so far, I just wanted to make sure I wasn't running afoul with the eval.
13:42cgrandcemerick: given your requirements you can't skip the eval.
13:43cemerickcgrand: OK. Should I take that to mean you think my requirements/approach are misguided? ;-)
13:49cgrandcemerick: No I wouldn't dare to say that but it doesn't fit with the Enlive Way™ :-)
13:51cemerickcgrand: huh -- I figured I was on the One True Path this whole time :-/
13:51cgrandas you decompose a problem in smaller functions, a page should be decomposed in smaller snippets (which themselves can be decomposed etc.)
13:52cemerickThat's what I've done, but I guess I'm still groping around for an elegant way to reassemble the whole.
13:52cgrandI understand
13:53cgrandI'm actually exploring two non-exclusive ways to ease this pain
13:54cemerickFWIW, I'm plenty giddy with how I've got things laid out now, so the heights of glee that I'll hit when you put out those blessed options are hard to imagine. :-)
13:54cgrandthe first one is smart/auto/magic templates which don't require selectors
13:56AWizzArdI don't understand why you need to generate html at all cemerick :)
13:57cemerickAWizzArd: ?
13:57AWizzArdI mean, why not generate the html/gui on the client, all via Javascript?
13:57AWizzArdThen your Clojure code will be html free.
13:57cemerickwell, my clojure code *is* html-free
13:57AWizzArdInstead you offer a rest interface
13:58cemerickwell, I do that too
13:58AWizzArdgood
13:58cemerickbut a js-generated interface doesn't let me work with a designer (as easily), and I particularly dislike javascript itself
13:58AWizzArdand GWT and/or Dojo don't help here?
13:59AWizzArdAah, you are not only the server side programmer but also responsible for the client side?
13:59cemerickGWT requires coding in Java, which I like only somewhat more than js
14:00cemerickand yup, I've got my hands in all the cookie jars
14:00chouserjs is much less painful than java, imo
14:00chouserwhich is why gwt has confused me from the beginning
14:00cemerickI know Java too well for that to be the case for me.
14:01AWizzArdchouser: then Dojo or some other framework could be more interesting
14:01cgrandI too prefer js to java
14:01cemerickchouser: and don't get me started. ;-) I blew an hour yesterday figuring out how 'this' works in js, which it turns out I've not understood for years.
14:01AWizzArdbut GWT offers you to step with a mature debugger through your JS program
14:02chousercemerick: have you read or seen anything by Douglas Crockford?
14:02AWizzArdSo, why do webbrowsers ship JS at all? They should natively run Clojure and our problems would be gone.
14:02chousercemerick: http://www.youtube.com/watch?v=hQVTIJBZook
14:02cemerickchouser: the's the "good parts" guy, right?
14:03chouserbut it's all moot. We'll compile clojure to js and all be happy.
14:03AWizzArdchouser: funny, recently i mailed with him
14:03chousercemerick: yes
14:03cgrandcemerick: and the second way I'm exploring is to glue html fragments together with ring/compojure middlewares
14:04cemerickcgrand: both sound intriguing
14:05cemerickchouser: a clojure GWT is a likely maxima -- actually running clojure in the browser will be nifty, but the size of the resulting lib will be quite massive.
14:06chousernope
14:06chouser< 5KB
14:06chouser(gzipped)
14:07cemerickheh
14:07AWizzArdhmm?
14:07AWizzArdWhat do you mean?
14:07cemerickchouser: lobby mozilla and apple *now*, and go all the way to 0
14:07chouserstill too much for "mostly static" pages, but not at all bad for an "app"
14:07chousercemerick: heh.
14:08chouserAWizzArd: I mean full clojure runtime support for javascript should be able to fit into a clojure.js.gz file of less than 5 kilobytes
14:08AWizzArdDo you talk about a Firefox plugin, or a clojure interpreter written in JS or just using an applet?
14:08chouserthat may not include contrib or a compiler
14:09cemerickchouser: are you serious?
14:09chouseryes
14:09cemerickballsy
14:09cemerickcall, that is
14:09chouserheh. not really -- I already did it once.
14:09AWizzArdI am still a bit sceptical. Do you want to use an underlying infrastructure?
14:09cemerickchouser: I seem to remember clojurescript's repl being in the 300K area
14:09chouseroh
14:09chouserreally?
14:09stuartsierraSo the multiple profiles in the contrib POM breaks the Hudson build.
14:10chousermaybe I should check my numbers. :-)
14:10chouseruh
14:10AWizzArdstuartsierra: oh good, you found the place of the problem
14:10cemerickstuartsierra: how?
14:11stuartsierraBreaks dependencies somehow.
14:11technomancyare we going to get to the point where we only AOT the stuff that actually needs it in contrib?
14:11cemerickstuartsierra: can you paste a stack?
14:12technomancyI guess I should wait on that question until it's stable. =)
14:12chouseryep, sorry, mis-remembering. I should be careful about that. 25KB gzipped
14:12cemerickhuh, I thought it was decidedly > 100
14:12somniumchouser: is that with a compressor?
14:13chouser130KB ungzipped
14:13cemerickah, that was probably it
14:13chousersomnium: yes. YUI compressor, gzipped, without sorted collections or a compiler, 22KB
14:13stuartsierratechnomancy: The maven plugin makes that pretty easy.
14:14stuartsierramaybe we should do that
14:15technomancystuartsierra: it's certainly caused a lot of confusion in the past
14:15cemerickstuartsierra: FWIW, changing the activation of the local profile to <activation><property><name>clojure.jar</name></property></activation> is probably worthwhile
14:15technomancystuartsierra: talking with replaca_ it sounds like at least the pprint stuff could be moved over to reify w/o AOT
14:16technomancyI think that would leave us with only a single gen-class requiring AOT, and that one might be able to be ported as well
14:16chouserI would *love* to see pprint without AOT. It was the only reason I started building contrib in the first place.
14:21hiredman:pre and :post are part of metadata?
14:22chousermetadata is how they're communicated to the compiler
14:22hiredmanok
14:23hiredmanI see examples of :pre and :post like (defn f [x] {:pre [(> x 1)]} ...)
14:23somnium,(macroexpand-1 '(fn [x] {:pre [ (= x 42)]} 42 ))
14:23clojurebot(fn* ([x] (clojure.core/assert (= x 42)) 42))
14:24hiredmanI thought metadata went before the arg list
14:24hiredmanis it a fn metadata vs var metadata thing?
14:26Hali_303how can I debug clojure code?
14:26Hali_303(I mean step by step, not evaluating something in the REPL)
14:26ohpauleezhiredman: maybe, but the order I use is doc string, args, pre/post
14:26somniumin the source for fn it appears they expand straight to assert clauses
14:26chouserhm, I take that back. metadata is one of the ways to communicate :pre and :post -- metadata on the arglist vector
14:27hiredmanhmmm
14:27hiredmanI would rather just have one metadata map
14:27chouserand it's only communicating to the fn macro, which emits the assert code itself. compiler uninvolved
14:27hiredmananyway
14:34hiredmanpre and post are in master right now, yes?
14:34chouseryes. 1.1
14:35chouseryou can have a separate :pre/:post pair for each fn body
14:35hiredmanhmmm
14:35AWizzArdwhat is pre/post?
14:35chouserso one for in the metadata of the whole fn or var wouldn't really work
14:36chouserAWizzArd: http://blog.fogus.me/2009/12/21/clojures-pre-and-post/
14:36AWizzArdseems it has become a fulltime job to follow all changes in Clojure :)
14:37cemerickI'm hoping the 1.2 release will be something we can sit on for a while. It's a helluva treadmill. ;-)
14:38chouseryou can just pretend the new features don't exists. *evil chuckle*
14:39cemerickI actually can't think of anything pressing for us that isn't on HEAD now.
14:39cemerickoh, actually, serialization is broken for vectors (again), which I should submit a patch for
14:39cemerickbut that's nothing compared to reify, deftype, etc., which is huge for us
14:40hiredmanhttp://gist.github.com/290030 the (numerator 1) throws java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Ratio instead of the expected assert exception
14:43chouserI get AssertionError here
14:43hiredmangrrr
14:43hiredmanhmmm
14:44hiredmanif I load the functions into a repl I get the assertion failed, but if I put them in core.clj and build a jar I get the class cast exception
14:45chouserperhaps it's getting built with *assert* false
14:45hiredmanOh
14:45hiredmanright
14:46AWizzArdwith a :pre [(do (log-to disk) true)] it looks a bit like Common Lisps :before modifier
14:46hiredman:(
14:46hiredmanAWizzArd: please no
14:46AWizzArdwhat?
14:46clojurebotWhat is meta
14:47AWizzArdI mena, "no" to what?
14:47chouserAWizzArd: until you compile with *assert* off
14:48AWizzArdWell, I would not want to misuse the :pre/:post thing for such cases, as it would be trivial to write a function or macro to add "before and after effects" to functions
15:00duncanmis there a version of cond in clojure that supports =>, like Scheme's cond?
15:00chouserduncanm: did you look at condp ?
15:01duncanmi did, i'll look closer
15:01chouserI'm not sure what scheme's => does, so condp may not help.
15:01duncanmoh
15:02duncanmchouser: in Scheme, you can write (cond (has-x?) => (lambda (x) ....))
15:02duncanmif HAS-X? doesn't return #f, the 'x' in the lambda gets bound to the return value of HAS-X?
15:02chouserwhere does that lambda's argument value come from?
15:02chouserah
15:02duncanmfrom the return value of the test
15:02duncanmit's handy
15:03AWizzArdduncanm: the => is ignored and only for the readability?
15:03chouser(if-let [x (has-x?)] (dosomethingwith x) :fail)
15:03duncanmAWizzArd: well, the => is a hint to the COND macro to set up the binding in the lambda, right?
15:04duncanmotherwise, it'll just return a lambda without evaluating it
15:04Chousukedoesn't condp have just that?
15:04Chousuke:>> or something
15:04duncanmahhh
15:04duncanmright
15:04duncanmtest-expr :>> result-fn
15:05chouserduncanm: but if you have just one test case, look at if-let or when-let
15:06_schulte_chouser: speaking of, why is there no while-let?
15:07Chousukeprobably because while is not that often needed :/
15:08_schulte_fair enough, it was easy enough to implement anyways
15:12chouserI've not yet found a use for 'while'
15:13_schulte_I used to for reading from a pipe in a shell script, not sure if there's a more idiomatic approach to that
15:13hiredmandamn
15:13chouserI've generally used 'repeatedly' in such places
15:13hiredmanpardon me
15:14hiredmangah
15:14hiredmanI was just going to post the issue I created and gmail says the conversation is updated, and it's someone else with an issue and a patch
15:15chouserpatch fight! may the best patch win!
15:15LauJensenIs the a variable I can use to (str "This file is called " special-var) ?
15:15hiredmanclojurebot: ticket #255
15:15clojurebot{:url http://tinyurl.com/ydbmus8, :summary "add denominator and numerator fns for Ratio", :status :test, :priority :normal, :created-on "2010-01-29T20:08:36+00:00"}
15:15chouser*file*
15:15hiredmanclojurebot: ticket #254
15:15clojurebot{:url http://tinyurl.com/ybk7bm9, :summary "Expose c.l.Ratio's accessors", :status :test, :priority :normal, :created-on "2010-01-29T20:05:24+00:00"}
15:16kotarakhiredman: I'm sorry...
15:16hiredman:(
15:16kotarakHow can I mark my ticket as duplicate?
15:16hiredmanI'll live, I guess
15:16hiredmankotarak: I marked mine as
15:17kotarakok. But how? I didn't see (an obvious) checkbox. (But I haven't looked very hard..)
15:17hiredmankotarak: the associate button
15:17chouserooh, hiredman's has hinted return value
15:17LauJensenchouser: Any others?
15:17hiredmanyou can then pick which kind of association
15:17chouserLauJensen: how many do you need?
15:18LauJensen1 that works
15:18kotarakAssemble is not intuitive. :(
15:18LauJensenchouser: Its probably a slime thing, I'll complain if it doesn't work when I deploy
15:19chouserhiredman's also has a test and correct docstring capitalization.
15:19kotarakhiredman: seems I should mark mine as duplicate: chouser
15:19kotarak:
15:19kotarakooh, hiredman's has hinted return value
15:19chouserbut kotarak's has a more meaning parameter name
15:19chousermeaningful
15:19kotarak2:1 for hiredman
15:20chouserIt's close, but I'm going to have to vote for hiredman's. :-)
15:20kotarakchouser: may I add, that I chose consist docstring caps according to surrounding functions? Or this just a cheap argument?
15:20chouserheh, no, perfectly valid!
15:21stuartsierraOk, pushed some changes to contrib's POM, should work in Hudson and also support builds with a local clojure.jar
15:21kotarak?
15:21chousergvimdiff
15:22kotarakvim doesn't do it?
15:22hiredmanbrowser is on the windows machine
15:22hiredmanI would have to download the patch, and find an scp client, and copy it somewhere
15:22stuartsierraAlso only AOT-compiles the namespaces that need it for gen-class.
15:22LauJensenchouser: *file* gives NO_SOURCE_PATH both in and out of SLIME
15:22chouseralso cygwin.
15:23kotarakstuartsierra: +1
15:23chouserLauJensen: are you sure you have a source file?
15:23hiredman,*file*
15:23clojurebot"NO_SOURCE_PATH"
15:23hiredman,(doc *file*)
15:23clojurebot"; The path of the file being evaluated, as a String. Evaluates to nil when there is no file, eg. in the REPL."
15:24hiredman:(
15:24duncanmis there a way to find out if all my agents are done working?
15:25chouserLauJensen: try defining a macro like this: (defmacro this-file [] *file*)
15:25LauJensenk
15:25chouserLauJensen: then use (this-file) instead of *file*
15:25duncanmi have agents running a function that tail-calls itself when it's not finished, i wanna know if all the agents are done
15:25chouserduncanm: nothing automatic. promise/deliver might help
15:26patrkrisquestion regarding vimclojure: how is it possible to kill a REPL instance? The documentation says to use the ",close" shortcut, but it doesn't work (it seems not even to be mapped).
15:26chouseroh, tail-calls as in (send *agent* ...) or as in (recur ...)?
15:26kotarakpatrkris: type ,close in the repl as a command
15:26LauJensenchouser: using that macro and then using (this-file) returns 415 when I call (count (slurp (this-file))) - the file is 19 lines long
15:26patrkriskotarak: aaaah, thanks
15:26duncanmchouser: (send *agent* (fn [] .... (recur)))
15:26LauJensenso its good now
15:26LauJensenWhat made the difference?
15:27kotarakpatrkris: , is not the leader. Then it would read <LocalLeader>close.
15:27duncanmchouser: i wanna know if they've all stopped polling
15:27patrkriskotarak: yeah, my mistake :)
15:27patrkriskotarak: how's the rewriting of clojureql coming along?
15:28patrkriskotarak: the frontend that is
15:28kotarakpatrkris: hopefully well. Slowly working through the system. It starts taking shape.
15:28chouserLauJensen: *file* is the file currently being evaluated. if you're at a repl and call a function that uses *file*, that file is no longer being evaluated, something at the repl is. thus NO_SOURCE
15:28patrkriskotarak: will it be ready for 1.0 or will it come in a later release?
15:28LauJensenchouser: But I wasnt calling from the REPL though
15:28kotarakpatrkris: It is planned for 1.0.
15:29patrkriskotarak: cool - looking forward
15:29LauJensenJust had a file which had (println *file*) in the middle of it, called that from a terminal
15:29hiredmanLauJensen: that works for me
15:29kotarakpatrkris: such a change must be done with a 0.x number. Later I would think twice about breaking code. But with a leading zero, we are still free to change everything.
15:29hiredmanecho "(prn *file*)" > a.clj ; java clojure.main a.clj
15:29chouserhowever, when (this-file) is expanded, the macro's body is evaluated while the file that's using (this-file) is being evaluated, thus at the moment *file* is what you're expecting. this-file expands to the current value, a string, which then sits there in the compiled function until you need it.
15:30patrkriskotarak: yeah... i thought that was what you were going to do - or wait for a 2.x release.
15:30chouserduncanm: await
15:30kotarakor that. But I don't like libraries change completely with a new major release.
15:31hiredmankotarak: have you looked at arel?
15:31kotarakarel?
15:31kotarak(^^^ obviously not)
15:31hiredmannew activerecord relational algebra thinger
15:32hiredmanhttp://github.com/rails/arel
15:34LauJensenIs there something in contrib which handles timespan durations, or are people still hanging on to Yoda time ?
15:35chouserJoda is the future of time.
15:35hiredmanjedis measure durations in yoda time
15:36LauJensenAs I thought exactly
15:36chouserYoda sets his watch to Jedi time
15:38kotarakhiredman: interesting. Similar to what we want to do. Though, I'd like to get away a little from SQL. Eg. I have a working prototype for a fleetdb backend.
15:38kotarakHow do I delete a file attachment from a ticket?
15:40hiredmanyeah, delay the move from some kind of abstract representation of a query on a dataset to a concrete query (as a string, or what have you) as long as possible
15:41kotarakWe delay until we know the connection type. Allows all sorts of emulations. Eg. FULL JOIN. etc. For SQL it will then go into a string first and then a PreparedStatement. For FleetDB it is "compiled" directly into a query: {:select :coll {:where ..}}.
15:42hiredmanhave you looked at google's datastore at all?
15:46kotarakno
15:47kotarakBut it looks ugly with the query strings. :|
15:48hiredmaneh? I've never used a query string
15:48kotarakJust reading about GqlQuery. But maybe that's very low-level.
15:49hiredmanhttp://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/package-summary.html <-- bottom stuff is generally more how I've used (but from clojure)
15:51hiredmananyway, it's another schemaless store
15:56jasapp~seen somnium
15:56clojurebotsomnium was last seen in #clojure, 90 minutes ago saying: in the source for fn it appears they expand straight to assert clauses
15:57jasappsomnium: you around?
16:06kotarak(doc into-array)
16:06clojurebot"([aseq] [type aseq]); Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
16:59LauJensenDo we have something in contrib which mimics cl-format, like (p 55) "55 secs", (p 120) "2 minutes", ?
16:59kotarakpprint?
17:01LauJensen~source pprint
17:01kotarak(doc pprint)
17:01clojurebot"clojure.contrib.pprint/pprint;[[object] [object writer]]; Pretty print object to the optional output writer. If the writer is not provided, print the object to the currently bound value of *out*."
17:02kotarak(doc clojure.contrib.pprint)
17:02clojurebotjava.lang.ClassNotFoundException: clojure.contrib.pprint
17:03LauJensenDoes look like it can handle time
17:04kotarakLauJensen: I think it's pretty complete.
17:04kotarakformat on steroids.
17:04LauJensenhehe
17:04LauJensenI think Rich once noted that format and loop together were more complex than all of Clojure
17:05kotarakmaybe adding for
17:07LauJensenIn addition to pprint, Tom has this on Github http://github.com/tomfaulhaber/cl-format/tree/master/com/infolace/
17:09LauJensenAmazing to see a subset of format implemented in 1700+ lines of Clojure
17:12raekhow does (alias) affect identity of qualified keywords?
17:13raek(alias 'pl 'se.raek.pyttelisp)
17:13raek(identical? :pl/foo :se.raek.pyttelisp/foo)
17:13raek=> false
17:13hiredmanraek: use ::pl/foo
17:14raekhmmm, ok
17:14hiredmanthe double colon on a namespace qualified keyword will resolve through an alias
17:15hiredmanon a non-qualified keyword it will qualify the keyword to the current namespace
17:15hiredman(at read time)
17:15kotarakLauJensen: I think the cl-format repo is from before contrib times.
17:16raekis namespace aliases only relevant at read time?
17:18hiredmanraek: no
17:18hiredmanwell
17:18hiredmanhmmm
17:19kotarakraek: you also can access things via introspection at runtime. Useful eg. for extracting completion information for an editor.
17:19hiredmanraek: what are you trying to do?
17:19raeki'm making a lisp toy language
17:20raekand I wanted to use multimethods
17:20hiredmanuse the ::pl/foo thing
17:20hiredman,(require '[clojure.zip :as z])
17:20clojurebotnil
17:20hiredman,::z/foo
17:20clojurebot:clojure.zip/foo
17:21raekyes, that was what I were looking for
17:21raek"Child and parent can be either symbols or keywords, and must be namespace-qualified:"
17:21raeki din't want to write the namespace all the time in the repl
17:21raekso I made an alias
17:22raekthat's when I found out that :pl/foo didn't mean what I thought
17:22raekanyway, thanks!
17:23xp_prghi all, I am a mere mortal and don't understand how lisp writes other languages
17:23xp_prgcan someone hold my hand and tell me?
17:23xp_prgI understand lamdba functions, functions writing other function via metaprogramming, functional languages in general
17:27hiredmanxp_prg: what does "how lisp writes other languages" mean?
17:33Hali_303if I have a function that can take two kinds of arities [a b] and [a b & c], how to transfer control from the first to the second?
17:33drewrcall that function with more than two args
17:33hiredmanhow do you normally transfer control between functions?
17:33Hali_303I've tried (functionname a b []), but that puts an empty vector into the list
17:34hiredmanwhy are you trying to call the three argument body with two arguments?
17:34kotarakHali_303: sounds you expected (apply fn-name a b []) ?
17:34hiredmanwell, 2+ argument body
17:36Hali_303my problem is that if c is not given (called only with two parameters), the three parameter function does not get selected (which is the default implementation)
17:37hiredmanHali_303: I don't think you understand how dispatching on arity works
17:39Hali_303see this http://pastebin.com/d5abec2c
17:40Hali_303the problem is, that in this case :children will be ([]) instead of []
17:40Hali_303when I use the two parameter version
17:40hiredmanwhy do you have & c?
17:40hiredmanor & children
17:41Hali_303so that the user can give children as parameters
17:41Hali_303but if he does not want, he can add later to the empty list
17:41kotarakHali_303 You don't need the 2-param case.
17:42hiredmanok, so the excpected behaviour is (Form foo bar baz bleep bloop) and inside Form, children will be bound to (baz bleep bloop)
17:42hiredmanwhy would you expect it to be any different if you replace baz with an empty vector?
17:43Hali_303kotarak: ahh indeed :)
17:44Hali_303hiredman: ok, now it sounds very logical :)
17:44Hali_303thanks!
18:06Hali_303is there a shorthand for (reduce str ?
18:06Chousukeno, but don't use reduce with str
18:06Chousukeuse apply instead
18:07Hali_303oh, thanks
18:07Chousukeit's faster because str uses a stringbuilder internally
18:07Hali_303I see
18:08DeusExPikachuis there a good pathname handling lib?
18:13technoma`DeusExPikachu: I use contrib's java-utils/file
18:17DeusExPikachutechnoma`, k
19:21devlinsfHey everybody.
19:21devlinsfI'm getting a weird bug w/ 1.2
19:21devlinsfjava.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V
19:21devlinsfHas anyone seen this before?
19:22the-kennyclojurebot: clojure.lang.RestFn
19:22clojurebotant clean and rebuild contrib
19:23devlinsfClojurebot knows common errors?
19:23the-kennydevlinsf: If we tell him the solutions, yes ;)
19:24devlinsfWow
19:24the-kennyclojurebot: the answer is 42
19:24clojurebotRoger.
19:24technoma`devlinsf: that means you're using .class files compiled with an older version of clojure
19:24the-kennyclojurebot: the answer?
19:24clojurebotthe answer is 42
19:24technoma`99% of the time it's contrib's fault
19:24devlinsftechnoma`: Ah, great. Since you're here...
19:24technoma`though now that contrib uses actual version numbers it should become less of an issue
19:24devlinsfHow do I solve w/ Lein?
19:24devlinsfIs there an "Edge Contrib"?
19:25technoma`devlinsf: if the version numbers for clojure and contrib match it shouldn't be an issue
19:25devlinsfSo there's a 1.2 contrib?
19:25technoma`if it is, that would point to a bug in either contrib's pom or the config in build.clojure.org
19:25technoma`yep
19:26the-kennydevlinsf: Oh, and try lein clean && lein deps
19:26the-kennyso you have a "clean" checkout
19:26devlinsfYeah, I've been cleaning
19:26devlinsfI do have a version mismatch
19:29devlinsfOkay, changed versions. Got a working jar
19:29devlinsfBack to hacking
19:30devlinsfThanks all
19:43_fogus_.((juxt + *))
19:43_fogus_,((juxt + *))
19:43clojurebot[0 1]
20:07AWizzArduh, the Oracle favicon.ico is now used in Suns Java documentation
20:10qed,(juxt + +)
20:10clojurebot#<core$juxt__4985$fn__4995 clojure.core$juxt__4985$fn__4995@c41d96>
20:10qed((juxt + +))
20:10qed,((juxt + +))
20:10clojurebot[0 0]
22:04chouser,((sorted-map (int 1) 2) (long 1))
22:04clojurebot2
22:04chouserrhickey: does this violate the java.util.Map contract?
22:05chouser,(instance? java.util.Map (sorted-map (int 1) 2))
22:05clojurebottrue
22:21ts00000,(def foo {:a 1, :b 1, :c 1})
22:21clojurebotDENIED
22:21ts00000how do I come up with a foo that has :c filtered?
22:22ts00000I tried remove and filter but I think my syntax is wrong
22:22ts00000if I have a :c, I want it not there
22:22rhickey,(instance? java.util.SortedMap (sorted-map (int 1) 2))
22:22clojurebotfalse
22:35chouserrhickey: is that my answer?
22:35chouserts00000: (dissoc {:a 1 :b 1 :c 1} :c)
22:43ts00000if I have keys in a map, and I want to look up the "prices" for those keys in a separate map named prices, should I do it with something like (for [x (keys map)] [prices x])? and if so, why does this return two results rather than one?
22:44ts00000like if the map is (def x {:a 1, :b 2, :c 3}) and prices is (def prices {:a 500.01, :b 500.02}) it returns two separate vectors
22:45ts00000but with the same values essentially
22:45ts00000it returns a vector per key?
22:47chouserare you trying to look up eack key in prices?
22:47ts00000yeah, pretty much
22:47chouserthen you want (prices x) not [prices x]
22:48ts00000hmm
22:48ts00000ok, that works, but I was actually hoping for some kind of map as a result, but I think I can work with that
22:49chouseryou want {1 500.01, 2 500.02} or something?
22:49ts00000well, i've got a great number of maps, and a single price table
22:50ts00000so I want to go through the maps, and come up with the prices, but I also need the quantities that are in the original map
22:50ts00000so the map has like :item qty
22:50ts00000:foo 300
22:50ts00000and I have a price for foo in the prices table
22:51ts00000but i'm looking for a clojurish way of basically doing some qty*price work and coming out with a number
23:14rhickeychouser: notreally