#clojure logs

2009-03-10

00:15replacaQ: how do I set the metadata on a symbol? That is, the equivalent of (def #^{ :foo "bar"} x 7) but where the actual metadata map is not a constant.
00:16cooldude127(doc alter-meta!)
00:16clojurebotAtomically sets the metadata for a namespace/var/ref/agent/atom to be: (apply f its-current-meta args) f must be free of side-effects; arglists ([iref f & args])
00:17replacacooldude127: beautiful! thanks!
00:17cooldude127no problem
00:43slashus2I am playing around with PircBot and looking at your code, hiredman, I can't seem to find where you use setName. changeNick isn't working for me. It is defaulting to PircBot as the nick.
00:44replacalisppaste8: url?
00:44lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
00:49lisppaste8replaca pasted "A bug in backquote processing?" at http://paste.lisp.org/display/76738
00:49replacaIs this a bug? I want to put functions inside a macro, but it won't work with backquote.
00:50slashus2(defmacro m [] `(apply (fn [a#] a#) [7]))
00:51slashus2autogensym
00:51replacaslashus2: ahh, of course
00:51replacaI was confused by the namespace stuff and forgot that I needed a gensym.
00:51replacaThanks!
00:52slashus2Your welcome
00:53slashus2Is there a way to use proxy to do a constructor. I am trying to call a protected method.
00:53slashus2... that doesn't really make sense.
00:56replacaNo, no contructors, no protected methods
00:56replacagotta use (ns (:gen-class ...)) for that with AOT
00:57slashus2I am trying to figure out how hiredman did it with his bot.
00:58slashus2When he creates a bot he just calls .changeNick , but that doesn't work in my java version, or clojure version.
00:58slashus2Have to call this.setName in java
00:58slashus2inside the constructor.
00:58replacaI haven't looked at his code
00:59replacahmmm....
01:05slashus2I fixed it by changing (.setAutoNickChange true)
01:06replacaahh, fun with bots :-)
01:39Raynes?
01:50replacathe magical lambda!
01:50replacatruly the symbol of a dark cult
02:04slashus2I am having a terrible time with name spaces. I have two namespaces, but when I try to use a function in the other namespace it says that that function is not public.
02:06cmvkkhmm. namespaces aren't my strong point, but I thought you had to do something specific to make a function private.
02:06slashus2defn- ?
02:06cmvkksomething like that
02:07slashus2I am not doing that :-(
02:07cmvkkyou're "use"ing the namespace or whatever?
02:08slashus2I have tried everything :-(
02:09cmvkkwhen i do (ns some.namespace (:use someother.namespace)) that usually does it for all the other namespace's functions
02:12slashus2When you are compiling to a jar file, does every single file that you have have to be a class?
02:13cmvkkevery function ends up being a class, i think, when you compile clojure code.
02:13slashus2I was using enclojure.
02:13slashus2This is very frustrating
02:13cmvkki've never even heard of that.
02:14slashus2netbeans enclojure
02:27slashus2cmvkk: I am using use inside of the namespace delcaration (:use [com.cljbot.cljbotcore :only (start-cljbot)])
02:27replacaand what func are you trying to call?
02:28slashus2wait.. I think it is working now.
02:28replacado you really want the :only?
02:28replacaahh, ok
02:29slashus2replaca: I am just playing with it.
02:29felzixis there a way to turn strings into numbers without using read-string?
02:29felzixI want to turn strings that could be numbers into numbers and leave them alone otherwise
02:29slashus2The multiple ways to deal with things use refer import etc. can get confusing.
02:30slashus2ugh.. It still says that the method isn't public
02:30slashus2misnamed function :-(
02:30cmvkkfelzix there are java functions that you can use maybe
02:31replacaI'm having a diferent problem with namespaces right now - I want to take a few different physical files and expose an API that's in a single namespace
02:31felzixcmvkk: oh, right. I sometimes forget about that. Thanks :)
02:31replacaIt's easy enough for funcs, but I have some vars that I want the user to be able to bind
02:32cmvkkwhy would it be any different for vars?
02:32cmvkkaren't funcs vars?
02:32replacayeah, but you don't really care about their originating namespace, so you can just copy them
02:33hiredmanreplaca: you might look at how clojure.core deals with that
02:33replacaif you copy a var and then bind it, you'll be binding the copy, not the original
02:33replacais it made up of more than one file? I haven't utsl'd in a long time
02:34hiredmanit is
02:40replacaI see, he does it by using "load" directly in core.clj and then "in-ns" in the helper files
02:41replacaIt doesn't let you pick and choose, but I think it's workable for what I need
02:42replacahiredman: thanks!
02:56replacaTests run: 271, failures: 0! Time to check in and go to bed :-)
02:57replacaclosing in on a pretty printer I can really publish!
03:02slashus2I wonder if there is a way to modify code while it is running in enclojure.
03:59hiredmanjava's two threads, clojure's threadpools, and my own threadpool, suddenly I have eleven threads churning away on this pool c2d
04:00hiredmanpoor
04:59tsdhHi.
05:01tsdhI've just subscribed to the google group and receive the messages, but somehow my own postings don't appear. How can I investigate what's going wrong?
05:02hiredmantsdh: your first posts have to get approval
05:02hiredmanto cut down on spam
05:02tsdhAh, ok. Thanks for the hint.
05:02hiredmanso, whenever rhickey wakes up and tends the queue...
05:05hiredmanactually, he may be awake in london for the thing
05:06cmvkkthere's a thing in london?
05:06hiredmana thing
05:07cmvkklike a.....computer thing
05:09hiredmanyes
07:58bstephenson,(str 1)
07:58clojurebot"1"
08:16timothypratleywhat's the best html clojure library to use (just want to output a basic html file)
08:28eevar2timothypratley, have a look at compojure if you're looking for a web framework
08:35timothypratleyeevar2: thanks, clojure.contrib.prxml seems to do all I need for now :)
08:35timothypratleyits just some throwaway code
09:38blbrown_lthello morning folks
09:53AWizzArdclojurebot: max people
09:53clojurebotmax people is 156
09:53blbrown_ltgetting there
09:53AWizzArdyup :)
09:55Chouserwhere's "there"?
09:55Chouser...just out of curiosity...
10:00AWizzArd1k :)
10:00AWizzArdno, I think 200+ is already fine
10:07Chouserhttp://tinyurl.com/d5g6nj -- trends
10:26rsynnottChouser: of course, people apparently talk about ocaml more than cl, but there are certainly fewer real-world systems of interest in ocaml than cl
10:26rsynnottso it may not mean that much
10:26rsynnottalso, some perspective: http://www.google.com/trends?q=clojure,ocaml,"common+lisp",+haskell,python&ctab=0&geo=all&date=ytd&sort=0
10:26Chouserthat's certainly not a good way to measure KLOC-in-production or anything.
10:27Chouserhaskell and python match outside the domain of programming languages quite a bit.
10:27Chousernote the headlines in the right-hand column.
10:27rsynnotthmm, yep
11:06marklarhi I'm new to both Lisp and Clojure, and am trying to learn using projecteuler.net. Would anyone mind sharing how they would solve the first problem (http://projecteuler.net/index.php?section=problems&id=1)? I'm getting the right answers but feel like I'm not doing it the 'Clojure' way
11:07Chouser~euler
11:07Chouser~projecteuler
11:07clojurebotPardon?
11:07Chouserhm
11:07cgrandhttp://clojure-euler.wikispaces.com/
11:08Chouser:-) thanks
11:08cgrandclojurebot: euler is http://clojure-euler.wikispaces.com/
11:08clojurebotYou don't have to tell me twice.
11:08marklarThanks!
11:08rsynnottapparently he does
11:08cgrand~euler
11:08clojureboteuler is http://clojure-euler.wikispaces.com/
11:26AWizzArdmarklar: And? After seeing some Clojure solutions, how clojuristical do you find your own solution now?
11:32danlarkins/clojuristical/idiomatic
12:08jayfieldshas anyone used clojure exclusively to test their java applications?
12:08jayfieldsI'm using it for some specific testing, but considering going to all clojure all day for testing.
12:09p_lanyone knows of good java disassembler? I want to do my code in clojure and then generate java source from generated bytecode :>
12:10cemerickjayfields: we've been using test-is exclusively for all new tests. We won't rewrite our "legacy" junit tests for the sake of purity, tho.
12:10AWizzArdp_l: jad
12:10cemerickp_l: jad is the only worthwhile one, I believe
12:11cemerickI'm pretty sure that diassembled clojure is pretty useless, tho.
12:12p_lcemerick: As long as it will pass "compile it back in BlueJ and still work", it's not useless
12:12cemerickmostly useless, that is...I tried it once when the AOT stuff was in its early stages, and jad's output was uncompilable.
12:12p_louch
12:12cemerickthat's pretty common for non-javac-generated bytecode
12:13AWizzArdit's good
12:13p_lthen my proffessor should prepare for few classes full of static member methods :/
12:13AWizzArdI still need to learn how to apply a code obfuscator on top of what Clojure outputs.
12:13cemerickAWizzArd: no luck with proguard from a few weeks ago?
12:14AWizzArdI did not continue with it, but I will.. soon.
12:14Chouserp_l: I think clojure produces bytecode in some cases for which there is no Java equiv.
12:14Chousergoto, for example
12:15jayfieldscemerick: not rewriting legacy makes perfect sense. any gotchas since you went to test-is exclusively?
12:16rsynnottjava doesn't have a goto?
12:17rsynnottp_l: will the lecturer not take offence to something which is obviously disassembled bytecode, anyway?
12:17cemerickjayfields: not really. One of the nicest parts of test-is is that it runs *all* tests, and doesn't stop at the first failure. At some point, I would like to be able to specify how many failures to tolerate before the testing process fails entirely, though (so if the environment is wedged, our CI box doesn't waste time counting thousands of failures).
12:18rsynnottthat may be undesirable if your test has side-effects, of course
12:18jayfieldscemerick: cool. thanks.
12:18rsynnott(test1: create user test2: delete original user or similar)
12:19p_lrsynnott: I think it might help drive my point home :>
12:19cemerickrsynnott: all of our tests are purely functional at the moment
12:19p_lwell, the task we have to do maps in my mind best to Haskell, but that was completely out due to JVM :/
12:22p_lI did come and ask him first if we can write it in any other language than Java, though
12:25cemerickChouser: did you happen to see this? http://groups.google.com/group/clojure/browse_thread/thread/c521f52e1b058bf2 I think I'm right, but I don't want to go too far astray before getting some validation.
12:31tsdhIs there something like return is clojure? I have a function with two nested loop/recurs in it, and I want to jump out oy both.
12:32danlarkintsdh: refactor :)
12:33tsdhok
12:37gnuvincetsdh: so such thing, no.
12:46jayfieldswhat's the clojure equivalent of Foo.class ? I tried (class Foo) but it didn't seem to work well
12:46gnuvince,(class 3)
12:46clojurebotjava.lang.Integer
12:49StartsWithKjayfields: JFrame.class is just JFrame in clojure
12:49jayfieldsthanks
12:49jayfieldsStartsWithK: thanks
12:49StartsWithKlisppaste8: help
12:49lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:51lisppaste8StartsWithK pasted "Declarative swing ui + cells, port of acp example" at http://paste.lisp.org/display/76752
12:52StartsWithKoriginal active context pattern is http://is.gd/mJhb here
12:54tsdhhow do i switch to a given namespace in the repl?
12:55StartsWithKno one interested? by the number of people on that cells thread i tought this would have some intereset :)
12:55cemericktsdh: (in-ns 'my.namespace)
12:55tsdhcemerick: Thanks
12:57durka42StartsWithK: is that a complete program?
12:57tsdhUsing slime, is there a way to abort a long-running funcall at the repl?
12:57StartsWithKdurka42: yes
12:58StartsWithKreplicates all of the functionalyt from original active context pattern example
12:58durka42the => and >> macros must be rather magic
12:58durka42where can i find the net.ksojat.neman jars that i assume i need to run this?
12:59StartsWithK=> is like extended version of doto, so you get :Setter, or in JFrame [] replaced with repetive add calls
12:59shoovertsdh: not last I checked, but there's a recent addition to clojure.contrib.repl-utils that may help (haven't tried it myself)
12:59StartsWithK>> is 'method' injected in Object, so i named it that it cant clash with any java names
13:00durka42injected? as in proxy?
13:00StartsWithKdurka42: http://bitbucket.org/ksojat/neman/ but give me a minute tu push this example
13:00StartsWithKno, more injected as in scope of =>
13:00StartsWithKno real method injection is done
13:01danlarkinthat would leak
13:01tsdhshoover: Thanks, I'll have a look at it. (My miller-rabin pseudo prime numbers test runs now 10 minutes for 3 (in words THREE!!). ;-)
13:03StartsWithKi uploaded this right now
13:04noidiis it possible to import all classes from a java package?
13:04noidisomething like (import '(com.trolltech.qt.gui *))
13:04StartsWithKeasy way to get it to run is to build http://bitbucket.org/ksojat/truba/ that will pull correct clojure version
13:04StartsWithKthen from neman project directory just type "ant publish-all" to build all modules and "ant repl" so it generates clojure repl script
13:05StartsWithKafter that ./clojure and you can load the example (load-file "examples/swing2.clj")
13:06durka42noidi: no
13:07noidiok, good :)
13:08noidimakes learning java, clojure and jambi at the same time a teensy bit harder for me, but i still consider the absence of import * a good thing in general :)
13:08durka42StartsWithK_: doesn't use the latest clojure version?
13:09StartsWithK_1322
13:11StartsWithK_i don't know how will ivy react if you just drop clojure.jar in lib directory :/
13:12durka42hmm, this will need ivy to build won't it
13:12durka42ant doesn't do much at all
13:13StartsWithK_ivy resolver all deps, so if you download http://bitbucket.org/ksojat/truba/ and build it, it will place clojure in your local ivy repository, and everything should work
13:14StartsWithK_resolves*
13:16durka42well i need to install ivy first
13:16StartsWithK_no
13:16StartsWithK_build will download it for you
13:17StartsWithK_just type "ant" in truba and "ant publish-all repl" in neman, that should do it
13:20durka42right, i'll try that
13:20jayfieldsis anyone using La Clojure for IntelliJ?
13:23StartsWithK_durka42: i'm sorry, didn't see that truba on bitbucket dosn't download 1322, just fixed it
13:23lisppaste8durka42 pasted "should really install ivy" at http://paste.lisp.org/display/76754
13:24StartsWithK_it must be a lod truba version on bitbucket
13:24StartsWithK_old*
13:32StartsWithK_durka42: it looks that you will also need to add to the end of CP in clojure script :neman/swing/targets/swing.jar
13:32StartsWithK_i don't know why it can't load classes from directory, but it works for jars
13:32StartsWithK_that didn't happen before i upgraded to 1322..
13:32durka42hmm
13:32durka42Unable to load a script engine manager (org.apache.bsf.BSFManager or javax.script.ScriptEngineManager)
13:33StartsWithK_no ant 1.7?
13:33StartsWithK_hmm
13:35durka42it is ant 1.7
13:37noidiis it possible to supply default values for positional arguments, like in python? (def foo(a, b=1, c=2): pass)
13:38noidior should i make versions with different arities?
13:39StartsWithK_durka42: i'm lost there, ant should have support for bsf or javax script enabled..
13:39gnuvincenoidi: different arities is usually used.
13:40noidignuvince, thanks
13:42jayfieldsis there a way to do this in Clojure
13:42jayfields new Object() {{
13:42jayfields System.out.println("hello");
13:42jayfields }};
13:42gnuvincejayfields: what's that?
13:42durka42jayfields: what does that do? ;)
13:43durka42clojurebot: can clojure do the above?
13:43clojurebotYes, Clojure can do that!
13:43gnuvinceIf it does what I think it does: #(println "hello")
13:43jayfieldsit creates a new instance of an object that prints hello as the initializer
13:43Chouserjayfields: but since it's creating it immediately, how is that different than just: System.out.println("hello");
13:44durka42hmm, you won't be able to do constructors without an AOT gen-class, right?
13:44jayfieldsbecause the actual code that I'm working on is more complicated
13:44Chouser,(#(println "hello"))
13:44clojurebothello
13:44gnuvinceUse a closure.
13:45slashus2What is the best method for live code manipulation? I know when you run code in the repl you can load methods on the fly, but it doesn't seem to be working that way in enclojure on netbeans.
13:46durka42do clojure regexes support named groups?
13:46gnuvinceDo Java's?
13:46Chouserdurka42, gnuvince: I don't think so.
13:47gnuvinceThen no.
13:48gnuvinceYeah, the javadoc doesn't seem to indivate that they do.
13:50StartsWithK_durka42: best thing i can do for now: http://ksojat.net/media/swing-example.tar.gz just pack with swing1 and swing2 examples
13:52duncanmis there a way to find out what namespaces/classes have been imported from the REPL?
13:53durka42,(all-ns)
13:53clojurebot(#<Namespace clojure.set> #<Namespace hiredman.sandbox> #<Namespace hiredman.clojurebot.seenx> #<Namespace hiredman.clojurebot.dice> #<Namespace hiredman.clojurebot.sb> #<Namespace org.danlarkin.json.decoder> #<Namespace user> #<Namespace hiredman.clojurebot.google> #<Namespace clojure.main> #<Namespace org.danlarkin.json> #<Namespace clojure.core> #<Namespace hiredman.clojurebot.translate> #<Namespace org.danlarkin.json.
13:53durka42ehm, that .tar.gz didn't really work
13:54durka42but i did get it to run by abusing add-classpath and compile :)
13:55StartsWithK_you can see swing examples? :)
13:55StartsWithK_wee
13:55StartsWithK_not much to look at :) hehe
13:57duncanmwhat's the general way to get a length of a Seq?
13:58durka42,count
13:58duncanmi'd think it'd be .length, but that's not it
13:58clojurebot#<core$count__3496 clojure.core$count__3496@83964f>
13:58durka42(count [1 2 3])
13:58duncanmahhh
13:58durka42,(count [1 2 3])
13:58clojurebot3
14:02noidiwow, clojure/java interop is amazing :O
14:03durka42man regexes are really write-only, aren't they
14:03noidii don't know either language (especially not clojure), but it's still trivial to translate java code examples into clojure :)
14:05Chousukenoidi: the translations might not be very clojurey code at first though :)
14:06noidiyeah, i'm sure they aren't
14:06Chousukebut as long as you're not using loads of refs to emulate mutability it should be fine.
14:07noidii'm working through the jambi hello world examples now, and i'm amazed by how much more concise the code becomes when written in clojure with a bit of refactoring
14:07noidi(quit-when (.. (quit-button) clicked))
14:10lisppaste8cgrand pasted "ref vs atom vs inexistant solution" at http://paste.lisp.org/display/76780
14:12cgrandany advice?
14:16Lau_of_DKGood evening gents
14:16cgrandHi!
14:16duncanmi want to import a class that has no namespace prefix, and if i say (import '(nil Foo)), i think it's trying to load /Foo and not just Foo
14:18duncanmis there a way to import that class?
14:18Chouserduncanm: you've created this class?
14:18cgrandduncanm: I don't thinks so
14:18duncanmChouser: it's not created by me
14:19duncanmin JS, the guy was able to load it by saying importClass(Packages.Foo);
14:19duncanmwell, the name of the thing is not Foo, but anyhow
14:19duncanmin the code, there's simply no line that declares the package
14:20cgrandduncanm: at the REPL, what does Foo returns?
14:20duncanmUnable to resolve symbol:
14:21Chousercgrand: ensure is just (ensure sessions), but I'm guessing you know that.
14:23duncanmsigh, so i can import the class in Rhino, but not Clojure?
14:24Chouserduncanm: it's pretty bad practice to have a class in the anonymous package. You're quite sure it has no package?
14:24duncanmyeah
14:24Chouserwhat if you say (clojure.lang.RT/classForName "Foo")?
14:25cgrandChouser: yep, I wonder whether it would be useful to be able ensure an invariant on the value of the ref rather than the value itself?
14:26Chousercgrand: you don't coordination with other reference objects, so 'atom' seems closer to what you want.
14:26Chouserbut either way, your problem is the potential for too many false positives on contension, right?
14:26cgrandright
14:27duncanmChouser: i get Foo
14:27Chouserduncanm: ok! so there's the class, we just need to import it somehow...
14:28duncanmexactly
14:28duncanmi tried nil, and that didn't help
14:30Chouser(.importClass *ns* "Foo" (clojure.lang.RT/classForName "Foo"))
14:31noidiis it possible to give the arguments to a java method call as a list?
14:31scottjDoes slime-who-calls work with clojure?
14:31duncanmjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol
14:31stuhoodnoidi: yes, use (apply)
14:31duncanmChouser: i think that's close....
14:32Chousernoidi: is the java method expecting varargs
14:32cgrandduncanm: (.importClass *ns* 'Foo (clojure.lang.RT/classForName "Foo"))
14:32duncanmi need a (str ...) around the classForName?
14:32duncanmah
14:32Chouserduncanm: oh, sorry, I mis-pasted.
14:32Chouseryeah, cgrand's got it.
14:32noidiChouser, nope
14:32noidiquit.setGeometry(10, 40, 180, 40);
14:33noidii'd like to take the arguments of that call from a list/vector
14:33noidistuhood, i'll look into that, thanks
14:33duncanmChouser: cool
14:33duncanmChouser: should i file a bug for this?
14:33Chouserno, (apply .foo ...) won't work.
14:33stuhoodapply and partial?
14:34duncanmChouser: it ought to be simpler than what you pasted, right?
14:34Chouserduncanm: I doubt it would get anywhere. anonymous-package classes are frowned on even in Java, I believe.
14:34hiredmanjava method, instance or static, are not clojure fns and cannot be treated as if they are
14:34hiredmanso no apply, partial, comp, etc
14:34noidimaybe apply and memfn?
14:35stuhood(apply #(.foo %) ...)?
14:35stuhooder, with the object in there somewhere
14:35hiredmannoidi: or just wrap it in a destructuring fn
14:35Chousuke,(apply #(.substring "foobar" %1 %2) [1 3])
14:35clojurebot"oo"
14:36hiredman(fn [[a b c d]] (.setGeometry quit a b c d))
14:36Chousukehmm
14:36Chouser(defmacro m-apply [& s] (apply list* s))
14:37Chouser(m-apply .substring "foobar" [1 3])
14:37hiredmanhmmmmm
14:37hiredmanI see
14:37ChousukeChouser: only works with literal seqs, does it?
14:37ChouserChousuke: oh!
14:38Chouserof course. :-(
14:38Chouserthought it seemed a little too easy.
14:38noidii think i'll go with the destructuring fn
14:39duncanmChouser: i wrote a post to the Google Group
14:39cgrandnoidi: is your method a vararg method?
14:39Chousernoidi: yeah, that's your best bet. ...gives you a good place to type-hint the args too, if needed to avoid runtime reflection.
14:39noidicgrand, no
14:39duncanmcgrand: varargs methods require a TO-ARRAY from the Clojure side, right?
14:40noidii'm just beginning to look into clojure, and i don't want to write macros until i get a feel for the clojure way of doing things
14:40noidiotherwise i might just use macros to make doing the wrong thing look easy :)
14:40cgrandduncanm: yes
14:40stuhoodnoidi: good point, heh
14:45Chousercgrand: could you do the new-id-picking inside the fn given to commute?
14:47Chouserthe point being, you really have to seriallize the process anyway -- you can't know the new id is good until you've checked it against the whole map and inserted it.
14:47Chouseractually, maybe a plain old lock is right in this case.
14:47Lau_of_DKewww
14:47scottjC-c C-k in slime will compile the current file. If it says 2 errors in the summary, does anyone know a way to get more details on what or where those errors are?
14:48duncanmcgrand: it'd be nice if clojure can figure that out without the explicit TO-ARRAY
14:48cgrandChouser: I can't do it inside a commute because I need to know which id is eventually picked
14:52Chouserwell you could do that, but I think it's starting to get pretty ugly.
14:52Chouserwhat about a java ConcurrentHashMap?
14:54Carkchouser: i remember reading somewhere a message from you about how printing agents now shows the content and with circular references the printing would be looping. you had a fix for that, but i don't remember where to find it
14:55DrakesonWhich openid library do you recommend? (I am pretty much hooked to compojure)
14:57stuhoodcgrand: i don't know the full problem, but what about a temporary ref that you involve in the transaction that gets set to the id value
14:58shooverscottj: check your inferior-lisp buffer. you can put slime-redirect-inferior-output in your emacs initialization to get see it in the REPL buffer
14:59lisppaste8Chouser annotated #76780 "too ugly for words" at http://paste.lisp.org/display/76780#1
14:59cgrandChouser: dunno, I'm not really worried about this case. It made me think about the general case of alleviating contention on ref holding large data structures due to false positives hence my "enhanced" ensure.
14:59cgrandChouser: argh!
15:00ChouserCark: (set! *print-level* 10)
15:01Carkah ... thanks, that was obvious enough ><
15:03Chousercgrand: I'm having a hard time seeing a general case (doesn't in any way mean there isn't one). In your case, the whole test-and-set operation really does need to have exclusive access to the map, doesn't it?
15:08cgrandChouser: thinking about it, I need to serialize access to key-set of the map only
15:12lisppaste8Chouser annotated #76780 "ConcurrentHashMap" at http://paste.lisp.org/display/76780#2
15:13Chouserthe enhanced ensure usage doesn't describe the "access to key-set" does it?
15:16cgrandI think I'm too reluctant to use mutable boxes and ends up using too few. (and in this case a ConcurrentHashMap seems to be a good idea)
15:16Chousersuch reluctance is quite natural, but rhickey does tend to encourage the use of java.util.concurrent when it makes sense.
15:17ChouserI don't know if CHM is serializing all writes there or not.
15:18Chouserhm, i'm guessing not. "The table is internally partitioned to try to permit the indicated number of concurrent updates without contention."
15:23cgrand(ensure sessions get id) would allow commute to proceed only if (get @sessions id) still returns nil: thus allowing for more concurrency than an alter or a swap! (I think -- need to check how swap! works)
15:24cgrandTo take another example: bOR_'s chlam-clean.clj
15:26cgrandI would have stored relations between humans in a single ref rather than putting a ref inside each human struct.
15:28cgrandand this is fine as long as you only need to commute...
15:41Hookehi
15:47Hookeguys, I'm trying (or trying to try) the examples in http://groups.google.com/group/clojure/files . The ants.clj works fine from the REPL, but the simple graphical application app.clj throws an error: java.lang.ClassNotFoundException: gui.MainFrame (NO_SOURCE_FILE:10)
15:47Hookeany tips, plz?
15:47cmvkki wouldn't trust the files in that directory to be working programs necessarily.
15:48Hookecmvkk: oh, I see, thanks.
15:48cmvkkthey're just files that people upload to the group to illustrate whatever they're discussing, but they could be anything.
15:48cmvkkexamples of errors, etc
15:48Chouseranyone can upload any file at any time, after which they're often abandoned, I think.
15:49cmvkki wonder if there's a good place to go for complete example programs, as opposed to code snippets etc?
15:50Hookehttp://en.wikibooks.org/wiki/Clojure_Programming/Examples/Temperature_Converter_GUI
15:50Hookehow about that?
15:50Hookewell, sorry, up to Examples
15:50cmvkkah yes, i always forget there's a wiki for that stuff.
15:51Chouserthere are also good bits on github and in clojure-contrib
15:51hiredmangithub
15:51hiredmangist
15:51ChouserI wouldn't trust gist either, though
15:51cmvkkwhat's gist?
15:51HookeI'm hearing a lot about github as of late
15:51hiredmancmvkk: git backed pastebin
15:51cmvkkhmm.
15:51hiredmanhttp://gist.github.com/
15:52cmvkkoh it's a part of github, even.
16:02HookeChouser: sorry, dumb question: where is clojure-contrib? I've found one at google code (but it has no downloads) and one at freshmeat (but I can't find the examples there)
16:03cmvkkit's the one at google code.
16:03cmvkkyou just have to use SVN to get it.
16:03cmvkkor look at the source directly, I guess.
16:04Hookecmvkk: ok, thanks. I'll try that :)
16:18Lau_of_DKWhat is faster? 3 consequtive filters, or 1 larger filters with a 3-way AND statement?
16:19cmvkkseems like it'd be the latter, but it's hard to guess at, right?
16:22Chousukeprobably the latter.
16:22Chousukebut should not be :)
16:22Chousukechoose the more readable form first
16:23Chousukehmm
16:25Lau_of_DKAND breaks on the first untrue form, starting with the first form?
16:25cmvkkit ought to...
16:25Chousukeyeah
16:26Lau_of_DKthen I'll go with AND, starting with the roughest filter first
16:26Chousukethere should be some higher-order predicates in clojure
16:26Chouserlike complement?
16:27Chousukeso you could do (filter (all even? odd?) aseq); (excuse the crappy example)
16:28hiredmanerm
16:28hiredmanwhat would that do?
16:28Chousukethat would do nothing, but with more intersting predicates it would :P
16:28Chousuke+e
16:29hiredmanlike, comp then?
16:30Chouser(defn all [& preds] (fn [x] (every? #(% x) preds)))
16:30Chousukeyeah
16:31hiredmanLau_of_DK: pmap a function that returns something if it is true for your predicate or nil if it isn't, then filter identity
16:31Chousukeisn't pmap intended for heavy functions.
16:32hiredmanChousuke: predicates can be heavy
16:32Chousukehmm, I guess.
16:32Chouser(defn all [& preds] #(every? (fn [pred] (apply pred %&)) preds))
16:32Chousukenot very often though
16:34Chousukemaybe "all" is not a very good name though. "andf"?
16:34hiredmanif you name the predicates you are going to filter by, (filter (comp p1 p2 p3 p4) seq)
16:35Chousukedoes that work? what if one of the predicates returns true instead of the object?
16:35slashus21It doesn't seem to work.
16:35hiredmanoh
16:35hiredmanduh
16:35tsdhHi. Is there some debug support for stepping through a function (preferably with slime).
16:36hiredmanclojurebot: filter is not map
16:36clojurebotAlles klar
16:36slashus21The first function Chouser suggested works, I think.
16:37Chousukeare there any more generic second-order predicates that might be useful? :/
16:37slashus21It has to pass every test in the list of predicates.
16:38ChousukeI really can't think of anything other than or and and :P
16:38Chouserdoesn't perl6 have something like this?
16:38Chousukexor too :)
16:42ChouserI was thinking of this, but now think it's different from what we're doing: http://en.wikipedia.org/wiki/Perl_6#Junctions
16:44slashus21so any?
16:45slashus21That is a little different.
16:45ChousukeChouser: interesting
16:46Chousukelooks a bit like algebraic data types :p
16:50Chouserperl6 was my favorite vaporware for a long time. ...haven't evaluated it recently.
17:15Chouserthere's not a 'alter' or 'update' fn for thread-local bindings, is there? Just 'set!'.
17:18Chouseryeah, I've used update-in with a vector of length 1
17:20kotarakme too
17:38Chouserthere's nothing like = that returns the value, is there?
17:39Chouser(let [x foo] (and (= x bar) x)) ; bleh
17:39Chouseroh, that's not what I want anyway.
17:40ChousukeChouser: would not be very nice for (= nil nil) :)
17:40Chouserindeed!
17:40Chousernor false, of course.
17:41Chouserbut actually I want the equivalent for not=
17:41Chouserwhich also makes it non-commutative. :-P
17:47Lau_of_DKI have a large hash-map in memory, can I get the physical size of it ?
17:48Chousernot as far as I know.
17:49Chouserthere are various memory heap analysis tools that can tell you how much memory is consumed by instances of each class
17:49Lau_of_DKk - It has a weird behaviour, if I populate it with 2M items, it runs very fast, if I go with 3M, it crashes with "GC overhead limit exceeded"
17:53hiredmanhave you seen http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html#cms.oom
17:53Lau_of_DKnot yet, but thx
17:55slashus213M means 3 million?
19:10brennanchello everyone. I'm looking into learning Compojure now and am wondering what environments are good to run it under? Jetty, Tomcat, Glassfish, Mina, etc? What are the pros/cons of each? What would you use in a high traffic production environment?
19:12hiredmanthere is not a lot of compojure chatter here, so I am not sure how many responses you will get, if you don't get what you need, compojure has a google group you can look at
19:13hiredmanjetty is most likely the easiest way to get started
19:13brennancthanks
19:13hiredmanbut I haven't used compojure in a few months
19:13brennancis a serious server though or is it just a toy to develop on I guess is what I'm wondering
19:13brennancI'm not all that familiar with java servers. My background is mostly the LAMP world.
19:13hiredmanI think the jetty website very much makes the claim that it is a real webserver
19:14albinothere are real production websites using it
19:15hiredmanI have a apache proxy access to my jetty instance, but it is *very* low traffic anyway so, I dunno
19:15albinohiredman: ajp?
19:15hiredmanalbino: ?
19:16albinoI thought the way to have apache talk to java server was a protocol called ajp, nevermind
19:16hiredmanoh
19:16hiredmanno, http proxy
19:16hiredmanproxypass or whatever it is called
19:16albinoregular reverse proxy
19:17hiredmanyeah, it's nice, I can have jetty run on whatever port and play with whatever
19:17brennancI was forwarding to glassfish that way as well
19:17brennancmod_proxy in apache that is
19:17hiredmanhttp://www.webtide.com/choose/jetty.jsp <-- jetty vs. tomcat
19:18albinoyeah, I was thinking of mod_ajp
19:19albinomaybe it's tomcat specific
19:31hiredmanwoa
19:32hiredmanhttp://groups.google.com/group/clojure/browse_thread/thread/1ebe3c8f342f3abe?hl=en <-- z/OS
19:37hiredmanI wonder how many decades will go by before everyone is on the unicode bus
19:38hiredmanand new vim clojure with nails goodness
19:39kotarakfinally...
19:39hiredman:)
19:39kotarakI hope releasing at half past midnight is not a bad idea....
19:39hiredmanit's 4:41pm
19:40kotarakAnyway. I go to bed now, and wait for the bug reports tomorrow. ;)
19:41kotarak.. eh today..
19:41kotarakis included
19:41kotarakhttp://www.martiansoftware.com/nailgun/
19:42hiredmanI was looking in ports, but it is not there
19:42kotarakdunno. It's included in the vimclojure distribution anyway.
19:44hiredmanoh
19:44hiredmanWell Then
19:44albinodoes that still work? I heard it was unmaintained
19:44kotarakNailgun? Well. It works. :)
19:45kotarakalbino: hmm... 2005 maybe you are right.
19:45hiredmanwhat is this .exe thing?
19:45kotarakIt's for the Windows users.
19:46kotarakUnix/Mac builds its own ng. That is the nailgun client.
19:50kotarakhiredman: any initial problems?
19:51hiredmankotarak: oh, uh, I just untared it
19:51hiredmanI am going to wait till I get home to try it out
19:51kotarakOk.
19:51kotarakNo hurry.
19:52kotarakGotta go now. Bye.
19:58brennancthe default JVM that comes with the macs are extremely slow compared to the linux version. wonder why that is.
19:59hiredmanit might be a -client vs -server thing
20:03brennancI'll give it another try when I'm home, that might be the case.
20:07slashus21Isn't the jvm that comes with macs still at 5?
20:07slashus21That may not be the case with leopard.
20:07danlarkinleopard comes with 1.5 yes
20:10slashus21There are probably performance gains between 5 and 6.
20:11arohnerthere is an official download for java 6 on 10.5
20:11arohnerfor intel 64-bit
20:46arohneris (/ x y) exactly as fast as x / y in java?
20:47arohnernm, (source /) answers my question
20:48danlarkinyou might want unchecked-divide
20:48arohnerdanlarkin: thanks
20:54ayrnieuslashus - ABCL sees performance degredation on java 6 through release 10, which... is only a little inferior.
21:00RaynesWhy can you only recur from the tail position?
21:01slashus21ayrnieu: Any idea why there was a performance degredation?
21:01ayrnieuslashus - no.
21:02ayrnieuRaynes - you can recur from any position, but you can only (recur ..) from a tail position.
21:03lisppaste8Rayne pasted "Towers of hanoi" at http://paste.lisp.org/display/76793
21:03RaynesWell, the reason I was asking is I was trying to do that ^ using recur.
21:03ayrnieuwhich is to say, "I was trying to do that ^ uing tail calls."
21:04slashus21tail recursion makes your function act as a loop.
21:04slashus21It wouldn't make sense in this condition.
21:04arohnerRaynes: you can only recur from the tail position because that is the only place where going to the top is guaranteed to be the same as calling the function again
21:05RaynesI understand.
21:06lisppaste8Rayne annotated #76793 "Updated tower of hanoi" at http://paste.lisp.org/display/76793#1
21:07slashus21..
21:31hiredmanRaynes: now do it with each agents
21:31dnolenfor trampoline experts: Is there a problem with calling trampoline while in a trampoline? Does this grow the stack because of the additional trampoline call?
21:31Rayneshiredman: WHat?
21:31hiredman~def trampoline
21:31hiredmanRaynes: do it with agents
21:32RaynesI don't know what an agent is. I just translated the common lisp implementation. I haven't read the /entire book/ yet.
21:32dnolenhiredman: doesn't quite answer my question, i've referred to the docs
21:32replacaQ: How do you get a symbol from a var? That is, #'foo -> 'foo?
21:33hiredmandnolen: I just wanted a look at the source
21:33hiredmanreplaca: I don't think you can
21:33dnolenhiredman: oops sorry :)
21:33replaca:-(
21:33replacahiredman: ok, thanks
21:33hiredmandnolen: trampoline is just another function
21:33Raynes,(var (def x 1))
21:33clojurebotDENIED
21:34Raynesclojurebot just showed me who wears the pants in this relationship.
21:34hiredman,`trampoline
21:34clojurebotclojure.core/trampoline
21:34hiredman,(find-var `trampoline)
21:34clojurebot#'clojure.core/trampoline
21:35hiredman,(map #(.getName %) (.getMethods (class (find-var `trampoline))))
21:35clojurebot("applyTo" "call" "alter" "bindRoot" "pushThreadBindings" "popThreadBindings" "setTag" "setMeta" "setMacro" "isMacro" "fn" "internPrivate" "setValidator" "doSet" "hasRoot" "unbindRoot" "commuteRoot" "alterRoot" "releaseThreadBindings" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "
21:35Rayneshiredman: Ohh pretty.
21:36gnuvince_(doc find-var)
21:36clojurebotReturns the global var named by the namespace-qualified symbol, or nil if no var with that name.; arglists ([sym])
21:36hiredman,(filter #(not= % "invoke") (map #(.getName %) (.getMethods (class (find-var `trampoline)))))
21:36clojurebot("applyTo" "call" "alter" "bindRoot" "pushThreadBindings" "popThreadBindings" "setTag" "setMeta" "setMacro" "isMacro" "fn" "internPrivate" "setValidator" "doSet" "hasRoot" "unbindRoot" "commuteRoot" "alterRoot" "releaseThreadBindings" "run" "get" "toString" "intern" "intern" "intern" "intern" "find" "set" "isPublic" "deref" "create" "create" "getRoot" "isBound" "doReset" "getTag" "getValidator" "notifyWatches" "getWatches
21:36gnuvince_Interesting the things you can do when you know Java ;)
21:36hiredmanI tell you what, you learn more java mucking around with clojure...
21:37Chouserword
21:37Raynesword
21:38dnolenhiredman: short answer is yes, calling trampoline within a trampoline grows the stack, makes sense.
21:38dnolenI suppose there's no way to know if you're in a recur?
21:38replacathat's the nature of the repl language, you spend a lot of time exploring your world
21:38Raynesdnolen: If you keep repeating yourself you know.
21:38Raynesdnolen: If you keep repeating yourself you know.
21:40dnolenRaynes: heh, so I suppose there's not.
21:42timothypratleyHi - I'm trying to use vimclojure, anyone know how to make it use ng.exe instead of ng?
21:42replacahiredman: so it looks like the var really has no idea what it's symbol name was
21:42replacahiredman: that would kind of indicate that there is a way for two symbols to point at the same var
21:43hiredmanreplaca: I would imagine there is a way
21:43replacatime to UTSL again, I think, though I don't really need that feature right now
21:44RaynesWhat is the symbol name of a var?
21:44RaynesCall me stupid, but I'm not sure what you mean. I think I do however.
21:45replacawhen I use a symbol like foo in (def foo 7), foo is pointing to a var object (specified by #'foo or (var foo))
21:46replacaI always thought that the symbol and its var were inextricably linked, but that appears not to be true
21:48Chouserthe var points to its name symbol, namespace symbol, and value
21:49Chouseryou can find the var by looking up the symbol in a namespace
21:53Chouseranyone here at looked at Compiler.java at all?
21:54duncanmreplaca: heh, nice nick
21:54duncanmisn't it rplaca, though?
21:59slashus21MAX_POSITIONAL_ARITY = 20 would mean that you can have at most 20 named arguments?
22:08ChouserI think that's correct.
22:09Chouserbut you can have unlimited 'rest' args.
22:09duncanmCjptjat
22:09duncanmeek
22:09duncanmChouser: that's because it's just an array, right?
22:10Chouserno, clojure varargs are a seq
22:10Chouserso it can be infinite
22:10duncanmokay, a seq, but a collection nevertheless
22:10brennancif you use a seq that's only one param
22:11brennancwhere did you see the MAX_POSITIONAL_ARITY? what is that from?
22:11Chouser,(let [nth-arg (fn [n & args] (nth args n))] (apply nth-arg 99 (iterate inc 44)))
22:11clojurebot143
22:13slashus21hiredman: I am playing with vimclojure too. I am getting errors at the start.
22:13slashus21Raynes: Have you figured out how to insert code while your program is running?
22:13Raynesslashus21: Haven't needed too.
22:14RaynesHaven't desired too.
22:14slashus21Raynes: I was playing with an irc bot and it would be nice to change functions while it is running.
22:15RaynesI tend to actually compile my code. hiredman took an alternate route :>
22:15hiredmanclojure is always compiled yo
22:15slashus21Well it is just dynamic compilation.
22:15slashus21Still compiled.
22:15slashus21Just more flexible.
22:15slashus21hiredman: How do you load code while your bot is running?
22:16hiredmananyway, gen-class just makes stubs that dispatch to fns
22:16hiredmanslashus21: I have a repl
22:16hiredmanof course
22:16slashus21slime?
22:16hiredmanjust clojure.main
22:17hiredmanclojurebot: emacs?
22:17clojurebotbut I like using notepad++!
22:17slashus21hehe
22:17slashus21I don't use slime either.
22:17slashus21How to you run the program and run a repl as well?
22:18hiredmanclojure.main -i file.clj -r
22:19slashus21I have a bot running through enclojure, I think the dynamic compilation will better suit my purposes.
22:26slashus21hiredman: Do you have to manually switch to the proper namespace?
22:28slashus21yea, that worke.d
22:52arohner_does anyone have experience with using a java profiler in clojure?
22:53arohner_I'm trying visualvm, but it seems to have issues with the clojure classload being GC'd
23:11replacaduncanm: (if you're still here): yeah, that's right, I added a vowell to avoid a collision years ago. It's a *very* non-clojure nick :-)
23:21Chouseris 'parse' some kind of builtin?
23:21ChouserI'm getting a really weird error.
23:22duncanmheh
23:23duncanmis there a way to define a class and methods in Clojure?
23:23replacaChouser: it's not in clojure.core
23:23replacaduncanm: gen-class
23:23cmvkkgen-class or proxy
23:24replacaduncanm: or you can use proxy if you just need to define something that matches an interface
23:25replacaChouser: I don't even have parse from the repl. where are you getting it?
23:26ChouserI must be confusing myself somehow.
23:27ChouserI've defined a multimethod named parse, but in one place where I'm using it I'm getting an error that doesn't make any sense.
23:27Chouserand vim colors parse like a builtin -- I'm sure that's not helping see the real problem.
23:29cmvkkwhat's the error?
23:29Chouserjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.String
23:30cmvkkheh, well, at least it's obvious what the error means
23:30Chouseryes, but there are no keywords or strings on that line. :-P
23:30ChouserI have to trim this down before anyone will be able to help me.
23:30ChouserI'm sure it's something dumb..
23:32cooldude127who here uses gorilla and vim for clojure?
23:32Chousergah. the line works at the repl.
23:33cooldude127and is willing to explain just how you set it up. cuz i can't even get the vimclojure part to work
23:33hiredmanme neither, actually
23:34replacaChouser: what's the multimethod discriminating on?
23:34replacaChouser: that would be my first suspect
23:36Chouserah, I had a try/catch block that was getting in the way
23:37replacaChouser: so much for guessing in the dark :-)
23:38Chouserheh, yeah, I wasn't giving you nearly enough to go on.
23:39replacathat's always the way at the beginning
23:39Chouserwoohoo!
23:40cooldude127ok, i have my clojure support in vim working, but it's kinda messed up in that it spews errors when i load a .clj file, even tho when i press q it lets me edit the file in all its goodness
23:40Chouserok, enough for now. g'night, all!
23:42arohner_night
23:46cooldude127i get a bunch of undefined function and etc errors everytime i load a clojure file in vim
23:46hiredmanyou must be missing some files
23:47hiredmanI don't even get that
23:47hiredman:(
23:48cooldude127yeah, i was missing files. the mistake was following the screencast, which is only and doesn't copy the autoload folder (presumably cuz it didn't exist)
23:49hiredmandoes the repl work now?