#clojure log - Feb 03 2013

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

0:31 aniero: hey, i just upgraded my system finally to lein 2.0.0 ... supposedly "lein repl" will write a repl-port file, but i'm not seeing one

0:32 via homebrew, specifically

0:34 never mind, i shot my own foot here. looks like i had lein installed elsewhere

0:48 zodiak: aniero, happens to the best of us :)

0:49 I jst spent about 30 minutes trying to debug an org.apache.httpclient problem, only to figure out my project.clj was pulling in an old version of clj-http and that was pulling in an old httpclient version ;)

0:49 bloody java

0:59 Raynes: zodiak: Dependency mismatches are not Java specific.

0:59 michaelr`: is there a way to define a GET or POST route with compojure?

0:59 zodiak: Raynes, maybe not, but java raises pkg mismatch to a whole brutal level in my experience

1:00 Raynes: You've never used Haskell + cabal-install then.

1:00 :p

1:00 michaelr`: I mean, a route which handles both GET and POST requests

1:00 zodiak: Raynes, nope.. I like my languages practical :P

1:00 Raynes: Low blow, dude. low blow.

1:01 zodiak: *tips hat to Raynes*

1:01 Raynes: michaelr`: Does it matter if it also matches DELETE, PUT, and POOT?

1:01 If not, ANY will work.

1:01 zodiak: michaelr`, if you have a route that does the same function for a get and post.. urm.. why not have them call the same function ?

1:02 Raynes: Because that's not how Clojurians do business.

1:02 We abstract every damn thing.

1:02 zodiak: Raynes, repeat code twice ? twice ? repeat code ?

1:02 michaelr`: yeah, i knew these were my options but just hoped maybe there is also something else :)

1:02 zodiak: michaelr`, it sounds (to my stupid ears) that your code is saying 'this should be a function'

1:02 your call as to wether or not you listen ;)

1:02 whether. rats.

1:02 Raynes: michaelr`: https://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#L86

1:03 michaelr`: zodiak: what i want is something like that: (GET|POST (do-whatever))

1:03 Raynes: michaelr`: This is the lower level function that the GET macros and what not calls.

1:04 michaelr`: Raynes: thanks.. i guess ;)

1:05 Raynes: Pretty sure that's the best you can do if you want something that can do both. You'd have to write it yourself. In this case though, and unless you have to do this a lot, it's probably best to do what zodiak proposed and just add two routes that both call the same function.

1:05 zodiak: anyhoo.. I am out for the night. pax.

1:06 michaelr`: Raynes: yeah

1:08 Raynes: it doesn't look like that code is built to easily support something like that

1:13 jonasen: dnolen: ping

2:26 doc_brown: does lein deps run everything with 'dependencies' in its name in the project.clj file ?

2:55 callenbot: I have some code I don't understand the behavior of.

2:57 ah wait, there it goes.

3:08 is anyone here using drip?

3:14 Sigh. No if/else in Clabango.

3:14 god save me from these goddamn template libraries.

3:34 jokar: Hello Folks

3:35 Can I find a person for talk about Clojure?

3:36 callenbot: jokar: I'll talk about it, but I'm a tumbler of vodka and redbull deep into some code.

3:36 jokar: callenbot: Can I send PM?

3:36 callenbot: why?

3:36 clojurebot: why is startup slow is busy compiling the `for` macroexpansion

3:37 jokar: My questions are a little odd

3:37 headshot: ask anyway

3:37 callenbot: you will share them with the masses.

3:38 jokar: OK

3:38 Why Clojure is good? Can you tell me some of the features

3:39 What is good for?

3:39 callenbot: jokar: writing software

3:39 jokar: :)

3:39 Which software?

3:39 I know it is lisp

3:39 callenbot: jokar: what do you use to code right now?

3:39 I can compare/contrast accordingly.

3:39 jokar: I use C\C++, Python, Assembly, Bash

3:41 Can I find "Rich Hickey" here?

3:41 callenbot: jokar: you'll learn and be able to apply functional concepts to your code. Clojure will be faster than Python and higher level than Python or C. It'll give you access to the JVM ecosystem of libraries.

3:41 jokar: It is based on java

3:41 callenbot: jokar: his time is too valuable to justify his programming language to random people when there's nothing special about your questions.

3:41 No, Clojure is based on Lisp.

3:42 There are multiple Clojure implementations and the JVM runtime is just the primary one for now.

3:42 jokar: if it based on Lisp, Why we should choose Clojure and not Lisp?

3:43 callenbot: because most Lisp communities are madmen living in the hills

3:43 headshot: "lisp" is a family of language implementations

3:43 callenbot: Clojure is for the lisp hacker that has work to do.

3:44 jokar: Can you compare Clojure and haskell or scala?

3:44 headshot: jokar: what problem spaces are you developing for?

3:44 jokar: I have not problem, I'm a nongeek in Lisp

3:44 http://www.google.com/trends/explore#q=clojure%2C%20Scala%2C%20haskell&cmpt=q

3:44 callenbot: jokar: Clojure and Haskell/Scala are very different. Haskell and Scala are statically typed whereas Clojure is dynamically typed.

3:45 jokar: interacting with things like arbitrary JSON is going to be a bit nicer in a language like Clojure. It's similar to Python in that respect.

3:45 headshot: and scala's type system can be quite a headache, especially with readability of code

3:45 callenbot: jokar: also Clojure is a Lisp, Scala and Haskell are not.

3:45 jokar: Do you make money with Clo...?

3:45 headshot: <-- yes

3:46 callenbot: jokar: some do, many do not.

3:46 jokar: there's a decent community of startups and contractors that use Clojure.

3:46 jokar: callenbot: Can you show me a big project that use clo...

3:46 callenbot: jokar: I don't know that that's a very good selection criteria for learning a programming language. You should seek languages that will teach you something.

3:46 jokar: can do you your own research?

3:46 jokar: you're not asking questions that are difficult to answer with Google.

3:46 jokar: Maybe

3:47 callenbot: jokar: don't PM me

3:48 jokar: callenbot: Can you tell me some projects that you do them with clo..?

3:49 headshot: jokar: i do a lot of apache camel stuff, and where i would write java i now use clojure

3:51 jokar: Why you switch from java to clo?

3:52 headshot: because java sucks

3:52 jokar: sucks?

3:52 clojurebot: why oo sucks is oo sucks

3:55 Sgeo: When is Java getting lambdas, exactly?

3:55 I heard they're finally getting them

3:56 ,(for [i [1 2 3] j [4 5 6]] (+ i j))

3:56 clojurebot: (5 6 7 6 7 ...)

3:56 Sgeo: pretty annoying to write the equivalent of that in Java

3:56 Nested loops etc

3:56 hm

3:57 I just reminded myself of why I like Tcl

3:58 headshot: 08:48 < callenbot> jokar: don't PM me

3:58 kthx

3:58 jokar: headshot: No problem, Bye

4:32 callenbot: Sgeo: Tcl is a programming language for nihilists and schizophrenics.

4:33 Sgeo: Uh, what?

4:34 I like how even if you define a command to do what in other languages you would use a macro for, you can still force the command to see the result of a computation rather than the literals that a Clojure macro might be expecting

4:43 callenbot: does anybody here use sandbar or riend?

4:43 friend*

5:28 ljos: Hi, is there somewhere where I can read about how to properly do clojurescript development with emacs. Right now I am just writing stuff and then compiling and testing it in the browser, but that is quite slow. I would like to get back the workflow I have in Clojure with Emacs+nrepl and being able to quickly tests things in the repl.

5:31 callenbot: ljos: you can do a terminal repl or: https://github.com/clojure/clojurescript/wiki/Emacs-&-inferior-lisp-mode

5:31 ljos: if you're not already doing so, you might want: https://github.com/ibdknox/cljs-watch or lein-cljsbuild

5:36 ljos: I am using lein-cljsbuild to build things. An `auto` does make things better, but what I want is the same workflow as I have in clojure. There I have the source and a repl open in emacs and then I C-c C-k to compile. I'm not sure if I like the autocompile function yet as I have a very erratic way of coding..

5:38 Though maybe I have to get used to it because the cljsbuild is very slow.

5:52 etherealG: hi everyone. i'm just getting started learning clojure as my first lisp. been doing the problems on 4clojure as practice, but at about problem 30 upwards i'm really struggling with each one. is there a good guide to get into the functional/recursive style of thinking for someone used to the imperative?

5:55 ljos: etherealG: one thing I did was to go back to some of the simple imperative code (I started with Java) and converted every loop to a recursive function call. That is not always the best thing to do (especially in Java) but you get a real feel for when to use loops and when recursion is more succint. Then, after working a bit with recursion you can convert every recursive function to using `map` and/or `reduce` instead.

5:56 etherealG: thanks for the idea

5:58 broquaint: etherealG: It can also be useful to follow other users and see how they solved problems.

6:00 rodney_: w

6:03 etherealG: broquaint: feels like cheating, although I have for a few of my more difficult ones

6:04 callenbot: http://pragprog.com/magazines/2011-03/punk-rock-languages

6:04 etherealG: i checked the source code for the builtin clojure functions for reverse and a few others, and worked back from there

6:05 but the knowledge of doing it myself hasn't sunk in

6:14 broquaint: Reading code for a problem you've already solved is hardly cheating and a great way to learn how the more fluent approach problems :)

6:21 etherealG: ah, I see, you meant for the problems I've already done

6:54 callenbot: https://www.refheap.com/paste/9226 alright, what am I fucking up?

6:54 it works if I remove (user-middleware)

6:56 arcatan: what does put-context do?

6:57 callenbot: (defn put-context [key val] (swap! g assoc key val))

6:58 arcatan: is g defined there? from the error message i'm guessing it's somehow related to g

6:58 callenbot: arcatan: yes...

6:58 (def ^:dynamic g (atom {})) is right above put-context

6:58 arcatan: right.

6:58 callenbot: in the same namespace

6:58 so what am I doing wrong?

6:59 arcatan: should the middlewares return something useful?

7:00 callenbot: oh fuck I'm an idiot

7:00 arcatan: good catch.

7:00 arcatan: heh, i'm just asking stupid questions :)

7:01 callenbot: arcatan: no dice, same error but at runtime instead of compile time: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.IDeref

7:01 shuffling around middleware order to see if moving my food around on my plate does something

7:01 nope

7:03 hrm, that's not a good sign.

7:03 arcatan: error is in noir.cookies

7:03 not my code

7:04 I mean I might be doing something wrong, but it's lib-noir's deref for cookies.

7:06 arcatan: weird

7:06 callenbot: arcatan: futzing around to fix it.

7:06 tomoj: perhaps the problem is that you didn't wrap noir-cookies?

7:06 er, wrap-noir-cookies

7:07 callenbot: tomoj: I figured the magic yog put in place would, but that might be the case. Testing that hypothesis now.

7:07 sigh, motherfucker.

7:08 I'm 404'ing on the goddamn / now.

7:08 tomoj: yog?

7:08 callenbot: tomoj: https://github.com/noir-clojure/lib-noir/blob/master/src/noir/util/middleware.clj#L75

7:09 tomoj: it's already part of it.

7:09 I think it's an ordering problem.

7:09 tomoj: oh

7:09 callenbot: I need to add my own middleware that depends on noir cookies

7:09 but it won't happen before the app handler.

7:09 this is not good magic.

7:10 tomoj: hmm

7:11 so the only way to use app-handler with your middleware that does put! is to put your middleware in your routes?

7:15 callenbot: your user-middleware doesn't seem to return a function?

7:16 callenbot: tomoj: I already fixed that

7:17 fun new error: Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: compojure.core$routes$fn__1194, compiling:(handler.clj:35)

7:18 wait, think I got this one

7:18 still 404.

7:22 yeah, think I fixed it.

7:26 tomoj: I feel like I'd use (let [x y :when z w v] ..) a whole lot

7:27 (let [x y :when-let [z w] v u] ..) ? :/

7:30 AfroCassowarries: tomoj,

7:30 I worship his shadow.

7:43 pepijndevos: Is there a stemmer in clojure, or should I just use a Java lib?

7:52 babilen: pepijndevos: Stemmer for which language?

7:52 pepijndevos: babilen, english.

7:54 Actually, for now I think I jest need to.... singularise? remove trailing S wit added magic.

7:54 babilen: pepijndevos: https://github.com/dakrone/clojure-opennlp might have one - I am currently using the stemmer that comes with lucene, but you might want to take a look at http://nlp.stanford.edu/software/tokenizer.shtml

7:54 pepijndevos: babilen, afaict opennlp has no stemmer.

7:55 lucene will definitaly work, but way overkill

7:55 maybe this: http://tartarus.org/~martin/PorterStemmer/java.txt

7:58 babilen: pepijndevos: Do you need a tokenizer too? As I said, I am currently using http://lucene.apache.org/core/4_0_0/core/org/apache/lucene/analysis/Analyzer.html like https://www.refheap.com/paste/9227 -- It comes with a parterstemmer implementation

7:58 pepijndevos: babilen, I have a kick-ass regex tokenizer now. Maybe I should in fact use lucene....

7:58 babilen: pepijndevos: See http://lucene.apache.org/core/4_0_0/core/org/apache/lucene/analysis/package-summary.html for further examples

7:59 regex tokenizer? haha

7:59 pepijndevos: (re-seq #"\w+(?:[.,]\w+)*|\S+" (s/lower-case l))

7:59 babilen: pepijndevos: Stanford's tokenizer is quite nice. I would use that if it weren't for the fact that this particular project uses lucene anyway

7:59 pepijndevos: I'll have a look at both.

7:59 babilen: pepijndevos: That is a /very/ crude tokenizer

8:01 pepijndevos: lucene does search... I don't need that

8:01 babilen, I'm building a very crude tool.

8:02 babilen: Sure, that does not prevent you from using its StandardTokenizer though

8:02 pepijndevos: right

8:02 but I don't like to download the internet

8:02 maybe I should use the stanford one

8:02 babilen: pepijndevos: You only need [org.apache.lucene/lucene-analyzers-common "4.0.0"] -- but have a look yourself.

8:03 pepijndevos: oh :)

8:04 babilen: wait, that implementation I pasted above is a buggy one ... (sorry, old checkout)

8:05 pepijndevos: babilen, I was about to mindlessly copy that :)

8:05 why is it first creating a lazy seq and then doall'ing it?

8:06 and, are tokens already stemmed, or is that a separate step?

8:06 babilen: pepijndevos: https://www.refheap.com/paste/9228 is the right one (you'll have to trim the imports, that includes /much/ more than you need.

8:07 pepijndevos: thanks :)

8:12 babilen, am I supposed to bind *analyzer* to the StandardAnalyzer, or some other thing?

8:14 babilen: pepijndevos: https://www.refheap.com/paste/9229 has all the bits (sorry) -- You can use different analyzers and http://lucene.apache.org/core/4_0_0/analyzers-common/overview-summary.html has the overview. You want to play with TokenFilter's -- Take it to #lucene if you need help with that.

8:14 s/'//

8:14 pepijndevos: cool

8:21 babilen: pepijndevos: Looks as if http://lucene.apache.org/core/4_0_0/analyzers-common/org/apache/lucene/analysis/en/package-summary.html is what you are looking for. You might want to play with that -- Otherwise combine your own analyzer as detailed in the Analyzer package description.

8:39 pepijndevos: babilen, this is definitely not what I want: (token-seq "what is the age of the king of france?") ("what" "ag" "king" "franc")

8:42 maybe I want org.apache.lucene.analysis.core.SimpleAnalyzer but that is not much better than my regex it seems

8:42 augustl: pepijndevos: just fyi, the query will also run with the same analyzer

8:43 so "age" will match "ag" if the same analyzers are used on both ends

8:44 and "is" and "the" will also be "analyzed away", etc

8:45 pepijndevos: augustl, at the other end is a database and a core.logic program. Both of these would be rather ugly if I mangle all words like that

8:46 actually, the standard analyzer sortof makes sense

8:46 augustl: are you analyzing with lucene and querying with core.logic?

8:49 iirc the lucene analyzers are made to work with IndexReader and IndexWriter, not for stand-alone use. But I'm not 100% sure about that ;)

9:00 abp: cemerick, I can even reproduce the "write end dead"-exception thrown by nrepl from lein repl. Just (read-line), wait for around four minutes and try evaluating some other form.

9:05 babilen: pepijndevos: You want to override the stopwordlist ...

9:05 pepijndevos: babilen, why?

9:06 babilen: Because the analyzer filters stopwords otherwhise ... It works like "(... *analyzer* (StandardAnalyzer. *version* (StringReader. ""))) for the StandardAnalyzer

9:07 pepijndevos: Or what is your problem with the output exactly?

9:07 pepijndevos: babilen, with the standard analyzer not much. With the english one that in mangles all words

9:10 babilen: pepijndevos: You mean that it uses the Porter stemmer algorithm and actually stems the words?

9:10 pepijndevos: babilen, I don't know, but it gives me "franc" for "frances"

9:11 babilen: augustl: You can use them independently just fine. It is more common to use something like http://nlp.stanford.edu/software/tokenizer.shtml though

9:12 pepijndevos: yeah, that is the stemmed form. (cf. http://en.wikipedia.org/wiki/Stemming) -- You don't have to use the porterstemmer and you could just use something like the EnglishMinimalStemmer (which sounds like something you want)

9:13 pepijndevos: babilen, I'm using standardAnalyzer now, which doesn't do all the stemming

9:13 babilen: ok

9:14 There are /many/ ways in which you can tailor the Lucene analyzers to do /exactly/ what you want .. Some of this might mean more work in creating the analyzer though

9:17 I would also recommend to take a look at the stanford one. I've used it for other NLP projects in the past (along with their Chinese and Arabic one) and it should be quite easy to implement token-seq with that.

9:25 svedubois: Does anybody know any Clojure machine learning framework?

9:26 daimrod: svedubois: you can use weka which is in java.

9:32 babilen: svedubois: weka is certainly a good choice, but what do you need exactly? "machine learning" is a pretty large field :)

9:33 svedubois: babilen: Model-based detection, segmentation and classification for medical image analysis

9:39 babilen: hmm, not my field :-/

9:43 pepijndevos: &(keyword "foo bar")

9:43 lazybot: ⇒ :foo bar

9:43 pepijndevos: Will that ever do something sensible?

9:46 hyPiRion: ,((keyword "woop woop") {(keyword "woop woop") 102})

9:46 clojurebot: 102

9:46 hyPiRion: Perfectly fine, I assure you.

9:47 not serializable though

9:47 hm

9:50 pepijndevos: hyPiRion, yea, there is a difference between readable and valid keywords. hmmm

9:51 Most of the time I'm saying (keyword "some string") I'd like it to return :some-string, which might be an unreasonable expectation. Maybe a helper is appropriate

9:53 hyPiRion: ,(.replace "some string" \ \-)

9:53 clojurebot: "some-string"

9:53 hyPiRion: ,(.replace "a longer string" \ \-)

9:53 clojurebot: "a-longer-string"

9:54 cemerick: abp: ok; could you file an issue on jira describing how to reproduce?

9:58 abp: cemerick, will do.

10:24 pepijndevos: I'm ocasionally getting "ERROR: Unhandled REPL handler exception processing message" followed by some trivial piece of code and a long ID.

10:24 After that, the repl is completely dead

10:28 actually: ERROR: Unhandled REPL handler exception processing message {:code (use 'asky.core :reload), :id e2c7d4b1-8d7c-497e-aabc-77173d438cc5, :op eval, :session 143f6060-0c52-46d6-bd59-7be51996cd97}

10:28 java.io.IOException: Write end dead

10:28 pretty anoying

10:29 Maybe less so if I set up drip. I'm hoping somene makes a lein plugin of it

10:36 doc_brown: why would java complain about compjure classes not being in the classpath in one project and not the other ? they have identical project.clj's

10:52 when i do lein classpath i see all the required directories i need to access my classes yet lein complains it cant find them when i try to execute them

11:18 Ralt: what's the state of clojure-clr right now?

11:33 svedubois: Is this java to clojure conversion correct?

11:33 Img< T > output = duplicate.factory().create( duplicate, duplicate.firstElement() );

11:33 (def output (-> (duplicate) (.factory (.create duplicate (.firstElement duplicate)))))

11:38 a|i: is there an xml selector like enlive which supports xml namespaces?

11:39 svedubois: It seems .create is malformed. Any advice?

11:50 How I can translate this java line to clojure? Img< T > output = duplicate.factory().create( duplicate, duplicate.firstElement() );

12:06 yedi: is defn- a thing?

12:06 and if so what does it do?

12:07 Frozenlock: IIRC, it's for making private functions.

12:07 (functions only available in this namespace)

12:08 oskarth: ,(source defn-)

12:08 clojurebot: Source not found\n

12:08 zodiak: yedi (doc defn-)

12:11 svedubois: Is this java to clojure conversion correct?

12:11 Img< T > output = input.factory().create( input, input.firstElement() );

12:11 (def output (.create (input (.firstElement input)) (.factory input)))

12:15 hyPiRion: svedubois: maybe this reads better? (.. input (factory) (create input (.firstElement input)))

12:15 svedubois: hyPiRion: Yes, it works

12:15 Thanks

12:20 hyPiRion: Anytime

12:23 weavejester: Anyone know much about Friend?

12:40 TimMc: yedi: It's just defn + ^:private, which keeps the var from being exported by the namepace.

12:46 yedi: i see, thanks guys

13:11 rodnaph: does anyone know a tool/service for quickly querying the latest version of a library? (that'll check maven central/clojars/etc...)

13:12 Raynes: $latest compojure

13:12 lazybot: [compojure "1.2.0-SNAPSHOT"] -- https://clojars.org/compojure

13:12 Raynes: That checks clojars.

13:15 gfredericks: is `lein search` still claimed to work?

13:16 sshack: $latest clojuratica

13:16 lazybot: No project by this name exists on clojars.

13:17 gfredericks: $.50

13:29 LauJensen: Evening. Im trying out nrepl, specifically nrepl-jack-in which spawns a server and connect and also allows me to evaluate sexps from my .clj files, but the *nrepl* buffer is empty and I cannot use it as a repl. Am I missing something?

13:30 Frozenlock: LauJensen: Any interesting info in the *nrepl-server* buffer?

13:30 LauJensen: Frozenlock: Just that the server is started and in this specific case that its opened a jetty

13:31 nREPL server started on port 61718

13:31 2013-02-03 18:54:05.117:INFO:oejs.Server:jetty-7.6.1.v20120215

13:31 2013-02-03 18:54:05.161:INFO:oejs.AbstractConnector:Started SelectChannelConnector@

13:40 jamii: This doesn't seem right... https://www.refheap.com/paste/9231

13:43 cgag: if i ran (ring.server/serve app {:port 3000 :join? false}), but didn't bind the result to a symbol, is there any way for me to get hold of it so I can stop the server?

13:44 Frozenlock: *1, if it was your last command :P

13:44 I think it goes up to 3 last commands.... *3

13:45 cgag: i thought of that a few commands too late, it's not an issue to just kill my repl, i'm just curious now

14:05 angerman: I'm having some trouble converting some java code to clojure. Is this correct: https://gist.github.com/10acef8fddd6588468c4 ?

14:06 gfredericks: angerman: looks plausible; does it work? I'm surprised you need the type hints

14:07 angerman: gfredericks: I've added type hints while trying to see why it does not work.

14:07 gfredericks: how does it fail?

14:07 angerman: I'm not completely certain that's the issue though.

14:08 javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated

14:08 gfredericks: oh so it compiles fine?

14:08 angerman: yep. The clojure code just doesn't behave identical to the javacode.

14:09 I'll try another more line-to-line rewrite.

14:09 gfredericks: definitely looks fine to me

14:16 jonasen: dnolen: ping

14:18 a|i: does clojure-contrib come with clojure distribution?

14:18 if not, how to add it to dependencies?

14:19 cldwalker: hi all, anyone know how I could open an editor within clojure i.e. (clojure.java.shell/sh "emacs" file)?

14:24 rodnaph: Raynes: thanks i didn't know there was a bot for that.

14:30 core.logic question: i'm trying to write a flatteno relation - https://gist.github.com/4703280 - but am wondering if there's a much easier way i can do this, something like... https://gist.github.com/4703286 (which obv doesn't work)

14:33 dnolen: jonasen: pong

14:34 rodnaph: isn't flatteno covered in The Reasoned Schemer? Are you trying to write it from scratch?

14:35 rodnaph: dnolen: it might be, i don't have a copy to hand though. but yes, i'm learning more than trying to get something done.

14:38 angerman: gfredericks: so I rewrote it. Still compiles, still same issue. But I switched on warn on reflection. And got a invokeStaticMethod error.

14:38 but NO_SOURCE_PATH:1 is not that helpful :)

14:39 dnolen: rodnaph: yeah, you can't write things that way

14:40 rodnaph: dnolen: i didn't imagine i could, but i'm trying to work out how using clojure with core.logic behaves. any suggestions for where and when it makes sense to do this?

14:41 dnolen: a|i: clojure-contrib is deprecated - don't use it

14:41 a|i: dnolen: what's the alternative? I want to use zip-filter.

14:42 dnolen: rodnaph: not that I can sum up easily. There's a tutorial on the wiki which might help. Also I recommend The Reasoned Schemer

14:42 a|i: I don't know of any alternatives, but other people might

14:42 rodnaph: dnolen: ok thanks i'll check it out (am half way through the reasoned schemer as well, book at work though, so will pick it up again). cheers

14:45 dnolen: rodnaph: it's possible to use clojure functions if you project vars, but it means your program will be non-relational and behave strangely unless you are extremely careful.

14:47 bruceadams: a|i: looks like zip-filter has moved to data.zip http://clojure.github.com/data.zip/

14:47 powrtoc: dnolen: I'm flicking through the Byrd thesis, and toying with core.logic to test my understanding

14:49 dnolen, I'm trying to grok walk and unify... but I don't really understand how they work, outside of the run macro... what arguments do they take etc?

14:49 jonasen: dnolen: What's your take on http://dev.clojure.org/jira/browse/CLJS-455?focusedCommentId=30533&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-30533

14:50 dnolen: see my latest comment

14:50 a|i: bruceadams: thanks.

14:59 dnolen: jonasen: noted, will get back to you.

14:59 jonasen: dnolen: ok, thanks

15:00 dnolen: powrtoc: unify takes the substitution map and two terms to unify. walk takes a substitution map and a value to lookup in the substitution map.

15:00 powrtoc: they can both be used outside of run, run is just sugar.

15:00 ivaraasen: hm, nrepl.el is giving me a blank buffer when connecting with nrepl-jack-in/nrepl

15:00 REPLy is working fine though

15:05 powrtoc: dnolen: I clearly don't understand the purpose of walk then... because (walk (-> empty-s (ext 'a 1)) 'a) returns => a ... I would have expected it to lookup 'a and return 1

15:11 angerman: great. I found it. don't understand it though.

15:13 hyPiRion: Could anyone explain the following:

15:13 ,(fn [^long a ^long b ^long c ^long d ^long e] (+ a b c d e))

15:13 clojurebot: #<CompilerException java.lang.IllegalArgumentException: fns taking primitives support only 4 or fewer args, compiling:(NO_SOURCE_PATH:0)>

15:13 hyPiRion: As why there's only 4 or fewer?

15:16 svedubois: How I can write this java conditional in clojure? https://www.refheap.com/paste/9253

15:16 Frozenlock: hyPiRion: Because otherwise you'll rip the space-time continuum appart and doom us all!

15:16 dnolen: powrtoc: you cannot put random things on the left hand side - only logic vars

15:17 powrtoc: ahh

15:17 hyPiRion: Frozenlock: Well darn it.

15:18 powrtoc: cool... so (walk (-> empty-s (ext (lvar 'a false) 5) (ext (lvar 'b false) 10)) (lvar 'a false)) returns 5 as expected

15:19 skelternet: svedubois: if you do min or max separately you might be able to use reduce?

15:19 ,(doc min)

15:19 clojurebot: "([x] [x y] [x y & more]); Returns the least of the nums."

15:20 powrtoc: as does: (walk (-> empty-s (ext (lvar 'a false) 5) (ext (lvar 'b false) (lvar 'a false))) (lvar 'b false))

15:20 sweet

15:20 hyPiRion: svedubois: (let [iseq (iterator-seq iterator)] (.set min-val (reduce min iseq)) (.set max-val (reduce max iseq)))

15:23 ivaraasen: hyPiRion: got any idea why nrepl.el is giving me an empty buffer? never experienced this before.

15:25 seangrove: Christ, my advanced-compiled cljs file is 588kb

15:25 That's rough

15:25 Ah, looks like whitespace optimization isn't turned on. That'll shave a bit off

15:26 haspaker: I propose that we should replace all parenthesis with the words "start-raccoon" and "end-raccoon"

15:26 hyPiRion: ivaraasen: no idea, never experienced it

15:27 ivaraasen: hyPiRion: turns out I forgot to install rainbow delimiters. god damnit

15:27 hyPiRion: heh

15:27 Frozenlock: haspaker: Would that bring those who are afraid of parentheses?

15:27 skelternet: Anyone using reader literals to do something useful?

15:28 ivaraasen: hyPiRion: thanks for the code review BTW

15:29 bosie: Frozenlock: i don't understeand the parentheses thing. it was really the last thing that bothered me when i started with clojure

15:29 haspaker: Frozenlock: Indeed. And those that love raccoons.

15:30 seangrove: My sister is learning python, and when she saw python, she said, "Wow, so many parentheses!"

15:30 Natural reaction, I suppose

15:30 err, sorry, "when she saw clojure"

15:35 skelternet: the whitespace vs parens as structure seem like two different sides of a coin…or a d20.

15:35 bosie: the task 'itneractive' isn't valid anymore in leiningen 2.0?

15:36 Frozenlock: parens love http://www.thejach.com/imgs/lisp_parens.png

15:38 hyPiRion: ivaraasen: Anytime sir

15:38 svedubois: hyPiRion: java.lang.IllegalArgumentException: No matching method found: .set for class clojure.core$min

15:39 sshack: skelternet: Does it even seem like an argument? Take something you can easily see over something you can't every time.

15:40 svedubois: hyPiRion: The java source is https://github.com/imagej/imglib/blob/master/imglib2/examples/src/main/java/Example3a1.java

15:41 skelternet: sshack: Actually yes, I can see the argument. However, having experienced tooling failures and getting bit by whitespace distortion, I too would rather not risk it again.

15:41 svedubois: hyPiRion: And I have write in clojure this: https://www.refheap.com/paste/9265

15:41 sshack: That was exactly what I was getting at.

15:42 pepijndevos: dnolen, what is the difference between the actual code in logic.datomic and the wiki page? Just optimizations, or structural stuff?

15:42 dnolen: pepijndevos: I need to update, the unification protocols changed, no more double dispatching

15:42 sshack: skelternet: There's actually some academic work into the subject from the military field on why you absolutely, under no circumstances ever want that sort of friction.

15:43 skelternet: sshack: a while back I went through a thought exercise looking at what more I could remove from the expression of Clojure code. Using whitespace and spatial orientation of the glyphs was an idea. I haven't pursued it.

15:43 pepijndevos: dnolen, Ok, so I'll just have to study the code. Can I update the wiki?

15:43 skelternet: sshack: to help explain…the context was kind of an art project as well

15:43 dnolen: pepijndevos: please do

15:43 pepijndevos: the changes are very minor

15:44 skelternet: sshack: You don't have to sell me the practicalities.

15:44 pepijndevos: dnolen, ok. Also. I'm not sure it's easy to integrate with a mutable dataase.

15:44 Frozenlock: Wait, you mean there's languages using whitespace as a structure?

15:44 sshack: skelternet: Awesome. You'd be using tooling to move the information around?

15:45 dnolen: pepijndevos: what challenges do you forsee?

15:46 pepijndevos: dnolen, not sure yet, but it seems it's hard to reason aout something that chnges under your feet.

15:46 skelternet: skelternet: that was the idea to make it practical and elegant. You must have instant and interactive feedback on a touch or gesture device.

15:46 why did I say that to myself?

15:46 pepijndevos: unless you download the internet

15:47 sshack: skelternet: Trying to make yourself believe?

15:48 skelternet: sshack: finger macro?

15:48 svedubois: Any advice to correct this clojure code (https://www.refheap.com/paste/9265) from this java code (https://github.com/imagej/imglib/blob/master/imglib2/examples/src/main/java/Example3a1.java)

15:48 Bronsa: dnolen: do you know who i should ping for a hudson account?

15:49 dnolen: Bronsa: Stuart Sierra I think

15:49 Bronsa: ok, thanks

15:51 dnolen: Bronsa: nice to see that things are moving forward!

15:52 Bronsa: yeah, yesterday stuarthalloway was on irc so I took the occasion and asked him to setup all the things

15:58 ivaraasen: hyPiRion: https://github.com/emilhf/array-utils :)

16:05 svedubois: How I can convert this to clojure: if ( type.compareTo( min ) < 0 ) min.set( type );

16:07 dnolen: jonasen: ping

16:13 ljos: Is there somewhere I can read about how people work with clojurescript, because the workflow just feels horrendous to me. First of all, how can I get a proper repl (not the standard one where I can't even go back in history) that allows me to import new namespaces? I seem to be having this problem right now: WARNING: Use of undeclared Var cljs.user/use at line 1

16:14 jonasen: dnolen: pong

16:14 dnolen: jonasen: I read over your comments - yeah I'm OK w/ backing out that commit.

16:15 jonasen: dnolen: Yeah, it seems like js/... is meant to provide that level of magic

16:16 dnolen: jonasen: yes

16:16 jonasen: a bit surprising

16:17 dnolen: jonasen: or, we could allow new to be dynamic

16:17 jonasen: we don't have the limitations of the JVM here

16:17 svedubois: Any advice?

16:18 jonasen: I agree. I mentioned that in my comment.

16:19 Maybe you could ask Rich at Clojure/West what the intent for js/.. is.

16:21 cgag: (when (< (.compareTo type min) 0) (.set min type)) to translate it literally i think

16:22 callenbot: dnolen: Carthago delenda est: source maps?

16:22 jonasen: dnolen: But it might be a good idea to revert the change for now. Otherwise people will get lots of (potentially false) warnings

16:29 dnolen: ljos: yes let's revert and keep the ticket open until we get more information

16:29 oops that was for jonasen

16:29 ljos: I got very confused there.

16:30 dnolen: jonasen: if you add a patch to revert I'll apply

16:30 ljos: workflow for CLJS could definitely use improvement

16:31 ljos: but somebody needs to work on that

16:31 callenbot: waiting on 1.5.0 to merge in the current work, then probably switch over to tools.reader

16:32 ljos: dnolen: maybe I will have to look into that. I have been trying to improve some of the cljs-libs I am using, but I get so frustrated by the tools and workflow that I just stop. Maybe it is better if I fix that firs.t

16:32 svedubois: cgag: Thanks, it works

16:33 Frozenlock: ljos: I would absolutely welcome a REPL that can survive a page change :)

16:35 ljos: Frozenlock: I would like a REPL that can handle a `use` or `require` properly.

16:36 svedubois: I would like to print the numbers of an UnsignedByteType, but when I println I obtain this #<UnsignedByteType 42>. How I can get the number? I have tried count without success.

16:38 ljos: svedubois: (.toString val) ?

16:39 svedubois: ljos:

16:39 ljos: It works

16:40 cgag: i thought println called toString?

16:40 ljos: It calls Object.toString, right?

16:41 Or am I way off here?

16:42 skelternet: might that depend on the argument? I thought printing was one of those favorite protocol examples?

16:42 or multimethod...

16:43 ljos: The question here though is what happens when println is called on a java class.

16:45 skelternet: print and println might use .toString but it may not be all they print.

16:45 (println myfile)

16:45 #<File .>

16:46 We're asking in the context of UnsignedByteType?

16:46 svedubois: Is there any more concise way? https://www.refheap.com/paste/9290

16:47 dnolen: svedubois: I think you can add a print-method case for UnsignedByteType

16:48 skelternet: is UnsignedByteType from img lib? where is that from?

16:49 ljos: svedubios: I can't really understand what you are trying to do in that paste. There is too little information.

16:49 dnolen: svedubois: any reason to not user iterator-seq ?

16:50 mpenet: https://www.refheap.com/paste/9293

16:50 svedubois: dnolen: I have tried, but I doesn't work. I am doing something wrong... https://www.refheap.com/paste/9265

16:50 mpenet: what am I missing?

16:51 is this a bug?

16:52 ,(type (dec (short 1)))

16:52 clojurebot: java.lang.Long

16:52 mpenet: ,(doc dec)

16:52 clojurebot: "([x]); Returns a number one less than num. Does not auto-promote longs, will throw on overflow. See also: dec'"

16:53 skelternet: mpenet: that surprises me.

16:53 dnolen: mpenet: dec only takes long

16:53 look at Numbers.java

16:53 svedubois: How I can use iterator-seq in https://www.refheap.com/paste/9290 ?

16:54 mpenet: dnolen: thanks I will have a look

16:54 dnolen: mpenet: actually it does take Number, but it gets the longValue

16:54 mpenet: dnolen: but still, this deserves a mention in the docstring

16:54 :/

16:54 skelternet: ,(doc compare)

16:54 clojurebot: "([x y]); Comparator. Returns a negative number, zero, or a positive number when x is logically 'less than', 'equal to', or 'greater than' y. Same as Java x.compareTo(y) except it also works for nil, and compares numbers and collections in a type-independent manner. x must implement Comparable"

16:55 augustl: svedubois: I'd use doseq, that's a common way to iterate with side effects

16:56 mpenet: dnolen: is there an alternative that preserves the original type in core or should I just use (- x (short 1))?

16:56 augustl: svedubois: (doseq [item (iterator-seq my-iterator] (when ...) (when ...))

16:56 dnolen: mpenet: not sure's if that true, Clojure as of 1.3.0 only really deals with 64bit arithmetic as far as I know.

16:56 augustl: missing a ) there

16:56 dnolen: mpenet: if you look at Numbers.java you'll see what I mean.

16:56 mpenet: dnolen: ok

16:57 lynaghk: dnolen: hey dude, you have some time to chat about the latest core.logic bits?

16:58 dnolen: lynaghk: heya what's up?

16:58 bordatoue: hi, when working with emacs and repl i have noticed that once a function is defined it remains loaded in the namespace even after the function is removed from the source . Any ideas on this issue

16:59 lynaghk: dnolen: sorry for being out of touch, I've been traveling for the past two months. Finally got a chance to check out core.logic 0.8.0 and start trying to use this new unification stuff

17:01 dnolen: I've been having a hard time figuring out how to actually put constraints on the lvars during unification---couldn't find any docs or tests and couldn't get the syntaxes we'd discussed (https://gist.github.com/4116442) workin

17:01 ljos: bordatoue: it is by design. If you want to remove a symbol from a namespace you can use (ns-unmap ns symbol).

17:01 dnolen: lynaghk: yeah sorry I haven't quite finished up that bit yet, but it's not much work

17:02 ljos: bordatoue: *ns* is the current namespace.

17:02 lynaghk: dnolen: oh, no worries. I wasn't sure where you were at and couldn't tell from the code---after a few hours of prodding around I thought I should find you on IRC and ask = )

17:03 bordatoue: ljos: the problem is once a function is defined with wrong no of arguments then latter you change it to correct no of arguments the namespace in the repl seems to have reference to the wrong no of arguments

17:03 lynaghk: dnolen: is there anything I can help with? One thing I was trying to figure out is what exactly the relationship is between predicate functions and constraints. I.e., do I have to use `defc` to make toplevel vars, or can I somehow use anon functions in my constraints?

17:04 dnolen: lynaghk: yeah so I'm still planning on moving forward with what we discussed.

17:04 lynaghk: you cannot use regular fns for constraints, since regulars fns don't do enough

17:04 ljos: bordatoue: I don't think so. Can you give an example?

17:05 bordatoue: if you do (defn f [a b] (- a b)) then (defn f [a] (- a)), (f 1) => -1.

17:07 bordatoue: the repl does not have a notion of a source file. It only know the input it recieves. If you remove something from a file that happens to be the input that the repl takes that should not affect the repl.

17:07 lynaghk: dnolen: shouldn't there be a way to macro-around that, since you can (defc A [x] (A? x))

17:07 bordatoue: ljos i did it using mutimethods , please try writing a something similar to this (defmulti fun1 [x] (print x) x)

17:08 (defmulti fun1 [x y] (print x y) x)

17:08 lynaghk: dnolen: I was looking at the implementation to see what exactly was going on, but I couldn't make heads or tails...

17:08 bordatoue: this is causing problem in the repl on emacs

17:09 please note i have relaced the first version of fun1 with the second version using two arguments

17:11 ljos: bordatoue: that there is not correct multimethod syntax. Did you mean (defmulti f (fn [x] (print x) x))?

17:11 chico_chicote: what is the standard way to do nlp in clojure?

17:12 bordatoue: sorry, yes , basically define two functions one that replace other with different arguments

17:12 ljos: bordatoue: a multimethod and a function is not exactly the same, just so you know.

17:13 bordatoue: (defmulti fun (fn [x] (print x) x) ) this version is latter replace by (defmulti fun (fn [x y] (print x y) x))

17:14 ljos: i know that , i am fininding that the repl is holding on the reference of previously definined multimethods

17:14 dnolen: lynaghk: a fnc macro would be useful - for creating anonymous constraints

17:15 lynaghk: dnolen: I can submit a patch today if you want it

17:16 dnolen: though I dunno if your dev plans involve modifying all of the existing constraint stuff

17:17 dnolen: I could also write up a bunch of usage tests against the API we discussed if that'd be helpful to run against while you're developing the implementation

17:18 but yeah, I'm in San Francisco at the moment and several folks have been very excited about the grammar of graphics stuff, so I want to get the core implementation (including the core.logic pattern rewrites) nailed down sooner rather than later = )

17:18 dnolen: lynaghk: modifying what existing constraint stuff?

17:19 lynaghk: dnolen: a patch to split the defc implementation into two pieces, one piece of which is anonomyous constraints

17:19 dnolen: lynaghk: oh yeah, that would be awesome

17:20 lynaghk: dnolen: okay, I'll crank that out today.

17:20 ljos: bordatoue: what to do mean by holding on to? As in when you define new methods for the multimethod or that old methods still work?

17:23 svedubois: How I can write this java line in clojure?

17:23 for ( int i = 0; i <= 10; ++i ) list.add( new FloatType( i ) );

17:23 ljos: bordatoue: could you post a complete example on https://www.refheap.com/paste with exlenation of what happens and what you expect to happen. I think I am a bit too engrained with this to know exactly what you are having problems with.

17:26 mpenet: chico_chicote: I dont think there is a standard way, if you are looking for a wrapper to one of the big java frameworks: there is clojure-opennlp. I used it, it's fine for some uses. If you need performance it will require some work though (lots of reflection warnings among other things)

17:27 chico_chicote: mpenet: no native libs?

17:27 mpenet: chico_chicote: not that I am aware of, but I haven't looked into that for a while

17:28 dnolen: lynaghk: I'll definitely apply as soon as I get it - I'll try to find some time in the next couple days to wrap up the constraint interface on the unifier should be pretty simple. I'm also considering supporting :let, so you can name subexpressions

17:29 mpenet: prismatic made one I think, not open source (yet, or ever maybe, I can't remember)

17:30 dnolen: (unifier '(?x ?y) '(?z 1) :let '{?x (...)}) or something like that

17:30 lynaghk: dnolen: I'm getting back to PDX on Tuesday afternoon. Would love to do some pairing with you on this when you find the time---I can make room in my schedule

17:30 dnolen: lynaghk: sounds good

17:30 lynaghk: dnolen: I think we may be able to hash out a lot of stuff if we can just sit down and chat+code for a bit

17:31 dnolen: lynaghk: definitely. not sure if you know, but I'll be at Clojure/West, will be fun to hang in Portland

17:31 lynaghk: oh and I think you know my friend Tims Gardner and some other people as well

17:31 lynaghk: dnolen: rad! Yeah, I met Tims at strangeloop

17:31 dnolen: lynaghk: do you know his friend David who recently moved to NYC?

17:32 lynaghk: dnolen: David Landsdown? yeah, I knew him at university

17:33 svedubois: How I can use (map inc (range 10)) to convert this java line? for ( int i = 0; i <= 10; ++i ) list.add( new FloatType( i ) );

17:34 lynaghk: dnolen: are core.logic master tests supposed to be passing? "mvn test" is throwing a lot of "no implementation of method runnable?..."

17:35 dnolen: also, datomic and the goog closure compiler are depending on different versions of the guava library, so anyone running lein-pedantic is going to have a hell of a time getting this core.logic lib workin'

17:35 chico_chicote: mpenet: prismatic makes some great libs, i'll check it out, thanks

17:36 dnolen: lynaghk: yeah he built that crazy wooden toy thing for KickStarter right?

17:37 lynaghk: tests passing for me, I'd make sure your environment is clean

17:37 lynaghk: using 'lein test' anyway

17:37 lynaghk: dnolen: yep, I know all of those guys.

17:38 dnolen: lynaghk: core.logic deps are resolved through the pom not project.clj - datomic is not a part of the pom

17:39 lynaghk: dnolen: ah, got it. yeah, "lein test" works but "mvn test" throws errors.

17:39 svedubois: Is this correct? (for [i (range 10)] (.add list (FloatType. i)))

17:41 dnolen: lynaghk: mvn test works for me too

17:42 svedubois: do you really need an ArrayList? What about (for [i (range 11)] (FloatType. i))

17:46 svedubois: you don't want to do it the way you had written it - for is a list comprehension not a for loop

17:46 lynaghk: dnolen: hmm, I'll keep poking around. strange that lein test works but mvn doesn't. Anyway, back later and/or I'll push a patch up my github core.logic fork.

18:16 mjewkes: Hey all - I'm trying to connect to nrepl from emacs on win 8. I have a new project made from lein, and have it open in emacs. I run nrepl-jack-in, but I get: Could not start nrepl server: 'eval' is not recognized as an internal or external command

18:16 Anyone seen this before? google is unhelpful.

18:19 amalloy: mjewkes: https://github.com/kingtim/nrepl.el/blob/master/nrepl.el#L1407 suggests nobody tried to make it work on windows

18:19 but you can customize that var to something more useful

18:21 mjewkes: cool :)

18:24 bordatoue: ljos: please check this https://www.refheap.com/paste/9327

18:25 Could anyone check if there is any bug with the multimethod support in clojure on the repl

18:29 Frozenlock: bordatoue: careful with multi, defining it more than once in a REPL might bring trouble...

18:30 bordatoue: i knew there would be something , where are these information provided Frozenlock

18:31 Frozenlock: I just learned it the hard way and asked wiser individuals here :P

18:31 As everyone know, documentation is Clojure's biggest problem.

18:32 http://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/

18:32 bordatoue: Frozenlock: how did you know about the problem with multimethod, how did you resolve it , please don't tell me you don't define multimethod twice. What happens if you make an error

18:34 Frozenlock: Well... I don't define multimethod twice. Or I switch namespace. Perhaps (ns-unmap ns symbol) could work..

18:36 bordatoue: Frozenlock: consider while you are working on prototype and made some error while defining this multimethod are you saying everytime you do that you use ns-unmap

18:40 Frozenlock: such fun, with multimethod

18:43 headshot: "Only 5 respondents indicated that they target Java 1.5. I honestly expected that number to be much, much higher."

18:43 i find that an odd expectation

19:30 a|i: is http://clojure.github.com/ official?

19:31 headshot: Clojure Source

19:31 Clojure source code is hosted at github.com/clojure/clojure.

19:31 from: http://clojure.org/downloads

19:31 a|i: what is http://clojure.github.com/ ?

19:31 clojure libraries are indeed confusing.

19:32 why is that there is a data.xml and a clojure.xml?

19:32 a data.zip and a clojure.zip?

19:34 headshot: i'm puretty sure those are both the same

19:34 one's the project github front end, the other is the repo view

19:34 a|i: are they.

19:37 headshot: they seem different.

19:38 https://github.com/clojure/data.zip/ says to use [org.clojure/data.zip "0.1.1"] dependency.

19:38 it has an xml-> function, while clojure.zip doesn't have that function.

20:04 sgarrett|afk: So I upgraded to Lein 2.0 and I'm having trouble getting "leon midje" to work again. I added [midje "1.4.0"] and [lein-midje "2.0.4"] to my profiles.clj and now I'm getting this error: http://pastebin.com/DFtY8HBA

20:04 sgarrett: s/leon/lein

20:07 Anyone experienced this issue before?

20:36 skelternet: I might just have to read http://clojure.github.com/clojure/clojure.core-api.html more often.

20:36 durka42: bathroom reading material perhaps? :p

20:37 skelternet: i just forget some of these gems are in here

20:47 SegFaultAX: Does anyone know if delimitmate is compatible with vim-clojure-static?

20:48 Because when I use vim-clojure-static, it stops automatically closing matched pairs (eg () "" {} etc)

20:55 warz: anybody know of a good example of using gen-class' constructors functionality? im using gen-class to subclass a java class, but i want to specify a custom class constructor function

20:55 ive been trying to comprehend this blog post: http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html

20:55 as well as the docs

20:56 but i guess im just not getting it

21:00 a|i: is clojure.xml/parse built on top of SAX?

21:00 damn.

21:01 isn't SAX one of the slowest java parsers?

21:01 S11001001: warz: 1. Just a sanity check: what is the subclass for?

21:01 a|i: SAX is an API, not sure what "slow" means for it

21:01 a|i: that is to say, it's an abstract interface

21:02 sgarrett: Anyone seen this error: http://pastebin.com/DFtY8HBA after installing Lein 2.0?

21:02 a|i: S11001001: so it's no the same SAX library that comes with java?

21:03 S11001001: a|i: it's whatever SAX library you have; SAX is seriously just an interface, you supply an implementation via configuration

21:03 warz: S11001001, it's a Minecraft server plugin, and actually to be honest I don't know if subclassing is what I'm doing. In Java, this would be an Annotation, which I'm not familiar with.

21:03 I did figure out how to do it in Clojure, though.

21:03 so really, I just need to create my own constructor.

21:03 S11001001: warz: so minecraft plugins are reflectively looked up by java class name?

21:04 a|i: S11001001: does the actual xml parsing happen in clojure, or does it call some external java library?

21:04 S11001001: a|i: if you supply an external java library, it uses an external java library; if you supply a clojure library, it uses clojure. I imagine it usually ends up using a java library, because no one wants to rewrite all that crap.

21:05 a|i: S11001001: I'm just using clojure.xml, what's the default implementation for it?

21:06 warz: S11001001, actually I'm sorry, I mispoke. These plugins have classes that in Java, implement an "Listener" class, which says hey this class is an event listener. They're categorized into various event groups. So, I've got a few of these using gen-class, for various event types in-game.

21:06 In instanciate them and register them elsewhere.

21:06 But when I instanciate them, I need to give them a reference to the main plugin instance.

21:07 Which is why I'm just trying to create a constructor.

21:07 S11001001: warz: if you are responsible for instantiating them

21:07 warz: yea, i am

21:07 S11001001: warz: you don't need gen-class, and should avoid it

21:07 warz: what's Listener? interface, class?

21:08 warz: even if they need to be called from Java-land? the Minecraft server is in Java.

21:08 S11001001: warz: yes, even then

21:08 warz: hrm ok, im new to clojure so this is all helpful to me

21:08 Listener is an interface

21:08 S11001001: warz: in that case, try using reify instead

21:09 warz: here's my code here: https://github.com/ryancole/com.rycole.bukkit.mixpanel/blob/master/src/com/rycole/bukkit/mixpanel/listeners/block.clj

21:09 you can see sort of how i'm tryijng to get the construcotr going

21:09 reify, hrm ok

21:10 S11001001: warz: when you need to subclass a class that is not an interface, proxy is available

21:10 warz: ok, i need to do that as well

21:10 for another class

21:10 S11001001: well there you have it

21:10 using these is much easier and much more convenient

21:10 warz: i was wondering why i thought i needed AOT, when i was providing clojure on the class path

21:11 which seemed like i could just use clojure

21:11 S11001001: with reify and proxy, you won't :)

21:11 warz: ok, i wont worry about this constructor issue then. ill just try rewriting this using those methods, and deal with it when i get there.

21:12 learn a lot on the way :P

21:15 so when would you need gen-class, i guess?

21:16 S11001001: When Java or Scala code needs to be able to instantiate the class by name *and* it needs to subclass something that is not an interface.

21:16 note that's *and*, not *or*

21:17 so pretty much never

21:17 warz: hm ok

21:18 S11001001: you get classes by name with deftype/defrecord, and you get subclassing with proxy

21:18 a|i: what's a good way of adding a java jar dependency with lein?

21:19 S11001001: a|i: 1. find in maven 2. if not in maven, put it in 3. refer to it

21:28 a|i: the system is explained here: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#dependencies

21:29 a|i: S11001001: I hate maven.

21:29 S11001001: a|i: Leiningen isn't maven.

21:29 a|i: I want to use vtd-xml, which is not in maven repo.

21:30 S11001001: a|i: then read this: https://github.com/technomancy/leiningen/wiki/Repeatability

21:31 Frozenlock: Is there an implementation of the clojure's map {:a 1 :b 2} in emacs?

21:32 S11001001: Frozenlock: there are mutable hash tables in the stdlib, not sure if anyone's done treeish things

21:33 Frozenlock: Yes, but I mean with the same functionality: map is a function of its key and vice versa

21:33 SegFaultAX: Frozenlock: There is no vice versa.

21:33 S11001001: Ah. No. Pretty sure you can't do that at all.

21:34 SegFaultAX: Frozenlock: Keywords look themselves up in maps, but that's a special case.

21:34 S11001001: well, I can think of how to do it for alists and plists

21:34 you won't like it though

21:36 cjfrisz: Can you do rest argument destructuring in ClojureScript?

21:37 cljnewb: Looking for a way to access previous element when using the map function.

21:38 For example, if this element meets condition x, look at previous element to complete calculation.

21:38 S11001001: cljnewb: (map (fn [prev here] ...) (cons nil lst) lst)

21:40 cljnewb: S11001001: thanks - I'll try to understand what you've put here

21:41 Frozenlock: Could anyone link me to an explanation of sets? Seems all I'm using are lists, vectors and maps.

21:41 cljnewb: So you're passing two seqs to map? The original, and the original offset by one?

21:41 S11001001: cljnewb: you got it

21:41 cljnewb: Frozenlock: sets may not contain duplicate values - think mathematical sets

21:41 ChongLi: Frozenlock: a set is essentially a map from keys to themselves

21:41 every key into a set returns itself

21:42 the primary job of a set is to test for membership

21:43 Frozenlock: Oh I see. So an idiomatic example would be instead of writing a `add-to-list-if-not-present' function?

21:43 ChongLi: sure, and many other things

21:44 technomancy: Frozenlock: there are no good associative data structures in emacs lisp

21:44 ChongLi: because can effectively treat the result of calling a set on some key as true/false

21:44 you can treat a set as a predicate

21:44 technomancy: elisp hash tables are a joke =\

21:44 Frozenlock: technomancy: but plist!

21:44 a|i: for uploading a java jar to clojars, do I have to create project.clj?

21:44 cjfrisz: Try this once again...Can you do rest argument destructuring in ClojureScript?

21:45 dnolen: cjfrisz: yes

21:45 technomancy: Frozenlock: the fact that plists are actually the best choice in many cases tells you how sad things are

21:45 dnolen: cjfrisz: all destructuring is supported

21:45 Frozenlock: ChongLi: Oh right, I remember seeing this with as an example with `filter'

21:45 cjfrisz: dnolen: damn...then it must somehow be *my* fault ;-)

21:45 dnolen: thanks

21:46 technomancy: Frozenlock: most elisp functions only work on lists too, so even something that should be as simple as using vectors means rewriting half your codebase

21:46 Frozenlock: technomancy: True... In my case it wasn't so bad, I only had 10s or 100s of elements, but that would never scale...

21:46 technomancy: don't get me started on the nightmare of lisp-2

21:46 S11001001: technomancy: just use the cl sequence functions :)

21:47 hiredman: technomancy: surely switching from lists to vectors just means switching from the elisp list module to the vector module

21:47 cause of elisp's great module system

21:48 technomancy: hiredman: you could have a shining career ahead of you in comedy

21:48 so the changes in clojure 1.5 to speed up multimethods only make a difference for concurrent calls to the same method, right?

21:49 hiredman: technomancy: hard to say, in theory uncontended locks are cheap, but that may just be theory

21:49 dnolen: cjfrisz: doesn't work for protocol fns of course, but that's the case for Clojure too

21:50 hiredman: http://mechanical-sympathy.blogspot.com/2011/11/java-lock-implementations.html

21:50 the guy who did the thing

21:50 cjfrisz: dnolen: right

21:50 hiredman: the lmax disruptor?

21:51 cjfrisz: Speaking of changes in 1.5, there was a "performance enhancement" that when-first only evaluates its argument once now

21:51 technomancy: https://www.refheap.com/paste/9363 <- sloppy benchmarking of clucy on a complete indexing run of the clojars corpus

21:51 cjfrisz: ...I'm not crazy and that's a *correctness* issue, right?

21:52 technomancy: 1.5.0 brings a 1-3s improvement on a 6 minute indexing run

21:53 oddly enough the multimethod implementation is slightly slower but more consistent

21:54 hiredman: technomancy: have you tried with citerium?

21:54 technomancy: hiredman: nah; don't need anything beyond ballpark numbers

21:56 loliveira: hi, did I find a bug? (->> (range 10) (partition-all 3 0))

21:56 hiredman: interesting findings prefering ReentrantLock to synchronized there

21:56 S11001001: ,(->> (range 10) (partition-all 3 0))

21:56 clojurebot: ((0 1 2) (0 1 2) (0 1 2) (0 1 2) (0 1 2) ...)

21:56 S11001001: ,(doc partition-all)

21:56 clojurebot: "([n coll] [n step coll]); Returns a lazy sequence of lists like partition, but may include partitions with fewer than n items at the end."

21:57 hiredman: loliveira: step by 0? what behavor do you expect?

21:57 S11001001: loliveira: looks right

21:57 loliveira: hiredman: imo 0 is an invalid value to setp

21:57 S11001001: how come?

21:58 hiredman: loliveira: ok, but what should it do?

21:58 loliveira: thow an exception?

21:59 S11001001: it freezes my repl. exiting only with kill

21:59 dpick: anyone know why sorting is so much slower in clojure vs. ruby? - https://gist.github.com/4704719

22:00 technomancy: shuffling an array is much cheaper than shuffling a list

22:00 you're measuring very different operations

22:00 dpick: I've tried without shuffling as well

22:00 that was just a concise example

22:01 cjfrisz: dnolen: Had an extraneous "apply"

22:01 S11001001: loliveira: you'll get that with any infinite seq where the repl doesn't apply a print-length, though

22:01 cjfrisz: dnolen: Problem solved and cljs works as expected

22:01 technomancy: dpick: simple microbenchmarks on a JIT VM typically aren't testing the JIt

22:02 because for it to start caring enough to optimize it needs to be convinced it's a hotspot worth optimizing; typically needs 10k+ iterations

22:02 see criterium for an example of how to do it right

22:03 dpick: technomancy: that makes sense, but the use in my app is always ~10k elements

22:03 and I need a response time under 100 ms

22:03 loliveira: S11001001: but why should anybody want step = 0? Am I missing something?

22:03 dpick: would there be a better way to find top n elements?

22:04 dnolen: dpick: by removing shuffling, and using a vector instead - shuffling takes about 6ms on my machine.

22:04 S11001001: dpick: heap, implemented as prioqueue in java.util

22:04 dpick: implementing a heap seemed like overkill

22:04 technomancy: dpick: you can certainly sort at least an order of magnitude faster in clojure than ruby; if your measurements suggest otherwise they probably aren't realistic

22:04 S11001001: loliveira: totality is strongly preferred in clojure fns, as well as equivalences

22:04 dnolen: dpick: range take about 12-13ms

22:04 takes

22:04 dpick: er I mean by moving shuffling out, and timing just sorting of course

22:05 S11001001: loliveira: asking for an exception there in the 0 case is kind of like looking for ##(doc iterate) to throw in the identity case, as partition-all is just a fancy iterate

22:05 lazybot: ⇒ ------------------------- clojure.core/iterate ([f x]) Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects nil

22:05 S11001001: loliveira: welcome to clojureland btw :)

22:05 hiredman: dnolen: I imagine that also moves the lazy seq allocation out

22:06 dpick: alright, thanks for the advice

22:06 dnolen: hiredman: right, I never use shuffle, didn't think about the fact that it's lazy

22:06 hiredman: shuffle isn't, but range is

22:07 an shuffle actually pours through and ArrayList I think

22:08 loliveira: S11001001: thank you. =) i'm enjoying this new place.

22:19 a|i: I have src/foo.clj with ns foo and src/bar.clj with ns bar, when I import bar in foo, the repl cannot find ns bar.

22:32 is clojure-contrib completely deprecated?

22:33 arkx: a|i: most of it lives on as independent projects

22:34 See http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go for more information.

22:34 clojurebot: dakrone maintains clj-http

22:34 S11001001: ~contrib

22:34 clojurebot: Monolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

22:35 S11001001: :D

22:35 arkx: This will be a recurring question as long as clojuredocs.org features Clojure Contrib prominently on the front page.

22:39 a|i: a lot older projects use contrib.

22:39 and it is not obvious what happened to each project.

22:39 eg, I'm not sure what happened to http://richhickey.github.com/clojure-contrib/duck-streams-api.html

22:39 lazybot: Nooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/duck-streams-api.html and try to stop linking to rich's repo.

22:40 arkx: "clojure.contrib.duck-streams mostly migrated to clojure.java.io"

22:42 a|i: mostly?

22:43 S11001001: stuff that didn't belong was excluded

22:47 cemerick: a|i: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

22:48 oh, it's already been linked :-P

22:48 a|i: thanks anyway :)

22:48 dnolen: a|i: completely deprecated

22:52 Frozenlock: hrmph.. is there a function to read a number ("1") without using the clojure reader and having to think about security?

22:53 arkx: Integer.parseInt? :P

22:53 Frozenlock: o_O

22:53 dat java interop...

22:54 arkx: thanks by the way :)

22:54 arkx: Hehe, np

22:55 The host platform is there to be embraced.

22:56 Frozenlock: arkx: Yes and no... tried the cljsbuild crossover option recently and was really pleased to reuse my code in both the jvm and js :)

22:56 qz: Frozenlock: have you managed to reduce its compiled size? hello-world taking 700k is a bit too much..

22:57 warz: S11001001, what if i need to instantiate a class by name and have that class inherit from another class, but my other classes do not, because im in charge of instanciating them?

22:57 do you need to use aot for all of the classes, or jsut that one?

22:58 Frozenlock: qz: 700k? That must be without advanced compilation... my whole cljs code fit into a 270kb js file.

22:58 S11001001: warz: just the one

22:58 Frozenlock: And it's really not a simple hello-world example...

22:59 qz: Frozenlock: yeah, without advanced compilation..

22:59 Frozenlock: Oh in that case.. at simple compilation it fits in 2mb :)

23:00 dnolen: Frozenlock: wow, sounds like a sizeable CLJS app

23:00 Frozenlock: dnolen: not so big... I'm probably just bad at writting it.

23:02 https://bacnethelp.com if you want to take a look. Every JS there is cljs (except for an external library).

23:03 dnolen: qz: the smallest footprint you will see w/ advanced compilation on hello world is ~100k, ~20k gzipped.

23:03 Frozenlock: cool

23:07 qz: anyone uses lein repl? i'm unable to make arrow keys work there (last/next command choosing) - it thinks i'm pressing Ctrl+R instead of arrow..

23:09 S11001001: qz: try C-p/C-n instead of arrows

23:11 qz: S11001001: it worked. now i wonder why arrows do not work..

23:17 kaoD: ,(range 10)

23:17 clojurebot: (0 1 2 3 4 ...)

23:26 jonasen: dnolen: I added a patch that reverts CLJS-455

23:27 dnolen: jonasen: great thanks

23:34 jonasen: btw, I think I finally have an idea how to do the structure matching on sequences you've been asking

23:45 cjfrisz: Well, I drew a blinky light in a web browser

23:45 I'm gonna call that an achievement and go to bed

23:51 TimMc: Congratulations, you made a black triangle!

23:53 durka42: do we have any incanter pros in the house?

Logging service provided by n01se.net