#clojure log - Jan 17 2011

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

0:00 Scriptor: amalloy: ah, right

0:01 amalloy: tonyl: i confess i don't see what thunk has to do with the code there. the comment seems out of place

0:01 see http://en.wikipedia.org/wiki/Thunk#Functional_programming

0:01 tonyl: ok, that was an option that came into mind

0:01 thanks

0:55 hiredman: https://gist.github.com/750897

1:00 TimMc: If someone passes me a function, can I extract a name from it?

1:02 tonyl: &(name 'first)

1:02 sexpbot: ⟹ "first"

1:03 tonyl: but I haven't use that snippet in projects

1:03 amalloy: tonyl: that's getting a name from a symbol, not a function

1:04 &(meta (fn foo []))

1:04 sexpbot: ⟹ nil

1:04 amalloy: &(name (fn foo []))

1:04 sexpbot: java.lang.ClassCastException: sandbox9112$eval11089$foo__11090 cannot be cast to clojure.lang.Named

1:04 amalloy: so it looks like no, tim

1:04 &(map meta first #'first)

1:04 sexpbot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$first

1:05 amalloy: &(map meta [first #'first])

1:05 sexpbot: ⟹ ({:line 53} {:ns #<Namespace clojure.core>, :name first, :file "clojure/core.clj", :line 48, :arglists ([coll]), :doc "Returns the first item in the collection. Calls seq on its\n argument. If coll is nil, returns nil.", :added "1.0"})

1:18 TimMc: &(str (fn foo []))

1:18 sexpbot: ⟹ "sandbox9112$eval11112$foo__11113@1b6f4ea"

1:18 TimMc: Clojure knows the name somehow.

1:21 amalloy: TimMc: no it doesn't, it knows the classname

1:21 &(class (fn[]))

1:21 sexpbot: ⟹ sandbox9112$eval11121$fn__11122

1:21 amalloy: &(class first)

1:21 sexpbot: ⟹ clojure.core$first

1:22 amalloy: &(str first)

1:22 sexpbot: ⟹ "clojure.core$first@130e714"

1:23 amalloy: hiredman: cute little error-handler

1:23 TimMc: amalloy: The classname of (fn foo []) includes "foo"?

1:23 amalloy: TimMc: yes

1:23 TimMc: &(str (fn FOOBARQUX []))

1:23 sexpbot: ⟹ "sandbox9112$eval11144$FOOBARQUX__11145@1a41a8d"

1:23 hiredman: amalloy: thanks

1:23 amalloy: &(map (juxt class str) [(fn []) (fn test [])])

1:23 sexpbot: ⟹ ([sandbox9112$eval11153$fn__11154 "sandbox9112$eval11153$fn__11154@c06c8b"] [sandbox9112$eval11153$test__11156 "sandbox9112$eval11153$test__11156@1163ae3"])

1:24 TimMc: gah

1:24 Anyway... every anonymous function generates a class?

1:24 amalloy: TimMc: every function, period

1:25 TimMc: &(class (fn FOOBARQUX []))

1:25 sexpbot: ⟹ sandbox9112$eval11164$FOOBARQUX__11165

1:25 TimMc: cool

1:25 amalloy: TimMc: IFn is an interface with the method .invoke(args)

1:25 every function is a class implementing that interface

1:25 TimMc: hrm

1:26 I'll sleep on that.

1:26 amalloy: &(use '[clojure.contrib.repl-utils :only [show]])

1:26 sexpbot: java.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath:

1:27 hiredman: IFn is huge in 1.3, all the LOL inner interfaces

1:27 amalloy: hiredman: as a stylistic thing, might it be...prettier to return either {:result x} or {:exception e} and destructure with :keys?

1:27 blugh really? gross

1:28 hiredman: well, each arity for invokePrim gets an interface

1:28 amalloy: yeah, i know

1:28 hadn't thought about the repercussions

1:29 hiredman: amalloy: *shrug* that bit is internal plumbing

1:30 amalloy: hiredman: how are return values handled in the morass of interfaces? can we still only return Object, or is there like...invokeBoolean(int, double)?

1:31 dnolen: amalloy: in 1.3 you can return long and double

1:32 amalloy: ah

1:32 not much need for highly-performant booleans anyway, i guess :)

2:27 LauJensen: Morning all ya'll

2:27 seancorfield: it's half past 11pm on Sunday night :)

2:29 hey LauJensen i forked clojureql with a view to maintaining a 1.3-compatible version... any input from you much appreciated

2:30 LauJensen: clojurebot: UGT?

2:30 clojurebot: ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html

2:30 LauJensen: seancorfield: ^

2:31 seancorfield: lol... that's new to me but i like it

2:35 LauJensen: seancorfield: re clojureql, how incompatible are 1.2 and 1.3 ?

2:43 seancorfield: haven't dug into it yet... ^dynamic seemed to leap out... will report on more as i find it

2:44 compiling for 1.3 and some basic testing worked cleanly tho'

2:48 amalloy: seancorfield: not sunday night for LauJensen, even ignoring ugt

2:58 LauJensen: seancorfield: The dynamic tags will not break 1.2 compat. I would greatly prefer if we could have them co-exist within the same project since that will give is 50% fewer codebases to maintain

3:01 seancorfield: yup, i'll compile against 1.2 as well - if anything looks 1.3 only, i'll discuss coz that's not good either way

3:03 LauJensen: Sure, just bring it up in #clojureql and if manage to make the projects mergable that would be preferable

3:04 seancorfield: tomorrow (well, later today now), we have our company conference that will either bless or reject clojure for production...

3:05 my right hand developer looked at some clojureql code and was comfortable with it so i'm going in well armed :)

3:05 LauJensen: Very intesting, let me know how it goes

3:05 amalloy: seancorfield: best of luck

3:06 night folks

3:06 seancorfield: night amalloy

3:06 well, it's now morning here (in LA, not my home) so i'm going to sign off and say goodnight

3:09 LauJensen: Goodnight

4:04 AWizzArd: http://blogs.oracle.com/henrik/2011/01/jdk_7_feature_complete_milestone_reached.html

4:06 LauJensen: Its incredible to me, that this can be considered succesfull "We hit the date less than a week late"

4:07 AWizzArd: Today in one month they plan to offer a Developer Preview.

4:15 bobo_: so in... 3 years people will start using it?

4:17 robonobo: will clojure 1.3 run on on jdk 7?

4:17 LauJensen: Also - I dont understand why they're working on new features when the old stuff is still broke. I dont think Ive ever worked with a framework as frustrating, unrealiable and inconsistently designed as Swing

4:17 PHP is close, but even #java says PHP is designed with more rigor :(

4:17 robonobo: Clojure targets 1.5, so yes

4:18 robonobo: LauJensen: I've never had real problems with swing, what is unreliable about it?

4:18 hoeck: LauJensen: come on, swing is so old and had to make many compromises that are not necessary today

4:18 LauJensen: robonobo: Im working on a desktop application now, in which Im seeing undeterministic behaviors, such as scrollbars suddenly disappearing leaving half of the content unreachable etc

4:19 hoeck: LauJensen: and there are really much much much more worse toolkits out there

4:19 LauJensen: hoeck: They should just integrate QT and substitute it for all the junk code they put in

4:19 hoeck: like what? name one

4:19 robonobo: Is there a GUI framework that doesn't do stuff like that?

4:19 hoeck: LauJensen: powerbuilder, win32 crap ...

4:19 LauJensen: robonobo: Qt, Winforms, Aqua...

4:20 robonobo: I've seen Aqua do strange stuff as well

4:20 LauJensen: hoeck: I dont remember PB, but designings UI is such a pleasure on Windows

4:20 bobo_: LauJensen: but they are replacing swing?

4:20 LauJensen: They are a almost a decade ahead of unix in that regard

4:20 AWizzArd: I must say that Swing is not that bad after all.

4:20 LauJensen: I could write a short book on how bad and inconsistent Swing is

4:20 bobo_: well "replacing" atleast

4:20 LauJensen: Its really amazing

4:20 bobo_: link?

4:20 bobo_: LauJensen: javafx will get a java api instead of an own language...

4:21 swing will ofcource be there

4:21 robonobo: LauJensen: how is it inconsistent?

4:21 AWizzArd: They will add JavaFX on top of Swing.

4:21 bobo_: AWizzArd: no, its a new grapichs stack

4:21 AWizzArd: Nice new effects and visuals for Swing apps.

4:22 LauJensen: robonobo: I havent written it down everytime Ive come across these inconsisties, but I remember writing a function which changed the font/style on all components, but lo and behold a single component didnt submit. So I went on Google and it turns out that they made this one component a special case, and so it had to be rewritten for that specifically. And I come across stuff like that quite often

4:22 hoeck: and I'd rather deal with swing than with all the c++ legacy that a qt gui brings to my sweet little abstract clojure stuff

4:22 LauJensen: hoeck: You can run Qt from Clojure

4:22 AWizzArd: hoeck: yup

4:23 hoeck: of course, and you can run OpenGL from common lisp too, except that from now on you have to deal with JVM segfaults :(

4:23 robonobo: JVM segfaults sound really scary

4:23 s/sound/sounds

4:23 sexpbot: <robonobo> JVM segfaults sounds really scary

4:24 AWizzArd: No no, Swing may have some learning overhead, but it's pretty nice.

4:24 Very customizable and really fast, after the initial startup, which is slooow

4:24 robonobo: AWizzArd: I agree. And the documentation is terrific

4:24 ttmrichter: Worse than Swing? FOX leaps to mind.

4:24 hoeck: well, to be honest, I don't know how mature qt on the JVM actually is

4:25 AWizzArd: robonobo: what I can criticize is: not yet HTML 5 support and some components are missing, such as a DatePicker, etc.

4:25 LauJensen: AWizzArd: I can tell from your statements that you are an inexperienced Swing user, when you get to know it a little better, you'll hate it

4:25 AWizzArd: And of course the initial startup times.

4:25 For me it was quite the other way around. I went from hate to liking it more and more.

4:26 First I thought that the handling of JTables is freaking complicated.

4:26 Later I realized that I need to customize a million of things and that JTables offer everything I need.

4:26 LauJensen: The novice hates it, the journeyman likes it, the master hates it with a passion

4:27 hiredman: AWizzArd: seems to be the general consensus in #java on swing too

4:28 bobo_: a clojure question: if i have a big map, and then create a new car with 99% of its content. it shouldnt realy take alot more memory right?

4:28 AWizzArd: bobo_: car in the sense of CL or as in "driving vehicle"?

4:29 bobo_: *var

4:29 so as in i cant type

4:29 AWizzArd: bobo_: it depends on how you "create a new var" with 99% of its content.

4:29 bobo_: (def newcar (second (second original)))

4:29 something like that

4:30 tomoj: :)

4:30 AWizzArd: hmm, are you sure you work with "second" on maps?

4:30 The results could be pretty... random.

4:30 bobo_: the result i get is what i want

4:30 AWizzArd: It can be done in microseconds if you do use things such as dissoc.

4:30 robonobo: is map a hashmap or a treemap?

4:30 bobo_: its a incanter dataset

4:30 raek: bobo_: map the data structure or map the function?

4:30 bobo_: not sure what thta is

4:30 AWizzArd: bobo_: maps are typically accessed by "get"

4:31 Unless it is a sorted-map-by the order may appear totally random to us.

4:31 ,(second (apply hash-map (range 0 5000)))

4:31 clojurebot: [1024 1025]

4:32 AWizzArd: I don't find this intuitive. A (get m 1024) however was expected to return 1025

4:32 bobo_: gonna checck the type if my emacs and slime just would wake up

4:33 tomoj: robonobo: neither

4:33 they're a kind of bit hash tries

4:34 not sure of the exact term.. I think clojure's implementation was somewhat novel?

4:35 hiredman: novel in the sense that other languages didn't have until recently, but they come from some paper

4:35 bagwel?

4:35 raek: I've heard the term "bit-partitioned hash trie" for clojure's hash-map

4:35 tomoj: those weren't persistent, though

4:35 I think? but maybe persistence was no big deal, I dunno

4:36 hiredman: http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/

4:37 robonobo: hiredman: i was just about to post that

4:37 hiredman: someone recently ported clojure's to haskell

4:37 mduerksen: #clojure.de

4:37 ups

4:40 AWizzArd: mduerksen: yes, it's good! :)

4:41 bobo_: ok, so its a seq of seqs not a map

4:41 say its 1GB, doing (second (second myseq)) should not render 1GB more data right?

4:43 tomoj: (second (second myseq)) should only consume more memory if you haven't yet produced the second elements of either seq

4:43 bobo_: great, thats what i thought

4:43 tomoj: if you haven't, and the second element is 1GB big...

4:43 bobo_: yes well, it is

4:43 LauJensen: bobo_: Is there a timeframe for the JFX integration?

4:44 tomoj: don't hold the head if you're processing long seqs with big elements

4:44 bobo_: LauJensen: i think i saw something, il try to find it

4:44 it was announced at devoxx this year atleast

4:44 tomoj: (or very long seqs with small elements, or short seqs with very big elements...)

4:44 bobo_: i have alot of small elements

4:45 dont think it should be this large though

4:45 the .csv is 160MB

4:45 tomoj: do you need to hold the entire dataset in memory at once?

4:45 bobo_: yes =(

4:46 but is it reasonable that 160MB file eats 1GB of ram?

4:46 tomoj: depends on what representation you use in memory..

4:46 bobo_: ofcource

4:46 hoeck: bobo_: you checked it with jvisualvm?

4:47 LauJensen: bobo_: each char in a string takes 2 bytes of memory on the JVM

4:47 bobo_: hoeck: no i didnt, il do that

4:48 tomoj: bobo_: is the dataset just strings split from the csv? some numbers/dates/..?

4:48 bobo_: im not sure what incanter does with it... but there are numbers and dates. not sure if they are converted to that

4:49 LauJensen: I did a project once where as massive CSV file had to be stored in memory. I made by own slurper that put everything in appropriate types. Memory wasnt a problem

4:49 tomoj: did you measure overhead based on theoretical values for types?

4:50 or guess..

5:55 holy shit

5:56 just as I was toying around with lamina ideas, ztellman was committing better looking variants

5:56 I love that dude

7:29 MrHus: If my namespace imports another namespace and the other namespace imports a java class does my namespace need to import that java class as well?

7:45 bartj: MrHus, no

7:45 MrHus, as far as I know

7:45 MrHus: bartj: apparently you do have too.

7:45 Raynes: MrHus: If you want to use that Java class in your namespace, then yes.

7:52 chouser: None of use/require/import are transitive

7:55 Raynes: chouser: What font did you guys use for code in TJoC?

7:56 chouser: Raynes: In the PDFs? I have absolutely no idea -- not my department. :-)

7:56 Raynes: Man, I wish it wasn't mine. :<

7:56 chouser: Can the PDF be queried for that kind of info?

7:56 Raynes: Not sure.

8:01 chouser: Raynes: I think it's just Courier

8:01 Raynes: Looks about right.

8:05 robonobo: silly question: when using slime + emacs, how do I switch from the repl back to the current file?

8:06 AWizzArd: robonobo: Strg+x and then the arrow key left or right

8:06 Ah, Strg = Ctrl

8:07 You can also split the screen via Ctrl+2 or Ctrl+3 (back to one screen via Ctrl+1)

8:07 And then do Ctrl+o to jump between those windows.

8:08 robonobo: i'm new to emacs: Strg?

8:08 AWizzArd: Strg is german for the "Ctrl" key.

8:08 Steuerung (i.e. Control)

8:09 robonobo: one can't spell your name without spelling bonobo :)

8:09 robonobo: yes

8:11 aha, i got it. Thanks

8:12 and is there a way to have history in slime?

8:12 mrBliss: robonobo: M-p and M-n

8:15 robonobo: what I love about it is that if you type 'bladibla', it automatically searches for the last input starting with 'bladibla'. This has saved me lots of time and I miss it in other REPLs (luckily, my zsh prompt has a similar feature).

8:15 robonobo: zsh is so nice

8:15 mrBliss: have you tried oh-my-zsh?

8:16 chouser: many readline prompts let you search backwards using Ctrl-R

8:16 mrBliss: robonobo: yes I have, I'm currently running a heavily modified (or mutilated :) version of it.

8:16 robonobo: do you have it on github?

8:16 mrBliss: robonobo: https://github.com/mrBliss/dotfiles/

8:17 robonobo: i've got four or five branches of ohmyzsh and i'm constantly switching between them

8:17 mrBliss: why is that?

8:18 robonobo: Because I go back and forth on how I like my shell. I can't really decide

8:18 plus i've developed the svn plugin for it

8:19 mrBliss: is this you then? https://github.com/RobinRamael/oh-my-zsh

8:21 robonobo: yes it is

8:21 Are you going to come to my house and peek through my windows now?

8:22 * mrBliss opens google maps ;)

8:22 robonobo: i'm behind 7 (proxys)

8:23 mrBliss: it's just worrying that a simple google query can reveal so much about a person.

8:24 AWizzArd: robonobo: á propos history: you can also just scroll up to form and hit enter to copy it down.

8:24 robonobo: aha.

8:24 I'm trying to make lein and slime work together

8:24 but i can't import anything

8:25 lein swank is running in one window, what else should be done?

8:26 mrBliss: my usual workflow: 1) open a file in a leiningen project, 2) run M-x lein-swank https://github.com/mrBliss/dotfiles/blob/master/.emacs.d/custom-clojure.el#L86 3) Done

8:29 robonobo: mrBliss: I just put that in my .emacs and call it with M-x lein-swank?

8:30 mrBliss: robonobo: make sure your current buffer is a file in a lein project (with [lein-swank "1.2.1"] as one of the dev-dependencies), and then M-x lein-swank

8:56 fbru02: hey guys anyone can help out on a macro question ?

8:57 ./s/macro/macros

8:57 mids: just ask

9:06 fbru02: mids: I c&p'ed around 8 lines of code http://pastie.org/1469852 ... the problem is that the functions i create always end up being user-fede634-action instead of ["add" "get" "is-in"]

9:07 qbg: macros work at compile time

9:07 They are a compile time code transformation

9:08 Thus when gif is compiled, the (gidf ...) form is transformed to (defn user-fede634-action [] println "abc")

9:10 fbru02: qbg: thanks ! how do i make my local action to be compile time too ?

9:10 gju_: is there a function that inserts an item at the beginning of a list?

9:10 raek: fbru02: could you tell us what you want the resulting defn to look like?

9:10 gju_: conj and cons

9:10 qbg: fbru02: You probably don't wan that solution

9:10 Is there any reason why you want this done at runtime?

9:11 Instead of compile time?

9:11 fbru02: raek: yes, there should be 3 defn user-fede634-get, user-fede634-add , user-fede634-is-in

9:12 raek: fbru02: (do (defn user-fede634-get [] (pritln "abc")) (defn user-fede634-add [] (pritln "abc")) (defn user-fede634-is-in [] (pritln "abc")) ?

9:12 fbru02: qbg: yes, the naming depends on external input during runtime

9:13 qbg: Sounds like it might be bad design

9:14 raek: fbru02: if you strictly cannot do it at compile-time, then I don't think you have any other choice than calling 'eval'.

9:14 fbru02: but not that anything that is possible during run-time is also possile in compile-time

9:14 *but note

9:15 so you can call code that fetches the names from a database or whatever

9:15 fbru02: qbg: raek: I

9:15 It seems i'm overusing macros

9:16 I finish this proof of concept and go back to drawing board

9:16 raek: fbru02: also, the arguments of a macro are the code itself, so you cannot bind a name to some value and pass that symbol as an arg

9:16 unless the calling code is a macro too

9:17 fbru02: raek: qbg: thanks

9:18 raek: (defmacro gif [model occurrence & body] (list* 'do (for [action ["add" "get" "is-in"]] `(gidf "user" "fede634" ~action (println "abc")))))

9:19 so you see, macros are contagious in a sense

9:20 qbg: raek: or you make gidf a function and gif be (defmacro gif [] (do ~@(map #(gidf "user" "fede634" % '(println "abc")) ["add "get" "is-in"])))

9:20 raek: (hrm, no need to use 'list*' there. could have used 'cons' instead)

9:20 qbg: That should be `(do ...)

11:39 arkh: for simple datetime parsing / usage in clojure, is clj-time the way to go?

11:41 Raynes: arkh: Yes. clj-time is fantastic.

11:42 arkh: Raynes: thank you

11:43 robonobo: Silly question: how do I remove brackets in clojure-mode?

11:45 klang: robonobo: backspace?

11:46 robonobo: klang: yeah, uh, that's the thing, neither backspace or C-d work on parens

11:47 the only way i can remove them is by cutting

11:47 which can't be right

11:48 raek: robonobo: you have paredit activated? if so, it will be removed when you remove the matching one when there is nothing in between

11:48 klang: robonobo: no, that's not right .. my backspace runs the command paredit-backward-delete

11:49 robonobo: i'm new to emacs, how would i see wether paredit was activated?

11:49 raek: x (y)| x (y|) x (|) x |

11:49 jwr7: So — if I have an agent fn that generates lazy sequences and I don't force them with doall, will they actually be generated outside of the agent fn, in a different threads (possibly multiple threads)?

11:50 raek: for me, it sais this above the minibuffer: (Clojure Hi Paredit Fill)

11:50 klang: M-x describe-mode

11:50 jwr7: I've just realized that this kind of defeats the serialization that agents provide :-/

11:50 robonobo: raek: yeah, i'm in paredit mode

11:51 klang: robonobo: in the repl or in a clj file?

11:51 raek: robonobo: you can use M-s to remove the innermost pair of parens at the point

11:51 I think paredit is really useful, so I would recommend to learn it. http://www.emacswiki.org/emacs/PareditCheatsheet

11:52 otherwise: M-x paredit-mode to disable

11:53 robonobo: raek: thanks

11:54 raek: http://p.hagelb.org/paredit-outline <-- tutorial by technomancy

12:33 jamiltron: I am having some problems with clojure.contrib, it seems. When I try (ns jamiltron (:require clojure.contrib.server-socket)) I am getting a FileNotFoundException.

12:35 tonyl: is clojure-contrib.jar in the classpath?

12:35 jamiltron: It is

12:36 tonyl: can you share the exception stack of the problem?

12:37 or how are you calling clojure

12:39 &(require '[clojure.contrib.server-socket :as ccss])

12:39 sexpbot: java.io.FileNotFoundException: Could not locate clojure/contrib/server_socket__init.class or clojure/contrib/server_socket.clj on classpath:

12:39 tonyl: ,(require '[clojure.contrib.server-socket :as ccss])

12:39 clojurebot: java.io.FileNotFoundException: Could not locate clojure/contrib/server_socket__init.class or clojure/contrib/server_socket.clj on classpath:

12:39 jamiltron: FileNotFoundException Could not locate clojure/contrib__init.class or clojure/contrib.clj on classpath: clojure.lang.RT.load (RT.java:412)

12:40 tonyl: &*clojure-version*

12:40 sexpbot: ⟹ {:major 1, :minor 2, :incremental 0, :qualifier ""}

12:40 jamiltron: I am calling clojure through an alias of clj which is clojure.contrib's clj-env-dir

12:40 Raynes: Sandboxes don't seem to like certain namespaces.

12:41 Not that it will fix your problem, but consider cake or leiningen. They'll serve you far better than a wee little clj script.

12:41 jamiltron: I usually use leiningen, but am getting the same errors.

12:41 tonyl: Raynes: what do you usually use?

12:42 Raynes: cake

12:42 jamiltron: My clojure version is 1.3.0-master

12:44 raek: jamiltron: looks like the error suggests you are trying to (:require clojure.contrib)

12:44 jamiltron: Oops, that doesn't work either

12:45 server-socket gives:

12:45 FileNotFoundException Could not locate clojure/contrib/server_socket__init.class or clojure/contrib/server_socket.clj on classpath: clojure.lang.RT.load (RT.java:412)

12:45 raek: jamiltron: what contrib jars do you use?

12:45 hiredman: I suggest you not user the launcher script

12:45 use

12:46 raek: that error means that the server-socket module of contrib is not on the class path

12:47 jamiltron: I copied clojure-contrib/modules/complete/target/complete-1.3.0-SNAPSHOT.jar into my classpath as clojure-contrib.jar

12:48 raek: that only depends on all the other jar files and does not include them

12:48 it's basically empty

12:49 I think "standalone" is the droid you are looking for

12:49 jamiltron: Ah, let me try that.

12:50 That worked. Thank you very much!

12:51 Thanks for the help, everyone. I'm really new to Clojure and I love it but I keep getting stuck on stuff like this.

12:53 Raynes: My best tip is to not try to manage the classpath manually with launcher scripts and the like. Your life will be much easier just using cake or leiningen, especially since they scale to more complex things than this easily.

12:53 jamiltron: Yeah, I'm trying to learn lein as much as possible.

12:54 shortlord: shouldn't (catch Exception e (do-something)) catch every Exception, including NullPointerExceptions?

12:55 raek: shortlord: yes.

13:05 jamiltron: Does anyone know about lein and swank?

13:09 markskilbeck: http://projecteuler.net/index.php?section=problems&id=11

13:10 Well that sounds interesting.

13:13 raek: jamiltron: just ask.

13:14 jamiltron: I think I found the answer - does leiningen not work with clojure 1.3.0?

13:14 raek: it should

13:14 jamiltron: I am getting a series of classpath errors when running lein swank in a project using clojure 1.3.0, but I can run swank-clojure from the .lein/bin directory.

13:15 shortlord: raek: I have surrounded a function call with try + catch Exception e, but there is still a NullPointerException occuring as soon as I execute the block

13:15 does try + catch work somewhat differently in clojure than in Java / is there anything obvious that could be wrong?

13:15 jamiltron: Var *classpath* not marked :dynamic true, setting to :dynamic. You should fix this before next release!

13:15 Exception in thread "main" java.io.FileNotFoundException: Could not locate mire/server__init.class or mire/server.clj on classpath:

13:15 at clojure.lang.RT.load(RT.java:412)

13:15 at clojure.lang.RT.load(RT.java:381)

13:15 hiredman: shortlord: your catch is throwing the npe

13:15 jamiltron: at clojure.core$load$fn__4389.invoke(core.clj:5308)

13:15 raek: no, they are compiled to the same byte code

13:15 jamiltron: at clojure.core$load.doInvoke(core.clj:5307)

13:15 at clojure.lang.RestFn.invoke(RestFn.java:409)

13:15 at clojure.core$load_one.invoke(core.clj:5132)

13:15 at clojure.core$compile$fn__4394.invoke(core.clj:5319)

13:15 at clojure.core$compile.invoke(core.clj:5318)

13:15 at user$eval7.invoke(NO_SOURCE_FILE:1)

13:16 at clojure.lang.Compiler.eval(Compiler.java:6222)

13:16 raek: jamiltron: gist.github.com

13:16 jamiltron: at clojure.lang.Compiler.eval(Compiler.java:6213)

13:16 at clojure.lang.Compiler.eval(Compiler.java:6189)

13:16 at clojure.core$eval.invoke(core.clj:2680)

13:16 at clojure.main$eval_opt.invoke(main.clj:232)

13:16 at clojure.main$initialize.invoke(main.clj:251)

13:16 at clojure.main$null_opt.invoke(main.clj:284)

13:16 at clojure.main$main.doInvoke(main.clj:362)

13:16 at clojure.lang.RestFn.invoke(RestFn.java:422)

13:16 at clojure.lang.Var.invoke(Var.java:405)

13:16 at clojure.lang.AFn.applyToHelper(AFn.java:165)

13:16 at clojure.lang.Var.applyTo(Var.java:518)

13:16 at clojure.main.main(main.java:37)

13:16 dakrone: gah jamiltron, use gist

13:16 raek: shortlord: the NPE doesn't happen in the catch block?

13:16 jamiltron: Sorry

13:17 https://gist.github.com/783190

13:18 shortlord: I'm doing "(catch Exception e (println "in the catch block"))

13:19 that should not throw a NPE, right?

13:20 raek: with a (try ...) surrounding it?

13:21 (try (inc nil) (catch Exception e (.getName (class e)))) => "java.lang.NullPointerException"

13:23 jamiltron: I would check the versions of the libraries you use and make sure they are for the same clojure version

13:24 ossareh: morning yo!

13:24 amalloy: &(supers NullPointerException)

13:24 sexpbot: ⟹ #{java.lang.RuntimeException java.lang.Throwable java.lang.Object java.lang.Exception java.io.Serializable}

13:25 amalloy: shortlord: yeah, should work

13:25 ossareh: bobo_: as long as you're not newing up new objects to put in that map - then yes, that is part of the Persistent datastructure stuff that Rich has gifted us with.

13:48 LauJensen: Remind me again why whenever somebody pastes 3+ lines people start crying gist gist, isnt it more convenient to read it right here in this buffer than to tab out to Conkeror?

13:49 Scriptor: LauJensen: 1. You don't have to keep scrolling back up to find the code again if people have talked since

13:49 2. Syntax highlighting, line numbers, and formatting

13:50 3. If someone joins and wants to help, you can just link them, instead of pasting all over again

13:51 TimMc: keep going

13:51 LauJensen: 1. Use ERC, then this is a non-issue, 2. I can certainly live without syntax highlighting for short 5 - 10 liners and stacktraces, and 3. I agree that if somebody joins halfway through you should gist instead

13:52 TimMc: 4. I can't read both the preceding and following parts of the conversation on the same screen when there is a giant chunk of stuff in the middle.

13:52 amalloy: 4 is the one that bugs me, personally

13:53 LauJensen: If 5 - 10 lines can screw up your display, quit using those tiny netbooks, they're not made for developers!

13:53 TimMc: Same here, though Scriptor's 1-3 are important too.

13:53 LauJensen: Even with the somewhat massive paste above, I can stille read 5 - 10 lines both above and below, and if I couldnt, hitting C-M-v isnt a huge problem

13:53 TimMc: LauJensen: 1280x800 laptop here.

13:54 I wish I had a giant flatscreen monitor in portrait mode, but I don't.

13:54 Scriptor: the point of windows is to not have to maximize everything :)

13:54 LauJensen: Scriptor: You're on Windows? that explains it ... :)

13:54 Scriptor: windows, not Windows :p

13:55 LauJensen: I have viewports, 1) Emacs, no border, fullscreen, 2) Conkeror, no border, full screen, 3) thunderbird, maximized, .. and so forth

13:55 Thats gives you guys a lot of freedom to paste whatever you want :)

13:59 technomancy: some people do IRC on phones even

14:00 tonyl: i don't like fullscreen windows, except for the internet browser

14:00 and watching videos

14:02 pjstadig: technomancy: yaaic for android is what i use

14:02 LauJensen: tonyl: I really like it, and it lets me keep away from the mouse completely

14:03 Derander: LauJensen: what window manager do you use?

14:03 technomancy: pjstadig: I have andchat, but I never use it.

14:03 Raynes: I have a whole viewport dedicated to Emacs. However, I don't actually have a single maximized Emacs window in there. Rather, I have two Emacs frames side by side, because it's easier to resize than a single frame with several panes.

14:03 technomancy: pjstadig: is it halfway decent?

14:03 LauJensen: Derander: Gnome + Compiz - I wrote about my setup on offtopic.bestinclass.dk

14:03 pjstadig: yeah

14:03 Derander: LauJensen: have you looked at a tiling window manager? seems like gnome is overkill

14:03 oh

14:03 cmd+f "tiling" in that post

14:04 technomancy: nothing wrong with andchat I guess; I just never got my bouncer situation figured out

14:04 LauJensen: Derander: I had Awesome WM for many months, then switched to Gnome and replicated my setup and binding with Compiz - Like I said, its on the blog

14:04 Derander: yep. found it seconds after I asked

14:05 LauJensen: Yea, I didn't mean that in the rude way that it came out, sorry :)

14:05 Derander: no sweat

14:17 islon: how do I generate/write xml in clojure?

14:18 amalloy: islon: clojure.contrib.prxml is decent

14:19 TimMc: Asus-- for not having a decent way to browse their laptops

14:20 bah, wrong window

14:20 amalloy: islon: https://gist.github.com/ea060658b5677649d8e7

14:20 islon: thanks amalloy

14:21 amalloy: and it's not hard to get it to print with decent whitespace; by default it's compact

14:49 albertid: hi, can I traverse a list without evaluation? e.g. I want (first v) to return vec instead of 1 when v = (vec (1 2))

14:50 dale: Like (first '(vec (1 2)))?

14:50 pdk: ,(for [i '(vec (1 2))] i)

14:50 clojurebot: (vec (1 2))

14:51 pdk: apparently so

14:51 albertid: yea, except I can't use 'v

14:51 amalloy: albertid: traversing a list never causes evaluation. you're looking (i think) for a way to input a list without evaluation

14:51 Raynes: Sounds like you need a macro.

14:51 amalloy: &(let [v '(vec (1 2))] (first v))

14:51 sexpbot: ⟹ vec

14:52 dale: What amalloy said. I think we'll need to know how whatever gets into v, got into v.

14:53 albertid: amalloy_omglunch, hey thats right

14:53 so v would (read-string "[ 1 2]")

14:54 or (read-string "(vec (1 2))")

14:54 which should be a seperate case

14:55 ok I will try myself

15:09 shortlord: I need to grant unique tokens from a pool of 4 tokens to several concurrent accessors, so that every one ends up with a different token (or none at all, if the access happens if all the tokens are already taken). How would I do that? I can use drop on an atom, but that give me only the remaining elements, not the one I picked. Is there any elegant solution for this?

15:11 chouser: shortlord: you already have the more than 4 threads that need tokens?

15:12 shortlord: chouser: yeah, the scenario is the connection phase of a simple 4 player game. I need to distribute the 4 player colors to the first players that connect

15:12 chouser: ah, I see now.

15:13 there has been talk of an alternative to 'swap!' that returns both the old and new values of the atom

15:13 which would suffice in your case. alas such a thing doesn't currently exist.

15:14 shortlord: so that means I need to retain the original 4-token vector and compare it with the one after the swap! to figure out the token, right?

15:15 chouser: so, off the top of my head: (1) a BlockingQueue, (2) store in an atom a pair of [taken available] tokens

15:16 shortlord: chouser: ah, the idea about the token pair sounds nice, thx :)

15:16 chouser: shortlord: I don't think that would be sufficient. The original could be (a b c d), and the swap! could return (c d).

15:17 shortlord: chouser: could that happen? I thought the updates happen atomically, so after a swap! I would get only the result of my latest swap?

15:18 chouser: shortlord: well, it seems a bit messier than one might hope. (ffirst (swap! x (fn [[taken avail]] [(cons (first avail) taken) (next avail)]))

15:20 shortlord: updates are atomic, but in (let [before @a, after (swap! a next)] ...), you can't assume only one swap has happened between before and after. others may have snuck in.

15:22 shortlord: chouser: well, but that would work for (let [before original-tokens, after (swap! a next)]...), right? Using before independently from the atom

15:22 (but anyway, your solution is great, thx a lot :))

15:23 chouser: shortlord: no, 'after' would contain less than 3 tokens for all but the first thread in, leaving them uncertain which token is theirs.

15:25 (def q (LinkedBlockingQueue. '[a b c d])) ... (.poll q)

15:25 shortlord: that looks even easier. see http://download.oracle.com/javase/6/docs/api/java/util/concurrent/LinkedBlockingDeque.html

15:29 shortlord: chouser: nice, thx :)

16:18 amalloy: shortlord: store a map of {token, owner} pairs?

16:20 then you swap! with some function that adds an entry if possible, and an argument some sort of this-is-me identifier; after the swap you look through the map for your identifier

16:21 shortlord: amalloy: the problem is that players get initially identified through this token (well, I guess it could also be done differently, but it works good enough right now)

16:23 but I think in general your solution should be the best way to do it for a variable number of players

16:25 is (:entry map-foo) or (map-foo :entry) more idiomatic clojure code (or is there no real difference in style)?

16:26 amalloy: shortlord: there's not a huge difference, but i'd prefer the former

16:26 for one thing if you ever switch from maps to records, the second form will stop working

16:28 speaking of which, anyone know if records will start implementing IFn or ILookup in 1.3?

16:31 hiredman: uh, I am pretty sure records do implement ilookup

16:31 amalloy: hiredman: oh, you're right

16:31 i guess i don't quite understand what ILookup means; but what about IFn?

16:32 hiredman: I doubt it

16:33 (foo :bar) lookup (which is what the default IFn would do presumably) wouldn't be able to use the call site cache (:bar foo) uses for records

16:35 amalloy: hiredman: interesting. i don't know what that means, but a call-site cache sounds handy :)

16:36 hiredman: the first time (:foo x) happens on a record clojure stores a thunk that calls (.foo x) non-reflectlively (which hopefully hotspot just inlines away)

16:37 and it falls back to (:foo x) if the site becomes megamorphic

16:37 http://en.wikipedia.org/wiki/Inline_caching

16:37 amalloy: neat

17:45 tonyl: does anybody in what server is the ##java channel? I can't seem to find it by searching the Internet

17:45 I have a question about the java code in clojure and it is a feature I've never seen in java

17:46 * tonyl knows little about java

18:08 benreesman: can anyone answer a quick question about ring?

18:08 brehaut: benreesman: maybe?

18:08 benreesman: it seems to evaluate my handler function twice?

18:09 brehaut: that seems surprising

18:09 are you able to paste up a snippet somewhere?

18:10 benreesman: if that's surprising then i'll mess around some more, just wanted to know if that was a common mistake. if i don't get anywhere i'll create a gist. thanks!

18:11 brehaut: benreesman: are you using ring directly or via some intermediate library like compojure or moustache?

18:11 benreesman: ring directly

18:11 brehaut: and at the moment just simple GET requests?

18:12 benreesman: yes

18:14 brehaut: benreesman: then yes, i think that is weird

18:14 benreesman: https://gist.github.com/783678

18:17 brehaut: huh

18:17 hiredman: benreesman: most likely your webbrowser is doing two gets

18:18 favicon + whatever

18:18 brehaut: benreesman: look at your urls, one is to the favicon

18:18 benreesman: gotcha

18:18 newbie mistake

18:18 brehaut: benreesman: yeah, i think your mistake is not logging the requests url

18:19 benreesman: cheers

18:27 Derander: technomancy: do you know why lein keeps using Derander as my clojars group even though I'm registered under derander?

18:27 technomancy: is this a setting I can change somewhere?

18:28 technomancy: I don't know, but I encourage you to get comfy with the clojars source, because not enough people are. =)

18:29 maybe I'm misunderstanding the question, but it doesn't sound like it has anything to do with leiningen

18:29 Derander: the reason that I am questioning leiningen is that lein pom is generating the incorrect word in my pom file

18:29 I am not familiar with the java ecosystem, though

18:29 I am confused in general because I don't recall typing "Derander" anywhere on my system

18:30 technomancy: the pom just comes straight from project.clj

18:30 Derander: oh god. I'm a moron. I forgot to save the file.

18:30 thanks. :-P

18:30 technomancy: easy fix =)

19:04 markskilbeck: Knock knock.

19:05 raek: who's there?

19:05 markskilbeck: ...

19:05 Java.

19:06 Doesn't work too well in IRC.

19:07 tonyl: it uses phonetics?

19:07 markskilbeck: Supposed to wait a while before answering.

19:07 tonyl: oh hehe

19:08 pkinney: I've told that joke to a group of computer illiterates... haha, they just threw me weird looks

19:08 (It's 1 of my fav programming jokes)

19:10 Adamant: markskilbeck: try this

19:10 ....

19:10 ...

19:10 .......

19:10 .....

19:10 Java!

19:10 markskilbeck: haha

19:10 Yeah I guess that does the trick

19:10 Adamant: sadly/gladly the joke isn't as true anymore

19:11 making Java fast got turned into the primary goal of compiler folks like speeding up C and C++ used to be before that

19:11 so after a decade+, it's pretty damn fast

19:12 technomancy: boot time is still quite bad, which is what I assumed the joke was about

19:12 "Knock Knock/who's ther--dalvik"

19:14 "dalvik who?/......... user=> "

19:14 brehaut: technomancy: it has race conditions?

19:15 technomancy: just quick VM boot plus slow load of clojure's runtime libs.

19:15 brehaut: oh right

19:17 Adamant: technomancy: that is true

19:18 shortlord: has anyone successfully used clojure-processing? There seems to zero documentation, not even the source code is really helpful. :-/ I'm trying to get text alignment to work

19:25 technomancy: I used it like a year and a half ago; it was really hard to get working. had to fall back to Java documentation for most things.

19:30 shortlord: technomancy: what a shame, live editing processing would've been promising

19:37 technomancy: well it could certainly be fixed

19:38 there's nothing inherently difficult about it; it's just a matter of modernizing a legacy codebase

19:44 amalloy: tonyl: did you get your java question answered?

19:45 Derander: Is there a good way to monitor a directory for changes in java?

19:45 brehaut: Derander: by 'good way' do you mean 'not polling' ?

19:46 Derander: well, if there is a library to do polling out there that would work. I'd prefer not to have to poll, though

19:46 I see NIO2 in java 7 but I haven't see anything for java6

19:47 brehaut: Derander: i think that about sums things up.

19:48 Derander: that is unfortuante

19:48 brehaut: Derander: i think lazy-test is the canoncial example people point to in clj land

19:52 arohner: is there a way to tell the JVM to attempt a GC before increasing its heap size?

19:53 hiredman: the jvm doesn't dynamically increase it's heapsize

19:53 use the -Xwhatever to set the heapsize you want

19:53 arohner: hiredman: yes it does, if you use -Xmx

19:54 hiredman: no

19:54 that is the max size

19:54 arohner: yes

19:54 hiredman: if you want to cause a gc before reach that size then decrease that size

19:54 arohner: and my current heap size starts small (50MB?), and the JVM increases its heap size when it feels the need, up to the max size

19:54 hiredman: right

19:54 if that is not the correct max size, then you should make it smaller

19:56 tonyl: amalloy: no, still trying to figure it out

19:56 clojurebot: amalloy: therfor I return [previous] if rest is empty

19:56 Derander: brehaut: thanks for the pointer to lazy test. it seems like I've basically written a slightly buggy clojure implementation of ScheduledThreadPoolExecutor.

19:57 amalloy: tonyl: i can join ##java from freenode; not sure why you'd be having trouble there. but maybe you could just ask your java question here?

19:58 arohner: (System/gc) i think

19:58 though usually that's...not a good idea. why do you want to?

19:58 arohner: amalloy: yes, that tells the JVM to try to GC. I want it to try automatically, before increasing the heap size

19:59 hiredman: if you don't want a lage heapsize then make the max heapsize smaller

19:59 arohner: because it's being lazy. Right now, if I tell it to GC, it will free ~300MB

20:00 amalloy: arohner: so why do you care? that's 300 mb that's paged/swapped

20:00 hiredman: if you tell java to use a 1G heap max, don't freak out if it does

20:00 if you really don't want it to, drop the max

20:01 tonyl: amalloy I

20:01 amalloy: it is this line https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/AFn.java#L145

20:01 amalloy: arohner: if you could get java to actually behave the way you're describing, you would be sad, not happy

20:01 tonyl: AFAIK java doesn't have ... operators

20:01 amalloy: tonyl: yeah it does

20:02 arohner: amalloy: why?

20:02 amalloy: as of 1.5

20:02 pdk: void main(String... args)

20:02 that code is fucking scary

20:02 amalloy: it's syntactic sugar for taking an array of arguments; it lets the caller pass N arguments without wrapping them in an array first

20:03 pdk: please tell me it's not production code so i can sleep

20:05 tonyl: amalloy: I can't seem to find documentation about it, do you know how is this operator called?

20:06 joegallo: http://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html

20:06 amalloy: http://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html

20:06 joegallo: varargs

20:08 tonyl: so why not use that instead of making an function signature with 21 arguments

20:08 is it to be safe on java versions

20:08 hiredman: array allocations are not free

20:09 arohner: the clojure compiler does it for speed

20:09 amalloy: tonyl: speed

20:13 tonyl: ok didn't know the performance

20:13 thanks for the help guys

Logging service provided by n01se.net