#clojure log - Mar 10 2009

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:15 replaca: Q: 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.

0:16 cooldude127: (doc alter-meta!)

0:16 clojurebot: Atomically 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])

0:17 replaca: cooldude127: beautiful! thanks!

0:17 cooldude127: no problem

0:43 slashus2: I 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.

0:44 replaca: lisppaste8: url?

0:44 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

0:49 replaca pasted "A bug in backquote processing?" at http://paste.lisp.org/display/76738

0:49 replaca: Is this a bug? I want to put functions inside a macro, but it won't work with backquote.

0:50 slashus2: (defmacro m [] `(apply (fn [a#] a#) [7]))

0:51 autogensym

0:51 replaca: slashus2: ahh, of course

0:51 I was confused by the namespace stuff and forgot that I needed a gensym.

0:51 Thanks!

0:52 slashus2: Your welcome

0:53 Is there a way to use proxy to do a constructor. I am trying to call a protected method.

0:53 ... that doesn't really make sense.

0:56 replaca: No, no contructors, no protected methods

0:56 gotta use (ns (:gen-class ...)) for that with AOT

0:57 slashus2: I am trying to figure out how hiredman did it with his bot.

0:58 When he creates a bot he just calls .changeNick , but that doesn't work in my java version, or clojure version.

0:58 Have to call this.setName in java

0:58 inside the constructor.

0:58 replaca: I haven't looked at his code

0:59 hmmm....

1:05 slashus2: I fixed it by changing (.setAutoNickChange true)

1:06 replaca: ahh, fun with bots :-)

1:39 Raynes: ?

1:50 replaca: the magical lambda!

1:50 truly the symbol of a dark cult

2:04 slashus2: I 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.

2:06 cmvkk: hmm. namespaces aren't my strong point, but I thought you had to do something specific to make a function private.

2:06 slashus2: defn- ?

2:06 cmvkk: something like that

2:07 slashus2: I am not doing that :-(

2:07 cmvkk: you're "use"ing the namespace or whatever?

2:08 slashus2: I have tried everything :-(

2:09 cmvkk: when i do (ns some.namespace (:use someother.namespace)) that usually does it for all the other namespace's functions

2:12 slashus2: When you are compiling to a jar file, does every single file that you have have to be a class?

2:13 cmvkk: every function ends up being a class, i think, when you compile clojure code.

2:13 slashus2: I was using enclojure.

2:13 This is very frustrating

2:13 cmvkk: i've never even heard of that.

2:14 slashus2: netbeans enclojure

2:27 cmvkk: I am using use inside of the namespace delcaration (:use [com.cljbot.cljbotcore :only (start-cljbot)])

2:27 replaca: and what func are you trying to call?

2:28 slashus2: wait.. I think it is working now.

2:28 replaca: do you really want the :only?

2:28 ahh, ok

2:29 slashus2: replaca: I am just playing with it.

2:29 felzix: is there a way to turn strings into numbers without using read-string?

2:29 I want to turn strings that could be numbers into numbers and leave them alone otherwise

2:29 slashus2: The multiple ways to deal with things use refer import etc. can get confusing.

2:30 ugh.. It still says that the method isn't public

2:30 misnamed function :-(

2:30 cmvkk: felzix there are java functions that you can use maybe

2:31 replaca: I'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

2:31 felzix: cmvkk: oh, right. I sometimes forget about that. Thanks :)

2:31 replaca: It's easy enough for funcs, but I have some vars that I want the user to be able to bind

2:32 cmvkk: why would it be any different for vars?

2:32 aren't funcs vars?

2:32 replaca: yeah, but you don't really care about their originating namespace, so you can just copy them

2:33 hiredman: replaca: you might look at how clojure.core deals with that

2:33 replaca: if you copy a var and then bind it, you'll be binding the copy, not the original

2:33 is it made up of more than one file? I haven't utsl'd in a long time

2:34 hiredman: it is

2:40 replaca: I see, he does it by using "load" directly in core.clj and then "in-ns" in the helper files

2:41 It doesn't let you pick and choose, but I think it's workable for what I need

2:42 hiredman: thanks!

2:56 Tests run: 271, failures: 0! Time to check in and go to bed :-)

2:57 closing in on a pretty printer I can really publish!

3:02 slashus2: I wonder if there is a way to modify code while it is running in enclojure.

3:59 hiredman: java's two threads, clojure's threadpools, and my own threadpool, suddenly I have eleven threads churning away on this pool c2d

4:00 poor

4:59 tsdh: Hi.

5:01 I'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?

5:02 hiredman: tsdh: your first posts have to get approval

5:02 to cut down on spam

5:02 tsdh: Ah, ok. Thanks for the hint.

5:02 hiredman: so, whenever rhickey wakes up and tends the queue...

5:05 actually, he may be awake in london for the thing

5:06 cmvkk: there's a thing in london?

5:06 hiredman: a thing

5:07 cmvkk: like a.....computer thing

5:09 hiredman: yes

7:58 bstephenson: ,(str 1)

7:58 clojurebot: "1"

8:16 timothypratley: what's the best html clojure library to use (just want to output a basic html file)

8:28 eevar2: timothypratley, have a look at compojure if you're looking for a web framework

8:35 timothypratley: eevar2: thanks, clojure.contrib.prxml seems to do all I need for now :)

8:35 its just some throwaway code

9:38 blbrown_lt: hello morning folks

9:53 AWizzArd: clojurebot: max people

9:53 clojurebot: max people is 156

9:53 blbrown_lt: getting there

9:53 AWizzArd: yup :)

9:55 Chouser: where's "there"?

9:55 ...just out of curiosity...

10:00 AWizzArd: 1k :)

10:00 no, I think 200+ is already fine

10:07 Chouser: http://tinyurl.com/d5g6nj -- trends

10:26 rsynnott: Chouser: 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:26 so it may not mean that much

10:26 also, some perspective: http://www.google.com/trends?q=clojure,ocaml,"common+lisp",+haskell,python&ctab=0&geo=all&date=ytd&sort=0

10:26 Chouser: that's certainly not a good way to measure KLOC-in-production or anything.

10:27 haskell and python match outside the domain of programming languages quite a bit.

10:27 note the headlines in the right-hand column.

10:27 rsynnott: hmm, yep

11:06 marklar: hi 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:07 Chouser: ~euler

11:07 ~projecteuler

11:07 clojurebot: Pardon?

11:07 Chouser: hm

11:07 cgrand: http://clojure-euler.wikispaces.com/

11:08 Chouser: :-) thanks

11:08 cgrand: clojurebot: euler is http://clojure-euler.wikispaces.com/

11:08 clojurebot: You don't have to tell me twice.

11:08 marklar: Thanks!

11:08 rsynnott: apparently he does

11:08 cgrand: ~euler

11:08 clojurebot: euler is http://clojure-euler.wikispaces.com/

11:26 AWizzArd: marklar: And? After seeing some Clojure solutions, how clojuristical do you find your own solution now?

11:32 danlarkin: s/clojuristical/idiomatic

12:08 jayfields: has anyone used clojure exclusively to test their java applications?

12:08 I'm using it for some specific testing, but considering going to all clojure all day for testing.

12:09 p_l: anyone knows of good java disassembler? I want to do my code in clojure and then generate java source from generated bytecode :>

12:10 cemerick: jayfields: 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:10 AWizzArd: p_l: jad

12:10 cemerick: p_l: jad is the only worthwhile one, I believe

12:11 I'm pretty sure that diassembled clojure is pretty useless, tho.

12:12 p_l: cemerick: As long as it will pass "compile it back in BlueJ and still work", it's not useless

12:12 cemerick: mostly useless, that is...I tried it once when the AOT stuff was in its early stages, and jad's output was uncompilable.

12:12 p_l: ouch

12:12 cemerick: that's pretty common for non-javac-generated bytecode

12:13 AWizzArd: it's good

12:13 p_l: then my proffessor should prepare for few classes full of static member methods :/

12:13 AWizzArd: I still need to learn how to apply a code obfuscator on top of what Clojure outputs.

12:13 cemerick: AWizzArd: no luck with proguard from a few weeks ago?

12:14 AWizzArd: I did not continue with it, but I will.. soon.

12:14 * p_l has to write this stupid assignment in java ;_;

12:14 Chouser: p_l: I think clojure produces bytecode in some cases for which there is no Java equiv.

12:14 goto, for example

12:15 jayfields: cemerick: not rewriting legacy makes perfect sense. any gotchas since you went to test-is exclusively?

12:16 rsynnott: java doesn't have a goto?

12:17 p_l: will the lecturer not take offence to something which is obviously disassembled bytecode, anyway?

12:17 cemerick: jayfields: 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:18 rsynnott: that may be undesirable if your test has side-effects, of course

12:18 jayfields: cemerick: cool. thanks.

12:18 rsynnott: (test1: create user test2: delete original user or similar)

12:19 p_l: rsynnott: I think it might help drive my point home :>

12:19 cemerick: rsynnott: all of our tests are purely functional at the moment

12:19 p_l: well, the task we have to do maps in my mind best to Haskell, but that was completely out due to JVM :/

12:22 I did come and ask him first if we can write it in any other language than Java, though

12:25 cemerick: Chouser: 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:31 tsdh: Is 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:32 danlarkin: tsdh: refactor :)

12:33 tsdh: ok

12:37 gnuvince: tsdh: so such thing, no.

12:46 jayfields: what's the clojure equivalent of Foo.class ? I tried (class Foo) but it didn't seem to work well

12:46 gnuvince: ,(class 3)

12:46 clojurebot: java.lang.Integer

12:49 StartsWithK: jayfields: JFrame.class is just JFrame in clojure

12:49 jayfields: thanks

12:49 StartsWithK: thanks

12:49 StartsWithK: lisppaste8: help

12:49 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

12:51 StartsWithK pasted "Declarative swing ui + cells, port of acp example" at http://paste.lisp.org/display/76752

12:52 StartsWithK: original active context pattern is http://is.gd/mJhb here

12:54 tsdh: how do i switch to a given namespace in the repl?

12:55 StartsWithK: no one interested? by the number of people on that cells thread i tought this would have some intereset :)

12:55 cemerick: tsdh: (in-ns 'my.namespace)

12:55 tsdh: cemerick: Thanks

12:57 durka42: StartsWithK: is that a complete program?

12:57 tsdh: Using slime, is there a way to abort a long-running funcall at the repl?

12:57 StartsWithK: durka42: yes

12:58 replicates all of the functionalyt from original active context pattern example

12:58 durka42: the => and >> macros must be rather magic

12:58 where can i find the net.ksojat.neman jars that i assume i need to run this?

12:59 StartsWithK: => is like extended version of doto, so you get :Setter, or in JFrame [] replaced with repetive add calls

12:59 shoover: tsdh: not last I checked, but there's a recent addition to clojure.contrib.repl-utils that may help (haven't tried it myself)

12:59 StartsWithK: >> is 'method' injected in Object, so i named it that it cant clash with any java names

13:00 durka42: injected? as in proxy?

13:00 StartsWithK: durka42: http://bitbucket.org/ksojat/neman/ but give me a minute tu push this example

13:00 no, more injected as in scope of =>

13:00 no real method injection is done

13:01 danlarkin: that would leak

13:01 tsdh: shoover: 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:03 StartsWithK: i uploaded this right now

13:04 noidi: is it possible to import all classes from a java package?

13:04 something like (import '(com.trolltech.qt.gui *))

13:04 StartsWithK: easy way to get it to run is to build http://bitbucket.org/ksojat/truba/ that will pull correct clojure version

13:04 then from neman project directory just type "ant publish-all" to build all modules and "ant repl" so it generates clojure repl script

13:05 after that ./clojure and you can load the example (load-file "examples/swing2.clj")

13:06 durka42: noidi: no

13:07 noidi: ok, good :)

13:08 makes 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:08 durka42: StartsWithK_: doesn't use the latest clojure version?

13:09 StartsWithK_: 1322

13:11 i don't know how will ivy react if you just drop clojure.jar in lib directory :/

13:12 durka42: hmm, this will need ivy to build won't it

13:12 ant doesn't do much at all

13:13 StartsWithK_: 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:14 resolves*

13:16 durka42: well i need to install ivy first

13:16 StartsWithK_: no

13:16 build will download it for you

13:17 just type "ant" in truba and "ant publish-all repl" in neman, that should do it

13:20 durka42: right, i'll try that

13:20 jayfields: is anyone using La Clojure for IntelliJ?

13:23 StartsWithK_: durka42: i'm sorry, didn't see that truba on bitbucket dosn't download 1322, just fixed it

13:23 lisppaste8: durka42 pasted "should really install ivy" at http://paste.lisp.org/display/76754

13:24 StartsWithK_: it must be a lod truba version on bitbucket

13:24 old*

13:32 durka42: it looks that you will also need to add to the end of CP in clojure script :neman/swing/targets/swing.jar

13:32 i don't know why it can't load classes from directory, but it works for jars

13:32 that didn't happen before i upgraded to 1322..

13:32 durka42: hmm

13:32 Unable to load a script engine manager (org.apache.bsf.BSFManager or javax.script.ScriptEngineManager)

13:33 StartsWithK_: no ant 1.7?

13:33 hmm

13:35 durka42: it is ant 1.7

13:37 noidi: is it possible to supply default values for positional arguments, like in python? (def foo(a, b=1, c=2): pass)

13:38 or should i make versions with different arities?

13:39 StartsWithK_: durka42: i'm lost there, ant should have support for bsf or javax script enabled..

13:39 gnuvince: noidi: different arities is usually used.

13:40 noidi: gnuvince, thanks

13:42 jayfields: is there a way to do this in Clojure

13:42 new Object() {{

13:42 System.out.println("hello");

13:42 }};

13:42 gnuvince: jayfields: what's that?

13:42 durka42: jayfields: what does that do? ;)

13:43 clojurebot: can clojure do the above?

13:43 clojurebot: Yes, Clojure can do that!

13:43 gnuvince: If it does what I think it does: #(println "hello")

13:43 jayfields: it creates a new instance of an object that prints hello as the initializer

13:43 Chouser: jayfields: but since it's creating it immediately, how is that different than just: System.out.println("hello");

13:44 durka42: hmm, you won't be able to do constructors without an AOT gen-class, right?

13:44 jayfields: because the actual code that I'm working on is more complicated

13:44 Chouser: ,(#(println "hello"))

13:44 clojurebot: hello

13:44 gnuvince: Use a closure.

13:45 slashus2: What 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:46 durka42: do clojure regexes support named groups?

13:46 gnuvince: Do Java's?

13:46 Chouser: durka42, gnuvince: I don't think so.

13:47 gnuvince: Then no.

13:48 Yeah, the javadoc doesn't seem to indivate that they do.

13:50 StartsWithK_: durka42: best thing i can do for now: http://ksojat.net/media/swing-example.tar.gz just pack with swing1 and swing2 examples

13:52 duncanm: is there a way to find out what namespaces/classes have been imported from the REPL?

13:53 durka42: ,(all-ns)

13:53 clojurebot: (#<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:53 durka42: ehm, that .tar.gz didn't really work

13:54 but i did get it to run by abusing add-classpath and compile :)

13:55 StartsWithK_: you can see swing examples? :)

13:55 wee

13:55 not much to look at :) hehe

13:57 duncanm: what's the general way to get a length of a Seq?

13:58 durka42: ,count

13:58 duncanm: i'd think it'd be .length, but that's not it

13:58 clojurebot: #<core$count__3496 clojure.core$count__3496@83964f>

13:58 durka42: (count [1 2 3])

13:58 duncanm: ahhh

13:58 durka42: ,(count [1 2 3])

13:58 clojurebot: 3

14:02 noidi: wow, clojure/java interop is amazing :O

14:03 durka42: man regexes are really write-only, aren't they

14:03 noidi: i don't know either language (especially not clojure), but it's still trivial to translate java code examples into clojure :)

14:05 Chousuke: noidi: the translations might not be very clojurey code at first though :)

14:06 noidi: yeah, i'm sure they aren't

14:06 Chousuke: but as long as you're not using loads of refs to emulate mutability it should be fine.

14:07 noidi: i'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:07 (quit-when (.. (quit-button) clicked))

14:10 lisppaste8: cgrand pasted "ref vs atom vs inexistant solution" at http://paste.lisp.org/display/76780

14:12 cgrand: any advice?

14:16 Lau_of_DK: Good evening gents

14:16 cgrand: Hi!

14:16 duncanm: i 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:18 is there a way to import that class?

14:18 Chouser: duncanm: you've created this class?

14:18 cgrand: duncanm: I don't thinks so

14:18 duncanm: Chouser: it's not created by me

14:19 in JS, the guy was able to load it by saying importClass(Packages.Foo);

14:19 well, the name of the thing is not Foo, but anyhow

14:19 in the code, there's simply no line that declares the package

14:20 cgrand: duncanm: at the REPL, what does Foo returns?

14:20 duncanm: Unable to resolve symbol:

14:21 Chouser: cgrand: ensure is just (ensure sessions), but I'm guessing you know that.

14:23 duncanm: sigh, so i can import the class in Rhino, but not Clojure?

14:24 Chouser: duncanm: it's pretty bad practice to have a class in the anonymous package. You're quite sure it has no package?

14:24 duncanm: yeah

14:24 Chouser: what if you say (clojure.lang.RT/classForName "Foo")?

14:25 cgrand: Chouser: 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:26 Chouser: cgrand: you don't coordination with other reference objects, so 'atom' seems closer to what you want.

14:26 but either way, your problem is the potential for too many false positives on contension, right?

14:26 cgrand: right

14:27 duncanm: Chouser: i get Foo

14:27 Chouser: duncanm: ok! so there's the class, we just need to import it somehow...

14:28 duncanm: exactly

14:28 i tried nil, and that didn't help

14:30 Chouser: (.importClass *ns* "Foo" (clojure.lang.RT/classForName "Foo"))

14:31 noidi: is it possible to give the arguments to a java method call as a list?

14:31 scottj: Does slime-who-calls work with clojure?

14:31 duncanm: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol

14:31 stuhood: noidi: yes, use (apply)

14:31 duncanm: Chouser: i think that's close....

14:32 Chouser: noidi: is the java method expecting varargs

14:32 cgrand: duncanm: (.importClass *ns* 'Foo (clojure.lang.RT/classForName "Foo"))

14:32 duncanm: i need a (str ...) around the classForName?

14:32 ah

14:32 Chouser: duncanm: oh, sorry, I mis-pasted.

14:32 yeah, cgrand's got it.

14:32 noidi: Chouser, nope

14:32 quit.setGeometry(10, 40, 180, 40);

14:33 i'd like to take the arguments of that call from a list/vector

14:33 stuhood, i'll look into that, thanks

14:33 duncanm: Chouser: cool

14:33 Chouser: should i file a bug for this?

14:33 Chouser: no, (apply .foo ...) won't work.

14:33 stuhood: apply and partial?

14:34 duncanm: Chouser: it ought to be simpler than what you pasted, right?

14:34 Chouser: duncanm: I doubt it would get anywhere. anonymous-package classes are frowned on even in Java, I believe.

14:34 hiredman: java method, instance or static, are not clojure fns and cannot be treated as if they are

14:34 so no apply, partial, comp, etc

14:34 noidi: maybe apply and memfn?

14:35 stuhood: (apply #(.foo %) ...)?

14:35 er, with the object in there somewhere

14:35 hiredman: noidi: or just wrap it in a destructuring fn

14:35 Chousuke: ,(apply #(.substring "foobar" %1 %2) [1 3])

14:35 clojurebot: "oo"

14:36 hiredman: (fn [[a b c d]] (.setGeometry quit a b c d))

14:36 Chousuke: hmm

14:36 Chouser: (defmacro m-apply [& s] (apply list* s))

14:37 (m-apply .substring "foobar" [1 3])

14:37 hiredman: hmmmmm

14:37 I see

14:37 Chousuke: Chouser: only works with literal seqs, does it?

14:37 Chouser: Chousuke: oh!

14:38 of course. :-(

14:38 thought it seemed a little too easy.

14:38 noidi: i think i'll go with the destructuring fn

14:39 duncanm: Chouser: i wrote a post to the Google Group

14:39 cgrand: noidi: is your method a vararg method?

14:39 Chouser: noidi: yeah, that's your best bet. ...gives you a good place to type-hint the args too, if needed to avoid runtime reflection.

14:39 noidi: cgrand, no

14:39 duncanm: cgrand: varargs methods require a TO-ARRAY from the Clojure side, right?

14:40 noidi: i'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:40 otherwise i might just use macros to make doing the wrong thing look easy :)

14:40 cgrand: duncanm: yes

14:40 stuhood: noidi: good point, heh

14:45 Chouser: cgrand: could you do the new-id-picking inside the fn given to commute?

14:47 the 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:47 actually, maybe a plain old lock is right in this case.

14:47 Lau_of_DK: ewww

14:47 scottj: C-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:48 duncanm: cgrand: it'd be nice if clojure can figure that out without the explicit TO-ARRAY

14:48 cgrand: Chouser: I can't do it inside a commute because I need to know which id is eventually picked

14:52 Chouser: well you could do that, but I think it's starting to get pretty ugly.

14:52 what about a java ConcurrentHashMap?

14:54 Cark: chouser: 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:55 Drakeson: Which openid library do you recommend? (I am pretty much hooked to compojure)

14:57 stuhood: cgrand: 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:58 shoover: scottj: 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:59 lisppaste8: Chouser annotated #76780 "too ugly for words" at http://paste.lisp.org/display/76780#1

14:59 cgrand: Chouser: 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:59 Chouser: argh!

15:00 * Chouser smiles sweetly

15:00 Chouser: Cark: (set! *print-level* 10)

15:01 Cark: ah ... thanks, that was obvious enough ><

15:01 * Cark shoudl have another coffee

15:03 Chouser: cgrand: 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:08 cgrand: Chouser: thinking about it, I need to serialize access to key-set of the map only

15:12 lisppaste8: Chouser annotated #76780 "ConcurrentHashMap" at http://paste.lisp.org/display/76780#2

15:13 Chouser: the enhanced ensure usage doesn't describe the "access to key-set" does it?

15:16 cgrand: I 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:16 Chouser: such reluctance is quite natural, but rhickey does tend to encourage the use of java.util.concurrent when it makes sense.

15:17 I don't know if CHM is serializing all writes there or not.

15:18 hm, i'm guessing not. "The table is internally partitioned to try to permit the indicated number of concurrent updates without contention."

15:23 cgrand: (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:24 To take another example: bOR_'s chlam-clean.clj

15:26 I would have stored relations between humans in a single ref rather than putting a ref inside each human struct.

15:28 and this is fine as long as you only need to commute...

15:41 Hooke: hi

15:47 guys, 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:47 any tips, plz?

15:47 cmvkk: i wouldn't trust the files in that directory to be working programs necessarily.

15:48 Hooke: cmvkk: oh, I see, thanks.

15:48 cmvkk: they're just files that people upload to the group to illustrate whatever they're discussing, but they could be anything.

15:48 examples of errors, etc

15:48 Chouser: anyone can upload any file at any time, after which they're often abandoned, I think.

15:49 cmvkk: i wonder if there's a good place to go for complete example programs, as opposed to code snippets etc?

15:50 Hooke: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Temperature_Converter_GUI

15:50 how about that?

15:50 well, sorry, up to Examples

15:50 cmvkk: ah yes, i always forget there's a wiki for that stuff.

15:51 Chouser: there are also good bits on github and in clojure-contrib

15:51 hiredman: github

15:51 gist

15:51 Chouser: I wouldn't trust gist either, though

15:51 cmvkk: what's gist?

15:51 Hooke: I'm hearing a lot about github as of late

15:51 hiredman: cmvkk: git backed pastebin

15:51 cmvkk: hmm.

15:51 hiredman: http://gist.github.com/

15:52 cmvkk: oh it's a part of github, even.

16:02 Hooke: Chouser: 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:03 cmvkk: it's the one at google code.

16:03 you just have to use SVN to get it.

16:03 or look at the source directly, I guess.

16:04 Hooke: cmvkk: ok, thanks. I'll try that :)

16:18 Lau_of_DK: What is faster? 3 consequtive filters, or 1 larger filters with a 3-way AND statement?

16:19 cmvkk: seems like it'd be the latter, but it's hard to guess at, right?

16:22 Chousuke: probably the latter.

16:22 but should not be :)

16:22 choose the more readable form first

16:23 hmm

16:25 Lau_of_DK: AND breaks on the first untrue form, starting with the first form?

16:25 cmvkk: it ought to...

16:25 Chousuke: yeah

16:26 Lau_of_DK: then I'll go with AND, starting with the roughest filter first

16:26 Chousuke: there should be some higher-order predicates in clojure

16:26 Chouser: like complement?

16:27 Chousuke: so you could do (filter (all even? odd?) aseq); (excuse the crappy example)

16:28 hiredman: erm

16:28 what would that do?

16:28 Chousuke: that would do nothing, but with more intersting predicates it would :P

16:28 +e

16:29 hiredman: like, comp then?

16:30 Chouser: (defn all [& preds] (fn [x] (every? #(% x) preds)))

16:30 Chousuke: yeah

16:31 hiredman: Lau_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:31 Chousuke: isn't pmap intended for heavy functions.

16:32 hiredman: Chousuke: predicates can be heavy

16:32 Chousuke: hmm, I guess.

16:32 Chouser: (defn all [& preds] #(every? (fn [pred] (apply pred %&)) preds))

16:32 Chousuke: not very often though

16:34 maybe "all" is not a very good name though. "andf"?

16:34 hiredman: if you name the predicates you are going to filter by, (filter (comp p1 p2 p3 p4) seq)

16:35 Chousuke: does that work? what if one of the predicates returns true instead of the object?

16:35 slashus21: It doesn't seem to work.

16:35 hiredman: oh

16:35 duh

16:35 tsdh: Hi. Is there some debug support for stepping through a function (preferably with slime).

16:36 hiredman: clojurebot: filter is not map

16:36 clojurebot: Alles klar

16:36 slashus21: The first function Chouser suggested works, I think.

16:37 Chousuke: are there any more generic second-order predicates that might be useful? :/

16:37 slashus21: It has to pass every test in the list of predicates.

16:38 Chousuke: I really can't think of anything other than or and and :P

16:38 Chouser: doesn't perl6 have something like this?

16:38 Chousuke: xor too :)

16:42 Chouser: I was thinking of this, but now think it's different from what we're doing: http://en.wikipedia.org/wiki/Perl_6#Junctions

16:44 slashus21: so any?

16:45 That is a little different.

16:45 Chousuke: Chouser: interesting

16:46 looks a bit like algebraic data types :p

16:50 Chouser: perl6 was my favorite vaporware for a long time. ...haven't evaluated it recently.

17:15 there's not a 'alter' or 'update' fn for thread-local bindings, is there? Just 'set!'.

17:16 * kotarak misses update-in / ???? as in get-in / get or assoc-in / assoc

17:18 Chouser: yeah, I've used update-in with a vector of length 1

17:20 kotarak: me too

17:38 Chouser: there's nothing like = that returns the value, is there?

17:39 (let [x foo] (and (= x bar) x)) ; bleh

17:39 oh, that's not what I want anyway.

17:40 Chousuke: Chouser: would not be very nice for (= nil nil) :)

17:40 Chouser: indeed!

17:40 nor false, of course.

17:41 but actually I want the equivalent for not=

17:41 which also makes it non-commutative. :-P

17:41 * Chouser gives up.

17:47 Lau_of_DK: I have a large hash-map in memory, can I get the physical size of it ?

17:48 Chouser: not as far as I know.

17:49 there are various memory heap analysis tools that can tell you how much memory is consumed by instances of each class

17:49 Lau_of_DK: k - 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:53 hiredman: have you seen http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html#cms.oom

17:53 Lau_of_DK: not yet, but thx

17:55 slashus21: 3M means 3 million?

19:10 brennanc: hello 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:12 hiredman: there 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:13 jetty is most likely the easiest way to get started

19:13 brennanc: thanks

19:13 hiredman: but I haven't used compojure in a few months

19:13 brennanc: is a serious server though or is it just a toy to develop on I guess is what I'm wondering

19:13 I'm not all that familiar with java servers. My background is mostly the LAMP world.

19:13 hiredman: I think the jetty website very much makes the claim that it is a real webserver

19:14 albino: there are real production websites using it

19:15 hiredman: I have a apache proxy access to my jetty instance, but it is *very* low traffic anyway so, I dunno

19:15 albino: hiredman: ajp?

19:15 hiredman: albino: ?

19:16 albino: I thought the way to have apache talk to java server was a protocol called ajp, nevermind

19:16 hiredman: oh

19:16 no, http proxy

19:16 proxypass or whatever it is called

19:16 albino: regular reverse proxy

19:17 hiredman: yeah, it's nice, I can have jetty run on whatever port and play with whatever

19:17 brennanc: I was forwarding to glassfish that way as well

19:17 mod_proxy in apache that is

19:17 hiredman: http://www.webtide.com/choose/jetty.jsp <-- jetty vs. tomcat

19:18 albino: yeah, I was thinking of mod_ajp

19:19 maybe it's tomcat specific

19:31 hiredman: woa

19:32 http://groups.google.com/group/clojure/browse_thread/thread/1ebe3c8f342f3abe?hl=en <-- z/OS

19:37 I wonder how many decades will go by before everyone is on the unicode bus

19:38 and new vim clojure with nails goodness

19:39 kotarak: finally...

19:39 hiredman: :)

19:39 kotarak: I hope releasing at half past midnight is not a bad idea....

19:39 hiredman: it's 4:41pm

19:40 kotarak: Anyway. I go to bed now, and wait for the bug reports tomorrow. ;)

19:41 .. eh today..

19:41 * hiredman looks for nailgun

19:41 kotarak: is included

19:41 http://www.martiansoftware.com/nailgun/

19:42 hiredman: I was looking in ports, but it is not there

19:42 kotarak: dunno. It's included in the vimclojure distribution anyway.

19:44 hiredman: oh

19:44 Well Then

19:44 albino: does that still work? I heard it was unmaintained

19:44 kotarak: Nailgun? Well. It works. :)

19:45 albino: hmm... 2005 maybe you are right.

19:45 hiredman: what is this .exe thing?

19:45 kotarak: It's for the Windows users.

19:46 Unix/Mac builds its own ng. That is the nailgun client.

19:50 hiredman: any initial problems?

19:51 hiredman: kotarak: oh, uh, I just untared it

19:51 I am going to wait till I get home to try it out

19:51 kotarak: Ok.

19:51 No hurry.

19:52 Gotta go now. Bye.

19:58 brennanc: the default JVM that comes with the macs are extremely slow compared to the linux version. wonder why that is.

19:59 hiredman: it might be a -client vs -server thing

20:03 brennanc: I'll give it another try when I'm home, that might be the case.

20:07 slashus21: Isn't the jvm that comes with macs still at 5?

20:07 That may not be the case with leopard.

20:07 danlarkin: leopard comes with 1.5 yes

20:10 slashus21: There are probably performance gains between 5 and 6.

20:11 arohner: there is an official download for java 6 on 10.5

20:11 for intel 64-bit

20:46 is (/ x y) exactly as fast as x / y in java?

20:47 nm, (source /) answers my question

20:48 danlarkin: you might want unchecked-divide

20:48 arohner: danlarkin: thanks

20:54 ayrnieu: slashus - ABCL sees performance degredation on java 6 through release 10, which... is only a little inferior.

21:00 Raynes: Why can you only recur from the tail position?

21:01 slashus21: ayrnieu: Any idea why there was a performance degredation?

21:01 ayrnieu: slashus - no.

21:02 Raynes - you can recur from any position, but you can only (recur ..) from a tail position.

21:03 lisppaste8: Rayne pasted "Towers of hanoi" at http://paste.lisp.org/display/76793

21:03 Raynes: Well, the reason I was asking is I was trying to do that ^ using recur.

21:03 ayrnieu: which is to say, "I was trying to do that ^ uing tail calls."

21:04 slashus21: tail recursion makes your function act as a loop.

21:04 It wouldn't make sense in this condition.

21:04 arohner: Raynes: 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:05 Raynes: I understand.

21:06 lisppaste8: Rayne annotated #76793 "Updated tower of hanoi" at http://paste.lisp.org/display/76793#1

21:07 slashus21: ..

21:31 hiredman: Raynes: now do it with each agents

21:31 dnolen: for 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:31 Raynes: hiredman: WHat?

21:31 hiredman: ~def trampoline

21:31 Raynes: do it with agents

21:32 Raynes: I don't know what an agent is. I just translated the common lisp implementation. I haven't read the /entire book/ yet.

21:32 dnolen: hiredman: doesn't quite answer my question, i've referred to the docs

21:32 replaca: Q: How do you get a symbol from a var? That is, #'foo -> 'foo?

21:33 hiredman: dnolen: I just wanted a look at the source

21:33 replaca: I don't think you can

21:33 dnolen: hiredman: oops sorry :)

21:33 replaca: :-(

21:33 hiredman: ok, thanks

21:33 hiredman: dnolen: trampoline is just another function

21:33 Raynes: ,(var (def x 1))

21:33 clojurebot: DENIED

21:34 Raynes: clojurebot just showed me who wears the pants in this relationship.

21:34 hiredman: ,`trampoline

21:34 clojurebot: clojure.core/trampoline

21:34 hiredman: ,(find-var `trampoline)

21:34 clojurebot: #'clojure.core/trampoline

21:35 hiredman: ,(map #(.getName %) (.getMethods (class (find-var `trampoline))))

21:35 clojurebot: ("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:35 Raynes: hiredman: Ohh pretty.

21:36 gnuvince_: (doc find-var)

21:36 clojurebot: Returns the global var named by the namespace-qualified symbol, or nil if no var with that name.; arglists ([sym])

21:36 hiredman: ,(filter #(not= % "invoke") (map #(.getName %) (.getMethods (class (find-var `trampoline)))))

21:36 clojurebot: ("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:36 gnuvince_: Interesting the things you can do when you know Java ;)

21:36 hiredman: I tell you what, you learn more java mucking around with clojure...

21:37 Chouser: word

21:37 Raynes: word

21:38 dnolen: hiredman: short answer is yes, calling trampoline within a trampoline grows the stack, makes sense.

21:38 I suppose there's no way to know if you're in a recur?

21:38 replaca: that's the nature of the repl language, you spend a lot of time exploring your world

21:38 Raynes: dnolen: If you keep repeating yourself you know.

21:38 dnolen: If you keep repeating yourself you know.

21:40 dnolen: Raynes: heh, so I suppose there's not.

21:42 timothypratley: Hi - I'm trying to use vimclojure, anyone know how to make it use ng.exe instead of ng?

21:42 replaca: hiredman: so it looks like the var really has no idea what it's symbol name was

21:42 hiredman: that would kind of indicate that there is a way for two symbols to point at the same var

21:43 hiredman: replaca: I would imagine there is a way

21:43 replaca: time to UTSL again, I think, though I don't really need that feature right now

21:44 Raynes: What is the symbol name of a var?

21:44 Call me stupid, but I'm not sure what you mean. I think I do however.

21:45 replaca: when I use a symbol like foo in (def foo 7), foo is pointing to a var object (specified by #'foo or (var foo))

21:46 I always thought that the symbol and its var were inextricably linked, but that appears not to be true

21:48 Chouser: the var points to its name symbol, namespace symbol, and value

21:49 you can find the var by looking up the symbol in a namespace

21:53 anyone here at looked at Compiler.java at all?

21:54 duncanm: replaca: heh, nice nick

21:54 isn't it rplaca, though?

21:59 slashus21: MAX_POSITIONAL_ARITY = 20 would mean that you can have at most 20 named arguments?

22:08 Chouser: I think that's correct.

22:09 but you can have unlimited 'rest' args.

22:09 duncanm: Cjptjat

22:09 eek

22:09 Chouser: that's because it's just an array, right?

22:10 Chouser: no, clojure varargs are a seq

22:10 so it can be infinite

22:10 duncanm: okay, a seq, but a collection nevertheless

22:10 brennanc: if you use a seq that's only one param

22:11 where did you see the MAX_POSITIONAL_ARITY? what is that from?

22:11 Chouser: ,(let [nth-arg (fn [n & args] (nth args n))] (apply nth-arg 99 (iterate inc 44)))

22:11 clojurebot: 143

22:12 * hiredman struggles with vimclojure

22:13 * Raynes doesn't struggle with enclojure

22:13 slashus21: hiredman: I am playing with vimclojure too. I am getting errors at the start.

22:13 Raynes: Have you figured out how to insert code while your program is running?

22:13 * Raynes gives hiredman a "nah nah na nah nah" look.

22:13 Raynes: slashus21: Haven't needed too.

22:14 Haven't desired too.

22:14 slashus21: Raynes: I was playing with an irc bot and it would be nice to change functions while it is running.

22:15 Raynes: I tend to actually compile my code. hiredman took an alternate route :>

22:15 hiredman: clojure is always compiled yo

22:15 slashus21: Well it is just dynamic compilation.

22:15 Still compiled.

22:15 Just more flexible.

22:15 hiredman: How do you load code while your bot is running?

22:16 hiredman: anyway, gen-class just makes stubs that dispatch to fns

22:16 slashus21: I have a repl

22:16 of course

22:16 slashus21: slime?

22:16 hiredman: just clojure.main

22:17 clojurebot: emacs?

22:17 clojurebot: but I like using notepad++!

22:17 slashus21: hehe

22:17 I don't use slime either.

22:17 How to you run the program and run a repl as well?

22:18 hiredman: clojure.main -i file.clj -r

22:19 slashus21: I have a bot running through enclojure, I think the dynamic compilation will better suit my purposes.

22:26 hiredman: Do you have to manually switch to the proper namespace?

22:28 yea, that worke.d

22:52 arohner_: does anyone have experience with using a java profiler in clojure?

22:53 I'm trying visualvm, but it seems to have issues with the clojure classload being GC'd

23:11 replaca: duncanm: (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:21 Chouser: is 'parse' some kind of builtin?

23:21 I'm getting a really weird error.

23:22 duncanm: heh

23:23 is there a way to define a class and methods in Clojure?

23:23 replaca: Chouser: it's not in clojure.core

23:23 duncanm: gen-class

23:23 cmvkk: gen-class or proxy

23:24 replaca: duncanm: or you can use proxy if you just need to define something that matches an interface

23:25 Chouser: I don't even have parse from the repl. where are you getting it?

23:26 Chouser: I must be confusing myself somehow.

23:27 I'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:27 and vim colors parse like a builtin -- I'm sure that's not helping see the real problem.

23:29 cmvkk: what's the error?

23:29 Chouser: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.String

23:30 cmvkk: heh, well, at least it's obvious what the error means

23:30 Chouser: yes, but there are no keywords or strings on that line. :-P

23:30 I have to trim this down before anyone will be able to help me.

23:30 I'm sure it's something dumb..

23:32 cooldude127: who here uses gorilla and vim for clojure?

23:32 Chouser: gah. the line works at the repl.

23:33 cooldude127: and is willing to explain just how you set it up. cuz i can't even get the vimclojure part to work

23:33 hiredman: me neither, actually

23:34 replaca: Chouser: what's the multimethod discriminating on?

23:34 Chouser: that would be my first suspect

23:36 Chouser: ah, I had a try/catch block that was getting in the way

23:37 replaca: Chouser: so much for guessing in the dark :-)

23:38 Chouser: heh, yeah, I wasn't giving you nearly enough to go on.

23:39 replaca: that's always the way at the beginning

23:39 Chouser: woohoo!

23:40 cooldude127: ok, 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:40 Chouser: ok, enough for now. g'night, all!

23:42 arohner_: night

23:46 cooldude127: i get a bunch of undefined function and etc errors everytime i load a clojure file in vim

23:46 hiredman: you must be missing some files

23:47 I don't even get that

23:47 :(

23:48 cooldude127: yeah, 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:49 hiredman: does the repl work now?

Logging service provided by n01se.net