#clojure logs

2010-01-13

00:00ts00000I think it's the java regex part that I was confused about; I was using a regex construction kit that I guess didn't have a clue about java and was instead focused on php etc
00:00chouser,(re-find #"a.\b" "abc addr ax aj")
00:00clojurebot"ax"
00:00chouseryeah, each regex engine is a little different. :-/
00:01chouserJava's is *very* similar to perl and javascript. Not so much like sed or grep, for example.
00:01chouserI don't know php regex at all.
00:03ts00000chouser: would I use doseq to iterate over the matches, or something else?
00:03ts00000if I was using re-seq
00:04chouserlearning clojure and regex all at once?
00:04chouser:-)
00:04ts00000pretty much :)
00:04chousersure, doseq would be good for experimenting, printing out your matches as you go.
00:05chouserbut if you're going to do something with each match, like run another regex on it, or put it into a hash-map, you'll want to be using 'for' or 'map'
00:06chouserneither of those actually iterate as such (they both return lazy seqs) but that's useful for stringing together more "passes" of work
00:06defn`(def md (new MarkdownProcessor)) (.markdown md "text") fails
00:06ts00000just to print them out - is that like (doseq [i (re-find #"..." x)] print) or something?
00:07chouser(doseq [i (re-seq #"..." x)] (prn i))
00:07chouserfor map:
00:07chouser,(map count (re-seq #"\w+" "alpha beta gamma epsilon"))
00:07clojurebot(5 4 5 7)
00:08defn`weird. it works all of a sudden
00:09chouserok, bedtime. fare ye well, all!
00:13ts00000hmm, doseq returns nil
00:16lowlycoderhow do I write a basic clojure app that retrieves a webpage?
00:16lowlycoderI want something where I can type "myprog foo bar" and have it return me links for the top 100 results from scholar.google.com for "foo bar"
00:33hiredmanlowlycoder: clojurebot has a google plugin you can start with
00:33hiredman~google clojurebot
00:33clojurebotFirst, out of 63 results is:
00:33clojurebothiredman's clojurebot at master - GitHub
00:33clojurebothttp://github.com/hiredman/clojurebot
00:34lowlycoderhiredman: nice; thanks
01:13lowlycoderhow do I install clojure-contrib?
01:16hiredman~how do I install clojure-contrib?
01:16clojurebothttp://groups.google.com/group/clojuredev-users
01:17hiredmanclojurebot: bah
01:17clojurebotexcusez-moi
01:17hiredman~how do I install contrib?
01:17clojurebotI guess that is my answer.
01:17hiredman:|
01:17hiredmanlowlycoder: you don't really install it, you just get a jar
01:18hiredmanyou can either grab one from build.clojure.org or build one from a git checkout
01:19lowlycoderdone
01:19lowlycodernow looking into this nailgun thing
01:19lowlycoderhttp://martiansoftware.com/nailgun/quickstart.html
01:33mebaran151how do I make paraedit default for slime and clojure-mode buffers?
01:34lowlycoderdoes anyon ahve a tutorial for running clojure inside of nailgun?
01:37Raynesmebaran151: (add-hook 'clojure-mode-hook 'paredit-mode)
01:37RaynesAdd that for Clojure-mode buffers.
01:37RaynesDunno about slime buffers.
01:37RaynesI was wondering the same thing.
01:45somniumthere's a slime-mode-hook too
01:48itistodaywhat does DSL refer to?
01:48itistodayi've seen it mentioned in several clojure related blog posts but none of them had the courtesy of defining it
01:49arbschtdomain-specific language, I guess
01:49itistodayarbscht: thanks!
01:53unfo-itistoday, with clojure's powerful macro system you can easily implement new language features to better fit the language used in your domain for example
01:53unfo-s/easily//
01:58lowlycoderis there a pure clojure database anywehre?
01:58mebaran151lowlycoder: I think the closest we have is FleetDB
01:58mebaran151neo4j is pretty close to the way you'd think about a ClojureDB exist
02:15RaynesIs there any way to get paredit to shut up and insert a closing paren? I accidentally deleted a closing paren, and now it's yelling at me.
02:16RaynesOh yeah, undo.
02:16RaynesHeh.
02:19replacaRaynes: you can also use ^Q before a character you want to push around paredit
02:19RaynesNeat.
02:24RaynesOh that is awesome.
02:24RaynesDefining my stack operations as a protocol and implementing it in a Stack type reduced the length of the code. :D
03:59LauJensenMorning team
04:00RaynesMorning.
04:19LauJensenI think a lot of people tried my Reddit scraper w/o inserting appropriate thread/sleeps :( The admins seemed to have noticed
04:22ChousukeLauJensen: Unintentional DDoS. :P
04:22LauJensenYea - People only read the code not the comment below 'If you use this, sleep a little'
04:23ChousukeYou should have put the sleep in the code
04:23Chousukenever trust people to read anything beyond the most prominent section
04:30LauJensenTrue, but I thought an exact 30 lines looked so nice :)
04:31RaynesLauJensen: I noticed one of the admins complaining about it earlier.
04:31LauJensenI know - I updated my post after that saying UPDATE: Please do as I say
04:32LauJensen(to that effect at least)
05:04esjLau: LOL !
05:28Chousuke"Static type analysis leads to brain damage"
05:33ordnungswidrigChousuke: have a link?
05:33ordnungswidrigplanet lisp
05:34ordnungswidrigre. gree.
05:36ChousukeThe discussion I'm reading right now is at http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/ee785b7a1d8d22ec/374dcaf3bbf02dae#374dcaf3bbf02dae (this links to a specific comment though. Can't find a link to the top of the thread. :/)
05:37ChousukeHis style of writing reminds me somewhat of RMS. Unforgiving, but logical and consistent.
05:37ordnungswidrigthis combination can be hard to swallow :-)
05:38Chousukeyes. But it can also be very enlightening if you can put aside your own opinions for a moment
05:42ordnungswidrigLike it: "Yes, God had a deadline. So he wrote it all in Lisp."
05:42lessandlessI am trying to make incanter usable from clojure from anywhere. So far I have tried to put the incanter-full *jar onto the classpath, but that did not succeed. Any advice?
05:57LauJensenChousuke, RMS ?
05:57ChousukeRichard M. Stallman
06:00LauJensenThanks - What do you want to highlight by linking that comment?
06:01ordnungswidrigLauJensen: he did not find a link to the whole thread :-)
06:02ChousukeI followed a link from the Erik Naggum comment archive to a specific comment and started reading the whole thread.
06:03LauJensenk
06:08Raynes> You folks sure are touchy --
06:08RaynesWe're having a nasty winter. Wait till spring and try again.
06:13RaynesI didn't know Erik Naggum was dead. :\
06:43LauJensenLife is very fragile
06:46RaynesLauJensen: So are glass houses.
06:46RaynesStop throwing parentheses.
06:47sparievon completely unrelated note, what do you guys would recommend to read about lisp macroses and metaprogramming in general? I'm thinking about Graham's On Lisp
07:00crazzyfordOn lisp is nice once you get past the fact that its common lisp
07:01crazzyfordhttp://github.com/liron/knockoff has a load of stuff stolen from the arc source
07:01crazzyfordThe general purpose macros in it (some of them anyway) are rather nice
07:01crazzyford(see util.clj under there)
07:07sparievcrazzyford: thanks, that looks interesting
07:08crazzyfordThat and try not to repeat yourself more than twice in a bit of code
07:08crazzyfordfufilling that means writing a lot of macros
07:08crazzyfordand writing a lot of macros > reading a book about em
07:08crazzyfordonce you've gotten past the basics
07:09crazzyford(usually means writing a lot of macros anyway. depends on your code)
07:09sparievwell, I suspected that )
07:09crazzyford:)
07:09sparievI'm rather new to lisp macros (I did some metaprigramming in ruby, though), so I wanted to read some theory first
07:09crazzyfordis metaprogramming in ruby mostly confined to adding methods to classes?
07:11crazzyfordand/or objects that you already have instantiated?
07:11sparievyes, adding methods/fields, like usual rails plugins do
07:11crazzyfordaye
07:11crazzyfordclojure's metaprogramming is kinda different
07:11sparievthat's what I did, anyway )
07:13crazzyfordjust learn about gemsyms and backquote templates and you'll find it easier to understand
07:13crazzyfordotherwise a lot of macros are kind confusing
07:14ChousukeIs adding methods and fields really metaprogramming?
07:14crazzyfordit is on some levels I guess. Considering you can add to base classes like Array and Object
07:15ChousukeWell, I guess you could use it to modify the behaviour of an existing program.
07:15Chousukein Clojure, macros are more about programs that generate programs rather than modifying programs during runtime.
07:15crazzyfordaye
07:16crazzyfordquite different to ruby
07:16crazzyfordruby has method_missing as well, so when you send an object a method it doesn't expect, it calls its own method_missing
07:16crazzyfordwhich can be further used for changing behaviour
07:16crazzyfordbut yeah, no sexps hence no macros
07:17ChousukeYeah. in most languages code generation is a hack that works around language limitations
07:17crazzyfordheh, c macros
07:17LauJensen~def ->
07:17Chousukeor any code generation tool you might have. :)
07:17crazzyfordvim :P
07:18Chousuke:P
07:18crazzyfordor emacs for that matter
07:18crazzyfordor any of the ide's out there
07:18crazzyfordhttp://briancarper.net/blog/vim-brute-force
07:23crazzyfordgoing back to ruby metaprogramming, you can create classes at runtime if you want as well
07:23crazzyfordand generate said classes using code (things like map etc)
07:23crazzyfordso that's sorta like macros
07:26crazzyford,(doc reify)
07:26clojurebotGabh mo leithscéal?
07:26crazzyford,(doc deftype)
07:26clojurebot"([name [& fields] & [[& interfaces] & methods]]); Alpha - subject to change Dynamically generates compiled bytecode for an anonymous class with the given fields, and, optionally, interfaces and methods. The Name will be used to create a dynamic type tag keyword of the form :current.ns/Name. This tag will be returned from (type an-instance). A factory function of current.ns/Name will be defined, overloaded on 2 arities, t
07:36sparievI dont really like ruby metaprogramming. Simple things like adding methds are fine, but more advanced manipulations are too much magic and complexity to me
07:37crazzyfordrhickey had a really nice explanation of clojure macros. Its somewhere in here http://channel9.msdn.com/shows/Going+Deep/Expert-to-Expert-Rich-Hickey-and-Brian-Beckman-Inside-Clojure/
07:38crazzyfordbasic point was that the reader reads strings, and turns it into a tree
07:38crazzyfordthen it feeds it to the compiler
07:38crazzyfordmacros are programs that the compiler runs when it finds them
07:39crazzyfordyou can see the diagram on the right hand side of the video preview (before clicking play)
07:40sparievcrazzyford: thanks, I haven't seen this one
08:02Raynescrazzyford: That docstring is old.
08:27chouserrhickey: should restart be named restart-agent?
08:27rhickeychouser: yes
08:28chouserOk, I think everything else is done. want to see the patch with docstrings before I check it in?
08:29rhickeychouser: no, go ahead
08:29rhickeythanks!
08:42rhickeychouser: let me know when you are done pushing patches
08:44chouserok, just a moment.
08:48chouserrhickey: done
08:48rhickeychouser: thanks
08:54rhickey,(defmacro foo [x] *macro-meta*)
08:54rhickeyno bot :(
08:54rhickey#^{:a 1} (foo 42)
08:54Chousukedefmacro doesn't work anyway
08:55rhickeyah
09:16fliebelAaah, I can't do Python anymore… I'm infected by functional lisp style.
09:19fliebelI wanted to write a shuffled set of cards like shuffle(['j', 'q', 'k', 'a']].extend(range(2, 11)) * 4) But it turns out these things don't return at all, but just do it in-place.
09:20fliebelAnd I start every line with a ( and forget to separate my lists with commas :P
09:21Raynesfliebel: I come from Haskell, so I have the opposite problem with the list separation bit.
09:22fliebelRaynes: how do lists work in Haskell?
09:22Raynesfliebel: Surrounded by brackets and separated with commas.
09:22Raynes[1, 2, 3, 4] or [1,2,3,4]
09:23fliebelThat is like Python… NOT writing them was easy for me, going BACK and write them is the problem for me.
09:24fliebeland Clojure would just allow you to write them, right?
09:26RaynesYes, Clojure would allow me to write the commas.
09:26RaynesBut I still don't like to, because I want to fit in. :>
09:27RaynesI have to catch myself doing it sometimes.
09:28chouserI guess you could also end all your lines with semicolons. :-)
09:41rhickeydoes anyone use attribute maps trailing bodies in defn?, e.g. (defn foo ([x] x) {:y :z})
09:41chouserI didn't remember that was an option until yesterday. I don't think I've seen any code in the wild using it.
09:43fliebelWhat does it do?
09:43RaynesWhat he said, only 30 minutes ago instead of yesterday.
09:43rhickeyso, I'm considering implicit 'magic' args to defmacro - &locals &form. Haven't been able to talk myself out of them. The alternative is rather cumbersome special 'please pass me the form' magic in defmacro arglist
09:44Raynesfliebel: It's a reader metadata map.
09:44fliebelAh...
09:44rhickeyactually its just a map, used by defn for metadata
09:45rhickeyCL lets you name the form using &whole my-name
09:45RaynesIt's just a map, but it's still a metadata map. :p
09:45rhickeyand environment using &environment my-name
09:47chouserrhickey: this is magic other than a var binding with the info in it?
09:48rhickeychouser: yes - that *macro-meta* example from before actually works, just not documented and unsupported. Too finicky with nesting. These would be arguments inserted before those declared, and automatically passed
09:49_fogusSorry for being dense, but what would &form and &locals contain?
09:49rhickey&form would be the form of the macro call itself
09:49rhickeyi.e. the list, with the macro name and the args
09:50rhickeyso you could e.g. recover metadata from the list form or the macro name if desired
09:51rhickey&locals would be a map of symbols to something-unspecified-until-cinc, representing the locals in scope
09:51crazzyfordis there an easy way to delete files using clojure?
09:52_fogus(defmacro foo [x] ... (prn &form)) (foo 42) would print "(foo 42)"?
09:52rhickey_fogus: yes
09:52_fogusok
09:54defncrazzyford: do you know how to use any java in clojure?
09:55crazzyfordI do
09:55crazzyfordbut looks like I have to mess with java's security model
09:56defnsecurity model?
09:56defnto delete a file?
09:56crazzyfordas in the jvm doesn't have permissions to delete a file
09:56crazzyfordI think
09:56defnhttp://java.ociweb.com/mark/clojure/article.html#JavaInterop
09:56crazzyford(.delete (java.io.File. "data/bork.db")) returns false at least
09:57defnfrom where? the repl?
09:57crazzyfordyep
09:57defnusing swank?
09:57crazzyfordyep
09:58crazzyfordand the file exists
09:58defntype ,cd[enter] in the repl
09:58defnand navigate to the path you think you're at
09:58crazzyfordaah
09:58_fogusrhickey: I shudder to, but mostly out of amazement. ;)
09:58crazzyfordswank thought I was in a different directory to where the jvm thought I was
09:58crazzyfordI think
09:59defncrazzyford: paths are funky at first
09:59defncrazzyford: you'll get the hang of it
09:59crazzyfordyeah returns true now
09:59crazzyfordmany thanks
09:59defnno problem
10:01defncrazzyford: also, just for fun: (ns my-namespace (:require clojure.contrib.java-utils)) (delete-file (file "data/bork.db"))
10:01defnhttp://richhickey.github.com/clojure-contrib/java-utils-api.html#clojure.contrib.java-utils/delete-file
10:01defna handy little library -- i like the (as-#"*") stuff
10:02defnit hides a lot of ceremony
10:18chouserrhickey: you could always just redefine defmacro later. ...a version that will be useful for cinc if I'm understanding self hosting yet.
10:20cburroughsI'm having OOMs with this code: http://paste.lisp.org/display/93333. I am not sure why. My understanding is that doseq does not collect results (http://onclojure.com/2009/03/04/dorun-doseq-doall/). I have confirmed I can evaluate urls and (map make-call-fn urls)
10:22cburroughs(The reason for using an explicit threadpool and not something like contrib.http.agent is to control it's size, and thus approximately to control the rate of requests.)
10:26cemerickinteresting that the +constant-name+ convention doesn't seem to be used in clojure
10:35chousercemerick: because everything is a constant
10:35chouserat least that's been my argument
10:36cemerickchouser: well, I've been using +foo+ to indicate a var that is not meant to be rebound
10:36cemerickthat is, starting this week :-P
10:39chouserah
10:40chouserprobably not meant to be rebout and also not function?
10:40cemerickright. (def +universal-constant+ 42), etc
10:43chouserthis week a I wrote a bunch of code to mock out a big chunk of our api to allow testing of RPC servers independent of the network.
10:43chouserrebound a lot of things that were not meant to be rebound. :-)
10:44cemerickyeah, that's what I'm trying to avoid
10:44chouserwell, but it was useful.
10:46cemerickoh, sure, but there really are some things that are constants :-)
10:52crazzyforddid you use fixtures/contrib.mock for that?
10:52chouserno
10:52crazzyfordjust rebound the vars?
10:52chouseryep
10:53chouserI should look at using clojure.test's junit support. I set up my own weak little tie-in to junit before that existed.
10:53defnchouser: do you have any advice for someone who is a medicore, fairly inexperienced programmer who is trying to contribute to clojure?
10:54RaynesNext time I'm at the library, definitely.
10:55defnRaynes: I finally got mine in but I'm intimidated ATM
10:55defnI'm no genius -- only have been messing with lisps, clojure, AND java for about 3 months
10:55defnbut I desperately want to help out
10:56crazzyfordwell where do you want to help out?
10:56defnanywhere it wont be annoying if i fail
10:56stuartsierrachouser: it only supports the JUnit XML output format right now
10:56crazzyfordwrite some tests for something in clojure or contrib then?
10:56chouserstuartsierra: I don't know if I need more than that.
10:57chouserhm, I probably need to be callable from a junit runner or whatever
10:57defncrazzyford: idk ive been working on this thing called cljex which will eventually be a sort of clojure examples server, but im hoping to abstract it enough to make it sort of an all-purpose documentation helper tool for projects
10:57defnit's a lot of junk, but ive learned a lot
10:58chouserdefn: Rich has been begging for tests on a few specific features, though I forget at the moment which ones.
10:59defnchouser: im about to go to bed, but if you think of anything you guys need help with let me know
10:59crazzyfordI was poking around yesterday and I don't think refs/agents/atoms have tests on them
11:00defnim just interested in cultivating community and helping people get better while i get better
11:01crazzyfordI liked the examples server idea
11:01mjt0229what test framework is the core and contrib exercised with?
11:01crazzyfordclojure.test I think
11:01defncrazzyford: i did it all wrong. i need to redo it
11:01crazzyfordoh
11:01crazzyford:(
11:01crazzyfordI was looking forward to that
11:01defnit *works*, but the thing is, someone mentioned to me that it should be a central server
11:01defnwhere people can edit documention and submit it to the server
11:02defnlike JSON format documentation
11:02crazzyfordand ?
11:02crazzyfordoh
11:02crazzyfordso you store it on the server as JSON, and people can pull it down as they like?
11:02defnone thing that really needed to change was the whole python requirements things i had going on
11:03crazzyford(were you using pygments to syntax highlight stuff?)
11:03defncrazzyford: yeah
11:03mjt0229crazzyford: is that clojure.test-is? google is coming up blank on clojure.test
11:03defnthere's nothing like pygments for java or clojure
11:03crazzyfordmjt0229: yeah, test-is got moved to clojure.test a while back
11:03crazzyforddefn use prettify.js
11:04crazzyfordor summat similar
11:04pjacksonIs that a google library?
11:04crazzyfordyes
11:04defnwhere do yuou get it
11:04pjacksonI've heard good things.
11:04crazzyfordyou'd need to download the lisp language pack for it and specify that your code is lisp
11:04crazzyfordbut should be good
11:04mjt0229hmm, am I crazy or do the clojure.org api docs not reflect the change yet?
11:04crazzyforddefn: http://code.google.com/p/google-code-prettify/
11:04defnoh you mean SyntaxHighlighter?
11:05crazzyforddon't know
11:05crazzyfordnah, didn't mean syntaxhighlighter
11:05crazzyfordprettify.js outputs far nicer stuff
11:06crazzyford(by default anyway)
11:06defni should just write my own tbh
11:06crazzyfordscrew linenums for examples
11:06crazzyfordwhy?
11:06defnit's not that hard with a lisp and the existing tools
11:06crazzyfordI wouldn't know
11:06defnits harder than im imagining im sure
11:07defnbut nowhere near impossible
11:07crazzyfordquite probably
11:07crazzyfordyou could be lazy and do it with regex
11:07mjt0229oh, there we go. If I navigate to it rather than search, they appear correct.
11:07defnmjt0229: clojars?
11:07crazzyfordclojure doesn't really need that much highlighted
11:07defncrazzyford: yeah
11:08defncrazzyford: it does as it doesnt
11:08defnfor readability i would probably highlight (first [fn blah])
11:08crazzyfordlook at clojure.vim's syntax file for a big list of clojure keywords, sorted so similar stuff is together
11:09crazzyfordseriously, I'd much rather have this come out without syntax highlighting (or minimal stuff via prettify.js) and then have proper syntax highlighting later
11:09crazzyfordrelease early, release often an all
11:10defngood point man
11:10defn80/20
11:10defn80 of this is making the creation of examples easy, making them accessible to potential client implementations
11:10defn20 is making it pretty
11:10crazzyfordeven less than that
11:10crazzyfordvery few places that have good docs have pretty docs
11:11crazzyfordas long as its easy enough to use etc
11:11defnive always loved the ruby docs
11:11defnbest docs ive ever seen IMO
11:11crazzyfordrdoc generated ones?
11:11defnhttp://ruby-doc.org/core/
11:11defni love that layout
11:11defnit's difficult to do the same thing with clojure
11:12crazzyfordI've found those annoying
11:12defnwhat's a good doc to you?
11:12crazzyfordneeds more search
11:12esj+1 crazzyford, i too do not like the Ruby doc style
11:13defngood ideas for the style?
11:13defnwhat do you envision?
11:13crazzyfordI unno
11:13crazzyforddoesn't matter that much
11:13crazzyfordneeds to be released first
11:14defnmaybe a library which just adds a basic (docjure) fn which lets you do something like (docjure and)
11:14crazzyfordcan just use (doc and)
11:14crazzyfordthat works now as well
11:14defnit gives you an extended doc which includes an example
11:14crazzyfordhow?
11:15crazzyfordare you putting examples on metadata?
11:15defnpulls the JSON from a server
11:15crazzyfordah
11:15crazzyfordgotcha
11:16crazzyfordso currently you have a (I assume compojure) site that runs locally, that you can get JSON from?
11:19djorkdefn: Ruby only has good docs when it has good docs... many are incomplete or outright missing
11:21Carkha little question : i'm doing log files by printing maps to a file. If i want to read that back for processing, there might be some unreadable objects in there like #<Date Wed Jan 13 17:24:39 CET 2010>
11:22Carkhis there soem way to tell the reader i want theses values as strings ?
11:22crazzyfordyes
11:22crazzyfordsee http://briancarper.net/blog/who-needs-a-db
11:22RaynesAll your lambda are belong to us.
11:23crazzyfordSkip down to the part that starts with "Some Java data types"
11:24Carkhcrazzyford : right that's from the printing part, but i don't know all the types that might be printed
11:24crazzyford:/
11:24Carkhi'm looking at solving this problem from the reading side
11:24crazzyfordmight be difficult with that
11:25Carkhsee i'm logging agent errors along with agent data, abd want to make it as generic as possible in order to use it in different projects
11:26Carkhahwell i think i'll just log the whole agent data as a string and be done with it !
11:27crazzyfordhow are you logging agent errors?
11:30Carkhwell i'm using a macro that will take all exceptions and send these to a log file
11:30crazzyfordout of interest, can you paste it?
11:31crazzyfordI might have a use for that (if you're ok with it)
11:31Carkhclojurebot: paste?
11:31Carkhhum =P
11:32crazzyfordhttp://paste.lisp.org/
11:32djorkwhat are people using for persistence in compojure web apps?
11:32crazzyfordtokyocabinet here
11:32crazzyfordwas a right arse to set up though
11:32Carkhhttp://gist.github.com/276336
11:33Carkhpretty standard stuff
11:33Carkhnow for the log function, there's a whole framework behind that with log rotation and stuff
11:34Carkhso i'm using this in every sensible agent function and that's it
11:35Carkhthis is not to be abused as most of the time you might want to let your agents fail
11:35crazzyfordso you do something like (send-off an-agent (fn [args] (safe-agent body))) ?
11:35Carkhright, body being the meat of the function
11:35crazzyfordaye aye
11:36crazzyforddjork: I looked into using redis, but realised manipulating data in clojure was easier than using redis' stuff
11:36chouserCarkh: agent error handling was just updated this morning. It's better now. :-)
11:37djorkso crazzyford you just persist clojure objects to disk?
11:37crazzyfordusing tokyocabinet, yeah
11:37Carkhahwell, i'm always 3 months late as clojure versions go...
11:37crazzyfordand strings
11:38Carkhchouser : do you have a writeup somewhere about this ?
11:38crazzyfordcarkh you can look at the diffs
11:39crazzyfordhttp://github.com/richhickey/clojure/commit/b63af1ad6ce38b50552be3c424ea166cb063ee7c
11:39crazzyfordbasically as well as :validator you can add :error-handler
11:39crazzyfordthat's very nice
11:40chouseralso, here: http://www.assembla.com/wiki/show/clojure/Agent_exception_handlers
11:40djorkcrazzyford: what were the hiccups in getting tokyocabinet set up?
11:40djorkI am building a back-end system for a web/iPhone app and want to try it in compojure if posisble
11:41crazzyforddjork: you have to set java.library.path, and making the java stuff compile was an annoyance
11:41djorkah, so it's just standard java native stuff
11:41djorktypically annoying, yes
11:41djorkbut not too bad
11:41crazzyfordnah it uses c libs in there as well
11:41djorkright native libs
11:41djorkI mean
11:41crazzyfordaye
11:41Carkhchouser : you went for the sync version ?
11:42crazzyfordand make sure you dl/install tokyocabinet (not java bindings) before you install the java bindings
11:42djorkTK seems pretty mature
11:42crazzyfordalso I had to ensure $JAVA_HOME was set correctly to get it to compile (seeing as it needs to know where to find jini.h)
11:43djorkare you using Tyrant as well?
11:43crazzyfordnope
11:43djorkhmm, so how do you handle concurrent access to the DBM?
11:43crazzyfordnearly everything I actually do sits in refs inside clojure
11:44crazzyfordand sends-off to agents at the end of dosync to write to the db
11:44djorkah, so you just persist occasionally
11:44djorkright
11:44djorkmakes sense
11:44Carkhcrazzyford : funny, i'm having most of my stuff in agents =P
11:44crazzyfordI only really use agents as backup
11:44crazzyford*for persistence
11:45crazzyfordthough actually using them instead of refs might make a lot of sense
11:46Carkhthough some people here disagree, i feel like refs are for data and agents for action
11:46crazzyfordwell this is data
11:46crazzyfordso keeping stuff in refs makes sense
11:46Carkhtrue
11:46Carkhthough most data sits in a database on my projects
11:47crazzyfordaye
11:47crazzyfordmy stuff probably could
11:47Carkhso there isn't that much state to keep in memory
11:47crazzyfordloading the largest quanta of state my app uses takes 8ms
11:48crazzyfordgogo TK
11:48Carkhwew that's fast ... connecting to postgres is already 30ms on my dev computer
11:48crazzyfordSSD mind
11:48Carkhahh you're cheating !
11:49crazzyford:)
11:50crazzyfordthough having said that
11:50crazzyfordon my server (smallest linode host you can get) that takes 8ms as well
11:50mjt0229Nice. I think the test framework looks pretty solid. I don't suppose that there exists any sort of coverage tools though....
11:51crazzyfordmjt you can probably write one pretty quickly
11:51mjt0229Hm, I'll have to think about it.
11:51mjt0229I'm still new at this :)
11:52crazzyfordseeing as tests are (iirc) attached to functions as metadata before you run each test
11:53crazzyfordyou can look at each function and check whether it has :test data at the end of your clojure.test file
11:53crazzyfordI think
11:54crazzyfordusing something like ns-publics
11:56stuartsierraThat won't tell you that all possible branching paths are covered.
11:56stuartsierraAnd deftest does not not attach to existing functions test.
11:56kefkaI have a question about sorted maps/sets
11:57kefkanil seems to always be the leastmost element. Is this something I'm allowed to depend upon?
11:57crazzyfordcheers stuart
11:57crazzyfordis there a possible way to do test coverage?
11:57stuartsierraSure. Write an interpreter. :)
11:58crazzyford:(
11:58crazzyfordthought it was something like that or somebody would have already done it
11:58stuartsierraOr figure out how to modify a Java code-coverage tool.
11:58stuartsierraBut somehow you'd have to look at the bytecode that's being executed and relate it back to the Clojure code that created it.
11:59kefka,,, or should I avoid depending on that trait of sorted maps as a matter of general principle?
11:59mjt0229I was afraid it was something like that. I skimmed a paper about code coverage a long time back that had the problem neatly modeled, but I don't think that it's trivial to solve.
12:01mjt0229There's a (possibly apocryphal) story that the author of Emma, a guy named Vlad who worked for Trilogy back in the glory days, come in to the office over a weekend with a fifth of whiskey and emerged with the first version of Emma.
12:07arohnerkefka: sorted maps can use an arbitrary comparator
12:08arohnerkefka: so you probably can't depend on that, unless you're assuming the default sort. which I wouldn't do
12:09chouserthe default comparator, however, explicitly sorts null before everything else, so it's likely that will stay the same.
13:08chouserHa! http://twitter.com/jeremey/status/7716361820
13:09chouser"Clojure programmers have more fn"
13:11the-kennychouser: haha
13:11the-kennyI want this on a shirt
13:18unfo-chouser, i heard a similar version when i was in the erlang community - only functional programmers know to have fun was the jist of it but i forget the witty version ;)
13:18wilighaving a problem running the contrib.sql test suite in emacs + swank. evaling (db-sql-exception) gives No matching method found: println for class swank.util.io.proxy Anyone come across this?
13:19wiligswank was installed via elpa on a brand new emacs 23.1 Mac OS X
13:21wiligIt seems any time a JDBC driver raises an exception, this problem occurs.
13:21technomancywilig: is it different if you enter it in the *inferior-lisp* buffer vs *slime-repl*?
13:22technomancythere are a few bugs with stdin and stdout in swank-clojure that are on my list to track down
13:22technomancythings like read-line and the debug-repl must be run in inf-lisp for now until they're resolved
13:23wiligah, let me try that.
13:23mjt0229Does anyone here use Leiningen to set a test path that's different than their source path?
13:23mjt0229lein test appears to figure out which namespaces I've got tests written for, but doesn't actually report running any tests.
13:24wiligtechnomancy: that did it! thanks so much, I've been beating my head against this for a while.
13:25technomancywilig: yeah, it's a frustrating bug. wish I had time to really dig into the swank-clojure codebase and rustle it out.
13:26technomancymjt0229: you could try setting the :test-path key in project.clj, otherwise maybe report a bug on the leiningen mailing list
13:26mjt0229yeah, that's what I tried.
13:26mjt0229I'm assuming that the project.clj snippet should read :test-path "test"
13:26wiligtechnomancy: where would you being looking? I've got some time this afternoon. I'm a complete newbie to clojure, but I know my way around java.
13:26mjt0229but it's not explicitly specified in the docs.
13:26technomancymjt0229: if it's just "test" then you don't need anything in project.clj; that's the default.
13:27mjt0229huh.
13:27mjt0229that seems like a good default.
13:27Raynestechnomancy: Leiningen's README doesn't have any examples of using :repositories; how would you use that?
13:27technomancyRaynes: it just needs to be a map of repository names to URLs
13:27Raynestechnomancy: Thanks. :)
13:27mjt0229oh, I didn't make the connection, are you the author?
13:27ts00000technomancy: are there any issues you know of with lein, swank, and fuzzy completion w/ slime?
13:28technomancymjt0229: yeah
13:28Raynesmjt0229: He is. Sir Phil.
13:28the-kennyts00000: Works flawlessly here
13:28ts00000chouser: thanks again for the help last night, got everything working this morning
13:28ts00000the-kenny: even while connecting remotely?
13:28technomancyts00000: there are with slime trunk, but wdouglas just submitted a version of slime-fuzzy to elpa that should be uploaded any day now
13:28mjt0229technomancy: after 5 years building software in the industry, where we had our own home grown solutions, I was totally flummoxed by the complexity that is Maven. Leiningen is my new best friend.
13:28technomancymjt0229: yay! =)
13:29the-kennyts00000: I think so
13:29mjt0229On top of that, by looking at the generated POMs, I'm starting to figure out what the hell Maven is supposed to be doing for me.
13:29ts00000technomancy: ok, great
13:29technomancywilig: that's exactly the response I was fishing for. =) unfortunately I'm not sure quite where to start. possibly util/io.clj and core/server.clj
13:29the-kennytechnomancy: Huh? fuzzy in elpa? Cool!
13:30technomancyI'm not actually that familiar with the clj side of the codebase; I've mostly just worked on the elisp side
13:30ts00000someone should do a slime/emacs/clojure tips/tricks screencast with keys
13:30wiligtechnomancy: Well, off I go. I'll probably make the situation worse, but you've got to try. ;-)
13:31technomancywilig: thanks!
13:34chris_suteri'm looking to parse some rather large, somewhat complex xml in clojure. i've taken note of clojure.xml and clojure.zip; wondering if anyone has any suggested reading on general tree-walking methodology. i'm relatively new to the functional programming paradigm. TIA
13:35chris_suteri should say, by "parse" i actually mean break apart and import into a relational database
13:38RaynesLeiningen makes me happy.
13:50ajazzhello! There is *default-encoding* in defined in clojure.contrib.duck-streams (http://bit.ly/8H5ouV). How can I change it?
13:50cburroughsI wan to read in lines from several files larger than RAM, generate a url for each line, and make concurrent http requests at a controlled rate (such as by controlling how many threads are making requests). Is there an obvious way to do this in Clojure?
13:51the-kennyajazz: Either set! (Not very functional) or rebind it with binding
13:52cburroughsI've spent most of the day trying to use Executors/newFixedThreadPool and a lazy sequence, but have not managed to find a solution free of OOMs.
13:52wiligtechnomancy: what would be the best place to get the source for swank-clojure? take yours from github?
13:52the-kennyajazz: e.g. (binding [*default-encoding* "foobar"] (slurp* url))
13:52chousercburroughs: you want more than one thread going?
13:52technomancywilig: yup
13:53cburroughschouser, yes. ideally I'd like to control how many threads are going.
13:53wiligtechnomancy: oh dear, the tests fail. not a great start.
13:54technomancywilig: yeah, I inherited it that way. =\
13:55wiligwhat fun. broken code with broken tests. can open, worms everywhere!
13:55cburroughschouser, A more sophisticated way of controlling the rate at which URLs requests would work just as well, it does not have to be number of threads.
13:58cburroughsIn a conventional language I would have a shared queue with producers and consumer threads.
13:59chouserNo reason not to do that.
14:00cburroughsUse refs for the queue then?
14:01chouserI'd look at using a BlockingQueue
14:01technomancydepends on how you want to handle errors
14:01chouserjava.util.concurrent.LinkedBlockingQueue for example
14:02technomancyrefs with a persistent queue might be a nice way to keep something on the queue in the case of errors
14:02technomancybut it gets icky for 100%-reproducible errors I guess
14:03chouserand no good way to block waiting for the next item.
14:03technomancyyeah, you'd have a lot of useless retries
14:04cburroughsI'm not particularly picky about error handling at this point.
14:04wiligtechnomancy: tests don't seem to be getting compiled. lein compile should compile the tests as well as src right?
14:06technomancywilig: no, there's generally no reason to AOT tests
14:07wiligtechnomancy: ah ok. just wondering cause I get classpath exceptions when trying to run tests.
14:07technomancyalso: looks like you have to move the tests from test/clojure/swank to just test/swank to get it working
14:07technomancyI haven't run the tests since switching to leiningen obviously =\
14:08technomancybut once you do that they seem to be OK, though sparse
14:08wiligoh, great, thanks
14:09wiligtests now running. a much better starting point.
14:49crazzyfordtechnomancy: I got some emacs code that flashes the modeline green/red based on test output
14:50crazzyfordtechnomancy:you want me to try integrating it in clojure-test-mode?
15:00technoma`crazzyford: sure. maybe get it to only flash on failure?
15:01technoma`I guess it depends on how distracting it is.
15:01crazzyfordoflashes for like a second
15:02crazzyfordnot that bad
15:02technoma`cool
15:02technoma`yeah, I'd love a patch
15:02technoma`haven't done much with clojure-test-mode in a while
15:04cemerickI'm shocked that there's no date utils in contrib.
15:04jkdufairwhat's the idiomatic way of evaluating a string as a set?
15:05crazzyfordtechnomancy: here's the gist of it http://gist.github.com/276535
15:05technoma`cemerick: I tried writing one once
15:05cemericktechnoma`: tried?
15:06technoma`wrapping java.util.Calendar, but the JDK's built-in classes are very problematic to work with
15:06technoma`cemerick: any time you cross DST boundaries or perform cross-timezone calculations you get incorrect results
15:06technoma`it's pretty horrible
15:06crazzyfordyou can use joda time anyway
15:06technoma`if you want it done right, you have to use the joda library
15:06crazzyfordworks well enough
15:06crazzyford^_^
15:07cemerickoh, at the moment I'm just talking about parse, format, now fns, etc., which is what 99% of my apps need
15:07technoma`and joda objects are immutable, so not much wrapping is needed
15:07jasappjkdufair: do you mean like:
15:07technoma`cemerick: you could search the mailing list for "chrono" if you want to find my old lib
15:07jasapp,(read-string "#{1 2 3}")
15:07technoma`don't judge me based on it though; it was my first public clj code. =)
15:07jasapphmm
15:07cemericktechnoma`: I'm not that motivated :-) I have no need for calendar anyway.
15:07technoma`as long as you don't need to perform date arithmetic you should be OK
15:08cemerick"java.util.Date is fine for me" ;-)
15:08jkdufairwell, more like (index-of-any (set "foobar") (set "foo"))
15:08technoma`hehe; sure
15:08jkdufair(working my way through "programming clojure")
15:08jkdufairtrying some other ideas out as i go along
15:09jasappI'm not sure what you mean by index-of-any
15:09jkdufairwhere index-of-any wants a predicate and a collection
15:09jasappahh
15:09lisppaste8cemerick pasted "barebones date lib" at http://paste.lisp.org/display/93346
15:09jkdufairsets seem to act as predicates when passed possible members but strings, no
15:09cemerickI *might* add before/after :-P
15:10jasappI'm still not quite sure I understand
15:10jkdufairah, i probably just need to go read some more code. trying to learn not just the language but the common idioms
15:11somnium,(map (set "foo") "foobar")
15:11somniumno bot today?
15:12jkdufairspiff. thx somnium
15:39qbgIs there a function like var?
15:55djorkqbg: what do you mean?
15:55djorkdo you mean a function that behaves like the special form "var"?
15:56qbgdjork: yes
15:56rhickeyqbg: what would you pass it?
15:56qbgA symbol
15:56rhickey,(resolve 'rest)
15:57qbgPerfect
15:57jasappclojurebot is mia
15:58hiredmanagain?
15:58hiredmanjava.net.ConnectException: Connection refused (NO_SOURCE_FILE:0)
15:58hiredman:|
15:59{newbie}hiredman: what happens if the try to block the stack of the bot
15:59{newbie}we*
15:59hiredmanblock the stack?
16:00{newbie}blow*
16:00hiredmanit blows
16:00Chousukeand then nothing happens :)
16:01clojurebothmm
16:01jasapp,(+ 1 2)
16:05hiredmanhmmm
16:05hiredman(System/setSecurityManager nil) <-- fess up, who is trying to break clojurebot?
16:07the-kennyhiredman: Heh
16:07the-kennyhiredman: I think that was me.. in the XMPP room. Just trying, of course
16:08hiredman:P
16:08hiredman,(+ 1 2)
16:08clojurebot3
16:16technomancyotherwise every single person who wants to perform a checkout is going to have to download several useless megabytes
16:16technomancy2x the size of the jars, since they are added *and* removed
16:17Raynes:\
16:17technomancygit is *really* bad at storing binary files
16:17technomancyI wish people would understand that
16:18RaynesI hope I can find these jars in maven repos somewhere. I've found a few of them, but a few aren't in central.
16:20lypanovdamn. 217 people. wow.
16:20lypanovcan someone (preferably a zealot) please explain why scala sucks and i should be using clojure?
16:21technomancyclojurebot: scala?
16:21{newbie}scala doesn't suck
16:21hiredmanclojurebot: tell us something about scala
16:21clojurebotamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
16:21qbgWe have awesome parens.
16:22hiredmanclojurebot: that was dumb
16:22clojurebotwhose job is<reply>that is arohners job
16:22technomancyclojurebot: hey, wake up. the city has need of a hero.
16:22Rayneslypanov: http://blog.bestinclass.dk/index.php/2009/09/scala-vs-clojure-lets-get-down-to-business/
16:22hiredmanclojurebot: what do you think about scala?
16:22clojurebotdownload is http://github.com/richhickey/clojure/downloads
16:22clojurebot☝(^_^)☝
16:22hiredmanhmmm
16:22{newbie}haha
16:22rhickeylypanov: Clojure rocks in no small part because the community doesn't waste time dissing other langs and instead prefers to just help each other out using Clojure
16:22{newbie}the hand detal is superb
16:23lypanovrhickey: um. and the lead is on a channel of 217. k. i'm convinced. thx
16:23technomancyok, who put meth in clojurebot's init file?
16:23lypanovrhickey: 1 q. how insane is it to imagine a gwt equiv (or just gwt somehow) for clojure?
16:23Rayneslypanov: Yeah, rhickey is awesome.
16:23hiredman<--
16:24Rayneslypanov: Why not use GWT directly from Clojure?
16:24djorkthat would be the easy way out
16:24lypanovRaynes: its messed up. it parses the java rather than using bytecode. *sob*
16:25hiredmanclojurebot: what do you think about scala?
16:25clojurebot{((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
16:25hiredman~scala {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
16:25clojurebotAny = 1
16:25chouserlypanov: you might be interested in http://www.webtoolkit.eu/jwt
16:26technomancyRaynes: nothing wrong with putting clj-oauth's dependencies on clojars yourself under a non-canonical groupId if you can't find them elsewhere
16:28lypanovchouser: alas, i'm interested in gwt not for its magical ui toolkit or anything, but rather for its optimised js gen ability.
16:28Raynestechnomancy: But you can't just upload random jars, can you? Doesn't there have to be a project.clj?
16:28RaynesI've not used this magic yet.
16:28hiredmanRaynes: just a pom
16:28lypanovchouser: (we're using pure.js + jquery + json backend atm)
16:28lypanovcharrrrrrles. etc
16:28{newbie}hiyou can write {((x: Any, y: Any) => (f: (Any, Any) => Any) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
16:28{newbie}too
16:29hiredman*shrug*
16:29technomancyRaynes: all you need is a pom; it's not hard to construct a minimal one that is used only for dependency calculation
16:29lypanovchouser: (also, we have very little interest in degradation, as our product would simply suck if it was needed, so i don't see the point :) )
16:29RaynesBleh.
16:30RaynesGuess I'll have to figure out maven crap tonight then.
16:30chouserlypanov: ah, well google has a javascript-to-javascript compiler named, unfortunately, "closure"
16:30technomancyit's like six lines of XML; it's not bad. it should be documented somewhere though.
16:30lypanovyeah, closure is pretty cute. but it doesn't optimise shit. gwt otoh does.
16:30chouserso all you need then is a way to generate js in the first place. There are several options that consume Clojure or clojure-like expressions and produce js
16:30hiredmanlypanov: optimizing is the whole point of "closure"
16:31lypanovhiredman: opting source size. but not opting exec time.
16:31hiredman"The Closure Compiler compiles JavaScript into compact, high-performance code. The compiler removes dead code and rewrites and minimizes what's left so that it downloads and runs quickly."
16:31lypanovjs is too dynamic for closure to possibly compare.
16:32chousergwt doesn't do runtime optimization, does it?
16:32lypanovi can give some examples if needed, but it doesn't really cut it.
16:32lypanovchouser: it does silly things that removing abstraction if only one class implements something. etc.
16:32lypanovthey add up to a lot together with dead code elim.
16:32lypanovalmost impossible with js imo.
16:33chouserin that case you'll either need to write java code yourself, or write a java *source* backend to the clojure compiler.
16:33lypanovchouser: aye. there is a start of one for scala. but its still very basic.
16:33lypanovand i'm wondering if clojure isn't better suited to my mind set.
16:33chouserthe latter has been contemplated, but I doubt any work will be done on it until after clojure is self-hosted, and maybe not even then.
16:34lypanovi need to learn more about it tbh.
16:34chouserthe former is done by thousands of programmers every day. :-)
16:34lypanovi have much more experience with scala.
16:34lypanovaye, i'm doing that atm.
16:34lypanovthanks to ide's java is quite comfortable.
16:35lypanovbut sometimes i really miss the high abstraction levels that other langs provide.
16:35chouserglad it's working for you.
16:35lypanov(well, primarily i code in ruby, but i abhor that language)
16:36hiredman1. lisp 2. functional 3. good selection of immutable persistant datastructures 4. ??? 5. profit
16:36{newbie}lypanov: if you still work with java this might be interesting http://code.google.com/p/fluentjava/wiki/GettingStarted
16:37lypanovoooooooooooooooooo (repeat 10x)
16:37lypanovits like that apache collections proj but apparently doesn't blow
16:38Raynestechnomancy: Yeah, I think I can manage. Just looked at a pom generated by lein. I could adapt one of those if I need to. Most of this stuff is apache stuff, so surely I can find them on a maven repo somewhere anyways.
16:38RaynesFor now, I must sleep!
16:38lypanovRaynes: thx for the link dude:)
16:39Rayneslypanov: No problem.
16:41mabesIs there a function that will slice a vector into two different ones?
16:41mabes,(let [x '(a b c d e f g)] [(take 2 x) (drop 2 x)])
16:41clojurebot[(a b) (c d e f g)]
16:41mabeslike this ^
16:41hiredman(a b c d e f g) is a list
16:42chouser(doc split-at)
16:42clojurebot"([n coll]); Returns a vector of [(take n coll) (drop n coll)]"
16:42mabesright, sorry, I don't really care if it is a vector or a list
16:42mabeschouser: great, thanks
16:44Chousukehmm
16:44Chousuke,((juxt take drop) 4 [1 2 3 4 5 6])
16:44clojurebot[(1 2 3 4) (5 6)]
16:44chousernice
16:44Chousukefirst real use of juxt I've figured out so far :P
16:45hiredmandeeply?
16:45hiredmanthinks that are highly offensive offend you deeply?
16:45hiredmanthings
16:45ChousukeI think so
16:46the-kenny,(doc juxt)
16:46clojurebot"([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"
16:48lisppaste8stuartsierra pasted "Double dispatch with protocols" at http://paste.lisp.org/display/93353
16:48stuartsierraI don't know if that's correct, but it works.
16:50hiredmanhuh
16:51Chousuketricky
16:52stuartsierraanyway, got to go, would like to discuss this tomorrow
16:53hiredmanthere was some paper that used something similar for double dispatch in a java like language
16:53hiredmandouble dispatch type inference
16:54hiredman~google double dispatch type inference
16:54clojurebotFirst, out of 3330 results is:
16:54clojurebotEfficient Just-In-Time Execution of Dynamically Typed Languages ...
16:54clojurebothttp://www.ics.uci.edu/~franz/Site/pubs-pdf/ICS-TR-07-10.pdf
16:54arnihermanncan anyone point me towards some performance benchmark of clojure?
16:55ChousukeI don't think there are any that will help you
16:55arnihermannI'm akin' to use it for a general game playing agent
16:56ChousukeClojure is definitely not as fast as java in the general case, but for a dynamic language, it's pretty good.
16:56arnihermannI think clojure would be perfect in almost every aspect except maybe performance
16:56arnihermannright
16:56hiredmanarnihermann: that basically means you need clojure to do things as fast a person sitting on the other end of IO lag?
16:56arnihermannI'm aware of that
16:56arnihermannnot a person
16:56arnihermannanother program
16:56arnihermanncompeting against my program
16:56arnihermannin a turn based game
16:56arnihermannsuch as chess
16:58arnihermannscheme/lisp is perfect for this
16:58arnihermannexcept performance wise
16:58ChousukeIf something really turns out to be too slow in Clojure, you can write it in Java, and use Clojure as "glue"
16:58hiredmanarnihermann: that is hard to imagine
16:59hiredmanis that based on actually experience?
16:59arnihermannright
16:59arnihermannhiredman: no, not actual experience
16:59arnihermannstanford provides reference implementation of agents in scheme and java
17:00arnihermannI know one of the best performing agents is written in caml
17:00arnihermannanother in c++ and prolog
17:01hiredmanagents is the name of the game?
17:01arnihermannno no
17:01arnihermanngeneral game playing *agent*
17:01arnihermannor program
17:01hiredmanconfusing
17:01arnihermannthe games which are played are turn based games such as chess
17:01arnihermannhttp://games.stanford.edu/
17:02arnihermannsure, it's confusing
17:02hiredmanclojure has a reference type called an "agent"
17:02arnihermanntrue
17:02arnihermannyeah I know :)
17:02arnihermannsorry about htat
17:02arnihermannshould have been more explicit
17:02arnihermannso the player programs are often references as "agents"
17:02arnihermannreference players: http://games.stanford.edu/resources/resources.html
17:02arnihermanndon't reflect the state of the art though
17:03arnihermannone area though which appeals to me is easy parallelized code in clojure
17:03hiredmanI'ver used ocaml, but my impression is it is a speed daemon
17:04hiredmancomes out on top in many cases
17:04arnihermannyes
17:04arnihermannI will probably go with haskell if my clojure evaluation turns negative in performance
17:04hiredman:|
17:04arnihermannanywho, I was just wondering if you guys knew any comparisons
17:04arnihermannwith other languages
17:04arnihermannbenchmark
17:05arnihermannI'll do my best to evaluate it based on my needs
17:05headiusmath is most likely to be the biggest problem area
17:05hiredman~performance
17:05clojurebothttp://clojure.org/java_interop#toc46
17:05hiredmanhttp://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips/
17:05arnihermannmight just post something on my finds
17:05headiusyou can locally type some things to help, but it will only help locally
17:05arnihermannfindings
17:05arnihermannright
17:05arnihermannmost of the time spent in these programs in search
17:06arnihermann+ the knowledge base
17:06arnihermann"is search"
17:07arnihermannanywho, thanks a lot
17:08hiredmanmore control over the generated bytecode without the need to use java
17:14hiredmanyou could generate a set of small static utility methods
17:14clojurebota is t
17:14hiredmanclojurebot: what?
17:14clojurebotwhat is wrong with you
17:17scottjHow would you define a function that could take a list like (* x 10) and square any numbers in it, so in this case it would return (* x 100)
17:18chouser,(map #(if (number? %) (* % %) %) '(* x 10))
17:18clojurebot(* x 100)
17:20scottjahh, that's what I tried except I had identity instead of your last %
17:20scottjthanks
17:22RadioApeShotis there a clojure library that I can use to interact with web apis?
17:22RadioApeShotLike wikipedia's api?
17:23RadioApeShotSomething that can POST etc?
17:24hiredmanwait, post?
17:24the-kennyRadioApeShot: clojure-http-client has some interesting things to help
17:25hiredmanisn't POST the easy one?
17:25beutdeuceI know (eval) evaluates form data structures, is there something in Clojure that can evaluate strings/text ?
17:25hiredman(eval (read-string "(+ 1 2)"))
17:26beutdeucethnx
17:26RadioApeShotthe-kenny: thanks
17:26RadioApeShotthe-kenny: that is probably what I want
17:28hiredmanhttp://gist.github.com/236676
17:28hiredmanillegitimate use of juxt
17:28hiredmanthat post assumes an xml reply, and parses it
17:31hiredman"response" I guess
17:40mjt0229technomancy: do I need to list "tests" as a source path in my project.clj file for Leiningen to compile the test code that lives there?
17:42technomancymjt0229: you mean to do AOT-compilation of test source?
17:42mjt0229yeah.
17:42mjt0229or does lein test eval the files?
17:43technomancymjt0229: do you have gen-class or something in your tests?
17:43mjt0229no, I don't.
17:43technomancythey shouldn't need to be compiled
17:43mjt0229Hmm. Well, I'll keep digging. Thanks!
17:44technomancyif it helps you can try to structure your tests like the ones from leiningen itself
17:45mjt0229that's a good idea. I'm sure I'll figure it out, I've probably just done something strange.
17:45technomancyI need to have "lein new" include a scaffold test file
17:50mjt0229That's possible.
17:50mjt0229I fixed it, by changing my test code to use a namespace different from that of the module under test.
17:51mjt0229I'm not certain why that would change matters, however.
17:51technomancymjt0229: if two files contain the same namespace, then whichever comes first on the classpath wins
17:51hiredmanyeah, that is not a good idea
17:51technomancythe loser will never be visible
17:51mjt0229Evidently :)
17:51hiredmanEVER
17:52mjt0229Unfortunatly, I wanted to have the test output say that it was testing the module I was testing, not the test-module itself.
17:52mjt0229ie, "Testing org.tomko.index" rather than "Testing org.tomko.test-index"
17:52mjt0229Well, I've learned my lesson...
17:53mjt0229it seems that clojure code idiomatically uses less-structured packages/namespaces.
17:54mjt0229Is that motivated by the relatively fewer files/LOC needed in Clojure, or is it a throwback to the LISP days?
17:55hiredmaneh?
17:55hiredmanless structured how?
17:55mjt0229well, it tends to be the case that source directories contain a ton of files, but there does not tend to be the Java-style hierarchy of files and directories.
17:56mjt0229At least, that's what I've seen in the clojure code that I've read (which consists of some of clojure core and contrib, plus some of leiningen)
17:57mjt0229As a java programmer, I'm inclined to create a big hierarchy of packages that's deep rather than broad.
17:58mjt0229less structured may have been the wrong term, it sounds pejorative
17:59arohnerbroad rather than deep is a fair generalization of clojure ns's, IMO
17:59arohnerI suspect a lot of that has to do with the lack of limitations about what you can do in a single clojure file
18:00arohnerno need for multiple files just because you want multiple public classes
18:01hiredmanless baroque
18:02mjt0229my habits are definitely informed by java restrictions/requirements, plus java best practices, many of which don't apply here.
18:04hiredman_bah
18:08beutdeucewhat is the clojure regex for any character?
18:08the-kenny.
18:08beutdeucehmm, tried, but didnt work
18:08mabesI need to merge some nested maps.. I know the level of the mappings before hand. I'm wondering if there is a nice way to merge them..
18:08mabesright now I'm doing:
18:09mabes,(let [t1 {"A" {"B" {"C" 10}}} t2 {"A" {"B" {"C" 2}}}] (merge-with (partial merge-with (partial merge-with +)) t1 t2))
18:09clojurebot{"A" {"B" {"C" 12}}}
18:09mabeswhich works just fine but I want to know if I'm going at the problem totally wrong
18:10mabesthe use of partial is nice but seems a little dirty when I'm using so many in that way.. thoughts?
18:13{newbie}iteresting why does nth return AIOF for a seq
18:14{newbie}(let [omg (iterate inc 0)] (nth omg 100000000000000000000000))
18:14hiredmanAIOF?
18:14{newbie}s/F/B
18:14{newbie},(let [omg (iterate inc 0)] (nth omg 100000000000000000000000))
18:14clojurebotjava.lang.ExceptionInInitializerError
18:14hiredmanAIOB?
18:15{newbie}array index out of bounds
18:15hiredmandunno
18:16hiredmanpossibly something chunked sequence related?
18:18hiredman,(let [omg (seq1 (iterate inc 0))] (nth omg 100000000000000000000000))
18:18clojurebotjava.lang.ExceptionInInitializerError
18:18hiredmanor not
18:20arohner(let [omg (seq1 (iterate inc 0))] (nth omg 1000))
18:20arohner,(let [omg (seq1 (iterate inc 0))] (nth omg 1000))
18:20clojurebot1000
18:21arohner,(let [omg (seq1 (iterate inc 0))] (nth omg 1000M))
18:21clojurebot1000
18:22hiredmanOh
18:25scottjI wrote a library for that provides common unit conversion functions, and I'd be interested in feedback before I post it on the mailinglist. http://gist.github.com/276662#file_units.clj
18:26scottjWith just two equations for inches-to-feet and feet-to-meters, this package automatically creates feet-to-inches, meters-to-feet, inches-to-meters, meters-to-inches, and all the corresponding sqfeet-to-sqmeters, cubicmeters-to-cubicfeet, etc.
18:30technomancy,(binding [identity reverse] (identity "ohai"))
18:30clojurebot(\i \a \h \o)
18:30technomancy(that returns "ohai" on 1.1.0-new)
18:30somniumscottj: have you seen the JScience quantities? (admittedly its java...)
18:31hiredmantechnomancy: direct binding for clojure.core
18:31hiredmanwhich I haven't really seen an anouncement about, possibly I missed it
18:32technomancyit also manifests itself in clojure.test
18:32technomancywhich breaks our build
18:32hiredman:(
18:32danlarkinnot just our build
18:32technomancyto say the least
18:33danlarkinbut clojure.test is designed to have functions bound
18:33hiredmanI love performance, but hate the loss of dynamicism
18:33hiredmaninfact, I think I just "like" performance
18:33scottjsomnium: I hadn't, thanks.
18:33hiredmannot even "like like"
18:33technomancyno hits on the mailing list for direct binding. =\
18:33danlarkinI like performance too, but not when it... breaks things
18:33hiredmanthere was some discussion about it
18:34hiredmanbut I don't actually remember some conclusion
18:34technomancygoogle only gives me haskell hits when searching for clojure "direct binding"
18:35hiredman*shrug*
18:35hiredmanmake a stink on the mailing list
18:37technomancydefinitely going to have to get some clarification
18:37beutdeucehow would i evaluate: (1 2 3) to "(1 2 3)" ?
18:38hiredmanbeutdeuce: you want to turn a list into a string?
18:38beutdeuceyes
18:38hiredmanpr-str
18:38beutdeucethnx!
18:38hiredman,(pr-str '(1 2 3 4))
18:38clojurebot"(1 2 3 4)"
18:38technomancylooks like the bug doesn't manifest with clojure.test in master
18:38hiredman,(pr-str '[1 2 3 4])
18:38technomancytime to get off the new branch I guess
18:38clojurebot"[1 2 3 4]"
18:38beutdeucegreat
18:38hiredmantechnomancy: it might have been merged into master
18:39technomancyhiredman: pretty sure it has, but I guess on master it's been fixed to only apply to clojure.core
19:35mebaran151anybody know a good guide to paredit?
19:38scottjmebaran151: http://www.slideshare.net/mudphone/paredit-preso
20:07mebaran151I'm starting to get the hang of paredit mode
20:10mebaran151thanks scottj
20:11technoma`oh snap!
20:11technoma`if it isn't our old friend clojure.io
20:20sethsscottj: that is one hell of a presentation on paredit
20:20sethswow
20:22joshua-choiAccording to http://clojure.org/reader keywords cannot contain periods ('.'). But this doesn't seem to be true:
20:22joshua-choi,(name :.a)
20:22clojurebot".a"
20:22joshua-choiWhy does that web page say that it's not allowed, then?
20:23technoma`joshua-choi: lots of things are possible that aren't supported
20:24joshua-choiSo is it still officially unsupported?
20:24technoma`yeah, the behaviour is undefined
20:24technoma`that could certainly be clearer in the documentation
20:24joshua-choiI'm writing a Clojure parser in Clojure, so should I enforce that, you think?
20:25technoma`if it's not too much trouble, yeah--I would go with the explicit rules over the implementation
20:25technoma`it's possible the documentation there is just out of date though; wouldn't hurt to check on the mailing list.
20:25joshua-choiYeah, maybe I should
20:25joshua-choiI'm trying to follow the rules defined in LispReader.java, but it's a pain figuring it out from the regexes
20:26joshua-choiAlso, do you know of a rationale for the rule? It seems a little arbitrary
20:26mebaran151I think you can't have them because symbols can be namespace
20:26mebaran151,::abc
20:26clojurebot:sandbox/abc
20:26joshua-choi,::a.bc
20:27mebaran151and namespaces are . delimited
20:27clojurebot:sandbox/a.bc
20:27joshua-choiI was wondering if it would finish :P
20:27joshua-choiYeah, namespaces are delimited
20:28joshua-choiBut I don't really see why that precludes using periods in keywords; just that it requires periods to be allowed in symbols
20:30joshua-choiIn addition, double-coloned keywords can also have prefixes if you aliased a namespace; do those follow different rules too?
20:32joshua-choiExample:
20:32joshua-choiuser=> (require '[clojure.test :as t])
20:32joshua-choinil
20:32joshua-choiuser=> ::t/a
20:32joshua-choi:clojure.test/a
20:32joshua-choiWhat if the alias is a period-containing symbol? Could I still create double-coloned keywords with the alias?
20:34mebaran151I think periods are best avoided
20:34joshua-choiHmm
20:34mebaran151:: is supposed to undo all aliases
20:34mebaran151*resolve them
20:34mebaran151(require '[clojure.test :as t])
20:34joshua-choiI've got to go, but I'd like to figure this out later; thanks
20:35mebaran151no problem
20:35joshua-choi(require '[clojure.test :as t.a]) and then ::t.a/a works too, by the way; is this illegal...
23:32optimizeranyone have a good resource on clojure-gwt interaction?
23:44akingLooks like chouser and _fogus's book (early access MEAP version) is now finally available
23:48arohneroh, this is amusing. There are cases when you can't use println for debugging, when a lazy seq is being realized
23:49hiredmanprn
23:50hiredmanI never use println for debugging
23:50arohnersigh.
23:50arohnercomparing the source, I don't see why prn would work and println doesn't
23:51hiredmanwe maybe talking about different issues
23:52arohnerlet's say I have a function where I return a lazy seq
23:52hiredmanand actually, what I am thinking of is a problem with str not println, so we must be
23:52arohnerand the lazy seq is constructed by calling a function
23:52arohner(for [i ..] (foo))
23:52hiredmandoto
23:52hiredman(doto (foo) prn)
23:53arohnerand then inside foo, you do some println / prn debugging
23:53hiredmanright, you don't see it until you walk the sequence
23:53arohnerif the realization of your lazy seq causes an exception to be thrown, the printlns won't appear, even though they happen before the exception
23:54arohnerbut break the laziness, and you'll see the prints before the exception
23:54hiredmanthey don't happen before the exception
23:54arohnerthey do.
23:54hiredmanthey don't
23:54hiredmanby definition, if they happened, you would see stuff printed
23:54hiredmansince you don't see stuff printed, they did not happen
23:55arohnerI'm glad you cleared that up for me
23:55hiredman:P
23:56hiredman,#(prn :foo)
23:56clojurebot#<sandbox$eval__3833$fn__3835 sandbox$eval__3833$fn__3835@1941856>
23:57hiredmanthe prn did not happen, but it will if you call the function, a laz-seq is more or less just a series of thunks
23:58arohnerI'm looking at seq here. the 13th element throws an exception
23:59hiredmanok
23:59arohnerif I put a dorun around it, I see 12 prints, and then an exception thrown
23:59arohnersorry, I have a (for []..), that I know generates 13 elements
23:59arohnerthe for calls a function that prints