#clojure log - Jan 13 2010

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:00 ts00000: I 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

0:00 chouser: ,(re-find #"a.\b" "abc addr ax aj")

0:00 clojurebot: "ax"

0:00 chouser: yeah, each regex engine is a little different. :-/

0:01 Java's is *very* similar to perl and javascript. Not so much like sed or grep, for example.

0:01 I don't know php regex at all.

0:03 ts00000: chouser: would I use doseq to iterate over the matches, or something else?

0:03 if I was using re-seq

0:04 chouser: learning clojure and regex all at once?

0:04 :-)

0:04 ts00000: pretty much :)

0:04 chouser: sure, doseq would be good for experimenting, printing out your matches as you go.

0:05 but 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'

0:06 neither of those actually iterate as such (they both return lazy seqs) but that's useful for stringing together more "passes" of work

0:06 defn`: (def md (new MarkdownProcessor)) (.markdown md "text") fails

0:06 ts00000: just to print them out - is that like (doseq [i (re-find #"..." x)] print) or something?

0:07 chouser: (doseq [i (re-seq #"..." x)] (prn i))

0:07 for map:

0:07 ,(map count (re-seq #"\w+" "alpha beta gamma epsilon"))

0:07 clojurebot: (5 4 5 7)

0:08 defn`: weird. it works all of a sudden

0:09 chouser: ok, bedtime. fare ye well, all!

0:13 ts00000: hmm, doseq returns nil

0:16 lowlycoder: how do I write a basic clojure app that retrieves a webpage?

0:16 I 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"

0:25 * Raynes just realized he could define his little toy-stack as a protocol since the stack is a data type anyways.

0:33 hiredman: lowlycoder: clojurebot has a google plugin you can start with

0:33 ~google clojurebot

0:33 clojurebot: First, out of 63 results is:

0:33 hiredman's clojurebot at master - GitHub

0:33 http://github.com/hiredman/clojurebot

0:34 lowlycoder: hiredman: nice; thanks

1:13 how do I install clojure-contrib?

1:16 hiredman: ~how do I install clojure-contrib?

1:16 clojurebot: http://groups.google.com/group/clojuredev-users

1:17 hiredman: clojurebot: bah

1:17 clojurebot: excusez-moi

1:17 hiredman: ~how do I install contrib?

1:17 clojurebot: I guess that is my answer.

1:17 hiredman: :|

1:17 lowlycoder: you don't really install it, you just get a jar

1:18 you can either grab one from build.clojure.org or build one from a git checkout

1:19 lowlycoder: done

1:19 now looking into this nailgun thing

1:19 http://martiansoftware.com/nailgun/quickstart.html

1:33 mebaran151: how do I make paraedit default for slime and clojure-mode buffers?

1:34 lowlycoder: does anyon ahve a tutorial for running clojure inside of nailgun?

1:37 Raynes: mebaran151: (add-hook 'clojure-mode-hook 'paredit-mode)

1:37 Add that for Clojure-mode buffers.

1:37 Dunno about slime buffers.

1:37 I was wondering the same thing.

1:45 somnium: there's a slime-mode-hook too

1:48 itistoday: what does DSL refer to?

1:48 i've seen it mentioned in several clojure related blog posts but none of them had the courtesy of defining it

1:49 arbscht: domain-specific language, I guess

1:49 itistoday: arbscht: thanks!

1:53 unfo-: 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

1:53 s/easily//

1:58 lowlycoder: is there a pure clojure database anywehre?

1:58 mebaran151: lowlycoder: I think the closest we have is FleetDB

1:58 neo4j is pretty close to the way you'd think about a ClojureDB exist

2:15 Raynes: Is 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.

2:16 Oh yeah, undo.

2:16 Heh.

2:19 replaca: Raynes: you can also use ^Q before a character you want to push around paredit

2:19 Raynes: Neat.

2:24 Oh that is awesome.

2:24 Defining my stack operations as a protocol and implementing it in a Stack type reduced the length of the code. :D

3:59 LauJensen: Morning team

4:00 Raynes: Morning.

4:19 LauJensen: I think a lot of people tried my Reddit scraper w/o inserting appropriate thread/sleeps :( The admins seemed to have noticed

4:22 Chousuke: LauJensen: Unintentional DDoS. :P

4:22 LauJensen: Yea - People only read the code not the comment below 'If you use this, sleep a little'

4:23 Chousuke: You should have put the sleep in the code

4:23 never trust people to read anything beyond the most prominent section

4:30 LauJensen: True, but I thought an exact 30 lines looked so nice :)

4:31 Raynes: LauJensen: I noticed one of the admins complaining about it earlier.

4:31 LauJensen: I know - I updated my post after that saying UPDATE: Please do as I say

4:32 (to that effect at least)

5:04 esj: Lau: LOL !

5:27 * Chousuke ended up reading Erik Naggum's posts on c.l.l thanks to Planet Lisp

5:28 Chousuke: "Static type analysis leads to brain damage"

5:33 ordnungswidrig: Chousuke: have a link?

5:33 planet lisp

5:34 re. gree.

5:36 Chousuke: The 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. :/)

5:37 His style of writing reminds me somewhat of RMS. Unforgiving, but logical and consistent.

5:37 ordnungswidrig: this combination can be hard to swallow :-)

5:38 Chousuke: yes. But it can also be very enlightening if you can put aside your own opinions for a moment

5:42 ordnungswidrig: Like it: "Yes, God had a deadline. So he wrote it all in Lisp."

5:42 lessandless: I 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?

5:44 * the-kenny read something on EmacsWiki about languages like Pascal are for building pyramids and lisps are for building organisms :)

5:57 LauJensen: Chousuke, RMS ?

5:57 Chousuke: Richard M. Stallman

6:00 LauJensen: Thanks - What do you want to highlight by linking that comment?

6:01 ordnungswidrig: LauJensen: he did not find a link to the whole thread :-)

6:02 Chousuke: I followed a link from the Erik Naggum comment archive to a specific comment and started reading the whole thread.

6:03 LauJensen: k

6:08 Raynes: > You folks sure are touchy --

6:08 We're having a nasty winter. Wait till spring and try again.

6:13 I didn't know Erik Naggum was dead. :\

6:43 LauJensen: Life is very fragile

6:46 Raynes: LauJensen: So are glass houses.

6:46 Stop throwing parentheses.

6:47 spariev: on 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

7:00 crazzyford: On lisp is nice once you get past the fact that its common lisp

7:01 http://github.com/liron/knockoff has a load of stuff stolen from the arc source

7:01 The general purpose macros in it (some of them anyway) are rather nice

7:01 (see util.clj under there)

7:07 spariev: crazzyford: thanks, that looks interesting

7:08 crazzyford: That and try not to repeat yourself more than twice in a bit of code

7:08 fufilling that means writing a lot of macros

7:08 and writing a lot of macros > reading a book about em

7:08 once you've gotten past the basics

7:09 (usually means writing a lot of macros anyway. depends on your code)

7:09 spariev: well, I suspected that )

7:09 crazzyford: :)

7:09 spariev: I'm rather new to lisp macros (I did some metaprigramming in ruby, though), so I wanted to read some theory first

7:09 crazzyford: is metaprogramming in ruby mostly confined to adding methods to classes?

7:11 and/or objects that you already have instantiated?

7:11 spariev: yes, adding methods/fields, like usual rails plugins do

7:11 crazzyford: aye

7:11 clojure's metaprogramming is kinda different

7:11 spariev: that's what I did, anyway )

7:13 crazzyford: just learn about gemsyms and backquote templates and you'll find it easier to understand

7:13 otherwise a lot of macros are kind confusing

7:14 Chousuke: Is adding methods and fields really metaprogramming?

7:14 crazzyford: it is on some levels I guess. Considering you can add to base classes like Array and Object

7:15 Chousuke: Well, I guess you could use it to modify the behaviour of an existing program.

7:15 in Clojure, macros are more about programs that generate programs rather than modifying programs during runtime.

7:15 crazzyford: aye

7:16 quite different to ruby

7:16 ruby has method_missing as well, so when you send an object a method it doesn't expect, it calls its own method_missing

7:16 which can be further used for changing behaviour

7:16 but yeah, no sexps hence no macros

7:17 Chousuke: Yeah. in most languages code generation is a hack that works around language limitations

7:17 crazzyford: heh, c macros

7:17 LauJensen: ~def ->

7:17 Chousuke: or any code generation tool you might have. :)

7:17 crazzyford: vim :P

7:18 Chousuke: :P

7:18 crazzyford: or emacs for that matter

7:18 or any of the ide's out there

7:18 http://briancarper.net/blog/vim-brute-force

7:23 going back to ruby metaprogramming, you can create classes at runtime if you want as well

7:23 and generate said classes using code (things like map etc)

7:23 so that's sorta like macros

7:26 ,(doc reify)

7:26 clojurebot: Gabh mo leithscéal?

7:26 crazzyford: ,(doc deftype)

7:26 clojurebot: "([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

7:36 spariev: I dont really like ruby metaprogramming. Simple things like adding methds are fine, but more advanced manipulations are too much magic and complexity to me

7:37 crazzyford: rhickey 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/

7:38 basic point was that the reader reads strings, and turns it into a tree

7:38 then it feeds it to the compiler

7:38 macros are programs that the compiler runs when it finds them

7:39 you can see the diagram on the right hand side of the video preview (before clicking play)

7:40 spariev: crazzyford: thanks, I haven't seen this one

8:02 Raynes: crazzyford: That docstring is old.

8:27 chouser: rhickey: should restart be named restart-agent?

8:27 rhickey: chouser: yes

8:28 chouser: Ok, I think everything else is done. want to see the patch with docstrings before I check it in?

8:29 rhickey: chouser: no, go ahead

8:29 thanks!

8:42 chouser: let me know when you are done pushing patches

8:44 chouser: ok, just a moment.

8:48 rhickey: done

8:48 rhickey: chouser: thanks

8:54 ,(defmacro foo [x] *macro-meta*)

8:54 no bot :(

8:54 #^{:a 1} (foo 42)

8:54 Chousuke: defmacro doesn't work anyway

8:55 rhickey: ah

9:16 fliebel: Aaah, I can't do Python anymore… I'm infected by functional lisp style.

9:19 I 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.

9:20 And I start every line with a ( and forget to separate my lists with commas :P

9:21 Raynes: fliebel: I come from Haskell, so I have the opposite problem with the list separation bit.

9:22 fliebel: Raynes: how do lists work in Haskell?

9:22 Raynes: fliebel: Surrounded by brackets and separated with commas.

9:22 [1, 2, 3, 4] or [1,2,3,4]

9:23 fliebel: That is like Python… NOT writing them was easy for me, going BACK and write them is the problem for me.

9:24 and Clojure would just allow you to write them, right?

9:26 Raynes: Yes, Clojure would allow me to write the commas.

9:26 But I still don't like to, because I want to fit in. :>

9:27 I have to catch myself doing it sometimes.

9:28 chouser: I guess you could also end all your lines with semicolons. :-)

9:28 * chouser is amused by the thought.

9:41 rhickey: does anyone use attribute maps trailing bodies in defn?, e.g. (defn foo ([x] x) {:y :z})

9:41 chouser: I didn't remember that was an option until yesterday. I don't think I've seen any code in the wild using it.

9:43 fliebel: What does it do?

9:43 Raynes: What he said, only 30 minutes ago instead of yesterday.

9:43 rhickey: so, 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

9:44 Raynes: fliebel: It's a reader metadata map.

9:44 fliebel: Ah...

9:44 rhickey: actually its just a map, used by defn for metadata

9:45 CL lets you name the form using &whole my-name

9:45 Raynes: It's just a map, but it's still a metadata map. :p

9:45 rhickey: and environment using &environment my-name

9:47 chouser: rhickey: this is magic other than a var binding with the info in it?

9:48 rhickey: chouser: 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

9:49 _fogus: Sorry for being dense, but what would &form and &locals contain?

9:49 rhickey: &form would be the form of the macro call itself

9:49 i.e. the list, with the macro name and the args

9:50 so you could e.g. recover metadata from the list form or the macro name if desired

9:51 &locals would be a map of symbols to something-unspecified-until-cinc, representing the locals in scope

9:51 crazzyford: is there an easy way to delete files using clojure?

9:52 _fogus: (defmacro foo [x] ... (prn &form)) (foo 42) would print "(foo 42)"?

9:52 rhickey: _fogus: yes

9:52 _fogus: ok

9:54 * rhickey shudders at how little of Clojure exists where defmacro is defined

9:54 defn: crazzyford: do you know how to use any java in clojure?

9:55 crazzyford: I do

9:55 but looks like I have to mess with java's security model

9:56 defn: security model?

9:56 to delete a file?

9:56 crazzyford: as in the jvm doesn't have permissions to delete a file

9:56 I think

9:56 defn: http://java.ociweb.com/mark/clojure/article.html#JavaInterop

9:56 crazzyford: (.delete (java.io.File. "data/bork.db")) returns false at least

9:57 defn: from where? the repl?

9:57 crazzyford: yep

9:57 defn: using swank?

9:57 crazzyford: yep

9:58 and the file exists

9:58 defn: type ,cd[enter] in the repl

9:58 and navigate to the path you think you're at

9:58 crazzyford: aah

9:58 _fogus: rhickey: I shudder to, but mostly out of amazement. ;)

9:58 crazzyford: swank thought I was in a different directory to where the jvm thought I was

9:58 I think

9:59 defn: crazzyford: paths are funky at first

9:59 crazzyford: you'll get the hang of it

9:59 crazzyford: yeah returns true now

9:59 many thanks

9:59 defn: no problem

10:01 crazzyford: also, just for fun: (ns my-namespace (:require clojure.contrib.java-utils)) (delete-file (file "data/bork.db"))

10:01 http://richhickey.github.com/clojure-contrib/java-utils-api.html#clojure.contrib.java-utils/delete-file

10:01 a handy little library -- i like the (as-#"*") stuff

10:02 it hides a lot of ceremony

10:18 chouser: rhickey: you could always just redefine defmacro later. ...a version that will be useful for cinc if I'm understanding self hosting yet.

10:20 cburroughs: I'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:22 (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:26 cemerick: interesting that the +constant-name+ convention doesn't seem to be used in clojure

10:35 chouser: cemerick: because everything is a constant

10:35 at least that's been my argument

10:36 cemerick: chouser: well, I've been using +foo+ to indicate a var that is not meant to be rebound

10:36 that is, starting this week :-P

10:39 chouser: ah

10:40 probably not meant to be rebout and also not function?

10:40 cemerick: right. (def +universal-constant+ 42), etc

10:43 chouser: this 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:43 rebound a lot of things that were not meant to be rebound. :-)

10:44 cemerick: yeah, that's what I'm trying to avoid

10:44 chouser: well, but it was useful.

10:46 cemerick: oh, sure, but there really are some things that are constants :-)

10:52 crazzyford: did you use fixtures/contrib.mock for that?

10:52 chouser: no

10:52 crazzyford: just rebound the vars?

10:52 chouser: yep

10:53 I should look at using clojure.test's junit support. I set up my own weak little tie-in to junit before that existed.

10:53 defn: chouser: do you have any advice for someone who is a medicore, fairly inexperienced programmer who is trying to contribute to clojure?

10:54 * Raynes needs to get access to a printer to print out the CA. :\

10:54 Raynes: Next time I'm at the library, definitely.

10:55 defn: Raynes: I finally got mine in but I'm intimidated ATM

10:55 I'm no genius -- only have been messing with lisps, clojure, AND java for about 3 months

10:55 but I desperately want to help out

10:56 crazzyford: well where do you want to help out?

10:56 defn: anywhere it wont be annoying if i fail

10:56 stuartsierra: chouser: it only supports the JUnit XML output format right now

10:56 crazzyford: write some tests for something in clojure or contrib then?

10:56 chouser: stuartsierra: I don't know if I need more than that.

10:57 hm, I probably need to be callable from a junit runner or whatever

10:57 defn: crazzyford: 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:57 it's a lot of junk, but ive learned a lot

10:58 chouser: defn: Rich has been begging for tests on a few specific features, though I forget at the moment which ones.

10:59 defn: chouser: im about to go to bed, but if you think of anything you guys need help with let me know

10:59 crazzyford: I was poking around yesterday and I don't think refs/agents/atoms have tests on them

10:59 * crazzyford emphasises I think

11:00 defn: im just interested in cultivating community and helping people get better while i get better

11:01 crazzyford: I liked the examples server idea

11:01 mjt0229: what test framework is the core and contrib exercised with?

11:01 crazzyford: clojure.test I think

11:01 defn: crazzyford: i did it all wrong. i need to redo it

11:01 crazzyford: oh

11:01 :(

11:01 I was looking forward to that

11:01 defn: it *works*, but the thing is, someone mentioned to me that it should be a central server

11:01 where people can edit documention and submit it to the server

11:02 like JSON format documentation

11:02 crazzyford: and ?

11:02 oh

11:02 so you store it on the server as JSON, and people can pull it down as they like?

11:02 defn: one thing that really needed to change was the whole python requirements things i had going on

11:03 crazzyford: (were you using pygments to syntax highlight stuff?)

11:03 defn: crazzyford: yeah

11:03 mjt0229: crazzyford: is that clojure.test-is? google is coming up blank on clojure.test

11:03 defn: there's nothing like pygments for java or clojure

11:03 crazzyford: mjt0229: yeah, test-is got moved to clojure.test a while back

11:03 defn use prettify.js

11:04 or summat similar

11:04 pjackson: Is that a google library?

11:04 crazzyford: yes

11:04 defn: where do yuou get it

11:04 pjackson: I've heard good things.

11:04 crazzyford: you'd need to download the lisp language pack for it and specify that your code is lisp

11:04 but should be good

11:04 mjt0229: hmm, am I crazy or do the clojure.org api docs not reflect the change yet?

11:04 crazzyford: defn: http://code.google.com/p/google-code-prettify/

11:04 defn: oh you mean SyntaxHighlighter?

11:05 crazzyford: don't know

11:05 nah, didn't mean syntaxhighlighter

11:05 prettify.js outputs far nicer stuff

11:06 (by default anyway)

11:06 defn: i should just write my own tbh

11:06 crazzyford: screw linenums for examples

11:06 why?

11:06 defn: it's not that hard with a lisp and the existing tools

11:06 crazzyford: I wouldn't know

11:06 defn: its harder than im imagining im sure

11:07 but nowhere near impossible

11:07 crazzyford: quite probably

11:07 you could be lazy and do it with regex

11:07 mjt0229: oh, there we go. If I navigate to it rather than search, they appear correct.

11:07 defn: mjt0229: clojars?

11:07 crazzyford: clojure doesn't really need that much highlighted

11:07 defn: crazzyford: yeah

11:08 crazzyford: it does as it doesnt

11:08 for readability i would probably highlight (first [fn blah])

11:08 crazzyford: look at clojure.vim's syntax file for a big list of clojure keywords, sorted so similar stuff is together

11:09 seriously, 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:09 release early, release often an all

11:10 defn: good point man

11:10 80/20

11:10 80 of this is making the creation of examples easy, making them accessible to potential client implementations

11:10 20 is making it pretty

11:10 crazzyford: even less than that

11:10 very few places that have good docs have pretty docs

11:11 as long as its easy enough to use etc

11:11 defn: ive always loved the ruby docs

11:11 best docs ive ever seen IMO

11:11 crazzyford: rdoc generated ones?

11:11 defn: http://ruby-doc.org/core/

11:11 i love that layout

11:11 it's difficult to do the same thing with clojure

11:12 crazzyford: I've found those annoying

11:12 defn: what's a good doc to you?

11:12 crazzyford: needs more search

11:12 esj: +1 crazzyford, i too do not like the Ruby doc style

11:13 defn: good ideas for the style?

11:13 what do you envision?

11:13 crazzyford: I unno

11:13 doesn't matter that much

11:13 needs to be released first

11:14 defn: maybe a library which just adds a basic (docjure) fn which lets you do something like (docjure and)

11:14 crazzyford: can just use (doc and)

11:14 that works now as well

11:14 defn: it gives you an extended doc which includes an example

11:14 crazzyford: how?

11:15 are you putting examples on metadata?

11:15 defn: pulls the JSON from a server

11:15 crazzyford: ah

11:15 gotcha

11:16 so currently you have a (I assume compojure) site that runs locally, that you can get JSON from?

11:19 djork: defn: Ruby only has good docs when it has good docs... many are incomplete or outright missing

11:21 Carkh: a 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:22 is there soem way to tell the reader i want theses values as strings ?

11:22 crazzyford: yes

11:22 see http://briancarper.net/blog/who-needs-a-db

11:22 Raynes: All your lambda are belong to us.

11:23 crazzyford: Skip down to the part that starts with "Some Java data types"

11:24 Carkh: crazzyford : right that's from the printing part, but i don't know all the types that might be printed

11:24 crazzyford: :/

11:24 Carkh: i'm looking at solving this problem from the reading side

11:24 crazzyford: might be difficult with that

11:25 Carkh: see 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:26 ahwell i think i'll just log the whole agent data as a string and be done with it !

11:27 crazzyford: how are you logging agent errors?

11:30 Carkh: well i'm using a macro that will take all exceptions and send these to a log file

11:30 crazzyford: out of interest, can you paste it?

11:31 I might have a use for that (if you're ok with it)

11:31 Carkh: clojurebot: paste?

11:31 hum =P

11:32 crazzyford: http://paste.lisp.org/

11:32 djork: what are people using for persistence in compojure web apps?

11:32 crazzyford: tokyocabinet here

11:32 was a right arse to set up though

11:32 Carkh: http://gist.github.com/276336

11:33 pretty standard stuff

11:33 now for the log function, there's a whole framework behind that with log rotation and stuff

11:34 so i'm using this in every sensible agent function and that's it

11:35 this is not to be abused as most of the time you might want to let your agents fail

11:35 crazzyford: so you do something like (send-off an-agent (fn [args] (safe-agent body))) ?

11:35 Carkh: right, body being the meat of the function

11:35 crazzyford: aye aye

11:36 djork: I looked into using redis, but realised manipulating data in clojure was easier than using redis' stuff

11:36 chouser: Carkh: agent error handling was just updated this morning. It's better now. :-)

11:37 djork: so crazzyford you just persist clojure objects to disk?

11:37 crazzyford: using tokyocabinet, yeah

11:37 Carkh: ahwell, i'm always 3 months late as clojure versions go...

11:37 crazzyford: and strings

11:38 Carkh: chouser : do you have a writeup somewhere about this ?

11:38 crazzyford: carkh you can look at the diffs

11:39 http://github.com/richhickey/clojure/commit/b63af1ad6ce38b50552be3c424ea166cb063ee7c

11:39 basically as well as :validator you can add :error-handler

11:39 that's very nice

11:40 chouser: also, here: http://www.assembla.com/wiki/show/clojure/Agent_exception_handlers

11:40 djork: crazzyford: what were the hiccups in getting tokyocabinet set up?

11:40 I am building a back-end system for a web/iPhone app and want to try it in compojure if posisble

11:41 crazzyford: djork: you have to set java.library.path, and making the java stuff compile was an annoyance

11:41 djork: ah, so it's just standard java native stuff

11:41 typically annoying, yes

11:41 but not too bad

11:41 crazzyford: nah it uses c libs in there as well

11:41 djork: right native libs

11:41 I mean

11:41 crazzyford: aye

11:41 Carkh: chouser : you went for the sync version ?

11:42 crazzyford: and make sure you dl/install tokyocabinet (not java bindings) before you install the java bindings

11:42 djork: TK seems pretty mature

11:42 crazzyford: also 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:43 djork: are you using Tyrant as well?

11:43 crazzyford: nope

11:43 djork: hmm, so how do you handle concurrent access to the DBM?

11:43 crazzyford: nearly everything I actually do sits in refs inside clojure

11:44 and sends-off to agents at the end of dosync to write to the db

11:44 djork: ah, so you just persist occasionally

11:44 right

11:44 makes sense

11:44 Carkh: crazzyford : funny, i'm having most of my stuff in agents =P

11:44 crazzyford: I only really use agents as backup

11:44 *for persistence

11:45 though actually using them instead of refs might make a lot of sense

11:46 Carkh: though some people here disagree, i feel like refs are for data and agents for action

11:46 crazzyford: well this is data

11:46 so keeping stuff in refs makes sense

11:46 Carkh: true

11:46 though most data sits in a database on my projects

11:47 crazzyford: aye

11:47 my stuff probably could

11:47 Carkh: so there isn't that much state to keep in memory

11:47 crazzyford: loading the largest quanta of state my app uses takes 8ms

11:48 gogo TK

11:48 Carkh: wew that's fast ... connecting to postgres is already 30ms on my dev computer

11:48 crazzyford: SSD mind

11:48 Carkh: ahh you're cheating !

11:49 crazzyford: :)

11:49 * crazzyford likes cheating

11:50 crazzyford: though having said that

11:50 on my server (smallest linode host you can get) that takes 8ms as well

11:50 mjt0229: Nice. I think the test framework looks pretty solid. I don't suppose that there exists any sort of coverage tools though....

11:51 crazzyford: mjt you can probably write one pretty quickly

11:51 mjt0229: Hm, I'll have to think about it.

11:51 I'm still new at this :)

11:52 crazzyford: seeing as tests are (iirc) attached to functions as metadata before you run each test

11:53 you can look at each function and check whether it has :test data at the end of your clojure.test file

11:53 I think

11:54 using something like ns-publics

11:56 stuartsierra: That won't tell you that all possible branching paths are covered.

11:56 And deftest does not not attach to existing functions test.

11:56 kefka: I have a question about sorted maps/sets

11:57 nil seems to always be the leastmost element. Is this something I'm allowed to depend upon?

11:57 crazzyford: cheers stuart

11:57 is there a possible way to do test coverage?

11:57 stuartsierra: Sure. Write an interpreter. :)

11:58 crazzyford: :(

11:58 thought it was something like that or somebody would have already done it

11:58 stuartsierra: Or figure out how to modify a Java code-coverage tool.

11:58 But 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:59 kefka: ,,, or should I avoid depending on that trait of sorted maps as a matter of general principle?

11:59 mjt0229: I 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:01 There'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:07 arohner: kefka: sorted maps can use an arbitrary comparator

12:08 kefka: so you probably can't depend on that, unless you're assuming the default sort. which I wouldn't do

12:09 chouser: the default comparator, however, explicitly sorts null before everything else, so it's likely that will stay the same.

13:08 Ha! http://twitter.com/jeremey/status/7716361820

13:09 "Clojure programmers have more fn"

13:11 the-kenny: chouser: haha

13:11 I want this on a shirt

13:18 unfo-: 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:18 wilig: having 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:19 swank was installed via elpa on a brand new emacs 23.1 Mac OS X

13:21 It seems any time a JDBC driver raises an exception, this problem occurs.

13:21 technomancy: wilig: is it different if you enter it in the *inferior-lisp* buffer vs *slime-repl*?

13:22 there are a few bugs with stdin and stdout in swank-clojure that are on my list to track down

13:22 things like read-line and the debug-repl must be run in inf-lisp for now until they're resolved

13:23 wilig: ah, let me try that.

13:23 mjt0229: Does anyone here use Leiningen to set a test path that's different than their source path?

13:23 lein test appears to figure out which namespaces I've got tests written for, but doesn't actually report running any tests.

13:24 wilig: technomancy: that did it! thanks so much, I've been beating my head against this for a while.

13:25 technomancy: wilig: yeah, it's a frustrating bug. wish I had time to really dig into the swank-clojure codebase and rustle it out.

13:26 mjt0229: you could try setting the :test-path key in project.clj, otherwise maybe report a bug on the leiningen mailing list

13:26 mjt0229: yeah, that's what I tried.

13:26 I'm assuming that the project.clj snippet should read :test-path "test"

13:26 wilig: technomancy: 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:26 mjt0229: but it's not explicitly specified in the docs.

13:26 technomancy: mjt0229: if it's just "test" then you don't need anything in project.clj; that's the default.

13:27 mjt0229: huh.

13:27 that seems like a good default.

13:27 Raynes: technomancy: Leiningen's README doesn't have any examples of using :repositories; how would you use that?

13:27 technomancy: Raynes: it just needs to be a map of repository names to URLs

13:27 * technomancy makes a note to document that

13:27 Raynes: technomancy: Thanks. :)

13:27 mjt0229: oh, I didn't make the connection, are you the author?

13:27 ts00000: technomancy: are there any issues you know of with lein, swank, and fuzzy completion w/ slime?

13:28 technomancy: mjt0229: yeah

13:28 Raynes: mjt0229: He is. Sir Phil.

13:28 the-kenny: ts00000: Works flawlessly here

13:28 ts00000: chouser: thanks again for the help last night, got everything working this morning

13:28 the-kenny: even while connecting remotely?

13:28 technomancy: ts00000: there are with slime trunk, but wdouglas just submitted a version of slime-fuzzy to elpa that should be uploaded any day now

13:28 mjt0229: technomancy: 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:28 technomancy: mjt0229: yay! =)

13:29 the-kenny: ts00000: I think so

13:29 mjt0229: On 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:29 ts00000: technomancy: ok, great

13:29 technomancy: wilig: 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:29 the-kenny: technomancy: Huh? fuzzy in elpa? Cool!

13:30 technomancy: I'm not actually that familiar with the clj side of the codebase; I've mostly just worked on the elisp side

13:30 ts00000: someone should do a slime/emacs/clojure tips/tricks screencast with keys

13:30 wilig: technomancy: Well, off I go. I'll probably make the situation worse, but you've got to try. ;-)

13:31 technomancy: wilig: thanks!

13:34 chris_suter: i'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:35 i should say, by "parse" i actually mean break apart and import into a relational database

13:38 Raynes: Leiningen makes me happy.

13:45 * the-kenny likes the idea of Exception Handlers for agents

13:50 ajazz: hello! There is *default-encoding* in defined in clojure.contrib.duck-streams (http://bit.ly/8H5ouV). How can I change it?

13:50 cburroughs: I 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:51 the-kenny: ajazz: Either set! (Not very functional) or rebind it with binding

13:52 cburroughs: I'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:52 wilig: technomancy: what would be the best place to get the source for swank-clojure? take yours from github?

13:52 the-kenny: ajazz: e.g. (binding [*default-encoding* "foobar"] (slurp* url))

13:52 chouser: cburroughs: you want more than one thread going?

13:52 technomancy: wilig: yup

13:53 cburroughs: chouser, yes. ideally I'd like to control how many threads are going.

13:53 wilig: technomancy: oh dear, the tests fail. not a great start.

13:54 technomancy: wilig: yeah, I inherited it that way. =\

13:55 wilig: what fun. broken code with broken tests. can open, worms everywhere!

13:55 cburroughs: chouser, 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:58 In a conventional language I would have a shared queue with producers and consumer threads.

13:59 chouser: No reason not to do that.

14:00 cburroughs: Use refs for the queue then?

14:01 chouser: I'd look at using a BlockingQueue

14:01 technomancy: depends on how you want to handle errors

14:01 chouser: java.util.concurrent.LinkedBlockingQueue for example

14:02 technomancy: refs with a persistent queue might be a nice way to keep something on the queue in the case of errors

14:02 but it gets icky for 100%-reproducible errors I guess

14:03 chouser: and no good way to block waiting for the next item.

14:03 technomancy: yeah, you'd have a lot of useless retries

14:04 cburroughs: I'm not particularly picky about error handling at this point.

14:04 wilig: technomancy: tests don't seem to be getting compiled. lein compile should compile the tests as well as src right?

14:06 technomancy: wilig: no, there's generally no reason to AOT tests

14:07 wilig: technomancy: ah ok. just wondering cause I get classpath exceptions when trying to run tests.

14:07 technomancy: also: looks like you have to move the tests from test/clojure/swank to just test/swank to get it working

14:07 I haven't run the tests since switching to leiningen obviously =\

14:08 but once you do that they seem to be OK, though sparse

14:08 wilig: oh, great, thanks

14:09 tests now running. a much better starting point.

14:49 crazzyford: technomancy: I got some emacs code that flashes the modeline green/red based on test output

14:50 technomancy:you want me to try integrating it in clojure-test-mode?

15:00 technoma`: crazzyford: sure. maybe get it to only flash on failure?

15:01 I guess it depends on how distracting it is.

15:01 crazzyford: oflashes for like a second

15:02 not that bad

15:02 technoma`: cool

15:02 yeah, I'd love a patch

15:02 haven't done much with clojure-test-mode in a while

15:04 cemerick: I'm shocked that there's no date utils in contrib.

15:04 jkdufair: what's the idiomatic way of evaluating a string as a set?

15:05 crazzyford: technomancy: here's the gist of it http://gist.github.com/276535

15:05 technoma`: cemerick: I tried writing one once

15:05 cemerick: technoma`: tried?

15:06 technoma`: wrapping java.util.Calendar, but the JDK's built-in classes are very problematic to work with

15:06 cemerick: any time you cross DST boundaries or perform cross-timezone calculations you get incorrect results

15:06 it's pretty horrible

15:06 crazzyford: you can use joda time anyway

15:06 technoma`: if you want it done right, you have to use the joda library

15:06 crazzyford: works well enough

15:06 ^_^

15:07 cemerick: oh, at the moment I'm just talking about parse, format, now fns, etc., which is what 99% of my apps need

15:07 technoma`: and joda objects are immutable, so not much wrapping is needed

15:07 jasapp: jkdufair: do you mean like:

15:07 technoma`: cemerick: you could search the mailing list for "chrono" if you want to find my old lib

15:07 jasapp: ,(read-string "#{1 2 3}")

15:07 technoma`: don't judge me based on it though; it was my first public clj code. =)

15:07 jasapp: hmm

15:07 cemerick: technoma`: I'm not that motivated :-) I have no need for calendar anyway.

15:07 technoma`: as long as you don't need to perform date arithmetic you should be OK

15:08 cemerick: "java.util.Date is fine for me" ;-)

15:08 * cemerick ducks

15:08 jkdufair: well, more like (index-of-any (set "foobar") (set "foo"))

15:08 technoma`: hehe; sure

15:08 jkdufair: (working my way through "programming clojure")

15:08 trying some other ideas out as i go along

15:09 jasapp: I'm not sure what you mean by index-of-any

15:09 jkdufair: where index-of-any wants a predicate and a collection

15:09 jasapp: ahh

15:09 lisppaste8: cemerick pasted "barebones date lib" at http://paste.lisp.org/display/93346

15:09 jkdufair: sets seem to act as predicates when passed possible members but strings, no

15:09 cemerick: I *might* add before/after :-P

15:10 jasapp: I'm still not quite sure I understand

15:10 jkdufair: ah, i probably just need to go read some more code. trying to learn not just the language but the common idioms

15:11 somnium: ,(map (set "foo") "foobar")

15:11 no bot today?

15:12 jkdufair: spiff. thx somnium

15:39 qbg: Is there a function like var?

15:55 djork: qbg: what do you mean?

15:55 do you mean a function that behaves like the special form "var"?

15:56 qbg: djork: yes

15:56 rhickey: qbg: what would you pass it?

15:56 qbg: A symbol

15:56 rhickey: ,(resolve 'rest)

15:57 qbg: Perfect

15:57 jasapp: clojurebot is mia

15:58 hiredman: again?

15:58 java.net.ConnectException: Connection refused (NO_SOURCE_FILE:0)

15:58 :|

15:59 {newbie}: hiredman: what happens if the try to block the stack of the bot

15:59 we*

15:59 hiredman: block the stack?

16:00 {newbie}: blow*

16:00 hiredman: it blows

16:00 Chousuke: and then nothing happens :)

16:01 clojurebot: hmm

16:01 jasapp: ,(+ 1 2)

16:05 hiredman: hmmm

16:05 (System/setSecurityManager nil) <-- fess up, who is trying to break clojurebot?

16:07 the-kenny: hiredman: Heh

16:07 hiredman: I think that was me.. in the XMPP room. Just trying, of course

16:08 hiredman: :P

16:08 ,(+ 1 2)

16:08 clojurebot: 3

16:15 * Raynes is going to have to migrate mattrepl's clj-oauth and clojure-twitter to Leiningen. He currently includes all dependencies in his repo. I don't even know what to do with that anymore. :p

16:16 * technomancy recommends interactive rebase to remove the commits in which the jars were added

16:16 technomancy: otherwise every single person who wants to perform a checkout is going to have to download several useless megabytes

16:16 2x the size of the jars, since they are added *and* removed

16:17 Raynes: :\

16:17 technomancy: git is *really* bad at storing binary files

16:17 I wish people would understand that

16:18 Raynes: I 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:20 lypanov: damn. 217 people. wow.

16:20 can someone (preferably a zealot) please explain why scala sucks and i should be using clojure?

16:21 technomancy: clojurebot: scala?

16:21 {newbie}: scala doesn't suck

16:21 hiredman: clojurebot: tell us something about scala

16:21 clojurebot: amespaces 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:21 qbg: We have awesome parens.

16:22 hiredman: clojurebot: that was dumb

16:22 clojurebot: whose job is<reply>that is arohners job

16:22 technomancy: clojurebot: hey, wake up. the city has need of a hero.

16:22 Raynes: lypanov: http://blog.bestinclass.dk/index.php/2009/09/scala-vs-clojure-lets-get-down-to-business/

16:22 hiredman: clojurebot: what do you think about scala?

16:22 clojurebot: download is http://github.com/richhickey/clojure/downloads

16:22 ☝(^_^)☝

16:22 hiredman: hmmm

16:22 {newbie}: haha

16:22 rhickey: lypanov: 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:23 lypanov: rhickey: um. and the lead is on a channel of 217. k. i'm convinced. thx

16:23 technomancy: ok, who put meth in clojurebot's init file?

16:23 lypanov: rhickey: 1 q. how insane is it to imagine a gwt equiv (or just gwt somehow) for clojure?

16:23 Raynes: lypanov: Yeah, rhickey is awesome.

16:23 hiredman: <--

16:24 Raynes: lypanov: Why not use GWT directly from Clojure?

16:24 djork: that would be the easy way out

16:24 lypanov: Raynes: its messed up. it parses the java rather than using bytecode. *sob*

16:25 hiredman: clojurebot: what do you think about scala?

16:25 clojurebot: {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}

16:25 hiredman: ~scala {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}

16:25 clojurebot: Any = 1

16:25 chouser: lypanov: you might be interested in http://www.webtoolkit.eu/jwt

16:26 technomancy: Raynes: nothing wrong with putting clj-oauth's dependencies on clojars yourself under a non-canonical groupId if you can't find them elsewhere

16:28 lypanov: chouser: alas, i'm interested in gwt not for its magical ui toolkit or anything, but rather for its optimised js gen ability.

16:28 Raynes: technomancy: But you can't just upload random jars, can you? Doesn't there have to be a project.clj?

16:28 I've not used this magic yet.

16:28 hiredman: Raynes: just a pom

16:28 lypanov: chouser: (we're using pure.js + jquery + json backend atm)

16:28 charrrrrrles. 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 too

16:29 hiredman: *shrug*

16:29 technomancy: Raynes: all you need is a pom; it's not hard to construct a minimal one that is used only for dependency calculation

16:29 lypanov: chouser: (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:29 Raynes: Bleh.

16:30 Guess I'll have to figure out maven crap tonight then.

16:30 * hiredman has loaded pl

16:30 chouser: lypanov: ah, well google has a javascript-to-javascript compiler named, unfortunately, "closure"

16:30 technomancy: it's like six lines of XML; it's not bad. it should be documented somewhere though.

16:30 lypanov: yeah, closure is pretty cute. but it doesn't optimise shit. gwt otoh does.

16:30 chouser: so 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:30 hiredman: lypanov: optimizing is the whole point of "closure"

16:31 lypanov: hiredman: opting source size. but not opting exec time.

16:31 hiredman: "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:31 lypanov: js is too dynamic for closure to possibly compare.

16:32 chouser: gwt doesn't do runtime optimization, does it?

16:32 lypanov: i can give some examples if needed, but it doesn't really cut it.

16:32 chouser: it does silly things that removing abstraction if only one class implements something. etc.

16:32 they add up to a lot together with dead code elim.

16:32 almost impossible with js imo.

16:33 chouser: in that case you'll either need to write java code yourself, or write a java *source* backend to the clojure compiler.

16:33 lypanov: chouser: aye. there is a start of one for scala. but its still very basic.

16:33 and i'm wondering if clojure isn't better suited to my mind set.

16:33 chouser: the 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:34 lypanov: i need to learn more about it tbh.

16:34 chouser: the former is done by thousands of programmers every day. :-)

16:34 lypanov: i have much more experience with scala.

16:34 aye, i'm doing that atm.

16:34 thanks to ide's java is quite comfortable.

16:35 but sometimes i really miss the high abstraction levels that other langs provide.

16:35 chouser: glad it's working for you.

16:35 lypanov: (well, primarily i code in ruby, but i abhor that language)

16:36 hiredman: 1. 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:37 lypanov: oooooooooooooooooo (repeat 10x)

16:37 its like that apache collections proj but apparently doesn't blow

16:38 Raynes: technomancy: 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:38 For now, I must sleep!

16:38 lypanov: Raynes: thx for the link dude:)

16:39 Raynes: lypanov: No problem.

16:41 mabes: Is there a function that will slice a vector into two different ones?

16:41 ,(let [x '(a b c d e f g)] [(take 2 x) (drop 2 x)])

16:41 clojurebot: [(a b) (c d e f g)]

16:41 mabes: like this ^

16:41 hiredman: (a b c d e f g) is a list

16:42 chouser: (doc split-at)

16:42 clojurebot: "([n coll]); Returns a vector of [(take n coll) (drop n coll)]"

16:42 mabes: right, sorry, I don't really care if it is a vector or a list

16:42 chouser: great, thanks

16:44 Chousuke: hmm

16:44 ,((juxt take drop) 4 [1 2 3 4 5 6])

16:44 clojurebot: [(1 2 3 4) (5 6)]

16:44 chouser: nice

16:44 Chousuke: first real use of juxt I've figured out so far :P

16:45 * hiredman is highly offended

16:45 hiredman: deeply?

16:45 thinks that are highly offensive offend you deeply?

16:45 things

16:45 Chousuke: I think so

16:46 the-kenny: ,(doc juxt)

16:46 clojurebot: "([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:48 lisppaste8: stuartsierra pasted "Double dispatch with protocols" at http://paste.lisp.org/display/93353

16:48 stuartsierra: I don't know if that's correct, but it works.

16:50 hiredman: huh

16:51 Chousuke: tricky

16:52 stuartsierra: anyway, got to go, would like to discuss this tomorrow

16:53 hiredman: there was some paper that used something similar for double dispatch in a java like language

16:53 double dispatch type inference

16:54 ~google double dispatch type inference

16:54 clojurebot: First, out of 3330 results is:

16:54 Efficient Just-In-Time Execution of Dynamically Typed Languages ...

16:54 http://www.ics.uci.edu/~franz/Site/pubs-pdf/ICS-TR-07-10.pdf

16:54 arnihermann: can anyone point me towards some performance benchmark of clojure?

16:55 Chousuke: I don't think there are any that will help you

16:55 arnihermann: I'm akin' to use it for a general game playing agent

16:56 Chousuke: Clojure is definitely not as fast as java in the general case, but for a dynamic language, it's pretty good.

16:56 arnihermann: I think clojure would be perfect in almost every aspect except maybe performance

16:56 right

16:56 hiredman: arnihermann: that basically means you need clojure to do things as fast a person sitting on the other end of IO lag?

16:56 arnihermann: I'm aware of that

16:56 not a person

16:56 another program

16:56 competing against my program

16:56 in a turn based game

16:56 such as chess

16:58 scheme/lisp is perfect for this

16:58 except performance wise

16:58 Chousuke: If something really turns out to be too slow in Clojure, you can write it in Java, and use Clojure as "glue"

16:58 hiredman: arnihermann: that is hard to imagine

16:59 is that based on actually experience?

16:59 arnihermann: right

16:59 hiredman: no, not actual experience

16:59 stanford provides reference implementation of agents in scheme and java

17:00 I know one of the best performing agents is written in caml

17:00 another in c++ and prolog

17:01 hiredman: agents is the name of the game?

17:01 arnihermann: no no

17:01 general game playing *agent*

17:01 or program

17:01 hiredman: confusing

17:01 arnihermann: the games which are played are turn based games such as chess

17:01 http://games.stanford.edu/

17:02 sure, it's confusing

17:02 hiredman: clojure has a reference type called an "agent"

17:02 arnihermann: true

17:02 yeah I know :)

17:02 sorry about htat

17:02 should have been more explicit

17:02 so the player programs are often references as "agents"

17:02 reference players: http://games.stanford.edu/resources/resources.html

17:02 don't reflect the state of the art though

17:03 one area though which appeals to me is easy parallelized code in clojure

17:03 hiredman: I'ver used ocaml, but my impression is it is a speed daemon

17:04 comes out on top in many cases

17:04 arnihermann: yes

17:04 I will probably go with haskell if my clojure evaluation turns negative in performance

17:04 hiredman: :|

17:04 arnihermann: anywho, I was just wondering if you guys knew any comparisons

17:04 with other languages

17:04 benchmark

17:05 I'll do my best to evaluate it based on my needs

17:05 headius: math is most likely to be the biggest problem area

17:05 hiredman: ~performance

17:05 clojurebot: http://clojure.org/java_interop#toc46

17:05 hiredman: http://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips/

17:05 arnihermann: might just post something on my finds

17:05 headius: you can locally type some things to help, but it will only help locally

17:05 arnihermann: findings

17:05 right

17:05 most of the time spent in these programs in search

17:06 + the knowledge base

17:06 "is search"

17:07 anywho, thanks a lot

17:08 * hiredman should really polish his asm macros

17:08 hiredman: more control over the generated bytecode without the need to use java

17:14 you could generate a set of small static utility methods

17:14 clojurebot: a is t

17:14 hiredman: clojurebot: what?

17:14 clojurebot: what is wrong with you

17:17 scottj: How 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:18 chouser: ,(map #(if (number? %) (* % %) %) '(* x 10))

17:18 clojurebot: (* x 100)

17:20 scottj: ahh, that's what I tried except I had identity instead of your last %

17:20 thanks

17:22 RadioApeShot: is there a clojure library that I can use to interact with web apis?

17:22 Like wikipedia's api?

17:23 Something that can POST etc?

17:24 hiredman: wait, post?

17:24 the-kenny: RadioApeShot: clojure-http-client has some interesting things to help

17:25 hiredman: isn't POST the easy one?

17:25 beutdeuce: I know (eval) evaluates form data structures, is there something in Clojure that can evaluate strings/text ?

17:25 hiredman: (eval (read-string "(+ 1 2)"))

17:26 beutdeuce: thnx

17:26 RadioApeShot: the-kenny: thanks

17:26 the-kenny: that is probably what I want

17:28 hiredman: http://gist.github.com/236676

17:28 illegitimate use of juxt

17:28 that post assumes an xml reply, and parses it

17:31 "response" I guess

17:40 mjt0229: technomancy: 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:42 technomancy: mjt0229: you mean to do AOT-compilation of test source?

17:42 mjt0229: yeah.

17:42 or does lein test eval the files?

17:43 technomancy: mjt0229: do you have gen-class or something in your tests?

17:43 mjt0229: no, I don't.

17:43 technomancy: they shouldn't need to be compiled

17:43 mjt0229: Hmm. Well, I'll keep digging. Thanks!

17:44 technomancy: if it helps you can try to structure your tests like the ones from leiningen itself

17:45 mjt0229: that's a good idea. I'm sure I'll figure it out, I've probably just done something strange.

17:45 technomancy: I need to have "lein new" include a scaffold test file

17:50 mjt0229: That's possible.

17:50 I fixed it, by changing my test code to use a namespace different from that of the module under test.

17:51 I'm not certain why that would change matters, however.

17:51 technomancy: mjt0229: if two files contain the same namespace, then whichever comes first on the classpath wins

17:51 hiredman: yeah, that is not a good idea

17:51 technomancy: the loser will never be visible

17:51 mjt0229: Evidently :)

17:51 hiredman: EVER

17:52 mjt0229: Unfortunatly, I wanted to have the test output say that it was testing the module I was testing, not the test-module itself.

17:52 ie, "Testing org.tomko.index" rather than "Testing org.tomko.test-index"

17:52 Well, I've learned my lesson...

17:53 it seems that clojure code idiomatically uses less-structured packages/namespaces.

17:54 Is that motivated by the relatively fewer files/LOC needed in Clojure, or is it a throwback to the LISP days?

17:55 hiredman: eh?

17:55 less structured how?

17:55 mjt0229: well, 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:56 At 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:57 As a java programmer, I'm inclined to create a big hierarchy of packages that's deep rather than broad.

17:58 less structured may have been the wrong term, it sounds pejorative

17:59 arohner: broad rather than deep is a fair generalization of clojure ns's, IMO

17:59 I suspect a lot of that has to do with the lack of limitations about what you can do in a single clojure file

18:00 no need for multiple files just because you want multiple public classes

18:01 hiredman: less baroque

18:02 mjt0229: my habits are definitely informed by java restrictions/requirements, plus java best practices, many of which don't apply here.

18:04 hiredman_: bah

18:08 beutdeuce: what is the clojure regex for any character?

18:08 the-kenny: .

18:08 beutdeuce: hmm, tried, but didnt work

18:08 mabes: I 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:08 right now I'm doing:

18:09 ,(let [t1 {"A" {"B" {"C" 10}}} t2 {"A" {"B" {"C" 2}}}] (merge-with (partial merge-with (partial merge-with +)) t1 t2))

18:09 clojurebot: {"A" {"B" {"C" 12}}}

18:09 mabes: which works just fine but I want to know if I'm going at the problem totally wrong

18:10 the 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 (let [omg (iterate inc 0)] (nth omg 100000000000000000000000))

18:14 hiredman: AIOF?

18:14 {newbie}: s/F/B

18:14 ,(let [omg (iterate inc 0)] (nth omg 100000000000000000000000))

18:14 clojurebot: java.lang.ExceptionInInitializerError

18:14 hiredman: AIOB?

18:15 {newbie}: array index out of bounds

18:15 hiredman: dunno

18:16 possibly something chunked sequence related?

18:18 ,(let [omg (seq1 (iterate inc 0))] (nth omg 100000000000000000000000))

18:18 clojurebot: java.lang.ExceptionInInitializerError

18:18 hiredman: or not

18:20 arohner: (let [omg (seq1 (iterate inc 0))] (nth omg 1000))

18:20 ,(let [omg (seq1 (iterate inc 0))] (nth omg 1000))

18:20 clojurebot: 1000

18:21 arohner: ,(let [omg (seq1 (iterate inc 0))] (nth omg 1000M))

18:21 clojurebot: 1000

18:22 hiredman: Oh

18:25 scottj: I 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:26 With 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:30 technomancy: ,(binding [identity reverse] (identity "ohai"))

18:30 clojurebot: (\i \a \h \o)

18:30 technomancy: (that returns "ohai" on 1.1.0-new)

18:30 somnium: scottj: have you seen the JScience quantities? (admittedly its java...)

18:31 hiredman: technomancy: direct binding for clojure.core

18:31 which I haven't really seen an anouncement about, possibly I missed it

18:32 technomancy: it also manifests itself in clojure.test

18:32 which breaks our build

18:32 hiredman: :(

18:32 danlarkin: not just our build

18:32 technomancy: to say the least

18:33 danlarkin: but clojure.test is designed to have functions bound

18:33 hiredman: I love performance, but hate the loss of dynamicism

18:33 infact, I think I just "like" performance

18:33 scottj: somnium: I hadn't, thanks.

18:33 hiredman: not even "like like"

18:33 technomancy: no hits on the mailing list for direct binding. =\

18:33 danlarkin: I like performance too, but not when it... breaks things

18:33 hiredman: there was some discussion about it

18:34 but I don't actually remember some conclusion

18:34 technomancy: google only gives me haskell hits when searching for clojure "direct binding"

18:35 hiredman: *shrug*

18:35 make a stink on the mailing list

18:37 technomancy: definitely going to have to get some clarification

18:37 beutdeuce: how would i evaluate: (1 2 3) to "(1 2 3)" ?

18:38 hiredman: beutdeuce: you want to turn a list into a string?

18:38 beutdeuce: yes

18:38 hiredman: pr-str

18:38 beutdeuce: thnx!

18:38 hiredman: ,(pr-str '(1 2 3 4))

18:38 clojurebot: "(1 2 3 4)"

18:38 technomancy: looks like the bug doesn't manifest with clojure.test in master

18:38 hiredman: ,(pr-str '[1 2 3 4])

18:38 technomancy: time to get off the new branch I guess

18:38 clojurebot: "[1 2 3 4]"

18:38 beutdeuce: great

18:38 hiredman: technomancy: it might have been merged into master

18:39 technomancy: hiredman: pretty sure it has, but I guess on master it's been fixed to only apply to clojure.core

19:35 mebaran151: anybody know a good guide to paredit?

19:38 scottj: mebaran151: http://www.slideshare.net/mudphone/paredit-preso

20:07 mebaran151: I'm starting to get the hang of paredit mode

20:10 thanks scottj

20:11 technoma`: oh snap!

20:11 if it isn't our old friend clojure.io

20:20 seths: scottj: that is one hell of a presentation on paredit

20:20 wow

20:22 joshua-choi: According to http://clojure.org/reader keywords cannot contain periods ('.'). But this doesn't seem to be true:

20:22 ,(name :.a)

20:22 clojurebot: ".a"

20:22 joshua-choi: Why does that web page say that it's not allowed, then?

20:23 technoma`: joshua-choi: lots of things are possible that aren't supported

20:24 joshua-choi: So is it still officially unsupported?

20:24 technoma`: yeah, the behaviour is undefined

20:24 that could certainly be clearer in the documentation

20:24 joshua-choi: I'm writing a Clojure parser in Clojure, so should I enforce that, you think?

20:25 technoma`: if it's not too much trouble, yeah--I would go with the explicit rules over the implementation

20:25 it's possible the documentation there is just out of date though; wouldn't hurt to check on the mailing list.

20:25 joshua-choi: Yeah, maybe I should

20:25 I'm trying to follow the rules defined in LispReader.java, but it's a pain figuring it out from the regexes

20:26 Also, do you know of a rationale for the rule? It seems a little arbitrary

20:26 mebaran151: I think you can't have them because symbols can be namespace

20:26 ,::abc

20:26 clojurebot: :sandbox/abc

20:26 joshua-choi: ,::a.bc

20:27 mebaran151: and namespaces are . delimited

20:27 clojurebot: :sandbox/a.bc

20:27 joshua-choi: I was wondering if it would finish :P

20:27 Yeah, namespaces are delimited

20:28 But I don't really see why that precludes using periods in keywords; just that it requires periods to be allowed in symbols

20:30 In addition, double-coloned keywords can also have prefixes if you aliased a namespace; do those follow different rules too?

20:32 Example:

20:32 user=> (require '[clojure.test :as t])

20:32 nil

20:32 user=> ::t/a

20:32 :clojure.test/a

20:32 What if the alias is a period-containing symbol? Could I still create double-coloned keywords with the alias?

20:34 mebaran151: I think periods are best avoided

20:34 joshua-choi: Hmm

20:34 mebaran151: :: is supposed to undo all aliases

20:34 *resolve them

20:34 (require '[clojure.test :as t])

20:34 joshua-choi: I've got to go, but I'd like to figure this out later; thanks

20:35 mebaran151: no problem

20:35 joshua-choi: (require '[clojure.test :as t.a]) and then ::t.a/a works too, by the way; is this illegal...

23:32 optimizer: anyone have a good resource on clojure-gwt interaction?

23:44 aking: Looks like chouser and _fogus's book (early access MEAP version) is now finally available

23:48 arohner: oh, this is amusing. There are cases when you can't use println for debugging, when a lazy seq is being realized

23:49 hiredman: prn

23:50 I never use println for debugging

23:50 arohner: sigh.

23:50 comparing the source, I don't see why prn would work and println doesn't

23:51 hiredman: we maybe talking about different issues

23:52 arohner: let's say I have a function where I return a lazy seq

23:52 hiredman: and actually, what I am thinking of is a problem with str not println, so we must be

23:52 arohner: and the lazy seq is constructed by calling a function

23:52 (for [i ..] (foo))

23:52 hiredman: doto

23:52 (doto (foo) prn)

23:53 arohner: and then inside foo, you do some println / prn debugging

23:53 hiredman: right, you don't see it until you walk the sequence

23:53 arohner: if 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:54 but break the laziness, and you'll see the prints before the exception

23:54 hiredman: they don't happen before the exception

23:54 arohner: they do.

23:54 hiredman: they don't

23:54 by definition, if they happened, you would see stuff printed

23:54 since you don't see stuff printed, they did not happen

23:55 arohner: I'm glad you cleared that up for me

23:55 hiredman: :P

23:56 ,#(prn :foo)

23:56 clojurebot: #<sandbox$eval__3833$fn__3835 sandbox$eval__3833$fn__3835@1941856>

23:57 hiredman: the 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:58 arohner: I'm looking at seq here. the 13th element throws an exception

23:59 hiredman: ok

23:59 arohner: if I put a dorun around it, I see 12 prints, and then an exception thrown

23:59 sorry, I have a (for []..), that I know generates 13 elements

23:59 the for calls a function that prints

Logging service provided by n01se.net