#clojure log - Jan 09 2011

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

0:00 btw0: cemerick: you are right, I'll go with the shuffle solution, thanks man.

0:01 amalloy: there's a tradeoff either way, and if performance is important you'll have to decide based on the size of the input coll and how many unique elements you want

0:01 tomoj: you could take the source set and make a transient to pop from, maybe?

0:01 s/pop/randomly disj!/

0:01 sexpbot: <tomoj> you could take the source set and make a transient to randomly disj! from, maybe?

0:04 btw0: tomoj: good idea, but that's overskill for my case :)

0:23 tomoj: I want forcat a lot

0:30 amalloy: tomoj: so write it?

0:31 tomoj: in cases where I wanted in a lot inside a single project, I have

1:12 replaca: tomoj: forcat and formap, too

1:13 tomoj: formap?

1:13 oh, with an (into {} ..)?

1:20 LauJensen: you ever use keyboard macros on clojure code?

2:21 amalloy: tomoj: i'm curious what macros you would find useful. i mean, i'm sure they exist but i can't think of any

2:21 tomoj: hard to say, they're nonce by nature I think

2:23 a recent example: I had a map something like {:x (.foo bar) :y (.baz bar) ..} and wanted {:x (-> bar .foo bing) :y (-> bar .baz bing) ...}

2:28 I've got this giant top-level form with 60 or so children like (:handshake 0x02 :username java-string) and (:collect-item 0x16 :collected-id :int32 :collector-id :int32), pretty soon I suspect I will want children more like (:handshake 0x02 :fields [:username java-string]) and (:collect-item 0x16 :fields [:collected-id :int32 :collector-id :int32])

2:45 replaca: Is clutch the right way to talk to couchdb or are folks using other libs?

2:50 cemerick: replaca: Certainly what I use. ;-)

2:50 * cemerick is a committer

2:52 replaca: cemerick: thanks. So you think it's a reasonable way to wade in? I'm a couch newbie

2:53 * replaca looks at his watch and says "Chas it's 2:45 in the morning" :)

2:53 cemerick: replaca: Yeah, I'd say so. You will inevitably want to plink away at it using curl (or whatever) from time to time to understand just what's going on, but clutch is pretty good overall.

2:53 No shit, huh?

2:53 * cemerick has ongoing linux font problems

2:54 replaca: cemerick: ( I knew someday I'd get you back :))

2:54 cemerick: replaca: so this is a hex you set on me?!?! ;-)

2:54 replaca: cemerick: cool. I just want to massage a bunch of data out of XML and into couch

2:54 yup :)

2:54 cemerick: sounds easy enough

2:54 replaca: and then play with it

2:55 cemerick: AFAIK, clutch has the broadest support for couchdb features, and some nice almost-clojure-specific bits

2:55 optionally getting view results as an inputstream so you can read them lazily, etc.

2:55 replaca: I'm trying to understand if I should consider moving our huge orver-normalized db of video events into couch

2:56 nice, I really want everything to be lazy or async (ala clojure or node.js)

2:56 cemerick: between efficient binary attachments and sane replication (I presume you need to move video around between sites a fair bit?), that seems like a good way to go

2:57 replaca: video isn't really part of the equation, just structured events

2:57 like, I saw a face over here at at this time and it looked like this or someone used their ATM card here for such and such an amount

2:58 then folks can annotate those things etc.

2:58 the actual video is a whole othe rkettle of fish and hugely complicated in the volumes we're talking about

2:59 cemerick: When you said "events", I thought maybe you meant e.g. 20s clips surrounding particular noticed actions, etc.

2:59 replaca: (think: data from > 10,000 cameras running all the time)

3:00 yeah, that's about right, but folks want all the video and every motion is an event or every face going through a subway station in downtown seoul

3:01 so they get continuous in lots of cases

3:01 cemerick: you'll want to do a fair bit of thinking about what your requirements are around durability, write availability, etc etc etc

3:01 all the newfangled databases slice up the domain in their own idiosyncratic ways

3:01 replaca: yeah, that's what I'm trying to begin to explore

3:02 cemerick: It seems that most people hit showstoppers for their respective domains when looking at each database, with just one or two as serious candidates.

3:02 replaca: to begin with I'm thinking multiple dbs (one per recorder) using our big distributed framework to manage them

3:03 but in the future, a goal is flexible topologies

3:03 cemerick: in that case, I presume couch's replication is attractive

3:03 replaca: yeah, at some point

3:04 i'm mostly interested in the "document" structure versus the normal relational model

3:04 relational kills us in I/O

3:04 cause we basically spread things all around

3:04 * cemerick flashes back to star schemas

3:04 replaca: then we get hammered on joins

3:05 yeah, at one time I was going in that direction

3:06 cemerick: off to bed with me

3:06 * cemerick cries uncle

3:06 replaca: cemerick: g'night. Thanks for the input

3:06 cemerick: replaca: good bumping into you; let me know if you have any couch/clutch questions :-)

3:06 replaca: cemerick: will do!

3:12 tomoj: amalloy: http://vimeo.com/18582018

3:15 I guess kb macros are more often useful if you write ugly code like that :)

3:19 amalloy: tomoj: pffft

3:21 perhaps instead your direction could be an [index, sign] pair? then the whole thing is (defn add-dir [loc [ind sign]] (update-in loc [ind] #(+ % sign)))

3:25 tomoj: yeah, I just had things like :x+ from a gloss enum

3:25 could put less opaque things in the enum, but.. eh

3:26 or just have a map from the opaque things to less opaque things handy when needed

3:45 peterevjan: what is your favorite unit testing framwork for clojure?

3:49 mids: just using clojure.test myself

3:53 bobo_: peterevjan: take a look at midje

3:56 amalloy: midje looked really cool to me, and i'm sure it is, but when i tried using it i just got frustrated and gave up

3:57 mids: lazytest also has some fun stuff in the pipe

3:57 like the test watcher

4:01 I am using this autotest script to run lein test whenever a file is modified: https://gist.github.com/771550

4:02 with red/green bar! :)

4:03 tomoj: whoa thanks for the tput tricks

4:04 bobo_: that looks nice =)

4:12 msappler: hello, is it possible to write a macro which writes another macro and using template with syntax-quote ` inside another template?

4:14 my problem is that the unquote ~ of the inside-template gets evaluated when the outside-template is evaluated

4:14 amalloy: msappler: yes, it's possible, although usually there's a better way to accomplish your goal

4:15 msappler: basically I had two functions which have functions as arguments for updating/rendering

4:15 (defn active [f] {:updatefn f})

4:15 (defn rendering [f] {:renderfn f})

4:16 now a lot of my code looks like this: (active (fn [delta component] do-stuff))

4:16 amalloy: msappler: https://github.com/Raynes/clojail/blob/master/src/clojail/core.clj#L134 is an example of me doing what you're looking for

4:17 Raynes: Oh my. I never thought I'd see the day when that code was being used as an example of something that somebody wants.

4:17 amalloy: *eyeroll*

4:17 msappler: SO I wrote two macros for active and rendering which can be used (active [delta comp] do-stuff) ...

4:17 amalloy: msappler: okay, with you so far

4:17 msappler: and those macros share a pattern so my first macro-writing-macro was born

4:18 ^^

4:18 amalloy: ah. give me a few minutes and i'll gist how i would do it

4:18 msappler: maybe i just paste my example ...

4:20 amalloy: yeah, please do

4:20 also, wait, are you just using your macro to avoid writing (fn)?

4:21 msappler: http://pastebin.com/26YBU1AV

4:23 yes as you can see

4:29 amalloy: msappler: http://pastebin.com/36n4DhDB maybe?

4:32 i think `(fn ~@args#) would have worked too (ie that your problem was only in line 7), but i was more confident about my list* construct

4:33 msappler: hmm

4:33 thanks

4:33 why is he expanding to (apply (hash-map (seq concat ... ?

4:34 amalloy: what?

4:34 clojurebot: what is exceptions

4:34 amalloy: clojurebot: forget what

4:34 clojurebot: Titim gan éirí ort.

4:34 amalloy: grr

4:36 msappler: when expanding (def-function-map-factory active "docs" :updatefn)

4:36 the `{~~k ~f#} is being expanded to apply hash-map seq concat list .. list ... ..

4:39 amalloy: {a b} is syntax sugar for (hash-map a b)

4:39 the macroexpansion facility removes that sugar since it's generating code that you won't need to see

4:40 &(macroexpand `{a b})

4:40 sexpbot: ⟹ {clojure.core/a clojure.core/b}

4:40 msappler: I see. I thougt when i `syntax-quote it it won't be expanded yet

4:41 amalloy: um okay i can't actually show that here. but if you macroexpanded a defmacro, that's what it does

4:41 (macroexpand '(defmacro foo [] `{1 2}))

4:41 msappler: &3

4:41 sexpbot: ⟹ 3

4:41 msappler: &(macroexpand '(defmacro foo [] `{1 2}))

4:41 sexpbot: java.lang.SecurityException: You tripped the alarm! def is bad!

4:42 amalloy: msappler: sexpbot and clojurebot don't allow various things, including defs

4:42 msappler: my repl does ;)

4:42 Okay that was the missing link :)

4:42 amalloy: indeed, which is why i sent you the defmacro

4:43 msappler: thx very much

4:43 amalloy: msappler: in general, if you have a symbol nested within N backticks, you usually want to have a total of N [~ or #] things attached to it

6:15 Norrit: Is there really no way to capture symbols in macros?

6:17 shortlord: is there any shorter way to filter all non-nil items in a seq than using (filter (comp not nil?) coll)?

6:19 mrBliss: shortlord: (remove nil? coll)

6:21 Chousuke: Norrit: There is

6:21 shortlord: mrBliss: ah, remove! great, thx :)

6:21 Chousuke: Norrit: ~'sym generates an unqualified symbol within a syntax quote form

6:22 mduerksen: shortlord, mrBliss: ##(doc keep)

6:22 sexpbot: ⟹ "([f coll]); Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects."

6:22 mduerksen: would be an alternative where you can even project each item of the coll

6:24 Norrit: Chousuke: I will try it out, thx

7:33 rrc7cz: does anyone have any advice when it comes to custom exceptions? I don't really want to gen-class my own exception, so I'm looking at error-kit, condition, and I know raek talked about some type of throwable map thing..

7:34 I'm looking through contrib to see if I can find some examples of how other people have done it, but the pickins are surprisingly thin

7:34 AWizzArd: rrc7cz: you can generate classes with proxy too.

7:34 But using an existing Clojure lib is probably the best thing you can do.

7:37 rrc7cz: AWizzArd: error-kit looks nice, especially because you can have it rethrow a normal Java Exception for clients who don't want to use error-kit. I still need to look at the conditions lib. I just wish I could see some examples of both being used

8:00 raek: conditions uses an ordinary java throwable, so it works pretty well with java

8:01 a new error system to rule them all is under discussion

8:06 rrc7cz: with conditions:

8:06 (defn raising-fn [] (raise :type ::foo-exception, :message "Foo occurred!"))

8:10 (defn handling-fn [] (handler-case :type ...body... (raising-fn) ...body... (handle ::foo-exception (println "condition occurred: " *condition*))))

8:10 dsop: coniditions are beautiful

8:10 in comparision to stnadard java exceptions

8:10 raek: https://github.com/clojure/clojure-contrib/blob/master/modules/condition/src/examples/clojure/examples/condition.clj

8:11 as soon my exams are done, I will continue working on this: https://github.com/raek/map-exception

8:12 warning: that is not stable.

8:12 as in, there should be consensus regarding what the new error system should look like, and this is only my exploration

8:13 rrc7cz: sorry guys, I stepped out. Let me read all this stuff and catch up

8:13 dsop: looks nice

8:14 rrc7cz: yeah I kinda ran up against a wall when I started looking at ways to handle exceptions. there's very little out there, even in the clojure books

8:14 most of the documentation is about simple try/catch, consuming of exceptions, not producing them

8:15 I know I don't want to gen-class, but I also need real java exceptions for the java client of the lib. So it seems like I have to try out both error-kit and conditions and pick one

8:16 schaf_: is there anything like a static final constant in clojure?

8:16 fliebel: Why can't one make a protocol out of a regular class? In Java, one can implement a concrete class just the same, right?

8:16 rrc7cz: I also considered exceptions-as-return-types, something like Maybe/Either or just returning different maps, but without pattern matching it doesn't really look too nice and bloats up the client code

8:17 fliebel: rrc7cz: Me to :) I thought about adding it as one of the the things that are false, liek nil and false.

8:17 raek: rrc7cz: I recognize your thoughts... I agree that error handling is a hole in the language currently.

8:18 one way could be to use namespace qualified keywords as "error values"

8:18 but they cannot have any payload

8:18 another way would be records/types, since they are unique types

8:19 rrc7cz: in your scenario, would it be a problem for your java interop if clojure only had one exception class?

8:20 fliebel: raek: Why can't a protocol implement Exception?

8:20 raek: (assuming that the exception object would have a getType method)

8:20 fliebel: protocols can't implement stuff. you meant defrecord/deftype?

8:21 fliebel: yea

8:21 rrc7cz: raek: I'm not sure. I'm still on the fence abot whether or not I'll write a wrapper to make the Java client code easier

8:21 raek: well, subclassing is not ideomatic clojure

8:21 and def(type|record) was made to be a clojure-y thing

8:21 rrc7cz: in other words, I'm writing the clojure core without thinking about a java client, then perhaps gen-class a wrapper that makes it easier to use from java. that wrapper could consume a single clojure exception and rethrow it as however many types. bit of layering

8:22 raek: even if Exception would be an interface, you still need the class name at compile time

8:22 fliebel: raek: I understand, but in Java, I think I'm allowed to write "public class Exept implements Exception" which does not inherit any implementation at all.

8:22 raek: which rules out redefining the record/type

8:22 really?

8:23 fliebel:

8:23 rrc7cz: you can only implement an interface

8:23 raek: I think defrecord, when evaluated at run-time, generates a uniquely named class (with some serial number)

8:24 rrc7cz: Exception is not an interface

8:24 fliebel: rrc7cz: Uh? Oh :(

8:24 raek: you'd have to write something like (try .. (catch Foo__6456 e ...))

8:24 and that number would change if you reevaluated the defrecord

8:25 the problem is: the jvm does not allow redefinition of classes, and catch clauses require a fixed class name

8:25 fliebel: raek: I think I need to seriously reconsider my image of Java, deftype, and the rest.

8:26 raek: however, I like the idea of having one map-carrying exception type for use in clojure-land

8:27 then the "type" could just be watever that's in the :type key

8:27 and we can use isa? and derive for "type" hierarchies

8:27 rrc7cz: raek: but how would you propogate it up the call stack?

8:27 raek: so, this is what c.c.condition does now

8:28 rrc7cz: by the usual java exception mechanism

8:28 rrc7cz: okay, so it's not actually just a map with-meta :type exception or whatever

8:28 raek: c.c.condition includes a AOT-compiled exception class

8:28 with a fixed name

8:28 rrc7cz: but it allows a custom payload?

8:28 raek: yes

8:28 it carries the map as its metadata

8:29 rrc7cz: so how is your proposal different?

8:29 raek: not very much

8:29 it's more about how it should be used

8:29 rrc7cz: could you maybe show an example?

8:29 raek: and making a syntax where you can mix java exceptions and conditions (not my idea either)

8:29 https://github.com/raek/map-exception

8:30 condition lets you choose the handler with a dispatch fn, like with multimethods

8:31 there has been suggestions for making it able to handle odrinary exceptions as well

8:31 but I think these two usages (dispatch-fn and java-integration) should be separate forms

8:31 I recommend looking at the source - it isn't long

8:32 rrc7cz: so right now you could write the dispatch-fn w/class to determine whether or not it's the AOT condition exception or another java exception?

8:32 and you'd like to separate that?

8:32 I'm looking at it now

8:33 raek: in the github page there's a link to a google group thread

8:33 rrc7cz: k

8:35 raek: rrc7cz: just pushed a minor addition

8:38 rrc7cz: I don't see how you catch a regular java exception and convert it to a PersistentMapException w/:type set to the exception type (as opposed to a keyword coming from a straight throw+ clj map)

8:38 clklein: Are/where there versions of Clojure in which keywords can be applied to 3 arguments?

8:39 raek: ,(:foo {:bar 1} :not-found)

8:39 clojurebot: :not-found

8:39 raek: it has been there as long as I can remember

8:39 the meaning of it is the same as for 'get', but with the arguments reordered

8:40 clklein: raek: That's 2 arguments by my count

8:40 raek: eh

8:40 sorry

8:40 I guess I was counting the "function argument"... :-)

8:45 rrc7cz: I don't. if the type is a symbol that resolves into a class, that catch clause becomes an exception catch clause. if not, it gets added as a match case in a (catch PersistentMapException ...) clause

8:46 fliebel: If I wanted to make something that is equally taxing for my computer as a game of Lemmings, what would be the *simplest* way to do that in Clojure? Java has a few options, like the 2D api and ljwgl, and Clojure has Penumbra.

8:49 raek: rrc7cz: I intend to add try-map, which is just like try+ but only handles map exceptions. then try+ will be easier to describe.

8:51 (try+ (throwing-code) (catch ::foo-error ...) (catch BarException ...) (finally ...)) --> (try (try-map (throwing-code) (catch ::foo-error ...)) (catch BarException ...) (finally ...))

8:53 rrc7cz: raek: I think I understand now.. the try+ just merges regular (catch e) for pure java exceptions with your single (catch PME) to grab those (throw+ maps)

8:53 raek: yes

8:54 rrc7cz: so it's just augmenting the standard try/catch to support throwing these maps. I like it. So if client code uses a regular try/catch it would still work, but they'd have to explicitly catch and parse your PME. So you provide the try+ sugar to handle that part

8:55 raek: (the change I pushed introcuded 'throw-map' (and the example now uses that one), but 'throw+' is still there)

8:55 yes

8:56 the exception class should really have one getter method for each "common" key of the map: :type, :cause, :message

8:58 rrc7cz: I feel like the situation is a little rough in general. I feel like one of these libs (yours, conditions, error-kit, dunno) need to be part of the language. Because if I use three libs and each one uses a different exception lib, I'm forced to use all three, right? Like if I write a lib that uses map_exception and throws throwable maps, any use of my lib really needs that try+ sugar to handle it well, right?

8:58 or I'd have to forgo the sugar and deal with PMEs manually I guess

8:59 raek: yes, I hope one of them becomes elegant and useful enough to be "official"

9:00 http://dev.clojure.org/display/design/Error+Handling

9:01 rrc7cz: thanks, I hadn't seen that before. I did manage to find Stuart's comparison of error handling which mentioned yours, EK, conditions, and some type of stacktrace parser

11:04 Berengal: How do you re-export names from one namespace in another?

11:05 tonyl: (ns (:use :reload-all ...

11:05 I believe

11:07 david`: is there any easier way to start compojure: https://gist.github.com/84a4f22d8966d0d825dc

11:08 raek: david`: https://github.com/weavejester/lein-ring

11:08 david`: thanks!

11:09 raek: I think there is a "lein run" plugin for starting clojure and evaling a file too (this is probably already integrated into the last lein version)

11:10 "lein repl" is not made for that case, but it happened to work in a few versions.

11:14 fliebel: LauJensen: Nice post! 2 questions: Why InnoDB? Any thoughts about voting algorithms?

11:15 LauJensen: fliebel: No particular reason for InnoDB for this schema, no thoughts on voting

11:15 and thanks for the compliment :)

11:16 raek: hrm, blog.bestinclass.dk (a URL I tried at random, since I didn't remember the real URL) points to the ClojureQL site

11:17 LauJensen: raek: yea, its nginxs trickle down strategy, it can be quite unfortunate. If you access something which it doesnt have a handler for, it will just pick one from the available options

11:17 raek: LauJensen: the font in the logo, is it Kontrapunkt?

11:17 LauJensen: raek: CQL? Yes

11:18 raek: elegant.

11:18 LauJensen: blog.* fixed

11:21 fliebel: Does anyone here have experience with the performance and ease of use/learn of different drawing libraries in Clojure? I just need simple bitmaps blitted to the screen.

11:21 bobo_: LauJensen: nice post!

11:21 LauJensen: bobo_: Thanks :)

11:22 bobo_: the database optimiser in me screams abit. but thats not realy important for the post =)

11:22 LauJensen: fliebel: I wrapped JMonkeyEngine once, that was easy because of the tutorials. But just for bitmaps I would say Slick2D is easy to use

11:22 bobo_: would just make the unimportant stuff take up more space

11:22 LauJensen: bobo_: What would you optimize?

11:23 bobo_: i would add indexes, dont think any of your queries use index.

11:23 but its horrible booring with indexes

11:24 fliebel: LauJensen: I'll check them out. I was thinking about the Java 2D api, and the Clojure OpenGL wrapper myself.

11:26 LauJensen: fliebel: I mentioned JME because you spoke of a game earlier. If I was building a game, JME would be my first stop

11:26 I did to a swirly, 3d, bouncing tunnel with Slick2D once, that was easy

11:26 fliebel: LauJensen: Yes, it's for a game, some point in the future.

11:27 LauJensen: Then you really dont want to miss JME - Check out their demos

11:27 They have great tutorials

11:28 fliebel: LauJensen: Great :) Shaders and all sound a bit scary, if it's labeled draw_bitmap, it feels more easy ;)

11:28 currentB: what's the best way to conj a single item to a vector stored as a value in a hash?

11:29 raek: currentB: update-in

11:29 currentB: thanks!

11:29 raek: ,(update-in {:foo [1 2]} [:foo] conj 3)

11:29 clojurebot: {:foo [1 2 3]}

11:29 currentB: i really need to memorize the api

11:29 raek: fliebel has made a clojure quiz...

11:30 currentB: cool i'll check it out

11:30 raek: https://github.com/pepijndevos/clojure-quiz

11:30 fliebel: gehe, it hasn't got a web interface yet

11:32 currentB: no need, thanks :)

11:40 duck1123: Does anyone know why when using slime with 1.3, I never get traces anymore when I get an error at the REPL

11:43 LauJensen: Somebody put my post on the frontpage of HN, thanks :)

11:49 fliebel: LauJensen: Are you sure I can do 2D with the monkey thing, and do it without Eclipse?

11:50 (that someone wasn't me, I only submitted it ;)

11:50 LauJensen: fliebel: Im sure you can use it without Eclipse, but I dont think you can do 2D- You can do 3D that looks like 2D which is better, but different

11:51 fliebel: LauJensen: That is a strange thing to say, since 3D is merely 2D that looks 3D.

11:51 LauJensen: You know what I mean right?

11:52 ejackson: evening LauJensen et fliebel

11:52 rooney: Hi all, can I ask about using clojure with emacs here?

11:52 LauJensen: Evening el Jackson

11:52 fliebel: LauJensen: I think I do. But what I mean is that it sounds like a weird thing to do, emulate 2D in an emulated 3∂ environment on a 2∂ screen. What is the advantage?

11:52 LauJensen: rooney: sure

11:52 fliebel: ejackson: hey

11:52 LauJensen: fliebel: You can make it look nicer

11:54 fliebel: LauJensen: At the cost of what?

11:54 LauJensen: At the cost of having to model everything in 3d

11:54 ...and then position the camera and models in a wy that it appears to be 2d...

11:55 fliebel: LauJensen: Okay, not what I want. I chose 2D because it keeps things simple.

11:56 rooney: great, thanks, I'm a newbie, I'm following the swank-clojure instructions, if I do M-x slime, it will ask me to install clojure, if I press y it will contacting host repo.techomancy.us:80 and then stop, giving message failed to download Clojure jars.

11:56 what should I do?

11:57 mrBliss: rooney: I think swank-clojure is not supported anymore. Use ELPA instead to install clojure-mode, slime and slime-repl.

11:57 raek: hrm, sounds like you are using the deprecated swank-clojure.el

11:58 (swank-clojure.el = swank-clojure the emacs lisp file)

11:58 rooney: ok, so how do I use this ELPA?

11:58 raek: swank-clojure the clojure project you do want to use

11:58 the instructions are here: https://github.com/technomancy/swank-clojure

11:59 1) install package.el (instructions in the above link)

11:59 2) M-x package-list-packages

12:00 3) select clojure-mode, slime and slime-repl by pressing the i key on them

12:00 4) press x to install

12:00 5) M-x slime-connect

12:01 rooney: ok I got the package list, but there's no clojure-mode, no slime, no slime-repl, there's clojure-test-mode though

12:01 raek: rooney: have you added technomancy's repo?

12:01 mrBliss: rooney: (add-to-list 'package-archives

12:01 '("technomancy" . "http://repo.technomancy.us/emacs/&quot;) t)

12:01 rooney: I put that to the package.el, right?

12:02 mrBliss: no, in your .emacs

12:02 raek: no, in your .emacs file

12:03 rooney: I don't have .emacs file, I'm using the emacs-starter-kit

12:03 mrBliss: rooney: v2 or v1?

12:03 rooney: (it told me to remove my .emacs file)

12:03 fliebel: LauJensen: I found a couple of others :) Most seem to point to JGame, but that might just be title-inherited-ceo-advantage. http://stackoverflow.com/questions/293079/java-2d-game-frameworks

12:04 mrBliss: rooney: the emacs-starter-kit comes with ELPA (package.el) and technomancy's repo, so you can skip step 1

12:05 rooney: how do I check the version? I just cloned it, so it should be the latest

12:05 ah ok

12:05 so it's M-x slime-connect? Not M-x slime?

12:05 raek: yes

12:06 mrBliss: rooney: master is v1 (v2 is a separate branch only for Emacs 24)

12:06 raek: nowadays, you usually start the clojure instance outside of emacs

12:06 this makes classpath handling *way* simpler

12:06 so, the last step assumes you have a swank server running.

12:06 rooney: have you used leiningen or cake?

12:07 rooney: lein swank already works

12:07 anyway, should I upgrade to emacs 24? I'm using 23

12:07 raek: good. then you shold be able to connect to that server with slime-connect

12:07 mrBliss: rooney: no need

12:07 rooney: ok, cool! slime-connect works

12:08 raek: (since emacs 24, package.el is included)

12:08 rooney: happy hacking!

12:08 rooney: umm, but no highlighting on the console?

12:08 I mean REPL

12:09 raek: (add-hook 'slime-repl-mode-hook 'clojure-mode-font-lock-setup)

12:10 from the swank-clojure docs: "Put this in your Emacs configuration to get syntax highlighting in the slime repl:"

12:10 rooney: my Emacs configuration, since I don't have .emacs, so the line goes to...

12:11 (sorry, very newbie)

12:11 mrBliss: rooney: starter-kit-lisp.el

12:11 above (provide 'starter-kit-lisp)

12:12 dakrone: rooney: you cat put it in the scratch buffer and use C-x C-e on the end of the line to eval it also

12:12 raek: Speculation: I think you should be able to have a .emacs file anyway. The reason why it tells you to delete it is probably to avoid conflicting settings.

12:13 ah, now i see. it might cause the starter kit to not load, if present... so ignore my previous utterance

12:13 rooney: yes, the starter-kit won't load if I have .emacs

12:13 anyway, error in process filter: run-hooks: Symbol's function definition is void: clojure-mode-font-lock-setup

12:14 mrBliss: rooney: are you sure clojure-mode is installed?

12:15 raek: maybe that has to be added after the part that loads clojure-mode

12:15 you could try to add it to the bottom rather than the top

12:16 rooney: I have this file: ~/.emacs.d/elpa/clojure-mode-1.8.0/clojure-mode.el

12:16 that means it is installed, right?

12:16 dakrone: rooney: it's also recommended to create a ~/.emacs.d/<your_username>.el to put any tweaks in

12:16 mrBliss: rooney: installed, but not necessarily loaded

12:16 dakrone: which will be loaded automatically

12:18 mrBliss: good idea of darkrone to put all your customizations in a separate file, so add (require 'clojure-mode) and the (add-hoo.. line from raek to that file.

12:18 rooney: ok, so I should put the add-hook to rooney.el instead?

12:18 ah ok

12:18 mrBliss: maybe restart emacs to be sure everything is loaded

12:19 dakrone: emacs starter kit will load ~/.emacs.d/<username>.el and everything in ~/.emacs.d/<username>/* automagically

12:20 flight leaving, good luck

12:21 StartsWithK: hi

12:21 i think i found a error in clojure 1.3alpha1 when using remove-ns on aliased namespaces http://paste.pocoo.org/show/317723/

12:23 rooney: awesome, highlighting works now, thanks dakrone, mrBliss, raek, LauJensen

12:26 mduerksen: is this intended behavior? ##(-> (sorted-set-by #(< (%1 1) (%2 1))) (conj [1 3]) (conj [2 3]))

12:26 sexpbot: ⟹ #{[1 3]}

12:27 mduerksen: apparently the comparator is not only used for sorting, but for identified duplicates too?

12:31 dale: Can anyone explain to me why the old filter definition at http://clojure.org/lazy#toc7 could run out of memory, i.e. with the given example? Why would a closure closing over coll be created and hang around past (recur pred (rest coll))?

12:33 Bah, naturally as soon as I type that I think I figured it out. I think the problem (as stated there, albeit in a way I couldn't grasp) was that the looping happens in the context of a closure created by lazy-cons, which still has the head (or 20th element in a long sequence, in that example).

12:34 clojurebot: examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

14:02 slyrus_: ok, who's the guy in berkeley with the CLOJURE license plate?

14:04 Null-A: haha

14:56 willtim: test

15:59 mduerksen: is it possible to fetch a 1.3 release with leiningen? how would i have to set up my project.clj?

16:05 churib: mduerksen: search for the announcements for 1.3 releases on the gougle group, it is described there.

16:05 raek: mduerksen: I usually check here: http://build.clojure.org/releases/org/clojure/clojure/

16:29 mduerksen: churib, raek: thank you, i just got clojure.core. but i can't find clojure.contrib - of course i could manually download it, but i'd rather let leiningen do the work for me :)

16:40 naeu: Is #^"[B" is old syntax for tag metadata?

16:40 amalloy: naeu: i think you can use ^"[B" now

16:41 but that's still the right tag for boolean arrays

16:41 or byte? i forget

16:41 brehaut: byte

16:41 naeu: It's just that I was perusing https://github.com/clojure/clojure/blob/master/src/clj/clojure/java/io.clj and saw metadata with the #^ syntax

16:43 I guess it just hasn't been updated?

16:44 core/slurp and core/spit also use #^

16:45 I guess the old syntax is still usable

16:49 cheezey: does anyone know if (do ..) can reorder the execution?

16:50 brehaut: cheezey: its the basic sequential execution operator so i wouldnt think so

16:50 amalloy: cheezey: no, it can't

16:50 Raynes: I'm pretty sure it can't.

16:50 amalloy: do you want it to, or are you worried it might be?

16:51 Raynes: &(macroexpand '(do stuff morestuff lotsofotherstuff wowevenmorstuff))

16:51 sexpbot: ⟹ (do stuff morestuff lotsofotherstuff wowevenmorstuff)

16:51 cheezey: nope, i don't want it to =p

16:51 Raynes: Is do a special form?

16:51 &(doc do)

16:51 sexpbot: ⟹ "Special Form: Please see http://clojure.org/special_forms#do"

16:51 amalloy: Raynes: yes

16:51 Raynes: Damn.

16:51 Is that even necessary?

16:51 amalloy: uh...yes?

16:52 brehaut: Raynes: probably not necessary, but id guess it makes it easier

16:52 amalloy: if you didn't have a compiler-level syntax for "do a, then b", how could you do it with a macro?

16:52 brehaut: amalloy: rewrite into nested functions

16:52 Raynes: amalloy: Go work on sexpbot or something. Nobody asked you.

16:52 ;)

16:52 amalloy: brehaut: that will mess up your recur, no?

16:53 brehaut: amalloy: i imagine a world of hurt would be involved with doing it nicely without a tail recursive host

16:53 amalloy: heh

16:53 but you're right, you could probably do it

16:59 brehaut: amalloy: actually, i dont think you would mess up recurs

16:59 amalloy: eg (do (loop [a 10] (prn a) (when (> a 0) (recur (- a 1)))) (prn "hello, world"))

16:59 could be rewritten to

17:00 ((fn [] ((fn [_] (prn "hello, world")) (loop [a 10] (prn a) (when (> a 0) (recur (- a 1)))))))

17:00 acutally, you would obviously ditch the wrapping fn of no args

17:01 amalloy: brehaut: you've made loop into a compiler-level sequential operator

17:01 not really solving the problem

17:01 brehaut: amalloy: i havent? the loop recur bit occurs before the hello world bit

17:01 oh wait, no i see what you mean

17:01 amalloy: brehaut: your loop has two forms in it, one of which is discarded

17:02 brehaut: anycase yes: can of worms :)

17:02 amalloy: :)

17:04 probably you could do it even more easily with let. (let [_ (prn a)] (blah))

17:05 brehaut: amalloy: i think you are right

17:11 amalloy: although you could argue that swapping one special form for another is self defeating :P

17:11 amalloy: brehaut: let* is already special

17:11 brehaut: amalloy: exactly

17:12 amalloy: so...? we need only let*, not do, to be special, afaict

17:13 naeu: does anyone know why (def s (Socket. "localhost" 6666)) throws a connection refused exception?

17:13 brehaut: amalloy: i think the 'so…?' here is that if you care enough about purity of implementation to want to avoid do being special, you also to treat let* the same way

17:13 amalloy: naeu: because you don't have a process listening on 6666 yet?

17:14 naeu: amalloy: hmm, I clearly need to brush up my network programming skills here

17:14 amalloy: naeu: you're probably looking for ServerSocket

17:15 naeu: amalloy: so Socket's constructor creates an OS socket & binds to an external socket?

17:16 amalloy: naeu: it's been a while, but i believe so

17:16 $google java.net socket

17:16 sexpbot: First out of 198000 results is: Socket (Java 2 Platform SE v1.4.2)

17:16 http://download.oracle.com/javase/1.4.2/docs/api/java/net/Socket.html

17:18 naeu: ok, cool - so the particular constructor i'm using does attempt to connect: "Creates a stream socket and connects it to the specified port number on the named host."

18:11 raek: mduerksen: from 1.3 on, contrib has been split up into modules

18:22 cheezey: clojure namespaces are confusing or something o_o.

18:23 naeu: cheezey: in what way?

18:23 cheezey: well when i print out the classpath, my files are there

18:23 but when i try to use that particular file, it says it can't find it..

18:23 i think i'm missing something dumb

18:23 naeu: what does the path look like?

18:23 cheezey: what do you mean

18:23 naeu: and what's the filename?

18:24 cheezey: config.clj

18:24 naeu: src/foo/bar/baz.clj

18:24 are you using lein or cake?

18:24 cheezey: no X_x

18:24 i probably should use lein eh

18:25 naeu: well, I find it just makes this stuff a lot easier on the outset

18:25 but you shouldn't really need it :-)

18:25 cheezey: well im just working on a small project

18:26 naeu: still, unless you're doing something particularly bespoke, it probably makes sense to use one of them

18:26 especially if you want to start pulling down deps

18:26 cheezey: well ok,for now

18:26 naeu: but anyway, that's not solving your problem :-)

18:26 cheezey: basically, 2 files, one has (:use [config])

18:27 both in the same folder

18:27 naeu: and how are you setting the classpath?

18:28 cheezey: it includes the folder they're in

18:28 i mean, i can import jar libraries from within the folder so :\

18:28 naeu: and how are you trying to run things?

18:29 cheezey: the non compiling way :x

18:29 naeu: can you paste the command you're running?

18:30 cheezey: it's just $ clj sadf.clj

18:30 naeu: hmm, what's your definition of clj?

18:30 cheezey: it was set up with http://riddell.us/ClojureOnUbuntu.html

18:31 raek: cheezey: if you want to use foo.bar-baz, you need to have the code in src/foo/bar_baz.clj and the src/ directory on the class path

18:32 (of course, you don't need to call that "src")

18:32 cheezey: yes i have it in there.

18:32 we're talking about CLOJURE_EXT right :x

18:33 naeu: raek: cheezey said he was just doing a (:use [foo])

18:33 does that imply that he needs a src/foo.clj?

18:33 if his classpath contains the current dir?

18:33 raek: he needs some-dir-on-the-classpath/foo.clj

18:34 if the dir that contains foo.clj is on the classpath, it should work

18:34 cheezey: >_>

18:34 raek: cheezey: what is CLOJURE_EXT?

18:35 naeu: there's this line from the tutorial he linked to: export CLOJURE_EXT=~/.clojure

18:35 cheezey: raek: it defines the classpath for my clojure binary

18:36 i mean when i go to my repl, i can see my directory by printing out the paths

18:36 naeu: cheezey: do you have any particular reason you're not using lein or cake?

18:37 cheezey: no but no reason to not try to fix this

18:37 dale: I am surprised (not complaining) that clojure.contrib.error-kit is not better documented after what looks like nearly two years of existence, given that it looks so useful.

18:38 naeu: dale: I'm sure the author is happy to accept doc patches ;-)

18:39 dale: That's one very possible theory. Another is that it is not very widely used, perhaps because it operates apart from Java exceptions.

18:39 raek: yep. I feel optimistic again when this has started to get some more serious attention: http://dev.clojure.org/display/design/Error+Handling

18:40 dale: Yeah, I saw that too.

18:40 raek: cheezey: can you post the stacktrace you get somewhere?

18:40 sound like it should work

18:41 dale: I really just want a way to make a new exception type, which looks like it currently requires me to make a separate file with :gen-class and use AOT or something.

18:42 raek: the jvm requires the class to be hardcoded, so yes. AOT is the only option for making a usable completely new exception

18:42 cheezey: raek: http://pastebin.com/t2P8ApJW .. i don't htink it's that helpful though

18:42 raek: *in catch clauses, the jvm requires...

18:43 dale: raek: Heh, thanks, that's what I was about to ask for clarification on.

18:46 raek: I think this is why clojure didn't include an error system from the beginning

18:46 it's a non-trivial problem

18:48 cheezey: so if you have your file in /some/path/config.clj, /some/path/ is present in the class path (that you printed)?

18:48 dale: I'm guessing that "make the JVM more flexible WRT exceptions" would be a nice fix except for the whole "get everyone to understand new byte code" thing.

18:48 cheezey: raek: yes.

18:50 raek: then it should really work

18:50 strange

18:51 cheezey: oh well. i'll just put them the stuff in the same files

18:51 like i said, small project, no big deal. just wondering wats up :|

18:51 raek: did the directory exist when you started clojure?

18:52 cheezey: ya

18:52 raek: you could alway ugly-hack it in: (add-classpath "file:///some/path")

18:53 if it starts to work after that, check what the difference between that path and the one you had before was

18:54 also, are you sure the path is /some/path/ and not /some/path/*?

18:55 cheezey: yep

18:55 like i said, it can find jars within the same location

18:58 raek: that's not the same thing

18:58 a jar file counts as a "source root directory"

18:59 so there is probably a * somewhere in you clj script

18:59 the classpath should countain one entry for each jar file (possibly using the * shortcut) and one entry per source directory

19:00 so it looks like you don't have /some/path on your classpath, but instead everything in it

19:03 cheezey: i'll have to look into it later again

19:08 amalloy: &(macroexpand '(fn[]))

19:08 sexpbot: ⟹ (fn* ([]))

19:10 amalloy: &(macroexpand '#())

19:10 sexpbot: ⟹ (fn* [] ())

19:10 qbg: &'#()

19:10 sexpbot: ⟹ (fn* [] ())

19:10 amalloy: is there any particular reason that the latter should have a () in it?

19:10 qbg: That is part of the syntax

19:11 The form () becomes the body of the function

19:12 &'#(foobar)

19:12 sexpbot: ⟹ (fn* [] (foobar))

19:12 amalloy: qbg: i guess that makes sense. it kinda annoyed me when i was writing (->> whatever #())

19:15 with the hope that this would result in (fn [] whatever); the extra () doesn't really matter but seems unnecessary

19:19 raek: (-> whaterver (#(foo %))) is one way of doing it

19:27 amalloy: raek: that calls the function; i just want to define it and pass it along

19:28 &(macroexpand '(->> whatever (fn []))) works of course, but i would have liked the other way to work

19:28 sexpbot: ⟹ (fn* ([] whatever))

19:56 cheezey: quick question, is there a function that appends (instead of prepending) an element to a sequence?

19:56 instead of doing 2 reverses with cons

19:57 qbg: cheezey: Use vectors instead

19:57 ,(conj [1 2 3] 4)

19:57 clojurebot: [1 2 3 4]

19:57 cheezey: qbg: thnx :d

20:14 amalloy: cheezey: btw, cons often isn't what you want. conj adds wherever it's most efficient for a given sequence type: the front for lists, the back for vectors. ##(map (comp #(conj % [5 6]) #(% 1 2 3 4)) [list vector hash-map])

20:14 sexpbot: ⟹ (([5 6] 1 2 3 4) [1 2 3 4 [5 6]] {1 2, 3 4, 5 6})

20:17 qbg: My syntax-rules library now uses itself to define parts of itself.

20:18 I feel meta right now...

21:56 jk_: i'm trying to package a compojure app as a regular war file but can't figure out how to confgure the servlet class for my web.xml

21:58 can someone clue me in? does the defroutes function extend httpservlet underneath? do i need a genclass extends httpservlet or soemthing like that? it's just not clear

21:58 want to deploy on tomcat

21:59 mids: jk_: take a look at https://github.com/alienscience/compojure-war-example

21:59 jk_: mids: ah, great! thanks.

22:00 mids: exactly what i was trying to find

22:01 brehaut: anyone where familiar with clojureql?

22:03 amalloy: brehaut: LauJensen probably is :)

22:03 brehaut: amalloy: i imagine so too. i think he is away though

22:04 Raynes: brehaut: There is a #clojureql channel.

22:04 brehaut: Raynes: thanks!

22:31 GMTao: I have a "noob" question if that's alright.

22:32 I'm not quite convinced that my approach is valid, but I seem to have painted myself into a corner.

22:34 brehaut: GMTao: it sure is ok

22:35 GMTao: Perfect. The gist of it is that I've got a string that I'm chunking up based on calls to .substring, but the catch is that those calls are done in a dotimes call.

22:36 brehaut: can you paste your code and sample input an result somewhere?

22:36 GMTao: Sure, I was typing out the block in question, but that may be easier. One sec.

22:37 cheezey: are lists implemented as linked lists?

22:37 GMTao: The idea is that the code is generating a bunch of substrings, which is fine. I can process each substring with other functions I've written. The issue is that I want the substrings that I process to go into a list.

22:37 amalloy: cheezey: yeah, though immutability has some side effects you may not expect

22:37 cheezey: amalloy: like wut :o

22:38 amalloy: well like it's not cheap to add to the end

22:38 only the front

22:39 cheezey: eh, i think the maximum size of the lists will be 1000 anyway

22:39 oh wait no it won't

22:39 suddenly i am sad.

22:41 amalloy: cheezey: chill. there's a right way to do it, whatever your goal is

22:41 GMTao: https://gist.github.com/772314 <-- For those interested

22:42 cheezey: amalloy: ok so i'd like to represent a lot of text. each line is an element in some list (what kind of list?)

22:42 amalloy: aha, project euler

22:42 cheezey: depends what you want to do with the text. so far, a lazy sequence sounds good, but who knows

22:42 cheezey: amalloy: modifcation of text.

22:42 brehaut: GMTao: can you give us an example input ?

22:44 GMTao: brehaut: sure, try 7316717653. I'm looking for the dotimes block to return me a list like: (882 126 294 1764 1470 630)

22:44 brehaut: ok

22:44 amalloy: GMTao: just use for instead of dotimes, and don't print the result. or, use ##(doc partition), which is intended for just this purpose

22:44 sexpbot: ⟹ "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complet... http://gist.github.com/772320

22:44 GMTao: amalloy: yep, it's a project euler problem, but I'm actually doing it Coderloop instead. :-)

22:45 amalloy: &(partition 5 1 (map #(Integer/valueOf %) "7316717653"))

22:45 sexpbot: java.lang.IllegalArgumentException: No matching method found: valueOf

22:45 GMTao: amalloy: thanks! I'll give that a shot now. The println was there for my own sanity, I wasn't hoping to keep it. :-)

22:45 amalloy: &(partition 5 1 (map #(Integer/valueOf (str %)) "7316717653"))

22:45 sexpbot: ⟹ ((7 3 1 6 7) (3 1 6 7 1) (1 6 7 1 7) (6 7 1 7 6) (7 1 7 6 5) (1 7 6 5 3))

22:46 brehaut: GMTao: if you use for, use the range function

22:46 GMTao: amalloy: Wow, how elegant! Thank you kindly, this is exactly what I was hoping for. My clojure skills truly are weak.

22:47 amalloy: GMTao: well, i've done this problem before :P

22:47 there's an eye-opening description of the Clojure Way to do this somewhere on one of IBM's websites

22:48 GMTao: amalloy: Heh, touche! Regardless, this is why I'm doing these problems. To try to get a better understanding of clojure, one frustrating problem at a time. :-)

22:48 brehaut: I'm going to try using for/range first, then I'll use amalloy's solution.

22:49 amalloy: GMTao: http://www.ibm.com/developerworks/opensource/library/os-eclipse-clojure/ - example 3 is project euler #8, which i assume is what you're doing. it's pretty in-depth so you'll probably consider it a spoiler; view at your own risk

22:50 GMTao: Thanks amalloy, I'll take a look after I submit my hack. :-)

23:15 amalloy: GMTao: for your entertainment, https://gist.github.com/8d88fd495752514295fb is a solution using the same algorithm as ibm's approach, but written in a different style and with some added features. have a look when you're done

23:28 laurus: mail

Logging service provided by n01se.net