#clojure logs

2011-01-09

00:00btw0cemerick: you are right, I'll go with the shuffle solution, thanks man.
00:01amalloythere'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
00:01tomojyou could take the source set and make a transient to pop from, maybe?
00:01tomojs/pop/randomly disj!/
00:01sexpbot<tomoj> you could take the source set and make a transient to randomly disj! from, maybe?
00:04btw0tomoj: good idea, but that's overskill for my case :)
00:23tomojI want forcat a lot
00:30amalloytomoj: so write it?
00:31tomojin cases where I wanted in a lot inside a single project, I have
01:12replacatomoj: forcat and formap, too
01:13tomojformap?
01:13tomojoh, with an (into {} ..)?
01:20tomojLauJensen: you ever use keyboard macros on clojure code?
02:21amalloytomoj: i'm curious what macros you would find useful. i mean, i'm sure they exist but i can't think of any
02:21tomojhard to say, they're nonce by nature I think
02:23tomoja recent example: I had a map something like {:x (.foo bar) :y (.baz bar) ..} and wanted {:x (-> bar .foo bing) :y (-> bar .baz bing) ...}
02:28tomojI'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])
02:45replacaIs clutch the right way to talk to couchdb or are folks using other libs?
02:50cemerickreplaca: Certainly what I use. ;-)
02:52replacacemerick: thanks. So you think it's a reasonable way to wade in? I'm a couch newbie
02:53cemerickreplaca: 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.
02:53cemerickNo shit, huh?
02:54replacacemerick: ( I knew someday I'd get you back :))
02:54cemerickreplaca: so this is a hex you set on me?!?! ;-)
02:54replacacemerick: cool. I just want to massage a bunch of data out of XML and into couch
02:54replacayup :)
02:54cemericksounds easy enough
02:54replacaand then play with it
02:55cemerickAFAIK, clutch has the broadest support for couchdb features, and some nice almost-clojure-specific bits
02:55cemerickoptionally getting view results as an inputstream so you can read them lazily, etc.
02:55replacaI'm trying to understand if I should consider moving our huge orver-normalized db of video events into couch
02:56replacanice, I really want everything to be lazy or async (ala clojure or node.js)
02:56cemerickbetween 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
02:57replacavideo isn't really part of the equation, just structured events
02:57replacalike, 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
02:58replacathen folks can annotate those things etc.
02:58replacathe actual video is a whole othe rkettle of fish and hugely complicated in the volumes we're talking about
02:59cemerickWhen you said "events", I thought maybe you meant e.g. 20s clips surrounding particular noticed actions, etc.
02:59replaca(think: data from > 10,000 cameras running all the time)
03:00replacayeah, 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
03:01replacaso they get continuous in lots of cases
03:01cemerickyou'll want to do a fair bit of thinking about what your requirements are around durability, write availability, etc etc etc
03:01cemerickall the newfangled databases slice up the domain in their own idiosyncratic ways
03:01replacayeah, that's what I'm trying to begin to explore
03:02cemerickIt seems that most people hit showstoppers for their respective domains when looking at each database, with just one or two as serious candidates.
03:02replacato begin with I'm thinking multiple dbs (one per recorder) using our big distributed framework to manage them
03:03replacabut in the future, a goal is flexible topologies
03:03cemerickin that case, I presume couch's replication is attractive
03:03replacayeah, at some point
03:04replacai'm mostly interested in the "document" structure versus the normal relational model
03:04replacarelational kills us in I/O
03:04replacacause we basically spread things all around
03:04replacathen we get hammered on joins
03:05replacayeah, at one time I was going in that direction
03:06cemerickoff to bed with me
03:06replacacemerick: g'night. Thanks for the input
03:06cemerickreplaca: good bumping into you; let me know if you have any couch/clutch questions :-)
03:06replacacemerick: will do!
03:12tomojamalloy: http://vimeo.com/18582018
03:15tomojI guess kb macros are more often useful if you write ugly code like that :)
03:19amalloytomoj: pffft
03:21amalloyperhaps 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)))
03:25tomojyeah, I just had things like :x+ from a gloss enum
03:25tomojcould put less opaque things in the enum, but.. eh
03:26tomojor just have a map from the opaque things to less opaque things handy when needed
03:45peterevjanwhat is your favorite unit testing framwork for clojure?
03:49midsjust using clojure.test myself
03:53bobo_peterevjan: take a look at midje
03:56amalloymidje looked really cool to me, and i'm sure it is, but when i tried using it i just got frustrated and gave up
03:57midslazytest also has some fun stuff in the pipe
03:57midslike the test watcher
04:01midsI am using this autotest script to run lein test whenever a file is modified: https://gist.github.com/771550
04:02midswith red/green bar! :)
04:03tomojwhoa thanks for the tput tricks
04:04bobo_that looks nice =)
04:12msapplerhello, is it possible to write a macro which writes another macro and using template with syntax-quote ` inside another template?
04:14msapplermy problem is that the unquote ~ of the inside-template gets evaluated when the outside-template is evaluated
04:14amalloymsappler: yes, it's possible, although usually there's a better way to accomplish your goal
04:15msapplerbasically I had two functions which have functions as arguments for updating/rendering
04:15msappler(defn active [f] {:updatefn f})
04:15msappler(defn rendering [f] {:renderfn f})
04:16msapplernow a lot of my code looks like this: (active (fn [delta component] do-stuff))
04:16amalloymsappler: https://github.com/Raynes/clojail/blob/master/src/clojail/core.clj#L134 is an example of me doing what you're looking for
04:17RaynesOh my. I never thought I'd see the day when that code was being used as an example of something that somebody wants.
04:17amalloy*eyeroll*
04:17msapplerSO I wrote two macros for active and rendering which can be used (active [delta comp] do-stuff) ...
04:17amalloymsappler: okay, with you so far
04:17msapplerand those macros share a pattern so my first macro-writing-macro was born
04:18msappler^^
04:18amalloyah. give me a few minutes and i'll gist how i would do it
04:18msapplermaybe i just paste my example ...
04:20amalloyyeah, please do
04:20amalloyalso, wait, are you just using your macro to avoid writing (fn)?
04:21msapplerhttp://pastebin.com/26YBU1AV
04:23msappleryes as you can see
04:29amalloymsappler: http://pastebin.com/36n4DhDB maybe?
04:32amalloyi 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
04:33msapplerhmm
04:33msapplerthanks
04:33msapplerwhy is he expanding to (apply (hash-map (seq concat ... ?
04:34amalloywhat?
04:34clojurebotwhat is exceptions
04:34amalloyclojurebot: forget what
04:34clojurebotTitim gan éirí ort.
04:34amalloygrr
04:36msapplerwhen expanding (def-function-map-factory active "docs" :updatefn)
04:36msapplerthe `{~~k ~f#} is being expanded to apply hash-map seq concat list .. list ... ..
04:39amalloy{a b} is syntax sugar for (hash-map a b)
04:39amalloythe macroexpansion facility removes that sugar since it's generating code that you won't need to see
04:40amalloy&(macroexpand `{a b})
04:40sexpbot⟹ {clojure.core/a clojure.core/b}
04:40msapplerI see. I thougt when i `syntax-quote it it won't be expanded yet
04:41amalloyum okay i can't actually show that here. but if you macroexpanded a defmacro, that's what it does
04:41amalloy(macroexpand '(defmacro foo [] `{1 2}))
04:41msappler&3
04:41sexpbot⟹ 3
04:41msappler&(macroexpand '(defmacro foo [] `{1 2}))
04:41sexpbotjava.lang.SecurityException: You tripped the alarm! def is bad!
04:42amalloymsappler: sexpbot and clojurebot don't allow various things, including defs
04:42msapplermy repl does ;)
04:42msapplerOkay that was the missing link :)
04:42amalloyindeed, which is why i sent you the defmacro
04:43msapplerthx very much
04:43amalloymsappler: 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
06:15NorritIs there really no way to capture symbols in macros?
06:17shortlordis there any shorter way to filter all non-nil items in a seq than using (filter (comp not nil?) coll)?
06:19mrBlissshortlord: (remove nil? coll)
06:21ChousukeNorrit: There is
06:21shortlordmrBliss: ah, remove! great, thx :)
06:21ChousukeNorrit: ~'sym generates an unqualified symbol within a syntax quote form
06:22mduerksenshortlord, mrBliss: ##(doc keep)
06:22sexpbot⟹ "([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."
06:22mduerksenwould be an alternative where you can even project each item of the coll
06:24NorritChousuke: I will try it out, thx
07:33rrc7czdoes 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..
07:34rrc7czI'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
07:34AWizzArdrrc7cz: you can generate classes with proxy too.
07:34AWizzArdBut using an existing Clojure lib is probably the best thing you can do.
07:37rrc7czAWizzArd: 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
08:00raekconditions uses an ordinary java throwable, so it works pretty well with java
08:01raeka new error system to rule them all is under discussion
08:06raekrrc7cz: with conditions:
08:06raek(defn raising-fn [] (raise :type ::foo-exception, :message "Foo occurred!"))
08:10raek(defn handling-fn [] (handler-case :type ...body... (raising-fn) ...body... (handle ::foo-exception (println "condition occurred: " *condition*))))
08:10dsopconiditions are beautiful
08:10dsopin comparision to stnadard java exceptions
08:10raekhttps://github.com/clojure/clojure-contrib/blob/master/modules/condition/src/examples/clojure/examples/condition.clj
08:11raekas soon my exams are done, I will continue working on this: https://github.com/raek/map-exception
08:12raekwarning: that is not stable.
08:12raekas in, there should be consensus regarding what the new error system should look like, and this is only my exploration
08:13rrc7czsorry guys, I stepped out. Let me read all this stuff and catch up
08:13dsoplooks nice
08:14rrc7czyeah 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
08:14rrc7czmost of the documentation is about simple try/catch, consuming of exceptions, not producing them
08:15rrc7czI 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
08:16schaf_is there anything like a static final constant in clojure?
08:16fliebelWhy can't one make a protocol out of a regular class? In Java, one can implement a concrete class just the same, right?
08:16rrc7czI 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
08:17fliebelrrc7cz: Me to :) I thought about adding it as one of the the things that are false, liek nil and false.
08:17raekrrc7cz: I recognize your thoughts... I agree that error handling is a hole in the language currently.
08:18raekone way could be to use namespace qualified keywords as "error values"
08:18raekbut they cannot have any payload
08:18raekanother way would be records/types, since they are unique types
08:19raekrrc7cz: in your scenario, would it be a problem for your java interop if clojure only had one exception class?
08:20fliebelraek: Why can't a protocol implement Exception?
08:20raek(assuming that the exception object would have a getType method)
08:20raekfliebel: protocols can't implement stuff. you meant defrecord/deftype?
08:21fliebelyea
08:21rrc7czraek: 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
08:21raekwell, subclassing is not ideomatic clojure
08:21raekand def(type|record) was made to be a clojure-y thing
08:21rrc7czin 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
08:22raekeven if Exception would be an interface, you still need the class name at compile time
08:22fliebelraek: 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.
08:22raekwhich rules out redefining the record/type
08:22raekreally?
08:23fliebel
08:23rrc7czyou can only implement an interface
08:23raekI think defrecord, when evaluated at run-time, generates a uniquely named class (with some serial number)
08:24rrc7czException is not an interface
08:24fliebelrrc7cz: Uh? Oh :(
08:24raekyou'd have to write something like (try .. (catch Foo__6456 e ...))
08:24raekand that number would change if you reevaluated the defrecord
08:25raekthe problem is: the jvm does not allow redefinition of classes, and catch clauses require a fixed class name
08:25fliebelraek: I think I need to seriously reconsider my image of Java, deftype, and the rest.
08:26raekhowever, I like the idea of having one map-carrying exception type for use in clojure-land
08:27raekthen the "type" could just be watever that's in the :type key
08:27raekand we can use isa? and derive for "type" hierarchies
08:27rrc7czraek: but how would you propogate it up the call stack?
08:27raekso, this is what c.c.condition does now
08:28raekrrc7cz: by the usual java exception mechanism
08:28rrc7czokay, so it's not actually just a map with-meta :type exception or whatever
08:28raekc.c.condition includes a AOT-compiled exception class
08:28raekwith a fixed name
08:28rrc7czbut it allows a custom payload?
08:28raekyes
08:28raekit carries the map as its metadata
08:29rrc7czso how is your proposal different?
08:29raeknot very much
08:29raekit's more about how it should be used
08:29rrc7czcould you maybe show an example?
08:29raekand making a syntax where you can mix java exceptions and conditions (not my idea either)
08:29raekhttps://github.com/raek/map-exception
08:30raekcondition lets you choose the handler with a dispatch fn, like with multimethods
08:31raekthere has been suggestions for making it able to handle odrinary exceptions as well
08:31raekbut I think these two usages (dispatch-fn and java-integration) should be separate forms
08:31raekI recommend looking at the source - it isn't long
08:32rrc7czso 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?
08:32rrc7czand you'd like to separate that?
08:32rrc7czI'm looking at it now
08:33raekin the github page there's a link to a google group thread
08:33rrc7czk
08:35raekrrc7cz: just pushed a minor addition
08:38rrc7czI 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)
08:38clkleinAre/where there versions of Clojure in which keywords can be applied to 3 arguments?
08:39raek,(:foo {:bar 1} :not-found)
08:39clojurebot:not-found
08:39raekit has been there as long as I can remember
08:39raekthe meaning of it is the same as for 'get', but with the arguments reordered
08:40clkleinraek: That's 2 arguments by my count
08:40raekeh
08:40raeksorry
08:40raekI guess I was counting the "function argument"... :-)
08:45raekrrc7cz: 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
08:46fliebelIf 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.
08:49raekrrc7cz: I intend to add try-map, which is just like try+ but only handles map exceptions. then try+ will be easier to describe.
08:51raek(try+ (throwing-code) (catch ::foo-error ...) (catch BarException ...) (finally ...)) --> (try (try-map (throwing-code) (catch ::foo-error ...)) (catch BarException ...) (finally ...))
08:53rrc7czraek: 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)
08:53raekyes
08:54rrc7czso 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
08:55raek(the change I pushed introcuded 'throw-map' (and the example now uses that one), but 'throw+' is still there)
08:55raekyes
08:56raekthe exception class should really have one getter method for each "common" key of the map: :type, :cause, :message
08:58rrc7czI 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?
08:58rrc7czor I'd have to forgo the sugar and deal with PMEs manually I guess
08:59raekyes, I hope one of them becomes elegant and useful enough to be "official"
09:00raekhttp://dev.clojure.org/display/design/Error+Handling
09:01rrc7czthanks, 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:04BerengalHow do you re-export names from one namespace in another?
11:05tonyl(ns (:use :reload-all ...
11:05tonylI believe
11:07david`is there any easier way to start compojure: https://gist.github.com/84a4f22d8966d0d825dc
11:08raekdavid`: https://github.com/weavejester/lein-ring
11:08david`thanks!
11:09raekI 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:10raek"lein repl" is not made for that case, but it happened to work in a few versions.
11:14fliebelLauJensen: Nice post! 2 questions: Why InnoDB? Any thoughts about voting algorithms?
11:15LauJensenfliebel: No particular reason for InnoDB for this schema, no thoughts on voting
11:15LauJensenand thanks for the compliment :)
11:16raekhrm, blog.bestinclass.dk (a URL I tried at random, since I didn't remember the real URL) points to the ClojureQL site
11:17LauJensenraek: 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:17raekLauJensen: the font in the logo, is it Kontrapunkt?
11:17LauJensenraek: CQL? Yes
11:18raekelegant.
11:18LauJensenblog.* fixed
11:21fliebelDoes 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:21bobo_LauJensen: nice post!
11:21LauJensenbobo_: Thanks :)
11:22bobo_the database optimiser in me screams abit. but thats not realy important for the post =)
11:22LauJensenfliebel: I wrapped JMonkeyEngine once, that was easy because of the tutorials. But just for bitmaps I would say Slick2D is easy to use
11:22bobo_would just make the unimportant stuff take up more space
11:22LauJensenbobo_: What would you optimize?
11:23bobo_i would add indexes, dont think any of your queries use index.
11:23bobo_but its horrible booring with indexes
11:24fliebelLauJensen: I'll check them out. I was thinking about the Java 2D api, and the Clojure OpenGL wrapper myself.
11:26LauJensenfliebel: I mentioned JME because you spoke of a game earlier. If I was building a game, JME would be my first stop
11:26LauJensenI did to a swirly, 3d, bouncing tunnel with Slick2D once, that was easy
11:26fliebelLauJensen: Yes, it's for a game, some point in the future.
11:27LauJensenThen you really dont want to miss JME - Check out their demos
11:27LauJensenThey have great tutorials
11:28fliebelLauJensen: Great :) Shaders and all sound a bit scary, if it's labeled draw_bitmap, it feels more easy ;)
11:28currentBwhat's the best way to conj a single item to a vector stored as a value in a hash?
11:29raekcurrentB: update-in
11:29currentBthanks!
11:29raek,(update-in {:foo [1 2]} [:foo] conj 3)
11:29clojurebot{:foo [1 2 3]}
11:29currentBi really need to memorize the api
11:29raekfliebel has made a clojure quiz...
11:30currentBcool i'll check it out
11:30raekhttps://github.com/pepijndevos/clojure-quiz
11:30fliebelgehe, it hasn't got a web interface yet
11:32currentBno need, thanks :)
11:40duck1123Does anyone know why when using slime with 1.3, I never get traces anymore when I get an error at the REPL
11:43LauJensenSomebody put my post on the frontpage of HN, thanks :)
11:49fliebelLauJensen: Are you sure I can do 2D with the monkey thing, and do it without Eclipse?
11:50fliebel(that someone wasn't me, I only submitted it ;)
11:50LauJensenfliebel: 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:51fliebelLauJensen: That is a strange thing to say, since 3D is merely 2D that looks 3D.
11:51LauJensenYou know what I mean right?
11:52ejacksonevening LauJensen et fliebel
11:52rooneyHi all, can I ask about using clojure with emacs here?
11:52LauJensenEvening el Jackson
11:52fliebelLauJensen: 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:52LauJensenrooney: sure
11:52fliebelejackson: hey
11:52LauJensenfliebel: You can make it look nicer
11:54fliebelLauJensen: At the cost of what?
11:54LauJensenAt the cost of having to model everything in 3d
11:54LauJensen...and then position the camera and models in a wy that it appears to be 2d...
11:55fliebelLauJensen: Okay, not what I want. I chose 2D because it keeps things simple.
11:56rooneygreat, 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:56rooneywhat should I do?
11:57mrBlissrooney: I think swank-clojure is not supported anymore. Use ELPA instead to install clojure-mode, slime and slime-repl.
11:57raekhrm, sounds like you are using the deprecated swank-clojure.el
11:58raek(swank-clojure.el = swank-clojure the emacs lisp file)
11:58rooneyok, so how do I use this ELPA?
11:58raekswank-clojure the clojure project you do want to use
11:58raekthe instructions are here: https://github.com/technomancy/swank-clojure
11:59raek1) install package.el (instructions in the above link)
11:59raek2) M-x package-list-packages
12:00raek3) select clojure-mode, slime and slime-repl by pressing the i key on them
12:00raek4) press x to install
12:00raek5) M-x slime-connect
12:01rooneyok I got the package list, but there's no clojure-mode, no slime, no slime-repl, there's clojure-test-mode though
12:01raekrooney: have you added technomancy's repo?
12:01mrBlissrooney: (add-to-list 'package-archives
12:01mrBliss '("technomancy" . "http://repo.technomancy.us/emacs/&quot;) t)
12:01rooneyI put that to the package.el, right?
12:02mrBlissno, in your .emacs
12:02raekno, in your .emacs file
12:03rooneyI don't have .emacs file, I'm using the emacs-starter-kit
12:03mrBlissrooney: v2 or v1?
12:03rooney(it told me to remove my .emacs file)
12:03fliebelLauJensen: 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:04mrBlissrooney: the emacs-starter-kit comes with ELPA (package.el) and technomancy's repo, so you can skip step 1
12:05rooneyhow do I check the version? I just cloned it, so it should be the latest
12:05rooneyah ok
12:05rooneyso it's M-x slime-connect? Not M-x slime?
12:05raekyes
12:06mrBlissrooney: master is v1 (v2 is a separate branch only for Emacs 24)
12:06raeknowadays, you usually start the clojure instance outside of emacs
12:06raekthis makes classpath handling *way* simpler
12:06raekso, the last step assumes you have a swank server running.
12:06raekrooney: have you used leiningen or cake?
12:07rooneylein swank already works
12:07rooneyanyway, should I upgrade to emacs 24? I'm using 23
12:07raekgood. then you shold be able to connect to that server with slime-connect
12:07mrBlissrooney: no need
12:07rooneyok, cool! slime-connect works
12:08raek(since emacs 24, package.el is included)
12:08raekrooney: happy hacking!
12:08rooneyumm, but no highlighting on the console?
12:08rooneyI mean REPL
12:09raek(add-hook 'slime-repl-mode-hook 'clojure-mode-font-lock-setup)
12:10raekfrom the swank-clojure docs: "Put this in your Emacs configuration to get syntax highlighting in the slime repl:"
12:10rooneymy Emacs configuration, since I don't have .emacs, so the line goes to...
12:11rooney(sorry, very newbie)
12:11mrBlissrooney: starter-kit-lisp.el
12:11mrBlissabove (provide 'starter-kit-lisp)
12:12dakronerooney: 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:12raekSpeculation: 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:13raekah, now i see. it might cause the starter kit to not load, if present... so ignore my previous utterance
12:13rooneyyes, the starter-kit won't load if I have .emacs
12:13rooneyanyway, error in process filter: run-hooks: Symbol's function definition is void: clojure-mode-font-lock-setup
12:14mrBlissrooney: are you sure clojure-mode is installed?
12:15raekmaybe that has to be added after the part that loads clojure-mode
12:15raekyou could try to add it to the bottom rather than the top
12:16rooneyI have this file: ~/.emacs.d/elpa/clojure-mode-1.8.0/clojure-mode.el
12:16rooneythat means it is installed, right?
12:16dakronerooney: it's also recommended to create a ~/.emacs.d/<your_username>.el to put any tweaks in
12:16mrBlissrooney: installed, but not necessarily loaded
12:16dakronewhich will be loaded automatically
12:18mrBlissgood 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:18rooneyok, so I should put the add-hook to rooney.el instead?
12:18rooneyah ok
12:18mrBlissmaybe restart emacs to be sure everything is loaded
12:19dakroneemacs starter kit will load ~/.emacs.d/<username>.el and everything in ~/.emacs.d/<username>/* automagically
12:20dakroneflight leaving, good luck
12:21StartsWithKhi
12:21StartsWithKi think i found a error in clojure 1.3alpha1 when using remove-ns on aliased namespaces http://paste.pocoo.org/show/317723/
12:23rooneyawesome, highlighting works now, thanks dakrone, mrBliss, raek, LauJensen
12:26mduerksenis this intended behavior? ##(-> (sorted-set-by #(< (%1 1) (%2 1))) (conj [1 3]) (conj [2 3]))
12:26sexpbot⟹ #{[1 3]}
12:27mduerksenapparently the comparator is not only used for sorting, but for identified duplicates too?
12:31daleCan 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:33daleBah, 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:34clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
14:02slyrus_ok, who's the guy in berkeley with the CLOJURE license plate?
14:04Null-Ahaha
14:56willtimtest
15:59mduerksenis it possible to fetch a 1.3 release with leiningen? how would i have to set up my project.clj?
16:05churibmduerksen: search for the announcements for 1.3 releases on the gougle group, it is described there.
16:05raekmduerksen: I usually check here: http://build.clojure.org/releases/org/clojure/clojure/
16:29mduerksenchurib, 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:40naeuIs #^"[B" is old syntax for tag metadata?
16:40amalloynaeu: i think you can use ^"[B" now
16:41amalloybut that's still the right tag for boolean arrays
16:41amalloyor byte? i forget
16:41brehautbyte
16:41naeuIt'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:43naeuI guess it just hasn't been updated?
16:44naeucore/slurp and core/spit also use #^
16:45naeuI guess the old syntax is still usable
16:49cheezeydoes anyone know if (do ..) can reorder the execution?
16:50brehautcheezey: its the basic sequential execution operator so i wouldnt think so
16:50amalloycheezey: no, it can't
16:50RaynesI'm pretty sure it can't.
16:50amalloydo you want it to, or are you worried it might be?
16:51Raynes&(macroexpand '(do stuff morestuff lotsofotherstuff wowevenmorstuff))
16:51sexpbot⟹ (do stuff morestuff lotsofotherstuff wowevenmorstuff)
16:51cheezeynope, i don't want it to =p
16:51RaynesIs do a special form?
16:51Raynes&(doc do)
16:51sexpbot⟹ "Special Form: Please see http://clojure.org/special_forms#do&quot;
16:51amalloyRaynes: yes
16:51RaynesDamn.
16:51RaynesIs that even necessary?
16:51amalloyuh...yes?
16:52brehautRaynes: probably not necessary, but id guess it makes it easier
16:52amalloyif you didn't have a compiler-level syntax for "do a, then b", how could you do it with a macro?
16:52brehautamalloy: rewrite into nested functions
16:52Raynesamalloy: Go work on sexpbot or something. Nobody asked you.
16:52Raynes;)
16:52amalloybrehaut: that will mess up your recur, no?
16:53brehautamalloy: i imagine a world of hurt would be involved with doing it nicely without a tail recursive host
16:53amalloyheh
16:53amalloybut you're right, you could probably do it
16:59brehautamalloy: actually, i dont think you would mess up recurs
16:59brehautamalloy: eg (do (loop [a 10] (prn a) (when (> a 0) (recur (- a 1)))) (prn "hello, world"))
16:59brehautcould be rewritten to
17:00brehaut((fn [] ((fn [_] (prn "hello, world")) (loop [a 10] (prn a) (when (> a 0) (recur (- a 1)))))))
17:00brehautacutally, you would obviously ditch the wrapping fn of no args
17:01amalloybrehaut: you've made loop into a compiler-level sequential operator
17:01amalloynot really solving the problem
17:01brehautamalloy: i havent? the loop recur bit occurs before the hello world bit
17:01brehautoh wait, no i see what you mean
17:01amalloybrehaut: your loop has two forms in it, one of which is discarded
17:02brehautanycase yes: can of worms :)
17:02amalloy:)
17:04amalloyprobably you could do it even more easily with let. (let [_ (prn a)] (blah))
17:05brehautamalloy: i think you are right
17:11brehautamalloy: although you could argue that swapping one special form for another is self defeating :P
17:11amalloybrehaut: let* is already special
17:11brehautamalloy: exactly
17:12amalloyso...? we need only let*, not do, to be special, afaict
17:13naeudoes anyone know why (def s (Socket. "localhost" 6666)) throws a connection refused exception?
17:13brehautamalloy: 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:13amalloynaeu: because you don't have a process listening on 6666 yet?
17:14naeuamalloy: hmm, I clearly need to brush up my network programming skills here
17:14amalloynaeu: you're probably looking for ServerSocket
17:15naeuamalloy: so Socket's constructor creates an OS socket & binds to an external socket?
17:16amalloynaeu: it's been a while, but i believe so
17:16amalloy$google java.net socket
17:16sexpbotFirst out of 198000 results is: Socket (Java 2 Platform SE v1.4.2)
17:16sexpbothttp://download.oracle.com/javase/1.4.2/docs/api/java/net/Socket.html
17:18naeuok, 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:11raekmduerksen: from 1.3 on, contrib has been split up into modules
18:22cheezeyclojure namespaces are confusing or something o_o.
18:23naeucheezey: in what way?
18:23cheezeywell when i print out the classpath, my files are there
18:23cheezeybut when i try to use that particular file, it says it can't find it..
18:23cheezeyi think i'm missing something dumb
18:23naeuwhat does the path look like?
18:23cheezeywhat do you mean
18:23naeuand what's the filename?
18:24cheezeyconfig.clj
18:24naeusrc/foo/bar/baz.clj
18:24naeuare you using lein or cake?
18:24cheezeyno X_x
18:24cheezeyi probably should use lein eh
18:25naeuwell, I find it just makes this stuff a lot easier on the outset
18:25naeubut you shouldn't really need it :-)
18:25cheezeywell im just working on a small project
18:26naeustill, unless you're doing something particularly bespoke, it probably makes sense to use one of them
18:26naeuespecially if you want to start pulling down deps
18:26cheezeywell ok,for now
18:26naeubut anyway, that's not solving your problem :-)
18:26cheezeybasically, 2 files, one has (:use [config])
18:27cheezeyboth in the same folder
18:27naeuand how are you setting the classpath?
18:28cheezeyit includes the folder they're in
18:28cheezeyi mean, i can import jar libraries from within the folder so :\
18:28naeuand how are you trying to run things?
18:29cheezeythe non compiling way :x
18:29naeucan you paste the command you're running?
18:30cheezeyit's just $ clj sadf.clj
18:30naeuhmm, what's your definition of clj?
18:30cheezeyit was set up with http://riddell.us/ClojureOnUbuntu.html
18:31raekcheezey: 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:32raek(of course, you don't need to call that "src")
18:32cheezeyyes i have it in there.
18:32cheezeywe're talking about CLOJURE_EXT right :x
18:33naeuraek: cheezey said he was just doing a (:use [foo])
18:33naeudoes that imply that he needs a src/foo.clj?
18:33naeuif his classpath contains the current dir?
18:33raekhe needs some-dir-on-the-classpath/foo.clj
18:34raekif the dir that contains foo.clj is on the classpath, it should work
18:34cheezey>_>
18:34raekcheezey: what is CLOJURE_EXT?
18:35naeuthere's this line from the tutorial he linked to: export CLOJURE_EXT=~/.clojure
18:35cheezeyraek: it defines the classpath for my clojure binary
18:36cheezeyi mean when i go to my repl, i can see my directory by printing out the paths
18:36naeucheezey: do you have any particular reason you're not using lein or cake?
18:37cheezeyno but no reason to not try to fix this
18:37daleI 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:38naeudale: I'm sure the author is happy to accept doc patches ;-)
18:39daleThat's one very possible theory. Another is that it is not very widely used, perhaps because it operates apart from Java exceptions.
18:39raekyep. I feel optimistic again when this has started to get some more serious attention: http://dev.clojure.org/display/design/Error+Handling
18:40daleYeah, I saw that too.
18:40raekcheezey: can you post the stacktrace you get somewhere?
18:40raeksound like it should work
18:41daleI 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:42raekthe jvm requires the class to be hardcoded, so yes. AOT is the only option for making a usable completely new exception
18:42cheezeyraek: http://pastebin.com/t2P8ApJW .. i don't htink it's that helpful though
18:42raek*in catch clauses, the jvm requires...
18:43daleraek: Heh, thanks, that's what I was about to ask for clarification on.
18:46raekI think this is why clojure didn't include an error system from the beginning
18:46raekit's a non-trivial problem
18:48raekcheezey: so if you have your file in /some/path/config.clj, /some/path/ is present in the class path (that you printed)?
18:48daleI'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:48cheezeyraek: yes.
18:50raekthen it should really work
18:50raekstrange
18:51cheezeyoh well. i'll just put them the stuff in the same files
18:51cheezeylike i said, small project, no big deal. just wondering wats up :|
18:51raekdid the directory exist when you started clojure?
18:52cheezeyya
18:52raekyou could alway ugly-hack it in: (add-classpath "file:///some/path")
18:53raekif it starts to work after that, check what the difference between that path and the one you had before was
18:54raekalso, are you sure the path is /some/path/ and not /some/path/*?
18:55cheezeyyep
18:55cheezeylike i said, it can find jars within the same location
18:58raekthat's not the same thing
18:58raeka jar file counts as a "source root directory"
18:59raekso there is probably a * somewhere in you clj script
18:59raekthe classpath should countain one entry for each jar file (possibly using the * shortcut) and one entry per source directory
19:00raekso it looks like you don't have /some/path on your classpath, but instead everything in it
19:03cheezeyi'll have to look into it later again
19:08amalloy&(macroexpand '(fn[]))
19:08sexpbot⟹ (fn* ([]))
19:10amalloy&(macroexpand '#())
19:10sexpbot⟹ (fn* [] ())
19:10qbg&'#()
19:10sexpbot⟹ (fn* [] ())
19:10amalloyis there any particular reason that the latter should have a () in it?
19:10qbgThat is part of the syntax
19:11qbgThe form () becomes the body of the function
19:12qbg&'#(foobar)
19:12sexpbot⟹ (fn* [] (foobar))
19:12amalloyqbg: i guess that makes sense. it kinda annoyed me when i was writing (->> whatever #())
19:15amalloywith the hope that this would result in (fn [] whatever); the extra () doesn't really matter but seems unnecessary
19:19raek(-> whaterver (#(foo %))) is one way of doing it
19:27amalloyraek: that calls the function; i just want to define it and pass it along
19:28amalloy&(macroexpand '(->> whatever (fn []))) works of course, but i would have liked the other way to work
19:28sexpbot⟹ (fn* ([] whatever))
19:56cheezeyquick question, is there a function that appends (instead of prepending) an element to a sequence?
19:56cheezeyinstead of doing 2 reverses with cons
19:57qbgcheezey: Use vectors instead
19:57qbg,(conj [1 2 3] 4)
19:57clojurebot[1 2 3 4]
19:57cheezeyqbg: thnx :d
20:14amalloycheezey: 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:14sexpbot⟹ (([5 6] 1 2 3 4) [1 2 3 4 [5 6]] {1 2, 3 4, 5 6})
20:17qbgMy syntax-rules library now uses itself to define parts of itself.
20:18qbgI feel meta right now...
21:56jk_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:58jk_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:58jk_want to deploy on tomcat
21:59midsjk_: take a look at https://github.com/alienscience/compojure-war-example
21:59jk_mids: ah, great! thanks.
22:00jk_mids: exactly what i was trying to find
22:01brehautanyone where familiar with clojureql?
22:03amalloybrehaut: LauJensen probably is :)
22:03brehautamalloy: i imagine so too. i think he is away though
22:04Raynesbrehaut: There is a #clojureql channel.
22:04brehautRaynes: thanks!
22:31GMTaoI have a "noob" question if that's alright.
22:32GMTaoI'm not quite convinced that my approach is valid, but I seem to have painted myself into a corner.
22:34brehautGMTao: it sure is ok
22:35GMTaoPerfect. 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:36brehautcan you paste your code and sample input an result somewhere?
22:36GMTaoSure, I was typing out the block in question, but that may be easier. One sec.
22:37cheezeyare lists implemented as linked lists?
22:37GMTaoThe 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:37amalloycheezey: yeah, though immutability has some side effects you may not expect
22:37cheezeyamalloy: like wut :o
22:38amalloywell like it's not cheap to add to the end
22:38amalloyonly the front
22:39cheezeyeh, i think the maximum size of the lists will be 1000 anyway
22:39cheezeyoh wait no it won't
22:39cheezeysuddenly i am sad.
22:41amalloycheezey: chill. there's a right way to do it, whatever your goal is
22:41GMTaohttps://gist.github.com/772314 <-- For those interested
22:42cheezeyamalloy: ok so i'd like to represent a lot of text. each line is an element in some list (what kind of list?)
22:42amalloyaha, project euler
22:42amalloycheezey: depends what you want to do with the text. so far, a lazy sequence sounds good, but who knows
22:42cheezeyamalloy: modifcation of text.
22:42brehautGMTao: can you give us an example input ?
22:44GMTaobrehaut: sure, try 7316717653. I'm looking for the dotimes block to return me a list like: (882 126 294 1764 1470 630)
22:44brehautok
22:44amalloyGMTao: just use for instead of dotimes, and don't print the result. or, use ##(doc partition), which is intended for just this purpose
22:44sexpbot⟹ "([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:44GMTaoamalloy: yep, it's a project euler problem, but I'm actually doing it Coderloop instead. :-)
22:45amalloy&(partition 5 1 (map #(Integer/valueOf %) "7316717653"))
22:45sexpbotjava.lang.IllegalArgumentException: No matching method found: valueOf
22:45GMTaoamalloy: thanks! I'll give that a shot now. The println was there for my own sanity, I wasn't hoping to keep it. :-)
22:45amalloy&(partition 5 1 (map #(Integer/valueOf (str %)) "7316717653"))
22:45sexpbot⟹ ((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:46brehautGMTao: if you use for, use the range function
22:46GMTaoamalloy: Wow, how elegant! Thank you kindly, this is exactly what I was hoping for. My clojure skills truly are weak.
22:47amalloyGMTao: well, i've done this problem before :P
22:47amalloythere's an eye-opening description of the Clojure Way to do this somewhere on one of IBM's websites
22:48GMTaoamalloy: 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:48GMTaobrehaut: I'm going to try using for/range first, then I'll use amalloy's solution.
22:49amalloyGMTao: 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:50GMTaoThanks amalloy, I'll take a look after I submit my hack. :-)
23:15amalloyGMTao: 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:28laurusmail