#clojure log - Dec 23 2011

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

0:22 GeoffSK: clojure.data.json - what is the best way to included it in a project (leiningen) ?

0:31 nickmbailey: follow the instructions here: https://github.com/clojure/data.json

0:33 GeoffSK: thanks, but where do i find my pom.xml? I didn't realise i had one.

0:33 oops sorry

0:33 ibdknox: GeoffSK: you just need to add this to your project.clj: [org.clojure/data.json "0.1.1"]

0:34 then do lein deps

0:36 GeoffSK: shouldn't (use 'clojure.data.json) work at the repl?

0:36 nickmbailey: it will work after you added it to your project.clj and then ran 'lein deps'

0:38 GeoffSK: yep works thanks. clooj doesn't always seem to respond after doing a lein deps.

0:38 Raynes: amalloy: Hi.

0:38 nickmbailey: hmm haven't used clooj

0:39 GeoffSK: pretty limited dedicated clojure editor

2:07 devn: it has promise

2:07 i hope they continue to expand it

4:33 tsdh: How can I fire up a SLIME REPL in clojure itself? M-x clojure-jack-in relies on an existing project.clj...

4:33 sandy1986: tsdh: simply start clojure.jar with java?

4:34 tsdh: sandy1986: That gives me a REPL at the console, but not in emacs.

4:34 sandy1986: ahhh okay, I do not use emacs

4:34 G0SUB: tsdh: you can use swank-clojure to start a swank server. emacs can then connect to it.

4:36 tsdh: G0SUB: How would I do so? Or the other way round, it's probably easier to create a project.clj with no deps and stuff, isn't it?

4:36 G0SUB: tsdh: take a look at the embedding section in here - https://github.com/technomancy/swank-clojure

4:37 tsdh: G0SUB: Thanks.

4:37 G0SUB: tsdh: you are welcome

4:41 Raynes: I'm not sure how useful a SLIME repl is without an associated project.

4:48 tsdh: Raynes: Well, the project is clojure.

4:50 G0SUB: Raynes: he is just not using Lein.

4:53 sandy1986: How to read the json string from a request? (JSON & HTTP_POST)

4:55 tsdh: G0SUB, Raynes: Not "he", clojure itself is just not using leiningen. ;-)

4:55 G0SUB: tsdh: true ;-)

5:40 sandy1986: Mhhh, JQuery + Json drive me insane

5:43 Raynes: cemerick: Surely you're not up *this* early.

5:43 cemerick: I'm up at 5 most mornings.

5:43 Raynes: Man.

5:43 Get off my lawn.

5:44 cemerick: Surely you're not *still* up *this* late.

5:44 Raynes: I woke up at 11PM.

5:44 cemerick: I don't even know what to say to that.

5:45 Raynes: "Get a life." is appropriate.

5:45 cemerick: Hrm. Might be a little harsh.

5:46 G0SUB: cemerick

5:49 cemerick: G0SUB: Hi! :-)

5:49 G0SUB: cemerick: how's business?

5:49 Raynes: G0SUB: You took some amazingly unflattering pictures of me at the Conj. We are no longer friends.

5:50 cemerick: We'll find out in the next month or so. Probably 50% of revenues are in January.

5:50 G0SUB: Raynes: oh, that was entirely unintentional :-P

5:50 cemerick: cool

5:50 Raynes: :p

5:50 G0SUB: Raynes: next time, you tell me which angle to pick. Ok?

5:51 Raynes: The one where my manboobs aren't showing.

5:51 cemerick: G0SUB: as a corollary, selling software sucks.

5:51 G0SUB: Raynes: haha. I will airbrush those out if they come into the frame next time.

5:52 Raynes: Excellent.

5:52 G0SUB: cemerick: get someone else to do that.

5:54 cemerick: G0SUB: Can't outsource customer contact. It's the most valuable commodity.

5:54 Nah, I just need to flip the switch on a different business model.

5:55 G0SUB: cemerick: get a non-technical co-founder.

5:55 cemerick: you hack, he hustles.

5:56 cemerick: it'd probably be the other way around :-P

5:56 G0SUB: :-P

5:57 Vinzent: if I compile cljs file like this $ cljsc src/repl/test.cljs '{:optimizations :simple}' then I'm getting pretty long js code, but if I omitted optimizations part, get only couple of goog.addDependency calls

5:57 what could be the problem?

5:57 cemerick: G0SUB: How are you guys doing?

5:57 G0SUB: Vinzent: that's right. there is no problem with that.

5:57 cemerick: launch imminent.

5:58 Vinzent: G0SUB, really? So I always have to compile with optimizations?

5:58 G0SUB: Vinzent: your production code should be compiled in advanced mode. for dev, you can leave it off.

5:59 Vinzent: when in no optimization mode, remember to include goog/base.js. you don't need that in simple or advanced.

5:59 Vinzent: everything else should just work

6:00 cemerick: G0SUB: Stellar. Go get 'em. :-)

6:00 G0SUB: cemerick: PM?

6:00 cemerick: sure

6:01 G0SUB: apparently I can't do PM in Adium.

6:01 wtf

6:02 cemerick: irc through adium?

6:02 G0SUB: cemerick: temporary arrangement

6:02 Vinzent: G0SUB, indeed, it works. Thank you.

6:03 Blkt: good day everyone

6:03 G0SUB: Vinzent: go and hack some Cljs!

6:07 Vinzent: G0SUB, hah, right :) but I'm still setting up my dev env, can you advise me something else what I should use?

6:08 G0SUB: Vinzent: browser-repl.

6:08 Vinzent: ibdknox's one?

6:09 As I understand, it's a standalone repl, and I use emacs

6:09 G0SUB: Vinzent: no. it's in cljs core now.

6:10 Vinzent: https://github.com/clojure/clojurescript/wiki/Emacs-%26-inferior-lisp-mode

6:10 Vinzent: https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments

6:10 Vinzent: ah, yeah, I use it already

6:11 https://github.com/ibdknox/cljs-watch this one seems useful too

6:11 G0SUB: Vinzent: yes, it's great. but it can't handle no-optimization mode. it does either simple or advanced.

6:12 Vinzent: use my fork if you want to use cljs-watch with no optimizations - https://github.com/ghoseb/cljs-watch

6:13 Vinzent: G0SUB, great, thanks, I'll check it out!

6:14 G0SUB: Vinzent: I haven't fixed the shell script, just the code. so fix the shell script accordingly, please.

6:15 Vinzent: ok

6:17 by the way, why there is no lein plugin for that? lein cljs install, lein cljs repl and lein cljs watch would be much nicer than a bunch of shell scripts

6:17 G0SUB: Vinzent: those things should exist. just not right now.

6:18 Vinzent: I see - cljs even have not been released yet

6:20 tsdh: On JIRA, is there no way to get a listing of all issues where I have done something? I tried searching for Tassilo with [x] for Summary, Description, Comments, and Environment, selected "Any project" and "Any" type of issue, but I only get empty results...

6:33 Hm, what's the right way to close a JIRA issue that's actually a non-issue, i.e., the reported bug is no bug at all but a misunderstanding on the reporter's side?

6:34 Neither Completed, Declined, nor Duplicate seem appropriate. And what should I specify as Fix versions when there's no fix. Empty, I guess?

6:35 CmdrDats: tsdh: it depends on what you've adopted as 'the right way', for me it would be to assign the task to the reporter with a comment, then have them resolve/close it as 'won't fix'

6:36 tsdh: CmdrDats: The reporter is the assembla importer. ;-)

6:39 CmdrDats: tsdh: ah :)

8:50 elricl: Hello

8:51 Is there a way to control the heap size a clojure script?

8:51 Something similar to -Xmx64m for clojure?

8:53 pyr: elricl: -Xmx64m

8:53 any option you pass to the jvm

8:53 will be applied

8:54 elricl: I run my files as clojure xx.clj

8:54 pyr: ok

8:54 clojure is probably a shell script

8:54 and probably knows about env variables such as JAVA_OPTS or JAVA_OPTIONS

8:59 `fogus: Has anyone written a node-connected REPL for ClojureScript?

9:26 ambrosebs: how can I get a seq of all classes defined in the java.lang.* namespace?

9:28 rallie: (java.lang)

9:29 sorry, that was meant for a repl

9:30 ambrosebs: I'm trying to get a seq of all the implicit imports in a clojure namespace, which I believe is just java.lang.*

9:33 perhaps an easier problem would be to work out which classes clojure.core imports

9:42 ,(into {} (filter #(re-seq #"java.lang.*" (str (val %))) (ns-imports 'clojure.core)))

9:42 clojurebot: {ProcessBuilder java.lang.ProcessBuilder, Enum java.lang.Enum, SuppressWarnings java.lang.SuppressWarnings, Throwable java.lang.Throwable, InterruptedException java.lang.InterruptedException, ...}

9:42 ambrosebs: seems to work

10:08 is :exclude the only valid :refer-clojure option?

10:19 jodaro: ambrosebs: looks like refer takes :exclude, :only and :rename

10:20 ambrosebs: jodaro: where'd you find that out?

10:20 Raynes: ambrosebs: Documentation, I imagine.

10:20 ambrosebs: oh right, refer's docs

10:21 Raynes: Clojure has these cool docstring thingies.

11:14 tmarble: O

11:14 I'm stuck with a simple routing question in Noir... keep getting "Key must be integer" from compojure...

11:15 This is a very simple app based on noir:jar:1.2.2-SNAPSHOT

11:15 I can't seem to construct the form: (defpage user [:get "/user/:id"] {id :id}

11:16 w/o getting a stack trace??

11:16 lazybot: tmarble: Definitely not.

11:18 TimMc: Christ, I've got about a 5 second latency. I feel like brehaut.

11:18 Stupid train wireless.

11:25 Raynes: tmarble: If there isn't a stacktrace then how are you seeing that error in the first place?

11:26 tmarble: Raynes: sorry, I mean I cannot reformulate it without a stack trace => I'm getting one every time

11:26 Raynes: tmarble: The problem is probably the 'user' bit there.

11:26 (defpage "/user/:id" {id :id} ..)

11:26 tmarble: Try that.

11:27 It defaults to a GET request.

11:27 So no need to specify the method.

11:27 tmarble: right.. tried that.. same result

11:28 Raynes: Can you paste the whole defpage along with the stacktrace?

11:28 On gist.github.com.

11:28 tmarble: right, hold on

11:32 Raynes: please see https://gist.github.com/1514675

11:32 Raynes: I see the problem.

11:33 tmarble: That vector wont work. The defpage has to return a string. You can generate an HTML string from that [:div ..] vector using hiccup.core/html, or by creating a defpartial as explained here: http://webnoir.org/tutorials/html

11:34 Well, a string or a map. In this case you just want to return a string. Compojure sees that it isn't a string and assumes it is a map, and thus when it tries to work with the map, it fails with your vague exception.

11:40 tmarble: Rayne: thanks! removing the hiccup stuff worked (using it within (html ...) has some ns error ... looking now)

11:40 Raynes ^

11:50 Raynes: ok, my mistake was in expanding the example on http://webnoir.org/tutorials/routes to use just hiccup (thus resulting in the behavior you describe)

11:51 when the other tutorial examples are wrapped in (common/layout ....) or (common/site-layout ... )

11:51 which, themselves, call (html5 ... content)

11:57 triyo: I'm a bit baffled as to what approach to take when introducing configuration to my clojure application.

11:58 My requirements are as follows. I have an entry point -main that receives command arguments

11:59 The top-level of the app is an web application (ring) that has some routes and handlers. The handlers call some namespace that contains persistence level logic that performs the db side effects.

12:01 Question is, what approach do I take, for instance, to pass environment-specific db connection info?

12:02 In a simple functional approach, I could have all my functions down the abstraction take a config argument..

12:02 But this of course has its own drawbacks

12:03 I could maybe go for some sort of a macro like with-config... But how will this work through different layers?

12:10 I see Chas wrote some cool post on this topic not so long ago: http://cemerick.com/2011/10/17/a-la-carte-configuration-in-clojure-apis/

12:10 tolstoy: Is there a handy unsigned-bit-shift-right floating around anywhere, written in Clojure?

12:10 tscheibl: triyo: you could create the macro "with-config" which binds the config to a thread local var using binding

12:12 triyo: tscheibl: could you please refresh my memory. Can a `binding` be performed so that it binds over multiple namespaces in the call stack?

12:12 tscheibl: triyo: to "transfer" the binding to your ring handler you will have to introduce a middleware that uses bound-fn

12:13 triyo: the bound var will stay in it'S namespace

12:13 its

12:13 triyo: So thats the first hurdle. Thanks. But then to transfer from handler to else where, do I have to do it explicitly with an with- type macro?

12:13 Well thought as much

12:14 tscheibl: triyo: use bound-fn

12:14 triyo: thats the uglish part if I may say.

12:14 Ok I'll have a loo at bound-fn

12:14 tscheibl: i did it that way first

12:14 but

12:15 in a single web-app there will normally be only one config for the whole app... so you can omit the with-config part

12:15 what I do now...

12:16 ..is to read the config into an atom defiined like (def (atom nil))

12:17 and read in like: (reset! config (read-string (slurp (file-or-resource (System/getProperty "backoffice.config")))))

12:18 you see I use a Java system property to configure the config path outside .. in this case backoffice.config

12:18 file-or resource is defined like: (defn file-or-resource [path] (or (io/resource path) (io/file path)))

12:18 so I can use it either standalone or in a Servlet context

12:19 triyo: Hmm, if I go that route, I need to make sure it loads the file only once for when the process starts.

12:19 tscheibl: yes

12:20 i define a function (load-config!) which is executed from the startup code

12:20 triyo: app is a rest service that is gonna be under considerable fire so need to minimize loacl fs and db IO as much as possible ...

12:21 tscheibl: ... of course you could change the config at runtime since it is an atom and use watchers to notify ore app of the change

12:21 just call (load-config) again to do that

12:21 triyo: Thanks for that last tip on watchers... that could be useful so no surprising side effect

12:21 *s

12:22 So you load the .conf file in to a atom right?

12:22 And atom will be bound to only a single ns right?

12:23 If thats true, I'd have to call load-config in each ns where appropriate right? Would this be on each web request though?

12:24 * triyo is thinking that state monad might actually finally be useful ;-)

12:24 tscheibl: no

12:24 cemerick: triyo: Note that what I describe there is *not* what I eventually settled on in clutch.

12:25 tscheibl: u include the config with (ns ... (:use [....config :only [config]]))

12:25 and refer to it as config

12:25 triyo: cemerick: Thanks, noted.

12:25 cemerick: If you look at clutch/master, you'll see what's currently going on.

12:27 triyo: cemerick: I'll have a look. If possible in a sentence or two maybe just to describe what route you took thats different to what you contemplated in your post?

12:28 cemerick: Accomplishes the same thing, but uses a slightly smarter defn-wrapping macro. Thus, pitfall #3 is avoided.

12:28 https://github.com/ashafa/clutch/blob/0.3.0/src/com/ashafa/clutch.clj#L60

12:29 tscheibl: .. I do use the "with" paradigm quite often in my code... but imho it's too much boilerplate code for a global config

12:30 and having the config as an atom (state) it gives you the advantage of beein easily reloadable

12:34 .. and you don't have to use bound-fn or create your own special purpose macro for that...

12:34 ... but then it's an evil global ;)

12:35 triyo: cemerick: Ok it took me a little while to figure out but I get it now and how wih-db* wraps the call and passes an implicit db arg.

12:35 cemerick: doesn't seem like it took you too long :-)

12:37 pandeiro: cemerick: is there a way to test that the clojure view server is installed and working other than just getting the couchdb config and parsing that and testing a query?

12:37 triyo: cemerick: I'm to rusty on the Clojure front. Its been more then a year since active use, unfortunately. But I'm back, we got some great work that Clojure fits well and should keep me busy for quite some time to come. :)

12:39 cemerick: pandeiro: If you can get away with it, you can just clobber the view server config every time your app starts up.

12:39 pandeiro: cemerick: k i figured as much, i will just do that

12:40 cemerick: If you want to be more careful, yes, you need to access the couchdb config, and somehow make a decision as to whether it's "correct".

12:40 triyo: tscheibl: Global vars or implicit fn arg via a smart with- fn/macro... Hmm, the choice is yours :)

12:40 cemerick: I've no idea how you could make that determination though.

12:40 triyo: sounds good :-)

12:40 pandeiro: cemerick: seems like a 3 step process - parse the config, throw up a test view and doc, and query it

12:40 but it's overkill for a little demo app so i will just clobber te config every time app starts

12:41 tscheibl: triyo: my main reason to use the statefull approach with the config was the dynamic reloadabilty

12:41 although it may not be that functional...

12:42 cemerick: pandeiro: really no reason not to. Once you *do* have a reason not to, you should probably be using a deployment process more sophisticated than the view server config fns in clutch.

12:43 tscheibl: ... but it's quite convenient in an inherently multithreaded web-app

12:43 triyo: tscheibl: Well thats the tradeoff I guess. In my case reloading is not desired at all so the functional route for me may very well be more suitable. I'm also thinking what the effect on composability are, if any...

12:45 oh and testability of course.

12:46 tscheibl: triyo: the "with" approach doesn't keep your code from knowing where (which namespace) to get the config from....

12:46 so composability isn't tht much enhanced

12:47 sure you could write a getter function... but you will also have to refer to it via it's namespace

12:47 its

12:47 arghh... I do always mix it's with its

12:48 triyo: I know which you mean :)

12:48 pandeiro: tscheibl: you and 95% of every blog post that shows up on hacker news

12:59 triyo: If I take the with- + defnc (defn with conf) approach, I still have to battle with: how do I carry the cofig from -main to moustache/ring. I have to think about part like (delegate h/consumption ss ts d u) where delegate macro passes HTTP request on to the handler function h/consumption.

13:00 Beyond that, things do look rosier

13:00 krey: Hi ;)

13:02 https://gist.github.com/1514936

13:02 I like to write a "with-req-body" ;)

13:03 which takes the code as a parameter and executes it where "parse-stream buf true" is

13:07 tscheibl: pandeiro: it's not that I didn't know the difference :) ... it's just that I don't write much except program code ...

13:08 .. and I type too fast with only 2-6 fingers.. never managed to learn it with all 10 during about 30 years of coding

13:08 .. but it easily leads to typing errors

13:10 I honestly never felt the need to learn it because when I code I work with my brain most oft the time and only type it in when it works inside my head

13:11 ... I'm not a secretary ;)

13:11 ..although the REPL changed that a bit...

13:54 sbryant: I'm trying out clojure with leiningen as my build + dependency management tool and I cannot for the life of my figure out how to access any dependencies. Keeps telling me things aren't in the classpath but lien classpath gives me what I'm looking for

13:54 p.s. using lein swank for slime integration

13:55 Which involved going from CVS to elpa (yay) but made me turn off slime fancy (boo but understandable)

13:56 The dependency I'm trying to work with is the penumbra lwjgl wrapper library

13:59 aaelony: sbryant: not sure, will this help? http://clojars.org/penumbra/lwjgl

14:00 sbryant: Is that different from penumbra?

14:01 aaelony: try it, dunno

14:01 sbryant: sure thing

14:12 tolstoy: Trying to match (in Clojure) whatever CRC16 they're using in Boost/C++: not a lot of fun. ;)

14:34 Kvaks: What the best way to install Clojure and SLIME from scratch? I've spent an hour messing around, and ended up with bits and pieces from various sources such as ELPA, Git, Ubuntu repos and leinigen. I think I should just start over and find the pieces that work together better.

14:35 Vinzent: Kvaks, 1. install leiningen. 2. install clojure-mode, slime, slime-repl from the elpa

14:36 Kvaks: Alright, thank you!

14:38 sbryant: Just out of curiosity should the dependencies be present in loaded-libs?

14:38 jcromartie: so I've had a Linode server running a Compojure web app from a REPL for a few months now, really no idea how long, but it's just kept running with no issues… so long-running Clojure processes look like they work OK :)

14:39 it's never been restarted

14:49 ibdknox: cool

14:49 most of my sites are running off of lein run

14:57 tscheibl: ^^

14:58 pandeiro: ibdknox: where would you stick a noir configuration file, in the project root?

14:58 ibdknox: pandeiro: usually, yeah

15:02 tscheibl: ibdknox: would you consider to make it possible to exclude the jetty dependency via leiningen? I'm using aleph because I need asynchronous io and I have to carry these unneeded dependencies with me. I usually slove this kind of problem in my libraries by requiring the excludable dependency in code just before I need it (if I need it). This saves you from splitting up the project in multiple jars to make it modular (like ring does)

15:03 ibdknox: in noir...

15:06 tauntaun: I'm about to write a web app. Any recommendations other than for Compojure?

15:06 tscheibl: noir

15:06 Tharem: Hi, could someone help me implement assoc for a deftype? I'm trying to make a 2-d array and would like to be able to use assoc to change specific fields.

15:07 tauntaun: tscheibl: reasons?

15:07 tscheibl: tauntaun: it's built upon compojure but saves you a lot of boilerplate code

15:08 ibdknox: tauntaun: also it has lots of stuff to get you started: http://www.webnoir.org

15:08 tscheibl: tauntaun: ... but doesn't take away the flexibility of compojure

15:08 Tharem: The code I've writted so far is here: http://pastebin.com/tSZ1PF4s, but it complains about not being able to find assoc in the interfaces...

15:08 bweaver: Tharem: Could you use `defrecord` instead of `deftype`? It supports `assoc`.

15:08 tauntaun: ok, thanks...

15:09 tscheibl: ibdknox: have u read my former request?

15:09 ibdknox: tscheibl: is there some downside to having that dependency that I'm not aware of?

15:09 Tharem: Hmm, I could, but I'm trying to make it do the following: (assoc game-map [3 3])

15:09 tscheibl: ibdknox: well.. it makes the standalone jar bigger

15:09 Tharem: and I'm not sure how to implement that on a deftype either

15:09 ibdknox: tscheibl: is that actually a problem in practice?

15:10 tscheibl: ibdknox: jetty is quite big and I like to run my stuff on small arm devices

15:10 ibdknox: I see

15:10 tscheibl: embedded stuff

15:10 bweaver: Tharem: Oh, sorry then. I'm new to Clojure but a defrecord would get you `(assoc game-map :xdim 3 :ydim 3)`. Dunno how to boil away the field names from that.

15:11 ibdknox: tscheibl: add an issue for it on github :)

15:11 tscheibl: ibdknox: :)

15:11 Tharem: Nah, that could work, but how do I then get it to look in the appropriate cell? I'm currently using a vector to store the data

15:12 ibdknox: Tharem: why are you hijacking assoc? Why not just write your own function?

15:12 what you described doesn't have the semantics of assoc, it's something else really

15:12 Tharem: That's also an option, but I figured that I could save myself a headache if I could just have a 2-d vector behave like a 1-d one

15:14 And it does have the semantics of assoc, but instead of using a single key, it uses 2 keys contained in a vector. Or 2 keys separately, that doesn't matter.

15:14 I just need a way to assoc something using 2 keys

15:14 bweaver: Tharem: After looking at the code in your pastebin I see you're trying to do something different than I thought. I can't quite tell what the `assoc` you have written now is supposed to be doing.

15:15 ibdknox: you could use a sorted map with vectors as keys

15:17 Tharem: The idea is rather simple: I've got an n-by-m vector, which I would like to index using an x and an y value. I'm currently using a built-in vector and translating the x and y vector by (+ x (* y y-length))

15:17 That value is then used to index the vector

15:17 erm, (+ x (* y x-lenght)) I mean

15:18 bweaver: ok

15:18 Tharem: I'm just not sure how to tell clojure to do that. I could use a separate function to index a 2-d array, but I'd prefer using assoc to keep it consistent with the rest of clojure

15:23 jsnikeris: Hi all, I'm working on a formatter for namespace forms. Which output would you prefer for namespaces with long names: http://pastebin.com/cT2A3uWw

15:23 ibdknox: jsnikeris: B

15:25 jsnikeris: Hmm, ya the more I think about this, the problem isn't just namespaces with long names. It also applies to long ":only" lists

15:28 I guess you'd prefer B here too: http://pastebin.com/M57F1RVL

15:28 ibdknox: definitely

15:29 tscheibl: ibdknox: put that on github as an issue

15:29 I've put that...

15:29 ..sry I'm not native

15:30 ibdknox: tscheibl: okidoke, I'll probably fix it shortly for 1.3-alpha(somenum)

15:30 tscheibl: no worries :)

15:30 tscheibl: ibdknox: thx would be awesome :)

15:30 ibdknox: tscheibl: Sind Sie Deutsch?

15:30 tscheibl: ibdknox: Österreich (Austria)

15:30 ibdknox: ah

15:30 tscheibl: ibdknox: but we almost speek german ;)

15:31 ibdknox: haha

15:31 tscheibl: is Clojure being used much over there?

15:32 tscheibl: ibdknox: dunno ... I'm on no lokal IRC channels orforums...

15:32 local..

15:32 ibdknox: tscheibl: do you just use it for side projects?

15:33 tscheibl: ibdknox: nope.. it's my main programming language since about a year

15:33 ibdknox: I'm even using ClojureScript by now

15:33 ibdknox: :)

15:33 tscheibl: how's that working out for you?

15:34 tscheibl: ibdknox: It saves you quite some time when you don't have to switch programming languages all the time in a web project...

15:34 ibdknox: browser differences are hard enough to handle...

15:35 Tharem: In case someone's still interested, I found the solution: http://pastebin.com/KQ829qua

15:35 tscheibl: ibdknox: after solving some problems with the setup it's quite convenient to work with

15:36 deech: Hi all, can someone point me to a resource that compares Clojure's Java interop with ABCL's?

15:36 ibdknox: tscheibl: cool, are you using any CLJS libs?

15:36 tscheibl: ibdknox: hiccups

15:36 ibdknox: maybe soon "match" from dnolen

15:36 or was it matcher?

15:37 ibdknox: match

15:37 bweaver: Tharem: You beat me to it :) http://paste.lisp.org/display/126668

15:37 tscheibl: ibdknox: I've integrated all the clojre and clojurescript compiling stuff with eclipse, ccw and custom builders

15:38 bweaver: Tharem: It's interesting, I hadn't looked at protocols with deftype yet. It's pretty cool stuff.

15:38 tscheibl: ibdknox: ..and use a slightly extended lein-clojurescript from the custom builder

15:39 Tharem: Hmm, does your code work? For me it gave errors with Associative, so I used IPresistentVector

15:39 ibdknox: tscheibl: nice! You should share your workflow with the CCW guys, I bet they'd be interested in seeing how you did it

15:39 bweaver: Tharem: Yeah, using Clojure 1.3

15:39 Tharem: Oh yeah, yours works too

15:39 tscheibl: ibdknox: no prob... took me quite a while to figure it out .. so it could be uf use to others

15:40 Tharem: now I just have to make it so that it doesn't crash the repl when it tries to print a game-map XD

15:41 tscheibl: ibdknox: I've even managed to combine all the clojurescript stuff smoothly with jquery and jquery-mobile

15:42 ibdknox: tscheibl: how'd you do that? an externs file?

15:42 tscheibl: ibdknox: mainly because of jquery-mobile for the UI

15:42 ibdknox: yep

15:42 ibdknox: there are official ones for jquery

15:43 ibdknox: all the other things I need I try to use from the closure library

15:44 ibdknox: tscheibl: like?

15:44 tscheibl: ibdknox: cookie stuff ... crypto hashes .etc

15:44 ibdknox: but not the UI

15:44 ibdknox: yeah

15:44 tscheibl: ibdknox: that's too cumbersom in google

15:45 ibdknox: from what I've seen the UI stuff really sucks

15:45 tscheibl: ibdknox: you name it :)

15:46 ibdknox: the google closure library seems to be quite inconsistent in a lot of places...

15:46 ibdknox: tscheibl: very much so, that's why I started wrapping it :)

15:46 tscheibl: pinot...

15:46 ibdknox: yeah

15:47 tscheibl: ibdknox: I tried to use that too but actually couldn't utilize much of oit because of my jquery-mobile thing

15:48 ibdknox: so I coded the remoting by myself.. but more resty

15:48 ibdknox: I use GET and POST

15:48 deech: I am having trouble setting up SLIME to work with Clojure. I already have a "lein swank" running on port 4005, when I connect it immediately disconnects with a RuntimeException.

15:48 ibdknox: tscheibl: how do you know which to use?

15:49 deech: I have a SLIME config for SBCL and ABCL, I don't want to have to hose those.

15:49 dnolen: deech: have you tried clojure-jack-in provided by clojure-mode ?

15:50 tscheibl: ibdknox: I use get when I need to fetch some data .. if i need arguments for the call they get passed as url parameters.... the jquery ajax call does that automatically... works even with array and maps

15:50 deech: dnolen : Trying that now.

15:51 tscheibl: ibdknox: I use POST when I INSERT or UPDATE things in a CRUD kind of thinking

15:51 ibdknox: ahh yes and also DELETE .. when I delete record

15:51 ibdknox: tscheibl: and what does the client-side code look like?

15:52 tscheibl: ibdknox: the calls are not dispatched from a map like you do.. they are all separate resources..

15:52 ibdknox: i'Äll set up a gist .. mom

15:53 deech: dnolen: I get "error "Could not start swank server: That's not a task. Use \"lein help\" to list all tasks."

15:54 sbryant: deech: you need to install swank-clojure

15:55 tscheibl: ibdknox: https://gist.github.com/1515333

15:55 sbryant: which can be done via plugin install or project dependency

15:55 then you'll be able to jack in

15:55 ibdknox: tscheibl: I see, so you provide the URL.

15:55 tscheibl: cool stuff

15:56 sbryant: and it looks like penumbra is clj 1.3.0 only :(

15:56 tscheibl: ibdknox: jquery automatically encodes the data either as url parameters or form encoded depending on the request type

15:56 ibdknox: yeah

15:56 tscheibl: ibdknox: you could also send it as clojure datastructures with some jwuery ajax option

15:57 ibdknox: you could possibly wrap this in some fancy macro.. but I think it wouldn't spare you much

15:57 ibdknox: tscheibl: it looks like you might have a bug, line 15 should be on-error, right?

15:57 deech: sbryant: I'm trying that now.

15:57 sbryant: deech: let me know how it goes

15:57 this is my first time with clojure

15:57 and that got me too

15:57 I have to keep repeating Clojure is not Common Lisp

15:57 tscheibl: ibdknox: ahh thx... just added this 30 minutes ago or so

15:58 ibdknox: error handling comes last :)

15:58 ibdknox: :D

15:58 tscheibl: ibdknox: clients want to see something...

15:58 sbryant: I have no asdf or systems to tell me where all of this code is

15:58 tscheibl: ibdknox: they don't pay me for error handling :)

15:58 ibdknox: haha

15:58 true

15:58 sbryant: and I don't really know java, so it gets pretty damn confusing

15:58 Tharem: Clojure doesn't happen to have a built-in function to make a vector of a specified length?

15:59 Borkdude: Tharem: of what use would that be?

15:59 deech: sbryant : I have swank-clojure.jar installed but I think I need to include that in my .emacs file. I have other CL's configured for SLIME and I'd rather not have to hose those. How did you get SLIME to connect?

15:59 sbryant: Ah

15:59 Are you using CVS slime?

16:00 Tharem: Say I want to make a vector containing, initialy, only zeroes, which can be used for assoc

16:00 deech: sbryant: Yes

16:00 sbryant: Okay, kill your checkout

16:00 and use the elpa versions

16:00 Tharem: I know how much space I need, just not what to put in it when the vector is created

16:00 Borkdude: Tharem: you can use repeat for it, to create a seq of the same elements n times

16:00 sbryant: I don't know why maybe technomancy can fill in the details but the clojure-swank requires a certain version of slime

16:00 Tharem: Ah thanks

16:01 That's what I was looking for

16:01 Borkdude: Tharem: and you can use vec to make it a vec

16:01 sbryant: Also remove your slime setup configuration lines

16:01 Borkdude: ,(vec (repeat 10 0))

16:01 deech: sbryant: Does that mean that SLIME will quit working with SBCL etc?

16:01 clojurebot: [0 0 0 0 0 ...]

16:01 sbryant: so no (slime-setup '(fancy))

16:01 No

16:01 autoloads will take care of setting up slime

16:02 which elpa installs

16:02 so install slime and slime-repl from the package list

16:03 deech: sbryant: Ok, I'll try that. I'll have to install ELPA first :)

16:03 sbryant: If you're feeling daring try out the latest emacs 24 pretests

16:03 they have elpa already installed

16:03 so you can install clojure-mode, slime, and slime-repl from the same place

16:04 Do the normal thing and add the marmalade repo.

16:13 Tharem: Does anyone happen to know what interface a deftype needs to be printable on the repl?

16:15 tscheibl: Tharem: have you ever had a look at https://github.com/david-mcneil/defrecord2 ?

16:17 yaron-2342: What exactly is the object I get when I call agent-error on an agent? It's not a throwable because I get a cast error when I try to throw it.

16:18 Tharem: Hmm, maybe I should indeed use a record instead of a deftype. I originally picked deftype because I didn't need the functionality provided by a record (or needed to overload it anyway).

16:18 ibdknox: you probably don't need either :)

16:20 Tharem: ibdknox: True, but then I'm going to have to define a lot of functions that do conceptually the same thing as functions that are already built-in

16:21 And working with records is childishly simple if I could just find an overview of what interface does what XD

16:21 joegallo: Tharem: pretty sure you just need to overload toString from java.lang.Object -- maybe

16:22 ibdknox: depends on how you represent your data in the beginning. What if you represented your board as a map, instead of nested vectors? Then you wouldn't need anything special at all

16:23 that may not be the right thing to do (I'm not sure what you're doing :) but it's something to think about

16:23 Tharem: True, but every cell is going to be occupied by something

16:23 yaron-2342: O.k. now my head hurts. When I try to throw a value from agent-error inside of a function it fails with a cast error. But when I Try to throw it from inside the repl it's fine. ARG!

16:24 Tharem: and that means a map would add a huge amount of overlap. Plus, I already know how to work with maps :P

16:24 overhead*

16:25 yaron-2342: Oh, o.k. it is an exception. I just had a typo. Phew!

16:26 It's at times like this I really wish Clojure had types.

16:26 Tharem: You can add type hints if you need them

16:28 yaron-2342: But they don't seem to be enforced. E.g. I will put in a type hint saying something is supposed to be a map, send in something that isn't a map and Clojure is perfectly happy. My (probably wrong) understanding is that type hints are only used to avoid reflection in Java. Am I confused?

16:29 joegallo: I think in that case you are using the type hints incorrectly.

16:29 Let's say I call (.substring x 5) on a string -- clojure does that via reflection because it doesn't know what x might be.

16:30 TimMc: yaron-2342: You can put in preconditions.

16:30 joegallo: But if I hinted it as a String, then it would compile into a straight up call to the right substring.

16:30 Clojure would not be perfectly happy if I had passed a map into either example -- but in both cases, a map has no substring method.

16:30 But that might just be my very flawed understanding of things, and I could be completely wrong.

16:31 yaron-2342: joegallo - Indeed, that's what I meant, but for example if I just had a normal clojure function and put in a type hint then Clojure seems to ignore the type hint. The type hint only seems to apply when Java methods are involved.

16:31 joegallo: s/but/because/

16:31 Right, the purpose of type hints there is to turn those java method calls from reflection into the actual right thing.

16:31 yaron-2342: TimMc - And I do but they are so… ugly. It would be beyond amazing to just up in something like ^map and call it a day rather than having to stick in pre and post and put in test functions and the rest. Too much ceremony.

16:32 joegallo: Tagging something as a Vector before calling first on it isn't going to do anything at all, the way I understand things.

16:32 yaron-2342: joegallo - That was my understanding, I was just wishing out loud for them to be expanded so they would apply within Clojure

16:32 joegallo: It would just be noise.

16:32 Okay -- I think I understand you now.

16:37 Borkdude: every sequence has its own implementation of first, for vectors it is nth(0)

16:38 so providing a type hint isn't needed

16:38 it is just java polymorphism that takes care of it

16:38 if I understand correctly

16:40 mdeboard: Is DOM-level JavaScript libraries like jQuery/jQuery-UI within the scope of tasks that one might undertake in ljs?

16:40 cljs*

16:40 ibdknox: mdeboard: as in writing your own?

16:41 Borkdude: mdeboard: you can use jquery from cljs: https://gist.github.com/1096382

16:41 mdeboard: ibdknox: No, I mean as in say I need to write some autocomplete elements in JavaScript; that would be something I'd drop in with jQuery autocomplete widgets. Is that something one would handle with cljs?

16:42 ibdknox: you certainly could, I'm not sure you'll find you gain much out of it though

16:43 mdeboard: right

16:46 Just looking for a reason to get involved with clojurescript

16:46 ibdknox: mdeboard: you could help build the jquery for cljs: https://github.com/levand/domina

16:46 it'd be a good way to learn I'm sure

16:49 dnolen: mdeboard: honestly at this point using it at all and giving feedback is "getting involved" :)

16:51 mdeboard: dnolen: Yeah I'm trying to fit it into my normal projects here, but I asked before you just joined the channel whether jQuery js would be a good fit for Clojure Script, since that's 99% of what we use JS for

16:51 autocomplete widgets etc

16:53 dnolen: mdeboard: autocomplete widgets that you build from scratch? are you already using some pre-existing auto-complete library?

16:53 mdeboard: dnolen: No we use the jQuery autocomplete widgets, very minimal code etc

16:53 we have one "pure" javascript class that handles pagination

16:53 dnolen: mdeboard: are you planning on getting more ambitious w/ your JS?

16:54 mdeboard: e.g. http://lockheedmartin.jobs/ the "More"/"Less" buttons are handled by a "Pager" class

16:54 ibdknox: cljs only really makes sense for really client heavy applications

16:55 if you're trying to build an "application" instead of a website

16:55 mdeboard: dnolen: Doubt it, we're "committed" (*scoff*) to using Django & Python

16:55 sandy1986: How can I add parameters to my ~@body in a macro ?

16:55 sbryant: I had no idea people evened used the .jobs TLD

16:56 mdeboard: sbryant: Oh yes, we definitely do

16:56 theconartist: steve.jobs => server not found

16:56 :(

16:56 mdeboard: theconartist: Research In Motion once had a .jobs domain

16:56 theconartist: But we changed it for them

16:56 to careers.rim.com

16:56 sbryant: theconartist: you can't use it for personal pages

16:56 dnolen: ibdknox: I would argue any site that is looking at underscore.js / backbone.js should also consider cljs, seems like a lot of sites these days.

16:56 mdeboard: instead of rim.jobs

16:56 sbryant: I'm sure no one would stop you

16:57 theconartist: that's pretty damn funny mdeboard

16:57 Borkdude: sandy1986: what exactly do you mean

16:57 sbryant: mdeboard: but the double entendre is awesome.

16:58 mdeboard: dnolen: Actually we are implementing backbone.js, but that's not a project I Have any involvement with, and the guys that do are not keen on doing anything but js. Interestin though.

16:58 sandy1986: I like to write a macro that wraps something

16:58 sbryant: I would love to have an email at rim.jobs

16:58 it's even more ridiculous than my current domain

16:58 sandy1986: (defmacro with-req-body [req & body] `(with-open [r# (~req :body)] (let [buf# (BufferedReader. (InputStreamReader. r#))] body)))

16:59 this works!

16:59 But not with something like: (with-req-body req (parse-stream buf true))

16:59 Cause "buf" is unknown

16:59 I need buf to be known in this context

17:00 body (missed out ~@), sorry <<

17:01 amalloy: sandy1986: make the user call it as (with-req-body [buf] req (...)). then you can bind it to the name they specify

17:02 sandy1986: okay, I'll give it a try. one moment

17:02 dnolen: mdeboard: if you're just reusing widgets and using a couple selectors here an there - no I don't see what cljs buys you. if you need more than the I would start to consider cljs.

17:03 mdeboard: I am not nor ever was a fan of jQuery. MooTools was my tool for my client projects for a long time and that was nice.

17:03 sandy1986: amalloy: where does [buf] came from in your example?

17:03 amalloy: uh

17:03 the user supplies it when they call your macro?

17:04 mdeboard: dnolen: Noted

17:04 sandy1986: But I want my macro to create id

17:04 andrewvc_: Hi guys, I'm just getting started with macros, and I'm sugaring a common case I see. I'm wondering if my use of letfn here is considered a good idea: https://gist.github.com/af4daaf57ae9ce19d824/d4ca8d360de1cbd14c060223ba44998b34ebdab3

17:04 amalloy: huh?

17:05 your macro is creating it; the user is saying what name to give it

17:05 sandy1986: and [buf] is a string?

17:06 amalloy: no, it's evidently a vector containing a symbol

17:06 sandy1986: (with-req-body ["buf"] req (parse-stream buf true)) << ?

17:06 amalloy: (with-req-body [buf] req (parse-stream buf true))

17:07 (defmacro with-req-body [[binding] req & body] `(with-open [r# (~req :body)] (let [~binding (BufferedReader. (InputStreamReader. r#))] body)))

17:08 sandy1986: what kind of a type is binding? I try to understand...

17:08 amalloy: andrewvc_: i don't know anything about the part of aleph you're working with. (a) it seems like a reasonable way to wrap things, but (b) why is your wrapped-handler taking ~ch-binding if you rebind it before you let the user see it?

17:10 sandy1986: damn, it really works as excepted

17:10 Borkdude: sandy1986: excepted..?

17:10 andrewvc_: amalloy: My bad, still haven't run it, yeah I'm going to bind ch# to the one aleph provides, and then rebind ch# to ~ch-binding to make it available to the user. That's a bug in it

17:10 just checking that using letfn inside a macro was an OK thing mostly

17:11 sandy1986: as assumed ;)

17:11 Raynes: amalloy is a fan of letfn in all places, big and small.

17:11 andrewvc_: LOL

17:11 well, so part of my question is, letfn doesn't go in auto-generated docs

17:11 so I guess I just need more docs in the enclosing macro then

17:11 that worried me in particular

17:11 amalloy: sure. it's a bit weird to introduce these "magic" names, but you seem to be making some sort of mini-dsl where you pretend those names are primitives

17:11 andrewvc_: cool

17:11 great, well, then back to making it actually work

17:12 thanks guys!

17:12 sandy1986: yes amalloy, this is what i like to do

17:12 but why is binding evaluated in the macro

17:13 amalloy: sandy1986: i don't understand your question

17:14 mcrittenden: eny0j0p1

17:14 sandy1986: okay ;) I pass in the magic argument binding

17:14 it gets evaluated by ~ when the macro is created

17:14 why does it work?

17:15 amalloy: it's not getting evaluated

17:16 sandy1986: and why is ~binding used in the macro?

17:16 amalloy: &(let [binding x, body '(inc x)] `(let [binding 10] ~body))

17:16 lazybot: java.lang.RuntimeException: Unable to resolve symbol: x in this context

17:17 amalloy: &(let [binding 'x, body '(inc x)] `(let [binding 10] ~body))

17:17 lazybot: ⇒ (clojure.core/let [clojure.core/binding 10] (inc x))

17:17 amalloy: &(let [binding 'x, body '(inc x)] `(let [~binding 10] ~body))

17:17 lazybot: ⇒ (clojure.core/let [x 10] (inc x))

17:17 amalloy: that's the difference between including the ~ and leaving it out

17:19 sandy1986: & = defmacro ?

17:19 lazybot: ⇒ #<core$_EQ_ clojure.core$_EQ_@1ba28e7>

17:20 amalloy: haha

17:20 sandy1986: ;)

17:20 amalloy: no, just asking lazybot to eval

17:20 sandy1986: ahh

17:21 what's the difference between & and , for lazybot?

17:21 * Raynes is always slightly confused that people don't immediately realize that.

17:21 Raynes: ,0

17:21 &0

17:21 lazybot: ⇒ 0

17:21 clojurebot: 0

17:21 Raynes: Different bots.

17:21 sandy1986: ahh ;)

17:21 Raynes: :>

17:21 joegallo: right, & talks to lazybot, while , talks to clojurebot.

17:21 iirc

17:21 mdeboard: I'll tell you what I could stand to write in cljs, is a browser plugin that hides stories on HN that have the string "SOPA" in them

17:21 Raynes: yrc

17:22 mdeboard: SOPA I agree SOPA I'm getting SOPA tired of hearing SOPA about SOPA.

17:22 mdeboard: @kick Raynes

17:22 damn

17:22 Raynes: $guards

17:22 lazybot: SEIZE HIM!

17:22 mdeboard: ha

17:23 sandy1986: amalloy: so the ~ evaluates binding to 'x !?

17:23 amalloy: yes

17:24 sandy1986: cause [binding] stands alone in my macro definition, it simply evaluates to the passed name of binding?

17:24 mcrittenden: mdeboard: try http://hnapp.com/filter/d65a1cfd462aaf310bcd358d3c44f9d3

17:24 mdeboard: mcrittenden: brilljant

17:25 mcrittenden: That actually is awesome. Did you write?

17:25 mcrittenden: mdeboard: nope, I use it a good bit though. nice site.

17:26 mdeboard: Indeedly doo

17:29 amalloy: sandy1986: that's another question that doesn't make sense. "stands alone" doesn't mean anything; ~binding evaluates to what was passed in because that's what always happens when you unquote anything

17:30 sandy1986: okay, and a vector was passed in, containing "a word" ?

17:30 amalloy: containing a symbol

17:33 sandy1986: ahhh,... okay it makes sense

17:37 jodaro: hrm

17:37 is there a one size fits all number parsing way in java?

17:38 mcrittenden: is there a place to go for clojure code review?

17:38 jodaro: i.e. Something/parseWhatever "3.14"

17:38 instead of having to know if i want a long/double/etc

17:38 Raynes: &(read-string "3.14")

17:38 lazybot: ⇒ 3.14

17:38 Raynes: &(read-string "1")

17:38 lazybot: ⇒ 1

17:38 pandeiro_: when i change a file that is already loaded in a slime REPL session, what if anything do i need to do for the changes to be reflected in the repl?

17:39 Raynes: jodaro: read-string will try to read any object and give you something.

17:39 joegallo: If you don't know where you are going, any road will get you there.

17:39 jodaro: oh

17:39 hmmm

17:39 i thought i tried that

17:39 and it was returning a symbol

17:39 but maybe i did something else

17:39 Raynes: &(read-stirng "foo")

17:39 lazybot: java.lang.RuntimeException: Unable to resolve symbol: read-stirng in this context

17:39 Raynes: &(read-string "foo")

17:39 lazybot: ⇒ foo

17:39 amalloy: mcrittenden: just tell hiredman you came up with a great new idea, you'll get feedback about the parts that are horrible

17:40 Raynes: It can return lots of things. It just happens to do what you want as well.

17:40 jodaro: rad

17:40 thats the way i like it

17:40 mdeboard: uh huh uh huh

17:40 jodaro: "it works lots of ways, one of which is the way you want it to work."

17:40 amalloy: pandeiro_: C-c C-k the file

17:40 pandeiro_: amalloy: thanks

17:40 Raynes: jodaro: You don't want use read-string if the numbers are user input. For example, you wouldn't want to use it on a string passed as a query param on a http request.

17:41 Because they can use it to evaluate arbitrary code. Unless you bind *read-eval* to false. Or use clojail. </plug>

17:41 jodaro: heh

17:41 i think its safe in this case

17:42 its in a situation where i'm providing a decent length of rope for which one can, optionally, hang themself

17:42 Raynes: I'm not sure it should be optional. Why not just make them do it?

17:43 lnostdal_: what does "Symbol's function definition is void: define-slime-contrib" even mean? .. slime is loaded....

17:45 not sure i want to deal with all this shit anymore .. why the heck isn't the contents of slime (a few kilobytes) simply wrapped in a namespace (does elisp even support namespaces) and included with every, single swank-backend for every single language / tool /whatever out there ....

17:45 sritchie: lnostdal_: no namespaces in elisp

17:45 lnostdal_: then we need to throw emacs and/or elisp away right now

17:46 totally fed up with it .. especially when dealing with multiple languages and tools

17:46 sritchie: the initial setup can be a little harrowing, but once it's set I've loved it for clojure

17:46 that define-slime-contrib thing probably doesn't mean anything bad

17:46 Tharem: It means that slime won't run in his case

17:47 Raynes: lnostdal_: Are you trying to use SLIME for CL as well as Clojure?

17:47 lnostdal_: yes, it works with clojure here too .. but not when "combined" with other stuff .. sbcl, ccl, some nodejs swank backend .. etc.

17:47 sritchie: got it

17:47 Tharem: The problem is that clojure only works with an outdated version of slime

17:47 Raynes: If so, I believe technomancy's advice is "don't bother".

17:48 It is a fairly complex set up.

17:48 lnostdal_: yeah, i see he's trying to skip everything via that jack-in thing

17:48 IIUC

17:49 Tharem: Clojure-jack-in assumes that slime is running properly though

17:49 Raynes: Tharem: I think part of the problem is that the SLIME developers don't really have a concept of releasing things.

17:49 lnostdal_: it does? .. k

17:50 Raynes: I'm not sure what he is talking about.

17:50 clojure-jack-in doesn't assume anything.

17:50 lnostdal_: yeah, it injects elisp code (slime) for emacs to eval on-the-go or something?

17:50 that's what i thought at least

17:50 Tharem: clojure-jack-in does use slime though, no?

17:50 Raynes: It just bootstraps a version of SLIME and runs a Leiningen command for you to start the swank server.

17:51 Tharem: Yes, but having 2 different types of slime on the ready causes problems

17:51 Raynes: It is an absolute godsend for new Clojurians. 90% of the problems reported here were people who were unfamiliar with Emacs.

17:51 Using SLIME with Clojure and other languages is a whole different configuration and ball game.

17:51 Tharem: One way around that is to not load slime in .emacs, but provide a function that does the loading

17:51 Raynes: Swank backends target whatever SLIME happened to be around "at the time", in most cases.

17:51 Because, like I said, they don't do releases.

17:52 Tharem: That way you can do clojure-jack-in or start slime separately, but things will still break if you use clojure-jack-in after you started slime

17:52 the other way around is fine apparently

18:01 sandy1986: Mhhh,...

18:03 Trying to test it via repl... (def testinpt (fn [] (java.io.ByteArrayInputStream. (.getBytes "{name: Sandy}"))))

18:05 mhhh? #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$testinpt>

18:05 with (with-req-body [buf] testinpt (print "x"))

18:06 Tharem: You're obviously trying to call testinpt with 1 argument somewhere. Have you tried macroexpanding that call yet?

18:07 sandy1986: ahh Tharem, thx

18:07 (def testinpt (fn [param] (java.io.ByteArrayInputStream. (.getBytes "{name: Sandy}")))) fixed it

18:08 Tharem: Arity is just a fancy word for number if input paramters

18:08 so an arity exception means there's a mismatch between what the function is getting and what it's expecting

18:08 Vinzent: sandy1986, why not (defn testinpt [param] ...)?

18:10 sandy1986: yeah Vinzent thank you very much

18:11 how can I macroexpand it to view what's getting generated?

18:12 Tharem: If you're using a macro (and I think with-req-body is one), you can use (macroexpand-1 '(macroname foo bar))

18:12 Vinzent: In emacs C-c RET, or use macroexpand-1

18:14 Tharem: Is someone here familiar with the intricacies of painting on a JPanel?

18:15 If so, can you tell me why the following code doesn't do what I'm expecting: http://pastebin.com/q3Bg2yuY

18:16 sandy1986: oh thank you guys very much

18:16 (clojure.core/with-open [r__798__auto__ (testinpt :body)] (clojure.core/let [buf (java.io.BufferedReader. (java.io.InputStreamReader. r__798__auto__))] (print "x"))) << yeah

18:17 Are the resources auto-garbage collected?

18:18 What is happening after the macro was run?

18:18 Tharem: When the macro is run, it generates the code shown, which is then fed to the JIT-compiler, which compiles and excecutes it

18:18 Any garbage created is collected

18:19 sandy1986: Ahh, so the code does not stay in the memory?

18:19 amalloy: Tharem: can you paste somewhere else, like gist? my computer can't resolve pastebin.com now - maybe dns issues related to sopa? :P

18:19 sandy1986: (code = code generated from macro)

18:20 semperos: tried out the code in this article: http://steve.vinoski.net/pdf/IC-ClojureScript.pdf

18:20 works fine when compiling the ClojureScript with {:optimizations :advanced}

18:20 ah, nm

18:20 just saw my syntax error

18:22 Tharem: Amalloy, Sure, here is it: https://gist.github.com/1515646

18:22 amalloy: (.darwString "bla" 10 10)?

18:22 Tharem: For some reason it does manage to create a swing window with a black background, but it's not printing bla on it

18:22 Yeah that's test code

18:23 amalloy: darw

18:23 Tharem: I'm trying to get it to print some strings somewhere, but it doesn't even do that

18:23 XD

18:23 Ok thanks

18:23 That makes me wonder how that got past the compiler though....

18:24 SergeyD: Hi, is it ok to share my Clojure project link here?

18:24 amalloy: well the compiler doesn't have the type information, i think

18:25 mcrittenden: what does & mean in the params for a function declaration? for example: (defn head [url & [req]] ...)

18:25 ibdknox: mcrittenden: & essentially means the rest of the params put into a seq

18:26 Tharem: mcrittenden, it means that the function can be called with any number of arguments and all remaining arguments will be collected into the final parameter

18:26 ibdknox: mcrittenden: in this case it's being used to make the param req optional

18:26 mcrittenden: ahh interesting, thanks

18:27 lnostdal_: now jack-in doesn't even work

18:27 *Messages* is showing "error in process filter: Symbol's function definition is void: slime-output-buffer [2 times]" no repl shows though

18:28 mcrittenden: ibdknox: you still get any requests via i will build your prototype?

18:28 ibdknox: mcrittenden: fairly often, actually

18:28 mcrittenden: are the clients typically pretty decent?

18:28 ibdknox: it depends

18:28 mcrittenden: mostly startup founders w/o a tech cofounder I'd imagine?

18:29 ibdknox: actually it's been all over the board

18:30 I've gotten some requests from larger organizations and some from would-be entrepeneurs

18:30 mcrittenden: does anyone ever show concern about the fact that you'd be using clojure?

18:30 ibdknox: I think my offer weeds them out lol :)

18:31 mcrittenden: interesting stuff. sounds like a great way to work on a bunch of different projects and get to use the tools you want

18:32 i'm a drupal dev by day, mostly just because there's so much work, not at all because I enjoy drupal. so color me jealous

18:33 ibdknox: drupal pains me

18:33 mcrittenden: drupal is extremely productive once you've spent a few months with it, but it never really gets fun. it's always a bit of a grind

18:33 at least for me

18:34 anyways thanks for the info, just curious

18:35 sandy1986: what does defn- do '?

19:04 lnostdal_: sandy1986, it makes the function only available within the current namespace

19:05 sandy1986: lnostdal_: ahhh thx

19:08 what is defn-memo ?

19:16 lnostdal_: sandy1986, if you move the cursor over to defn-memo and press Alt-. it might lead to the definition of that, which might include some docs

19:16 Alt-, will take you back

19:17 sandy1986: Does not work... which cursor? I'm using putty and vim

19:17 lnostdal_: ok, i assumed emacs

19:18 sandy1986: I googled for it... it is in clojure.contrib v1.2 which is not compatible up to clojure 1.3, right?

19:19 https://github.com/adamwynne/kestrel-client/blob/master/src/kestrel/client.clj << is the use of defn-memo default-client okay? Maybe this is not good cause the function has side-effects (connection-closed, ...) ?

19:33 lnostdal_: ?

19:53 dnolen: (+ 4 5)

19:53 clojurebot: *suffusion of yellow*

19:54 dnolen: oops

20:03 grr, has anyone seen the issue where the SLIME REPL just doesn't seem to take any input

20:04 though interactive SLIME commands from w/in .clj files works fine

21:04 mdeboard: I'm seeking a quote by rhickey that said something along hte lines of, "Performance is meaningless if you don't have reliable data", anyone have a link?

21:48 xcv: Hey guys, any news on when the screencasts from the last conj will be up on blip.tv? Really looking forward to watching them.

21:54 aphyr: Style question: how should I handle kwargs?

21:56 dnolen: aphyr: destructuring supports kwargs


21:56 aphyr: (func :opt value :opt2 value), written with destructuring bind looks cleaner, but I've read that it can be slower.

21:57 The other thing is that sometimes I want to write a function that takes keyword args, provides a default for *one* of them, and passes the merged options down to some lower-level function

21:57 dnolen: aphyr: you can provide defaults

21:57 aphyr: With (func {...}), that's easy to write as (lower-func (merge defaults opts))

21:58 dnolen: (defn foo [& {:keys [foo bar] :or {bar 1}}] ...)

21:59 aphyr: For destructuring, I'm aware of (defn func [ & { :keys [a b c] :or [{...}]}]). Do I have to list the keys explicitly every time?

21:59 It'd be great if I could say "Take your args, provide a default for :somekey, and call the next fun"

22:00 (without necessarily knowing what all the keys are)

22:01 amalloy: just don't do it in the destructuring context

22:01 as an aside, i think having a hierarchy with dozens of functions using kwargs is pretty gross. if you want kwargs as your top-level api, fine, but once you get into the internals accept an actual map so you don't have to do all this wrangling with & args

22:02 aphyr: aha! That's the opinion I was starting to form.

22:02 Just passing maps down seems like less code

22:02 amalloy: once you're just working with maps, it's easy

22:02 dnolen: what amalloy said

22:03 aphyr: So... for user-facing code, kwargs for a concise API. For internal code, use maps for brevity (and speed?)

22:03 amalloy: (defn foo [opts] (bar (into {:a default-a} opts)))

22:03 aphyr: personally i don't usually bother with kwargs for the user-facing code either, but there's nothing wrong with it

22:03 it seems to me that if i write an API that has many kwargs i've usually designed it badly

22:04 aphyr: Mostly I need it for network configuration, etc.

22:04 :host, :port, :proto, blah blah blah

22:05 amalloy: eh. so ask them to pass a config/options map

22:05 aphyr: Sounds good. Thanks a bunch guys. I haven't seen anything expressing this clearly in my googling, so I'll write a short post about it.

23:55 tauntaun: I can't seem to use the sql API without provoking exceptions. What are the latest versions of clojure & clojure-contrib that I should specify in leiningen's dependencies (project.clj)?

23:57 dnolen: tauntaun: don't use the sql lib from monolothic contrib. there's a new one well maintained one.

23:58 tauntaun: I recommend 1.3.0 + https://github.com/clojure/java.jdbc

23:58 ibdknox: tauntaun: and for a higher level API, Korma: http://www.sqlkorma.com

23:59 tauntaun: thanks

Logging service provided by n01se.net