#clojure logs

2010-03-17

00:01brian__test
00:06zaphar_psanyone had problems with swank-clojure and working directories when compiling?
00:10brian__hi, I am trying to run zef's leiningen tutorial, I have the latest lein, and followed directions
00:10brian__i have java 1.5
00:10brian__zephyr:~/desktop/test2/helloworld rberger$ lein compile
00:10brian__[copy] Copying 2 files to /Users/rberger/Desktop/test2/helloworld/lib
00:10brian__Exception in thread "main" java.lang.NullPointerException (NO_SOURCE_FILE:0)
00:10brian__at clojure.lang.Compiler.eval(Compiler.java:4658)
00:10brian__at clojure.core$eval__5236.invoke(core.clj:2017)
00:10brian__at clojure.main$eval_opt__7411.invoke(main.clj:227)
00:12zaphar_psbrian__: can't really help without code
00:12brian__ok
00:13brian__test2/helloworld rberger$ cat project.clj
00:13brian__(defproject helloworld "0.1"
00:13brian__:dependencies [[org.clojure/clojure
00:13brian__"1.1.0-master-SNAPSHOT"]
00:13brian__[org.clojure/clojure-contrib
00:13brian__"1.0-SNAPSHOT"]]
00:13brian__:main helloworld)
00:13brian__zephyr:~/desktop/test2/helloworld rberger$
00:13brian__zephyr:~/desktop/test2/helloworld rberger$ ls src
00:13brian__helloworld.clj
00:13brian__zephyr:~/desktop/test2/helloworld rberger$ cat src/helloworld.clj
00:13brian__(ns helloworld
00:13brian__(:gen-class))
00:13brian__(defn -main [& args]
00:13brian__(println "Hello world!"))
00:13brian__its on mac 10.4 though
00:14zaphar_psbrian__: just a tip since it's quiet but pastebin is your friend.
00:14brian__ok
00:14zaphar_psI'm pretty cool but some folks on some channels would get upset at a paste bomb like that :-)
00:14brian__lol
00:14brian__i never did this
00:15zaphar_psever used pastebin before?
00:15brian__no
00:15brian__what do i do?
00:15zaphar_pshttp://clojure.pastebin.com/
00:15brian__ok
00:15zaphar_psgo there and paste your code in
00:15brian__ok
00:15zaphar_psthen return here with the link
00:15brian__ok
00:17zaphar_psohla folks
00:18crowb4rHi
00:19brian__http://clojure.pastebin.com/mw0ta2GF
00:23brian__zaphar_ps> do you see it?
00:23Boohbahclojure rocks!
00:23zaphar_psbrian__: I'm not seeing any obvious error in your code.
00:24brian__i dont either, i copied off the site
00:24brian__its java 1.5
00:24bmasonjetty is driving me crazy... is there a way to stop it once it's gone 'rogue' ?
00:24zaphar_psbmason: I don't use it so have no idea
00:25bmasonzaphar_ps: do you use compojure?
00:26technomancybrian__: the real question is what are you doing on rberger's machine, and does he know about it?
00:26brian__its a different rberger
00:26technomancybrian__: you should probably use clojure 1.1.0 instead of the prerelease snapshot
00:26technomancyalso: that doesn't look like the latest leiningen
00:27zaphar_psbmason: no
00:27brian__ok, i just reloaded it
00:27zaphar_psbrian__: the code compiles fine for me :-)
00:27brian__hmm
00:28zaphar_pstechnomancy: hows it goin :-)
00:28bmasonanyone else had problems with extra jetty processes starting and clogging up one's ports?
00:28zaphar_psbmason: my one and only web clojure project is a static site generator like jekyll
00:28technomancyzaphar_ps: not bad
00:29zaphar_pstechnomancy: You use swank-clojure right?
00:29technomancyzaphar_ps: I maintain it... sort of.
00:29bmasonlol
00:30zaphar_psI'm having an issue I think is probably something I just don't have setup right when compiling files
00:30zaphar_psspecifically files that need to reference local files during the compile
00:31zaphar_psI think it might be related to the working directory of whatever java process is compiling the file? but I'm not sure and I'm new to elisp so I'm not completely following it all
00:31technomancyare you requiring the gen-class nses from the nses that need them?
00:33zaphar_pstechnomancy: yes but I the clojure code is enlive and it references an html file during the compile and that seems to be what it's failing on
00:33technomancyzaphar_ps: aha... is the HTML file in the resources directory?
00:33zaphar_pstechnomancy: yes
00:34brian__this is an aside, but you need gen-class to create java classes? Isn't that generally what its used for, no pun intended?
00:34technomancyzaphar_ps: oh... I think earlier versions of swank-clojure-project didn't respect resources
00:34technomancyzaphar_ps: have you tried lein swank?
00:34zaphar_pstechnomancy: no, details?
00:34zaphar_pshttp://code.google.com/p/molehil/source/browse/src/com/marzhillstudios/molehill/template.clj
00:34zaphar_psthats the code in question
00:35zaphar_pslein compile works fine
00:35technomancyzaphar_ps: lein swank in the shell, then M-x slime-connect in Emacs
00:35technomancyor upgrade to the latest swank-clojure.el
00:35zaphar_psI have the latest from elpa I think I can check to make sure.
00:35zaphar_psis elpa current?
00:36technomancyI think the elpa version might be missing resources
00:36technomancyI should push out a fix
00:36zaphar_pstechnomancy: okie where can I get latest then?
00:37technomancyzaphar_ps: try from my git fork: http://github.com/technomancy/swank-clojure
00:38zaphar_pstechnomancy: how much has changed?
00:38technomancyzaphar_ps: hardly anything on the elisp side
00:38brian__technomancy> I thought leiningen loads the latest clojure jars , I don't have clojure in my path
00:39technomancywhich is why I haven't gotten around to pushing the fix
00:39technomancybrian__: no, you should have clojure in lib
00:39technomancyI just mean there's no reason for you to be using an outdated version like that
00:40zaphar_pstechnomancy: got install instructions that don't use elpa? :-)
00:40zaphar_psnew to elisp so sorry for the newb questions :-(
00:40technomancynp; just do M-x package-install-from-buffer
00:43brian__ technomancy> i'm not sure i follow you this is in lib-> clojure-1.1.0-master-20091231.150150-10.jar
00:44bmasonthis means leiningen is pulling a snapshot version of clojure
00:45zaphar_pstechnomancy: then just restart emacs? do I need to install the clojure libs as well?
00:45technomancybrian__: right, your project.clj specifies an old version of clojure. you should update it (and contrib) to 1.1.0 instead. then do lein clean && lein deps
00:46brian__oh, i c
00:46technomancyzaphar_ps: I don't think you need to restart, but if it's acting funky you could try it
00:46brian__thx
00:46zaphar_psokie
00:47bmasonah I missed the date on the snapshot... yeah that is old :)
00:47bmasonis that from Stuart's book examples?
00:47zaphar_pstechnomancy: hrmmm still not compiling I'll try lein swank next
00:48technomancyzaphar_ps: that's the best way to ensure fidelity between slime and leiningen for sure
00:48zaphar_pshrmmm I don't have the right version of lein apparently :-)
00:49technomancylein swank should work with any version
00:49technomancyzaphar_ps: what problem are you seeing?
00:49zaphar_psit says swank isn't a task
00:49technomancyzaphar_ps: oh, you have to add lein-swank as a dev-dependency
00:49zaphar_psahhh ok
00:50technomancyhttp://github.com/technomancy/leiningen/tree/master/lein-swank/
00:52brian__technomancy> I have 1.0 for contrib but not clojure: dependencies [[org.clojure/clojure
00:52brian__ "1.1.0-master-SNAPSHOT"]
00:53technomancybrian__: ok, it's very important that your versions match for contrib and clojure
00:53technomancyunless you have a reason not to, you should use 1.1.0 for both
00:53technomancyas I've said
00:53brian__ok
00:56technomancybrian__: I recommend checking your project's setup using lein test or something before trying compile
00:56technomancysince there are more things that can go wrong with AOT
00:57zaphar_pssweet worked great thanks technomancy!!!
00:57technomancyawesum
00:57zaphar_psnow I just have to make it all happen straight from emacs :-)
00:58zaphar_psbut that will have to wait for another night
00:58brian__technomancy> I ran lein clean, then when I ran lein deps i got this: [null] Unable to resolve artifact: Missing:
00:58brian__ [null] ----------
00:58brian__ [null] 1) org.clojure:clojure-contrib:jar:1.1.0-SNAPSHOT
00:58technomancyM-x eshell lein swank RET =)
00:58technomancybrian__: ah yeah, get rid of "-SNAPSHOT"
00:58brian__ok
00:58zaphar_pstechnomancy: ahhh that's too much typing surely I can get it down lower than that :-)
00:58technomancyand maybe read the INTRO doc I just uploaded: http://github.com/technomancy/leiningen/blob/master/INTRO.md
00:59brian__do i leave "master" in
01:00technomancybrian__: just 1.1.0 is all
01:00brian__ok
01:00technomancyI'm not sure that it's the actual problem, but it's just good to be on the released version
01:03brian__still doesnt work
01:04brian__same error
01:04technomancyhrm... I need to go to bed, but you might try generating a new project with "lein new" using the latest stable 1.1.0 release... it looks like you are using an older version of leiningen.
01:04zaphar_psbrian__: are you able to launch a clojure repl at all?
01:05brian__you mean from lein?
01:05zaphar_psno just a vanilla clojure repl
01:05brian__yes, i've done some clojure on this box already
01:06zaphar_psok then just to rule out leiningen issues can you try to load the file from a clojure repl
01:06brian__but i dont have clore in my path
01:06brian__ok, let me see
01:06zaphar_psif it's a syntax error I'm just missing then that would tell you
01:07brian__yea, but it worked for you, right?
01:07zaphar_psyeah :-)
01:07zaphar_psI forgot I did that test :-)
01:07brian__this is osx 10.4
01:08brian__its old mac
01:08zaphar_psbrian__: I'm running mac as well I don't think it's your java version
01:08brian__weird, maybe its cursed ;-)
01:08zaphar_psdoes lein new work like technomancy|away suggested
01:08brian__hmm
01:09hiredmanwell, he wrote it
01:09brian__no
01:10brian__i've used leinigen to build other software on this
01:12brian__zaphar_ps> what version java r u using?
01:12zaphar_pswell that's exhausted my ideas and it's time for me to go to bed
01:13brian__yea ok
01:13brian__thanks
01:13zaphar_psbrian__: I honestly don't know right now
01:13zaphar_pswhatever comes with mac 10.5
01:13brian__java -version
01:13zaphar_ps1.5.0_19
01:14brian__ok
01:14brian__good night
01:14zaphar_psnow off to bed
01:24JonSmithbrian_ have you tried it without the clojure-contrib dependency?
01:57defnI need to create a regex using a variable -- I was trying to do this:
01:58defn(re-pattern (concat "\(.*" text ".*\)"))
01:58defnbut it doesn't like the \(
01:59psykotic\\(
01:59defnthanks psykotic
01:59hiredmandefn: concat returns a seq
01:59hiredmandoes re-pattern take seqs?
01:59psykoticremember, there is clojure's string literal escaping and there is the regexp's library's
02:00psykotichiredman: nope, he has to fix that too.
02:01psykoticthis reminds me that it might be nice to have a reader macro for "raw" strings
02:01psykoticala python's r"\(...)"
02:04psykoticmaybe that should be the default for regexp literals. most of the time, the usual escape sequences aren't useful anyway, e.g. the default matching mode is line-based, so \n won't ever match
02:05chouserwhat?
02:05chouser,(re-find #"\n" "\n")
02:05chouserthat matches \n just fine
02:06defnclojurebot, where art thou?
02:19dnolen,(str "é")
02:19clojurebot"é"
02:20dnolenhmm anybody had trouble with unicode chars period?
02:21defnhaven't really used them tbqh
02:22defnim american! we don't need them extrie alphabet doodads!
02:23dnolenerg this is driving me insane
02:26hiredman,(let [x 1 x´ (inc x)] x´)
02:26clojurebot2
02:27hiredmandnolen: jline has unicode issues
02:27hiredmanI think lein starts the repl with jline
02:27dnolenhiredman: k that's unicode problem #1. you think that affects lein swank as well?
02:27dnolenif so, I only have curse words for that.
02:28hiredmanumm, that I dunno
02:28hiredmanI know emacs has its own encoding settings
02:28dnolenyeah it's a rats nest trying to figure out what is wrong.
02:28hiredmanand java defaults to different things depending on the OS
02:28dnolenI read through the ML stuff
02:29hiredman(System/getProperty "file.encoding")
02:29dnolenbut my slime (connected to lein swank) if I enter a unicode char just completely hangs
02:29dnolenon the other hand if I send something to the REPL with compile file, just wack characters. However if I compile a region everything works fine!
02:30dnolengrr
02:33_mstin emacs do you have a slime-net-coding-system defined? I remember having to set mine to 'utf-8-unix
02:33_mstalthough I don't understand why compiling a region would work but not a file...
02:33dnolen_mst: yeah I set that. I set JVM file.encoding as well.
02:34_mstah! mine hangs too with lein swank :)
02:35dnolenARGH
02:35dnolen:) well at least it's something to report
02:35_mstmaybe we could form a support group...
02:36defnthis is impossible...only one mention of (shit) in #clojure for over two years
02:37hiredmanclojure
02:37hiredmaner
02:37cgranddnolen: hi, how do you call html-content?
02:37hiredman~#clojure
02:37clojurebotthis is not IRC, this is #clojure. We aspire to better than that.
02:37dnolendefn: rhickey doesn't like cursing on channel
02:38dnolencgrand: after much teeth gnashing I'm no longer convinced it has anything to do with Enlive.
02:38dnolenit's also possible issues with lein
02:41Raynesdefn: I bet both of those were from me.
02:42defn:)
02:43RaynesDidn't gnuvince use to hang around in here?
02:43RaynesWhatever happened to him? :o
02:43RaynesAppears he ran off to Scalaland and got married to curly brackets.
02:43cgranddnolen: well, I found a bug/inconsistency between html-content and content. At the moment you can't call (html-content ["foo" "bar"]) you must (apply html-content ["foo" "bar"])
02:44dnolencgrand: it's like a crazy nexus of bugs here :)
02:45cgranddnolen: good luck then :-)
02:45dnolencgrand: I'm pretty sure it's not really enlive. I can get the unicode characters to render depending how I compile the code. compile file is broken, but if I compile region, I see them properly.
02:45defnThanks to Licenser for making this search so much faster. This is actually turning out to be quite handy. I can include this in my projects and use it as an extra documentation tool to view (in general) nice examples of functions in action
03:53defndid I kill chat?
03:53LauJensenMorning crew
03:57RaynesLauJensen: Morning.
03:57sparievmorning
04:01defngut morning
04:15Raynes(((@modules (keyword (first args))) :load))
04:16RaynesEh, wrong window.
04:20sparievdefn: have you figured out your Unicode problem ?
04:21RaynesI'm surprised nobody commented on how deeply nested I am. ;)
04:21RaynesLauJensen: inb4ingeniousredneckjoke
04:21sparievwhere is actually a hardcoded value for encoding in http://github.com/technomancy/swank-clojure/blob/master/src/swank/swank.clj
04:22LauJensenRaynes: :)
04:23Chousukespariev: I think it's just the default
04:23_mstspariev: I hacked at the unicode thingy here: http://github.com/marktriggs/swank-clojure
04:23_mstto let you override with a system property...
04:23Chousuke,(merge {:foo 'bar} {:foo 'my-bar})
04:23clojurebot{:foo my-bar}
04:23Chousukeso you just pass :encoding "utf-8" to start-repl and it'll work
04:25RaynesI've been writing this (horribly designed) irc bot for two days, and I've already forgotten how to put modules on the autoload list. :o
04:25ChousukeRaynes: and I almost did comment on the nesting :P
04:25Chousukebut chose not to
04:26RaynesChousuke: You should have done it. Wouldn't have livened things up a bit. :D
04:26hiredmanif you use -> no one will notice
04:26RaynesHow could I rewrite that with ->?
04:26spariev_mst: yep, I did basically the same, I just wanted to point defn to the unicode problem solution
04:27Chousuke((-> args first keyword @modules :load)) I think
04:27_mstyep :)
04:27Chousukehmm
04:27Chousuke,(apply +)
04:27clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$apply
04:27hiredman((@modules (-> args first keyword)) :load)
04:28hiredman@ is (deref …)
04:28sparievwonder why unicode is not default
04:28Chousukeah, right. shoot.
04:29Chousukespariev: probably an oversight by jochu :P
04:29hiredmanbut, depending on what modules is, you may be able to get by without derefing
04:29hiredmanif modules is a var you don't need to deref
04:29hiredmanmaybe not refs either, I don't recall
04:30hiredman,((ref @#'+) 1 2)
04:30clojurebot3
04:30RaynesModules is a ref.
04:30hiredmanthe jvm doesn't default to utf-8
04:30hiredmanso you don't need to deref
04:31defni need to add syntax hilighting for the '.' at the end of a java.io.File.
04:31defnsomething to make it stand out
04:32Chousukeyou could do something fancy like transform it into a superscript "new" or something :P
04:32Chousukejust like my emacs transforms (lambda ...) to (λ ...)
04:33Chousuke(interestingly enough it's also smart about deleting it so that pressing DEL after it results in "(lambd ...)")
04:38RaynesLauJensen: Wouldn't happen to know how to stop Emacs from putting anything you highlight on the clipboard, would you?
04:39psykoticthe clipboard?
04:39Rayneskill-ring or whatever.
04:39LauJensenRaynes: I wouldn't know how to get it to start
04:39RaynesDoes it matter? :\
04:40psykotici don't understand what you mean.
04:40psykoticit doesn't put anything in the killring if you do that
04:40RaynesIt most certainly does on my machine.
04:40RaynesIf I highlight something, it's put on the clipboard (or whatever).
04:40psykotichow do you know it's on the "clipboard"?
04:41psykoticwhat happens exactly, is what i mean
04:41RaynesI just highlighted a piece of code in Emacs.
04:41Raynes(str (keys @modules))))
04:41Raynes^
04:41hiredmanthe clipboard is an X or GTK thing, the killring is an emacs thing, different things
04:42psykoticold school X behavior is to make the latest marked text in an application available for pasting elsewhere
04:42RaynesOh. Then I suppose it does that everywher.
04:42Rayneseverywhere*
04:42LauJensenAnd i Quote:
04:42RaynesYep.
04:42LauJensenNot sure when this appeared in GNU emacs, or if it’s how the developers intended things, buts it’s useful for me (I habitually use emacs from CVS, BTW, so not sure when this tip first applies): The “x-select-enable-clipboard t” method seems to resuscitate the “traditional” (and IMHO deeply strange) emacs interaction with the X11 primary and clipboard selections. EVERYTHING you highlight as a region winds up in both
04:43LauJensenSo either pull and compile a recent snapshot, or (setq x-select-enable-clipborad nil)
04:46_mstRaynes: there's also: (setq mouse-drag-copy-region nil)
05:04LauJensenRaynes: Is your uncle going to slow on the dynamo-bicycle powering your laptop, or did something happen to you?
05:04RaynesLauJensen: He's going too slow. :(
05:04sparievLauJensen: you made my day :)
05:05LauJensenI did? Sweet! :)
05:23defnweeee
05:24psykoticrandom snippet: inverse of conj, http://gist.github.com/335063
05:24defnit better be called jnoc
05:24psykoticsnoc isn't cons's inverse, so that would be improper :)
05:25defnhttp://github.com/defn/walton/blob/master/src/walton/core.clj
05:25defnany comments on this code? any suggestions in general are welcome....
05:32Licenser_morning
05:33Chousukedefn: the logfile and parsed-logs defs are suspicious
05:34Chousukedefn: you should instead just make a parse-logs function that takes a path as an argument
05:34RaynesSuspiciously awesome! Amirite?
05:34defnLicenser_: ! -- I've been messing with what you gave me yesterday morning
05:34defnIt runs really quick...
05:34Licenser_:) I've seen
05:34defnI'm still a noob, but baby steps have been made. I think I've slowly degraded your performance! :)
05:35Licenser_haha
05:35Licenser_just be aware, you keep the reader open for all eternity in that code - or my snippet as a tradein for lazyness
05:35defnChousuke: oh yeah...about that... I've been having some issues with getting my REPL to use the right path
05:36defnLicenser_: it needs a with-something or other
05:37Licenser_defn: with-open
05:37Licenser_but then you can't have the line seq's lazy, you've to force them in existance then
05:39Licenser_defn: in the extract-code fn, why not move the searcou output inline?
05:40Licenser_*search
05:42defnwho what? *looks*
05:42defnoh, i dont know -- i kind of like it in the let, but it could be inline i suppose
05:42defnis it more readable to you one way or the other?
05:43defnLicenser_: reload that source file
05:44defnive added proper credit :)
05:44Licenser_I am new to this myself, but when I stuff thyings in let I always feel so imperative, I might be me
05:46defnReally? I never really thought of it that way
05:46defnI guess I treat let like "let the sky be blue for 4 seconds"
05:46Licenser_well it is kind of a feeling
05:47Licenser_I noticed i tend to do stuff like (let [a (+ 1 1) b (+ a 1) c (+ b 2) ...
05:47Licenser_I didn't liked it since it reminded me a lot of what I've done in imperative langauges
05:56defni like using first, second, rest in the let
05:57defnin general im partial to getting as much compartmentalized up front so i can cut the fat and use a more human readable style
06:05LauJensenpsykotic: Its good that you make the distinction between first and peek, but any idea why you have to ?
06:06psykoticLauJensen: because of conj's container-dependent semantics.
06:06LauJensenI mean, any idea why the definition of 'first' doesn't start with (if vector)
06:06psykoticbut i agree it's weird. it'd be nice if the ICollection interface exposed something a la peek that always refers to the 'next' insertion position, if oyu know what i mean.
06:07psykoticwell, first is first in a linear sense
06:07psykoticso it's correct that it behaves this way
06:07psykoticconj adds at the back on vectors. what you really need is a separate function that works for all containers and is compatible with conj.
06:09psykoticdoes that make sense?
06:10LauJensenYes, but not relating to my question
06:10psykotici thought i answered that. if first had an (if vector) check then it would change the meaning of first.
06:10LauJensenAh wait, yes it does
06:10LauJensenI had just mixed up peeks behavior
06:10LauJensenYes Im with you now
06:11psykoticactually, my code should actually also check for (queue? ...)
06:11psykoticthe fact that this code is so ad hoc and container specific tells you that this really belongs in the ICollection
06:14psykotici guess you could extend peek and pop to work on all containers
06:29spariev,(isa? "123" String)
06:29clojurebotfalse
06:30ChousukeI think it goes the other way around
06:30esj,(string? "abc")
06:30clojurebottrue
06:30Chousukeor hm
06:30Chousuke(doc isa?)
06:30clojurebot"([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"
06:31Chousukeah, right.
06:31Chousuke,(isa? String Object)
06:31clojurebottrue
06:31sparievso its for classes
06:31Chousukeor hierarchies
06:32Chousuke,(derive String ::blah)
06:32clojurebotnil
06:32Chousuke,(isa? String ::blah)
06:32clojurebottrue
06:33sparievI see, mistaken Clojure's isa? with Ruby is_a?
06:33sparievin Ruby "123".is_a? String
06:33spariev=> true
06:34Chousukeruby's is different then
06:34Chousukeclojure has instance?
06:35spariev,(instance? String "123")
06:35clojurebottrue
06:35sparievcool, I didn't knew that, thanks Chousuke
06:39Raynes~google test
06:39clojurebotFirst, out of 59600000 results is:
06:39clojurebotTest.com Web Based Testing and Certification Software v2.0
06:39clojurebothttp://www.test.com/
06:40Rayneshiredman: I just stoleded your google code. :>
06:44Chousukehm, shouldn't tickets with patches be marked as "Test" on assembla? :/
07:31Licenser_,(greet #clojure.de)
07:31clojurebotNo dispatch macro for: c
07:32Licenser_,#clojure
07:32clojurebotNo dispatch macro for: c
07:32Chousukeheh :P
07:32Licenser_ah sneaky
07:32Licenser_clojurebot is silly
07:59rem7I'm trying to understand how nested vectors (and I guess lazy seq work) how would you access the first element of the first vector in something like this (def abc [[1 2 3] [4 5 6] [7 8 9]])
08:01tomoj(first (first abc)) ?
08:02esjor (ffirst abc) ?
08:02tomojoh yeah
08:03rem7oh I was using take
08:03rem7how about the 3rd element (or any other element)
08:03rem7first and second work....
08:04tomoj,(get-in [[1 2 3] [4 5 6] [7 8 9]] [2 2])
08:04clojurebot9
08:05tomojthat's one way
08:05tomoj,(doc nth)
08:05clojurebot"([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."
08:05tomojor that
08:05tomojbut vectors act like maps from indices to values, so
08:06rem7,(nth 1 (second [[1 2 3] [4 5 6] [7 8 9]]))
08:06clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
08:06tomojget-in is really perfect here
08:07rem7yeah, that works
08:07rem7thanks
08:07tomojalso works with maps
08:07tomoj,(get-in {:foo {:bar 3}} [:foo :bar])
08:07clojurebot3
08:08rem7ahh nice
08:28defnAnyone have any recommendations on writing tests in clojure?
08:29defnI am really interested in getting into TDD, and I'd like a "nice" introduction in clojure
08:30defnI am determined to write 3 lines of test to 1 line of production from here on out.
08:30licoresseDoes it exist a mechanism that can tell me which functions are in use and which are not?
08:30mattc58I'm using clojure.test with the deftest and is macros, along with lein test
08:31defnmattc58: do you by any chance have a repo with an example project that uses that style?
08:31licoresselike a dead function detection...
08:33mattc58defn: check out http://github.com/mattc58/animate
08:33Licenser_does the lein test thing have a autotest feature?
08:33mattc58defn: it's a personal project for a web server I'm doing, but it does indeed have tests that work from lein
08:35defnLicenser_: thats my next question
08:35defnmattc58: does lein test have autotesting? ;)
08:35Licenser_:D
08:35Licenser_there was a bdd framework too
08:35mattc58defn: what is autotesting?
08:36mattc58like a buildbot or something?
08:36Licenser_autotesting runs tests in functions / files that change automatically
08:36Licenser_and in the best case informs you about failures / successes
08:38defnmattc58: have you ever used ZenTest aka autotest for Ruby:?
08:38mattc58ah, no i haven't
08:38Licenser_if you ever get them running they are incredible
08:38mattc58that does sound interesting
08:38defnhttp://vimeo.com/2680374
08:39mattc58probably be a good addition to clojure
08:39defnmattc58: touche
08:39Licenser_aye
08:39Licenser_hmm I wonder if you can write a plugin for leiningen
08:39Licenser_when I remember correct java 7 has nio which allows file change hooks
08:40defnI'd be interested in doing it -- I messed with some osascript the other day via clojure, we could do growl notifcations, hook into swank somehow maybe?
08:40tomojthere's also something external which works now
08:40defnLicenser_: you can write plugins for lein pretty easily
08:40tomojin java 6 I mean
08:40defnIt's not well documented
08:40sparievhave you guys tried circumspec - http://vimeo.com/9770382 ?
08:40tomojhttp://jnotify.sourceforge.net/
08:40defnspariev: not yet, you?
08:40sparievnope :)
08:40chouserclojure-jna has some code for watching for file changes on linux via inotify, if that helps. :-)
08:40tomojI've never even heard of circumspec
08:40Licenser_tomoj: nice
08:40Chousukecircumspec seems to have autotesting
08:41defnChousuke: cool.
08:41tomojhow could I never have heard of it? :(
08:42defni was sort of distracted by all of stuart's departures from what ive seen as sort of the standard
08:42Licenser_Chousuke: nice!
08:42defn(in that particular video)
08:43tomojlike hard 'j'? :)
08:43defnI really like his book and talks, some of myf avorite actually
08:43defntomoj: hahaha
08:43psykoticyeah what's the story with that?
08:43defn(inc tomoj)
08:44defnit is more clear than saying "
08:44defn"closure"
08:44defnfor sake of argument
08:44psykoticnot really
08:44psykotichumans are pretty good at using context :)
08:44defnim just saying, for sake of argument, it leaves less to the imagination
08:45defnit's a style choice
08:45tomojyeah, hadn't really thought about that
08:47defnon the other hand...i think we can all agree it's "closure" :)
08:47psykoticplease.
08:47tomojevery time he says "clojure" now I stop listening for a second :(
08:48defnit doesn't really bother me -- it might just be his voice...like he has a cold when he says clojure
08:49defnthe low quality recording probably makes it worse than it is
08:50tomojhmm
08:50tomojthe (example, example-test) is different
08:50tomojI think I might like that better
08:51tomojehh
08:51defnWhy are (def x \n(+ 1 1)) indented with a larger space than defns?
08:51LauJensenThis reminds me of Reddit, you have one of these great technical talks, and the entrailing discussion is "did he say CloJOUre" or "Clo-djure" ?
08:52defnLauJensen: yeah it's ridiculous
08:52defnI feel terribly guilty about it already
08:52defnbut I appreciate having my nosed rubbed in it
08:52defnthat probably came off as sarcsam but I'm being sincere
08:53tomojdefn: clojure-mode?
08:53defntomoj: yessir, clojure-mode has a larger indetation of a def than a defn -- it looks weird
08:54licoressehow to change?
08:54LauJensendefn: Great - I glad you didnt take offense :)
08:55LauJensen+am
08:55tomojdefn: yeah, the small indentation is a special case for definitions
08:55defntomoj: is that an official lisp style guide thing?
08:55tomojyou could probably just add def in there
08:55tomojin general certain macros will have special indentation conventions, I think, yeah
08:56tomojbut there is no official rule as far as I know
08:56defnahhh i didn't really consider the whole macro thing
08:56defnthat makes a lot more sense
08:56defnyou can use that bit to being more discriminative
08:56tomojif you write your own wrapper around defn, you get ugly indentation
08:57tomojwait, do you?
08:57defnwhat do you mean by wrapper -- like clojure-mode is a wrapper?
08:57tomojdeftype seems to get proper indentation even though it's not mentioned in clojure-mode.el
08:58tomojI meant that if you write your own macro like defoo, clojure-mode wouldn't know to indent it like defn
08:58tomojbut maybe I'm wrong
08:58defnit might be there to stop people from doing multiline defs
08:58tomojit actually seems like clojure-mode will indent anything def* like defn
08:58tomojer, /def.+/
08:58defnyeah, the length
08:59defnless than 4 chars means different indentation maybe?
08:59Licenser_def.+ does not match def
08:59tomojindeed
09:00tomojit's /def.+/ and /with-.+/ it seems
09:00Licenser_make it def.*?
09:00tomojline 429 in 1.6
09:01tomoje.g. you'll notice that defoo and with-foo get defun style indentation
09:01tomojwith- does too, but not def, strange
09:04tomojI have no idea really what's going on in line 429
09:22licoresseI have a (Dimension. 30 40) and a '[30 40], how can I wrap those values onto Dimension without creating temporaries?
09:23Licenser_licoresse: does apply work on dimension?
09:23licoresseLicenser_: I don't know
09:23licoressebut would this be a scenario for apply?
09:24Chousukeno
09:24Chousukecan't apply java things
09:24Licenser_but I think even this will create temporaries
09:24Licenser_I apply java to my coffe filter!
09:24licoresse:-)
09:24Chousukeyou can't make Dimension without temporaries in this case
09:24licoresseok
09:24Chousukebut temporaries are cheap. just two pointers :P
09:24Licenser_licoresse: you can use macros
09:25licoresseyes, I could use a macro, of course....
09:25chouserwouldn't help
09:25Chousuke(let [[x y] pair] (Dimension. x y))
09:25Licenser_like (Dimension. (first [30 40]) (second [30 40]))
09:25licoresseif I use a lot of Dimensions, why would'nt that help?
09:25Chousukelicoresse are all your pairs known at compile time?
09:26licoresseno
09:26Chousukeright. so macros would create temporaries anyway
09:26licoresseI'm just interested in the most terse way of writing it
09:26Licenser_hmm it would expand :P
09:26Licenser_well I'd use let to be frank but I hink it is possible to do it without
09:26Chousukejust make a function that works like (make-dimension [1 3])
09:27licoresseChousuke:
09:27licoresseChousuke: excactly
09:27licoresseok, thanks...
09:27Licenser_licoresse: if you are crazy about performance don't use [] but something like (Defn make-dim [x #^Integer y #^Integer]...
09:27Licenser_or the other way round
09:28Chousukewell, no.
09:28Licenser_hmm can you put type hints into destructing?
09:28Chousukein that case just use (Dimension. x y) directly :P
09:28licoresseThere is no need for overenginering at my specific case ;-)
09:28Licenser_licoresse: there always is need for overenginering ;)
09:31stuartsierraIs there a Clojure web REPL anywhere, like "Try Ruby"
09:32Licenser_try clojure?
09:33peregrine81Hey all I am working on Euler Problem 5 which asks for number evenly divisble by 1-20. I've got two versions, the first one will work, but slow so I took another crack at it. http://gist.github.com/335218
09:33peregrine81And I get a java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer (NO_SOURCE_FILE:0)
09:34peregrine81Which doesn't make sense cause iterate returns a seq
09:34chouserstuartsierra: http://lotrepls.appspot.com/ is the only one I know of
09:34chouserdunno if that's like "try ruby" or not
09:34stuartsierraperegrine81: you've got "20" instead of "(range 20)"
09:36arbschtI suppose you could have a chat with clojurebot over mibbit :-)
09:36LauJensenarbscht: mibbit is banned from freenode afaik
09:37stuartsierrachouser: thanks
09:42Licenser_peregrine81: an simpeler solution is to think about what is required to solve the problem
09:43dcnstrcthow can I access the static properties of an inner class using clojure's java interop ?
09:43chouserOuterName$InnerName/staticThing
09:43dcnstrct$ neat
09:43dcnstrctbling bling
09:43dcnstrctthnx
09:43dcnstrctworked!
09:44peregrine81Licenser_: What do you mean?
09:45Licenser_peregrine81: there isn't much needed aside of simple multiplication
09:45Licenser_:)
09:48peregrine81Licenser_: Its looking for the smallest number :)
09:49Licenser_peregrine81: I know :) but the solution takes 2 minutes a penci, a paper and some multipplicatio
09:50G0SUBI want to use clojure.zip to process a nested map. any tips?
09:50tomojwhat's a "temporary"?
09:51peregrine81Licenser_: True but the purpose is to learn clojure :)
09:52Licenser_true true, but a good algorithm is a good algorithm even in clojure :d
09:52peregrine81stuartsierra: Thanks!
09:53peregrine81dumb error.
09:53zaphar_away /quit
09:53zaphar_away\quit
09:54peregrine81\quit
09:55defnwish circumspec was easier to setup...
09:57licoresseIt's amazing how few errors I make when writing code in Clojure, compared to when writing plain java...
09:58G0SUBhmm, so people here are not interested in zippers :)
09:59chouserG0SUB: sounds interesting, just never done it. Not sure how well the api will fit
10:00G0SUBchouser, I am looking at a functional solution to massage the keys of an arbit. nested map.
10:01G0SUBchouser, can you suggest a good/fast way? I was investigating zippers for that.
10:01psykoticif you can do it in a single top-down traversal, you don't need zippers.
10:01G0SUBbut it seems zippers are better suited for vectors or list like stuff.
10:01chouserclojure.zip currently assumes you have an ordered sequence of children
10:02G0SUBpsykotic, indeed, yes.
10:02G0SUBchouser, hmm.
10:02chouserI don't see any reason it couldn't be made to work -- it would be interesting, but I don't have any particular advice.
10:02G0SUBpsykotic, do you have any nice solution of your own?
10:03G0SUBchouser, OK. Thanks.
10:03chouserG0SUB: you looked at just using update-in?
10:03bsteuberyou don't mean this, I suppose:
10:03bsteuber,(get-in {:a {:b 42}} [:a :b])
10:03clojurebot42
10:04G0SUBbsteuber, no. I want to run a fn on all the keys and then replace them.
10:04bsteuberso it's some sort of tree traversal
10:04tomojseems like a faq
10:05G0SUBchouser, let me see if that can be used.
10:05chouseryou want a kind of mapping fn to be run on every key/val of the whole tree?
10:06G0SUBhmm, won't work for something like {"a" 1 "b" {"c" 3 "d" {"e" 5 "f" [{"g" 7} 8]}}}
10:06chouseror you have more like specific paths into the map tree that you want to massage?
10:06G0SUBchouser, I just want to massage the keys, but the vals might be maps which will again have keys.
10:06G0SUBchouser, no specific paths. just all of them.
10:06psykoticgosub: that sounds like a simple recursive mapping.
10:07chouserok, I suspect zippers would be overkill
10:07chouserG0SUB: your values may be scalars, maps, or vectors??
10:07G0SUBpsykotic, it is. now to write it in a non-stack consuming way.
10:07G0SUBchouser, yes.
10:07chouserG0SUB: I wouldn't worry about the stack if this is a concrete tree
10:08psykoticgosub: zippers consume space too, it's just in reified context data form instead of stack.
10:08G0SUBchouser, OK. that would relieve me a bit.
10:08chousera solution that consumes only as much stack as the depth of your tree will (a) be safe enough and (b) much prettier.
10:08psykoticin fact, a good way of thinking about zippers is that they reify the stack that would exist during a recursive map-style traversal
10:08G0SUBpsykotic, your IRC client doesn't do tab completion on nicks? the nick is G-Zero-SUB ;)
10:09chouserpsykotic: they do a bit more than that.
10:10psykotici was simplifying. i've done a ton of zipper work in the past, so know them pretty well.
10:11psykoticbut the relationship to delimited continuations ("reified stacks") is formally provable, you just have to elaborate a bit on exactly what you mean by "map-style traversal"
10:11chouserok. I've only used them a little, but mainly when I specifically wanted to do weird navigation from arbitrary points in the tree (up, left, left, down, etc.)
10:11psykoticright, if you want to think about it as a recursive traversal, you can think of the user function called on the child node returning an instruction to the calling combinator
10:12psykoticthat kind of thing, oleg has some good stuff on it
10:12psykoticanyway, you definitely don't need it for a simple traversal like this guy's.
10:16chouser,((fn z [f c] (cond (map? c) (into {} (for [[k v] c] [(f k) (z f v)])) (vector? c) (vec (map #(z f %) c)) :else c)) #(.toUpperCase %) {"a" 1, "b" {"c" 3, "d" {"e" 5, "f" [{"g" 7} 8]}}})
10:16clojurebot{"A" 1, "B" {"C" 3, "D" {"E" 5, "F" [{"G" 7} 8]}}}
10:17chouserso much more fun than solving C++ link issues...
10:17G0SUBchouser, haha!
10:18G0SUB(inc chouser)
10:28G0SUBchouser, btw, when is the joy of clojure up for review?
10:37chouserG0SUB: I think it's going out this week to the tech review people.
10:38chouserI'm hoping we'll start seeing updated or additional chapters for the MEAP any day now.
10:39danleicool
10:39rfgAce
10:40chouserI'm especially looking forward to the revised chapter 1 -- fogus did some great work pulling that together, and I think it will be much more useful for people to get a sense of whether this is the right book for them.
10:42RaynesIs there a way to decode html entities in a string that doesn't involve me adding an apache-commons jar to my dependency list?
10:45chouser,(-> "this&that" .getBytes java.io.ByteArrayInputStream. clojure.xml/parse :content last :content first)
10:45clojurebotorg.xml.sax.SAXParseException: Content is not allowed in prolog.
10:45chouser,(-> "<x>this&amp;that</x>" .getBytes java.io.ByteArrayInputStream. clojure.xml/parse :content last :content first :content first)
10:45clojurebotnil
10:46chouserhuh. getting different results here.
10:46chouser,(-> "<x>this&amp;that</x>" .getBytes java.io.ByteArrayInputStream. clojure.xml/parse :content last :content first)
10:46clojurebotnil
10:46sparievRaynes: try java.net.URLDecoder/decode
10:46chouser,(-> "<x>this&amp;that</x>" .getBytes java.io.ByteArrayInputStream. clojure.xml/parse :content)
10:46clojurebot["this&that"]
10:46Raynesspariev: Doesn't work for this.
10:46chouser,(-> "<x>this&amp;that</x>" .getBytes java.io.ByteArrayInputStream. clojure.xml/parse :content first)
10:46clojurebot"this&that"
10:48RaynesCool.
10:48chouserthere may be a better way to access that functionality
10:51stuartsierraRaynes: if you only care about the standard XML entities, it's easy. Supporting all 200-some HTML entities is annoying.
10:51danleihm
10:51danleiyes
10:51danleijust recognized that
10:51chouserI was surprised that this method seems to handel &nbsp; and &copy;
10:51danlei(-> "<p>&uuml;ber</p>" .getBytes java.io.ByteArrayInputStream. clojure.xml/parse :content first) won't work
10:51RaynesI just caved and pulled in commons.lang
10:52RaynesIt's not like it's a huge dependency.
10:52fogusThat's how it starts... :p
10:52Raynesfogus: ;)
10:59maacl_ I think there is a problem round-tripping xml from xml/parse to xml/emit - please look at http://paste.lisp.org/display/96511 at tell me if I am missing somthing. The result is not escaped correctly, i.e. the attribute values contain ' instead of apos;
11:00chousermaacl_: clojure.emit is buggy :-(
11:00chouserer
11:00chouserclojure.xml/emit
11:00maacl_chouser: ah, ok
11:01maacl_chouser: is there a recomended solution if I need to read - mutate - write xml?
11:01chousermaacl_: you might try clojure.contrib.lazy-xml/emit instead
11:02chouserit can use the kind of parsed tree produced by clojure.xml/parse or lazy-xml/parse, either one.
11:02Raynes~def time
11:02maacl_chouser: thanks, I will give that a try
11:02remleduffIf I'm in some arbitrary namespace (namespace1), and I want to invoke a function that's in another namespace (namespace2), I should be able to do something like (namespace2/function ...), right?
11:03S11001001remleduff: aye
11:03chouserremleduff: yes, as long as namespace2 has been loaded
11:04maacl_chouser: ah, that worked like a charm - thanks
11:05chousermaacl_: great. the one in lazy-xml can do indenting and non-default encodings too
11:07Chousukehm
11:07ChousukeI wanted to build zsh from source but it seems to depend on some obscure documentation markup language called yodl and yodl then depends on an obscure build system called icmake ;/
11:08chouseri love build systems
11:08chouserlove 'em
11:08chouserthe more the better
11:08Chousukeof course, neither of those are installable via macports
11:09cypher23Chousuke, have you tried Homebrew? it has a zsh recipe
11:10Chousukehmmh
11:10ChousukeI suppose I could try it.
11:11Chousukebut damn, I have too many package managers.
11:11cypher23I've switched to Homebrew, and booted MacPorts off my system
11:11ChousukeOS X's own with appfresh, macports, elpa, stow...
11:11Chousukehorror.
11:12cypher23someone needs to write a package meta-manager :)
11:13ChousukeI also don't want to install any package-managed stuff into /usr/local ;/
11:13Chousukebecause all the random installers put stuff there
11:13Chousukeand I want to at least be able to tell what's managed and what's not
11:13cypher23Chousuke, by default, Homebrew installs stuff into /usr/local/Cellar, then symlinks it to /usr/local
11:13cypher23but you can use a different install dir
11:18Chousukehm, github is being slow
11:18Chousukedownloading 12kB/s :P
11:18ChousukeI'm glad I'm not cloning emacs.
11:18Licenser_Chousuke: what are you cloning? Sheep?
11:19Chousukehomebrew :P
11:23Chousukehm, it looks like the zsh formula doesn't install from git :(
11:29Licenser_write a clojure os!
11:35SynrGi remember decades ago reading about the lisp machine
11:35astoddardI am using the clojure REPL for same exploratory data analysis. I have put some big data as references in a namespace. How should I clear the namespace to release the memory used by those references?
11:36chouser(ns-unmap (find-ns 'your-ns) 'your-var)
11:38SynrGoh. my first practical use of the repl to solve a problem. kinda trivial, but: (/ 800 480) (the question was "i have an image that i'd like to use as a desktop image. what aspect ratio does it need to be to fit my eeepc's display?)
11:39cypher23SynrG, (float (/ 800 480))
11:40SynrGcypher23: i didn't want a float
11:40cypher23oh, sorry. thought you were asking a question
11:40Bozhidaryou need a fraction?
11:42SynrGsure. i think it's more natural to express it as 5:3
11:42SynrGthan 1.666
11:42Bozhidartrue
11:42SynrGnot to mention, more accurate
11:44astoddardIs there a quick concise way to "clear" a whole namespace?
11:44RaynesIIRC: nope.
11:45Licenser_,(doc remove-ns)
11:45clojurebot"([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace."
11:45Bozhidarhmm, I don't know if there is a fuction to find equivalent fractions
11:46chouser= ?
11:46danlei(= 1/2 2/4)?
11:46astoddardLicenser_: Thank you. I missed it because I tried to (find-doc "ns-")
11:47etateLauJensen: nice post on IDEs :)
11:47BozhidarI meant something that could find the minimal equivalent fractions of (/ 800 480)
11:47RaynesI didn't think of remove-ns. :o
11:49texodusI'm looking for some feedback on the API design of a Netty wrapper library
11:49texodusIdeally I would like it to be as generally useful and clojure-y as possible before I tag it 1.0 or some such number
11:49texodusAnyone in here interested in such a library and willing to provide some feedback?
11:50texodushttp://github.com/texodus/saturnine
11:50texodusI like how handlers are defined right now
11:50texodusbut I'm torn on how to properly wrap server and client instances, how to deal with start and stop functions, threadpools, etc
11:51texodusso many java objects I want to make invisible in the clojue version
11:51chouserI don't think I need anything at that level -- I'd love async features for ring
11:52chousertexodus: I'd be wary of tieing your api too tightly to defining vars.
11:52LauJensenetate: thanks
11:52LauJensenJust updated that post with a Netbeans fix - and wow it is an impressive plugin they did: http://www.bestinclass.dk/index.php/2010/03/clojure-ides-the-grand-tour-getting-started/
11:52chouserIt's usually nearly as terse and much more flexible to do things like (def sum-server (server 1234 ...))
11:53astoddardchouser: I am a little confused by ns-unmap, both (ns-unmap (find-ns 'your-ns) 'your-var) and (ns-unmap 'your-ns 'your-var) appear to work. Is this just a convenience, using either a symbol or the namespace itself as the first argument?
11:53texodusthat makes sense
11:53chouserastoddard: oh, sorry -- I didn't try without find-ns
11:54chouserastoddard: the ns manipulation functions used to only take namespace objects, so you had to find them yourself with find-ns. Most (all?) now will find the ns for you if you pass in a symbol.
11:54chouserso yes, just a convenience.
11:56chousertexodus: one (possible) exception is when the thing your defining (server, handler, whatever) needs to know its own name. But even in that case I'd suggest your defserver be a very simple and just expand to (def foo (server foo ...)) so that users can stuff their servers in a map or something instead of vars, if they want.
11:57chousertexodus: you may find that this also helps you think more clearly about which Java objects belong in your Clojure API.
11:57texoduschouser: ah
11:57texoduschouse: so, if I want to represent the concept of a "server"
11:57astoddardchouser: thanks, got it.
11:57texoduschouser: and a server has a specification (list of handlers, port to bind, threadpool opts, etc)
11:58texoduschouser: *and* it has to have an identity once its been bound to a port and is actively listening (or a new state, at least)
11:58texoduschosuer: and it has single use resource like an executors threadpool
11:59texoduschouser: I want to cover all that. is it acceptable to have one (new-server ...) funciton that just takes a set of config options and returns a Servre datatype ...
11:59texoduschouser: then some other functions (start ...) (stop ...) that bash in place that one symbol boudn to teh result of (new-server ...)?
12:00texodusor should I treat the server isntance as a value?
12:01chousertexodus: that is a very good question -- one I've run headlong into a few times now, and I'm not sure I'm overly pleased with any of my solutions.
12:02chousertexodus: I guess I'd recommend keeping the value-like stuff as seperate as possible -- maybe in its own immutable object? I mean stuff like the set of handlers, config, port numbers, etc.
12:03chouserwell, that's too much detail.
12:04chouserI guess in short, yes -- providing start and stop functions that bash on a stateful object is I think exactly what you have to do for something like sockets
12:05texoduschouser: yeah, I stuck with vars originalyl because I never want there to be 2 clojure vals that reference the same server
12:06texoduschouser: making them vars limits how much you can ignore that they are inherently very stateful
12:06chouserI can see why that would be tempting, but I think it's incorrect
12:07texoduschouser: but it's ok to make functions like (start ...) and (stop ...) return nil, but bash in place the "server isntance"?
12:07chouseryes -- think of how clojure handles files
12:07texoduschouser: ah, good point
12:08chouseryou can do (def f (java.io.File. "foo")) if you want, but usually you don't. and certainly a (deffile f "foo") would be weird
12:08chousereither way you'd be responsible for closing it
12:12texodusits usualyl rpetty easy to encapsulate the file-processing logic without blocking, something like (with-rdr ...) works great
12:12texodus(with-server ...) would only ever look like (with-server [repl (new-server ...)] (Thread/sleep ....
12:13texodusimo, you should be responsible for closing a server explicitly
12:13chouserright. the analogy breaks down pretty quickly
12:14texodusneat
12:14texodusI looked at the grizzly, http-core and jetty ring adaptors
12:15texodusit doesnt loko terribly complicated, Netty has good HTTP support so it should be pretty simple to write an adaptor
12:15chousermy only point there was that it's entirely proper to have objects with real resources independent of vars
12:16texodusperfect
12:17texoduswould there be any advantage to having a Netty nonblocking ring adapter?
12:17texodusring isnt exactly asynchronous
12:17chouserit should be. :-)
12:17texodusalso, cant call sub-http level stuff, like starttls
12:17texoduswhich i think is the big win to netty over the others
12:18chouserI have an entirely asynchronous app sitting right below a ring server.
12:19texodushrm - maybe it would make more sense to have a ring-like api to an http handler than a straight ring wrapper
12:19texoduser, adapter
12:20texodusmake an http-handler that gets called with ring-like HTTPRequest maps and whatnot as messages
12:20chouserI wish ring itself provided both api styles -- sync and async
12:21texodusI actually like how grizzly, netty, mina handle that in java
12:22texodusthe design makes it trivial to choose synch or asynch at runtime, but force you to write in an asynch style, even if you block in your code
12:23texodusif ring supported both, would it have two apis?
12:24texodusor just force you to code in asynch style and let you block in one listener if you dont care
12:25LauJensenAny way to affect the priority that a future gets?
12:36astoddard Can I do something akin to c.c.shell-out but get a line-seq of the stdout?
12:36astoddardIf I try "with-open" to wrap the stream going to my line-seq then I get a runtime exception, "stream closed".
12:37astoddard If I don't use with-open I assume I am not closing the stream when I exhaust the line-seq?
12:37fogus,(sort [[3 2 1] [:a] [1 2 3]])
12:37clojurebot([:a] [1 2 3] [3 2 1])
12:37Licenser_astoddard: you've to force the line seq to evaluate compleately wit doall
12:37fogus,(sort [[:a :b :c] [3 2 1] [1 2 3]])
12:37clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Keyword
12:37Licenser_or dorun
12:37fogushrmph
12:37Licenser_but the lzyness bites you here
12:46astoddardLiceneser_: got it, doall works. So I can't lazily read a stream and then have it close at the end?
12:46stuartsierranot safely
12:47chouserastoddard: what happens if you happen to not get to the end?
12:49astoddardchouser: is that a didactic or a specific question? In my case I should always consume the whole sequence, its just very long and I might want to filter it on the way.
12:49chouserdidactic
12:49chouserduck-streams has a function that returns a lazy-seq on a file which closes said file when the seq is fully consumed.
12:50chouserso it can be done, but it's fragile and not recommend.
12:50chouserstuartsierra: no worries -- I wrote such functions as well, just didn't get around to putting them in contrib.
12:50clojurebotstuartsierra is volunteering
12:51stuartsierraclojurebot: hush
12:51clojurebotI don't understand.
12:51stuartsierraLately I've been thinking about scoped streams with dynamic vars.
12:52Licenser_astoddard: not sure I guess you can wrap it in a new lazy seq
12:52chousersounds somewhat similar to rhickey's "scopes" -- you're thinking of something a bit different?
12:52stuartsierraprobably similar, not sure how scopes are/were supposed to work
12:53chouserthey provide sort of generic dynamic scoping hooks
12:53stuartsierrayeah
12:53astoddardchouser and stuartsierra: I see, thank you. Is the general principle here that laziness and java exceptions don't mix well?
12:54stuartsierraastoddard: when open resources are involved
12:54stuartsierraastoddard: it's more that laziness doesn't mix well with resources that must be explicitly closed
12:56chouseriteractions between laziness or closures and any kind of dynamic context introduces complexity that can be hard to manage.
12:56astoddardstuartsierra: ok, thank you. Is the infamous function above "read-lines" ?
12:57stuartsierrayes
13:05Licenser_wouldn't somethjing liuke this work: http://gist.github.com/335459
13:05Licenser_(not tested)
13:05hiredmanline-seq does similar
13:05chouserLicenser_: no, because the exception could occur elsewhere, simply causing the consumer of the seq to quit consuming.
13:06hiredmanbut it only works if you consume the whole seq
13:06chouserand thus leaving the file open accidentally
13:07Licenser_ahhh I see
13:08Licenser_it is sad that there does not seem to be a nice solution for this
13:09chouseryes. which is why rhickey and stuartsierra are dreaming up solutions.
13:10chouserbut I'm guessing there's something the rhickey doesn't like about his scopes, because they've been implemented at least once if not twice, and still aren't in core.
13:10chousers/the/that/
13:15stuartsierraHow did scopes work when they were there?
13:15hiredmanthey never were "there" beyond a lisppaste
13:15hiredmanclojurebot: scope?
13:15clojurebotscope is at http://paste.lisp.org/display/73838
13:22Licenser_clojurebot: cookies?
13:22clojurebotTitim gan éirí ort.
13:22gkoHello: with contrib.clojure.command-line, what's the idiom for with-command-line with variable? Looks like I have to build cmdspec by hand...
13:24chousergko: there's a little example at the end of command_line.clj that shows what a cmdspec can look like.
13:24chousernot exactly overwhelminging complete documentation, sorry.
13:24Licenser_hmm are there any centralized efforts to improve documentation?
13:24gkochouser: (with-command-line *command-line-args* ...
13:24gko [[serve "Starts a repl server on the given port" 8081]...
13:24gko
13:25gkochouser: OK, but if 8081 is a symbol, SERVE is bound to that symbol, not the value in it.
13:25chouseroh, I see
13:26gkochouser: basically, I want to (def *my-default-value* XXXX)
13:26chouserI'd just leave it blank, which gives you a nil value if that flag isn't specified.
13:26gkochouser: then use: [[serve "help" *my-default-value*] ...]
13:26chouserthen when you're passing that value into your real function, provide the default there: (or myflag *my-default-value*)
13:27chouserhm -- perhaps that default should indeed be evaluated.
13:27gkochouser: yes, but -help doesn't show the default value...
13:27chouserright
13:27chouser:-/
13:28gkoI guess I'd have to hack command-line/make-map ...
13:28chouserok, it looks to me like with-command-line could allow those defaults to be evaluated.
13:29chouserit might be better to do something a bit more like 'locals' -- extract just the defaults from the cmdspec and provide that at runtime as another arg to make-map and print-help
13:30chouserso with-command-line would expand to something like (let [defaults {:port *my-default-value*}, {:strs ...} (make-map defaults ...)] ...)
13:31chouserI would welcome such a patch.
13:33gkoI'll try...
13:33chouserthanks!
13:35gkomaybe it could with-command-line* so that the non-evaluating still exists...
13:35chouserI'm having trouble thinking of when non-evaluating would be useful.
13:36gkobind a symbol ?
13:36gkoor keyword
13:36chouserit's not like you can pass in symbols or lists from the shell command-line. Your values pretty much have to be converted from strings anyway, so why not your defaults as well?
13:37chouserI'm not even sure numeric defaults like in that example make much sense.
13:37gkowell, I think the problem is repetition...
13:38gkothat is, the hard-coded value is stored here and maybe in a Var...
13:39chousergko: right. evalution of defaults makes sense to me. maybe after evaluation the default should be converted to a string so it matches the type you'd get if the user entered it on the command-line
13:40chouseroh, before you work on a patch make sure you've got your CA signed.
13:41gkoURL?
13:41clojurebotsomething
13:41chouserhttp://clojure.org/patches
13:42gkoOK
13:43rfgI just pulled the latest clojure, swank-clojure, slime, clojure-mode etc. and now the slime repl seems to just hang. Any ideas?
13:44gkoWhat's CA ? Certificate Authorization ?
13:44technomancyrfg: slime from trunk is known to be problematic with clojure, have you tried the swank-clojure readme?
13:45chouserContributor's Agreement: http://clojure.org/contributing
13:47chousergko: of course you can patch the file for your own usage, but if you want to get it into contrib, we need a CA from you so I can commit it into the official repo.
13:47rfgtechnomancy: heh, wait I hadn't actually pulled swank-clojure. Let me try again. :)
13:47gkoOK, I'll check about this later.
14:04crowb4rHey, clojure every submit to google sumemr of code?
14:04crowb4rsummer*
14:09slyphonanyone know if there's a "sane" way to update a database after an STM transaction commits?
14:09slyphonkind of like this: http://groups.google.com/group/clojure/browse_thread/thread/aa22a709501a64ac/b578f0915b55c4be?lnk=gst&amp;q=dosync+and+database+transactions#b578f0915b55c4be
14:09slyphonbut not requiring an STM/XA necessarily
14:13technomancyhttp://gist.github.com/335533 <= is this a known issue?
14:13technomancyrest args getting ignored on recur
14:18polypus~ping
14:18clojurebotPONG!
14:28polypusanybody know what the story is with c.c.string. it is documented but is not in the latest 1.2 build
14:29stuartsierrapolypus: what?
14:29polypuswhat what :)
14:29stuartsierrac.c.string should be in current contrib 1.2.0-SNAPSHOT
14:29polypuslet me just go double check again
14:32crowb4rWhat ides does everyone use for clojure?
14:32crowb4rJust curious
14:32chouservim + rlwrap
14:32seangroveUse for clojure?
14:32seangroveemacs
14:32polypusstuart. was looking into it late last night, tired. seems to be there now. must have a path problem someplace. sorry
14:33stuartsierranp
14:33crowb4rI use emacs as well. I'm giving inteliJ community edition with the clojrue plug-in a shot.
14:34seangrovecrowb4r: Are you a long time emacs user?
14:35polypusstuart: btw, in the comment at the top of c.c.string on github it says that it is meant to replace c.c.string. did you mena c.c.str-utils?
14:35polypus*mean
14:38crowb4rseangrove: actually no. I only started using it when I started using clojure.
14:39seangrovecrowb4r: Ah, got it
14:39seangroveLet me know how you like intellij
14:47crowb4rseangrove: will do. the code completion is nice in any IDE, but lets see how good it is.
14:49stuartsierrapolypus: yes
14:49polypusss: k, ty
14:51tomojI've been amazed lately by the code completion in emacs
14:51tomojit's started doing things I didn't think it could do
14:51tomojI believe it completed a java method name in a (.method style call
14:51tomojhow it could possibly have known, I can hardly imagine
14:52tomojI hadn't even typed the symbol for the object var yet..
14:52polypustomoj: which emacs lib are you using? i haven't really looked into completion yet
14:52tomojpolypus: just standard clojure-mode and swank-clojure from elpa
14:53tomojI am going to investigate
14:53polypusC-/ ?
14:53tomojI have TAB bound to slime-indent-and-complete-symbol
14:53polypushuh, thx, i'll have a look at that
15:04duncanmtechnomancy: ping?
15:04duncanmtechnomancy: if i 'embed' swank-clojure in my java app, i'm getting this error "Can't def -main because namespace: .... refers to:#'swank.swank/-main
15:06duncanmdum de dum
15:09zaphar_psduncanm: how are you embedding?
15:09zaphar_psand is it clojure?
15:09zaphar_psor vanilla java?
15:12duncanmzaphar_ps: i have that already
15:12duncanmwell
15:12duncanmi have (:use [swank.swank :as swank])
15:20technomancyduncanm: use is very different from require
15:20technomancyuse doesn't make sense with :as
15:21technomancytry (:use [swank.swank :only [vars you are using]])
15:21duncanmthat's what i did
15:21duncanmit works now
15:21technomancycools
15:21duncanmbut only if i build it from Ant, i think Enclojure for Netbeans is a bit confused
15:21zaphar_ps:-)
15:32duncanmhmm, is it the case that the JVM in osx 10.5 is not as good as the one on Windows?
15:35stuartsierrayes
15:35duncanmstuartsierra: if i upgrade to 10.6, would it be better?
15:35stuartsierradunno.
15:35stuartsierraOSX JVMs lag 1-2 revisions behind Windows & Linux
15:36duncanmbut linux jvms are decent?
15:36stuartsierrayes
15:36duncanmi've been developing on windows, and it's definitely pretty good
15:36duncanmstuartsierra: i've noticed that swing seems to work best on Windows
15:36stuartsierraduncanm: also check your JVM version, many versions of OSX come packaged with Java 1.5, not 1.6
15:37duncanmyeah, i did that, i'm running 1.6 already
15:37polypus~ping
15:37clojurebotPONG!
15:38tomojthe JVM shipped with OSX is partially made by apple, right?
15:38stuartsierraI don't understand the relationships, but "Apple" appears in the vendor string.
15:45mabesApple doesn't want java GUIs to look un-appley so they release there own modified version.. that is why the releases lag
15:46mabesthats my understanding at least.. it might differ in other ways too
15:46ChousukeCyberduck is a good example of a native OS X Java app
15:46ChousukeI couldn't even tell it was java before I glanced at the source and saw java files
15:47Chousukehiredman: exactly :)
15:50hiredman~ticker JAVA
15:50clojurebotjava.io.IOException: Server returned HTTP response code: 400 for URL: http://www.google.com/finance/info?q=JAVA
15:50hiredman~ticker ORCL
15:50clojurebotORCL; +0.29
15:52crowb4rhiredman: when you did the modules for clojurebot how did you set-up the keywords that trigger the function in that module?
15:52hiredmanit's a function
15:52hiredmanyou define a predicate that gets to examine messages
15:53crowb4rok
16:04arohnerhrm. IMO, the indentation on clojure-mode for letfn is broken
16:04arohnerand the instructions for how to fix lisp-mode indentation all say "CL and Scheme are indented properly. Don't touch it"
16:07The-Kennyarohner: I think it's also broken for cond
16:07arohnerhmm, (setq lisp-indent-offset 2) makes me happier
16:09The-Kennyhm.. cond looks correct now. But something wasn't very beautiful
16:10The-Kennyhttp://gist.github.com/335665
16:10The-KennyThat was is
16:10The-Kennys/is/it/
16:14arohnerThe-Kenny: that still has too much indentation for me
16:14arohnerThe-Kenny: your example looks correct here
16:15The-Kennyarohner: Huh, strange
16:15The-KennyWait, I'll gist the whole macro
16:15arohnerI'm running clojure-mode HEAD (as of 5 minutes ago), with (setq lisp-indent-offset 2)
16:15LauJensenM-x gist-region
16:15arohnertechnomancy's clojure-mode, that is
16:16The-Kennyhttp://gist.github.com/335674 is another function there the indenting is broken
16:16The-Kenny(this version is indented by-hand)
16:17The-Kennyarohner: hm ok.. haven't updated clojure-mode in a while
16:17The-KennyI think I have to get back to this later, or tomorrow... I have some non-clojure work to do :(
17:01Licenser(doall (map greet (/who)))
17:01ChousukeLicenser: illegal token
17:02Licenserit is a special reader macro for my irc clojure reader
17:25{newbie}_Hi I created a double[] with double-array and defined a
17:26{newbie}_the problem is Arrays/toString says it is using reflection
17:26{newbie}_I tried to make a new def with a type hint
17:26{newbie}_like this
17:26{newbie}_(def #^doubles b a)
17:26{newbie}_but when I try tu use toString on b
17:26{newbie}_I get the error
17:26{newbie}_: Unable to resolve classname: clojure.core$doubles__6157@4cedf389 (NO_SOURCE_FILE:14)
17:28hiredmanpastebin it
17:31{newbie}_http://paste.pocoo.org/show/190941/
17:41{newbie}_noone?
17:54Licenser{newbie}_: Sorry that really isn't my expertise
17:55Licenserso I don't even have Arrays
17:56{newbie}_ups I forgot the (import 'java.util.Arrays)
17:56{newbie}_in the paste
17:57Licenserfor me it works
17:57{newbie}_Licenser: the problem is after you set (set! *warn-on-reflection* true)
17:58Licenserah sneaky
17:58Licenser((fn [#^doubles d] (Arrays/toString d)) a)
17:58Licenserthat works
17:59{newbie}_yeah
17:59{newbie}_I was wondering why the type hint in the def doesn't work
17:59Licensergood question
18:00Licenseralso why there is an exception
18:00Licenser(let [#^doubles d a] (Arrays/toString d)) works too
18:01Licenseralso the exception is very odd: swank.util.io.proxy$java.io.StringWriter$0 cannot be cast to java.io.PrintWriter
18:02LicenserI think that I think that it might be a swank thingy
18:02{newbie}_that execption is from swank
18:02technomancyshould be fixed in the latest swank
18:04Licenserhmm in repl I see that it gives the same error as yours
18:06Licenser(def #^"[D" d a)
18:06Licenserthat is your solution
18:06Licenserweeh!
18:07{newbie}_but
18:07Licenser{newbie}_: The cause was that #^ requires java notation and java calles an array of doubles [D
18:07{newbie}_thats horrid
18:08Licenserit's not horrid it's worst, it's JAVA
18:08{newbie}_but Licenser why is #^[D only required in def?
18:08Licenseryap
18:09chouseryou're sure #^doubles doesn't work? What version of Clojure?
18:09{newbie}_1.1
18:10Licenserhmm and you can't type a function it seems
18:11chouser,(use '[clojure.contrib.repl-utils :only [expression-info]])
18:11clojurebotjava.lang.ExceptionInInitializerError
18:11{newbie}_,(import 'java.util.Arrays)
18:11clojurebotjava.util.Arrays
18:11{newbie}_, (def #^doubles a (array-doubles 2))
18:11clojurebotDENIED
18:11{newbie}_,(def #^doubles a (array-doubles 2))
18:11clojurebotDENIED
18:12{newbie}_doesn't work in my 1.2 snap
18:12chouseroh, it's something about 'def'
18:12Licenserwhat is odd is that i can't (def #^"[D" ds (fn [n] (doubles n)))
18:12LicenserI wonder really why it is not possible
18:13chouseryou can use #^doubles to hint a defn, or your *use* of a def, but not the def itself
18:13chouser'def' is one of the few special forms we use directly
18:14Licenserchouser: I tried def since defn didn't worked
18:14{newbie}_chouser: what is the *use*
18:14{newbie}_?
18:14chouserjust emphasising that word
18:14{newbie}_o
18:14Licenseruser=> (defn #^"[D" ds [n] (doubles n)) ;=> #'user/ds
18:14Licenseruser=> (ds 2) ;=> java.lang.ClassCastException: java.lang.Integer cannot be cast to [D (NO_SOURCE_FILE:0)
18:15Licenseror am I doing it wrong
18:15Licenserit seems not possible to type the reslt of a functio
18:16chouser(defn foo []) (expression-info '#^doubles (foo)) ;=> {:class [D, :primitive? false}
18:17chouser(defn #^Integer foo []) (expression-info '(foo)) ;=> {:class java.lang.Integer, :primitive? false}
18:17Licenserchouser: the type hint seems to be seen as the value of the first argument not for the function
18:18polypusi have a bunch of functions which i'd like to have the side effect of writing to a character stream of some sort. do i need to dig into javaland or is there something in clojure i should be looking at.
18:18Licenserpolypus: you can rebind *out* or something like that
18:19Licenseralso the duck-streams are very niceish for that
18:19chouserLicenser: you see I hinted that foo would return an Integer?
18:19polypusLicenser: thx, don't want to rebind out, but i'll look through duckstreams. ty
18:20Licensertry something like (defn #^Integer foo [a]) (foo 2) it will fail
18:20{newbie}_Licenser: you hints function will work
18:20{newbie}_(ds (double-array 2))
18:20{newbie}_it just explodes because you are passing an integer
18:20Licenserodd odd it didn not work with the doubles
18:20LicenserI am confused
18:20{newbie}_Licenser:
18:20{newbie}_you passed an integer
18:21{newbie}_then it calls (doubles on that integer
18:21{newbie}_then it throws the expcetion
18:21{newbie}_,(doubles 2)
18:21clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to [D
18:22Licenserah darn I'm a idiot
18:24Licenserso I wonder why when a is defed to something with a fixed type why a itself isn't type hinted
18:24polypusso is duck-streams now called c.c.io?
18:25chouseryes
18:25polypusis there someplace where all these name changes are documented?
18:27Licenserthere is on documentation in clojure :
18:33Licenseryou know people I start to feel more compfortable with clojure day to day :) it is a really great experience when you can see how you go from only asking silly questions to actually be able to contribute back to the community
18:34polypus(doc format)
18:34clojurebot"([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"
18:34polypusoops wrong buffer, sorry
18:34Licenser^^
18:42slyphontechnomancy: hey, is there a way to get swank-clojure-project to add extra system properties to the jvm startup commandline?
18:48slyphontechnomancy: actually, i guess the problem is that i have a custom *.jks file and i need to set the system property so the SSL layer will use that instead of the default trust store
18:50Licenserslyphon: I think there is a property for the JVM parameters
18:50slyphonoh?
18:51slyphoni was wondering if there was one in the project.clj
18:51LicenserI don't remember wich but I remember I could set it
18:51Licensern
18:51slyphonhmm
18:51Licenserno no it was emacs glboal
18:51slyphonah
18:51Licensercan't put anythin in the project one, after all it needs to load the project.clj with the JVM ;)
18:51slyphonyeah, totally
18:51slyphonthere's swank-clojure-classpath
18:52slyphoni guess i'll just look through the cod
18:52slyphone
18:54tomojslyphon: I think you can just set swank-clojure-extra-vm-args
18:55tomojas for leiningen, I don't know, but I believe that works for swank-clojure-project
18:55slyphonoh, ah, yes
18:55slyphoni think you're right
18:55slyphonthere's also this: http://wiki.github.com/technomancy/leiningen/emacs-integration
18:55slyphonwhich i guess could do something similar, but no need
18:59duncanmwhat's the right way to load clojure.contrib.string now?
18:59duncanm(use 'clojure.contrib.string :as s) doesn't work
18:59slyphon(use '[clojure.contrib [string :as s]])) ?
18:59slyphon(untested)
19:01duncanmnope
19:01slyphonhrm
19:01slyphonoh
19:01slyphonrequire?
19:02duncanmahh
19:02duncanmwhat's the difference between USE and REQUIRE?
19:03Chousukerequire imports the names fully qualified
19:03Chousukeuse just imports the names.
19:03Chousukeuse require :P
19:06dnolenduncanm, easy rule of thumb: (:use [lib :only [a b c]) or (:require [lib :as alias])
19:06technomancys/import/refer/ to be pedantic
19:06technomancysince import already has a specific meaning
19:07dnolendon't bother with any other combination, (:use lib) is only for playing around. you're just begging for refer conflicts down the line if you use plain :use
19:07tomojrefer has a specific meaning too, doesn't it? :(
19:10tomojis use just require+refer ?
19:10slyphonhrm
19:11technomancytomoj: yeah
19:18technomancyclojurebot: use vs require is (:use [lib :only [a b c]) or (:require [lib :as alias]) -- (:use lib) is only for playing around
19:18clojurebotIk begrijp
19:18technomancy(rather a faq)
19:19crowb4rwhat is that string clojurebot jsut spitout?
19:19slyphontechnomancy: lein swank?
19:19slyphonhowto?
19:20slyphondo i need the bleeding edge?
19:20technomancy$ lein swank # <= like that?
19:20technomancyoh, it's a plugin
19:20slyphonah
19:20technomancybelongs in :dev-dependencies
19:20slyphonah, ok
19:20slyphonwow, that adds quite a bit to the 'ol lib there
19:21slyphontechnomancy: awesome, ty
19:21technomancysure
19:31polypuswith lein repl, loading c.c.string, i get: java.lang.VerifyError: class clojure.contrib.string$loading__4789__auto____3 overrides final method meta.()Lclojure/lang/IPersistentMap; (init_specs.clj:1) is this because lein repl is loading clojure 1.1.0 and not 1.2.0?
19:33dnolenpolypus: I believe lein only really support 1.2.0. If you want to hack reliably with 1.2.0 lein is not the way to go. Write you're own shell script, import swank and be done with it.
19:33technomancypolypus: probably; you should use nailgun or swank instead of the repl if you're mixing clojure versions
19:33dnolener sorry 1.1.0
19:33technomancydnolen: that's only true of "lein repl"; it works fine for the other tasks
19:34polypusk, ty
19:34dnolentechnomancy: that's good to know.
19:41duncanmdoes lein work with java sources as well?
19:41duncanmi've been using netbeans and ant because it sorta lets me have mixed projects
19:41technomancyduncanm: yes, but cemerick will mock you mercilessly if you do
19:41duncanmheh
19:41duncanmokay
19:41technomancysearch for lein-javac
19:52tomojare dev-dependencies added to the jar/uberjar?
20:13duncanmhmm, what can i do to convert a LazySeq to a java Iterable?
20:14duncanmah, iterator-seq
20:14duncanmahh
20:14duncanmiterator-seq goes the other way, sigh ;-(
20:20hoeckduncanm: seqs implement Iterable already
20:20hoeck(.iterator (seq ...))
20:23slyphonso, let's say I wanted to persist my data structures in a database, what would be the sanest way of handling the db-transaction/stm-transaction interaction
20:24slyphonwow, that kind of sounded like Jesse Jackson
20:24lancepantzlo
20:24lancepantzl
20:24slyphon:)
20:51duncanmis it no good if i have side-effect inside a :let in a for-expression?
20:53powr-tocI'm considering trying to host a Clojure workshop for a few guys I know who are don't know Clojure but are intreagued... does anyone have ideas about what to do, and how to structure it?
20:53powr-tocI'd like it to be hands on.... i.e. I think step 1 will be to install either Emacs/SLIME or Netbeans
20:53powr-tocwith enclojure
21:03technomancypowr-toc: that will take longer than you think it will
21:03technomancyjust as a warning
21:03technomancypowr-toc: I would recommend setting up a screen session on a shared user that everyone can SSH into
21:03technomancythat worked really well for the seajure meeting
21:03technomancyno projector required. =)
21:03slyphonrhickey: do you have any suggestions wrt. database transaction / stm transaction interactions?
21:04slyphoni saw a thread a while back about integrating STM with JTA, but it looked as though that were a patch that got abandoned
21:04slyphonthat was*
21:04psykoticthe obvious answer is 2pc but that's tricky to get right
21:05powr-toctechnomancy: that's not a bad idea, but I'd like people to take away a working clojure environment
21:05slyphoni didn't think there were the hooks necessary in STM to do it
21:05clojurebotthe STM is not a lock
21:05slyphonclojurebot: excuse you
21:05clojurebotI don't understand.
21:05replacatechnomancy: what was the reason that lein includes dev-dependencies in the uberjar?
21:06technomancyreplaca: nobody's bothered to fix it yet. =)
21:06powr-toctechnomancy: but it might be a good idea, to get people to do that anyway as a way of focussing everyone on the same task
21:06dnolenslyphon: because of stm transactions retries, rhickey added the ability to send-off an agent at the end of a successfully completed transaction, is that what you're asking about?
21:06replacatechnomancy: ok
21:06slyphondnolen: so would that be the suggested strategy?
21:07dnolenwell people brought up the issue and he added that feature in response. there's thread on the ML about it.
21:07slyphonwell, suggested is probably the wrong word
21:07slyphonoh, i didn't know that feature was a response to that
21:07slyphoni saw something about JTA transactions specifically, posted about 2 years ago
21:07technomancypowr-toc: it would be good to have everyone on a working environment, but you'll guaranteed have one guy with a really old emacs (or something) and it will take 5x as long on his machine, so it's a shame to have everyone else slowed down because of it
21:08technomancypowr-toc: ideally: one guy doing the main preso, someone else can help with environment setup for the problematic cases
21:08technomancyyou could use agents!
21:09technomancyreplaca: uberjar should just tie into a list that comes from the lancet/maven tasks rather than listing lib/, but I'm not sure how involved of a change that is
21:09technomancyslyphon: just be aware that ACI + agents for writing is not ACID by any means
21:09technomancyit's ACI + some persistence, but that's all
21:09slyphonright
21:10slyphoni'm willing to accept some lossage if the process is killed
21:10technomancythat should work then
21:10slyphonit's a task-queueing system that will basically load its state from the database, and perform planning around the values in memory, persisting to the db after a state change
21:10replacatechnomancy: makes sense
21:11slyphonif some change doesn't make it to the DB because of power loss or something, it's not the end of the world
21:11crowb4rtechnomancy: Thanks for the post on Rudel. My friend and I are using it to work on some things.
21:11technomancya'ight; bye folks
21:11slyphontechnomancy: lata
21:11technomancycrowb4r: sweet
21:13powr-toctechnomancy: hmmm... true... do you have any ideas on cute little code snippets or problems that would be good for beginners study?
21:23mebaran151in Windows Emacs, how do I get auto-indentation?
21:24duncanmC-M-\
21:24duncanmit's the same in all of emacs
21:24duncanmor M-x indent-region
21:24mebaran151I mean auto-indentation, on enter
21:24slyphonmebaran151: you need to rebind RET
21:25duncanmif you use paredit, or even lisp-mode/clojure-mode, it should do that for it already
21:25slyphonnewline-and-indent
21:26mebaran151I have paredit mode running
21:26rpenguinhow do demo repls avoid getting stuck and burning cycles from things like (recur)
21:27mebaran151but it still doesn't auto-indent newlines
21:30slyphonmebaran151: (define-key global-map (kbd "RET") 'newline-and-indent)
21:30slyphonin your .emacs
21:31mebaran151slyphon: but I only want this behavior in clojure-mode or paredit-mode
21:32slyphonmebaran151: well, i guess you should research http://emacswiki.org or go ask in #emacs
21:42mebaran151alright slyphon, I'll check it out
21:42slyphoni'm pretty sure emacswiki has something on this
22:44slyphongah
22:44slyphonjava sucks
22:44slyphonno, not java
22:44slyphonSOAP
22:45TheBusbyhaha, so so true
22:45slyphoni can't believe someone thought SOAP was a good idea
22:45TheBusbyit solves a certain set of problems, but introduces a fair number as well
22:46slyphonyes, the classic, "I have a problem, oh i know, i'll use $technology, now I have two problems"
22:46TheBusbyI prefer xmlrpc for simplicity, if I really want to pay the XML performance demon
22:46TheBusbyI'm hopeful google protocol buffers will become more popular though
22:47TheBusbynot quite the same thing, but "good enough" for many of the areas where I see soap used
22:47slyphoncouple of big boys are into them
22:47slyphoni know twitter is messin' with them internally
22:47slyphon(take that for what it is)
22:47slyphonargh
22:47TheBusbydoesn't twitter "mess" with just about everything?
22:48TheBusbyseems like that's the case at least
22:48slyphoneh, i got a buddy that works there, there's a bunch of really smart mfkrs there
22:48slyphonthey're trying to deal with a hockey-stick growth curve
22:49TheBusbyquite possibly, but they get known for trying just about every new piece of tech that comes out
22:49slyphonheh
22:49slyphoni think they got that rep because they were using rails
22:49TheBusbythere traffic is nothing to be sneezed at, but it's nothing that any of the big boys aren't playing with
22:50slyphontrue
22:50TheBusbyI'm thinking post rails, then scala, then every message queuing system on the market, a hord of distributed db systems...
22:51slyphonyeah, they're trying to scale *fast*
22:51TheBusbyit really seems like everytime I hear about something new, I shortly hear "twitters playing with that"
22:51slyphonand a lot of MQ systems are fucking garbage
22:51slyphonesp. for the type of use-case they're dealing with
22:51slyphonoh, and integrating it with ruby :P
22:51slyphonstomp is a joke
22:51TheBusbyyeah, but something at that volume they should fall back on C
22:51slyphonehhhhhh
22:52slyphonthey had to transition most of the real heavy lifting ot the JVM
22:52TheBusbyyou pay your pound of flesh for coding in it, but it'll give you the best performance available
22:52slyphonhard to find good C app devs though
22:52TheBusbyreally?
22:52slyphonwell
22:52slyphoni dunno
22:53TheBusbyit's certainly not the "hot new thing"
22:53slyphonin my circles
22:53slyphoni ran into a recruiter for Bloomberg and he told me the financial sector is desparate for C++ guys
22:54TheBusbyyou have to be careful though because certain industries stick with certain technologies "just because"
22:54TheBusbygoogle's care backend is C++ isn't it?
22:55TheBusbyer, *core*
22:55slyphonyeah
22:55slyphonwell, they have the money and need for that kind of shit
22:55slyphonyou can't just rely on moore's law
22:55slyphonat that scale
22:55TheBusbyneither can twitter...
22:56slyphoni mean, shit, that project that facebook is using
22:56slyphonturns PHP into C++
22:56slyphonthat's just evil
22:56TheBusbyit's "performant"
22:56slyphonsure
22:56TheBusbysame issue with Ruby, when you need the performance you drop down to C.
22:57TheBusbydo fancy stuff in Ruby, but keep the core "performant" bits in C
22:57TheBusbyClojure is great because with the multithreading you'll get the performance of C in many cases (not IO though :'( )
22:58TheBusbywhile staying in clojure the entire time
22:58slyphoni don't think multithreading has to do with "the performance of C"
22:58slyphonyou're talking about two different cases there
22:58TheBusbythat's true
22:59TheBusbyapples to oranges
22:59TheBusbybut with clojure you can quickly put together a multithreaded app that is equilavent to the single threaded app in C you'd probably have created instead
22:59TheBusbyer, performance wise at least
23:00slyphonif your problem is parallelizable, sure
23:04TheBusbythe issue I'm consistently running into is JVM IO
23:06slyphonhrm
23:08TheBusbyfeel my pain, http://tinyurl.com/yl4fo46
23:08TheBusby(JVM IO compared to C)
23:09slyphondon't direct buffers basically give you zero-copy performance?
23:10slyphoni mean, sure, NIO is kind of a pain in the nuts...
23:10TheBusbydidn't know about NIO, googling now
23:11slyphon!!
23:11TheBusbyI used java primarily when Java 1.1 and 1.2 we're popular
23:11slyphonah
23:11TheBusbyI've missed about a decade of Java development
23:12slyphonyeah, NIO is the newish hawtnez
23:12slyphonit's like a select(2) loop based thing
23:12TheBusbyfunny that the article I linked to is missing NIO as well...
23:12TheBusby(from Feb 2008 no less)
23:13slyphoni'm pretty sure NIO gives you mmap() too
23:13slyphoni don't generally do anything at that level