#clojure log - Dec 06 2008

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

1:20 drewolson: which is more idiomatic: (into [1 2 3] [4 5 6]) or (vec (concat [1 2 3] [4 5 6]))

1:22 don't think this sent before, but sorry if it's a repeat question. which is more idiomatic:

1:22 (vec (concat [1 2 3] [4 5 6])) or (into [1 2 3] [4 5 6])

10:14 kib2: hi, anyone knows how to save a uft-8 text file with contrib.duck-streams ?

10:19 emacsen: if ORM is not the right way to handle databases, what is?

10:25 kib2: new SLIME slides : http://common-lisp.net/%7Etrittweiler/slime-talk-2008.pdf

10:26 dhaya: emacsen: http://groups.google.com/group/clojure/msg/79022b44684a9b38

10:27 emacsen: that doesn't answer my question- only affirms my initial statement

10:32 dhaya: "having very few data structures and very many general functions to manipulate".. i thought that answers your question. sorry if did not :)

10:41 Chouser: emacsen: I think what I want is a DSL for building queries that are returned as seqs of hash-maps.

10:41 emacsen: Chouser, yeah...

10:45 Chouser: no?

10:59 duck1123: do I have to do anything special to compile my namespace?

11:00 I'm getting a "Could not initialize class ..." error

11:01 StartsWithK: duck1123: can you provide full paste of error?

11:03 lisppaste8: duck1123 pasted "First attempt at compiling a ns" at http://paste.lisp.org/display/71696

11:04 duck1123: I'm not trying to generate classes yet, I'm just trying to compile

11:04 or can I only compile if I'm using gen-class

11:05 I have a "classes/" folder on the classpath, and this namespace is properly loaded

11:09 Chouser: duck1123: you don't need :gen-class

11:09 duck1123: actually, now that I've reloaded my repl, I'm getting a different error, so that's probably the cause of my problem

11:10 I'm now getting an j.l.ExceptionInInitializerError need to find out why

11:13 hmm... that must've been because it created a few class files, but not all of them. I removed the class files and it went away

11:13 Chouser: duck1123: If it helps diagnosis, I think that without :gen-clss you will not get a Java class named the same as your namespace.

11:17 duck1123: ok, When I try to do this in a straight repl, it works fine. It's just my repl-via-slime that's acting funky

11:18 I moved a bunch of stuff around. (trying to get compojure to work with Tomcat) so that may be the problem.

11:19 StartsWithK: any old gen-class functions like gen and load?

11:19 evals in macros?

11:19 that made trouble for me with compiler

11:21 duck1123: I haven't gotten into any of that. This has been my first foray into compilation or class generation

11:21 I wanted to get standard compilation down before I tried using gen-class

11:50 mattrepl: hrmm, how does declare a method has a return type of void using gen-class' :methods?

11:51 ah, the class type looks like it works. i.e., Void, not Void/TYPE

11:52 Chouser: I think 'void' should work. lowercase.

11:58 mattrepl: yup, it does

12:25 how about referencing the super, for example to get at the superclass' implementation of a method

12:38 Chouser: mattrepl: you need to call a super's method that has exactly the same signature as one you've overridden?

12:39 gnuvince_: Good morning

12:39 (or afternoon I guess...)

12:39 mattrepl: Chouser: yeah, (. this SuperClass/foo arg) seems to work

12:40 Chouser: really!? good to know.

12:40 mattrepl: finishing testing, but it does something at least. =)

12:41 gnuvince_: Chouser: I don't know if you caught this message yesterday: map depends on every? for when you supply more than three collections, so using map inside every? to allow for an arbitrary number of args would probably not work

12:42 Chouser: gnuvince_: I saw that, thanks.

12:42 gnuvince_: OK

12:43 Chouser: but it only uses the single-collection form of 'every?', which wouldn't need to call 'map' so it actually might work ok.

12:44 gnuvince_: You would need to (declare map) before every however.

12:44 Else the compiler won't let it pass.

12:44 Chouser: true

12:45 gnuvince_: What's the policy for submitting patches to contrib?

12:45 Chouser: you need to have a CA submitted.

12:45 gnuvince_: CA?

12:46 Chouser: Contributor Agreement: http://clojure.org/contributing

12:46 Then you can post patches to the Google Group and whoever maintains the code you're patching can work with you to get it in.

12:47 I think you could also petition rhickey for commit privs at that point, but I don't know of a formal process for that.

12:47 dudleyf: clojurebot: CA?

12:47 clojurebot: CA is Contributor Agreement: http://clojure.org/contributing

13:03 mattrepl: Chouser: scratch that, looks like it just recurses instead of calling super

13:04 I really didn't want to dig into bytecode today...

13:18 thearthur: I need an output queue, whats the best clojure structure for this?

13:18 i will be adding data to it in small chunks and pulling it out in big chunks

13:19 would a vector work for this?

13:19 can you efficiently add to both ends of it and take subvectors?

13:25 Chouser: thearthur: do you want blocking on an empty queue?

13:26 if so, you'll need something from java.util.concurrent, a BlockingQueue of some sort.

13:26 If not, you may like clojure.lang.PersistentQueue

13:27 vectors only grow or shrink efficiently on the right-hand end.

13:27 thearthur: Chouser, a blocking queue would be nice

13:27 but i think I cna do with out it using agents

13:28 Chouser: ok. Currently Clojure doesn't wrap or provide any thread-blocking tools, but using the Java classes directly is pretty convenient.

13:28 thearthur: is persistentqueue on clojure.org?

13:29 Chouser: no, it's below the radar.

13:30 Rich didn't want people using it and doing busy polling or anything I guess.

13:30 clojure.lang.PersistentQueue/EMPTY is an empty one

13:31 larrytheliquid: hm, i updated to clojure trunk yesterday and now im getting back nil for metadata on symbols (though collections work fine), anyone else experiencing this?

13:31 Chouser: then you can conj onto one end, and use peek/pop to consume on the other

13:32 larrytheliquid: like (doc map) doesn't work?

13:32 larrytheliquid: (doc map) works, but ^clojure.core/map and ^map do not

13:32 clojurebot: No entiendo

13:33 larrytheliquid: nor does (meta clojure.core/map) or (meta map)

13:33 Chouser: larrytheliquid: functions have never had metadata

13:34 ^#'map gives you all the metadata on the var

13:34 larrytheliquid: ahh right, quoting to get the symbol instead of the function, my mistake

13:35 err var

13:35 Chouser: thx

13:39 Chouser: np

13:51 duck1123: is it generally to use gen-class to actually create the class, or just proxy it?

13:52 I'm getting the feeling that Compojure won't work under Tomcat without extensive re-write

14:02 RSchulz: Don't overlook (proxy ...)

14:02 What is it about Tomcat that seems problematic?

14:02 And is it not true of other servlet container?

14:03 duck1123: can a proxied class be read by java outside clojure?

14:04 Lau_of_DK: Good evening gents

14:05 RSchulz: It doesn't produce a .class file, if that's what you mean.

14:06 Howdy, Lau. How're things with the Danes?

14:07 AWizzArd: Hi Lau

14:07 Chousuke: duck1123: The actual proxy class is anonymous, but you should be able to pass the instance to java using a reference typed as teh implemented class or interface.

14:08 duck1123: Compojure currently initializes the servlet container and proxies up a servlet for use. If I want to run a webapp with an external container (tomcat) I'm thinking I'm going to need to use gen-class to actually get the .class file

14:08 danlucraft: why is (first []) nil but (first '()) an exception?

14:08 RSchulz: duck1123: That's probably true. The servlet container parts are obviously handled by Tomcat itself.

14:08 Perhaps if you know enough about how it works inside, you could get it use existing (in-core) classes instead of .class files.

14:09 Chousuke: danlucraft: it isn't?

14:09 danlucraft: works just fine

14:09 danlucraft: are you using the release version?

14:09 RSchulz: But I don't think there's a portable way to do that, and you'd be stuck with Tomcat or have to replicate that work for ever servlet container you wanted to support.

14:09 duck1123: ok, that's what I was thinking. Compojure is compact and elegant, and completely unsuited to what I need.

14:09 danlucraft: Chousuke: no, svn.

14:10 RSchulz: I don't get an exception from (first '())

14:10 Chousuke: :/

14:10 anyway user=> (first '()) -> nil

14:10 danlucraft: not lying :) http://pastie.org/332764

14:11 hmmm, old revision. let me pull

14:12 RSchulz: duck1123: What is your need / use case?

14:12 danlucraft: OK works now. I pulled the revision recommended in the new PragProg book, which was from nov sometime.

14:13 Chousuke: the git clone for clojure is falling behind :/

14:13 duck1123: RSchulz: just to have a servlet environment that I can compile into a war

14:13 RSchulz: What's the Clojure aspect, then?

14:13 I guess AOT is the answer, right?

14:14 AOT compilation, that is.

14:14 duck1123: RSchulz: well, I have an app that I'm writing in clojure. I was yusing compojure, but I want/need to run it on tomcat, but I think I need to change some things first

14:15 That's what I am thinking. Hopefully I can re-use some of these libraries though

14:16 RSchulz: I'd start with the simples thing, which is AOT compilation. I'm not sure how you get a static class that implements the appropriate Servlet type, but I'm sure it's possible and practical.

14:17 danlucraft: Chousuke, RSchulz: thanks for your help.

14:22 holmak: There is a length function for vectors _somewhere_, right? I can't find it anywhere.

14:22 duck1123: (doc count)

14:22 clojurebot: Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps; arglists ([coll])

14:22 holmak: Aha, I tried length and size. Thanks.

14:23 RSchulz: holmak: Always keep (find-doc) in mind. It does RE pattern matching against documentation strings, so with a bit of guessing, you can usually find what you're looking for, assuming it exists...

14:24 holmak: I tried searching through the online API section for "length" and "size", but the doc string sneakily avoids using those words.

14:25 Not to say that its inaccurate, I just didn't think of the right word to search for.

14:25 RSchulz: Yeah, it's hardly foolproof, but still very useful.

14:25 mon_key: need used-fors

14:26 RSchulz: Eh?

14:26 mon_key: standard librarian technique

14:26 duck1123: I've run into the same thing with distinct vs. uniq and rem vs mod

14:26 mon_key: 'length' - use 'count'

14:26 RSchulz: Yeah. Actually, it's still an open problem how to really, truly deeply facilitate software reuse.

14:26 mon_key: 'count' - used-for 'length'

14:27 see iso z39.50

14:27 duck1123: clj-doc is also pretty handy for looking up functions

14:27 mattrepl: anyone see a reason why genclass methods should not support "super" as a keyword like Java?

14:29 RSchulz: What super keyword is that? gen-class supports :extends and :implements.

14:30 You mean to invoke superclass methods?

14:30 mattrepl: if in an implementation you need to refer to the superclass' implementation

14:30 yeah, invokespecial

14:30 RSchulz: There's something for that w.r.t. calling superclass constructors.

14:31 I think elsewhere you have to know the specific superclass you extended and refer to that class/method specifically.

14:33 mattrepl: I tried that, but it was calling the subclass' implementation still.

14:34 RSchulz: Interesting. That could be a bug. You might want to send message with an example to the mailing list / group.

14:34 Or, if not a bug, an oversight in the design.

14:35 mattrepl: weird.. I'm looking at bytecode from the Clojure compiler and it is using invokespecial... must be operator error, gonna go over my code again, something is causing it to recurse

14:37 duck1123: is there an easy tool for examining compiled .class files?

14:38 RSchulz: All I know of is javap...

14:38 I don't do that sort of thing much, obviously.

14:38 There's JAD, right?

14:38 duck1123: I think I remember Eclipse doing that, but I don't have it set up anymore

14:40 RSchulz: $100 shareware: http://www.freedownloadscenter.com/Programming/Java/ClassSpy.html

14:41 It better fix your code for you, for that price!

14:42 Here's a list of such tools: http://schmidt.devlib.org/java/class-file-optimizers.html

14:44 mattrepl: RSchulz: the syntax you believe should work is (. this a.b.SuperClass/foo arg)?

14:44 RSchulz: Do I believe that? I never knew I believed that!

14:44 It looks plausible, anyway.

14:45 mattrepl: hehe, perhaps wrong word choice, was referring to your comment 10 min ago or so. didn't know if you had tried it before and it worked

14:46 RSchulz: No, I'm just thinking out load... On the keyboard.

14:46 duck1123: RSchulz: I think JAD did what I need

14:47 RSchulz: Cool. Is that where you saw the invokespecial (an opcode I've seen, but don't understand. Don't understand _either_.)

14:48 duck1123: What OS do you use?

14:48 duck1123: Debian

14:49 Lau_of_DK: Hi RSchulz - All is well in the empire of Denmark

14:49 RSchulz: Empire?? I thought you folks had moved on from your imperial era!

14:50 Lau_of_DK: Nei - We shall in no way depart from our dominion of the peasants

14:50 RSchulz: duck1123: So far I've one one Mac-specific and one Windows-specific JAR file inspector.

14:50 OK, then Lau. I'll be sure to behave especially obsequiously toward you!

14:51 duck1123: RSchulz: I'm installing Netbeans to see if that'll do the trick

14:51 RSchulz: duck1123: There does appear to be an Eclipse plug-in. I hate Eclipse, though. I use IDEA and I suspect it has a suitable tool, but I'm not specifically aware of it.

14:51 Lau_of_DK: RSchulz: much appreciated

14:51 RSchulz: While you're at it with NetBeans, keep an eye out for the next release of Enclojure (expected within a week). The current one has some problems and isn't recommended.

14:52 duck1123: I used to be a big fan of Eclipse because it integrated nicely with Oxygen

14:52 but now I'm strictly an emacs guy

14:53 RSchulz: I use <oXygen/>, though not much recently. I didn't know it had specific Eclipse tie-ins.

14:53 Well, Emacs is commendable, but I know Vi / Vim too well to change.

14:53 duck1123: and I have a feeling that I'm probably the only one here that actually likes xml

14:53 XSLT was my first lisp

14:54 RSchulz: I (and I think many) have mixed feelings about XML. It's ugly as hell and a bit hard to work with, but too useful and ubiquitous to ignore.

14:54 mon_key: :) like lisp

14:54 RSchulz: Lisp: The only language you'll ever need.

14:54 Lau_of_DK: RSchulz: I think only Assembler can bear that title truthfully

14:55 duck1123: I wrote my entire application in a mix of XML, XHTML, XPL, XSLT, XQuery, and XForms

14:55 RSchulz: OK. I won't argue with that, but then ... what are you doing here??

14:55 duck1123: So... You're a masochist?

14:55 Lau_of_DK: RSchulz: Just trying to bring you guys up to speed, you can thank me at the after party

14:56 RSchulz: That would be the party after Denmark invades North & South America, East & South Asia, Africa and the rest of Europe??

14:57 julian_morrison: Hi all, made a start on my first Clojure wrapper lib http://github.com/JulianMorrison/neo4j-clojure/tree/master

14:58 RSchulz: Ah, Neo. Everything old is new again...

14:58 julian_morrison: heh

14:58 RSchulz: julian_morrison: The close paren snuck into the URL for the Neo4J link on your github page.

14:59 julian_morrison: gah

14:59 I'll fix that next upload.

15:00 Chouser: proxy does create a .class file, if you compile, but not one with a name you should rely on.

15:00 duck1123: Chouser: I need to specify the class name in my web.xml file, so that won't work

15:01 Chouser: right, :gen-class is what you'll need then

15:01 rhickey: Chouser: there is now proxy-name, undocumented as yet, but probably will be

15:01 RSchulz: Chouser, duck1123: You guys might want to petition Rich for a change that would make proxy useful in this sort of situation.

15:01 I think he'd probably be amenable to something like that.

15:02 duck1123: RSchulz: It's going to be a pain to get this working, but I think I'll be better off with gen-class in the long run

15:02 julian_morrison: I know one change I'd petition for: make seq a multimethod

15:03 the language is positively littered with (xyzzy-seq)

15:04 RSchulz: rhickey: What is the baseline overhead associated with multimethod dispatch?

15:04 julian_morrison: or failing that, define a multimethod to-seq and call it as a last-chance fallback

15:05 duck1123: can you add new methods to a multimethod from outside the namespace?

15:05 mattrepl: rhickey: is there currently a way to invoke a superclass' instance method from a subclass in a genclass method? the equivalent to "super.inheritedMethod()" in Java

15:05 Chouser: duck1123: yes

15:05 duck1123: ok

15:05 RSchulz: duck1123: I think namespaces and multimethod dispatch are orthogonal, so the answer should be "yes"

15:06 rhickey: julian_morrison: many of those seqs are on stateful things, so the explicit seq step is important to avoid aliasing, e.g. iterator-seq - things like iterators can't be considered implicitly seq-able as two independent seqs on the same iterator is a mistake

15:07 julian_morrison: rhickey, I'm not against explicit (seq (xyzzy))

15:07 rhickey, I'm against ten thousand bitty little (xyzzy-seq (xyzzy))

15:08 rhickey: of the 9 I find from (find-doc "-seq"), 7 are that way

15:09 julian_morrison: or at least a single multimethod (seq-once-only (xyzzy))

15:09 rhickey: julian_morrison: the point is, seq is explicitly called, often more than once, for these things that's not safe

15:10 maybe seq-on-mutable

15:11 stuarthalloway: rhickey: I need a name for the .. operator, so I have something to call it in the book. I like "threaded member access", what do you think?

15:11 julian_morrison: there is already (cache-seq)

15:11 rhickey: but I'm not spending time there as I think the right thing for those things is left-fold-enumerating

15:12 RSchulz: rhickey: But those considerations, while valid, are independent on the desire to have an "open" (seq ...) that programmers can extend, assuming they understand when it is and is not appropriate to do so.

15:12 Chouser: stuarthalloway: you've just going ignore all my advice to drop the .. operator?

15:12 rhickey: stuarthalloway: OK

15:12 Chouser: ;-)

15:12 stuarthalloway: Chouser: glad to have this conversation with Rich here to guard my back! :-)

15:13 rhickey: Chouser: he is, on my advice :)

15:13 Chouser: ok, so how is .. better than -> ?

15:13 julian_morrison: .. is bad?

15:13 rhickey: .. is easy to explain to Java programmers - just stitch the calls together with dots

15:13 stuarthalloway: and it is more specific

15:13 Chouser: (-> foo .bar .baz) looks awefully pretty to me.

15:14 julian_morrison: I propose a name "put-dots-between" operator

15:14 Chouser: to mean the same as foo.bar.baz()

15:14 rhickey: Chouser: that's fine - you are no longer a beginner

15:14 stuarthalloway: so just as you might sometimes use a vector specific function to say "I have a vector" instead of "I have a seq", you might use .. to say "I have some Java" instead of just "I have some Clojure"

15:15 * Chouser proposes the "I'm a beginner operator"

15:15 stuarthalloway: ...which I believe is still valid (but not required!) even for non-beginners

15:15 let the archives show that Chouser wants to scare beginners :-)

15:15 Chouser: but you put a dot before every single method call, fairly screaming "this is java".

15:16 duck1123: I think I've only actually used -> once

15:16 julian_morrison: -> makes it easier for a haskelly person to understand

15:16 rhickey: RSchulz: there is an open type-based seq - it's called IPersistentCollection

15:16 stuarthalloway: Chouser: no, could say (-> foo (.java) (.moreJava) (.moreJava) (hahClojure))

15:17 I am certainly not questioning a coding standard of "always ->", just saying it might not be for everybody

15:18 rhickey: Imagine being in front of a room full of Java programmers - .. is much simpler to explain than ->

15:18 duck1123: when using gen-class, I have to remove the class files before I can call compile again, right?

15:18 mon_key: I'm out of my element but... what about `>.'

15:18 RSchulz: rhickey: I see. So duck1123 could proxy that? Possibly with a function or macro to syntactically sugar any patterned cases he has?

15:18 Chouser: That's exactly why -> is better -- it doesn't get you stuck in a java hole.

15:18 rhickey: RSchulz: I missed that part of the conversation

15:19 RSchulz: The original request was for (seq ...) as a multimethod. I assumed that was so it would be open.

15:19 Chouser: But having made my case, I'm certainly not going to try to stand against both you guys! :-)

15:19 * Chouser drops it.

15:19 aperotte: There might be something that I'm missing, but I can't get the basic :gen-class example to compile

15:19 RSchulz: And now Chouser must clean up the shards...

15:21 aperotte: I get a java.io.IOException :(

15:21 RSchulz: What is the "pronunciation" of ->?

15:22 duck1123: "that way"

15:22 RSchulz: Any other suggestions??

15:22 julian_morrison: just checking my understanding of (require) is right... if I (require 'abc') and there is on a classpath a dir "abc" containing file "abc.clj" which begins (ns abc ... then this will all work?

15:23 RSchulz: "chain"

15:23 duck1123: julian_morrison: it should be (require 'abc)

15:23 julian_morrison: duck1123: you're right, that was a typo

15:23 RSchulz: Somehow the description of -> in the documentation does not convey to me what it does. It wasn't until I saw the use in the Zipper code that I realized what it did.

15:24 duck1123: also, post AOT, it'll just look for a file abc.clj the name isn't doubled anymore

15:24 julian_morrison: RSchulz: (-> a b c d) is (d (c (b a))) right?

15:24 duck1123: 'foo.bar.abc becomes foo/bar/abc.clj

15:24 RSchulz: I think so. But it may be more general than that. I'm really not the person to be asking!

15:24 julian_morrison: duck1123: post AOT?

15:25 duck1123: there were some breaking changes a while back

15:25 mostly, you just have to move your files

15:25 mon_key: .. can also be harder to build regexes for when refactoring in some IDEs

15:25 julian_morrison: someone needs to update (doc require)

15:26 mon_key: e.g. \\(\(\.\.\)

15:26 RSchulz: mon_key: What are you thinking about? I don't think refactoring can usually be specified in terms of REs. Regular Tree Expressions, maybe, but not conventional sequential REs.

15:28 mon_key: elsip to sub in/out a change with replace-regexp

15:29 you windup having to escape the hell out of the `path' just to catch the .'s

15:29 Chouser: julian_morrison: you're right, that's exactly what -> does.

15:29 RSchulz: Well, like I said, REs are not a good tool for source code (or syntax tree) manipulation.

15:30 aperotte: Can someone tell me if my approach is correct? I copied the code for the :gen-class example into a hello.clj file and put it in "one of the cp folders"/clojure/examples/hello.clj then opened a repl and typed (compile 'clojure.examples.hello).

15:30 mon_key: you're prob. right

15:30 RSchulz: Chouser: You know, -> is really elegant, but its doc string just does not do it justice. If you didn't know what it did, you'd just never think it would be something you'd want to use.

15:30 duck1123: I had a hell of a time refactoring this morning. I was using really short namespaces, so I had a bunch of fully qualified calls all over the place

15:31 RSchulz: duck1123, mon_key: You guys should pass on your experiences to Peter Wolf (he's on the list). He's writing an IDEA plug-in for Clojure, and I think he wants to support refactoring (which is a classic strength of IDEA).

15:31 He should know what kind of use cases to address and what priority to assign, and real-world experience would help him with that, I think.

15:32 aperotte: I get a IOException saying "No such file or directory (hello.clj:1)

15:32 duck1123: is your classes folder on the clsspath

15:32 julian_morrison: duck1123: the moral is - pick what you need and then "use" it. Redundancy is effort waiting to happen.

15:33 duck1123: I *just* got hit with that

15:34 aperotte: hmm ... classes folder is not on the classpath

15:34 RSchulz: Stu's books includes the recommendation "Don't just require, Use!". But there are times that doesn't work.

15:35 (use 'clojure.zip) will fail 'cause it redefines two core functions.

15:35 duck1123: aperotte: if you're putting your classes folder somewhere else, do: (set! *compile-path* "WEB-INF/classes") or similar

15:35 RSchulz: The cover script I wrote for invoking Clojure from the CLI includes a +cp=classpath-addition option, which may be repeated, of course.

15:35 aperotte: duck1123: ok, I'll give it a try, thanks

15:35 RSchulz: Of course, that's no good for dynamic situations or non-CLI situations.

15:36 duck1123: I don't like using use too much because I have a lot of functions named the same with similar paths

15:37 RSchulz: Well, I guess that's unavoidable. It's one of the virtues of class-centered programming...

15:37 Chouser: RSchulz: I dislike the unqualified use of 'use'. 'use' with :only or :as is ok, but otherwise I really recommend 'require', perhaps with :as

15:37 duck1123: I've been doing things like: (:require net.mycyclopedia.model [view :as model-view]). previously, it was just model.view/foo

15:37 RSchulz: I can't disagree with that. Mostly 'cause I don't have enough experience with the down-sides of unrestricted (use ...).

15:38 Chouser: Of course we've already seen what respect my advice is getting today. :-D

15:38 RSchulz: Oh, now, you win some, you lose some.

15:39 rhickey: namespace separator is / specifically so alias/name is easy

15:39 duck1123: can you alias a whole section of a namespace, or can it only be the last segment?

15:39 rhickey: e.g. require :as is good

15:39 RSchulz: Yes. Aliasing is very nice. I miss not being able to assign type name aliases in Java. The more so since generics were introduced.

15:40 duck1123: I want to alias net.mycyclopedia.model to just model, so I can go back to model.view/foo

15:41 Chouser: duck1123: your alias can have dots in it

15:42 (alias 'model.view 'net.mycyclopedia.model.view)

15:43 mon_key: lol just caught a funny "Imagine being in front of a room full of Java programmers - .. is much simpler to explain than ->" Not unlike explaining to a room full of lispers just cons it

15:43 :)

15:44 duck1123: but I would have to alias every thing. I have things like model.user model.entry model.statements view.user, etc. right?

15:44 RSchulz: There's a Weird Rick Hickovic parody there: "Just Cons It!"

15:44 Chouser: yes. could write a macro to do it for you.

15:45 duck1123: hmm... not a bad idea... see not *all* of your ideas are being ignored today :)

15:47 rhickey: I never got an answer from you the other day. Do you need the CA's mailed to you, or can I scan it and email?

15:48 rhickey: duck1123: please mail

15:49 * duck1123 wonders if he has any stamps

15:50 rhickey: Chouser: do you have test case handy for reduction seq consumption?

15:50 lisppaste8: Chouser pasted "reduction tests" at http://paste.lisp.org/display/71709

15:51 rhickey: Chouser: thanks

15:57 stuarthalloway: Chouser, RSchulz: I got pulled away for a few, but (contrary to my own book) I agree with Chouser about require and use

15:58 the advice about "just use" is appropriate for getting started

15:59 and later in the book I need to make a different recommendation

16:00 in the next beta, all the book examples that refer to contrib will do use/only

16:21 aperotte: duck1123: I put the classes folder on my classpath and still no luck with the compilation

16:25 duck1123: aperotte: what's it saying now

16:25 aperotte: duck1123: same, java.io.IOException: No such file or directory (hello.clj:1)

16:26 duck1123: aperotte: did it actually create the class files?

16:26 RSchulz: Where's the current / latest definition of (reduction ...)?

16:26 duck1123: and can you require that ns?

16:28 aperotte: duck1123: it didn't create the class files (ie I didn't find them anywhere on my classpath or in the classes folder)

16:28 duck1123: do I need to put my clojure/examples/hello.clj in the classes folder?

16:28 duck1123: aperotte: it needs to be on the classpath

16:29 mon_key: aperotte: what OS are you using?

16:29 duck1123: is the namespace 'clojure.examples.hello

16:29 aperotte: mon_key: ubuntu hardy

16:30 duck1123: yup, I copied straight from the website

16:31 duck1123: aperotte: and you are able to (require 'clojure.examples.hello)

16:32 aperotte: duck1123: yes, that worked fine

16:32 Chouser: RSchulz: Here's my latest valid version of 'reduction' http://groups.google.com/group/clojure/msg/1c98053f10ea3e55

16:32 Dunno if that's what rhickey's going to use or not.

16:33 s/that's/either of those are/

16:33 RSchulz: Thanks.

16:34 aperotte: duck1123: the odd thing is that if I intentionally put an error in the hello.clj file, the call to compile catches it, but with the correct code it throws an IOException

16:35 mon_key: permissions?

16:36 duck1123: aperotte: I'm not sure then

16:36 aperotte: mon_key: I don't think so, everything's in my home directory

16:36 mon_key: aperotte: no maybe cuz ubnt sudo?

16:37 aperotte: mon_key: I'm not sure I understand what you mean

16:37 AWizzArd: (defn pipe [& functions] (apply comp (reverse functions)))

16:38 aperotte: duck1123: :( thanks for the help

16:38 mon_key: the class has to get written right? Does the process compiling have permissions to write to the dir on your path? Ubnt can be tricky that way... Just a thought.

16:40 aperotte: mon_key: oh ok, yeah, it should have permissions. All of the classpath folders and the clojure folder are in my home directory and shouldn't need sudo to write

16:41 AWizzArd: partner of (rem ..) is?

16:42 Chousuke: quot?

16:42 mon_key: stimpy

16:42 AWizzArd: Chousuke: thx

16:42 Chousuke: mon_key: no, stinpy.

16:42 mon_key: see...

16:45 lisppaste8: rhickey annotated #71709 with "recursive reduction with delay" at http://paste.lisp.org/display/71709#1

16:48 rhickey annotated #71709 with "reduction" at http://paste.lisp.org/display/71709#2

16:51 rhickey: Chouser: that works, yes?

16:53 mon_key: aperotte: are you using the OpenJDK?

16:53 Chouser: ah, interesting. I was aware of delay, but it's not really in my toolbox yet.

16:55 mon_key: aperotte: reason i ask is I was having similar probs. on SUSE until switching over to Sun...

16:55 aperotte: mon_key: nope, I'm using sun's jdk

16:55 mon_key: jdk 6 update 11

16:56 mmcgrana: namespaces can't :use each other, right?

16:57 duck1123: is there an easy way to compile every source file on my classpath, or do I have to do them one by one?

16:58 mon_key: :) Good luck with that then... have you inspected (System/getProperties) checked for trailing /'s in the classpath? Made sure your colon's are semis?

16:58 aperotte: sorry should say colon's *areN'T* semis?

16:59 Chouser: rhickey: looks good to me.

16:59 aperotte: mon_key: I didn't know about (System/getProperties) let me take a look

17:00 Chouser: duck1123: if you compile x and x requires y, y will also be compiled.

17:00 mon_key: aperotte: hehehe Got that From Stu Halloway's beta .pdf - helping me alot

17:01 Chouser: aperotte: has anyone asked you to paste the whole stack trace?

17:02 aperotte: Chouser: nope, but the only thing that prints after I call compile is java.io.IOException: No such file or directory (hello.clj:1)

17:02 mon_key: where can I get that pdf?

17:02 Chouser: aperotte: (.printStackTrace *e) and paste the results, if you don't mind.

17:03 duck1123: Chouser: Are you sure about that? I compiled a ns, and only that ns got compiled

17:03 Chouser: it certainly used to be true. let me check again.

17:03 duck1123: unless that's something's changed since I last built

17:05 aperotte: Chouser: http://paste.lisp.org/display/71712

17:05 Chouser: duck1123: it compiled a :require'd lib for me just now.

17:05 mon_key: aperotte: give the man $20 buck he deserves it: http://www.pragprog.com/titles/shcloj/programming-clojure

17:05 aperotte: mon_key: ohh, you're talking about the book. I've been meaning to get that

17:06 Chouser: duck1123: compile used to return a set of the namespaces compiled. It doesn't seem to do that now, but it still compiled my dependencies.

17:08 aperotte: did you say you were copying some example?

17:09 aperotte: Chouser: yes the example from the new compilation webpage on the clojure site, it's the first thing under "gen-class Examples"

17:10 Chouser: that stack trace looks to me like it's finding your hello.clj, but then failing during the 'ns' call.

17:11 aperotte: the only thing I have on line 1 is (ns clojure.examples.hello (:gen-class))

17:11 Chouser: ah, createNewFile -- double check your directory names, esp. for *classes*

17:13 Lau_of_DK: Can somebody bring me up to speed on TCO? In saying 'jvm does not do TCO' what is the implications?

17:14 AWizzArd: Lau: recursive function calls

17:15 Chouser: If Clojure had TCO, ((fn foo [] (foo))) would be an infinite loop. Instead it overflows the heap.

17:15 duck1123: Chouser: I must have an old version. I get the set of namespaces

17:15 AWizzArd: Lau_of_DK: the problems come when several functions call each other recursively.

17:16 duck1123: mine's from 11/26

17:16 Chouser: 4 versions on that date.

17:16 Lau_of_DK: Ok, thanks AWizzArd and Chouser

17:16 aperotte: Chouser: the classes directory I should be pointing to in the classpath is clojure/target/classes no?

17:17 Chouser: 18 versions since that day.

17:19 aperotte: *compile-path* defaults to "classes", which means ./classes/

17:20 aperotte: so unless you've changed that value, you should make sure you have a writable subdirectory named "classes" in your current working directory when you start clojure.

17:20 RSchulz: The gist of a "tail call" is one in which none of the local state (local variables) of the function need to be used again. That means the code can just jump back to the beginning of the function and reuse the current stack frame. In a generically recursive call, a new stack frame is required.

17:20 aperotte: Chouser: ahh, ok let me try again

17:20 Chouser: also make sure you have "./classes" in your classpath.

17:20 RSchulz: Tail-call optimization means detecting (or being told) the tail-call status of a recursive invocation and skipping the new stack frame creation.

17:21 Java does not accommodate this (as Lisps often do), so it's up to the language and / or the programmer to bridge the gap.

17:26 mon_key: Lau xah lee (love him or leave him) has a nice discussion on TCO








17:26 Chousuke: hmm

17:26 mon_key:



17:26 sorry about that. http://xahlee.org/UnixResource_dir/writ/tailrecursion.html

17:26 Chousuke: that discussion must be between zen masters.

17:28 aperotte: Chouser: woohooooo! compilation successful

17:29 Chouser: I was confused about the location of the classes folder and its inclusion in the classpath

17:30 Chouser, duck1123, mon_key: thank you!

17:30 RSchulz: It's always easy to rail against "jargon," but every profession has its argot and it's necessary. Otherwise, we'd communicate in some kind of low-level, perfectly unambiguous "Newspeak..."

17:31 mon_key: RSchulz: That particular `Xah' has positive ramifications for Clojure, trampolines, recur, etc.

17:32 RSchulz: OK. I'm still reading it, but I tend to be pretty skeptical of missives about language and vocabulary per se.

17:33 Of course, I'm refraining from commenting on the many ungrammatical uses of English in this particular individual's writings...

17:33 It would be very rude to even allude to them.

17:33 Wait...

17:37 mon_key: Rschulz: ... I just got that :)

17:42 RSchulz: So... He wants to expunge jargon. To that end he proposes replacing "tail recursion" with "linear recursion."

17:43 Woo-Hoo! Clarity and logic triump!

17:43 Chouser: constant-space recursion

17:43 RSchulz: (If not my spelling and / or typing.)

17:44 And as we progress towards a complete and unambiguous noun phrase, we see why humans need arbitrary labels for their complex thoughts.

17:45 It's the same deal with "patterns." The point is that they capture complex concepts with simple titles that (naturally) do not fully express those concepts. Nothing less than the full exposition of the concept could do that!

17:47 Chousuke: replacing tail recursion with another term would just create more confusion than it'd do away with :/

17:48 it's wrong to complain about established meanings of terms, or to say they are incorrect. If they are established meanings, they are by definition correct :P

17:48 aperotte: when using swank, if I use the keybinding C-x C-e on a call to (ns ...), the repl doesn't switch namespaces, is that the case for everyone?

17:48 mon_key: Rschulz: It is interesting to consider Xah's linguistic cultural heritage in lieu "The full exposition of the concept" - e.g. Eastern idiomatic languages

17:49 RSchulz: I can't speak to that, as someone who only speaks English. (In my defense, I did study German for three years in high school and Mandarin for two years in college.)

17:49 mon_key: aperotte: it is the case for my current setup

17:50 RSchulz: However, I'm not sure the particular language one speaks constitutes an argument or counter-argument for a particular technical argot.

17:50 aperotte: mon_key: thanks, just wanted to make sure it wasn't just me

17:50 mon_key: aperotte: I think i found a kludge this afternoon. Still working on it.

17:51 RSchulz: After all, Xah ("he?" "she?") did argue for replacing "tail recursion" with "linear recursion." This is an almost meaningless distinction, given the fact that the concept is far too complex to be captured in any two words, especially if one is fixed as "recursion."

17:52 aperotte: mon_key: great! I would offer to help, but my emacs skill level would probably make me more of a hindrance than help

17:53 mon_key: mon_key: :) it's not my kludge. I'm `borrowing' - i'll paste it over once i know.

17:54 RSchulz: Chousuke: I just noticed your last two posts. I agree fully.

17:56 mon_key: RShulz: I think he is advocating for, "optimized implementation of linear recursion" - Not advocating this position. Just thougth it had relevance to Clojure stylee.

17:58 RSchulz: mon_key: Use RS<tab>, then you don't have to type my whole name, risking misspellings...

17:58 aperotte: mon_key: I haven't tried copying his setup but bill clementson posted about his setup at http://bc.tech.coop/blog/081205.html ... I'm going to give it a try sometime. Gotta go, but thanks again for the help

17:58 RSchulz: (My dad taught me to be proud of my name...)

18:02 And, as if by coordinated effort, the same misspelling appears on the mailing list...

18:02 Lau_of_DK: Did you guys know, that there's actually a plugin for ERC, which automatically makes a lisp-paste if you paste to much raw code to the channel? :)

18:02 mon_key: RSchulz: Sorry :( (...my name...) He teach you about named-entity recognition? I need all the help i can get on that one :P

18:03 Chousuke: Lau_of_DK: :P

18:03 RSchulz: No. He just tought be to be proud of being a Schulz. It's just a name, but it's our name...

18:03 Chousuke: I think it's probably the most generic german name there is.

18:05 Lau_of_DK: I dont know googlegroups very well, but is it possible to add some filtering possibilities which automatically filter out spam and french ?

18:07 rottcodd: Lau_of_DK: there is lisppaste.el

18:08 RSchulz: Generic!? How dare you! ... Where I come from most of 'em are Schultz.

18:09 I understand it means "protector" and is also etymologically related to the first S in the infamous SS...

18:09 What can I do? What can I say? I'm a Schulz... In name, at least.

18:09 Lau_of_DK: hiredman: Can we modify clojurebot so that it automatically does a dictionary lookup on RSchulz's sentenses?

18:10 mon_key: dictserv.el :)

18:10 RSchulz: Gack! Try Google. You'll get tens of thousands. I'm borderline logorrheic...

18:11 Lau_of_DK: haha

18:11 I gotta hit the sack, Have a good weekend all

18:12 RSchulz: Ciao, Lau.

18:16 duck1123: when doing gen-class, do I need to specify what exceptions my fns throw?

18:16 and if so, how would I do that

19:19 RSchulz: OK. I'm officially no longer going to read any of Xah Lee's articles. He is clearly obsessed with words to the ultimate detriment of useful communcation. I don't believe there is enough substance, if any, in his polemics to make them worth the time it takes to read them.

19:20 AWizzArd: Xah believes like Wolfram, that Mathematica is the best programming language available.

19:21 RSchulz: ! Why didn't someone tell me that before I spent any time at all reading his stuff?

19:21 AWizzArd: Damn, and he writes so much. Well, that is the tricky part.. people who haven't seen him before may be tricked into thinking at first that he is doing serious posts.

19:22 RSchulz: That can't last long. Volume / quantity does not equal quality. Most people know that.

19:24 Chousuke: I tend not to take seriously people who write a lot but don't bother to pay attention to grammar or their typing :/

19:25 AWizzArd: It depends.. if RSchulz is writing something long I would probably be interested. But Xah.. no thanks.

19:26 Chousuke: Well, RSchulz does not seem to be making crude grammar errors all the time.

19:26 RSchulz: Well, I went through this with Lau (privately). I don't tend to just write stuff. I respond, but don't just fire off my random thoughts.

19:26 I think the world is better that way.

19:27 AWizzArd: ;-)

19:30 Chousuke: I'll agree that English isn't the easiest language to learn, but if I were to write something I simply couldn't publish rants full of typos or grammar errors. I'm too much of a perfectionist :/

19:31 RSchulz: There's an aphorism: "Better to remain silent and be thought a fool than to speak and remove all doubt."

19:31 Chousuke: heh.

19:32 RSchulz: Which, of course, is somewhat at odds with "There's no such thing as a dumb question."

19:32 We just like to keep our options for judging people open.

19:34 Chousuke: A question is never dumb if it stems from genuine desire to learn I suppose.

19:34 RSchulz: Yes. That's the point.

19:35 But one does expose oneself to ridicule if the question is posed in a setting where it discloses fundamental ignorance.

19:35 You've just got to be able not to care if anyone knows you're a rank newbie.

19:35 I know I don't. Not usually...

19:40 Chousuke: Occasionally I've helped people trying to learn to program. Many are capable of understanding, but there have been some who even after careful explaining are unable to understand how a simple loop works.

19:41 RSchulz: I've occasionally thought about how I'd try to teach programming. I took to it so effortlessly that it's hard to imagine someone not immediately grasping the basics.

19:42 AWizzArd: Can one have only one of #{:when :while} for each binding form inside a (for ...)?

19:43 (for [x (range 20) :when (> x 8) :while (zero? (rem x 2))] x) doesn't work. When I remove the :when or the :while block it works.

19:44 duck1123: It's odd, but I am able to decompile many different class files, but not the ones generated by clojure

19:44 RSchulz: I'm not sure. They seem compatible. One determines the termination while the other determines when the body expr is evaluated. But the wording of the doc suggests one or the other.

19:44 Have you tried using both?

19:45 duck1123: What are you using to decompile?

19:45 It may make assumptions about the source of the bytecodes that don't apply to Clojure.

19:45 Clearly, Clojure's bytecodes are acceptable to the JVM, or we'd get some low-leve exception from the bytecode verifier.

19:46 duck1123: I've tried jad and netbeans

19:46 AWizzArd: I tried using both, just copy my (for [x (range 20) :when (> x 8) :while (zero? (rem x 2))] x) example into a repl. But (for [x (range 20) :when (> x 8)] x) works, as well as (for [x (range 20) :while (zero? (rem x 2))] x)

19:46 duck1123: Tomcat seems to be rejecting my class file, that's the only reason I'm bothering to look into this

19:47 RSchulz: duck1123: What exception / error are you getting from Tomcat?

19:48 AWizzArd: duck1123: I have a similar problem, with Jetty+Rife.

19:48 RSchulz: AWizzArd: "unsupproted binding expression."

19:48 AWizzArd: RSchulz: yes.

19:48 But both work when they are alone.

19:48 RSchulz: It could be a bug / oversight or it could be intentional. I'd send a message to the list asking what the deal is.

19:48 AWizzArd: Yes oki, I will ask the list.

19:49 duck1123: RSchulz: I'm not getting any exceptions or errors. When I enable the lines in my web.xml, it removes my servlet

19:49 RSchulz: duck1123: Is it possible that the class in question does not implement the proper interface and / or extend the proper base class?

19:49 duck1123: I just updated my clojure, let's see if that helps

19:49 sean_____: Hello all. Has anyone tried to edit the wiki page lately?

19:50 RSchulz: Which of Tomcat's log files did you check? it makes two or three, and I've never quite figured out what goes into each of them.

19:50 sean_____: Do you mean the WikiBooks page(s)?

19:51 sean_____: RSchulz: Yep. I'm trying to make some edits because it's pretty out of date, but when I click the section edit link, it seems to think I want to delete most of the content

19:52 duck1123: RSchulz: apparently the wrong one. I'm seeing an error I need to investigate

19:52 RSchulz: The only thing I know is that according to Meikel B., they've instituted a policy that restricts update / requires review.

19:53 sean_____: Whatever they've done seems to make it impossible to make minor edits (i.e. anything less than a rewrite)

19:53 which makes a wiki useless :P

19:54 RSchulz: Yeah, it's perverse. I don't know anything about it, but you can check out the thread on the mailing list / Google Group Subject: "Bureaucracy has reached Wikibooks"

19:54 Chousuke: sean_____: I split up the wikibook

19:54 sean_____: make sure to edit the appropriate pages, *and* make sure you edit the draft version

19:55 I can't "approve" the split version so it's not shown by default

19:55 sean_____: Chousuke: How do I do that? When I click "edit" next to the relevant section, it gives me a "Draft" with all the content deleted.

19:56 Chousuke: sean_____: view the draft version and find the subpage you want to edit, and edit the section there.

19:57 http://en.wikibooks.org/w/index.php?title=Clojure_Programming&oldid=1343699 this is the split up book with links to the subpages.

19:58 or actually, this link http://en.wikibooks.org/w/index.php?title=Clojure_Programming&stable=0 ... should result in the same page though :P

19:58 someone needs to approve the change ;(

19:58 sean_____: Chousuke: *That* is what I needed. Thank you!

19:58 Chousuke: I hate the new "stable version" stuff too

19:59 apparently the draft version is shown by default if you're logged in though.

20:00 sean_____: I didn't want to bother logging in. I'm accustomed to making minor edits without that (admittedly small) hassle. I'm just correcting all the little mistakes I find while setting up clojure :).

20:00 RSchulz: Who acts as editor for these revisions? Is it even someone affiliated with Clojure??

20:00 Chousuke: I don't know.

20:00 probably not.

20:00 RSchulz: It sounds a bit crazy...

20:01 Ha! Now I know AWizzArd's real name!

20:01 ...Presumably...

20:07 Chousuke: you /whois'd him? :/

20:07 RSchulz: Ah. Actually, it's been there in the WHOIS output all along.

20:07 No. I correlated his question here with a posting on the list.

20:07 That just seems so much more clever...

20:08 Chousuke: Yes. Why do things the easy way...

20:08 RSchulz: Exactly!

20:08 Chousuke: but: oh crap

20:08 it's already 3 AM here ;(

20:08 RSchulz: "Oh, laddy! You've got a lot to learn if you want people to think of you as a miracle worker!" --Scotty to Geordi

20:08 Chousuke: I should've been sleeping hours ago.

20:09 RSchulz: Definitely. I'm an early riser. I'm up at 5:30 AM.

20:13 Chouser: AWizzArd: you can have :when and :while in the same 'for' as long as they're on different expressions

20:13 AWizzArd: yes

20:13 But I mean for the same binding

20:14 Chouser: that's not currently support

20:14 works for doseq, though.

20:15 AWizzArd: Can you show how to do it for (for [x (range 1 20) :when (> x 8) :while (< 0 (rem x 13))] x) ?

20:16 Where does one place the :when and :while inside doseq?

20:17 RSchulz: Isn't (doseq ...) syntactically the same as (for ...)?

20:18 AWizzArd: indeed

20:18 (doseq [x (range 1 20) :when (> x 8) :while (< 0 (rem x 13))] (prn x))

20:22 Chouser: you can cheat even with 'for'

20:22 (for [i (range 9) :when (odd? i) x [i] :while (< i 5)] i)

20:28 RSchulz: Isn't '(1 3) simpler?

20:39 AWizzArd: btw, isn't there this type unsigned long in java?

20:40 (class 4000000000) ==> BigInteger

20:42 RSchulz: Java has no unsigned types, other than byte (implicitly unsigned).

20:44 AWizzArd: okay anyway, then it should be long at least, no?

20:44 RSchulz: "It?"

20:47 you mean 4,000,000,000? By asking for a class, you force Clojure to produce an reference type, and it doesn't bother with java.lang.Long.

20:48 AWizzArd: although for 2 billion it returns an Int

20:51 RSchulz: Apparently it just converts longs and Longs to BigInteger.

20:51 There may be a reason for it, but I don't know what that might be.

21:06 Chouser: RSchulz: oh, good point! next time I'll write '(1 3)

21:28 lsmith: Does the :gen-class option in (ns actually work for anyone?

21:28 Chouser: yes

21:29 lsmith: svn? or the archive on sourceforge?

21:29 Chouser: svn

21:29 lsmith: alright.

21:29 Chouser: the latest "release" doesn't have :gen-class for the ns macro

21:30 lsmith: It does, but it doesn't behave

21:31 Chouser: ah, yes. you might actually be able to just about any function name in 'ns' but most won't behave

21:31 I'd recommend checking (doc ns) before trying to use any particular option.

22:12 spaceman_stu: hey guys. newbie emacs question: what's the best way to kill my slime process if I start an infinite loop?

22:33 rottcodd: spaceman_stu: does slime-interrupt work?

22:34 spaceman_stu: I haven't tried taht. Sounds like it's what I'm looking for though. Thanks

22:42 rottcodd: slime-interrupt doesn't seem to work for clojure, slime-restart-inferior-lisp is another way to go

22:53 holmak: yah

22:54 Disregard that, had focus in the wrong window. Sorry.

23:56 arohner: does anyone remember the name of the paper that rhickey likes to link, "out of the turing tar pit" or something like that?

23:56 I finally have time to read it, and I can't remember the name well enough to google for it

23:56 gnuvince_: I think I have it...

23:58 arohner: sorry, I must have deleted it

23:59 arohner: I think I found it, but the link appears broken

23:59 "out of the tar pit"

Logging service provided by n01se.net