#clojure log - Jul 27 2010

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

0:53 technomancy: is it to cute to replace (clean project) (deps project) (jar project) with (doto project clean deps jar)?

0:53 I think of doto as a java-interop-y thing

1:16 Apage43: it feels java interopy since clojury functions tend not to have side effects, i spose.

1:40 hiredman: ping?

1:40 clojurebot: PONG!

1:44 jacortinas: ping

1:44 ping?

1:44 clojurebot: PONG!

1:44 jacortinas: ,('ping)

1:44 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: Symbol

1:45 jacortinas: "ping?"

1:45 ,"ping?"

1:45 clojurebot: "ping?"

1:48 slyrus: ,(str (lazy-seq "1234"))

1:48 clojurebot: "clojure.lang.LazySeq@251fc3"

1:49 slyrus: ,(lazy-seq "1234")

1:49 clojurebot: (\1 \2 \3 \4)

1:49 slyrus: ,(Integer/parseInt (lazy-seq "1234"))

1:49 clojurebot: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.lang.String

2:23 SandGorgon: Bryan Cantrill's (of Dtrace) article bashing STM - http://dtrace.org/blogs/bmc/2008/11/03/concurrencys-shysters/

2:52 herdrick: say, is there a way to use memfn (or something else) to make a function from a static method?

4:04 lpetit: test

6:34 Bahman: Hi all!

6:43 LauJensen: Hey Bahman

6:44 Bahman: Hi LauJensen!

7:40 lpetit: vimperator on firefox rocks !

7:48 OliverUv: lpetit: i agree, but I changed to chrome so no vimperator for me :(

7:58 lpetit: OliverUv: there's something for you on Chrome: Vimium

7:58 similar to vimperator

8:00 OliverUv: nice! thanks

8:00 I've been googling around for stuff like "vimperator for chrome" but never found anything

8:01 thanks

8:12 LauJensen: OliverUv: I highly recommend that you use Conkeror instead, for more reasons than this channel can contain :)

8:24 lpetit: LauJensen: give just one :)

8:24 LauJensen: Has better keybindings

8:27 Nikelandjelo: LauJensen: I haven't seen Conkeror, but what keybindings does it offer? Why are they better?

8:30 LauJensen: Nikelandjelo: Conkeror has all of Emacs keybindings

8:35 lpetit: LauJensen: and you dare say those are better keybindings to a vim user ! :-p

8:35 OliverUv: My hands don't appreciate emacs' keybindings

8:37 lpetit: My hands hurt at all bindings involving the Control key

8:42 LauJensen: lpetit: Swap control and capslock, then your pinky finger can rest on it. I can honestly say that Ive never had any finger/hand pain after a full day of coding

8:43 lpetit: and no, I dont actually know that they are better since I dont know Vims bindings, but I know that Emacs is better so it makes sense to tie everything together. (see my latest screencast for a full rant about this)

8:44 Dranik: hello!

8:44 I'm trying to develop a macro which generates a java class

8:44 but it simply does not want to compile

8:45 may anybody help me with that?

8:45 (the same code without the macro definition compiles greatly!)

8:46 bobo_: LauJensen: do you have a writeup of for ex the 10-20 keybindings you use most in emacs? i bet theres alot i didnt know i want...

8:46 LauJensen: bobo_: No, but its a good idea - I'll incorporate that into my next post

8:46 bobo_: cool

8:47 lozh: Dranik: Put some code up and I'll give it a shot

8:47 Dranik: lozh, may I put the code here or should I use pastebin?

8:49 OK, let's put it here then

8:49 (ns macros.win

8:49 (:gen-class

8:49 :name macros.win))

8:49 this works fine, AOT-compilation goes OK

8:49 I want to create a macros which will generate exactly the same code

8:49 look here

8:50 (defmacro mywin [name]

8:50 `(ns macros.~name

8:50 (:gen-class

8:50 :name macros.~name

8:50 )))

8:50 (mywin :win)

8:50 I'm sure I miss something really simple

8:50 lozh: pastebin or gisthub would probably be better, but I'll have a go, sec

8:51 gist.github even

8:52 Dranik: lozh, gist: 492178

8:53 lozh: ta

8:54 lpetit: LauJensen: inferring that emacs bindings are better than vi bindings from *a* (questionable) knowledge that emacs is globally better than vi is a logic error

8:55 LauJensen: lpetit: Like I said 'I dont actually know that they (the bindings) are better'. But Emacs is better than Vi, ask anybody in #emacs

8:55 lpetit: LauJensen: interesting idea, swapping control and capslock. It's what you've done yourself for your configuration ? And what about all the keys that are on the "left" of the keyboard: how do you type them with capslock ?

8:56 LauJensen: lpetit: Yea I have them swapped. Im not sure what you mean about keys on the left

8:56 lpetit: LauJensen: I asked on #eclipse, and surprisingly everybody told me eclipse is better than x/y/z :-p

8:56 chouser: My capslock key does ctrl too.

8:56 LauJensen: lpetit: yea I know, it was a joke.

8:56 chouser: My capslock key does ctrl too.

8:57 lpetit: LauJensen: prior to your swap, you would have typed Ctrl+Z : "ctrl with the right hand on the right control key, Z with the left hand". How do you type Ctrl+Z ?

8:58 seems like this "capslock/ctrl" key swap is this kind of little dirty secrets ... :)

8:59 LauJensen: lpetit: Ah, I never use Ctrl+Z

8:59 lpetit: chouser, LauJensen: out of curiosity, you changed the behaviors at the OS level, at the X server level, at the app (emacs/vim) level ?

8:59 chouser: I got used to ctrl being there on Sun keyboards in college and was quite dismayed to find it was uncommon on PC keyboards.

8:59 LauJensen: lpetit: xmodmap - OS level

9:00 lpetit: LauJensen: please, it was just an example. I'm pretty sure there is at least one combination of Ctrl+ a key you normally type with the left hand in what you're using with emacs

9:00 LauJensen: lpetit: hehe. Im not aware of any such keys that I use in my daily workflow, but if I had to, I would use the pinky finger, and index finger on the same hand

9:00 lpetit: LauJensen: thanks. If you intend to also talk about this little dirty secret on your next blog entry, you're welcome

9:00 chouser: lpetit: I currently use xmodmap, but xorg also has a special config setting specifically for swapping capslock/ctrl and that actually behaves more consistently in my opinion.

9:01 LauJensen: (and I was half serious- try to avoid tricky key-combos for maximum efficiency)

9:01 lpetit: LauJensen: isn't C-c something usual in emacs ?

9:01 LauJensen: chouser: gnome can trip you up, otherwise xmodmap should be the preferred method. Ubuntu is changing things though

9:01 * lpetit remembers seing examples of "Hit C-c C-<something else>" all over the place

9:01 LauJensen: lpetit: yea, and C-x, but I use one hand for those

9:02 lpetit: LauJensen: so I'm out of luck. C-c, C-x, C-v are the most common bindings in all apps / OS, and they force you to twist you wristle, I guess those are the ones which harm my hands

9:03 s/harm/hurt/

9:03 sexpbot: LauJensen: so I'm out of luck. C-c, C-x, C-v are the most common bindings in all apps / OS, and they force you to twist you wristle, I guess those are the ones which hurt my hands

9:03 lpetit: maybe I could swap Enter and right-control :-)

9:03 LauJensen: lpetit: hmm

9:03 lpetit: LauJensen: how old are you ?

9:03 LauJensen: 28

9:04 lpetit: I'm 36: wait for 8 more years and we can talk about this again :)

9:04 LauJensen: Seems fair :)

9:04 though, looking at my hands, my left hand is always rested in that slighty twisted position, so Im not twinching

9:05 lpetit: LauJensen: oh yes, typing CapsLock+c/x/v with the left hand indeed seems way better than Ctrl+c/x/v

9:05 * lpetit is gonna find a tutorial on xmodmap right now

9:06 LauJensen: I can send you mine

9:06 lpetit: LauJensen: if you please

9:06 LauJensen: remove Lock = Caps_Lock

9:06 remove Control = Control_L

9:06 keysym Control_L = Caps_Lock

9:06 keysym Caps_Lock = Control_L

9:06 add Lock = Caps_Lock

9:06 add Control = Control_L

9:06

9:06 (for everyones benefit)

9:06 lpetit: where do I put/replace all these nice looking commands ?

9:06 LauJensen: put them in ~/.xmodmap

9:06 then run xmodmap ~/.xmodmap

9:08 lpetit: so xmodmap will not change the behaviour of the keys if I'm using vim from a terminal ?

9:09 chouser: lpetit: is it an X terminal?

9:09 lpetit: almost. But I also tend to access remote servers, hmmm

9:09 chouser: yes, but you access them via your local X session, don't you?

9:10 * lpetit hides in the darkness

9:11 chouser: there's another mechanism for setting capslock behavior in linux console terminals, but it's been ages since I bothered doing that.

9:11 lpetit: no, you're right, xmodmap will be sufficient for me too

9:12 subsidiary question: the xmodmap command must be called just once ?

9:12 :wq

9:12 woops, wrong window focus

9:14 apparently no, what's the *better* place to put the xmodmap command, please ?

9:14 chouser: mine is 1~~~7`

9:15 mine is in my .xsession

9:18 lpetit: chouser, LauJensen: I would like to thank you both on behalf of my wrists

9:18 chouser: I wish your wrists well. :-)

9:19 lpetit: chouser, LauJensen: no other little dirty secrets w/regards to keyboard keys switching ?

9:23 chouser: nope, I've got nuthin.

9:23 except the dirty little secret that although emacs' infrastructure is more flexible, vim's keybindings are better.

9:23 Raynes: I hated the first two weeks after switching my ctrl and caps keys.

9:25 lpetit: Raynes: sure, I already switched to upper cases 4 since I switched 10 minutes ago. But I also appreciated each time I had to hit Capslock instead of Control !

9:28 Chousuke: I sometimes forget that caps lock is not control when I borrow other people's computers

9:29 lpetit: hey, it seems that anybody except me already knows and applies the little dirty secret ! Is this a genetic transmission ? :)

9:31 LauJensen: lpetit: just question everything about your setup, eventually you'll end up on Arch, using Awesome as the WM and Emacs for everything else. np bye :)

9:31 Raynes: I never really minded ctrl being ctrl. I just changed it to see if it made a significant difference, and I got used to it.

9:32 lozh: Would you expect (ns (symbol "blah")) to work, or (ns (ns-name (symbol "blah"))?

9:32 chouser: nope

9:33 ns is 1~~~7`

9:33 something is wrong with my keyboard

9:33 ns is a macro, so its args may not (and 1~~~7`

9:33 in fact are not) evaluated

9:33 1~

9:33 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

9:34 Raynes: o.o

9:35 chouser: sorry about that.

9:36 lozh: nps, I guess that means that Dranik was out of luck with what he was trying in http://gist.github.com/492178

9:36 lpetit: LauJensen: and using a Kinesis Contoured keyboard, and live in Denmark, etc. :)

9:37 chouser: ah, no that could still be made to work.

9:37 arkh: lpetit: the kinesis would be so much better if it had tilt (clockwise on the left, counter-clockwise on the right) with its split

9:38 lpetit: I have no improvements for Denmark ;)

9:38 chouser: something like (defmacro mywin [name] `(ns ~(symbol "macros" name) ...))

9:40 Nikelandjelo: Dranik's variant also work if replace macros.~name with only ~name. And call (mywin macros.win)

9:42 lpetit: arkh: I've looked at the kinesis. Seem very expensive, and I've no real proof that it is *that* better. Maybe the kinesis which switches the keyboard in the halves, ...

9:42 arkh: lpetit: true, there is the other model(s)

10:01 LauJensen: lpetit: would be great to have you up here :)

10:03 lpetit: LauJensen: thanks for the compliment :)

10:03 I also wish I had more clojurists near me, but having Christophe is already a great chance !

10:11 LauJensen: Yea its hard to find a better sparing partner than him

10:43 noidi: I'd like to pick a Java class in a conditional statement and give the picked class a name using let; that works fine, but how can I create an instance of the class?

10:43 ,(let [d BigDecimal] (new d 3))

10:43 clojurebot: java.lang.IllegalArgumentException: Unable to resolve classname: d

10:48 lpetit: ,(source clojure.lang.Reflector)

10:48 clojurebot: java.lang.Exception: Unable to resolve symbol: source in this context

10:48 lpetit: ,(show clojure.lang.Reflector)

10:49 clojurebot: java.lang.Exception: Unable to resolve symbol: show in this context

10:49 lpetit: bleh

10:49 ~source clojure.lang.Reflector

10:49 noidi : there it is ^^^

10:50 noidi: lpetit, thanks!

10:50 lpetit: noidi: invokeConstructor

10:51 noidi: ,(let [d BigDecimal] (clojure.lang.Reflector/invokeConstructor d (to-array [3])))

10:51 clojurebot: 3M

10:51 noidi: that's a bit verbose, but works great

10:52 I'll grep the contrib sources just in case, maybe it's wrapped into a nicer package somewhere :P

10:53 apparently not

10:54 lpetit: ,(clojure.lang.Reflector BigDecimal 3)

10:54 clojurebot: java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn

10:55 lpetit: ,(clojure.lang.Reflector/invokeConstructor BigDecimal 3)

10:55 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to [Ljava.lang.Object;

10:57 lpetit: ,(BigDecimal/valueOf 3)

10:57 clojurebot: java.lang.IllegalArgumentException: No matching method found: valueOf

10:58 lpetit: ,(BigDecimal/valueOf (long 3))

10:58 clojurebot: 3M

10:59 lpetit: ,(clojure.lang.Reflector/invokeStaticMethodVariadic BigDecimal "valueOf" (long 3))

10:59 clojurebot: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String

11:00 lpetit: ,(clojure.lang.Reflector/invokeStaticMethodVariadic (.getSimpleName BigDecimal) "valueOf" (long 3))

11:00 clojurebot: java.lang.ClassCastException: java.lang.Long cannot be cast to [Ljava.lang.Object;

11:00 lpetit: hehe, I give up

11:02 lozh: ,(clojure.lang.Reflector/invokeConstructor BigDecimal (to-array [3]))

11:02 clojurebot: 3M

11:02 jfields: is it possible to add additional methods to a proxy that are not in any of the interfaces specified and call those methods?

11:03 (.runAlso (proxy [Runnable] [] (run [] (println "running")) (runAlso [] (println "running also"))))

11:03 chouser: ,(clojure.lang.Reflector/invokeStaticMethod BigDecimal "valueOf" (to-array [(long 3)]))

11:03 clojurebot: 3M

11:03 chouser: lozh: you beat me!

11:04 oh, we did slightly different things. that's good. :-)

11:04 lozh: Unfortunately I know java better than clojure... :)

11:05 chouser: jfields: no, proxy can only implement existing interface methods

11:05 jfields: thanks chouser

11:06 chouser: jfields: but you can use defprotocol to create a new interface with methods of its own.

11:09 lozh: ,(defmacro my-new [class-name & args] `(new ~(symbol class-name) ~@args))

11:09 clojurebot: DENIED

11:09 lozh: with that you could do (my-new "BigDecimal" 3)

11:12 chouser: yes, but only if you knew the class name at compile-time

11:12 in which case you might was well say (BigDecimal. 3)

11:34 lpetit: ~source mapcat

12:13 slyrus: technomancy: so... how do I build leiningen?

12:18 git checkout 3dc47c138 ; lein self-install # works, of course, but it would be nice to not have to do that. I'd just as soon build my own jar than have to check out an old version, pull a jar and then checkout the head.

12:27 technomancy: slyrus: you need an older version of lein to bootstrap the deps for a checkout.

12:27 it's self-hosting

12:28 slyrus: ok, but why do you need an _older_ version?

12:28 shouldn't the current version be able to build itself?

12:29 technomancy: oh sure; was just assuming the current version hadn't been built yet.

12:29 I just haven't uploaded a prebuilt jar for 1.2.1-SNAPSHOT yet for self-install since that version is so new.

12:30 slyrus: right, that's the symptom I'm seeing.

12:31 I notice that there are many more things in leiningen/lib than in project.clj's dependencies. are these dependencies computed (and pulled) by maven?

12:31 technomancy: yep, many of them are are transitive dependencies

12:33 slyrus: ok, so if I checkout an older version, I can do lein self-install and things are happy. BUT if I then upgrade to the HEAD, I don't have the current jar. How do I move from the old version to the new?

12:34 technomancy: just do "lein deps" in the checkout

12:34 slyrus: but the question is ... when do I checkout the current HEAD?

12:35 after doing lein deps?

12:35 (recall that I had to checkout the pre-1.2.1 to get things to build)

12:36 and I would argue that lein isn't self hosting, but rather older-version hosting, ATM :)

12:37 mmarczyk: it's just not being packaged in between releases

12:37 slyrus: right, and it's self-fully-packaged-hosting then...

12:38 mmarczyk: one cannot hope for more than that, can one? :-)

12:38 slyrus: it would be nice if there were a minimal build tool that could then be used to self-host, but

12:38 yeah, the current situation is probably workable, I was just confused on how to get back to a working state

12:39 mmarczyk: well, you can use pom.xml with mvn

12:39 I guess

12:39 never tried that, mind you

12:39 not that I'm calling mvn minimal :-P

12:39 slyrus: mmarczyk: I added some shortcut documentation the other day

12:39 mmarczyk: but it is compared to ant + mvn + wrapping = lein

12:39 slyrus: mmarczyk: actually, you _can't_ because there's no pom.xml

12:39 mmarczyk: slyrus: cool! :-)

12:40 no pom.xml? I'm sure I've got one in my checkout, but perhaps it's in .gitignore

12:40 slyrus: and some more functionality and bug fixes to

12:40 mmarczyk: ...it is

12:40 slyrus: ah, it is!

12:40 mmarczyk: hm

12:40 slyrus: that's what I was looking for. hrmmmm indeed.

12:42 mmarczyk: well, to my untrained eye

12:43 this doesn't look like a pom which could actually be used to build anything

12:43 just some metadata and dependencies

12:43 slyrus: perhaps it's vestigal

12:43 mmarczyk: which makes perfect sense, of course...

12:46 * slyrus waits for somebody to build a java build tool called Binks

13:21 arohner: what is the proper way to write a macro that emits type hints?

13:21 ^foo ~obj in the returned code doesn't seem to be doing it

13:26 rubydiamond_: http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html are these paths mentioned valid now

13:26 ~/opt/swank-clojure/src/emacs

13:26 clojurebot: Titim gan éirí ort.

13:26 rubydiamond: http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html are these paths mentioned valid now

13:27 ~/opt/swank-clojure/src/emacs

13:27 clojurebot: It's greek to me.

13:27 rubydiamond: ~/opt/swank-clojure/src/main/clojure

13:27 clojurebot: No entiendo

13:27 rubydiamond: technomancy: you there?

13:31 mmarczyk: arohner: (with-meta obj {:tag 'foo})

13:33 arohner: mmarczyk: I haven't been able to get that to work either

13:33 mmarczyk: still, this is the correct way

13:34 could you make a Gist of your macro?

13:34 I mean, actually it is ~(with-meta obj {:tag 'foo})

13:36 rubydiamond: ~/opt/swank-clojure/src/main/clojure & ~/opt/swank-clojure/src/main/clojure are not there in swank-clojure

13:36 clojurebot: see swank

13:36 mmarczyk: the point the metadata needs to be attached to the symbol in the expansion, meaning that you have to attach it when the macro gets expanded, which is after read time, but before runtime

13:37 arohner: here's what I tried last: http://gist.github.com/492566

13:37 mmarczyk: arohner: ok, I'll have a look

13:37 arohner: Indexed here is clojure.lang.Indexed

13:37 mmarczyk: arohner: also, I've recently answered an SO question which might be relevant, just found the link:

13:37 http://stackoverflow.com/questions/3330666/using-clojure-deftype-as-a-parameterized-function

13:38 arohner: it needs to be 'Indexed -- note the quote

13:39 arohner: mmarczyk: ah, fully qualified

13:39 the compiler wasn't happy with 'Indexed, but was with 'clojure.lang.Indexed

13:39 mmarczyk: thanks

13:39 mmarczyk: np

13:40 I'd expect it to be more about class vs. symbol -- the type hint should be a symbol, I believe

13:40 anyway, nice macro!

13:43 rubydiamond: can somebody help me in understanding..

13:43 what line of http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html makes

13:43 slime to load slime repl * clojure

13:43 instead of sbcl

13:45 anybody there?

13:45 ztellman: what's up?

13:47 rubydiamond: ztellman: hey

13:47 I need to setup my inferior-lisp-program to swank clojure

13:48 ztellman: doesn't swank bypass inferior-lisp?

13:48 seancron: rubydiamond: Do you have lein installed?

13:49 rubydiamond: ztellman, seancron I have this http://github.com/anildigital/emacs/blob/master/anil/slime.el

13:49 seancron: yes.. I have lean installed

13:49 if i comment above slime.el code ..

13:49 it asks me lisp program not found

13:50 seancron: Then in your project.clj, add to dev-dependencies swank-clojure "1.2.1"

13:50 rubydiamond: but I wonder how this guy http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html is able to do that .. without setting inferior-lisp-program

13:50 seancron: like this :dev-dependencies [[swank-clojure "1.2.1"]]

13:50 like this : dev-dependencies [[swank-clojure "1.2.1"]]

13:50 technomancy: those instructions are waaaay out of date

13:51 ztellman: rubydiamond: you're running "lein swank" at the command line, and then "slime-connect" within emacs?

13:52 rubydiamond: technomancy: right ~/opt/swank-clojure/src/main/clojure & ~/opt/swank-clojure/src/main/clojure paths are not valid now

13:52 ztellman: slime-connect works

13:52 now I am trying to setup the way http://riddell.us guy has done

13:52 basically copied clojure.jar and clojure-contrib.jar to ~/.clojure

13:53 now I just want to type 'slime'

13:53 and which should show me the swank clojure prompt

13:53 am i missing something here

13:53 technomancy: rubydiamond: it's a lot easier if you follow the swank-clojure readme

13:53 mmarczyk: slyrus: I think connected-components could (should?) use recur to self-call

13:53 technomancy: rather than some random stuff you found on a guy's blog

13:54 ztellman: rubydiamond: maybe you won't have any better success with this, but I've found it's easier to do (setq swank-clojure-binary "path/to/clj/script")

13:54 just have something that will give you a REPL with the appropriate classpaths set

13:55 and point swank-clojure-binary at it

13:56 rubydiamond: ztellman: which script I should point to

13:56 ztellman: rubydiamond: I created one of my own, but this might work for you: http://github.com/liebke/cljr

13:57 slyrus: mmarczyk: good idea, but the naive change doesn't work for some reason. hmm...

13:58 also, if that blows up the stack, you're probably likely to have other problems elsewhere!

13:58 mmarczyk: sure, but I think recur might be a bit faster at no cost at all (incl. to readability)

13:58 though if it breaks things

13:59 then I suppose I'm wrong on this point ;-)

13:59 I can't see why it would, though... hm.

13:59 raek: lozh: my reply to your my-ew macro:

13:59 rubydiamond: btw which is good .. running lein swank and then slime-connect

13:59 slyrus: no, i agree. it's a good idea. question is why doesn't it work?

13:59 raek: (defmacro runtime-new "Much like new, but the first argument can be anything that evaluates to a class" [class & args] `(clojure.lang.Reflector/invokeConstructor class (to-array args)))

13:59 technomancy: mmarczyk: the pom can be used to fetch the dependencies; you just have to copy jars frob target/dependency to lib

13:59 I will see about documenting that.

13:59 rubydiamond: or running slime to directly connect to swank-clojure

14:00 raek: hrm, should be ~class and ~args, too

14:00 technomancy: ~swank

14:00 clojurebot: swank is try the readme. seriously.

14:00 lozh: ~@args?

14:00 clojurebot: I don't understand.

14:01 mmarczyk: technomancy: ah, right -- and that's enough, because nothing needs to be compiled when working out of a checkout... cool

14:01 lozh: or does to-array deal with that?

14:01 raek: to-array works on a collection, right? in that case: no.

14:01 lozh: cool

14:02 slyrus: mmarczyk: [acc] -> acc in the arg list makes recur work. why would that be?

14:02 raek: ,(doc to-array)

14:02 clojurebot: "([coll]); Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util.Collection.toArray()."

14:02 raek: ok, it does

14:03 rubydiamond: getting this error

14:03 on typing slime

14:03 apply: Searching for program: No such file or directory, lisp

14:04 raek: the swank/slime/clojure-mode tutorial on ridell.us should really contain a link to the swank-clojure readme at the top!

14:04 mmarczyk: slyrus: ah, never thought about that, but I guess that's because defn does destructuring in an implicit first-line let or sth (will check in a sec)

14:04 raek: preferably, a working one, too

14:05 I must admitt, I've been lazy too

14:05 rubydiamond: don't know why.. but i don't want to use package.el

14:05 raek: it was the first tutorial I found hwn googling "emacs clojure ubuntu"

14:05 mmarczyk: slyrus: so, maybe try recurring with an extra [ ... ] added around the second arg

14:05 raek: I've managed to run slime without package.el

14:06 slyrus: or just remove [] off the arg list. I'd still like to understand the difference between (call-myself arg1 arg2) and (recur arg1 arg2) though...

14:07 raek: rubydiamond: try to add this: (ad-activate 'slime-read-interactive-args)

14:07 I think you need to have that if you're not using package.el

14:07 mmarczyk: slyrus: if you remove the [] from around acc, you will of course get something else passed inside it

14:08 slyrus: actually the simplest way to proceed would be to provide to fn bodies

14:08 rickmode: slyrus: recur is clojure's answer to tail-call optimization. basically recur is a loop. calling the method directly uses the stack and so can cause the stack to run out

14:08 rubydiamond: raek: hmm yeah.. something it's downloading clojure

14:09 mmarczyk: slyrus: (defn connected-components ([graph] (connected-components graph nil)) ([graph acc] ...))

14:09 rubydiamond: raek: hope it sets path and loads it automatically

14:10 raek: rubydiamond: I would recommend to start the swank server with lein swank

14:10 rubydiamond: raek: yeah.. I can start the server and do slime-connect

14:10 but basically I want to point my slime to swank-clojure

14:10 raek: just starting slime makes emacs start its own swank server

14:10 rubydiamond: currently my slime goes to CL-USER which is lisp

14:10 mmarczyk: slyrus: anyway, if you recur in a function with rest args, the final argument to recur will need to be a seqable which it will then be possible to destructure as per the specification after & in the arg vector

14:11 rubydiamond: raek: for me that is not the case

14:11 raek: ...and that swank server is not configure to include any project's paths into the classpath

14:12 there is also swank-clojure-project that does sort of the same thing as lein swank, but doesn't use leiningen

14:12 technomancy: is swank-clojure-project deprecated?

14:12 rubydiamond: does slime-connect:ing work for you?

14:13 tridd3ll: rubydiamond: saw you were asking about my tutorials in the irc log... here is one I made but never blogged about: http://riddell.us/ClojureSwankLeiningenWithEmacsOnArch.html

14:13 rubydiamond: raek: yes.. it works..

14:13 raek: it connects to swank server started with lein

14:13 tridd3ll: rubydiamond: it's for arch but on the package management stuff is different that ubuntu

14:13 raek: tridd3ll: are you the author of that blog?

14:13 tridd3ll: yes

14:13 alexyk: what would you use to suck in all of #clojure logs off n01se.net?

14:14 raek: 1) the link to technomancy's blog is broken

14:14 tridd3ll: raek: the above link is much more current... but not tested with 1.2

14:14 rubydiamond: raek: right

14:15 technomancy: you should write the other way of running swank clojure..

14:15 without package.el

14:15 users like me prefer not to use packages.el

14:15 technomancy: get used to package.el; it's part of Emacs now

14:15 raek: 2) it would be *very* good if there was a link to the readme files in technomancy's repos

14:16 preferably with a note that they are the most up to date instructions

14:16 alexyk: technomancy: is your http lib the way to scrape the wild web?

14:16 tridd3ll: rubydiamond: need to drop back off irc again... on-site at a customer and can't connect... went on my aircard to note the location of a more recent tutorial.. hope it helps

14:17 raek: the http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html page is the first result on google if one searches for "clojure emacs ubuntu"

14:17 it would be very helpful if that could point to the most up-to-date documentation

14:17 tridd3ll: raek: which is where?

14:18 rubydiamond: tridd3ll: is it written by you?

14:18 raek: swank-clojure: http://github.com/technomancy/swank-clojure

14:18 tridd3ll: raek: my more recent tutorial or something else?

14:18 raek: clojure-mode: http://github.com/technomancy/clojure-mode

14:18 rubydiamond: why there are two repositories of swank-clojure ..

14:19 raek: all articles about how to setup clojure with emacs, preferably

14:19 rubydiamond: which one is valid ..

14:19 raek: ....imho

14:19 arohner: mmarczyk: what if you want to add a type hint to an array, in a macro? I'm getting the exception that arrays don't support IMeta.

14:19 rubydiamond: is it valid swank-clojure git://github.com/jochu/swank-clojure.git ?

14:19 tridd3ll: raek: well, that link is not really a step by step tutorial... there are many ways to configure an environment, mine didn't use the emacs package management stuff

14:20 mmarczyk: arohner: you don't place hints on the actual objects to be hinted, but rather on the names they'll be bound to

14:20 arohner: so if you want to generate a let -- (let [arr <the-array>] ...)

14:20 arohner: attach the hint to arr

14:20 arohner: mmarczyk: k. thanks again

14:20 mmarczyk: np

14:20 rubydiamond: tridd3ll: yeah.. I also don't use emacs package management stuff.

14:22 seancron: rubydiamond: You're using ubuntu, right? What version?

14:23 rubydiamond: seancron: I am now using Snow Leopard on Macbook Pro

14:24 seancron: rubydiamond: Ah, my mistake. I thought you had said you used Ubuntu

14:24 rubydiamond: seancron: nope :)

14:24 seancron: What version of emacs do you have?

14:24 tridd3ll: raek: but yes, this one http://riddell.us/ClojureSwankLeiningenWithEmacsOnArch.html is much more recent

14:24 and last I knew worked well

14:24 rubydiamond: yes, it's my much neglected blog :-)

14:24 raek: I'll try to get an update to the older entry to point to newer documentation

14:25 rubydiamond: raek: what should I do once (ad-activate 'slime-read-interactive-args) downloads all the necessary files

14:25 chrisffm: hi

14:25 raek: tridd3ll: thanks! http://github.com/technomancy/swank-clojure would be the new link-to-rule-them-all regarding swank and how to connect to it

14:26 rubydiamond: raek: nope.. technomancy's tutorial assumes you use packages.el

14:26 chrisffm: ,(def a (repeat 5 (transient [])))

14:26 clojurebot: DENIED

14:26 technomancy: point it to the assembla wiki if you don't like the official docs for some reason

14:26 chrisffm: :(

14:27 seancron: rubydiamond: Can you upgrade emacs to emacs 23?

14:28 rubydiamond: seancron: it's emacs 23

14:28 raek: I'm not an emacs guru... all I know is that technomancy (who is the current maintiner of swank-clojure) has to point a lot of people to the official updated docs

14:29 rubydiamond: this is my .emacs if that will provide any help: http://gist.github.com/443590

14:29 rubydiamond: raek: okay.. checking

14:29 btw here is my emacs config http://github.com/anildigital/emacs

14:29 tridd3ll: raek: yep, what I'll do is preface my tutorials with links to the wiki and the relevant swank-clojure, etc links... and then if my tutorials also help (or don't work) then they can access information elsewhere

14:30 seancron: So why not use ELPA?

14:30 rubydiamond: raek: is this path in your emacs config right "/Projekt/swank-clojure/src/main/clojure" ?

14:30 I can see that there is not folder named main now

14:30 in swank-clojure

14:30 raek: there is tilde in that path

14:31 ~/Projekt/swank-clojure/ is where I keep the cloned git repo

14:31 clojurebot: You don't have to tell me twice.

14:32 rubydiamond: raek: yeah I can see but is this particular path present ".../src/main/clojure"

14:32 I don't see folder named main in src folder

14:33 raek: hrm, that has probably been there for a long time

14:33 just the src/ part will probably do now

14:34 rubydiamond: raek: :)

14:34 right

14:34 raek: that is the root of the clojure code of swank-clojure, anyway

14:34 seancron: rubydiamond: Why can't you use package.el?

14:35 raek: and that has to be on the classpath for clojure to find the swank stuff

14:35 rubydiamond: seancron: it has all the packages listed which I have added as submodules

14:35 seancron: I keep watch on submodules

14:36 and when there are commits.. I just update those

14:36 raek: anyway, using slime-connect to connect to a swank server started outside emacs seems to be the preferred way now

14:36 rubydiamond: git submodule foreach git pull

14:36 that is not possible with packages

14:36 raek: really?

14:36 then I don't need to setup my slime to connect to swank.. it's connecting to lisp now

14:37 I can use slime-connect to connect swank server

14:37 raek: yes

14:37 "Previous versions of Swank Clojure bundled an Elisp library called swank-clojure.el that provided ways to launch your swank server from within your Emacs process. While swank-clojure is still distributed with the project, it's a much more error-prone way of doing things than the method outlined above."

14:38 rubydiamond: oh nice

14:38 then my setup is good one

14:38 I thought it's wrongly I have setup

14:39 raek: there was some way of starting swank from emacs with the slime command

14:39 but that does not really work well when you have multiple projects

14:39 better to let the project management tool (e.g. leiningen) to set up the correct class path and launch swank

14:40 jfields: if I want to doseq over [1 2 3 4 5 6] but I want to do it in pairs such that it iterates 3 times and gives me a pair each time, how would I do that?

14:40 raek: jfields: partition

14:40 rubydiamond: raek: yeah that looks correct way..

14:40 raek: ,(partition 2 [1 2 3 4 5 6])

14:40 clojurebot: ((1 2) (3 4) (5 6))

14:41 jfields: cool, thanks guys

14:41 rubydiamond: lein is just awesome

14:41 technomancy: can I get the stickers

14:41 mailed to my address

14:41 :p

14:41 raek: stickers?

14:41 rubydiamond: yeah...

14:42 technomancy: rubydiamond: sure, but you have to contribute a patch first. =)

14:42 rubydiamond: :)

14:42 technomancy: hope I can do that in coming days..

14:43 http://github.com/downloads/technomancy/leiningen/leiningen-banner.png is the one right?

14:44 technomancy: haven't decided yet

14:44 slyrus: mmarczyk: ah, I didn't realize that about recur with & args. thanks!

14:44 mmarczyk: slyrus: :-)

14:46 alexyk: so folks, what's the smartest, cutest way to download a bunch of web pages?

14:47 slyrus: mmarczyk: so if this were really an optional second arg intended to be called from user code, I'd do (recur ... [acc]), but since this isn't, I'm happy to cheat and just not destructure acc in the & args and... problem solved.

14:48 but, like I said, if we're sunk here due to lack of stack space, there are probably other calls that are truly recursive calls that are going to blow the stack...

14:49 on another resource limitation note, I did try to compute the graph-distance-matrix of a random graph with 1000 nodes and 10000 edges and ran out of heap space... not sure I really need to compute that though, so I'll skip trying to make that work until I (or somebody else) actually needs it

14:50 mmarczyk: did you see my comment about bft-recur?

14:51 alexyk: slyrus: what are you computing?

14:51 slyrus: what am I actually computing or what am I building general infrastructure for computing?

14:51 the stuff I'm actually doing is fairly small graphs (atoms and bonds in molecules)

14:52 but it would be nice if the core routines in shortcut could work on graphs of 1000s of nodes

14:52 alexyk: slyrus: ah ok; but the infrastructure sounds interesting :)

14:52 mmarczyk: slyrus: my personal preference would be not to expose the extra arg at all

14:52 slyrus: which they mostly do, except for the n-x-n graph distance of all the nodes

14:52 alexyk: slyrus: usually you see graphs and paths in social web

14:53 mmarczyk: slyrus: and just go with a (letfn [(do-actual-work ...)] (do-actual-work the-only-user-visible-arg))

14:53 alexyk: (hence it stumbled on my grep :)

14:53 mmarczyk: but anyway, I need to go away for a sec, brb

14:54 raek: do-actual-work doesn't use only tail call recursion?

14:54 slyrus: your library sounds relly interesting

14:55 do you have a repo for it?

14:57 Nikelandjelo: How to reload some clj sources after I changed them if I use swank?

14:59 qbg: Nikelandjelo: You could recompile the file with C-c C-k

14:59 slyrus: raek: thanks

14:59 raek: you can always run (require 'the.name.space :reload) at the repl

14:59 slyrus: raek: http://github.com/slyrus/shortcut

15:01 Nikelandjelo: qbg, raek: Thanks, guys.

15:01 raek: a graph library is a really neat thing to have in one's toolbox

15:03 slyrus: yeah, that's my thinking too. c.c.graph is nice, but I needed undirected graphs, hence shortcut.

15:03 raek: slyrus: did you find out about recur vs lazy-seq?

15:04 I saw some questionmarks in the source

15:04 slyrus: no, it's still a question for me

15:04 raek: ok. recursive calls in lazy-seq does not consume stack

15:05 since the call is made from another place later

15:05 the current stack frame is unwinded when the lazy-seq object is returned

15:06 slyrus: ok, but I can't seem to use recur in a function the returns a lazy-seq

15:06 perhaps I'm doing something/thinking about this wrong

15:06 raek: yes.

15:06 no

15:06 that is the way it should

15:06 slyrus: ah, so I don't need to worry about blowing up the stack in breadth-first-traversal because I'm using a lazy-seq?

15:07 raek: yes

15:07 slyrus: ok, great. thanks!

15:07 raek: the call to your function *does* return after the first steo

15:07 slyrus: bft-recur can go away then

15:07 right, got i.

15:07 t

15:08 raek: if you don't want to expose the 3-arg function, you could let or letfn it

15:09 recur has the nice property that you can specify an unnamed point to jump back to with loop

15:10 like in this factorial function : (defn fac [n] (loop [n n, acc 1] (if (zero? n) acc (recur (dec n) (* n acc)))))

15:13 slyrus: yeah, yeah :)

15:15 common-lisp programmers are used to doing all sorts of crazy things with lambda lists like &aux variables :)

15:15 but I'll hide all of the & state vars with letfn's if folks want nice clean APIs...

15:17 chrisffm: hi

15:17 serp_: hoi

15:17 chrisffm: maybe somebody has an idea what i am doing wrong:

15:18 serp_: need more info than that

15:18 chrisffm: i googled but did not find anyone with the same problem

15:18 (def a (repeat 5 (transient [])))

15:19 and than (map #(persistent! %) a)

15:19 i get: java.lang.IllegalAccessError: Transient used after persistent! call

15:19 qbg: Repeat doesn't do what you want

15:19 chrisffm: not?

15:20 qbg: ,(let [a (repeat 2 (transient []))] (identical? (first a) (second a)))

15:20 clojurebot: true

15:20 chrisffm: ahhh

15:20 qbg: ,(let [a (repeatedly 2 #(transient []))] (identical? (first a) (second a)))

15:20 clojurebot: false

15:20 chrisffm: i see :(

15:20 raek: repeatedly takes a no-arg fn

15:20 chrisffm: okay, shame on me

15:21 ;(

15:21 thank you very much

15:21 qbg: State is hard! Lets go shopping.

15:21 chrisffm: lol

15:22 need to finish this. then perhaps shopping ;)

15:23 thank you anyway

15:51 pedroteixeira: what's the current way to reload protocol impls, during an interactive repl test session?

15:52 it seems that removing/requiring namespace has no effect

15:52 chouser: try require with :reload or :reload-all

15:55 pedroteixeira: a deftype impl keeps executing old code. i've tried (alter-var-root #'my-namespace/MyProtocol assoc :impls {}) with no success

15:56 chouser: currently using lazytest, I think it does that already but will try it manually now..

15:58 even removing the generated .class, old deftype impl is execute.. :/

15:59 mmarczyk: so, is there a feature freeze in place in contrib? or maybe just on the 1.2.x branch?

16:03 pedroteixeira: I'd expect it to work they way you want if you used extend (-type, -protocol) to provide the protocol impls rather than inlining them in the deftype

16:04 pedroteixeira: mmarczyk: thanks, will try that now. you can reload protocols' impls with no problem then?

16:04 mmarczyk: pedroteixeira: I guess that when you inline, the deftype-generated class implements the appropriate interface, which is simply not the one accompanying the recreated protocol

16:04 well, I can check

16:04 it makes sense to me that this should happen though

16:06 ah, wait, I might have misunderstood what you're asking about... I think the solution is still the same, though

16:06 going off to check

16:09 pedroteixeira: mmarczyk: you were right, with extend-type, impl was reloaded :)

16:09 mmarczyk: cool :-)

16:10 pedroteixeira: mmarczyk: i actually prefered the style with extend.. was only using inline before :(

16:10 mmarczyk: pedroteixeira: the question remains

16:10 how do we remove impls altogether

16:10 I've no idea, tbh

16:11 and I'm pretty amazed to learn that (def PFoo nil) doesn't seem to help

16:14 Licenser: a question I have my-namespace.a/xxx and (use) my name-space.a in my-namespace.b then need to redefine xxx how can I remove it?

16:15 mmarczyk: (ns-unmap 'my-namespace.a 'xxx)

16:17 Licenser: way thank you!

16:17 mmarczyk: :-)

16:32 raek: slyrus: I made a gallery of various implementations of the factorial function illustrating different ways of doing recursion in clojure: http://gist.github.com/492810

16:33 the book Programming Clojure as a very good chapter about this

16:35 qbg: raek: No reduce version?

16:36 raek: heh, no...

16:36 that is, of course, also a very good way of implementing the factorial function

16:37 qbg: ,(take 10 (reductions * 1 (iterate inc 1)))

16:37 clojurebot: (1 1 2 6 24 120 720 5040 40320 362880)

16:38 mmarczyk: (def facts (concat [1] (lazy-seq (map * facts (iterate inc 1)))))

16:39 raek: I manly wrote the gist to show how recursive calls looks like in different situations

16:39 mmarczyk: actually skip the lazy-seq

16:39 raek: there are of course better ways of implementing factorial

16:39 ...than those I showed

16:40 a self-refering one, how neat!

16:41 qbg: Why recurse when you can get a function to do it for you?

16:41 mmarczyk: there's also (take 10 (cseq/rec-seq facts (concat [1] (map * facts (iterate inc 1))))) with cseq = clojure.contrib.seq ... ok, enough ;-)

16:43 * qbg waits for a monad based solution

16:43 raek: qbg: I prefer composition of functions too, but that was not the point of the gist

16:45 miltondsilva: hi, what exactly is a sequence?

16:46 qbg: ,(trampoline ((fn fact [n acc] (if (= n 0) acc #(fact (dec n) (* n acc)))) 5 1))

16:46 clojurebot: 120

16:46 slyrus: raek: I find myself using reduce mostly

16:46 raek: miltondsilva: a sequence is a sequential view of a collection

16:46 miltondsilva: I'm having some problems understanding the whole seq? sequential?

16:46 raek: ,(seq [1 2 3])

16:46 clojurebot: (1 2 3)

16:47 raek: well, first of all, you can test wether the object in front of you is a sequence with seq?

16:47 ,(seq? (seq [1 2 3]))

16:47 clojurebot: true

16:47 raek: of course...

16:47 but

16:47 ,(seq? [1 2 3])

16:47 clojurebot: false

16:47 qbg: ,(sequential? '(1 2 3))

16:47 clojurebot: true

16:47 qbg: ,(sequential? [:a 5 :c])

16:47 clojurebot: true

16:48 chouser: be careful with these terms. They're often used casually and in a way that's somewhat imprecise.

16:48 qbg: ,(sequential? {:a 4, :b 5})

16:48 clojurebot: false

16:48 miltondsilva: hmm... shouldn't they both return true?

16:48 after looking at the clojure-cheat-sheet

16:48 raek: seqs support two operations: first and rest

16:48 miltondsilva: .(first [1 2 3])

16:48 qbg: miltondsilva: Which two?

16:49 miltondsilva: (seq? [1 2 3]) -> true?

16:49 qbg: ,(first [1 2 3])

16:49 clojurebot: 1

16:49 qbg: Works because first calls seq on its argument

16:49 raek: as a convenience feature, first, rest and the functions in the sequence library calls seq on its argument

16:49 qbg: A vector is not a seq

16:50 raek: so, vectors don't support first and rest themselves

16:50 but when calling seq on them, they return a seq-of-vector object

16:50 chouser: 'sequential?' has very limited use. It only returns true for objects that implement clojure.lang.Sequential, but that's rarely a useful fact to know.

16:50 miltondsilva: hmm.. but vectors maps lists etc aren't sequences? so what are they? is there some pred that can be use to identify them? (much like the original atom)

16:50 raek: that basically keeps track of which vector it belongs to and which index of it

16:51 qbg: ,(vector? [1 2 3])

16:51 clojurebot: true

16:51 qbg: ,(map? {:a 5, :b 3})

16:51 clojurebot: true

16:51 raek: so (seq [1 2 3]) would return something that knows about [1 2 3] and index 0

16:51 slyrus: this doesn't do what I expect: (with-open [r (io/reader "/etc/passwd")] (take 2 (line-seq r)))

16:51 take 1 works, but the stream is closed after that.

16:52 raek: caling 'first' on that will lookup index 0 in the vector, and return 1

16:52 qbg: slyrus: Take returns a lazy seq, perhaps you should use doall?

16:52 raek: calling rest in it will make *a new* thinh that knows about the vector and index 1

16:52 *on it

16:53 chouser: perhaps 'coll?'

16:55 raek: miltondsilva: if you have 2h over, I recomment watching http://clojure.blip.tv/file/734409/

16:55 (one thing about that one, though: what he refers to as 'rest' is now called 'next', (defn next [x] (seq (rest x))) )

16:56 slyrus: qbg: sure, but that kind of defeats the purpose, doesn't it? I was just surprised that line-seq only lets you read one line at a time. perhaps I'm doing something wrong.

16:56 this works: (with-open [r (io/reader "/etc/passwd")] [(take 1 (line-seq r)) (take 1 (line-seq r))])

16:57 ,(with-open [r (io/reader "/etc/passwd")] [(take 1 (line-seq r)) (take 1 (line-seq r))])

16:57 clojurebot: java.lang.Exception: No such namespace: io

16:57 miltondsilva: I do.. and will watch it now... anyway, it seems to me that something like atom whould be a good thing too have in core.. I guess

16:57 slyrus: (with-open [r (clojure.java.io/reader "/etc/passwd")] [(take 1 (line-seq r)) (take 1 (line-seq r))])

16:57 ,(with-open [r (clojure.java.io/reader "/etc/passwd")] [(take 1 (line-seq r)) (take 1 (line-seq r))])

16:57 clojurebot: java.security.AccessControlException: access denied (java.io.FilePermission /etc/passwd read)

16:57 slyrus: heh. didn't think that would work.

16:59 qbg: slyrus: Take a look at the source of line-seq

16:59 raek: slyrus: the with-open macro will close the reader when the caller returns

16:59 qbg: The first element is not lazy, which is why it works in that case

17:00 raek: since line-seq is lazy, it will not have read everything when the close is done

17:00 slyrus: oh, thanks raek

17:00 raek: close would have to be lazy too

17:00 slyrus: awesome

17:00 (with-open [r (io/reader "/etc/passwd")] (doall (take 4 (line-seq r))))

17:01 qbg: I missed your point about where to put the doall!

17:01 raek: you can roll your own line-seq and make that close the reader

17:02 chouser: there's one of those in contirb already, but it's not recommended

17:03 raek: (defn my-line-seq [rdr] (lazy-seq (if-let [line (.readLine rdr)] (cons line (my-line-seq rdr)) (do (.close rdr) nil))))

17:03 chouser: hrm, why?

17:04 bad habit to close some else's file?

17:04 chouser: raek: because it's linking a real side-effect (the releasing of OS resources) with the consumption of a lazy seq

17:04 raek: isn't the .readLine call a real side-effect too?

17:05 it removes bytes from the stream

17:05 chouser: it's very easy to forget you must walk to the end of the seq in order to close the file, esp since the consumer of the seq may be very far away from the creator

17:05 raek: ah, I see

17:07 so the user should close the file himself when he's done with it, which is independent on how many lines actually got read

17:07 chouser: yes

17:07 and with-open provides a convenient way to do that while keeping the open and close near each other.

17:09 if your lazy seq leaks out past the with-open, then you'll get an error when you try to read an uncached step of the seq.

17:11 * riddochc sets up my new account on dev.clojure.org to help out with documenting things for the 1.2 release.

17:27 krunaldo: Hi guys! Is there any support for byte arrays out of the box?

17:27 I find some references with java using bytes but I don't really see how(reading the docs on Byte on java-doc).

17:28 qbg: ,(byte-array 10)

17:28 clojurebot: #<byte[] [B@a71c3a>

17:28 krunaldo: now I feel really stupid :)

17:28 qbg: ,(make-array Byte/TYPE 10)

17:28 clojurebot: #<byte[] [B@1ba63a4>

17:29 qbg: ,(byte-array [(byte 1) (byte 2) (byte 3)])

17:29 clojurebot: #<byte[] [B@18259c8>

17:29 qbg: ,(seq (byte-array [(byte 1) (byte 2) (byte 3)]))

17:29 clojurebot: (1 2 3)

17:29 chrisffm: lol

17:30 (into-array Byte/TYPE (range 10))

17:30 ;-)

17:30 krunaldo: :)

17:30 Is there any nifty way to add them all into one int?

17:31 qbg: ,(reduce + (byte-array [(byte 1) (byte 2) (byte 3)]))

17:31 clojurebot: 6

17:31 qbg: ,(reduce + [1 2 3])

17:31 clojurebot: 6

17:31 krunaldo: Ah

17:32 I meant making them into to a bitfield

17:32 qbg: You mean bitwise or them?

17:33 krunaldo: more like shifting them

17:33 chrisffm: hm use shift-left

17:34 qbg: So the first 8 bits comes from the first, the next 8 comes from the second, etc?

17:34 chrisffm: should not be to complicated

17:34 krunaldo: qbg: yes

17:34 qbg: ,(reduce #(bit-or (bit-shift-left %1 8) %2) 0 [1 2 3])

17:34 clojurebot: 66051

17:35 qbg: Well, the highest 8 come from the first there

17:35 riddochc: Hmmm.

17:35 ,(byte 255)

17:35 clojurebot: java.lang.IllegalArgumentException: Value out of range for byte: 255

17:35 qbg: You can always reverse the sequence first

17:36 The jvm's lack of unsigned math can be troubling sometimes.

17:36 riddochc: Signed, evidently.

17:36 krunaldo: Highest first is okay, I'm doing some IP-address stuff so that should be fine

17:37 thx! :)

17:42 tashafa: test

17:42 yay!

17:42 finally got emacs to work in #clojure

17:49 slyrus: raek: no thanks on the my-line-seq thing! I'm used to with-open-file and friends from CL, so I get nervous when I see file IO without one of those nearby :)

17:53 how do I get the fields of a record type?

17:54 arohner: slyrus: .getFields on the class

17:54 http://java.sun.com/javase/6/docs/api/java/lang/Class.html

17:54 slyrus: thanks arohner!

17:55 meh java arrays... I was hoping defrecord would expose the fields clojurishly. oh well.

17:56 raek: but, but, but... this library is what I've been coding on for a month: http://wiki.github.com/ztellman/aleph/channels

17:57 I was planning on releasing an alpha of mine this week...

17:57 qbg: slyrus: You could do (keys ...) on a defrecord instance

17:57 For the map based interface that defrecord provides

17:58 slyrus: well, yeah, except I'm trying to figure out how to populate my instances :) I was hoping I could get some help from the record type itself :)

17:58 qbg: Perhaps the defrecord2 macro would help that was floating around?

17:58 slyrus: wuzzat?

17:59 qbg: http://david-mcneil.com/post/765563763/enhanced-clojure-records

18:09 arkh: As a music major, did Rich learn math and algorithms on his own or through more formal means?

18:19 pedroteixeira: is there something similar to scala's regexp parser for clojure?

18:36 slyrus: ,(defrecord Foo [bogosity annoyance])

18:36 clojurebot: DENIED

18:36 slyrus: bah

18:36 ok, well, the problem is I don't know how to (apply Foo. ...)

18:37 qbg: You can't apply Foo.

18:37 You could do something like (apply #(Foo. %1 %2 ...) ...)

18:38 You could also do some reflection magic

18:47 KirinDave: slyrus: You'd need a helper function to apply that.

18:59 slyrus: I don't suppose there's a (make-instance 'Foo ...) hiding in the bushes somewhere then?

18:59 I need a helper because Foo. is a macro?

19:00 cemerick: slyrus: Foo. is sugar for (new Foo ...)

19:00 slyrus: oh, great! thanks!

19:00 cemerick: e.g. invokes a constructor

19:00 slyrus: apply cannot be used with ctors.

19:01 slyrus: yes, I hear there are these constructor things. It's unclear how to write one or otherwise supply default values for fields in records.

19:01 cemerick: slyrus: blog post coming very shortly :-)

19:01 slyrus: cool. oh, wait, let me guess again... new is a macro not a function so I can't apply that either. hrm...

19:01 cemerick: ctors are automatically generated for deftype and defrecord classes

19:02 slyrus: (apply new '(Foo. :high :medium)) would be nice

19:02 cemerick: new is a special form

19:02 * slyrus looks around for :initform

19:02 slyrus: right, ok.

19:03 I'm sure there's a reason, but I can't see why new couldn't just be a regular function.

19:03 * slyrus wishes M-. worked on special forms

19:04 lancepantz: dnolen: you around?

19:07 cemerick: slyrus: this is decidedly bad practice, but: https://gist.github.com/bab9181cf1f1eda95caf

19:08 blog tomorrow morning about defrecord defaults

19:10 slyrus: cemerick: it's a little disturbing that that works :)

19:11 of course that's still a macro, so I can't apply that anyway, which is what a really want. argh...

19:20 cemerick: slyrus: wrapping that with a fn you can apply is totally reasonable

19:22 slyrus: the compiler doesn't seem to think so, but perhaps that's operator error on my part

19:23 I'm probably doing something stupid: (defn bogus [args] (apply-ctor Foo args))

19:33 KirinDave: ,(apply apply '(+ 1 2))

19:33 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

19:56 raek: ,(apply apply [+ [1 2]])

19:56 clojurebot: 3

20:06 KirinDave: raek: Funny how awkward that is to write using lists as containers. :)

20:06 ,(apply apply '(+ (1 2)))

20:06 clojurebot: 2

20:06 KirinDave: :)

20:06 wwmorgan: ,(apply apply (list + (list 1 2)))

20:06 clojurebot: 3

20:07 KirinDave: No I know.

20:07 It's just funny how the '() is such a ballsack sometimes. :)

20:07 wwmorgan: yes. I puzzled over that for a good five minutes :-P

20:08 KirinDave: I am still not sure what ('+ 1 2) does.

20:08 wwmorgan: the symbol is behaving like an accessor

20:09 gfrlog: ,('+ 1 2)

20:09 clojurebot: 2

20:09 KirinDave: but

20:09 ,('+ 1)

20:09 clojurebot: nil

20:09 KirinDave: I guess it's just the default coming through

20:09 But it makes for some amusing bugs.

20:09 gfrlog: ,('* 1 2)

20:09 clojurebot: 2

20:09 technomancy: ,((ancestors (class '+)) clojure.lang.IFn)

20:09 clojurebot: clojure.lang.IFn

20:10 gfrlog: ,('bit-shift-right 1 2)

20:10 clojurebot: 2

20:10 KirinDave: Stopped Clock. :)

20:10 gfrlog: so symbols are functions that return their second argument?

20:10 KirinDave: No.

20:10 gfrlog: ,('* 1 2 3)

20:10 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (3) passed to: Symbol

20:11 KirinDave: ,(:test {:test 1})

20:11 clojurebot: 1

20:11 gfrlog: that's a keyword

20:11 KirinDave: ,(:test {})

20:11 clojurebot: nil

20:11 gfrlog: a keyword in clojure is a symbol in ruby is an atom in erlang

20:11 technomancy: oh, calling a symbol calls RT.get with this as the second arg

20:11 KirinDave: ,('test {'test 1})

20:11 clojurebot: 1

20:11 KirinDave: ,('test {})

20:11 clojurebot: nil

20:11 gfrlog: ooh nice

20:12 KirinDave: ,('test {} :default)

20:12 clojurebot: :default

20:12 KirinDave: Tadaaa

20:12 technomancy: just like keywords... only nobody does it.

20:12 KirinDave: technomancy: Just like keywords because they are keywords. :)

20:12 gfrlog: symbols are keywords?

20:12 KirinDave: Or rather, keywords are them.

20:12 gfodor: I dunno if that's strictly true, but a keyword is just a symbol in a universal top level namespace.

20:13 The reason we don't use 'test and prefer to use :test for keys is that 'test gets mapped to your current namespace

20:13 technomancy: interesting that .invoke on keywords does a little more smarts surrounding ILookup than symbols do.

20:13 KirinDave: So user/test and funky/test are different values.

20:13 technomancy: wonder if there's a reason for that

20:14 KirinDave: technomancy: No idea.

20:14 ,(apply apply '(+ (1 0))) ; A pretty funny bug tho, wouldn't you agree?

20:14 clojurebot: 0

20:15 KirinDave: Not in clojure, of course.

20:15 technomancy: yeah, it's pretty weird

20:15 or at least, weird to debug.

20:34 slyrus: bah. out of heap space... how do i start my process (with lein swank preferably) with a decent sized heap?

20:41 gfrlog: I'm doing some really low level number crunching. Mostly just a bunch of adds/subtract/multiplies using integers (likely bigints). A naive clojure implementation is a lot slower than I'd like. Does anybody have any suggestions about what I should try first for optimization? Type hints? Transients? A bit of java code?

20:41 I did some profiling and the results were a bit bizarre: most time spent in var resolution

22:51 slyrus: JAVA_OPTS=-Xmx1g lein swank seems to do the trick

22:55 * slyrus wonders what his java process is doing now. Can GC take a _really_ long time if there's lots of stuff to gc?

23:07 lancepantz: slyrus: not from my experiences, i would hook a profiler up to it

23:15 daaku: is there a way to get a string back from pprint for use with logging? (i haven't gotten to the streams chapter yet :)

23:18 slyrus: lancepantz: killed the process. I think something had gone haywire. I suppose I should figure out how to inspect processes a bit at some point.

23:21 lancepantz: slyrus: i didn't find much use for it outside of optimizing garbage collection

23:21 slyrus: still, I'd like to be able to find out where my processes/threads are when things go awry, which they certainly will at some point.

23:21 lancepantz: ofcourse

23:25 chouser: Ctrl-\ on unix

23:27 that was for slyrus. -)

23:27 :-)

23:27 slyrus: chouser: that's fantastic! thanks!

23:28 chouser: ,(with-out-str (clojure.pprint/pprint []))

23:28 clojurebot: "[]\n"

23:28 chouser: and that's for daaku.

23:28 slyrus: for me too :)

23:28 daaku: chouser: cool, i got it working using a StringWriter thing too

23:29 slyrus: yay. 104855 movies and 76251 actors loaded up in shortcut. Now to connect one set to the other for my kevin-bacon-solver.

23:30 daaku: chouser: with-out-st is cool

23:31 slyrus: and it's 9 chars shorter than CL's with-output-to-string!

23:31 :)

23:32 daaku: is there a way to make some clojure code always available during development? it'd be nice to have this pprint enabled logging function globally available without needing to import stuff

23:49 is it possible to add something to the clojure namespace such that it's automatically available in every namespace when the ns macro automatically refers the clojure namespace? i want to do this in a script i load in my dev environment

23:57 this (in-ns 'clojure) (def p my-lib/p) makes (clojure/p "hi") work, but (p "hi") still doesn't work, and fails with "Unable to resolve symbol: p in this context"

23:59 wwmorgan: daaku: would a user.clj work for your purposes?

Logging service provided by n01se.net