#clojure log - Jul 06 2009

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:23 hiredman: lisppaste8: url?

0:23 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

0:24 hiredman pasted "adapt" at http://paste.lisp.org/display/83084

0:26 duncanm: interesting implementation

0:27 hiredman: it's one of those sort of inbred things

0:27 slashus2: You produce interesting implementations genetically?

0:27 hiredman: if I've written and rewritten that a few times never really satisfied

0:28 slashus2: hah, no

0:28 I think previously I tried have the first arg to the function a keyword naming the method called

3:16 Raynes: I'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. ;)

4:10 slashus2: Raynes: What happened?

4:10 Raynes: slashus2: What do you mean?

4:10 slashus2: Raynes: You are rejoining. Why did you leave?

4:12 Raynes: slashus2: 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.

4:12 slashus2: Raynes: How was your foray with Haskell?

4:12 Raynes: Fun! Haskell taught me lot's of stuff.

4:13 lots, even.

4:13 And Slime really does rock doesn't it? I mean, everyone told me that, but I didn't think it was this awesome...

4:14 Lau_of_DK: Raynes: This morning I felt a disturbance in the force - I'm pleased to see that Emacs has once again embraced you

4:14 Raynes: Lau_of_DK: I got wrapped up in Emacs thanks to Haskell.

4:15 Lau_of_DK: Should I learn Haskell?

4:15 Raynes: Totally, it doesn't hurt. :p

4:15 Lau_of_DK: Just dont want to waste my time

4:15 Raynes: It will likely influence how you program in Clojure, in good ways.

4:17 Lau_of_DK: kthxbye

6:23 AWizzArd: btw, is Joshua Choi also here?

6:23 (author of fnparse)

6:24 Or is any experienced fnparse user here? :)

6:24 arbscht_: I don't believe I have ever seen him here

6:25 I have used fnparse, but I won't guarantee my experience will be useful to you :)

6:27 AWizzArd: Ah cool, so I know someone who I can bug with a few (hopefully specific) questions.

9:06 ChrisPS: when you say: (require 'whatever)

9:06 what does this really mean?

9:07 as opposed to (use 'whatever)

9:07 Chouser: that means load the code for the 'whatever namespace either ..

9:07 oh

9:08 in both cases the code for the 'whatever namespace is loaded either from .clj or .class files compiled from .clj files

9:08 when that's done you should have a "whatever" namespace with vars in it. 'require' is then done

9:09 'use' goes a step further and brings names from "whatever" into your current namespace, like the 'refer' function does.

9:09 ChrisPS: do you have to name the namespace in a specific way, in relation to where it is placed on disk?

9:09 Chouser: yes

9:09 ChrisPS: how?

9:10 Chouser: a namespace foo.bar.baz must be defined in a file name <src>/foo/bar/baz.clj and <src> must be in your classpath

9:10 ChrisPS: and, do you have to include the directory where this 'whatever namespace resides in your classpath?

9:10 ah

9:10 ok

9:11 guess I have ignored that bit

9:11 working with files is such a drag

9:11 Chouser: it's very much like java expects it's .class files to be named

9:12 ChrisPS: such a long time since I've even sniffed on java

9:13 Chouser: I'm deeper into the JVM with Clojure than I ever was with Java

9:19 ChrisPS: hopefully 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

9:19 but files are really a pain to work with

9:20 we'll manage :-)

9:20 Chouser: you have an alternative code storage mechanism other than files?

9:21 maybe that shows how little I know about smalltalk. :-)

9:21 ChrisPS: hehe

9:21 cemerick: Chouser: boy, are you in for it now :-)

9:21 ChrisPS: that's cool

9:23 cemerick: ChrisPS: 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.

9:23 there'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)

9:24 A clojure-on-smalltalk would be fascinating, though.

9:24 rhickey: cemerick: interesting

9:24 Chousuke: I wonder what Clojure-on-CL would look like :P

9:26 rhickey: Chousuke: the big benefit there would be fixnums, but there aren't a lot of CLOS libs to tap into...

9:27 cemerick: rhickey: 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).

9:27 Chousuke: rhickey: I suppose so. It'd still be an interesting experiment though.

9:28 rhickey: Chousuke: 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

9:29 Chousuke: hmm :/

9:30 rhickey: LispWorks, my favorite, is not open source, but the only one I'd personally spend time on, next version promises true MT

9:30 Raynes: The 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.

9:30 rsynnott: rhickey: there is a slightly dubious multi-threading library which supports most which have any sort of multithreading at all

9:31 AWizzArd: rhickey: have you tried to use Jessrules together with Clojure?

9:31 rsynnott: (though the differing behaviour of different multiprocessing approaches might be a problem)

9:31 cemerick: Raynes: yeah, ant is pretty good. "It's the worst build system, except for all of the others."

9:31 Raynes: cemerick: :p

9:31 cemerick: rhickey: do you do much of any CL hacking anymore/

9:31 ChrisPS: CLR? There is Clojure for .net as well? Dang, of course, its jvm...hmm

9:31 cemerick: ?

9:31 Raynes: Stuart should work on Lancet more. :\

9:32 rsynnott: (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)

9:32 ChrisPS: cemerick: I get your point with external tools, of course

9:33 rhickey: cemerick: not much CL anymore, no

9:34 cemerick: ChrisPS: 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.

9:34 Chouser: via a dynamic classloader, any particular IDE could choose to provide code storage of its own in any arbitrary way.

9:35 ChrisPS: cemerick: I am using emacs-slime

9:35 cemerick: I use enclojure (which provides a small jar you can drop into your application to get remote REPLs easily). Others use slime.

9:35 ChrisPS: any repl that is better?

9:35 enclojure, looking into it

9:35 rsynnott: ChrisPS: the SLIME one is decent

9:35 cemerick: ChrisPS: probably a personal preference. Having a passable debugger and profiling tools in NetBeans is pretty compelling.

9:36 ChrisPS: I only need to master the namespace thing

9:36 have you peeked at what the intellij-people are doing?

9:36 * Raynes is surprised to find that he seems to be the only one that Enclojure doesn't work for in NetBeans 6.7

9:36 ChrisPS: or maybe it's just a thirdparty plugin

9:36 Raynes: ChrisPS: Last I checked La Clojure is pretty good.

9:37 I used to use Enclojure, now I use Emacs+Slime.

9:37 ChrisPS: I love this french-thing

9:37 or italian..

9:37 whatever

9:37 cemerick: ChrisPS: Looks promising, but not very comprehensive. Not being able to set up a remote REPL is pretty critical for what I do.

9:38 actually, I'm not sure the intellij plugin even supports local repls, although I have to imagine that it will sooner rather than later

9:38 noidi_: q

9:40 ChrisPS: La Clojure looks pretty, but I am determined to master emacs, and make it my best-friend (next to TextMate)

9:40 Raynes: cemerick: I think La Clojure supports local REPL's now.

9:41 cemerick: ChrisPS: dangerous road. Many a hacker have lost their souls to emacs.

9:41 Raynes: REPLs even.

9:41 ChrisPS: Don't listen to him, surrender to the darkness.

9:41 ChrisPS: I lost my soul 20 years ago, and it was not due to emacs :-)

9:42 I also lost some more of my soul to Microsoft Visual Basic 2.0

9:42 cemerick: I personally had to check my best friend into a sanitarium because he would involuntarily shriek about losing his mark and such.

9:42 ChrisPS: hehe

9:42 ctrl-space mark?

9:43 haha

9:43 cemerick: yeah, it's what I came up with off the top of my head :-D

9:43 ChrisPS: so absurd

9:43 look, he is a stack now

9:50 how to get a list of all color-constants in emacs?

9:57 M-x list-colors-display

11:29 arg, I cannot get autocompletion to work

11:30 in emacs

11:30 rsynnott: using slime?

11:30 ChrisPS: yes

11:34 any idea for where to start looking?

12:50 amitava: I am trying out ahead of time compilation without much success

12:51 took clojure.example.hello.clj straight out of the docs

12:51 in ./clojure/examples/hello.clj

12:51 user=> (compile 'clojure.examples.hello) java.io.IOException: No such file or directory (hello.clj:1) user=>

12:52 Chousuke: amitava: di you add . to your classpath? :)

12:52 amitava: user=> (System/getProperty "java.class.path") "/Users/amitava/myapps/clojure/clojure-1.0.0.jar:/Users/amitava/tmp/clj/classes:/Users/amitava/tmp/clj/"

12:52 yes

12:53 Chousuke: hmm

12:53 amitava: user=> (System/getProperty "user.dir") "/Users/amitava/tmp/clj"

12:54 user=> *clojure-version* {:major 1, :minor 0, :incremental 0, :qualifier ""}

12:54 Chousuke: that ought to work then :/

12:55 Chouser: that error is odd. I get: java.io.FileNotFoundException: Could not locate clojure/examples/hello__init.class or clojure/examples/hello.clj on classpath

12:55 amitava: see http://pastebin.com/m65d56531 for java stack trace

12:55 Chouser: ah!

12:55 you need a "classes" directory

12:55 it must exist and be in your classpath -- that's where the .class files will be put

12:56 technomancy: there's got to be a way to make that process a little more friendly

12:56 Chouser: some have suggested creating the 'classes' dir if it doesn't exist.

12:56 amitava: no joy - user=> (compile 'clojure.examples.hello) java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.examples.hello$_main__13 (NO_SOURCE_FILE:0)

12:56 technomancy: I guess you can't create the directory on the fly since it needs to be on the classpath at JVM boot time.

12:56 Chouser: maybe just a better error message.

12:56 technomancy: I mean, you could create it, but it wouldn't hepl

12:56 amitava: k, let me restart REPL

12:56 technomancy: yeah, improving the error message would be fine.

12:57 Chouser: amitava: you're closer -- it created the class file now, and it is just having trouble loading it

12:57 * technomancy muses

12:57 Chouser: starting a fresh java with 'classes' in the classpath should do it

12:57 amitava: it compiled now - thx :-)

12:57 do i need classes to begin with?

13:01 i am hoping to get some advise

13:01 i would like use clojure and distribute web-app as war

13:02 what's the best way to deploy a war file with clojure

13:02 compojure is nice - but i want to deploy to existing app server

13:04 technomancy: the 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:05 sorry, that joke is getting old.

13:05 cemerick: I really don't understand the impulse to do AOT compilation outside of an automated build process.

13:05 danlarkin: ha ha ha

13:05 technomancy: cemerick: 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:06 amitava: compile plain old servlet (aot), manually package war, deploy to tomcat

13:06 cemerick: technomancy: people are perfectly free to use rake or whatever *shrug*

13:06 or make or shell scripts, even.

13:06 I'm just saying that getting the environment set up for compilation more than once would be unbearable.

13:07 amitava: include clojure.jar in WEB-INF/lib

13:07 cemerick: and the fact that clojure.lang.Compile exists makes things *really* easy, IMO

13:07 amitava: i haven't tried this approach and thought this group might have already experimented

13:46 suresh: hello.. 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:46 any help appreciated, thanks

13:50 anyone used ring + servlet?

13:51 Chouser: I haven't, sorry.

13:51 do you have an fcase.clj somewhere?

13:51 suresh: it is part of clojure-contrib

13:51 and the contrib jar is in classpath

13:53 Chouser: the jar you're using has .clj as well as .class files?

13:53 suresh: it has only the .clj file

13:56 Chouser: huh. 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:58 suresh: Caused by: java.io.FileNotFoundException: Could not locate clojure/contrib/fcase__init.class or clojure/contrib/fcase.clj on classpath: (httpcore.clj:1)

13:58 at clojure.lang.Compiler.eval(Compiler.java:4617)

13:58 at clojure.lang.Compiler.eval(Compiler.java:4593)

13:58 at clojure.lang.Compiler.load(Compiler.java:4931)

13:58 at clojure.lang.RT.loadResourceScript(RT.java:330)

13:58 at clojure.lang.RT.loadResourceScript(RT.java:321)

13:58 oops.. messed it up.. basically those were a few likes of the stack trace

13:58 Chouser: yeah, that's enough

13:59 that really suggests the contrib jar isn't in the classpath, or isn't in the right classpath.

13:59 but clojure clearly is

14:00 amitava: did you include the jars in WEB-INF/lib ?

14:00 suresh: yes, it is in there

14:00 Chouser: as is whatever line of .clj code that's trying to load fcase

14:01 suresh: i even added a main method to the generated class and invoked it from command line and it seems to work perfectly fine

14:01 amitava: r u running this on tomcat?

14:02 suresh: no, using jetty.. actually google app engine

14:07 cemerick: ugh, I'd bet on GAE classloader oddities

14:07 amitava: i noticed that the exception is coming out of httpcore

14:07 but in the ring example, it is invoked via ring.jetty

14:08 is ring routing to the right handler?

14:08 suresh: i am trying to do what ring.jetty does, but for a plain servlet

14:09 i dont think i got it working yet, but the moment i use ring.jetty, i get the file not found exception

14:17 well, it is quite late here.. i will post back results here if i get it working..

14:17 thanks amitava, Chouser

14:18 Chouser: sorry we souldn't get you there.

14:19 suresh: not a problem at all.. some sleep might help figuring it out :)

14:19 amitava: this seems like a classloader issue

14:20 suresh: yup, absolutely.. i just cant seem to figure out what might be causing this.

14:20 amitava: last question - did u package this as a war file?

14:20 suresh: it is all in exploded form

14:20 and i use the jetty based dev server from app engine

14:20 amitava: so the compiled classes in WEB-INF/classes

14:21 suresh: yes

14:21 amitava: k - thx

14:21 suresh: all i have right now is one clj which is compiled as a servlet

14:21 and i do see a bunch of class files in the right package

14:22 amitava: can u post u'r files?

14:22 suresh: sure.. let me send you the url

14:32 amitava: the code is here -> http://bitbucket.org/itzsuresh/paper-notes/

14:33 Fossi: hi

14:34 Chouser: hi

17:02 Anniepoo: is 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:08 Chouser: what's amb?

17:18 replaca__: 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:21 Chouser: ah, yes. thanks.

17:22 pjstadig: clojurebot: mascot?

17:22 clojurebot: the official mascot of clojure is a futuristic ninja robot

17:22 pjstadig: nice

17:22 Hun: ,(= 'p 'np)

17:22 clojurebot: false

17:36 cemerick: anyone 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:38 Chouser: cemerick: http://groups.google.com/group/clojure/browse_thread/thread/e4125580fac21177

17:38 maacl1: I 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:38 Chouser: flow control via exceptions. :-/

17:38 cemerick: Chouser: thanks. Jeez, google can't search itself. :-/

17:39 Chouser: when nothing else will do... :-)

17:39 Chouser: cemerick: yeah, it's very difficult to find google group messages, either via google's regular search or its group search. lame.

17:39 cemerick: I take it you just searched your local history of msgs?

17:41 Chouser: cemerick: 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:43 maacl1: wow, amap. I don't think I've ever used that.

17:43 * Chouser reads the docs

17:45 maacl1: Chouser: yeah, trying to make it fast :-) serves me well that it doesn't work

17:47 Chouser: found the bug - I think

17:50 Chouser: yeah, posting the correct version now

17:51 Chouser: http://paste.lisp.org/display/83130#1

17:53 ozzilee: Anybody know how to get the ServletContext in Compojure? I'm going nuts trying to serve a file out of the .war

17:55 Bah nevermind, (request :servlet-context)

17:57 Chouser: maacl1: good. I don't think I would have been able to help you. :-)

17:57 clojurebot: http://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:01 durka42: hmm, (newline) should respect (System/getProperty "line.separator"), shouldn't it?

18:01 _hrrld` is on windows?

18:02 Chouser: hm, dunno

18:02 should \newline not always be a single Character?

18:02 or 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:02 durka42: Chouser: i meant the second one

18:03 _hrrld` wants (newline) => \return \newline

18:03 _hrrld`: A separate function (carrage-return) might be nice.

18:03 As long as prn calls it. (:

18:03 durka42: ,(System/getProperty "line.separator")

18:03 clojurebot: java.security.AccessControlException: access denied (java.util.PropertyPermission line.separator read)

18:03 replaca__: 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:04 Chouser: right, 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 s/Does/Is

18:07 Chouser: ,(str \return \newline \space \a \b \c)

18:07 clojurebot: "\r\n abc"

18:08 _hrrld`: Dont forget:

18:08 ,(str \formfeed)

18:08 clojurebot: "\f"

18:09 _hrrld`: ,(int \formfeed)

18:09 clojurebot: 12

18:10 replaca__: 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:11 technomancy: println works fine with telnet for me

18:12 _hrrld`: technomancy, what os/telnet software are you using?

18:13 techonomancy, also, are you the author of "mire" ?

18:13 technomancy: _hrrld`: ubuntu client and server

18:13 mrpika: ,(str "neat")

18:13 clojurebot: "neat"

18:13 technomancy: also Emacs' telnet implementation

18:13 _hrrld`: yeah, that's me

18:13 durka42: _hrrld`: note you can also do (binding [newline #(do (. *out* (append \return)) (. *out* (append \newline)))] (prn "hi"))

18:13 technomancy: guess 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 Using the windows telnet client as well as putty.

18:14 technomancy: _hrrld`: aha; good to know.

18:14 _hrrld`: durka42, interesting hack. :)

18:14 technomancy, fwiw I think emacs telnet just shells out to regular old telnet.

18:14 technomancy: never mind then

18:14 durka42: not 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:15 durka42: well, yes :)

18:16 _hrrld`: Is there any case where we wouldn't want prn to also to output a "\r" ?

18:17 durka42: you mean, except when not on windows

18:17 _hrrld`: Does a "\r" hose non windows?

18:18 durka42: when i run that snippet (mac) i get "hi"^M

18:18 ,(binding [newline #(do (. *out* (append \return)) (. *out* (append \newline)))] (prn "hi"))

18:18 clojurebot: "hi"

18:19 durka42: http://en.wikipedia.org/wiki/Unix2dos

18:20 * durka42 has to run

18:27 _hrrld`: Thanks for the help/discussion.

18:29 * ataggart loks forward to the day we no longer use control characters that were designed for carriage-based printers

18:37 technomancy: so 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:37 any ideas what that could mean?

18:40 looks like a random nailgun bug

19:05 anyone have an example of gen-class that creates a static method?

19:07 * danlarkin watches as all of technomancy's questions go unanswered

19:08 technomancy: danlarkin: well nailgun is pretty obscure. but this gen-class stuff is just java-specific jargon.

19:09 "Static methods can be specified with #^{:static true} in the signature's metadata." <- where exactly would that go?

19:09 hiredman: technomancy: the method signature in the gen-class block

19:09 a method signature is a vector, if I recall

19:10 technomancy: gotcha; will give that a shot

19:10 hiredman: so you just put that out in front so it gets attached to the vector

19:10 technomancy: cool; thanks

19:22 lisppaste8: technomancy pasted "nailgun class" at http://paste.lisp.org/display/83136

19:22 technomancy: according to this page, that code I pasted should copy stdin to stdout: http://martiansoftware.com/nailgun/api/com/martiansoftware/nailgun/NGContext.html

19:23 instead it complains: java.lang.NoSuchMethodException: nailgun.Copy.main([Ljava.lang.String;)

19:25 hrm; vimclojure uses nailgun; I'll take a look at how they do this

19:26 hiredman: I think you have an extra dash there

19:26 -nailMain in the signature should maybe be nailMain

19:26 technomancy: aha

19:27 maybe, but that's not the only problem. vimclojure's code looks promising though.

20:24 duncanm: i really enjoy working with clojure - but man, there are a lot of broken Java APIs out there ;-(

20:25 technomancy: =(

20:25 duncanm: and really, no amount of Clojure can help fix that (unfortunately)

20:25 drewr`: Perhaps. I don't care for the JavaMail API, but was able to make it fairly sane for my needs.

20:26 (e.g.)

20:26 technomancy: javamail is very sane compared to some of the stuff I've been playing with

20:26 duncanm: i'm dealing with ImageJ here, and it's based on AWT

20:26 also, Java IO just stinks

20:26 all the InputSources and InputStreams and this and that

20:45 gstamp: If 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:32 arohner_: is there a way to create a new def, without using a macro?

22:33 Chouser: 'intern'?

22:33 arohner_: ah, great

22:33 thanks

Logging service provided by n01se.net