#clojure log - Sep 14 2009

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

2:59 lowlycoder: is there anyway to use vim keybindings in enclojure?

3:28 LauJensen: Top o' da morning gents

3:42 Fossi: hi

4:33 LauJensen: (defn fac [x] (if (zero? x) 1 (* x (fac x))))

4:34 hiredman: you are missing a dec

4:34 LauJensen: yes, add the dec, then help me understand why I cant replace the last expression with (* x (recur (dec x))

4:34 If I wanted to add tail recursion that is

4:35 hiredman: that's why you make a factorial sequence generating function use nth

4:35 Chousuke: the expression is not tail recursive.

4:36 LauJensen: Chousuke: No the question is, how would I make it so ?

4:37 Chousuke: the fac function needs an accumulator parameter for that.

4:37 and then you just need to return the accumulator at the end of the recursion

4:37 LauJensen: ah yes

4:37 Thanks

4:48 Can someone explain currying real quick for me ?

4:50 Chousuke: isn't it the approach that all functions take only one parameter?

4:50 ie. a function that "has two parameters" really takes just one and returns a function that takes the other parameter.

4:50 LauJensen: Currying is the process of transforming a function that takes multiple arguments into a function that takes just a single argument and returns another function if any arguments are still needed. f :: a -> b -> c

4:51 Thats from the Haskell wiki - No different for Clojure I hope ?

4:51 hiredman: well, haskell currys automagically

4:51 clojure doesn't

4:53 Chousuke: currying also neatly explains why the type notations in haskell are what they are :)

4:54 I really had trouble with them until I understood the "one argument only" idea :/

4:54 liwp: if you wanted to write non-curried Haskell you could use tuples everywhere: f :: (a, b) -> c

4:54 (not saying it's a good idea ;-)

4:54 hiredman: ,((((curry +) 1) 2) 3)

4:54 clojurebot: #<sandbox$uncurry__2574$uc__2576 sandbox$uncurry__2574$uc__2576@1860045>

4:54 hiredman: ,(((((curry +) 1) 2) 3))

4:54 clojurebot: 6

4:55 liwp: but that's how the authors approach currying and higher order functions in The Little MLer and it works quite well in the book

4:56 LauJensen: Alright thanks

4:56 Then just to clear our factorial discussion up, this is the way to implement a durable factorial

4:56 (defn fac ([x] (fac 1 x))[acc x] (if (zero? x) acc (recur (* x acc) (dec x))))

4:58 liwp: looks good

4:59 LauJensen: So sad that the JVM doesn't have tail recurrence

4:59 liwp: I really like how defining the same fn with different arities lends itself to defining helper functions

4:59 LauJensen: indeed. Hopefully they'll fix it at some point, but I'm not holding my breath

4:59 LauJensen: 'lends itself' ?

5:00 liwp: you can use the feature to define helper methods

5:00 LauJensen: Yes thats true

5:01 liwp: in Haskell you'd probably define the two arg helper as an internal definition in a where expr

5:01 LauJensen: In the danish IT press, it's what we got hammered for. Verbosity. But I think the people doing the hammering spoke for an inferior intellectual viewpoint.

5:01 liwp: verbosity? Surely that's less verbose than doing the same thing (method overloading) in Java?

5:02 LauJensen: See comment regarding IQ of critics

5:08 liwp: hehee

5:08 rfgpfeiffer: ,((comp (partial apply *) (partial range 1) inc)) 5)

5:08 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$inc

5:09 liwp: ,((comp (partial apply *) (partial range 1) inc) 5)

5:09 ,((comp (partial apply *) (partial range 1) inc) 5)

5:09 clojurebot: 120

5:10 rfgpfeiffer: * is tail recursive enough

5:15 LauJensen: ,((comp (partial apply *) (partial range 1) inc) 5000)

5:15 clojurebot: 42285779266055435222010642002335844053907866746266467488497824021813580527081082006908990478717063875370847466573006854458784860666838127363372108937727876312793903630584621606439044789869822398719297088962116126529683217755003992421968370314690726447287878979040475488416221522667192841096923691044956597173635294840022384038112064482023085767110450230617489475542830976178172404080532480992780932878405548619936454829121187

5:15 LauJensen: Wow

5:15 How did you come up with that rfgpfeiffer ?

5:16 rfgpfeiffer: well that's how i wold write it

5:17 hiding recursion

5:17 LauJensen: Can you explain the steps please?

5:17 liwp: you create a seq of the number you want to multiply together: (range 1 (inc n))

5:18 and then you apply * to the seq

5:18 rfgpfeiffer: very nice

5:18 rfgpfeiffer: (defn fac [n] (apply * (range 1 (inc n))))

5:18 liwp: ,(apply * (range 1 (inc 5)))

5:18 clojurebot: 120

5:18 LauJensen: ooh

5:18 rfgpfeiffer: and then I made it point-free

5:19 LauJensen: I'm amazed

5:19 That's a new mindset to me entirelyu

5:19 rfgpfeiffer: hiredman: can clojurebot refactor to point-free style like lambdabot?

5:20 LauJensen: Read http://github.com/raganwald/homoiconic

5:20 LauJensen: Will do

5:21 Chousuke: I don't like point-free style in Clojure.

5:21 most of the time it just doesn't work

5:21 as in, improve readability :P

5:23 rfgpfeiffer: There is a website about complicated implementations of factorial in Haskell

5:23 hiredman: ,(pl ((partial apply *) · (partial range 1) · inc 5))

5:23 clojurebot: 120

5:23 Chousuke: for example, the earlier point-free fac function is just ugly compared to the explicit defn (It's not the programmer's fault :))

5:24 hiredman: eh? ugly to you

5:24 Chousuke: all the comp and partial calls are just noise.

5:24 hiredman: #() is noise

5:24 Chousuke: no, it's not.

5:24 hiredman: comp is compose and partial is partial

5:24 Chousuke: but it doesn't even apply in this situation

5:25 liwp: Chousuke: I agree. I think point-free look a lot nicer in haskell

5:25 Chousuke: hiredman: yes, but using them obfuscates what teh function actually does

5:25 hiredman: Chousuke: #() is usually what is used instead of comp and partial

5:25 liwp: in Clojure / lisp the prefix syntax just makes it ugly

5:25 hiredman: Chousuke: no, it makes it clearer

5:25 the function is a composition of the other functions

5:26 the function is the partial application of this function to this argument

5:26 Chousuke: sorry, but how the hell is (comp (partial apply *) (partial range 1) inc) clearer than (apply * (range 1 (inc n)))

5:26 rfgpfeiffer: that is unfair

5:26 Chousuke: the latter reads "product of range from 1 to n"

5:26 rfgpfeiffer: it should be #(apply * (range 1 (inc %)))

5:26 Chousuke: rfgpfeiffer: well that's still much nicer.

5:27 rfgpfeiffer: yeah

5:27 hiredman: thats like, your opinion, man...

5:27 Chousuke: I can't understand how you think the point-free style better in this case.

5:28 the comp and partial calls tell nothing about what the function does.

5:28 LauJensen: How do you guys define point-free?

5:28 Chousuke: or what the code does.

5:28 liwp: ~google point-free style

5:28 clojurebot: First, out of 194000000 results is:

5:28 Pointfree - HaskellWiki

5:28 http://www.haskell.org/haskellwiki/Pointfree

5:28 Chousuke: unlike in, say (partial merge-with +) that I used earlier. that's small and simple and says "merge-with +"

5:29 liwp: LauJensen: another one on Stack Overflow: http://stackoverflow.com/questions/944446/what-is-point-free-style-in-functional-programming

5:29 rfgpfeiffer: ~google evolution of haskell factorial

5:29 clojurebot: First, out of 1500 results is:

5:29 The Evolution of a Haskell Programmer

5:29 http://www.willamette.edu/~fruehr/haskell/evolution.html

5:29 rfgpfeiffer: cool

5:29 LauJensen: Thanks guys, what a community :)

5:30 Chousuke: I'm just saying that while there are cases where point-free style is better, it doesn't really fit Clojure.

5:30 liwp: rfgpfeiffer: you can't port your factorial to haskell though because haskell doesn't have apply. You'd have to use reduce and that then makes the definition a bit more complicated

5:30 Chousuke: yeah, I agree

5:30 too much noise in a lot of cases

5:31 rfgpfeiffer: fac = foldr (*) 1 . enumFromTo 1

5:31 liwp: rfgpfeiffer: ok, fair enough ;)

5:32 Chousuke: that's already much better because of the implicit partials and . for comp :P

5:32 rfgpfeiffer: you could use reduce instead of apply in clojure too

5:32 LauJensen: rfgpfeiffer: You're git repo yields one question, whats 'chutzpah' ?

5:32 liwp: There was a post on the list recently that showed a use for point-free style that actually didn't look too bad: http://groups.google.com/group/clojure/msg/ae2c655c76a2b56b

5:33 But even there the reader must do a double take on the code IMHO

5:33 rfgpfeiffer: yeah of course, I just mean that having apply in clojure makes the factorial even nicer

5:33 rfgpfeiffer: LauJensen: what?

5:34 LauJensen: "He said he let her off on the grounds of novelty and chutzpah."

5:34 rfgpfeiffer: i mean it is a yiddish word that means boldness

5:34 but what repo

5:34 LauJensen: homoiconic

5:34 rfgpfeiffer: or ruthlessness

5:35 okay

5:36 liwp: is there a foldr1 in haskell... then you'd get fac n = foldr1 (*) $ enumFromTo 1 n

5:39 rfgpfeiffer: factorial should be in core.clj

5:39 so we have a shorter definition than haskell :)

5:40 hiredman: add a ! special form

5:41 rfgpfeiffer: On a more serious note: has anybody used java.nio and selectors with clojure?

9:45 crios: Hello, I'm studying the code in http://pastebin.com/m2dc9a491. How: (bench-fn (fn []> (+ 1 2))) is different from: (bench-fn (fn [] (+ 1 2))) ?

9:45 what does it mean "fn []>" syntax ?

9:52 AWizzArd: crios: a typo

9:58 Chousuke: interestingly enough the code works like that too :)

9:59 the > is just ignored.

9:59 because it's just the > function :P

10:02 crios: I don't understand

10:02 Chousuke: crios: it's the same as:

10:02 ,(do > 5)

10:02 clojurebot: 5

10:03 Chousuke: it just gets ignored because it's not a function call, it has no side-effects and it's not the last expression in the body so it doesn't get returned either.

10:10 Fossi: wouldnt work with #( though

10:11 Chousuke: well, that's because #( is not (fn :P

10:11 Fossi: or it would return true then

10:11 Chousuke: hm

10:12 ,(> 3)

10:12 clojurebot: true

10:12 Chousuke: I guess that's useful for checking if a seq of numbers is sorted.

10:14 AWizzArd: ,>

10:14 clojurebot: #<core$_GT___4136 clojure.core$_GT___4136@18b995c>

10:34 crios: so does > character, in that contest, is a of real value?

10:39 Fossi: no, it doesn't do anything senseful. it's a "bug" in the book, as the first hit on google (the errata) also tell

10:42 crios: Fossi, here http://www.pragprog.com/titles/shcloj/errata ?

10:42 Fossi: yes

10:43 see 233 or such

10:46 achim: crios: if you don't understand what's going on, imagine what a call to foo would return in this case: (defn foo [] 3 5 < :bar + (/ 5 2) "hey" (+ 1 3)). that's exactly what's going on with []>, it only looks a bit weirder

10:53 crios: achim, I'm not sure whether your example helps :)

10:53 *how* that help (I'm a newbe)

10:54 in your example '<' evaluates to <, being just a symbol, right?

10:56 achim: yes, it evaluates to the < function. functions are values just like numbers and strings are

10:56 Chouser: ,[1 2 :a :b "hello" <]

10:56 clojurebot: [1 2 :a :b "hello" #<core$_LT___4049 clojure.core$_LT___4049@dd23cf>]

10:56 achim: the body of a function can contain multiple expresssions. each of those will be evaluated, but only the result of the final one will be returned

10:57 crios: ,(<)

10:57 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$-LT-

10:58 crios: where < apply here : (defn foo [] 3 5 < (+ 1 3))

10:58 liwp: ,(do (+ 1 1) (+ 1 2) (+ 1 3))

10:58 clojurebot: 4

10:58 liwp: crios: only the last form gets returned to the caller

10:58 AWizzArd: crios: everything is ignored, only the last form gets returned

10:58 achim: crios, it isn't applied, it's just there

10:58 liwp: i.e. (+ 1 3) -> 4

10:59 AWizzArd: ,1 2 3

10:59 clojurebot: 1

10:59 AWizzArd: fine :)

10:59 liwp: all the other forms get also evaluated, but the return values do not get shown to caller

10:59 crios: It is not returned, but is it evaluated?

10:59 liwp: yep

10:59 ,(do (+ 1 1) (+ :a :b) (+ 1 3))

10:59 clojurebot: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number

11:00 liwp: so the (+ :a :b) fails

11:00 even though its return value (3 in the previous example) did show up in the output

11:00 Chouser: did not :-)

11:00 liwp: ,(do (println 1) (println 2 (+ 1 3))

11:00 clojurebot: EOF while reading

11:01 liwp: Chouser: uhh, yeah, sorry

11:01 ,(do (println 1) (println 2) (+ 1 3))

11:01 clojurebot: 4

11:01 1 2

11:01 crios: in (defn foo [] 3 5 < (+ 1 3)) , how is < evaluated ? as (< x ) ?

11:01 achim: crios: simpler example (defn foo [] 1 2) -> first 1 is evaluated, but not returned since not the final expression, then 2 is evaluated and returned

11:01 liwp: ,<

11:01 clojurebot: #<core$_LT___4049 clojure.core$_LT___4049@dd23cf>

11:01 Chousuke: crios: no, just <

11:01 crios: it's a function, so when evaluated you get the function object

11:01 liwp: it evaluates to the function <

11:02 (let [fn <] (fn 1 2))

11:02 crios: ,(doc <)

11:02 liwp: ,(let [fn <] (fn 1 2))

11:02 clojurebot: "([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically increasing order, otherwise false."

11:02 java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: nth not supported on this type: Integer

11:02 Chousuke: crios: in fact, that's what happens even when it's (< 1 3); the < is evaluated, yielding the fn, which is then called :)

11:02 liwp: ,(let [f <] (f 1 2))

11:02 clojurebot: true

11:02 achim: crios: (defn bar [] > 2) -> first "<" is evaluated (but not called!), but not returned, then 2 is evaluated and returned

11:03 crios: I would guess that the < evaluation should fail, becouse < expects twos arguments at least

11:03 Chousuke: crios: no. it's not being called

11:03 ,(<)

11:03 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$-LT-

11:03 achim: if you don't put parentheses around a function symbol, it doesn't do anything, it's just "named". just like a number doesn't do anything

11:03 Chousuke: that fails

11:03 but

11:03 clojurebot: http://clojure.org/contributing

11:04 Chousuke: ,<

11:04 clojurebot: #<core$_LT___4049 clojure.core$_LT___4049@dd23cf>

11:04 crios: yes,

11:04 (resolve <)

11:04 ,(resolve <)

11:04 clojurebot: java.lang.ClassCastException: clojure.core$_LT___4049 cannot be cast to clojure.lang.Symbol

11:04 Chousuke: if just evaluating < would fail, then (apply < [1 2 3 4]) would fail as well :/

11:05 crios: good point :)

11:05 Chousuke: but really, it's no different from 5 or "foo", as a value

11:06 crios: they are just symbol...

11:06 Chousuke: crios: well, when it's evaluated it's no longer the symbol.

11:06 you get the function

11:08 konr_: Hmm, what's the difference between compojure and conjure? Has anyone used them?

11:09 crios: Fossi are you italian? do you know any Clojure user group in Milan area?

11:11 Fossi: more like ,(resolve '<)

11:11 crios: no. i'm german. what makes you think i'm italian? :D

11:17 crios: your nickname is very similar to ours real surnames :D

11:18 pardon anyway, fossi

11:20 raphinou_: is there a way to display the :doc of a namespace like it exists for functions doc strings?

11:21 Chousuke: ,(:doc ^*ns*)

11:21 clojurebot: nil

11:21 Chousuke: hm. no doc for that namespace I guess.

11:21 Chouser: (doc clojure.contrib.seq-utils)

11:21 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.seq-utils

11:21 Chouser: hmph. clojurebot doc is not the same as core doc

11:22 rfgpfeiffer: crios: were you at ELS?

11:22 crios: no rfgpfeiffer. What is ELS ?

11:23 rfgpfeiffer: European Lisp Symposium

11:23 crios: no

11:23 rfgpfeiffer: was in Milano this Year

11:23 Chouser: oh, I think the metadata on namespaces disappears when compiled to .class files.

11:24 crios: :( - one more problem of being a newbe in clojure!

11:24 rfgpfeiffer: everybody said "clojure is cool but i have not yet have had the time to run it"

11:24 crios: so I'm pleased to not be there! ;)

11:25 to much people, in these days, like buzz / fashion words! But how many try what adulate?

11:25 Chouser: ~ticket #130

11:25 clojurebot: {:url http://tinyurl.com/ndkovn, :summary "Namespace metadata lost in AOT compile", :status :new, :priority :normal, :created-on "2009-06-19T04:47:33+00:00"}

11:25 raphinou_: Chouser: (doc clojure.test) gives nil

11:32 Chousuke: raphinou_: looks like it's not documented

11:33 raphinou_: Chouser: clojure.test namespace definitely has :doc : http://github.com/richhickey/clojure/blob/270185aba54cef1d8ce59ec347b5623f2e502afe/src/clj/clojure/test.clj

11:33 stuartsierra: What Clojure tutorial should I give to CS students who know neither Lisp nor Java?

11:34 raphinou_: it's as a comment in the file and as :doc attached to ns (strange to have twit twice btw)

11:34 rfgpfeiffer: stuartsierra: timeframe?

11:34 Chousuke: hm, so the mock library went into contrib? :/

11:35 stuartsierra: rfgpfeiffer: shorter than a book, but a thorough trip through the language

11:35 raphinou_: that's an artifact of when someone added metadata to the ns, copying my comments

11:37 Chousuke: hm.

11:37 clojure-mode syntax highlighting seems to break on mock.clj :P

11:38 raphinou_: ok

11:44 LauJensen: Anybody gearing up for the Alioth Shootout?

11:48 crios: coming for a moment (forgive me) to the expression (def [] 2 < (+ 1 2)), the < is evaluated to the fuction name by means of the fourth rule into http://clojure.org/evaluation , that is "A lookup is done in the current namespace to see if there is a mapping from the symbol to a var"

11:49 Fossi: LauJensen: i'd guess that running on a vm will alwazs slow you down compared to machinecode compiled languages :)

11:49 so what's the point?

11:49 LauJensen: Notice Scala in the top 5 ?

11:57 Fossi: well, i guess it depends a lot on how you measure

11:57 seems they have measurements for java with and without startup and first run

12:16 tmountain: stuartsierra: http://java.ociweb.com/mark/clojure/article.html ?

12:17 stuartsierra: tmountain: thanks, that's one I hadn't seen before

12:19 tmountain: stuartsierra: no problem. it's my go to document when introducing people to clojure

12:19 clojurebot: People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....

12:21 michael_teter: lol

15:31 crios_: ,>

15:31 clojurebot: #<core$_GT___4136 clojure.core$_GT___4136@18b995c>

15:35 Chouser: crios_: exactly

15:46 crios_: ,(defn foo [] > (+ 1 2))

15:46 clojurebot: DENIED

15:47 Chouser: clojurebot won't let you def stuff.

16:08 crios_: After carefully reading (I hope!) http://clojure.org/evaluation, this is my understanding:

16:08 Regarding the expression: (do > 5) => 5

16:08 'do' is a special form, which evaluates all the expressions.

16:08 > is evaluated to an instance java class, for the second rule in http://clojure.org/evaluation: "A lookup is done in the current namespace to see if there is a mapping from the symbol to a class. If so, the symbol is considered to name a Java class object". In fact, > returns an instance class of core$_GT___3996 clojure.core$_GT___3996 type:

16:09 ,>

16:09 clojurebot: #<core$_GT___4136 clojure.core$_GT___4136@18b995c>

16:09 crios_: 5 is evaluated to 5, and returned as the expression value.

16:09 [ah, here the GT internal class has a diffent name - implementation detail :)]

16:10 I think all Clojure should condensate into http://clojure.org/evaluation rules

16:11 :)

16:12 core$_GT___4136 clojure.core$_GT___4136 is an internal class, inside clojure.jar

16:14 hiredman: http://www.thelastcitadel.com/images/clojure.png

16:19 not as nice as I was hoping for, since, of course, clojure.core has a very minimal ns form

16:31 crios_: what is it hiredman? an "import" visual tracking?

16:31 hiredman: it's a trawl of information from ns forms in my local checkout of clojure

16:32 crios_: how has you get it?

16:32 hiredman: http://github.com/hiredman/clojure-dependency-grapher

16:32 it outputs stuff in the graphviz dot format

16:33 crios_: cool!

16:35 it would worth explain better, in the README file, the lib purpose :)

16:37 hiredman: the purpose is to make pretty pictures

16:38 crios_: "script reads the ns forms from clojure files in a directory and writes out a graph of dependencies"

16:38 well, I think it is very useful

16:39 every tool which can give an higher overview on the code worth the effort

16:39 hiredman: I updated the readme and pushed, just hasn't shown up on the web ui yet

16:40 crios_: have you ever seen this: http://www.visualcomplexity.com/vc/project.cfm?id=261

16:40 or this: http://www.visualcomplexity.com/vc/project.cfm?id=262

16:40 ?

16:40 hiredman: I think I may have seen the first one somewhere

16:43 crios_: presenting code as art is a great effort

16:43 someone also tries to converting it into music: www.codesounding.org/indexeng.html ;)

16:44 LauJensen: ~def time

16:48 danlarkin: Hello clojure folk

16:48 LauJensen: Hey Mr. Dan

16:49 danlarkin: I have a probably stupid question

16:49 but in my repl \u066f is coming back as \?

16:49 ,\u066f

16:49 clojurebot:

16:49 danlarkin: perhaps it's a factor of my environment

16:50 hiredman: do you have a font with that glyph?

16:50 http://www.fileformat.info/info/unicode/char/066f/index.htm

16:51 hmm

16:51 danlarkin: hiredman: yeah it's not the font

16:52 hiredman: clojurebot: logs?

16:52 clojurebot: logs is http://clojure-log.n01se.net/

16:52 Chousuke: funky

16:52 iTerm renders that character *before* the \...

16:53 hiredman: http://clojure-log.n01se.net/date/2009-09-12.html#19:28 <-- hard to follow because the logger doesn't handle utf8

16:53 user=> (.getEncoding *out*)

16:53 "Cp1252"

16:53 user=>

16:53 :(

16:54 danlarkin: Hmmm mine is MacRoman

16:55 hiredman: ,(.getEncoding *out*)

16:55 clojurebot: java.lang.IllegalArgumentException: No matching field found: getEncoding for class java.io.StringWriter

16:55 hiredman: oh, right

16:55 crios_: probably also a System.out.println("\u066f") in plain old Java does not output the arabic char, doesnt'it?

16:57 danlarkin: crios_ correct, just tried it and I get a ? back from java

16:59 hiredman: the -Dfile.encoding=UTF8 seems to do the trick

16:59 if you have a UTF8 locale setup it seems to default to UTF8 anyway

17:00 crios_: ,(System/getProperty "file.encoding")

17:00 clojurebot: java.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding read)

17:01 crios_: confirm hiredman

17:01 here user=> (System/getProperty "file.encoding") => "UTF-8"

17:01 java defaults to the OS charset

17:02 unless you use -D

17:02 BTW: http://www.websina.com/bugzero/kb/java-encoding-charset.html

17:04 logs?

17:04 clojurebot: logs?

17:04 clojurebot: logs is http://clojure-log.n01se.net/

17:11 danlarkin: well so that's pretty annoying

17:12 I don't think I can change my default encoding on a OS X

17:12 Chousuke: hm

17:12 there should be a way to set systemwide properties

17:14 hiredman: http://www.rift.dk/news.php?item.7.6

17:14 http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/locale.1.html

17:15 crios_: yes there is: java -Dfile.encoding=UTF-8

17:16 starts your REPL with such property

17:16 it should work

17:16 hiredman: if osx still uses bsd's setup stuff, there is always .login_conf

17:17 http://gist.github.com/186934

17:19 crios__: IMHO you can change just the JVM property , not the whole OS configuration

17:19 danlarkin: crios_: I don't want to set it every time

17:19 and in every place I launch the jvm

17:19 hiredman: and everything should be set for utf-8 anyway

17:20 crios__: as you like :) just saying what suffice

17:24 danlarkin: well I have set LANG and LC_ALL to en_US.UTF-8 and still java has my file.encoding as MacRoman

17:24 I am annoyed because it did not used to be this way

17:24 I noticed this because of a test failing... but it used to pass

17:24 hiredman: hmmm

17:25 are you sure the LANG variables are set?

17:26 danlarkin: Tarragon:~ dan$ echo $LANG, $LC_ALL

17:26 en_US.UTF-8, en_US.UTF-8

17:27 Chousuke: there's the environment.plist thing. what about that? :)

17:28 technomancy: Chousuke: when all else fails, edit an XML file!

17:28 ~xml

17:28 clojurebot: It's greek to me.

17:28 Chousuke: technomancy: and then the rest will fail too

17:28 technomancy: ~xml is like violence; if it's not working, you're not using enough of it.

17:28 clojurebot: 'Sea, mhuise.

17:30 Chousuke: hm, no wonder it's popular then

17:30 hiredman: ~XML

17:30 clojurebot: XML is like violence; if it doesn't solve your problems, you're not using enough of it.

17:30 Chousuke: people are generally attracted to violence

17:30 as long as it's someone else.

17:31 hiredman: the switch to a derby backend should also take care of case sensitivity issues

17:31 technomancy: hiredman: nice; it echoes in the same case as you use in the query

17:31 hiredman: technomancy: no :( there are just two factions, XML and xml

17:31 the XML one already there

17:31 Chousuke: clojurebot uses a real database now?

17:31 hiredman: not yet

17:32 it's on my list of things todo

17:32 Chousuke: ~XmL is case-sensitive

17:32 clojurebot: You don't have to tell me twice.

17:33 technomancy: oh; hah

17:33 I think I added the all-caps one too.

17:35 hiredman: you did, in July

17:36 technomancy: great minds think alike!

17:42 Chouser: ~exceptions

17:42 clojurebot: http://paste.lisp.org/display/74305

17:42 Chouser: perfect!

17:43 hm. could be sorted.

17:45 crios__: what is pastelisp?

17:46 hiredman: lisppaste8: url?

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

17:47 crios__: is it a sort of paste bin?

17:47 futuranon: crios__: yes

17:47 crios__: ah

17:48 hiredman: it's a neat pastbin, because it comes with an irc bot

17:50 lisppaste8: crios pasted "try" at http://paste.lisp.org/display/87068

17:51 crios__: cool :)

17:51 how do you use it? to share code?

17:52 hiredman: to paste examples and problems

17:52 Chousuke: I don't like the lisp pastebin though. it doesn't colourise the source properly :(

17:52 I prefer gists

17:53 hiredman: http://paste.lisp.org/list/clojure

17:53 http://delicious.com/clojurebot/pastbin

18:18 crios__: is there an ANTLR grammar for Clojure? http://code.google.com/p/clojure-antlr-grammar/ seems empty

18:18 clojurebot: logs?

18:18 clojurebot: logs is http://clojure-log.n01se.net/

18:27 stuartsierra: crios__; there's an old version somewhere in the google code SVN that Rich Hickey started and abandoned.

18:29 crios__: abandoned? why?

18:31 Chousuke: that grammar doesn't seem that old. only about 6 months :P

18:31 the one on the page you posted.

18:33 crios__: have you checkout the code? http://code.google.com/p/clojure-antlr-grammar/downloads/list is empty

18:33 hiredman: http://code.google.com/p/clojure-antlr-grammar/source/browse/

18:33 crios__: ah ok

18:33 http://code.google.com/p/clojure-antlr-grammar/source/browse/src/Clojure.g

18:33 yes

18:34 beutdeuce: I have a question regarding clojure and maven. i ran mvn install and a jar file was created successfully;however, I am having trouble running the jar file. Can anyone help as to what I can do to successfully run that jar file?

18:35 hiredman: define trouble

18:35 beutdeuce: no class def found. no main class found

18:35 hiredman: what is inside the jar?

18:36 beutdeuce: does it matter? Canit i use -cp ?

18:36 hiredman: well, if the classes are not inside the jar, that would explain why there is no class def found

18:37 beutdeuce: doesnt mvn install package the classes into the jar automatically?

18:37 i can check whats inside anyway

18:37 h/o

18:37 hiredman: a jar file is just a zip file

18:37 beutdeuce: i know

18:38 hiredman: I have no idea, I've never used maven

18:38 so unzip it

18:38 beutdeuce: k, there is META_INF, and there is clojureworld. Inside clojureworld, there is main__init.class and main$main__1.class

18:39 technomancy: beutdeuce: the maven build of clojure is not very well-supported

18:39 if you just want to build the jar, try ant instead

18:39 crios__: does that grammar is used to generate the Clojure runtime reader?

18:39 beutdeuce: technomancy: perhaps, but it is required for the project I'm working on (altlaw) to use it

18:39 hiredman: beutdeuce: that's not right

18:40 beutdeuce: hiredman: ?

18:40 hiredman: the clojure.jar should have more inside then that

18:40 technomancy: beutdeuce: do you need 1.0 or 1.1-SNAPSHOT?

18:40 you can use one of the forks we have at work that fix the pom file

18:40 beutdeuce: technomancy: ? i'm just having trouble building a clohure program i wrote with mvn, I'm fine with lcojure itself

18:41 I just need help as to how i can run the jar file created by maven

18:41 technomancy: http://github.com/sonian/clojure/tree/1.0.x

18:42 beutdeuce: i take it that is the clojure repo?

18:42 technomancy: it's a fork of it that fixes the pom file so it will work with mvn install, yes

18:43 beutdeuce: but im not having trouble with maven install

18:43 i create my own clojure program using mvn called clojureworld which is basically a hello world application

18:43 im trying to compile it with mvn into a jar file

18:43 technomancy: sorry; misread the question

18:43 beutdeuce: which succeeded. My problem is running the jar file

18:43 np

18:44 hiredman: lisppaste8: url

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

18:44 hiredman: paste the exception

18:44 and your classpath

18:44 and how

18:45 you are attempting to run the jar

18:45 beutdeuce: l

18:47 k

18:48 lisppaste8: beutdeuce pasted "untitled" at http://paste.lisp.org/display/87070

18:49 hiredman: ~compile

18:49 clojurebot: the unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation

18:50 hiredman: http://clojure.org/API#gen-class <-- I'd read what it says about prefixes

18:50 and I recomend using defn there instead of def

18:54 beutdeuce: hmm

18:54 now i get a different error

18:54 lisppaste8: beutdeuce pasted "Error" at http://paste.lisp.org/display/87071

18:56 hiredman: beutdeuce: paste your new main.clj file

18:56 beutdeuce: (ns clojureworld.main

18:56 (:gen-class))

18:56 (defn -main

18:56 [args]

18:56 (println "Hello World"))

18:57 thnx to :gen-class, i know have a main.class class in my jar, but when i run clojureworld.main, i get an iFn no class found error

18:57 which is the Fn

18:57 im not sure why

18:58 hiredman: pastebin updates of all teh previous information: the exception, the classpath, and how you are runing the jar

18:59 beutdeuce: its all the same

18:59 hiredman:

18:59 you just said the exception is different

18:59 beutdeuce: i just pasted it

18:59 http://paste.lisp.org/display/87071

18:59 thats all that changed

18:59 hiredman: and how are you trying to execute the jar?

19:00 beutdeuce: java -cp target/clojureworld.jar clojureworld.main

19:00 hiredman: well, clojure needs to be on the classpath too

19:04 beutdeuce: how do i specify multiply classpaths in -cp ?

19:04 technomancy: beutdeuce: colon-separated list of jar files on unix

19:05 beutdeuce: still get the latest error

19:05 Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/IFn

19:05 hiredman: lets see your new command line

19:05 beutdeuce: ava -cp target/clojureworld-1.0-SNAPSHOT.jar:~/.clojure/clojure.jar clojureworld.main

19:06 hiredman: you cannot use ~ there

19:06 beutdeuce: oh? has to be fully-qualified?

19:06 technomancy: use $HOME

19:06 beutdeuce: k

19:06 hiredman: $HOME or $PWD

19:07 beutdeuce: k, works now. Thanks! But its weird. the clojure.jar file is in my $CLASSPATH but apparently it doesnt detect it?

19:07 hiredman: -cp negates $CLASSPATH

19:07 one or the other

19:07 beutdeuce: ah

19:07 got it

19:07 thanks!

19:09 huh, why does it take 1.4 seconds to run?

19:09 hiredman: jvm start up time

19:10 beutdeuce: very time java is called, jvm restarts?

19:10 hiredman: java = jvm

19:10 beutdeuce: k

19:10 thanks

19:11 oh, and why would u use defn rather than def ?

19:11 hiredman: ,(defn def)

19:11 clojurebot: DENIED

19:12 hiredman: clojurebot: thanks!

19:12 clojurebot: Huh?

19:12 Chousuke: beutdeuce: defn has better syntax.

19:12 hiredman: defn is specifically for defining functions

19:12 Chousuke: (defn main [] foo) instead of (def main (fn [] foo))

19:12 hiredman: and it has all kinds of doo-dads

19:12 like docstrings

19:12 Chousuke: and it supports doc.. yes.

19:12 it also expresses your intent better than def. :)

19:13 beutdeuce: ok

19:13 Chousuke: and in the end it expands to (def ...) but you need not care about that.

19:13 beutdeuce: even though it is used several times through the doc

19:13 hiredman: which docs?

19:13 beutdeuce: clojure.org

19:14 hiredman: be more specific

19:14 there is a lot on clojure.org

19:14 beutdeuce: http://clojure.org/special_forms

19:15 hiredman: it's only used there twice, and once is part of an example of the fn special form

19:16 beutdeuce: k

19:17 Chousuke: there's nothing wrong with using def for fns of course

19:17 hiredman: (but don't)

19:18 beutdeuce: k

19:18 Chousuke: just like there's nothing wrong with walking barefoot even though you have shoes :P

19:18 beutdeuce: so, defn is more efficient in some way?

19:18 Chousuke: for the programmer it is.

19:18 beutdeuce: k

19:19 Chousuke: it reduces clutter and the intent is clearer.

19:19 beutdeuce: k

19:19 hiredman: I mean, you could just wrap your program in side a single large fn

19:20 ,((fn [f g] (f (g 1 2) 3)) (fn [x y] (+ x y)) (fn [x y] (* x y*)))

19:20 clojurebot: java.lang.Exception: Unable to resolve symbol: y* in this context

19:20 hiredman: ,((fn [f g] (f (g 1 2) 3))) (fn [x y] (+ x y)) (fn [x y] (* x y*)))

19:20 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--2860$fn

19:20 hiredman: bah

19:20 I really need paren balancing irc

19:20 Chousuke: :P

19:21 erc with paredit!

19:21 no more mismatched parentheses!

19:21 hiredman: ,((fn [f g] (f (g 1 2) 3)) (fn [x y] (+ x y)) (fn [x y] (* x y)))

19:21 clojurebot: 5

19:21 hiredman: no def at all

19:23 Chousuke: ,((fn [f g] (f (g 1 2) 3)) * +); one wonders why you didn't just do this :P

19:23 clojurebot: 9

19:24 Chousuke: (other way around though :))

19:24 hiredman: Chousuke: because I was demonstrating the binding of Fns to names without using def

19:25 now granted that does the samething, but it is less obvious that a fn is being bound, because you only see the one fn on the lef there

19:25 Chousuke: I suppose

19:26 hiredman: clearly an exercise in tom foolery

19:27 have you seen http://www.thelastcitadel.com/images/clojure.svg ?

19:27 Chousuke: ,((fn this [f] (f this)) (fn this [f] (f this))); more funky stuff

19:27 clojurebot: java.lang.StackOverflowError

19:27 Chousuke: that's like putting two mirrors against each other

19:28 hiredman: ,((fn [x y] (x y)) (fn [x y] (x y)))

19:28 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--2909$fn

19:28 hiredman: bah

19:29 ,((fn [x] (x x)) (fn [x] (x x)))

19:29 clojurebot: java.lang.StackOverflowError

20:32 manic12: how do you do a return-from ?

20:33 dnolen`: manic12: no such thing as far as I know.

20:34 manic12: ok

20:34 Chousuke: you can throw an exception :)

20:34 (and then you can stop coding :P)

20:34 dnolen`: manic12: i did a little experiment on how you can have arbitrary control with an exception on the mailing, and even returning a value.

20:34 manic12: as long as the exception is created ahead of time, it won't be slow.

20:35 this is again a hack.

20:35 you should figure out how to solve your problem in a different way.

Logging service provided by n01se.net