#clojure logs

2008-06-28

02:42spacebat_forgive yet another newb question, but how do you make a seq non-lazy?
02:43spacebat_what I mean is, say I have a seq s, and try to concat it with (str s)
02:43spacebat_and print that out, I get clojure.lang.LazySeq@cd4cae45
02:44spacebat_perhaps I've asked the wrong question, if str is n-ary, how do I pass s to it such that its expanded as a normal argument list?
02:45spacebat_and I know that answer, apply
02:45spacebat_lol thanks for listening
03:06slavaconvert it to a string, i guess
03:06slavaoh, you figured it out :)
03:09spacebat_yes, (println (apply str s))
03:10spacebat_I just set up ilisp-clojure.el
03:10spacebat_but clj files load in lisp-mode, and slime seems to rebind some of the keys that ilisp expects
03:10spacebat_is there slime support for clojure I wonder
03:19spacebat_looks like this could be the ticket: http://clojure.codestuffs.com/
03:19spacebat_so I don't need ilisp, or even lisp-mode for clojure
10:36gomer-nychello
10:37Chouserhi
10:39gomer-nycI'm struggling with something; I have read just enough in a few postings to put me on a trajectory but am now stumped
10:39gomer-nycsummary: gen-and-save-calss; servlet; tomcat
10:41gomer-nycI guess my Q is this: how to configure my webapp in tomcat to load my servlet that I'm defining in a clj file under WEB-INF/classes?
10:43ChouserMy servlet knowledge is pretty shallow. I was actually trying that myself a couple weeks ago.
10:43ChouserYou might want to look at webjure and see how it does this.
10:44gomer-nycright
10:44ChouserI think the lastest version of webjure is still from before there was gen-and-save-class, but it may help point the right direction.
10:44rhickeyYou've got a servlet .class file from gen-and-save-class?
10:46rhickeyfomr something like:
10:46rhickey(clojure/gen-and-save-class "/Users/rich/dev/clojure/gen/"
10:46rhickey 'org.myns.MyServlet
10:46rhickey :extends javax.servlet.http.HttpServlet)
10:47gomer-nycyes, I've done that
10:47rhickeyand a corresponding MyServlet.clj?
10:48gomer-nychmmm, I think my .clj is named differently
10:48rhickeythan your servlet?
10:49rhickeyput both in WEB-INF/classes/org/myns/
10:50gomer-nycok
10:50rhickeyand entries like this in web.xml:
10:50rhickey <servlet>
10:50rhickey <servlet-name>MyServlet</servlet-name>
10:50rhickey <servlet-class>org.myns.MyServlett</servlet-class>
10:50rhickey </servlet>
10:50rhickey <servlet-mapping>
10:50rhickey <servlet-name>MyServlet</servlet-name>
10:50rhickey <url-pattern>/*</url-pattern>
10:50rhickey </servlet-mapping>
10:50Chousersince we're on the topic, this something I've been wondering about gen-class...
10:51gomer-nycbloody awesome
10:51gomer-nycit works
10:51rhickeyand clojure.jar in WEB-INF/lib/
10:51gomer-nycbeautiful
10:51rhickeygreat!
10:51Chousergen-and-load-class seems to be to act like a runtime definition, just like proxy or any function def. But gen-and-save-class seems like it would be used at something like build or install time.
10:52gomer-nycchouser: yes, that is a little confusing
10:52gomer-nycI was under the impression that a bootstrapper would call my XServlet.clj, which includes the gen-and-save-class
10:54rhickeygen-and-save-class gets you your static stub, after which you can get on with your dynamic life
10:54gomer-nycbut you have to to gen-and-save-class during a build phase, i.e. the .class file must be there before your servlet will be called.
10:56rhickeyIt is anticipated that gen-and-save-class will rarely need to be rerun, only if you change signatures
10:56rhickeyit should definitely be separate from the implementation code
10:57gomer-nycyeah, it makes sense. I'm structuring my code in WEB-INF/classes/org/myns/ as genstubs-XServlet.clj and XServlet.clj. Calling genstubs-XServlet.clj only when I'm starting to build out my Servlet implementation. Likelihood of needing to regen the .class file is very low
10:58rhickeyI know the enclojure guys are struggling with where this (gen-and-save-class) fits in the Java build cycle
10:58Chouserit's almost like you want an ant task to run your genstubs at build time.
10:58rhickeyright, that's why eric wants a different extension
10:59Chouserah, i do remember him mentioning that.
11:00ChouserI think I like the prefix (genstubs-) better. Or at least something that leaves the .clj in place, since it is still Clojure source code.
11:00rhickeycan you trigger Ant tasks off of file prefixes?
11:01ChouserI haven't a clue. I'm not an ant guy. But you certainly could with gnu make.
11:02gomer-nycif not, one could do something like .cljgenstub
11:02gomer-nyc:-)
11:09gomer-nycfollow-up question....
11:10gomer-nycIf I simply modify my servlet implementation contained in the .clj file, when will Tomcat (or other servlet container) start serving that?
11:10gomer-nycam I now entering the world of server configuration?
11:11ChouserI would think you'd have to tell something to re-load your .clj
11:12Chouseryou can probably add a feature to your servlet to allow you to tell it to load-file on request.
11:15gomer-nychmmm, interestin idea -so it reloads itself when called?
11:15ChouserRight.
11:16ChouserI think clojure.jar (or maybe you gen'ed .class file?) is loading your .clj the first time. Nothing's going to automatically re-load the .clj when it changes.
11:17ChouserBut it would be easy to run (load-file "XServlet.clj") yourself whenever you see fit.
12:29gomer-nycChouser: I can think of 3 approaches:
12:29gomer-nyc1) whenever a request is made to the servlet, it can check whether the .clj has has been modified, then reload (not every efficient)
12:30gomer-nyc2) servlet allows a socket connection that gives you a REPL (like webjure)
12:31gomer-nyc3) one of the servlet requests could be reload-source, and so you can issue it like you would any other request
12:31ChouserI like all three.
12:31gomer-nycI'm gonna try #3 for now, since it seems like the simplest
12:31rhickeyAlso file system watcher looks for changes on predetermined interval
12:31ChouserYou could adjust (1) to only happen if a *development-mode* was true, and that flag could be set via (2) or (3)
12:32Chouserhm, predetermined interval or by using OS support to get notifications of file changes.
12:33ChouserI know linux and Mac both can provide that sort of notification, and I assume Windows can as well. I dunno how hard it would be to get the JVM to hook into those.
12:33rhickeywhatever Java lets you does easiest. a 10 sec poll is no big overhead
12:34rhickeydo most easily
12:37gomer-nycI wondered about implementing FileListener
14:08Chouserfail. "Servlet is not available"
14:09Chouserthis has been my general experiance with Servlets. :-/
14:24gomer-nycchouser: so I've done (3); basically just another servlet called ReloadServlet, and which takes the querystring passed to it and does a (load-file) on it - this way I can specify which servlet to refresh from its .clj
14:26gomer-nycOne improvement to this may be to say, if no querystring, then reload everything that has been modified since last reload
14:27gomer-nyc(I'm taking this approach over the auto-reload via a file listener approach, because (a) what refresh time to choose? and (b) more in line with the typical (load-file) during interactive dev)
14:39Chousersounds like it might be a security risk on a production server to be able to name any file to load. But useful for dev.
14:40Chouserwhat web server are you using?
14:42gomer-nycI'm using tomcat right now
14:43gomer-nycright, you wouldn't be making code changes like that on a running server anyway
14:43gomer-nyc(production server)
14:46ChouserI think Paul Graham might disagree, but that's a whole other thing. ;-)
14:46Chouserdo you have to provide a logging.properties file for tomcat?
14:48gomer-nychehe, yeah, I guess you could "protect" the reload servlet and have it avail.
14:48gomer-nycI didn't do any tomcat customization
14:48gomer-nyc(I'm only learning servlet/tomcat now, so might be missing some stuff)
14:49gomer-nycto get my stuff up, just created a folder in the webapps dir under tomcat, and built the web-inf/classes and lib directories with the required .clj and .class files for the servlets
14:49Chouseryeah, thought I was following along, but I'm just getting "Servlet is not available"
14:50ChouserI've got a stack trace in the tomcat log whining about being unable to read a logging.properties file in WEB-INF/classes
14:50gomer-nycI have this file structure:
14:51gomer-nyc- web-inf / classes / com / myorg / *.clj and *.class
14:51gomer-nyc- web-inf / web.xml
14:51gomer-nyc- web-inf / lib / clojure.jar
14:51gomer-nycthat's it (make sure web.xml specifies the servlets)
14:52Chouseryeah, that's what I've got.
14:52gomer-nycrunning out now; going to see the olafur eliasson waterfalls in the east river
14:53Chouserok, have fun!
14:53gomer-nyccatch you later
22:43lozzarcan anyone point me to any resources on how i might use sqlite in clojure or just somewhere to dive in?
22:45spacebat_hi lozzar, I'm in a similar position
22:45spacebat_the clojure google group has been quite useful
22:46lozzarthanks ill check it out
22:51spacebat_along with the part on the wiki where it maps old function names to new
22:52spacebat_people have recommended spending a lot of time reading boot.clj and other files where the clojure environment is built from primitives
22:52spacebat_I didn't get very far with that at first but soon I should be able to get more out of it
22:53spacebat_still wrestling a bit with getting my emacs environment right for it
22:55spacebat_when running with slime the output of (.. System out (println "string")) doesn't make it to the buffer, whereas (println "string") does
22:56spacebat_there is another clojure-mode that seems to be set up for ilisp, which I might try again
22:56spacebat_I'm curious to know what other people use
23:12drewrlozzar: First, find a sqlite Java lib. Then call it from Clojure.
23:13lozzarright now i'm just playing around with the sql library in clojure-contrib to get a feel for it but can't get it to work with the example .. something about (lib/use sql) not being a right library
23:40drewrI haven't plumbed the depths of clojure-contrib yet. :-/