#clojure logs

2009-09-14

02:59lowlycoderis there anyway to use vim keybindings in enclojure?
03:28LauJensenTop o' da morning gents
03:42Fossihi
04:33LauJensen(defn fac [x] (if (zero? x) 1 (* x (fac x))))
04:34hiredmanyou are missing a dec
04:34LauJensenyes, add the dec, then help me understand why I cant replace the last expression with (* x (recur (dec x))
04:34LauJensenIf I wanted to add tail recursion that is
04:35hiredmanthat's why you make a factorial sequence generating function use nth
04:35Chousukethe expression is not tail recursive.
04:36LauJensenChousuke: No the question is, how would I make it so ?
04:37Chousukethe fac function needs an accumulator parameter for that.
04:37Chousukeand then you just need to return the accumulator at the end of the recursion
04:37LauJensenah yes
04:37LauJensenThanks
04:48LauJensenCan someone explain currying real quick for me ?
04:50Chousukeisn't it the approach that all functions take only one parameter?
04:50Chousukeie. a function that "has two parameters" really takes just one and returns a function that takes the other parameter.
04:50LauJensenCurrying 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
04:51LauJensenThats from the Haskell wiki - No different for Clojure I hope ?
04:51hiredmanwell, haskell currys automagically
04:51hiredmanclojure doesn't
04:53Chousukecurrying also neatly explains why the type notations in haskell are what they are :)
04:54ChousukeI really had trouble with them until I understood the "one argument only" idea :/
04:54liwpif you wanted to write non-curried Haskell you could use tuples everywhere: f :: (a, b) -> c
04:54liwp(not saying it's a good idea ;-)
04:54hiredman,((((curry +) 1) 2) 3)
04:54clojurebot#<sandbox$uncurry__2574$uc__2576 sandbox$uncurry__2574$uc__2576@1860045>
04:54hiredman,(((((curry +) 1) 2) 3))
04:54clojurebot6
04:55liwpbut that's how the authors approach currying and higher order functions in The Little MLer and it works quite well in the book
04:56LauJensenAlright thanks
04:56LauJensenThen just to clear our factorial discussion up, this is the way to implement a durable factorial
04:56LauJensen(defn fac ([x] (fac 1 x))[acc x] (if (zero? x) acc (recur (* x acc) (dec x))))
04:58liwplooks good
04:59LauJensenSo sad that the JVM doesn't have tail recurrence
04:59liwpI really like how defining the same fn with different arities lends itself to defining helper functions
04:59liwpLauJensen: indeed. Hopefully they'll fix it at some point, but I'm not holding my breath
04:59LauJensen'lends itself' ?
05:00liwpyou can use the feature to define helper methods
05:00LauJensenYes thats true
05:01liwpin Haskell you'd probably define the two arg helper as an internal definition in a where expr
05:01LauJensenIn 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.
05:01liwpverbosity? Surely that's less verbose than doing the same thing (method overloading) in Java?
05:02LauJensenSee comment regarding IQ of critics
05:08liwphehee
05:08rfgpfeiffer,((comp (partial apply *) (partial range 1) inc)) 5)
05:08clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$inc
05:09liwp ,((comp (partial apply *) (partial range 1) inc) 5)
05:09liwp,((comp (partial apply *) (partial range 1) inc) 5)
05:09clojurebot120
05:10rfgpfeiffer* is tail recursive enough
05:15LauJensen,((comp (partial apply *) (partial range 1) inc) 5000)
05:15clojurebot42285779266055435222010642002335844053907866746266467488497824021813580527081082006908990478717063875370847466573006854458784860666838127363372108937727876312793903630584621606439044789869822398719297088962116126529683217755003992421968370314690726447287878979040475488416221522667192841096923691044956597173635294840022384038112064482023085767110450230617489475542830976178172404080532480992780932878405548619936454829121187
05:15LauJensenWow
05:15LauJensenHow did you come up with that rfgpfeiffer ?
05:16rfgpfeifferwell that's how i wold write it
05:17rfgpfeifferhiding recursion
05:17LauJensenCan you explain the steps please?
05:17liwpyou create a seq of the number you want to multiply together: (range 1 (inc n))
05:18liwpand then you apply * to the seq
05:18liwprfgpfeiffer: very nice
05:18rfgpfeiffer(defn fac [n] (apply * (range 1 (inc n))))
05:18liwp,(apply * (range 1 (inc 5)))
05:18clojurebot120
05:18LauJensenooh
05:18rfgpfeifferand then I made it point-free
05:19LauJensenI'm amazed
05:19LauJensenThat's a new mindset to me entirelyu
05:19rfgpfeifferhiredman: can clojurebot refactor to point-free style like lambdabot?
05:20rfgpfeifferLauJensen: Read http://github.com/raganwald/homoiconic
05:20LauJensenWill do
05:21ChousukeI don't like point-free style in Clojure.
05:21Chousukemost of the time it just doesn't work
05:21Chousukeas in, improve readability :P
05:23rfgpfeifferThere is a website about complicated implementations of factorial in Haskell
05:23hiredman,(pl ((partial apply *) · (partial range 1) · inc 5))
05:23clojurebot120
05:23Chousukefor example, the earlier point-free fac function is just ugly compared to the explicit defn (It's not the programmer's fault :))
05:24hiredmaneh? ugly to you
05:24Chousukeall the comp and partial calls are just noise.
05:24hiredman#() is noise
05:24Chousukeno, it's not.
05:24hiredmancomp is compose and partial is partial
05:24Chousukebut it doesn't even apply in this situation
05:25liwpChousuke: I agree. I think point-free look a lot nicer in haskell
05:25Chousukehiredman: yes, but using them obfuscates what teh function actually does
05:25hiredmanChousuke: #() is usually what is used instead of comp and partial
05:25liwpin Clojure / lisp the prefix syntax just makes it ugly
05:25hiredmanChousuke: no, it makes it clearer
05:25hiredmanthe function is a composition of the other functions
05:26hiredmanthe function is the partial application of this function to this argument
05:26Chousukesorry, but how the hell is (comp (partial apply *) (partial range 1) inc) clearer than (apply * (range 1 (inc n)))
05:26rfgpfeifferthat is unfair
05:26Chousukethe latter reads "product of range from 1 to n"
05:26rfgpfeifferit should be #(apply * (range 1 (inc %)))
05:26Chousukerfgpfeiffer: well that's still much nicer.
05:27rfgpfeifferyeah
05:27hiredmanthats like, your opinion, man...
05:27ChousukeI can't understand how you think the point-free style better in this case.
05:28Chousukethe comp and partial calls tell nothing about what the function does.
05:28LauJensenHow do you guys define point-free?
05:28Chousukeor what the code does.
05:28liwp~google point-free style
05:28clojurebotFirst, out of 194000000 results is:
05:28clojurebotPointfree - HaskellWiki
05:28clojurebothttp://www.haskell.org/haskellwiki/Pointfree
05:28Chousukeunlike in, say (partial merge-with +) that I used earlier. that's small and simple and says "merge-with +"
05:29liwpLauJensen: another one on Stack Overflow: http://stackoverflow.com/questions/944446/what-is-point-free-style-in-functional-programming
05:29rfgpfeiffer~google evolution of haskell factorial
05:29clojurebotFirst, out of 1500 results is:
05:29clojurebotThe Evolution of a Haskell Programmer
05:29clojurebothttp://www.willamette.edu/~fruehr/haskell/evolution.html
05:29rfgpfeiffercool
05:29LauJensenThanks guys, what a community :)
05:30ChousukeI'm just saying that while there are cases where point-free style is better, it doesn't really fit Clojure.
05:30liwprfgpfeiffer: 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
05:30liwpChousuke: yeah, I agree
05:30liwptoo much noise in a lot of cases
05:31rfgpfeifferfac = foldr (*) 1 . enumFromTo 1
05:31liwprfgpfeiffer: ok, fair enough ;)
05:32Chousukethat's already much better because of the implicit partials and . for comp :P
05:32rfgpfeifferyou could use reduce instead of apply in clojure too
05:32LauJensenrfgpfeiffer: You're git repo yields one question, whats 'chutzpah' ?
05:32liwpThere 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
05:33liwpBut even there the reader must do a double take on the code IMHO
05:33liwprfgpfeiffer: yeah of course, I just mean that having apply in clojure makes the factorial even nicer
05:33rfgpfeifferLauJensen: what?
05:34LauJensen"He said he let her off on the grounds of novelty and chutzpah."
05:34rfgpfeifferi mean it is a yiddish word that means boldness
05:34rfgpfeifferbut what repo
05:34LauJensenhomoiconic
05:34rfgpfeifferor ruthlessness
05:35rfgpfeifferokay
05:36liwpis there a foldr1 in haskell... then you'd get fac n = foldr1 (*) $ enumFromTo 1 n
05:39rfgpfeifferfactorial should be in core.clj
05:39rfgpfeifferso we have a shorter definition than haskell :)
05:40hiredmanadd a ! special form
05:41rfgpfeifferOn a more serious note: has anybody used java.nio and selectors with clojure?
09:45criosHello, I'm studying the code in http://pastebin.com/m2dc9a491. How: (bench-fn (fn []> (+ 1 2))) is different from: (bench-fn (fn [] (+ 1 2))) ?
09:45crioswhat does it mean "fn []>" syntax ?
09:52AWizzArdcrios: a typo
09:58Chousukeinterestingly enough the code works like that too :)
09:59Chousukethe > is just ignored.
09:59Chousukebecause it's just the > function :P
10:02criosI don't understand
10:02Chousukecrios: it's the same as:
10:02Chousuke,(do > 5)
10:02clojurebot5
10:03Chousukeit 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:10Fossiwouldnt work with #( though
10:11Chousukewell, that's because #( is not (fn :P
10:11Fossior it would return true then
10:11Chousukehm
10:12Chousuke,(> 3)
10:12clojurebottrue
10:12ChousukeI guess that's useful for checking if a seq of numbers is sorted.
10:14AWizzArd,>
10:14clojurebot#<core$_GT___4136 clojure.core$_GT___4136@18b995c>
10:34criosso does > character, in that contest, is a of real value?
10:39Fossino, it doesn't do anything senseful. it's a "bug" in the book, as the first hit on google (the errata) also tell
10:42criosFossi, here http://www.pragprog.com/titles/shcloj/errata ?
10:42Fossiyes
10:43Fossisee 233 or such
10:46achimcrios: 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:53criosachim, I'm not sure whether your example helps :)
10:53crios*how* that help (I'm a newbe)
10:54criosin your example '<' evaluates to <, being just a symbol, right?
10:56achimyes, it evaluates to the < function. functions are values just like numbers and strings are
10:56Chouser,[1 2 :a :b "hello" <]
10:56clojurebot[1 2 :a :b "hello" #<core$_LT___4049 clojure.core$_LT___4049@dd23cf>]
10:56achimthe 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:57crios,(<)
10:57clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$-LT-
10:58crioswhere < apply here : (defn foo [] 3 5 < (+ 1 3))
10:58liwp,(do (+ 1 1) (+ 1 2) (+ 1 3))
10:58clojurebot4
10:58liwpcrios: only the last form gets returned to the caller
10:58AWizzArdcrios: everything is ignored, only the last form gets returned
10:58achimcrios, it isn't applied, it's just there
10:58liwpi.e. (+ 1 3) -> 4
10:59AWizzArd,1 2 3
10:59clojurebot1
10:59AWizzArdfine :)
10:59liwpall the other forms get also evaluated, but the return values do not get shown to caller
10:59criosIt is not returned, but is it evaluated?
10:59liwpyep
10:59liwp,(do (+ 1 1) (+ :a :b) (+ 1 3))
10:59clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number
11:00liwpso the (+ :a :b) fails
11:00liwpeven though its return value (3 in the previous example) did show up in the output
11:00Chouserdid not :-)
11:00liwp,(do (println 1) (println 2 (+ 1 3))
11:00clojurebotEOF while reading
11:01liwpChouser: uhh, yeah, sorry
11:01liwp,(do (println 1) (println 2) (+ 1 3))
11:01clojurebot4
11:01clojurebot1 2
11:01criosin (defn foo [] 3 5 < (+ 1 3)) , how is < evaluated ? as (< x ) ?
11:01achimcrios: 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:01liwp,<
11:01clojurebot#<core$_LT___4049 clojure.core$_LT___4049@dd23cf>
11:01Chousukecrios: no, just <
11:01Chousukecrios: it's a function, so when evaluated you get the function object
11:01liwpit evaluates to the function <
11:02liwp(let [fn <] (fn 1 2))
11:02crios,(doc <)
11:02liwp,(let [fn <] (fn 1 2))
11:02clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically increasing order, otherwise false."
11:02clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: nth not supported on this type: Integer
11:02Chousukecrios: in fact, that's what happens even when it's (< 1 3); the < is evaluated, yielding the fn, which is then called :)
11:02liwp,(let [f <] (f 1 2))
11:02clojurebottrue
11:02achimcrios: (defn bar [] > 2) -> first "<" is evaluated (but not called!), but not returned, then 2 is evaluated and returned
11:03criosI would guess that the < evaluation should fail, becouse < expects twos arguments at least
11:03Chousukecrios: no. it's not being called
11:03Chousuke,(<)
11:03clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$-LT-
11:03achimif 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:03Chousukethat fails
11:03Chousukebut
11:03clojurebothttp://clojure.org/contributing
11:04Chousuke,<
11:04clojurebot#<core$_LT___4049 clojure.core$_LT___4049@dd23cf>
11:04criosyes,
11:04crios(resolve <)
11:04crios,(resolve <)
11:04clojurebotjava.lang.ClassCastException: clojure.core$_LT___4049 cannot be cast to clojure.lang.Symbol
11:04Chousukeif just evaluating < would fail, then (apply < [1 2 3 4]) would fail as well :/
11:05criosgood point :)
11:05Chousukebut really, it's no different from 5 or "foo", as a value
11:06criosthey are just symbol...
11:06Chousukecrios: well, when it's evaluated it's no longer the symbol.
11:06Chousukeyou get the function
11:08konr_Hmm, what's the difference between compojure and conjure? Has anyone used them?
11:09criosFossi are you italian? do you know any Clojure user group in Milan area?
11:11Fossimore like ,(resolve '<)
11:11Fossicrios: no. i'm german. what makes you think i'm italian? :D
11:17criosyour nickname is very similar to ours real surnames :D
11:18criospardon anyway, fossi
11:20raphinou_is there a way to display the :doc of a namespace like it exists for functions doc strings?
11:21Chousuke,(:doc ^*ns*)
11:21clojurebotnil
11:21Chousukehm. no doc for that namespace I guess.
11:21Chouser(doc clojure.contrib.seq-utils)
11:21clojurebotjava.lang.ClassNotFoundException: clojure.contrib.seq-utils
11:21Chouserhmph. clojurebot doc is not the same as core doc
11:22rfgpfeiffercrios: were you at ELS?
11:22criosno rfgpfeiffer. What is ELS ?
11:23rfgpfeifferEuropean Lisp Symposium
11:23criosno
11:23rfgpfeifferwas in Milano this Year
11:23Chouseroh, I think the metadata on namespaces disappears when compiled to .class files.
11:24crios:( - one more problem of being a newbe in clojure!
11:24rfgpfeiffereverybody said "clojure is cool but i have not yet have had the time to run it"
11:24criosso I'm pleased to not be there! ;)
11:25criosto much people, in these days, like buzz / fashion words! But how many try what adulate?
11:25Chouser~ticket #130
11:25clojurebot{: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:25raphinou_Chouser: (doc clojure.test) gives nil
11:32Chousukeraphinou_: looks like it's not documented
11:33raphinou_Chouser: clojure.test namespace definitely has :doc : http://github.com/richhickey/clojure/blob/270185aba54cef1d8ce59ec347b5623f2e502afe/src/clj/clojure/test.clj
11:33stuartsierraWhat Clojure tutorial should I give to CS students who know neither Lisp nor Java?
11:34raphinou_it's as a comment in the file and as :doc attached to ns (strange to have twit twice btw)
11:34rfgpfeifferstuartsierra: timeframe?
11:34Chousukehm, so the mock library went into contrib? :/
11:35stuartsierrarfgpfeiffer: shorter than a book, but a thorough trip through the language
11:35stuartsierraraphinou_: that's an artifact of when someone added metadata to the ns, copying my comments
11:37Chousukehm.
11:37Chousukeclojure-mode syntax highlighting seems to break on mock.clj :P
11:38raphinou_ok
11:44LauJensenAnybody gearing up for the Alioth Shootout?
11:48crioscoming 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:49FossiLauJensen: i'd guess that running on a vm will alwazs slow you down compared to machinecode compiled languages :)
11:49Fossiso what's the point?
11:49LauJensenNotice Scala in the top 5 ?
11:57Fossiwell, i guess it depends a lot on how you measure
11:57Fossiseems they have measurements for java with and without startup and first run
12:16tmountainstuartsierra: http://java.ociweb.com/mark/clojure/article.html ?
12:17stuartsierratmountain: thanks, that's one I hadn't seen before
12:19tmountainstuartsierra: no problem. it's my go to document when introducing people to clojure
12:19clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
12:21michael_teterlol
15:31crios_,>
15:31clojurebot#<core$_GT___4136 clojure.core$_GT___4136@18b995c>
15:35Chousercrios_: exactly
15:46crios_,(defn foo [] > (+ 1 2))
15:46clojurebotDENIED
15:47Chouserclojurebot won't let you def stuff.
16:08crios_After carefully reading (I hope!) http://clojure.org/evaluation, this is my understanding:
16:08crios_Regarding the expression: (do > 5) => 5
16:08crios_'do' is a special form, which evaluates all the expressions.
16:08crios_> 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:09crios_,>
16:09clojurebot#<core$_GT___4136 clojure.core$_GT___4136@18b995c>
16:09crios_5 is evaluated to 5, and returned as the expression value.
16:09crios_[ah, here the GT internal class has a diffent name - implementation detail :)]
16:10crios_I think all Clojure should condensate into http://clojure.org/evaluation rules
16:11crios_:)
16:12crios_core$_GT___4136 clojure.core$_GT___4136 is an internal class, inside clojure.jar
16:14hiredmanhttp://www.thelastcitadel.com/images/clojure.png
16:19hiredmannot as nice as I was hoping for, since, of course, clojure.core has a very minimal ns form
16:31crios_what is it hiredman? an "import" visual tracking?
16:31hiredmanit's a trawl of information from ns forms in my local checkout of clojure
16:32crios_how has you get it?
16:32hiredmanhttp://github.com/hiredman/clojure-dependency-grapher
16:32hiredmanit outputs stuff in the graphviz dot format
16:33crios_cool!
16:35crios_it would worth explain better, in the README file, the lib purpose :)
16:37hiredmanthe purpose is to make pretty pictures
16:38crios_"script reads the ns forms from clojure files in a directory and writes out a graph of dependencies"
16:38crios_well, I think it is very useful
16:39crios_every tool which can give an higher overview on the code worth the effort
16:39hiredmanI updated the readme and pushed, just hasn't shown up on the web ui yet
16:40crios_have you ever seen this: http://www.visualcomplexity.com/vc/project.cfm?id=261
16:40crios_or this: http://www.visualcomplexity.com/vc/project.cfm?id=262
16:40crios_?
16:40hiredmanI think I may have seen the first one somewhere
16:43crios_presenting code as art is a great effort
16:43crios_someone also tries to converting it into music: www.codesounding.org/indexeng.html ;)
16:44LauJensen~def time
16:48danlarkinHello clojure folk
16:48LauJensenHey Mr. Dan
16:49danlarkinI have a probably stupid question
16:49danlarkinbut in my repl \u066f is coming back as \?
16:49danlarkin,\u066f
16:49clojurebot
16:49danlarkinperhaps it's a factor of my environment
16:50hiredmando you have a font with that glyph?
16:50hiredmanhttp://www.fileformat.info/info/unicode/char/066f/index.htm
16:51hiredmanhmm
16:51danlarkinhiredman: yeah it's not the font
16:52hiredmanclojurebot: logs?
16:52clojurebotlogs is http://clojure-log.n01se.net/
16:52Chousukefunky
16:52ChousukeiTerm renders that character *before* the \...
16:53hiredmanhttp://clojure-log.n01se.net/date/2009-09-12.html#19:28 <-- hard to follow because the logger doesn't handle utf8
16:53hiredmanuser=> (.getEncoding *out*)
16:53hiredman"Cp1252"
16:53hiredmanuser=>
16:53hiredman:(
16:54danlarkinHmmm mine is MacRoman
16:55hiredman,(.getEncoding *out*)
16:55clojurebotjava.lang.IllegalArgumentException: No matching field found: getEncoding for class java.io.StringWriter
16:55hiredmanoh, right
16:55crios_probably also a System.out.println("\u066f") in plain old Java does not output the arabic char, doesnt'it?
16:57danlarkincrios_ correct, just tried it and I get a ? back from java
16:59hiredmanthe -Dfile.encoding=UTF8 seems to do the trick
16:59hiredmanif you have a UTF8 locale setup it seems to default to UTF8 anyway
17:00crios_,(System/getProperty "file.encoding")
17:00clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding read)
17:01crios_confirm hiredman
17:01crios_here user=> (System/getProperty "file.encoding") => "UTF-8"
17:01crios_java defaults to the OS charset
17:02crios_unless you use -D
17:02crios_BTW: http://www.websina.com/bugzero/kb/java-encoding-charset.html
17:04crios_logs?
17:04crios_clojurebot: logs?
17:04clojurebotlogs is http://clojure-log.n01se.net/
17:11danlarkinwell so that's pretty annoying
17:12danlarkinI don't think I can change my default encoding on a OS X
17:12Chousukehm
17:12Chousukethere should be a way to set systemwide properties
17:14hiredmanhttp://www.rift.dk/news.php?item.7.6
17:14hiredmanhttp://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/locale.1.html
17:15crios_yes there is: java -Dfile.encoding=UTF-8
17:16crios_starts your REPL with such property
17:16crios_it should work
17:16hiredmanif osx still uses bsd's setup stuff, there is always .login_conf
17:17hiredman http://gist.github.com/186934
17:19crios__IMHO you can change just the JVM property , not the whole OS configuration
17:19danlarkincrios_: I don't want to set it every time
17:19danlarkinand in every place I launch the jvm
17:19hiredmanand everything should be set for utf-8 anyway
17:20crios__as you like :) just saying what suffice
17:24danlarkinwell I have set LANG and LC_ALL to en_US.UTF-8 and still java has my file.encoding as MacRoman
17:24danlarkinI am annoyed because it did not used to be this way
17:24danlarkinI noticed this because of a test failing... but it used to pass
17:24hiredmanhmmm
17:25hiredmanare you sure the LANG variables are set?
17:26danlarkinTarragon:~ dan$ echo $LANG, $LC_ALL
17:26danlarkinen_US.UTF-8, en_US.UTF-8
17:27Chousukethere's the environment.plist thing. what about that? :)
17:28technomancyChousuke: when all else fails, edit an XML file!
17:28technomancy~xml
17:28clojurebotIt's greek to me.
17:28Chousuketechnomancy: and then the rest will fail too
17:28technomancy~xml is like violence; if it's not working, you're not using enough of it.
17:28clojurebot'Sea, mhuise.
17:30Chousukehm, no wonder it's popular then
17:30hiredman~XML
17:30clojurebotXML is like violence; if it doesn't solve your problems, you're not using enough of it.
17:30Chousukepeople are generally attracted to violence
17:30Chousukeas long as it's someone else.
17:31hiredmanthe switch to a derby backend should also take care of case sensitivity issues
17:31technomancyhiredman: nice; it echoes in the same case as you use in the query
17:31hiredmantechnomancy: no :( there are just two factions, XML and xml
17:31hiredmanthe XML one already there
17:31Chousukeclojurebot uses a real database now?
17:31hiredmannot yet
17:32hiredmanit's on my list of things todo
17:32Chousuke~XmL is case-sensitive
17:32clojurebotYou don't have to tell me twice.
17:33technomancyoh; hah
17:33technomancyI think I added the all-caps one too.
17:35hiredmanyou did, in July
17:36technomancygreat minds think alike!
17:42Chouser~exceptions
17:42clojurebothttp://paste.lisp.org/display/74305
17:42Chouserperfect!
17:43Chouserhm. could be sorted.
17:45crios__what is pastelisp?
17:46hiredmanlisppaste8: url?
17:46lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
17:47crios__is it a sort of paste bin?
17:47futuranoncrios__: yes
17:47crios__ah
17:48hiredmanit's a neat pastbin, because it comes with an irc bot
17:50lisppaste8crios pasted "try" at http://paste.lisp.org/display/87068
17:51crios__cool :)
17:51crios__how do you use it? to share code?
17:52hiredmanto paste examples and problems
17:52ChousukeI don't like the lisp pastebin though. it doesn't colourise the source properly :(
17:52ChousukeI prefer gists
17:53hiredmanhttp://paste.lisp.org/list/clojure
17:53hiredmanhttp://delicious.com/clojurebot/pastbin
18:18crios__is there an ANTLR grammar for Clojure? http://code.google.com/p/clojure-antlr-grammar/ seems empty
18:18crios__clojurebot: logs?
18:18clojurebotlogs is http://clojure-log.n01se.net/
18:27stuartsierracrios__; there's an old version somewhere in the google code SVN that Rich Hickey started and abandoned.
18:29crios__abandoned? why?
18:31Chousukethat grammar doesn't seem that old. only about 6 months :P
18:31Chousukethe one on the page you posted.
18:33crios__have you checkout the code? http://code.google.com/p/clojure-antlr-grammar/downloads/list is empty
18:33hiredmanhttp://code.google.com/p/clojure-antlr-grammar/source/browse/
18:33crios__ah ok
18:33crios__http://code.google.com/p/clojure-antlr-grammar/source/browse/src/Clojure.g
18:33crios__yes
18:34beutdeuceI 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:35hiredmandefine trouble
18:35beutdeuceno class def found. no main class found
18:35hiredmanwhat is inside the jar?
18:36beutdeucedoes it matter? Canit i use -cp ?
18:36hiredmanwell, if the classes are not inside the jar, that would explain why there is no class def found
18:37beutdeucedoesnt mvn install package the classes into the jar automatically?
18:37beutdeucei can check whats inside anyway
18:37beutdeuceh/o
18:37hiredmana jar file is just a zip file
18:37beutdeucei know
18:38hiredmanI have no idea, I've never used maven
18:38hiredmanso unzip it
18:38beutdeucek, there is META_INF, and there is clojureworld. Inside clojureworld, there is main__init.class and main$main__1.class
18:39technomancybeutdeuce: the maven build of clojure is not very well-supported
18:39technomancyif you just want to build the jar, try ant instead
18:39crios__does that grammar is used to generate the Clojure runtime reader?
18:39beutdeucetechnomancy: perhaps, but it is required for the project I'm working on (altlaw) to use it
18:39hiredmanbeutdeuce: that's not right
18:40beutdeucehiredman: ?
18:40hiredmanthe clojure.jar should have more inside then that
18:40technomancybeutdeuce: do you need 1.0 or 1.1-SNAPSHOT?
18:40technomancyyou can use one of the forks we have at work that fix the pom file
18:40beutdeucetechnomancy: ? i'm just having trouble building a clohure program i wrote with mvn, I'm fine with lcojure itself
18:41beutdeuceI just need help as to how i can run the jar file created by maven
18:41technomancyhttp://github.com/sonian/clojure/tree/1.0.x
18:42beutdeucei take it that is the clojure repo?
18:42technomancyit's a fork of it that fixes the pom file so it will work with mvn install, yes
18:43beutdeucebut im not having trouble with maven install
18:43beutdeucei create my own clojure program using mvn called clojureworld which is basically a hello world application
18:43beutdeuceim trying to compile it with mvn into a jar file
18:43technomancysorry; misread the question
18:43beutdeucewhich succeeded. My problem is running the jar file
18:43beutdeucenp
18:44hiredmanlisppaste8: url
18:44lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
18:44hiredmanpaste the exception
18:44hiredmanand your classpath
18:44hiredmanand how
18:45hiredmanyou are attempting to run the jar
18:45beutdeucel
18:47beutdeucek
18:48lisppaste8beutdeuce pasted "untitled" at http://paste.lisp.org/display/87070
18:49hiredman~compile
18:49clojurebotthe 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:50hiredmanhttp://clojure.org/API#gen-class <-- I'd read what it says about prefixes
18:50hiredmanand I recomend using defn there instead of def
18:54beutdeucehmm
18:54beutdeucenow i get a different error
18:54lisppaste8beutdeuce pasted "Error" at http://paste.lisp.org/display/87071
18:56hiredmanbeutdeuce: paste your new main.clj file
18:56beutdeuce(ns clojureworld.main
18:56beutdeuce (:gen-class))
18:56beutdeuce(defn -main
18:56beutdeuce [args]
18:56beutdeuce (println "Hello World"))
18:57beutdeucethnx 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:57beutdeucewhich is the Fn
18:57beutdeuceim not sure why
18:58hiredmanpastebin updates of all teh previous information: the exception, the classpath, and how you are runing the jar
18:59beutdeuceits all the same
18:59hiredman
18:59hiredmanyou just said the exception is different
18:59beutdeucei just pasted it
18:59beutdeucehttp://paste.lisp.org/display/87071
18:59beutdeucethats all that changed
18:59hiredmanand how are you trying to execute the jar?
19:00beutdeucejava -cp target/clojureworld.jar clojureworld.main
19:00hiredmanwell, clojure needs to be on the classpath too
19:04beutdeucehow do i specify multiply classpaths in -cp ?
19:04technomancybeutdeuce: colon-separated list of jar files on unix
19:05beutdeucestill get the latest error
19:05beutdeuceException in thread "main" java.lang.NoClassDefFoundError: clojure/lang/IFn
19:05hiredmanlets see your new command line
19:05beutdeuceava -cp target/clojureworld-1.0-SNAPSHOT.jar:~/.clojure/clojure.jar clojureworld.main
19:06hiredmanyou cannot use ~ there
19:06beutdeuceoh? has to be fully-qualified?
19:06technomancyuse $HOME
19:06beutdeucek
19:06hiredman$HOME or $PWD
19:07beutdeucek, works now. Thanks! But its weird. the clojure.jar file is in my $CLASSPATH but apparently it doesnt detect it?
19:07hiredman-cp negates $CLASSPATH
19:07hiredmanone or the other
19:07beutdeuceah
19:07beutdeucegot it
19:07beutdeucethanks!
19:09beutdeucehuh, why does it take 1.4 seconds to run?
19:09hiredmanjvm start up time
19:10beutdeucevery time java is called, jvm restarts?
19:10hiredmanjava = jvm
19:10beutdeucek
19:10beutdeucethanks
19:11beutdeuceoh, and why would u use defn rather than def ?
19:11hiredman,(defn def)
19:11clojurebotDENIED
19:12hiredmanclojurebot: thanks!
19:12clojurebotHuh?
19:12Chousukebeutdeuce: defn has better syntax.
19:12hiredmandefn is specifically for defining functions
19:12Chousuke(defn main [] foo) instead of (def main (fn [] foo))
19:12hiredmanand it has all kinds of doo-dads
19:12hiredmanlike docstrings
19:12Chousukeand it supports doc.. yes.
19:12Chousukeit also expresses your intent better than def. :)
19:13beutdeuceok
19:13Chousukeand in the end it expands to (def ...) but you need not care about that.
19:13beutdeuceeven though it is used several times through the doc
19:13hiredmanwhich docs?
19:13beutdeuceclojure.org
19:14hiredmanbe more specific
19:14hiredmanthere is a lot on clojure.org
19:14beutdeucehttp://clojure.org/special_forms
19:15hiredmanit's only used there twice, and once is part of an example of the fn special form
19:16beutdeucek
19:17Chousukethere's nothing wrong with using def for fns of course
19:17hiredman(but don't)
19:18beutdeucek
19:18Chousukejust like there's nothing wrong with walking barefoot even though you have shoes :P
19:18beutdeuceso, defn is more efficient in some way?
19:18Chousukefor the programmer it is.
19:18beutdeucek
19:19Chousukeit reduces clutter and the intent is clearer.
19:19beutdeucek
19:19hiredmanI mean, you could just wrap your program in side a single large fn
19:20hiredman,((fn [f g] (f (g 1 2) 3)) (fn [x y] (+ x y)) (fn [x y] (* x y*)))
19:20clojurebotjava.lang.Exception: Unable to resolve symbol: y* in this context
19:20hiredman,((fn [f g] (f (g 1 2) 3))) (fn [x y] (+ x y)) (fn [x y] (* x y*)))
19:20clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--2860$fn
19:20hiredmanbah
19:20hiredmanI really need paren balancing irc
19:20Chousuke:P
19:21Chousukeerc with paredit!
19:21Chousukeno more mismatched parentheses!
19:21hiredman,((fn [f g] (f (g 1 2) 3)) (fn [x y] (+ x y)) (fn [x y] (* x y)))
19:21clojurebot5
19:21hiredmanno def at all
19:23Chousuke,((fn [f g] (f (g 1 2) 3)) * +); one wonders why you didn't just do this :P
19:23clojurebot9
19:24Chousuke(other way around though :))
19:24hiredmanChousuke: because I was demonstrating the binding of Fns to names without using def
19:25hiredmannow 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:25ChousukeI suppose
19:26hiredmanclearly an exercise in tom foolery
19:27hiredmanhave you seen http://www.thelastcitadel.com/images/clojure.svg ?
19:27Chousuke,((fn this [f] (f this)) (fn this [f] (f this))); more funky stuff
19:27clojurebotjava.lang.StackOverflowError
19:27Chousukethat's like putting two mirrors against each other
19:28hiredman,((fn [x y] (x y)) (fn [x y] (x y)))
19:28clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--2909$fn
19:28hiredmanbah
19:29hiredman,((fn [x] (x x)) (fn [x] (x x)))
19:29clojurebotjava.lang.StackOverflowError
20:32manic12how do you do a return-from ?
20:33dnolen`manic12: no such thing as far as I know.
20:34manic12ok
20:34Chousukeyou can throw an exception :)
20:34Chousuke(and then you can stop coding :P)
20:34dnolen`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:34dnolen`manic12: as long as the exception is created ahead of time, it won't be slow.
20:35dnolen`this is again a hack.
20:35dnolen`you should figure out how to solve your problem in a different way.