#clojure logs

2009-02-02

00:50ricreeHi. I'm new to clojure, and I'm having a tough time figuring out how to get it to work with java libraries. I've been trying to work through this post (http://briancarper.net/2008/10/31/qt4-in-lisp/), but when I try the import commands I keep getting ClassNotFoundException. Can anyone point me to a good resource for figuring out what I'm doing wrong here?
00:53cp2ricree are you using -cp when you invoke java or are you using add-classpath in the code
00:54ricree-cp
00:55ricreealthough I tried it in slime when I added the .jar files to my .clojure directory, and I get similar results
00:55ricreewhen I print out the classpath with (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader)))) , it shows the jar files
00:56cp2i had a similar problem a few days ago, and it was because i was using both -cp and -jar
00:56cp2although im not entirely sure
00:57durka42when i had this problem i was running an old jvm, and the jars that wouldn't import were marked newer
00:58ricreeI suppose that part of the problem is that I'm new to both clojure and java. I'm honestly having trouble sometimes keeping straight where exactly these things are supposed to be getting loaded from at times
01:00durka42ricree: join the club. classpaths are the bane of java programming
01:02xitamis there any way to use a sorted-map with a custom comparator? or some way to make a comparable object out of a struct?
01:04xitamwhat i'm trying to do is implement a-star search as sort of a beginner project with clojure, and i guess typically the "open set" of search nodes is implemented with a priority queue
02:44cads!seen rhickey_
02:45cadshrm
02:46replacacads: it's three in the morning where he is
02:46replacacads: insn't it?
02:46cadshehe
02:46cadsI need to hang out here at american hours then
02:49cadsI read somewhere where he writes, of the question "should I learn clojure through SICP?", that SICP is great for learning programming but that it won't really help with the task of learning the clojure toolset (I'm paraphrasing and might be wrong).
02:49cadsAnd I was wondering what path would be recommended for someone learning clojure as a first language.
02:49replacacads: yeah, that's about right
02:50replacacads: what do you know already?
02:50replacano programming yet?
02:50cadsI know enough programming to make my way through the tutorials I can find
02:51replacawhat languages do you know?
02:51cadsbut I have a friend I'd like to recommend lisp to
02:51cadsI know ruby and haskell
02:51replacaFor you, I'd do Stuart Holloway's book
02:52cadsthe one in beta?
02:52replacayou might want to do SICP and "On Lisp" for context
02:52replacayeah
02:52replacafor your friend, I would think that Clojure would be a tough place to start
02:53replacajust cause I don't think the clojure-specific starter doc is there yet
02:53replacaand there's the extraneous confusion of a new language
02:53cadsI'm tempted to recommend stuff like SICP and graham's "On Lisp" but that was frustrating to me, when my goal was to play with clojure
02:53BigTomcads: stu halloway's book is pretty good
02:54BigTomhe has just added a chapter on functional programming
02:54replacayeah, like rhickey said, they're not directly related
02:54cadswhat helped was the getting started guide, and rich's talk on clojure for lisp programmers
02:54BigTomI am working through SICP (very slowly!)
02:54cadswhich I wanted to complement him on
02:54replacacads: that's what I used too, but I knew lisp & java coming in
02:55BigTomI knew java and was familiar with scheme
02:55cadsI know lisp more from theory papers than playing with it, and it's great that clojure in many ways feels like a purer lisp than CL, while being more practical than scheme
02:56replacayou could say that (though others would flame you) :-)
02:56BigTomI love it :-) I finally get a Lisp that I can do at work
02:57replacarhickey has made some great design decisions
02:57cadsreplaca: most CLers are all about CL, rather than the abstract ideal of lisp, I've found
02:57replacaCL is still fighting wars from the 80s so it feels clunky now, IMO
02:58replacawell they like the standard and the library
02:58replacaI can't blame them entirely
02:58cadsbut it's an old library and standard
02:58replacaafter all, I'm the guy you implemented the CL format func for Clojure :-)
02:59replacayeah, that's part of the problem
02:59replaca*you => who
03:00cadsI have a hard time feeling like I could axiomatize CL like I've seen done in purer settings in papers
03:01cadsand at the same time I have a hard time seeing how something that could be grasped mathematically by a single person would also be a pragmatic language to do programming in
03:01replacayup, though Clojure may have some similar problems (cause of the Java interop)
03:01replacain any case, gotta crash here in California!
03:01cadstake care replaca
03:01replacagoodnight all!
03:32Lau_of_DKTop of the morning gents
03:32RaynesGood morning.
03:41cgrandHello
03:55Lau_of_DKcgrand: Did you notice my new project on Github?
03:57cgrandnot yet :-)
03:58Lau_of_DKI ripped your partition-by for it :)
03:58Lau_of_DKAlong with shell-out
04:05cgrandyou don't want to depend on contrib?
04:06Lau_of_DKNo, not really
04:08cgrandCan't you load git.ui from the classpath? (Just asking, I don't know Jambi)
04:09Lau_of_DKI was fiddling with that last night, but maybe I was too tired
04:09Lau_of_DKI'm looking into just passing the content of the file to the UI loader
04:11cgrandWhat you call a port of Jambi to clojure is the end of engine.clj + slot.clj. Right?
04:11Lau_of_DKYea, and as Chousuke reminded me, its not a port, its bindings. I need to update the README
04:12cgrandI like the tone of it (the README)
04:13Lau_of_DKIm glad you like it - because its informal ?
04:14Lau_of_DKOr because I actually took the time to write quality instructions for windows users?
04:17cgrandits informality... which instructions for windows users?
04:20cgrandbe kind, I'm still uncaffeinated
04:21Chousukeis a dependency of contrib really that bat?
04:21Chousukebad*
04:21Chousukekind of defeats the point of contrib if people don't use it :/
04:22Chousukehaving it as a separate dependency relieves you from the burden of maintaining the code, too :)
04:23RaynesKind of like saying you don't want to depend on a languages standard library :|
04:23Rayneslanguage's*
04:25Chousukewell, clojure kind of has two standard libraries.
04:25Lau_of_DKChousuke: To me Contrib is big, its not optimal in all regards (like, for obvious reasons I dont want to associate with contrib.sql), and I just dont want to fiddle with more namespaces, I dislike that system, so its easier just to cut/paste 100 lines and mention where I took them from
04:25Lau_of_DKcgrand: The instructions at the very bottom of the readme
04:26ChousukeLau_of_DK: if you compile your code though you won't get anything other than the parts you used from contrib :/
04:27Lau_of_DKI know - I said 'associate' :)
04:27Chousukeand frankly, caring about contrib.sql being there is just silly :)
04:28Lau_of_DKI think its a big dependency to force on your users
04:28Lau_of_DKI think I'll just make standard loot.clj with the snippits I need
04:29Chousukeit's not that big, is it. 632K with *everything* compiled in. :P
04:29Lau_of_DKThats pretty huge compared to my entire project being 28k
04:29Chousukeit
04:29Chousukeit
04:29Chousukegah
04:29Chousukeit's just a compile-time dependecy.
04:30Chousuke+n
04:30Chousukethough hm
04:30Chousukenever mind :P
04:30Chousukethought of something that might be a problem, but isn't.
04:31Lau_of_DKhaha
04:31Lau_of_DKI think the whole point of IRC is that you can have what we call a "reflection" without nessarcily sharing it, in case its useless :)
04:34cgrandTo me Jambi appears to be a bigger dependency than contrib...
04:34Lau_of_DKIt is
05:39Chousukeooh, when did the clojure site get the "related functions" thingy? very nice.
05:49leafwis there any way to call "this"? In a proxy, or when creating a function to pass as a Runnable to a new Thread, I have no means of calling isInterrupted() from within the body of the thread, unless I do some hoops such as declaring first a "self" ref to nil and then altering it to contain the thread, and in the fn that works as Runnable, call (.isInterrupted @self)
05:49leafwexample here: http://github.com/acardona/xmms2-clj/blob/c4745f0e19c75e67a08ae6fb7c1a8500f0663d93/xmms2.clj#L95
05:50leafweven though the dereferencing is not done in the context of the dosync transaction, it looks like and it is an ugly workaround.
05:54achim_pleafw: can't you use let?
05:54achim_p(let [runnable (fn [] (println "blah"))
05:54achim_p thread (Thread. runnable)]
05:54achim_p ...)
05:54leafwachim_p: I tried, but it failed with null pointer
05:55leafwno, the problem is that isInterrupted is as a method of Thread, not interface Runnable. I would have to call (.isInterrupted Thread/currentThread)
05:55leafwwhich is not tragic, but looks silly
05:56leafwit would certanly simplify things ...
05:56leafwthere's no need for a transaction in there.
05:56Chousukethe first argument to a proxy method is "this" isn't it? or was it automatically bound...
05:56leafwsorry, this is not a proxy. So in a proxy it's possible?
05:57leafwChousuke: I think the first argument of any function in a proxy is the first argument of that function, not "this"
05:57Chousuke Each method fn takes an additional implicit
05:57Chousuke first arg, which is bound to 'this
05:57leafwoh really!
05:57leafwthat is good news.
05:57leafwthanks.
05:58Chousukethat's in a proxy; with fns I don't think there's a way to refer to the thread you run the fn in, other than through Thread/currentThread
05:58leafwthat's ok
05:58leafwI'll use that.
05:58leafwwith the let [runnable suggestion.
05:58achim_pleafw: hmm, i don't really see why you can't instantiate the thread in a let form and call .isInserrupted on the let-bound symbol you assign the thread to ...
05:58ayrnieu(.start (Thread. (proxy [Runnable] [] (run [] (println (str "this: " this))))))
05:58ayrnieuthis: clojure.proxy.java.lang.Object$Runnable@d22889
05:59leafwas always, clojure offers 3 ways to do something
05:59leafwthanks ayrnieu
05:59Chousukeprobably more :)
05:59Chousukethe problem is finding the best.
06:00leafwI agree.
06:01ChousukeI think a closure will do as well, (let [t (Thread. #(do (something) (something-with t)))] (.start t))
06:02ayrnieu,(let [a #(list a 1)] (a))
06:02clojurebotjava.lang.Exception: Unable to resolve symbol: a in this context
06:03Chousukehm :/
06:03achim_pleafw: forget what i said, it's too early in the morning :) let doesn't work of course - mutual references
06:03leafwachim_p: no problem. I had tried that.
06:04leafwproxy is overkill. The runnable path is nice.
06:16leafwmuch cleaner now. Thanks guys.
06:21lisppaste8ayrnieu pasted "defmethod takes a MultiFn as its first argument (as opposed to: the name of one)" at http://paste.lisp.org/display/74717
07:44turbo24prgayrnieu: that's tricky, but it makes sense, of course
07:49ayrnieuit's useful.
07:49ayrnieuCompare http://gist.github.com/56893 to http://gist.github.com/54950
08:15Chousukeayrnieu: why don't you use autogensyms in the actor macro? :/
08:17ayrnieuin the second one? I didn't know about them.
08:17Chousukeyou do now though? :)
08:18ayrnieuyeah, I use them in the ! !! arecur macros in the first one.
09:40AWizzArdrhickey: did you already decide if lazy-cat is an issue, with having the empty sequence being nil?
09:47rhickeyAWizzArd: I'm working on laziness issues in a branch, and not going to spend any time on current laziness issues that will go away if the branch work becomes core
09:48Chouserare the fully-lazy branch and streams branch completely orthogonal?
09:51AWizzArdrhickey: makes sense
09:53rhickeyChouser: yes, basically I am still on the fence about streams. finding them, even when made safe as I have done, ugly,
09:53Chouserrhickey: really, that's interesting.
09:54rhickeybut integrating streams means dealing with the ISeq/more issue, which opens the door to fully lazy sequences, which are very beautiful and Clojure-like
09:55rhickeyso in the lazy branch I am fiddling with ISeq, with much success, in terms of backwards compatibility and full laziness, having made Clojure itself work with fully-lazy filter/map/concat replacements
09:56rhickeyI was working on performance over the weekend, since full laziness requires another indirection in inner loops
09:56ricreecan anyone point me in the right direction for using java libraries besides the core java libs? I've been trying to play around with some examples in jambi and java-gnome, but I can't seem to get at the library classes. As far as I can tell, the .jar files are in the classpath
09:57rhickeybut it looks like making (rest x) == (seq (more x)) is a good recipe for backwards compatibility
09:59ayrnieuricree, what are you trying to do that is failing?
09:59rhickeyChouser: streams are ugly since many of them will need state
09:59rhickeyChouser: their only attribute is performance at this point
10:00Chouserrhickey: yep, the contention there seems pretty inherent. You've got it bottled up pretty tight, but it still feels like you have to think about the statefulness inside.
10:01rhickeyChouser: the lazy branch has a major enhancement relating to clearing closed-over objects on a tail call of a one-time function, the key to avoiding accidentally hanging onto head when recursing
10:02rhickeyI've been clearing locals for a while, but the closed-overs were a tricky problem the user can't solve
10:03Chouservery cool. did that require more analysis of the code to see what could be cleared?
10:04rhickeyChouser: I'm not yet sure how I'll expose it, if at all, but essentially you can adorn a fn* as :once-only, meaning it will only be run once, as is the case in delay and the new lazy-seq - the compiler picks up this once attribute and generates closed-over clearing code at the same point as local-clearing code
10:05Chouserah.
10:05rhickeyI need the attribute since clearing it depends on its being invoked only once, true for any call-and-cache mechanisms
10:06Chouserunexposed would mean only a few builtin cache mechanisms could use it?
10:06rhickeyChouser: right, at least initially
10:07ricreeayrnieu: well, trying to import anything is giving me trouble. For example, I've been trying to go through the example at http://briancarper.net/2008/10/31/qt4-in-lisp/ , and I can't get the initial import statement to work right. It gives me a NoClassDefFoundError
10:07rhickeydelay being one of them, and the most likely to be used other than lazy-seq, which is very special at this point, giving generated fns new superclasses (i.e. other then AFn/RestFn)
10:08AWizzArdhmm
10:08Chouserricree: try pasting your exact import line and java command-line, maybe someone can spot the error.
10:09ricree(ns clojure-qt4-demo
10:09ricree (:import (com.trolltech.qt.gui QApplication QPushButton QFont QFont$Weight)
10:09ricree (com.trolltech.qt.core QCoreApplication))
10:09ricreethis is taken straight from the example on the site I linked
10:11ayrnieuThat should work. You can try typing in just: com.trolltech.qt.gui.QApplication
10:12ayrnieuor you could look at (System/getProperty "java.class.path") to see if it really points to these jars.
10:12Chousukericree: you're not just adding the directory containing the jars to the CP, are you?
10:13Chousukericree: because it doesn't work that way.
10:13ricreeThe jars seem to be included when I print out the classpath
10:13AWizzArdOh btw, can Clojures trampolines be used to provide stack-safety for all kinds of mutual recursive calls?
10:14AWizzArdI was not sure if they can be applied in any situation, or if there exist cases where they can't protect from stack overflows.
10:14ChouserAWizzArd: the function you give to 'trampoline' returns a function instead of making a tail call
10:14AWizzArdChouser: yes, I understand that
10:15ChouserAWizzArd: so you have to write the function specifically to be used by 'trampoline'
10:15AWizzArdright
10:15AWizzArdBut maybe there exist some really crazy cases of tail calls where this can't be done.
10:15gnuvincethickey_: I showed your site to the webdesigner I work with; he likes the way you show the websites :)
10:15AWizzArdI don't think so, but in a discussion with a mathematician (and known c.l.l troll) I was not so sure anymore.
10:15ricreeChousuke: I did, but I'm currently running this from slime, and my understanding was that it would load whatever .jars were in my ~/.clojure directory. That seems to be the case when I print out the classpath. Am I missing something?
10:16Chouserwell, my point is that it has to be a well understood discrete system.
10:16Chousukehmm :/
10:16Chousukericree: maybe one of the classes is misnamed in the article?
10:16ChouserAWizzArd: if you *know* your function is being called by 'trampoline', then sure -- any tail call you would make you simply replace with returning a closure.
10:17Chousukericree: you sure you have the correct JARs in the first place? :)
10:18AWizzArdIn fact this other guy could not deliver an example so far, so I come to think that all cases can be mapped to trampolines.
10:20ricreeChousuke: I think so, but I'm not 100% sure. Just putting qtjambi-4.3.jar and qtjambi-linux32-gcc-4.4.3_01.jar into the classpath should be sufficient, right?
10:20ChousukeI guess :/
10:21Chousukericree: try running java manually?
10:21Chousukeie. manually specify the java classpath and start a clojure repl.
10:22ricreeI have, but I'll go ahead and give it another go to make sure
10:22rhickeyAWizzArd: the argument there was that it wasn't a universal TCO if it had to be a discrete system (invoke specially by trampoline), which is true, trampoline is not universal TCO, just a la carte TCO for subsystems
10:24AWizzArdoki, I see
10:24rhickeyAWizzArd: so, not a limitation of trampolines as an implementation technique for TCO (as was pointed out, it is quite commonly used by Scheme implementations), just that trampoline, as a library fn, is not universal TCO, and I never said it was
10:26AWizzArdok
10:26AWizzArdthx
10:28rhickeyAWizzArd: remember, don't feed trolls :)
10:28ricreeChousuke: I tried the command "java -cp qt-jambi-4.4.3_01.jar:qtjambi-linux32-gcc-4.4.3_01.jar:clojure.jar:jline-0.9.94.jar jline.ConsoleRunner" from the directory with the jar files. I get the following error when I tried to just type out one of the classes "java.lang.ClassNotFoundException: com.trolltech.qt.gui.QApplication (NO_SOURCE_FILE:0)". I was able to get to classes like javax.swing.JFrame, so it looks like it's just having trouble
10:29Chousukehmm
10:30Chousukericree: that's weird, it should exist :/
10:34ricreewhen I was trying to figure this out last night, someone suggested that it might be an older version of the java runtime. I checked, and everything is up to date from the Ubuntu repositories. Think it would be worth it to try installing things manually to make sure it is as up to date as possible?
10:34gnuvincerecur sends you to the nearest recursion point, there's no way to arbitrarily choose one, right?
10:35ricreealthough I haven't been able to get it to work with any other jar files, so that doens't seem likely to be the problem
10:35AWizzArdWhat I find nice is that I get private mails of CLers who got interested in Clojure, asking questions and such
10:37AWizzArdgnuvince: right
10:37ricreeah well, I have to get ready for class. I'll try to figure this all out when I get done today. Thanks for the help, it's appreciated
10:38gnuvinceAWizzArd: thanks
10:38Carkawizzard : there's again an argument about clojure on c.l.l ?
10:39AWizzArdCark: well, every few days some known trolls try to convince Lispers that Lisp sucks. I show them some Clojure code and usually outperform their examples in Ruby or such. So, enough talk is going on in c.l.l
10:40Carkmay i ask who you are on cll ?
10:40AWizzArd /who AWizzArd
10:40Carki've been i follow this newsgroup for a couple years =)
10:41Carkahh right
10:41Carkthey've been pretty harch to you
10:42Chousukewhat does c.l.l stand for? :P
10:42AWizzArdcomp.lang.lisp
10:42cooldude127mhm
10:42ayrnieuhttp://groups.google.com/group/comp.lang.lisp is one way to get there.
10:42Chousukeyou know, I realised that about half a second after I asked.
10:42cooldude127lol
10:42AWizzArd;-)
10:44cooldude127b-trees suck
10:46MarkVolkmannI need to pass a string to a macro. I have the string in a variable created with def. How can I force the symbol created by def to be evaluated to its string value when I pass it to the macro?
10:46ChouserMarkVolkmann: you want to use the value of that def as it stands at compile time?
10:46Cark(defmacro bleh [var-name] `(println ~var-name))
10:47MarkVolkmannYes
10:47Carkoh
10:47Carkso scratch that
10:47MarkVolkmannIt's really a constant string in my usage.
10:47ChouserMarkVolkmann: you're willing to assume that the thing passed in to the macro is always the name of a Var?
10:47MarkVolkmannIt's a URL path being passed the GET macro in Compojure.
10:48cooldude127MarkVolkmann: unless the macro already evaluates what you pass to it, you can'
10:48cooldude127t force it to
10:48MarkVolkmannI can't modify the macro.
10:48Chouseroh
10:48MarkVolkmannThe macro wants a string.
10:48ayrnieu`(eval (annoying-macro ~myvar))
10:49Chouserhm, do you have a link to the macro?
10:49ayrnieuit's OK to use eval if you resent it!
10:49Chouserheh
10:50Cark(defmacro bleh [var-name] (let [a# var-name] `(println ~a#)))
10:50Cark?
10:51MarkVolkmannRemember though that I can't change the macro since it's supplied by Compojure.
10:51Carkthat's not right anyways
10:52MarkVolkmannAre suggesting that I should override the GET macro?
10:52ChouserMarkVolkmann: do you have a link to the specific macro you're trying to use?
10:53MarkVolkmannIt's defined in compojure/http/routes.clj. I'll see if I can find a URL that provides the source.
10:53MarkVolkmannhttp://github.com/weavejester/compojure/blob/87d9d6591bb5649e9ac99733eddfff992b33c7b4/src/compojure/http/routes.clj
10:54Chouserit's the GET macro?
10:54MarkVolkmannThe parameter in question is "path".
10:54Carki would wrap the macro in a function ... (defn call-the-macro [var] (the-macro var))
10:56Carkthen you can either call (call-the-macro "coucou") or (call-the-macro *coucou*)
10:58ChouserCark: I don't think that'll work.
10:58lisppaste8rhickey pasted "fully-lazy sequences vs. streams" at http://paste.lisp.org/display/74721
10:58Chouserhere's a simplified example: (defmacro ick [p] (let [x (str "<" p ">")] x))
10:58Carkdidn't check the macro itself
10:58ChouserI can call: (ick "hi") and get "<hi>"
10:58rhickeyfully-lazy sequences vs. streams - which would you rather write?
10:59Chouserbut if I call (ick myvar) I get "<myvar>" rather than the contents of myvar
10:59Carkright
11:01Carkrhickey : the lazy-seq is easier on the eye
11:01ayrnieublech: http://gist.github.com/56945 - actors, 'non-blocking' I/O, and an echo-server rough with debugging hooks. But it works until a client disconnects :-) I think I can do something with this.
11:04rhickeysuggestions for alternatives to 'more' still welcome, you can look at that paste for typical usage. I had also considered 'etc'
11:05Chouser'more' is relatively common as a local name following &
11:05rhickeyChouser: yeah, etc too :(
11:06Chouseranyway, the lazy-seq is much easier for me to think about. Perhaps that would change if I grew accustomed to looking at stream code.
11:07Chouserfor the lazy-seq version, I feel like I'm keeping track of two objects: the lazy-seq itself and the cons
11:07rhickeyChouser: actually map is one of the more straightforward stream code, being stateless
11:07ayrnieuMarkVolkmann - see clojure.contrib.apply-macro
11:07rhickeyChouser: lazy-seq might not be the best name, it's more of a lazy-seqable, or lazy-coll
11:08ayrnieu(let [hum "hi"] (apply-macro ick [hum])) => "<hi>"
11:08ayrnieuoh, that just uses eval. Nevermind.
11:08Chousukeayrnieu: how's iterator-seq! different from iterator-seq?
11:08Chouserfor the stream version, there's the coll, the iter, the stream, and the eos.
11:08ayrnieuChousuke - the .remove is important.
11:09Chousukehmm
11:09Chousukeoh, and in conds, I think :else is more idiomatic than "true"
11:09thickey_gnuvince: thanks =)
11:09Chouserthe 'if' packs a surprising amount of mental complexity into one line.
11:11ayrnieu:else looks nice, thanks.
11:18ChouserMarkVolkmann: it looks to me like apply-macro's about as good as you're going to get.
11:19ChouserMarkVolkmann: but you might take it up with James Reeves, and see if he'd be willing to provide a less restrictive API.
11:19MarkVolkmannThanks. Maybe I'll suggest to James Reeves that ... yeah, what you said.
11:20ChouserI think that if compile-ruote's call to compile-path-matcher were inside the syntax-quote instead of outside, you'd be able to use names that resolve to string instead of only string literals.
11:21Chouserpresumably the reason it is this way instead is for performance.
11:22Chouserbut that could be obtained by caching at runtime instead, I would think. There may be other solutions as well.
11:54WizardofWestmarcthat was strange, got a "you are banned from the channel" message first time I tried to connect to the room
11:55danlarkinodd
12:01rhickeycycle has a nice def in fully-lazy land:
12:01rhickey(defn cycle
12:01rhickey "Returns a lazy (infinite!) sequence of repetitions of the items in coll."
12:01rhickey [coll] (lazy-seq (seq (concat coll (cycle coll)))))
12:01AWizzArdhmm, is concat lazy?
12:02rhickeyAWizzArd: this is in the fully-lazy branch
12:02AWizzArdyeah nice
12:03AWizzArdClojure gives people great training in thinking lazy
12:03AWizzArdI got some private mails from long-time lispers who asked me how my code worked.. they wonedered because lazyness what not in their minds.
12:03rhickeyAWizzArd: Clojure is only a tiny bit lazy, compared to Haskell
12:05AWizzArdit's nice though
12:05AWizzArdfull lazyness could perhaps sometimes result in strange behaviour, regarding memory at runtime.
12:06ayrnieu,(first (concat (repeat 1) (repeat 2)))
12:06clojurebot1
12:07Chousukehmm.
12:08ayrnieuwizard, mibbit.com has been used for spamming.
12:10WizardofWestmarcayrnieu: ah ha
12:14WizardofWestmarcmay have to install an irc client again then.
12:18cgrandrhickey: can't cycle be similarly defined in current Clojure with lazy-cat?
12:23clojurebotsvn rev 1243; [lazy] interim checkin
12:23clojurebotsvn rev 1244; [lazy] moving off of lazy-cons - remove, takes, drops
12:26rhickeycgrand: probably, but this has no macro-fu
12:27rhickeye.g. maybe lazy-cat can go away when all sequence fns are fully lazy
12:28kotarakHuh? Big things going on?
12:29gnuvincewhat replaces it? Just cons?
12:29AWizzArdHi K�te
12:29rhickeykotarak: this in the lazy branch only for now
12:29ChouserI think rhickey enjoys breaking ClojureScript even more than I enjoy breaking everyone else's code.
12:29AWizzArd;-)
12:39cgrandrhickey: ok it's nice but I don't understand the seq in (lazy-seq (seq (concat ...)))
12:41rhickeycgrand: lazy-seq may not be the best name, what is does is define a logical collection in terms of the seq returned by the body, since concat (and all the sequence fns) now returns a logical collection (e.g. not a seq necessarily) you need to call seq on it
12:42rhickeyuser=> (concat [] [] [])
12:42rhickey()
12:42rhickeyuser=> (seq (concat [] [] []))
12:42rhickeynil
12:43AWizzArdrhickey: (def x (concat [] [] [])) ==> will concat end immediately without even looking at the first arg?
12:43rhickeybasically the body of lazy-seq must always yield a seq
12:43Chouserwithout the seq, cycle would return an infinite seq of empty things?
12:43Chousercould
12:44replacaQ: from a method in a :gen-class, how do I call a method in the superclass (skipping my own)? I.e., I have a method .write in my class, but I want to call (.write (super this)) instead of (.write this).
12:45LordOfTheNoobsWould it be rude of lazy-seq to wrap its body in a implicit seq?
12:45Chouserreplaca: see :exposes-methods in the gen-class docstring
12:45ayrnieuclojure.core/proxy-call-with-super proxy-super supers
12:45replacaChouser: I don't think that's what I want. I have a write method in my class already.
12:45rhickeyChouser: , no, you'll get ClassCast exception since the return value of concat is not an ISeq
12:46replacaayrnieu: I'm not using proxy, but (ns (:gen-class))
12:46Chouserayrnieu: that's for proxy, not gen-class
12:46rhickeyall the sequence fns return Seqables, not ISeqs
12:47Chouserreplaca: yes, but if you want to get at the super-classes write method, you can use :exposes-methods to get a new name for it, so you can call it.
12:47replacaChouser: ahh, ok, let me read doc :-)
12:49rhickeyAWizzArd: yes, in fully-lazy land all sequence fns consume only when absolutely necessary:
12:49rhickeyuser=> (def x (concat (map #(doto % prn) (range 10)) (map #(doto % prn) (range 10))))
12:49rhickey#'user/x
12:49rhickeyuser=> (first x)
12:49rhickey0
12:49rhickey0
12:49replacaChouser: yup, that's it. Thanks! (This syntax feels a little unnatural)
12:50Chouserrhickey: oh, lazy-seq demands an ISeq, not just a Seqable?
12:52replacaQ: do call the exposed method as (.super-write this ...) or (super-write this ...)?
12:52rhickeyChouser: right, it creates a closure that implements seq for its return value, so body must yield ISeq, lazy-seq yields Seqable
12:53Chouserreplaca: former, I believe.
12:53rhickey(lazy-seq body) -> x, (seq x) calls body
12:53rhickeyand caches
12:54replacaChouser: thanks
12:55Chouserwhich brings me to LordOfTheNoobs' question -- why can't lazy-seq call seq on its arg? That's usually pretty cheap if you already have an ISeq, and would be quite handy if you don't.
12:56technomancyis anyone in the Seattle area going to SeaFunc this week?
12:57rhickeyChouser: it could do - I'm trying to do without that at present
12:57technomancylooks like an interesting meeting
12:59hiredmansounds interesting, but it might interfere with my social reclusing, and it is, well *downtown*
12:59technomancyhiredman: you're in Seattle?
13:00hiredmannorth seattle
13:00technomancyit's in the University district... not really downtown
13:00technomancybut that doesn't mean the parking is decent
13:01rhickeyLordOfTheNoobs: sorry, I missed your q about lazy-seq calling seq, it could, I'll look into the perf...
13:01technomancyheh: "The merits of the FP approach are highly debateable. Much more clear, is that people who debate these issues are interesting."
13:01Kerris7actions vs words
13:02technomancyhiredman: looks like it bounces around to different locations, but this one is at Ruby restaurant in the U district.
13:02hiredmantechnomancy: I am looking at the google streetview
13:07hiredmantechnomancy: I work up in south shoreline (looking at the clojure google map)
13:10rhickeyperf looks ok, now lazy-seq calls seq on body, so:
13:10rhickey(defn cycle
13:10rhickey "Returns a lazy (infinite!) sequence of repetitions of the items in coll."
13:10rhickey [coll] (lazy-seq (concat coll (cycle coll))))
13:11technomancyhiredman: oh cool; I'm right on 155th.
13:11technomancybut I work downtown
13:12hiredmandanlarkin: took me a while to
13:12hiredmantoo
13:13danlarkinhiredman: care to share? :)
13:13hiredmanyou have to click "edit" on the side bar, and then there is a menu sort of thing across the top
13:13hiredmanwith a pin icon
13:13rhickeyonly 9 lazy-cons calls left...
13:13clojurebotsvn rev 1245; [lazy] moving off of lazy-cons, lazy-seq calls seq on body
13:14danlarkinhiredman: ohhh, I bet I have to bed logged in to google. that'd explain it
13:15hiredmanhuh
13:15hiredmanSeaFunc (a group of Seattle functional programmers formerly known as SeaLUG - Seattle Lisp Users Group)
13:15technomancyguess they wanted to avoid being called SLUG
13:16kotarakGuys from Denver, shouldn't take over the idea: DeFunc....
13:17WizardofWestmarchaha that'd be great
13:17WizardofWestmarcI'd have to go simply because of the awesome name
13:22duck1123hmm... I wonder if anyone likes MiFunc
13:22Lau_of_DKHi all
13:23ayrnieuduck, do you mean clojure.lang.MultiFn ?
13:23WizardofWestmarcheya Lau
13:23ayrnieuoh, nevermind.
13:25cooldude127WOOHOO i can take a break from stupid java homework, my b-tree works
13:26Lau_of_DKwoohoo :)
13:28AWizzArdHi the Lau
13:29ayrnieu,(let [mi (new clojure.lang.MultiFn (fn [a & _] a) :default)] (doto mi (defmethod :add [_ a b] (+ a b)) (defmethod :sub [_ a b] (- a b))) [(mi :add 2 3) (mi :sub 2 3)])
13:29clojurebotDENIED
13:36WizardofWestmarchere I thought it was just a net split
13:39cooldude127technomancy: yay, imenu is working with clojure-mode
13:42technomancycooldude127: great!
13:42technomancyhave you tried the installer?
13:43cooldude127technomancy: no, not yet, i'm afraid to mess with my setup
13:43cooldude127i'm using clojure-slime-config tho
13:44technomancycooldude127: M-x clojure-install won't touch your current setup if you give it a test location when it asks you where to install
13:44technomancycooldude127: I ask just because I'd like to get it tested on more systems than my own
13:44cooldude127technomancy: yeah ok i can test
13:49cooldude127technomancy: can haz bugs
13:49cooldude127it tried to check everything out into ~/.emacs.d
13:50technomancycooldude127: what location did you give it when prompted?
13:50cooldude127technomancy: ~/sr
13:50cooldude127c
13:50cooldude127~/src
13:50clojurebotExcuse me?
13:50technomancyheh
13:50cooldude127clojurebot: this doesn't involve you
13:50clojurebotIt's greek to me.
13:50technomancycooldude127: what's the value of clojure-src-root then?
13:51cooldude127technomancy: i set that to ~/src as well before i did this. normally it's ~/lisp/clj
13:53cooldude127technomancy: somehow that (cd src-root) isn't doing its job
13:53technomancycooldude127: that's *really* strange; there's no mention of ~/.emacs.d anywhere in the code
13:54technomancyclearly
13:54technomancymaybe I need to move the cd inside the shell-command call
13:54cooldude127technomancy: maybe, cuz it depends on which buffer i'm in, the result of (pwd) is different
13:56cooldude127technomancy: it doesn't make sense tho. if i do M-: (cd clojure-src-root), then do M-! pwd, i get ~/src (expanded)
13:57technomancyyeah; I'm not sure how that works. it seems like putting it in shell-command would be pretty foolproof though.
13:57cooldude127technomancy: yeah, like adding (shell-command src-root) before the dolist ?
13:58cooldude127cuz i could try that real quick
13:58technomancycooldude127: I was thinking (shell-command (format "cd %s; %s" src-root cmd))
13:59cooldude127technomancy: oh that works
13:59cooldude127let me try that
14:01cooldude127technomancy: that is working, i think, emacs kinda freezes up, but that's its fault, it's checking out into the right directory
14:01ryszard_szopaHi, I've got a question about classpaths and clojure
14:01technomancycooldude127: yeah, the slime checkout takes forever because there's so much history
14:01technomancycooldude127: considering using CVS for that, but I hate CVS, so it's a rock and a hard place.
14:01ryszard_szopaI understand that I am supposed to set the classpath at the command line
14:02cooldude127technomancy: i think i got a timeout on that git repo tho
14:02cooldude127last time
14:02ryszard_szopabut what should I do when developing in the REPL?
14:02ryszard_szopaadd-classpath seems to have no effect
14:02technomancycooldude127: I could do a shallow clone, but IIUC that means you wouldn't be able to do an update in the future.
14:02hiredmanclojurebot: add-classpath
14:02clojurebotadd-classpath is bad, avoid it. I mean it!
14:02cooldude127ryszard_szopa: are you using the command-line repl or slime?
14:02technomancyI thought it was ok on the repl
14:02ryszard_szopaslime
14:03technomancyas long as you promise you're just screwing around. =)
14:03technomancyryszard_szopa: set the swank-clojure-extra-classpaths variable
14:03cooldude127ryszard_szopa: you should configure your swank-clojure-extra-classpaths
14:03cooldude127technomancy: i hate you
14:03technomancyheh
14:03technomancyit should be a list of all the jars/dirs you want apart from clojure.jar itself
14:04ryszard_szopacooldude127: no way of doing that via something like ,l in slime?
14:04cooldude127ryszard_szopa: not that i know of
14:04technomancyryszard_szopa: I think you will need to restart slime
14:05ryszard_szopaHuh... I am not sure I like the idea of restarting the repl each time I realized I need to use yet another library...
14:05technomancykill all the slime-related buffers as well as the *inferior-lisp* buffer
14:05technomancyryszard_szopa: it's annoying, but that's how the classpath works.
14:05gnuvinceryszard_szopa: see my blog: http://gnuvince.net
14:05cooldude127ryszard_szopa: well, i haven't really noticed it as a problem, i don't really work with too many other libraries besides clojure-contrib, at least in the middle of a project
14:05gnuvinceryszard_szopa: I posted a clojure-add-classpath command for Emacs.
14:06gnuvinceryszard_szopa: you run it before starting SLIME (or else you need to stop and start it again)
14:06cooldude127technomancy: i have problems again. now it checks everything out, but slime won't load. no classdeffound clojure/main
14:07technomancycrapp�
14:08cooldude127technomancy: i think i know why, clojure didn't compile
14:08cooldude127i think it's the same problem as the other stuff
14:08technomancyif clojure didn't compile, it should complain with a message and stop
14:08cooldude127technomancy: well it didn't, cuz i don't have any jars
14:10cooldude127technomancy: oh wait, maybe that's not it, but one problem is that those (cd ...) lines use clojure-src-root instead of src-root
14:10ryszard_szopagnuvince: I see, thanks. So it seems that Clojure is more like than like CL in terms of loading libraries.
14:10technomancygnuvince: are you sure you don't want that function to use add-to-list on swank-clojure-extra-classpaths instead?
14:11cooldude127ryszard_szopa: if you were saying more like java than CL, then yes it is
14:11technomancycooldude127: oh, of course... that's the problem
14:11cooldude127technomancy: yeah my clojure-src-root was my original one this time
14:12cooldude127technomancy: shit it's doing it wrong again
14:12ryszard_szopacooldude127: yeah, that's what I was saying ;-)
14:13cooldude127technomancy: now it's checking it out into my home folder, wtf!?
14:13gnuvincetechnomancy: what would it change?
14:13technomancycooldude127: yow.
14:14technomancycooldude127: comment out the slime line for testing the checkout stuff; should make it quicker
14:14cooldude127technomancy: this time i didn't type anything, i just accepted the default ~/src. could it possibly be misreading the default and using "" ?
14:14cooldude127k
14:14technomancycooldude127: that's possible
14:15technomancycooldude127: yeah, it doesn't handle default values correctly. which of course I never tested because I already had a checkout in ~/src. =)
14:15cooldude127technomancy: how do we fix?
14:16shoovercan someone please tell clojurebot *why* add-classpath is bad?
14:16shoover(and by extension, tell the rest of us)
14:16cooldude127technomancy: ok well it's definitely the default, cuz entering it in does it right
14:17technomancycooldude127: (if (string= src-root "") (setq src-root clojure-src-root))
14:17cooldude127technomancy: what's that last parameter of clojure-src-root in the read-from-minibuffer call?
14:18technomancycooldude127: it's *supposed* to provide a default value, but it doesn't.
14:19cooldude127technomancy: "However, in the usual case (where read is nil), read-from-minibuffer ignores default when the user enters empty input and returns an empty string, """
14:19technomancywtf... the default value only works if you're reading a lisp object. that's... not useful.
14:19cooldude127technomancy: lol
14:20cooldude127technomancy: what about read-string?
14:20technomancycooldude127: i'm just going to force the default value afterwords if there's an empty string
14:20cooldude127technomancy: it looks like read-string tho is what you want
14:21technomancycooldude127: just pushed out a new version to my clojure-mode "installer" branch on github
14:21technomancyoh?
14:21cooldude127http://www.gnu.org/software/emacs/elisp/html_node/Text-from-Minibuffer.html
14:21ryszard_szopawhen I do (setq swank-clojure-extra-classpaths '("/Applications/Processing.app/Contents/Resources/Java")), clojure slime refuses to start
14:21technomancyoh, that's more like it
14:22ryszard_szopait says: java.lang.Exception: No such namespace: clojure.lang.RT (basic.clj:261) and some "No such var" exceptions
14:22technomancyryszard_szopa: the classpath might be picky about trailing slashes
14:22technomancybut it shouldn't cause that kind of error. =\
14:23cooldude127technomancy: so it looks like it should be (read-string (concat "Install Clojure in (default: " clojure-src-root "): ") nil nil clojure-src-root)
14:23technomancycooldude127: sounds good; will push out that fix
14:23cooldude127technomancy: i'm doing it right now to test
14:24hiredmanryszard_szopa: I think I have seen that before
14:25hiredmancan you pastebin the whole exception?
14:25hiredmanlisppaste8: url?
14:25lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
14:25cooldude127technomancy: yeah the default value is working now
14:26lisppaste8ryszard pasted "clojure won't start, classpath issues" at http://paste.lisp.org/display/74730
14:26technomancycooldude127: the format invocations are horribly wrong though
14:26cooldude127technomancy: are they? mine work
14:26technomancythe ones I pushed, I mean
14:27cooldude127yeah, you forgot your s's
14:28cooldude127technomancy: i actually didn't even need to do a (format) for the ant ones
14:28cooldude127which is weird as hell
14:28technomancyso the cd lisp function works for ant but not for git?
14:28cooldude127technomancy: yeah wtf?
14:30technomancycooldude127: ok, I found another box to test it on; seems to work fine there though it's also an ubuntu system. what are you running?
14:30cooldude127technomancy: i've been doing my work in my emacs-starter-kit code, let me push it and you can see what i have working
14:30cooldude127technomancy: this is emacs 23 cocoa on OS X
14:31technomancycool. will want to test in 22 as well, but that makes me feel better that it works on Macs
14:31hiredmanugh
14:31hiredmanhe left
14:32hiredmanryszard_szopa: there is some member of clojure.lang.RT that used to be public, but became private that swank-clojure is trying to call
14:33cooldude127technomancy: http://tinyurl.com/amvszn
14:35technomancylooks good
14:35cooldude127technomancy: yeah seems to work, at least for me
14:36ryszard_szopahiredman: oh... so do you think svn-up swank-clojure may help?
14:36cooldude127more like a git pull
14:36cooldude127swank-clojure is on git isn't it?
14:36hiredmanryszard_szopa:
14:36hiredmanmaybe
14:37hiredmanyou can change clojure.lang.RT/ROOT_CLASSLOADER to (clojure.lang.RT/baseLoader) in basic.clj
14:37hiredmanmaybe
14:39ryszard_szopagit pulling made it work. Thanks!
14:40technomancycooldude127: what do you think about switching to CVS for slime? the git clone takes a long time...
14:41cooldude127technomancy: i think it might be a good idea, git doesn't really gain much in this case
14:41cooldude127if you're installing this way, you're probably not hacking on slime
14:41duck1123I think that's the first time I've heard CVS recommended over git because git was too slow
14:41cooldude127lol
14:41cooldude127cvs doesn't carry a bunch of history
14:42technomancyright; the only downside is that it would depend on four things instead of three (git, jvm, ant)
14:42duck1123can't you tell git to not dl all the history
14:42cooldude127duck1123: then you can't update apparently
14:42duck1123ahh... I've never tried it
14:42cooldude127me neither, technomancy said it :)
14:43cooldude127i think i'm gonna install with this for real now, not just testing
14:44technomancynever tried it; that's just what I've heard
14:45duck1123shallow coppies can't be cloned or fetched from or pushed to/from
14:45duck1123you should still be able to fetch/pull into
14:45cooldude127duck1123: then how do we do such a thing?
14:45cooldude127i'm about to run it, i want to make this happen :)
14:45duck1123git clone --depth 2 git://....
14:45technomancyduck1123: ah; I must have misunderstood
14:46ChousukeI find git to be faster *despite* the fact it clones the whole history.
14:46duck1123I just checked the docs
14:46technomancyChousuke: I haven't actually tried this; it's just a hunch
14:46technomancyslime has *lots* of history though
14:46cooldude127Chousuke: in general, yes, but with something like slime, it's slow as crap
14:46duck1123I wonder if you can pull in more history after the fact
14:46Chousukecooldude127: it took a few minutes for me.
14:46Chousukenot exactly slow.
14:46Chousukeemacs took a bit longer.
14:47duck1123I had problems git cloning slime on friday, I might try this as well
14:47cooldude127Chousuke: cvs doesn't take nearly that long tho, and this clojure-install thing makes emacs hang until it's odne
14:47cooldude127*done
14:48Chousukehmm, I might just test it
14:48duck1123doing it right now
14:49Chousukegithub is usually slow though. ./
14:49Chousukeor well, slowish
14:49technomancyjust pushed out a fixed version that uses a shallow clone for slime
14:50technomancyhttp://github.com/technomancy/clojure-mode/blob/9219f13d87f4e98feeca01dc6079c1c558b907d6/clojure-mode.el
14:50Chousuke... slow internets, only 6kB/s |
14:50Chousukenot a git problem though.
14:50technomancyif anyone else could test this I'd appreciate it
14:51cooldude127technomancy: i don't know if it actually made it any better
14:51Chousukethe whole slime repo seems to be about 3MB
14:51Chousukewith full history.
14:51duck1123--depth 2 seems like it is still downloading a lot
14:51technomancyChousuke: 33MB for me
14:51Chousuketechnomancy: unpacked?
14:51cooldude127WOO i have up-to-date slime and stuff
14:51technomancyChousuke: from git://git.boinkor.net/slime.git
14:52cooldude127clojurebot: latest?
14:52clojurebotlatest is 1245
14:52technomancyChousuke: .git itself is 30MB. haven't packed it; this is a fresh clone.
14:52Chousuketechnomancy: the transported size is about 3MB
14:52technomancywith --depth 2 it took 5.350 secs
14:52Chousukeor maybe closer to 4 actually.
14:53cooldude127technomancy: so the git repo for clojure can be a few revs behind
14:53ChousukeReceiving objects: 28% (3867/13438), 1.10 MiB | 6 KiB/s
14:53Chousukewhy are my intertubes so clogged right now :/
14:53cooldude127lol. brb
14:54duck1123I'm doing an offlineimap sync of my gmail account as well
14:54Chousukeand then sometimes it looks like my ISP decides to put me on low-speed zone.
14:54Chousukecompletely randomly.
14:56duck1123what git repos are you pulling from nablaone's on github?
14:56Chousukeyeah
14:59technomancyshould work in 22 now
15:03duck1123so you guys were able to clone slime recently, or no? I'm still getting "Cannot obtain needed blob abe81d1e64ba1dba47e4a1d81ee2c83a124615f4"
15:04technomancyduck1123: you could try git://git.boinkor.net/slime.git
15:04technomancybut the github one works for me with depth 2
15:05duck1123ah ha. --depth works over git:// but not http://
15:06duck1123The firewall at my work blocks the git:// port
15:06technomancyweak
15:07rhickeyOne more lazy-cons to go - in for
15:07duck1123I was trying to set up all of my dependencies for my dotfiles as submodules in git, and I needed Url's that would work both at work and home
15:10cooldude127technomancy: so is clojure-install now pretty much finalized?
15:11technomancycooldude127: I'm happy with it as long as it works on 23, 22, gnu/linux, and OS X.
15:11technomancyif it works on w32 then great, but I'm not going to lose sleep over it. =)
15:11cooldude127yeah i wouldn't
15:11technomancyanyway, I'll probably send a pull request to jochu to see if it can get merged upstream
15:11technomancythen I'll ping the mailing list and toss up a blog post.
15:12cooldude127cool
15:12cooldude127i'm happy to have up-to-date stuff
15:12technomancyoh right; well there still needs to be an update function; this just does the initial clone.
15:13technomancybut that should be easy to write.
15:13cooldude127technomancy: yeah, just git pull in each dir
15:13technomancyand recompile
15:13technomancybut yeah
15:13cooldude127oh yeah that too
15:14technomancyif you've got some spare cycles... patches are accepted. =)
15:14technomancypreferably to the clojure-mode repo rather than the starter-kit
15:14cooldude127Chouser: you get your custom-print stuff in yet?
15:14cooldude127technomancy: i'll see if i have time, but my elisp skills are quite bad
15:15technomancycooldude127: well this seems like a great place to get started
15:15cooldude127lol true
15:16cooldude127well, i'm just in health class, so i got time, let's see what i can do :)
15:16Chouserrhickey: ha! 'for' only took you an hour to knock out the first time, right?
15:17Chousercooldude127: nope, haven't even brought it up on the group yet.
15:17cooldude127technomancy: why don't i get the installer branch when i clone the repo?
15:17Chousercooldude127: do you have a good (simple?) use case?
15:17cooldude127Chouser: ok, just wondering, i'm still using my crappy hack
15:18cooldude127Chouser: um, i don't know if it's simple, but i'm writing some code that deals with matrices, and i have it so they print out in columns and rows
15:18cooldude127kind of like matlab
15:20rhickeyChouser: heh - for should be a lot easier now, but...
15:20technomancycooldude127: git clone just clones master; you need to add it as a remote
15:20technomancycooldude127: or use the github gem; it's pretty handy for stuff like this
15:20cooldude127technomancy: i think git checkout --track worked for me
15:21technomancyoh, right
15:21rhickeyits full of workarounds for partial laziness as is
15:21rhickeyit's
15:23cooldude127technomancy: clojure-update probably doesn't need a src-root, shouldn't it just use clojure-src-root, since it would assume it's already setup correctly?
15:24technomancycooldude127: that sounds like a good assumption
15:24technomancycooldude127: would be good to provide a helpful error message if it hasn't been set correctly (or if the install hasn't happened) though.
15:25cooldude127yeah i was gonna check if the appropriate directories were there
15:25technomancymight be enough just to check the return value of shell-command
15:25cooldude127oh yeah maybe
15:25technomancyit'll be zero if it succeeded
15:26cooldude127yeah
15:26cooldude127emacs lisp is like cl, where let is not sequential, that's let*, right?
15:26ayrnieuright.
15:27cooldude127k
15:27gnuvinceright.
15:29Chousercooldude127: oh, that is a good example. still readable by 'read', just \newline instead of \space in a few places.
15:29cooldude127Chouser: not exactly
15:29Chouseroh
15:30cooldude127not readable by read at all
15:30Chouserwell, that could be my example anyway. :-)
15:30cooldude127lol
15:30cooldude127that works then
15:31Chousercooldude127: out of curiosity, though, why do you need prn and friends to print in this format, instead of just having a new function?
15:31cooldude127Chouser: i want the repl to print it this way, instead of having to call a function everytime
15:31Chouseroh, sure.
15:31cooldude127that's how i did it at first, but it was infuriating
15:32cooldude127technomancy: i have something here that i'm about to test for the update function
15:32ayrnieu,(doc repl)
15:32clojurebotjava.lang.Exception: Unable to resolve var: repl in this context
15:32ayrnieu,(doc clojure.main/repl)
15:32clojurebot"([& options]); Generic, reusable, read-eval-print loop. Reads from *in* and writes to *out*. *in* must either be an instance of LineNumberingPushbackReader or duplicate its behavior of both supporting .unread and collapsing CR, LF, and CRLF into a single \\newline. Options are sequential keyword-value pairs. Available options and their defaults: - :init, function of no arguments, initialization hook default
15:32ayrnieu:print is one of the options
15:33cooldude127ayrnieu: but how do i make that happen in the normal slime repl?
15:34ayrnieuI don't know what slime does.
15:34hiredmanclojurebot: slime?
15:34clojurebotslime is icky
15:35cooldude127technomancy: i think i have something that works, but it displays a buffer with the ant results, why doesn't yours do that? i ripped your compiling code verbatim (except for a variable name change)
15:35cooldude127ayrnieu: ok
15:35cooldude127well this is working for me at the moment
15:38technomancycooldude127: it could be related to the length of the output
15:38technomancycheck the shell-command docstring
15:39cooldude127technomancy: i can send you a patch of what i have for a clojure-update function
15:39cooldude127and you are right, it's long enough now to show
15:39cooldude127i guess
15:40technomancyif you wrap it in a save-window-excursion, it will probably suppress the buffer being shown
15:40technomancycooldude127: no need for a patch if it's just a single new function; you can just lisppaste it
15:41cooldude127technomancy: ok i will after i try the save-window-excursion
15:42cooldude127technomancy: that's probably better, the diff is weird cuz i used your little C-c n shortcut and it changed a lot of indentation
15:42cooldude127technomancy: ok save-window-excursion suppressed it, i'll paste it real quick
15:44technomancyyeah, definitely don't want to clean up whitespace in the same commit as real features
15:45kefkaWhich do you recommend for accessing MySQL: SBCL + CLSQL or Clojure + JDBC?
15:45lisppaste8cooldude127 pasted "clojure-update emacs function" at http://paste.lisp.org/display/74734
15:45cooldude127technomancy: lisppaste for emacs is soooo cool
15:46technomancythat it is. =)
15:46cooldude127technomancy: i find that the autoloads for it don't work tho
15:46hiredmanwell, obviously, the one with clojure...
15:46kefkaAssume I can do it with either Clojure or SBCL
15:46cooldude127like when i try to just use one of the lisppaste functions, it says it can't load the file
15:46technomancycooldude127: yeah, I think that's a bug in elpa
15:47cooldude127technomancy: it works once i explicitly load the lisppaste.el file
15:47technomancycooldude127: i'd collapse your let* into a let with a single variable
15:47kefkaI started down the SBCL + CLSQL road, but CLSQL has a lot of missing features that are pissing me off... plus it seems not to be a very "lively" project in terms of development
15:47cooldude127technomancy: you're welcome to, i did it for clarity in my development, which i expected to be longer
15:47cooldude127lol
15:47ayrnieuI think that Java doesn't have very solid libraries for accessing MySQL. It's an undernourished language with few developers or business use, you see.
15:48cooldude127ayrnieu: jdbc does work tho
15:48WizardofWestmarcI think he was joking
15:48technomancycooldude127: sure; I'll make the change.
15:48technomancythanks for the codes.
15:48cooldude127technomancy: no problem, that didn't take very long. i love it
15:48kefkaWizardofWestmarc: I hope so...
15:48WizardofWestmarcat some point I want to play with sqlite in clojure, but haven't gotten around to it
15:48kefkaWizardofWestmarc: I took ayrnieu seriously, because I thought "it" meant MySQL
15:48cooldude127i like sqlite
15:48cooldude127yeah me too
15:49WizardofWestmarcum, mysql is a pretty heavily supported codebase...
15:49kefkaWizardofWestmarc: e.g. MySQL undernourished compared to enteprise products
15:49kefkaWizardofWestmarc: Cool.
15:49kefkacooldude127: How hard is JDBC to learn?
15:49technomancyit's too bad mysql isn't more closely connected with Sun... then it would get better Java support.
15:50WizardofWestmarctechnomancy: it may get there with time, it's only been what, a year since they bought the company?
15:50cooldude127kefka: not too hard i think
15:50technomancyWizardofWestmarc: (it was a joke)
15:50WizardofWestmarc:P
15:50WizardofWestmarcI didn't think they'd tightened integration yet
15:50WizardofWestmarchence still needing JDBC
15:50cooldude127nothing like a good joke to reveal how much none of us know what we're talking about :)
15:51ayrnieukefka: http://www.jdbc-tutorial.com/
15:51WizardofWestmarc�_�
15:51hiredmankefka: there is also clojureql
15:51hiredmanwhich I think is maybe sort of like clsql
15:51cooldude127hiredman: hopefully with less suck
15:52hiredmanI guess
15:52WizardofWestmarcwell it's actively being worked on
15:52hiredmanI haven't really used either
15:52WizardofWestmarcso that's an automatic plus ;)
15:52technomancythere's nothing quite like being able to bother the author on IRC if something goes wrong
15:53hiredmanlast I checked clojureql did not work well with postgres
15:53cooldude127technomancy: that's what i love about emacs-starter-kit ;)
15:54cooldude127i just go on irc and bug you when something's wrong
15:56technomancyheh
15:57cooldude127hmm, great health class is over and i actually accomplished something. thank you for that, i wouldn't have done shit otherwise
16:08gnuvince,(let [x (short 0)] ({0 "zero"} x))
16:08clojurebotnil
16:08gnuvince,(let [x (short 0)] ({0 "zero"} (int x)))
16:08clojurebot"zero"
16:09rhickeygnuvince: why are you using shorts?
16:09gnuvincerhickey: getting them from a buffer.
16:09gnuvince(.getShort byte-buf)
16:10rhickeygnuvince: use a sorted map if you want fuzzy compares
16:11rhickey,(let [x (short 0)] ((sorted-map 0 "zero") (int x)))
16:11clojurebot"zero"
16:12ayrnieu,((shorted-map 0 "zero") 0M)
16:12clojurebotjava.lang.Exception: Unable to resolve symbol: shorted-map in this context
16:13ayrnieu,((sorted-map 0 "zero") 0M)
16:13clojurebot"zero"
16:14gnuvince,[(/ (Math/log 10000) (Math/log 32)) (/ (Math/log 10000) (Math/log 2))]
16:14clojurebot[2.65754247590989 13.28771237954945]
16:15cooldude127eww
16:15cooldude127what is that?
16:16gnuvincecooldude127: can't specify the base with Math/log
16:16rhickeygnuvince: it can't be otherwise and retain compatibility with java.util.Map, which is quite important to some people, so either normalize your keys or use sorted-maps
16:16gnuvincerhickey: I'll normalize.
16:17gnuvinceIt's not a chore, it's just a pitfall I keep falling into.
16:17cooldude127gnuvince: oh, change of base, got it
16:17rhickeygnuvince: Clojure once had its own numbers and Java interop was much more painful and pitfall-ful
16:18gnuvinceI can imagine.
16:19cooldude127making clojure.lang.Ratio work with other numbers is weird enough. it doesn't fall into the hierarchy
16:19cooldude127gnuvince: what was the problem you were running into?
16:20gnuvinceI have some litteral maps with integers as keys, and when I use shorts (that I get from reading a ByteBuffer) and try to fetch a value, I got nil because I forgot to convert to int.
16:20gnuvinceThis illustrated the problem:
16:20gnuvince,(let [x (short 0)] ({0 "zero"} x))
16:20clojurebotnil
16:21cooldude127oh, i see
16:24clojurebotsvn rev 1246; [lazy] got rid of lazy-cons
16:25rhickeyok, lazy branch safe for the intrepid
16:25Chouserwow
16:25cooldude127woahh! where did lazy-cons go?
16:25rhickeyi.e. those willing to try living without lazy-cons
16:25durka42i guess i missed a huge discussion about what replaces it
16:25Chouserout moded, out dated, downsized, replaced.
16:26cooldude127what's done instead?
16:26ayrnieuhttp://clojure-log.n01se.net/
16:26rhickeythe important thing to note, at least until I get to doc, is that sequence fns return logical sequences, not (necessarily) ISeqs
16:26Chouserspecifically: http://clojure-log.n01se.net/date/2009-02-02.html#09:47
16:26rhickeyuse lazy-seq, cons and more in lazy fns, all of core has been changed over and should serve as an example
16:27Chouserso no nil-punning on anything except 'rest'?
16:27rhickeyChouser: and seq!
16:28Chouserah. right.
16:28rhickeyhttp://code.google.com/p/clojure/source/browse/branches/lazy/src/clj/clojure/core.clj#409
16:28gnuvinceWhat's nil punning again?
16:28Chouserbut not concat, filter, map, etc?
16:28rhickeyhttp://code.google.com/p/clojure/source/browse/branches/lazy/src/clj/clojure/core.clj#1408
16:28rhickeyChouser: right
16:29rhickeyamazingly, after I got lazy-seq in, I didn't have to change any consumer code of the lazy-sequence fns, only the fns themselves, so I expect the vast majority of code is using seq or rest, which work as always
16:29hiredmanhmmm
16:29rhickeyhttp://code.google.com/p/clojure/source/browse/branches/lazy/src/clj/clojure/core.clj#1441
16:30rhickeyhttp://code.google.com/p/clojure/source/browse/branches/lazy/src/clj/clojure/core.clj#1459
16:30rhickeyetc, search for lazy-seq
16:31rhickeyeverything should be truly lazy now, if not it's a bug
16:31Lau_of_DKrhickey: If I start producing code that works with that branch, what are the odds that I ahve to throw it all away in a month or two ?
16:31Chouseris (apply concat coll) still greedy on the first couple elements of coll?
16:32rhickeyuser=> (def x (apply concat [(map #(doto % prn) (range 10)) (map #(doto % prn) (range 10))]))
16:32rhickey#'user/x
16:32rhickeyuser=> (first x)
16:32rhickey0
16:32rhickey0
16:33rhickeyfully lazy everywhere, or it's a bug
16:33Chouser:-) sweet
16:34rhickeyPlease try it out and let me know - I'll try to write up a little doc + treatise later tonight
16:34rhickeygotta run
16:41hiredmanxD
16:42hiredmanI take that back
16:42hiredman:(
16:42hiredmanfor a second I thought a Runnable was also a TimerTask
17:03hiredmanwhat is better: mutiple atoms holding state, or one atom holding a map of state?
17:04Carki adopted this rule : if you start using atoms/refs all over the place, the you can as well program in java
17:04Carkthen*
17:05hiredman:P
17:05hiredmanas it happens I am proxying a java class
17:05hiredmanthe javadoc has all kinds of reference to state, most of which I will ignore
17:05Carkah the beast is lurking below, trying to take you in the mutation depths
17:06ayrnieuI have refs all over the place for debugging agents.
17:06hiredmanI think it will end up with two pieces of state
17:06Carkyep when using agents i too have refs showing up
17:07hiredmanone for cancel() so if the TimerTask is canceled it will no longer run, and one for scheduledExecutionTime
17:07hiredmanto keep track of the last execution time
17:08Carkwhy not a single ref with both values ?
17:08hiredmanatom
17:09Carkah right
17:09tei cant get clojure mode to do syntax hilighting
17:09tewhere have i failed as a father
17:09hiredmanCark: that is what I am doing right now
17:09hiredman(atom {})
17:09tei have: (add-to-list 'load-path "~/.clojure/clojure-mode") (require 'cojure-mode)
17:09tedo i need more?
17:09hiredmanthe time at which the most recent execution of this task was scheduled to occur, in the format returned by Date.getTime(). The return value is undefined if the task has yet to commence its first execution.
17:09durka42te: you chose emacs over vim :p
17:10teeventually yes
17:10tei havent played with emacs much since we last talked
17:10hiredmanbrilliant spec there
17:10tebut i have some time to kill today
17:10ayrnieute - (global-font-lock-mode 1), something like.
17:10teoh that will turn on hilighting and shite?
17:10teill try it
17:11ayrnieuAlso look at http://www.emacswiki.org/cgi-bin/wiki?ColorTheme
17:11Carkhiredman : heh, last time i had a ref being a map with one field being the agent, when this field was nil the agent was supposed to stop
17:12Carkpretty much the same thing
17:18hiredmanok
17:29nsinghalI have classpath with "classes" and "src" directory of a java project in that order. When i do (require :reload-all 'org.cc.file) - it is not reevaluating the file. Does clojure not look for the changed clj file if it finds the file__init.class?
17:31hiredmanhmmm
17:31hiredmanI am pretty sure I read somewhere that it picks whichever is newest, .class or .clj
17:52hiredmanhmmm
18:05technomancyte: it should be on by default unless you're on a really old version
18:07ricreeI'm slightly confused by defining classes in clojure. If I wanted to do something like this jambi tutorial where they define a custom QT widget (http://doc.trolltech.com/qtjambi-4.4/html/com/trolltech/qt/qtjambi-tutorial5.html), what would be the best way to go about it in clojure?
18:13ayrnieu(proxy [QWidget] [] ...), I'd expect.
18:17ricreethanks, ayrnieu.
18:22djpowellwhat happens when you send or send-off to an agent from inside the agent?
18:23djpowelldoes it reuse the same thread?
18:23ayrnieuNothing obviously special. I don't know if it reuses the same thread.
18:24djpowellok. The docs say that they are ordered though
18:24ayrnieuthey are ordered from the caller's POV.
18:25hiredmandjpowell: send and send-off are held till either the end of the action, or they are explicitly released
18:26hiredmansends happen on a fixed size thread pool
18:26ayrnieuthat is to say, multiple threads can send to an agent and these sends can be interleaved, but the sends from each thread will still be in their own order.
18:26hiredmancores + 1 I think
18:26ayrnieudo send-off spawn their own thread?
18:27hiredmanit is another threadpool, maybe it grows dynamically?
18:27hiredmandunno
18:34ayrnieusend-off creates a new thread; send uses the thread pool
18:34hiredmanoh
18:35hiredmanhmm
18:35ayrnieuer, no, I'm confused.
18:35ayrnieufinal static ExecutorService soloExecutor = Executors.newCachedThreadPool();
18:35ayrnieuthis is what it uses.
18:36hiredmanhttp://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool%28%29
18:36hiredmanok
18:36hiredmanclojurebot needs java doc url lookups
18:37durka42gorilla has such a function that i bet you could steal
18:37ayrnieuso the difference is that send-off may create a new thread, but send will stick to
18:37ayrnieuExecutors.newFixedThreadPool(2 + Runtime.getRuntime().availableProcessors());
18:37hiredmandurka42: hmmmm
18:37hiredman,(System/getRuntime)
18:37clojurebotjava.lang.NoSuchFieldException: getRuntime
18:38durka42,(Runtime.getRuntime)
18:38clojurebotjava.lang.ClassNotFoundException: Runtime.getRuntime
18:38hiredman,(Runtime/getRuntime)
18:38clojurebot#<Runtime java.lang.Runtime@14275d4>
18:38hiredman,(Runtime/getRuntime/availableProcessors)
18:38clojurebotjava.lang.Exception: No such namespace: Runtime/getRuntime
18:38ayrnieuuse clojure.contrib.javadoc
18:38durka42(.. Runtime getRuntime availableProcessors)
18:38durka42,(.. Runtime getRuntime availableProcessors)
18:38clojurebot1
18:39durka42,(use 'clojure.contrib.javadoc)
18:39clojurebotjava.lang.ExceptionInInitializerError
18:39durka42that was not supposed to happen
18:40hiredmanayrnieu: seems pretty bare
18:40durka42=> (find-javadoc-url "java.lang.String")
18:40durka42"http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html&quot;
18:40ayrnieuit gets URLs; what else did you want?
18:40hiredmanI must be looking at an old rev
18:41hiredmanhmm
18:41hiredmannone if the 'clojure.contrib.javadoc verions I a can find have find-javadoc-url
18:42durka42rev 430
18:42hiredmanI am looking at trunk on google code
18:43ayrnieuare you looking at the master svn repo, or a github copy?
18:43ayrnieuOK. I have 432, trunk, and see ./src/clojure/contrib/javadoc.clj:(defn find-javadoc-url
18:43hiredmanI am look at it in the google code web interface
18:44hiredmanah
19:31ricreewhen defining a function from a gen-class call, what is the clojure equivelent of "this"
19:32Chouserricree: if you're using gen-class (not proxy) then each function's first argument will be the value of "this" -- you can name it whatever you want.
19:32ricreeoh, thanks. Out of curiosity, what is it when using proxy?
19:32Chousukethis
19:32Chousukeit's just auto-bound
19:33ricreeok. thanks
19:50ayrnieuQApplication::exec: Must be called from the main thread <- bah.
19:51Chouseryes, Qt is a bit touchy to get working the way you'd want in Java and/or Clojure.
19:52ayrnieuhttp://gist.github.com/57210 follows the java, but - at least in OSX - the created window gives me the color wheel.
19:53durka42the spinning beach ball of death you mean? :p
19:53ayrnieuSBoD, yes.
19:54durka42are you trying to .show() a button like it was a window? i don't know Qt at all but that seems wrong
19:54ayrnieuthat's what http://doc.trolltech.com/qtjambi-4.4/html/com/trolltech/qt/qtjambi-tutorial1.html has
19:55durka42hmm, so it does
20:20thearthurhello all
20:20thearthurim attempting to use clojure with mvn
20:20talios'lo
20:20thearthurand cant get clojure-contrib into the classpath
20:21talioshow are you using it with mvn?
20:21thearthurmvn seems overly complicated for clojure (hainv to create a stub java class to start clojure and all)
20:21thearthurhttp://pupeno.com/blog/how-to-create-a-clojure-application
20:21ayrnieuaha, for the SBoD I just needed -XstartOnFirstThread
20:21taliosI made a simple mojo plugin for the compiler the other night, will probably add something to run the repl shortly
20:22ricreecan you create an instance of a class in the file where it is defined with gen-class?
20:22thearthurwhat should the clojure-contrib.jar be named and where should it be
20:23thearthurso the loader-thing will find it?
20:23Chouserricree: yes
20:26cpathIs this normal? After starting clojure repl, I replaced, added or changed jar or java classes. However it doesn't affect anything until restarting it.
20:27cpathI'm looking for :reload-all for java classes.
20:27thearthurwhen do i use a '.' and when do i use a '/' in (use 'bla.bla/foo)
20:28durka42thearthur: just make sure clojure-contrib.jar is in the classpath
20:28durka42 / is for java class static members
20:28durka42and for namespace/function i believe
20:28ayrnieufoo.bar.baz is always for packages named 'foo.bar.baz'. These never refer to methods. Separate .foo .bar are methods. foo.bar.baz/quux calls the static method quux under foo.bar.baz
20:29thearthurshould I put clojure-contrib under the maven root, or assume everyone building this will have it?
20:29ricreeFor some reason, I'm getting "Unable to resolve classname" errors with this code http://pastebin.com/d6d2de890 . Can anyone spot what I'm doing wrong here?
20:30durka42which classname
20:30hiredmanwew
20:30hiredmanwhen it rains it pours
20:30durka42hmm i thought you were supposed to put gen-class in the ns macro nowasdays
20:30ayrnieuthearthur - the .jar is only 111K. I've seen projects on github that just include clojure.jar and such
20:30durka42nowadays*
20:31ayrnieuricree, where do you get it?
20:31cpathDo I have restart clojure REPL whenever I change java classes, even though they are in classpath?
20:31hiredmancpath: I am pretty sure you do
20:32metaperlat the REPL, I typed something and got back (quote foo) instead of just foo ... if I type 'foo I get back just foo and that is what I see on my screen, but I must've typed a hidden character
20:32ayrnieu(.. QFont$Weight Bold value) <-- huh. I just did (.setFont (doto (QFont. "Times" 18) (.setBold true)))
20:32ricreewhen I call load-file on it in slime. it's coming from the (new BlockClass) at the end
20:32hiredmanthere are seperate java frameworks that do class reloading and stuff
20:32metaperlhi ayrnieu, you are into haskell arent you?
20:32ayrnieumetaperl - no.
20:32metaperlI thought I knew you from somewhere
20:32taliosanyone here working woth OSGi at all?
20:32hiredmanricree: I am pretty sure (gen-class ...) only generates a class if you (compile ...) the namespace
20:33cpathhiredman, Thank you.
20:33ricreehiredman: is there a good alternative for what I'm trying to do here?
20:34ricreeI've been trying to follow along with the qt tutorials. in particular (http://doc.trolltech.com/qtjambi-4.4/html/com/trolltech/qt/qtjambi-tutorial5.html )
20:34hiredmanricree: make a seperate namespace with gen-class and (compile ...) it
20:35thearthurhow dose maven choose the class path?
20:35hiredmanthat is the only way to really extend a class
20:35hiredmanthearthur: I would check to see if maven has it's own irc channel were you can ask maven specific questions
20:35taliosthearthur: class path is based on your declared dependencies
20:35Chouserricree: you might need the fully qualified name of your new class.
20:36ricreeshould this be done in a separate file from the other code? can I use multiple namespaces in one file.
20:36thearthurno #maven,#mvn,#maven2 ... that i could find
20:36ricreeChouser: I tried that, didn't seem to work
20:37durka42thearthur: they're on irc.codehaus.org
20:38thearthurok, :)
20:39taliosthearthur: not sure if it
20:39taliosthearthur: not sure if it'll help, but over on http://www.talios.com/clojure_running_successfully_under_osgi.htm I describe how I'm attempting to use clojure with maven, using the mojo I wrote
20:40taliosjust added a repl mojo, but not tried it yet as waiting on clojure to checkout on this machine to compile it first ;)
20:40Chouserricree: you know that you have to compile that file for the gen-class to work?
20:41thearthurtalios, :) /me looks at that
20:41ricreeno, I didn't.
20:41durka42what's mojo?
20:42durka42~mojo
20:42clojurebotexcusez-moi
20:42taliosdurka42: a mojo is a maven plugin
20:42durka42moldy old java object :)
20:42durka42oh ok
20:45Chouserricree: if you're not adding any methods in your new subclass, and you don't need the name of the class to be anything particular, 'proxy' is easier to use.
20:48thearthurhow will the loader know to look in clojure-contrib.jar for clojure.contrib.duck-streams
20:49hiredmanthearthur: the jvm looks through all jars for classpaths
20:49hiredmanclojure.contrib.duck-streams is actually a classpath/directory structure in the jar
20:50hiredmanclojure/contrib/duck_streams.clj
20:50o_I just saw Making Clojure Lazier on clojure.org. very interesting stuff. can someone explain what "nil punning" means there?
20:50hiredman,(seq [])
20:50clojurebotnil
20:50thearthurnil punning is the result of (good? (gen-pun 'joke))
20:51thearthur:)
20:51o_;-)
20:51o_but really
20:51thearthursorry, i dont actually know
20:51hiredmanI think nil punning is what rhickey calls it when (seq) of an empty thing is nil
20:52hiredmanso when you see stuff like (if n foo bar)
20:52hiredmanand n is a seq
20:52o_but isn't a seq of an empty thing an empty sequence ()?
20:52hiredman,(seq [])
20:52clojurebotnil
20:53hiredman^- no
20:53o_oh
20:54o_well, then no nil punning is a good thing, no?
20:54Chousernil punning is when you assume the return value of a fn is nil instead of an empty collection.
20:55Chouseryes, it's very convenient
20:55o_chouser: but only if you (seq) it, no? otherwise it's still an empty seq.
20:55ayrnieu,(nil? (seq []))
20:55clojurebottrue
20:56ayrnieuis clojurebot running the fully-lazy branch?
20:56o_ayrnieu: according to the new docs, no.
20:57hiredmanayrnieu: nope
20:58o_does the new lazy branch means sequences behave more like functions and less like data-structures?
21:03hiredmano_: eh? not from what I have seen
21:04hiredman(which, granted is not much)
21:04hiredmanI think it mostly just means more explicit calls to seq
21:04Chouserin both trunk and lazy, (seq foo) will return nil for empty foo
21:05rhickeylazy notes in progress: http://clojure.org/lazier
21:06Chouserin trunk, all functions that return seqs (map, filter, concat, etc.) return nil instead of anything empty, but in lazy branch they may return a non-nil empty thing, such that you have to call 'seq' on them to test if there's something there.
21:09o_I'm trying to figure out when I last used or assumed that map/filter/concat return nil when applied to an empty sequence but I can't. anyone got an example of idiomatic use of nil punning?
21:10o_this is important. otherwise I won't know whether I should be excited or alarmed following the latest developments. :-)
21:11ayrnieuI just installed lazy and saw that what I was just doing still worked. That was pretty calming.
21:14ChouserIf I understood what rhickey was saying earlier, he wasn't relying on nil punning as much as he thought. Perhaps not at all (except for with 'rest' which will still work)
21:16ayrnieu(rest x) == (seq (more x))
21:20teSo I'm using clojure-mode with swank clojure/slime
21:21tebasically i open up slime, and then M-x clojure-mode
21:21tethe syntax turns on, but then when I hit return it doesn't interpret the block i just typed in
21:21teit just keeps going to the next line, as if i never hit enter
21:22cooldude127te: don't use clojure-mode in slime buffer
21:22cooldude127s
21:22cooldude127slime as it is is fine, it uses repl-mode
21:22cooldude127clojure-mode is for .clj files
21:22teit doesnt do any hilighting though
21:23cooldude127highlighting isn't really important at the repl
21:23teor does it?
21:23teyeah i know its not that big of a deal
21:23tebut it would be nice while im learning
21:23teim very visual
21:23cooldude127te: it's not supposed to highlight the repl
21:23tei understand
21:23cooldude127te: you can type all your code into a file, and then eval it
21:23teim just making a comment
21:23cooldude127C-M-x evaluates a top-level form
21:24thearthurwhat is the best method/framework for turning clojure code into a program that can ship?
21:25hiredmanwhat do you mean by ship?
21:25thearthurie: what is better than maven
21:25thearthurand by better i mean easier to use
21:25hiredmanif you mean "make a jar" most people use ant
21:26hiredmanI cannot say I am fond of maven or ant
21:26thearthurmaven is hard to get right this classpath issue on clojure-contrib has stopped me
21:26hiredmanmake works fine
21:26taliosI found maven quite easy to work with
21:26ayrnieudoes a gen-class tutorial exist?
21:27hiredmanclojurebot: compile?
21:27clojurebotExcuse me?
21:27hiredmanayrnieu: there is http://clojure.org/compilation
21:27taliosthearthur: you just need to declare clojuire-contrib as a dependency in your pom.xml - if its not in a repository (local or otherwise), you could use a system dependency and specify the path
21:27ayrnieuyeah, I've seen that.
21:28hiredmanthere are that, and the doc string for gen-class
21:28ayrnieu... huh. Nevermind.
21:30thearthurthanks talios
21:30thearthuri will try to figure out how to do that
21:30thearthurmvn is not intended it seems for the java newb
21:31cooldude127thearthur: go with ant if you're a beginner
21:31taliosI wouldn't say that - I'd just say it sounds like you've not yet learnt how dependencies work.
21:33thearthurthey are quite mysterious actually
21:33thearthurtalios, if i understood how the classpath was constructed things i think would get better
21:34lisppaste8ayrnieu pasted "lazy fail" at http://paste.lisp.org/display/74760
21:34ayrnieuwith trunk, that compiles
21:36ayrnieuOK, lazy rev 1247 compiles it.
21:42ricreehonestly. compiling is kind of confusing
21:43Chouserit is a bit, and it certainly has more moving parts
21:43ChouserI avoid it whenever possible
21:43ricreethe most frustrating part is how easy the documentation makes it look
21:44hiredmanyou almost never need to (compile ...) stuff
21:44hiredmanclojurebot: I am using gen-class
21:44clojurebotNo entiendo
21:44hiredmanbah
21:44ayrnieunow I have two problems?
21:44hiredmanis that it?
21:44hiredman:P
21:45ricreeso with defining a new widget in that QT example I was working with earlier. is there some way I should be doing this that avoids gen-class/compile?
21:46Chouserricree: if you're not adding any methods in your new subclass, and you don't need the name of the class to be anything particular, 'proxy' is easier to use.
21:46ricreeand that doesn't require compiling?
21:47Chousercorrect
21:47ayrnieu(def widget (doto (proxy [QWidget] []) (.setFixedSize 200 120) ...))
21:50ricreeby the way. thanks a ton for all the help, everyone. I know I've been making a pest of myself in this channel today, and I appreciate all the help I've gotten
21:54Chouseron behalf of all the other people who actually answered your questions, you're quite welcome. :-)
21:55lisppaste8ayrnieu pasted "qt4 - this seems about right" at http://paste.lisp.org/display/74761
21:56gnuvince_Is it just me or is the hardest part of "Clojure" when you are dealing with a mutable Java object and you wonder how the hell you're going to use it cleanly?
21:57ayrnieuI for one praise Java's ByteBuffers.
22:00duck1123evening folks
22:00duck1123I bought Programming Clojure tonight. I'm happy.
22:02cooldude127gnuvince_: um, i would say the hardest part is doing things you're used to doing with mutable data when that isn't possible
22:02ricreeI've been thinking about getting it, if for no other reason than as a sign of appreciation for the posts he did translating examples from PCL to clojure
22:02ricreeit's been a tremendous help getting started with clojure
22:03hiredmanthe hardest part is when you find a java interface that is almost exactly the same as Runnable, but clojure functions don't implement it
22:03cooldude127lol
22:04hiredmanI really should write a mk-interface macro to avoid writing proxy all the time
22:04waltershiredman: i wonder if invokedynamic could make the performance cost of auto-implementing single-method interfaces acceptable
22:05waltersseems like it could; you'd only pay to do the reflection once
22:05danlarkinhiredman: gen-interface?
22:06hiredmandanlarkin: nah
22:07hiredmanjust a macro that generates the proxy form for me
22:09gnuvince_ayrnieu: they're actually what I'm dealing with now.
22:15yangsx,(reduce (fn [result entry] (if (even? (count entry)) (conj result entry) (conj (butlast result) (concat (last result) entry)))) [] [[1 2] [3 4] [6 7]])
22:15clojurebot[[1 2] [3 4] [6 7]]
22:16yangsx,(reduce (fn [result entry] (if (even? (count entry)) (conj result entry) (conj (butlast result) (concat (last result) entry)))) [] [[1 2] [3 4 5] [6 7]])
22:16clojurebot([6 7] (1 2 3 4 5))
22:16yangsxCan anyone help me understand the difference between the above two?
22:18yangsxThe second result is unexpected to me.
22:20yangsxIs it a bug with reduce or butlast, or am I doing something wrong?
22:20ChouserI'll look at it
22:20ayrnieu,(concat [1 2] [3 4])
22:20clojurebot(1 2 3 4)
22:21ayrnieu,(vec (concat [1 2] [3 4]))
22:21clojurebot[1 2 3 4]
22:23Chouseroh, were you expecting butlast to return a vector?
22:25yangsxChouser: yes, but I may be wrong?
22:25Chouser,(butlast [1 2 3])
22:25clojurebot(1 2)
22:26Chouserbutlast returns a seq
22:28Chouseryou can pour it back into a vector using 'vec', as perhaps ayrnieu was demonstrating
22:31yangsxThanks, it seems I have to pay for the seq interface :) and that's not the first time I forgot it.
22:31ricreeproxy returns a new instance, right?
22:31Chouserricree: yes
22:31Chouseryangsx: you may be interested in subvec
22:32lisppaste8ayrnieu pasted "qt5 - but the style bothers me." at http://paste.lisp.org/display/74762
22:33ayrnieuso (blocks) returns a new QWidget each time, but they bear no relation to each other as the Java example has it.
22:33Chouseryangsx: or if you're going to do a lot of pushing things onto one end of the collection and pulling them off the other, you might like clojure.lang.PersistentQueue
22:34ayrnieuhm. /me &
22:37yangsxThanks, I'll try that if my program is too slow.
22:37ricreehehe. nice to know I'm not the only one working through those examples
22:39hiredmanthis mk-interface is proving more difficult then I had hoped
23:06ricreeis there a way to have a function call in a macro expand without a namespace?
23:06gnuvince_Don't use `?
23:07dnolen_ricree: what are you trying to do?
23:08cooldude127ricree: use ~'blah
23:08hiredmanlisppaste8: url?
23:08lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
23:09cooldude127ricree: actually, that might not work in your case
23:09lisppaste8hiredman pasted "mk-interface" at http://paste.lisp.org/display/74764
23:10hiredmanit can end up being just as verbose as proxy
23:11ricreeI'm trying to write a macro that lets you use an anonymous function as the callback for a qt connect call. I'm doing it by using proxy on the base object class and then calling a function from proxy's return value
23:11lisppaste8ricree pasted "connect macro" at http://paste.lisp.org/display/74765
23:11hiredmanbut if it is a single method interface...
23:11hiredmanstill some issues
23:12ayrnieu,(doc connect)
23:12clojurebotjava.lang.Exception: Unable to resolve var: connect in this context
23:14ricreeclojurebot seems to be having trouble tonight. I don't think I've seen even half of the calls to it succeed
23:14hiredmanclojurebot: give more is <reply>please don't just say it doesn't work, exceptions are not just noise, so please pastbin code+the exception it generates
23:14clojurebotAlles klar
23:14hiredman~give me more
23:14clojurebotPardon?
23:14hiredmanclojurebot: bite me
23:14clojurebotHuh?
23:14hiredman~give more
23:14clojurebotplease don't just say it doesn't work, exceptions are not just noise, so please pastbin code+the exception it generates
23:15ayrnieuricree, it isn't having problems.
23:18hiredman,(loop [] (recur))
23:18clojurebotExecution Timed Out
23:18hiredmanxD
23:28eyeris_I am writing fact tests for clojureql. clojureql uses a keyword ::AnyDB. I want to pass that to a function from my test module. If I use ::AnyDB it resolves it to my namespace, as I'd expect. I've require'd the clojureql namespace as sql. When I try sql/:AnyDB I get the error: No such var sql/:AnyDB. How can I use :AnyDB from outside the clojureql module?
23:29hiredmaneyeris_: :sql/AnyDB
23:29hiredman,::AnyDB
23:29clojurebot:clojure.core/AnyDB
23:29eyeris_Ahh!
23:29eyeris_That makes sense, sort of :)
23:30hiredmanweird that that ends up in clojure.core
23:30ayrnieu,*ns*
23:30clojurebot#<Namespace sandbox>
23:30hiredmanhmmm
23:33eyeris_The multi-method still dispatches on :dk.bestinclass.clojureql/AnyDB though
23:33eyeris_What is strange is that it doesn't respect the alias of :sql/AnyDB
23:34hiredmansql is just an alias
23:35eyeris_Right, I know.
23:35hiredman,(doc alias)
23:35clojurebot"([alias namespace-sym]); Add an alias in the current namespace to another namespace. Arguments are two symbols: the alias to be used, and the symbolic name of the target namespace. Use :as in the ns macro in preference to calling this directly."
23:36eyeris_What I'm saying is that, since clojure knows sql is an alias for dk.bestinclass.clojureql, it should be able to resolve :sql/AnyDB as :dk.bestinclass.clojureql/AnyDB before passing it to the multi-method.
23:36hiredmanuh
23:43blbrownmy lisp is a little rusty. If I want to apply a function to all members of a sequence. I am assuming I use 'apply'. e.g. (apply println ["a" "b"]) ?
23:44hiredmandepends
23:44blbrownforexample, using 'println' as an example
23:44hiredman(apply println ["a" "b"]) is the same as (println "a" "b") if that is what you want
23:46blbrownOK, bad example
23:46hiredmannot really
23:46hiredman(apply + [1 2 3 4]) is the same as (+ 1 2 3 4)
23:46hiredmanyou may want map
23:47hiredman(map println ["a" "b"]) is like (println "a") (println "b")
23:47hiredmanexcept map is lazy
23:47hiredmanso you need to wrap it in doall or dorun
23:48hiredman(if you are running it for side effects)
23:48hiredmanthere is also doseq
23:48cooldude127hiredman: or in the case of println, probably dorun
23:48cooldude127oh nvm
23:48cooldude127you said that already
23:48cooldude127lol
23:48hiredmanwhich I rarely use, but is like a foreach loop
23:48hiredman:P
23:49hiredman,(doseq [i (range 10)] (print i))
23:49clojurebot0123456789
23:50hiredman,(dotimes [i 10] (print i))
23:50clojurebot0123456789
23:52blbrown,(doseq [i ["a" "b"]] (print i))
23:52clojurebotab