#clojure logs

2009-07-06

00:23hiredmanlisppaste8: url?
00:23lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
00:24lisppaste8hiredman pasted "adapt" at http://paste.lisp.org/display/83084
00:26duncanminteresting implementation
00:27hiredmanit's one of those sort of inbred things
00:27slashus2You produce interesting implementations genetically?
00:27hiredmanif I've written and rewritten that a few times never really satisfied
00:28hiredmanslashus2: hah, no
00:28hiredmanI think previously I tried have the first arg to the function a keyword naming the method called
03:16RaynesI'm pleased to announce I'm rejoining the Clojure community. I'm dedicating the entirety of tonight to re-learning Clojure as much as possible. Some of you might be pleased to know, I'm using emacs now. ;)
04:10slashus2Raynes: What happened?
04:10Raynesslashus2: What do you mean?
04:10slashus2Raynes: You are rejoining. Why did you leave?
04:12Raynesslashus2: I was learning Haskell. I never really left the Clojure community, I was just never really around, or doing anything. I haven't touched Clojure in over 2 months, and I hadn't really written bundles of code then. I've forgotten a lot of things, so I'm just going to re-read Programming Clojure.
04:12slashus2Raynes: How was your foray with Haskell?
04:12RaynesFun! Haskell taught me lot's of stuff.
04:13Rayneslots, even.
04:13RaynesAnd Slime really does rock doesn't it? I mean, everyone told me that, but I didn't think it was this awesome...
04:14Lau_of_DKRaynes: This morning I felt a disturbance in the force - I'm pleased to see that Emacs has once again embraced you
04:14RaynesLau_of_DK: I got wrapped up in Emacs thanks to Haskell.
04:15Lau_of_DKShould I learn Haskell?
04:15RaynesTotally, it doesn't hurt. :p
04:15Lau_of_DKJust dont want to waste my time
04:15RaynesIt will likely influence how you program in Clojure, in good ways.
04:17Lau_of_DKkthxbye
06:23AWizzArdbtw, is Joshua Choi also here?
06:23AWizzArd(author of fnparse)
06:24AWizzArdOr is any experienced fnparse user here? :)
06:24arbscht_I don't believe I have ever seen him here
06:25arbscht_I have used fnparse, but I won't guarantee my experience will be useful to you :)
06:27AWizzArdAh cool, so I know someone who I can bug with a few (hopefully specific) questions.
09:06ChrisPSwhen you say: (require 'whatever)
09:06ChrisPSwhat does this really mean?
09:07ChrisPSas opposed to (use 'whatever)
09:07Chouserthat means load the code for the 'whatever namespace either ..
09:07Chouseroh
09:08Chouserin both cases the code for the 'whatever namespace is loaded either from .clj or .class files compiled from .clj files
09:08Chouserwhen that's done you should have a "whatever" namespace with vars in it. 'require' is then done
09:09Chouser'use' goes a step further and brings names from "whatever" into your current namespace, like the 'refer' function does.
09:09ChrisPSdo you have to name the namespace in a specific way, in relation to where it is placed on disk?
09:09Chouseryes
09:09ChrisPShow?
09:10Chousera namespace foo.bar.baz must be defined in a file name <src>/foo/bar/baz.clj and <src> must be in your classpath
09:10ChrisPSand, do you have to include the directory where this 'whatever namespace resides in your classpath?
09:10ChrisPSah
09:10ChrisPSok
09:11ChrisPSguess I have ignored that bit
09:11ChrisPSworking with files is such a drag
09:11Chouserit's very much like java expects it's .class files to be named
09:12ChrisPSsuch a long time since I've even sniffed on java
09:13ChouserI'm deeper into the JVM with Clojure than I ever was with Java
09:19ChrisPShopefully I will try to settled a bit with Clojure, coming from a Smalltalk background, I've been waiting for the next great thing, or for the comeback of lisp
09:19ChrisPSbut files are really a pain to work with
09:20ChrisPSwe'll manage :-)
09:20Chouseryou have an alternative code storage mechanism other than files?
09:21Chousermaybe that shows how little I know about smalltalk. :-)
09:21ChrisPShehe
09:21cemerickChouser: boy, are you in for it now :-)
09:21ChrisPSthat's cool
09:23cemerickChrisPS: it's honestly not so bad once you get over the initial hump. And, really, the fact that there *are* files makes interop with common tools a lot more pleasant.
09:23cemerickthere's no way that the jvm or CLR could ever dump an image, for example, so it's hard to imagine what the alternative would be (given those backends)
09:24cemerickA clojure-on-smalltalk would be fascinating, though.
09:24rhickeycemerick: interesting
09:24ChousukeI wonder what Clojure-on-CL would look like :P
09:26rhickeyChousuke: the big benefit there would be fixnums, but there aren't a lot of CLOS libs to tap into...
09:27cemerickrhickey: I seem to remember seeing a jvm-on-smalltalk implementation a looong time ago (e.g. java 1.1.7-era), that had access to the smalltalk bits (for continuations and such, although I have no idea how that meshed with the memory model semantics).
09:27Chousukerhickey: I suppose so. It'd still be an interesting experiment though.
09:28rhickeyChousuke: I don't think there are sufficient portable concurrency primitives to do that part of Clojure for anything other than one specific implementation of CL
09:29Chousukehmm :/
09:30rhickeyLispWorks, my favorite, is not open source, but the only one I'd personally spend time on, next version promises true MT
09:30RaynesThe way people talk about Ant had me scared last night as I embarked on what I figured would be a long journey into using Ant for simple build tasks. I was surprised to find that I figured it out by reading Clojure's build.xml file in 30 minutes, and actually had fun doing it. I still hate XML though.
09:30rsynnottrhickey: there is a slightly dubious multi-threading library which supports most which have any sort of multithreading at all
09:31AWizzArdrhickey: have you tried to use Jessrules together with Clojure?
09:31rsynnott(though the differing behaviour of different multiprocessing approaches might be a problem)
09:31cemerickRaynes: yeah, ant is pretty good. "It's the worst build system, except for all of the others."
09:31Raynescemerick: :p
09:31cemerickrhickey: do you do much of any CL hacking anymore/
09:31ChrisPSCLR? There is Clojure for .net as well? Dang, of course, its jvm...hmm
09:31cemerick?
09:31RaynesStuart should work on Lancet more. :\
09:32rsynnott(Lispworks and Allegro use something akin to the python GIL, sbcl and ccl have proper multithreading but only on certain platforms, CMUCL has a weird cooperative thing)
09:32ChrisPScemerick: I get your point with external tools, of course
09:33rhickeycemerick: not much CL anymore, no
09:34cemerickChrisPS: to be clear, given a good REPL, you can have an excellent development experience. Note, there's no UI integration, so no exploration of widgets, but the clojure REPL is at least as good as CL's, which is to say it's pretty good.
09:34Chouservia a dynamic classloader, any particular IDE could choose to provide code storage of its own in any arbitrary way.
09:35ChrisPScemerick: I am using emacs-slime
09:35cemerickI use enclojure (which provides a small jar you can drop into your application to get remote REPLs easily). Others use slime.
09:35ChrisPSany repl that is better?
09:35ChrisPSenclojure, looking into it
09:35rsynnottChrisPS: the SLIME one is decent
09:35cemerickChrisPS: probably a personal preference. Having a passable debugger and profiling tools in NetBeans is pretty compelling.
09:36ChrisPSI only need to master the namespace thing
09:36ChrisPShave you peeked at what the intellij-people are doing?
09:36ChrisPSor maybe it's just a thirdparty plugin
09:36RaynesChrisPS: Last I checked La Clojure is pretty good.
09:37RaynesI used to use Enclojure, now I use Emacs+Slime.
09:37ChrisPSI love this french-thing
09:37ChrisPSor italian..
09:37ChrisPSwhatever
09:37cemerickChrisPS: Looks promising, but not very comprehensive. Not being able to set up a remote REPL is pretty critical for what I do.
09:38cemerickactually, I'm not sure the intellij plugin even supports local repls, although I have to imagine that it will sooner rather than later
09:38noidi_q
09:40ChrisPSLa Clojure looks pretty, but I am determined to master emacs, and make it my best-friend (next to TextMate)
09:40Raynescemerick: I think La Clojure supports local REPL's now.
09:41cemerickChrisPS: dangerous road. Many a hacker have lost their souls to emacs.
09:41RaynesREPLs even.
09:41RaynesChrisPS: Don't listen to him, surrender to the darkness.
09:41ChrisPSI lost my soul 20 years ago, and it was not due to emacs :-)
09:42ChrisPSI also lost some more of my soul to Microsoft Visual Basic 2.0
09:42cemerickI personally had to check my best friend into a sanitarium because he would involuntarily shriek about losing his mark and such.
09:42ChrisPShehe
09:42ChrisPSctrl-space mark?
09:43ChrisPShaha
09:43cemerickyeah, it's what I came up with off the top of my head :-D
09:43ChrisPSso absurd
09:43ChrisPSlook, he is a stack now
09:50ChrisPShow to get a list of all color-constants in emacs?
09:57ChrisPSM-x list-colors-display
11:29ChrisPSarg, I cannot get autocompletion to work
11:30ChrisPSin emacs
11:30rsynnottusing slime?
11:30ChrisPSyes
11:34ChrisPSany idea for where to start looking?
12:50amitavaI am trying out ahead of time compilation without much success
12:51amitavatook clojure.example.hello.clj straight out of the docs
12:51amitavain ./clojure/examples/hello.clj
12:51amitavauser=> (compile 'clojure.examples.hello) java.io.IOException: No such file or directory (hello.clj:1) user=>
12:52Chousukeamitava: di you add . to your classpath? :)
12:52amitavauser=> (System/getProperty "java.class.path") "/Users/amitava/myapps/clojure/clojure-1.0.0.jar:/Users/amitava/tmp/clj/classes:/Users/amitava/tmp/clj/"
12:52amitavayes
12:53Chousukehmm
12:53amitavauser=> (System/getProperty "user.dir") "/Users/amitava/tmp/clj"
12:54amitavauser=> *clojure-version* {:major 1, :minor 0, :incremental 0, :qualifier ""}
12:54Chousukethat ought to work then :/
12:55Chouserthat error is odd. I get: java.io.FileNotFoundException: Could not locate clojure/examples/hello__init.class or clojure/examples/hello.clj on classpath
12:55amitavasee http://pastebin.com/m65d56531 for java stack trace
12:55Chouserah!
12:55Chouseryou need a "classes" directory
12:55Chouserit must exist and be in your classpath -- that's where the .class files will be put
12:56technomancythere's got to be a way to make that process a little more friendly
12:56Chousersome have suggested creating the 'classes' dir if it doesn't exist.
12:56amitavano joy - user=> (compile 'clojure.examples.hello) java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.examples.hello$_main__13 (NO_SOURCE_FILE:0)
12:56technomancyI guess you can't create the directory on the fly since it needs to be on the classpath at JVM boot time.
12:56Chousermaybe just a better error message.
12:56technomancyI mean, you could create it, but it wouldn't hepl
12:56amitavak, let me restart REPL
12:56technomancyyeah, improving the error message would be fine.
12:57Chouseramitava: you're closer -- it created the class file now, and it is just having trouble loading it
12:57Chouserstarting a fresh java with 'classes' in the classpath should do it
12:57amitavait compiled now - thx :-)
12:57amitavado i need classes to begin with?
13:01amitavai am hoping to get some advise
13:01amitavai would like use clojure and distribute web-app as war
13:02amitavawhat's the best way to deploy a war file with clojure
13:02amitavacompojure is nice - but i want to deploy to existing app server
13:04technomancythe C-140 cargo plane is a popular choice for deploying wars, but if you'd prefer an aquatic approach, a hovercraft is a viable alternative.
13:05technomancysorry, that joke is getting old.
13:05cemerickI really don't understand the impulse to do AOT compilation outside of an automated build process.
13:05danlarkinha ha ha
13:05technomancycemerick: maybe if there were automated build processes that didn't involve writing XML as if it were code, people wouldn't be so adverse to it. =(
13:06amitavacompile plain old servlet (aot), manually package war, deploy to tomcat
13:06cemericktechnomancy: people are perfectly free to use rake or whatever *shrug*
13:06cemerickor make or shell scripts, even.
13:06cemerickI'm just saying that getting the environment set up for compilation more than once would be unbearable.
13:07amitavainclude clojure.jar in WEB-INF/lib
13:07cemerickand the fact that clojure.lang.Compile exists makes things *really* easy, IMO
13:07amitavai haven't tried this approach and thought this group might have already experimented
13:46sureshhello.. i am fairly new to clojure.. im stuck with a problem.. i have been trying to write a web app using only clojure + ring, i use gen-class to generate a servlet, which i then wrap with ring.. but i keep getting a filenotfoundexception for fcase.clj from ring's httpcore
13:46sureshany help appreciated, thanks
13:50sureshanyone used ring + servlet?
13:51ChouserI haven't, sorry.
13:51Chouserdo you have an fcase.clj somewhere?
13:51sureshit is part of clojure-contrib
13:51sureshand the contrib jar is in classpath
13:53Chouserthe jar you're using has .clj as well as .class files?
13:53sureshit has only the .clj file
13:56Chouserhuh. well, I'm stumped. If you have a full stack trace you could try pasting that, but I really don't know anything about servlets
13:58sureshCaused by: java.io.FileNotFoundException: Could not locate clojure/contrib/fcase__init.class or clojure/contrib/fcase.clj on classpath: (httpcore.clj:1)
13:58suresh at clojure.lang.Compiler.eval(Compiler.java:4617)
13:58suresh at clojure.lang.Compiler.eval(Compiler.java:4593)
13:58suresh at clojure.lang.Compiler.load(Compiler.java:4931)
13:58suresh at clojure.lang.RT.loadResourceScript(RT.java:330)
13:58suresh at clojure.lang.RT.loadResourceScript(RT.java:321)
13:58sureshoops.. messed it up.. basically those were a few likes of the stack trace
13:58Chouseryeah, that's enough
13:59Chouserthat really suggests the contrib jar isn't in the classpath, or isn't in the right classpath.
13:59Chouserbut clojure clearly is
14:00amitavadid you include the jars in WEB-INF/lib ?
14:00sureshyes, it is in there
14:00Chouseras is whatever line of .clj code that's trying to load fcase
14:01sureshi even added a main method to the generated class and invoked it from command line and it seems to work perfectly fine
14:01amitavar u running this on tomcat?
14:02sureshno, using jetty.. actually google app engine
14:07cemerickugh, I'd bet on GAE classloader oddities
14:07amitavai noticed that the exception is coming out of httpcore
14:07amitavabut in the ring example, it is invoked via ring.jetty
14:08amitavais ring routing to the right handler?
14:08sureshi am trying to do what ring.jetty does, but for a plain servlet
14:09sureshi dont think i got it working yet, but the moment i use ring.jetty, i get the file not found exception
14:17sureshwell, it is quite late here.. i will post back results here if i get it working..
14:17sureshthanks amitava, Chouser
14:18Chousersorry we souldn't get you there.
14:19sureshnot a problem at all.. some sleep might help figuring it out :)
14:19amitavathis seems like a classloader issue
14:20sureshyup, absolutely.. i just cant seem to figure out what might be causing this.
14:20amitavalast question - did u package this as a war file?
14:20sureshit is all in exploded form
14:20sureshand i use the jetty based dev server from app engine
14:20amitavaso the compiled classes in WEB-INF/classes
14:21sureshyes
14:21amitavak - thx
14:21sureshall i have right now is one clj which is compiled as a servlet
14:21sureshand i do see a bunch of class files in the right package
14:22amitavacan u post u'r files?
14:22sureshsure.. let me send you the url
14:32sureshamitava: the code is here -> http://bitbucket.org/itzsuresh/paper-notes/
14:33Fossihi
14:34Chouserhi
17:02Anniepoois André Ferreira's amb implementation the best one out there? I've got a real use for amb, I don't see one in clojure.contrib
17:08Chouserwhat's amb?
17:18replaca__Chouser: amb is a function that implements non-determinism. See http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-16.html#node_sec_14.1 for a description
17:21Chouserah, yes. thanks.
17:22pjstadigclojurebot: mascot?
17:22clojurebotthe official mascot of clojure is a futuristic ninja robot
17:22pjstadignice
17:22Hun,(= 'p 'np)
17:22clojurebotfalse
17:36cemerickanyone have a link for the amb impl that Anniepoo mentioned? googling 'clojure amb' and the name he mentioned doesn't turn up anything helpful.
17:38Chousercemerick: http://groups.google.com/group/clojure/browse_thread/thread/e4125580fac21177
17:38maacl1I am trying to implement a longest common subsequence algorithm in Clojure. My attempt so far is here: http://paste.lisp.org/+1S56. There is a bug somewhere in this as the lcs-length table is not calculated correctly (correct one is illustrated here: http://bit.ly/ubqZu). I suspect the bug is around line 10-13. Can anyone help?
17:38Chouserflow control via exceptions. :-/
17:38cemerickChouser: thanks. Jeez, google can't search itself. :-/
17:39cemerickChouser: when nothing else will do... :-)
17:39Chousercemerick: yeah, it's very difficult to find google group messages, either via google's regular search or its group search. lame.
17:39cemerickI take it you just searched your local history of msgs?
17:41Chousercemerick: no, I googled "André Ferreira clojure amb" (no quotes) whic brought up a mail-archive.com link to a message deeper in the thread, from which I harvested some nice keyword to feed back into google
17:43Chousermaacl1: wow, amap. I don't think I've ever used that.
17:45maacl1Chouser: yeah, trying to make it fast :-) serves me well that it doesn't work
17:47maacl1Chouser: found the bug - I think
17:50maacl1Chouser: yeah, posting the correct version now
17:51maacl1Chouser: http://paste.lisp.org/display/83130#1
17:53ozzileeAnybody know how to get the ServletContext in Compojure? I'm going nuts trying to serve a file out of the .war
17:55ozzileeBah nevermind, (request :servlet-context)
17:57Chousermaacl1: good. I don't think I would have been able to help you. :-)
17:57clojurebothttp://www.khanacademy.org/
17:57_hrrld`Right now I wish that println or something it called (e.g., prn) emitted a \r in addition to \n.
18:01durka42hmm, (newline) should respect (System/getProperty "line.separator"), shouldn't it?
18:01durka42_hrrld` is on windows?
18:02Chouserhm, dunno
18:02Chousershould \newline not always be a single Character?
18:02Chouseror should (newline) not always print \newline ?
18:02_hrrld`I am on windows, but I'm working on an app that people will telnet to from all OSs...
18:02durka42Chouser: i meant the second one
18:03durka42_hrrld` wants (newline) => \return \newline
18:03_hrrld`A separate function (carrage-return) might be nice.
18:03_hrrld`As long as prn calls it. (:
18:03durka42,(System/getProperty "line.separator")
18:03clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission line.separator read)
18:03replaca__Chouser: remember that the telnet protocol specifies a two character newline
18:04_hrrld`On this machine line.separator is "\r\n", so respecting that with (newline) would be fine too.
18:04Chouserright, in which case you'd want "\r\n" even if (System/getProperty "line.separator") is just "\n"
18:06_hrrld`On a related note "\return" is a crazy thing for the reader to respect... Does that some Lisp tradition?
18:06_hrrld`s/Does/Is
18:07Chouser,(str \return \newline \space \a \b \c)
18:07clojurebot"\r\n abc"
18:08_hrrld`Dont forget:
18:08_hrrld`,(str \formfeed)
18:08clojurebot"\f"
18:09_hrrld`,(int \formfeed)
18:09clojurebot12
18:10replaca__Chouser: that's right, telnet demands \r\n. See http://www.faqs.org/rfcs/rfc854.html for details (search for "The sequence "CR LF"," and you'll find the discussion)
18:11technomancyprintln works fine with telnet for me
18:12_hrrld`technomancy, what os/telnet software are you using?
18:13_hrrld`techonomancy, also, are you the author of "mire" ?
18:13technomancy_hrrld`: ubuntu client and server
18:13mrpika,(str "neat")
18:13clojurebot"neat"
18:13technomancyalso Emacs' telnet implementation
18:13technomancy_hrrld`: yeah, that's me
18:13durka42_hrrld`: note you can also do (binding [newline #(do (. *out* (append \return)) (. *out* (append \newline)))] (prn "hi"))
18:13technomancyguess I haven't tried it on windows
18:13_hrrld`I noticed that mire uses println, that happens to make it quite broken on windows.
18:14_hrrld`Using the windows telnet client as well as putty.
18:14technomancy_hrrld`: aha; good to know.
18:14_hrrld`durka42, interesting hack. :)
18:14_hrrld`technomancy, fwiw I think emacs telnet just shells out to regular old telnet.
18:14technomancynever mind then
18:14durka42not a hack :) functions are stored in vars
18:15_hrrld`durka42, until another developer wants either the original behavior of (newline) or to use the new behavior outside that bound context. :)
18:15durka42well, yes :)
18:16_hrrld`Is there any case where we wouldn't want prn to also to output a "\r" ?
18:17durka42you mean, except when not on windows
18:17_hrrld`Does a "\r" hose non windows?
18:18durka42when i run that snippet (mac) i get "hi"^M
18:18durka42,(binding [newline #(do (. *out* (append \return)) (. *out* (append \newline)))] (prn "hi"))
18:18clojurebot"hi"
18:19durka42http://en.wikipedia.org/wiki/Unix2dos
18:27_hrrld`Thanks for the help/discussion.
18:37technomancyso I'm using Nailgun to persist my clojure app. When I try to open a reader on System/in for functions launched with ng, I randomly get "Unexpected chunk type 83 ('S')"
18:37technomancyany ideas what that could mean?
18:40technomancylooks like a random nailgun bug
19:05technomancyanyone have an example of gen-class that creates a static method?
19:08technomancydanlarkin: well nailgun is pretty obscure. but this gen-class stuff is just java-specific jargon.
19:09technomancy"Static methods can be specified with #^{:static true} in the signature's metadata." <- where exactly would that go?
19:09hiredmantechnomancy: the method signature in the gen-class block
19:09hiredmana method signature is a vector, if I recall
19:10technomancygotcha; will give that a shot
19:10hiredmanso you just put that out in front so it gets attached to the vector
19:10technomancycool; thanks
19:22lisppaste8technomancy pasted "nailgun class" at http://paste.lisp.org/display/83136
19:22technomancyaccording to this page, that code I pasted should copy stdin to stdout: http://martiansoftware.com/nailgun/api/com/martiansoftware/nailgun/NGContext.html
19:23technomancyinstead it complains: java.lang.NoSuchMethodException: nailgun.Copy.main([Ljava.lang.String;)
19:25technomancyhrm; vimclojure uses nailgun; I'll take a look at how they do this
19:26hiredmanI think you have an extra dash there
19:26hiredman-nailMain in the signature should maybe be nailMain
19:26technomancyaha
19:27technomancymaybe, but that's not the only problem. vimclojure's code looks promising though.
20:24duncanmi really enjoy working with clojure - but man, there are a lot of broken Java APIs out there ;-(
20:25technomancy=(
20:25duncanmand really, no amount of Clojure can help fix that (unfortunately)
20:25drewr`Perhaps. I don't care for the JavaMail API, but was able to make it fairly sane for my needs.
20:26drewr`(e.g.)
20:26technomancyjavamail is very sane compared to some of the stuff I've been playing with
20:26duncanmi'm dealing with ImageJ here, and it's based on AWT
20:26duncanmalso, Java IO just stinks
20:26duncanmall the InputSources and InputStreams and this and that
20:45gstampIf I define a namespace and import a class eg:(ns myns (import '(java.awt Color)) then I 'use' that namespace in another namespace does the imported class become available in the second namespace?
22:32arohner_is there a way to create a new def, without using a macro?
22:33Chouser'intern'?
22:33arohner_ah, great
22:33arohner_thanks