#clojure log - Aug 15 2010

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

4:00 LauJensen: Good morning all

8:00 rdsr: Can I type hint the protocol methods so that the methods in generated interface does not have Object as the argument type?

8:42 Bahman: Hi all!

8:50 no_mind: hi

8:54 emh: rdsr: I googled for that earlier this week, found http://www.listware.net/201006/clojure/44571-protocol-type-hints-java-interface.html

8:54 rdsr: emh, oh cool thks

8:55 emh, I tried adding type hints but the generated interface contains only objects as types

8:57 emh: rdsr: yes, according to the thread seems like you have to use definterface to get non-Object types

8:58 rdsr: thks emh

9:39 Licenser: cookies?

9:40 woooh it's working!

9:41 now that I can talk again I wanted to say it's amazing how well clojure works with jpcap

9:51 defn: Licenser: Did you give me permission to port lein-search to cake?

9:52 Licenser: defn: it is open source :) you don't need my permission

9:52 defn: It's polite to ask :)

9:52 Also, does anyone know if java-utils was renamed for 1.2.0?

9:52 is it just .java now?

9:52 specifically im looking for (as-file ...)

9:53 Licenser: defn: heh

9:53 * defn needs to memorize this list of renamed contrib libs

9:53 defn: I keep forgetting which were changed and to what

9:57 Licenser: wow my knowledge about TCP IP is rusty :(

9:57 defn: Licenser: im sure you'll pick it up-

9:57 Licenser: defn: it can take a while, it's non trivial sadly

9:58 and too well documented

9:59 defn: Licenser: know anything about protocol buffers?

9:59 Licenser: the google protobuf ting?

9:59 defn: yeah

9:59 im curious why it's so efficient

9:59 it just looks like kv pairs

10:00 Licenser: defn: because it's binary compiled

10:01 defn: Licenser: ah -- i found an interesting clojure library that allowed you to do them easily in clojure as your serialization format

10:01 Licenser: *nods*

10:01 I know

10:01 captured with clojure: http://gist.github.com/525514

10:02 defn: ha! interesting coincidence

10:04 Licenser: now I wonder how can I make out the TCP stream from that :(

10:21 gfrlog: can an agent ever have more than one error?

10:30 ,(* 3 3)

10:30 clojurebot: 9

10:51 Licenser: awsome I can follow TCP Streams now :D

10:57 technomancy: defn: as-file is just clojure.java.io/file now

10:59 LauJensen: Licenser: What are you working on ?

10:59 Licenser: LauJensen: jpcap & clojure

10:59 LauJensen: Yes - I mean from a highlevel POV - What kind of applicaton ?

10:59 s/applicaton/application/

10:59 sexpbot: Yes - I mean from a highlevel POV - What kind of application ?

11:01 Licenser: LauJensen: oh well I want some network debugging

11:01 LauJensen: Ok

11:01 Licenser: think of a wireshark specialized for my usual problems

11:01 also I'm still in the testing stage :)

11:02 LauJensen: Wireshark has been good to me in the past, would be interesting if you came up with something like it

11:02 Licenser: LauJensen: it has been to me too, for now I want a somewhat compfy lib to handle basic cases :P

11:02 LauJensen: Can you give some examples of what you're targeting?

11:05 Licenser: (backgrond-capture-streams streams open-en1) => streams keeps an up to date list of TCP streams on en1

11:05 where open-en1 is a capture interface I opened and strems is an (atom {})

11:06 in general I hope for a tool to debug SIP, since it's part of my day job and it'd be way cooler then whireshark :P

11:07 LauJensen: Ok

11:08 Licenser: but that is a long run thing :P for the moment I am glad to play with package capturing ^^

11:08 since I've my doubt that I'll ever manage to finish the entire project

11:14 LauJensen: Yea I understand- Its amazing how fast you can get work done, once you get paid for it

11:32 Licenser: LauJensen: yea my problem is I ain't :P

11:32 LauJensen: Yea I figured

11:33 Licenser: which is quite sad since I bet we could use a program like that

11:35 defn: technomancy: thanks

11:35 technomancy: is this documented anywhere besides notes on a commit?

11:36 technomancy: defn: there was a mailing list thread about clojure.io

11:37 defn: technomancy: oh :X I must admit the mailing list is not the best way for me personally to follow new developments

11:39 * technomancy mumbles something about "oral tradition"

11:39 technomancy: there may be more somewhere else

11:42 maybe the 1.2 changelog?

11:56 bobbytek: what's the best ide for clojure?

11:56 counterclockwise?

11:56 clojurebot: Counterclockwise aka ccw at http://code.google.com/p/counterclockwise/

12:00 Licenser: LauJensen: out of curiosity, where does your interest come form?

12:10 kensho: what is the best way to mutate a java graphics context in a thread safe way in clojure? i.e. I want to call setColor and drawRect atomically from multiple threads.

12:13 Is this possible without locks?

12:14 Licenser: kensho: I guess using agents won't be wrong

12:15 kensho: Licenser: thanks, I'll look into it

13:41 Licenser: in the slime repl what was the specal variable for the last result?

13:41 qbg: *1

13:42 Licenser: thanks qbg

13:55 LauJensen: Licenser: my interest?

13:55 Licenser: LauJensen: in package capturing

13:56 LauJensen: I was just trying to imagine what kind of project you could be working on. Last time I used it was to reverse engineer a proprietary communications protocol

14:01 ~seen etate

14:01 clojurebot: no, I have not seen etate

14:01 LauJensen: $seen etate

14:01 sexpbot: I have never seen etate.

14:01 Licenser: *nods*

14:02 LauJensen: ah :) well clojure works great for this since it's nice for stuff

14:03 wow that was a very non saying sentence :) I ment all the data mangling is really great

14:04 LauJensen: haha

14:05 Yea - Dude, I want a t-shirt with that printed

14:05 "since its nice for stuff"

14:05 Clojure is indeed, nice for stuff :D

14:05 Licenser: yes it is

14:44 LauJensen: ATTENTION PRODUCITIVTY FREAKS: Im about to wrap up my blogposts on productivity and Im looking to share some Emacs bindings that help speed things up. If any of you have some really good bindings would you mind hitting me with an msg or sending me an email with your 10 favorite bindings ?

14:48 gfrlog: Ctrl-X Ctrl-C vim

14:48 LauJensen: gfrlog: In my company that would get you fired, so dont joke like that :)

14:48 gfrlog: :-D

14:49 qbg: M-x butterfly

14:49 LauJensen: yea, butterfly is good

14:49 qbg: It flips the bits for me!

14:49 LauJensen: qbg: yea, like a bigger M-x zone-mode

14:50 qbg: M-x tetris makes you very productive ;)

14:50 LauJensen: Both of you guys scroll up, I said produtivity freaks - you sound like slackers :)

14:51 qbg: It makes you very productive at slacking off. Slacking off is hard work, after all...

14:55 Licenser: is there something like re-split?

14:56 I totally fail to find that :(

14:56 gfrlog: clojure.contrib.str-utils2/split looks promising

14:56 ,(doc clojure.contrib.str-utils2/split)

14:56 clojurebot: Pardon?

14:56 Licenser: gfrlog: thank you!

14:57 qbg: clojure.string/split

14:57 gfrlog: guess I'm not up to date on the latest organization

14:57 neither is the main site apparently

16:04 ,(nil)

16:04 clojurebot: java.lang.IllegalArgumentException: Can't call nil

16:06 alpheus: There's a *follow-redirects* in clojure-http-client ("1.1.0-SNAPSHOT"). How do I access it in my code?

16:07 Licenser: I think (set! *follow-redirects* true) or even better (binding [ *follow-redirects* true] ...your code...)

16:07 alpheus: I've tried binding, but I get an exception with the message "No such var: clojure-http.client/*follow-redirects*"

16:07 Licenser: then your intel might be outdated?

16:08 alpheus: Intel? I am looking at source with the save version number. But maybe the jar that lein downloaded doesn't match the source?

16:08 Licenser: hmm hmmm

16:08 alpheus: s/save/same

16:09 LauJensen: alpheus: (def *http-agent-defaults* (assoc *http-agents-default* :follow-redirects false)) I think.

16:09 http://github.com/clojure/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/http/agent.clj#L166

16:11 alpheus: Actually, after (ns clojure-http.client), evaluating *follow-redirects* still causes an exception. So the source I'm reading must really not match the jar, I think.

16:23 LauJensen: Do we have something in Clojure-land for producing guids ?

16:24 alpheus: dunno about clojure, but if you happen to be using Linux, there's /proc/sys/kernel/random/uuid -- just read a line from int

16:26 AFAICT, clojure-http.client doesn't use http/agent, but just uses HttpURLConnection directly.

16:28 LauJensen: ,(slurp "/proc/sys/kernel/random/uuid")

16:28 clojurebot: java.security.AccessControlException: access denied (java.io.FilePermission /proc/sys/kernel/random/uuid read)

16:29 LauJensen: tsk

16:29 Hard to get an easier UUID than that

16:30 alpheus: Yes. I replaced a few hundred lines of Ruby code with that one-liner.

16:30 LauJensen: hehe

16:30 ouch

16:47 alpheus: OK, the clojure-http.client jar and source were definitely out of sync. Proved it by loading client.clj by hand.

16:48 So I built a jar called clojure-http-client-1.1.0-SNAPSHOT.jar. How do I replace the jar called clojure-http-client-1.1.0-20100502.112537-2.jar (that's apparently out-of-date) in my project?

16:53 gfrlog: alpheus: are you using leiningen?

16:53 alpheus: yes

16:53 gfrlog: when I went to clojars I saw two versions of that library

16:54 I have [org.clojars.raynes/clojure-http-client "1.1.0-SNAPSHOT"] in my project.clj

16:54 which was the newer of the two

16:54 and included the namespace switch mentioned on the project page

16:54 maybe that's good enough for you?

16:55 alpheus: Now it's starting to make more sense.

16:56 As an experiment, I copied the jar I just built into the lib/ directory, and removed the other one. Everything's now working exactly as I'd hoped.

16:57 gfrlog: would that survive a "lein clean"?

16:57 alpheus: I obviously need to invest some time in learning how leiningen and clojars work

16:57 gfrlog: or cloning the project into a new directory?

16:57 alpheus: no, not at all. it's just a quick sanity check.

16:59 gfrlog: okeedoke

16:59 leiningen is pretty simple I think

17:00 alpheus: I'm a total newb. This is my firt attempt at a clojure program.

17:00 first*

17:00 gfrlog: are you familiar with build tools in other languages?

17:01 alpheus: sure, from Common Lisp, and make. I've looked at ant

17:21 ender403: test

17:22 kencausey: ender403: pong

17:23 kotrin: ender403: test

17:23 ender403: hello all. i'm trying to use a java library that require me to define a class with some primitive fields and a java annotation per field

17:23 i tried doing this using deftype but I also need a default constructor that takes no arguments

17:26 should I use gen-class to create a class for thsi type?

17:26 hi ken, kotrin

17:43 hoeck: ender403: right, with gen-class you can define custom ctors

17:45 ender403: hoeck, thanks. what is the syntax to add fields using gen-class?

17:45 hoeck: ender403: you can have only one single field :/

17:46 its usually called state and contains a ref

17:47 so using gen-class won't work in your case

17:48 gfrlog: is there a native closure function for getting the current time?

17:48 ender403: i'm trying to defining a class such that it will work to serialize in binary data using the preon library (http://preon.sourceforge.net/)

17:50 preon requires that I declare a simple java class with some annotations. like this class Rectangle {

17:50 @Bound private int x1;

17:50 @Bound private int y1;

17:50 @Bound private int x2;

17:50 @Bound private int y2;

17:50 }

17:50 i'd like to create a class exactly like this using clojure if possible

17:55 hoeck: sounds (currently) impossible to me doing this in clojure

17:56 genclass is missing the ability to have mutable fields, and deftype defrecord do not have no-ar ctors

18:00 ender403: i read that rich doesn't want to make deftype into an all purpose java interop feature so deftype probably won't allow custom constructors in future

18:01 isn't gen-class supposed to be a java interop feature?

18:02 hoeck: imo a right decision, but gen-class should then support mutable or mutable-volatile fields

18:02 kencausey: It sounds to me like this is just a case where it makes more sense to implement that class in Java and move on

18:02 If it's simple and requires a lot of Java-isms, why do otherwise?

18:03 hoeck: of course, and you have to compile it anyways, so little gain from writing it in clojure

18:06 ender403: it would be nice to have a macro that can generate the class in clojure. we can then have nice binary serialization like Erlang. But if there is no way current then I can write it in java

18:07 preon library looks very nice. has anyone here had experience with it?

18:08 brb. making pasta

18:15 hoeck, i'm still new to clojure. do you mean there is little to gain because the class is created at compile time instead of runtime?

18:19 hoeck: ender403: I just assume that because most java-serialization libs use named classes wich must be created by compiling a gen-class namespace in clojure

18:48 technomancy: Leiningen repl now listens on a socket as a bonus: http://github.com/technomancy/leiningen/commit/4f64c64afb455c3494873d469729b4a89f7f9f29

18:57 I hate how long that function is, but building up a form for eval-in-project makes it harder to split out functionality. =\

18:58 * kencausey has seen worse

18:59 technomancy: not on my watch =)

19:05 vIkSiT: lo all

19:06 anyone using mongodb here?

19:06 I was wondering if there was a way to use congomongo to do range queries on a collection.

19:07 (For instance, if a collection has a 100 rows, is there a way to retrieve the first 10, the next 10, and so on)

19:09 phaer: What does "(~ var)" in clojure do? Or do you know whats the name of "~" in english, so i can look for it?

19:09 vIkSiT: the tilde operator?

19:09 One use is when creating macros

19:10 gfrlog: is there another use?

19:10 technomancy: I think it's called unquote

19:10 vIkSiT: (def mymacro [n] `(apply str "this is" ~n))

19:10 gfrlog, I'm not sure I know enough about Clojure to comment if there was ONLY one use :)

19:10 phaer: ah, makes sense. thank you

19:11 pdk: fkin hate how you cant even change your nick without leaving some channels on freenode

19:11 anyway ~ is called tilde

19:11 and in clojure it's used in macros to tell it to eval a part of a quoted form iirc

19:11 we're rebellious so we dont do cl style ,

19:13 phaer: pdk: Yes, but thats a plus point for clojure. The use of different kind of brackets for example makes it much more readable than common lisp in my opinion. :)

19:13 pdk: it's not so much a bracket difference here as just using a different symbol for the same function from cl

19:14 since people already use , as a reading aid in map literals

19:14 vIkSiT: hmm, so what would be the best way to iterate over a large collection of elements, taking n elements at a time?

19:15 pdk: (partition n n list)?

19:15 vIkSiT: pdk, would that be lazy?

19:15 pdk: (doc partition)

19:15 clojurebot: "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."

19:15 vIkSiT: aah

19:15 thanks for the info

19:15 pdk: (partition 3 (take 15 (iterate inc 1)))

19:15 ,(partition 3 (take 15 (iterate inc 1)))

19:15 clojurebot: ((1 2 3) (4 5 6) (7 8 9) (10 11 12) (13 14 15))

19:17 vIkSiT: awesome

19:18 pdk, so assuming I've got a list of elements whose total I do not know of.

19:18 pdk: total as in number of items in the list or sum of all numerical items in the list

19:18 vIkSiT: hmm. the former

19:18 pdk: partition doesnt require the list it takes in to be a clean multiple of n in terms of length

19:19 ,(partition 4 (take 15 (iterate inc 1)))

19:19 clojurebot: ((1 2 3 4) (5 6 7 8) (9 10 11 12))

19:19 pdk: ,(partition 3 (take 15 (iterate inc 1)))

19:19 clojurebot: ((1 2 3) (4 5 6) (7 8 9) (10 11 12) (13 14 15))

19:19 vIkSiT: aah indeed

19:19 pdk: MAYBE

19:19 ,(partition 4 4 (take 15 (iterate inc 1)))

19:19 clojurebot: ((1 2 3 4) (5 6 7 8) (9 10 11 12))

19:19 pdk: clojurebot dont make this difficult

19:20 ,(partition 4 1 (take 15 (iterate inc 1)))

19:20 clojurebot: ((1 2 3 4) (2 3 4 5) (3 4 5 6) (4 5 6 7) (5 6 7 8) (6 7 8 9) (7 8 9 10) (8 9 10 11) (9 10 11 12) (10 11 12 13) (11 12 13 14) (12 13 14 15))

19:20 pdk: obvious way would probably be to do a step of 1 then grab every nth item and the last item i guess

19:20 vIkSiT: ah so the 1 there is an overlap step

19:20 pdk: this could use some more looking into

19:21 yeah the 3 argument version uses the second argument to control how far to advance between steps

19:21 ,(partition 4 1 (range 1 9))

19:21 clojurebot: ((1 2 3 4) (2 3 4 5) (3 4 5 6) (4 5 6 7) (5 6 7 8))

19:21 pdk: see how it steps with a step of 1

19:21 ,(partition 4 2 (range 1 9))

19:21 clojurebot: ((1 2 3 4) (3 4 5 6) (5 6 7 8))

19:21 vIkSiT: right

19:22 pdk: so partition 4 2 sort of makes half of each list overlap

19:22 vIkSiT: right

19:24 pdk: would need to know a few more details about what we want for this problem before deciding if partition's cutting-off behavior would be an issue

19:25 vIkSiT: well, in my case, I'm trying to compensate for the fact that my database won't let me do ranged queries on my data. So, I'm using a lazy "fetch" to get the entire dataset

19:25 pdk: cause apparently the 2 argument version if the length of the list isn't a multiple of n it'll just drop the excess

19:25 vIkSiT: and then partitioning it into manageable chunks, map a function on it, and finally dump it. so the exact partition doesn't make a difference ot me

19:26 pdk, yes, the overlap won't be a problem

19:26 pdk: hmm not quite sure if partition would do the job on its own without the 3 arg version or some extra trickery to make it not drop stuff in the 2 arg

19:26 in that case 3 arg version with a step 1 seems to preserve all the data when the list length isn't a multiple of n

19:26 vIkSiT: pdk, not sure I understood your last statement

19:26 pdk: like when i tried to partition a 15 element list with n = 4 earlier

19:26 vIkSiT: right

19:26 pdk: in the 2 arg version of partition

19:27 note how it retrieved 12 items then just dropped the last 3 cause it couldn't make a 4 element list out of them

19:27 vIkSiT: aah.

19:27 ,(partition 4 4 (take 15 (iterate inc 1)))

19:27 clojurebot: ((1 2 3 4) (5 6 7 8) (9 10 11 12))

19:27 raek: I think you can pass nil as one of the args to solve that

19:27 vIkSiT: right

19:27 ,(partition 4 nil (take 15 (iterate inc 1)))

19:27 clojurebot: java.lang.RuntimeException: java.lang.NullPointerException

19:27 pdk: oh yeah there's a 4 arg version

19:27 with the 3rd arg as padding

19:28 (doc partition)

19:28 clojurebot: "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."

19:28 pdk: the 3rd arg has to be a sequence

19:28 you could do either (repeat nil) or (repeatedly nil), i forget which

19:28 (doc repeat)

19:28 clojurebot: "([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."

19:28 pdk: (doc repeatedly)

19:28 clojurebot: "([f] [n f]); Takes a function of no args, presumably with side effects, and returns an infinite (or length n if supplied) lazy sequence of calls to it"

19:28 pdk: yeah repeat

19:28 raek: yeah, pad = nil will make the last sequence be the rest of the elements

19:29 pdk: (partition 4 4 nil (range 1 16))

19:29 ,(partition 4 4 nil (range 1 16))

19:29 clojurebot: ((1 2 3 4) (5 6 7 8) (9 10 11 12) (13 14 15))

19:29 vIkSiT: hmm

19:29 pdk: ,(partition 4 4 nil (range 1 15))

19:29 clojurebot: ((1 2 3 4) (5 6 7 8) (9 10 11 12) (13 14))

19:29 vIkSiT: aah the third argument

19:29 pdk: !!!

19:29 that makes it preserve everything without overlap

19:29 vIkSiT: ,(partition 4 4 nil (take 15 (iterate inc 1)))

19:29 clojurebot: ((1 2 3 4) (5 6 7 8) (9 10 11 12) (13 14 15))

19:29 vIkSiT: ah that works

19:29 pdk: oughta take note of that little trick

19:30 vIkSiT: indeed

19:30 thats pretty neat

19:30 pdk: though still dumb that it doesnt document what happens when you use nil as 3rd arg in 4 arg version

19:30 at least not explicity

19:30 cause first time you read it say "pad collection" you assume it has to be an actual collection

19:31 raek: well, I guess you could use () as padding too

19:31 but yeah... it's a common usage that is not very obvious

19:32 pdk: (partition 4 4 () (range 1 15))

19:32 ,(partition 4 4 () (range 1 15))

19:32 clojurebot: ((1 2 3 4) (5 6 7 8) (9 10 11 12) (13 14))

19:42 chouser: there was a pretty extensive discussion about changing how partition with padding works

19:42 but I guess it didn't end up going anywhere

19:43 pdk: what was the gist of the proposed change

19:43 chouser: I think the final statements were feeling out whether the current partition-with-pad was perhaps mixing two things into a single function that ought to be separated.

19:44 I'm sure it's on the google group or IRC log. Not sure which.

19:47 hm, or maybe assembla

19:49 pdk: https://www.assembla.com/spaces/clojure/tickets/120

20:05 ender403: hi chouser

20:07 is it possible to declare the following java class using gen-class or deftype? class Rectangle {

20:07 @Bound private int x1;

20:07 @Bound private int y1;

20:07 @Bound private int x2;

20:07 @Bound private int y2;

20:07 }

20:09 chouser: Is @Bound some sort of annotation?

20:11 hm, I don't think either will do private fields.

20:12 ender403: yes Bound is an annotation provided by the preon library

20:12 it doesn't have to be private field. When I tried defining this type using deftype I couldn't get a default constructor which takes no arguments. preon needs this

20:13 preon overview is here http://www.scribd.com/doc/8128172/Preon-Introduction

20:13 chouser: ugh. I don't think so.

20:14 deftype only provides a ctor with one arg per field, and no way to provide more ctors

20:14 gen-class only allows zero or one fields, no more.

20:15 ender403: hmm, is it possible to embed java code inside clojure code?

20:15 raek: maybe it's just simpler to write that class int java, and interact with it using clojure's usual java interop

20:16 chouser: no, but you can define your little class in a .java file, then use that as needed from clojure

20:16 raek: ender403: there is, for example, a lein-javac plugin for leiningen that allows you to have both clojure and java sources in the same project

20:17 ender403: ok. i was hoping to do it in clojure so I can get nice binary serialization like Erlang has

20:17 raek: iirc, the build tool Cake has support for java sources out of the box

20:19 ender403: thanks raek. lein-javac looks interesting

20:27 gfrlog: how do you handle circular definitions in clojure? like if functions a and b want to refer to each other

20:28 do we vacuously pre-def one of them C++ style?

20:28 then re-def it later?

20:29 raek: yes.

20:29 gfrlog: okeedoke

20:29 raek: you can simply do a (def a)

20:30 gfrlog: thanks

20:30 spewn: Isn't the preferred way to do it with declare?

20:30 raek: or it you want to create multiple variables: (declare a b)

20:30 phaer: raek: thanks from me too. lein-javac seems to be exactly what i was looking for at the moment :)

20:30 gfrlog: I learned a new word

20:31 raek: spewn, I think declare signals the intentions more clearly, so I guess so

20:35 gfrlog: I can swap an atom inside an agent function, right?

20:35 raek: sure

20:37 dreish: I had slime working just yesterday, and now, restarting after my Mac crashed, slime-connect reports success but does not create a buffer for the REPL.

20:37 raek: but I have no idea of what makes most sense in your situation

20:37 dreish: is there a repl in the *inferior-lisp* buffer?

20:38 dreish: raek: The only buffers currently open are *scratch*, *Messages*, and *slime-events*

20:38 tomoj: dreish: do you have slime-repl installed?

20:39 dreish: tomoj: That might be it. I think I moved some things around in my .emacs file and now my slime/contrib dir is no longer in the load path.

20:39 I had to symlink a couple of slime things just to get emacs to start at all, and I missed slime-repl.el.

20:41 raek: I finally surrendered to ELPA

20:42 and installing slime though it wasn't that bad

20:44 tomoj: you get a crippled slime I guess

20:45 raek: old version?

20:46 tomoj: it doesn't contain the whole thing

20:46 right?

20:46 I mean, you get more stuff if you install slime yourself?

20:47 raek: I dunno... I haven't missed anything so far :)

20:47 dreish: This doesn't look good. My *slime-repl clojure* buffer has a CL-USER> prompt.

20:48 And I still had to load slime-repl.el manually.

20:48 raek: you used slime-connect to start it?

20:48 dreish: Yes.

20:48 tomoj: haha

20:48 dreish: It still didn't create a repl buffer.

20:48 raek: do you have clojure-mode?

20:48 dreish: Yes.

20:49 tomoj: wait, I'm confused... "it stil didn't create a repl buffer" "my *slime-repl clojure* buffer..."

20:49 dreish: Which I created after manually loading slime-repl.el and running M-x slime-repl

20:49 I think I need to just give up and go with ELPA.

20:49 It can't be much worse than this.

20:50 raek: I think slime-repl starts the repl itself, rather than connect to an existing

20:50 what happens if you don't run slime-repl and only slime-connect?

20:50 tomoj: I don't think you should be running M-x slime-repl

20:50 dreish: It says "Hack and be merry" or whatever, but I just have the buffers I listed at 8:38.

20:50 raek: dreish: http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Emacs

20:51 there is some relevant info there

20:51 perticularily about how slime finds out which program to start

20:52 I only have to run slime-connect to get started

20:52 gfrlog: does "java.lang.Exception: Can't await in agent action" ring a bell to anybody?

20:52 dreish: That worked for me, too, last time.

20:53 raek: gfrlog: what are you trying to do? (on a more larger scale)

20:54 dreish: Oh, I already have ELPA. :-?

20:54 raek: it sounds like you are using agents in the wrong way

20:55 gfrlog: can you paste the code?

20:55 gfrlog: um

20:55 I'm trying to have most of my code running within an agent

20:55 and it includes a lot of http

20:55 throught clojure.contrib.http.agent

20:55 so if there's an issue with one agent function calling another agent and waiting for the result...

20:55 raek: why in an agent? to have it in its own thread?

20:56 gfrlog: hmm

20:56 raek: you can use (future ...code...) to run something in another thread

20:56 gfrlog: well I want other threads to be able to add code to the main thread

20:57 I suppose imagine a main thread and some worker threads

20:57 where each worker thread ultimately results in an http call

20:57 but I'd rather the http calls be one-at-a-time

20:57 so I do them in the main thread

20:57 via the agent

20:57 raek: where does the waiting come in?

20:58 gfrlog: waiting for the result of the http

20:58 raek: that sounds more like futures

20:58 gfrlog: but I don't want the next http call to start before the last one finishes

20:58 raek: if you do a @ on a future, it will block until the values is completed

20:58 gfrlog: hmm.

20:59 raek: why not simply do the calls one after another?

20:59 in one thread

20:59 gfrlog: so

20:59 the main thread I want to make http calls whenever one of the worker threads finishes, or 30 seconds elapses, whichever is first

21:00 raek: anway, to answe the original question: yes, agents are not allowed to wait for other agents in their action functoin

21:00 gfrlog: so I could tell him to sleep for 30 seconds, but then how does he get interrupted by the workers?

21:01 I'll rework it I guess

21:02 thanks

21:02 raek: I'm sorry... I can't come up with a simple solution right now...

21:02 gfrlog: I know, this setup is rather complex

21:03 I have a hard enough time coming up with good ideas even with full knowledge

21:03 raek: futures have a future-cancel function too, might be good to know

21:03 gfrlog: yep

21:03 I'm using futures for the worker threads actually

21:04 raek: I guess the worker agents could send a "I'm ready for work" message to the main agent or something

21:05 gfrlog: but then the main thread is still an agent

21:06 I wonder if I can sidestep it by just wrapping the await in a future

21:06 raek: maybe one could send an "add job" message to the main agent, which adds the job to a queue (the main agent's sate)

21:06 gfrlog: ah hah! the sidestep worked

21:07 so an agent can wait on a future, but not another agent

21:07 that seems arbitrary from my naive point of view

21:07 raek: an agent kind of is a thread

21:08 and a future is a thread too

21:08 so the agent is not waiting

21:08 gfrlog: I bet the clojure.contrib.http.agent library would be better rewritten with futures anyhow

21:08 raek: because another thread does the waiting

21:08 gfrlog: the agent waits for the future though

21:09 raek: ...and then when a worker agent is ready, it sends a function to the main agent that will pop the next job and send it to itself

21:10 anyway, agents are asynchronous in their nature

21:10 gfrlog: right

21:11 raek: but they might be the closest fit anyway, if one needs the queing facility

21:11 gfrlog: yeah, I think it works fine without that one issue

21:11 I'm actually only using one agent

21:11 the "worker threads" are all futures

21:15 spewn: How does one typically deal with having a defstruct foo and passing instances of that struct to a function as an arg named foo?

21:15 I can only think of renaming one or the other to struct-foo or a-foo, but that seems awkward.

21:16 gfrlog: ,(keys {})

21:16 clojurebot: nil

21:16 gfrlog: ick

21:16 ,(or (keys {}) [])

21:16 clojurebot: []

21:19 gfrlog: spewn: if you were using deftype, you could have Foo and foo

21:19 spewn: gfrlog: I'll have to wait until 1.2 comes out for that, I think

21:20 gfrlog: yeah :(

21:43 pdk: how is 1.2 release looking now anyway

21:43 i see on the dl page it's at rc3

21:48 gfrlog: ,(.substring (str :keyword) 1)

21:48 clojurebot: "keyword"

21:54 brweber2: gfrlog you could use (name :keyword), of course I have no idea what you are trying to do...

21:54 gfrlog: (name :youreright)

21:54 ,(name :onemoretime)

21:54 clojurebot: "onemoretime"

21:54 gfrlog: ah ha

21:55 ,(doc name)

21:55 clojurebot: "([x]); Returns the name String of a string, symbol or keyword."

21:55 gfrlog: good man!

21:55 that'll clean my code up

22:27 eckroth: how do I convert a map to a string? (str [1 2 3]) works but not (str {:a 1 :b 2})

22:28 defn: eckroth: how do you want it to look

22:28 like "a 1 b 2"?

22:28 eckroth: defn: anything that can parse into a map with (read-string)

22:28 oddly try-clojure.org halts on (read-string "{:a 1 :b 2}")

22:29 defn: Raynes: 21:28 < eckroth> oddly try-clojure.org halts on (read-string "{:a 1 :b 2}")

22:29 eckroth: defn: thanks for forwarding to Raynes :)

22:29 defn: :D

22:29 eckroth: so you want to...serialize this to a file or?

22:29 eckroth: defn: exactly

22:30 defn: iirc you need to use *print-dup*

22:30 one sec

22:30 a_strange_guy: ,(print-str {:a 1, :b 2})

22:30 clojurebot: "{:a 1, :b 2}"

22:30 defn: yeah but that wont work with read-string i dont think, will it?

22:30 ,(read-string "{:a 1, :b 2}")

22:30 clojurebot: {:a 1, :b 2}

22:30 a_strange_guy: ,(read-string (print-str {:a 1, :b 2}))

22:30 clojurebot: {:a 1, :b 2}

22:31 defn: i must be wearing orthopaedic shoes...

22:31 eckroth: a_strange_guy: a great

22:31 a_strange_guy: ah great I mean

22:31 defn: eckroth: http://clojuredocs.org/v/2020

22:32 eckroth: you want to use *print-dup* -- im failing to remember why that is the case right now

22:34 eckroth: ah -- it's if you're serializing something in your map which is a java object:

22:34 a_strange_guy: *print-dup* conserves the type of maps and numbers etc

22:34 eckroth: defn: ok right

22:34 ,(binding [*print-dup* true] (str {:a 1 :b 2}))

22:34 clojurebot: "#=(clojure.lang.PersistentArrayMap/create {:a 1, :b 2})"

22:34 defn: ,(read-string (print-str {:a (java.util.Date.), :b 1}))

22:34 clojurebot: java.lang.RuntimeException: java.lang.Exception: Unreadable form

22:35 a_strange_guy: (binding [*print-dup* true] +)

22:36 ,(binding [*print-dup* true] (print +))

22:36 clojurebot: #=(clojure.core$_PLUS_. )

22:36 defn: ,(read-string (binding [*print-dup* true] (str {:a (java.util.Date.), :b 1})))

22:36 clojurebot: java.lang.RuntimeException: java.lang.IllegalArgumentException: No method in multimethod 'print-dup' for dispatch value: class java.util.Date

22:36 defn: a_strange_guy: you're a strange guy.

22:37 a_strange_guy: xD

22:37 if you want to serialize POJOs then you have to extend the print-dup multimethod to Serializable

22:38 eckroth: there should be no expectation that "any" POJO can be serialized

22:39 a_strange_guy: neither is every datastucture printable

22:40 eckroth: a_strange_guy: such as records at the moment, right? they cannot be printed

22:40 a_strange_guy: and multimethods I assume

22:41 a_strange_guy: ,(binding [*print-dup* true] (print #'clojure.core/print-method))

22:41 ,(binding [*print-dup* true] (print #'clojure.core/print-method))

22:42 clojurebot: #=(var clojure.core/print-method)

22:42 a_strange_guy: ,(binding [*print-dup* true] (print @#'clojure.core/print-method))

22:42 clojurebot: java.lang.IllegalArgumentException: No method in multimethod 'print-dup' for dispatch value: class clojure.lang.MultiFn

22:42 eckroth: ,(binding [*print-dup* true] (print (fn [x] (+ 1 x)))

22:42 clojurebot: EOF while reading

22:42 eckroth: oh bother

22:42 ,(binding [*print-dup* true] (print (fn [x] (+ 1 x)))

22:42 clojurebot: EOF while reading

22:42 eckroth: whoops again

22:43 a_strange_guy: ,(binding [*print-dup* true] (print (fn [a] (+ a a)))

22:43 clojurebot: EOF while reading

22:43 a_strange_guy: ,(binding [*print-dup* true] (print (fn [a] (+ a a))))

22:43 clojurebot: #=(sandbox$eval502761$fn__502762. )

22:43 eckroth: so, usless

22:44 a_strange_guy: actually it works

22:44 you can read functions

22:45 defn: it's also dangerous

22:45 a_strange_guy: unless they are closures

22:45 defn: and the sandbox would be smart to not let you just read in any old string

22:45 eckroth: a_strange_guy: not if you lose state, right? that printed function makes no sense once you restart java

22:46 a_strange_guy: toplevel fns do work actually

22:46 if you AOT

22:46 eckroth: a_strange_guy: I mean anon functions

22:47 a_strange_guy: I don't know why print can't just represent as the same datastructure that defines the anon func (that is, '(fn [x] ...))

22:48 a_strange_guy: because clojure compiles everything

22:48 the source is gone then

22:48 defn: there's a way to pretty print an anon function fwiw

22:48 eckroth: a_strange_guy: but the datastructure remains

22:48 defn: from a string i mean

22:48 a_strange_guy: nope, no datastructure

22:49 eckroth: a_strange_guy: what is no datastructure? an anon func has no associated datastructure?

22:50 a_strange_guy: an anon func is just a singleton instance of a java class

22:50 (more or less)

22:50 eckroth: a_strange_guy: why say singleton instance? why not just instance?

22:51 defn: singleton implies anon i believe

22:51 a_strange_guy: is that right?

22:51 or at least in the ruby object model it does

22:52 a_strange_guy: singleton means that there is only one instance

22:53 you don't need more than one if the fn is not a closure

22:53 but I am not sure if clojure compiles that way

22:54 (letfn [(make-fn [] (fn [] nil))] (indentical? (make-fn) (make-fn)))

22:55 ,(letfn [(make-fn [] (fn [] nil))] (indentical? (make-fn) (make-fn)))

22:55 clojurebot: java.lang.Exception: Unable to resolve symbol: indentical? in this context

22:55 a_strange_guy: ,(letfn [(make-fn [] (fn [] nil))] (identical? (make-fn) (make-fn)))

22:55 clojurebot: false

22:55 a_strange_guy: forget singleton

22:55 defn: a_strange_guy: you're a strange guy.

22:56 im sorry but i cannot resist

22:56 great nick

22:56 reminds me of a strange loop

22:56 a_strange_guy: from G.E.B?

22:58 defn: the author of GEB wrote a book called "I am a Strange Loop"

22:58 http://en.wikipedia.org/wiki/I_Am_a_Strange_Loop

22:59 Raynes: eckroth: Aye, read-string shouldn't even been allowed. Thanks for letting me know.

22:59 a_strange_guy: damn, I have to read that

22:59 defn: a_strange_guy: :) It's fantastic.

22:59 Raynes: Oh wait.

23:00 I was thinking of read-line.

23:00 That is odd. It doesn't seem to be halted though.

23:00 defn: a_strange_guy: I also very much recommend "The Mind's I"

23:00 by Hofstadter and Dennett

23:01 Raynes: -> (read-string "{:a 1 :b 2}")

23:01 sexpbot: => {:a 1, :b 2}

23:01 Raynes: Odd.

23:01 defn: that could be naughty.

23:01 a_strange_guy: defn: thanks, GEB already blew my mind

23:01 Raynes: That's beside the point.

23:02 I have no clue why it would make it freeze (if only temporarily).

23:02 a_strange_guy: this seem to be its successor ^^

23:02 Raynes: (read-string "3") works

23:02 defn: -> (read-string "#=(var foo)")

23:02 sexpbot: java.lang.Exception: EvalReader not allowed when *read-eval* is false.

23:03 Raynes: It only fails with maps it seems.

23:03 defn: hm, weird

23:03 Raynes: defn: Licenser isn't that stupid. ;)

23:03 defn: Raynes: haha :)

23:03 Raynes: It even works with vectors.

23:03 eckroth: Raynes: yeah, odd :)

23:04 Raynes: Licenser: When you get back, check out the backlog. This might be a job for the almighty Heinz. I don't even know where to start.

23:04 defn: -> (map class [{} [] '()])

23:04 sexpbot: => (clojure.lang.PersistentArrayMap clojure.lang.PersistentVector clojure.lang.PersistentList$EmptyList)

23:04 Raynes: Seems like Licenser does more work on tryclojure than I do these days. ._.

23:04 defn: what's the REPL say

23:06 Raynes: might wanna look at clojure.lang.RT as well

23:07 Raynes: defn: ?

23:07 defn: just thinking out loud

23:07 Raynes: I don't know what you mean.

23:08 Or what you're implying.

23:08 :p

23:09 defn: Raynes: no implication, simply places I would begin investigating-- read-string uses clojure.lang.RT

23:09 Raynes: Oh.

23:10 I know what I need to do. I can find out if this is a sandbox problem, and if it is, I can just whine to Heinz.

23:10 Luckily, try-clojure has a bit of a public API I can use without the Javascript console.

23:11 java.lang.NullPointerException

23:12 Well, I see the problem.

23:13 defn: http://try-clojure.org/magics?code=(read-string%20%22{:a%201%20:b%202}%22)

23:13 Tell me what you see.

23:13 ;)

23:14 defn: Raynes: hah

23:14 Raynes: you know, i had a similar problem with walton

23:15 functions which were in the sandbox which just refused to show up

23:15 Raynes: The problem is that the console does nothing but sit there if nothing is returned by it's callback.

23:15 eckroth: It isn't locking up, the cursor is just disappearing. After you type the read-string stuff, you can move the cursor with the arrow buttons and then delete what you typed.

23:16 But the actual reason that it isn't returning anything is the real problem.

23:16 I'll work on that later tonight or tomorrow.

23:24 defn: google analytics is great

23:25 (doc root-cause)

23:25 clojurebot: Gabh mo leithscéal?

23:25 defn: ->(doc root-cause)

23:25 sexpbot: java.lang.Exception: Unable to resolve var: root-cause in this context

23:27 Raynes: ->(doc clojure.stacktrace)

23:27 sexpbot: java.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.core/print-namespace-doc)

23:27 Raynes: ->(doc clojure.stacktrace/root-cause)

23:27 sexpbot: => ------------------------- clojure.stacktrace/root-cause ([tr]) Returns the last 'cause' Throwable in a chain of Throwables. nil

23:27 defn: danke

23:27 (read-string (read-string

23:27 grr

23:27 -> (read-string (read-string "{:a 1 :b 2}"))

23:27 sexpbot: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.String

23:41 no_mind: are there any plans to get rid of JVM from clojure in near or distant future ?

23:43 Raynes: No. Why would there be?

23:43 :o

23:43 Clojure in Clojure is one current focus, and it'll make it easier for their to be other implementations of Clojure, but as of now, the JVM is the primary platform for Clojure.

23:54 mmarczyk: hey guys, I've just done a write-up on Compojure... I'm not (at all) a web programmer, but I am becoming interested in the field, so it was an interesting exercise... anyway: any comments?

23:54 http://stackoverflow.com/questions/3488353/whats-the-big-idea-behind-compojure-routes/3490479#3490479

23:54 hi Raynes :-)

23:56 Raynes: mmarczyk: Hai.

23:58 mmarczyk: I want to read that, but I don't know if I have the energy.

23:58 ;P

23:58 mmarczyk: oh come on :-P

23:59 on a more serious note, I'd love to find out whether the general picture is correct and what I'm missing...

23:59 no hurry, though ;-)

23:59 Raynes: Actually, this is something that might help me understand Compojure better.

23:59 * Raynes reads it.

Logging service provided by n01se.net