#clojure logs

2010-07-27

00:53technomancyis it to cute to replace (clean project) (deps project) (jar project) with (doto project clean deps jar)?
00:53technomancyI think of doto as a java-interop-y thing
01:16Apage43it feels java interopy since clojury functions tend not to have side effects, i spose.
01:40hiredmanping?
01:40clojurebotPONG!
01:44jacortinasping
01:44jacortinasping?
01:44clojurebotPONG!
01:44jacortinas,('ping)
01:44clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: Symbol
01:45jacortinas"ping?"
01:45jacortinas,"ping?"
01:45clojurebot"ping?"
01:48slyrus,(str (lazy-seq "1234"))
01:48clojurebot"clojure.lang.LazySeq@251fc3"
01:49slyrus,(lazy-seq "1234")
01:49clojurebot(\1 \2 \3 \4)
01:49slyrus,(Integer/parseInt (lazy-seq "1234"))
01:49clojurebotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.lang.String
02:23SandGorgonBryan Cantrill's (of Dtrace) article bashing STM - http://dtrace.org/blogs/bmc/2008/11/03/concurrencys-shysters/
02:52herdricksay, is there a way to use memfn (or something else) to make a function from a static method?
04:04lpetittest
06:34BahmanHi all!
06:43LauJensenHey Bahman
06:44BahmanHi LauJensen!
07:40lpetitvimperator on firefox rocks !
07:48OliverUvlpetit: i agree, but I changed to chrome so no vimperator for me :(
07:58lpetitOliverUv: there's something for you on Chrome: Vimium
07:58lpetitsimilar to vimperator
08:00OliverUvnice! thanks
08:00OliverUvI've been googling around for stuff like "vimperator for chrome" but never found anything
08:01OliverUvthanks
08:12LauJensenOliverUv: I highly recommend that you use Conkeror instead, for more reasons than this channel can contain :)
08:24lpetitLauJensen: give just one :)
08:24LauJensenHas better keybindings
08:27NikelandjeloLauJensen: I haven't seen Conkeror, but what keybindings does it offer? Why are they better?
08:30LauJensenNikelandjelo: Conkeror has all of Emacs keybindings
08:35lpetitLauJensen: and you dare say those are better keybindings to a vim user ! :-p
08:35OliverUvMy hands don't appreciate emacs' keybindings
08:37lpetitMy hands hurt at all bindings involving the Control key
08:42LauJensenlpetit: 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
08:43LauJensenlpetit: 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)
08:44Dranikhello!
08:44DranikI'm trying to develop a macro which generates a java class
08:44Dranikbut it simply does not want to compile
08:45Dranikmay anybody help me with that?
08:45Dranik(the same code without the macro definition compiles greatly!)
08:46bobo_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...
08:46LauJensenbobo_: No, but its a good idea - I'll incorporate that into my next post
08:46bobo_cool
08:47lozhDranik: Put some code up and I'll give it a shot
08:47Draniklozh, may I put the code here or should I use pastebin?
08:49DranikOK, let's put it here then
08:49Dranik(ns macros.win
08:49Dranik(:gen-class
08:49Dranik :name macros.win))
08:49Dranikthis works fine, AOT-compilation goes OK
08:49DranikI want to create a macros which will generate exactly the same code
08:49Draniklook here
08:50Dranik(defmacro mywin [name]
08:50Dranik`(ns macros.~name
08:50Dranik(:gen-class
08:50Dranik :name macros.~name
08:50Dranik)))
08:50Dranik(mywin :win)
08:50DranikI'm sure I miss something really simple
08:50lozhpastebin or gisthub would probably be better, but I'll have a go, sec
08:51lozhgist.github even
08:52Draniklozh, gist: 492178
08:53lozhta
08:54lpetitLauJensen: inferring that emacs bindings are better than vi bindings from *a* (questionable) knowledge that emacs is globally better than vi is a logic error
08:55LauJensenlpetit: Like I said 'I dont actually know that they (the bindings) are better'. But Emacs is better than Vi, ask anybody in #emacs
08:55lpetitLauJensen: 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 ?
08:56LauJensenlpetit: Yea I have them swapped. Im not sure what you mean about keys on the left
08:56lpetitLauJensen: I asked on #eclipse, and surprisingly everybody told me eclipse is better than x/y/z :-p
08:56chouserMy capslock key does ctrl too.
08:56LauJensenlpetit: yea I know, it was a joke.
08:56chouserMy capslock key does ctrl too.
08:57lpetitLauJensen: 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 ?
08:58lpetitseems like this "capslock/ctrl" key swap is this kind of little dirty secrets ... :)
08:59LauJensenlpetit: Ah, I never use Ctrl+Z
08:59lpetitchouser, LauJensen: out of curiosity, you changed the behaviors at the OS level, at the X server level, at the app (emacs/vim) level ?
08:59chouserI got used to ctrl being there on Sun keyboards in college and was quite dismayed to find it was uncommon on PC keyboards.
08:59LauJensenlpetit: xmodmap - OS level
09:00lpetitLauJensen: 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
09:00LauJensenlpetit: 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
09:00lpetitLauJensen: thanks. If you intend to also talk about this little dirty secret on your next blog entry, you're welcome
09:00chouserlpetit: 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.
09:01LauJensen(and I was half serious- try to avoid tricky key-combos for maximum efficiency)
09:01lpetitLauJensen: isn't C-c something usual in emacs ?
09:01LauJensenchouser: gnome can trip you up, otherwise xmodmap should be the preferred method. Ubuntu is changing things though
09:01LauJensenlpetit: yea, and C-x, but I use one hand for those
09:02lpetitLauJensen: 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
09:03lpetits/harm/hurt/
09:03sexpbotLauJensen: 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
09:03lpetitmaybe I could swap Enter and right-control :-)
09:03LauJensenlpetit: hmm
09:03lpetitLauJensen: how old are you ?
09:03LauJensen28
09:04lpetitI'm 36: wait for 8 more years and we can talk about this again :)
09:04LauJensenSeems fair :)
09:04LauJensenthough, looking at my hands, my left hand is always rested in that slighty twisted position, so Im not twinching
09:05lpetitLauJensen: oh yes, typing CapsLock+c/x/v with the left hand indeed seems way better than Ctrl+c/x/v
09:06LauJensenI can send you mine
09:06lpetitLauJensen: if you please
09:06LauJensenremove Lock = Caps_Lock
09:06LauJensenremove Control = Control_L
09:06LauJensenkeysym Control_L = Caps_Lock
09:06LauJensenkeysym Caps_Lock = Control_L
09:06LauJensenadd Lock = Caps_Lock
09:06LauJensenadd Control = Control_L
09:06LauJensen
09:06LauJensen(for everyones benefit)
09:06lpetitwhere do I put/replace all these nice looking commands ?
09:06LauJensenput them in ~/.xmodmap
09:06LauJensenthen run xmodmap ~/.xmodmap
09:08lpetitso xmodmap will not change the behaviour of the keys if I'm using vim from a terminal ?
09:09chouserlpetit: is it an X terminal?
09:09lpetitalmost. But I also tend to access remote servers, hmmm
09:09chouseryes, but you access them via your local X session, don't you?
09:11chouserthere's another mechanism for setting capslock behavior in linux console terminals, but it's been ages since I bothered doing that.
09:11lpetitno, you're right, xmodmap will be sufficient for me too
09:12lpetitsubsidiary question: the xmodmap command must be called just once ?
09:12lpetit:wq
09:12lpetitwoops, wrong window focus
09:14lpetitapparently no, what's the *better* place to put the xmodmap command, please ?
09:14chousermine is 1~~~7`
09:15chousermine is in my .xsession
09:18lpetitchouser, LauJensen: I would like to thank you both on behalf of my wrists
09:18chouserI wish your wrists well. :-)
09:19lpetitchouser, LauJensen: no other little dirty secrets w/regards to keyboard keys switching ?
09:23chousernope, I've got nuthin.
09:23chouserexcept the dirty little secret that although emacs' infrastructure is more flexible, vim's keybindings are better.
09:23RaynesI hated the first two weeks after switching my ctrl and caps keys.
09:25lpetitRaynes: 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 !
09:28ChousukeI sometimes forget that caps lock is not control when I borrow other people's computers
09:29lpetithey, it seems that anybody except me already knows and applies the little dirty secret ! Is this a genetic transmission ? :)
09:31LauJensenlpetit: 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 :)
09:31RaynesI never really minded ctrl being ctrl. I just changed it to see if it made a significant difference, and I got used to it.
09:32lozhWould you expect (ns (symbol "blah")) to work, or (ns (ns-name (symbol "blah"))?
09:32chousernope
09:33chouserns is 1~~~7`
09:33chousersomething is wrong with my keyboard
09:33chouserns is a macro, so its args may not (and 1~~~7`
09:33chouserin fact are not) evaluated
09:33chouser1~
09:33chouser hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
09:34Rayneso.o
09:35chousersorry about that.
09:36lozhnps, I guess that means that Dranik was out of luck with what he was trying in http://gist.github.com/492178
09:36lpetitLauJensen: and using a Kinesis Contoured keyboard, and live in Denmark, etc. :)
09:37chouserah, no that could still be made to work.
09:37arkhlpetit: the kinesis would be so much better if it had tilt (clockwise on the left, counter-clockwise on the right) with its split
09:38arkhlpetit: I have no improvements for Denmark ;)
09:38chousersomething like (defmacro mywin [name] `(ns ~(symbol "macros" name) ...))
09:40NikelandjeloDranik's variant also work if replace macros.~name with only ~name. And call (mywin macros.win)
09:42lpetitarkh: 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, ...
09:42arkhlpetit: true, there is the other model(s)
10:01LauJensenlpetit: would be great to have you up here :)
10:03lpetitLauJensen: thanks for the compliment :)
10:03lpetitI also wish I had more clojurists near me, but having Christophe is already a great chance !
10:11LauJensenYea its hard to find a better sparing partner than him
10:43noidiI'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:43noidi,(let [d BigDecimal] (new d 3))
10:43clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: d
10:48lpetit,(source clojure.lang.Reflector)
10:48clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
10:48lpetit,(show clojure.lang.Reflector)
10:49clojurebotjava.lang.Exception: Unable to resolve symbol: show in this context
10:49lpetitbleh
10:49lpetit~source clojure.lang.Reflector
10:49lpetitnoidi : there it is ^^^
10:50noidilpetit, thanks!
10:50lpetitnoidi: invokeConstructor
10:51noidi,(let [d BigDecimal] (clojure.lang.Reflector/invokeConstructor d (to-array [3])))
10:51clojurebot3M
10:51noidithat's a bit verbose, but works great
10:52noidiI'll grep the contrib sources just in case, maybe it's wrapped into a nicer package somewhere :P
10:53noidiapparently not
10:54lpetit,(clojure.lang.Reflector BigDecimal 3)
10:54clojurebotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
10:55lpetit,(clojure.lang.Reflector/invokeConstructor BigDecimal 3)
10:55clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to [Ljava.lang.Object;
10:57lpetit,(BigDecimal/valueOf 3)
10:57clojurebotjava.lang.IllegalArgumentException: No matching method found: valueOf
10:58lpetit,(BigDecimal/valueOf (long 3))
10:58clojurebot3M
10:59lpetit,(clojure.lang.Reflector/invokeStaticMethodVariadic BigDecimal "valueOf" (long 3))
10:59clojurebotjava.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String
11:00lpetit,(clojure.lang.Reflector/invokeStaticMethodVariadic (.getSimpleName BigDecimal) "valueOf" (long 3))
11:00clojurebotjava.lang.ClassCastException: java.lang.Long cannot be cast to [Ljava.lang.Object;
11:00lpetithehe, I give up
11:02lozh,(clojure.lang.Reflector/invokeConstructor BigDecimal (to-array [3]))
11:02clojurebot3M
11:02jfieldsis it possible to add additional methods to a proxy that are not in any of the interfaces specified and call those methods?
11:03jfields(.runAlso (proxy [Runnable] [] (run [] (println "running")) (runAlso [] (println "running also"))))
11:03chouser,(clojure.lang.Reflector/invokeStaticMethod BigDecimal "valueOf" (to-array [(long 3)]))
11:03clojurebot3M
11:03chouserlozh: you beat me!
11:04chouseroh, we did slightly different things. that's good. :-)
11:04lozhUnfortunately I know java better than clojure... :)
11:05chouserjfields: no, proxy can only implement existing interface methods
11:05jfieldsthanks chouser
11:06chouserjfields: but you can use defprotocol to create a new interface with methods of its own.
11:09lozh,(defmacro my-new [class-name & args] `(new ~(symbol class-name) ~@args))
11:09clojurebotDENIED
11:09lozhwith that you could do (my-new "BigDecimal" 3)
11:12chouseryes, but only if you knew the class name at compile-time
11:12chouserin which case you might was well say (BigDecimal. 3)
11:34lpetit~source mapcat
12:13slyrustechnomancy: so... how do I build leiningen?
12:18slyrusgit 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:27technomancyslyrus: you need an older version of lein to bootstrap the deps for a checkout.
12:27technomancyit's self-hosting
12:28slyrusok, but why do you need an _older_ version?
12:28slyrusshouldn't the current version be able to build itself?
12:29technomancyoh sure; was just assuming the current version hadn't been built yet.
12:29technomancyI just haven't uploaded a prebuilt jar for 1.2.1-SNAPSHOT yet for self-install since that version is so new.
12:30slyrusright, that's the symptom I'm seeing.
12:31slyrusI 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:31technomancyyep, many of them are are transitive dependencies
12:33slyrusok, 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:34technomancyjust do "lein deps" in the checkout
12:34slyrusbut the question is ... when do I checkout the current HEAD?
12:35slyrusafter doing lein deps?
12:35slyrus(recall that I had to checkout the pre-1.2.1 to get things to build)
12:36slyrusand I would argue that lein isn't self hosting, but rather older-version hosting, ATM :)
12:37mmarczykit's just not being packaged in between releases
12:37slyrusright, and it's self-fully-packaged-hosting then...
12:38mmarczykone cannot hope for more than that, can one? :-)
12:38slyrusit would be nice if there were a minimal build tool that could then be used to self-host, but
12:38slyrusyeah, the current situation is probably workable, I was just confused on how to get back to a working state
12:39mmarczykwell, you can use pom.xml with mvn
12:39mmarczykI guess
12:39mmarczyknever tried that, mind you
12:39mmarczyknot that I'm calling mvn minimal :-P
12:39slyrusmmarczyk: I added some shortcut documentation the other day
12:39mmarczykbut it is compared to ant + mvn + wrapping = lein
12:39slyrusmmarczyk: actually, you _can't_ because there's no pom.xml
12:39mmarczykslyrus: cool! :-)
12:40mmarczykno pom.xml? I'm sure I've got one in my checkout, but perhaps it's in .gitignore
12:40slyrusand some more functionality and bug fixes to
12:40mmarczyk...it is
12:40slyrusah, it is!
12:40mmarczykhm
12:40slyrusthat's what I was looking for. hrmmmm indeed.
12:42mmarczykwell, to my untrained eye
12:43mmarczykthis doesn't look like a pom which could actually be used to build anything
12:43mmarczykjust some metadata and dependencies
12:43slyrusperhaps it's vestigal
12:43mmarczykwhich makes perfect sense, of course...
13:21arohnerwhat is the proper way to write a macro that emits type hints?
13:21arohner^foo ~obj in the returned code doesn't seem to be doing it
13:26rubydiamond_http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html are these paths mentioned valid now
13:26rubydiamond_~/opt/swank-clojure/src/emacs
13:26clojurebotTitim gan éirí ort.
13:26rubydiamondhttp://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html are these paths mentioned valid now
13:27rubydiamond~/opt/swank-clojure/src/emacs
13:27clojurebotIt's greek to me.
13:27rubydiamond~/opt/swank-clojure/src/main/clojure
13:27clojurebotNo entiendo
13:27rubydiamondtechnomancy: you there?
13:31mmarczykarohner: (with-meta obj {:tag 'foo})
13:33arohnermmarczyk: I haven't been able to get that to work either
13:33mmarczykstill, this is the correct way
13:34mmarczykcould you make a Gist of your macro?
13:34mmarczykI mean, actually it is ~(with-meta obj {:tag 'foo})
13:36rubydiamond~/opt/swank-clojure/src/main/clojure & ~/opt/swank-clojure/src/main/clojure are not there in swank-clojure
13:36clojurebotsee swank
13:36mmarczykthe 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:37arohnerhere's what I tried last: http://gist.github.com/492566
13:37mmarczykarohner: ok, I'll have a look
13:37arohnerIndexed here is clojure.lang.Indexed
13:37mmarczykarohner: also, I've recently answered an SO question which might be relevant, just found the link:
13:37mmarczykhttp://stackoverflow.com/questions/3330666/using-clojure-deftype-as-a-parameterized-function
13:38mmarczykarohner: it needs to be 'Indexed -- note the quote
13:39arohnermmarczyk: ah, fully qualified
13:39arohnerthe compiler wasn't happy with 'Indexed, but was with 'clojure.lang.Indexed
13:39arohnermmarczyk: thanks
13:39mmarczyknp
13:40mmarczykI'd expect it to be more about class vs. symbol -- the type hint should be a symbol, I believe
13:40mmarczykanyway, nice macro!
13:43rubydiamondcan somebody help me in understanding..
13:43rubydiamondwhat line of http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html makes
13:43rubydiamondslime to load slime repl * clojure
13:43rubydiamondinstead of sbcl
13:45rubydiamondanybody there?
13:45ztellmanwhat's up?
13:47rubydiamondztellman: hey
13:47rubydiamondI need to setup my inferior-lisp-program to swank clojure
13:48ztellmandoesn't swank bypass inferior-lisp?
13:48seancronrubydiamond: Do you have lein installed?
13:49rubydiamondztellman, seancron I have this http://github.com/anildigital/emacs/blob/master/anil/slime.el
13:49rubydiamondseancron: yes.. I have lean installed
13:49rubydiamondif i comment above slime.el code ..
13:49rubydiamondit asks me lisp program not found
13:50seancronThen in your project.clj, add to dev-dependencies swank-clojure "1.2.1"
13:50rubydiamondbut I wonder how this guy http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html is able to do that .. without setting inferior-lisp-program
13:50seancronlike this :dev-dependencies [[swank-clojure "1.2.1"]]
13:50seancronlike this : dev-dependencies [[swank-clojure "1.2.1"]]
13:50technomancythose instructions are waaaay out of date
13:51ztellmanrubydiamond: you're running "lein swank" at the command line, and then "slime-connect" within emacs?
13:52rubydiamondtechnomancy: right ~/opt/swank-clojure/src/main/clojure & ~/opt/swank-clojure/src/main/clojure paths are not valid now
13:52rubydiamondztellman: slime-connect works
13:52rubydiamondnow I am trying to setup the way http://riddell.us guy has done
13:52rubydiamondbasically copied clojure.jar and clojure-contrib.jar to ~/.clojure
13:53rubydiamondnow I just want to type 'slime'
13:53rubydiamondand which should show me the swank clojure prompt
13:53rubydiamondam i missing something here
13:53technomancyrubydiamond: it's a lot easier if you follow the swank-clojure readme
13:53mmarczykslyrus: I think connected-components could (should?) use recur to self-call
13:53technomancyrather than some random stuff you found on a guy's blog
13:54ztellmanrubydiamond: 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:54ztellmanjust have something that will give you a REPL with the appropriate classpaths set
13:55ztellmanand point swank-clojure-binary at it
13:56rubydiamondztellman: which script I should point to
13:56ztellmanrubydiamond: I created one of my own, but this might work for you: http://github.com/liebke/cljr
13:57slyrusmmarczyk: good idea, but the naive change doesn't work for some reason. hmm...
13:58slyrusalso, if that blows up the stack, you're probably likely to have other problems elsewhere!
13:58mmarczyksure, but I think recur might be a bit faster at no cost at all (incl. to readability)
13:58mmarczykthough if it breaks things
13:59mmarczykthen I suppose I'm wrong on this point ;-)
13:59mmarczykI can't see why it would, though... hm.
13:59raeklozh: my reply to your my-ew macro:
13:59rubydiamondbtw which is good .. running lein swank and then slime-connect
13:59slyrusno, i agree. it's a good idea. question is why doesn't it work?
13:59raek(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:59technomancymmarczyk: the pom can be used to fetch the dependencies; you just have to copy jars frob target/dependency to lib
13:59technomancyI will see about documenting that.
13:59rubydiamondor running slime to directly connect to swank-clojure
14:00raekhrm, should be ~class and ~args, too
14:00technomancy~swank
14:00clojurebotswank is try the readme. seriously.
14:00lozh~@args?
14:00clojurebotI don't understand.
14:01mmarczyktechnomancy: ah, right -- and that's enough, because nothing needs to be compiled when working out of a checkout... cool
14:01lozhor does to-array deal with that?
14:01raekto-array works on a collection, right? in that case: no.
14:01lozhcool
14:02slyrusmmarczyk: [acc] -> acc in the arg list makes recur work. why would that be?
14:02raek,(doc to-array)
14:02clojurebot"([coll]); Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util.Collection.toArray()."
14:02raekok, it does
14:03rubydiamondgetting this error
14:03rubydiamondon typing slime
14:03rubydiamondapply: Searching for program: No such file or directory, lisp
14:04raekthe swank/slime/clojure-mode tutorial on ridell.us should really contain a link to the swank-clojure readme at the top!
14:04mmarczykslyrus: 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:04raekpreferably, a working one, too
14:05raekI must admitt, I've been lazy too
14:05rubydiamonddon't know why.. but i don't want to use package.el
14:05raekit was the first tutorial I found hwn googling "emacs clojure ubuntu"
14:05mmarczykslyrus: so, maybe try recurring with an extra [ ... ] added around the second arg
14:05raekI've managed to run slime without package.el
14:06slyrusor 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:07raekrubydiamond: try to add this: (ad-activate 'slime-read-interactive-args)
14:07raekI think you need to have that if you're not using package.el
14:07mmarczykslyrus: if you remove the [] from around acc, you will of course get something else passed inside it
14:08mmarczykslyrus: actually the simplest way to proceed would be to provide to fn bodies
14:08rickmodeslyrus: 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:08rubydiamondraek: hmm yeah.. something it's downloading clojure
14:09mmarczykslyrus: (defn connected-components ([graph] (connected-components graph nil)) ([graph acc] ...))
14:09rubydiamondraek: hope it sets path and loads it automatically
14:10raekrubydiamond: I would recommend to start the swank server with lein swank
14:10rubydiamondraek: yeah.. I can start the server and do slime-connect
14:10rubydiamondbut basically I want to point my slime to swank-clojure
14:10raekjust starting slime makes emacs start its own swank server
14:10rubydiamondcurrently my slime goes to CL-USER which is lisp
14:10mmarczykslyrus: 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:11rubydiamondraek: for me that is not the case
14:11raek...and that swank server is not configure to include any project's paths into the classpath
14:12raekthere is also swank-clojure-project that does sort of the same thing as lein swank, but doesn't use leiningen
14:12raektechnomancy: is swank-clojure-project deprecated?
14:12raekrubydiamond: does slime-connect:ing work for you?
14:13tridd3llrubydiamond: 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:13rubydiamondraek: yes.. it works..
14:13rubydiamondraek: it connects to swank server started with lein
14:13tridd3llrubydiamond: it's for arch but on the package management stuff is different that ubuntu
14:13raektridd3ll: are you the author of that blog?
14:13tridd3llyes
14:13alexykwhat would you use to suck in all of #clojure logs off n01se.net?
14:14raek1) the link to technomancy's blog is broken
14:14tridd3llraek: the above link is much more current... but not tested with 1.2
14:14rubydiamondraek: right
14:15rubydiamondtechnomancy: you should write the other way of running swank clojure..
14:15rubydiamondwithout package.el
14:15rubydiamondusers like me prefer not to use packages.el
14:15technomancyget used to package.el; it's part of Emacs now
14:15raek2) it would be *very* good if there was a link to the readme files in technomancy's repos
14:16raekpreferably with a note that they are the most up to date instructions
14:16alexyktechnomancy: is your http lib the way to scrape the wild web?
14:16tridd3llrubydiamond: 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:17raekthe http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html page is the first result on google if one searches for "clojure emacs ubuntu"
14:17raekit would be very helpful if that could point to the most up-to-date documentation
14:17tridd3llraek: which is where?
14:18rubydiamondtridd3ll: is it written by you?
14:18raekswank-clojure: http://github.com/technomancy/swank-clojure
14:18tridd3llraek: my more recent tutorial or something else?
14:18raekclojure-mode: http://github.com/technomancy/clojure-mode
14:18rubydiamondwhy there are two repositories of swank-clojure ..
14:19raekall articles about how to setup clojure with emacs, preferably
14:19rubydiamondwhich one is valid ..
14:19raek....imho
14:19arohnermmarczyk: 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:19rubydiamondis it valid swank-clojure git://github.com/jochu/swank-clojure.git ?
14:19tridd3llraek: 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:20mmarczykarohner: you don't place hints on the actual objects to be hinted, but rather on the names they'll be bound to
14:20mmarczykarohner: so if you want to generate a let -- (let [arr <the-array>] ...)
14:20mmarczykarohner: attach the hint to arr
14:20arohnermmarczyk: k. thanks again
14:20mmarczyknp
14:20rubydiamondtridd3ll: yeah.. I also don't use emacs package management stuff.
14:22seancronrubydiamond: You're using ubuntu, right? What version?
14:23rubydiamondseancron: I am now using Snow Leopard on Macbook Pro
14:24seancronrubydiamond: Ah, my mistake. I thought you had said you used Ubuntu
14:24rubydiamondseancron: nope :)
14:24seancronWhat version of emacs do you have?
14:24tridd3llraek: but yes, this one http://riddell.us/ClojureSwankLeiningenWithEmacsOnArch.html is much more recent
14:24tridd3lland last I knew worked well
14:24tridd3llrubydiamond: yes, it's my much neglected blog :-)
14:24tridd3llraek: I'll try to get an update to the older entry to point to newer documentation
14:25rubydiamondraek: what should I do once (ad-activate 'slime-read-interactive-args) downloads all the necessary files
14:25chrisffmhi
14:25raektridd3ll: 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:26rubydiamondraek: nope.. technomancy's tutorial assumes you use packages.el
14:26chrisffm,(def a (repeat 5 (transient [])))
14:26clojurebotDENIED
14:26technomancypoint it to the assembla wiki if you don't like the official docs for some reason
14:26chrisffm:(
14:27seancronrubydiamond: Can you upgrade emacs to emacs 23?
14:28rubydiamondseancron: it's emacs 23
14:28raekI'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:29raekrubydiamond: this is my .emacs if that will provide any help: http://gist.github.com/443590
14:29rubydiamondraek: okay.. checking
14:29rubydiamondbtw here is my emacs config http://github.com/anildigital/emacs
14:29tridd3llraek: 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:30seancronSo why not use ELPA?
14:30rubydiamondraek: is this path in your emacs config right "/Projekt/swank-clojure/src/main/clojure" ?
14:30rubydiamondI can see that there is not folder named main now
14:30rubydiamondin swank-clojure
14:30raekthere is tilde in that path
14:31raek~/Projekt/swank-clojure/ is where I keep the cloned git repo
14:31clojurebotYou don't have to tell me twice.
14:32rubydiamondraek: yeah I can see but is this particular path present ".../src/main/clojure"
14:32rubydiamondI don't see folder named main in src folder
14:33raekhrm, that has probably been there for a long time
14:33raekjust the src/ part will probably do now
14:34rubydiamondraek: :)
14:34rubydiamondright
14:34raekthat is the root of the clojure code of swank-clojure, anyway
14:34seancronrubydiamond: Why can't you use package.el?
14:35raekand that has to be on the classpath for clojure to find the swank stuff
14:35rubydiamondseancron: it has all the packages listed which I have added as submodules
14:35rubydiamondseancron: I keep watch on submodules
14:36rubydiamondand when there are commits.. I just update those
14:36raekanyway, using slime-connect to connect to a swank server started outside emacs seems to be the preferred way now
14:36rubydiamondgit submodule foreach git pull
14:36rubydiamondthat is not possible with packages
14:36rubydiamondraek: really?
14:36rubydiamondthen I don't need to setup my slime to connect to swank.. it's connecting to lisp now
14:37rubydiamondI can use slime-connect to connect swank server
14:37raekyes
14:37raek"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:38rubydiamondoh nice
14:38rubydiamondthen my setup is good one
14:38rubydiamondI thought it's wrongly I have setup
14:39raekthere was some way of starting swank from emacs with the slime command
14:39raekbut that does not really work well when you have multiple projects
14:39raekbetter to let the project management tool (e.g. leiningen) to set up the correct class path and launch swank
14:40jfieldsif 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:40raekjfields: partition
14:40rubydiamondraek: yeah that looks correct way..
14:40raek,(partition 2 [1 2 3 4 5 6])
14:40clojurebot((1 2) (3 4) (5 6))
14:41jfieldscool, thanks guys
14:41rubydiamondlein is just awesome
14:41rubydiamondtechnomancy: can I get the stickers
14:41rubydiamondmailed to my address
14:41rubydiamond:p
14:41raekstickers?
14:41rubydiamondyeah...
14:42technomancyrubydiamond: sure, but you have to contribute a patch first. =)
14:42rubydiamond:)
14:42rubydiamondtechnomancy: hope I can do that in coming days..
14:43rubydiamondhttp://github.com/downloads/technomancy/leiningen/leiningen-banner.png is the one right?
14:44technomancyhaven't decided yet
14:44slyrusmmarczyk: ah, I didn't realize that about recur with & args. thanks!
14:44mmarczykslyrus: :-)
14:46alexykso folks, what's the smartest, cutest way to download a bunch of web pages?
14:47slyrusmmarczyk: 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:48slyrusbut, 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:49slyruson 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:50slyrusmmarczyk: did you see my comment about bft-recur?
14:51alexykslyrus: what are you computing?
14:51slyruswhat am I actually computing or what am I building general infrastructure for computing?
14:51slyrusthe stuff I'm actually doing is fairly small graphs (atoms and bonds in molecules)
14:52slyrusbut it would be nice if the core routines in shortcut could work on graphs of 1000s of nodes
14:52alexykslyrus: ah ok; but the infrastructure sounds interesting :)
14:52mmarczykslyrus: my personal preference would be not to expose the extra arg at all
14:52slyruswhich they mostly do, except for the n-x-n graph distance of all the nodes
14:52alexykslyrus: usually you see graphs and paths in social web
14:53mmarczykslyrus: and just go with a (letfn [(do-actual-work ...)] (do-actual-work the-only-user-visible-arg))
14:53alexyk(hence it stumbled on my grep :)
14:53mmarczykbut anyway, I need to go away for a sec, brb
14:54raekdo-actual-work doesn't use only tail call recursion?
14:54raekslyrus: your library sounds relly interesting
14:55raekdo you have a repo for it?
14:57NikelandjeloHow to reload some clj sources after I changed them if I use swank?
14:59qbgNikelandjelo: You could recompile the file with C-c C-k
14:59slyrusraek: thanks
14:59raekyou can always run (require 'the.name.space :reload) at the repl
14:59slyrusraek: http://github.com/slyrus/shortcut
15:01Nikelandjeloqbg, raek: Thanks, guys.
15:01raeka graph library is a really neat thing to have in one's toolbox
15:03slyrusyeah, that's my thinking too. c.c.graph is nice, but I needed undirected graphs, hence shortcut.
15:03raekslyrus: did you find out about recur vs lazy-seq?
15:04raekI saw some questionmarks in the source
15:04slyrusno, it's still a question for me
15:04raekok. recursive calls in lazy-seq does not consume stack
15:05raeksince the call is made from another place later
15:05raekthe current stack frame is unwinded when the lazy-seq object is returned
15:06slyrusok, but I can't seem to use recur in a function the returns a lazy-seq
15:06slyrusperhaps I'm doing something/thinking about this wrong
15:06raekyes.
15:06raekno
15:06raekthat is the way it should
15:06slyrusah, so I don't need to worry about blowing up the stack in breadth-first-traversal because I'm using a lazy-seq?
15:07raekyes
15:07slyrusok, great. thanks!
15:07raekthe call to your function *does* return after the first steo
15:07slyrusbft-recur can go away then
15:07slyrusright, got i.
15:07slyrust
15:08raekif you don't want to expose the 3-arg function, you could let or letfn it
15:09raekrecur has the nice property that you can specify an unnamed point to jump back to with loop
15:10raeklike in this factorial function : (defn fac [n] (loop [n n, acc 1] (if (zero? n) acc (recur (dec n) (* n acc)))))
15:13slyrusyeah, yeah :)
15:15slyruscommon-lisp programmers are used to doing all sorts of crazy things with lambda lists like &aux variables :)
15:15slyrusbut I'll hide all of the & state vars with letfn's if folks want nice clean APIs...
15:17chrisffmhi
15:17serp_hoi
15:17chrisffmmaybe somebody has an idea what i am doing wrong:
15:18serp_need more info than that
15:18chrisffmi googled but did not find anyone with the same problem
15:18chrisffm(def a (repeat 5 (transient [])))
15:19chrisffmand than (map #(persistent! %) a)
15:19chrisffmi get: java.lang.IllegalAccessError: Transient used after persistent! call
15:19qbgRepeat doesn't do what you want
15:19chrisffmnot?
15:20qbg,(let [a (repeat 2 (transient []))] (identical? (first a) (second a)))
15:20clojurebottrue
15:20chrisffmahhh
15:20qbg,(let [a (repeatedly 2 #(transient []))] (identical? (first a) (second a)))
15:20clojurebotfalse
15:20chrisffmi see :(
15:20raekrepeatedly takes a no-arg fn
15:20chrisffmokay, shame on me
15:21chrisffm;(
15:21chrisffmthank you very much
15:21qbgState is hard! Lets go shopping.
15:21chrisffmlol
15:22chrisffmneed to finish this. then perhaps shopping ;)
15:23chrisffmthank you anyway
15:51pedroteixeirawhat's the current way to reload protocol impls, during an interactive repl test session?
15:52pedroteixeirait seems that removing/requiring namespace has no effect
15:52chousertry require with :reload or :reload-all
15:55pedroteixeiraa deftype impl keeps executing old code. i've tried (alter-var-root #'my-namespace/MyProtocol assoc :impls {}) with no success
15:56pedroteixeirachouser: currently using lazytest, I think it does that already but will try it manually now..
15:58pedroteixeiraeven removing the generated .class, old deftype impl is execute.. :/
15:59mmarczykso, is there a feature freeze in place in contrib? or maybe just on the 1.2.x branch?
16:03mmarczykpedroteixeira: 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:04pedroteixeirammarczyk: thanks, will try that now. you can reload protocols' impls with no problem then?
16:04mmarczykpedroteixeira: 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:04mmarczykwell, I can check
16:04mmarczykit makes sense to me that this should happen though
16:06mmarczykah, wait, I might have misunderstood what you're asking about... I think the solution is still the same, though
16:06mmarczykgoing off to check
16:09pedroteixeirammarczyk: you were right, with extend-type, impl was reloaded :)
16:09mmarczykcool :-)
16:10pedroteixeirammarczyk: i actually prefered the style with extend.. was only using inline before :(
16:10mmarczykpedroteixeira: the question remains
16:10mmarczykhow do we remove impls altogether
16:10mmarczykI've no idea, tbh
16:11mmarczykand I'm pretty amazed to learn that (def PFoo nil) doesn't seem to help
16:14Licensera 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:15mmarczyk(ns-unmap 'my-namespace.a 'xxx)
16:17Licenserway thank you!
16:17mmarczyk:-)
16:32raekslyrus: 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:33raekthe book Programming Clojure as a very good chapter about this
16:35qbgraek: No reduce version?
16:36raekheh, no...
16:36raekthat is, of course, also a very good way of implementing the factorial function
16:37qbg,(take 10 (reductions * 1 (iterate inc 1)))
16:37clojurebot(1 1 2 6 24 120 720 5040 40320 362880)
16:38mmarczyk(def facts (concat [1] (lazy-seq (map * facts (iterate inc 1)))))
16:39raekI manly wrote the gist to show how recursive calls looks like in different situations
16:39mmarczykactually skip the lazy-seq
16:39raekthere are of course better ways of implementing factorial
16:39raek...than those I showed
16:40raeka self-refering one, how neat!
16:41qbgWhy recurse when you can get a function to do it for you?
16:41mmarczykthere's also (take 10 (cseq/rec-seq facts (concat [1] (map * facts (iterate inc 1))))) with cseq = clojure.contrib.seq ... ok, enough ;-)
16:43raekqbg: I prefer composition of functions too, but that was not the point of the gist
16:45miltondsilvahi, what exactly is a sequence?
16:46qbg,(trampoline ((fn fact [n acc] (if (= n 0) acc #(fact (dec n) (* n acc)))) 5 1))
16:46clojurebot120
16:46slyrusraek: I find myself using reduce mostly
16:46raekmiltondsilva: a sequence is a sequential view of a collection
16:46miltondsilvaI'm having some problems understanding the whole seq? sequential?
16:46raek,(seq [1 2 3])
16:46clojurebot(1 2 3)
16:47raekwell, first of all, you can test wether the object in front of you is a sequence with seq?
16:47raek,(seq? (seq [1 2 3]))
16:47clojurebottrue
16:47raekof course...
16:47raekbut
16:47raek,(seq? [1 2 3])
16:47clojurebotfalse
16:47qbg,(sequential? '(1 2 3))
16:47clojurebottrue
16:47qbg,(sequential? [:a 5 :c])
16:47clojurebottrue
16:48chouserbe careful with these terms. They're often used casually and in a way that's somewhat imprecise.
16:48qbg,(sequential? {:a 4, :b 5})
16:48clojurebotfalse
16:48miltondsilvahmm... shouldn't they both return true?
16:48miltondsilvaafter looking at the clojure-cheat-sheet
16:48raekseqs support two operations: first and rest
16:48miltondsilva.(first [1 2 3])
16:48qbgmiltondsilva: Which two?
16:49miltondsilva(seq? [1 2 3]) -> true?
16:49qbg,(first [1 2 3])
16:49clojurebot1
16:49qbgWorks because first calls seq on its argument
16:49raekas a convenience feature, first, rest and the functions in the sequence library calls seq on its argument
16:49qbgA vector is not a seq
16:50raekso, vectors don't support first and rest themselves
16:50raekbut when calling seq on them, they return a seq-of-vector object
16:50chouser'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:50miltondsilvahmm.. 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:50raekthat basically keeps track of which vector it belongs to and which index of it
16:51qbg,(vector? [1 2 3])
16:51clojurebottrue
16:51qbg,(map? {:a 5, :b 3})
16:51clojurebottrue
16:51raekso (seq [1 2 3]) would return something that knows about [1 2 3] and index 0
16:51slyrusthis doesn't do what I expect: (with-open [r (io/reader "/etc/passwd")] (take 2 (line-seq r)))
16:51slyrustake 1 works, but the stream is closed after that.
16:52raekcaling 'first' on that will lookup index 0 in the vector, and return 1
16:52qbgslyrus: Take returns a lazy seq, perhaps you should use doall?
16:52raekcalling rest in it will make *a new* thinh that knows about the vector and index 1
16:52raek*on it
16:53chouserperhaps 'coll?'
16:55raekmiltondsilva: if you have 2h over, I recomment watching http://clojure.blip.tv/file/734409/
16:55raek(one thing about that one, though: what he refers to as 'rest' is now called 'next', (defn next [x] (seq (rest x))) )
16:56slyrusqbg: 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:56slyrusthis works: (with-open [r (io/reader "/etc/passwd")] [(take 1 (line-seq r)) (take 1 (line-seq r))])
16:57slyrus,(with-open [r (io/reader "/etc/passwd")] [(take 1 (line-seq r)) (take 1 (line-seq r))])
16:57clojurebotjava.lang.Exception: No such namespace: io
16:57miltondsilvaI 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:57slyrus(with-open [r (clojure.java.io/reader "/etc/passwd")] [(take 1 (line-seq r)) (take 1 (line-seq r))])
16:57slyrus,(with-open [r (clojure.java.io/reader "/etc/passwd")] [(take 1 (line-seq r)) (take 1 (line-seq r))])
16:57clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission /etc/passwd read)
16:57slyrusheh. didn't think that would work.
16:59qbgslyrus: Take a look at the source of line-seq
16:59raekslyrus: the with-open macro will close the reader when the caller returns
16:59qbgThe first element is not lazy, which is why it works in that case
17:00raeksince line-seq is lazy, it will not have read everything when the close is done
17:00slyrusoh, thanks raek
17:00raekclose would have to be lazy too
17:00slyrusawesome
17:00slyrus(with-open [r (io/reader "/etc/passwd")] (doall (take 4 (line-seq r))))
17:01slyrusqbg: I missed your point about where to put the doall!
17:01raekyou can roll your own line-seq and make that close the reader
17:02chouserthere's one of those in contirb already, but it's not recommended
17:03raek(defn my-line-seq [rdr] (lazy-seq (if-let [line (.readLine rdr)] (cons line (my-line-seq rdr)) (do (.close rdr) nil))))
17:03raekchouser: hrm, why?
17:04raekbad habit to close some else's file?
17:04chouserraek: because it's linking a real side-effect (the releasing of OS resources) with the consumption of a lazy seq
17:04raekisn't the .readLine call a real side-effect too?
17:05raekit removes bytes from the stream
17:05chouserit'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:05raekah, I see
17:07raekso the user should close the file himself when he's done with it, which is independent on how many lines actually got read
17:07chouseryes
17:07chouserand with-open provides a convenient way to do that while keeping the open and close near each other.
17:09chouserif 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:27krunaldoHi guys! Is there any support for byte arrays out of the box?
17:27krunaldoI find some references with java using bytes but I don't really see how(reading the docs on Byte on java-doc).
17:28qbg,(byte-array 10)
17:28clojurebot#<byte[] [B@a71c3a>
17:28krunaldonow I feel really stupid :)
17:28qbg,(make-array Byte/TYPE 10)
17:28clojurebot#<byte[] [B@1ba63a4>
17:29qbg,(byte-array [(byte 1) (byte 2) (byte 3)])
17:29clojurebot#<byte[] [B@18259c8>
17:29qbg,(seq (byte-array [(byte 1) (byte 2) (byte 3)]))
17:29clojurebot(1 2 3)
17:29chrisffmlol
17:30chrisffm(into-array Byte/TYPE (range 10))
17:30chrisffm;-)
17:30krunaldo:)
17:30krunaldoIs there any nifty way to add them all into one int?
17:31qbg,(reduce + (byte-array [(byte 1) (byte 2) (byte 3)]))
17:31clojurebot6
17:31qbg,(reduce + [1 2 3])
17:31clojurebot6
17:31krunaldoAh
17:32krunaldoI meant making them into to a bitfield
17:32qbgYou mean bitwise or them?
17:33krunaldomore like shifting them
17:33chrisffmhm use shift-left
17:34qbgSo the first 8 bits comes from the first, the next 8 comes from the second, etc?
17:34chrisffmshould not be to complicated
17:34krunaldoqbg: yes
17:34qbg,(reduce #(bit-or (bit-shift-left %1 8) %2) 0 [1 2 3])
17:34clojurebot66051
17:35qbgWell, the highest 8 come from the first there
17:35riddochcHmmm.
17:35riddochc,(byte 255)
17:35clojurebotjava.lang.IllegalArgumentException: Value out of range for byte: 255
17:35qbgYou can always reverse the sequence first
17:36qbgThe jvm's lack of unsigned math can be troubling sometimes.
17:36riddochcSigned, evidently.
17:36krunaldoHighest first is okay, I'm doing some IP-address stuff so that should be fine
17:37krunaldothx! :)
17:42tashafatest
17:42tashafayay!
17:42tashafafinally got emacs to work in #clojure
17:49slyrusraek: 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:53slyrushow do I get the fields of a record type?
17:54arohnerslyrus: .getFields on the class
17:54arohnerhttp://java.sun.com/javase/6/docs/api/java/lang/Class.html
17:54slyrusthanks arohner!
17:55slyrusmeh java arrays... I was hoping defrecord would expose the fields clojurishly. oh well.
17:56raekbut, but, but... this library is what I've been coding on for a month: http://wiki.github.com/ztellman/aleph/channels
17:57raekI was planning on releasing an alpha of mine this week...
17:57qbgslyrus: You could do (keys ...) on a defrecord instance
17:57qbgFor the map based interface that defrecord provides
17:58slyruswell, 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:58qbgPerhaps the defrecord2 macro would help that was floating around?
17:58slyruswuzzat?
17:59qbghttp://david-mcneil.com/post/765563763/enhanced-clojure-records
18:09arkhAs a music major, did Rich learn math and algorithms on his own or through more formal means?
18:19pedroteixeirais there something similar to scala's regexp parser for clojure?
18:36slyrus,(defrecord Foo [bogosity annoyance])
18:36clojurebotDENIED
18:36slyrusbah
18:36slyrusok, well, the problem is I don't know how to (apply Foo. ...)
18:37qbgYou can't apply Foo.
18:37qbgYou could do something like (apply #(Foo. %1 %2 ...) ...)
18:38qbgYou could also do some reflection magic
18:47KirinDaveslyrus: You'd need a helper function to apply that.
18:59slyrusI don't suppose there's a (make-instance 'Foo ...) hiding in the bushes somewhere then?
18:59slyrusI need a helper because Foo. is a macro?
19:00cemerickslyrus: Foo. is sugar for (new Foo ...)
19:00slyrusoh, great! thanks!
19:00cemericke.g. invokes a constructor
19:00cemerickslyrus: apply cannot be used with ctors.
19:01slyrusyes, I hear there are these constructor things. It's unclear how to write one or otherwise supply default values for fields in records.
19:01cemerickslyrus: blog post coming very shortly :-)
19:01slyruscool. oh, wait, let me guess again... new is a macro not a function so I can't apply that either. hrm...
19:01cemerickctors are automatically generated for deftype and defrecord classes
19:02slyrus(apply new '(Foo. :high :medium)) would be nice
19:02cemericknew is a special form
19:02slyrusright, ok.
19:03slyrusI'm sure there's a reason, but I can't see why new couldn't just be a regular function.
19:04lancepantzdnolen: you around?
19:07cemerickslyrus: this is decidedly bad practice, but: https://gist.github.com/bab9181cf1f1eda95caf
19:08cemerickblog tomorrow morning about defrecord defaults
19:10slyruscemerick: it's a little disturbing that that works :)
19:11slyrusof course that's still a macro, so I can't apply that anyway, which is what a really want. argh...
19:20cemerickslyrus: wrapping that with a fn you can apply is totally reasonable
19:22slyrusthe compiler doesn't seem to think so, but perhaps that's operator error on my part
19:23slyrusI'm probably doing something stupid: (defn bogus [args] (apply-ctor Foo args))
19:33KirinDave,(apply apply '(+ 1 2))
19:33clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
19:56raek,(apply apply [+ [1 2]])
19:56clojurebot3
20:06KirinDaveraek: Funny how awkward that is to write using lists as containers. :)
20:06KirinDave,(apply apply '(+ (1 2)))
20:06clojurebot2
20:06KirinDave:)
20:06wwmorgan,(apply apply (list + (list 1 2)))
20:06clojurebot3
20:07KirinDaveNo I know.
20:07KirinDaveIt's just funny how the '() is such a ballsack sometimes. :)
20:07wwmorganyes. I puzzled over that for a good five minutes :-P
20:08KirinDaveI am still not sure what ('+ 1 2) does.
20:08wwmorganthe symbol is behaving like an accessor
20:09gfrlog,('+ 1 2)
20:09clojurebot2
20:09KirinDavebut
20:09KirinDave,('+ 1)
20:09clojurebotnil
20:09KirinDaveI guess it's just the default coming through
20:09KirinDaveBut it makes for some amusing bugs.
20:09gfrlog,('* 1 2)
20:09clojurebot2
20:09technomancy,((ancestors (class '+)) clojure.lang.IFn)
20:09clojurebotclojure.lang.IFn
20:10gfrlog,('bit-shift-right 1 2)
20:10clojurebot2
20:10KirinDaveStopped Clock. :)
20:10gfrlogso symbols are functions that return their second argument?
20:10KirinDaveNo.
20:10gfrlog,('* 1 2 3)
20:10clojurebotjava.lang.IllegalArgumentException: Wrong number of args (3) passed to: Symbol
20:11KirinDave,(:test {:test 1})
20:11clojurebot1
20:11gfrlogthat's a keyword
20:11KirinDave,(:test {})
20:11clojurebotnil
20:11gfrloga keyword in clojure is a symbol in ruby is an atom in erlang
20:11technomancyoh, calling a symbol calls RT.get with this as the second arg
20:11KirinDave,('test {'test 1})
20:11clojurebot1
20:11KirinDave,('test {})
20:11clojurebotnil
20:11gfrlogooh nice
20:12KirinDave,('test {} :default)
20:12clojurebot:default
20:12KirinDaveTadaaa
20:12technomancyjust like keywords... only nobody does it.
20:12KirinDavetechnomancy: Just like keywords because they are keywords. :)
20:12gfrlogsymbols are keywords?
20:12KirinDaveOr rather, keywords are them.
20:12KirinDavegfodor: I dunno if that's strictly true, but a keyword is just a symbol in a universal top level namespace.
20:13KirinDaveThe reason we don't use 'test and prefer to use :test for keys is that 'test gets mapped to your current namespace
20:13technomancyinteresting that .invoke on keywords does a little more smarts surrounding ILookup than symbols do.
20:13KirinDaveSo user/test and funky/test are different values.
20:13technomancywonder if there's a reason for that
20:14KirinDavetechnomancy: No idea.
20:14KirinDave,(apply apply '(+ (1 0))) ; A pretty funny bug tho, wouldn't you agree?
20:14clojurebot0
20:15KirinDaveNot in clojure, of course.
20:15technomancyyeah, it's pretty weird
20:15technomancyor at least, weird to debug.
20:34slyrusbah. out of heap space... how do i start my process (with lein swank preferably) with a decent sized heap?
20:41gfrlogI'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:41gfrlogI did some profiling and the results were a bit bizarre: most time spent in var resolution
22:51slyrusJAVA_OPTS=-Xmx1g lein swank seems to do the trick
23:07lancepantzslyrus: not from my experiences, i would hook a profiler up to it
23:15daakuis there a way to get a string back from pprint for use with logging? (i haven't gotten to the streams chapter yet :)
23:18slyruslancepantz: 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:21lancepantzslyrus: i didn't find much use for it outside of optimizing garbage collection
23:21slyrusstill, 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:21lancepantzofcourse
23:25chouserCtrl-\ on unix
23:27chouserthat was for slyrus. -)
23:27chouser:-)
23:27slyruschouser: that's fantastic! thanks!
23:28chouser,(with-out-str (clojure.pprint/pprint []))
23:28clojurebot"[]\n"
23:28chouserand that's for daaku.
23:28slyrusfor me too :)
23:28daakuchouser: cool, i got it working using a StringWriter thing too
23:29slyrusyay. 104855 movies and 76251 actors loaded up in shortcut. Now to connect one set to the other for my kevin-bacon-solver.
23:30daakuchouser: with-out-st is cool
23:31slyrusand it's 9 chars shorter than CL's with-output-to-string!
23:31slyrus:)
23:32daakuis 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:49daakuis 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:57daakuthis (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:59wwmorgandaaku: would a user.clj work for your purposes?