#clojure log - Jul 24 2011

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

0:06 amalloy: do we have a print-stack-trace function somewhere? ie, like .printStackTrace but respecting *out*

0:09 appparently it's in clojure.stacktrace. shocking

0:36 hiredman: anyone used http://code.google.com/p/reflectasm/? I wonder if there are any glaring problems with it, might be nice faster replacement for java reflection in clojure.lang.Reflector

0:37 clojure's repackaging of asm is kind of a drag here

0:42 amalloy: hiredman: do source files full of tab characters count as glaring problems?

0:43 hiredman: not if I don't have to edit them

0:43 metajack: Is there a clj->js in Clojurescript? I'm trying to pass a map to a JS library

0:44 hiredman: but I guess I would if I wanted it to use the asm that comes with clojure :/

0:52 amalloy: hiredman: i don't know a lot about classloaders, but i've heard that one basic rule is "you must delegate to your parent classloader before trying to do something yourself", and if you don't things will have mysterious problems. i notice that the reflectasm doesn't do that

0:53 gstamp: anyone use durendal.el? I'm wondering how to set the default port.

0:57 nevermind. I think I have it sorted out

0:58 hiredman: ClassLoaders: They're Funky

0:58 amalloy: srsly

1:01 hiredman: I think reflectasm's classloader is only ever used to load the generate class that calls the methods

1:01 it's interesting that the whole thing weighs in so small

1:02 (not counting asm I guess)

1:03 amalloy: hiredman: it tries to do some funky stuff like setting all methods accessible if it can

1:03 i mean, i imagine it works. but reflectasm breaks the only rule i actually remember, and it also overrides a method that the javadoc for classloader says they'd prefer you not override

1:04 so i'd want to do some research before using it

1:04 hiredman: right

1:05 I am not too concerned, I mean given the shuffling around clojure already does with classloaders

1:54 metajack: Any idea what this error could mean in cljs? Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :-compile of protocol: #'cljs.closure/Compilable found for class: nil

2:49 antares_: hi

2:49 how do I address an inner Java class?

2:49 for example, in a package x.y I have classes A and B. How do I address B?

2:52 the answer is, first import x.y.A$B and then use A$B, per JVM conventions

2:52 nice

2:52 amalloy: that's not...what...conventions?

2:53 antares_: well, it is an "enforced convention" ;)

2:53 amalloy: the class's name *is* A$B

2:53 antares_: amalloy: right

2:53 amalloy: it is still a convention, how inner classes are named

2:54 amalloy: that it's an "inner" class is mostly invented by javac, and i strongly suspect that the name A$B is guaranteed by the spec, not a convention

2:55 antares_: amalloy: you are right. I believe the spec does define this naming scheme.

3:02 amalloy: antares_: found http://www.coderanch.com/t/324724/java/java/Where-inner-class-naming-scheme, fwiw. interesting reading

3:03 antares_: amalloy: ah, right. That's why I remember it, I read the whole JVM spec but the JLS was too boring for me :)

3:05 amalloy: i'll bet

3:05 though i learned relatively recently that foo(a(), b()) is guaranteed to call a before b, which is not that case in many languages

3:08 hiredman: the jvm is sort of odd compared with other stack based languages in that regard

3:11 amalloy: hiredman: is being stack-based correlated? C, for example, doesn't make that guarantee

3:11 i think it's more about the java language than the jvm

3:15 hiredman: amalloy: doing it the way the jvm does means you have to kind of box method calls

3:16 push target, push arg1, push arg2, call target.invoke(2)

3:16 vs. something like

3:17 push arg2, push arg1, push target, call.invoke(2)

3:18 amalloy: hmmmm

3:19 hiredman: the two are not actually all that different if you just treat everything as a static method with the target as the first arg

3:20 the big difference is having the pushing of the target coincident with the invoke instruction can make code generation easier

3:22 huh, OCaml does right to left too

3:23 C on x86 could be considered stack based, I mean, there are barely any registers involved

3:23 oh, I misread that sentence, OCaml leaves it unspecified

5:01 anyone using clojure.java.jdbc with derby? getting an exception when trying to run insert-records

5:03 #<SQLException java.sql.SQLException: Only executeBatch and clearBatch allowed in the middle of a batch.>

5:30 neotyk: Good morning everyone!

7:04 ahriman: i want to do (map #(my-fn %) [(all-records)]) (all-records is a fn that conj maps) and my-fn is a fn that doing smth like (defn my-fn [data] (gen-td (get data :link). But i gets ex #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn>. What should i do?

7:08 raek: first, "#(my-fn %)" is the same as "my-fn"

7:09 can you see which line the exception comes from? if you entered it through the repl you might not. then you can do (require 'your.ns :reload) and the code will have line nunbers

7:09 ahriman: ^

7:10 also, the [(all-records)] looks suspicious. are you sure it shouldn't be just (all-records)?

7:10 (assuming all-records returns a collection of things you want to map my-fn over)

7:11 ahriman: oh, and to get the stacktrace, enter (.printStackTrace *e) into the repl, if you use a bare repl

7:12 (the IDEs usually provide a more convenient or automatic way to do this)

7:13 ahriman: raek that's great, [(all-records)] was the issue! Thank u for such a detailed answer!

7:26 swarmer_ab: what is the best way to get two biggest (possibly equal) numbers from vector?

7:28 ahriman: raek no, nothing is great. getting ex "NullPointerException". something wrong with this.

7:28 and clojure.lang.LazySeq@3784b96 on a webpage on a place where output should be.

7:29 but bare repl evaluates these fns with output as it should be.

7:32 raek: would sorting it in descending order and taking the first 2 elements yield the correct answer?

7:33 swarmer_ab: isn't it very slow if the vector is big?

7:33 raek: ahriman: that is because you try to serialize the datastructure with str and not with pr-str

7:34 ahriman: raek str is using only in my-fn function, is it no good?

7:34 raek: ,(str '("this looks like" "five words"))

7:34 clojurebot: "(\"this looks like\" \"five words\")"

7:34 raek: hrm.

7:34 (pr-str ["foo" "bar"])

7:34 ,(pr-str ["foo" "bar"])

7:34 clojurebot: "[\"foo\" \"bar\"]"

7:35 raek: ahriman: it depends on what you want to turn into a string

7:36 if you want to stringify clojure data, then you want quotes arount strings etc. (str a-string) will not have the quotes, so you need pr-str in that case

7:36 ahriman: raek my code is http://paste.org.ru/?msxdqw

7:36 maybe there are some missing parentheses its ok.

7:36 raek: what type does gen-td return?

7:37 tufflax: ,(map (juxt pr-str str) ["abc" [1 2] {:a "a"}])

7:37 clojurebot: (["\"abc\"" "abc"] ["[1 2]" "[1 2]"] ["{:a \"a\"}" "{:a \"a\"}"])

7:37 ahriman: it returns html code string

7:37 raek: ,((juxt pr-str str) (lazy-seq [1 2 3]))

7:37 clojurebot: ["(1 2 3)" "clojure.lang.LazySeq@7861"]

7:38 ahriman: replacing str with pr-str results in "clojure.lang.LazySeq@fa1b87ff" =)

7:38 raek: ahriman: but then you should not get "clojure.lang.LazySeq...."

7:38 use 'str' to concatenate two strings

7:38 ahriman: http://paste.org.ru/?hf3baw there is code for gen-td.

7:38 raek: if you get "clojure.lang.LazySeq...." then one of the arguments is not a string, but a sequence

7:38 tufflax: oh, i've been using str for serializaton so far, but not had problems with it yet :P

7:38 ahriman: maybe there is an error in my logic.

7:39 raek: tufflax: you should use pr-str and read-string

7:39 tufflax: yeah now i know :)

7:39 ahriman: strange thing is that in repl all is ok.

7:40 raek: ahriman: I think the problem is in some peice of code you did not post

7:40 for example the handler function in your web app

7:41 ahriman: hm. other code is route and that's only related code to this webpage. (GET "/" request (pages/gen-rating)).

7:42 raek: ah

7:42 (map gen-record (all-records))) <-- this returns a sequence

7:42 and html calls str on it

7:43 you probably want (apply html (map gen-record (all-records))))

7:43 so the error was not in gen-records

7:43 *-s

7:44 ahriman: ^

7:44 ahriman: Can't take value of a macro: #'hiccup.core/html .

7:45 leo2007: Anyone develops for Android using clojure?

7:45 raek: hrm, do you even wrap the content in any html elements?

7:46 this is why you should not write a macro if a function could do the job, folks

7:47 leo2007: Is it ready for serious projects?

7:48 raek: ahriman: try this: (html (into [:p] (map gen-record (all-records)))))

7:48 that might not work if 'html' tries to do the work at macro expand time

7:49 ahriman: raek thanks, it works.

7:49 generates rating as it should be.

7:50 raek: you might want to read more about how you are supposed to do this things with hiccup. I don't use the library, so my suggestion might not be very ideomatic

7:52 ahriman: raek thank u. and last question - what is exactly going on with this code and why simpple (map ...) doesn't work but with apply and into all is OK?

7:55 tufflax: swarmer_ab not very slow, it's O(n log n) (or maybe it could be a little better with a lazy sort) but you need O(n) of course. But maybe you could do something like this...

7:55 ,(reduce (fn [prev new] (take 2 (sort > (concat prev [new])))) [] [1 29 9 4 10])

7:55 clojurebot: (29 10)

7:55 antares_: hey guys. How do I do "continue" in the try/catch block in Clojure?

7:58 ahriman: and why there is such html code http://paste.org.ru/?tr9cr2 with so much slashes??

7:58 tufflax: ,(reduce (fn [prev new] (take 2 (sort > (conj prev new))) [] [1 29 9 4 10])

7:58 clojurebot: EOF while reading

7:58 tufflax: ,(reduce (fn [prev new] (take 2 (sort > (conj prev new)))) [] [1 29 9 4 10])

7:58 clojurebot: (29 10)

7:58 tufflax: maybe better

8:00 swarmer_ab: thanks

8:04 kumarshantanu: Hi

8:05 the-kenny: Any tips on how to integrate clojurescript into a leiningen project? I need something like :dependencies [[clojurescript ..]] and "lein clojurescript" :)

8:05 kumarshantanu: Is there a way to set! a private variable in a Java object?

8:05 the-kenny: I know it's very early, but nonetheless

8:05 raek: ahriman: I just read the readme for hiccup (https://github.com/weavejester/hiccup) it says that: "If the body of the tag is a seq, its contents will be expanded out into the tag body. This makes working with forms like map and for more convenient."

8:05 so you are supposed to write [:p (map ...)]

8:07 ahriman: well, it looks like hiccup is not built to accept sequences at this place: (html <here>)

8:07 ahriman: raek ok, but what about slashes? it leads to spmething like 1" " 2" " 3" ".

8:10 so all of attributes of html tags are going away.(

8:13 raek: ahriman: so why? because you are not using the library as the authors indended to.

8:13 ahriman: backslashes?

8:13 ahriman: yep

8:14 raek: you want to have a \ character in a string?

8:15 ahriman: no, i want to render it adequately, not as i mentioned above (with many of ") and with attributes, because not all, but many attributes of html tags are dissapeared

8:19 raek: ahriman: I'm sorry. I don't understand what result you get.

8:21 all you said was that slashes in some way "leads" to this sequence of strings (with unmatched quotes): 1" "<tab character>2" "<tab character>3" "

8:21 ahriman: raek http://disk.tom.ru/rfgyeku/1/ab82a/Clipboard-1.png

8:21 . \"title"\ is what i get as a link.

8:23 <a href=\"link2\" .

8:23 raek: also, did you revert the pr-str back into str?

8:23 ahriman: omg, not.

8:23 thanks, now all is ok.

8:23 raek: (cause it turned out that using str instead of pr-str was not the issue)

8:24 ahriman: i don't even thought that pr-str can invoke such a problem.

8:24 now every morning i will study two or three functions from api.

8:25 raek: it is used to serialize clojrue data. strings will have quotes and quotes inside them will be scaped

8:25 *escaped

8:25 ahriman: ah, understand.

8:26 raek: "clojure.lang.LazySeq...." is a common symptome of using str instead of pr-str, but in your case something else was the problem

8:26 and str was correct

8:29 ahriman: is it possible to develop commercial applications with clojure? this is a question that asks my chief/

8:30 raek: there is nothing in the language that stop you from doing it :)

8:30 but your boss is probably looking for something like this http://dev.clojure.org/display/community/Clojure+Success+Stories

8:31 ahriman: 10x :)

8:39 tomoj: ahriman: possible? demonstrably so.

8:46 gfrlog: if I created a record one of whose fields is a reference type, have I violated the entire spirit of records?

8:46 s/created/create

8:46 lazybot: <gfrlog> if I create a record one of whose fields is a reference type, have I violated the entire spirit of records?

8:48 tomoj: not necessarily. it's not necessarily a good idea either :)

8:48 raek: gfrlog: not more than if you would put a reference inside an ordinary map, IMHO

8:48 the record is still a persistent container

8:49 gfrlog: it's not even for threaded things. I just want mutable state :/

8:49 for some reason this particular problem is making me think only of classic OOP solutions

8:50 raek: if state is essential to the application, then by all means use the reference primitives

8:51 gfrlog: yeah I'm probably worrying too much

10:04 triyo: I'm having a strange problem with ClojureScript when calling the goog.net.XhrIo/send static method. Here is my code: https://gist.github.com/1102641

10:05 My callback function is an anonymous Clojure function that looks like this: #(dom/replaceNode (dom/htmlToDocumentFragment (.getResponse (.target %))) essay-el))

10:07 The strange result is that the response from (dom/htmlToDocumentFragment (.getResponse (.target %))) is a String: "function (){try{return this.a&&this.a.response}catch(a){return E(this.e,"Can not get response: "+a.message),i}}"

10:08 It just seems to be an unevaluated JavaScript function. Anyone have an idea why this would happen?

10:10 I did check the *returned* payload for the send method execution and it has exactly the right data. (Returned data is an HTML fragment btw)

10:15 I'm wander if this is the expected behavior based on that maybe I'm doing some wrong or if it is a bug.

10:15 *wandering

10:43 argvader: I may have a noob question - I am a noob with clojure but I get an error running my application if i dont clean first

10:43 i am using lein clean, run

10:44 if i dont clean then i get an ExceptionInInitializerError - anybody seen this?

10:44 gfrlog: argvader: you have to clean every time even when you don't make any changes?

10:45 argvader: yeah

10:45 gfrlog: nope, never seen that. I don't use `lein run` though

10:45 argvader: i even get it using compile

10:46 theignorati: when doing (classname/staticfield) how would I use a symbol instead of staticfield?

10:46 gfrlog: I could imagine that kind of thing happening if there was something wrong with your project.clj

10:46 argvader: ok i will look into that

10:46 thanks

10:46 gfrlog: theignorati: reflection? :/ what brings you into that sad state of affairs

10:47 ?

10:48 theignorati: err I want to pass the name of a field in a static class to a function

10:48 one of these fields: http://download.oracle.com/javase/1.4.2/docs/api/javax/sound/midi/ShortMessage.html

10:49 gfrlog: if it were me I'd probably pre-process it into a map (using reflection if necessary)

10:51 theignorati: right

10:51 gfrlog: ,(.getFields BigInteger)

10:51 clojurebot: #<Field[] [Ljava.lang.reflect.Field;@da52a1>

10:52 gfrlog: ,(seq (.getFields BigInteger))

10:52 clojurebot: (#<Field public static final java.math.BigInteger java.math.BigInteger.ZERO> #<Field public static final java.math.BigInteger java.math.BigInteger.ONE> #<Field public static final java.math.BigInteger java.math.BigInteger.TEN>)

10:54 gfrlog: ,(->> BigInteger .getFields seq (map (juxt #(.getName %) #(.get % BigInteger))) (into {}))

10:54 clojurebot: {"ZERO" 0, "ONE" 1, "TEN" 10}

10:54 gfrlog: theignorati: ^ looks like that works

10:54 theignorati: cheers

10:54 what does ->> do?

10:55 ill read the docs

10:55 gfrlog: theignorati: it's a threading macro. e.g., (->> BigInteger .getFields seq) turns into (seq (.getFields BigInteger))

10:56 ,(->> BigInteger .getFields seq (map (juxt #(-> % .getName clojure.string/lower-case keyword) #(.get % BigInteger))) (into {}))

10:56 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string

10:56 gfrlog: dang

10:56 I was trying to turn the keys into lower-cased keywords

10:56 ,(->> BigInteger .getFields seq (map (juxt #(-> % .getName .toLowerCase keyword) #(.get % BigInteger))) (into {}))

10:56 clojurebot: {:zero 0, :one 1, :ten 10}

10:56 gfrlog: like that

10:57 one more expression to replace underscores with dashes and we're golden...

10:58 ,(->> BigInteger .getFields seq (map (juxt #(-> % .getName .toLowerCase (.replaceAll "_" "-") keyword) #(.get % BigInteger))) (into {}))

10:58 clojurebot: {:zero 0, :one 1, :ten 10}

10:58 gfrlog: no difference in this case of course

11:02 theignorati: this here is a general version: https://gist.github.com/1102703

11:03 theignorati: thanks :)

11:04 gfrlog: no probalo

11:36 bobnormal: hey, what's the ("a" "b" "c") -> "abc" function again?

11:36 gfrlog: clojure.string/join?

11:36 clojurebot: you mean clojure.main

11:37 bobnormal: ta. drives me nuts learning this language, but i love it :)

11:37 gfrlog: $findfn ["a" "b" "c"] "abc"

11:37 lazybot: [clojure.string/join]

11:37 gfrlog: clojurebot: what's wrong with you?

11:37 clojurebot: No entiendo

11:37 mdeboard: ,(apply str ("a" "b" "c"))

11:37 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

11:37 mdeboard: ,(apply str '("a" "b" "c"))

11:37 clojurebot: "abc"

11:37 gfrlog: ,(apply str ["a" "b" "c"])

11:37 clojurebot: "abc"

11:37 mdeboard: that too

11:37 gfrlog: bobnormal: so that's a more specific way, if you're not interested in a separator

11:38 mdeboard: (apply str (interpose ":" ["a" "b" "c"]))

11:38 ,(apply str (interpose ":" ["a" "b" "c"]))

11:38 clojurebot: "a:b:c"

11:38 gfrlog: hrmph.

11:38 bobnormal: apply str and reduce str both work, but apply str = less chars .. looks like i just levelled-up in codegolf ;)

11:38 mdeboard: :')

11:39 kephale: ,(clojure.string/join ":" ["a" "b" "c"])

11:39 gfrlog: bobnormal: apply might be more efficient too

11:39 clojurebot: java.lang.ClassNotFoundException: clojure.string

11:39 gfrlog: at least it has the potential to be

11:42 bobnormal: gfrlog: thanks, but i'm FAR too n00b to worry about efficiency yet

11:42 gfrlog: very good

11:43 kephale: is there a more up-to-date bot in here?

11:43 gfrlog: &(clojure.string/join ":" ["a" "b" "c"])

11:43 lazybot: ⇒ "a:b:c"

11:43 kephale: gfrlog: aha, ty

12:14 mdeboard: I like the string/join syntax better to be honest

12:15 ahriman: ÷¸

12:15 devn: stop golfing, before golfing stops you. ;)

12:15 ejackson: than devn :)

12:15 s/than/thanks

12:15 lazybot: <ejackson> thanks devn :)

12:16 devn: we have another bot in here now?

12:17 ah, nevermind, sexpbot got renamed

12:29 What happens when you accidentally past some code into your pianobar (command line pandora) client?

12:30 Well if you're like me, you get a station named "ns a lazy seq of nums from start (inclusive) to end" that is /actually/ Luke Vibert.

12:32 * ejackson wanders over to take a listen....

12:32 ejackson: he seems to be a snare drum

12:57 StayInSkool: how come set takes in a sequence but sorted-set takes in arguments?

13:22 ahriman: using with compojure 0.6.4 route (GET "/greet/:name" (str "Hello " (params :name))) and receiving error "unsupported binding form". what is it?

13:22 got code from http://en.wikibooks.org/wiki/Compojure/Core_Libraries

13:28 solved

14:00 maacl: Has anyone been able to compile the Convex Hull ClojureScript demo? (http://jng.imagine27.com/articles/2011-07-23-101007_clojurescript_demo_convex_hull.html)

14:08 dnolen_: anyone know much about AVL trees here?

14:14 jcromartie: since it's a wiki book, can we fix it?

14:14 grantm: i want to start up a webserver in a separate thread, and then have a function i can call to kill that thread. i got as far as (.stop Thread) but apparently that's deprecated and the wrong way to go about it. can someone point me in the direction of the right way?

14:16 jcromartie: (def server (... code to start server))

14:17 (.stop server)

14:18 grantm: but starting the server will block, so i can't just go (server) in the repl because then i'll never be able to type (.stop server)

14:19 jcromartie: geez that wikibooks page on compojure should just be deleted

14:20 ahriman: wikibooks is old :(

14:22 jcromartie: although it was originally written by weave

14:22 grantm: (future (start-server)) is, like, 80% of what i want. i just want something like future-kill

14:30 maacl: Has anyone been able to compile the Convex Hull ClojureScript demo? (http://jng.imagine27.com/articles/2011-07-23-101007_clojurescript_demo_convex_hull.html)

14:33 grantm: found an answer to my problem! for posterity: http://stackoverflow.com/questions/2706044/how-do-i-stop-jetty-server-in-clojure

15:06 gfrlog: is it plausible that (spit) might not touch the file's timestamp?

15:36 maacl: gfrlog: no, that is not possible

15:38 gfrlog: turns out my issue is low resolution on the timestamp (1 sec)

15:50 raek: I wonder if it would be possible to make a browser plugin that could work as the development environment for ClojureScript

15:50 so that we can use the browser JS engine instead of Rhino

15:51 that way it might be possible to test stuff like paining on a canvas in the dev repl

15:51 gfrlog: what from java does the CS compiler require?

15:52 raek: the CS compiler is a Clojure lib

15:52 so it requires Clojure

15:52 I was thinking of taking the output from the compiler and send it to the browser

15:52 gfrlog: perhaps more to the point, is CS-in-CS implausible for some reason, or just a lot of work?

15:53 raek: instead of letting Rhino eval the result, let the browser do it

15:54 gfrlog: java applet?

15:55 raek: maybe the clojure side could start a http server, which the browser can query

15:55 ibdknox: just do it over websockets

15:55 gfrlog: that sounds like the easiest route

15:55 ibdknox: stream the JS to a page

15:55 raek: basically, we just need some communication channel between the compiler and the browser

15:56 gfrlog: and stream the CS back to the server

15:56 ibdknox: yep

15:56 it'd be fairly easy to do I would think

15:59 hugod: swank-js could probably be converted to clojurescript…

16:03 qbg: I wonder what the CS compiler needs that CS doesn't currently have

16:06 gfrlog: is the gclosure compiler written in JS or Java?

16:06 i suppose it's not strictly necessary...

16:06 chouser: raek: great idea. I've got a cljs compiler-as-a-service nearly ready to go

16:06 gclosure is a java lib

16:07 qbg: (inc chouser)

16:07 lazybot: ⟹ 1

16:07 gfrlog: but clojurescript doesn't need it, right?

16:07 qbg: compiler as a service should in theory make a web-based repl possible

16:08 chouser: qbg: that's my actual goal

16:08 gfrlog: correct

16:09 qbg: Just add a web server to the mix and you could make ajax calls to get the compiled code

16:09 chouser: I had it working for my old ClojureScript, though with the compiler in an applet rather than on a server.

16:10 qbg: It would be like jstestdriver, but the other way around

16:10 hugod: swank-js uses node.js and socket.io to talk to the browser

16:17 qbg: Is there any reason why CS doesn't implement the STM for compatibility?

16:18 raek: javascript does not have threads

16:19 well, maybe some frameworks add support for threads, but it's not in the language as in Java

16:23 nickik: One could implment the refs just as atoms that would make it easy to make libs compatibel

16:48 grantm: is there a builtin for what's in other languages a if/elseif/elseif construct?

16:48 alandipert: grantm: see cond and condp

16:49 grantm: alandipert: hmm... cond isnt exactly what i want - let me see if i can clarify

16:51 better question: is there an idiomatic way to return the first non-nil form

16:52 raek: grantm: or

16:52 grantm: haha ... thanks

16:52 raek: ,(or nil nil false 4 "foo")

16:52 clojurebot: 4

16:52 grantm: yeah

16:53 thanks :)

17:00 * raek is trying to fiddle with ClojureScript

17:00 raek: is it possible to use the ns form at the repl?

17:16 gfrlog: converting a byte-array to a hex-string shouldn't be this hard :(

17:39 qbg: Rich comes up with the best stuff: "ClojureScript is an action movie, and we're interested in helping people kick butt."

17:40 technomancy: does anyone have a good solution for gmail killfiles?

17:41 it's easy enough to just blacklist ken wesson and james keats, but replies from non-trolls still get through

17:41 amalloy: technomancy: use imap and a mail client with killfiles?

17:41 technomancy: I guess their name would still exist in the body of the reply

17:41 amalloy: I do, but I read gmail on my phone as well as my laptop

17:41 and I'd like the rules to apply even when my laptop is off

17:41 amalloy: alas

17:42 technomancy: applying the killfile to the body seems a bit excessive, but at this point I'm ready to try it

17:48 aw geez; almost forgot mike meyer

17:54 I just need to be able to rely on other folks to clue me in in the unlikely event that there's a relevant conversation on the mailing list involving them.

17:55 amalloy: technomancy: every time i get a message from one of them, i'll forward it to you just in case it's relevant

17:56 ejackson: careful amalloy, i really worry that technomancy could go affect a rule 24 (charlie stross style) if pushed

17:56 clojure would be a good choice for that :)

17:56 34.... bah

17:58 ftod: http://en.wikipedia.org/wiki/Rule_34_%28novel%29

18:00 what a mess, honestly.

18:10 amalloy: huh. i guess i don't understand the macro story for cljs. there seem to be no macros in core.cljs, and it relies on macros defined in cljs/core.clj. are macros not implemented for cljs?

18:11 raek: I heard from the talk that macros run in clojure

18:11 ejackson: ditto

18:13 mjg123: WARNING: Use of undeclared Var bfcoins/defmacro

18:14 which is to say that macros don't seem to work in cljs

18:17 amalloy: it's too bad rich "wasted" one of his rare appearances on the mailing list for this silly thread

18:42 alandipert: amalloy: macros are written in clojure

18:42 (there is no cljs defmacro)

18:43 hugod: I'm not sure if this is useful, but https://gist.github.com/1103191 will let you run the cljs compiler every time a .cljs buffer is saved in emacs

18:43 amalloy: alandipert: right, but i don't really understand what that means. if i'm writing a cljs app with some repeated code i want to factor out, i have to...somehow step out of cljs and back to clj, to define a macro i can use in my cljs?

18:45 glob157: Not sure about how "let" works... used to let in python (just offers some output to the calling function) ?

18:45 amalloy: &(let [x 1] (+ 3 x))?

18:45 lazybot: ⇒ 4

18:46 hugod: a pom file for cljs https://gist.github.com/1103202, which depends on a jar for the closure-library, which can be built with https://gist.github.com/1103200

18:46 glob157: so what is the need for the let ?

18:47 ejackson: glob157: it provides a scope within which variables are bound

18:47 glob157: seems unnecessary, why not just declare the variable.

18:47 amalloy: glob157: that's how you declare a variable

18:47 glob157: oh ok i think i get it thanx

18:48 let is the syntax required for declaring variables INSIDE of a function.

18:48 ?

18:49 seems kind of strange though--- let is kind of verbose , dont you think ? why not just x = 2

18:50 instead of let [x 2]

18:50 amalloy: because we're writing lisp, not c

18:51 "x = 2" further implies that you could reassign x later, which you can't

18:52 glob157: @amalloy haha touche (first comment)

18:52 theignorati: if you do (let [a 1 b 2 c 3] it's less verbose than c

18:52 amalloy: plus "x = 2" kinda has to be bounded by punctuation of *some* sort. c uses semicolons for that

18:52 python chooses to make whitespace semantically meaningful, which would be disastrous in an expression-oriented language

18:52 glob157: for (int i = 0 ; i < s ; i++) {printf("clojure is not C");

18:53 mjg123: }

18:53 alandipert: amalloy: right, and your clj file with your macros should be on the compiler's classpath

18:53 amalloy: see https://bitbucket.org/puffnfresh/clojurescript-timeout-cps/src for an example

18:54 amalloy: ah, require-macros. okay, fair enough

19:00 mjg123: I've a macro, sort of like (time) except it returns the time taken rather than printing it

19:01 the implementation of how to get the current time has to depend on whether I'm on top of JVM of JS

19:01 what's a good way to wrap that up?

19:03 grantm: is there an easy way to concat two regexes, for example (regex-concat #"a" #"b") => #ab?

19:05 amalloy: grantm: it isn't really meaningful as a plain concat. someone (cgrand?) has a library for less-terse, more-composable regexes

19:05 grantm: what do you mean by meaningful?

19:05 amalloy: grantm: suppose the first regex were #"foo|test"

19:06 grantm: oh i see.

19:06 amalloy: or had capturing groups

19:06 but https://github.com/cgrand/regex might be what you want; i haven't tried it

19:06 grantm: that makes sense

19:06 as an alternate solution, is there support for raw strings?

19:07 i dont think i need a whole library :)

19:07 (at least i hope not... what i'm doing is pretty simple)

19:07 amalloy: sure. java has that

19:07 &(re-pattern (str "a" "b"))

19:07 lazybot: ⇒ #"ab"

19:08 grantm: right, that's what i switched to

19:08 it's a little annoying that i have to change all my \s to \\s but i'll manage

19:08 :)

19:09 amalloy: &(str #"\s")

19:09 lazybot: ⇒ "\\s"

19:09 grantm: ooh. oh neat!

19:09 feels a little hacky..?

19:09 amalloy: well you're hacking, so...

19:10 $javadoc java.util.regex.Pattern toString

19:10 lazybot: http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#toString()

19:10 grantm: (so i guess you can go about concating regexes like (re-pattern (str (str re-1) (str re-2))) ...)

19:10 amalloy: grantm: the extra strs are unnecessary

19:10 &(re-pattern (str #"\s+" "\d*"))

19:10 lazybot: java.lang.Exception: Unsupported escape character: \d

19:10 amalloy: &(re-pattern (str #"\s+" #"\d*"))

19:10 lazybot: ⇒ #"\s+\d*"

19:11 grantm: oh cool

19:11 thanks!

19:11 that's just what i need.

19:11 amalloy: anyway, Pattern.toString is defined to return a string that you could compile and get back the same regex

19:12 so if you feel the usefulness outweighs the grossness, knock yourself out

19:12 grantm: haha

19:13 glob157: Is there a less verbose way to create statefull variables than (def/ref) combinations?

19:14 (if not, can someone elucidate the added value of the varbosity (i assume this is related to lisp statelessness))

19:15 amalloy: glob157: stop doing it. you think you need state, but you don't

19:16 (disclaimer: not always true, but always good advice for someone just learning the syntax)

19:17 glob157: oh, you mean, def/ref are rightfully "salient"... i.e. they aren't supposed to be taken lightly.

19:17 or used commonly.

19:17 grantm: glob157: you may find it useful to explain why you need state

19:17 glob157: this is helping me.

19:18 thanks guys . Its been a while since i did any FP....

19:18 State is required for applications with users or outputs.

19:18 (just for arguments sake....)

19:19 is "alter" also a bad idea ?

19:19 amalloy: glob157: haskell manages with no stateful constructs at all. clojure is a bit more forgiving

19:19 grantm: well, you can get output with println ;) be more specific?

19:20 amalloy: grantm: well, as the saying goes, a program with no side effects just heats up your cpu

19:20 mjg123: a warm room is a side-effect :)

19:20 amalloy: it's not crazy to claim that side effects are a kind of state, though i do think it's clouding the picture for no real goal

19:21 grantm: that's true :)

19:23 say i have ["1" "2"] and want to destructure it and parse the ints - is there an idiomatic way to do that?

19:24 amalloy: &(let [[a b] (for [x ["1" "2"]] (Integer/parseInt x)))

19:24 lazybot: ⇒ nil ; Adjusted to (let [[a b] (for [x ["1" "2"]] (Integer/parseInt x))])

19:24 amalloy: oh, and then of course you have to use a and b

19:24 grantm: cool, that makes sense

19:26 mjg123: Change "Integer/parseInt" to "* 1" if you're in cljs

19:28 * technomancy whimpers

19:29 ejackson: you thought he was done ?

19:30 hiredman: ,*clojure-version*

19:30 clojurebot: {:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"}

19:30 * hiredman queues ominous music

19:30 hiredman: ques

19:31 I guess it is 'queues'

19:36 glob157: how come its okay to "nest" code inside of let ? i.e. (let [past-visitor (@visitors username)]

19:37 more appropriate question : why does let take two args..? why not just take in the bindings? no need for an expression.

19:38 dnolen_: fun, strongly terminating purely relational assoc, https://gist.github.com/1102865

19:39 amalloy: glob157: i think your two questions answer each other?

19:44 powrtoc: Is there an implementation of a sorted vector / array / list datastructure in clojure?

19:44 I know we have sorted-set and sorted-map

19:45 ejackson: bollocks, who let it become 1am. i'm off.

19:47 * amalloy maliciously advances ejackson's clock

19:51 technomancy: hiredman: cueues?

19:51 err--cues?

19:56 amalloy: queues

19:57 powrtoc: Yeah, I guess I really need a priority queue ... are there any persistent ones implemented for clojure yet? What about finger-trees?

19:59 pdk: http://code.google.com/p/jc-pheap/

19:59 contrib also has priority-map

20:04 zakwilson: If I'm not doing load balancing or anything of that sort, is there a good reason to have something like Apache or nginx sit in front of ring/jetty?

20:07 amalloy: zakwilson: we do that so we can have additional servers running that know nothing about jetty

20:08 zakwilson: amalloy: well, yes. Assuming that isn't a consideration.

20:09 amalloy: your question seems to summarize as: "assuming there are no reasons to use nginx, is there a reason to use nginx"

20:09 (that is, "anything of that sort" is not defined well enough to answer)

20:10 zakwilson: I guess the question is: are there security or performance problems inherent in exposing ring/jetty directly to the web?

20:12 seancorfield: looking at clojure.test it doesn't appear that there's any way for a fixture function to be able to inspect the metadata of an actual test?

20:13 i was hoping to be able to annotate tests to allow for optional behavior in the fixture...

20:14 hiredman: seancorfield: you can create a test that reruns tests in a different context kind of thing

20:15 seancorfield: yeah, i was hoping for something a bit cleaner than that :(

20:15 hiredman: we do something like that combined with test selectors at work

20:16 seancorfield: i may end up using test-ns-hook and running the tests that way

20:17 or breaking the tests into multiple namespaces

20:17 real shame that fixtures aren't passed the test var as well as the test fn

20:17 or at least the :each fixtures

20:17 hiredman: lein test selectors

20:18 seancorfield: this has to run in maven - it's clojure.java.jdbc :)

20:18 i've repro'd the apache derby failure

20:18 hiredman: I've fixed in clojurebot by jsut re-defing the function in question to what I need for derby

20:24 powrtoc: what's the best idiom for reduce-until? i.e. I want the reduce to return when a condition is met, and not consume the remaining seq?

20:25 seancorfield: given that .executeBatch fails on SQL Server and PostgreSQL and .executeUpdate fails on Derby (but works on every other DB tested so far) for that use case makes this a tricky bug :)

20:25 Scriptor: powrtoc: maybe a reduce on a take-while?

20:25 powrtoc: Scriptor, was just thinking that... hmmm

20:27 Scriptor, actually that doesn't work... because it's the accumulation value that I need to test on

20:28 ahh I think I can use reductions

20:28 then test on that

20:28 with a take-while

20:37 amalloy: right

20:37 i guess i was afk, but reductions

22:23 seancorfield: hiredman: looks like i have a fix for apache derby with clojure.java.jdbc

22:23 * seancorfield wish i'd written the test suite when i'd started :)

22:45 leeda: Hi, anyone know what's wrong with this simple function? I get a "java.lang.IllegalArgumentException: Key must be integer" error: https://gist.github.com/5e181362ead42965e1fd

22:45 hiredman: ,([] :foo)

22:45 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>

22:46 leeda: but user is a map

22:47 hiredman: *shrug*

22:47 leeda: hm

22:47 hiredman: somewhere you are calling a vector as a function with a non-number argument

22:54 leeda: yeah you were right, i found the problem. it was in a different function.

23:14 darevay: Hi. Anyone ever notice slurp adding an extra newline at the end when reading from a resource? Clojure 1.2.0.

23:14 hiredman: have you looked at what you are slurping in a made sure there is no extra newline there?

23:15 darevay: Yeah. It's a single line file with no newline. If I add a newline, then I get two newlines.

23:16 hiredman: are you sure?

23:18 darevay: No :) I'll try in a smaller test and come back if it's still a problem. Just checking.

23:18 hiredman: what does wc -l say for whatever you are slurping in?

23:18 0 means no newlines

23:21 darevay: User error. For some reason vim betrayed me. Sorry to waste your time.

23:23 On the bright side I learned something new about vim tonight.

23:43 technomancy: cron will screw you over silently if you have files that don't end in newlines

23:56 argvader: anybody used the form-dot-clj project?

23:56 i am getting an error and i think its part of a macro within that library but I really dont know macros yet

23:58 is this an ok last statement for a macro `(def ~field-namve ~field)

23:58 it appears to have 2 namespaces when i expand it and i think this might be causing a no matching ctor error

Logging service provided by n01se.net