#clojure logs

2010-08-02

00:14slyrusah... my old friend "error: java.lang.OutOfMemoryError: PermGen space (smiles.clj:311)"
00:23cais2002hi guys, when does the execution of the body of defmacro occur?
00:23Scriptorcais2002: during compile time
00:24cais2002-> (defmacro ++ [& exprs]
00:24cais2002 (if (>= 2 (count exprs))
00:24cais2002 `(+ ~@exprs)
00:24cais2002 `(+ ~@(first exprs) (++ ~@(rest exprs)))))
00:24sexpbotjava.lang.Exception: EOF while reading
00:25cais2002at compile time exprs still has no value, right?
00:25cais2002is this a valid macro definition?
00:25Scriptorcais2002: please paste code in a pastebin, like http://pastebin.com/
00:26cais2002scriptor: sorry, i thought it's short enough.. will do
00:27Chousukecais2002: otherwise yes, but the ~@(first exprs) is wrong and the condition looks weird.
00:28Chousukeor hm
00:28cais2002scriptor: am I correct to say that I can not rely on any run time value of the parameters in macro def?
00:28Chousukemaybe I just misread it.
00:28Chousukeyes.
00:28Chousukerather, you *can't* rely on runtime values of the parameters
00:28Scriptorcais2002: you can still rely on the count, I think, since it's still a list
00:29Scriptorbut like Chousuke said, it should be ~(first exprs)
00:30cais2002can you guys elaborate on "rely", (count exprs) is a type of "rely" that's allowed, but (= (first exprs) 1) is not?
00:31Chousukecais2002: exprs will most likely be a sequence of symbols and/or lists
00:31Chousukecais2002: though IF they are literal numbers, then the latter works too
00:31Scriptorcais2002: remember, exprs is unevaluated
00:31Scriptorsay you have (my-macro (+ 2 3))
00:32Scriptors/my-macro/++
00:32Scriptorwhen exprs would be a list containing +, 2, and 3
00:32Chousukeactually not
00:32cais2002chousuke: but the actual value of (count exprs) varies depending on the run time value, isn't it?
00:32Chousukeit would be ((+ 2 3))
00:32Chousukesince there's no destructuring
00:32Chousukecais2002: nope
00:33ScriptorChousuke: ah, good point
00:33Chousukecais2002: the macro expansion is done before runtime
00:33Chousukecais2002: though I suppose macro expansion could be thought of as "runtime" too since the entire language is useable already.
00:35Chousukecais2002: the value of (count exprs) depends on the number of parameters you pass to the macro, but the evaluated values (the ones a normal function would see) of those parameters don't matter.
00:37Chousukeas long as you remember you're dealing with unevaluated code in macros, you can do anything you want to the parameters though.
00:37TakeVIs there a way to define a struct that extends another struct?
00:38Chousukeyou could write a C compiler macro if you wanted :P
00:38Chousukejust parse a string
00:38Chousukeand return a function
00:38cais2002chousuke: here is an example that confuses me http://pastebin.com/QUNBcPrY
00:39Chousukecais2002: right. the parameter to testm in the first cases is a vector of numbers, so it works.
00:39Chousukecais2002: but in the last case, it's just a symbol. you can't call first or rest on a symbol
00:40cais2002chousuke: so it's evaluated at run time, but using the unevaluated form of the parameters?
00:40Chousukehmmh
00:41Chousukea macro call is expanded at macro expansion time, and then the result of the macro call is the thing that's evaluated
00:41Chousukeso in your case, (+ 1 2 3) and (* 2 2 3) are the things that get evaluated at runtime
00:42Chousukethe (def a [1 2 3]) doesn't matter at all to the macro, you can remove it and the error you get would not change.
00:44Chousukethough IIRC if I remember clojure's evaluation model correctly, the macro could access a from itself since it's a previously defined global constant.
00:45Chousukejust not through the parameter. :P
00:45ChousukeI mean, the testm def would have to be after the def for that to work, too
00:46wwmorgancais2002: the use case for most macros is syntax transformation. If you find that you need the parameter value, you probably just want a function
00:46cais2002wwmorgan: I figured so. but just want to make sure that I understand how it works
00:48cais2002chousuke: at macro expansion time, are the parameters replaced with the actual values of the parameters verbatiam?
00:54Chousukecais2002: what do you mean?
00:55Chousukecais2002: the macro is given the parameters you call it with, unevaluated. Then the macro does its magic, returns some code, and that code is then either further macroexpanded or just evaluated
00:58Chousukewhat the macro returns usually depends on the parameters you pass to the macro but that need not be the case.
00:58Chousukeeg. the comment macro that just returns nil :P
01:01cais2002chousuke: thanks, let me digest a bit
01:26notsonerdysunnyhttp://github.com/relevance/labrepl/issues#issue/14
01:26notsonerdysunnyhttp://osdir.com/ml/clojure/2010-07/msg00977.html
01:26notsonerdysunnyI am a newbie to netbeans-enclojure-maven thing .. and I am trying to get labrepl working .. but have trouble ..
01:27notsonerdysunnyI see that other people have had similar problem for over a month ..
01:28notsonerdysunnyIt seems like the problem is with the maven trying to track the latest-bleeding-edge clojure-contrib stuff.. I would like some help trying to resolve this...
01:28notsonerdysunnyIt is probably some thing very simply if you knew maven
01:28notsonerdysunnycan anybody help me?
01:29tomojnotsonerdysunny: I don't understand
01:29tomojlabrepl doesn't specify clojure-contrib 1.2.0-master-SNAPSHOT as a dependency
01:30notsonerdysunnywell my latest labrepl from git-hub is doing that
01:31tomojyou're getting an error that says 1.2.0-master-SNAPSHOT isn't found? from netbeans?
01:31notsonerdysunnyyes only for clojure-contrib
01:32mister_mdoes clojure have list comprehensions?
01:32tomojoh, maybe one of labrepl's dependencies has 1.2.0-master-SNAPSHOT as a dependency
01:33notsonerdysunnyhttp://pastebin.org/440415
01:34notsonerdysunnyshows the complete log of the netbeans-enclojure compile output
01:34raekmister_m: for
01:34raek,(for [x [1 2 3 4]] (inc x))
01:34clojurebot(2 3 4 5)
01:35notsonerdysunnyeven though it shows up as a warning only .. I get an error when I try to start the repl for the project
01:36tomojwhat's the error then?
01:37tomojhmm "[WARNING] JAR will be empty - no content was marked for inclusion!" that's odd
01:38tomojwell, I'm stumped, sorry, I've used neither labrepl nor netbeans
01:42raekS = {2x | x e N, x^2 > 3} --> (for [x (iterate inc 0) :when (> (* x x) 3)] (* 2 x))
01:42notsonerdysunnytomoj: http://dl.dropbox.com/u/7271654/labrepl-netbeans-enclojure-start-repl-error.png shows the screen-shot of the error-message
01:44tomoj... are you working on clojure inside a windows VM on an ubuntu host?
01:44notsonerdysunnyyea
01:45tomojI think things are probably a lot more likely to work on ubuntu than on windows
01:45tomoj(not that I think windows is causing your current problem)
01:46notsonerdysunnyk let me give direct-ubuntu a shot ..
01:48tomojI really have no idea whether your current problem is caused by windows (never used labrepl or netbeans..)
01:49tomojand since it's all java I guess it shouldn't make much of a difference?
01:49raekis this dependent on leiningen?
01:49tomojlooks like it's using mvn, not lein
01:49raekcause iirc, windows support for leiningen is still experimental
01:49notsonerdysunnyyes it is using mvn
02:21notsonerdysunnyoutside the topic ..
02:21notsonerdysunnyshouldn't freenode make all the irc-log available to the search engines..?
02:22Scriptornotsonerdysunny: freenode itself doesn't keep logs
02:22Scriptorthey're kept by individual users
02:22notsonerdysunnyoh ..
02:22notsonerdysunnyif it did it would be wonderfull!!
02:23Scriptorsome channels have official logs though kept by some bot
02:24Scriptorfor others, I think people like not having a permanent record of what they say, especially if it's just a conversational place
02:24notsonerdysunnyprobably #clojure should have one though .. :)
02:24brehautlike clojure-log.n01se.net/ ?
02:25notsonerdysunnyoh neat there is one!
02:25notsonerdysunnybut can the searach-engines access this log?
02:26Scriptoryep
02:26notsonerdysunnymay be we should mention the link where the log is available on the topic of clojure
02:28notsonerdysunnyi meant #clojure
03:05cobol_expertwhat's the best way to force a (map) to fully execute if all you care about is the side-effects?
03:06tomojdorun
03:06cobol_expert(dorun (map ...)) ?
03:06tomojbut I usually like doseq better than (dorun (map ..))
03:07tomojyeah
03:07cobol_expertawesome, it took me forever to figure out why my code wasn't running (i.e. map is lazy)
03:08unfo-cobol_expert, had the same problem :)
03:08unfo-latest commit to my clj project:
03:08unfo-(map fn coll) is *LAZY* -- thanks #clojure @ freenode :-)
03:08unfo-;)
03:09cobol_experthaha
03:10tomoj,(first (map println (range 100)))
03:10clojurebot0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
03:10tomojso.. just be careful :)
03:28notsonerdysunnyIf all I am interested in is Clojure .. should I try to learn Maven or leiningen
03:30bobo_notsonerdysunny: leinigen is simpler i belive. and fits more into clojure.
03:31bobo_but maven is probably more usefull outside of clojure. or more used atleast.
03:31brehautstart with lein unless you already do a bunch of java stuff
03:32bobo_also, with maven, you an open the project without any fuss in netbeans/eclipse/idea. if you are gonna use one of thoose
03:44notsonerdysunnythanks bobo_ brehaut .. I am using netbeans .. I will start of with leiningen ..
03:45brehautim using eclipse and bobo_ is right that maven would be more cleanly integrated
03:46brehautbut id rather be learning clojure than tools
03:47bobo_indeed, you should use what you used before
03:48bobo_i used netbeans for a while, and just used the plugin. no leinigen or maven. belive its ant based
03:48bobo_worked fine
04:21BjeringWhat is the clojure syntax to do: new byte[] { 0 }
04:25BjeringFount it I think, this: (byte-array [(byte 0)]), right?
04:29Fossithat's at least a way to do it
04:33Bjeringnext question. how do I call a static java method that takes variable no of arguments?
04:34BjeringTrying to call a static method with this signature: public static ChannelBuffer wrappedBuffer(byte[]... arrays)
04:35BjeringYet (ChannelBuffers/wrappedBuffer (.getBytes "Hello" "UTF-8") (byte-array [(byte 0)])) fails, with this: java.lang.IllegalArgumentException: No matching method found: wrappedBuffer
04:50raekI think java's variadic methods work a bit differently under the hood that one would suspect
04:50raekBjering: try doing (show TheClass) to check what the signature really looks like
04:51raek(use 'clojure.contrib.repl-utils)
04:52raek^-- that's where show is
04:52raek[18] format : Formatter (String,Object[])
04:52raekthat is what Formatter.format(String, Object...) looks like under the hood
04:53sid3kmorning guys
05:03callen-nycwould anyone like to critique my code?
05:03callen-nyctrivial, but I'd like to know if I'm violating any idioms.
05:04esjGood Morning Noble Colleagues
05:04callen-nycesj: good morning. would you like to critique some trivial code?
05:05esjcallen-nyc: i'm truly not qualified, but I'm happy to try help
05:05callen-nycesj: you read Stuart's Clojure book?
05:05esjyup
05:05callen-nycesj: is there a clojure pastebin?
05:06esjgist or pastebin
05:06callen-nycshould I just use lisp highlighting?
05:06callen-nycah gist.
05:06callen-nycesj: you know the ellipsize he demonstrated in the book?
05:06esjyeah, that's fine
05:06esjnot offhand - point me in the direction, the book is right here
05:07callen-nycit drove me nuts, here's my attempt at improving on it: http://gist.github.com/504370
05:07callen-nycthe original generated ellipsized sentences with a space between the final word and the ellipsis, drove frakking crazy.
05:07esjhehe
05:08callen-nycwent through like 4 revisions as I was getting a feel for the different way of functioning, so to speak.
05:08callen-nycthat's what I came up with.
05:08callen-nycyou want to see stuart's version?
05:08esjhmmm.... first idea is that you could just (str (last words) "...") to get the non-spaced ellipse
05:09esjand the str join " " blah blah as before ?
05:09callen-nycI'm not sure the difference you're proposing
05:09callen-nycedit the gist?
05:10esj1 sec... need to get a REPL up in front of me
05:11callen-nyc(ellip-2 "test1 test2 test3 test4 test5") returns "test1 test2 test3..."
05:11esjsorry... I misunderstood your intent
05:12callen-nycesj: anything to improve on?
05:12esjI would say that code is good
05:12callen-nycanyone care to squish my clojure neophyte ego?
05:12Chousukeit looks fine to me
05:12callen-nycit's 3 lines :P
05:13esjcallen-nyc: that's not how they do it here. No squishing.
05:13brehautcallen-nyc: its clear and it does what it needs to do right?
05:13esjyes
05:13callen-nycbrehaut: da.
05:13brehautcallen-nyc: no ego needs squishing then :)
05:13callen-nycI'm calling it finito and proceeding then.
05:13callen-nycbtw I would just like to state my undying love for leiningen and personal wish that it be replicated for all programming languages.
05:14esjif you're a real neophyte you might like to add an optional second argument that varies the number of words taken before placing the ellipse with a default of 3
05:14esjbut its pretty trivial
05:14ChousukeThe only critique I can think of is that the "sentlist" name is weird :P
05:14callen-nycChousuke: pseudo-hungarian.
05:14callen-nycalthough it's technically not a list
05:15callen-nycthe re-split returns some type I don't know the name of
05:15callen-nycbut the literal is parens.
05:15Chousukeyeah but what's "sent"? :/
05:15brehautwhat about words ?
05:15callen-nycChousuke: sentence
05:15callen-nycbrehaut: string
05:15callen-nycbrehaut: words is Mr. Stuart's nomenclature, not mine.
05:15Chousukeit doesn't return sentences though, does it?
05:15brehautoh sorry, i missed that as an arg
05:15callen-nycChousuke: it returns strings again.
05:15callen-nycChousuke: eventually.
05:16callen-nycafter the (str)
05:16ChousukeI mean the splitting operation
05:16callen-nycthat's re-split which is...clojure.contrib.str-utils
05:16Chousukebut yeah, the function is so simple the name could be frob and it wouldn't matter much
05:17Chousukeyeah, and it'd return a list of words, not sentences, right? :)
05:17callen-nyc(defn re-split "Splits the string on instances of 'pattern'. Returns a sequence of strings. Optional 'limit' argument is the maximum number of splits. Like Perl's 'split'."
05:17callen-nycChousuke: "sentence that is a list of words"
05:17callen-nycChousuke: sentlist. technically a sequence
05:17Chousukeyou have the words and sentence backwards there I think
05:17callen-nycbut I don't know the bloody difference.
05:18Chousukethe argument is a sentence, and splitting it produces a list of words
05:18callen-nycword-seq would be less moonspeaky.
05:18callen-nycwould you like it to be word-seq? :P
05:18callen-nycit is now word-seq
05:18ChousukeI think I would just change words -> string/sentence and sentlist -> words
05:19callen-nycit matches the actual type, and expresses what each object returned on iteration is.
05:19LajlaChousuke, menekaamme yhteen gaybariin.
05:19Chousukeno :P
05:19brehaut(defn ellip-2 [words] (str (->> words (re-split #"\s+") (take 3) (str-join " ")) "…"))
05:20callen-nycoi vey finnish.
05:20brehautremove the need to keep handlng the name when the ops make it clear
05:20callen-nycbrehaut: you made it points-free 'ish?
05:20brehautyeah
05:20callen-nychoopy.
05:20brehauti learn FP in haskell sorry
05:20brehautits not really point free
05:20callen-nycbrehaut: I know not technically
05:20callen-nycbrehaut: that's why I said ish.
05:20brehautcool
05:20Lajlamutta anna mun käyttää sun gaybariin, gaybariin gaybariin.
05:20callen-nycbrehaut: I fiddled with haskell before.
05:21brehauti love haskell but it breaks my brain
05:21LajlaLoppukaamme gaybarilla, gaybarilla gaybarilla
05:21callen-nycbrehaut: haskell just isn't practical.
05:21Lajlabrehaut, does clojure support continuation passing style?
05:21brehautif clojure had an ML syntax it would a) probably not work as clojure any more and b) be totally amazing
05:21callen-nycbrehaut: handling IO and state composition is just cantankerous.
05:21Lajlabrehaut, eeeewwwww
05:21brehautLajla: *somewhat*
05:21LajlaML syntax
05:22brehautthere is a continuations monad for haskell
05:22Lajlabrehaut, but I said cloure.
05:22brehautbut it runs into no tail call removal overflows
05:22callen-nycbrehaut: your version is gorgeous. please make me understand ->>
05:22callen-nycbrehaut: trampoline?
05:22brehauterr sorry ment clojure
05:22Lajlabrehaut, clojure has monads?
05:22brehautLajla:
05:22brehautyes
05:22Chousukein contrib
05:22callen-nycLajla: anything with first class functions has monads.
05:22brehautbut they are often not idiomatic
05:23callen-nycLajla: ^^ caveat.
05:23brehautjavascript can have monads if you are mad enough
05:23brehauthttp://intensivesystems.net/tutorials/cont_m.html
05:23callen-nycbrehaut: I've used currying in js before. legitimately.
05:23LajlaDon't monads require a (static) type system?
05:23ChousukeI wrote my own monad implementation for clojure a while ago
05:23LajlaAfter all, it's just a type
05:23Chousukeit's just a toy though, like a couple dozen lines of code :P
05:23brehautLajla: yes and no
05:23callen-nycLajla: naw. it's just state expressed in function composition
05:23brehauthttp://brehaut.net/blog/2010/monads_redux thats my opion of monads in clojure
05:23LajlaChousuke, mikä on gaybar suomeksi?
05:23callen-nycLajla: the reification of monads in the type system in haskell is an idiom, not an absolute.
05:24Lajlacallen-nyc, that's not really a 'monad' as in Haskell though
05:24LajlaThat's just 'a random way to use functions to express state'
05:24brehautLajla: conceptually it is and isnt
05:24brehautthey obey the monadic laws
05:24Chousukecallen-nyc: I wouldn't say "state" has anything to do with monads intrinsically
05:24brehautthere is conceptually a wrapper
05:24Chousukecallen-nyc: state is just one of the things that monads can be used to handle.
05:24callen-nycChousuke: it doesn't, I'm just speaking on how they're used
05:24LajlaAhhh, obedience brings victory, and victor yis life.
05:24Lajladefn, you can /
05:24callen-nycChousuke: this is #clojure not #lambda-calculus :P
05:24LajlaI love you
05:24LajlaYou can never ignore me
05:25defnawww, lambda calculus is fun!
05:25callen-nycmoving right along.
05:25Lajladefn, noooo
05:25brehautcallen-nyc: re what does ->> do, it stiches the first arg into as the last arg of the second form
05:25LajlaYou cannot ignore me
05:25LajlaI love you
05:25callen-nycbrehaut: explain ->> ?
05:25LajlaLike Chousuke loves child porn
05:25brehautand does that recursively
05:25callen-nycbrehaut: or at least tell me the things bloody name.
05:25LajlaLike Bush loves oil
05:25callen-nycLajla: shush you.
05:25LajlaLike women love to be raped
05:25ChousukeLajla: You really need to learn to shut up
05:25brehautdefn you have excellent ideas
05:26callen-nycbrehaut: if you tell me the name, I can google it.
05:26callen-nycbrehaut: I cannot google ->>
05:26ChousukeLajla: If you want to be weird, do that on -casual; don't be disruptive on this channel.
05:26callen-nycwait a second.
05:26callen-nyct?
05:26brehautcallen-nyc: yeah but you can search for it on clojuredocs.org
05:26clojurebotcallen-nyc: the fn created by future (like all fns) doesn't close over dynamicly scoped stuff
05:26callen-nycbrehaut: you make panda sad.
05:26callen-nycSorry, couldn't find any results for your search of '->>'.
05:26brehauthttp://clojuredocs.org/v/1660
05:26callen-nycbrehaut: liar.
05:27brehautyeah sorry
05:27brehauti browse that sight by default
05:27brehauts/sight/site/
05:27sexpboti browse that site by default
05:27brehautok thats just too cool
05:27callen-nycAHA
05:27callen-nycbrehaut: shanks.
05:27brehautno worries
05:27callen-nyclooks like a unidirectional pipe.
05:27Chousukethe first example has the good old redundant #() error :P
05:27callen-nycI'm sure that's a facile way of putting it.
05:27brehautpretty much :)
05:27Chousukeor well, not an error but an anti-idiom
05:28Chousukeoh wait never mind, I misread it
05:28brehautcallen-nyc: in ML family it would be a pipe or similar
05:29LajlaI will never abide to your twisted sense of artificial order.
05:29LajlaI bow to no man, not even to you.
05:29ChousukeLajla: k. Then you get ignored.
05:29brehautit also has a relative -> which stiches the args into the first position of the form
05:29LajlaNever shall I.
05:30brehautyou could do proper point free in clojure, but it gets bogged down in calls to partial comp and #( )
05:30brehautand all the overhead of being so incredibly explicit about it all defeats the purpose
05:31sid3khow can I add clojure-contrib directory to classpath? I'm not familiar with java stuff
05:31callen-nycbrehaut: yeah I did OCaml.
05:31brehautsid3k: java -cp clojure-contrib.jar ?
05:31callen-nycbrehaut: btw, I think 2 lines is short enough for this :)
05:31brehautcallen-nyc: sure :)
05:31sid3kbrehaut: it raises an exception
05:31callen-nycno.
05:31callen-nycjust have him use leiningen
05:32callen-nycone nubcake to another. just use lein.
05:32brehautyeah that works too, its my prefered solution ;)
05:32callen-nycbrehaut: hypocrite >:P
05:32brehautaccidentally overly literal
05:32brehautsid3k: have you heard of leiningen ?
05:33sid3kwhat should I do put in that command instead of ? sign?
05:33brehautoh you dont need the question mark
05:33brehautit was intended as just the beginning of your (soon to be monsterous) incantation
05:34brehautare you on linux, mac os x or another *nix?
05:34callen-nycbrehaut: I've named ->> The Winchester. It shoots things that way ->
05:34sid3klinux
05:34defnlol
05:34brehauthaha
05:34defn"The Winchester"
05:34callen-nycdamned skippy.
05:34defnI call -> Whistler's Mother
05:34raekto start a repl with contrib manually, you can do java -cp 'path/to/clojure.jar:oath/to/clojure-contrib.jar' clojure.main
05:34sid3kbtw, what's the lein way?
05:34callen-nycdefn: lol.
05:34callen-nycsid3k: it's a shell script you put in your bash path.
05:34raek*path/to
05:34brehautsid3k: github.com/technomancy/leiningen
05:35defnwould -> be an inverted whistler's mother?
05:35raekbut with lein, it's simpler
05:35sid3kraek: this is what I'm looking for, thanks
05:35defnI can't remember which way she's sitting
05:35raeklein new my-proj; cd my-proj; lein deps; lein repl
05:35brehautsid3k: it handles project dependancies for you
05:35callen-nycsid3k: you describe project dependencies/versions/libs in project.clj, run lein deps, it gets everything going locally, then lein repl to fiddle around.
05:35callen-nycsid3k: personally, I run swank-clojure -> emacs slime, but that's me.
05:36brehautsid3k: related is http://github.com/liebke/cljr which is based on lein and provides the repl without needing to create a project
05:36raekbetween the cd and lein deps step, instert: "edit project.clj and specifiy dependencies (clojure and clojure contrib will be filled in by default)
05:36callen-nycI am a laaaaazy bastard, so I loves me some slime.
05:36sid3kcallen-nyc: me too?
05:36brehautcallen-nyc: no need to scare the new guy
05:36callen-nycbrehaut: I was using emacs when I was 10. :(
05:36brehautcallen-nyc: i used emacs for about 7 years and eventually just got sick of it
05:37brehauti hate futzing with my tools
05:37callen-nycbrehaut: I don't use it for everything.
05:37callen-nycbrehaut: as do I.
05:37callen-nycI just grab the right tool for what I'm doing.
05:37callen-nycfor workaday, I'm usually in gedit because I have to deal with a ridiculous number of files.
05:37brehautfor workaday im stuck in .net land so i have exactly one choice :(
05:37sid3kraek I'm using this line "alias clj=clj-env-dir" to start clojure
05:38callen-nycbrehaut: ooh. I left .NET 2 years ago.
05:38callen-nycbrehaut: I'm in django-land now. :)
05:38sid3kas I understand I should change this line too
05:38callen-nycbrehaut: maybe F# will saves you?
05:38brehautcallen-nyc: i recall having this discussion the other night :)
05:38callen-nycwait a tic.
05:38callen-nycbrehaut: I'm terribly sleep deprived, pardon me.
05:38brehautcallen-nyc: only one problem, my coworkers dont understand it
05:38brehautno problem
05:38sid3kcallen-nyc: try tornado, its much better and pythonic
05:38callen-nycbrehaut: fuck them, do all the work yourself with F#
05:39callen-nycsid3k: uh, that's not how working for a company works.
05:39callen-nycsid3k: they have shit. they want shit changed. you change shit as described. you don't re-implement the whole backend on a whim.
05:39callen-nycsid3k: it's a backend web service, not a high traffic frontend that needs to be evented.
05:39sid3kcallen-nyc: in my previous job, I used django for just administration panel, it's the only thing django does well
05:39callen-nycsid3k: don't make lib recommendations to people when you don't have a clue what they're working on.
05:39callen-nycsid3k: we don't even use the ORM, the database is couchdb. :P
05:40brehautman, i totally love couch now
05:40callen-nycit's actually one of the largest clusters of couch that are publicly known.
05:40brehautim still getting my head around writing the views
05:40callen-nycbrehaut: s'okay. it's not great when you need up to the minute stats for the frontend though.
05:40sid3kbrehaut: btw, what should I do with lein ue what they're working on. [05:40]
05:40sid3k<callen-nyc> sid3k: we don't even use the ORM, the database is couchdb. :P
05:40sid3kERC>
05:40sid3kfuck, sorry
05:40callen-nycbrehaut: it's great for map-reduce + views
05:40callen-nycsid3k: stop while you're ahead mate :)
05:41callen-nycbrehaut: and general ability to do processing during high-writes
05:41raeksid3k: in my experience, when your code needs a jar from somewhere else, you'll want to use a project management tool lile leiningen
05:41callen-nycbrehaut: but not so great for recent reads.
05:41callen-nycraek: ie, everything.
05:41raekyes, eventually...
05:41sid3kall right, what should I do with lein? which command I need to type?
05:41brehautcallen-nyc: im replacing my creeking python+django site with clojure+couch+the cgrand stack
05:41callen-nycsid3k: read the readme/tutorial
05:41raekfirst, do you have the lein script?
05:41callen-nycsid3k: it goes over the basic project pattern.
05:42sid3kyeah
05:42sid3kI used lein before for the swank things
05:42raekor, first first, do you develop under windows?
05:42callen-nycbrehaut: personal sites are good for experimentation like that.
05:42raekok
05:42brehautcallen-nyc: absolutely
05:42sid3knope, linux
05:42brehautbbs
05:42brehautgetting dinner cooking
05:42callen-nycbrehaut: that said, be aware that couchdb is terrible for ajax stuff that needs to be up to the minute.
05:42raekcreate a new project somewhere by running "lein new <project name>"
05:43sid3kall right
05:43raekthat will create a directory with a project.clj file, and some subdirectories for tge source, etc
05:43LauJensenraek: only true, if <project name> is something technomancy approves of
05:43sid3kraek: created
05:43raekedit the project.clj file and add any dependencies you like
05:43raekor change the versions of clojure and contrib
05:43sid3klike?
05:44sid3kproject.clj contains this line: "org.clojure/clojure-contrib "1.2.0-beta1""
05:44raekyou could add swank-clojrue: :dev-dependencies [[swank-clojure "1.2.1"]]
05:44raekthat version is fine
05:44brehautcallen-nyc: cheers for the heads up :) up to the minute is not what my blog is about :)
05:44raekI think there is a RC1 version now
05:45brehautraek: you are correct
05:45raekafter you're done with that, run lein deps, standing in the project directory
05:45sid3kraek: I've added that
05:45callen-nycbrehaut: I know, just letting you know how the battle-lines is
05:46raekafter that, just run "lein repl" or "lein swank"
05:46callen-nycbrehaut: up-to-the-minute type stuff is more mongo // cassie
05:46callen-nycbrehaut: we might be deploying a cassandra cluster for that very reason soon, since nobody at my company seems to trust mongodb, hahaha.
05:46sid3kraek: completed and put Copying 3 files to /tmp/test/lib
05:47raeklein repl, will start a repl with those 3 jar file and the src/ directory on the class path,
05:47sid3kwhich command displays classpath in repl?
05:48callen-nycthat's an excellent question.
05:48brehauthttp://clojuredocs.org/leiningen/leiningen.classpath
05:49raek(println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
05:50callen-nycI need to stop eating raw hamburger.
05:50brehautthere is also clojure.contrib.classpath
05:50raekI hope this will get you started
05:50raekif you need another lib, just add it to the project.clj and restart the repl
05:50callen-nycraek: ahem. lein deps first.
05:51callen-nycproject.clj -> lein deps -> lein repl
05:51sid3ktyvm for help, but I get the problem now, finally
05:52sid3kmy cli repl already has clojure-contrib directory in its classpath
05:52sid3kproblem is in my slime backend actually
05:53sid3kI guess now I can fix it, thank you
05:55callen-nycI'm hard at work on the internet popularizing the use of "The Winchester" for ->>
05:55defncallen-nyc: hahaha
05:56defncallen-nyc: please try to throw in "whistler's mother" for ->
05:56callen-nycdefn: what's the reference for that? Blade?
05:56defnit's a famous painting
05:56callen-nycohhhh
05:56callen-nycthe painting.
05:56defnit's sort of wrong because i think whistler's mother is more like <_
05:56defn<-
05:56callen-nycdefn: because it roughly matches how she's sitting?
05:56defnbut the thing is, it's so lonely
05:56defnjust like whistler's mother
05:56callen-nycdefn: so do you want -> to be whistler's mother?
05:57defnyes i do
05:57defni want it with every aching beat of my heart
05:57defn:D
05:57callen-nycdefn: tweeting nao.
05:57callen-nycdefn: I'll start pestering people on /r/clojure about it too.
05:57defnhaha that's awesome
05:57defnthanks callen!
05:58callen-nycdefn: I'm aiming the tweet at Hickey
05:58callen-nycit's in the ether.
05:58defnpeople arent going to go for whistler's mother on the -> i dont think
05:58defnbut they're wrong i tell you
05:58callen-nycdefn: I'm just going to hover over discussions of clojure (I have a yahoo pipe that feeds me EVERYTHING) and correct everyone.
05:59callen-nycdefn: the more people discuss ->, the more likely it'll spread.
05:59brehauti'd rather not bite your app thanks very much :P
05:59callen-nycmy cat agrees. our nomenclature is superior.
05:59callen-nycbrehaut: way to watch twitter.
05:59brehautthats right
05:59defnive discussed this at length with my cat as well
06:00callen-nycmy cat has epic whiskers
06:00defngreat minds, as they say...
06:00callen-nycshe looks like a double-barreled winchester.
06:00esjWhisters Mother - lol
06:00callen-nycdefn: even furry minds.
06:01defni have an idea
06:01defnmaybe -> is iwogima
06:01callen-nycHAHAHAHA
06:01callen-nycno that's
06:01callen-nyco\
06:01defnhahaha
06:01callen-nycdefn: get hickey to let us fuck the reader with macros so we can make o\ Iwo Jima
06:02callen-nycdefn: I like The Winchester because it describes what the macro does as well as what it looks like.
06:02brehauti just hope nobody ever makes a nighthawks operator
06:02brehautcause that would be a nightmare to type
06:02defna nighthawk's at the diner operator
06:02defna la Tom Waits
06:03callen-nyc :(
06:03sid3karright, fixed finally
06:03callen-nycmy kitty just banged her knee :(
06:04defn-> is washington crossing the delaware
06:04sexpbotjava.lang.Exception: Unable to resolve symbol: is in this context
06:04callen-nycdefn: no changing mind allowed.
06:04defndamn
06:04callen-nycsexpbot: yo symbol don't exist yo.
06:05callen-nycsexpbot: bad ns, bad def, bad defn, w/e
06:05defni just got everyone in the office to give me famous paintings of characters facing east or to the right
06:05callen-nycdefn: lmfao.
06:08defncallen-nyc: so yes, whistler's mum and the winchester
06:08defnwhich reminds me of a cartoon i saw, looney toons from many years ago
06:08callen-nycdefn: righto.
06:08defnwherein whistler's mother pulled a winchester out from under her skirt
06:08defn(-> (->> ...))
06:08callen-nycdefn: seriously? that makes it even better.
06:10LauJensenHas anybody here got an idea about how to use Rings session middleware? Just decorating a handler only passes around an empty {}
06:10brehautLauJensen: i've only used it via moustache
06:10callen-nycdefn: who's thickey? Rich's long lost evil twin?
06:10LauJensenbrehaut: got a snippet+
06:11brehauti'll make a gist or something
06:11LauJensencool, thanks
06:11LauJensenIf you have gist.el, just mark the region and hit M-x gist-region
06:12brehauti dont use emacs sorry
06:12LauJensennp - there's a webinterface for it then
06:12brehautyup
06:12brehautits rough and ready http://gist.github.com/504433
06:13defncallen-nyc: thickey is tom hickey
06:13defni believe his brother, pretty sure he did the clojure site
06:14brehautLauJensen: sorry about the dreadful code, i'm only a n00b
06:14callen-nycdefn: fascinating. programmer or designer?
06:14defncallen-nyc: http://1.bp.blogspot.com/_4OYGjUrdllo/STNrCcmik_I/AAAAAAAAMyw/thuhBLYwhN0/s400/whistler.jpg
06:14defncallen-nyc: dont really know
06:14callen-nycdefn: hahahahaha
06:14callen-nycthickey_: what are you?
06:15callen-nycthickey_: and don't answer human. we knew that.
06:15esjcallen-nyc: its Tom Hickey, as defn says
06:15LauJensenbrehaut: the code looks alright, but Im not seeing any calls to session?
06:15callen-nycesj: what not who
06:15brehautoh sorry the session one in particular?
06:15LauJensenYea its the session middleware which isnt behaving, everything else works alright
06:15brehautah right. sorry its late here and im getting a little daft
06:15LauJensenbrehaut: my entire site (bestinclass.dk) is run using only enlive/moustache
06:15LauJensenhehe, np
06:15brehautLauJensen: yup, ive read it
06:16callen-nycLauJensen: that's you? nice.
06:16LauJensenyea
06:18brehautLauJensen: you editors for clojure article was invaluable when i got sick of textmates support
06:19LauJensenbrehaut: my editors?
06:19LauJensenoh that one
06:19LauJensenNow I remember - Glad you liked it :)
06:20callen-nycLauJensen: you used the term "IDEs"
06:22LauJensenyea
06:22callen-nycLauJensen: ooooh. you baked the site.
06:22callen-nycLauJensen: I need dynamic eval demos :P
06:24LauJensenYea its nice and baked. Next step is to make some fancy browsing for the content that is already there
06:25brehautLauJensen: do you do all the form processing yourself or is the a lib worth investigation?
06:26LauJensenI did it all myself, and its all on Github
06:26brehautsweet, i'll go have a read
06:26LauJensenSomebody submitted a much better way to handle comment/captchas in the comments on that baking article though, cool macro
06:26callen-nycLauJensen: ...baked comments?
06:27callen-nychao?
06:27LauJensennaah, just dynamic captchas which produce lisp statements
06:27LauJensenBut yea, actually the comments are baked in a way
06:27callen-nyc....eeeeeek
06:27callen-nycyou're dynamically producing code based on user input?
06:28LauJensennope - but it was suggested, and it was good - I just didnt take the time
06:28callen-nycthat sounds ridiculously dangerous to me.
06:28LauJensenits not
06:28LauJensenoh wait sorry
06:29LauJensenI misread. The macro spits out a statement like (+ 15 (* 2 (/ 4 2))), and you supply the answer in the captcha
06:29LauJensenSo its completely safe, and its not based on user-input
06:29callen-nycoh.
06:29callen-nycI misunderstood.
06:29LauJensenRight now my Captchas are hardcoded
06:30brehautLauJensen: am i correct in my reading of the code that its flat file backed and uses a ref to hold the model in memory?
06:30callen-nycLauJensen: how are the comments stored and rendered?
06:30callen-nycLauJensen: what web server are you using to serve your static content?
06:30LauJensensec, phone
06:31opqdonutwhat's a nice way of "calling" another clojure script
06:31opqdonut(use 'name.space) seems a bit ugly
06:32callen-nycopqdonut: is it even possible to make it shorter than that?
06:32opqdonutload is okay but it wants a path. I'd rather use the name of the namespace
06:32brehautopqdonut: require ?
06:32opqdonutrequire sounds better
06:32brehauti'll load the other file and not polute the current namespace
06:32opqdonutuse looks too much like an import
06:32opqdonutyes
06:33callen-nycopqdonut: my cat agrees, use require.
06:35defncallen-nyc: my cat says meow
06:36callen-nycdefn: my cat sits in my lap when I code.
06:36callen-nycdefn: she likes watching my hands, especially when I'm ^ X ^ E'ing.
06:36callen-nycshe's sitting in my lap right now, but kinda sleepy.
06:36callen-nycI've been coding all night, it's 6:36am
06:37sid3kcallen-nyc: freelancer?
06:37defnShe's all like "WUT THIS HOTKEY DO?"
06:37sid3kor remote conractted?
06:37callen-nycsid3k: contractor, but it was a sunday night, I was coding for pleasure.
06:37callen-nycdefn: she sits her butt on my keyboard occasionally.
06:37callen-nycsid3k: remote contractor, da.
06:37sid3kprogramming is the best hobbie I've know
06:37callen-nycsid3k: picking up a laptop in a couple hours, then working until 8 pm
06:38callen-nycand then, passing out more than likely.
06:38callen-nycthat or hacking moar.
06:38callen-nycdepends on how whiny the cat gets // wants attention.
06:38callen-nycdefn: :3 is now the 'kitty key'
06:39LauJensencallen-nyc: comments are stored directly in the html, thats the whole point of baking. NGINX is serving statics
06:39callen-nycLauJensen: should've been more than 250% faster unless you have the PHP rig super-cached to hell.
06:40callen-nycLauJensen: what processes the comments mate? it has to be dynamic at some point.
06:40LauJensenbrehaut: comments are held in a memory queue and flushed once in a while to a flat-file, to avoid a race condition on the fs
06:40LauJensencallen-nyc: Jetty/Moustache
06:40brehautLauJensen: ah right, nice
06:40LauJensencallen-nyc: I think it performs better under higher load, didn't press it
06:40callen-nycLauJensen: was the PHP setup heavily tuned/cached?
06:40LauJensencallen-nyc: yea
06:41callen-nycLauJensen: that explains it. regardless if you hammer nginx with high concurrency load it's going to vastly outperform.
06:41callen-nycLauJensen: baking might be a better idea for any website that is mostly content.
06:42callen-nycLauJensen: one potential idea, to solve race conditions, queue changesets/transactions, feed them into map-reduce on a database, dump from database into flat files
06:42LauJensencallen-nyc: Yea, when it dawned on me that both the html presentation and sql data, were both the very same thing, I couldnt resist fusing them. With Enlive you can browse an html file as easily as an sql database
06:42callen-nycLauJensen: that'll solve your reader/writer problem.
06:42callen-nycLauJensen: virtually any map-reduce capable database would work.
06:42LauJensencallen-nyc: all race conditions are ironed out and dont need databases. The trick is to boil the I/O down to calls to 'mv' which is atomic
06:42LauJensenI would really hate to have to get a database back into play
06:43callen-nycLauJensen: the point is that the database is arbitrating change resolution and allowing unblocked reads (async differential dumps to statics) while writes are incoming.
06:43LauJensencallen-nyc: this is no different
06:43LauJensenyou have your data in file1, then you write the next version in file2, then call 'mv file2 file1', which is atomic. Nothing blocks
06:43callen-nycit's quite different, you're using mv wrapped in atomicity as a database.
06:44brehautcallen-nyc: http://github.com/LauJensen/bestinclass.dk/blob/master/src/bestinclass/comments.clj
06:44LauJensenmv is atomic, Im not wrapping :)
06:44LauJensenAnd yes, the fs is my database, thats the whole point of baking
06:44callen-nycLauJensen: call me paranoid, but it's not something I'd ever do.
06:45callen-nycLauJensen: baking sure.
06:45callen-nycLauJensen: arbitrating changes via fs. no.
06:45callen-nycnot for anything even slightly important.
06:45LauJensenIs your attitude based on anything rational?
06:46LauJensen(not meant sarcastically)
06:46brehautLauJensen: the only down side i can see with your code is the unlikely even that the who JVM dies and you loose 1 minute of comments?
06:46callen-nycLauJensen: personal experience with hacky things I've seen before, so, anecdote, and knowledge of how VMs work such that the notion of streaming writes into anything but something like a database makes me cringe.
06:46LauJensenbrehaut: thats right, there is no durability guaratees for in-memory storage
06:46callen-nycLauJensen: frankly, I take reliability pretty seriously and if I lost data I'd be really mad.
06:46xkbhi all
06:46callen-nyc(not (.contains url ".."))) <--- nice protection :P
06:46LauJensencallen-nyc: Ive never lost data - This is not less secure than a database.
06:47LauJensencallen-nyc: hehe :)
06:47callen-nycLauJensen: what do you usually work in?
06:47xkbWhat would be the most idiomatic way to retrieve JSON from a web-server?
06:47callen-nycxkb: ask nicely.
06:47LauJensencallen-nyc: You mean clothes-wise? :)
06:47xkbI'm using readers now :)
06:47callen-nycLauJensen: field, specialty, ken.
06:47LauJensencallen-nyc: Best In Class is my consultancy company, specializing in Clojure
06:47callen-nycLauJensen: so webapps?
06:47LauJensenAmong other things
06:48callen-nycLauJensen: I appreciate that the cavalier infrastructure you're using for your blog/whatever site is working fine
06:49callen-nycLauJensen: but please, for the sake of your clients, do not inflict a "filesystem as database" webapp on any of them.
06:49LauJensencallen-nyc: My clients usually respond best to rational arguments, based on performance, maintenance cost, development time etc, sometimes fs as db is the best, often its not
06:50callen-nycLauJensen: I've done a lot of data (base) wrangling in the past, and I've dealt with hacky setups that just wrote to the fs as a means of persistence, and it was a horror.
06:50callen-nycLauJensen: it's simply irresponsible.
06:50callen-nycLauJensen: regardless of what you think is logical.
06:50LauJensencallen-nyc: I dont see how - You're afraid the fs will be corrupted? What do you think happens to a db situated on a corrupted fs?
06:50callen-nycyou're missing the point by a mile.
06:51LauJensenrepeat it please
06:51callen-nycyou aren't grokking the myriad directions data loss can come from
06:51callen-nycno.
06:51callen-nycyou're an axe to grind.
06:51callen-nycyou've got your personal roof to thatch and I'm not going to go on a crusade for sake of people whom I'm not responsible for.
06:51LauJensenhehe
06:51callen-nycif you won't listen, it's not my angry clients.
06:51callen-nycLauJensen: I don't find this amusing at all.
06:52LauJensencallen-nyc: I find it very funny. Im asking you to state your case, and you reply by calling me an axe and saying I wont listen :)
06:52callen-nycLauJensen: I've had total data loss with 3 synced copies of data before.
06:52callen-nycLauJensen: comprende? I've seen the "worst case scenario" before
06:52LauJensenwow, and you're calling me irresponsible? :D
06:52callen-nycLauJensen: shut the fuck up
06:52LauJensenhaha
06:52callen-nycLauJensen: it wasn't my setup, I inherited it
06:52LauJensenCome on - That was funny
06:52callen-nycLauJensen: I had to do data recovery
06:52callen-nycLauJensen: I don't find this funny at all, get serious or stop talking to me.
06:52callen-nycLauJensen: it was a horrifying week.
06:53callen-nycLauJensen: I had three hard drives of different makes and ages die at the same time, on two different computers.
06:53callen-nycLauJensen: that's absurdly improbable, more so than the kinds of odds you're playing with a fs-as-database
06:53callen-nycLauJensen: it's a stupid design for data you even slightly care about.
06:54callen-nycI refuse to even deploy mongodb for a client with 3 machines plus a back-replication.
06:54LauJensenIm just not seeing where leaving out the actual database is elevating the risks? If I rsync the /bestinclass/ folder to 3 different systems - how is a database more safe?
06:54callen-nycwithout
06:54callen-nycLauJensen: your know-nothingness is not my problem. I'm done chasing the troll.
06:54LauJensenIf anything, the database adds its own concerns
06:54callen-nycback to coooode.
07:38BjeringI left for a long lunch-meeting, but now back and perhaps I missed a solution to my problem. Sadly it remains her on my end, how to I call a java method with this signature? public static ChannelBuffer wrappedBuffer(byte[]... arrays)
07:38Bjering(to-array '((byte-array [(byte 0)]) (byte-array [(byte 0)]))
07:38Bjering)
07:39Bjeringgives me Object[], and it needs byte[][]
07:40ChousukeBjering: first of all, you don't want to quote the list like that; you'll get an array that contains a list
07:41ChousukeBjering: you want (to-array [(byte-array [0]) (byte-array [0])]) or something
07:42Chousuke(there's no need to convert the 0s to bytes, literal vectors can't contain them anyway)
07:42esjwould into-array be better as it figures out the type ?
07:43Chousukemultidimensional arrays are horrible to use from clojure ;/
07:43ChousukeI think mostly because multidimensional arrays are horrible, and java just tries to hide that from you
07:43esjgood point indeed
07:44esjtoo bad the mathmeticians are so into them :)
07:44callen-nycChousuke: alternatives to multi-d arrays?
07:44Bjering(to-array [(byte-array [0]) (byte-array [0])]) throws ClassCastException
07:44callen-nycChousuke: clever key names? :P
07:44Chousukewhat byte[][] actually is in java IS a Object[]
07:44Chousukeand the Objects are byte[]s :P
07:44esjaaah
07:45BjeringChousuke, what I really want todo is call the vararg method listed above, google let me thing to-array was the way todo it with clojure.
07:45Chousukehmm
07:45Chousuke(doc to-array)
07:45clojurebot"([coll]); Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util.Collection.toArray()."
07:45Chousukeokay so that one is not the problem
07:45Chousuke(doc byte-array)
07:45clojurebot"([size-or-seq] [size init-val-or-seq]); Creates an array of bytes"
07:46esj,(doc into-array)
07:46clojurebot"([aseq] [type aseq]); Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
07:46esji've successfully used this for Java varargs functions
07:46Chousuketo-array should work just as well
07:47esjok
07:47Chousukeand I can't see why byte-array doesn't
07:48Bjering,(to-array [(byte-array [(byte 0)]) (byte-array [(byte 0)])])
07:48clojurebot#<Object[] [Ljava.lang.Object;@fc990c>
07:48Chousukethat looks correct.
07:48Bjering,(to-array [(byte-array [0]) (byte-array [0])])
07:48clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte
07:48Chousukehm.
07:48Chousukeoh, right, duh
07:48callen-nycstatic typing system biting you in the balls.
07:48callen-nycwhy in good ole' C, it'd just let you shoot yer arm off :P
07:49Chousukethe casting decides which object it gets boxed at.
07:49Chousukeas
07:49Bjeringnow the real problem is it doesnt match this Object[] to the right overload (the byte[]... vararg one)
07:49Chousukeyou might want to call (byte-array 1 0) instead so you can avoid the casting and vectors :P
07:50ChousukeBjering: so it has multiple varargs overloads? :/
07:50Bjeringyes
07:50Chousukeare there any other parameters?
07:50Bjeringin some of th overloads yes, not in this one.
07:51ChousukeI have no idea how to typehint that :P
07:52Chousuke,(class (byte-array 1 0))
07:52clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
07:52callen-nycand just a reminder to everyone why you're here instead of #haskell: http://www.haskell.org/haskellwiki/Zygohistomorphic_prepromorphisms
07:52Chousuke,(class (byte-array 1 [0]))
07:52clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte
07:52Chousuke,(class (byte-array [(byte 0)]))
07:52clojurebot[B
07:54BjeringChousuke: Here is the API I am trying to use, if it helps to know what overloads wrappedBuffer has: http://docs.jboss.org/netty/3.1/api/org/jboss/netty/buffer/class-use/ChannelBuffer.html
07:56defncallen-nyc: still awake?
07:56esj,(class (into-array (byte-array [(byte 0)])))
07:56clojurebot[Ljava.lang.Byte;
07:56Chousukehmm"
07:57Chousuke,(Class/forName "[[B")
07:57clojurebot[[B
07:57Chousukeso it looks like byte[][] is a special class after all
07:58Chousuke,(into-array (Class/ForName "[[B") [(byte-array [(byte 0)]])
07:58Chousukelooks like clojurebot got bored of arrays :P
07:59Chousuke,(into-array (Class/forName "[[B") [(byte-array [(byte 0)]])
07:59clojurebotUnmatched delimiter: ]
07:59Chousuke,(into-array (Class/forName "[[B") [(byte-array [(byte 0)])])
07:59clojurebotUnmatched delimiter: ]
07:59clojurebotjava.lang.IllegalArgumentException: array element type mismatch
08:00Chousukeargh
08:01Chousuke(doc make-array)
08:01clojurebot"([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
08:02ChousukeI think that's your function
08:02Chousukethen you just need to populate it manually
08:02Bjeringinto-array works :)
08:03Chousukefortunately java arrays are mostly an interop problem ;/
08:04Bjeringyes, its not code I'll write often, but appearantly I need it sometimes.
08:04Bjeringmy finished function: https://gist.github.com/7c931dbedfb6eb488131
08:10ChousukeBjering: I suggest using the sugared interop syntax instead of .
08:11Chousukeie. (ChannelBuffers/wrappedBuffer ...)
08:12Bjeringyes, nicer
08:12ChousukeUsing . should be reserved for code generated by macros.
08:15esjI got one ?
08:16noidi,(= (double (float 0.123)) 0.123)
08:16clojurebotfalse
08:16noidi,(type 0.123)
08:16clojurebotjava.lang.Double
08:16noidiwhat's up with that?
08:17noidiah, rounding errors
08:17noidi,(double (float 0.123))
08:17clojurebot0.12300000339746475
08:17noidiman, I hate floating point :P
08:18noidi,(float 0.123)
08:18clojurebot0.123
08:18esj(- (float 0.123) (double 0.123))
08:18esj,(- (float 0.123) (double 0.123))
08:18clojurebot3.3974647539736225E-9
08:18esjso annoying
08:19noidiI didn't expect any error to be introduced when moving to a larger type (float -> double)
08:22raekfloating point numbers are inherently inexact; (non-approximative) equality does not make much sense for them
08:23raek,(+ 1.0 10000000000000000000000000.0 -10000000000000000000000000.0)
08:23clojurebot0.0
08:24esjhahahah
08:29xkbIf I want to use butlast from contrib, what should I require?
08:29xkbI keep getting errors
08:29xkbclasspath wise
08:30LauJensenxkb: the butlast in core isnt good enough?
08:31noidiraek, in my case it sort of does, I serialize and deserialize floats so in my tests I want to check that they're read back correctly
08:31xkbhmm might also work
08:31xkbLauJensen: let me try
08:31LauJensenif not, you only need the contrib.jar file on your classpath, and then require the lib containing the fn, in this case its seq-utils IIRC
08:31defnis this a good example of val?
08:31defn,(map val {:a 1 :b 2})
08:31clojurebot(1 2)
08:31defnor am i missing something more idiomatic?
08:32Chousukethat's good I think
08:32LauJensendefn: looks fine to me
08:32defncool, thanks
08:32LauJensenIIRC it only works with MapEntries
08:32defnim trying to fill up clojuredocs :)
08:34defncould someone explain force to me?
08:34hircusLauJensen: works for a map-style vector too -- (map val (into [] {:a 1 :b 2}))
08:34hircus,(map val (into [] {:a 1 :b 2})
08:34clojurebotEOF while reading
08:34defnhircus: good example
08:34defnmay i use it?
08:34hircus,(map val (into [] {:a :b 2}))
08:34clojurebot3
08:34LauJensen,(map class (into [] {:a 1 :b 2}))
08:34clojurebot(clojure.lang.MapEntry clojure.lang.MapEntry)
08:35LauJensenhircus: Its the same thing, element wise
08:35hircusah
08:35defnah, yeah, good point, i dont want to extrapolate on every example by providing an into i dont think
08:35Chousukehmm
08:35defnwill just get bloated that way
08:35Chousuke,(val [1 2])
08:35clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry
08:35hircusdefn: certainly. code snippets are too silly to claim copyright on :)
08:35defnhircus: it's polite to ask :)
08:35hircusyou're welcome
08:35defnit's idiomatic in this community to ask i should say
08:35defn:)
08:37xkbAha, the butlast in core does something else as I wanted to
08:37xkbbut last in str does (butlast 3 "sander") => "san"
08:38xkbas in all but last #
08:42n2n3,(eval)
08:42clojurebotDENIED
08:42n2n3,(eval 'hello)
08:42clojurebotDENIED
08:43hircusn2n3: eval is dangerous :)
08:43defn,(read (eval 'hello))
08:43clojurebotDENIED
08:45LauJensenChousuke: Did you work out why your call to val failed ?
08:46raeknoidi: you might want to check whether the difference between the original value and the read value is under a certain value (or the percentage of their mean value)
08:47raekcertain float values don't have exact decimal represenations and vice versa
08:47ChousukeLauJensen: in the vector case? I suppose two-element vectors aren't map entries :P
08:48LauJensenChousuke: (into [] {:a 5 :b 10}) => [[:a 5] [:b 10]], sending that to map val work. Manually calling (map val [[:a 5] [:b 10]]) fails like yours did, although the class is the same.
08:48ChousukeLauJensen: it's not.
08:48ChousukeLauJensen: map entries print as vectors, but vectors aren't map entries.
08:48raek,(class (first (seq {:a 1}))
08:48defnhow do i properly use the :validator option on a ref?
08:48clojurebotEOF while reading
08:48raek,(class (first (seq {:a 1})))
08:48clojurebotclojure.lang.MapEntry
08:49LauJensen,(class (into [] {:a 5 :b 10}))
08:49clojurebotclojure.lang.PersistentVector
08:49LauJensen,(class [[:a 5] [:b 10]])
08:49clojurebotclojure.lang.PersistentVector
08:49LauJensen,(into [] {:a 5 :b 10})
08:49clojurebot[[:a 5] [:b 10]]
08:49ChousukeLauJensen: you're not calling val on the vector, but its contents
08:49raekbut conj accepts both MapEntries and vectors?
08:49ChousukeLauJensen: which are map entries
08:49LauJensenAh right - Good morning all :9
08:50Chousukeraek: mapentries immplement the vector interface
08:50hircus,(class (first [[:a 5] [:b 10]]))
08:50clojurebotclojure.lang.PersistentVector
08:50raek*(conj a-map a-vector/a-map-entry)
08:50Chousukedefn: isn't it a function of the value that the ref would hold?
08:50defnChousuke: hrm...
08:50hircusChousuke: so (into [] a-map) basically is a no-op, just return a pointer that's tagged as a vector?
08:51defnChousuke: what does it look like though?
08:51Chousukehircus: no
08:51Chousukehircus: the map can only be converted into a seq of map entries, not directly into a vector of map entries
08:51raek,(into [] {:a 1, :b 2})
08:51clojurebot[[:a 1] [:b 2]]
08:51defndo you refer with :validator (...) somehow to the value of the ref? does it apply to the in-trans. value?
08:51Chousukehircus: into transforms that seq into a vector
08:52raekreturn a vector of MapEntries
08:52defnis :validator like a :pre or :post?
08:52hircus*ah* ok
08:52Chousukedefn: only the value that would be committed
08:52Chousukedefn: and it's a function, it needs to take a parameter
08:53defnChousuke: so (def myref (ref [] :validator (< 4 %))???
08:53hircus,(map val (vector (clojure.lang.MapEntry. :a 5)))
08:53clojurebot(5)
08:53hircusneat :)
08:53Chousukedefn: #(< 4 %)
08:53defnerr right that's what i meant
08:54Chousukedefn: but yeah, just like that
08:54Chousukethough the initial value must of course pass the validator too :D
08:55Chousuke,(ref [] :validator pos?)
08:55clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
08:55defnChousuke: haha yes
08:55Chousuke,(ref 1 :validator pos?)
08:55clojurebot#<Ref@a9a4f: 1>
08:55defnahhhhh
08:55defnthanks Chousuke
09:05cpfrhey my code is giving a java exception that is being cutoff
09:05cpfrhow can i pipe it so i can see the full error
09:07n2n3,
09:07clojurebotEOF while reading
09:08n2n3,def
09:08clojurebotjava.lang.Exception: Unable to resolve symbol: def in this context
09:08n2n3,(println)
09:08clojurebot
09:08cpfranybody?
09:09raekcpfr: are you in the repl?
09:09cpfrraek, nope running on the command-line
09:10cpfri use swank for most of my dev work
09:10cpfrbut when actually running the code, there is pain
09:10raekso, the exception does not happen in the swank repl thread?
09:10raekwhere is it printed from?
09:11xkbhmm if I call read-json on a previously opened BufferedReader I get a class-cast exception, LazySeq cannot be cast to PushbackReader
09:11xkbany way to fix this?
09:11raekif you get an exception in the repl, it is bound to the variable *e
09:11cpfrraek, not sure how to get it to print
09:12raekbut something prints it? or how do you see it cut off?
09:13raekxkb: are you sure that you pass the buffered reader to read-json?
09:13cpfrim pasting right now
09:13xkbraek: I take away 2 substrings before passing it
09:13xkbraek: does that change anything? I can paste the code in pasty if u like?
09:13cpfrhttp://paste.lisp.org/display/113066
09:13raekxkb: a paste would help
09:14raekhow do you do substring operations on readers?
09:14cpfrI am trying to extend a class method that returns boolean[]
09:14raekcpfr: heh, that's the internal JVM notation of vectors
09:14raek[type
09:15xkbraek: http://paste.lisp.org/display/113067
09:15xkbhappens on calling userbooks
09:15xkbits my first attempt at anything beyond hello world btw :P
09:15cpfrraek I used the code (into-array [true true])
09:16cpfrdoesn't that get me to type boolean[]
09:21xkbraek: any tips? :)
09:22cpfrraek, so how do I get the risk of that exception error
09:29xkbhmm my problem appears to be in strip-header-var function
09:30xkbwhich should be generalized anyway :P
09:31xkbaha.. because drop is lazy
09:36raekcpfr: you're trying to use an array of boxed booleans as an array of primitive booleans
09:36cpfrah, how do I stop doing that
09:38raekwell, I'd have to see the code where you make the arrays in order to know that
09:38cpfrhmm will (into-array Boolean/TYPE [true true]) work?
09:39raekxkb: you need to do a (apply str ...) on the results to make them a string again
09:39xkbraek: Ok, will try, thanks
09:39xkbseq != String
09:40xkbgood to know
09:40xkbwee cool, it worked
09:40raekxkb: there are some goodies in clojure.string
09:41raekthose are preferred when working on strings
09:41raek,(into-array Boolean/TYPE [true true])
09:41clojurebot#<boolean[] [Z@ca00a>
09:41raek,(into-array Boolean [true true])
09:41clojurebot#<Boolean[] [Ljava.lang.Boolean;@ea369a>
09:42raekcpfr: yes, your example works
09:59sid3kis metadata feature of clojure is an operator overloading approach? since my attention is very distracted now, I couldn't understad it
10:00Chousukeoverloading?
10:00Chousukemetadata is just metadata, what about it makes you think of operator overloading?
10:01sid3klua's approach is metatables, just this naming resembling made me think of o.l
10:02sid3kspeaking of that, does clojure support operator overloading or sth like that?
10:03sid3kI guess it's an impossible feature for a lisp dialect
10:03dnolensid3k: metadata is one way to put ad hoc type information on supported data structures. useful when dispatching on multimethods
10:03Chousukesid3k: operators don't really exist in Clojure
10:03sid3kChousuke: right
10:04Chousukethough the generic term for the thing at the head of a list can be called "operator"
10:04dnolensid3k: tho it's easy to exclude fn's like + from your namespace and define your own if that's your cup of tea.
10:04Chousukethat term encompasses special forms, macros and functions
10:05sid3kdnolen: what if we need to execute > function on different data structures?
10:06Chousukesid3k: then the > function needs to be replaced with a polymorphic one
10:06Chousukemost likely though a new function will be introduces
10:06Chousukeintroduced*
10:06sid3kyou mean, clojure team is already working on that?
10:07dnolensid3k: no you can do that now if you want.
10:07Chousukethe new protocol stuff gives you a very efficient way of doing polymorphic functions
10:07Chousukebut it has always been possible.
10:07Chousukewith multimethods.
10:08sid3kthis is what I'm going to code now, here my first blog post comes
10:08Chousukeor manually via java interfaces and conditionals; eg. the "seq" function
10:08sid3k:)
10:09Chousukeseq is one of the functions that will most likely be changed into a protocol eventually
10:09Chousukethe API stays the same though, which is nice.
10:10raeksid3k: http://richhickey.github.com/clojure-contrib/generic.arithmetic-api.html :)
10:11sid3kwhat I think is to code a function executing a method named "gt" by passing second element as argument
10:11sid3kraek: checking out
10:12sid3kraek: thanks this is what I was talking about
10:12sid3ktyvm everyone
10:27cpfrraek, sorry my connection is faulty, but I got it working, thanks!
10:30otfromI've been frustrated by google today. Too many results and not enough answers.
10:31otfromIf I generate a pom.xml using leiningen, what maven command could I use to create an uberjar similar to lein uberjar?
10:31otfrom(I need it to work with some collaborators on windows who are clojure noobs)
10:34noidiotfrom, http://gist.github.com/504728
10:35noidiotfrom, that's a snippet from my pom.xml (hand written though, no leiningen)
10:36noidioops, that was a bit too much though, that conf also generates a .zip that contains the .jar
10:37otfromnoidi, thanks. I'll give that a try. I might have to look at the pom task and see what is going on though. It should generate that.
10:38noidihttp://gist.github.com/504728
10:38noidiI stripped the irrelevant bits
10:38noidiack, still too much, the property was only used by the .zip generation
10:39noidianyway, with that conf for the maven-assembly-plugin, the command "mvn package" should generate an equivalent of a lein uberjar
10:40otfromnoidi, cool. thanks again.
10:40noidino problem
10:41otfromnoidi, the your.main.class will need to be the generated class name rather than the clojure namespace won't it?
10:41noidiyes
10:41xkbis spit still in clojure.contrib.duck-streams?
10:41xkb1.1.0?
10:43otfromnoidi, ok. so for my kala.core with a main it will be <mainClass>core$_main.class</mainClass> I'll give that a go. Thanks again.
10:43noidino, it will be kala.core
10:43noidiif you define the namespace with (ns kala.core (:gen-class))
10:43mefestoIs the clojure-contrib link on the clojure.org site going to the github readme file, instead of github pages, by mistake?
10:44otfromI do. OK. Thanks for that. I think you just saved me an hour of head scratching. :-D
10:44noidiyeah, maven's a bit of a pain when you're just getting started
10:45noidibut once you get the hang of the basics, it's quite nice
10:50raekxkb: spit will be available in duck-streams for backwards compability
10:50raekclojure.contrib.duck-streams became clojure.contrib.io, which became clojure.java.io
10:50raeksince 1.2.0, clojure.java.io is the one to use for new code
10:52raekhrm, ok. 'spit' did not make it into clojure.java.io
10:55AWizzArdraek: right, it is in clojure.core
10:56AWizzArdBut why is read-lines not in clojure.java.io?
10:58raekread-lines was different from line-seq, rigth?
11:02otfromnoidi, that gist works great. Thanks (now to figure out why leiningen isn't creating that by default).
11:04noidiotfrom, great!
11:05xkbso if I want to write I file, what should I use?
11:05xkbI now use spit most of the time
11:06raekclojure.java.io/writer could be useful
11:07raekif you want to write things piece by piece
11:09xkband all at once, cause thats really neat with spit
11:11foguscemerick: I'm totally going to steal your defrecord+defaults macro
11:13cemerickfogus: have at it :-)
11:13cemerickI think the kwarg override next step would be a big winner.
11:14raekwhen dealing with very large files, you might want to read and write in a lazy manner
11:15raekso that the whole file does not need to reside in memory at one time
11:15foguscemerick: I was thinking more along the lines of defining invariants that the RecordRecordAbstractFactoryFactoryFunction checks, but yes, I agree with your next step
11:18cemerickfogus: something like slot-specific asserts/preconditions?
11:18fogusyes
11:19fogusOf course that only works if you go through the factory-fn, but I'
11:19cemerickfogus: I think we'd have to have interface/protocol impl mixins for that to work well (i.e. to "wrap" the default record assoc impl)
11:22foguscemerick: Do you mean something that is called automatically?
11:23cemerickfogus: yeah, I thought that was where you were going. e.g. (assoc foo :slot some-illegal-value) -> AssertException("some-illegal-value is not within the acceptable range of [-π π]"), etc
11:24cemerick(along with applying the same invariants at ctor-time
11:25fogus_cemerick: I thought there was talk of some such factory fn capability in a future Clojure, but I am not sure if the goal was to make it such a hook
11:26fogus_It would be ideal if it were
11:26cemerickNo, I don't think it was.
11:26cemerickThough, if some interface impl mixin facility comes to fruition, that can be used freely by any macro.
11:39fogus_I could always be evil and add a hook to assoc/etc. automagically :-P I might lose my Clojure membership though.
12:12fogus_cemerick: http://gist.github.com/504861
12:25AWizzArdWhy does (seq (.iterator (org.apache.commons.collections.set.ListOrderedSet.))) not work?
12:26AWizzArdhttp://commons.apache.org/collections/api-release/org/apache/commons/collections/set/ListOrderedSet.html says it returns a java.util.Iterator and I thought seq can traverse such structures?!
12:26wwmorgan,(doc iterator-seq)
12:26clojurebot"([iter]); Returns a seq on a java.util.Iterator. Note that most collections providing iterators implement Iterable and thus support seq directly."
12:29AWizzArdwwmorgan: thanks
13:30slyrushmm... I suppose in clojure the price of a map where each key has itself as its value is pretty low.
13:32somniumslyrus: I think those are called sets
13:32slyrussomnium: yeah, but if I do it this way I have the option of using a name as the key, or the value itself as the key.
13:34slyrusthis is for keeping track of nodes in a graph. sometimes I want a node like "5". It's pretty self explanatory. 5 is the value, the name, etc... Other times I might want "carbon-atom-34" as the name. I could keep a separate map of names to objects, but it might by easiest to just do it this way.
13:37somniumslyrus: whatever works, works
13:40slyrusindeed
13:46slyrussomnium: and the clojure API is nice enough that if I just use conj I can let the user decide which to use. even better!
13:58therealniis there a way to distribute access to the STM across a network? Like can STM be used an in-memory database.
14:04gigamonkeyAre Clojure's proxies a separate mechanism from java.lang.reflect.Proxy?
14:06slyrushey gigamonkey
14:08gigamonkeyYo, slyrus.
14:10dpritchettHey I was just rereading Steele's chapter in Coders at Work this morning. Do you have any new books on the way?
14:11gigamonkeydpritchett: no books but I'm working on this: http://www.codequarterly.com/
14:11gigamonkeyMore at http://codequarterly.wordpress.com/ and http://twitter.com/codequarterly
14:12dpritchettThat's new to me, thanks for sharing the link!
14:13gigamonkeyFeel free to spread it around! (And we're always looking for writers. And we pay!)
14:13gigamonkey(How much, exactly, TBD.)
14:14gigamonkeyObClojure--I've got a guy working on a Q&A interview with Rich Hickey.
14:14AWizzArdgigamonkey: yes, Clojures Proxies are a bit different
14:14gigamonkeyAWizzArd: any particular reason?
14:14gigamonkeyI notice you can subclass which you can't with j.l.r.Proxy.
14:14AWizzArdyes
14:15AWizzArdunder the hood Clojure uses Classes from the j.l.r package
14:15gigamonkeyBut to make a subclass it must cons up a .class on the fly, no?
14:15AWizzArdhttp://github.com/richhickey/clojure/blob/master/src/clj/clojure/core_proxy.clj
14:16gigamonkeyBased on the occurence of ClassWriter, I'm guessing what I just said is true.
14:16AWizzArdyes
14:17gigamonkeyAnd so is the ability to subclass the reason for doing it that way? Or are there other benefits?
14:18AWizzArdThere was the need for being able to subclass and to implement interfaces. That was before reify was added to Clojure.
14:18AWizzArdProxy is very general, while reify is working on Interfaces, but more efficient.
14:30Drakesonhow can I wrap a call with System.exit trapped?
14:34AWizzArd(System/exit 15)
14:36AWizzArd(Class/staticMethod arg1 arg2 ...)
14:38pjstadigis it possible to dispatch a multimethod on the types of its arguments, where one of those types is a primitive array?
14:38pjstadig,(second (map type [ "test" (byte-array [ (byte 1) (byte 2) (byte 3) ]) ]))
14:38clojurebot[B
14:39pjstadighow could I do (defmethod something [String [B ] @body)?
14:40AWizzArd(defn foo [^String s, ^"[B]" x] ...)
14:40AWizzArd"[B"
14:40AWizzArdwithout the closing ]
14:40pjstadigk thanks, i'll try that
14:41pjstadigwait no
14:41pjstadigthat won't work, i want to do a multimethod
14:41pjstadigi want to dispatch based on the type of the args
14:43_fogus_pjstadig: (defmethod foo (Class/forName "[Ljava.lang.String;") [a] ...)
14:44_fogus_pjdstadig: (defmethod foo (Class/forName "[[[[I") [a] ...) ;; for prim int
14:44pjstadig_fogus_: thanks, that looks like it might work, i'll try
14:45_fogus_pjstadig: That last example was a 4-d array however. ;-) "[I" would be a 1-d
14:48LauJensen_fogus_: You got that book wrapped up yet ? :)
14:49_fogus_mostly. the indexing is torturous but we hand it off to production, and the technical reviewer, in 1-2 days
14:50LauJensenCool
14:50replaca_fogus_: wow! congrats. The parts I've read so far are very cool.
14:50_fogus_replaca: thank you
15:19defn'lo all
15:24slyrushmm... could there be a bug in multi-arg dispatch for protocol methods implemented by records where a record in a different ns attempts to implement a protocol method from another ns?
15:24slyrussingle arg functions seem fine
15:26slyrusI suppose it's more likely that I've screwed something up
15:31jarodluebbertwould clojure be a good choice for writing a web crawler?
15:33qchamaeleonHi all... Got a question regarding import of java classes/interfaces.. Is it possible to import a java interface that happens to be inside a java class? Haven't had any luck with it at all.
15:33qchamaeleonThe particular case I'm looking at is creating a proxy for an interface in Piccolo2D, edu.umd.cs.piccolo.activities.PActivity.PActivityDelegate, where PActivity is a class containing the interface PActivityDelegate.
15:39_fogus_qchamaeleon: Try something like this: (import 'java.util.Map$Entry)
15:40qchamaeleonAh. Thank you. Using $ worked. Have I missed it in the docs somewhere?
15:40_fogus_Not sure where to find it.
15:40qchamaeleonApparently I have. Found it on the java_interop page..
15:41_fogus_hmm, I guess that would make sense. :-)
15:41qchamaeleonThanks a bunch for the insight. Been driving me nuts.
15:43cemerick_fogus_: nice addition. A lot simpler than what I was thinking of initially, aligning the kw vals so that they go into the ctor instead of the default expr.
15:44_fogus_i went down that path at first
15:44cemerickIt'll make a lot more sense if one were to add support for lexical ctor arg references as in hugod123's flavour.
15:45_fogus_I haven't seen that version
15:46cemerick_fogus_: http://github.com/hugoduncan/atticus/blob/master/src/main/clojure/atticus/factory.clj
15:46_fogus_I started playing around with my version in trammel but got sidetracked.
15:46_fogus_oh cool, thanks
15:47_fogus_I'll try to digest this later
15:48cemerickThe downside of that impl is that (IIUC), an instance of the record is essentially reduced through the non-default args, which would be a perf killer for me.
15:51defnHere is a picture of Whistler’s mother with a Winchester: (-> (->> ...))
15:53_fogus_defn: That reference just shot over my head
15:56defn_fogus_: which one?
15:57_fogus_-> ->>
15:57sexpbotjava.lang.Exception: Can't take value of a macro: #'clojure.core/->>
15:57defnhttp://en.wikipedia.org/wiki/Whistler's_Mother and http://web.blogs.clarin.com/lenovision/files/winchester1200.jpg
15:58_fogus_Well, I know what the words mean, but not put together like that
15:58cemerickI saw it kicking around twitter this morning. I don't get it either.
15:59defnit might not actually make sense
15:59defnbut im enjoying calling them that
15:59defn:D
16:08slyrusd'oh! bit by the fields aren't accessors notion again.
16:25arkhdo I need to be in a non-default namespace if I want to import java classes at a repl?
16:28arkhnvm - even within a namespace I get the following when trying to import a java class: java.lang.ClassNotFoundException: java.net (NO_SOURCE_FILE:6) Why?
16:30arkh,(import 'java.util BitSet)
16:30clojurebotjava.lang.ClassNotFoundException: java.util
16:30danielfmI think it's (import '[java.util BitSet])
16:31arkhdanielfm: that was it - thank you
16:32danielfmI have a silly question about function naming convention, maybe you guys know the answer
16:32danielfmthere are some functions that ends with an exclamation mark, e.g. 'swap!', because such functions have side effects, right?
16:33danielfmso, why 'alter' doesn't end with an exclamation mark? Am I missing something?
16:37dnolendanielfm: probably because they must appear inside of dosync
16:38danielfmdnolen, yeah, I misunderstood the docstring
16:38danielfm"Must be called in a transaction. Sets the in-transaction-value of ref to..."
16:38danielfmthat "sets the in-transaction-value" answers my question
16:39arkhthere's also io!, which is called in a transaction but given an ! for "opposite" reasons
16:39danielfm, (doc io!)
16:39clojurebot"([& body]); If an io! block occurs in a transaction, throws an IllegalStateException, else runs body in an implicit do. If the first expression in body is a literal string, will use that as the exception message."
16:40arkhthat's a horrible explanation
16:41danielfmarkh, yeah, the function itself doesn't have any side effects, but it avoids that you do some nasty stuff inside a transaction, which may be replayed several times
16:41arkhit should be something like "If IO occurs within io!, within a transaction, throw an IllegalStateException, etc.
16:42rhudsonSee http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards
16:42rhudson"Use the bang! only for things not safe in an STM transaction."
16:42arkhrhudson: you get +1 clojure credits for finding the canonical explanation ; )
16:43danielfmrhudson, thanks!
16:43tomojarkh: but wouldn't that be incorrect?
16:43dsantiagoio! is your declaration that something in the body is doing IO.
16:43tomoj->(dosync (io!))
16:43sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: ()
16:44tomojerr
16:44arkhoh ..
16:44tomoj,(dosync (io!))
16:44clojurebotjava.lang.IllegalStateException: I/O in transaction
16:44arkhI sit corrected :)
16:44tomojof course, an io! block with no IO would be kinda silly..
16:45danielfmtomoj, in this particular case, even if the io! function itself is safe, the function it wraps is not
16:45danielfmso I understand why this function ends with a !
16:47danielfmtomoj, but I got your point :)
16:48tomojseems like io! is only useful if you use it every time you do IO
16:48dsantiagoI think it's for writing libraries.
16:48dsantiagoSo you can help people keep troublesome functions out of their transactions.
16:48tomojthat makes sense
16:48tomojdoes anyone actually use it, though?
16:49danielfmdsantiago, indeed
16:53danielfmI don't see much use for io! because according to the coding conventions, is enough to just mark unsafe functions with a !
16:54danielfmio! just makes sure that such functions can't be used inside dosync
16:55danielfmbut that's a whole another discussion...
16:55rhudsonThe only uses of io! in core.clj are in await and await-for
16:59danielfmhm, that's what dsantiago told about avoid the misuse of certain functions inside transactions
16:59danielfmso probably 'io!' is not the best name for such function..
17:01danielfmi don't know :P
17:01rhudsonfwiw (dosync (spit "/tmp/foo" "foo")) executes without exception
17:02tomojif you always put io! around every bit of code that does IO, you will never accidentally do IO in a transaction
17:02tomojthat's the use I see
17:03tomojbut no one does that, so..
17:06danielfmtomoj, I actually didn't know about that function, but indeed its use is something to consider
17:06danielfmspecially in libraries
17:07danielfmthank you all!
18:46defnhow would you rework this: http://gist.github.com/505467
18:47confoundsi'd move the download link a little to the right
18:48confoundsand maybe change the background to an off-white
18:51tomojdefn: why dorun?
18:52tomojand why (let [rec (read r)] rec) instead of (read r) ?
18:52clojurebotclick
18:52tomojguess those aren't the kind of comments you're looking for, sorry :(
19:31defntomoj: no very good ty
19:57gfrlog,clojure.core.json
19:57clojurebotjava.lang.ClassNotFoundException: clojure.core.json
19:57gfrlog,clojure.core.json.read
19:57clojurebotjava.lang.ClassNotFoundException: clojure.core.json.read
19:58gfrlog,clojure.contrib.json.read
19:58clojurebotjava.lang.ClassNotFoundException: clojure.contrib.json.read
19:58gfrlog,clojure.contrib.json
19:58clojurebotjava.lang.ClassNotFoundException: clojure.contrib.json
20:11TakeVIs there a way to extend a struct, so that I have, say, Struct02 with all the keys of Struct01, as well as it's own keys?
20:16notsonerdysunnyis there a binary file format write s-expressions?
20:16dnolen_TakeV: not really, though you could write some macros, I did that once. But I'm not convinced there's much advantage to just merging two maps.
20:17notsonerdysunnyI am sorry I typed that in a hurry ... is there a binary file format to store s-expressions? I intend to use s-expressions to store large simulation data ..
20:19TakeVdnolen_: Hmm, a macro would work nicely. Thank you.
20:21dnolen_notsonerdysunny: I haven't heard of anything like that.
20:21notsonerdysunnyI just found out from the #lisp that there is something called cl-store .. which has a binary backend ..
20:22notsonerdysunnyI am still looking for a clojure equivalent ...
20:22brehautnotsonerdysunny: i believe the clojure core structure types all support java's serialisability
20:23brehauti cant speak for the quality of that
20:23brehautbut it might be half way to what you want?
20:24notsonerdysunnyI am new to serialisability thing .. but is there something like binary-serializable .. which would make reading large "serialized-data" really quick
20:25brehautnotsonerdysunny: no idea sorry, ive never wanted to look at javas serialisation support
20:31qbgI can read in a serialized list of 10000 integers in 138 msec on my machine
20:34qbgThe downside of serialization is that you shouldn't serialize functions/closures
20:34qbgThat includes lazy sequences
20:36brehautnotsonerdysunny: the other caveat re:serialization is that it is intended to be used with short term storage only
20:36brehautnotsonerdysunny: http://www.assembla.com/spaces/clojure/tickets/281?page=1#comment%3A17
20:39notsonerdysunnyqbg: I only intend to use serialization for storing data
20:39notsonerdysunnyqbg: so what you are saying is a non-issue .. I want to be able store large simulation-related data as s-exps .. since it is a simple extendable way of doing it
20:41brehautnotsonerdysunny: do you want the data to be able to survive releases of clojure?
20:42notsonerdysunnyyes .. I want it as a file format which can be easily read into clojure that is all...
20:42brehautnotsonerdysunny: then plain java serialisation is not for you (as per link above)
20:42KirinDavenotsonerdysunny: Write a function to read a line, then make a lazy sequence out of a file.
20:43KirinDavenotsonerdysunny: Clojure makes lightweight formats like tsv as easy as any lightweight text processing lang i've ever seen. Especially if you adopt clojure literals.
20:44KirinDaveHas anyone written a yaml-clojure yet?
20:45notsonerdysunnyKirinDave.. I don't want simple ascii .. since I intend to store large uniform array-like simulation related data ...
20:45apage43http://github.com/lancepantz/clj-yaml
20:45notsonerdysunnyit needs to be binary
20:45lancepantzoh don't look at that
20:45lancepantzthat was my learning clojure project :)
20:45apage43xDD
20:45KirinDave;)
20:45technomancypssh--back in my day we only had one value for a bit.
20:45brehautif its uniform and array shaped, why not just write a reader using javas binary IO layers
20:46lancepantzthat just deserializes anyways
20:46apage43you could ostensibly use most java yaml libraries with relative ease
20:46KirinDaveapage43: Bleck tho.
20:46brehauttechnomancy: haha
20:46lancepantzright, the clojure wrapper isn't even neccessary
20:46KirinDaveYeah but eff those.
20:46lancepantzjust use snakeyaml directly
20:46apage43http://github.com/joshua-choi/fnyaml
20:46apage43fnparse yaml
20:47lancepantzi always either use clj-json or protobufs
20:47KirinDavelet me look at snakeyaml. C# has taught me to distrust static typing implementations of heterogenous serialization formats.
20:47lancepantzjson is human readable enough imho
20:48KirinDavejson is great.
20:48KirinDaveBut yaml is less of a pain to type.
20:48KirinDaveThat can be an important consideration.
20:48lancepantzfair point
21:47mister_mhow do I make sure somethign is in my classpath, so I can (load x) it
21:47mister_mor (require )
21:48mister_mfrom the REPL
21:50tomojare you asking how you can see what your classpath is?
21:52mister_mtomoj, and I guess how to add a folder to it
21:52tomojdon't add folders to your classpath
21:52tomojwell.. how are you starting the repl?
21:53tomojfrom the repl you can see your classpath with (System/getProperty "java.class.path")
21:53mister_mI just type clojure at my command prompt
21:53tomoj..where'd you get that 'clojure' script?
21:53rhudsonmister_m: Check out cljr -- that makes it very easy to control your repl classpath.
21:54rhudsonhttp://github.com/liebke/cljr
21:56tomojjeez, I need to get cljr just for clojars searching
21:56lancepantzthere is also a lein plugin
21:57lancepantzdon't remember what its called
21:57tomojbut then you have to add it to all of your :dev-deps, eh?
21:57lancepantzright
21:57KirinDaveWhy is add-classpath still around? I thought it was deprecated?
21:58rhudsonIt's still deprecated
21:59mister_mtomoj, you know I don't even know
21:59tomojcljr looks like the way to go until you start making projects with lein
21:59mister_mwhere I picked up running the repl with 'clojure', probably through my trying to get it to work with emacs or soemthing
22:01tomojfor emacs you'll want `cljr swank`
22:02KirinDaveDidn't java-utils or repl-utils used to have a classpath convenience function?
22:03KirinDaveOh it's just classpath now. Haha, shows how often I have to do stuff w/out lein ;)
22:10mister_mthanks for the cljr tip guys
22:12qbggithub question: Is there any way to reopen a closed issue without create a new one?
22:14lancepantzheh, is it the read issue? :)
22:14qbgThat worked
22:14lancepantzyay!
22:15qbgBut I still can't read if I just (flush)'ed before hand
22:15qbgFor example, (do (print "> ") (flush) (read))
22:18tomojin what context? just curious
22:18qbgIf I run 'cake repl' and try to evaluate that, the problem presents itself
22:19tomojah, cake
22:20lancepantzqbg: ninjudd reopened it
22:20qbgIt seems weird; Clojure's repl seems to work fine...
22:21ninjuddqbg
22:21ninjuddqbg: looking into it
22:21qbgOkay
22:22ninjuddi think you can reopen on github with the "Actions" menu
22:23ninjuddqbg: cake's repl is much more compilcated than clojure's because it uses sockets to communicate with the persistent JVM
22:23qbgBut shouldn't the clojure repl be doing essentially the same thing under cake as I am?
22:24qbgI'm not seeing an "Actions" menu
22:24ninjuddqbg: i guess it is only for the repo owner...
22:27qbgThe project that I'm testing this on works fine under my nailgunized clojure repl
22:27ninjuddqbg: i reopened the ticket for you
22:28ninjuddqbg: yeah the issue is actually with readline. working on a fix
23:41ninjuddqbg: i just checked a fix in to github. let me know if it works when you get a second
23:42qbgYay! It works!
23:42qbgThank you ninjudd
23:42ninjuddsweet!
23:43ninjuddqbg: thanks for finding that bug. it was a tricky one