#clojure log - Sep 16 2011

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

0:01 icey: Does this java interop seem a little better? https://github.com/pmn/noir-messageboard/blob/master/src/noir_messageboard/utils/utils.clj#L14

0:02 brehaut: yes

0:03 icey: awesome, thanks again

0:09 amalloy: icey: you can cut out a lot of the duplication in describe-time-elapsed

0:10 (let [[hours days months years] (for [amt [60.0 1440.0 43829.0639 525948.766]] (Math/round (/ minutes amt)))] ...)

0:10 icey: amalloy: oh, that's pretty cool

0:10 amalloy: then you don't even waste the cpu to count out the years unless you end up using them, as a nice side effect

0:11 though i guess vector seqs are chunked, and for preserves chunkiness...feh, whatever

0:11 icey: it's pretty slick, i like it

0:12 brehaut: icey, id lean towards making human-date take a second argument (the reference point)

0:12 rather than implicitly using ctime/now

0:12 amalloy: good idea

0:13 icey: brehaut: out of curiosity, why? future flexibility or another reason?

0:13 brehaut: it makes that code pure which drasticly improves both reasonability and testability

0:14 (reasonability: you can reason about what its doing)

0:14 icey: brehaut: ahhh that makes sense

0:14 i'm still working on thinking functionally :)

0:14 brehaut: arent we all :)

1:12 jamiltron: I'm having some problems interfacing to a java class that has a public constructor, but whose main functionality is in a private method that reads from System/in.

1:13 Maybe I'm oblivious, but I want to be able to "lein run" my project with a supplied file name to be read and supplied as System/in.

1:15 amalloy: jamiltron: $ lein run < somefile.txt?

1:16 jamiltron: That seems to still be producing -1 as System/in

1:16 amalloy: System/in is a stream. it is impossible for its value to be -1, so i don't understand the assertion you just made

1:17 it's entirely possible (technomancy?) that lein run forks a new java process and doesn't forward stdin to it, but that would surprise me

1:21 jamiltron: Maybe its the way I'm running it. I have a parser that reads from System/in. When I do java myParser < testinput.txt, it runs fine.

1:21 gstamp1: does apply work on methods defined with a protocol?

1:22 jamiltron: When I try interloping with Clojure, I instantialize the object and call the parse method (.parse (new myParser)), and when running lein run < testinput.txt I get a java.lang.ArrayIndexOutOfBoundsException: -1 error

1:24 amalloy: gstamp1: yes. protocol functions are functions, not methods, and so anything that works for a function works for them

1:28 sounds more like an issue with mis-initializing your parser

1:29 jamiltron: try using clojure.main instead of lein run, so that you can eliminate lein as the source of the problem

1:30 or write your program to take a filename as an arg, and open the file yourself, so that you can stop worrying you're redirecting wrong. if you want, you can System/setIn some-stream

1:31 jamiltron: I normally read files with slurp, would that be the preferred method in this case?

1:32 amalloy: if you want an input stream...get the input stream however you want. slurp will produce a string, and it's not trivial to go from characters back to bytes

1:44 jamiltron: I think I'm just screwing this up. All the file io I've done in Clojure revolves around slurp. I'm having a pretty rough time getting the format right for System/setIn. Is there a better method than slurp to just get a stream in Clojure?

1:46 amalloy: &(find-doc "input-stream")

1:46 lazybot: ⇒ ------------------------- clojure.java.io/IOFactory nil Factory functions that create ready-to-use, buffered versions of the various Java I/O stream types, on top of anything that can be unequivocally converted to the requested kind of stream. Common op... https://gist.github.com/1221294

1:47 amalloy: &(clojure.java.io/input-stream "project.clj")

1:47 lazybot: java.security.AccessControlException: access denied (java.io.FilePermission project.clj read)

1:47 amalloy: ^ would work if the bots weren't sandboxed

1:57 jamiltron: amalloy: Thanks

1:58 I had to end up using (System/setIn (clojure.java.io/input-stream args))

1:58 Not sure if that's the best way but its at least working.

1:58 raek: why do you need to set System.in?

1:58 jamiltron: lein run doesn't seem to capture redirection

1:58 amalloy: raek: he has some crazy library that operates by reading System/in

1:59 raek: oh. dang.

1:59 jamiltron: Yeah, it's not fun.

1:59 But its either figure this out or do the rest of this course in Java or C++, neither of which I'm especially thrilled about.

3:31 robermann: hello, I'm using clojurebox; is clojure-jack-in available out of the box or I am supposed to install something else?

3:38 khaliG: robermann, try M-x clojure-jack-in

3:38 robermann, if it works then yes, otherwise you'll need to install it

3:39 (swank-clojure that is)

3:40 robermann: khaliG: I tryied, and it does not exist. I thought it would be there, because clojurebox have clojure-mode and swank-clojure preinstalled

3:41 khaliG: robermann, not necessarily. are you on windows?

3:41 robermann: yes .. :)

3:43 khaliG: robermann, if you really want c-j-i you might have to set it up from scratch yourself

3:44 robermann: BTW, what is the difference between running "lein swank" / clojure-jack-in versus M-x swank-clojure-project > set root project?

3:45 Don't both start a REPL in the specified lein project?

3:46 khaliG: jack-in takes care of the lein swank; m-x slime-connect for you,

3:52 raek: I think swank-clojure-project duplicates what leiningen does nowadays

3:53 also, it is not maintained anymore

3:53 with "lein swank" / clojure-jack-in, Leiningen starts the swank server. with swank-clojure-project the deprecated swank-clojure.el elisp package does it.

3:55 robermann: I recommend getting rid of clojure-box, install emacs the normal way and install clojure-mode.el

3:55 clojure-mode is the only thing you need on the emacs side since clojure-jack-in

3:56 * khaliG seconds raek

3:56 robermann: mmm so in the latest "best practice setup" by technomancy (http://technomancy.us/149) I'm supposed to find only clojure-jack-in, not clojure-swank-project, right? Whereas in Clojurebox I find clojure-swank-project and not clojure-jack-in.

3:57 raek: yes

3:57 pretty much

3:58 scottj: clojurebox is a year old

3:58 raek: you can install slime, start the swank server manually and slime-connect to it too, if you want to

3:58 but with clojure-jack-in you use the slime version that swank-clojure supplies

3:59 which (hopefully) makes ones configuration less brittle

3:59 thorwil: the only thing i miss with clojure-jack-in is triggering a startup script automatically

3:59 robermann: ok raek thanks, now this stuff make sense for me. Googling it was quite confusing

4:00 amalloy: thorwil: eh? c-j-i should honor the settings in project.clj

4:00 raek: what's currently the "best practice setup" has varied a lot from time to time

4:01 the clojure-box approach stems from the time before leiningen

4:02 so does the deprecated swank-clojure.el

4:02 robermann: ok

4:02 thorwil: amalloy: oh, i have to try that, then

4:02 raek: not easy to know since lots of old tutorials are out there

4:03 Fossi: "a lot" :D

4:04 that's an enormous understatement

4:04 (is that even a word?)

4:04 robermann: clojure-jack-in calls (after slime ecc) "lein swank" right? and "lein swank" pipes the forms into a "lein repl" subprocess?

4:05 Fossi: i still start my swank and slime by hand and have projects added in my classpath XD

4:05 amalloy: robermann: lein swank and lein repl are two different ways to communicate with a running clojure process

4:05 swank (almost certainly) doesn't communicate with a repl

4:07 khaliG: so a lot of the time when something goes wrong - there is nothing printed in the repl - no stacktraces, to get those I've got to look at *swank*

4:08 robermann: BTW this seems very clarifying: http://stackoverflow.com/questions/7238766/what-exactly-does-clojure-jack-in-do-and-how-to-config-the-settings-with-slime

4:35 thorwil: if i do clojure-jack-in and then paste the following into the slime-repl, it works: http://paste.pocoo.org/show/476890/

4:35 but if i trigger it via :repl-init-script, i get: No such var: ae/start

4:36 amalloy: you probably need to wrap it in a (do)?

4:36 raek: maybe this is the "IDE sniffing" appengine-magic does

4:37 ae/start is conditionally compiled and is only there if ae-m thinks you are using an IDE

4:37 amalloy: jesus

4:37 clgv: thorwill: I guess you using :require in a ns named user isnt the same as if you do (require ..) on repl with standard ns user for alter execution within the repl in both cases

4:39 raek: https://github.com/gcv/appengine-magic/blob/master/src/appengine_magic/core.clj#L5

4:39 *seriously*, there must a better way to do this

4:39 thorwil: (do) doesn't help. guess i should try falt require and use, no ns

4:40 raek: thorwil: this is a bug in appengine-magic

4:40 clgv: thorwil: do you really need that strange compile & in-ns for the startup?

4:40 raek: the same one I recall that I investigated with you once before

4:42 thorwil: raek: i do recall it, but didn't think of it here

4:43 clgv: humm why does "lein repl" swallow newlines that should be printed?

4:43 thorwil: clgv: the compile is there to make sure i get served the latest state. the in-ns i could get rid of

5:12 pyr: does anyone use ring.middleware.resource ?

5:12 instead of passing through when it doesn't find a resource it throws exceptions

5:17 meh, alright found the way to do it

5:35 mcstar: (example.gpgpu.mandelbrot/start) how can i make this shorter?

5:35 is there something like (in-package)?

5:36 Chousuke: is that a java package?

5:36 mcstar: (ns example.gpgpu.mandelbrot

5:36 raek: from your own namespace: (ns your-ns (:use [example.gpgpu.mandelbrot :only [start]]))

5:36 mcstar: i guess not

5:36 clojurebot: llahna: anyway the answer is no. you can use #(some-fn %1 default-arg %2), for example

5:37 raek: or from the repl: (use '[example.gpgpu.mandelbrot :only [start]])

5:37 Chousuke: you can do :require ... :as foo too in the ns form

5:37 so that you can do foo/start

5:37 raek: or if you want to actually be in that namespace: (in-ns 'example.gpgpu.mandelbrot)

5:37 mcstar: raek: yes, that is appropriate thx

5:38 raek: after one of those, you can call it with (start)

5:38 mcstar: yes :)

5:38 raek: the other common approach is what Chousuke said. that way is probably more convenient if you are going to use many vars from that namespace

5:39 in-ns requires that the namespace has been loaded first (with a 'require' or 'use' call)

5:39 mcstar: the project's main sorce creates this namespace, so i want to be in it, when using the repl

5:40 when youre developing you dont create just another package/namespace just to use the just-defined functions

5:40 raek: you can also use 'use' without the :only option. then you will have access to all public vars of that namespace in your current namespace

5:40 which is similar to being in that namespace

5:41 but yeah, while developing or testing the namespace, in-ns makes perfect sense

5:41 mcstar: raek: is there something like :export in clojure?

5:42 to control what symbol can be accessed with a :use?

5:42 raek: every def* thing is exported by default, unless you have ^{:private true} metadata on the var

5:42 mcstar: im coming from cl

5:42 i see

5:42 raek: for 'defn' there is a shortcut: 'defn-'

5:42 to make a private function

5:43 (def ^{:private true} ordinary-constant 123)

6:21 tsdh: On clojars, can I delete some jar (or even a complete group where I'm the only member)?

7:13 khaliG: hm. my uberjar is 15mb. are there any tricks to shrinking these down?

7:15 clgv: khaliG: checking your dependencies, maybe there a superfluous ones

7:15 scottj: khaliG: there's a slim version of clojure I think

7:16 also pack200. see thread "mini-version of clojure.jar"

7:17 actually slim version of clojure might only decrease the size by 2mb

7:21 khaliG: clgv, yep i just went through and did that, lein is pretty clever - it removed duplicates (ie those occuring in lib/ and lib/dev) already

7:21 scottj, from 3mb? that's pretty good!

7:22 clgv: khaliG: maybe you can only select a part of a dependency instead of the whole thing. I know thats possible for incanter for example

7:22 scottj: khaliG: 15mb -> 13mb though isn't

7:22 khaliG: clgv, does lein do that?

7:22 true scottj

7:22 clgv: khaliG: you do it by specifying "incanter.core" instead of "incanter" to lein

7:23 khaliG: clgv, as it happens i do use incanter as a dependency. i shall investigate..

7:23 clgv: but that only works since incanter is structured into these subprojects

7:23 khaliG: thanks for the hint :)

7:23 clgv: I use it myself as one of 3 deps and it pulls that much stuff withit

7:24 khaliG: yep parallelcolt for exmaple is 3.4mb

7:24 clgv: I tried to exclude parallelcolt but got an error. I dont use it at all^^

7:24 khaliG: clgv, so how do you restrict, in project.clj ?

7:25 clgv: you can :exclude jars as well, thats what I tried with parallelcolt

7:25 khaliG: i see!

7:34 42% of the 15mb is taken up clojure-1.2.0.jar and parallelcolt-0.9.4.jar

7:37 clgv: 11.8MB for incanter and its deps

7:37 khaliG: damn.. lol

7:37 clgv: yeah, have to change it when I know exactly what sublibs i need

7:38 khaliG: does that include the clojure jars too?

7:38 clgv: nope

7:38 khaliG: interesting

7:38 clgv: still 5.7MB when I only have incanter.core listed

7:42 khaliG: clgv, makes you wonder why incanter is so heavy. lispstat wouldnt have been more than a mb :P

7:42 clgv: khaliG: I think they should remove some more stuff from core^^

7:43 khaliG: here we go - ftp://ftp.stat.umn.edu/pub/xlispstat/3-52/xlispstat-3-52-20.tar.gz 1492 kB

7:43 and that includes an entire lisp as well

7:43 kharrington: khaliG: doesn't incanter come with example data?

7:44 clgv: kharrington: and zillions of dependencies ;)

7:44 kharrington: mmm

7:45 khaliG: kharrington, not sure

7:45 kharrington: i've often wanted optional dependencies in leiningen-based projects anyway

7:46 clgv: 37 deps for [incanter "1.2.3"]

7:47 16MB with clojure and clojure contrib

7:51 khaliG: wow, xlispstat still builds and runs .. amazing :)

7:53 kharrington: khaliG: no, it looks like datasets fetch from github by default

10:13 rqcursq: http://wiki.theory.org/YourLanguageSucks

10:29 clgv: lol what? :P

10:40 bpr: why does leiningen include the project.clj file in generated jar files?

10:40 pyr: so you can slurp it ?

10:41 bpr: I'm trying to write some code for android, and I'm depending on multiple clojure libraries. Therefore there are multiple files named "project.clj" and the android build process is choking on that :-/

10:41 khaliG: clgv, have you tried using proguard on your app?

10:41 clgv: khaliG: no. what's that?

10:42 khaliG: clgv, its a jar optimiser/obfuscator thingy

10:42 bpr: So, as a quick hack can I remove the project.clj files from the jars?

10:42 khaliG: just ran it on my uberjar and it choked though

10:42 clgv: it's free?

10:42 khaliG: the oracle app pack200 worked better reducing the file size from 15mb to 13mb though

10:42 clgv, yup

10:43 clgv, pack200 lives in $JAVA_HOME/bin if you want to try it

10:46 clgv: khaliG: humm maybe it could do more if you did AOT for all files and removed the clj-files, but I never tried that. It's also not encouraged to AOT all ;)

10:47 khaliG: clgv, worth a try!

10:47 bpr: oh... scratch my question lol I was being assinine

10:48 stuartsierra: AOT is fine for delivering an app.

10:48 clgv: ah ok, I remember one comment that you shouldnt do it if you dont need to

10:48 stuartsierra: It's bad for distributing a librar.

10:48 clojurebot: libraries is http://clojure.org/libraries

10:48 kharrington: rqcursq: the best thing from that link is: "Object-oriented programming is an exceptionally bad idea which could only have originated in California." --Edsger Dijkstra

10:48 stuartsierra: library.

10:51 clgv: ah right I noticed it once when trying a lib with AOT from clojure 1.2 in 1.3 ;)

10:52 rqcursq: kharrington: yes, is the best :D

10:53 dnolen: Haskell is purely object oriented http://www.mail-archive.com/haskell-cafe@haskell.org/msg72409.html

10:53 clgv: rqcursq: that site would be better if they agreed on criteria in advance to criticize the languages, so it's reading as just random opinions about the listed languages

10:55 s/so/now/

10:55 lazybot: <clgv> rqcursq: that site would be better if they agreed on criteria in advance to criticize the languages, now it's reading as just random opinions about the listed languages

10:55 rqcursq: youre right

10:57 there is no such a thing like clojure! a ha!

10:58 khaliG: it's annoying having to decide whether to include a 2mb jar into your project or write 200 lines of clojure doing the same thing :(

10:59 rqcursq: I think from now on Lisp dialects will go popular for production line of sw

10:59 or enterprise systems

10:59 cause they need logical instruments like this… not a functional static foolish things

11:01 khaliG: especially when you only need a tiny class from that jar!

11:03 rqcursq: any clojure based computer algebra system released ?

11:04 clgv: khaliG: humm if it fits your license you can just use their code snippet (not to forget attributing) ;)

11:04 rqcursq: or mathematical lib written in clj?

11:04 khaliG: clgv, true, i might just do that. it's LGPL code though

11:04 rqcursq, incanter is the only one i can think of

11:24 rqcursq: what project is needed for clojure?

11:25 which types of projects are *

11:35 gtrak: rqcursq, clojure's a general purpose language

12:42 SergeyD: ,(prn "test")

12:42 clojurebot: "test"

12:42 SergeyD: ,(defn tt []

12:42 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

12:42 SergeyD: (loop [i 0 tset #{}]

12:42 (if (= i (int 5e5))

12:42 (count tset)

12:42 (recur (inc i)

12:42 (let [nn (rem (* i (int 1e3)) 131071)

12:42 plus (count (filter #(contains? tset %) (range nn (+ nn 10))))

12:42 TimMc: ...

12:42 SergeyD: ]

12:42 (conj tset (+ plus nn)))))))

12:42 (tt)

12:43 Should be one-liner, I guess

12:43 gtrak: SergeyD, paste in a pastebin

12:43 TimMc: SergeyD: You shouldn't paste that much to the channel anyway.

12:43 manutter: SergeyD: also, the bot won't let you defn

12:43 TimMc: If you really need to eval that much code in clojurebot, do it in /query clojurebot

12:44 SergeyD: Sorry, ok

12:44 srid: is this the idiomatic way to print a list of maps? -- (map #(println (dissoc % :message :foo :json :level :component)) events)))

12:45 TimMc: srid: You'll need a doall around that at least.

12:45 doseq sounds better

13:05 * srid is hunting for visualization methods to use post log-analysis (incanter is not web-based!)

13:07 PPPaul: use pmap

13:12 technomancy: srid: you can generate pngs for web apps using incanter

13:21 amalloy: yeah, it's not clear what "not web-based" means for...a math library? like, you can't use it if you have an internet connection?

13:21 4clojure uses incanter to generate graphs on the fly

13:28 TimMc: PPPaul: Why?

13:42 rqcursq: what is the difference between def and defn ?

13:43 hiredman: please read the docs

13:43 amalloy: in fairness, ##(doc def) doesn't exactly work

13:43 lazybot: java.lang.SecurityException: You tripped the alarm! def is bad!

13:44 Raynes: def names something and defn creates a function and names it with def. defn is implemented in terms of defn.

13:45 in terms of def, even.

13:45 amalloy: I'm shocked that you let that pass for a whole minute with no amusing comment.

13:46 amalloy: Raynes: i /msg'd everyone but you to tell them you were wrong

13:46 rqcursq: #(doc def)

13:48 hiredman: amalloy: there are docs for it

13:48 rqcursq: Raynes: thank you

13:49 manutter: rqcursq: if you didn't have defn, you'd define functions like this: (def some-func (fn [x] (println x)))

13:50 defn is a bit shorter, and I think it might also set some meta-data? Or not, I haven't looked at the src for that one.

13:51 but consider (defn p-add [a b] (if (zero? a) b (p-add (dec a) (inc b)))) -- the function calls itself

13:54 rqcursq: manutter: i understand and defn also provides documentation?

13:54 like "this" ?

13:55 manutter: There you go, that's the metadata I was thinking of: if you say (defn my-func "prints out x" [x] (println x)) you get the doc string automatically tucked away inside the metadata for my-func

13:57 rqcursq: manutter: Thanks for your information :)

13:57 manutter: np

14:01 rqcursq: .git/ directory has more bytes than codes itself...

14:02 amalloy: rqcursq: i hope you can spare the thousandth of a cent that a few megabytes cost you

14:02 and of course it's larger than your source code directory: it contains *every version* of source code you've ever checked in

14:03 TimMc: in a manner of speaking

14:04 It contains enough information to reconstruct those versions.

14:05 rqcursq: but i want to latest version to clone not the all heads… :(

14:05 amalloy: TimMc: the hard drive only contains enough information to reconstruct the current version, in the same manner of speaking: it just has a bunch of bits, and a very clever algorithm for turning those into pixels on your screen

14:06 rqcursq: even in 1995 the amount of hard drive space taken up by .git would be only a little burdensome

14:13 TimMc: amalloy: I'm not sure what you're trying to say.

14:20 amalloy: TimMc: you were asserting that .git doesn't "actually" contain all the previous version

14:21 TimMc: Not as such -- they are not all side-by-side as independent copies.

14:21 Chousuke: of course not, that would be dumb

14:22 but the information is all there :P

14:22 TimMc: :-)

14:22 amalloy: my point is that it contains the previous versions in the same way the hard drive contains the current version: it stores enough bits to reproduce the characters, in the same way that git stores enough bits to reproduce the versions

14:22 Chousuke: so in a mathematical sense it does contain all previous versions

14:23 TimMc: I don't think we actually disagree on anything in an objective sense. :-P

14:34 icey: hmm. i think i'm going to have to change my irccloud setup

14:45 manutter: doh, now I'm going to have to google irccloud, it sounds cool (whatever it is)

14:45 amalloy: manutter: it's like a bouncer, except not as good

14:45 icey: manutter: it's a service that provides irc over the web

14:46 it was a good idea, but the implementation has been kind of meh. it goes down a lot

14:46 manutter: ah

14:59 lnostdal: just wanna say clojure is quite nice .. it feels like a very solid core

15:01 ..some tools are lacking here and there of course; it's a new thing or language .. perhaps this emphasizes the "solidness" of the core, because it still all works out somehow ......... :)

15:08 konr: Isn't swank-clojure.el missing from https://github.com/technomancy/swank-clojure ?

15:08 technomancy: konr: it's deprecated

15:40 rqcursq: how to include another source file in clojure ?

15:42 TimMc: rqcursq: http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-nshttp://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns

15:42 grah

15:42 rqcursq: Rather, http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns

15:46 rqcursq: TimMc: luvvv it!! thanks

15:47 TimMc: I still refer to that for syntax.

15:58 * dnolen is porting TodoMVC to ClojureScript

15:59 rqcursq: dnolen: inc dnolen

16:00 konr: oh wow, clojurescript!

16:00 dnolen: and looking forward to fixing delimc to work w/ ClojureScript so you can write AJAX w/o callbacks.

16:00 rqcursq: writing discrete math functions for clojure

16:04 hugod: does clojure.test exist for clojurescript?

16:08 rqcursq: (assoc {:a 1 :b 2} :c 3)

16:09 is this >:c 3< expression assigned everytime to first key-vale binding ?

16:09 like {:c 3, :a 1, :b 2} this ?

16:09 icey: is there currently a recommended way for doing comet with clojure web apps? i know about aleph, but is there anything like socket.io for clojure?

16:09 _fogus_: hugod: Not that I', aware of.

16:09 icey: or is it all long-polling still?

16:09 amalloy: rqcursq: maps have no ordering

16:10 any ordering that you see is coincidental and should not be relied on

16:11 dnolen: icey: aleph is the closest that I'm aware of.

16:13 srid: for my log analysis - looks I will have to create a separate process for pulling the log files, and another for processing them into list of maps. these maps need to be stored somewhere, from which the web process can pull them for visualization.

16:14 pulses uses 'redis' for this. is redis a good choice for storing processed log records?

16:15 konr: what text editor/IDE do you use?

16:23 icey: dnolen: hmm, thanks

16:33 srid: *must* i learn the concurrency primitives of clojure (atoms, state, identity, etc..) before implementing a multi-threaded program with producers and consumers interacting with redis/rabbitmq?

16:33 technomancy: srid: I'm going to go with yes

16:34 amalloy: you could always try just guessing, in the same way you don't need to learn clojure to write a clojure program - just pound letters and parens at random until you get the program you wanted by luck

16:38 srid: i'm inclined go with multi-process, as I'm not sure how easy it is to develop multi-threaded programs in REPL. (with multi-process, i can open multiple REPLs)

16:44 rqcursq: can we make a giant framework like rails ?

16:44 is it possible ?_

16:45 stuartsierra: rqcursq: Define "we." :)

16:45 rqcursq: alllll of clojurians :D

16:45 stuartsierra: Of course we can.

16:46 fliebel: Do we want to?

16:46 stuartsierra: I certainly don't.

16:46 hiredman: not it

16:48 fliebel: But a giant pile of independent composeable utilities would be fine with me.

16:48 stuartsierra: I'd prefer it.

16:49 rqcursq: utilities ?

16:49 fliebel: Something that can be explained as "an X for Y" ;)

16:51 tsdh: Hi

16:51 Can someone tell my why the extend-type form at http://pastebin.com/Z8J0X6S4 does only compile (and work) if I extend it to one type only?

16:52 Ah, it's extend-protocol, but anyway...

16:59 stuartsierra: tsdh: It may have something to do with the macroexpansion of extend-protocol

17:00 I've never tried using that with expressions like `(class "s")`

17:01 tsdh: stuartsierra: In my case, I want to extend a protocol to objects of classes that were compiled in memory. So I don't have a class literal.

17:01 * hiredman has used extend-protocol on 1.2 with (Class/forName "[B")

17:01 stuartsierra: Try using the `extend` function directly.

17:02 tsdh: hiredman: I don't have 1.2 handy, but I'll try tomorrow.

17:02 stuartsierra: Ok, I'll try.

17:07 stuartsierra: That works. Well, but then I need 3 extend forms which are even less convenient than 3 extend-protocol or extend-type forms that work, too.

17:08 stuartsierra: There may be a bug in one of the extend-* macros that prevents your example from compiling. The same code with literal class names works fine.

17:09 Aha, the doc string to `extend-type` says that it "Propagates the class as a type hint on the first argument of all fns."

17:09 And `extend-protocol` expands to multiple calls to `extend-type`.

17:10 tsdh: stuartsierra: Yes, but it's still a bug, right?

17:11 stuartsierra: depends. Nothing in the docstrings promises that extend-* work on arbitrary expressions.

17:11 Worth bringing up on the mailing list, however.

17:11 tsdh: If the class is a list, then it should omit the hint, I'd say

17:11 Ok, I'll write a mail.

17:11 stuartsierra: thanks.

17:15 hiredman: ,((fn [^(Class/forName "java.lang.String") x] (.getBytes x)) "foo")

17:15 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Metadata must be Symbol,Keyword,String or Map>

17:44 rqcursq: I dont know how to write tests i googled but icannot find any solution ?

17:45 dnolen: rqcursq: https://github.com/swannodette/delimc/blob/master/test/delimc/test/core.clj

17:45 there are fancier things like midje, but this way works for me.

17:46 rqcursq: dnolen: use travis for tests little suggestion from me :)

17:47 dump this in yaml file

17:47 language: clojure

17:47 script: "lein test"

17:47 rest is on every commit you do on travis

17:47 sorry github**

17:50 dnolen: rqcursq: sounds nice, but "mvn test" "lien test" at the REPL isn't much overhead

17:50 er command line :)

17:56 nerooth: Unable to connect to mongo db with clojure (congomongo "(mongo! :db "test") function), but it works with the mongo shell. Using mongo 2.0.0, clojure 1.2.1 and congomongo 1.7-snapshot. What's up?

17:57 amalloy: :db :test maybe?

17:59 nerooth: amalloy: nope. According to the congomongo examples the syntax should be (mongo! :db "name"), with host and port defaulting to localhost and 27017 (which is the port that mongo is running on)

18:00 amalloy: maybe ask seancorfield - congomongo 0.1.4-SNAPSHOT is working fine for me on several machines

18:01 nerooth: The fault is probably on my part, I just can't figure out what could be wrong. I've had it working on another project but now it's just not doing anything.

18:02 It should work as usual via lein repl, right?

18:08 seancorfield: hmm, i just installed mongodb 2.0 on my netbook but haven't tested congomongo against it yet

18:09 we're using congomongo 0.1.7 snapshot with mongodb 1.8.2 in production

18:09 nerooth: that's one thing that I remember has changed - will try downgrading mongodb

18:09 thanks for the pointer

18:35 Netpilgrim: Hi. In case one of the operators of 4clojure.com is around, I'm currently getting a 502 Bad Gateway for the site.

18:37 amalloy: dang it, again?

18:38 thanks Netpilgrim, up again

18:40 konr: What was the function to map an entire tree, again? like (maptree #(>% 1) [[1 0] 4]) -> [[false false] true]?

18:41 Netpilgrim: amalloy: Thanks. Great tech support! :)

18:42 amalloy: Netpilgrim: the best tech support will be if one of our users figures out what is going wrong and fixes it for us

18:43 Netpilgrim: amalloy: Sorry, probably out of my area of expertise.

18:50 amalloy: There is a typo in the description of problem 69. “the rest of the maps conj-ed onto the first” should probably read “the result of the maps conj-ed onto the first”.

18:51 amalloy: Hm, reading it again, it also makes sense the way it's written.

18:52 amalloy: I'm probably just tired but I had to read the whole description about three times before I got it.

18:52 amalloy: yeah, "result" doesn't make any sense, especially because ##(doc merge-with)

18:52 lazybot: ⇒ "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."

18:54 Netpilgrim: amalloy: This doc string could really be improved. “the latter (left-to-right)” is almost obfuscation.

18:57 amalloy: that said, please do let me know about typos or whatever. i'm itching to try out the new and improved question-editing UI

18:58 Netpilgrim: amalloy: I'll keep on the lookout.

19:43 amalloy: The questions often read “Write a function which …”. I’m not a native speaker and it might be nitpicking, but since what follows is not just some additional information but essential for the definition of the function talked about, shouldn’t it be “a function that”?

19:45 amalloy: you're probably right, and in many contexts i would care, but in this context it seems more like nitpicking

19:45 Netpilgrim: amalloy: Well, you were looking for something to edit. :)

19:46 amalloy: hah. okay, i'll fix one. example of a problem with that issue?

19:46 Netpilgrim: amalloy: Problem 70.

19:47 amalloy: But without looking through the problem, I think the phrase comes up very often.

19:48 amalloy: hm. that worked, but it set the "number of times solved" to 0

19:49 bugggg

19:50 konr: haha, it's so cool. I'm running pretty much the same algorithm I ran on Elisp in Clojure and the processing time went from minutes to about a second.

20:01 What's the fastest way to write 9 million strings in a vector to a file?

20:13 seancorfield: nerooth: i just tried congomongo 0.1.7 snapshot with mongodb 2.0 and it connected just fine (i had to swap to another machine to try it - i don't have 2.0 on this machine)

20:46 shep-home: Howdy all, what's the best way to debug a NPE?

20:46 I've been adding println calls, but that feels inefficient

20:47 (and they aren't really helping in this case, either)

20:48 hiredman: read the stacktrace

20:49 technomancy: before swank.break existed I'd stuff def calls into the middle of known problematic functions

20:52 shep-home: hiredman: yes, I did do that :-) The problem is that I must be missing something obvious

20:52 The line in question has a agent reference and a function name

20:52 and I println the reference in the line before

20:53 technomancy: I'm a super-n00b (like 2 days of Clojure), so I'm not sure what kind of stuff I'd put in those defs... :-)

20:55 https://gist.github.com/1223469

20:55 (please feel free to give me formatting tips too)

20:55 amalloy: #(do ...), not #((...))

20:56 technomancy: shep-home: if, not cond

20:56 amalloy: amusingly, it's your debugging code that's breaking it

20:57 technomancy: shep-home: in general, break things up into smaller and smaller pieces of functionality that can be called independently from the repl until you've isolated the problem

20:57 shep-home: technomancy: if/cond is a style tip, right?

20:57 amalloy: which line are you referring to?

20:57 technomancy: shep-home: yeah, it's not causing the problem

20:57 shep-home: amalloy: oh, I see

20:58 OK, I had previously been bitten by '((', I should have known better

20:59 I'll admit the cod was on purpose... I like the :else

20:59 cond*

21:02 Thanks for the tips technomancy and amalloy (and hiredman, of course)

21:03 konr: It's strange. my SLIME buffer is very slow and non-responsive, yet I've already cleared it with slime-repl-clear-buffer. Any idea of what's going on?

21:08 shep-home: Thanks for the tips technomancy and amalloy (and hiredman, of course)

21:09 doh, wrong window :-)

21:09 amalloy: probably wrong message too

21:45 mmarczyk: hi, is there someone experienced in Clojure's JIRA workflow around and willing to answer a basic question or two? :-)

21:45 dnolen: mmarczyk: I'm not experienced but what's up?

21:45 mmarczyk: oh yes you are :-)

21:45 anyway

21:46 say in the use-only case, if I change my mind about impl, is it better form to attach a patch based off of the previous one or a new one to be applied in one go?

21:48 and another thing, what's the established convention around bug reports: straight to JIRA (& be prepared to be flagged invalid if appropriate etc.) or always post on dev group first?

21:48 dnolen: mmarczyk: I think people tend to delete the old path and replace with a new one. Though personally I think it's nice to have the history of the various patches to see what design decisions came into play.

21:48 mmarczyk: I got straight JIRA unless there's some kind of design question involved.

21:48 go

21:49 mmarczyk: ok, thanks

21:49 I like having the history around too... oh well

21:49 oh, one more thing

21:49 do you have a reference to the upcoming Friedman paper you mentioned?

21:50 dnolen: not published yet and I can't share the copy I have. But it'll be out in for Scheme Workshop next month.

21:50 mmarczyk: got it, thanks

21:51 hiredman: dnolen: how do I negate a relation?

21:51 dnolen: hiredman: you can do a limited sort of thing with disequality constraints, which prevents two things from ever being unified.

21:52 I've been thinking about stratified negation, but it's not a priority at the moment.

21:55 hiredman: if you're looking for (not some-relation), no support for that.

21:57 hiredman_: dnolen: thanks (dunno if that came through be I got disconnected)

21:59 dnolen: hiredman: reading through the literature negation is suprisingly hard to implement. and event stratified negation seems … hacky (at least to this noob)

22:03 hiredman: you can do negation as failure in core.logic as you would in Prolog. if the goal succeeds, cut and fail.

22:04 prevents reversibility, but that may not be important for your particularly case.

22:04 hiredman: I'll just do with

22:24 konr: Any recipe to apply function X to the elements with odd position in a list?

22:27 bhenry: ,(doc map-indexed)

22:27 clojurebot: "([f coll]); Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thus function f should accept 2 arguments, index and item."

22:27 bhenry: konr: you can figure it out from there i presume

22:27 konr: thanks bhenry

Logging service provided by n01se.net