#clojure log - Dec 26 2011

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

0:22 clojure_0000: is there a way to write OSX sreensavers in clojure? I have the Java Graphics 2D drawing part already; I just need it to run as an OSX screensaver

0:24 replaca_: clojure_0000: I have no idea, but if you can find out how to do it from java, the same mechanism should work for clojure

0:32 clojure_0000: yeah; now that I think about it, this is really a Java/OSX question, not a clojure question :-)

1:14 is there a way to modify a (defrecord Cat [name age]), so that (Cat. a b) requires a to be a java.String and b to be a Java.int ?

1:14 this is kinda like :pre/:post, but I want to do a :pre on Cat.

2:03 a & b are both of defrecord Foo. Yet somehow, in my code (= a b) = false, whereas (.equals a b) = (.equals b a) = true. WTF is going on?

2:12 replaca_: clojure_0000: strange, that shouldn't be happening. = is the same as .equals except that it supports nil

2:12 and my test with defrecord shows that to be correct

2:12 clojure_0000: replaca_: great; atleats shows I'm reading the documentation correctly

2:13 I'm certain this is my fault; I however have no idea how to debug this (restarted repl + tried it = same bug(

2:13 replaca_: also: (defrecord Cat [^String name ^int age]) will do what you want

2:13 clojure_0000: are those hints; or enforced?

2:13 let me try that first

2:14 replaca_: enforced: (->Cat "Seymour" "unknown) throws an exception

2:14 (add a close quote there!)

2:16 clojure_0000: what Clojure version are you running. I'm using 1.3

2:16 clojure_0000: I'm also on 1.3

2:16 replaca_: yeah, so it should be the same

2:16 clojure_0000: I'm not getting the same

2:16 is there a in channel bot here?

2:17 replaca_: yeah, two I think

2:17 clojure_0000: (defrecord Cat [^String a ^int b]) (Cat. 23 45)

2:17 does not give me an error

2:17 maybe my clojure is fucked up

2:17 replaca_: but I'm not sure the sandboxes will let you use defrecord

2:17 Raynes: They wont.

2:17 replaca_: quoth the expert

2:17 Raynes: :p

2:18 replaca_: clojure_0000: interesting, I only tried on the int side

2:19 clojure_0000: hmm; I'm now closer

2:19 replaca_: maybe it's only primitives or maybe my notation is wrong

2:19 clojure_0000: this is what the following code outputs: (println (type other)) (println (type n)) (println (= (type other) (type n))) --> foo.Status foo.Status false

2:19 how is that possible?

2:19 shit; if I require/load a class twice, does clojure generate different types? (I'm using reload-all all over the place)

2:20 replaca_: clojure_0000: yeah, it might

2:20 require should only do it once, though

2:20 load isn't as smart, iirc

2:21 clojure_0000: i'm using :require :reload-all ...

2:21 replaca_: yeah, I think you're doomed

2:21 Clojure doesn't have much choice without decided that your types are identical for you

2:22 *deciding

2:22 clojure_0000: replaca_: I failed to parse the above sentence

2:22 replaca_: so you load foo.clj the first time and it sees a defrecord, so it creates a type

2:23 then you load foo.clj the second time and it sees defrecord again

2:23 clojure_0000: ah; then it reloads it; creates another defrecord

2:23 I'm a moron

2:23 replaca_: it can't tell if that's the same def or if you changed it without working hard

2:23 cause really clojure is just reading along as it goes

2:24 so every new thing it sees is new by default

2:24 I don't know what's happening inside the JVM here, though

2:24 clojure_0000: well

2:24 that was an expensive lesson to learn ~ 3 hours of my life :-)

2:25 how about :pre on defstruct constructors?

2:25 replaca_: some lessons are like that :(

2:25 clojure_0000: if I could get that to work; it would eliminate many of my clojure bugs

2:25 replaca_: dunno, I haven't used :pre at all

2:26 amalloy: replaca_: definitely not true that the only difference between = and .equals is nil-safety

2:27 Raynes: amalloy: I'm tempted to add another auto reply that whines about mentions of defstruct. Would probably end up annoying people during nostalgic conversations.

2:27 replaca_: yeah, there's the stuff about collections and type-independence too

2:27 anything else?

2:27 amalloy: nothing that comes to mind

2:27 Raynes: #pedant

2:27 replaca_: amalloy: that one's good to note

2:28 amalloy: also: what's going on inside the jvm is that clojure creates a new classloader for every unit it compiles. so there are two classes, both named Status and in the foo package, but from different classloaders

2:28 replaca_: though my real point was that clojure_0000's comparison of = and .equals results seemed valid

2:29 amalloy: clojure_0000: suggestion: treat records and structs as "advanced features", not "hey look i can make objects after all!"

2:29 s/objects/classes, i guess

2:29 replaca_: yeah, 99% of the time I am happy with maps

2:30 and they work quite well with :pre and :post reasoning too

2:31 oh, man, time for bed

2:31 good luck all!

2:37 clojure_0000: amalloy: no no, I'm not going for "I can make objcts after all"; I'm going for "I can have types after all"

2:37 amalloy: hence my s/objects/classes

2:38 clojure_0000: I have refined my needs to be able to do the following: <private> (defrecord Foo ...) (defn Typed-Checked-Foo [ ] (Foo. ... )) </private> <public> (defn Foo. TypeCheckedFoo.) </public> <--- is something like this easily possible?

2:40 what I need, is defn::defn- = defrecord:: ???

2:40 lazybot: clojure_0000: Oh, absolutely.

2:43 clojure_0000: alternatively:

2:43 how do I overwrite the constructor of a defrecord?

2:44 minds that wnat to implement haskell within clojure wants to know :-)

3:12 grr

3:12 no one in theworld knows how to do type checking on a clojure def struct constructor?

3:22 amalloy: clojure said it doesn't want to do static typing with you. no means no, man

4:29 clojure_0000: so I get an error in the repl like:

4:29 (ClassCastException ..... )

4:29 and there's no *.clj line associated with it

4:30 only a Util.java:104

4:30 how do I get a stack frame out of this?

4:30 I wnat to know which *.clj line caused this error so I can fix it

4:36 fixed

4:36 error in (ns ...)

4:40 morphling: clojure_0000: you probably used a list where you should use a vector in your (ns)-form

4:43 clojure_0000: yeah; I wote [( ... )] instead of [ ... ]

8:13 I realize this is bad practice, but is there a way to say:

8:13 (:require foo.*) ?

8:13 basicaly I want to require _ALL_ packages, ie.. foo/**/*.clj

8:19 thorwil: clojure_0000: afaik no. you should use require and use in a way that makes it clear in the code what comes from where, anyway

8:46 clojure_0000: thorwil: a blanket require still makes it clear where it come sfrom, since by default, all names have their paths encoded within

8:47 not being able to do a blanket require actualy encourages me to ... not have lots of little files lying around

8:47 which is bad; since I wnat to have code split quite a bit

8:51 thorwil: shouldn't said code split be much about what you have to require where?

8:52 clojure_0000: lots of decomposition = more files = more args to require = too lazy to type = want a blanket require

9:11 TimMc: Just use slamhound. :-)

11:28 Is xerial.org the place to get sqlite-jdbc?

11:29 Or should I use zentus?

11:39 Raynes: TimMc: Teach me how to use Enlive.

11:45 TimMc: Raynes: Pssh, *now* you ask. Can't though, I'm on a train with really shitty wifi/

11:45 also, I don't understand Enlive yet.

11:45 Raynes: Yeah, I'm not sure I quite understand how anybody possibly can.

11:45 But meh.

11:46 weavejester: Isn't enlive just (at selector transformer)?

11:46 TimMc: I intend to write a doc for Enlive that groups the API into different categories.

11:46 maybe invent some nomenclature

11:46 weavejester: Soemtimes that transformer does something, sometimes it returns a closure to do something.

11:47 Raynes: weavejester: I don't know, man. I read about a paragraph of dnolen's tutorial and hid behind hiccup.

11:47 neotyk: Good morning everyone!

11:47 Raynes: I think I got to "This would allow us to easily implement template inheritance which we’ll talk about later (grin).", facepalmed, and promptly gave up.

11:47 weavejester: I thought the transformer was just a function that modified a clojure.xml data structure

11:47 Vinzent: weavejester, selectors are pretty hard to write, imo

11:49 weavejester: Admittedly I haven't played around with enlive a whole lot.

11:49 neotyk: weavejester: I've seen your fork of autodoc, did you managed to get it to work on 1.3?

11:50 weavejester: neotyk: No, I gave up and wrote my own doc generator, codox

11:51 Raynes: weavejester: What the shit. I didn't know about that.

11:52 neotyk: weavejester: cool, will take it for a spin now

11:52 weavejester: Raynes: I created it for Ring, because I couldn't get autodoc to work

11:52 It generates docs like: http://weavejester.github.com/compojure/

11:52 And: http://mmcgrana.github.com/ring/

11:52 Raynes: weavejester: We've been looking for something new for Noir because... well, we can't get autodoc to work.

11:52 neotyk: weavejester: looks nice !

11:53 Raynes: weavejester: I think this will do fine. You need to publicize this.

11:53 neotyk: nobody can

11:53 weavejester: Raynes: I guess I should write up a Clojure group post on it then :)

11:54 You should just be able to include codox 0.3.0 as a dependency then run "lein doc"

11:54 I haven't got around to adding options to customize the output at all

11:54 But I'll accept patches

11:56 Raynes: weavejester: You missed a great opportunity here. You could have made the command 'lein dox'

11:56 neotyk: weavejester: good for yak shaving

11:56 weavejester: Ragnor: I thought about that :) - But I wasn't 100% sold on the name

11:57 But I couldn't think of any better name

11:57 Raynes: weavejester: Codox explodes on noir. :<

11:57 weavejester: Raynes: What does it say?

11:57 Raynes: Exception in thread "main" java.lang.RuntimeException: java.net.URISyntaxException: Illegal character in fragment at index 25: noir.core.html#var-route->name

11:57 I can make an issue if you'd like.

11:58 neotyk: weavejester: works like promised :)

11:59 weavejester: Raynes: Ohh

11:59 Raynes: weavejester: https://gist.github.com/1521648 Should be this code it goes boom on.

11:59 I guess there is still some old autodoc metadata in there.

11:59 weavejester: Raynes: Yeah, I can see why. It probably doesn't escape the ">" character

12:00 Raynes: And I don't have any macros or functions with that character in Ring or Compojure.

12:00 Hang on, let me just add a URL-encode in there...

12:00 Raynes: This is why you announce things. People test them. :p

12:01 weavejester: Raynes: I was meaning to... eventually...

12:05 Raynes: Hm, odd, I just grabbed noir master and codox 0.3.0 seems to work on it...

12:05 Raynes: weavejester: This var was added on the 1.3 branch.

12:06 weavejester: Raynes: Oh, right. Let me switch branches then

12:07 TimMc: weavejester: The selectors are easy. I want docs on the transformers.

12:07 (and back I go into cellular shadow)

12:09 Raynes: mdeboard: You've got the creepiest twitter picture I've ever seen.

12:10 neotyk: weavejester: also H.A.C. is using codox now http://neotyk.github.com/http.async.client/doc/

12:11 Raynes: Ooh, that's still around? I haven't heard anything about it in a while.

12:12 neotyk: Raynes: indeed, I was kind of busy :)

12:12 but yes, next rel will have 1.3 comat and maybe WS client

12:20 weavejester: Raynes: Try codox 0.3.1

12:20 Raynes: It should work now

12:21 Raynes: weavejester: We have liftoff.

12:22 Omgdocs.

12:23 weavejester: This looks great. I'm going to run it by Chris. I'm sure you'll see patches and such from us in the not-so-distant future.

12:24 weavejester: Raynes: I look forward to them :)

12:28 pandeiro: Raynes: is there a more intelligent way to debug noir stuff than throwing printlns all over?

12:29 Raynes: That's a pretty common way of debugging most Clojure code.

12:29 pandeiro: ok that it is then... i thought maybe there was a logging package i was missing

12:30 Raynes: pandeiro: Well, someone actually wrote something like that recently. Let me look it up.

12:31 pandeiro: https://github.com/ibdknox/noir/pull/63 ?

12:32 Raynes: pandeiro: Yeah, that's it.

12:32 I don't know anything about it, but it says 'logging', so it might be helpful. :)

12:34 weavejester: I've been playing around with the idea of creating a "component" from a transformer function and Ring middleware.

12:35 pandeiro: weavejester: for logging?

12:35 weavejester: pandeiro: Oh, no. Something else.

12:35 pandeiro: sorry, got logging on the brain :)

12:37 weavejester: I was thinking about how to combine a HTML snippet with server-side code.

12:37 Like how a text input might have a validation server-side

13:11 clojure_0000: I am writing my own macro. I want to take a symbol, and append other chars to it, i.e. Cat -> Cat_ and Cat -> Cat. How do I do this?

13:12 Vinzent: ,(-> 'cat name (str "_") symbol)

13:12 clojurebot: cat_

13:13 clojure_0000: ,(symbol (str (name 'Cat) "_"))

13:13 clojurebot: Cat_

13:13 clojure_0000: Vinzent: got it; thanks

13:13 Vinzent: clojure_0000, but it's usually not a good idea, i think

13:13 clojure_0000: Vinzent: why not?

13:14 in this particular case, "clobbering names" should be okay -- I'm writing a maco on top of defmacro

13:14 so the clobbering, if it happens, would be intentional

13:14 i.e. (myDefRecord Cat ...) would purposely create a Cat_ that does type checking before clalint Cat.

13:24 Vinzent: clojure_0000, probably I misunderstood you, but is it possible to use protocols here?

13:28 dabd: I am trying to use an http-agent but the following code hangs the REPL: https://gist.github.com/1521872

13:29 could someone please check it?

13:29 ty

13:29 neotyk: dabd: if you would use http.async.client I could help

13:30 dabd: neotyk: thx I might try it but I would like to understand why http-agent is not working for me.

13:32 in my example h is http-agent and ds is duck-streams

13:37 clojure_0000: how can I construt a function that takes a vector and outputs only every 2nd element

13:37 i.e. it outputs v[0], v[2], v[4], ...

13:37 so it's like a filter; but filters on the index

13:37 rather than the content

13:40 Vinzent: clojure_0000, ##(keep-indexed (fn [i x] (when (even? i) x)) [:a :b :c :d :e])

13:40 lazybot: ⇒ (:a :c :e)

13:45 clojure_0000: , (doc ##)

13:45 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>

13:46 clojure_0000: Vinzent: what is this ## ?

13:46 Vinzent: clojure_0000, it's just for lazybot

13:47 Raynes: It makes lazybot ##(println "evaluate the") code that comes after it.

13:47 lazybot: ⇒ evaluate the nil

13:48 TimMc: clojure_0000: How else would lazybot know what to evaluate?

13:48 Raynes: He could use magic.

13:48 magicbot

13:48 clojure_0000: mind-reader-bot

13:50 Raynes: "Powered by Clojure, Noir, MongoDB and the cries of children the world over."

14:10 clojure_0000: is there an idiomatic way to take a list of 2n elements; and create a list of n elements, each of which is a pair?

14:11 i.e. (0 1 2 3 4 5 6 7) into ((0 1) (2 3) (4 5) (6 7)) ?

14:11 Raynes: &(partition 2 [1 2 3 4 5 6 7])

14:11 lazybot: ⇒ ((1 2) (3 4) (5 6))

14:11 clojure_0000: is & = ## ?

14:11 Raynes: Yeah, it's another lazybot prefix.

14:17 TimMc: clojure_0000: & is the start-of-line eval trigger, ## is the inline eval trigger (and doesn't respond to as many forms)

14:17 clojure_0000: i have a dumb question

14:17 Raynes: I was tring to think of a non-confusing way to explain that, but decided against it.

14:17 clojure_0000: why is ~ chosen as the unquote char?

14:17 it feels very RSI -inducing ish

14:17 the way I have to contort my left hand

14:17 to hit shift + ` at the same time

14:18 Raynes: If you use it enough to cause RSI, you're writing code in the wrong language.

14:18 clojure_0000: isn't macros part of lisp?

14:18 TimMc: clojure_0000: Presumably because , was co-opted as whitespace for readability and ~ is on the same key as `.

14:18 Raynes: Yes, but you shouldn't use them enough to cause RSI.

14:18 arthurdenture: clojure_0000: hit shift with the opposite hand?

14:25 clojure_0000: darn it; looks like I'm going to have to learn how to type properly

14:45 dabd: I have the following code https://gist.github.com/1521996 to download a bunch of files using HTTP GET. I would like to create a standalone uberjar so I ran 'lein uberjar' but when I run the resulting jar with 'java -jar jwget-1.0.0-SNAPSHOT-standalone.jar "http://download.thinkbroadband.com/5MB.zip" "http://download.thinkbroadband.com/10MB.zip"' it downloads the files but the jar does not return terminate in the shell. What might be the cause?

14:45 ty

14:48 huahaiy_: \quit

14:51 clojure_0000: is there a short hand for: (fn [x] (apply f x)) ?

14:51 i.e. I'm looking for g s.t. (g f) = (fn [x] (apply f x))

14:51 seems like g should have a name

14:52 hroarke: dabd: Agents run in a pool of non-daemon threads. These will keep your JVM alive. You need to call shutdown-agents, this will let your JVM exit.

14:52 dabd: hroarke: ty!

15:16 TimMc: clojure_0000: "g" is spelled "partial apply"

15:17 &((partial apply +) [1 2 3 4 5])

15:17 lazybot: ⇒ 15

15:17 romanandreg: has anyone tried to run test.generative using leiningen (lein run)

15:17 >

15:18 I'm trying to find somewhere that tells me how to run clojure.test.generative with clojure.test but no luck so far

15:47 clojure_0000: for functions, I can alias w/ (def short some.path.cat.dog/func); can I do something similar with macros?

15:47 for functions, I can alias w/ (def short some.path.cat.dog/func); can I do something similar with macros? or am I forced to write (defmacro short [ & args] `(some.path.cat.dog/macro ~@args))

15:52 tmciver: clojure_0000: no need to alias that way. You can :use in the namespace declaration or use :as with :require.

15:56 clojure_0000: see http://clojuredocs.org/clojure_core/clojure.core/use#example_551

16:03 Xenocorp: hello?

16:03 clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline Xenocorp

16:04 Xenocorp: is anyone here?

16:04 http://pastebin.com/qygkjNix - could someone check that out for me and see where I am going wrong?

16:08 arthurdenture: Xenocorp, I get an answer when I evaluate that. can you more thoroughly describe "going wrong"?

16:11 Xenocorp: indeed. I was running it through emacs, the eval line is only 1 line so I just saw the nil. My algorithm is wrong, but I will fix that :)

16:12 arthurdenture: I'm using a library where lots of different namespaces get immigrated into a single ns "overtone.core". Is there a way to find the original definition site of a given immigrated name?

16:12 (other than grep)

16:13 technomancy_: arthurdenture: depends on your editor; it's M-. in emacs/slime.

16:14 Raynes: you pinged me like ages ago?

16:15 arthurdenture: technomancy_, thanks, that worked! i guess i was assuming the way would be via the repl

16:15 Raynes: technomancy_: Yeah. I was trying to run a website with 8 kabillion dependencies on Heroku, but `lein run` keeps trying to pull down deps but it times out because the app doesn't bind to a port within 60 seconds.

16:16 technomancy_: Raynes: curious, there should be no dependencies fetched at runtime; they should all be downloaded at slug-compilation time.

16:16 Raynes: Yeah, it does it at slug compilation time and when lein run is an.

16:16 ran*

16:16 technomancy_: can you paste project.clj?

16:16 Raynes: Sec.

16:17 technomancy_: https://github.com/4clojure/4clojure/blob/f/1.3/project.clj

16:17 I'm guessing checksum-deps is the problem?

16:17 I didn't notice that (because I didn't put it there) until now.

16:18 technomancy_: that'd be my guess; can you see if you can repro without that line?

16:18 Raynes: Sure

16:21 technomancy: That was it.

16:21 technomancy: Raynes: I'll see if I can debug further tomorrow; for the time being at least there's a workaround.

16:22 Raynes: technomancy: Well, it wasn't anything critical. I was just playing around with it and noticed it and figured it might be a bug.

16:22 technomancy: One question: the free hours you get are per-app, right? Not per-account?

16:23 technomancy: Raynes: I believe so but not confidently enough to put any money on a wager

16:23 Raynes: Heh

16:24 technomancy: by default you're getting 1.5.2, but I've got my apps running on the 1.6.2 branch of the buildpack, so it's been tricky for me to repro that issue in particular

16:25 Xenocorp: http://pastebin.com/qN4UyxdD for http://projecteuler.net/problem=1 if anyone's interested

16:25 Raynes: "Basic usage of Heroku is free. Each app you create has free access to 750 dyno hours per month and a 5MB database."

16:26 technomancy: ^ Awesome. I was curious because I'll be deploying a new heroku app soon.

16:26 (not 4clojure, in case anyone is wondering)

16:29 Xenocorp: does anyone know if there will be an updated version of clojurebox to 1.3?

16:30 technomancy: I don't think clojurebox is maintained

16:30 Xenocorp: no, i know. But I'm sure it won't be much work to package it up

16:30 it seems like the regular emacsW32 install + a clojure setup /.emacs.d folder

16:32 Raynes: amalloy: Y U NO SAY HI?

16:32 I didn't realize you were around.

16:33 technomancy: Xenocorp: using clojure directly is discouraged these days

16:33 Xenocorp: @technomancy can you explain that a bit more?

16:34 Raynes: https://github.com/technomancy/leiningen

16:34 technomancy: Xenocorp: clojure is really just a library rather than an application designed for end-user use

16:35 Xenocorp: a library for which language?

16:35 technomancy: a JVM library

16:35 I guess in this case you could say Emacs is the launcher

16:36 Xenocorp: ehh, I'm confused. You're treating the JVM as a platform that runs, what, exactly?

16:36 I thought you would label Clojure as a language in it's own right, correct?

16:36 technomancy: it's a language implemented as a library

16:36 Raynes: Yes, but Clojure doesn't have a decent end-user interface.

16:36 I think you're using the word 'library' in a confusing way, technomancy.

16:36 technomancy: most languages come with a launcher designed for end-user consumption, but clojure does not.

16:36 Xenocorp: I'm a noob to both clojure and the jvm, so bare with me.

16:37 technomancy: Xenocorp: do you know ruby?

16:37 Xenocorp: No, Python is the only language I 'know'

16:37 but I'm a fairly advanced user

16:38 Python has the interpreter, ran through python.exe on Windows. Is this what you're referring to as 'the user-interface' ?

16:38 technomancy: yeah

16:38 Xenocorp: ok, Clojure has clojure-*.*.*.jar

16:38 does that not count?

16:39 technomancy: imagine if instead of running python.exe you had to write a shell script for anything you wanted to run that set LD_LIBRARY_PATH to point to wherever python was installed

16:39 Xenocorp: ok

16:40 Raynes: Xenocorp: Clojure's jar has an executable portion for starting a REPL that isn't even wrapped by readline. The interface is terrible, but Leiningen fills all of the holes in it.

16:41 Xenocorp: I've not used leiningen, I don't use the REPL either (personal preference)

16:41 Python has a REPL and I find it horrible, I presumed Clojure's would be the same.

16:41 Raynes: Haha.

16:41 dnolen: Xenocorp: heh, when it comes to Lisps, the REPL is everything.

16:42 Xenocorp: Like I said, I'm a noob (== (time-spent) 0) :: TRUE

16:42 Raynes: That's less of a personal preference and more of a "totally missing everything" sort of thing. :p

16:42 Xenocorp: How so?

16:42 Raynes: What dnolen just said.

16:43 Xenocorp: but that doesn't explain anything, it's a statement?

16:43 technomancy: programming without a repl is cybernetically unsound no matter the language.

16:43 Raynes: And that wasn't a question.

16:44 amalloy: Xenocorp: if you don't have a repl, you can't answer simple questions like "hm, what happens if i call foo with various args?" you have to set up a whole program that prompts for args, calls foo, and prints the result

16:44 Raynes: Interactive development is something that can't really be explained to you. It's something you have to experience.

16:44 If you experience it, there isn't a question like "why a REPL" that makes sense.

16:45 Xenocorp: I have experienced it, I find that entering things that require >1 line in a single line REPL the most painful experience ever. If I can write it out in a file, hit a single button to run it, what's the difference. When it's running, sure, a REPL is great. Before that, nope.

16:46 amalloy: well that's not crazy. emacs's repl is a multi-line editable area

16:46 Xenocorp: I've just started with clojurebox today

16:46 amalloy: (and has a button for sending a file to the repl)

16:47 dnolen: Xenocorp: you can interact with the REPL w/o always typing into

16:47 Xenocorp: with using the arrow keys/

16:47 ?

16:48 dnolen: Xenocorp: all the good LISP environments support many ways of sending code to the REPL

16:48 Xenocorp: I never said a repl is a waste of time, just that it's not my main programming interface.

16:49 and I've been using clojure for about 2 weeks, only.

16:49 choffstein: Can anyone point me to a good post / article / book on writing performant clojure? I've done some profiling with JVisualVM and seem to be spending a lot of time with reflections. I've set *warn-on-reflections* and gotten rid of everything I could. But I would love to read a page about where I can use type-hints, best uses of Java arrays, or when it is better to use maps vs records.

16:49 Xenocorp: choffstein: There's a section about it in Practical Clojure on Apress pub, about 30-70 pages.. iirc

16:50 choffstein: Xenocorp: Awesome. Thanks.

16:54 Xenocorp: choffstein: I just checked. 9 pages, but it covers type hinting

16:54 sorry

16:58 choffstein: No worries. I just noticed an incredible speed-up in an app I am writing going from a generic map-of-maps to a map-of-records with type-hints. That sort of thing I never would have really "guessed." I'm trying to find more stuff like that.

17:01 Xenocorp: practical clojure seems like a decent book. I need something a little more basic, but it sufficed to get me 'hooked' on clojure.

17:02 mbai: is there an enhanced clojure repl that has built in doc, completion, sugar. some equivalent of ipython for python.

17:02 dnolen: choffstein: what are you using the type hints for? field access?

17:03 choffstein: computations on the fields

17:03 so something like (math/abs (:field record))

17:04 dnolen: choffstein: another approach is to definite a protocol for those accessors

17:04 choffstein: dnolen: Can you elaborate?

17:04 dnolen: choffstein: then you don't need type hints

17:04 choffstein: Like, create a protocol with type-hinted accessor functions?

17:05 dnolen: choffstein: (defprotocol IPoint (x [this]) (y [this]))

17:06 akhudek: mbac: I don't think so, but you can get documentations using the "doc" function: e.g. (doc some-fn)

17:06 err mbai

17:06 mbai: err?

17:06 clojure_0000: what is a good rule of thumb for naming stuff to NOT conflict w/ java classes? For example, I have a defrecord that is a wraper about KeyEvent; but what shoudl I name it?

17:07 I want to name it KeyEvent, since it's basically what it is

17:07 but then there's already java.awt.event.KeyEvent, and I think having both would be confusing

17:07 mbai: akhudek: I found cljr

17:07 There's also the built in repl in intellij idea.

17:08 akhudek: yes, the intellij repl is pretty nice

17:08 the enclojure repl is not as nice

17:08 clojure_0000: no one has advice on naming?

17:08 choffstein: dnolen: I don't think I understand protocols well enough to understand how that is helpful. Any links you can share?

17:08 amalloy: choffstein: (:field record) is taking limited advantage of its record-ness. (.field ^MyRecord record) will be at least a little faster

17:08 clojure_0000: iirc, all what protocols says is: this object implements these functions

17:09 mbai: akhudek: I was just about to install enclojure, but the author warns against using latest version of netbeans.

17:09 clojure_0000: how does defprotocol differ from java interfaces?

17:09 dnolen: choffstein: amalloy: (.field ...) is way faster than (:field ...)

17:09 mbai: I've used netbeans for a long time, but the plugins are never maintained.

17:09 dnolen: but (field ...) is just as fast as (.field ...) if field is a protocol fn

17:09 akhudek: mbai: I would recommend against encjoure at this time. The author is correct, the netbeans 7 version has some bad bugs.

17:10 choffstein: Ohhh. Wow. That is hugely helpful.

17:10 akhudek: the 6.x version is ok, but has problems with clojure 1.3 as it won't start a repl without the old contrib

17:10 dnolen: clojure_0000: you don't need to worry so much about naming - everything in Clojure is namespaced.

17:10 akhudek: also, the repl has some real issues with it's syntax parsing

17:10 choffstein: So, either use (.field ^MyRecord record) or make my record follow a protocol?

17:10 amalloy: dnolen: doesn't that put some strain on the jit to inline? i'd be surprised if it were really *just* as fast, though sure it would be close

17:10 akhudek: If you print \" to standard output, it will think everything is a string.

17:11 dnolen: amalloy: seems just as fast to me.

17:11 mbai: akhundek: understood. IDEA it is.

17:11 akhudek: It also becomes very very slow at that point as I guess the algorithm for parsing has bad behaviour on long strings.

17:11 dnolen: choffstein: keyword lookups are optimized, but for performance critical stuff yes make a protocol for the accessors

17:12 choffstein: dnolen: Okay, let's assume I am really stupid. Can you show me how you would use that IPoint protocol?

17:13 amalloy: dnolen: just benched it a bit and the protocol version takes ~3 times longer. putting together a gist in a sec

17:13 dnolen: choffstein: (x some-point), however if you're doing some primitive math, that approach is not so good and your type-hint approach is better.

17:14 amalloy: https://gist.github.com/1522199 outlines the approach i think dnolen is suggesting, and my timing results

17:14 choffstein: dnolen: It's a lot of accessors, data being passed around, then some primitive math. Wish I could share, but it's company code :-\ The performance speed-up isn't necessary -- just nice

17:16 Any such optimizations for setters? :D

17:16 amalloy: of course

17:16 dnolen: amalloy: those are the timings I've seen, but it probably depends on machine, JDK, etc.

17:16 amalloy: though the answer depends on whether you really mean setters, or you mean immutable updates

17:17 dnolen: choffstein: setters are really a last ditch thing since that's playing with fire.

17:17 choffstein: Hmm. Well, assoc on a record

17:17 amalloy: sure. i think the protocol dispatch here is something the JIT could be smart enough to inline, then optimize

17:17 dnolen: amalloy: I meant those aren't, sorry.

17:17 amalloy: choffstein: you might want to borrow a tool from `useful`, called assoc-record

17:18 it does the optimizations for you

17:18 choffstein: awesome, thanks

17:18 amalloy: and also generates the optimized accessor functions

17:18 https://github.com/flatland/useful/blob/develop/src/useful/datatypes.clj and sample usage at https://github.com/flatland/useful/blob/develop/test/useful/datatypes_test.clj

17:20 personally i hate the update-record syntax and don't really suggest using it, but the rest is pretty handy

17:20 dnolen: amalloy: choffstein: https://gist.github.com/1522208, OS X, JDK 7, 2.6ghz dual core i7

17:20 choffstein: much appreciated

17:22 amalloy: dnolen: yeah, must be a jvm thing. when i run your code the difference between (.a f) and (a f) is even more pronounced than in my code

17:22 40ms and 170ms respectively

17:23 on Ubuntu openjdk 1.6, slow-ass old cpu

17:24 rplevy: I'm curious about updating leiningen to depend on 1.3. Are there problems that have held this up, or is just a to-do that hasn't been done yet?

17:24 ibdknox: rplevy: many of the plugins rely on contrib

17:25 upgrading lein itself is easy

17:25 upgrading nearly every plugin? that's going to take some time

17:25 unfortunately :(

17:26 rplevy: ok, so basically what is holding it up is going down the list of plugins and eliminating their contrib dependencies.

17:26 clojure_0000: I have (:require foo.bar); then somewhere later, I use foo.bar/kick inside of a _macro_ -- do I have to do something special when using functions within a macro? [some lisps have multi level compilation; so depending on whether it's within a macro, I have to import the function in a special manner]

17:26 rplevy: but they can't be updated to 1.3 yet

17:27 ibdknox: rplevy: last I knew, technomancy is basically waiting to make that transition for the 2.0 release

17:27 rplevy: I see

17:28 are all of the plugins listed on the lein plugins page on github?

17:28 I can't think of any that aren't anyway...

17:28 ibdknox: most likely not

17:28 but that ought to be the majority

17:28 rplevy: ok

17:29 amalloy: clojure_0000: no

17:32 ibdknox: dnolen: done with cljs, clojail (only works in chrome, for some reason): http://blazing-flower-2726.herokuapp.com/

17:33 dnolen: and little example code: https://gist.github.com/1522225

17:34 clojure_0000: amalloy: it was a diferent error

17:34 dnolen: ibdknox: that's neat!

17:34 clojure_0000: I'm not yet versed in deciphering clojure's error codes yet.

17:35 choffstein: It's hard to profile when my network is running at 1.03KB/sec … sigh

17:38 ibdknox: dnolen: I'm working on an interactive teaching environment :)

17:39 dnolen: ibdknox: that is a-w-e-s-o-m-e :)

17:40 choffstein: Does a type-hint for the value being returned by a function go before or after the function name?

17:40 dnolen: choffstein: it comes before the arglist

17:41 choffstein: well if you're talking about primitive returns

17:41 choffstein: dnolen: …and if I am talking about an object? I am looking at an example in practical clojure that has #^String after defn

17:41 dnolen: choffstein: you can also type-hint the var of the fn to help the compiler

17:42 Xenocorp: hi, does anyone know a decent DEAD TREE book for learning clojure syntax?

17:42 dnolen: choffstein: but you're not really hinting return values (i.e. doesn't work higher order)

17:42 choffstein: dnolen: type hint the var of the fn … that has to do with every symbol having a var and a fn, right?

17:43 dnolen: choffstein: not quite. every top level definition is stored in a var.

17:43 choffstein: the compiler looks at the var's metadata to see if it can avoid reflection.

17:44 choffstein: So … what's the difference between (defn #^String greeting [] "hi!") and (defn greeting #^String [] "hi!")? Because this is confusing the crap out of me.

17:45 dnolen: choffstein: it's confusing.

17:45 choffstein: dnolen: If there is a book or article you can refer me to, I'm happy to go reading on me own and stop annoying you :)

17:45 dnolen: choffstein: I believe both forms work.

17:45 choffstein: there's no book on this stuff that I'm aware of.

17:45 choffstein: also ^String is preferred now.

17:46 choffstein: hmm… can I pay you to write an article on it? :D

17:46 ibdknox: haha

17:46 choffstein: …shit, that isn't a bad idea. have a website with "bounties" for answers. People can pledge a certain amount for an answer, and the community votes if the answer is adequate for a release of the $$ :)

17:46 dnolen: choffstein: if you search the ML I've written many times on Clojure perf, also I've got some posts on dosync.posterous.com

17:47 ibdknox: choffstein: it's been tried before

17:47 dnolen: choffstein: also the Clojure alioth benchmarks are a good source of ideas. core.logic also has a bunch of things in it I've learned from optimizing Clojure.

17:47 choffstein: ibdknox: Of course it has. I have never had a single original idea, nor a single good one ;)

17:48 dnolen: Awesome. I'll check that out. THanks :)

17:48 ibdknox: hehe

17:48 clojurebot: Titim gan éirí ort.

17:48 ibdknox: choffstein: none of us have ;)

17:55 Xenocorp: can someone give me a rundown of what lein is?

17:55 ibdknox: Xenocorp: it's a tool that lets you create, run, and manage clojure projects at the command line

17:55 Xenocorp: it's also the quickest way to get a repl up

17:56 Xenocorp: interesting

18:03 replaca_: ibdi

18:03 ~/////

18:03 clojurebot: I don't understand.

18:04 replaca_: sorry, network prrobs

18:05 ibdknox: I'm prepping a new release of autodoc. Any issues besides version numbers that are burning a hole with you.

18:07 choffstein: Anyone seen an error like this before: my.namespace.MyRecord cannot be cast to my.namespace.MyRecord ?

18:07 replaca_: did you reload the def?

18:08 choffstein: *le sigh*

18:25 rplevy: I just cloned the 53 leiningen plugins repos listed on https://github.com/technomancy/leiningen/wiki/Plugins to analyze their dependencies. Out of 53, 16 of them directly depend on contrib in project.clj

18:26 ibdknox: technomancy: ^^

18:26 alexbaranosky: rplevy: hey Rob

18:26 rplevy: he

18:26 ibdknox: replaca_: version numbers?

18:26 rplevy: *hey

18:28 replaca_: ibdknox: well, the fact that the current released version wants to be in clojure 1.1

18:28 and therefore doesn't build with newer things

18:29 ibdknox: replaca_: ah yes that makes things difficult. My biggest complaint was that I could never find one release to definitely use, I'm using someone's fork right now and it works only part of the time :(

18:29 replaca_: ibdknox: I see that you're using a version that Rayne pushed to get around that

18:29 ibdknox: yeah

18:29 replaca_: k, I'm trying to iron that out

18:29 Raynes: (a version that I don't remember pushing and have no idea why)

18:30 ibdknox: Raynes: I was wondering about that :p

18:30 replaca_: I'm about to do an interim release that will help at least some

18:30 (though maybe not 100% with leiningen)

18:37 choffstein: Thanks for the help today, everyone. I'm out for a while

18:50 weavejester: Out of interest, does anyone develop Clojure on a Mac?

18:52 clojure_1000: I need a powerful sounding name; something command/control-ish; it's basically the object that stores state for the user actions (in the heads up display)

18:52 I was going with somethign like "Status", but it sounds too weak

18:52 I need something like "this-button-launches-nukes"

18:52 but shorter

18:52 weavejester: red-button ?

18:52 clojure_1000: no no, it doesn't always launch nukes

18:53 weavejester: hmm

18:53 clojure_1000: it's like the mythical "houston" that is talked about in every space movie

18:53 it's the place where all info is routed through

18:53 and all important decisions are made

18:53 turbofail: NORAD

18:53 clojure_1000: a hub of sorts

18:53 weavejester: "Houston" might work too :)

18:53 clojure_1000: I feel like that has too much emotional connections; it wouldb be like naming a variable batman

18:54 (referring to Norad, not houston)

18:54 do the air controllers that F22 pilots talk to ... do they have a name besides "air controllers" ?

18:54 weavejester: I find naming things hard :/

18:55 rplevy: weavejester: I thought it was the most popular, but at the last baznex there was only 1 mac, GNU/Linux PCs represent

18:55 weavejester: rplevy: I wonder how they compare...

18:55 clojure_1000: bah

18:55 CommandCenter is too long

18:55 Hatch doesn't sound right

18:55 weavejester: I was thinking about getting an ultrabook

18:55 clojure_1000: so I think I should name it after the protoss Nexus

18:55 sandy1986: Can you help me? My tests behave other than my repl!

18:56 weavejester: And the best seems to be the Macbook Air. I kinda like OSX as well, but... I also like Linux :)

18:56 clojure_1000: I am running ubuntu inside of vmbox inside of a macbook pro

18:56 hkon_: mac air is good mkay

18:56 clojure_1000: wait wait

18:56 sandy1986: (is (= nil (test/get-item "notAvailable"))) << works in test

18:57 clojure_1000: I am runnig irssi inside of xterm inside of gnome inside of X inside of ubuntu inside of virtualbox inside of OSX on a macbook pro.

18:57 rplevy: weavejester: my preferred environment is Thinkpad / Ubuntu

18:57 sandy1986: in VimClojure repl: clojurestack.core=> (= nil (with-mc db-nodes get-item "notAvaliable")) ... evaluates to false

18:57 the expression itself to "true" ...

18:57 weavejester: sandy1986: Could that with-mc be doing anything?

18:58 sandy1986: (deftest get-item (test/with-mc testdb (is (= nil (test/get-item "notAvailable"))) ))

18:58 it's exactly the same as in the test

18:58 weavejester: sandy1986: And testdb is the same?

18:58 sandy1986: yes

18:59 weavejester: sandy1986: You could try adding some (prn ...) to your test to make sure all the data is the same

18:59 sandy1986: (def db-nodes "127.0.0.1:11211") << exactly the same

18:59 weavejester: Also...

18:59 Hang on

18:59 (with-mc db-nodes get-item "notAvailable")

18:59 Is that exactly what you have?

19:00 And not (with-mc db-nodes (get-item "notAvailable"))

19:00 ?

19:00 sandy1986: You might be missing some parentheses.

19:01 sandy1986: clojurestack.core=> (with-mc db-nodes get-item "notAvaliable") true clojurestack.core=> (with-mc db-nodes (get-item "notAvaliable")) true

19:01 weavejester: rplevy: Mine is Ubuntu too, but Mac hardware is always very nice.

19:02 sandy1986: Maybe the return value of with-mc isn't what you think

19:02 sandy1986: Try: (with-mc db-nodes (prn (get-item "notAvailable")))

19:02 clojure_1000: is str a multimethod? if so, for a struct, what is the difference between overloading toString vs hijacking the str multimethod?

19:02 sandy1986: when I use prn in my test it prints "nil" and the test works as excepted

19:02 expected

19:02 damn auto corretion

19:02 weavejester: My guess is that the (with-mc ...) macro might return true no matter what the body.

19:03 clojure_1000: how can I get the source of vector.toString?

19:03 rplevy: sandy1986: just curious, you said the repl behaves different from running it directly. Did you try turning the repl on and off again ;) it tends to build up state.

19:03 sandy1986: yes rplevy I've tried it

19:03 same result

19:04 amalloy: clojure_1000: it's in the clojure repo on github

19:04 rplevy: I had this problem with lein test working and running tests in the repl not working once, but I don't rememeber what the solution ws

19:04 clojure_1000: amalloy: Is there a way to get it via a combo of doc/source ?

19:04 weavejester: sandy1986: What happens when you put a prn function inside the with-mc block?

19:04 amalloy: src/jvm/clojure/lang/PersistentVector.java, though it probably inherits its tostring from somewhere else

19:04 no

19:04 clojure_1000: amalloy: Is there a way to get it via a combo of doc/source ? (from teh clojure repl)

19:04 amalloy: got it

19:05 sandy1986: I'll try weavejester !

19:05 clojure_1000: amalloy: do I want IPersistentVector.java or PersistentVector.java?

19:06 rplevy: in general, I tend not run my unit tests in the repl, so I sometimes interactively construct them in the test namespace in the repl

19:06 * "though", not "so"

19:06 clojure_1000: hmm, I want APersistentVector.java it looks like

19:06 Scriptor: clojure_1000: I think any file that starts with I is just for the interface

19:06 not sure though

19:06 actually, I'm probably wrong

19:07 nope, right

19:07 sandy1986: #<NullPointerException java.lang.NullPointerException>

19:07 amalloy: Scriptor: exception: Intrinsics.java :)

19:07 clojure_1000: anything that starts with I[A-Z].*.java

19:08 Scriptor: pfft, semantics

19:08 clojure_1000: what does the RT in: jvm/clojure/lang/APersistentVector.java: return RT.printString(this); stand for?

19:08 wtf is RT?

19:09 sandy1986: (defmacro with-mc "Macro to manage Connection" [spec & body] `( with-mc* ~spec (fn [] ~@body)))

19:09 clojure_1000: run tiem?

19:09 hmm

19:09 Scriptor: clojure_1000: it just contains a lot of java functions that are counterparts to clojure functions

19:09 without being attached to any particular data structure, which is why everything is static

19:10 weavejester: sandy1986: Hm? Are you doing: (with-mc db-nodes (prn (get-item "notAvailable"))) ?

19:10 clojure_1000: let me ask a simpler question:

19:10 Scriptor: well, not all counterparts, but a lof them are there

19:10 clojure_1000: does a clojure vector call toString on each of its args?

19:10 when I tell a vector to become a string?

19:10 sandy1986: clojurestack.core=> (with-mc db-nodes (prn (get-item "notAvaliable"))) nil true

19:11 There is my nil ... mhhh

19:11 yes, with-mc seems to eat the value

19:12 Raynes: clojure_1000: Do you want to convert all of the elements of a vector to a string or the vector itself?

19:13 Former is ##(map str [1 2 3 4]) and the latter is ##(pr-str [1 2 3 4])

19:13 lazybot: (map str [1 2 3 4]) ⇒ ("1" "2" "3" "4")

19:13 (pr-str [1 2 3 4]) ⇒ "[1 2 3 4]"

19:13 clojure_1000: I wish that (str vec) acts something like: (apply str (map str vec))

19:13 Raynes: actually, ti's more of a question: is (str vec) equiv to (apply str (map str vec))

19:14 Scriptor: clojure_1000: it just returns a string representation of the entire list, as opposed to each element

19:14 which I think makes sense

19:14 Raynes: Yes.

19:14 clojure_1000: what is "string representation of the entire list" ?

19:14 Scriptor: s/list/vector

19:14 clojure_1000: how is that defined?

19:14 sandy1986: How can I modify with-mc to not return "true"

19:14 Raynes: In order to make a vector a string, it has to make each of its elements a string.

19:15 clojure_1000: Raynes: so it has to call toString on each of them?

19:15 weavejester: sandy1986: It looks like with-mc is just calling with-mc*

19:15 Scriptor: clojure_1000: if you want to print [1 2 3] it just returns "[1 2 3]"

19:15 weavejester: sandy1986: Which library is this?

19:15 Scriptor: so that's the equivalent of converting the entire vector to a string

19:15 sandy1986: spymemcached

19:16 clojure_1000: , (defrecord Foo [] Object (toString [x] "Bar")) (str [ (Foo.) ] )

19:16 sandy1986: https://gist.github.com/1522334

19:16 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

19:17 clojure_1000: so in the above example

19:17 Scriptor: clojure_1000: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L1775

19:17 clojure_1000: how is the Foo object being converted to a string

19:17 is toString is not called?

19:17 Scriptor: that's what ends up happening if you call str on a vector

19:17 weavejester: sandy1986: It's that shutdown that's the problem. The last expression in a function is what it returns

19:18 sandy1986: Let me fork and modify your gist a sec...

19:18 sandy1986: ahh, damn... I got it

19:18 okay

19:19 Scriptor: clojure_1000: specifically it calls the write method of a stringwriter class on each element in a vector

19:19 clojure_1000: it looks like it's usinr print (a.nth ...)

19:20 weavejester: sandy1986: By the way, (. Thread (sleep 1)) is just going to sleep for 1 millisecond

19:20 clojure_1000: how can I check if print is a fn or if print is a multimethod?

19:20 Scriptor: btw, thanks for the link, it was quite interesting to read

19:20 (the print i'm referring to is line 1779)

19:20 Scriptor: clojure_1000: link to the print function https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L1697

19:20 sandy1986: I know weavejester , thats what the spymemcached team suggested

19:20 weavejester: sandy1986: Oh, okay. Weird! :)

19:20 sandy1986: there is an error when the first data is send before the connection is set up and running

19:20 this is a timing problem about ~1ms

19:20 Scriptor: clojure_1000: as you can see, print does a bunch of stuff but essentially calls stringwriter's write

19:21 clojure_1000: Scriptor: ah, well wait; doesn't the first line check if there is a multimethod, and if so, calls it?

19:21 Scriptor: (sorry for stupid questions; this is my first tour into the jvm side of clojure's source)

19:21 [i'm referring to lines 1699, 1700)

19:21 weavejester: sandy1986: What about this: https://gist.github.com/1522337

19:22 Using a (try ... (finally ...)) is the usual pattern for handling shutdowns

19:22 Scriptor: clojure_1000: no worries, I'm just trying to figure this out as I go along, I have no idea whawt PRINT_INITIALIZED means

19:22 weavejester: Because then if there's an exception in (func) the connection is still closed.

19:24 clojure_1000: hmm, (defmethod print Foo [x] (println "YAY")) <-- results in Exception complaining clojure.core$print can not be cast to clojure.lang.Multfn

19:24 amalloy: ,print-method

19:24 clojurebot: #<MultiFn clojure.lang.MultiFn@1b7e189>

19:26 sandy1986: weavejester: it works!

19:26 weavejester: Awesome :)

19:26 sandy1986: When it is finished, I'm going to publish it on github (the memcached / spymemcached things)

19:27 clojure_1000: amalloy: is there a way via the repl to get the dispatch-fn of print-method?

19:33 amalloy: for a multimethod, is there a way via the repl to get a list of all methods registered + their source?

19:34 i feel that based on the readings I have done so far, ideserve an upgrade

19:46 sandy1986: https://gist.github.com/1522366

19:46 nice ;)

20:19 how can I throw away a return value

20:19 ["addtodo"] (fn [req] ( (save-todo-from-req req) (response (str "ok"))))

20:20 (save-todo-from-req req) returns net.spy.memcached.internal.OperationFuture , message : OperationFuture cannot be cast to clojure.lang.IFn

20:20 amalloy: &(do (inc 1) "ignored that") ;; this, sandy1986?

20:20 lazybot: ⇒ "ignored that"

20:21 sandy1986: ahh

20:22 net.spy.memcached.internal.OperationFuture cannot be cast to clojure.lang.IFn << same error, even with "do"

20:23 amalloy: you put in too many parens

20:24 sandy1986: parens?

20:24 clojurebot: ΜΟΛΩΝ ΛΑΒΕ

20:25 sandy1986: ["addtodo"] (fn [req] ( (do (save-todo-from-req req)) (response (str "ok")))) << ...

20:25 amalloy: (fn [req] (do

20:26 sandy1986: ahh

20:40 What is the best way to get a list, containing the :task of https://gist.github.com/1522366

20:43 amalloy: (map :task ...)?

20:44 sandy1986: mhh

20:44 wow, works

20:47 and how to get both open and name ?

20:47 :name and :open

20:48 dnolen: (map (juxt :name :open) [{:name "foo" :open "bar"}])

20:48 (map (juxt :name :open) [{:name "foo" :open "bar"}])

20:48 ,(map (juxt :name :open) [{:name "foo" :open "bar"}])

20:48 clojurebot: (["foo" "bar"])

20:49 dnolen: sandy1986: ^ one way

20:49 sandy1986: wow, what is juxt, never seen it before

20:49 dnolen: ((juxt dec inc) 1)

20:49 ,((juxt dec inc) 1)

20:49 clojurebot: [0 2]

20:50 sandy1986: ahhh

20:52 and if I want to replace "true" as the result of :open in the list...? using a formatting method?

21:05 dnolen: sandy1986: what do you mean?

21:07 sandy1986: ["Wutttzi" true] ["Wuutz" false] should appear as ["Wutttzi" "Open"] ["Wuutz" "Closed"]

21:10 dnolen: sandy1986: then don't use :open, use a custom function

21:10 sandy1986: as a parameter of map?

21:10 dnolen: ((juxt :name my-fn) ...)

21:10 sandy1986: (map (fn [x] ... ) xyz ) ?

21:11 ahh

21:11 dnolen: (map (juxt :name my-fn) xs)

21:14 sandy1986: clojurestack.core=> (map (juxt :task (fn [x] ("x")) ) (get-todos)) ( #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>

21:14 dnolen: ,("x")

21:14 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>

21:15 sandy1986: ahh str

21:15 ,(str "x")

21:15 clojurebot: "x"

21:16 sandy1986: ,(power-on-skynet)

21:16 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: power-on-skynet in this context, compiling:(NO_SOURCE_PATH:0)>

21:20 sandy1986: (map (juxt :task (fn [x] (str (if (true? (:open x)) "Open" "Closed")))) (get-todos))

21:20 wooho ;)

21:22 okay, thank you very much

21:22 I'm going to bed

22:36 technomancy: rplevy: yeah, the problem is that the plugin guide actually mentions that clojure and contrib are implicit dependencies, so they don't need to be declared

22:37 rplevy: it's looking right now like lein 2.0 will not even attempt to be plugin-compatible with 1.x in most cases.

23:38 holy smokes; try.ocamlpro.com actually compiles ocaml bytecode straight to JS.

23:39 ibdknox: technomancy: any thoughts on why when I run heroku and leave a site idle for a bit, the next request takes a *really* long time

23:39 technomancy: also, that's ridiculous

23:39 technomancy: yeah, dead code elimination and everything

23:40 I think the delay is just it coming back from idling

23:40 IIRC that's just part of the deal with the free tier; you get the same thing with app engine &co

23:41 ibdknox: I see, outside of the free tier that won't happen?

23:43 technomancy: that's my understanding

Logging service provided by n01se.net