#clojure logs

2011-01-17

00:00Scriptoramalloy: ah, right
00:01amalloytonyl: i confess i don't see what thunk has to do with the code there. the comment seems out of place
00:01amalloysee http://en.wikipedia.org/wiki/Thunk#Functional_programming
00:01tonylok, that was an option that came into mind
00:01tonylthanks
00:55hiredmanhttps://gist.github.com/750897
01:00TimMcIf someone passes me a function, can I extract a name from it?
01:02tonyl&(name 'first)
01:02sexpbot⟹ "first"
01:03tonylbut I haven't use that snippet in projects
01:03amalloytonyl: that's getting a name from a symbol, not a function
01:04amalloy&(meta (fn foo []))
01:04sexpbot⟹ nil
01:04amalloy&(name (fn foo []))
01:04sexpbotjava.lang.ClassCastException: sandbox9112$eval11089$foo__11090 cannot be cast to clojure.lang.Named
01:04amalloyso it looks like no, tim
01:04amalloy&(map meta first #'first)
01:04sexpbotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$first
01:05amalloy&(map meta [first #'first])
01:05sexpbot⟹ ({:line 53} {:ns #<Namespace clojure.core>, :name first, :file "clojure/core.clj", :line 48, :arglists ([coll]), :doc "Returns the first item in the collection. Calls seq on its\n argument. If coll is nil, returns nil.", :added "1.0"})
01:18TimMc&(str (fn foo []))
01:18sexpbot⟹ "sandbox9112$eval11112$foo__11113@1b6f4ea"
01:18TimMcClojure knows the name somehow.
01:21amalloyTimMc: no it doesn't, it knows the classname
01:21amalloy&(class (fn[]))
01:21sexpbot⟹ sandbox9112$eval11121$fn__11122
01:21amalloy&(class first)
01:21sexpbot⟹ clojure.core$first
01:22amalloy&(str first)
01:22sexpbot⟹ "clojure.core$first@130e714"
01:23amalloyhiredman: cute little error-handler
01:23TimMcamalloy: The classname of (fn foo []) includes "foo"?
01:23amalloyTimMc: yes
01:23TimMc&(str (fn FOOBARQUX []))
01:23sexpbot⟹ "sandbox9112$eval11144$FOOBARQUX__11145@1a41a8d"
01:23hiredmanamalloy: thanks
01:23amalloy&(map (juxt class str) [(fn []) (fn test [])])
01:23sexpbot⟹ ([sandbox9112$eval11153$fn__11154 "sandbox9112$eval11153$fn__11154@c06c8b"] [sandbox9112$eval11153$test__11156 "sandbox9112$eval11153$test__11156@1163ae3"])
01:24TimMcgah
01:24TimMcAnyway... every anonymous function generates a class?
01:24amalloyTimMc: every function, period
01:25TimMc&(class (fn FOOBARQUX []))
01:25sexpbot⟹ sandbox9112$eval11164$FOOBARQUX__11165
01:25TimMccool
01:25amalloyTimMc: IFn is an interface with the method .invoke(args)
01:25amalloyevery function is a class implementing that interface
01:25TimMchrm
01:26TimMcI'll sleep on that.
01:26amalloy&(use '[clojure.contrib.repl-utils :only [show]])
01:26sexpbotjava.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath:
01:27hiredmanIFn is huge in 1.3, all the LOL inner interfaces
01:27amalloyhiredman: as a stylistic thing, might it be...prettier to return either {:result x} or {:exception e} and destructure with :keys?
01:27amalloyblugh really? gross
01:28hiredmanwell, each arity for invokePrim gets an interface
01:28amalloyyeah, i know
01:28amalloyhadn't thought about the repercussions
01:29hiredmanamalloy: *shrug* that bit is internal plumbing
01:30amalloyhiredman: how are return values handled in the morass of interfaces? can we still only return Object, or is there like...invokeBoolean(int, double)?
01:31dnolenamalloy: in 1.3 you can return long and double
01:32amalloyah
01:32amalloynot much need for highly-performant booleans anyway, i guess :)
02:27LauJensenMorning all ya'll
02:27seancorfieldit's half past 11pm on Sunday night :)
02:29seancorfieldhey LauJensen i forked clojureql with a view to maintaining a 1.3-compatible version... any input from you much appreciated
02:30LauJensenclojurebot: UGT?
02:30clojurebotugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html
02:30LauJensenseancorfield: ^
02:31seancorfieldlol... that's new to me but i like it
02:35LauJensenseancorfield: re clojureql, how incompatible are 1.2 and 1.3 ?
02:43seancorfieldhaven't dug into it yet... ^dynamic seemed to leap out... will report on more as i find it
02:44seancorfieldcompiling for 1.3 and some basic testing worked cleanly tho'
02:48amalloyseancorfield: not sunday night for LauJensen, even ignoring ugt
02:58LauJensenseancorfield: The dynamic tags will not break 1.2 compat. I would greatly prefer if we could have them co-exist within the same project since that will give is 50% fewer codebases to maintain
03:01seancorfieldyup, i'll compile against 1.2 as well - if anything looks 1.3 only, i'll discuss coz that's not good either way
03:03LauJensenSure, just bring it up in #clojureql and if manage to make the projects mergable that would be preferable
03:04seancorfieldtomorrow (well, later today now), we have our company conference that will either bless or reject clojure for production...
03:05seancorfieldmy right hand developer looked at some clojureql code and was comfortable with it so i'm going in well armed :)
03:05LauJensenVery intesting, let me know how it goes
03:05amalloyseancorfield: best of luck
03:06amalloynight folks
03:06seancorfieldnight amalloy
03:06seancorfieldwell, it's now morning here (in LA, not my home) so i'm going to sign off and say goodnight
03:09LauJensenGoodnight
04:04AWizzArdhttp://blogs.oracle.com/henrik/2011/01/jdk_7_feature_complete_milestone_reached.html
04:06LauJensenIts incredible to me, that this can be considered succesfull "We hit the date less than a week late"
04:07AWizzArdToday in one month they plan to offer a Developer Preview.
04:15bobo_so in... 3 years people will start using it?
04:17robonobowill clojure 1.3 run on on jdk 7?
04:17LauJensenAlso - I dont understand why they're working on new features when the old stuff is still broke. I dont think Ive ever worked with a framework as frustrating, unrealiable and inconsistently designed as Swing
04:17LauJensenPHP is close, but even #java says PHP is designed with more rigor :(
04:17LauJensenrobonobo: Clojure targets 1.5, so yes
04:18robonoboLauJensen: I've never had real problems with swing, what is unreliable about it?
04:18hoeckLauJensen: come on, swing is so old and had to make many compromises that are not necessary today
04:18LauJensenrobonobo: Im working on a desktop application now, in which Im seeing undeterministic behaviors, such as scrollbars suddenly disappearing leaving half of the content unreachable etc
04:19hoeckLauJensen: and there are really much much much more worse toolkits out there
04:19LauJensenhoeck: They should just integrate QT and substitute it for all the junk code they put in
04:19LauJensenhoeck: like what? name one
04:19robonoboIs there a GUI framework that doesn't do stuff like that?
04:19hoeckLauJensen: powerbuilder, win32 crap ...
04:19LauJensenrobonobo: Qt, Winforms, Aqua...
04:20robonoboI've seen Aqua do strange stuff as well
04:20LauJensenhoeck: I dont remember PB, but designings UI is such a pleasure on Windows
04:20bobo_LauJensen: but they are replacing swing?
04:20LauJensenThey are a almost a decade ahead of unix in that regard
04:20AWizzArdI must say that Swing is not that bad after all.
04:20LauJensenI could write a short book on how bad and inconsistent Swing is
04:20bobo_well "replacing" atleast
04:20LauJensenIts really amazing
04:20LauJensenbobo_: link?
04:20bobo_LauJensen: javafx will get a java api instead of an own language...
04:21bobo_swing will ofcource be there
04:21robonoboLauJensen: how is it inconsistent?
04:21AWizzArdThey will add JavaFX on top of Swing.
04:21bobo_AWizzArd: no, its a new grapichs stack
04:21AWizzArdNice new effects and visuals for Swing apps.
04:22LauJensenrobonobo: I havent written it down everytime Ive come across these inconsisties, but I remember writing a function which changed the font/style on all components, but lo and behold a single component didnt submit. So I went on Google and it turns out that they made this one component a special case, and so it had to be rewritten for that specifically. And I come across stuff like that quite often
04:22hoeckand I'd rather deal with swing than with all the c++ legacy that a qt gui brings to my sweet little abstract clojure stuff
04:22LauJensenhoeck: You can run Qt from Clojure
04:22AWizzArdhoeck: yup
04:23hoeckof course, and you can run OpenGL from common lisp too, except that from now on you have to deal with JVM segfaults :(
04:23robonoboJVM segfaults sound really scary
04:23robonobos/sound/sounds
04:23sexpbot<robonobo> JVM segfaults sounds really scary
04:24AWizzArdNo no, Swing may have some learning overhead, but it's pretty nice.
04:24AWizzArdVery customizable and really fast, after the initial startup, which is slooow
04:24robonoboAWizzArd: I agree. And the documentation is terrific
04:24ttmrichterWorse than Swing? FOX leaps to mind.
04:24hoeckwell, to be honest, I don't know how mature qt on the JVM actually is
04:25AWizzArdrobonobo: what I can criticize is: not yet HTML 5 support and some components are missing, such as a DatePicker, etc.
04:25LauJensenAWizzArd: I can tell from your statements that you are an inexperienced Swing user, when you get to know it a little better, you'll hate it
04:25AWizzArdAnd of course the initial startup times.
04:25AWizzArdFor me it was quite the other way around. I went from hate to liking it more and more.
04:26AWizzArdFirst I thought that the handling of JTables is freaking complicated.
04:26AWizzArdLater I realized that I need to customize a million of things and that JTables offer everything I need.
04:26LauJensenThe novice hates it, the journeyman likes it, the master hates it with a passion
04:27hiredmanAWizzArd: seems to be the general consensus in #java on swing too
04:28bobo_a clojure question: if i have a big map, and then create a new car with 99% of its content. it shouldnt realy take alot more memory right?
04:28AWizzArdbobo_: car in the sense of CL or as in "driving vehicle"?
04:29bobo_*var
04:29bobo_so as in i cant type
04:29AWizzArdbobo_: it depends on how you "create a new var" with 99% of its content.
04:29bobo_(def newcar (second (second original)))
04:29bobo_something like that
04:30tomoj:)
04:30AWizzArdhmm, are you sure you work with "second" on maps?
04:30AWizzArdThe results could be pretty... random.
04:30bobo_the result i get is what i want
04:30AWizzArdIt can be done in microseconds if you do use things such as dissoc.
04:30robonobois map a hashmap or a treemap?
04:30bobo_its a incanter dataset
04:30raekbobo_: map the data structure or map the function?
04:30bobo_not sure what thta is
04:30AWizzArdbobo_: maps are typically accessed by "get"
04:31AWizzArdUnless it is a sorted-map-by the order may appear totally random to us.
04:31AWizzArd,(second (apply hash-map (range 0 5000)))
04:31clojurebot[1024 1025]
04:32AWizzArdI don't find this intuitive. A (get m 1024) however was expected to return 1025
04:32bobo_gonna checck the type if my emacs and slime just would wake up
04:33tomojrobonobo: neither
04:33tomojthey're a kind of bit hash tries
04:34tomojnot sure of the exact term.. I think clojure's implementation was somewhat novel?
04:35hiredmannovel in the sense that other languages didn't have until recently, but they come from some paper
04:35hiredmanbagwel?
04:35raekI've heard the term "bit-partitioned hash trie" for clojure's hash-map
04:35tomojthose weren't persistent, though
04:35tomojI think? but maybe persistence was no big deal, I dunno
04:36hiredmanhttp://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/
04:37robonobohiredman: i was just about to post that
04:37hiredmansomeone recently ported clojure's to haskell
04:37mduerksen#clojure.de
04:37mduerksenups
04:40AWizzArdmduerksen: yes, it's good! :)
04:41bobo_ok, so its a seq of seqs not a map
04:41bobo_say its 1GB, doing (second (second myseq)) should not render 1GB more data right?
04:43tomoj(second (second myseq)) should only consume more memory if you haven't yet produced the second elements of either seq
04:43bobo_great, thats what i thought
04:43tomojif you haven't, and the second element is 1GB big...
04:43bobo_yes well, it is
04:43LauJensenbobo_: Is there a timeframe for the JFX integration?
04:44tomojdon't hold the head if you're processing long seqs with big elements
04:44bobo_LauJensen: i think i saw something, il try to find it
04:44bobo_it was announced at devoxx this year atleast
04:44tomoj(or very long seqs with small elements, or short seqs with very big elements...)
04:44bobo_i have alot of small elements
04:45bobo_dont think it should be this large though
04:45bobo_the .csv is 160MB
04:45tomojdo you need to hold the entire dataset in memory at once?
04:45bobo_yes =(
04:46bobo_but is it reasonable that 160MB file eats 1GB of ram?
04:46tomojdepends on what representation you use in memory..
04:46bobo_ofcource
04:46hoeckbobo_: you checked it with jvisualvm?
04:47LauJensenbobo_: each char in a string takes 2 bytes of memory on the JVM
04:47bobo_hoeck: no i didnt, il do that
04:48tomojbobo_: is the dataset just strings split from the csv? some numbers/dates/..?
04:48bobo_im not sure what incanter does with it... but there are numbers and dates. not sure if they are converted to that
04:49LauJensenI did a project once where as massive CSV file had to be stored in memory. I made by own slurper that put everything in appropriate types. Memory wasnt a problem
04:49tomojdid you measure overhead based on theoretical values for types?
04:50tomojor guess..
05:55tomojholy shit
05:56tomojjust as I was toying around with lamina ideas, ztellman was committing better looking variants
05:56tomojI love that dude
07:29MrHusIf my namespace imports another namespace and the other namespace imports a java class does my namespace need to import that java class as well?
07:45bartjMrHus, no
07:45bartjMrHus, as far as I know
07:45MrHusbartj: apparently you do have too.
07:45RaynesMrHus: If you want to use that Java class in your namespace, then yes.
07:52chouserNone of use/require/import are transitive
07:55Rayneschouser: What font did you guys use for code in TJoC?
07:56chouserRaynes: In the PDFs? I have absolutely no idea -- not my department. :-)
07:56RaynesMan, I wish it wasn't mine. :<
07:56chouserCan the PDF be queried for that kind of info?
07:56RaynesNot sure.
08:01chouserRaynes: I think it's just Courier
08:01RaynesLooks about right.
08:05robonobosilly question: when using slime + emacs, how do I switch from the repl back to the current file?
08:06AWizzArdrobonobo: Strg+x and then the arrow key left or right
08:06AWizzArdAh, Strg = Ctrl
08:07AWizzArdYou can also split the screen via Ctrl+2 or Ctrl+3 (back to one screen via Ctrl+1)
08:07AWizzArdAnd then do Ctrl+o to jump between those windows.
08:08robonoboi'm new to emacs: Strg?
08:08AWizzArdStrg is german for the "Ctrl" key.
08:08AWizzArdSteuerung (i.e. Control)
08:09AWizzArdrobonobo: one can't spell your name without spelling bonobo :)
08:09robonoboyes
08:11robonoboaha, i got it. Thanks
08:12robonoboand is there a way to have history in slime?
08:12mrBlissrobonobo: M-p and M-n
08:15mrBlissrobonobo: what I love about it is that if you type 'bladibla', it automatically searches for the last input starting with 'bladibla'. This has saved me lots of time and I miss it in other REPLs (luckily, my zsh prompt has a similar feature).
08:15robonobozsh is so nice
08:15robonobomrBliss: have you tried oh-my-zsh?
08:16chousermany readline prompts let you search backwards using Ctrl-R
08:16mrBlissrobonobo: yes I have, I'm currently running a heavily modified (or mutilated :) version of it.
08:16robonobodo you have it on github?
08:16mrBlissrobonobo: https://github.com/mrBliss/dotfiles/
08:17robonoboi've got four or five branches of ohmyzsh and i'm constantly switching between them
08:17mrBlisswhy is that?
08:18robonoboBecause I go back and forth on how I like my shell. I can't really decide
08:18robonoboplus i've developed the svn plugin for it
08:19mrBlissis this you then? https://github.com/RobinRamael/oh-my-zsh
08:21robonoboyes it is
08:21robonoboAre you going to come to my house and peek through my windows now?
08:22robonoboi'm behind 7 (proxys)
08:23mrBlissit's just worrying that a simple google query can reveal so much about a person.
08:24AWizzArdrobonobo: á propos history: you can also just scroll up to form and hit enter to copy it down.
08:24robonoboaha.
08:24robonoboI'm trying to make lein and slime work together
08:24robonobobut i can't import anything
08:25robonobolein swank is running in one window, what else should be done?
08:26mrBlissmy usual workflow: 1) open a file in a leiningen project, 2) run M-x lein-swank https://github.com/mrBliss/dotfiles/blob/master/.emacs.d/custom-clojure.el#L86 3) Done
08:29robonobomrBliss: I just put that in my .emacs and call it with M-x lein-swank?
08:30mrBlissrobonobo: make sure your current buffer is a file in a lein project (with [lein-swank "1.2.1"] as one of the dev-dependencies), and then M-x lein-swank
08:56fbru02hey guys anyone can help out on a macro question ?
08:57fbru02./s/macro/macros
08:57midsjust ask
09:06fbru02mids: I c&p'ed around 8 lines of code http://pastie.org/1469852 ... the problem is that the functions i create always end up being user-fede634-action instead of ["add" "get" "is-in"]
09:07qbgmacros work at compile time
09:07qbgThey are a compile time code transformation
09:08qbgThus when gif is compiled, the (gidf ...) form is transformed to (defn user-fede634-action [] println "abc")
09:10fbru02qbg: thanks ! how do i make my local action to be compile time too ?
09:10gju_is there a function that inserts an item at the beginning of a list?
09:10raekfbru02: could you tell us what you want the resulting defn to look like?
09:10raekgju_: conj and cons
09:10qbgfbru02: You probably don't wan that solution
09:10qbgIs there any reason why you want this done at runtime?
09:11qbgInstead of compile time?
09:11fbru02raek: yes, there should be 3 defn user-fede634-get, user-fede634-add , user-fede634-is-in
09:12raekfbru02: (do (defn user-fede634-get [] (pritln "abc")) (defn user-fede634-add [] (pritln "abc")) (defn user-fede634-is-in [] (pritln "abc")) ?
09:12fbru02qbg: yes, the naming depends on external input during runtime
09:13qbgSounds like it might be bad design
09:14raekfbru02: if you strictly cannot do it at compile-time, then I don't think you have any other choice than calling 'eval'.
09:14raekfbru02: but not that anything that is possible during run-time is also possile in compile-time
09:14raek*but note
09:15raekso you can call code that fetches the names from a database or whatever
09:15fbru02qbg: raek: I
09:15fbru02It seems i'm overusing macros
09:16fbru02I finish this proof of concept and go back to drawing board
09:16raekfbru02: also, the arguments of a macro are the code itself, so you cannot bind a name to some value and pass that symbol as an arg
09:16raekunless the calling code is a macro too
09:17fbru02raek: qbg: thanks
09:18raek(defmacro gif [model occurrence & body] (list* 'do (for [action ["add" "get" "is-in"]] `(gidf "user" "fede634" ~action (println "abc")))))
09:19raekso you see, macros are contagious in a sense
09:20qbgraek: or you make gidf a function and gif be (defmacro gif [] (do ~@(map #(gidf "user" "fede634" % '(println "abc")) ["add "get" "is-in"])))
09:20raek(hrm, no need to use 'list*' there. could have used 'cons' instead)
09:20qbgThat should be `(do ...)
11:39arkhfor simple datetime parsing / usage in clojure, is clj-time the way to go?
11:41Raynesarkh: Yes. clj-time is fantastic.
11:42arkhRaynes: thank you
11:43robonoboSilly question: how do I remove brackets in clojure-mode?
11:45klangrobonobo: backspace?
11:46robonoboklang: yeah, uh, that's the thing, neither backspace or C-d work on parens
11:47robonobothe only way i can remove them is by cutting
11:47robonobowhich can't be right
11:48raekrobonobo: you have paredit activated? if so, it will be removed when you remove the matching one when there is nothing in between
11:48klangrobonobo: no, that's not right .. my backspace runs the command paredit-backward-delete
11:49robonoboi'm new to emacs, how would i see wether paredit was activated?
11:49raekx (y)| x (y|) x (|) x |
11:49jwr7So — if I have an agent fn that generates lazy sequences and I don't force them with doall, will they actually be generated outside of the agent fn, in a different threads (possibly multiple threads)?
11:50raekfor me, it sais this above the minibuffer: (Clojure Hi Paredit Fill)
11:50klangM-x describe-mode
11:50jwr7I've just realized that this kind of defeats the serialization that agents provide :-/
11:50robonoboraek: yeah, i'm in paredit mode
11:51klangrobonobo: in the repl or in a clj file?
11:51raekrobonobo: you can use M-s to remove the innermost pair of parens at the point
11:51raekI think paredit is really useful, so I would recommend to learn it. http://www.emacswiki.org/emacs/PareditCheatsheet
11:52raekotherwise: M-x paredit-mode to disable
11:53robonoboraek: thanks
11:54raekhttp://p.hagelb.org/paredit-outline <-- tutorial by technomancy
12:33jamiltronI am having some problems with clojure.contrib, it seems. When I try (ns jamiltron (:require clojure.contrib.server-socket)) I am getting a FileNotFoundException.
12:35tonylis clojure-contrib.jar in the classpath?
12:35jamiltronIt is
12:36tonylcan you share the exception stack of the problem?
12:37tonylor how are you calling clojure
12:39tonyl&(require '[clojure.contrib.server-socket :as ccss])
12:39sexpbotjava.io.FileNotFoundException: Could not locate clojure/contrib/server_socket__init.class or clojure/contrib/server_socket.clj on classpath:
12:39tonyl,(require '[clojure.contrib.server-socket :as ccss])
12:39clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/server_socket__init.class or clojure/contrib/server_socket.clj on classpath:
12:39jamiltronFileNotFoundException Could not locate clojure/contrib__init.class or clojure/contrib.clj on classpath: clojure.lang.RT.load (RT.java:412)
12:40tonyl&*clojure-version*
12:40sexpbot⟹ {:major 1, :minor 2, :incremental 0, :qualifier ""}
12:40jamiltronI am calling clojure through an alias of clj which is clojure.contrib's clj-env-dir
12:40RaynesSandboxes don't seem to like certain namespaces.
12:41RaynesNot that it will fix your problem, but consider cake or leiningen. They'll serve you far better than a wee little clj script.
12:41jamiltronI usually use leiningen, but am getting the same errors.
12:41tonylRaynes: what do you usually use?
12:42Raynescake
12:42jamiltronMy clojure version is 1.3.0-master
12:44raekjamiltron: looks like the error suggests you are trying to (:require clojure.contrib)
12:44jamiltronOops, that doesn't work either
12:45jamiltronserver-socket gives:
12:45jamiltronFileNotFoundException Could not locate clojure/contrib/server_socket__init.class or clojure/contrib/server_socket.clj on classpath: clojure.lang.RT.load (RT.java:412)
12:45raekjamiltron: what contrib jars do you use?
12:45hiredmanI suggest you not user the launcher script
12:45hiredmanuse
12:46raekthat error means that the server-socket module of contrib is not on the class path
12:47jamiltronI copied clojure-contrib/modules/complete/target/complete-1.3.0-SNAPSHOT.jar into my classpath as clojure-contrib.jar
12:48raekthat only depends on all the other jar files and does not include them
12:48raekit's basically empty
12:49raekI think "standalone" is the droid you are looking for
12:49jamiltronAh, let me try that.
12:50jamiltronThat worked. Thank you very much!
12:51jamiltronThanks for the help, everyone. I'm really new to Clojure and I love it but I keep getting stuck on stuff like this.
12:53RaynesMy best tip is to not try to manage the classpath manually with launcher scripts and the like. Your life will be much easier just using cake or leiningen, especially since they scale to more complex things than this easily.
12:53jamiltronYeah, I'm trying to learn lein as much as possible.
12:54shortlordshouldn't (catch Exception e (do-something)) catch every Exception, including NullPointerExceptions?
12:55raekshortlord: yes.
13:05jamiltronDoes anyone know about lein and swank?
13:09markskilbeckhttp://projecteuler.net/index.php?section=problems&amp;id=11
13:10markskilbeckWell that sounds interesting.
13:13raekjamiltron: just ask.
13:14jamiltronI think I found the answer - does leiningen not work with clojure 1.3.0?
13:14raekit should
13:14jamiltronI am getting a series of classpath errors when running lein swank in a project using clojure 1.3.0, but I can run swank-clojure from the .lein/bin directory.
13:15shortlordraek: I have surrounded a function call with try + catch Exception e, but there is still a NullPointerException occuring as soon as I execute the block
13:15shortlorddoes try + catch work somewhat differently in clojure than in Java / is there anything obvious that could be wrong?
13:15jamiltronVar *classpath* not marked :dynamic true, setting to :dynamic. You should fix this before next release!
13:15jamiltronException in thread "main" java.io.FileNotFoundException: Could not locate mire/server__init.class or mire/server.clj on classpath:
13:15jamiltron at clojure.lang.RT.load(RT.java:412)
13:15jamiltron at clojure.lang.RT.load(RT.java:381)
13:15hiredmanshortlord: your catch is throwing the npe
13:15jamiltron at clojure.core$load$fn__4389.invoke(core.clj:5308)
13:15raekno, they are compiled to the same byte code
13:15jamiltron at clojure.core$load.doInvoke(core.clj:5307)
13:15jamiltron at clojure.lang.RestFn.invoke(RestFn.java:409)
13:15jamiltron at clojure.core$load_one.invoke(core.clj:5132)
13:15jamiltron at clojure.core$compile$fn__4394.invoke(core.clj:5319)
13:15jamiltron at clojure.core$compile.invoke(core.clj:5318)
13:15jamiltron at user$eval7.invoke(NO_SOURCE_FILE:1)
13:16jamiltron at clojure.lang.Compiler.eval(Compiler.java:6222)
13:16raekjamiltron: gist.github.com
13:16jamiltron at clojure.lang.Compiler.eval(Compiler.java:6213)
13:16jamiltron at clojure.lang.Compiler.eval(Compiler.java:6189)
13:16jamiltron at clojure.core$eval.invoke(core.clj:2680)
13:16jamiltron at clojure.main$eval_opt.invoke(main.clj:232)
13:16jamiltron at clojure.main$initialize.invoke(main.clj:251)
13:16jamiltron at clojure.main$null_opt.invoke(main.clj:284)
13:16jamiltron at clojure.main$main.doInvoke(main.clj:362)
13:16jamiltron at clojure.lang.RestFn.invoke(RestFn.java:422)
13:16jamiltron at clojure.lang.Var.invoke(Var.java:405)
13:16jamiltron at clojure.lang.AFn.applyToHelper(AFn.java:165)
13:16jamiltron at clojure.lang.Var.applyTo(Var.java:518)
13:16jamiltron at clojure.main.main(main.java:37)
13:16dakronegah jamiltron, use gist
13:16raekshortlord: the NPE doesn't happen in the catch block?
13:16jamiltronSorry
13:17jamiltronhttps://gist.github.com/783190
13:18shortlordI'm doing "(catch Exception e (println "in the catch block"))
13:19shortlordthat should not throw a NPE, right?
13:20raekwith a (try ...) surrounding it?
13:21raek(try (inc nil) (catch Exception e (.getName (class e)))) => "java.lang.NullPointerException"
13:23raekjamiltron: I would check the versions of the libraries you use and make sure they are for the same clojure version
13:24ossarehmorning yo!
13:24amalloy&(supers NullPointerException)
13:24sexpbot⟹ #{java.lang.RuntimeException java.lang.Throwable java.lang.Object java.lang.Exception java.io.Serializable}
13:25amalloyshortlord: yeah, should work
13:25ossarehbobo_: as long as you're not newing up new objects to put in that map - then yes, that is part of the Persistent datastructure stuff that Rich has gifted us with.
13:48LauJensenRemind me again why whenever somebody pastes 3+ lines people start crying gist gist, isnt it more convenient to read it right here in this buffer than to tab out to Conkeror?
13:49ScriptorLauJensen: 1. You don't have to keep scrolling back up to find the code again if people have talked since
13:49Scriptor2. Syntax highlighting, line numbers, and formatting
13:50Scriptor3. If someone joins and wants to help, you can just link them, instead of pasting all over again
13:51TimMckeep going
13:51LauJensen1. Use ERC, then this is a non-issue, 2. I can certainly live without syntax highlighting for short 5 - 10 liners and stacktraces, and 3. I agree that if somebody joins halfway through you should gist instead
13:52TimMc4. I can't read both the preceding and following parts of the conversation on the same screen when there is a giant chunk of stuff in the middle.
13:52amalloy4 is the one that bugs me, personally
13:53LauJensenIf 5 - 10 lines can screw up your display, quit using those tiny netbooks, they're not made for developers!
13:53TimMcSame here, though Scriptor's 1-3 are important too.
13:53LauJensenEven with the somewhat massive paste above, I can stille read 5 - 10 lines both above and below, and if I couldnt, hitting C-M-v isnt a huge problem
13:53TimMcLauJensen: 1280x800 laptop here.
13:54TimMcI wish I had a giant flatscreen monitor in portrait mode, but I don't.
13:54Scriptorthe point of windows is to not have to maximize everything :)
13:54LauJensenScriptor: You're on Windows? that explains it ... :)
13:54Scriptorwindows, not Windows :p
13:55LauJensenI have viewports, 1) Emacs, no border, fullscreen, 2) Conkeror, no border, full screen, 3) thunderbird, maximized, .. and so forth
13:55LauJensenThats gives you guys a lot of freedom to paste whatever you want :)
13:59technomancysome people do IRC on phones even
14:00tonyli don't like fullscreen windows, except for the internet browser
14:00tonyland watching videos
14:02pjstadigtechnomancy: yaaic for android is what i use
14:02LauJensentonyl: I really like it, and it lets me keep away from the mouse completely
14:03DeranderLauJensen: what window manager do you use?
14:03technomancypjstadig: I have andchat, but I never use it.
14:03RaynesI have a whole viewport dedicated to Emacs. However, I don't actually have a single maximized Emacs window in there. Rather, I have two Emacs frames side by side, because it's easier to resize than a single frame with several panes.
14:03technomancypjstadig: is it halfway decent?
14:03LauJensenDerander: Gnome + Compiz - I wrote about my setup on offtopic.bestinclass.dk
14:03pjstadigyeah
14:03DeranderLauJensen: have you looked at a tiling window manager? seems like gnome is overkill
14:03Deranderoh
14:03Derandercmd+f "tiling" in that post
14:04technomancynothing wrong with andchat I guess; I just never got my bouncer situation figured out
14:04LauJensenDerander: I had Awesome WM for many months, then switched to Gnome and replicated my setup and binding with Compiz - Like I said, its on the blog
14:04Deranderyep. found it seconds after I asked
14:05LauJensenYea, I didn't mean that in the rude way that it came out, sorry :)
14:05Deranderno sweat
14:17islonhow do I generate/write xml in clojure?
14:18amalloyislon: clojure.contrib.prxml is decent
14:19TimMcAsus-- for not having a decent way to browse their laptops
14:20TimMcbah, wrong window
14:20amalloyislon: https://gist.github.com/ea060658b5677649d8e7
14:20islonthanks amalloy
14:21amalloyand it's not hard to get it to print with decent whitespace; by default it's compact
14:49albertidhi, can I traverse a list without evaluation? e.g. I want (first v) to return vec instead of 1 when v = (vec (1 2))
14:50daleLike (first '(vec (1 2)))?
14:50pdk,(for [i '(vec (1 2))] i)
14:50clojurebot(vec (1 2))
14:51pdkapparently so
14:51albertidyea, except I can't use 'v
14:51amalloyalbertid: traversing a list never causes evaluation. you're looking (i think) for a way to input a list without evaluation
14:51RaynesSounds like you need a macro.
14:51amalloy&(let [v '(vec (1 2))] (first v))
14:51sexpbot⟹ vec
14:52daleWhat amalloy said. I think we'll need to know how whatever gets into v, got into v.
14:53albertidamalloy_omglunch, hey thats right
14:53albertidso v would (read-string "[ 1 2]")
14:54albertidor (read-string "(vec (1 2))")
14:54albertidwhich should be a seperate case
14:55albertidok I will try myself
15:09shortlordI need to grant unique tokens from a pool of 4 tokens to several concurrent accessors, so that every one ends up with a different token (or none at all, if the access happens if all the tokens are already taken). How would I do that? I can use drop on an atom, but that give me only the remaining elements, not the one I picked. Is there any elegant solution for this?
15:11chousershortlord: you already have the more than 4 threads that need tokens?
15:12shortlordchouser: yeah, the scenario is the connection phase of a simple 4 player game. I need to distribute the 4 player colors to the first players that connect
15:12chouserah, I see now.
15:13chouserthere has been talk of an alternative to 'swap!' that returns both the old and new values of the atom
15:13chouserwhich would suffice in your case. alas such a thing doesn't currently exist.
15:14shortlordso that means I need to retain the original 4-token vector and compare it with the one after the swap! to figure out the token, right?
15:15chouserso, off the top of my head: (1) a BlockingQueue, (2) store in an atom a pair of [taken available] tokens
15:16shortlordchouser: ah, the idea about the token pair sounds nice, thx :)
15:16chousershortlord: I don't think that would be sufficient. The original could be (a b c d), and the swap! could return (c d).
15:17shortlordchouser: could that happen? I thought the updates happen atomically, so after a swap! I would get only the result of my latest swap?
15:18chousershortlord: well, it seems a bit messier than one might hope. (ffirst (swap! x (fn [[taken avail]] [(cons (first avail) taken) (next avail)]))
15:20chousershortlord: updates are atomic, but in (let [before @a, after (swap! a next)] ...), you can't assume only one swap has happened between before and after. others may have snuck in.
15:22shortlordchouser: well, but that would work for (let [before original-tokens, after (swap! a next)]...), right? Using before independently from the atom
15:22shortlord(but anyway, your solution is great, thx a lot :))
15:23chousershortlord: no, 'after' would contain less than 3 tokens for all but the first thread in, leaving them uncertain which token is theirs.
15:25chouser(def q (LinkedBlockingQueue. '[a b c d])) ... (.poll q)
15:25chousershortlord: that looks even easier. see http://download.oracle.com/javase/6/docs/api/java/util/concurrent/LinkedBlockingDeque.html
15:29shortlordchouser: nice, thx :)
16:18amalloyshortlord: store a map of {token, owner} pairs?
16:20amalloythen you swap! with some function that adds an entry if possible, and an argument some sort of this-is-me identifier; after the swap you look through the map for your identifier
16:21shortlordamalloy: the problem is that players get initially identified through this token (well, I guess it could also be done differently, but it works good enough right now)
16:23shortlordbut I think in general your solution should be the best way to do it for a variable number of players
16:25shortlordis (:entry map-foo) or (map-foo :entry) more idiomatic clojure code (or is there no real difference in style)?
16:26amalloyshortlord: there's not a huge difference, but i'd prefer the former
16:26amalloyfor one thing if you ever switch from maps to records, the second form will stop working
16:28amalloyspeaking of which, anyone know if records will start implementing IFn or ILookup in 1.3?
16:31hiredmanuh, I am pretty sure records do implement ilookup
16:31amalloyhiredman: oh, you're right
16:31amalloyi guess i don't quite understand what ILookup means; but what about IFn?
16:32hiredmanI doubt it
16:33hiredman(foo :bar) lookup (which is what the default IFn would do presumably) wouldn't be able to use the call site cache (:bar foo) uses for records
16:35amalloyhiredman: interesting. i don't know what that means, but a call-site cache sounds handy :)
16:36hiredmanthe first time (:foo x) happens on a record clojure stores a thunk that calls (.foo x) non-reflectlively (which hopefully hotspot just inlines away)
16:37hiredmanand it falls back to (:foo x) if the site becomes megamorphic
16:37hiredmanhttp://en.wikipedia.org/wiki/Inline_caching
16:37amalloyneat
17:45tonyldoes anybody in what server is the ##java channel? I can't seem to find it by searching the Internet
17:45tonylI have a question about the java code in clojure and it is a feature I've never seen in java
18:08benreesmancan anyone answer a quick question about ring?
18:08brehautbenreesman: maybe?
18:08benreesmanit seems to evaluate my handler function twice?
18:09brehautthat seems surprising
18:09brehautare you able to paste up a snippet somewhere?
18:10benreesmanif that's surprising then i'll mess around some more, just wanted to know if that was a common mistake. if i don't get anywhere i'll create a gist. thanks!
18:11brehautbenreesman: are you using ring directly or via some intermediate library like compojure or moustache?
18:11benreesmanring directly
18:11brehautand at the moment just simple GET requests?
18:12benreesmanyes
18:14brehautbenreesman: then yes, i think that is weird
18:14benreesmanhttps://gist.github.com/783678
18:17brehauthuh
18:17hiredmanbenreesman: most likely your webbrowser is doing two gets
18:18hiredmanfavicon + whatever
18:18brehautbenreesman: look at your urls, one is to the favicon
18:18benreesmangotcha
18:18benreesmannewbie mistake
18:18brehautbenreesman: yeah, i think your mistake is not logging the requests url
18:19benreesmancheers
18:27Derandertechnomancy: do you know why lein keeps using Derander as my clojars group even though I'm registered under derander?
18:27Derandertechnomancy: is this a setting I can change somewhere?
18:28technomancyI don't know, but I encourage you to get comfy with the clojars source, because not enough people are. =)
18:29technomancymaybe I'm misunderstanding the question, but it doesn't sound like it has anything to do with leiningen
18:29Deranderthe reason that I am questioning leiningen is that lein pom is generating the incorrect word in my pom file
18:29DeranderI am not familiar with the java ecosystem, though
18:29DeranderI am confused in general because I don't recall typing "Derander" anywhere on my system
18:30technomancythe pom just comes straight from project.clj
18:30Deranderoh god. I'm a moron. I forgot to save the file.
18:30Deranderthanks. :-P
18:30technomancyeasy fix =)
19:04markskilbeckKnock knock.
19:05raekwho's there?
19:05markskilbeck...
19:05markskilbeckJava.
19:06markskilbeckDoesn't work too well in IRC.
19:07tonylit uses phonetics?
19:07markskilbeckSupposed to wait a while before answering.
19:07tonyloh hehe
19:08pkinneyI've told that joke to a group of computer illiterates... haha, they just threw me weird looks
19:08pkinney(It's 1 of my fav programming jokes)
19:10Adamantmarkskilbeck: try this
19:10Adamant....
19:10Adamant...
19:10Adamant.......
19:10Adamant.....
19:10AdamantJava!
19:10markskilbeckhaha
19:10markskilbeckYeah I guess that does the trick
19:10Adamantsadly/gladly the joke isn't as true anymore
19:11Adamantmaking Java fast got turned into the primary goal of compiler folks like speeding up C and C++ used to be before that
19:11Adamantso after a decade+, it's pretty damn fast
19:12technomancyboot time is still quite bad, which is what I assumed the joke was about
19:12technomancy"Knock Knock/who's ther--dalvik"
19:14technomancy"dalvik who?/......... user=> "
19:14brehauttechnomancy: it has race conditions?
19:15technomancyjust quick VM boot plus slow load of clojure's runtime libs.
19:15brehautoh right
19:17Adamanttechnomancy: that is true
19:18shortlordhas anyone successfully used clojure-processing? There seems to zero documentation, not even the source code is really helpful. :-/ I'm trying to get text alignment to work
19:25technomancyI used it like a year and a half ago; it was really hard to get working. had to fall back to Java documentation for most things.
19:30shortlordtechnomancy: what a shame, live editing processing would've been promising
19:37technomancywell it could certainly be fixed
19:38technomancythere's nothing inherently difficult about it; it's just a matter of modernizing a legacy codebase
19:44amalloytonyl: did you get your java question answered?
19:45DeranderIs there a good way to monitor a directory for changes in java?
19:45brehautDerander: by 'good way' do you mean 'not polling' ?
19:46Deranderwell, if there is a library to do polling out there that would work. I'd prefer not to have to poll, though
19:46DeranderI see NIO2 in java 7 but I haven't see anything for java6
19:47brehautDerander: i think that about sums things up.
19:48Deranderthat is unfortuante
19:48brehautDerander: i think lazy-test is the canoncial example people point to in clj land
19:52arohneris there a way to tell the JVM to attempt a GC before increasing its heap size?
19:53hiredmanthe jvm doesn't dynamically increase it's heapsize
19:53hiredmanuse the -Xwhatever to set the heapsize you want
19:53arohnerhiredman: yes it does, if you use -Xmx
19:54hiredmanno
19:54hiredmanthat is the max size
19:54arohneryes
19:54hiredmanif you want to cause a gc before reach that size then decrease that size
19:54arohnerand my current heap size starts small (50MB?), and the JVM increases its heap size when it feels the need, up to the max size
19:54hiredmanright
19:54hiredmanif that is not the correct max size, then you should make it smaller
19:56tonylamalloy: no, still trying to figure it out
19:56clojurebotamalloy: therfor I return [previous] if rest is empty
19:56Deranderbrehaut: thanks for the pointer to lazy test. it seems like I've basically written a slightly buggy clojure implementation of ScheduledThreadPoolExecutor.
19:57amalloytonyl: i can join ##java from freenode; not sure why you'd be having trouble there. but maybe you could just ask your java question here?
19:58amalloyarohner: (System/gc) i think
19:58amalloythough usually that's...not a good idea. why do you want to?
19:58arohneramalloy: yes, that tells the JVM to try to GC. I want it to try automatically, before increasing the heap size
19:59hiredmanif you don't want a lage heapsize then make the max heapsize smaller
19:59arohnerbecause it's being lazy. Right now, if I tell it to GC, it will free ~300MB
20:00amalloyarohner: so why do you care? that's 300 mb that's paged/swapped
20:00hiredmanif you tell java to use a 1G heap max, don't freak out if it does
20:00hiredmanif you really don't want it to, drop the max
20:01tonylamalloy I
20:01tonylamalloy: it is this line https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/AFn.java#L145
20:01amalloyarohner: if you could get java to actually behave the way you're describing, you would be sad, not happy
20:01tonylAFAIK java doesn't have ... operators
20:01amalloytonyl: yeah it does
20:02arohneramalloy: why?
20:02amalloyas of 1.5
20:02pdkvoid main(String... args)
20:02pdkthat code is fucking scary
20:02amalloyit's syntactic sugar for taking an array of arguments; it lets the caller pass N arguments without wrapping them in an array first
20:03pdkplease tell me it's not production code so i can sleep
20:05tonylamalloy: I can't seem to find documentation about it, do you know how is this operator called?
20:06joegallohttp://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html
20:06amalloyhttp://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html
20:06joegallovarargs
20:08tonylso why not use that instead of making an function signature with 21 arguments
20:08tonylis it to be safe on java versions
20:08hiredmanarray allocations are not free
20:09arohnerthe clojure compiler does it for speed
20:09amalloytonyl: speed
20:13tonylok didn't know the performance
20:13tonylthanks for the help guys