#clojure logs

2009-03-01

01:32banisterfiendcan someone tell me how to setup clojure in linux?
01:35ayrnieubanister - go to clojure.org, click on 'wiki' at the top-right, go to Getting Started.
01:41banisterfiendcan you please help me though instead
01:46cp2banisterfiend not much to setup
01:46cp2all you need is java
01:46cp2and then you can either grab the source from the svn and build it, or download the latest release
01:46banisterfiendwhich do you recommend?
01:46banisterfiendsource or latest release?
01:46cp2doesnt matter really
01:46banisterfiend(and how long does the source take to build?)
01:46cp2building from source isnt necessarily "stable"
01:47cp2it builds pretty quickly
01:47cmvkkon the other hand, some pretty significant changes have occurred since the last real release?
01:47cp2yeah, that is true
01:47banisterfiendill build from source
01:47cp2banisterfiend, i also recommend what ayrnieu told you to do
01:47cp2the wiki is a great place to start at
01:48banisterfiendcan i use clojure with slime?
01:48cp2there is clojure-slime
01:48banisterfiendis emacs the recommended clojure editor?
01:48cp2and also clojure-mode
01:48cp2and swank-clojure
01:48cp2well, banisterfiend, its up to you in the end
01:48banisterfiendyeah
01:48banisterfiendjust curious what most ppl are using though :)
01:48ayrnieuI did all my clojure editing with vi.
01:49banisterfiendwhat is the javac package called?
01:49banisterfiendit says i need javac
01:49banisterfiendbut apt-get install javac doesn't do the trick
01:49cp2jdc
01:49cp2er
01:49cp2jdk
01:49cp2*
01:49banisterfiendthanks
01:50cp2javac is included in the jdk
01:50cp2but, the package is not labeled jdk probably
01:50cp2what package manager?
01:50cp2oh right, apt
01:50banisterfiendapt
01:50cp2apt-get install sun-jdk iirc
01:51banisterfiendapt-get install sun-java6-jdk ?
01:51cp2yes thats it
01:51banisterfiend(i dont know anything about java sorry)
01:51banisterfiendjava6 rather than java5 ?
01:52cp2java6 is the latest
01:52banisterfiendok thanks
01:52cp2you could have java5 if you want, but it lacks some newer features
01:52cp2nothing too special though
01:52banisterfiendlike templates?
01:52cp2generics* were introduced in java 5
01:52cp2clojure will build in either tho
01:53banisterfiendgenerics are the java word for templates?
01:53cp2pretty much
01:53banisterfiendlast time i looked at some java code
01:53banisterfiendseems like it's getting pretty much as complicated as c++
01:53cp2eh, not so much
01:54banisterfiendso
01:54banisterfiendhmm
01:54banisterfiendis clojure really so good for multi-core systems?
01:55cp2i dont know; maybe a more competent person can answer :)
01:55banisterfiendyou're new to clojure too?
01:55cp2somewhat
01:56banisterfiendnew to lisps too?
01:56cp2somewhat
01:56cp2heh
01:57banisterfiendso what about clojure appealed to you?
01:58cp2i dont know, i was always curious about lisps
01:59cp2started learning cl, but never really did anything with it
01:59cp2then i found out about clojure, and like it because it used the java library
01:59cp2coming from java, that was appealing
01:59cp2being able to use a library i was familiar with
02:00banisterfiendwhat other languages do you know besides java? which dynamic ones esp? :D
02:03cp2pretty much python and ruby
02:03cp2and i wouldnt go as far as "know"
02:06banisterfiendah ok
02:06banisterfiendwhich do you prefer out of python and ruby?
02:07cp2i havent used either enough to say for sure, but i will go with python
02:07banisterfiendwow so you're pretty much just a java programmer?!
02:08cp2well, was
02:08cp2i had a fling with C# too
02:08banisterfiendwhat have you set things up to run the clojure repl?
02:09cp2what ?
02:09banisterfiendi mean what do you type to run the repl?
02:09cp2you can use java -jar clojure.jar
02:09cp2and it will drop a repl
02:09cp2on the wiki it goes over using jline with clojure at a shell, which is a bit nicer to use
02:21banisterfiendok
02:21banisterfiendhow do i get ant to do the equivalent of a 'make install' to install clojure system wide?
02:22cp2well, you dont really need to install clojure, its just a java library after all
02:22cp2i suppose you could put it in a directory thats in PATH
02:22banisterfiendoh ok
02:22banisterfiendim qutie new to linux
02:22cp2so you can just java -cp clojure.jar:. clojure.main somefile.clj
02:23banisterfiendhow/where should i put the clj bash script so that i can run it from anywhere?
02:23cp2/usr/bin
02:23banisterfiendoh ok
02:23banisterfiendthanks
02:23cp2make sure you chmod to a+x as well
02:25banisterfiendthanks
02:45banisterfiendcan someone give me a quick factorial example function in clojure?
02:45banisterfiend(nothing clever using apply or whatever, just a simple recursive) :D
02:49cmvkk(defn fact [i] (loop [i i res 1] (if (< i 2) res (recur (dec i) (* res i))))
02:51replacaSimpler is this: (defn fact [n] (if (<= n 1) 1 (* n (fact (dec n)))))
02:51replacabut it's not as optimal, since java doesn't know how to optimize it
02:51cmvkktrue; i automatically disregard solutions that aren't tail recursive now apparently?
02:52replacastrictly speaking, that is tail recursize :-)
02:52replaca*recursive
02:52cmvkkactually it isn't; fact's return still has to multiply against n.
02:53cmvkkotherwise you could use recur there, but if you try that it won't work.
02:53replacaoh yeah, you're right
02:54replacabut I think a good CL compiler would still optimize it, wouldn't it?
02:54cmvkkwell you can't optimise a solution that isn't tail recursive so that it won't blow the stack.
02:55replacahmmm
02:55banisterfiendthanks replaca
02:55cmvkkbecause you have to store that last "* n" somewhere...
02:55cmvkkand that somewhere is on the stack.
02:56replacanow I'm having to think too hard for this late on a Saturday night :-)
02:56replacabanisterfiend: no problem
02:56cmvkki was going to say, i'm not actually sure; maybe there IS a way or something.
02:57replacawell, it seems optimizable in this case, but I don't know if it generalizes
02:57replacasince you could basically analyze it out into a loop
02:59replacabut a quick check shows me that sbcl can't do it, so I guess it "isn't done"
03:00cmvkkyeah; although possible, it doesn't seem feasable in any general sense
03:00replacaThanks for the clarification cmvkk - I thought that case got converted to TCO
03:01replacaso I just learned something! :-)
03:08jhujhitianyone using vimclojure 1.3.0?
03:59Lau_of_DKMorning all
04:00ImInYourMonadis the ants example by rhickey an example of swarm intelligence algorithm or is it just concurrency?
04:01Lau_of_DKconcurrency
04:11ImInYourMonadknn.Knn with constructor Knn, then i should (import '(knn.KNN Knn)) right?
04:11ImInYourMonadknn.KNN with constructor Knn, then i should (import '(knn.KNN Knn)) right?
04:13lenstWrong?
04:14ImInYourMonadwell it doesnt work
04:14ImInYourMonadbut is it the correct syntax?
04:15lenstYou should only import the class, not the constructor.
04:16lensthmm. What is a constructor btw? Isn't a constructor in Java just the class name?
05:40Lau_of_DKHmm, SofiaBA, running with fog, double-textured translucent water and detail-textured Imagebased heightmap + skybox, idles at ~650 fps :)
05:42hoeckLau_of_DK: and your machine is a??
05:42Lau_of_DKIts a single-core AMD 4000+ with a Geforce 8600 GTS
05:43Lau_of_DKIt goes roughly at the same speed on my laptop also, nvidia MX something
05:44Lau_of_DKhoeck: Regarding physics - I got everything imported, all classes instantiated, added both statics and dynamics to my rootnode and everything rendered - but the physics wasnt active somehow, the gravity didnt pull for instance, so after working with that for 2 days I decided to freeze it until I had provided more wrapper functionality
05:45hoeckaha, thanks for the info, was just about to ask :)
05:45Lau_of_DKIf you want to contribute that functionality - you'd be most welcome :)
05:45hoeckat least, there is box2D + processing left for java-clojure 2D physics
05:45Lau_of_DKI always felt like I was THIS close
05:46Lau_of_DKHows that useful in this regard?
05:46hoeckonly for 2D, but still fun
05:47hoeckdid you try the jme-physics example from their wiki?
05:47Lau_of_DKThats the one I ported, almost directly
05:48Lau_of_DKThen when that didnt work, I commented out every but the physics part, it rendered, but didnt respond to forces
05:49Lau_of_DKBut its a big step that it rendered, because that means that all physics nodes (static + dynamic) were intantiated correctly
05:53hoeckwell, I'm giving it a try, repl-interactive physics sounds just too interesting to give up :)
06:02Lau_of_DKYea, although I dont have the physics, its cool to navigate an interactive world, like what Im doing now
06:03Lau_of_DKBut I recommend that you stick close to the Github, Im updating alot of stuff these days
06:03Lau_of_DK(adding particle support atm)
06:08hoecklast night i was busy with adding a better clojure-def-regexp to clojure-mode, so that speedbar and imenu will show correct definitions
06:10Lau_of_DKYoure contributing to technomancy's clojure-mode aswell ?
06:12hoeckno, just a local fork to keep xemacs compatibility
06:14hoeckdon't know if any xemacs and speedbar users are here
06:15Lau_of_DKk
06:18Lau_of_DKAlready got particles flying around - Im really feeling the rapid pace of Lisp development on this one now :)
06:21hoeckcool
06:21bOR_thanks rhickey :). 7 8-core computers crunching on simulations that take 13 hours each :). would have been horrible if I would be using a single core per simulation.
07:10banisterfiendwhat is a 'special form' ?
07:15Lau_of_DKAs I understand it, its a form thats provided from neither a clojure-function/macro
07:18rfgpfeiffer,`(let [def [1 2 3]] (def 2))
07:18clojurebot(clojure.core/let [def [1 2 3]] (def 2))
07:19rfgpfeiffer,(let [def [1 2 3]] (def 2))
07:19clojurebotDENIED
07:19rfgpfeifferbanisterfiend: you can't rebind special forms, for example
07:20rfgpfeiffer,(let [fn [1 2 3]] (fn 2))
07:20clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: nth not supported on this type: Integer
07:23rfgpfeiffer,([1 2 3] 2)
07:23clojurebot3
07:24rfgpfeiffer,'def
07:24clojurebotdef
07:50hoeckLau_of_DK: which revision of clojure are you using for SofiaBa?
08:13Cheshirehi clojeure
08:31rhickeyCheshire: hi
09:42gnuvince_Good morning
10:10Lau_of_DKhoeck: The one just before Lazy Town moved in
10:10Lau_of_DKI think only 1 functions is affected
10:11Lau_of_DKIs it easy enough to get running from the clone?
10:35replacagnuvince_: you were asking about "status of pretty print" yesterday?
10:37replacaThe core pretty print engine is all done, pretty printing data is all done, now I'm getting all the defiinitions for various code structures in
10:37replacaShould be ready for "preview release" RSN, but my day job has been a bear the last couple of months
10:41gnuvince_replaca: thanks
10:41replacagnuvince_: np
10:47gnuvince_Does anyone have any recommendation for tutorials or books to quickly get up to speed with Swing?
12:09blbrownhttp://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples#proxy How do you implement a constructor with Proxy
12:11kotarakblbrown: you don't? With proxy you get an object, which behaves as specified, when calling the methods. Why would you want to implement a constructor for an object, which is already there?
12:12blbrownkotarak, maybe that is the intended purpose, but if I wanted to implement an abstract class and have access to protected methods through defining a constructor, you are saying I can't do that?
12:14kotarakblbrown: I'm not that solid in Java knowledge. I never tried to access protected methods via a proxy....
12:16blbrownhmm, according to the docs, I do have access to protected methods
12:16kotarakblbrown: Well. then it should be possible, no? I'm not sure, though, why you would need a constructor to do so.
12:18blbrownkotarak, I don't necessarilly need a constructor. but i need to call the protected method some how
12:18kotarakblbrown: is this method implemented by the super class? Then there is proxy-super (or something like this).
12:19mattreplkotarak: was looking for that to post.. not finding it on site docs, must've seen it on list
12:20blbrownglad there aren't any usage examples in the clojure api docs
12:20mattreploh, no it's on the api page, just not on the java-interop page
12:21mattreplhttp://clojure.org/api#toc408
12:21mattrepl,(doc proxy-super)
12:21clojurebot"([meth & args]); Use to call a superclass method in the body of a proxy method. Note, expansion captures 'this"
12:36Chouser"Note that while method fns can be provided to override protected methods, they have no other access to protected members"
12:38gnuvince_Is -Xprof considerer accurate? Because it reports that one of the costliest functions in my code is PersistantVector.count, but I never call it (and as far as I know, count is supposed to be really fast)
12:41durka42PersistentVector.java:138 public int count(){ return cnt; }
12:41blbrownOK, this is what I am trying to do. Obviously I am doing that wrong, but at least it doesn't give me an error. http://paste.lisp.org/display/76325
12:41p_lgnuvince_: You sure it's never called? Is there any call graph tool available?
12:42gnuvince_ 22.9% 3774 + 0 clojure.lang.PersistentVector.count
12:42Chouserblbrown: (doto (proxy [PircBot] []) (.setName "-->dog"))
12:42durka42i don't know how you do breakpoints in java, but you could edit PersistentVector::count to throw an exception, then you'd get a backtrace
12:43gnuvince_p_l: the better profiler (which takes ages to run) has very different numbers
12:45blbrownChouser, setName is not found because it is protected
12:45Chouserblbrown: allow me to introduce you to gen-class
12:45blbrownbah
12:45ChouserI know. I'm sorry.
12:46Lau_of_DKGood evening gents
12:47Chouserall you would need is a class that extends PircBot, and provides public access to the protected members you need.
12:47ChouserThen you could go ahead and use proxy on that new class instead.
12:47ChouserLau_of_DK: hi
12:47Lau_of_DKYo Chris
12:48Lau_of_DKCoaching the crowd on Gen-class again? :)
12:49Chouser:-(
12:49Lau_of_DKMy solution worked out so great, that Im now doing gen-class in gen-class :)
12:50Lau_of_DKDid you check out my latest screenshot Chouser, with the fog and everything?
12:50Chouserproxy teases with its ease of use, then suddenly betrays.
12:50Chouserah, nope, hadn't 'seen the fog.
12:51Chouserthose are nice clouds. do they move?
12:51Lau_of_DKThey move when you move, its a skybox
12:51rhickeyChouser: is that :let for doseq ready for me to take? did you have any other thoughts on for unification?
12:51Lau_of_DK(im not happy with it yet though)
12:52Lau_of_DKclojurebot: proxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
12:52clojurebotYou don't have to tell me twice.
12:52Lau_of_DKTruer words are rarely spoken
12:52Chouserrhickey: don't use that, it's got a bug.
12:53rhickeyok
12:53Chouserstill working on let. I think I've got it by the tail now...
12:53Chouserer, for
12:57mattreplLau_of_DK: link to screenshot?
12:59Chousermattrepl: http://wiki.github.com/Lau-of-DK/sofiaba
12:59Lau_of_DKhttp://wiki.github.com/Lau-of-DK/sofiaba
12:59Lau_of_DKmattrepl: its a work in progress
13:00mattreplLau_of_DK: and I'm assuming this is jME? I'm curious if you've tried adding models to a scene after it was created. I've noticed issues with lighting
13:00Lau_of_DKYea, in the current project you can press P to spawn a swarm on particles, and N to spawn a textured sphere with a picture of my daughter :) All works perfectly
13:01mattreplheh, nice. =)
13:10Lau_of_DKhoeck: report
13:32blbrownhiredman you there?
13:34Lau_of_DKhoeck: report
13:37hoeckLau_of_DK: segfaulted my vm
13:37Lau_of_DKreally... Thats no good
13:37Lau_of_DKWhy are you on a VM ?
13:38hoeckregardless which renderer (lwjgl or jogl) was used
13:38hoecki mean my jvm :)
13:38Lau_of_DKAny way to deduct what kills it ?
13:38Lau_of_DKCan you compile it?
13:38hoecknow I've just upgraded to jdk6.11
13:39hoeckyeah, it compiles, then asks for screen resolution and such, then I see an empty frame, then the segfault
13:39Lau_of_DKHmm
13:39hoecksomewhere when calling an openGL routine
13:40Lau_of_DKHave you tried the Webstart demos from JMonkeyengine.com ?
13:40hoeckno, that would be the next step
13:41Lau_of_DKOk... Hope you can point your finger at something that breaks
13:41Lau_of_DKYou did read the README right?
13:41cp2hoeck it could be an opengl problem
13:42Lau_of_DKcp2: You got it running?
13:42cp2no, i dont know what you are talking about actually (the program i mean)
13:42cp2i know about jME, etc
13:42cp2link me, ill try it
13:42hoeckdefinetely a java-opengl problem (glxgears works)
13:43Lau_of_DKhttp://github.com/Lau-of-DK/sofiaba/tree/master
13:43cp2righto
13:43cp2give me a sec
13:44Lau_of_DKthanks
13:45cp2stupid tortoisegit
13:45Lau_of_DKGit rocks
13:45Lau_of_DKGithub is a little tortoise-like these days though
13:45cp2yeah, but tortoisegit (shell interface for windows)
13:46cp2right, now i need to get jme (again)
13:46Lau_of_DKhehe
13:47Lau_of_DKI think LWJGL is included in the git clone
13:47Lau_of_DKthe deps/ needs to be in your library path, and the src/ in your classpath
13:49cp2googlecode svn not too fast today
13:51cp2Lau_of_DK yeah, lwjgl is in there
13:51cp2once less thing for me to grab
13:53Lau_of_DKman tortoisegit looks awful
13:53cp2yeah
13:53cp2then again, windows is pretty awful too
13:53cp2i just ended up opening a git bash shell
14:01blbrownPircBot hello
14:03danlarkinLau_of_DK: Madison?
14:03blbrownChouser funny, you have to connect to the server, change the nick then join the channel. with pircbot/clojure
14:04blbrown,(+ 1 1)
14:04clojurebot2
14:04blbrownhehe [clojurebot] (n=PircBot@ip67-152-53-125.z53-152-67.customer.algx.net): PircBot 1.4.6 Java IRC Bot - www.jibble.org ...haha your name is really pircbot because hiredman didn't add code to change your name
14:06Lau_of_DKdanlarkin: Its good :)
14:06danlarkinLau_of_DK: madison it is, then!
14:07Lau_of_DKWEEEE! Its a big day today
14:07cp2ok, finally
14:07cp2got jme physics to build with much hassle
14:07cp2would be nice if ant didnt forcibly exit when its done
14:07cp2would also be nice to have known jmephysics needs jmetest
14:08cp2*sigh*
14:08Lau_of_DKcp2, I wrote out physics in the latest commit
14:08Lau_of_DKso - You wont need it :(
14:08cp2ugh
14:08Lau_of_DKSorry
14:08cp2didnt care to update your readme then
14:08cp2>:(
14:09Lau_of_DKNo I just wrote it in one of todays commit, because I plan on bringing it back
14:11Lau_of_DKofc
14:15cp2java.lang.RuntimeException: java.lang.ClassNotFoundException: dk.bestinclass.sof
14:15cp2iaba$get_resource_uri__3164 (sofiaba.clj:12)
14:15cp2eh Lau_of_DK ?
14:16cp2it gets built at least
14:16cp2hold on
14:16kotarakcp2: maybe you should rebuilt the project. Failures like that indicate an incomplete jar or an inconsistent build.
14:17cp2kotarak i fixed that problem
14:17cp2but now
14:17cp2java.lang.Exception: Unable to resolve symbol: lazy-cons in this context (wrappe
14:17cp2rs.clj:59)
14:17cp2*sigh*
14:17cp2this is a fresh svn build of clojure too
14:17cp2(lazy-cons t (map (eval f) c))) ;; TODO: UPDATE TO LATEST REV OF CLOJURE
14:17Lau_of_DKcp2, lazy-cons = cons
14:17Lau_of_DKYoure on a later revision than me
14:17cp2k, so just change it
14:17cp2?
14:17Lau_of_DKjust remove "lazy-"
14:17Lau_of_DKyea
14:17cp2aye
14:18hoeckLau_of_DK: did that replacement too :)
14:18cp2yay, it compiled
14:18Lau_of_DKWhat can I say - I had to wait for SLIME and SWANK :)
14:18Lau_of_DKyay
14:18hoeckLau_of_DK: but slime and swank works already with lazy
14:18Lau_of_DKYea I know, now Im just waiting for me
14:18hoeck:)
14:20cp2of course, got all that set but i forgot to put lwjgl in classpath
14:20Lau_of_DKLIBRARY_PATH
14:20Lau_of_DKnot classpath
14:20cp2no, im not talking about the shared libraries
14:20cp2im talking about lwjgl.jar etc
14:21Lau_of_DKAlso notice the "compile-it" function in sofiaba.clj, you need to adjust *compile-path*
14:21hiredmanblbrown: ?
14:21Lau_of_DKk
14:22cp2ok Lau_of_DK, it runs
14:22cp2jme didnt prompt me to set anything thought :(
14:23Lau_of_DKcp2, the very last function in sofiaba.clj, change NeverShowConfig to AlwaysShowConfig and run again
14:23cp2ok
14:24Lau_of_DKBut you see the island, and everything renders okay, you get an fps count?
14:24cp2yes
14:25Lau_of_DKcool
14:26Lau_of_DKcp2 - Are you comfortable with jmephysics?
14:26cp2as in, can i use it?
14:26cp2er, write code for/with it rather
14:27cp2cp2: tbh i never really took the time to learn about jmephysics, and i never did much with jme
14:27cp2as for right now, i am going to go play some et :)
14:28Lau_of_DKYea - I tried to integrate it, but I didnt fly - I got objects attached to dynamicphysicsnode / staticnodes, and everything rendered, but the physics didnt function
14:40blbrownhiredman, cool, you are back. In your clojure bot code, is there a way to call the protected methods of the pircbot api. E.g. I noticed that you didn't call setName in your code
15:01Lau_of_DKChouser: Are you done porting this yet? http://muaddibspace.blogspot.com/2009/03/how-to-halve-number.html
15:03hiredmanblbrown: no, I use proxy, so all the proxy provisos apply
15:03Lau_of_DKclojurebot: proxy?
15:03clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
15:04hiredmanWFM
15:04blbrownhehe
15:04ChouserLau_of_DK: what a waste.
15:04blbrownseems like it can do everything except access protected members and implement constructors
15:04Chouserand add new methods
15:05blbrown...OK that too
15:05Chouserand produce specifically-named classes
15:05blbrownChouser, ok, ok
15:05kotarakAnd when it can do all that, we rename it to gen-class. ;)
15:05blbrownkotarak, does gen-class work dynamically or do you need to compile
15:05kotarakYou have to compile.
15:06blbrownhmm
15:23rlbIs there a better way to write (in the scheme/lisp sense) to a file than calling pr-str or prn-str and then writing that?
15:24Lau_of_DKThere are many java-ways to write to a file, the right one depends on your purpose
15:24rlbLau_of_DK: I just mean wrt clojure, i.e. since pr and prn only write to *out*, then it seemed like you probably needed to use pr-str or prn-str if you want to send the output somewhere else (unless clojure has some way to locally bind *out*).
15:25Lau_of_DK(with-out-str
15:25Lau_of_DK(doc with-out-str)
15:25clojurebotEvaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls.; arglists ([& body])
15:25kotarakrib: (binding [*out* something-else] ....)
15:25rlbLau_of_DK: right, but that still wouldn't send the output to a file -- i.e. you still create the string then write that.
15:25rlbkotarak: ahh, ok, thanks.
15:25rlbkotarak: that's what I was wondering about.
15:27rlbHow do pr or prn handle errors?
15:28rlbMore specifically, is there a documented return value you're supposed to check, or are you supposed to rely on exceptions to report any errors?
15:29rlbi.e. if you need to be able to know for sure (or as sure as possible), whether or not something went wrong by the time you finish closing the file.
15:32Chouserpr and prn will return nil or throw an exception
15:32Lau_of_DKDo you guys generally use the java convention when naming clojure vars/functions ?
15:32rlbLau_of_DK: I'm not sure what conventions you're talking about, but I know scheme and lisp much better than java, so I tend to treat clojure like a scheme/lisp.
15:33Lau_of_DKk
15:33rlbChouser: thanks.
15:33Chousukejava convention?
15:33RaynesI remain closer to Scheme and such when naming vars and functions
15:35rlbLau_of_DK: in particular, assuming that this relates to what you're asking, I would use names like open? exists? with-frob-connection, etc.
15:37Lau_of_DKI meant specifically like the java convention names everything with smallFirstCapitalizedAfterThat
15:45rlbI'm fairly unfond of camelCase anywhere...
15:47RaynesIt's very unlispy to use camelCase.
15:48Lau_of_DKIt is -unfortunately I didnt notice until I had written about 4000 lines of it
15:48rlbLau_of_DK: emacs to the rescue ;>
15:48rlb(or maybe perl)
15:49Lau_of_DKEmacs... :)
15:49kotarakOr Vim :)
15:49RaynesScrew Vim.
15:49Lau_of_DKkotarak: neither could Raynes
15:49RaynesAgreed.
15:50Lau_of_DK;)
15:50rlbThat would be nice -- a tool that knows clojure well enough to unambiguously do a search/replace for a particular logical entity, i.e. "this particular foo".
15:56leafwrlb: yeah -- who is developing that?
15:58Lau_of_DKJava folk, I have a bunch of java files that I want to incorporate in my project, is there a quick way to convert them all to class files? java -compile * or something ?
15:59kotarakLau_of_DK: Have a look in the clojure ant build.xml.
15:59kotarakShould be easy to transfer.
15:59Lau_of_DKI was hoping for something quick and dirty :)
16:01kotarakLau_of_DK: well. That's quick and clean. Isn't that better? :)
16:01ayrnieufind .|egrep 'java$'|xargs javac
16:02Lau_of_DKperfect :)
16:02Lau_of_DKsorry Kota, Im too lazy to be clean
16:02slashus2Lau_of_DK: javac *.java
16:03kotarakLau_of_DK: hm... That will come to haunt you anyway later on.... Be clean now, have less work later. ;)
16:04leafwLau_of_DK: I use often: javac -classpath .$(find -name "*.jar" -printf "%h/%f:"):. $(find -name "*.java" -printf "%h/%f ")
16:05leafwor some variation.
16:05Lau_of_DKcool
16:07blbrownis OK to put lisp datastructures in a database. I have this idea for storing a list of items. hmm
16:07blbrownRDBMS don't really support tree/list structures very well
16:13hoeckblbrown: well, that hurts the relational model very hard
16:13hoeckblbrown: you use the ability to express queries over those stored lists
16:14hoeckbut for storing code, or big hashtables, maybe
16:16blbrownyea, would hurt the relational model. But modern databases are great for storing and retrieving "Data" and that would be the main goal.
16:16blbrownFor example, it would be better than storing XLM
16:16blbrownXML
16:19Lau_of_DKhoeck: Did you ever get beyond that segfault?
16:20hoeckLau_of_DK: not with sofiaba, the jme examples run fine, at least, they run
16:20Lau_of_DKok - weird
16:22hoeckit seems they all require shaders, too much for my old chipset graphics
16:22Lau_of_DKYea they're pretty advanced
16:23hoeckyeah, weird, before segfaulting they say something like "unsupported texture size - rescaling to power of 2"
16:23Lau_of_DKHmm, if you comment out the call to makeTerrain, you should be fine, thats the only object I scale
16:23hoeckand that my card won't support textures other than with 2^n sizes
16:23jhujhiti(HttpServer/create (InetSocketAddress. 8080)) where create is a static method of HttpServer. what am i doing wrong? i get "No matching method: create"
16:24Lau_of_DKIts also about to go away, Im working on a much larger streamed in terrain
16:30Lau_of_DKIt seems the gentlemen who wrote these java-classes were working off some odd OS, which has characters that are unmappable for UTF8. Is there a quick-fix way to convert them ?
16:30hiredmanwell
16:31hiredmanmagic
16:32hoeckblbrown: definitely better than storing xml
16:32blbrownhoeck, exactly
16:32hoeckblbrown: but you loose the expressive power of the relational algebra
16:33hoecksome databases provide means to query graph-like structures in sql
16:33hoeckor you use datalog for that
16:33blbrownblbrown, kind of buitin serialization if I save data as lisp code, plus, I suck at algebra. hehe.
16:33Lau_of_DKblbrown: Have you looked at Voldemort / CouchDB ?
16:33hiredmanthere are also graph databases
16:35blbrownLau_of_DK, I looked at couchdb. for my application, it is for my irc bot, so it isn't a production system or anything. couchdb might work. Actually my databse I was going to use was sqlite
16:35Lau_of_DKThen go with Derby instead
16:35Lau_of_DKIf you go with some type of SQL program, check out ClojureQL
16:36Lau_of_DKIm quite stuck here - Can someone help me compile this: http://mfkarpg.110mb.com/jme/TerrainPass-jME2.zip ?? Please
16:36blbrownLau_of_DK, why did you recommend couchdb. At the same time, I want to try new things
16:37Lau_of_DKI recently read an article about a new website called Urbantastic.something which used Clojure and CouchDB and were quite happy with that choise
16:37twopoint718CouchDB is a key/value store, right?
16:38Lau_of_DKAs far as I understood, yes
16:38twopoint718So can you do things like give me all of X whose value is Y?
16:38Lau_of_DKGoogle will tell you :)
16:38blbrownI thought it was a document database
16:39twopoint718say: SELECT * FROM some_table WHERE id==10
16:39Lau_of_DKBut actually, Clojure comes pretty close to perfect, if you want to write your own database system
16:39blbrownyea, that won't take any time, hehe. Actually I like the idea of serializing objects as a database system
16:39hiredman(use terracotta and persist to disk)
16:40twopoint718Heck for most of what I do (usually just store little config files) I love being able to 'print' 'read'-able data structures to a flat text file.
16:40hoecktwopoint718: yeah, thats a big win for lisps in general
16:40hiredmanclojurebot keeps factoids in a hash map printed to a file
16:41blbrownOK, here is what I think I will use, order of preference: couchdb -> terracota -> derby/hsqldb -> serialize -> rabbitmq -> sqlite
16:42hiredmanterracota will, I think, be the most work there
16:42twopoint718I was just looking to see what the equivalent was in Clojure and was happy to find (read-string (slurp "datafile.clj"))
16:43blbrownhiredman, yea, deployment on win32/linux would have to be easy. derby or hsqldb sure is a simple approach though, hmm
16:51blbrowngreat, on your own personal projects, you can make architecture decisions in 5 minutes.
16:54rlbIf clojure doesn't already have it, it might be interesting to have a persistent object store like rscheme's.
16:56rlb-- the ability to make a data structure and everything it references (at least read/writable things) persistent automatically, and only fault it in/out on demand as the pointers are traversed.
16:57rlb...same thing the Texas persistent object store does (one of Dr. Wilson's topics)...
16:59rlbIn any case, it might be interesting to at least have something like a "giant seq" interface, i.e. easy to use list/vector/hash-table's for data that's way to big to fit in RAM.
17:01hiredmanrlb: lazy-seq
17:01hiredmanjust don't hang on to the head
17:03rlbhiredman: I wonder if some of the semantics that I was thinking of don't fit in well with a functional model (unless you use some kind of versioned store), i.e. a giant vector (32GB?), that you can read and write efficiently, but that can be treated like a seq.
17:04hiredmanwell
17:04rlbhiredman: of course I'm still getting used to clojure, so I'm not familiar enough to have any strong opinions/ideas about it.
17:04hiredmanfunctional implies no write
17:04rlbs/it\./it yet./
17:04rlbhiredman: right -- that's what I meant.
17:07rlbPerhaps you could have a store that handled things more like clojure does internally, i.e. just create types of vectors, lists, etc. that can handle using the disk as a backing store, but still preserve the right functional semantics.
17:08rlbanyway... not today's problem.
17:12rlbDo any filesystems allow the user to efficiently and atomically splice two files?
17:12rlb(just curious)
17:22rlbDoes clojure have anything like atexit or trap? i.e. a way to register a function to be run when the program exits?
17:23rlb(actually dynamic-wind or unwind-protect would be just fine here -- I'll go check for that...)
17:24kotarakrlb: (try ... (finally (do-something)))
17:25rlbkotarak: ahh, thanks -- I suppose I should have thought of "finally".
17:25rlb(or rather expected finally)
17:26kotarakrlb: since there are no continuations, try-finally should be sufficient, I guess.
17:26rlbkotarak: right.
17:28kotarakrlb: beware of lazy-seqs so. (try (map #(do-something-depending-on-the-finally %) some-seq) (finally (close-some-file-or-whatever))) will get you in trouble.
17:28rlbkotarak: do you know if try will even handle catchable signals?
17:28kotaraks/so/though/
17:28kotarakrlb: signals in the sense "kill -15 1234" ?
17:28rlbkotarak: right -- signals that you can catch, but that take the app down by default.
17:29rlbi.e. stuff you would protect with a bash trap.
17:29kotarakrlb: dunno. Probably some JVM setting somewhere.
17:29rlbThe goal is to make sure that the program always cleans up on exit if it didn't finish cleanly.
17:29rlb(if that's possible, i.e. no kill -9)
17:29jhujhitihttp://blog.webinf.info/2008/08/intercepting-sigterm.html
17:30jhujhitii only googled that for you because i was curious of how to do it myself
17:30rlbjhujhiti: thanks.
17:31rlbkotarak: what did you mean wrt lazy-seqs?
17:32rlbkotarak: just that the finally could/would be executed before the list was fully traversed?
17:33kotarakrlb: if you use resources like a open file in something like map or the like you need to realize the sequence before leaking it outside the try. Otherwise the file will be already closed when the seq is realized.
17:33rlbkotarak: right -- that's what I guessed you meant.
17:33kotarakrlb: yes. one can do (doall (map ...)) to realize the seq.
17:33rlbkotarak: right.
18:00clojurebotsvn rev 1316; made futures use CachedThreadPool
18:04pietiahello
18:04pietiaanyone use eclipse + clojure plugin ?
18:05clojurebotsvn rev 1317; made letfn emit fn, not fn*
18:06pietiaclojurebot, hello darling :P
18:10rlbJust started reading about clojure's answer to objects. It looks nice so far -- more like clos/generic-functions...
18:12ayrnieurlb - defmulti/defmethod , you mean?
18:14blbrownrlb is that on a blog somewhere
18:15Raynespietia: I have.
18:15pietiaRaynes, do you have problems with running scripts?
18:16rlbayrnieu, blbrown: I was just poking around here -- http://clojure.org/multimethods
18:17rlbHmm, for now perhaps I'll just rely on File atomic creation, and not worry about other (non-java) clients.
18:17Raynespietia: Running doesn't run a script, it just loads the REPL, you can then load the script with C-M-l I believe and use it like that. With no offense to Laurent, I know he's doing the best he can, the Eclipse plugin leaves a lot to be desired such as autoindent. I recommend using the netbeans plugin simply because I find it suited to everyday editing and development.
18:17blbrownI have a good zazzle clojure t-shirt idea. "Clojure, I can finally be productive again"
18:18pietiaRaynes, yeah, it loads REPL - that's the point ;)
18:18RaynesSomeone really needs to make a damned wall paper.
18:20RaynesI would give all the parentheses in the world for a Clojure wall paper :<. I suck at image editing.
18:26blbrownRaynes you might post something about the google group board, I wouldn't mind one either.
18:42brennancbeen learning Clojure for the last 2 days. It's my first lisp dialect. It's very impressive. Anybody using it on their servers? Wondering easy it is to get sites up and running with it.
18:43brennanchow is it deployed normally?
18:45dcnstrctDoes Clojure have any 'lispy' file IO functions?
18:45dcnstrctsomething like with-open-file
18:46brennancyes, it has with-open
18:46dcnstrctor does everyone just use java.io ?
18:46dcnstrctahh
18:46dcnstrctok I'll check out with-open
18:47gnuvince_dcnstrct: there's also some nice stuff in clojure.contrib.duck-streams
18:47dcnstrctgood to know, will check that
18:52powr-tocbrennanc: If you're talking webapps, it's easily deployed in standard java infastructure... i.e. an app server/servlet-container... for non web stuff, you just throw a jar on the java classpath... easy! :-)
18:53brennanclike glassfish? I've only glanced at java app servers. only looked at them briefly.
18:53powr-tocbrennanc: yeah, glassfish, jetty, tomcat, jboss... any of 'em
18:54brennanccool, I'll look for that once I get through the "Programming Clojure" book
18:56powr-tocChouser: looks like add-watch's has changed again... did you revise your code yet?
19:00lethalcodeHowdy folks - Is there a way to get a pared down version of clojure for already compiled .cljs to link to? No compiler, interpreter, etc.
19:00hiredmanmm
19:01hiredmanclojure doesn't have an interpreter
19:01lethalcodeBy that, I meant Repl :D.
19:02brennancyou can compile to a .class file. From there you can run it like any other java class file. You will need to have clojure.jar and whatever other libraries you need though. Not sure if that answers your question.
19:02dcnstrctlol @ spit and slurp functions awesome naming
19:03lethalcodeNot really, brennanc - clojure.jar also includes the Compiler, Repl, etc.
19:03durka42hiredman: what is clojure-slim.jar?
19:03lethalcodeWhat I want is to build .class files from .clj, then jar it up (aimed at an embedded platform with minimal resources)
19:04lethalcodeSo I don't need Repl, Compile, etc.
19:04brennanclethalcode: ahh, I think I get what you are asking. I'm only on my 2nd day of learning Clojure but you might be able to re-jar it without those things in there. Hack it down so to speak.
19:04durka42the thing is, you might need those things, to implement the read and eval functions for instance
19:05brennancnot sure about the dependencies
19:05durka42lisp has trouble separating these things :)
19:05lethalcodebrennanc: Trying to do that now. Removed them, hacked at RT.java, etc.
19:05lethalcodedurka42: We don't want read and eval. =).
19:05lethalcodeWe're using clojure to develop an app for users. Won't include eval() or any lisp scripting by the user, etc.
19:07durka42well, i know there's been work done on getting clojure running in places where you can't generate code, like applets and android
19:07durka42so it might be possible
19:07lethalcodedurka42: Any idea who those folks are?
19:08durka42well, rhickey for one, of course
19:08hiredmanlethalcode: why do you need to remove eval completely? why not just don't use it?
19:08durka42i'd advise looking through the mailing list for android
19:08hiredmanI don't think the android stuff removes eval, it just doesn't work if you try to use it
19:09lethalcodehiredman: Long story. What we're actually doing is compiling clojure to .class files. Then using xmlvm to turn .class files into .objc files.
19:09lethalcodeSo we can then compile for the iPhone. :D.
19:09durka42that sounds a lot like what you have to do for android
19:09hiredmanlong story indeed
19:09lethalcodeHowever - xmlvm has limited support. Can't do too much more than a "Hello World".
19:10hiredmanyeah, track down the android stuff, I think there was a patch
19:10hiredmanthat could be tricky
19:10hiredmanxmlvm looks twisted
19:10lethalcodeI'm hoping that by removing eval and compile, we can reduce the work needed on xmlvm by a considerable amount. (Reflection, etc?)
19:11lethalcodeThe work needed to write wrappers in .objc, rather.
19:11durka42actually, xmlvm claims it can compile from android to iphone
19:11lethalcodedurka42: Not quite true. :D.
19:11durka42i suspected :p
19:11lethalcodedurka42: A Hello World is the only thing they can handle.
19:12lethalcodeAnd they implemented just barely enough of the android API for that hello world.
19:12lethalcode(And often incorrectly. e.g: ImageView uses hardcoded image names . . .)
19:13lethalcodeAs for Android: Davlik VM has cut out some portions needed for dynamic code generation as well, it's true.
19:13lethalcodeBut still has all the java files there that need to be wrapped when converted to objc.
19:13brennancxmlvm looks wicked. I'm looking at the javascript target now. That could be fun...
19:14lethalcodeAfter converting clojure .classes to objc, we have *90* java header files that aren't implemented in xmlvm's compatability layer. 49 of those are Error or Exception classes. A bunch of others are probably easy to wrap, just need doing. And then there's Reflect, ClassLoader, Thread, . . .
19:15lethalcodeI've been talking with Arno (main author of xmlvm) about what needs to be done and can be done.
19:15durka42Thread is kind of important...
19:16lethalcodeRight. I intend to either ask Arno to do it (if he's willing), or to implement it myself. (Objc tutorials, here I come?)
19:16lethalcodeReflect and ClassLoader, though - If they can be done away with, that's probably best?
19:16Raynesblbrown: Good idea, I'll get right on that
19:39Chouserpowr-toc: http://gist.github.com/32494 should be up to date
19:46powr-tocChouser: cool :-)
19:47cmvkkI frequently get in these situations where I essentially want a constant but I have to 'initialize' it first.
19:47cmvkkand it always seems wasteful to me to use a ref for something that i'm only planning to change the value of once
19:48cmvkkbut there's not actually any other way right?
19:48rhickeycmvkk: atom is the most lightweight
19:56brennancis it considered bad practice to do "(def my-func #(do-something %))" instead of "(defn my-func [x] (do-something x))"?
19:57hiredmanI think it is
19:57Chouserit's not idiomatic
19:57Chouseryou won't get docstring and arglists in the metadata
19:57hiredmanat the very least I would prefer using (fn ) to #( ) in that case
19:57cmvkkit seems like you're only saving about 4 characters too.
19:58brennanck, thanks
20:00hiredman,((partial apply identity) 1)
20:00clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
20:00hiredmanI see
20:02brennancI'm looking at this code in the clojure book: (defn non-blank? [line] (if (re-find #"\S" line) true false))
20:02brennancwhy is the if needed? and isn't there a better way if it is needed than explictly saying true false?
20:03ayrnieubrennanc - it could equivalently say (not (not (re-find ...))) ; would that be better?
20:03Chouser(boolean (re-find ...))
20:04cmvkkdoes re-find return nil if it doesn't find anything?
20:04hiredman,(re-find #"\S" "")
20:04clojurebotnil
20:04hiredman,(re-find #"\S" "foo")
20:04clojurebot"f"
20:04hiredman,(re-find #"\S" " ")
20:04clojurebotnil
20:04brennancyes, that was what I was looking for
20:04brennancanything that is not false or nil evaluates to true, correct?
20:04cmvkkso if you take the 'if' out, it will function the same as a predicate but you can also use it for if-let and stuff.
20:05hiredmancorrect
20:05brennancso why would it be needed to actually cast it to a boolean
20:05hiredman*shrug*
20:05cmvkkheh
20:05cmvkkactually i guess it doesn't matter; the true value would probably be pretty useless
20:06ayrnieuthe author was being fastidious. This is like having a side-effecting function carefully not return anything of interest.
20:38lethalcodeTrying to compile clojure/core_print.clj gets this error: Exception in thread "main" java.lang.Exception: namespace 'clojure.core_print' not found after loading '/clojure/core_print'
20:38lethalcodeCompiling clojure.core works fine, but clojure.core_print (or any other file that uses in-ns and is in a namespace that doesn't match its filename) borks.
20:39lethalcodeAny easy fix?
20:41hiredmanlethalcode: I believe compiling clojure.core should take care of core_print
20:41hiredmanthe file core-print is loaded using load-file by clojure.core
20:42hiredman(isn't it?)
20:42ChouserI believe that is correct.
20:42rhickeyhiredman: right, you can only compile namespaces, core-print is not a namespace
20:43lethalcodeReally? Because, e.g, print-sequential, print-meta, print-method, etc - aren't being turned into classes.
20:45rhickeycore-print is a subsidiary of core and gets compiled when core does
20:45lethalcodeThen shouldn't it be generating files such as clojure/core$print-method__blah.class ?
20:49Chouserclasses/clojure/core$print_sequential__5231.class
20:49rhickeyprint-method is a multimethod, won't have a class, I don't understand the question - if you build clojure it compiles core - can you not build?
20:51cp2'sup rhickey
20:54lethalcodeLet me back up a bit. rhickey, don't know if you saw my earlier comments/statements - I'm building a more minimal clojure, targeting XMLVM (which will convert .class files to objective-C for iPhone development)
20:55rhickeylethalcode: scary
20:55lethalcodeSo to do this, I've set up a smaller compile environment for clojure.
20:55lethalcodeGot most of the jvm classes pared down, I think, but clojure/core.clj at least seems to be needed.
20:56lethalcodeSo I've got the clojure core .clj files in the project, and am compiling them using the (full, unabridged) clojure compiler.
20:56lethalcodeAnd dumping .class files into build/classes. There are build/classes/clojure/core$*.class from core.clj, but nothing that I can see from core_print.clj
20:57rlbAre the java string methods the normal way to manipulate strings (substrings, etc.)?
20:58rlbnevermind.
21:00rhickeylethalcode: I ant clean, mkdir classes, java -cp ./src:./classes:clojure.jar clojure.main, (compile 'clojure.core)
21:01rhickeyI get core$print*
21:03lethalcoderhickey: I'm using clojure.lang.Compile
21:04lethalcodeAnd the only print functions I get are print, print_doc, print_namespace_doc, print_special_doc, print_str, printf, println, println_str
21:05rhickeylethalcode: use clojure.core/compile
21:07gnuvince_(doc compile)
21:07clojurebotCompiles the namespace named by the symbol lib into a set of classfiles. The source for the lib must be in a proper classpath-relative directory. The output files will go into the directory specified by *compile-path*, and that directory too must be in the classpath.; arglists ([lib])
21:10lethalcode(+ 2 2)
21:10clojurebot4
21:10lethalcodeCool.
21:10lethalcoderhickey: As in, use Repl then (compile 'filename) instead of using clojure.lang.Compile? How do they differ?
21:10lethalcode(doc clojure.lang.Compile)
21:10clojurebotexcusez-moi
21:11lethalcode(. @"hello" substring 3)
21:15hiredmanlethalcode: compile takes a namespace
21:16hiredmannot a filename
21:16Chouser,(.substring "hello" 3)
21:16clojurebot"lo"
21:16hiredmanthe unit of compilation is by namespace
21:17lethalcode(. "hello" substring 3)
21:17lethalcodeHm.
21:17lethalcodehiredman: And the unit of compilation for java.lang.Compile is file, not namespace?
21:20hiredmanuh
21:20hiredmanyou must mean clojure.lang.Compile
21:20banisterfiendsome guy just said this about clojure, is it true? "banisterfiend, I haven't used it, but I heard its implementation is full of black magic and dark and sinister hackery."
21:20hiredmanand that I dunno, my guess would be that it is namespace as well
21:21ayrnieubanister - it certainly doesn't seem that way, but you can look at it yourself.
21:21lethalcodehiredman: Err, yeah.
21:21hiredmanthe java source takes some getting used to, but the clojure source is very readable
21:25Chouserbanisterfiend: nah. other than STM, it's pretty straightforward, though frequently clever.
21:26Chouserin my opinion it's more the design than the implementation that's the key
21:26Chouserthough the STM is still magic to me. :-)