#clojure logs

2009-09-28

00:17tomojI'm having trouble making an executable jar
00:18tomojI've got a foo.main namespace with a main function, but no foo/main.class gets compiled, just stuff like foo/main__init.class, foo/main$main_8.class
00:19hiredmando you have a (:gen-class) in side the namespace declaration?
00:20tomojno, I'll look into that
00:20tomojclojure/main.clj doesn't have one of those.. confusing
00:21hiredmanmain.clj is not what is called by java -cp clojure.jar clojure.main
00:21tomojoh
00:21hiredmancheck src/jvm/clojure/main.java
00:21tomojwell now a main.class is getting created, but it doesn't work
00:22hiredman~compile
00:22clojurebotthe unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation
00:22tomojsomething wrong with my build.xml probably
00:23tomojkeep getting "could not find the main class: jboselpli.main" even though the jar contains jboselpli/main.class
00:45tomojwoot it works
00:45tomojI needed a zipgroupfileset to pull in the classes from clojure.jar and clojure-contrib.jar
00:46tomojnow I have a 4.6mb jar that just prints "foo" :D
01:33sfuentesis there such a thing as raw strings in clojure?
01:34Makoryu"Raw?"
01:40sfuentesso i can have a string like "\/"
01:41hiredman,"\\/"
01:41clojurebot"\\/"
01:41hiredman,(print "\\/")
01:41clojurebot\/
01:43sfuentesis there a way to do that without prefixing \?
01:43Makoryusfuentes: Nope.
01:44sfuentesok. thank you.
01:44hiredmanit's called "escaping"
01:47konr,(:foo {:foo [0 1] :bar [1 0]}
01:47clojurebotEOF while reading
01:47konr,(:foo {:foo [0 1] :bar [1 0]})
01:47clojurebot[0 1]
01:48konrHmmm, shouldn't this always work?
01:48hiredmanthis? work?
01:48konrhiredman: the (:foo {:foo [0 1] :bar [1 0]})
01:48hiredmanwhat about it?
01:49konrshouldn't it always return [0 1], or there is some catch?
01:49hiredmanin that exact case, I can say yes
01:49hiredmanbut I doubt you are using exactly that code
01:50hiredmanmost likely you are doing something like (x {:foo 1 :bar 2}) where x is a variable and you are passing in something other than a keyword
01:52konrhmmm
02:09konroh, of course
02:56licoresse,(doc ->>)
02:56clojurebotexcusez-moi
03:18sfuentesi'm trying to use slurp but i'm having trouble using the correct file path when using a jar deployment. anyone know what the correct path may be?
03:22cgrandsfuentes: I don't think slurp is the right tool for this job
03:23sfuenteswhy is that?
03:23cgrandslurp* in c.c.duck-streams should be better
03:24sfuentesthat's what i'm using
03:25cgrandthen what does your current attempt look like?
03:26sfuentesit works fine when i use an absolute path without using a jar file ... but when i try to package it inside a jar, it seems to loose track of the file location
03:27sfuentesI get: Exception in thread "main" java.io.FileNotFoundException
03:27cgrandare you loading the file through a FileSomething or through a classloader?
03:27cgrandor directly as a path ?
03:27sfuentesdirectly
03:27Fossihi
03:30cgrandsfuentes: what does (-> (RT/baseLoader) (getResourceAsStream "your/path/relative/to/the/jar/root")) returns?
04:08AWizzArd~max people
04:08clojurebotmax people is 178
04:08Fossistill
04:10AWizzArdwe will get 200+ this year
04:10AWizzArdFossi: happy with the election results? :)
04:13AWizzArdHi LauJensen1.
04:38pixelmanI'm writing a macro which uses a function not in the current namespace (but which is imported in), when the macro expands it tries to find the function in the current namespace and fails. how can make the macro not add the current namespace?
04:43Chousukehm
04:43Chousuke,flatten ;test
04:43clojurebot#<seq_utils$flatten__3 clojure.contrib.seq_utils$flatten__3@1c6fed0>
04:43Chousuke,`flatten
04:43clojurebotclojure.contrib.seq-utils/flatten
04:43Chousukepixelman: it should work like that.
04:44Chousuke,`foo
04:44clojurebotsandbox/foo
04:44Chousukepixelman: so what is your problem exactly?
04:45pixelmanChousuke: I am trying to write a macro that lies on top of the GET macro in compojure
04:45Chousuke~macro help
04:45clojurebotmacro help is http://clojure-log.n01se.net/macro.html
04:45pixelmanI want to do something with request first (log some stuff) and then execute the action.
04:46pixelmanah, great, I'll try the macro helper!
04:47Chousukeif the function is only imported by require, then you might need to manually type out the whole qualified name
04:55pixelmanHm. I think I got it wrong, the problem isn't that it's a a function, it's a variable that's in the scope of the underlying macro because of a macro called with-request-bindings
04:55pixelmanso I cannot say "request" there because it doesn't exist yet
04:56pixelmanI tried the paste bot but got proxy error
04:57pixelmanhere's a simple oneliner of the macro I am trying to do: (defmacro FOO_GET [path action] `(GET ~path (~@action params request)))
04:57pixelmanparams and request only exist when GET is expanded?
05:00Chousukeah, so they are variables that GET introduces?
05:01pixelmanyep
05:01Chousukethen you need to override the namespace expansion with ~'params and ~'request
05:01konrIs anybody using swing here? I've created a very simple 10-line hello-world program, yet one component (the label) doesn't show up. Any idea why that could be so? http://pastebin.com/m7a50dcc4
05:03LauJensen2konr: It shows here
05:04konrLauJensen2: hmmm... interesting... Are you using OpenJDK? Should I avoid it?
05:05pixelmanChousuke: thank you! worked perfectly!
05:05arbschtkonr: works for me, openjdk 6
05:06LauJensen2konr: Take the same precautions towards OpenJDK as you would the plaguage
05:06LauJensen2plague
05:07LauJensen2I had an image processing problem once, that was killing me, I just couldn't work out where the image was getting a bad color profile, nuked openJDK, problem solved :)
05:21eevar2^^ openjdk is great
05:21eevar2just avoid gcj
05:22eevar2and you'll be fine
05:22eevar2(which has nothing to do with openjdk)
05:24konrhaha, it's also not showing up using SunJDK
05:24konrI'm going to blame Xmonad
05:26arbschtkonr: what do you see?
05:29konrarbscht: just an empty canvas
05:30j3ffhey
05:31j3ffanyone here
05:31arbschtkonr: so there is a visible frame of the correct size, but no label?
05:32konrarbscht: yes
05:33konrhaha: The Java gui toolkit has a hardcoded list of so-called "non-reparenting" window managers. xmonad is not on this list (nor are many of the newer window managers). Attempts to run Java applications may result in `grey blobs' where windows should be, as the Java gui code gets confused.
05:34j3ffhey so i have this vector full of sorted strings, but i want to make the vector hold vectors of each group of identical strings, anyone know how i'd go about doing that?
05:38j3ffkind of like: ["alpha" "alpha" "alpha" "beta" "beta"] and i want [["alpha" "alpha" "alpha"]["beta" "beta"]]
05:39j3ffanyone? :(
05:39LauJensenrepeat?
05:41jdzj3ff: write a function that does what you want?
05:42j3ffyeah im trying to write the function but havent come up with much
05:45arbscht,(doc group-by)
05:45clojurebot"([f coll]); Returns a sorted map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll."
05:45arbscht,(doc partition-by)
05:45clojurebot"([f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of lazy seqs."
05:45arbscht,(group-by identity ["alpha" "alpha" "alpha" "beta" "beta"])
05:45clojurebot{"alpha" ["alpha" "alpha" "alpha"], "beta" ["beta" "beta"]}
05:46arbscht,(partition-by identity ["alpha" "alpha" "alpha" "beta" "beta"])
05:46clojurebot(("alpha" "alpha" "alpha") ("beta" "beta"))
05:46arbschtthey're in clojure.contrib.seq-utils
05:46j3ffwow thanks!
05:46j3ffthose weren't in the clojure book lol
05:50j3ffarbscht you rock!!
06:21LauJensenIts true arbscht, you do :)
06:35pixelman,(reduce #(str %1 %2) (re-seq #"[0-9]+" "320423-234-234-2341234"))
06:35clojurebot"3204232342342341234"
06:36pixelmancan I evaluate that lazy sequence without using the big gun reduce?
06:37arbscht,(apply str (re-seq #"[0-9]+" "320423-234-234-2341234"))
06:37clojurebot"3204232342342341234"
06:38pixelmanthanks!
06:53LauJensenLets say I have s = [23 24 25 26 26 27 28] and I want to pull out the first 26, because it's value is repeated. Do we have an idiomatic thing for that?
06:58arbschthm
06:58arbschtwhat do you want returned?
06:59LauJensen26
07:03arbscht,(filter (complement nil?) (map second (partition-by identity [23 24 25 26 26 27 28])))
07:03clojurebot(26)
07:03arbscht,(find-first (complement nil?) (map second (partition-by identity [23 24 25 26 26 27 28])))
07:03clojurebot26
07:05LauJensenah nice
07:05LauJensenthanks
07:22LauJensen,(reduce #(cond (integer? %1) %1 (= 1 (%1 %2)) %2 :else (assoc %1 %2 1)) {} [23 24 25 25 26 27])
07:22clojurebot25
07:23LauJensenThat would be very nice, except that can never be lazy ?
07:23LauJensenarbscht: ?
07:46arbschtLauJensen: that is also verging on unreadability ;)
07:49arbscht,(ffirst (drop-while (comp nil? second) (partition-by identity [23 24 25 26 26 27 28])))
07:49clojurebot26
07:49FossiChouser, anybody: got a more elaborate error-kit example? the link in the twitter message (http://tinyurl.com/nhvd5l) seems to be broken
07:50Fossialso: would you recommend using them over java exceptions?
07:52Fossiah, the link is not broken, just didn't find the pdf
08:11pixelmanis there something like map but that just return nil?
08:13hoeck1pixelman: (dorun (map ...)) or doseq
08:14pixelmanhoeck1: thanx!
09:15andysp_morning Greg
09:16LauJensenarbscht: The thing is, I don't like partition-by :)
09:19arbschtLauJensen: why?
09:19Chouserthere is some room for improvement: http://is.gd/3HpUs
09:20LauJensenIts not in my core arbscht
09:21arbschtChouser: ugh, those plots are inscrutable to the (partially) colourblind. how does clojure fare?
09:21Chouserarbscht: no visible line
09:21arbschtah
09:22Chousertop line is php, then python, then ruby. Near zero are groovy then scala.
09:24ambientthree things trouble me in py though: performance, packaging and binary incompatibilities
09:24rsynnottalso python, but to a much lesser extent :)
09:26jdzChouser: add Java to the list :)
09:27LauJensenambient: I wrote a Python vs Clojure post actually, but concluded that Python viewed in the light of Clojure was just plain cruel, so I let it go :)
09:27ambientpython is easier than clojure, but that's about it
09:27ambientbut in the long run clojure seems easier
09:28ambientpython has better development environmant
09:28LauJensennot true
09:28ambientwider choice and easier installation to windows
09:28LauJensenalso not true
09:28ambienthmm, well apparently you know something i dont
09:29LauJensentrue
09:29LauJensen;)
09:30ambientpypy guys seem to have done a jit that accelerates python by a factor of 5
09:31arbschtthis is somewhat interesting http://ur1.ca/cjoy
09:31ambientpython is also self contained, clojure depends on java and jvm
09:31arbscht(pardon the randomly-generated pun in the url)
09:33LauJensenambient: I think you're looking for #python :)
09:34ambientLauJensen nah, we were discussing about the merits of Python vs. Clojure so it's on topic afaict
09:40raekso, vars can have thread local bindings, right?
09:40raekcan agents have their own local bindings too?
09:41rsynnottambient: _one implementation_ of python is self-contained :)
09:41Chouserraek: vars: yes. agents: no.
09:43raekis there any simple way to isolate access to mutable java objects, so that only an agent can use them?
09:44raekI was thinking about swing objects, which i've heard are not thread safe
09:45Chouserraek: swing wants nearly everything to be done in its own thread. It provides methods to send tasks to that thread.
09:49raekChouser: thanks, I'll look into that way of doing it
09:51LauJensenDo we have a trick to round a double to 10 decimals ?
09:54duck1123LauJensen: Would format work for you?
09:54LauJensenduck1123: Yes, if you explain how I define the precious :)
09:54LauJensenhehe, golllum again... the precision!
09:59rhickeyClojure is the featured project this week on Assembla: http://www.assembla.com/community
10:00LauJensennice rhickey, this place is going to start growing
10:00stuarthallowayawesome
10:01stuarthallowayis it ok if I apply Howard's patch to contrib? (Not sure about the process, but I know it is blocking him)
10:01stuarthallowayhttps://www.assembla.com/spaces/clojure-contrib/tickets/22-clojure-contrib-str-utils2-is-not-AOT-compiled
10:02rhickeystuarthalloway: oh please yes, especially if you understand what it does :) I had some round trips with him just to get it in order but really can't evaluate it
10:02stuarthallowayI don't understand yet, but he reached out to me so I will run it down tonight
10:02rhickeystuarthalloway: thanks
10:07LauJensenJVM Summit talks up yet ?
10:08eevar2^^ no offense to indians, just ot php and/or mysql users ;)
10:09eevar2hehe. poor fellow :)
10:10LauJensencome now friends - isn't there an easy way to round a double to 10 digits?
10:10LauJensensomebody got one of those old obscure unreadable tricks from the good ol' C days? :)
10:11duck1123LauJensen: I found http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html but I'm not sure if it'll do what you want
10:11stuarthallowayare you opposed to using BigDecimal's round?
10:11tmountainLauJensen: in C, wouldn't you just sprintf?
10:11LauJensenstuarthalloway: no
10:11stuarthallowayyou'll have to create a MathContext (Java cruft)
10:12tmountainLauJensen: can you use java.text.DecimalFormat ?
10:12LauJensenI'm looking at the options now
10:12LauJensenThanks guys - I might complain again in 5 minutes :)
10:12tmountainit uses half-even rounding
10:13stuarthallowayuse the string constructor for MathContext -- more literate
10:13Chouser,(with-precision 10 (* 1 (BigDecimal. (double 30/7))))
10:13clojurebot4.285714286M
10:15duck1123why do you have to multiply it by 1?
10:16ChouserI think the precision setting only applies to an operation on a BigDecimal
10:18LauJensenChouser, this might be my danish-english tripping me up again, but does this look as one would expect
10:19LauJensen(let [herons (map heron (range 10000 100000))]
10:19LauJensen (with-precision 10 (BigDecimal. (double (/ (apply + herons) (count herons))))))
10:19LauJensen3.13846666666666695988396895700134336948394775390625M
10:19LauJensenbecause I was hoping for this: 3.2102888889
10:19clojurebotfor is not a loop
10:19LauJensenclojurebot: forget for
10:19clojurebotI forgot for
10:21duck1123LauJensen: you're not doing anything with the decimal
10:22Chouser,(let [herons (map #(/ % 7) (range 10))] (with-precision 10 (/ (BigDecimal. (double (apply + herons))) (count herons))))
10:22clojurebot0.6428571429M
10:22LauJensenah ok, I got it
10:22LauJensenthanks
10:39LauJensenThanks Chouser
11:18Chouserpoking around the #clojure logs, found this...
11:18Chouserrhickey takes Chouser to school: http://tinyurl.com/y8v9ean
11:26ambientthat definition of zip is interesting :)
11:47cemerickChouser: a great blog would be a series of those logs. You could call it "Rich Hickey p0wned me in #clojure" or something.
11:47Chouserheh
11:48Chouserit hasn't happened *that* often...
11:48cemerickChouser: right, no, it would feature various people being p0wned :-D
11:48cemerickI'd be a featured guest at least weekly.
12:20drewrI love albino's entry at the end of that
12:24arohneris there a preferred way to implement java classes. i.e. if proxy works for me, should I use it?
12:24Chousukeyes? :)
12:25Chousukeas far as I can tell, you should only use gen-class when you *need* to
12:26arohnerChousuke: that's kind of what I was assuming, thanks
12:27Chouserproxy is so much more pleasant.
12:40Chousercgrand: Did you see my comment on ticket #173?
12:43cgrandChouser: yes, but I thought you were asking Rich for approval
12:45Chouserah. Well, he already approved it, so he must not care too much.
12:45ChouserIf you don't think its worth changing, I can just commit it as-is.
12:46cgrandI can resubmit a patch but which names would you pick for the args?
12:46rhickeyChouser: I am not with you on complete avoidance of core names as locals in fns
12:47Chouserreally?
12:47rhickeyreally
12:47rhickeyespecially short ones
12:48Chousershort names or short fns?
12:48rhickeyshort fns
12:48rhickey:)
12:49Chouseryou've never had to rename a local because you realized you now needed to call 'map' on your 'map'?
12:49Chouseror perhaps that's just an acceptible cost.
12:50rhickeyChouser: I have, but most often for 'name', but that's still not a reason for making up awkward replacements. I think as long as the resulting code is clear it is fine
12:51Chouserok. *shrug* It's your core.clj. :-)
12:52rhickeyCL programmers frequently trot out a straw man function using list (local) and list (function)as why Lisp-2 is superior vs the confusion in an equivalent Scheme function, which has to use lst
12:52opqdonutindeed
12:52MakoryuPssssh, just call it xs
12:53Chouserhuh. I would think having the name list mean two different things in the same block would actually be an argument *against* lisp-2
12:53rhickeybut in practice it is not as much of a problem. Certainly 'map' can be dangerous, OTOH, if the arg is just passed along why not call it map?
12:53cemerickI've actually only had a naming collision once in 1.5 years *shrug*
12:53rhickeyChouser: the argument is based upon wanting to use the name that makes the most sense, and being precluded from doing that by Lisp-1 and having to make up bad-looking replacements
12:54Makoryurhickey: The real Lisp-1 vs. Lisp-2 argument concerns macros... But you've got that covered
12:54Chousercemerick: is that unrelated to me yelling at you all the time to stop using core names? ;-)
12:55cemerickChouser: oh, see, I thought we had moved on from that :-D
12:55rhickeyMakoryu: yes, there are real arguments, I'm talking about a less valid one, but if we rename every local every time there's a new core fn then we are making that argument true
12:55ChousukeI'm still not sure how having two namespaces affects writing macros. :/
12:56rhickeycemerick: right, I think it is a non-problem in general, given short functions
12:57Chousukehmm... I suppose it might be a problem if a macro introduces a name that shadows a function.
12:57MakoryuChousuke: Exactly
12:57MakoryuChousuke: Or more specifically, if a macro is expanded in a scope where a function used by the macro is shadowed
12:57rhickeyand something a little syntax highlighting could help you detect before running your program, i.e. if locals has a particular color, seeing that as a call could tip you off
12:57rhickeyor vice-versa
12:58rhickeye.g. map calls are usually purple but this on isn't
12:58rhickeythis one
12:58Makoryurhickey: Yeah, before the advent of free syntax highlighting, programmers had to rely on other visual cues
12:58MakoryuFor Lisp, that was the head position in a form
12:59rhickeyMakoryu: and #' when using a function as a value
12:59rhickeywhich I would all find quite icky in Clojure
13:00Chouseryes indeed
13:01manic12i'm trying to think of an external representation for physical units to be attached to numbers which works well will clojure and/or lisp
13:04manic12compactness is a problem
13:05Makoryu,[32'in]
13:05clojurebot[32 in]
13:05Makoryu,[600'mm]
13:05clojurebot[600 mm]
13:07manic12[600 mm^2] isn't going to work
13:09manic12compound units are a problem
13:10Makoryu,'mm^2
13:10clojurebotmm
13:10MakoryuHmm
13:11opqdonuthow about [600 [* mm mm]]?
13:11opqdonutor even [600 (sq 'mm)]
13:11manic12too bulky
13:12manic12non-standard
13:12opqdonutof course one could define aliases 'mm2 etc
13:14manic12[20 '(kg m / s2)] which is obviously 20 N, but not all compound units become derived units
13:15manic12still a bit bulky
13:17arbschtwhat's wrong with [20 "mm^2"]?
13:17Makoryu, '(foo . nil)
13:17clojurebot(foo . nil)
13:17hiredman{:value 20 :unit "mm^2"}
13:21manic12have < > been taken for the reader?
13:21albinodrewr: what do you like about it? Shows my naivety?
13:21hiredman,'<a>
13:21clojurebot<a>
13:22manic12maybe I could hijack >< for units
13:23manic12<20 ft/s2>
13:23drewralbino: the way it follows Chouser and rhickey's conversation it makes it look like you were accusing Chouser of being a newb from proggit :-)
13:23albinodrewr: :) good timing then
13:23drewrwell played
13:26arbschtmanic12: the reader is not user extensible
13:28manic12it is if there is source code available :)
13:48ambienti wish it was a bit easier to install and use penumbra :/
14:07LauJensenambient: how could it be any easier to install ?
14:07LauJensencopy 4 files, export a new LD-LIBRARY, thats it..
14:09ambientif you're using unix or something, yes
14:09manic12what's penumbra?
14:09manic12google says it's part of a shadow
14:09ambienthttp://github.com/ztellman/penumbra
14:10manic12interesting
14:10manic12i just used jogl and called the java directly
14:13LauJensenambient: For Unix and OSX it should be fairly simple, given that nothing is simple on Windows, I don't feel that we have to discuss that
14:13LauJensenBut even so, is there more to it? He supplies native windows libs
14:14manic12it was easy to use jogl on windows with clojure
14:14ambientLauJensen I don't know, I'm trying to figure it out
14:14ambientatm figuring out how to use netbeans & penumbra
14:15LauJensenk
14:15manic12netbeans is evil
14:15ambientif somebody has info on how to do this then im all ears
14:15ambienti dont know enough emacs to easily add new stuff into java classpath
14:15LauJensenWhen I got his opengl version of ikeda, I got is running quite quickly, just following his wiki, which is basically the same as for Sofiaba
14:15technomancyambient: you can't add new stuff at runtime
14:15manic12i fought with netbeans for days and finally switched back to slime and things just started working
14:16technomancyambient: but if you use swank-clojure you should get all the jars in lib/ added to the classpath for you
14:16ambienttechnomancy but restarting slime will read the new classpath, right?
14:16technomancyambient: yes
14:16technomancyyou should check out the M-x swank-clojure-project command I added recently
14:16ambientoh sweet
14:16manic12unless for some reason your fingers cannot do emacs keys i recommend emacs
14:18ambientemacs on windows is just pretty buggy
14:18manic12not really
14:19ambientfor example, i have to apply color-scheme twice until it looks ok
14:25manic12I have had a problem with emacs that if i run a lisp in it for more than three or four weeks straight it starts acting funny, probably because of the huge buffer
14:25manic12(on windows)
14:25ChousukeI usually don't get that long emacs uptimes :P
14:26manic12i'm sure now that i said that my machine will blue screen
14:26Chousukeheh
14:27ChousukeI haven't had my computer crash in months, but I reboot it occasionally to install updates.
14:27manic12usually i only have a problem with my computer if the power goes out unexpectedly and i don't run a chkdsk after restarting
14:27Chousukeright now going at 17 days it seems.
14:28manic12what os? linux?
14:28ChousukeOS X
14:28manic12my next computer is going to be an apple
14:29technomancythey're very reliable
14:30cemerickup 27 days on an MBP here, though that's not super-impressive.
14:30rsynnottWindows has reasonably long uptimes these days, no?
14:30manic12i have a freebsd server that only gets rebooted when the power goes out
14:30manic12lasts months
14:30Chousukeheh
14:31ChousukeI had that too.
14:31ChousukeI got 200 days of uptime and then I decided to upgrade it :P
14:31cemerickrsynnott: that's true on windows servers, but seemingly minor patches cause Vista to want to reboot for me
14:31Chousukeright now the machine is running Debian though.
14:32manic12now if clojure (i mean java) could only dynamically link classes
14:32Chousukeit's a bit slow, and using ports with it is a pain...
14:32rsynnottthe XP machine I use at work tends to not need to be rebooted too often
14:32manic12vista is not as bad as people try to make it seem
14:33technomancythat's the most positive thing I've ever heard anyone say about it. =)
14:33manic12i think it's ok though i will probably change to windows 7
14:34manic12so when is the jvm going to be able to dynamically link/relink classes?
14:34manic12(java classes)
14:35rsynnottwould that even be practical?
14:35manic12yes
14:36manic12i'm a cad hacker and oo is a very good paradigm for that
14:37manic12plus i noticed my directories fill up with new versions of clojure-generated classes each time i compile
14:44hiredmanstop compiling?
14:51manic12that's not practical if you need to use gen-class, eventually you might have to change a method signature
14:53Makoryumanic12: The JVM can dynamically load classes already, but IIRC it's not pretty
14:53manic12in CL that signals an error, but at least you can continue
14:53MakoryuAnd there might be some really strange caveats about memory usage
14:53manic12can it reload classes?
14:57hiredmanmanic12: that's why you make all your methods take a Map
14:57hiredman:P
14:57hiredmanthe signature never changes
14:58manic12if they are already predifined java interfaces that's not possible, unless you're talking about [& args] for everything
15:02hiredmanmanic12: well, you mentioned having to change the method signature, if you are using a predefined interface then what method signatures need to change?
15:03manic12because it took my a while to figure out what the signature looked like in clojure
15:04Makoryu, (length (range 0xffffffffffffffffffffffff))
15:04clojurebotjava.lang.Exception: Unable to resolve symbol: length in this context
15:06Makoryu, (.length (range 0xffffffffffffffffffffffff))
15:06clojurebotjava.lang.IllegalArgumentException: No matching field found: length for class clojure.lang.LazySeq
15:12hiredman,(doc count)
15:12clojurebot"([coll]); Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps"
15:12hiredmanclojurebot: length?
15:12clojurebotcount
15:12hiredmanclojurebot: botsnack
15:12clojurebotthanks; that was delicious. (nom nom nom)
15:14cemerickrhickey: I have clojure lib A that's been AOT-compiled, and clojure lib B depending on A. A generates a clojure.proxy.java.lang.Object$Foo as expected. B does not refer to Foo directly at all, but it is generating a clojure.proxy.java.lang.Object$Foo classfile as well, presumably because it is referring to the ns in A that proxies Foo. Is this expected?
15:15Chouserlib A and lib B have different root dirs?
15:15cemerick(the issue is that things break in odd ways when both A and B's resulting jar files are on an application classpath, as the proxy classfiles aren't the same)
15:15cemerickChouser: um, yes. They're different projects.
15:16ChouserI wonder why are the generated classfiles different. They ought to be identical.
15:17cemerickChouser: yes, that's got us pretty confused too. diff reports them to be different, though their signatures via javap are identical AFAICT
15:18ChouserI'm sure you know that the classname of proxy-generated classes has changed recently.
15:18cemerickChouser: I wasn't, but I'm still (very unfortunately) at v1 + selective patches.
15:18pixelmanis there something like gotapi.com but for clojure?
15:19Chouseroh!
15:19Chousercemerick: sorry, I should have read your question more closely.
15:19hiredmanhttp://clojure.org/api
15:21benreesmanany experienced clojure developers have a moment to help me out?
15:21pixelmanhiredman: I've used that but it's hard to navigate and search because it's just all functions on one page, though I like that there's a page about sequences and stuff.
15:22pixelmanbasically I'm looking for a way to easily browse all string functions etc.
15:24hiredman~jdoc String
15:25hiredmanI guess subs is a string function
15:26hiredmanthere is a strutils in contrib which wraps string stuff
15:26hiredmanclojurebot: contrib?
15:26clojurebotcontrib is http://github.com/richhickey/clojure-contrib/tree/master
15:27hiredmanhttp://richhickey.github.com/clojure-contrib/
15:28pixelmanmaybe I should try clj-doc
15:30stuartsierraexcept for subs and the regex stuff, core Clojure has no string functions
15:31pixelmanthe regex stuff is mostly matching right? no transformation stuff?
15:32hiredmanjava's .replaceAll method on Strings takes a regex, just as a string
15:32stuartsierracorrect
15:33stuartsierrac.c.str-utils2 does transformations with regexes
15:35pixelmanok
15:36milepHello, I have a noob question: is there some simple way to sort list of vectors by the vectors first item(integer)?
15:37Chouservectors are comparable, so just sort them.
15:38Chouser,(sort '[[3 a] [2 b] [4 c] [1 d]])
15:38clojurebot([1 d] [2 b] [3 a] [4 c])
15:38milepah, thanks
15:41hiredmanthere is also sort-by
15:41pixelmanwhy does the environment complain if I try to start swank in a .war file? no *3 or something like that
15:42hiredman*3 is bound to the third last result in the repl usually
15:42hiredmandunno what swank's deal is
15:46pixelmanYep, I gave up. I like deploying a war file to tomcat -- I do that now, but I might change to deploying just the sources and doing some hackety hack with nohup or something, it would be pretty nice to speed up deployment.
15:47ordnungswidrighi
15:47ordnungswidrigis there a shorthand for (or (nil? x) x (f x))
15:48ordnungswidrighmm, sorry, I meant (if (nil? x) x (f x))
15:48hiredmanthere is -?> in contrib somewhere
15:48hiredman,(doc -?>)
15:48clojurebot"([x form] [x form & forms]); Same as clojure.core/-> but returns nil as soon as the threaded value is nil itself (thus short-circuiting any pending computation). Examples : (-?> \"foo\" .toUpperCase (.substring 1)) returns \"OO\" (-?> nil .toUpperCase (.substring 1)) returns nil "
15:48pixelman(when-not x ?
15:49hiredman,(-?> nil .toUpper)
15:49clojurebotnil
15:49hiredman,(-?> "foo" .toUpper)
15:49clojurebotjava.lang.IllegalArgumentException: No matching field found: toUpper for class java.lang.String
15:49hiredman,(-?> "foo" .toUpperCase)
15:49clojurebot"FOO"
15:51benreesmananybody succeeded in implementing org.apache.catalina.CometProcessor in clojure?
15:52arohneranyone have a link to the snippet of code to call apply on java methods?
15:53Chouserarohner: http://paste.lisp.org/display/67182 -- jcall and jfn
15:53arohnerChouser: thanks
15:53arohnerthat should be built-in, IMO
15:55Chouserarohner: http://clojure-log.n01se.net/date/2009-09-22.html#08:58
15:55stuartsierraIt is:
15:55stuartsierra,(doc memfn)
15:55clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn."
15:56dthomasYeah, jfn looks like memfn.
15:56arohnerstuartsierra: thanks
15:56stuartsierranp
15:57arohnerBTW, I'm pretty sure I'm using this correctly, this time :-)
15:58arohnerthe java fn I'm calling takes a java.lang.Object...values
15:59arohnerbased on the number of columns in the 2d dataset
16:00arohnergrr, but memfn is a macro, and I need to apply
16:02lisppaste8spuz pasted "PE4" at http://paste.lisp.org/display/87854
16:03Chousukeyou indent too much :)
16:03Chouserarohner: right. in order to use memfn, you have to know the number of args.
16:03Chouser,(apply (memfn compareTo x) [16 8])
16:03spuzChousuke: oh yeah that would be eclipse converting to tabs
16:03clojurebot1
16:04spuzI posted that code because I was wondering why the solution to this project euler problem was about 10x slower than the java solution
16:04Chousermemfn is an older way to do some #() things, not a sufficient replacement for jcall
16:04Chouser,(apply #(.compareTo %1 %2) [16 8])
16:04clojurebot1
16:05spuzAdding a type hint to my palindrome function helps a lot, but I'm not sure how to find out where the rest of the time is being spent. Anyone have any ideas?
16:06Chousukethat code can't even work. you can't have and contain recur :/
16:06Chousukeand if you're using plain recursion, that would explain it.
16:07spuzChousuke: well it does work, I'm pretty sure the recur is working. It's guaranteed not to use the stack. If it couldn't loop, it wouldn't compile.
16:08Chousukewait, hm
16:08Chousukenever mind, I lied ;P
16:09ChousukeI thought of 'and as if it were a regular function. :/
16:09spuzah right
16:09spuzActually, thinking about it, in my java solution, I'm not creating substrings, that is probably the cause of the difference
16:10Chousukehmm
16:10Chousuke,(== \a \a)
16:10clojurebotfalse
16:10Chousukeright, no == for characters :/
16:10Chousuke(it's a faster way to compare numbers)
16:11hiredman,(== (int \a) (int \a))
16:11clojurebottrue
16:11Chousukethat's cheating :)
16:13spuzhehe
16:14spuzEven replacing the recur with a direct recursive call does not add that much extra time. With recur it is about 380ms, with a recursive call to palindrome? it is about 420ms. A recursive implementation in java however is about 38ms.
16:19spuzactually with multiple timings, recur and the direct call are both around 400ms
16:23somniumany idea what would cause "no matching method found intern"?
16:23serp_hello. I get errors when building clojure-contrib such as "Could not locate clojure/stacktrace__init.class or clojure/stacktrace.clj on classpath". what can I do to fix this?
16:24Chouserserp_: is it possible you're using mismatched versions of clojure and contrib?
16:24hiredmansomnium: no matching method usually means there is no method defined for some dispatch value, and the last thing in the message is usually the offending value
16:24serp_both are the latest
16:25somniumis intern used by some clojure datastructures internally?
16:25hiredmannot that I am aware of
16:25somniumIve run into it a few times now at the beginning of macros
16:25hiredmanlisppaste8: url
16:25lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
16:25hiredmansomnium: that is not a datastructure thing
16:25hiredmanthere is a function named in intern
16:25Chouserserp_: have you built older versions of contrib in that same directory? you might try "ant clean"
16:26serp_no luck... I just downloaded clojure and clojure-contrib for the first time yesterday
16:26hiredmanserp_: from were?
16:27serp_http://clojure.googlecode.com/svn/trunk and git://github.com/richhickey/clojure-contrib.git
16:28Chousergooglecode strikes again. :-(
16:28hiredman
16:28hiredman~github
16:28Chouserserp_: latest clojure is on github too
16:28clojurebothttp://github.com/richhickey/clojure/tree/master
16:28LauJensenSeriously, why don't somebody shut down that outdated svn repo ?
16:28ChouserLauJensen: BDFL said no
16:28LauJensenrhickey: Explain yourself
16:29serp_oh... let me try with clojure from github :)
16:30technomancyI thought he was going to check in a readme with a deprecation notice
16:32arohnerif I have a java method with the signature "addColumns(java.util.Collection<ColumnDescription> columnsToAdd)", can I call that directly with a clojure vector?
16:34hiredman(.addColumns someobject somevector)
16:34lisppaste8somnium pasted "untitled" at http://paste.lisp.org/display/87857
16:34Chouser,(instance? java.util.Collection [1 2 3])
16:34clojurebottrue
16:34hiredman,(filter (partial = java.util.Collection) (ancestors (class [])))
16:34clojurebot(java.util.Collection)
16:35arohnerI knew vectors implemented j.u.Collection, wasn't sure how that interacted with Generics
16:35hiredmangenerics do not exist at runtime
16:37somniumdamn pasted a typo
16:38arohnerah, so they're just sugar like variadic methods?
16:39lisppaste8somnium annotated #87857 "untitled" at http://paste.lisp.org/display/87857#1
16:39stuartsierranot entirely; they're used by the Java compielr to do automatic casting
16:39stuartsierrabut they're not part of the actual type signature of methods/objects
16:40stuartsierrakinda like Clojure type hints, actually
16:41arohnerstuartsierra: cool, thanks
16:46raekmy first useful piece of clojure: http://paste.lisp.org/display/87859
16:46raek(def r (ref {:a 1 :b 2}))
16:47raek(watcher-frame/watch r)
16:47raekand a window pops up, showing the value of the ref
16:47raekthat changes when the ref changes
16:47funkenblatt,(doc ns)
16:47clojurebot"([name & references]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class ...), when supplied, defaults to :name correspo
16:48raekwhich way is the preferred way to use include and use?
16:48Chouserraek: cool! I think add-watch may be even easier to use in this case than add-watcher.
16:49hiredmanthere is no include
16:50raeki'm really a clojure n00b
16:50raekso I don't know how to make libraries properly
16:50arohnerraek: you'll want an ns declaration at the top of your file
16:50Chouserraek: destructuring, agent, watcher -- you're not doing too bad.
16:50raekChouser: yes, you're right.
16:51arohnerraek: then use :include, :use, :require in the ns declaration
16:51hiredmanarohner: there is no :include
16:52raekam I doing the :include/:use/:require thingy wrong? and how should I do it?
16:52funkenblattlol
16:52arohnersorry, import
16:52Chouserraek: the ns form you've got in that paste is fine except for the namespace name
16:52hiredmanthere is no :include!
16:52raekwhat should I write?
16:53Chouserraek: you must have at least two levels, but it's recommended to use the java package naming style
16:53Chouserthat is, something like com.your-site.watcher-frame
16:54raekah
16:54Chouserthen put your code in a file named something like src/com/yout_site/watcher_frame.clj
16:55Chouserthen people can put your src dir in their classpath and do: (use 'com.your-site.watcher-frame) and they're good to go.
16:55raekah, I see
16:55somniumI found out what no method found intern means... calling keyword on something that can't be made into a keyword...
16:56lisppaste8mtm annotated #87854 "numeric version of palindrome?" at http://paste.lisp.org/display/87854#1
17:32technomancyanyone else think the "fixtures" feature of clojure.test is oddly named
17:35ChouserI assumed it was some kind of normal testing culture terminology.
17:35technomancyit is, but it means something else. =)
17:41cemericktechnomancy: the usage in clojure.test is non-idomatic?
17:41cemerickI thought it was just about right, insofar as we're generally working with immutable objects.
17:41technomancycemerick: possibly it's used that way in other circles
17:41technomancybut I've never seen that usage myself.
17:42cemerickI guess I don't really know the formal definition, but I wasn't suprised by the term's usage. *shrug*
17:42spuzmtm: thanks for adding that contribution. I was thinking whether it might be the string conversion that takes time in the palindrome? function. Either way, I'd like to know what clojure is doing under the hood and why there is this discrepancy with java
17:43technomancycemerick: where have you heard it before?
17:43technomancyI'd call it setup/teardown, but I guess I don't know of a single term that encompasses both those words.
17:43cemerickassociated with junit and such. Generally meaning "anything you want to put together in setup()"
17:44cemerickright -- how's that different from clojure.test fixtures?
17:44technomancywell I'd say you construct/initialize your fixtures in your setup.
17:45technomancythey aren't executable themselves... though maybe this is just one of those "code is data" moments...
17:46technomancyit's a nitpick; I was just wondering if I was missing something
17:46cemerickoh, well, yeah, you need to provide replacement for the setup method in xunit frameworks, etc.
17:47cemerickyou could just set up whatever data you want as a top-level in the namespace, which is a whole lot simpler.
17:47cemerickBut that's not appropriate for some usages.
17:50lisppaste8spuz annotated #87854 "2x faster function" at http://paste.lisp.org/display/87854#2
17:51spuzAnyone know why the 'for + :when' is about 2x faster than 'filter' in the above pasted code?
17:56Chouserspuz: you're sure you're letting the JVM warm up enough, averaging multiple runs, etc?
17:56spuzChouser: yeah, I'm running multiple timed runs
17:56spuzusing dotimes and time
18:05Chousukespuz: well, using filter you have one extra layer of laziness and an extra function call. maybe it makes the JVM optimisations less effective
18:18raekwhen naming namespaces/packages in clojure/java the first two levels should be one's domain, right?
18:19raekso, having the domain "raek.se", my namespace should begin with se.raek?
18:19raekI've only seen examples woth .com and .org...
18:20arohnerraek: the only real requirement is that it be unique. java says to use domains if you have them, because those are already guaranteed to be unique
18:23raekarohner: ok, that makes sense
18:24technomancyraek: no need to use a domain name
18:24technomancythat's for Java programmers that get paid by the directory
18:24raekhehe
18:24technomancyraek: hopefully you've already searched to make sure your project name is unique; if it is, then you will never have a problem just using your project's name as the namespace.
18:37arohnerare there any projects yet to generate or template javascript from clojure?
18:38hiredmanthere was(is?) clojurescript of course
18:39arohnerI'd like to avoid a 500k? client download. All I need to do is generate javascript function call literals
18:39arohnerjust a few steps above a JSON encoder
18:40arohneroh, and clojurescript.n01se.net crashed my firefox
18:42hiredmanI can't imagine it would be that hard to do a very simplistic clojure fn => javascript function compiler
18:43arohneryeah. I might work on that
18:43rboydI want an as3 compiler
18:43cemerickis there any reason to think the clojure compiler is non-deterministic the classfiles it generates?
18:43cemericke.g. given the same source, it should produce exactly the same output, right?
18:44hiredmancemerick: do you proxy the same bases in file B as you do in file A at anytime?
18:45cemerickhiredman: you're referring to my earlier question, I assume?
18:45hiredmanyes
18:45cemerickB never proxies Foo at all, it only refers to a ns in A that does
18:45cemerickyet the compiler generates a proxy classfile in B's output dir
18:45hiredmanhmmm
18:47hiredmanI have no idea
18:47cemerickheh, yeah, me neither :-)
18:47cemerickadd to the strangeness, that behaviour *appears* to be nondeterministic
18:47cemerickthus, my second question
18:49cemerickI wonder if one needs those AOT-compiled proxy classfiles anyway -- aren't such things generated at runtime as necessary, anyway?
18:50hiredmanproxy is an odd duck
18:50hiredmancemerick: well, AOT compiling would be pointless if it it just left everything to runtime
18:51hiredmanproxy generates a class for every set of bases I believe
18:51cemerickhiredman: right -- but the proxy classfiles are particularly empty -- no impl in them at all, and no backreferences to where they're used
18:51cemerickthey *should* be identical for any particular combination of bases
18:52hiredmancemerick: possible use of gensyms for name stubs of something or other?
18:52hiredmanegads, core_proxy.clj is gnarly
18:54cemerickI may just push back our delivery and upgrade to clojure HEAD to see if this funniness just goes away.
18:54dhazahi...why doesn't ns take a number of forms to add to the particular namespace
18:54dhazaas opposed to setting some read-time(?) variable with what ns the forms should be added to
18:54hiredmancemerick: at least try it out and see what happens with the proxy namechange stuff
18:55cemerickI'm assuming there's going to be breakage. If we're going to make the move, we're just going to do it top to bottom.
18:55cemerickwe wanted to be there a month ago anyway
18:55hiredmandhaza: def picks up the value of *ns* at readtime/compile time anyway
18:56dhazahiredman: http://pastebin.com/m45b1aa5a
18:56cemerickactually, we should be able to just replace our proxy usages with reify, no?
18:56dhazai think i understand how it works...im just wondering why it was chosen to be that way and not in the style of what i pasted below
18:56cemerickor is proxy sticking around in HEAD for a reason?
18:57hiredmancemerick: you can update proxy's mapping of fns at runtime
18:57cemerickah
18:58cemerickhiredman: is that proxy's only advantage at this point?
18:59hiredmancemerick: dunno, that was just off the top of my head
18:59hiredmanI don't think I've ever used that
19:01Chouserreify's not in master
19:01cemerickheh, I would have discovered that eventually :-/
19:01hiredmandhaza: since namespaces roughly map to a file, nesting everything in another pair of parens doesn't make much sense
19:02dhazahiredman, thats kind of what i assumed. i just wanted to make sure there wasn't some obvious reason i was missing out on
19:02dhazathanks for the info
19:03hiredmanI mean, I don't know, but that seems logical
19:41technomancyis use-fixtures idempotent?
19:42technomancyah, looks like yes
20:12arohnerwow, I need to read the clojure compiler source more often. Didn't realize that local variables are a var to a clojure map
20:30timothypratleyIf I want to check (instance? XXX (make-array Boolean/TYPE 2)), what is XXX?
20:32hiredman,(class (make-array Boolean/TYPE 2))
20:32clojurebot[Z
20:32hiredman,(Class/forName "[Z")
20:32clojurebot[Z
20:32timothypratleythankyou!
20:32rhickey_,(instance? (Class/forName "[Z") (make-array Boolean/TYPE 2))
20:32clojurebottrue
20:32timothypratley:)
20:36konrHow can I connect to my (already running) nailgun server, evaluate a file and return the output to be used by another shell utility? What I want to do is something like `for x in $(nailgun-client ~/src/generate_links.clj); do wget $x; done` in bash
20:38hiredmanng clojure.main ~/src/generate_links.clj
20:38savanniidentify thg,ttg
20:39hiredmanwhoops
20:39savanniWow.
20:39savanniYep. Oops. Now I have to figure out how to change that.
20:40savannifirst I've done that in four years...