#clojure log - Oct 05 2011

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

0:03 popinigga: Hello

0:04 I'm new to Clojure and I've written some code in a file helloworld.clj on my desktop.

0:04 How do I run the code?

0:14 sean_corfield: I see #(some-fn % arg1 arg2 ..) quite often and wondered if there was some variant of something like partial that could remove the #(.. % ..) noise?

0:34 amalloy: (defn kinda-like-partial [f & args] #(apply f % args))?

0:34 that is: i'm not aware of one, but of course you can write your own

0:37 sean_corfield: ^

0:38 ibdknox: yeah, it's a good personal utility one

0:39 though, I think a good case could be made for it to be a function in core

0:39 I want such a thing all the time

0:39 amalloy: ibdknox: core is full to overflowing. if i were a meme-generator kinda guy, i'd be pasting you a link to an image full of something looking ready to explode

0:39 ibdknox: lol

0:40 yeah

0:40 I said a good case could be made, didn't say it should make it ;)

0:40 I mean we couldn't risk crowding things like with-bindings :p

0:40 that one still gets me

0:41 amalloy: ibdknox: with-bindings exposes functionality you can't get with plain-old binding

0:41 ibdknox: like?

0:41 amalloy: you don't always have var symbols; sometimes you only have var objects

0:42 ibdknox: for example, https://github.com/cognitivedissonance/clojail/blob/master/src/clojail/core.clj#L172 - without with-bindings, this whole function would have to be a macro

0:42 ibdknox: is there a reason that binding couldn't also allow that?

0:43 ah

0:43 I misunderstood

0:43 fair enough

0:43 amalloy: how could it? you can't tell, at macro time, whether the symbol 'foo refers to the var #'foo, or the var referenced by the local foo

0:44 ibdknox: yeah, I misunderstood what you were saying

0:45 amalloy: mkay

0:45 ibdknox: that makes sense

0:46 I almost would've expected that to be like binding*

0:46 maybe that need arises much more than I think though

0:47 amalloy: ibdknox: no, i think it's a fairly uncommon need

0:52 brehaut: amalloy: that kinda-like-partial is called 'dispatch' in moustache

0:54 sorry i lied

0:54 delegate

0:54 https://github.com/cgrand/moustache/blob/master/src/net/cgrand/moustache.clj#L172-176

0:56 michaelr525: is there a web browser built-in in emacs?

0:56 brehaut: theres a browser for emacs called W3 but i don't know if its built in

0:58 michaelr525: it's not in package-list-packages

1:04 no_mind: I have couple of files in a directory,. I want all these files to be part of a single namespace, identified by the directory path. For example, if the directory path is xyz/applications/accounts then all files in this directory should belong to namespace xyz.applications.account . How do I do this ?

1:11 michaelr525: no_mind: why do you want to do it like that?

1:12 no_mind: ease of managing packages

1:14 brehaut: no_mind: http://stackoverflow.com/questions/4690758/splitting-a-clojure-namespace-over-multiple-files

1:33 no_mind: brehaut: that doesnt work. I get an error saying "Could not locate xyz//applications/accounts__init.class or xyz/applications/accounts.clj on classpath" the directory xyz/applications/accounts is in the classpath

1:34 brehaut: no_mind: i have no idea sorry. i just remembered the link and thought it might be relevant

1:44 symbole: no_mind: I'm not too sure, but you might have to run compile on the class you're generating.

3:11 sivajag: Hey All

3:54 ejackson: morning folks

4:22 Blkt: good morning everyone

4:29 amalloy: anyone (like seancorfield) know if there's a way in congomongo to say "give me a document except for keys X and Y?" i know you can ask for *only* keys X and Y, but i don't see the opposite

4:30 pyr: i wanted to tryout msgpack rpc but it seems as though it relies on annotations

4:31 is there a way to provide annotations in clojure ?

4:31 amalloy: mongodb allows it with db.coll.find(query, {X: false, Y: false})

8:40 Fossi: hmmm

8:41 battlenet? i'm intrigued

8:42 wink: I wouldn't b :P http://github.com/winks/battlenet

8:43 ejackson: aaaah, a black hole.

8:44 Fossi: wink: :)

8:44 already found that

8:45 look too WoWy for me ;)

8:46 wink: I'm just now wondering what slows a page request down to only 3req/s.

8:46 probably not jetty, so maybe h2

8:46 a bit of html generated by noir loads at 123 req/s

8:51 eirikb: Hello. I'm trying to clojure:test with the maven plugin, it finds my test but no deftest

8:51 edw: Is it possible to make a List<String> in clj? I'm working on a thrift server right now.

8:52 eirikb: I understand it will (run-tests) on the test

8:53 napping: edw: You should be able to make a List and fill it with Strings

8:53 edw: Will that 'satisfy' the interface's signature?

8:54 napping: generics are erased, so it should

8:55 edw: OK. Thank you.

8:57 napping: Is it not easy to test?

9:16 eirikb: Anyone know about any example projects with the maven plugin and some tests with larger namespaces (not just src/main/clojure/main.clj)

9:26 I'm guessing I have messed up ns, but it still finds the file. Although it should (run-tests 'some.ns)

9:38 ejackson: eirikb: hmm.... I have made this work in the past. Lets see.

9:38 Have you got the main and test directories properly set up ?

9:38 eirikb: ejackson: https://github.com/eirikb/comicparser/tree/clojure

9:39 Don't mind the java-parts and the resources

9:39 ejackson: I'll poke around for you a bit...

9:39 eirikb: Thanks a lot

9:39 mcoffbyone: hi, could anyone recommend me some clojure library which does a lot of file/directories/regex/parse related stuff?

9:40 (need to learn how to do it elegantly not to use it)

9:40 ejackson: eirikb: ah, you're not using the clojure-maven-plugin

9:41 eirikb: ejackson: Using the first hit on google

9:41 talios/clojure-maven-plugin

9:41 ejackson: that's the one

9:41 about halfway down it talks about testing

9:42 eirikb: I took the pom setup from here: https://github.com/talios/clojure-maven-plugin

9:45 ejackson: eirikb: your pom doesn't have the plugin listed https://gist.github.com/1264459

9:45 that gives gives you clojure testing in the test goal

9:46 eirikb: I do have the goal now though, and it find the file. It just does not run any deftest.

9:46 I updated my pom, let me try

9:48 ejackson: you also need to put your tests into a test namespace

9:50 so to test the namespace no.eirikb.comicparser.comicparser you need your tests to live in the namespace no.eirikb.comicparser.test.comicparser

9:51 or at least that was the arrangement back when I was using maven

9:57 eirikb: there's something up with your fork as well, if I try to fork off of it I only get the java :)

10:04 duck1123: ejackson: I believe they can live in any namespace in the test directory. The plugin shoul pick up all of them

10:11 ejackson: duck1123: OK, cool. I was just looking at a working project of mine and spewing forth.

10:12 duck1123: Personally, I prefer to name my test namespaces a.b.c-test

10:12 in part because it makes it easier to tell the buffers apart in emacs

10:14 ejackson: fact !

10:24 gfredericks: using clojure-maven for the first time, repl is primitive. Anybody know what a man gots to do to get rlwrap or whatever hooked up?

10:28 ejackson: gfredericks: id suggest using swank and getting at the repl via emacs

10:28 gfredericks: ejackson: what about the persecuted minority of vim users? :)

10:29 algernon: run vim from emacs, and get the best of both worlds

10:29 ejackson: there's a nailgun plugin too

10:29 (what exactly that means I don't know, but vim folk seem to like it)

10:29 gfredericks: algernon: vim from emacs works with swank and all that?

10:29 eirikb: ejackson: Did you clone the correct branch?

10:30 Guest66735: I started using vsclojure in vs2010 and I'm having a problem with my solution suddenly not compiling any more. if i check out the project again to a different location, it compiles, but eventually will fail repeastedly (BootstrapCompile has stopped working). Is this a known problem - file corruption or something?

10:30 eirikb: duck1123: But why are the tests not run?

10:30 ejackson: eirikb: must be the issue... you having any luck ?

10:30 eirikb: have you explicitly tried mvn clojure:test

10:30 eirikb: ejackson: Nope

10:30 Yes

10:31 Guest66735: btw, the exact same code compiles fine from command line or ccw in eclipse

10:34 eirikb: ejackson: It says: Testing no.eirikb.comicparser.comicparser \n\n Ran 0 tests containing 0 assertions.

10:35 ejackson: yeah, I'm having a look now

10:35 eirikb: Have to go for a short bit, be back in an hour

10:36 duck1123: eirikb: your test files are in src/test/clojure/ right?

10:36 the clojure-maven-plugin creates a test runnier in /tmp might whant to check out what namespaces it picked up

10:36 eirikb: duck1123: Yes, https://github.com/eirikb/comicparser/tree/clojure

10:37 duck1123: yeah, I can see it uses require

10:37 duck1123: you need to configure the plugin for tests

10:38 let me see if I can find my old poms

10:39 eirikb: duck1123: Namespace configuration under https://github.com/talios/clojure-maven-plugin ?

10:39 Seems to only be for limiting

10:40 And additional sources should not be needed either, as it finds my file

10:40 duck1123: Here's one of the files I was using https://github.com/duck1123/jiksnu/blob/5a124e864e2a98089d14ae56a798fc851277ebcc/pom.xml

10:40 so what happens when you do mvn clojure:test

10:41 eirikb: duck1123: https://gist.github.com/1264580 (the ns is probably wrong, but same with no.eirikb.comicparser)

10:42 I see you have <execution>, same as ejackson had. It did not seem to help me

10:43 ejackson: eirikb: if I move your test into a test dir it finds it

10:43 eirikb: ejackson: src/test/clojure/test ?

10:43 ejackson: i sec and I'll commit it back up for you

10:43 eirikb: cool

10:44 Ah, no.eirikb.comicparser.test.comicparser ?

10:45 That seems to do the trick at least

10:45 ejackson: eirikb: yes that's the one

10:46 eirikb: ejackson: Thanks a bunch! you even mentioned this earlier but I didn't test it out, sorry :(

10:46 ejackson: no worries, enjoy.

10:47 vinibaggio: hello, I'm still beginning Clojure and I am having a hard time to grasp some concepts, such as doseq. Do anyone know (besides clojure's own doc) any resource that could help me with that?

10:47 eirikb: What version of the maven plugin is the one I should use? On the github page it was 1.3.4, while I see 1.3.8 is in the repo and duck1123 had 1.3.7

10:47 ejackson: eirikb: no idea I'm afraid.

10:48 vinibaggio: I'd really suggest you get a book :)

10:48 eirikb: ejackson: ok =)

10:48 ejackson: Tried updating to 1.3.8 to see if I still had to put it under a test-folder, and that I did

10:49 ejackson: yeah, maven is persnickity.

10:49 eirikb: hehe. Well it works perfectly now

10:50 vinibaggio: ejackson: I am trying to follow The Joy of Clojure, but it's being difficult to me, I have to admit. It assumes I've understood what it does

10:51 ejackson: do you recommend any other?

10:52 ejackson: vinibaggio: yeah, JoC is not the point of departure, more the goal :)

10:53 I really like Programming Clojure, by Halloway

10:53 vinibaggio: ejackson: cool to know. I've been enjoying the read, it's amazingly well written, but quite hardcore for a beginner hehe

10:53 ejackson: but the others are all good too

10:54 vinibaggio: ejackson: okay, I will start with that. Thanks!

10:54 ejackson: enjoy.

10:54 vinibaggio: :)

10:54 ejackson: be aware that its a bit out of date though

10:56 vinibaggio: hmm I think it may serve as a good start nevertheless. It doesn't cover Clojure 1.3, right?

10:57 i think the problems I have are not very version-aware, but getting the whole LISP state of mind in my mind

10:57 duck1123: Programming Clojure covers 1.0, but I think there's a second edition in the works

10:58 rbranson: just keep trying on JoC

10:58 it's dense, but very rewarding

11:03 gfredericks: duck1123: I was just looking at a pdf of the second edition, coincidentially

11:04 vinibaggio: hmm ok, I think I will fallback a little bit on Programming Clojure and try to follow JoC after I have a better grasp on the language. Thanks guys

11:04 gfredericks: one of the beta versions I guess

11:05 rbranson: I have no previous LISP experience and found JoC to be a fantastic introduction

11:06 duck1123: so, it you bought the first edition, you have to pay for the second ed?

11:07 vinibaggio: rbranson: yeah, I am enjoying it, but i am having trouble to have a complete understanding of it. sometimes i feel i am leaving something out

11:08 rbranson: vinibaggio: it's a relatively challenging book

11:08 vinibaggio: rbranson: that's awesome :)

11:09 rbranson: vinibaggio: I found that it helped to stop and actually start hacking through some 4clojure to get my "watermark" up so that I really understood the previous material

11:09 vinibaggio: rbranson: ah yes, i am trying to do that. I am solving some project euler problems, and also spoj.pl

11:09 rbranson: no pain, no gain :)

11:10 ejackson: you guys are on the right track, as the rapper laureate himself said, "Lisping aint easy"

11:10 rbranson: i have been pleasantly surprised by the challenge, usually the challenge in learning a new language is learning the tools/environment

11:10 vinibaggio: rbranson: what was troublesome to me is that i am trying to read input from STDIN, and the example I've found used doseq, and I didnt understand what it does, and I, as a total beginner, am not understanding how to work with it

11:11 rbranson: exactly! that's how i feel about JoC, and that's why i am loving reading it

11:11 rbranson: vinibaggio: i don't really fully grasp the lazy-seq / doseq stuff yet either

11:12 dnolen: vinibaggio: doseq is simply a way to write imperative code on sequences.

11:12 gtrak: for me, the challenge is it feels like I'm doing less work, since it's less keypresses, and you can maybe express a few java classes worth of code in a couple of lines of clojure, but the trick is to know the best way to express it

11:13 rbranson: gtrak: yeah, clearly there's the "silly unwashed clown" way of solving problems :)

11:13 dnolen: vinibaggio: (doseq [x ...] (draw-to-screen x)) as opposed to (map inc xs) which returns a new sequence

11:14 gfredericks: dnolen: and importantly map is lazy so it won't necessarily do anything

11:14 rbranson: I don't feel like doseq is super duper important at the beginning stage, most of the time you can build on-top of the library

11:14 dnolen: gfredericks: that too.

11:14 rbranson: recur feels really important though

11:14 gfredericks: not so important is the rarely-used do-not-seq

11:15 rbranson: donut-seq?

11:15 vinibaggio: dnolen: hmm, okay, I will try to play with it here, thanks

11:15 gfredericks: doughnut-seq

11:15 rbranson: my experience in #clojure is that beginners often use recur a lot more than they need to

11:15 rbranson: gfredericks: i agree

11:15 gfredericks: when map or reduce would do what they need

11:15 rbranson: gfredericks: ignorance of the core library

11:16 gfredericks: coming from another language you're used to having to do algorithms by hand

11:16 so loop/recur seems like the best way to do nearly anything

11:16 rbranson: recur is a special form though, so i feel it's worth knowing

11:17 Chousuke: recur is fine, but loop tends to be a code smell

11:17 gfredericks: rbranson: just like monitor-enter? :)

11:17 rbranson: gfredericks: :)

11:17 gfredericks: Chousuke: you mean in contrast to recuring to a fn?

11:17 Chousuke: yes

11:18 lots of newbies using loop just think they want a looping construct

11:18 so they end up using loop

11:19 gtrak: maybe we should change the name of loop to something less recognizeable

11:19 rbranson: I think people make the same mistake in learning python/ruby

11:19 gfredericks: I was about to say it sounds like Chousuke just doesn't like the name

11:19 Chousuke: nah, that's just obfuscation

11:19 rbranson: so it's not clojure's fault ;)

11:19 Arafangion: rbranson: Python, no, ruby, yes.

11:19 gfredericks: Chousuke: what kind of refactoring do you do when you see a loop?

11:19 Chousuke: gfredericks: the name is irrelevant. it's just what the newbie will find when they search for loops :P

11:19 zerokarmaleft: vinibaggio: restricting yourself to working inside the REPL will help you get used to thinking about functional composition

11:19 gtrak: maybe people could say... i want to loop, but there's no loop keyword, how the f do I loop?

11:19 Arafangion: rbranson: The right way to loop /is/ to do a loop in python.

11:19 gtrak: ah... maybe map does what I need

11:20 Chousuke: gfredericks: I'm not saying all loops are bad but you can get away without an explicit one in most cases

11:20 rbranson: Arafangion: list comprehensions replace a good number of cases though

11:20 gtrak: maybe instead of loop, call it label

11:20 rbranson: Arafangion: I see what you're saying though, list comprehensions are kind of a special case

11:20 Arafangion: rbranson: Indeed.

11:21 Chousuke: gfredericks: that's why it's always somewhat suspicious if you see lots of looping

11:21 Arafangion: rbranson: Also, note that recursion is Bad in python.

11:21 gtrak: label-recur makes people think of gotos, and makes them feel worse about it

11:21 rbranson: haha

11:21 vinibaggio: Chousuke: I felt this way, I build a fibonacci totally with loops, and almost every implementations I've seen on clojure does not use loops nor recursions (at least in a clear manner). Maybe it would be nice for beginners to have some sort of comparison, and how to achieve that?

11:21 dnolen: Chousuke: gfredericks: unless of course it's a tight inner loop ;)

11:22 Chousuke: vinibaggio: maybe

11:22 rbranson: vinibaggio: I feel like some of those become "golfing"

11:22 there's definitely a threshold where code clarity takes a backseat to compactness

11:23 Chousuke: vinibaggio: the main issue is learning to use laziness

11:23 vinibaggio: Chousuke: i think so

11:23 gfredericks: and parentheses

11:23 arohner: I'm seeing an issue where noir is listening on ipv6 8080, but not ipv4 8080. Any ideas?

11:23 Chousuke: people with no functional background think in loops so using lazy sequences is something they can't even consider

11:24 until they encounter it somewhere

11:24 rbranson: are lazy seqs pretty much the norm?

11:24 zerokarmaleft: rbranson: coming from ruby, i find code clarity in lisps have a different paradigm...the shape of the code matters more than names of symbols

11:24 ejackson: I want to create a macro that does does some defs. I want to use that macro in various other namespaces. Clojure says "can't def in another namespace" Is there a workaround?

11:24 clojurebot: macro are just a game with symbols

11:25 ejackson: thanks clojurebot

11:25 Chousuke: rbranson: Clojure provides you with a whole library of dealing with sequences, so if you use sequences, you get lots of useful tools for free.

11:25 rbranson: Chousuke: right, but i'm talking about idiomatic code

11:25 arohner: ejackson: with-ns, in contrib

11:25 Chousuke: whereas looping always requires manual work.

11:25 ejackson: arohner: thanks, i'll check it out

11:25 Chousuke: sometimes you need a loop for performance reasons but yeah lazy seqs are almost always more idiomatic

11:26 gtrak: laziness should be invisible unless you're dealing with side-effects

11:26 raek: ejackson: maybe you are using syntax-quote for the def name.

11:26 clojurebot: defmulti doc is (defmulti #^{:doc "docs for foo"} foo class)

11:27 raek: , `(def foo)

11:27 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

11:27 ejackson: raek: yeah, I am... ha ! let me try do it raw. thanks.

11:27 gfredericks: ejackson: I've done what you described and had no trouble. I think I was using regular backquote: `(defn ~thing-name ...)

11:27 raek: ejackson: you don't want the name you pass to be qualified with the namespace that the macro was defined in

11:28 *the name you pass to 'def'

11:29 vinibaggio: this was a pretty nice discussion guys, thanks, learned a ton :)

11:29 raek: you can use `(def ~'my-name ...) to circumvent syntax-quote

11:29 ejackson: raek, yeah, gfredericks, I think I understand you guys. Lemme play a bit, thanks.

11:29 gfredericks: ejackson: when in doubt, sprinkle punctuation liberally

11:30 ejackson: :D

11:30 gfredericks: `~'~~('def ``~'puddle-ducks @@~'`&args)

11:30 ^ expands to whatever you need your code to do

11:31 ejackson: raek: Winner, winner, chicken dinner.

11:31 TimMc: throw in some # just to make sure

11:32 ejackson: gfredericks: you're a perl exile i see.

11:32 gfredericks: ejackson: only in jest

11:32 * gfredericks could not recognize perl if it came up and punctuated in his face

11:33 zerokarmaleft: gfredericks: Q(`_')-o

11:33 recognize!

11:33 gfredericks: that's just an emoticon, right?

11:33 maybe for something obscene?

11:34 zerokarmaleft: fairly certain it's not valid perl, but i don't think it's obscene

11:34 s/but/and/

11:34 lazybot: <zerokarmaleft> fairly certain it's not valid perl, and i don't think it's obscene

11:35 Arafangion: If it were perl, then it would be obscene.

11:36 gfredericks: fun fact: Every obscenity is a valid perl expression, and vice versa.

12:11 bsod1: I want to create an NxN grid with vectors, what is the idiomatic way to do this in clojure?

12:17 eblood: i don't know the idiomatic way, but a quick way to create a seq of seq: (repeat n (repeat n 0))

12:23 zerokarmaleft: bsod1: (for [x (range n) y (range n)] [x y])

12:28 eh, that should be (for [y (range n) x (range n)] [x y]) if you want them ordered by row

12:29 TimMc: zerokarmaleft: I don't think that's correct.

12:29 That gives a seq of coordinates, not a 2D array (matrix).

12:30 zerokarmaleft: ah, i read his question as a NxN grid with a vector at each (N, N)

12:31 TimMc: ,(for [y (range 2) x (range 3)] [x y])

12:31 clojurebot: ([0 0] [1 0] [2 0] [0 1] [1 1] ...)

12:31 TimMc: (repeat 2 (repeat 3 0))

12:31 ,(repeat 2 (repeat 3 0))

12:31 clojurebot: ((0 0 0) (0 0 0))

12:34 raek: ,(for [y (range 2)] (for [x (range 3)] [x y]))

12:34 clojurebot: (([0 0] [1 0] [2 0]) ([0 1] [1 1] [2 1]))

12:35 zerokarmaleft: TimMc: how would you access the value at x,y for that matrix?

12:36 PPPaul: what is the proper way to execute some side-effect code on a list? i'm doing (doall (map))

12:36 raek: ,(vec (for [y (range 1 4)] (vec (for [x (range 1 4)] (+ (* y 10) x)))))

12:36 clojurebot: [[11 12 13] [21 22 23] [31 32 33]]

12:36 raek: ,(let [matrix (vec (for [y (range 1 4)] (vec (for [x (range 1 4)] (+ (* y 10) x)))))] (get-in matrix [1 1]))

12:36 clojurebot: 22

12:37 raek: PPPaul: if you don't care about the return value of the function with side-effects, you should use dorun

12:37 (dorun (map println ["foo" "bar"]))

12:37 PPPaul: ok

12:37 raek: doseq is also very useful

12:38 PPPaul: using map, instead of some other construct, is still considered ok?

12:38 raek: (doseq [x coll] ...) = (dorun (for [x coll] (do ...)))

12:38 sure

12:38 PPPaul: for... i still don't understand for >_<

12:39 raek: it's like map, but with swapped arguments and an implicit anonymous function...

12:39 PPPaul: hmm

12:39 raek: (map (fn [x] (+ (inc x) (dec x))) [1 2 3 4])

12:39 PPPaul: i've seen for do magic

12:40 raek: (for [x [1 2 3 4]] (+ (inc x) (dec x)))

12:40 PPPaul: ooooooooh

12:40 raek: I usually pick for when I find myself writing (fn ...) in a map

12:40 PPPaul: i'm beginning to understand it

12:40 seancorfield: amalloy_: just saw your Q about congomongo... no idea so i'll go take a look

12:40 raek: it looks much prettier for bigger fns

12:41 doseq has the same syntax as for

12:42 but also allows multiple expression in the body (as if there was an enclosing 'do')

12:42 crazyFox: hi. i am dealing with a group of entities that all have the same kinds of properties. first approach: using a record data type. downsides: every access of some property requires repetitive code to get to the atomic values; slower. second approach: have a separate vector for each kind of property. downside: the different properties of an entity are only linked via their positions in the...

12:42 ...vectors. Any thoughts about the matter?

12:44 TimMc: zerokarmaleft: get-in

12:44 duck1123: crazyFox: proper use of destructuring should take care of a lot of the repetitive field access for maps / records

12:44 TimMc: But we haven't heard back from bsod1 about the specific requirements.

12:44 seancorfield: amalloy_: nope, it forces { fieldname: true } but it would be a nice enhancement to let it take a map of fields instead of just an array and then you could set true / false for selecting / omitting fields

12:44 i'll open an issue for that

12:45 zerokarmaleft: raek: is your matrix snippet still lazy?

12:46 crazyFox: duck1123: right now it looks sth like this: (let [xs (map :key entities) ...] ...)

12:46 raek: zerokarmaleft: the 'vec' calls forces the sequences returned by for

12:46 zerokarmaleft: that's what i suspected

12:46 TimMc: PPPaul: `for` can also do filtering and other fancy stuff.

12:46 raek: but if you leave out the 'vec' calls you have a lazy sequence of lazy sequences

12:47 PPPaul: !

12:47 gilescb: hi all, in core.logic is there something equivalent to prolog's retract?

12:48 duck1123: crazyFox: ok, if you're trying to key the :key field from every entry, that's probably the best you're going to get. But you'll probably need map no matter what

12:49 raek: (for [x (range 10), :let [y (* x x)], :when (even? y)] ...)

12:49 duck1123: if you're parsing them one record at a time, you can use destructuring to populate the variables for that record

12:50 crazyFox: duck1123: the thing is, i often need one property from all the entities at once

13:52 jjido: ,(char 33)

13:52 clojurebot: \!

13:58 gfredericks: ,(int \!)

13:58 clojurebot: 33

14:00 jjido: thanks g. I wanted the next char after space and couldn't find the syntax in lua

14:00 or python

14:01 (on my iPhone)

14:02 gfredericks: you mean they let people program without having memorized ASCII?

14:02 jjido: lol

14:09 gfredericks: I'm not letting my kid go to any school that doesn't teach ASCII alongside the alphabet.

14:10 tordmor: and at least superficial knowledge of the more important unicode areas

14:11 gfredericks: if I pick any unicode character, he ought to have at least _seen_ it by third grade.

14:11 scgilardi: bmp: it's not just for bitmaps any more.

14:11 gfredericks: scgilardi: what's it for?

14:11 jjido: lol again

14:12 scgilardi: gfredericks: the basic multilingual plane

14:12 gfredericks: scgilardi: ah yes.

14:13 I just read on the relevant wikipedia article: "Plane 3, the Tertiary Ideographic Plane (TIP), is reserved for Oracle Bone script, Bronze Script, ..."

14:14 and clicked on the "Oracle Bone" link wondering what weird oracle project it was

14:14 and why some dumb piece of proprietary technology got its own swath of characters

14:15 jjido: you should know 'ideographic'

14:19 cb`: Hi, hope you can help. I'm trying to setup Clojure on Emacs and am following the instructions on http://dev.clojure.org/display/doc/Getting+Started+with+Emacs. I'm on Windows 7

14:21 Kind of like Joshua Wood's comment at the bottom of that page I get an error when trying to run M-x clojure-jack-in which says: "sh: line 1: lein jack-in 63783: command not found". However lein is on the PATH. I can run lein from a running eshell without issue. Any ideas?

14:21 technomancy: cb`: running clojure-mode from git or marmalade?

14:22 hiredman: cb`: on osx by any chance?

14:22 cb`: technomancy: marmalade

14:22 hiredman: Windows 7

14:23 hiredman: ah, well, interesting choice there

14:23 technomancy: cb`: I just made some commits in git that should at least make it more clear what the problem is; maybe try that?

14:23 if it works on windows I'll push the release to marmalade

14:24 cb`: technomancy: Alright, thanks. Will give it a shot and report back here.

14:24 technomancy: Best to remove using package.el first or it'll pick up the latest version of clojure-mode regardless?

14:25 technomancy: cb`: yeah, try that

14:25 and restart emacs since it involves a defvar change

14:28 bsod1: I can't import clojure.contrib in my counterclockwise project, anyone know why? => clojure.contrib/priority-map #<CompilerException java.lang.ClassNotFoundException: clojure.contrib (NO_SOURCE_FILE:0)>

14:29 gfredericks: bsod1: I didn't think clojure.contrib was ever a namespace...

14:29 amalloy: it ain't

14:30 bsod1: so how can I use clojure.contrib.priority-queue? sorry I'm new at clojure

14:30 gfredericks: (use 'clojure.contrib.priority-queue)

14:30 or (require '[clojure.contrib.priority-queue :as pq])

14:30 bsod1: gfredericks: #<CompilerException java.io.FileNotFoundException: Could not locate clojure/contrib/priority_queue__init.class or clojure/contrib/priority_queue.clj on classpath: (NO_SOURCE_FILE:0)>

14:31 amalloy: seancorfield: what's the canonical congomongo repo? i'll have a look at permitting maps

14:32 gfredericks: bsod1: I don't see docs for priority-queue in clojure-contrib -- where are you seeing it?

14:32 amalloy: (i'm just going to assume it's aboekhoff's github repo)

14:32 cb`: technomancy: Now *swank* buffer looks alot better. There are lot of lines in there and last one is: ";;; proceed to jack in"

14:33 technomancy: cb`: but no repl?

14:33 cb`: technomancy: However, *Messages* has: "error in process filter: eval-buffer: Symbol's function definition is void: define-slime-contrib" and yes, no repl

14:33 technomancy: cb`: you've got some slime configuration that only works with CL slime

14:34 bsod1: gfredericks: yeah I was looking wrong place, I think right one is this. https://github.com/clojure/data.priority-map

14:34 still I don't understand how can I use this

14:35 gfredericks: bsod1: it'd be (require '[clojure.data.priority-map :as pm])

14:35 where 'pm' is whatever prefix you'd like to use

14:35 bsod1: gfredericks: same error: #<CompilerException java.io.FileNotFoundException: Could not locate clojure/data/priority_map__init.class or clojure/data/priority_map.clj on classpath: (NO_SOURCE_FILE:0)>

14:35 gfredericks: bsod1: It has to be included in your project as a dependency

14:36 how you do that with CCW, I don't know. Maybe build the jar and include it on the classpath somehow? Someone else may be able to comment better.

14:36 if you're using leiningen too, it shouldn't be hard

14:36 no idea if leiningen and CCW go together

14:36 cb`: technomancy: a hah.. OK, I commented out any previous slime related stuff from init.el and fired up another Emacs instance and I get a REPL with M-x clojure-jack-in!

14:37 technomancy: cb`: great! is the config you removed important?

14:37 cb`: technomancy: Do you know if it's possible to shield the CL slime config from Clojure? It looked to me like clojure-jack-in used its own copy of Slime anyway?

14:38 technomancy: cb`: I'm not sure; I don't use common lisp

14:38 amalloy: anyone know if type-hinting helps the compiler with protocol lookup? like, (extend-protocol SomeProto MyType (impl [this args] ...)) ... (impl ^MyType foo "test")

14:38 cb`: technomancy: It's quicklisp's version of Slime. I'd have to investigate to figure out what part is causing it to brek. So far it "just worked"

14:38 technomancy: this comes up periodically, but none of the CL users have gotten back to me about a reasonable fix

14:38 cb`: what's the offending config look like?

14:38 amalloy: it seems to me like it shouldn't help, but i don't know everything about what's going on in protocols

14:39 cb`: technomancy: I'll probably join that list of offending users as I'm not a CL expert either. Just dabbling in CL, Scheme and Clojure for now. But I will try and determine what subset of this config is causing the problem.

14:42 technomancy: It appears to be (slime-setup '(slime-fancy))

14:43 technomancy: That's a configuration for slime that tells it to use several of the common contrib packages. Perhaps cojure-mode just needs to grab slime contrib as well as slime when it's running clojure-jack-in?

14:45 technomancy: that's one way to do it

14:45 bsod1: argh, I can't use clojure.data.priority-map in la clojure too... it shouldn't be that hard.. I've already have clojure-contrib.jar imported in my project

14:46 technomancy: slime-setup-contribs could also just go inside an ignore-errors

14:47 cb`: A related question is, is it possible to get clojure-mode to save its copy of Slime somewhere? It seems to be downloading it each time and in that case downloading the contrib directory would obviously take a bit longer. I wouldn't really mind an extra bit of download time if it was a one off

14:47 technomancy: cb`: sure, swank-clojure 1.3.3 does that

14:47 (it's not downloading it from the 'net, just unpacking it out of the jar though)

14:48 cb`: oh, cool. I didn't realize it was coming from the jar. That's actually not so bad. I was concerned about trying to kick it off when not connected to the net. A few seconds of loading doesn't bother me too much

14:49 technomancy: yeah, but it's ugly

14:49 cb`: is 1.3.3 good to use or should I stick to 1.3.2 for other reasons?

14:49 technomancy: 1.3.3 is better

14:51 cb`: I don't notice a lein upgrade option. If I just ran "lein install swank-clojure 1.3.3" would that take of it?

14:51 technomancy: I think so

14:51 you may need to uninstall the old one; I'm a bit fuzzy on how that works

14:52 cb`: is adding slime-setup-contribs inside ignore-errors a quick fix? I'd be happy to try it out and confirm if it works here

14:53 technomancy: should be; can you give it a try?

14:53 if that works I'll add it to the swank readme

14:54 bsod1: can anyone help me? I created a lein project, added clojure 1.3 and clojure.contrib 1.2 to deps, run lein deps, run lein repl, and still can't use clojure.data.priority-map

14:57 ibdknox: bsod1: contrib won't work with 1.3, and I don't think there's an official release of clojure.data yet

14:57 technomancy: bsod1: priority map is not part of contrib 1.2; it's a separate project

14:57 clojurebot: what happened to contrib?

14:57 clojurebot: excusez-moi

14:57 technomancy: clojurebot: where did contrib go?

14:57 clojurebot: well... it's a long story: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

14:58 cb`: For what it's worth the list of things in slime-fancy is: slime-repl, slime-autodoc, slime-c-p-c, slime-editing-commands, slime-fancy-inspector, slime-fuzzy, slime-presentations, slime-scratch, slime-references, slime-package-fu and slime-fontifying-fu. I think at least some of those are used/working in clojure-mode.

14:59 technomancy: cb`: yeah, that could possibly be added to the bootstrapped elisp in the jar

14:59 but right now it loads everything; there's no way to configure which you want

14:59 bsod1: ibdknox: so how can I use this priority-map?

14:59 technomancy: maybe a separate swank-clojure-fancy jar could be used for that

15:00 ibdknox: bsod1: [org.clojure/data.priority-map "0.0.1"] it appears

15:03 sritchie: cemerick, have you had any trouble getting the clojure view server started (with clutch) in 0.2.5-SNAPSHOT?

15:03 cemerick: sritchie: no; though, 0.2.5 was released last week IIRC

15:03 I saw your message; you probably have a classpath issue in your view server config.

15:03 * cemerick is socked in with presentation stuff and clojurescript hacking at the moment

15:04 sritchie: cemerick got it, I'll keep playing. The server command works fine when I copy it into the command line, it just fails when couchdb tries to run it

15:04 cemerick: ah, that's interesting

15:05 Well, try 0.2.5 release. If you're still having issues, ping me (though probably not 'til next week? :-)

15:06 sritchie: cool, this is the homebrew couchdb, maybe I'll try couchbase or something

15:06 1.1.0. thanks for taking a look, I'll ping you next week

15:13 cemerick: sritchie: I do all my testing with CouchDBX or couchbase single, FWIW.

15:14 I'm seeing some very odd behaviour out of clojurescript macros.

15:14 Which probably means I'm not using them properly. :-P

15:14 a simple macro: (defmacro emit [k v] `(- k v))

15:15 when used, it produces javascript like: com.K.N.M.O - com.K.N.M.P

15:15 neither of which exist at runtime

15:16 chouser: cemerick: are you pulling it it with use-macros or require-macros?

15:16 cemerick: require-macros

15:16 chouser: hm. dunno why that wouldn't work.

15:17 cemerick: I'm just baffled by where those names are coming from.

15:17 or, not 'just', perhaps 'additionally'

15:17 chouser: you're using gclosjure advanced?

15:17 cemerick: yup, {:optimizations :advanced :pretty-print true}

15:17 * cemerick running simple just for the hell of it

15:17 cb`: technomancy: I'd not tried to use ignore-errors before. I tried wrapping (slime-setup '(slime-fancy)) in my config with (ignore-errors ...) but it didn't seem to help. I guess because the error doesn't happen when emacs starts up anyway, it's later when clojure-jack-in runs. I could be using it wrong though

15:18 cemerick: what a fool

15:18 chouser: I didn't put tildes in the macro body

15:19 good grief, Charlie Brown.

15:20 amalloy: chouser: any idea what's up with data.xml? it looks like the indentation test you wrote is failing on jira, but it works when i run tets locally so i'm not sure how i can get it building

15:21 cemerick: hey all: I'm speaking on (experimentally!) using ClojureScript to build CouchDB views, tomorrow night at the Bay Area Clojure Meetup: http://bit.ly/pFjdVK

15:21 seancorfield: you asked about my topic :-) ^^

15:21 amalloy: er, on hudson. or jenkins or whatever the dang build server is

15:22 chouser: amalloy: sorry, I still haven't given data.xml the love it needs.

15:23 amalloy: if it will help i can get out a pitchfork or other threatening-looking device

15:25 chouser: the xml emit stuff relies a lot on whatever xml processing classes are loaded into the jvm instance.

15:25 that might be related to whatever's causing it to fail.

15:25 what's the jenkins url?

15:27 amalloy: chouser: http://build.clojure.org/job/data.xml/ is in the general area

15:28 chouser: and http://build.clojure.org/job/data.xml/lastUnsuccessfulBuild/console has the test output

15:28 chouser: yeah, it's clearly not indenting it

15:28 isn't it.

15:29 amalloy: indeed. but when i run the test myself, it passes

15:30 seancorfield: amalloy: thanx for the patch for congomongo - merged and i'll post an updated snapshot build in a few

15:30 amalloy: perhaps jenkins and i have a different instance of (javax.xml.transform.TransformerFactory/newInstance)

15:30 chouser: amalloy: yeah, probably. ugh.

15:34 I don't know if that can be forced for hudson, or at least reported on the console?

15:34 PPPaul: in slime what can i press to kill the current operation?

15:35 amalloy: chouser: http://stackoverflow.com/questions/1264849/pretty-printing-output-from-javax-xml-transform-transformer-with-only-standard-ja seems to be suggesting you can also try setting an attribute on the factory

15:36 but it's equally implementation-dependent what properties the factory supports

15:37 as for reporting on the console, you can print out the class of the transformer you get back, right?

15:41 chouser: amalloy: yeah, I'd think so.

15:53 kencausey: Why for lein deps (in this case for cascalog) do I see messages indicating that each jar is downloaded 3 times, once each for conjars, clojars, central?

15:55 Should I assume no actual download occurs for each message unless I see a comparable Transferring message?

15:55 hiredman: kencausey: I believe those messages are for each attempt to download, it looks for jars from each repo

15:55 kencausey: I see, so it should really be a 'Looking for ... in ...'

15:56 thanks

16:28 cb`: technomancy: I'd not tried to use ignore-errors before. I tried wrapping (slime-setup '(slime-fancy)) in my config with (ignore-errors ...) but it didn't seem to help. I guess because the error doesn't happen when emacs starts up anyway, it's later when clojure-jack-in runs. I could be using it wrong though

16:29 technomancy: cb`: hm... I guess what you really want is to defer that execution until you're connecting and you know it's a CL instance

16:29 cb`: I did however add (setq slime-setup-contribs nil) to the top of clojure-jack-in's definition and that worked (though of course with the side effect of wiping out part of your slime config if you do run it later)

16:29 technomancy: well, you can't go from jack-in to a CL slime session without restarting emacs anyway, so that shouldn't be a problem

16:30 cb`: How come it uses its own version of slime? Is it just to reduce the amount of things a user has to install?

16:31 technomancy: cb`: CL makes you install slime from CVS

16:31 two reasons this is infeasible for clojure:

16:31 0) my conscience won't allow me to suggest users install CVS and 1) slime from CVS is always breaking, and I don't have the time or inclination to fix it.

16:32 cb`: it's on ELPA now, or marmalade (I'm not sure how to get Package Menu to show the source of a particular package)

16:33 technomancy: the marmalade version is not compatible with CL

16:33 cb`: with some particular CL? It seems a bit redudant to have it there if it doesn't work

16:34 technomancy: it's there for Clojure

16:34 bundling it via jack-in is a pretty recent development

16:34 however, you can use swank-clojure with marmalade's slime, it's just more manual and error-prone

16:34 useful if you're connecting to a swank server in production or something though

16:35 cb`: ok

16:35 well, the git version of clojure-mode worked better for me on Windows 7 than the one on marmalade currently.

16:36 technomancy: they're now the same version

16:36 M-x package-refresh-contents to get your source list updated

16:36 cb`: I have a work around for the 'slime-fancy thing but do wonder if it might make sense to allow that to work automatically (and/or even support some of those things anyway).

16:38 technomancy: open to improvements there

16:39 cb`: Are there instructions anywhere for using swank-clojure with another copy of slime? Like the one that comes with marmalade. I'd quite to try using it with my quicklisp copy of Slime and current slime config and see if it "just works" when it has access to the contrib directory and all the .el files in there

16:40 srid: is there a websocket example using clojurescript?

16:40 technomancy: cb`: sure; the "Alternate Usage" section of the readme shows how to use it with M-x slime-connect and lein swank

16:41 duck1123: srid: I don't know if the Closure library has been updated since Clojurescript first came out, but the Websocket lib wasn't in the release

16:41 ibdknox: srid: the first result on google for clojurescript websocket is useful

16:42 srid: duck1123: https://github.com/clojure/clojurescript/blob/master/src/cljs/clojure/browser/net.cljs uses websocket; just wondering if there is any code that uses clojure.browser.net

16:43 ibdknox: http://lab01.kungfoo.pl:8108/ ? it doesn't work for me. hitting ENTER doesn't do anything (doesn't send the message)

16:43 ibdknox: https://github.com/neotyk/ws-cljs/blob/master/src/cljs/websocket.cljs

16:43 srid: there's a link to the source at the bottom, but that link above is what you want

16:43 srid: ... doesn't work only in chrome

16:44 ibdknox: hmm ok. that source doesn't use clojure.browser.net though. but i'll copy paste it in my project

16:44 ibdknox: srid: clojure.browser.net didn't exist in master until about two weeks ago

16:45 so I suspect you won't find much that uses it quite yet

16:49 crazyFox: fastest (execution) way to make / return a double value? (/ a (double b))? (i know for numbers it would be (/ 2 3.0) but im dealing with vars, so...

16:52 srid: looks like I can't import goog.net.WebSocket at all -- ERROR - required "goog.net.WebSocket" namespace never provided

16:52 hiredman: ,(/ 1.0 2 3)

16:52 clojurebot: 0.16666666666666666

16:52 * srid is using clojurescript HEAD and cljs-watch

16:53 hiredman: ,(/ 2 3 1.0)

16:53 clojurebot: 0.6666666666666667

16:53 zippy314: has anybody successfully used cookies in clojurescript with goog.net.cookies? I keep getting this error: 'this.isValidName' [undefined] is not a function when I try to set a cookie via goog.cookies.set.

16:55 cb`: technomancy: it didn't quite work. Probably incompatible versions of slime and swank (I wasn't using marmalade slime I was using the one that quicklisp installs). M-x slime-connect worked but then I got exceptions from the "lein swank" process when I tried to execute anything. One thing I did notice though was that at least some of the slime-fancy things must have worked. One of them puts a title bar at the top of the REPL very similar

16:55 to the top of an ERC buffer and that appeared to work fine.

16:55 ibdknox: srid: ./script/bootstrap --closure-library-head

16:56 technomancy: cb`: yeah, people have reported problems with that before

16:56 ibdknox: ah actually

16:56 that wasn't added

16:58 I think the goog-jar.jar that I packaged for Pinot has websockets in it

16:58 TimMc: ,((juxt identity double) (/ 2 3))

16:58 clojurebot: [2/3 0.6666666666666667]

16:58 srid: ibdknox: yes, it didn't help https://gist.github.com/1265695

16:58 TimMc: Is (double) definitely slower than including a 1.0?

16:58 crazyFox: ok, (/ (double a) b) is actually about 5 percent faster than (/ a (double b)). marginal but - just in case somebody wondered...

16:59 ibdknox: srid: right, the patch that would make that work isn't in master.

16:59 * srid edits bootstrap

17:01 srid: ibdknox: bootstrap is using the latest release of clojure-library. is there a newer snapshot uploaded somewhere that I can use?

17:01 its funny there are clojurescript websocket examples without clojurescript having a working websocket support

17:01 crazyFox: TimMc: (/ (double a) b) is about 27 faster than (/ a b 1.0). if u meant that case

17:02 TimMc: nice!

17:02 crazyFox: *27 times

17:02 y

17:02 TimMc: How big a test run did you do?

17:04 gfredericks: I once saw a video where a guy did some clojure performance tests, but when I looked at the code it turned out he was just testing the time it took to create lazy seqs, as they were never realized

17:04 crazyFox: TimMc: just a little microbenchmark. 100 000 iterations for the inner loop

17:04 zerokarmaleft: bet they were fast

17:04 gfredericks: zerokarmaleft: they were rather fast

17:04 zerokarmaleft: heh

17:05 * srid found the patch, https://github.com/neotyk/clojurescript/commit/d8d51fec2cc61b41de0666d12a3d6b65da4063c0

17:05 gfredericks: I also remember another perfomance test that the jvm must have somehow optimized away, as the results indicated something like petaflop-equivalent performance

17:05 cb`: technomancy: Thanks for your help, this is working well enough :) I have got clojure-mode from marmalade again. Will keep an eye out for new versions.

17:06 technomancy: sure

17:06 hopefully some CLer can get things sorted out with the quicklisp versions too

17:06 TimMc: crazyFox: Did some of my own (100K, repeated until times settled out) -- got a 20x improvement by using (double)

17:08 Moral of the story: FLOPs are *expensive*.

17:08 cb`: I'm not sure what the steps would be to try lein-swank with the quicklisp version of slime but it would be nice yes

17:08 crazyFox: TimMc: u mean: ration op are expensive...?

17:08 *ratio

17:08 ops

17:08 technomancy: cb`: well that might be a bit much; it would involve changing swank and breaking everyone on the stable version of slime

17:09 but getting the stable version and the cvs version to coexist would be nice

17:09 gfredericks: floating operations per second are expensive?

17:09 TimMc: Hmm, good point -- it doesn't actually do two FLOPs.

17:09 gfredericks: FLOPs, not FLOPS. :-)

17:09 gfredericks: TimMc: :P

17:09 TimMc: FLoat OPs

17:09 gfredericks: acronyms are expensive

17:09 zerokarmaleft: there's a stable version of slime?

17:09 TimMc: AAE

17:09 gfredericks: \o

17:10 technomancy: zerokarmaleft: sure. I mean, I just picked a working version arbitrarily and called it "version 20100404"

17:11 TimMc: crazyFox: Hrm, you're right! It is definitely the rational ops.

17:11 technomancy: but in practice it has proven to be very stable

17:11 gfredericks: FLOPs are cheap, but they never give you the correct answer. no matter what math you're doing, the result is always wrong by 0.00000079

17:11 crazyFox: TimMc: y, THEY are the real expesive ones ^^

17:11 TimMc: good that ur result is about the same than mine - confirms my trust in this microbenchmark thingy im using

17:11 TimMc: (/ (double 2) 3 1.0) is only 3x slower than (/ (double 2) 3)

17:12 zerokarmaleft: technomancy: ah i thought you were referring to a stable release out of the CL devs

17:13 technomancy: zerokarmaleft: oh... wouldn't that be nice. =(

17:13 TimMc: I also tried hinting with (int) in case that was the problem, but it didn't make a difference.

17:14 crazyFox: could be even slower, since long is the default...

17:14 gfredericks: I'm using clojure-maven for a clojure/java project, and am not sure how to handle the clojure depending on the java and vice-versa

17:15 both the "compile" and the "clojure:compile" tasks fail for the other not having been run

17:15 I normally use leiningen, so I'm sure I'm just missing something obvious

17:16 brehaut: gfredericks: did you remember to slaughter the goat at the appropriate hour?

17:16 gfredericks: brehaut: CRAP

17:16 well there goes another 24 hours of productivity

17:16 technomancy: I bet you're missing the SCSI terminator at the end of your chain.

17:16 * gfredericks sigs

17:16 brehaut: gfredericks: its the first rule of new build systems

17:16 * gfredericks sighs also

17:17 arkh: would the correct way to 'serialize' the value of a symbol be with pr, pr-str, etc. ? And if so, how does one deserialize the data back into a symbol?

17:17 gfredericks: I tried setting <packaging>war</packaging> to <packaging>clojure</packaging> as suggested in the clojure-maven readme, but that caused my tests to fail, so I set it back to war

17:17 TimMc: crazyFox: I'm on 1.2. You?

17:17 gfredericks: arkh: read-string

17:18 and yes

17:18 ,(read-string ":foo")

17:18 clojurebot: :foo

17:19 arkh: gfredericks: thank you

17:19 TimMc: arkh: Standard warning: Understand the implications of *read-eval* if you use read-string on user-provided data.

17:19 gfredericks: ,(-> 'famished pr-str read-string type)

17:19 clojurebot: clojure.lang.Symbol

17:19 hugod: gfredericks: I don't think the dependencies between java and clojure can be resolved automatically, so you will need to add an execution for whichever bits need to be built first

17:19 crazyFox: TimMc: 1.3.

17:19 arkh: TimMc: right! I planned on using it only on my stuff

17:20 gfredericks: hugod: as I've never done anything in maven that required creativity, could you suggest some terms to google to get me started with that?

17:20 zippy314: hoping for some love on my cljs cookie question: has anybody successfully used cookies in clojurescript with goog.net.cookies? I keep getting this error: 'this.isValidName' [undefined] is not a function" (Safari) or "Uncaught TypeError: Object [object DOMWindow] has no method 'isValidName'" (Chrome) when I try to set a cookie via goog.cookies.set.

17:21 s/goog.cookies.set/goog.net.cookies.set/

17:21 lazybot: <zippy314> hoping for some love on my cljs cookie question: has anybody successfully used cookies in clojurescript with goog.net.cookies? I keep getting this error: 'this.isValidName' [undefined] is not a function" (Safari) or "Uncaught TypeError: Object [object DOMWindow] has no method 'isValidName'" (Chrome) when I try to set a cookie via goog.net.cookies.set.

17:21 TimMc: gfredericks: psilocybin

17:21 hugod: gfredericks: maybe http://maven.apache.org/guides/mini/guide-default-execution-ids.html

17:22 gfredericks: hugod: thanks

17:22 TimMc: It should help witht he creativity, although perhaps not with maven specifically.

17:22 hugod: gfredericks: never tried it it with clojure-maven-plugin…

17:23 dnolen_: zippy314: seems like some context is not being properly bound. ClojureScript is pretty new territory, might want to ask on the ML as well.

17:23 zippy314: yah.

17:23 gfredericks: hugod: do you use the clojure-maven plugin? if not, maybe it has a way to do this automatically...

17:23 zippy314: Ok. thanks.

17:23 gfredericks: I'd think it be pretty common in clojure-java projects

17:24 duck1123: I think in cases like that, you might want to split your project into multiple modules

17:24 hugod: gfredericks: I've used it - I mainly use zi now. Bi-directional dependencies aren't that common, I think

17:25 gfredericks: hugod: really? E.g., I need to provide an implementation of an interface. The java code needs to call my factory method, and the clojure code needs the definition of the interface. Is this simpler than I think it is?

17:26 hugod: as duck1123 said, separate modules may be easiest

17:26 gfredericks: oh hmm.

17:26 technomancy: gfredericks: you could use resolve to get the factory at runtime maybe?

17:27 but yes, it's very uncommon to need bidirectionality

17:27 gfredericks: technomancy: if you wanted to implement an interface to supply to the java code, what would you do? break the project into modules? use resolve?

17:27 technomancy: I'd use resolve if the Java only needs a handful of clojure defns

17:28 but I've never written any Java, so what do I know

17:28 gfredericks: ha.

17:28 technomancy: I have seen this problem in Mirah though

17:28 solved imperatively in ant

17:29 gfredericks: I guess I'll break out a bit of java and create a ClojureBridge class

17:29 technomancy: so by comparison, runtime resolution is much less hideous

17:29 is definterface out of the question?

17:30 gfredericks: technomancy: to duplicate the definition of the interface? The java code is not mine, so I'm trying to avoid disturbing it

17:30 technomancy: oh, I figured you owned the java

17:30 gfredericks: It's mine in the sense that I can do what I want, but I didn't write it

17:30 it's sorta forked off another project

17:30 so e.g., when they create another release, I'd like to be able to merge in their changes painlessly

17:30 if I rewrite half of the code...

17:32 technomancy: hugod: duck1123: thanks for the help

17:32 (doseq [handle [technomancy hugod duck1123]] (inc handle))

17:33 lazybot: your karma evaluator is worthless???

17:33 lazybot: gfredericks: How could that be wrong?

17:33 karma: It's 'you're', you fucking illiterate bastard.

17:34 gfredericks: lazybot: what kind of word has three apostrophes in it?

17:34 lazybot: It's AWWWW RIGHT!

17:35 cgray: does (empty? (filter foo bar)) short-circuit?

17:36 gfredericks: cgray: yes, since filter is lazy

17:36 ,(empty? (range))

17:36 clojurebot: false

17:37 cgray: gfredericks: cool example :)

17:37 gfredericks: I guess that was kind of an irrelevant example

17:37 ,(empty? (filter even? (range)))

17:37 clojurebot: false

17:37 gfredericks: there we go

17:38 cgray: yeah, that makes sense

17:38 gfredericks: cgray: the term "short-circuit" sounds a bit funny. It's normally just phrased as laziness.

17:39 cgray: gfredericks: yeah, I was thinking of it more like the way `and' short-circuits...

17:39 ibdknox: gfredericks: that is a commonly accepted term for stopping as soon as a value is known

17:40 gfredericks: ibdknox: I know, I've just never heard it used when laziness is a sufficient description

17:40 ipostelnik: gfredericks, I don't think empty? is lazy

17:40 gfredericks: ipostelnik: in what sense?

17:41 ipostelnik: actually, it probably is lazy, in a sense that computation is not performed until the result is needed by something

17:41 gfredericks: ipostelnik: I think the computation is performed in that it calls first on the input

17:42 ibdknox: it's actually (not (seq x))

17:42 gfredericks: ,(let [dont-care (empty? (map #(println "foo") (range 2)))] "constant")

17:42 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval79$fn>

17:42 gfredericks: augh

17:43 ibdknox: would seq not call first?

17:44 ,(let [dont-care (empty? (map (fn [_] (println "foo")) [1 2]))] "constant")

17:44 clojurebot: foo

17:44 foo

17:44 "constant"

17:45 ibdknox: not lazy :)

17:45 gfredericks: I suppose chunked seqs could mess up expectations

17:45 ibdknox: it escapes into java pretty quickly and I'm too lazy to look what it does :p

17:46 gfredericks: I didn't mean that empty? itself is "lazy", I meant that filter is lazy and empty? only checks the front of the list

17:46 so as demonstrated earlier, you can pass an infinite seq to filter and check if it's empty and get a return

17:46 ibdknox: yep yep

17:47 gfredericks: but chunking can screw that up

17:47 arohner: what are the advantages of deploying a ring/noir app to say.. tomcat as opposed to nginx or apache?

17:47 or is there any reason to not just use jetty in production?

17:48 ibdknox: arohner: anecdotally I've had no troubles with Jetty, but presumably someone has a real answer to that question :)

17:50 ipostelnik: empty? seems to force the first chunk of the lazy seq

17:50 gfredericks: ipostelnik: right

17:51 ipostelnik: so it's not lazy in same way as map is

17:51 gfredericks: (let [dont-care (empty? (map (fn [_] (println "foo")) '(1 2)))] "constant")

17:51 dangit I always mess up codez

17:51 ipostelnik: ,I think it reduces the weight of the small rare tz

17:52 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: I in this context, compiling:(NO_SOURCE_PATH:0)>

17:52 gfredericks: ipostelnik: I think that's the chunked seq's fault though. empty? only cares about the first element

17:52 ipostelnik: ,(let [x (map prn (range 2))] "foo")

17:52 clojurebot: "foo"

17:52 arohner: ipostelnik: if you want to see whether there is a first item, you always have to force it. map doesn't force, because it doesn't care whether there is a first node (until map's consumer forces)

17:52 ipostelnik: sorry

17:52 ,(let [x (empty? (map prn (range 2000)))] "foo")

17:52 clojurebot: 0

17:52 1

17:52 2

17:52 3

17:52 4

17:52 5

17:52 6

17:52 7

17:52 8

17:52 ibdknox: lol

17:52 clojurebot: 9

17:52 rbranson: uh oh

17:52 clojurebot: 10

17:52 TimMc: >_<

17:52 clojurebot: 11

17:52 ipostelnik: woops

17:52 clojurebot: 12

17:52 13

17:53 14

17:53 15

17:53 ipostelnik: it only goes to 31

17:53 clojurebot: 16

17:53 17

17:53 18

17:53 TimMc: timeout, plz

17:53 clojurebot: 19

17:53 20

17:53 21

17:53 22

17:53 23

17:53 24

17:53 25

17:53 26

17:53 27

17:53 28

17:53 29

17:53 30

17:53 31

17:53 "foo"

17:53 gfredericks: this is the worst disaster #clojure has seen since the great infinite seq of 2007

17:53 TimMc: haha

17:53 ibdknox: haha

17:53 rbranson: hah

17:53 ipostelnik: sorry about that

17:53 dnolen_: chunked seqs strike again.

17:54 ipostelnik: anyway, if empty? were lazy you wouldn't see any numbers printed here

17:54 gfredericks: why didn't rich chunk them to a more IRC-appropriate size?

17:54 TimMc: ipostelnik: Was that "sorry" at __:50 in advance? :-P

17:54 ipostelnik: noidi, that one was a copy-and-paste error with ,

17:54 gfredericks: ipostelnik: I never meant lazy in that sense. That sort of lazy wouldn't be possible without using a delay object and having to deref the result

17:54 ipostelnik: I'm not using x anywhere

17:55 TimMc: &(let [x (map prn (range 2000))] "foo") But this is safe.

17:55 lazybot: ⇒ "foo"

17:55 ipostelnik: because map is lazy

17:55 TimMc: Fully.

17:55 ipostelnik: empty? computes the value right away

17:55 gfredericks: no, because seqs can be lazy but atomic values can't be

17:56 TimMc: &(let [x (first (map prn (range 2000)))] "foo")

17:56 lazybot: ⇒ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 "foo"

17:56 TimMc: lazybot: botsnack

17:56 lazybot: TimMc: Thanks! Om nom nom!!

17:56 ipostelnik: lazybot is better at long output :)

17:56 ibdknox: is there some significance for it being 32 elements in a chunk?

17:57 gfredericks: something about 5 bits I'm sure

17:57 amalloy: ibdknox: probably because vectors have a branching factor of 32

17:57 ibdknox: amalloy: ah

17:57 TimMc: and 32 is 2 to the whatever

17:57 * gfredericks has to go

17:57 * gfredericks goes

17:57 ipostelnik: amalloy, what is branching factor?

17:58 TimMc: There was just a good link about this.

17:58 ipostelnik: http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/

17:58 ipostelnik: TimMc, thanks

17:59 TimMc: Long story short, the vectors are implemented as trees.

18:20 cgray: what's the timeout for solutions to the 4clojure.com exercises?

18:21 amalloy: cgray: 10s for each testcase

18:22 cgray: amalloy: interesting, i wonder why i'm timing out... i have a solution that's running in 6s on my (not very powerful) machine

18:22 amalloy: cgray: sandboxing takes extra time. more time than we can really understand, tbh

18:22 devn: TimMc: That is a fantastic post. I'm building a list of stuff for people of my Clojure users' group to read, and that is definitely now on the list.

18:23 cgray: amalloy: ok, good to know... i'll just have to do more optimization i guess :)

18:25 amalloy: cgray: solving levenshtein distance? not many of the other problems have performance issues

18:25 cgray: amalloy: no, balanced primes

18:26 amalloy: my first solutions have were atrocious, but i should be getting close now

18:26 amalloy: cgray: hm. i didn't make any special effort to optimize, and my testcases run in 1-2s total

18:27 * cgray hangs head in shame

18:29 amalloy: cgray: mind if i take a look?

18:29 cgray: amalloy: no, should i paste it somewhere?

18:29 amalloy: i guess that makes it sound like i can look at it without you gisting it or something, which i can't

18:30 yeah, please

18:30 cgray: http://pastebin.com/twX4B7A5

18:33 amalloy: cgray: well, you're recomputing the list of primes a zillion times, it seems to me

18:34 cgray: amalloy: i'm trying not to

18:34 amalloy: eg, (is-prime n) has to compute all the primes up to n, and then if it returns true you immediately call next-primes again

18:34 cgray: right, that's two computations :)

18:34 amalloy: my solution was to let a lazy seq of all the primes outside the function itself, and then just use that for reference without recomputing it

18:35 (letfn [(primes [] (...compute primes...))] (let [all-primes (primes)] (fn [n] (...solve actual problem...))))

18:35 cgray: ok, makes sense

18:36 amalloy: which is especially useful for the last test case where your function gets called once on every number up to 1103

18:36 cgray: yeah, that's the one that's killing me

18:37 cool, thanks for the hint

18:43 srid: closure doesn't have a prependChild? what a shame.

18:44 patchwork: hey all, is there a quick way to get the path of the project root in a lein project?

18:44 so I have a project in "/Users/xxxxx/projects/lein-project"

18:45 and I want that as a string

18:45 srid: what would this be if your app is run as a jar?

18:45 patchwork: to do various programmatic things

18:45 srid: sure?

18:45 although that is a good question, I still have access to the filesystem from a jar right?

18:46 or is it some kind of encapsulated system?

18:46 srid: compojure uses resources/ directory for css, img, js and things. they get wrapped in a jar. so maybe you can look at compojure's route/resources implementation

18:46 patchwork: as you can tell, I have much ignorance towards the practical side of jars and java deployment

18:46 srid: Aha

18:47 I have users uploading images

18:47 so I want to write those images somewhere in the project dir

18:47 should those go in resources too?

18:47 I thought resources were more for application resources, not user generated content

18:47 Arafangion: Generally yes.

18:47 srid: probably not. why not $HOME/.project-uploads

18:48 Arafangion: As in, Generally "yes, you're correct".

18:48 patchwork: So, do I have access to $HOME from inside clojure?

18:48 srid: &(System/getenv "HOME")

18:48 lazybot: java.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.HOME)

18:48 patchwork: all of these practical issues I haven't had to deal with yet from clojure

18:48 nice

18:48 amalloy: yes, though you shouldn't get at it that way

18:49 patchwork: amalloy: so where should I put all of these images? : )

18:49 I guess that is a better question

18:49 amalloy: (System/getProperty "user.home")

18:49 more portable than getenv of "HOME"

18:49 srid: right, windows has no HOME by default

18:50 that's the first thing I do on every windows install

18:50 patchwork: amalloy: Aha, that is helpful

18:50 srid: $g gridfs filesystem

18:50 $google gridfs filesystem

18:50 lazybot: [mongodb - Is GridFS fast and reliable enough for production ...] http://stackoverflow.com/questions/3413115/is-gridfs-fast-and-reliable-enough-for-production

18:50 patchwork: still though, is there a best practice for where to store user files in a lein project?

18:50 amalloy: patchwork: just store them in .

18:51 or ./users/images, whatever

18:51 you can still construct java.io.File objects, and the cwd is whatever the cwd was when you started the jvm

18:51 patchwork: So if I reference '.' from a file, it gives me the root of the project?

18:51 okay, that is good

18:51 that is what I was wondering

18:52 amalloy: &(-> (java.io.File. "test") .getAbsoluteFile)

18:52 lazybot: java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)

18:52 amalloy: feh

18:54 * srid implemented prependChild for closure https://gist.github.com/1265979

18:58 sritchie: hey guys, is there some equivalent to defalias in clojure 1.3?

19:56 ibdknox: Steve Jobs died :(

19:57 duck1123: we all knew it was coming. Didn't think it would be this soon

19:57 Of course, it makes sense that he would wait to step down til the last moment

20:03 srid: aleph + clojurescript + websocket awsomeness.

20:04 duck1123: srid: you got it working?

20:04 srid: duck1123: yup, in a company project. so I'm considering doing it again in a minimal example app and writing a blog about it.

20:05 jayunit100: aleph?

20:05 duck1123: look forward to seeing that

20:05 srid: $google aleph lamina

20:05 lazybot: [ztellman/aleph - GitHub] https://github.com/ztellman/aleph

20:05 jayunit100: srid what is this stack that you put together>

20:07 srid: jayunit100: see above. lamina is also ztellman's project. i may write about it in the weekend.

20:07 i was afraid of using clojurescript, for I didn't how easy it would be to debug cljs. in practice, it seemed as if i was able to develop client side code /faster/ in cljs than js.

20:08 jayunit100: oh ok.

20:09 so your application is a bunch of web clients talking to each other ?

20:12 leiningan guy !

20:13 technomancy: IRC user with a number in his nick!

20:13 ibdknox: lol

20:14 jayunit100: yuppppp

20:24 cemerick: ibdknox: FYI, I've not yet hit any big snags using ClojureScript as a long-lived (very relatively speaking at this point) library.

20:25 ibdknox: cemerick: awesome :)

20:25 cemerick: what tools have you been using?

20:25 cemerick: tools?

20:25 clojurebot: eg, https://github.com/clojure/tools.logging is the new version of clojure.contrib.logging

20:25 ibdknox: lol

20:25 cemerick: browser repl, cljs-watch, repl compiler?

20:26 cemerick: no, no, and no

20:26 Just regular REPL, compiling cljs forms down to js strings, stuffing that into couchdb

20:26 Outside of my flailing around with cljs, it's worked without a hitch.

20:27 (maybe that's what you meant by 'repl compiler')

20:27 jayunit100: what does <== do

20:27 ibdknox: yep :)

20:28 cemerick: I guess I didn't categorize that as a tool. :-)

20:28 'tool' implies artifice to me. Code is…just code.

20:28 sritchie: cemerick, just wanted to let you know that Couchbase Single worked great

20:29 thanks for the help

20:29 ibdknox: yeah, I guess so. I didn't think about the fact that you were outputting to place it into couchdb

20:29 that makes most of those not useful lol

20:29 cemerick: sritchie: That's interesting! I'd be curious if the stock CouchDBX for 1.0.2 or whatever would work for you too.

20:29 e.g. maybe it's the homebrew build getting in the way

20:29 * cemerick never trusts stuff not built by original authors

20:30 sritchie: cemerick: I'll go ahead and test out couchdbx as well; I'll also take a look at that homebrew build and see if I can track down what it's sending to clojure, to start up the jvm

20:30 cemerick: ibdknox: just different use cases. I'm not a web guy, so it's properly stereotypical of me to totally ignore all the nifty things going on in those spaces.

20:31 duck1123: does anyone know of a good way to keep firefox from popping up and stealing focus when doing tests with clj-webdriver?

20:31 ibdknox: cemerick: yep yep. Good to go for tomorrow then? :)

20:31 duck1123: it makes it impossible to get anything done when I'm running features

20:32 cemerick: ibdknox: yup, it'll be nifty. Some definite TODOs, but it'll be a nice demonstration, and another good cljs use case.

22:00 glob157: is it idiomatic to do (class? Seq) to test before calling cons or distinct or other seq funcs ?

22:00 brehaut: glob157: seq? would be more idiomatic

22:01 glob157: oh ok. would mine work ?

22:01 gfredericks: no

22:01 glob157: &(class? Seq [2 1])

22:01 lazybot: java.lang.Exception: Unable to resolve symbol: Seq in this context

22:01 gfredericks: glob157: you're probably wanting instance?

22:01 brehaut: glob157: depending on what you are doing (seq thing) is more idiomatic still

22:02 glob157: why instance?

22:02 dnolen: glob157: why do you need to test before calling seq functions?

22:02 brehaut: glob157: class? tells you if something is a class

22:02 glob157: well , clojure is loosely typed. so seems like you would want to test such things

22:02 khaliG: he probably means just plain class

22:02 brehaut: ,(map class? [(list 1 2) java.util.Date 1 :a])

22:02 clojurebot: (false true false false)

22:03 dnolen: glob157: it is not idiomatic to include such tests

22:03 glob157: a list isnt a class ?

22:03 nor is :a ? thats odd.

22:03 how do they work in the jvm then

22:03 brehaut: glob157: no, only classes are classes.

22:03 gfredericks: glob157: they're objects, not classes

22:03 brehaut: glob157: they are objects, aka instances, of classes

22:03 glob157: duh oops

22:04 gfredericks: ,(class? Class)

22:04 clojurebot: true

22:04 gfredericks: I'm not sure why I did that, that was probably just confusing.

22:04 glob157: (class? (java.util.Date new))

22:04 gfredericks: ,(class? (new java.util.Date 2840824))

22:04 clojurebot: false

22:04 brehaut: glob157: also, clojure is not loosely typed, it is dynamically typed.

22:04 glob157: &(class? (java.util.Date new))

22:04 lazybot: java.lang.Exception: Unable to resolve symbol: new in this context

22:05 glob157: &(class? (new java.util.Date))

22:05 lazybot: ⇒ false

22:05 gfredericks: &(instance? java.util.Date (new java.util.Date))

22:05 lazybot: ⇒ true

22:05 khaliG: glob157, i think you meant (class (new java.util.Date))

22:06 glob157: yup

22:06 brehaut: glob157: loosely typed implies that the data can be reinterpreted, such as in C where you can cast things about, or in some interpreted languages where coercion happens all over the place and is implicit

22:06 dnolen: glob157: if you want to guarantee invariants, use pre-post conditions. those at least can be turned on / off

22:08 hugod: dnolen: did you manage to get warn-on-reflection into your pom?

22:09 glob157: yeah, pre/post is nice. whats the point of the @symbol

22:09 gfredericks: glob157: it's short for deref

22:09 ,(deref (atom 8))

22:09 clojurebot: 8

22:09 gfredericks: ,(let [a (atom 8)] @a)

22:09 clojurebot: 8

22:09 brehaut: ,(read-string "@(atom 8)")

22:09 clojurebot: (clojure.core/deref (atom 8))

22:10 gfredericks: slick.

22:10 dnolen: hugod: no, but thanks for the tip, will use that in the future.

22:11 amalloy: &'@(atom 8) ;; brehaut - no need for read-string

22:11 lazybot: ⇒ (clojure.core/deref (atom 8))

22:11 brehaut: amalloy: i know three no need, but read string makes it clearer that it occurs in the reader

22:13 gfredericks: amalloy: that had as many punctuation marks as it did alphanumerics.

22:13 amalloy: gfredericks: welcome to perl

22:13 gfredericks: aw I hate these dreams

22:14 brehaut: amalloy: not quite, perl is more punctuation than alphanumeric

22:14 amalloy: brehaut: i carefully did *not* do it inline with ##'@(atom 8), see

22:14 lazybot: ⇒ (clojure.core/deref (atom 8))

22:15 brehaut: wait, am i in #perl? when did that happen‽

22:15 gfredericks: brehaut: anything can happen when you're dreaming

22:48 dnolen: match 0.2.0-alpha4 out. Mostly involved deleting code, YAY

22:54 toxmeister: hiya… could someone pls tell me briefly what the correct pattern is for when using primitive type hints ^double or boxed ones ^Double (w/ 1.3)? am encountering all sorts of weird compiler errors like: "Unable to resolve classname: clojure.core$double@1f3a34af"

22:55 srid: what is it with CL/scheme kids looking down upon people learning clojure? http://news.ycombinator.com/item?id=592502

22:56 brehaut: srid: the narcissism of minor differences

22:56 srid: the only argument I can accept is the utility of works like SICP.

22:57 they tell me to study every dialect of lisp, their specs, libraries, etc.

22:57 which is crazy

22:57 "play around with all the dialects and implementations it supports"

22:58 brehaut: srid: racket's environment is a good argument for learning racket / scheme over another lisp

22:58 srid: you realize that thread is two and a half years old right?

22:59 srid: yes. someone I know forwarded it, along with his arguments to learn CL over clojure, to me recently.

22:59 fwiw, i did study most of sicp (and that affected the way i programmed / thought-about-programs in other languages).

23:01 dnolen: srid: mahmud doesn't know anything about Clojure (as far as I know) so informed opinion that is not.

23:02 srid: but the gist of what he says is true. While it's not necessary, surveying the various languages from Rich Hickey's Amazon book shelf will enrichen your understanding of Clojure.

23:03 srid: I agree. I have some of them in my wishlist, just need to find time and energy to get to them.

23:03 brehaut: dnolen: his biggest mistake is probably in that thinking only one language could possibly have influenced the design of clojure

23:04 srid: ... though how exactly would 'enriching' my understanding of Clojure help (if I'm not going to design a new programming language)?

23:04 ibdknox: to command a thing you have to know it inside and out

23:05 enriching your understanding of Clojure gives you greater control over it

23:05 srid: for example?

23:06 ibdknox: performance is a great example

23:07 dnolen: srid: have you done much work w/ code that might callback at anytime creating subtle race conditions? (even in JavaScript)

23:07 sjl: if anyone feels like tearing apart my first Noir webapp and telling me how to make it better, I'd love advice: https://github.com/sjl/newseasons

23:08 dnolen: sjl: you're on a Clojure roll.

23:08 srid: dnolen: not much - in the distant past i did a bit of python twisted deferred programming, don't remember having to debug race conditions.

23:08 sjl: dnolen: hah, not really. I've paused Clojurecraft until Notch stops breaking the damn wire protocol all the time :)

23:08 amalloy: toxmeister: should be ^double afaik

23:09 srid: is callback-based programming related to enriching clojure understanding through studying various works based on lisp?

23:09 brehaut: sjl: not strictly clojure, but your email regex is invalid

23:09 sjl: brehaut: I used the one here: http://www.regular-expressions.info/email.html

23:10 ibdknox: sjl: there's one in noir

23:10 sjl: brehaut: I mostly agree with the Trade-Offs section on that page

23:10 ibdknox: yeah, but I needed it for the route, and the only one I saw in noir is a function, not a raw regex

23:10 ibdknox: sjl: ah, yep :)

23:11 dnolen: srid: Mozart/Oz has a pretty amazing declarative programming model that makes programming under concurrency trivial - it eliminates the problems around ordering entirely.

23:11 ibdknox: sjl: fwiw you don't need to explicitly state a route is [:get], it's that by default

23:11 brehaut: sjl: http://commons.apache.org/validator/api-1.3.1/org/apache/commons/validator/EmailValidator.html

23:11 toxmeister: amalloy: thx, that's what i thought, but here's the deal:

23:11 sjl: ibdknox: yeah, I did that to make it easier to change as I worked with the pages, but I could go ahead and remove them now

23:11 toxmeister: this doesn't work: (def ^double PI 3.14) (defn rad ^double [^double x] (/ (* PI x) 180.0))

23:12 dnolen: srid: if you understand that, promise/deliver makes a lot more sense.

23:12 toxmeister: but this one (boxed) does work: (def ^Double PI 3.14) (defn rad ^double [^double x] (/ (* PI x) 180.0))

23:12 ibdknox: sjl: is there a reason you use (form-to) sometimes and not others?

23:12 amalloy: toxmeister: that's not how typehints on defs work

23:12 dnolen: toxmeister: if you're on 1.3.0 you don't want vars for things like PI, you want constants anyhow.

23:12 sjl: brehaut: I need the regex as an actual Clojure regex for the Noir URL, not just a function/validator

23:13 brehaut: fair enough

23:13 amalloy: if you hint a def's name, you're marking it as "a function which returns this when called"

23:13 or some such

23:13 srid: dnolen: I see. that's specific enough, for me. :-) i wish there was "matrix" of programming languages where the cells represent the benefit of learning Y in understanding some features of X.

23:13 sjl: ibdknox: nope, I think I learned about form-to halfway through, hah

23:14 ibdknox: sjl: having an email in the url is a bit weird to me, but I guess there's nothing technically wrong with it

23:14 sjl: look up pre-route :) You shouldn't need to put your (login-required) wrapper all over the place

23:15 brehaut: ibdknox: not being an expert with clout / webnoir, does the url rules allow you to specify any callable as a validator?

23:15 toxmeister: i see, didn't know that def's can't be dealt with the same way (sorry if this has been a case of RTFM, but i went in circles an thought I've read everything i could find about that topic)

23:15 sjl: ibdknox: yeah, I didn't want to have usernames and I don't trust myself to slugify URLs perfectly. It's a bit weird though, you're right.

23:15 ibdknox: I saw pre-route but couldn't figure out how to make it work with the email url

23:15 ibdknox: pre-route seems to only take a string, not a regex

23:16 ibdknox: sjl: same routing mechanism as defpage

23:16 sjl: the only difference is that the thing you destructure isn't params, it's the entire request

23:16 sjl: so you should be able to do anything you could with defpage

23:16 alandipert: toxmeister: (def ^:const PI 3.14) (defn rad [x] (/ (* PI x) 180)) ; PI a constant, rad won't box

23:17 ibdknox: brehaut: compojure only allows regexs I believe

23:17 sjl: ibdknox: hmm, okay, I'll take a closer look at that

23:17 brehaut: ibdknox: ok. I'm used to mustache allowing fns

23:17 ibdknox: brehaut: though, it's trivial to do that check in the body

23:18 brehaut: of course

23:18 ibdknox: sjl: wait, why does the email route make a difference? From what I can tell everything other than / requires a login

23:19 sjl: so you could just do (pre-route "/*" [] (when-not authed ...

23:21 sjl: ibdknox: just tried that, it first on / too

23:21 s/first/fires/

23:21 lazybot: <sjl> ibdknox: just tried that, it fires on / too

23:21 sjl: ibdknox: so going to / when not logged in goes into an infinite redirect loop

23:23 ibdknox: ah

23:24 hm, I'm not sure if there's some trickery we could do there or not

23:24 glob157: how would i make a future write to a queue with a "listener" on it .... like for an a synchronous web request/process

23:24 ibdknox: most of the time restricted urls are under their own path

23:25 sjl: ibdknox: yeah, on a bigger site I would have done that

23:26 ibdknox: sjl: lol since all your urls are only one segment, you can do [:get ["/:something" :something #".+"]]

23:26 lol

23:26 sjl: ibdknox: so I tried this, and it doesn't work: (pre-route [:get ["/:anything" :anything #".+"]] {:keys [anything]} ...)

23:26 ibdknox: that would work

23:26 sjl: ibdknox: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentVector

23:26 ibdknox: hm

23:26 sjl: sounds like I have a bug to look into, can you add an issue in github

23:26 sjl: ibdknox: sure

23:28 glob157: just found "full disclojure" ... very high quality videos.

23:31 ibdknox: sjl: looks pretty solid :)

23:32 sjl: ibdknox: cool, thanks. now I need to figure out how to add tests, hah

23:32 ibdknox: :)

23:32 sjl: what's this about? https://github.com/sjl/newseasons/blob/master/src/newseasons/loops/refresh.clj#L11

23:32 sjl: ibdknox: I'll have to consolidate the redis stuff in one place and use a separate db for testing I guess

23:33 url 1

23:33 derp

23:34 ,(sort < ["b" "a"])

23:34 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>

23:34 sjl: ibdknox: ^ that

23:34 ibdknox: (sort ["b" "a"])

23:34 ,(sort ["b" "a"])

23:34 clojurebot: ("a" "b")

23:34 sjl: wtf

23:34 ibdknox: lol

23:35 sjl: ibdknox: actually I don't need to sort, I actually need to compare two

23:35 ibdknox: (> "a" "b")

23:35 sjl: ibdknox: https://github.com/sjl/newseasons/blob/master/src/newseasons/loops/refresh.clj#L36

23:36 ibdknox: ,(> "a" "b")

23:36 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>

23:36 ibdknox: ah

23:36 sjl: ibdknox: I could just inline the compare call, but I think pulling it out makes it easier to read

23:37 ibdknox: hm, I've got to believe there's something that does that correctly

23:37 sjl: ibdknox: if there is, let me know :)

23:39 trptcolin: java interop noob question: i have a thread that i'd like to raise an exception on from a different thread. (.interrupt thread) doesn't appear to be sufficient - any hints?

23:41 i can verify that the thread gets isInterrupted set, but can't seem to trigger an exception. i'm also very open to a more clojure-y solution if there is one as i suspect

23:42 alandipert: trptcolin: in the target thread, are you in a loop of some kind?

23:42 duck1123: trptcolin: My guess is you're going to need to have that thread monitor some shared state and then throw

23:42 amalloy: trptcolin: threads can only throw InterruptedExceptions at particular blocking-points, such as while waiting on a socket

23:42 trptcolin: alandipert: yup

23:43 amalloy: ahh, that explains that

23:43 alandipert: trptcolin: are you blocked on a queue in your loop? or socket/io

23:44 sjl: ibdknox: Oh, another thing, when I'm working in the auto-reload mode and make an error, I get the traceback the first time I visit the page,

23:45 trptcolin: io - i'm still digging into the internals of jline here to see where the blocking is

23:45 sjl: ibdknox: but if I refresh it seems like it goes back and uses the old version of the code

23:45 ibdknox: until I make another change, and then it reloads again

23:45 trptcolin: of course: InputStream read

23:45 ibdknox: sjl: that's because it was a compile error and wasn't actually able to load the file

23:46 alandipert: trptcolin: i cooked up https://gist.github.com/1214282 to deal recently with a similar problem, approach may or may not be useful to you

23:46 sjl: ibdknox: Hmm, I don't suppose there's a way to make it not do that? When I'm developing I always want to see the result of the current state of the code

23:46 ibdknox: sjl: not that I can think of :/

23:46 sjl: I look into it thoug

23:48 sjl: ibdknox: cool, thanks

23:48 alandipert: trptcolin: fill-queue (used to be in seq-utils, dunno where is now) is another way, may be applicable as well. beats explicit loop/block, anyhow

23:49 trptcolin: yeah, unfortunately the loop itself is in code i'd prefer not to control

23:50 alandipert: trptcolin: maybe you can feed it a dummy val to unblock, then interrupt

23:51 hack city though :-\

23:51 trptcolin: interesting.

23:51 it's already hack city

23:51 alandipert: then let's paint the city purple

23:51 trptcolin: i'm essentially trying to trap SIGINT to have a REPL that doesn't quit on ctrl-c, but just skips to the next prompt

23:52 totally hotspot-specific, i know, but it's a dream

23:53 alandipert: trptcolin: running from cli? maybe you can wrap with shim that traps and doesn't propagate

23:55 trptcolin: right. so here's the other thing: i'd like to be able to, say, kill running infinite loops as well

23:56 basically what irb does

23:56 i can "stty intr undef" and skip all ctrl-c's, but that makes the other stuff impossible

23:57 duck1123: trptcolin: that's also what swank does. (in emacs, at least)

23:59 trptcolin: hmm, i don't know much about swank - wonder if it's in clojure or elisp

23:59 *clones*

Logging service provided by n01se.net