#clojure log - Jul 28 2011

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

0:32 jcromartie: OK so I'm a little confused

0:32 is it: (defn name "doc string" {:stuff :map} [arg list] body)

0:32 or

0:32 (defn name "doc string" [arg list] {:stuff :map} body)

0:32 both work?

0:35 amalloy: jcromartie: the latter certainly won't

0:35 it'll compile, but won't do what you want

0:36 jcromartie: hm

0:36 so then...

0:36 amalloy: &(macroexpand '(fn {:doc "whatever"} [] 1))

0:36 lazybot: java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap

0:37 amalloy: hm. not the result i expected, but i rarely use the map syntax

0:37 &(doc defn

0:37 lazybot: ⇒ Macro ([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata ; Adjusted to (doc defn)

0:38 jcromartie: but attr-map can't reference params if it comes first

0:38 ah

0:38 http://clojure.org/special_forms

0:39 condition-map is separate from the attr map

0:39 so it's REALLY ([name doc-string? attr-map? [params*] condition-map? exprs*)

0:40 amalloy: mmm, not really. exprs* is passed along to fn; it's fn that has the magic for condition-map

0:42 i mean, it's arguing about something fairly meaningless, but exprs* subsumes the arguments to fn, including condition-map

0:44 jcromartie: ah ha

0:44 OK good point

0:53 hooray for pre-conditions

1:04 zone achieved

1:40 Pupeno: require loads the lib and use loads the lib and makes it possible to call functions without the lib prefix, is that it?

1:49 ibdknox_: anyone from the clojurescript team still up?

1:51 kumarshantanu: Pupeno: yes

1:52 Be wary of name clashes in the case of "use" though

1:52 replaca: technomancy (or anyone else) know why clojure-jack-in would be failing with "error in process filter: Assertion failed: (keywordp module)"

1:52 Pupeno: Thanks.

2:18 kjeldahlw: replaca: Haven't seen it myself, but make sure you do not have any other *swank* buffers open, and that you're not using older emacs packages..

2:21 replaca: kjeldahlw: I don't, but I think it may be glomming on to some swank-contrib stuff I had from an older version. Dunno why it used to work, though

2:38 ibdknox_: BWAHAHA

2:38 I have a fully functional browser repl

2:41 replaca: ibdknox_: congrats! Now what? :)

2:42 ibdknox_: replaca: haha clean it up so that other people can party on it :)

2:42 replaca: and then it's time for the clojurescript client-side framework

2:43 replaca: ibdknox_: there you go. that should be a fun project.

3:31 danbell: anyone know of a markdown parser for clojure?

3:33 amalloy: danbell: surely there's one for java

3:33 danbell: yeah

3:33 I know there is

3:34 just wondering if one had somehow escaped my googling

3:40 tsdh: Hi. Can someone explain me these 2 reflection warnings? http://pastebin.com/xFuzbsFz

3:42 raek: tsdh: replace "i ^Image (.getImage img)" with "^Image i (.getImage img)"

3:44 tsdh: raek: That doesn't make a difference.

3:45 raek: Even hinting the calls directly, e.g., (int (* @scale (.getWidth ^Image i))), won't get rid of the warnings...

3:46 Clojure 1.3, if that matters...

3:48 Well, that's no big deal anyway.

3:50 The more pressing issue which nearly made me running mad yesterday is that proxy silently discards exceptions thrown in the method implementations. Is that intended? At least, the docs don't indicate that...

3:52 Hm, oh well, probably that's not proxy, but the backtraces simply don't hit the slime repl...

3:52 amalloy: tsdh: that's not true

3:52 it's possibly something to do with the async event processing you're doing

3:53 but in my slime repl, eg: (.size (proxy [java.util.ArrayList] [] (size [] (throw (Exception. "test"))))) ; throws correctly

3:54 tsdh: amalloy: Throws correctly means what? You see the backtrace at the repl? Or are you even put in the debugger?

3:54 amalloy: the usual slime debug dialog appears

3:54 0 to abort to slime top-level, etc

3:54 tsdh: Yep, here, too.

3:55 amalloy: like i said, it's probably because you're doing async programming

3:55 the exception isn't occurring on the swank thread, so it isn't easily trapped

3:56 tsdh: amalloy: Yes, you are right. But if I did this in Java, at least I'd see the backtraces on System.err. With clojure and slime, I don't see anything.

3:56 amalloy: it's probably on the lein-swank console

3:56 (not my fault if phil's hiding that from you)

3:56 but you could try setting the defaultUncaughtExceptionHandler

3:57 $google defaultUncaughtExceptionHandler

3:57 lazybot: [Thread (Java Platform SE 6)] http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html

3:58 tsdh: What's the buffer name? I remember, with older slime/clojure-mode releases, I could jump to the *inferior-lisp* buffer, and that contained anything I'd see on System.out and System.err. But with the current version of clojure-mode and clojure-jack-in, that buffer doesn't even exist...

3:58 amalloy: *shrug*

3:58 i use lein/cake swank and slime-connect by hand

3:59 then it's either in the lein-swank process's stderr, or cake.log

4:00 it's not like you have to use jack-in if it's causing you problems

4:01 tsdh: amalloy: Well, except from that issue, it works perfectly without having to setup anything.

4:03 Ok, one other thing: Is case intended to work for public static int constants in java?

4:04 raek: tsdh: I think the buffer is called *swank*

4:04 tsdh: raek: That buffer is full of elisp.

4:05 raek: tsdh: look at the top

4:05 yes, that's from the swank bootstrapping process

4:05 tsdh: raek: Oh, yeah!

4:06 raek: tsdh: when I'm working on a swing app, I use this 'safety-net' macro to get stack traces of unhandled exceptions as popups: https://gist.github.com/1098366

4:07 amalloy: tsdh: no it's not, but that might be in 1.3

4:07 raek: so all callback method bodies has a (safety-net ...) form at the outermost level

4:08 tsdh: raek: Neat, thanks.

4:09 amalloy: I'm on 1.3, and there it does't work, too. (case 45 java.awt.KeyEvent/VK_MINUS true false) ==> false

4:09 amalloy: well, there was a fair bit of discussion about it on jira and the ML, which i didn't really follow

4:09 if you're interested in how it was resolved, that's where to look

4:10 raek: I think the case expression ends upp using the _symbol_ java.awt.KeyEvent/VK_MINUS

4:10 since the cases must be compile time constants

4:11 but in this case it's not very logical, since java.awt.KeyEvent/VK_MINUS is available at compile time

4:11 tsdh: exactly

4:12 raek: but there is nothing in clojure that is constant at compile time like that

4:13 you could probably work around this with a macro

4:13 amalloy: raek: indeed, chouser wrote such a macro

4:13 somewhere

4:14 tsdh: raek: No, I'll stick with cond and keep that in mind. It just felt natural to use case in that place.

4:14 raek: ah, here's an old variant of case I made once to dispatch on classes: https://gist.github.com/997652

4:15 tsdh: amalloy: He had a macro to make even enum constants work (somehow), right? Or was it Chas Emerick?

4:15 amalloy: i think cemerick patched case

4:15 chouser just pasted a quick macro into #clojure

4:15 (useless bugger)

4:15 tsdh: amalloy: Yes, case* or something.

4:16 raek: replacing 'resolve' with 'eval' would problably work...

4:16 amalloy: i'd be rather surprised if it were called case*

4:17 tsdh: amalloy: Right, it's case+. http://cemerick.com/2010/08/03/enhancing-clojures-case-to-evaluate-dispatch-values/

4:57 harblcat: is there a way to turn a whole bunch of static method calls on a class into something like a (doto ...)?

4:58 like, (Foo/a) (Foo/b) to (something Foo (.a) (.b))?

5:05 raek: ,(macroexpand-1 '(doto SomeClass (. foo "arg") (. bar "arg")))

5:05 clojurebot: (clojure.core/let [G__1705 SomeClass] (. G__1705 foo "arg") (. G__1705 bar "arg") G__1705)

5:05 raek: harblcat: it looks like the let form is in the way for doing that

5:06 so you probably have to roll your own "doto-class" macro

5:06 harblcat: I've tried that, but it seems to throw an error, saying "no matching method found: foo for class java.lang.Class"

5:07 raek: which had you tried?

5:07 harblcat: been looking at what (Foo/bar) expands to, and it's supposedly expanding to (. Foo bar)?

5:08 and if doto puts x as the first argument to each form, it should come out just right, but it doesn't apparently

5:10 raek: using doto here fails since you get (. G__1705 foo "arg") instead of (. SomeClass foo "arg")

5:11 . is a special form and its arguments are not evaluated

5:12 yes, it expands to (. Foo bar). this syntax is easier to generate by macros

5:12 harblcat: Ah, so you're saying that doto somehow loses the class along the way?

5:13 raek: look at this macro expansion:

5:13 ,(macroexpand-1 '(doto SomeClass (. foo "arg") (. bar "arg")))

5:13 clojurebot: (clojure.core/let [G__1733 SomeClass] (. G__1733 foo "arg") (. G__1733 bar "arg") G__1733)

5:13 raek: this is the code that the doto form is replaced by

5:14 for the interop to work, the *code* has to say (. SomeClass foo "arg"), i.e. the name of the class must be there in the code as a symbol

5:15 (. x foo "arg") is also the syntax for a instance method call

5:16 the compiler checks if the name represents a class ("SomeClass" does, but the is no class called "G__1733") and emits code for an instance or class method call based on that decision

5:17 harblcat: I think I understand now... It's treating the doto expansion as an instance-method call, and I want a static method call

5:17 raek: if you use doto here, it will generate code for calling an instance method called "foo" on the class object for the class "SomeClass", which is not the same as calling a class method called "foo" on the class

5:17 exaactly

5:17 harblcat: I see. Thanks a bunch!

5:17 kumarshantanu: can set! be used with protected inherited fields from a base class?

5:32 triyo: What version of clojure-contrib, if any, matches the current clojure 1.3.0-master-SNAPSHOT?

5:32 I want to include it in my project.clj.

5:32 Or even better question, how do I determine this myself?

6:16 Ok so I get error: java.lang.IllegalArgumentException: No matching field found: getRoot for class clojure.lang.Var from the clojure.contrib.sql when using the clojure1.3 master snapshot

6:16 Can someone explain why this would be the case?

6:17 My guess is that the contrib is not compatible with the latest clojure 1.3.

6:17 ambrosebs: aren't master snapshots out of date?

6:17 or is that the latest build?

6:23 triyo: ambrosebs: Not to sure, I have this in project.clj file: org.clojure/clojure "1.3.0-master-SNAPSHOT"

6:24 its looking for getRoot method that doesn't seem to be there

6:24 ambrosebs: try "1.3.0-beta1" (I think)

6:24 triyo: java.lang.IllegalArgumentException: No matching field found: getRoot for class clojure.lang.Var

6:25 Ok I'm giving the beta1 a try, thanks

6:29 I still get the error: java.lang.IllegalArgumentException: No matching field found: getRoot for class clojure.lang.Var :(

6:30 Ok, I have an idea

6:30 I have ClojureScript on my classpath too and need to run the it build in dev via my emacs session.

6:31 The ClojureScript/lib has a clojure.jar, any idea what version that is?

6:31 Is it compatible with 1.2.x?

6:31 ambrosebs: no idea

6:31 triyo: if so, then I don't really need reference to 1.3 at all

6:31 hmm

6:32 Ok, I'll have to take a look

6:45 danbell: ,("asdjklfsdfds" 0)

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

6:46 Pupeno_: I just ordered The Joy of Clojure! :)

6:47 Anyone using La Clojure?

6:51 kjeldahlw: triyo: I think clojurescript is clojure 1.3 beta 1 .

7:18 ohwow_: Clojure doesnt have call/cc, does it?

7:26 pepijn: fliebel from italy here. does anyone know if Clutch supports document update handlers?

7:29 it'd also be funny to write queries in ClojureScript, but Clutch already has a Clojure view server.

7:31 ilyak: Hi *

7:31 I did a (deftype Something [] Runnable (run [this] ...code...))

7:32 but if I try to instantiate Something from java code and run() it, I get the exception that variable I use in that code isn't bound

7:32 It is present in that namespaces (given that code compiles)

7:32 Why?

7:32 clojurebot: http://clojure.org/rationale

7:33 ilyak: Is deftype not standalone and I need gen-class for that?

7:40 volton: What's the name of the paper on pattern matching by Maranget everyone's talking about?

7:57 cemerick: volton: this is what dnolen linked to yesterday… http://moscova.inria.fr/~maranget/papers/ml05e-maranget.pdf

7:57 volton: cemerick: thanks

8:27 tsdh: Is it expected that apply-ing a function takes at least twice the time than calling it directly?

8:28 (time (dotimes [i 1000000] (+ ([i] 0)))) ==> ~40ms

8:28 (time (dotimes [i 1000000] (apply + [i]))) ==> ~130ms

8:32 triyo: Does anyone have an example that demonstraits how to create a postgresql "sequence" for auto-incrementing pk ids?

8:36 Found the answer on clojure group

8:37 ohwow_: tsdh: hm, that's interesting

8:37 Chousuke: tsdh: apply does quite a lot more than a plain function call. In addition, + gets inlined

8:38 Scriptor: tsdh: wouldn't it be (+ i 0) ?

8:38 Chousuke: it seems for some reason he wanted to put i in a vector and then extract it

8:39 tsdh: Scriptor: Yes, (+ i) is the same as (+ i 0), cause 0 is the neutral element of additien.

8:39 Chousuke: probably to simulate apply but that's not what apply does.

8:39 tsdh: Chousuke: Exactly, because apply gets the last args as seq.

8:40 Chousuke: at any rate, your example is not very good

8:41 apply is obviously going to be slower than a direct function call, but when measuring the difference you should use some code where it actually matters instead of something trivial like that

8:42 in other words, your benchmark is not representative of any real-world scenario

8:50 tsdh: Chousuke: Well, right. I'm just looking for some performance bottleneck in my code and realized that I apply very often, like for iteratively executing a function and passing the results along. However, if 10 million applications make only 90ms more, that's not where my seconds are left.

8:52 Scriptor: there should be a java profiling tool that can be used with clojure

8:52 cemerick: There are many

8:52 VisualVM, NetBeans (roughly the same), Eclipse, Yourkit, probably more

8:54 tsdh: cemerick: I'll try out one of those. Any suggestion what to take?

8:55 cemerick: Yourkit is probably the best; visualvm is also very nice, free, and you probably already have it (it ships with the JDK)

8:57 tsdh: cemerick: But not with OpenJDK/IcedTea on x86_64...

8:57 Chousuke: it might be in a separate package?

8:59 cemerick: tsdh: good luck in general, then. ;-) sun-java6-jdk (or whatever it's called) is worth the install IMO.

9:00 Oh, the *days* I spent trying to get Java2D font rendering working properly using openjdk/icedtea… :-(

9:01 tsdh: cemerick: I want it *fast* not *pretty*. ;-)

9:02 cemerick: tsdh: Last time I benchmarked the two, the sun VM was also faster *shrug*

9:03 Hopefully that's less the case now. Theoretically, there shouldn't be a difference between the two starting with JDK 7 IIRC — but I remain wary.

9:06 tsdh: Hm, visualvm instantly crashes due to some Qt stuff...

9:07 * tsdh is installing the oracle version to see if that helps...

9:33 Vinzent: ,map-indexed

9:33 clojurebot: #<core$map_indexed clojure.core$map_indexed@136055d>

9:54 tsdh: I don't get visualvm to work. When I run "lein test", two Clojure applications will show up. I guess one is leiningen, the other my app. No matter which I choose and select CPU in the Profiler tab, the results do not contain a single class/method of mine. Any hints?

10:04 cemerick: tsdh: yours is probably the one with the higher pid. Are you having your app do work while you're profiling?

10:07 tsdh: cemerick: Yes, I use the one with the higher pid. And yes, my test cases are plenty of cpu-brning work.

10:08 cemerick: When I delete anything from the "start profiling from classes", "do not profile classes" textfields, I get at least quite a few "Redefining 100 classes at idx 0, out of total 493" messages.

10:09 And some of my classes show up. However, that happens not before my tests are nearly done...

10:16 cemerick: tsdh: If you're just looking at the unaltered real-time hotspot view, then you may not see your functions/classes, especially if the hotspots aren't there. You can filter the classes shown via the text field at the bottom. If you take a snapshot after you've done a fair bit of work, then you can switch to the "combined" view, find a class/function of yours, and it'll show the entire stack above and below your class/function, along w

10:16 total time, invocation count, etc.

10:25 tsdh: cemerick: Now I get results. But why do I get these "Redefining 100 classes at idx 0" messages and my classes showing up in the profiler tab so late? Actually, that happens not before the last few deftests of the last of 5 test namespaces run...

10:26 Poet_: Hi .Can anyone give me link to real world project in clojure ?

10:30 cemerick: tsdh: the profiler has to instrument the classes it's going to track. I'm not sure about the delay/timing — I get data flowing within ~5s. If you fiddled with classname filters, perhaps they're set too strictly?

10:34 tsdh: cemerick: I had to remove all filters to get at least the current behavior...

10:35 joegallo: Poet_: What's qualifies as real world?

10:37 wjlroe: Poet_: this is Clojure (on the App Engine): https://the-deadline.appspot.com/

10:38 technomancy: I'm having problems running leiningen on Linux (through Jenkins) - it just hangs when `lein jar` or `lein compile`... any ideas what's going on there?

10:39 Vinzent: Poet_, http://www.uswitch.com/, flightcaster, etc, you can find some projects on clojure dev site under success stories

10:46 jcromartie: I'm working on a (albeit simple) real world app

10:46 and I'm using it in-house to put a shiny new layer on an old database system

10:47 ipostelnik: is there an existing function in clojure.core that will a apply a function to map's values?

10:47 wjlroe: (map fun (values this-map))

10:47 well not really

10:48 kumarshantanu: ipostelnik: (map (fn [[k v]] ...) {:a 10 :b 20})

10:48 ipostelnik: something like (fn mm [m f] (into {} (map (fn [[k v]] [k (f v)]) (seq m)))

10:52 jcromartie: I'm struggling with some design decisions when it comes to how to implement an API for a general "repository" of model objects

10:52 should I deal with refs?

10:52 or with the underlying value of the ref?

10:53 like, should I say a repo is (ref {}) or just {}

10:54 I think I'm having a hard time describing it well

10:56 ejackson: after setting the clojurescript environment, is it intended that cljsc works from anywhere in the filesystem but repl and repljs do not ?

10:59 jcromartie: here's what I have right now, with no refs in sight at this level: https://gist.github.com/1111698

10:59 I use refs for my actual domain layer

11:06 gtrak: working on a lein project that has tests in another lein project, is there a way to deploy the build of the first so the second will pick it up, or must I use the remote repo?

11:10 wjlroe: gtrak: https://github.com/technomancy/leiningen <- have a look for "checkout dependencies" in the FAQ

11:10 replaca: gtrak: you can just do a "lein install" on the dependency and it will put it in your local ~/.m2

11:11 gtrak: ah, perfect

11:12 you guys have thought of everything

11:14 charliekilo: stupid question: why can't I do (def m {:name String}) (new (:name m)) ?

11:17 Vinzent: charliekilo, i guess it's because new does not evaluates its argument

11:17 cemerick: charliekilo: new is a special form, not a function

11:18 kumarshantanu: charliekilo: (.newInstance (:name m))

11:18 which uses reflection

11:25 gtrak: does 'new' not use reflection?

11:27 kumarshantanu: gtrak: no, new uses the Class instance without looking up the runtime information

11:27 gtrak: ah, it's a compile-time binding

11:40 charliekilo: cemerick: thanks, thats works for me (not that I doubted you ;))

11:44 manutter: can I pull in the Spring Security jars by adding some dependency lines to my project.clj (and if so does anyone know what lines to add)?

11:49 Vinzent: manutter, I use http://www.mvnbrowser.com/ for searching right deps

11:50 manutter: Vinzent: cool, thanks much!

11:54 gtrak: manutter, there's also this: http://mvnrepository.com/

11:54 http://mvnrepository.com/artifact/org.springframework.security/spring-security-parent

11:55 manutter: Cool again, (and thanks again)

11:56 mrBliss: I use http://jarvana.com

11:57 gtrak: does lein have provided and excludes?

12:07 manutter: Ok, I got spring-security-core and spring-security-web, and I *think* that's all I need for basic auth & auth. Now to figure out how to make it all work.

12:07 (PHP programmer here, venturing into uncharted territory...)

12:08 Pupeno: Java 7 has been released?

12:08 dakrone: gtrak: it has excludes, not sure about 'provided'

12:10 manutter: ls

12:11 doh, wrong window

12:18 edoloughlin: Anyone used 'rand' to initialise values with clj-record/create? I'm seeing different values to what's in the DB if I do this. I posted some of the code I'm using to http://stackoverflow.com/questions/6862066

12:24 nowhere_man: hi all

12:24 I'm a happy Common Lisp and Scheme hacker, and I'd like to add Clojure to dialects

12:24 I recently tried installing swank through leiningen and it failed miserably

12:25 what is the current weapon of choice to have Clojure within SLIME?

12:25 ohwow_: I just did that tomorrow and everything went fine :(

12:25 dakrone: nowhere_man: how did the swank installation fail?

12:26 Vinzent: nowhere_man, I have :dev-dependencies [[swank-clojure "1.3.2"] in project.clj

12:26 kephale: nowhere_man: :dev-dependencies [[swank-clojure "1.4.0-SNAPSHOT"]]

12:26 dnolen: nowhere_man: note that getting Clojure to work an existing Common Lisp SLIME setup is difficult

12:27 nowhere_man: dnolen: I still need to work with Common Lisp each day...

12:27 technomancy: dnolen: actually now it works OK as long as you don't need them to coexist in the same instance

12:28 nowhere_man: dnolen: but I'm okay to launch swank manually and then connect to it with slime-connect, that shouldn't be a problem, should it?

12:28 dnolen: nowhere_man: technomancy is the man to speak to :)

12:28 technomancy: if you use a fresh emacs instance with M-x clojure-jack-in, the CL-compatible slime should not interfere

12:30 ohwow_: clojure-jack-in works only on projects?

12:30 or can i use it with ordinary .clj files

12:31 technomancy: ordinary .clj files are in projects =)

12:31 nowhere_man: Vinzent/kephale: thanks, I just did it wrong, I did `lein install swank-clojure`

12:31 technomancy: ohwow_: for stand-alone files you can use ~/.lein/bin/swank-clojure and M-x slime-connect

12:32 Vinzent: btw, technomancy, why lein tasks must be run from the project root now?

12:33 technomancy: Vinzent: I think that snuck in as a bug briefly; fixed in the latest release

12:34 Vinzent: oh, great! Thank you :)

12:40 nowhere_man: ok, thanks all

12:40 mrBliss: nowhere_man: my solution: https://gist.github.com/1111898

12:41 nowhere_man: technomancy: swank-closure is correctly documented, this is rare enough that it warrants my gratitude

12:41 jcromartie: nowhere_man: docs FTW, eh

12:41 nowhere_man: :-D

12:41 jcromartie: I'm kind of proud of the way clojure projects are documented

12:42 Cozey: is it possible to run leiningen repl without using lein script? I'd like to run it inside Intellij Idea 'La clojure' plugin, which just lets one specify arguments to a clojure.jar file...

12:42 jcromartie: part of my automated tests report any undocumented public fns

12:43 nowhere_man: jcromartie: nice QA·

12:43 raek: Cozey: well, you can use "lein classpath" to get the -cp option lein uses

12:44 Cozey: are you looking for a certain lein feature or just the clojure repl?

12:45 Cozey: repl would be best

12:46 because i need to debug an app which uses some java classes

12:46 i jsut can't go on with emacs and slime and cdt. I'm unhappy about it, but I must admit it is a productivity killer

12:48 hmm it seems leoiningen plugin for idea does wonders and it just works !

12:49 gtrak: oh wow, didn't know idea had one of those

12:50 raek: Cozey: the most basic way to start a repl manually in a lein project would be to do something like java -cp <output from lein classpath> clojure.main

12:51 assuming idea adds line editing and history

12:54 kumarshantanu: gtrak: yes

12:54 provided is dev-dependencies

12:54 and excludes is exclusions

12:55 Cozey: ok

12:55 just one problem more- it seems lein generates a pom.xml without excludes

12:55 and now i have contrib for 1.3 and 1.2 ( i try to run 1.3)

13:00 hv: yay for java.net.URLClassLoader/close

13:00 jcromartie: can I "clean up" a namespace and reload it?

13:01 hv: jcromartie: As far as I know, not easily. yet. the unloading of a class loader, and gc'ing it in JDK7 is in that direction.

13:02 jcromartie: there's remove-ns

13:02 worked OK for me

13:02 hiredman: just reload the namespace

13:03 use (and also I believe require) takes :reload or :reload-all

13:04 hv: just keep in mind that :reload does not magically take care of everything the ns did.

13:06 jcromartie: hiredman: reloading is fine, but I'm concerned with changing defs

13:06 like a (defn foo) goes away, and reloading leaves the old one

13:08 hv: jcromartie: in that case you remove-ns. (notice some libraries have ;; (remove-ns 'THEIR-NS) at the top. the developers eval them before reload).

13:10 if you did something to other namespaces, you may have to remove-ns them, too.

13:32 leonid_: hello people

13:32 I started playing with clojure yesterday

13:32 4clojure is helping me greatly

13:33 manutter: yeah, 4clojure is awesome

13:33 leonid_: i've got a question

13:34 hv: you should just ask ;)

13:34 leonid_: is there any ways to know the actual number of letters in the shortest 4clojure entries?

13:34 manutter: You might also want to google "clojure koans" for some good introductory material, btw

13:34 leonid_: all I'm seeing is a histogram

13:35 manutter: where are you seeing the histogram?

13:36 leonid_: when you submit a code and it passes all tests, it lets me click the "view chart" link

13:36 (I've joined the golf league btw)

13:36 manutter: Heh, I feel dumb now, I never noticed that link before.

13:37 Hmm, in fact I'm still not seeing it.

13:37 leonid_: you should join the golf league to see the chart

13:38 http://4clojure.com/league

13:38 manutter: That must be it, I never joined a league.

13:39 leonid_: it would be great if I could see the code sizes of the best entries and my own solutions next to the problem titles in the list

13:39 because as of now I just need to re-submit my solution to check the chart

13:40 manutter: Yeah that would be cool

13:40 The code is open source, you could submit a patch :)

13:43 leonid_: when I get better at clojure, I migh

13:43 t

13:55 jweiss: is there a way to get 'lein swank' to bind to all interfaces, not just local?

13:55 for connecting to remote project

13:57 technomancy: jweiss: there is a way, but you shouldn't do it. tunnel over SSH.

13:58 jweiss: technomancy: k

14:13 imade: in 4clojure can I see other people solutions, would be nice to compare with mine

14:17 k actually it makes sense not to show other solutions, otherwise the clojure gold loses it's point

14:18 I am wondering if #(reduce (fn [coll x] (cons x coll)) [] %) is idiomatic solution for http://www.4clojure.com/problem/23

14:18 mattmitchell: i'm trying to build a function called one-of? which accepts a value, and a list of predicate functions. I want it to return true if one of the predicates returns true... Is there anything like this already?

14:18 imade: the shortness is not important for me, more important is that it's easy to read

14:19 kumarshantanu: mattmitchell: (some #(% value) predicates)

14:19 mattmitchell: kumarshantanu: ahh perfect :)

14:27 ibdknox_: As promised

14:27 I have my browser-based ClojureScript repl:

14:27 https://github.com/ibdknox/brepl

14:28 triyo: Is there currently a solution to include ClojureScript in to existing projects? More specifically, leiningen based project and emacs with slime / swank.

14:28 gtrak: ooo nice

14:28 thearthur: Who should I politely nudge to get my range patch merged?

14:28 ibdknox_: 2 requirements: you need clojurescript on your machine, and rlwrap for a prettier REPL :)

14:28 triyo: Reason I ask, is that I have a project that is based on clojure 1.2.1 and it seems that ClojureScript requires clojure 1.3.

14:29 ibdknox_: triyo: that's going to be a pain

14:29 jcromartie: imade: I think I've got a better one

14:29 triyo: not going, it is ;)

14:29 gtrak: ibdknox_, I was just looking at your socketio library a couple of days ago, very cool

14:29 ibdknox_: gtrak: I actually didn't want to use it here

14:30 gtrak: it's like using a nuclear bomb to kill a mosquito

14:30 gtrak: but aleph wouldn't work with 1.3.0

14:30 gtrak: ah

14:30 jcromartie: imade: #(reduce conj nil %)

14:30 ibdknox_: also, changes in 1.3 killed the way the clj-socketio stuff worked :(

14:31 gtrak: isnt it just a wrapper for the java one?

14:31 ibdknox_: yeah, but it reify's an interface

14:31 triyo: ibdknox_: I could try to go the other route and that is upgrade my project to clojure 1.3, however that brings me to different problem. Is there a compatible version of clojure-contrib for 1.3?

14:31 ibdknox_: triyo: the contrib libraries have all been broken apart and become new things

14:32 triyo: ibdknox_: yup, I gather as much on attempting to do so anyway

14:32 it hell broke loose

14:32 ibdknox_: triyo: which ones are you looking for?

14:32 triyo: *it=all

14:32 jcromartie: It's easy to cheat on a lot of these 4clojure problem

14:32 ibdknox_: gtrak: before in that reify'd class I would call anonymous functions stored in an atom

14:33 triyo: well just org.clojure/clojure-contrib

14:33 ibdknox_: gtrak: for some reason it wouldn't let me do that anymore

14:33 triyo: there's no way you're using *all* of contrib :-p

14:33 triyo: Of course I am ;-)

14:33 *just kidding*

14:34 If I have -> in project.clj is that all libs? [org.clojure/clojure-contrib "1.2.0"]

14:34 cause fact of the matter is I only need contrib/sql as far as I recall

14:35 I think its a long shot that just my fall short of the mark...

14:36 I need to stick to 1.2.x of clojure and contrib

14:36 technomancy: triyo: have you tried clojure.java.jdbc? it should work with 1.2 or 1.3

14:36 imade: jcromartie: thank you, I will meditade about this a little bit

14:37 triyo: here are all the libraries I need for my exiting project -> https://gist.github.com/1112209

14:38 technomancy: I haven't tried with 1.3. I am utilizing the clojure.java.jdbc with 1.2

14:38 seancorfield: clojure.java.jdbc is tested against both 1.2.1 and 1.3.0

14:38 technomancy: triyo: I meant that jdbc should replace contrib/sql

14:39 triyo: what's more relevant is what nses you use inside contrib

14:39 triyo: technomancy: Oh right I see what you mean

14:39 seancorfield: yes, it's better to move to the new contrib libraries as soon as you can so your transition to clojure 1.3.0 will be easier

14:39 also means you don't get a "kitchen sink" of 60 modules when you only want one or two :)

14:40 ibdknox_: seancorfield: that transition has been surprisingly complicated so far :(

14:40 triyo: ok, I have a plan. I'll drop my use of clojure/contrib quick and see if there is any dependencies.

14:40 cemerick: it's the price one pays to be a bleeding edge library author, I think

14:41 jcromartie: wow, I just discovered "reductions"

14:41 triyo: its a small price to pay cemerick

14:41 ;)

14:42 seancorfield: ibdknox_: not for me - i moved to 1.3.0 snapshots before alpha builds i think :)

14:42 but, yeah, if you have a bunch of existing 1.2-compatible code, it can be painful

14:43 ibdknox_: my problem has largely been with the fact that most of the ecosystem is still on 1.2 code that won't even run in 1.3 lol

14:45 technomancy: well as long as people report the compatibility issues they find and/or submit patches fixing them things should be better by the time the release lands

14:46 most of the changes needed are trivial, there are just a lot of them

14:46 triyo: technomancy: so far so good. thanks for your assistance. only reason I had the clojure/contrib was because my project originally depended on the sql lib. But since I switched to clojure.java.jdbc, no need for it any more.

14:47 * hugod wishes clojure/core would use their magic fairies on contrib, rather than alioth

14:47 hiredman: ^{:dynamic true} this and ^{:dynamic true} that

14:47 thearthur: im trying to follow the patch submiting process from clojure.org, and it mentions taging the patch for testing. how do I do that

14:47 hiredman: hugod: do you have a list things you need from monolithic contrib?

14:47 technomancy: hugod: what's happening with alioth?

14:48 dnolen: hugod: why, contrib was always community driven, seems like a bad use of limited resources IMO. they don't even have time for alioth.

14:49 hiredman: thearthur: the instructions are written for pre-jira process, I think jira has some workflow drop down or something

14:49 triyo: technomancy: now for a question regarding clojure-swank that you might know a thing or two about pls. Does the clojure-swank lib need to have the matching clojure version? In other words, whats in the prj/lib dir andprj/lib/dev?

14:50 hugod: hiredman: I'm just about covered now, but it has been a long process

14:50 dnolen: technomancy: core wants the community to step up and write 1.3 alioth code to show that Clojure perf has made a significant jump (probably be as good or best OCaml now)

14:50 technomancy: triyo: I think swank is backwards-compatible as far as clojure 1.1

14:50 hugod: technomancy: just a comment from the mailing list

14:50 technomancy: hugod: oh, the benchmarks

14:50 yeah, waste of time

14:50 thearthur: hiredman: looking... any idea what this looks like?

14:50 technomancy: those guys are well-documented to have a prejudice against the JVM

14:50 hugod: dnolen: most of the new contribs don't have bug trackers set up for instance

14:51 dnolen: hugod: whose fault is that? the contrib authors.

14:51 technomancy: I thought you meant the alioth git repo

14:51 raek: what is this alioth?

14:51 technomancy: dnolen: someone has to give the authors the permissions in the first place

14:51 hiredman: thearthur: I forget, I go through this same dance everytime I try to submit a patch, which is not often enough to remember the steps

14:51 dnolen: technomancy: prejudice does help much since it's basically ATS, C, C++, Java -server dominating the benchmarks.

14:51 hugod: dnolen: and some of the authors are from core

14:52 triyo: Does one have to use clojureScript/lib/clojure.jar file or can I just getting via leiningen?

14:52 dnolen: technomancy: someone has to ask for it, that's like one email.

14:52 triyo: Its not a magical ver that works specially with cljs right?

14:53 technomancy: raek: alioth is a debian-specific gforge instance that also hosts some benchmarks

14:54 dnolen: hugod: ah yeah, that's true. it would be nicer if clojure/core was clear about what *they* no longer want to maintain.

14:54 leonid_: [11:18:39] <imade> I am wondering if #(reduce (fn [coll x] (cons x coll)) [] %) is idiomatic solution for http://www.4clojure.com/problem/23

14:54 dnolen: but again, people could just ask.

14:54 triyo: ok, I see its not as per the bootstrap script

14:55 leonid_: the more optimal (?) solution uses less than ten letters

14:56 if you want, I can pm you the solution

14:56 * triyo feeling over the moon. ClojureScript working in existing leining project and Emacs

14:58 triyo: Only problem I have is that I had to manually hack over the compiler.jar+goog.jar and the src/ in to my project. No package management for clojurescript at the moment sucks a bit.

14:58 ibdknox_: speaking of

14:58 is anyone working on a package management solution for CLJS?

14:59 leonid_: clj crashes due to a whitespace in my home directory name

14:59 so I need to use it on its parent directories

14:59 triyo: btw, whats the deal with ^:dynamic in clj 1.3?

15:00 hiredman: vars are no longer dynamically rebindabled by default, if you want them to be you have to mark them as such

15:03 triyo: hiredman: interesting move. More functional.

15:03 like maths let x = 3 -> x always 3 right?

15:04 hiredman: no

15:04 triyo: ok could you explain just a bit?

15:05 reasoning that is behind no dynamic rebind.

15:05 grumpytoad: so... i'm reading a lot about a good emacs environment - since I'm mainly a vim user, is it worth my while to switch to emacs for clojure ev ?

15:05 *dev

15:06 dnolen: triyo: it's a performance optimization. 1.3.0 is mostly about that, unifying numerics, with a couple other goodies here and there.

15:07 triyo: Oh I see, hence there is a manual override in case you need the dynamicity of Vars

15:07 dnolen: triyo: yup.

15:14 raek: ah, cool. some implemented the idea: https://github.com/ibdknox/brepl

15:14 mattmitchell: how can i get the difference between 2 vectors?

15:14 peterise1ins: mattmitchell: how would you define it?

15:16 mattmitchell: eheh, well i know there is set/difference, but i haven't been able to get it to work with vectors...

15:17 ok so let me convert to set... hmm.

15:17 dnolen: ,(set [1 2 3])

15:17 clojurebot: #{1 2 3}

15:17 dnolen: ,set/difference

15:17 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0)>

15:17 dnolen: ,clojure.set/difference

15:17 clojurebot: #<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0)>

15:17 dnolen: oh well

15:18 technomancy: mattmitchell: clojure.data/diff in 1.3 maybe

15:18 peterise1ins: ,clojure.set/set-difference

15:18 clojurebot: #<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0)>

15:18 mattmitchell: ok cool, this is giving me enough to play with

15:19 dnolen: mattmitchell: (set/difference (set [...]) (set [...])) should work as long as the vectors don't have duplicate items and order is not a consideration.

15:19 mattmitchell: dnolen: ok excellent thanks!

15:24 tsdh: If I have a function (defn foo [x] (let [a ... b ...] (foo a) (foo b))) where the recursion is for side-effects only, how do I write it to not consume stack?

15:25 gtrak: what is this syntax #'symbol?

15:26 chouser: gtrak: that's shortcut for (var symbol)

15:27 It evaluates to the Var object named "symbol"

15:27 gtrak: I see

15:28 what would be the purpose of that?

15:28 chouser: You can deref it to see the current value of that var

15:28 gtrak: it adds an indirection to symbol resolution?

15:29 Netfeed: how can i "unpack" a list? (take 2 (range 10)) returns (0 1), but how can i use that for say +? (+ (take 2 (range 10)))

15:29 Chousuke: apply

15:29 (doc apply)

15:29 clojurebot: "([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."

15:29 Netfeed: ah, yeah, that's true, thank you

15:29 dnolen: ,(reduce + (take 2 (range 10)))

15:29 clojurebot: 1

15:33 raek: gtrak: it is useful when you, for instance, want to store a callback function in a data structure somewhere

15:33 gtrak: aren't named functions all vars anyway?

15:34 raek: (defn foo ...) (def callbacks {:f foo}) ; <-- here the current value of foo is stored. if foo is redefined, 'callbacks' won't be updated

15:34 (def callbacks {:f #'foo}) solves that problem

15:34 gtrak: so a var to a var

15:36 I see, the root binding is early-bound, this makes it late?

15:36 raek: gtrak: when a function is refered to in a piece of code, the var will be dereference each time the code is executed.

15:36 gtrak: no, a var to a function

15:36 instead of just the function

15:37 gtrak: right, i think we're saying the same thing

15:37 raek: in (def a x), x is dereferenced once. in (defn b [] x), x is dereference each time b is called.

15:37 gtrak: early vs late binding

15:38 raek: (assuming x is a var here)

15:44 gtrak: raek, ah, if you use that var as a function it is automatically dereferenced, sneaky!

15:45 hiredman: no

15:45 names that are free in an expression are always resolved to the dereferencing of a var

15:47 gtrak: what's it mean to be free in an expression? I notice the leftmost is dereferenced and the arg is not

15:48 hiredman: gtrak: http://en.wikipedia.org/wiki/Lambda_calculus#Free_variables

15:49 gtrak: hiredman, this may be helpful to me someday :-), but right now it makes no sense

15:51 hiredman: (def x 1) (fn [] (+ x x)) is compiled as somethinglike (def x 1) (fn [] ((deref (resolve 'clojure.core/+)) (deref (resolve `x)) (deref (resolve `x))))

15:51 raek: (fn [x] (let [y 1] (list x y z))) ; <-- here z is a free variable, but not x and y

15:52 gtrak: ah, not a lexically scoped one

15:52 hiredman: in the code the compile emits vars are actually only resolved when the fn loads, and just loaded from the fn's var cache and derefed, instead of calling resolve every time

15:53 gtrak: ah, unless you explicitly tell it to be a var?

15:53 with #' or (var ..)?

15:54 hiredman: #' and (var ...) are actually the same thing

15:55 the reader changes one into the other

15:55 but yes, explicitly referencing the var gets you the var, not the value of the var

15:56 but if I recall it still loads the var into the var cache for the fn

15:56 gtrak: is it implemented as a var to a var? like a double pointer?

15:56 raek: this would be a var-to-a-var: (def x 1) (def y #'x)

15:57 gtrak: right

15:58 raek: vars are like pointers, but the reference they contain could also be seen as a kind of pointer

15:58 gtrak: right, so try (y nil)

15:58 you get "java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)"

15:59 raek: I never said anything about functions... :)

15:59 gtrak: so it's deref'ing the var, that's what I was referring to :-)

15:59 raek: if x would contain a function, that would have worked

15:59 gtrak: ah right, I'm not worried about the exception, obviously an int isn't a fxn, but y was a var

16:00 raek: but afaik, the compiler won't generate any var-to-var code unless you explicitly write something like the above

16:07 gtrak: hiredman, so, when you call a function the argument isn't considered to be a free variable to be resolved? doing (print y) gives you #'user/x

16:07 mefesto: gtrak: anything can be called like a function if it implements clojure.lang.IFn

16:08 gtrak: does var implement IFn?

16:08 mefesto: gtrak: clojure.lang.Var implements IFn

16:08 gtrak: ha

16:08 doubly sneaky

16:08 mefesto: gtrak: so do Keywords which is why (:fname amap) works

16:08 gtrak: so var just delegates to its value

16:09 hiredman: gtrak: y is a free variable, it is resolved to the var #'y, and deref'ed which gives you #'x

16:10 mefesto: gtrak: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Var.java#L377

16:10 gtrak: calls to invoke delegate to fn which derefs itself

16:10 gtrak: bam, well there it is

16:11 mefesto: gtrak: pretty cool setup :) pretty cool when using deftype

16:11 * mefesto says "pretty cool" a lot

16:13 Netfeed: is it possible to write tests for private functions? or is it better to just write for the public ones?

16:13 with clojure.test

16:15 mefesto: Netfeed: i can't comment on what's better but if you require a lib you can call a private function in it with something like (#'my.lib/f)

16:15 gtrak: mefesto, what's cool about it with deftype?

16:16 mefesto: gtrak: it's just more the same but applied to your own types

16:16 Netfeed: mefesto: alright, i'll start from there, thank you

16:20 mefesto: gtrak: https://gist.github.com/1112451

16:21 gtrak: the invoke is the special sauce?

16:21 mefesto: yeah IFn.invoke

16:21 gtrak: ah you're extending IFn

16:22 that one: invoke(Object arg1, Object arg2)

16:23 mefesto: IFn.invoke(Object arg1)

16:24 in deftype, the first arg is the target object

16:24 like how in python the "this" reference is made explicit

16:24 gtrak: ah

16:25 but when you run it it actually uses the java model, and doesn't pass in the 'this' as the first arg

16:25 mefesto: yup

16:27 imade: can anyone offer me feedback for 4clojure problem http://www.4clojure.com/problem/26, my solution is at https://gist.github.com/1112440

16:30 amalloy: imade: instead of using reduce/loop to eagerly create a list of N fibonacci numbers, try lazily creating a list of infinite fibonacci numbers and then just take'ing from that. it can come out a lot simpler that way

16:31 imade: amalloy: yeah that would definitley be a better alorithm

16:32 I will meditate about this now

16:33 amalloy: also in general if you find yourself building a list and then reversing it, you probably meant to use a vector instead (doesn't really apply if you want to take the first bit of advice)

16:34 imade: I used list so I could access the previous calculation

16:35 amalloy: right. you couldn't (shouldn't, anyway) do that with a lazy-seq, but with a vector it would be at least as easy

16:36 oh, but you couldn't destructure it

16:36 imade: yes

16:36 in list the previous calculation was in the first position

16:37 amalloy: &(let [prev [0 1 2 3 4]] ((fn last-two [v] [(peek v) (peek (pop v))]) prev))

16:37 lazybot: ⇒ [4 3]

16:38 imade: I see, very cool

16:39 btw, the correct solution in 4clojure starts with 1 1 ..., in wiki it's 0 1 1 ..., why's that?

16:39 amalloy: good question

16:40 i hadn't noticed we did that. kinda silly

16:40 but you can compensate for our failing by making your base case [1 1] instead of [0 1]

16:41 imade: yeah

17:23 triyo: I have a ClojureScript function that attempts to generate a slug uri based on input string and automatically set the input text field with the value. https://gist.github.com/1112594

17:24 zoldar: hello, I'm trying to setup ritz (formerly swank-clj). I'm able to run swank server through 'lein ritz' and connect to it, but when I pass a form with error I don't get any stacktrace: http://paste.lisp.org/display/123620 . Any ideas what could I've missed?

17:24 triyo: Problem is I don't really know how to set a value "property", instead it attempts to call it as a function instead a property of HTMLInputElement

17:26 hmm, set! I guess *blush*

17:27 * triyo calling it a nigh

17:27 hugod: triyo: ritz still needs to have some work done on filtering which exceptions break into the debugger

17:27 triyo: wrong person ;)

17:28 hugod: oops, sorry

17:28 triyo: np

17:28 hugod: zoldar ^^

17:30 leonid_: has anyone gotten less than 28 points on http://4clojure.com/problem/29 ?

17:30 zoldar: hugod, hmm but that exact simple example was taken from presentation - is there anything I can do to make it break into debugger in such cases?

17:31 triyo: Holy smokes, where have I bean for the past year, http://4clojure.com/

17:32 *bean=been

17:32 this looks awesome.

17:32 leonid_: yes it is!

17:33 hugod: zoldar: you could patch ritz… ritz.jpda.debug/break-for-exception?

17:33 Raynes: amalloy: You've got fanboys ^

17:34 hugod: zoldar I'm currently working on fixing it -but not managing to devote much time to it

17:34 triyo: I see that the 4clojure numbers haven't hit even close to the number of foreclosures in the US ;-)

17:35 23,451 only

17:35 zoldar: hugod, ok, thanks for your efforts so far

17:36 amalloy: leonid_: two people have 25

17:36 leonid_: wonder how they managed to do it

17:36 hugod: zoldar: np, I get annoyed by the same issue - so it's likely to get fixed

17:36 leonid_: amalloy: how does one know the size of the smallest entry?

17:37 amalloy: leonid_: i log into the server and query the database :P

17:37 leonid_: you should make it visible

17:37 please !

17:37 scottj: ibdknox: why have CLOJURESCRIPT_HOME in brepl when already set for clojurescript? also maybe print index.html url in terminal so user can just click on it

17:37 amalloy: patches welcome :)

17:37 leonid_: after I get more familiar at clojure..

17:37 (started only a day ago)

17:38 amalloy: ah

17:41 leonid_: mind gisting your 28-character solution somewhere? there might be a way to trim three characters off it while using the same general approach

17:41 leonid_: mind if I just post it here?

17:41 amalloy: hah, sure. i guess it's short enough

17:41 leonid_: #(apply str (re-seq #"[A-Z]" %))

17:42 i'm suspecting that I can reduce 3b from the regex

17:42 mattmitchell: anyone know of a lib i can use to get the distance between to x/y coordinates?

17:43 amalloy: mattmitchell: i think it's called Math.sqrt :P

17:43 gtrak: jesus... pythagoreanlib

17:46 raek: (defn distance [p1 p2] (->> (map - p1 p1) (map square) (reduce +) (Math/sqrt)))

17:46 (defn square [x] (* x x))

17:46 works on any number of dimensions!

17:49 leonid_: looks like regex is not the problem

17:54 dnolen: clojurebot: max people

17:54 clojurebot: max people is 317

17:54 technomancy: clojurebot: lies

17:54 clojurebot: excusez-moi

18:12 leonid_: hell yeah got 25 chars

18:56 technomancy: interesting; debian is considering dropping java for mips, which would mean most -gcj packages would go away across the board.

18:57 FSVO interesting

19:08 frou: I posted a socket-REPL-related question on StackExchange. Can any shell scripters tell me if it's a fool's errand? http://unix.stackexchange.com/questions/17562

19:10 technomancy: you want rep!

19:10 clojurebot: rep?

19:11 clojurebot: you mean clojure.main

19:11 technomancy: ...

19:12 I'm not sure if you can do it with that contrib lib. you could try calling (.close *in*) or something

19:15 frou: ooh, that does work it seems

19:16 I was coming at it from the wrong angle, shell hackery. thank you technomancy

19:17 technomancy: no problem

19:19 amalloy: frou: C-c is kinda rude there anyway. use C-d to close repls, most of the time

19:20 (which amounts to basically the same thing as closing the socket)

19:21 wait, but you only want to kill the netcat process, not the long-lived clj process. i see. so does technomancy's solution really work?

19:23 frou: amalloy → ^D doesn't appear to do much when using netcat as a client of the socket REPL

19:23 it does, I run `lein repl` then in the code sent via netcat, have (.close *in*) appended

19:24 amalloy: frou: right, but can you then reconnect and send another command?

19:24 ihodes: netcat can die. gnu's doesn't compile on osx, and osx's isn't compatible with gnu's. :(

19:24 amalloy: dur, never mind. you must be opening a new socket on each connectgion

19:25 frou: ihodes → i installed gnu 0.7.1 no sweat via homebrew

19:25 ihodes: frou: might have to try that. don't remember if i did. i just gave up pretty quickly to be honest.

19:26 pmbauer: I've seen the following idiom several times, what is the motivation? (defn somefunc [x] (let [x x] (...)))

19:27 technomancy: pmbauer: trying to use up _exactly_ 140 characters in a tweet maybe?

19:27 pmbauer: Ha! I can't understand the need for the local alias

19:27 ...saw it in some of dnolen's code today.

19:28 dnolen: pmbauer: eh?

19:28 pmbauer: Ah! Hi. https://gist.github.com/888733 see lines 40, 44, and 48

19:28 dnolen: pmbauer: are you ignoring the type hints?

19:29 pmbauer: The type hint can't be put on the parameter?

19:30 dnolen: pmbauer: not in this case no, at least not when I wrote that code.

19:30 pmbauer: Ah. Thanks for the explanation, thought I was missing something.

19:30 dnolen: pmbauer: those aren't regular fns

19:31 pmbauer: protocol implementations ...

19:34 dnolen: One other q, on line 21 (compute [_] (.compute task)), I get a reflection warning for 'compute', yet all the other RecursiveTask methods resolve. Any idea why?

19:35 I double checked the signature in jdk7 just to check my sanity ...

19:35 dnolen: pmbauer: it's a protected method I think.

19:35 pmbauer: *sigh* staring me in the face. Thanks.

19:36 dnolen: pmbauer: didn't seem to matter in the end performance wise.

19:36 pmbauer: ...trying to port a fork/join java algorithm to clojure. This was a great help. Thank you for the gist

19:36 dnolen: pmbauer: no problem! look forward to seeing that. haven't messed much with fork/join beyond that gist.

19:57 seancorfield: i try *really* hard not to respond to ken wesson... i really should know better... :(

20:00 dnolen: seancorfield: not … worth … it

20:01 seancorfield: in my defense, i'd just got back from the dentist and was unusually grumpy :)

20:04 technomancy: seancorfield: killfiles dude

20:04 ndimiduk: technomancy: have a moment?

20:05 seancorfield: that's a bit brutal - ken also posts some really interesting answers to questions :)

20:05 technomancy: ndimiduk: what's up?

20:05 seancorfield: well actually I just have a filter that marks all his posts as already read

20:06 but that's only because I don't know of a killfile implementation that's portable across emacs and android =\

20:06 ndimiduk: technomancy: i have a swank hook for adding cdt debugging jvm options to my project. it works when i invoke `lein swank` from the cli but when i use emacs clojure-jack-in i get an exception for passing 6 arguments to my hook fn. any ideas?

20:07 * hiredman finally got around to setting up gmail to delete ken wesson spam

20:07 technomancy: ndimiduk: curious; can you gist the hook?

20:08 ndimiduk: technomancy: https://gist.github.com/1112864

20:09 hiredman: I imagine you need a & args in your hook

20:09 technomancy: ndimiduk: yeah, hiredman is right. you need to apply f to the project and args

20:09 since swank takes optional args as well

20:10 ndimiduk: so, (defn swank-hook [f project & args] ...) ?

20:10 technomancy: aye

20:11 and (apply f (assoc project [...]) args)

20:12 ndimiduk: ah!

20:12 nice, that works.

20:12 thanks guys

20:12 technomancy: np

20:21 ndimiduk: technomancy: do i need to do something special to have the lein process started by clojure-jack-in respect my $JAVA_HOME?

20:21 (use 'swank.cdt) throws because it can't find tools.ja

20:21 r

20:22 which is in the lib in my $JAVA_HOME

20:22 clojurebot: Roger.

20:24 technomancy: ndimiduk: try setting JAVA_CMD to point to the right executable instead

20:25 amalloy: clojurebot: forget which

20:25 clojurebot: Pardon?

20:27 technomancy: ndimiduk: do you think it would be wise to search for the java executable using JAVA_HOME if JAVA_CMD is not set?

20:27 devn: ibdknox: cool.

20:27 ibdknox: I like this REPL

20:27 ndimiduk: that sounds reasonable.

20:28 try $JAVA_HOME/bin/java

20:28 which is what i just set my $JAVA_CMD to

20:28 devn: ibdknox: I especially like the fancy-shmancy tab-completion. I think my next project is to try and get (doc) hooked up to gClosure in ClojureScript

20:28 technomancy: I'm a big fan of software that doesn't require JAVA_HOME to be set, but I guess if it is set, it's usually set for a reason

20:28 ndimiduk: feel free to open an issue

20:28 ndimiduk: why would you prefer JAVA_CMD?

20:29 this is the first time i've encountered that one

20:29 also, i'm not sure why that should resolve my classpath correctly

20:29 technomancy: I think JAVA_CMD came from some autogenerated shell scripts from a maven plugin or something

20:30 ndimiduk: and it doesn't

20:30 technomancy: hm. I had that same issue of missing tools.jar, and it was from using a JRE instead of a JDK

20:30 once I switched JAVA_CMD to point to java from a JDK, it worked fine

20:31 ndimiduk: not so for me.

20:31 can i query the current classpath from within a repl?

20:32 something off of System perhaps?

20:32 technomancy: (System/getProperty "java.class.path")

20:32 or lein classpath

20:34 ndimiduk: interesting. i have nothing in my classpath which is not defined by my project

20:34 so says (System/getProperty "java.class.path")

20:35 it must be omitting some assumed entries. or the runtime appends to this list

20:35 technomancy: you may also want sun.boot.class.path?

20:35 ndimiduk: ah, there we have some system libs

20:35 it's using a jre path

20:35 technomancy: that's the stuff that doesn't go through bytecode verification, etc

20:36 ndimiduk: haha.

20:36 okay. $JAVA_HOME/bin/java is a symlink to ../jre/bin/java

20:38 this is a full jdk; i have javac in $JAVA_HOME/bin

20:41 `$ $JAVA_CMD -verbose:class | grep tools` returns no results

20:42 are you using openjdk? does that version of the java bin load additional libs?

20:44 technomancy: openjdk on ubuntu has it, yeah

20:44 choffstein: Hey all. I have a question for you -- I am doing some data set-up in a let statement and half-way through the statement I want to determine whether there is enough data to proceed or not. If not, I want to throw an error -- if there is, I want to proceed computing the data. What is the "clojure way" of doing this?

20:46 technomancy: ,(let [x 2, _ (when (neg? x) (throw (Exception. "Positive numbers only plz"))) y (Math/sqrt x)] y)

20:46 clojurebot: 1.4142135623730951

20:46 technomancy: you can do that; it's not great

20:46 amalloy: often you can just create the lazy seqs representing the processing of your data unconditionally, and then later only force it if the condition is met

20:47 choffstein: technomancy: yeah, I really don't like the use of _ for creating side-effects and what-not.

20:47 amalloy: can you expand on that a bit?

20:48 oh, wait, nope. re-read … I think I understand.

20:48 how can I be sure that my process will be lazy?

20:52 amalloy: uhhh. only use lazy functions to operate on it? not very helpful, but there's not a lot of specific things to say

20:54 hugod: ndimiduk: it is my understanding that openjdk automatically adds tools.jar, while sun jdk does not - see "Sun/Oracle JDK" in https://github.com/pallet/ritz

21:28 tmountain: is this the preferred (and fastest?) way to convert an ArrayList to a vector? (into [] array-list)

21:29 amalloy: preferred is probably: "are you sure you need to do it?"

21:30 tmountain: well, I'm calling some Java code that returns an ArrayList, so I don't have much choice in that regard

21:30 amalloy: tmountain: but is there a reason you need a vector, is my point. java's collections can be worked with as seqs

21:31 &(seq (java.util.ArrayList. [1 2 3 4]))

21:31 lazybot: ⇒ (1 2 3 4)

21:31 tmountain: oh, I see

21:31 that makes life easier, thanks!

21:31 amalloy: i mean, the seq isn't random-accessible anymore

21:33 tmountain: what you're saying is it acts like a seq, not a vec, right?

21:33 amalloy: right

21:33 tmountain: I gotcha, thanks for the help

21:39 scottj: hugod: ndimiduk: I thought it was openjdk that didn'thave tools.jar on cp by default, at least on ubuntu

21:42 ndimiduk: this is sun's java

21:42 scottj: maybe it's both

21:45 ritz with openjdk source is pretty sweet, you can step through not only your code, the clojure code, but the jvm code too

21:45 jcromartie: wow, I just realized exactly how powerful a remote slime REPL is

21:45 :P

21:45 scottj: mars lander?

21:46 be sure to do it over ssh

21:46 jcromartie: yes

21:46 what about a mars lander?

21:46 I've heard NASA uses some similar kind of technology

21:46 scottj: there wassome famous lisp project like that that had a repl jpl or someone used to debug something far away

21:46 jcromartie: yeah

21:47 but I like the idea that I can have the files on my local machine, and hit C-c C-k and fix a problem live

21:47 if I absolutely have to cowboy code it

22:01 nowhere_man: scottj: just saw your closing of my issue with SLIME disconnecting, would it be a daunting task to make swank-clojure play nice with recent SLIME?

22:02 scottj: nowhere_man: I don't think so, just no one's done it

22:03 nowhere_man: hugod's fork ritz works with a more recent version

22:03 nowhere_man: I would be really happy to have swank-clojure work with latest slime, but technomancy had a bad experience following master on slime in the past

22:04 hugod: still nowhere near current, but my aim was always to get it up to date,

22:04 ritz works with slime-autodoc

22:04 scottj: swank-clojure does too (for me)

22:05 but I use a different slime version than the recommended one

22:06 I think it would be cool to have a auto-complete mode for dependencies in project.clj so where it completes the name and version based on clojars

22:06 tomoj: there's an index you can download, right?

22:07 hugod: I believe lein already downloads it

22:07 ~/.lein/clojars

22:07 clojurebot: Huh?

22:08 scottj: hugod: nice didn't know about that

22:08 tomoj: http://clojars.org/repo/feed.clj.gz

22:08 I don't have ~/.lein/clojars

22:08 oh, lein-search writes it

22:09 scottj: if anyone writes a mode like that please post it to ml, otherwise I'll probably take a stab at that soon now that I know about ~/.lein/clojars

22:09 tomoj: whoa

22:10 scm repos in that index

22:10 nowhere_man: hugod: I did lein install plugin and added dev-deps to my project, but on lein ritz, I get java.lang.ClassNotFoundException: com.sun.jdi.VirtualMachine

22:10 is it something leiningen doesn't check for?

22:11 hugod: it is require by the jpda debugger - see the Sun/Oracle JDK section of the readme

22:11 tomoj: scottj: need a primitive clojure reader in elisp? or rely on running slime?

22:12 scottj: hugod: note I have that issue with openjdk

22:12 hugod: nowhere_man: it is tools.jar that you have to get on the classpath

22:12 scottj maybe they both need it then…

22:14 scottj: tomoj: yeah i was thinking of using slime and basing it on ac-slime.el, but not using slime would be better

22:18 nowhere_man: hugod: added /usr/lib/jvm/java-6-openjdk/lib/tools.jar to .lein-classpath to no avail...

22:20 hugod: nevermind, I didn't find anything else in lein's online help but I just stumbled on `lein help sample`

22:20 hugod: nowhere_man: maybe try :dev-resources-path

22:20 scottj: nowhere_man: see ritz readme

22:23 I'm still amazed no one seems to care about clojure-refactoring

22:23 hugod: btw, still looking for any input on https://github.com/pallet/ritz/issues/14 - how to filter/manage which exceptions break into the debugger

22:24 nowhere_man: ha, shit, I thought these sections were exclusive, I only read the one for lein

22:25 hugod: keep meaning to try clojure-refactoring, but never did…

22:26 scottj: it's awesome

22:26 but there are some bugs. I really like the thread-first, thread-last, unthread refactorings

22:26 nowhere_man: ooOOooOo, it works!

22:26 I'll finally be able to play with Clojure, great!

22:27 thanks a lot, you all

22:28 hugod: nowhere_man: ritz still has some rough edges…issues welcome

22:28 scottj: hugod: did you ever get a response to your -dev locals clearing request?

22:28 hugod: scottj: not from core

22:29 nowhere_man: hugod: one of the greatest pleasures in using free software is seeing bugs fixed, so I'll happily file issues...

22:29 hiredman: I thought rhickey replied

22:29 something like "I dunno what the best way to do this is"

22:29 hugod: hiredman: earlier on in the year

22:30 a dynamic var controlling the locals clearing would be fine with me

22:32 that could be set by emacs using a prefix for C-c C-c or C-c C-k

22:33 hiredman: more hooks for the compiler would be nice in general

22:59 jcromartie: hm... form validation in sandbar look complicated

23:23 scottj: jcromartie: maybe look at valip or noir

23:23 jcromartie: I just wrote this https://gist.github.com/1113067

23:24 I achieved my goals :)

23:24 seems to be sufficient for a decoupled validation lib

23:24 the results can be passed to the view layer

23:25 and the view doesn't need to know anything about validation itself

23:26 alandipert: jcromartie: neato

23:26 jcromartie: lines 18/19 could be (when-let [x (get m k)]...)

23:26 jcromartie: yes

23:27 actually

23:27 no

23:27 because if the form was not submitted, then there will be no key in the params map

23:27 this only validates when the form was actually submitted

23:27 alandipert: that's ok, get returns nil on not found (by default)

23:28 jcromartie: no, I mean when the key is not present I don't want to validate at all

23:28 alandipert: oh i gotcha

23:28 jcromartie: but when it's present and nil, then it's an error

23:28 although... hm

23:29 I'm not sure if that's secure

23:46 kephale: hopefully an easy leiningen question: how does one refer to files in the resources directory in a portable way (so it works in an uberjar)?

23:49 hiredman: kephale: clojure.java.io/resource

23:50 kephale: hiredman: hoorah, thank you

23:55 jcromartie: now with infinity% more tests!

23:55 https://gist.github.com/1113067

Logging service provided by n01se.net