#clojure logs

2009-11-03

00:00tomojhuh
00:00tomojnot for max or +, right?
00:01hiredmanno
00:01hiredmannot for operations over sequences
00:01hiredmanbut just for functions that take a lot of args
00:01tomojah
00:02hiredmanhttp://gist.github.com/178350
00:03hiredman(sched/fixedrate {:task #(dump-dict-is config) :start-delay 1 :rate 10 :unit (:minutes sched/unit)})
01:35adityo~max people
01:36hiredmanwow
01:37hiredmanclojurebot is flipping out
01:41hiredmanoh
01:44j3ff,(. Math abs (/ 5 2))
01:44j3ffoops
01:45j3ffsaw ato do that ;P
01:45j3ffanyone know why the math abs function doesnt work on a fraction?
01:46j3ff,(. Math abs -5)
01:46clojurebot5
01:46_atoMath is a java library and doesn't know anything about fractions
01:46_ato,(. Math abs (float (/ 5 2)))
01:46j3ffic
01:46clojurebot2.5
01:46j3ffthanks
01:46_atothough
01:47_atothat doens't help if you want a fraction
01:47j3ffno i just need the value
01:47_atohmm.. I wonder if...
01:48_ato,(clojure.contrib.math/abs (/ 5 2))
01:48clojurebotjava.lang.ClassNotFoundException: clojure.contrib.math
01:48j3ff,(use 'clojure.contrib.math)
01:48clojurebotnil
01:48j3ff,(clojure.contib.math/abs (/ 5 2))
01:48clojurebotjava.lang.ClassNotFoundException: clojure.contib.math
01:49_ato,(abs (/ 5 2))
01:49clojurebot5/2
01:49_atoyeah
01:49_atothere we go
01:49j3ffhaha cool
01:49tomoj,(abs (- (/ 5 2)))
01:49clojurebot5/2
01:49tomoj~def abs
01:50tomojI just searched youtube for "did clojure kill god"
04:44ordnungswidrighi all
04:47zefhemelhello
05:59krumholthi i am using emacs with clojure-mode and i have a java application i like to extend from clojure. this application will create a window and call exit on close when closed. This will also terminate slime. does anyone know a way to prevent this? it's very annoying in testing
06:02raekdon't call exit?
06:02raekmaybe you could just close/hide the window
06:03krumholtraek, the application will call exit. it's a java application and i can't change that
06:04krumholti want to "capture" it or something if possible :)
06:09CalJuniorI trying to port some Java code to Clojure and have rather basic question. I would like to declare a new variable 'client' of type 'EClientSocket' (a class from the API I am implementing). The Java code is: EClientSocket client = new EClientSocket(this);
06:11CalJuniorI tried (let [client (.EClientSocket this)]) which throws an exception. Unable to resolve symbol: this in this context (NO_SOURCE_FILE:19)
06:11rfgpfeifferwhat is this in this context?
06:11CalJunior(typo: I AM trying to port …)
06:11CalJuniorgood question
06:12rfgpfeifferthis refers to an object, which class are you in?
06:12CalJuniorThe class is called Wrapper
06:13rfgpfeifferyou have to pass the instance of wrapper explicitly
06:13CalJuniorThis is what I did. (ns TestJavaClient.Wrapper
06:13CalJunior (:gen-class
06:13CalJunior :name TestJavaClient.Wrapper
06:13CalJunior :implements [EWrapper]
06:13CalJunior )
06:14rfgpfeifferthat's not what i mean
06:14rfgpfeifferwhat does 'this' refer to in the java version?
06:15CalJuniorThat's one of the problems. I do not know. I think it refers to an object in the API library.
06:15CalJuniorDid I already tell you I am a Java newbie? Now you know.
06:16krumholtCalJunior, May I ask why you want to port that Java Code?
06:16CalJuniorI would like to implement a Java API in Clojure.
06:17CalJuniorI have the code of a demo test client in Java.
06:17CalJuniorI am trying to port this to Clojure so I can learn how to interop with Java.
06:18CalJuniorI am more than a bit out of my depth here.
06:19krumholtCalJunior, I am not sure porting something you don't fully understand will provide a very good learning experience.
06:19CalJuniorYou might be right.
06:22CalJuniorLast try: I found the 'this' object in the ESocketClient source file: m_reader = createReader(this, new DataInputStream(
06:22CalJunior socket.getInputStream()));
06:24raekCalJunior: (.Class x) and (Class. x) is not the same thing
06:24raek(Class. x) becomes (new Class x)
06:25CalJuniorSo I should do: (let [client (EClientSocket. this)])
06:25CalJunior?
06:26CalJuniorSame exception, I tried: (let [client (EClientSocket. [])]). Now I get java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to com.ib.client.AnyWrapper (NO_SOURCE_FILE:0)
06:26krumholtno you must replace this with an object you are refering to. In java "this" refers to the class itself
06:26CalJunioraha
06:27krumholtyou might wanna read http://java.sun.com/docs/books/tutorial/java/javaOO/thiskey.html
06:27CalJuniorthanks krumholt.
06:27CalJuniorand raek
06:27CalJuniorand rfgpfeiffer
06:28raekCalJunior: (let [client (EclientSocket.)])
06:28CalJuniorraek: with that I get: java.lang.IllegalArgumentException: Unable to resolve classname: EclientSocket (NO_SOURCE_FILE:23)
06:29raekoops, EClientSocket
06:29raekcapial C
06:29raek*capital
06:29CalJunioroops. now I get: java.lang.IllegalArgumentException: No matching ctor found for class com.ib.client.EClientSocket (NO_SOURCE_FILE:24)
06:29raekwhat arguments does the constructor of EClientSocket take?
06:30CalJuniorgive me a second ...
06:31CalJunior public EClientSocket( AnyWrapper anyWrapper) {
06:31CalJunior m_anyWrapper = anyWrapper;
06:31CalJunior }
06:31CalJuniorThis is AnyWrapper
06:31CalJuniorpublic interface AnyWrapper {
06:31CalJunior void error( Exception e);
06:31CalJunior void error( String str);
06:31CalJunior void error(int id, int errorCode, String errorMsg);
06:31CalJunior void connectionClosed();
06:31CalJunior}
06:31CalJuniorhope this helps
06:33CalJuniorthe 'public EClientSocket(…' method (?) is part of the EClientSocket class: public class EClientSocket {
06:33CalJuniorif that makes any sense.
06:35krumholtit means it is a constructor not a method
06:35CalJuniorok. thanks.
06:36cemerickanyone here use clojure.contrib.logging? I'm getting logger names like "clojure.contrib.logging$fn__2450$impl_write_BANG___245", as warned in the ns docs.
06:36raek(let [wrapper (proxy [AnyWrapper] [] (error [e] ...) (error [id error-code error-msg] ...) (connectionClosed [] ...))]
06:37raekor something similar
06:37raekpass that to the constructor
06:37CalJuniorok, thanks raek.
06:38raekyou have to create something that implements the AnyWrapper interface
06:38raekproxy does that
06:38CalJuniorOK, it is becoming a lot more clear now. I think I will have to chew on this for a while. Will get back if I make progress.
06:38raek(let [client (EClientSocket. wrapper)] ...)
06:39CalJuniorCouldn't I just call (proxy [AnyWrapper]) as an argument to ESocketClient.?
06:40CalJuniorGuess I can't: java.lang.Exception: Can't take value of a macro: #'clojure.core/proxy (NO_SOURCE_FILE:29)
06:41raek,(doc proxy)
06:41clojurebot"([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which creates a instance of a proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, must be first. If not provid
06:41raekyou have to provide an implementation of the methods specified in the interface
06:42CalJuniorok, that's clear. thanks again.
06:42CalJuniorSo this means I would need to port (parts of) the API libary to Clojure as well.
06:43CalJuniorWas hoping to avoid this.
06:43CalJuniorAnyWrapper.java is part of this API.
06:44Chousukeyou should be able to call proxy directly to get an instance :/
06:44ChousukeI don't see why (Foo. (proxy ...)) wouldn't work. Maybe there's something wrong with your form?
06:45CalJuniorI've done (Foo. [proxy …])
06:46Chousukewell, no wonder :)
06:46CalJunior(let [client (EClientSocket. (proxy AnyWrapper))])
06:47yasonCalJunior: I've never needed anything but a proxy for java class/interface interop.
06:47CalJuniorthat's good news yason.
06:47ChousukeCalJunior: the interfaces need to be in a vector, but an empty proxy like that doesn't make sense.
06:47raekCalJunior: you'll have to give some instance of AnyWrapper to the constructor
06:48raekwhat did you pass in your java code?
06:48ChousukeCalJunior: why would you proxy AnyWrapper if you're not defining any of its methods?
06:50CalJuniorThe ESocketClient class contains the ESocketClient constructor (AFAI understand it). public EClientSocket( AnyWrapper anyWrapper) {
06:50CalJunior m_anyWrapper = anyWrapper;
06:50CalJuniorThe constructor takes AnyWrapper as its argument.
06:51raekto use that class, either in java or in clojure, you'll have to pass a AnyWrapper as an argument
06:51raekso how did you implement AnyWrapper in java?
06:51CalJuniorThere is no reference to AnyWrapper in the demo client code that I am trying to port to Clojure here.
06:52raekcan you post a link to that code?
06:52Chousukemaybe it's indirectly used.
06:52CalJunior private AnyWrapper m_anyWrapper; // msg handler
06:52Chousukeie. the demo code inherits/implements something that implements/extends AnyWrapper
06:53CalJunior public EClientSocket( AnyWrapper anyWrapper) {
06:53CalJunior m_anyWrapper = anyWrapper;
06:53CalJunior }
06:53CalJunior
06:53Chousukethat's not the interesting code
06:53CalJuniorChousuke: exactly
06:53CalJunioroh
06:53Chousukeis there no place where the EClientSocket constructor gets called?
06:54Chousukebut I suppose you'll want to proxy AnyWrapper and implement its methods in your clojure code.
06:55Chousukethat'd be similar to creating a class and having it extend AnyWrapper in Java
06:55CalJuniorChousuke: yes: that's the line of java I am trying to port. EClientSocket client = new EClientSocket(this);
06:55Chousukeah. so the class you're reading implements AnyWrapper
06:55CalJuniorYes
06:56CalJuniorIf you want/like to have a look, the code is all public. So you can see the bigger picture. I realise I am asking a lot.
06:57Chousukeyeah, then you'll want to use proxy so that (defn make-my-whatever [arg arg2] (proxy [AnyWrapper] [] (anywrapperMethod1 [foo bar] (dostuff)) (anywrapperMethod2 [foo bar] (domorestuff arg1 arg2))))
06:57Chousukethen (ESocketClient. (make-my-whatever foo bar))
06:58Chousukethe make-* is a factory function for creating instances of your proxy, and the proxy closes over the arguments to the factory function, so you can use them in the method implementation if you need to
06:59CalJunior,(doc make-)
06:59clojurebotIt's greek to me.
06:59ChousukeI just defined it :)
06:59CalJunior,(doc make-*)
06:59clojurebotExcuse me?
06:59Chousukeit's make-my-whatever. it's not a core function :P
06:59Chousukeit's just a whatever name
07:00CalJuniorOh, sorry. Thought it was a Clojure expression.
07:00Chousukeand I was too lazy to type so I abbreviated it to make* :P
07:00Chousuke+-
07:00CalJuniorClear
07:00Chousukedidn't save me much typing in the end though :D
07:01Chousuke(moral of the story: don't abbreviate out of laziness)
07:01CalJuniorWould you want to have a look at the code I'm porting?
07:01ChousukeI don't have the time right now. Class starts in 15 minutes.
07:01krumholt_what time is it?
07:02Chousukehere? 14:02 :P
07:02CalJuniorOK, thanks for the advice Chousuke. Very helpful.
07:02krumholt_i am always forgetting differnet time zones
07:02CalJunioralso krumholt and raek.
07:03CalJuniorI think I have my work cut out for me for the afternoon. :-)
07:29AWizzArdStrange, my clojure-contrib does not compile to .class files. I do ant -Dclojure.jar=../clojure/clojure.jar and this produces the clojure-contrib.jar, and that jar contains many .clj files. When I give a wrong part to the clojure.jar I get warning. Is there something else I need to do to aot-compile?
07:29AWizzArdI am using the NEW branch of Clojure.
07:33AWizzArdIt contains *some* .class files, but by far not everything. The clojure-contrib.jar has a size of 567 kb.
07:34AWizzArdAnyone else here who has a fresh checkout of Clojures NEW branch and master of Contrib?
07:37gerry`my clojure-contrib.jar is 3252kb
07:38AWizzArdYes, sounds realistic, as it should be.
07:40gerry`i have setup clojure-new and clojure-contrib-new dirs
07:40gerry`new branch use the two dirs
07:41gerry`last compile was after deftype case are out
07:42gerry`it worked
07:42_atoAWizzArd: sure you're not looking at the slim jar?
07:43gerry`what's wrong with slim.jar?
07:43AWizzArd_ato: yes, I am sure. I also have the slim, and that file is even smaller (as expected).
07:43_atoah wait, new branch, I didn't see that
07:43AWizzArdI am inspecting the build file of Contrib.
07:44AWizzArdThe clojure.jar file looks as expected, that's fine.
07:44gerry`clojure-contrib-slim.jar is 284kb on my box
07:45_atoah yes
07:45_atoI get the same with HEAD of new branch
07:45_atoguess (compile) is broken
07:46AWizzArdSo, _ato, I interpret from what you said that you also get a smallish clojure-contrib.jar when you give the path to NEW clojure.jar during ant'ing it?!
07:46_atono wait
07:46_atoI'm being stupid
07:46_atohad the path wrong
07:47_atono I get a full 3.3MB clojure-contrib.jar
07:47_atoAWizzArd: did you ant clean ?
07:48AWizzArdyes, I did a clean
07:49AWizzArdIt says it compiles: pprint.ColumnWriter pprint.PrettyWriter fnmap.PersistentFnMap condition.Condition jmx.Bean
07:49AWizzArdin compile_classes
07:49_atothen there should be a seperate compile_clojure task
07:50_atowhich takes a while
07:50_atoit doesn't print out the name of everything it compiles
07:50_atojust says: [echo] Locating namespaces to compile ...
07:50_atothen: [echo] Compiling Clojure namespaces ...
07:50AWizzArdyes
07:50AWizzArdbut this guy seems to be doing nothing for me
07:51_atoweird
07:52AWizzArdAre you on Windows XP?
07:54_atoUbuntu x86 with Sun Java 6 update 16
07:55AWizzArdXP x86, also with that JDK
07:56AWizzArdIt‘s this compile_clojure step which does not compile anything for me.
08:00gerry`i'm update new branch now
08:02_atoAWizzArd: you could try compiling manually. try something like: java -cp /path/to/clojure.jar:clojure-contrib/src:clojure-contrib/classes clojure.main -e "(compile 'clojure.contrib.seq-utils)"
08:03_ato(with paths and whatever appropriately adjusted to however you'd write that on windows)
08:03gerry`it worked perfectly
08:05AWizzArd_ato: well yes, manual compilation works.
08:06AWizzArd39 .class files for seq-utils were produced.
08:06_atohmm, guess it's probably an ant problem then
08:06AWizzArdgerry`: are you also under Windows XP?
08:06_atoI've got ant 1.7.1
08:06gerry`no,i'm using ubuntu 9.10
08:06gerry`why use winxp?
08:07gerry`winxp sucks :)
08:09AWizzArdI also use ant 1.7.1 and XP is installed at my computer for work.
08:09_atoant -v -Dclojure.jar=../clojure/clojure.jar compile_clojure
08:09_ato^ makes it print out all the files it finds to compile
08:13AWizzArdyes, but it only finds those 5 which I reported above.
08:14AWizzArdvery strange
08:19gerry`AWizzArd: delete them and reinstall
08:20gerry`to see if it work
08:20AWizzArdWorks fine for compiling clojure.jar
08:22AWizzArd1823 kb for me (NEW branch)
08:23gerry`here is 1740
08:23gerry`oops, New is 1834 right
08:24AWizzArdvery comparable
08:29gerry`AWizzArd: are you using jre or jdk?
08:29AWizzArdI can manually add all namespaces to the compile_classes task.. that works *sigh*
08:29AWizzArdjdk
08:30gerry`ant problem?
08:31AWizzArdseems so
08:31AWizzArdOr at least the build file needs something to work under Windows as well.
08:38weissji'm trying to write my own "primes" function that returns an inf seq. i wanted to implement it so that it uses its own earlier primes to calculate later primes. the implementation in contrib doesn't do this though, and there's a comment saying that it can't be done efficiently that way. can someone explain a) how to do it that way, even if it's slow, and b) why its not efficient? i thougght lazy seqs were great for this sort of thing
08:44chouserweissj: I think that comment may be referring to the fact that you'd need to store all of the previous primes somewhere anyway, so there's not much value in making it a function vs a lazy seq. But I'm not quite sure.
08:46weissjchouser: i was thinking that a lazy seq should cache its results so that the function that returns primes could call itself efficiently, as long as it only wanted values that had already been calculated
08:46weissjdon't clojure lazy seqs do this?
08:47weissjhalloway's book implies that they do - let me find the paragraph
08:47chouseryes, clojure lazy seqs cache their values, which the contrib primes definition takes advantage of.
08:48weissjchouser: what do you have to do to take advantage of the caching? it seems like my function that returns a lazy seq of primes, there's no caching between calls to the fn
08:48AWizzArddon't lose the head of the seq
08:48chouserwell it has to be the same seq for it to find the cache
08:49weissjAWizzArd: i see - so clojure doesn't realize that my fn returns the same seq every time, i have to use literally the same seq
08:50AWizzArdIt's important that lazy-seqs can be GCed. Imagine you map over a lazy seq that contains 100 GB of data. I have similar cases, and my program runs with constant memory needs.
08:50chouserwhich I think is what the comment before contrib primes is talking about -- it's got to hang on to the same seq object anyway, so might as well store it in a var name 'primes' rather than making a function public.
08:50AWizzArdweissj: there is already something for memoization, in Contrib. So, with that there would remain a pointer to the seq that you created the first time.
08:52weissjchouser: AWizzArd: ok, so my mistake was to call primes a fn, i could just call it a var.
08:52AWizzArdyes!
08:52weissjok, i'll see what i can do with that. thanks!
08:53Chousukestoring an infinite lazy seq in a var is generally bad style though.
08:53Chousukesince it'll never be gc:d, and might grow massive :P
08:54weissjChousuke: well, if you suppose that any consumer of this 'primes' var really needs to know these primes, the gc will never know when the consumer is done asking for them, so it kinda makes sense
08:55weissjseems like the only other choice is to recalculate the seq
08:55AWizzArd,(doc if-let)
08:55clojurebot"([bindings then] [bindings then else & oldform]); bindings => binding-form test If test is true, evaluates then with binding-form bound to the value of test, if not, yields else"
08:55AWizzArdWhat is oldform?
08:55AWizzArd,(if-let [x 1] :a :b :c)
08:55clojurebotjava.lang.IllegalArgumentException: if-let requires a vector for its binding
08:58cgrandAWizzArd: in distant times, (if-let [x y] a b) was written (if-let x y a b)
09:00AWizzArdi see
09:00AWizzArdcgrand: are you using Windows XP?
09:02cgrandAWizzArd: no, why?
09:04AWizzArdWould be great if someone with Windows XP and ant 1.7.1 could confirm that clojure-contrib won't aot-compile everything, resulting in a smallish clojure-contrib.jar file.
09:12AWizzArdrhickey: can we maybe have a without-exception macro? :)
09:12AWizzArd(defmacro without-exception [& body] `(try ~@body (catch Exception _# nil)))
09:16AWizzArdsomething like CLs ignore-errors
09:16rhickeyAWizzArd: sounds evil
09:17chouserlooks like the checked-exception hacks in nearly every bit of Java example code out there.
09:18AWizzArdMaybe this is more domain specific when writing a web app with Compojure *shrugs*
09:18rhickeyexcept we don't have checked exceptions to work around in Clojure
09:19AWizzArdthis ignore-errors is nice when working with when-let or if-let
09:19chouserAWizzArd: why?
09:19chouseroh, to get 'nil' instead of an exception. hm.
09:21cemerickoh, dammit, I got caught by not explicitly capturing the value of a bindable var before returning a lazy seq. :-(
09:22AWizzArdIn Compojure for example a request could get stopped by exceptions, returning debug output to the enduser. Trying to parse json can result in an exception or lots of error checking code. It's nice when the json parser just returns nil (for my case).
09:22_atoit's not something you'd want to do commonly enough to justity shortening with a macro IMO
09:23_atoand it's bad to be in a habit of catching all exceptions rather than just the ones you want to deal with
09:26AWizzArdFor the general case I agree.
09:26djorkso my friend says: "so why would you use a language that no one else is taking seriously"
09:26chouserbait
09:26AWizzArdyup ;)
09:27AWizzArdI'm fast outta here
09:29krumholt_does clojure need an installed jdk to work or is a jre enough?
09:29chouserkrumholt_: jre is sufficient unless you want to build clojure itself.
09:29krumholt_chouser, ok thanks
09:30djorkchouser: he's baiting me
09:31chouserdjork: yes
09:31djorkk
09:31djorkjust didn't want people to think I was baiting the channel
09:31AWizzArdgood
09:31chouserdjork: did you run away? or ask who's opinion is so important he didn't question it?
09:31djorkheh heh
09:31chouserdjork: oh, yes, I didn't think that. You've been here enough. :-)
09:31djorkI don't know of many people who aren't taking Clojure seriously
09:32AWizzArdAnyone here who worked with Contribs logging module?
09:32aatifhI have a hash map like {"bar" {"foobar" "foo"}} and to convert into {"foobar" "foo", "name" "bar"}
09:32cemerickAWizzArd: I was just looking at it now.
09:33cemerickif one is AOT-ing code, that's when "macro-expansion-time" is, right?
09:33chouserI see posts from people who dismiss Clojure pretty easily, but those strike me more as matters of taste than not taking it seriously.
09:33AWizzArdcemerick: oh good, I had a short look yesterday and would now like to check it out.
09:33chousercemerick: yes, macro expansion happens more or less during compilation (slightly before for each form)
09:34chouseraatifh: your input map always has only one pair?
09:35chousercemerick: eh. let me try that again -- during AST-generation (slightly before for each form), all of which is before bytecode generation.
09:39cemerickchouser: that's what I thought.Means that one has to be careful not to AOT clojure.contrib, lest logging gets locked into a logging subsystem that isn't in the deployment environment.
09:39aatifh?
09:39cemerickI'd be happy to be proven wrong, of course.
09:39_atoaatifh: where does "name" come from?
09:39_atoor you mean that's hardcoded?
09:39AWizzArdcemerick: what is clojure.contrib.logging/*impl-name* for you?
09:39aatifh_ato, that key has to be added
09:39_ato,(into {} (map (fn [[k v]] (assoc v "name" k)) {:bar {:foobar :foo}}))
09:39clojurebot{"name" :bar, :foobar :foo}
09:39_ato,(into {} (map (fn [[k v]] (assoc v "name" k)) {:bar {:foobar :foo}, :baz {:quox :kaboom}))
09:39clojurebotUnmatched delimiter: )
09:39_ato,(into {} (map (fn [[k v]] (assoc v "name" k)) {:bar {:foobar :foo}, :baz {:quox :kaboom}}))
09:39clojurebot{"name" :baz, :foobar :foo, :quox :kaboom}
09:39aatifhchouser, yes
09:40cemerickAWizzArd: java.util.logging
09:40AWizzArdcemerick: for me it's "org.apache.commons.logging" and (impl-get-log "my.namespace") returns a Jdk14Logger. And I would love to know how I can set the current log level, or turn logging off completely.
09:41cemerickAWizzArd: setting log levels and such is totally orthogonal to c.c.logging -- for that, you need to configure the in-use logging subsystem.
09:42aatifh_ato, Thanks
10:00patricius_Hey. Very simple question: How do I make a string out of the contents of a seq? I thought that (str x) where x = ["Peter" \, "George" \, "Jack"] would yield the string "Peter,George,Jack"?
10:00AWizzArd(apply str your-seq)
10:01AWizzArd,(apply str ["Peter" \, "George" \, "Jack"])
10:01clojurebot"Peter,George,Jack"
10:01patricius_ahr!
10:01patricius_thanks!
10:02The-Kenny(I think there should be str* for that in core, writing apply is a bit annoying sometimes)
10:03patricius_yeah... I just misread the definition of str
10:03_atommm perhaps better would be string/str to match vector/vec
10:04chouserthat'd be a breaking change for str
10:04_atoI know
10:05AWizzArdin the http-agent lib (contrib) there already is a function string
10:05_atoit's just sad it'll get stuck as the odd one out :(
10:10AWizzArdcemerick: do you happen to know if all these logging libs do have ways to turn logging on/off?
10:11cemerickAWizzArd: log4j and java.util.logging both have roughly similar control mechanisms
10:11cemerickThe former is probably more powerful.
10:14AWizzArdAnd how do you get the logger object? Is it really (def my-logger (.getLogger (impl-get-log "my.namespace")))?
10:15cemerickAWizzArd: you'll have to look at c.c.logging's docs, etc. It's rolled off my stack.
10:16AWizzArdk
10:22AWizzArdrhickey: without compiling the namespace?
10:22AWizzArdoh, I see
10:23chouserrhickey: what do you mean by inline caching?
10:25rhickeychouser: swapping in a class-specific stub at (:k x) call points. Basically every deftype defines stub per field. Keyword callsites can obtain these stubs and swap them in, replacing lookup with direct call
10:26patricius_there should be no problem in having one agent creating a promise, and sending it to another agent that at some point delivers? this is one of its usage scenarios, right?
10:26chouserpatricius_: sounds good to me
10:27rhickeypatricius_: just remember that dereferencing an undelivered promise blocks
10:27chouserrhickey: That doesn't sound like the Keyword invoke method, but instead special Compiler support (:k x) calls?
10:27patricius_rhickey: yes, that is exactly why I use it
10:27patricius_:)
10:28_atorhickey: ah... that's a great idea. I had been defaulting to (x :k). I should get into the habit of (:k x) instead.
10:28rhickeychouser: yes, a ton of compiler support, still trying to access if it's worth it - case dispatch is surprisingly very good
10:28rhickeyassess
10:28chousersurely would be easier with cinc
10:30rhickeychouser: it's done, but there are some overheads - more classes being generated, some cost when not a deftype lookup (although they still trounce any more generic lookup, e.g. struct/arraymaps)
10:34djorkwhat's going on with this...?
10:34djork'`[:foo :bar]
10:34djork,'`[:foo :bar]
10:34clojurebot(clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list :foo) (clojure.core/list :bar))))
10:34djorkis that what [:foo :bar] translates to at runtime?
10:35chouserdjork: :-) what were you expection?
10:35_atohehe
10:35djorker, evaluation
10:35_atowe were talking about this yesterday or so
10:35chouserdjork: that's what `[:foo :bar] compiles to
10:35djorkgotcha
10:35rhickeyalways scary changing something so pervasively used, OTOH, getting (:field x) as fast as possible for deftypes means that independently written protocol functions have no disadvantage vs methods, i.e. not dynamic penalty
10:36chouserdjork: that's the code template for building a vector that can have expressions inserted via ~ or spliced via ~@ at runtime.
10:36_atorhickey: is this only when x is type-hinted?
10:36djorkok
10:36djorkso the reader isn't doing that translation every time?
10:36rhickey_ato: nothing to do with type hints
10:37chouserdjork: yes, that's what the reader produces when you use `
10:37djorkwell yeah, when you use `
10:37djorkbut not for every []
10:37djork` makes a template
10:37chouserrhickey: does it swap back to generic lookup of x stops being the type is was before?
10:38rhickeychouser: yes
10:38chouserdjork: right.
10:38_atoag
10:38_atoah*
10:38rhickeychouser: and subsequent to that is never quite as fast
10:38chouseroh, interesting.
10:38rhickeyI guess hotspot backs off then
10:39chouserheh
10:39rhickeywell, at that point the call site *is* polymorphic
10:40chousersure
10:41rhickeybut your basic set of functions implementing a protocol for a deftype will never be
10:42djork,(let [n 1000000] (do (time (dorun (take n (repeatedly #(do {:foo :bar}))))) (time (dorun (take n (repeatedly #(do `{:foo :bar})))))))
10:42chouserbecause the correct call site will be selected by protocol machinery first?
10:42clojurebot"Elapsed time: 1024.347 msecs" "Elapsed time: 4017.524 msecs"
10:43rhickeyits only in non-polymorphic situations that you could expect .field-like perf, after all .field is never polymorphic
10:43rhickeychouser: there will be one fault, swapping in the initial thunk, but after that it will never change
10:44patricius_perhaps I am a moron, but let's say that an agent action A creates a promise P1 and sends it off to an agent B. A then blocks until P1 is delivered, which B is responsible for. When B delivers, it sets the value of the promise to another promise P2 that it itself blocks on (by deref'ing). A then sees the new promise, performs some work and then delivers P2, which lets B continue. Is this a sure deadlock? I'm sure there is a more clever way to solv
10:44patricius_problem, so foregive me.
10:46djorkhah "perhaps I am a moron, but ... <highly intelligent discussion of advanced computing follows>"
10:46ericthorsene72291196T
10:46patricius_:P
10:46ericthorsensorry...wrong window
10:48chouserpatricius_: I'm trying to follow, but that doesn't sound like a deadlock to me.
10:49patricius_chouser: here's what I am trying to do (follows)
10:51cgrandpatricius_: is A awaiting P1 to be delivered in the same action where it sent P1 to B?
10:52rhickeypatricius_: one thing is true of promise/deliver (and dataflow vars in general) - if you've got a deadlock it will always occur
10:53djorkwell that's actually quite nice :)
10:53djorknothing worse than a non-deterministic deadlock
10:53fogus_That seems the flavor I've always experienced.
10:54patricius_I am creating a simulation of a system where you have a bunch of "processes" that each need to access certain cylinders on a disk. It is a requirement that when a process requests access to a cylinder, it blocks until it gets access. But when it *has* been given access, it is up to the process to release it again, before any other processes can get access to the disk and its cylinders. So a process blocks on a request promise, and when a "disk sch
10:54patricius_agent gets to that request, it delivers the promise, effectively giving the process access to the cylinder.
10:54patricius_*sigh* horrible explanation
10:55patricius_in any case, clojure probably doesn't lend itself well to such a scenario - but I'm investigating concurrent languages on a single, common, concurrent problem
10:56patricius_cgrand: yes, your understanding is correct
10:57chouserpatricius_: if each process will only ever have access to one cylinder at a time, is this perhaps a good scenario for a simple lock per cylinder?
10:57patricius_chouser: hmm... maybe
11:02patricius_for some reason, i can get the processes to block and unblock correctly, if I deliver the first promise directly from the REPL thread, but not when I get an agent to deliver the first promise
11:02chouserpatricius_: you're using send-off not send for these agents, right?
11:02patricius_yes
11:03cgrandpatricius_: actions dispatched to other agents are held until the current action is done so (do (send B some-action P1) @P1) blocks
11:03patricius_cgrand: ahhh.... that seems to explain it
11:03rhickey,(doc release-pending-sends)
11:03clojurebot"([]); Normally, actions sent directly or indirectly during another action are held until the action completes (changes the agent's state). This function can be used to dispatch any pending sent actions immediately. This has no impact on actions sent during a transaction, which are still held until commit. If no action is occurring, does nothing. Returns the number of actions dispatched."
11:06patricius_rhickey: you're such a genius :)
11:06patricius_rhickey: come to my university and give a talk about clojure - there are some people here that will wet their pants in excitement over clojure
11:09fogus_Sounds like an offer that can't be refused!
11:15djorkwet pants are not to be missed
11:19CalJuniorquestion on "new" vs. "old" branch: is 'this-name?' functionality in reify (like Java's 'this' for method bodies to refer to the current instance) also available in proxy?
11:24chouserwithin a proxy form, the symbol this refers to the instance that proxy returns
11:26rathore,(.getString String)
11:26clojurebotjava.lang.IllegalArgumentException: No matching field found: getString for class java.lang.Class
11:26rathore,(.getName String)
11:26clojurebot"java.lang.String"
11:26rathore,(.parseLong Long "12312232")
11:26clojurebotjava.lang.IllegalArgumentException: No matching method found: parseLong for class java.lang.Class
11:30_ato,(Long/parseLong "12345")
11:30clojurebot12345
11:31rathore_ato: yes, I'm aware of that form
11:31rathore_ato: i'm looking at http://clojure.org/java_interop
11:31chouser(. Long parseLong "12312232")
11:31chouser,(. Long parseLong "12312232")
11:31clojurebot12312232
11:32rathorechouser: under member-access, there's a general form shown as - (.instanceMember Classname args*)
11:32rathorechouser: i know that the dot operator works as u described...
11:32rathorechouser: but whats this form in the documentation?
11:32rathorechouser: (.instanceMember Classname args*)
11:32chouserinstance not static member
11:33rathorefor a Classname?
11:33rathorewhat would be an example?
11:33_ato (. (identity Classname) instanceMember args*)
11:33_atohmm
11:33chouser,(.pow 2M 2)
11:33clojurebot4M
11:33chouseroh!
11:33chouserClassname
11:33chouserhm.
11:34chouser,(.isAssignableFrom Integer Float)
11:34_atoit is somewhat misleading
11:34clojurebotfalse
11:35_atoit implies it's the instance of the class rather than the instance of the Class
11:35chouser_ato: that's ok. rathore's book will clear it up.
11:36rathorechouser: funny
11:40rathore_ato: can you elaborate on that statement?
11:41CalJuniorchouser: thanks
11:42_atoI just mean the doc is misleading. (.instanceMember Long) is like Long.class.instanceMember() in java, not Long.instanceMember()
11:42_atoit's not wrong, it uses an uppercasee "Class" meaning instance of java.lang.Class for that type
11:44rathore_ato: got you, thanks
11:45_ato,(.getMethods Long)
11:45clojurebot#<Method[] [Ljava.lang.reflect.Method;@13cc05f>
11:45_ato,(seq (.getMethods Long))
11:45clojurebot(#<Method public int java.lang.Long.hashCode()> #<Method public static long java.lang.Long.reverseBytes(long)> #<Method public int java.lang.Long.compareTo(java.lang.Object)> #<Method public int java.lang.Long.compareTo(java.lang.Long)> #<Method public static java.lang.Long java.lang.Long.getLong(java.lang.String,java.lang.Long)> #<Method public static java.lang.Long java.lang.Long.getLong(java.lang.String,long)> #<Method
11:55JomyootAny good new IDE for clojure?
11:56The-KennyJomyoot: Emacs + slime + swank-clojure :)
11:56Jomyootnot that again :(
11:56jasappdoesn't get any better
11:57ericthorsenJomyoot: We are using and developing actively the Enclojure library for this which has a Netbeans plugin www.enclojure.org
11:57JomyootI use IDEA
11:57JomyootSo unfortunate that La Clojure is not up to that level
11:59ericthorsenJomyoot: I'm playing with putting the Enclojure repls into Jetbrains clojure plugin...not sure if that is La Clojure?
11:59ericthorsenJomyoot: from here - http://git.jetbrains.org/?p=idea/clojure-plugin.git;a=summary
11:59fanaticoericthorsen: how integrated is Enclojure with the REPL. For example, do you have macroexpand support?
12:00ericthorsenfanatico: Not sure what you mean...you can call macroexpand on a form
12:01JomyootIs Compojure still THE web development tool?
12:01JomyootAnything new than that?
12:01JomyootConjure?
12:02fanaticoericthorsen: can I expand inline? Or do I have to jump down to the REPL and reload the file?
12:03ericthorsenfanatico: There are hotkeys for loading files, expressions, etc. There is no hotkey for macroexpand (that is in interesting idea). Is that what you are looking for?
12:05_atoericthorsen: with emacs/SLIME there's a hotkey for showing the macro expansion in a temporary buffer, as well as replacing the form the cursor is over with it's expansion. I guess fanatico is referring to those
12:06ericthorsen_ato: I was thinking about being able to do this from the editor...it sounds similar. We do not support that yet.
12:07cemerickI try to keep my macro-writing down to a dull roar. If ericthorsen is taking a tally, better Java-oriented code completion is more common thing to optimize on. :-P
12:08chousermacroexpansion can be useful for understanding builtin macros as well
12:08_atohehe. Both are pretty handy for debugging macros, eg you can type something out, macroexpand it and then edit the expansion and then eval to see if you fix worked, then go back to your macro and make the fix there
12:08chouserplus Yegge asked for it
12:08cemerickYegge talked about clojure?
12:09chouserno
12:09_atoaww
12:09chouserYegge talked about wanting an editor that has a macroexpand keystroke. I don't know why he thinks emacs doesn't have that.
12:11cemerickhrmph. I don't use emacs, and I knew it had that. :-/
12:11_atomaybe (e)lisp-mode doesn't have it, I don't do enough elisp to have noticed it missing
12:12chouserhttp://steve-yegge.blogspot.com/2006/04/lisp-is-not-acceptable-lisp.html
12:12tknudsenhey peeps. Anyone making constructive use of a web framework implemented in clojure?
12:12The-KennyI need a cheatsheet for slime-commands.. I always forget the shortcuts for them.
12:12chouser"If your editor knows all about macros, then you should be able to click to see the expansion, and click again to see its sub-expansions, all the way down to the primitive functions. Some editors can do this, but none of them (that I'm aware of) handle macros as cleanly or seamlessly as they do normal functions."
12:13m0smithhi?
12:13_atoThe-Kenny: there's several, just google: emacs cheat sheet
12:13tknudsenm0smith, hello
12:13fanaticoHe wrote that ~10,000 LOC js2-mode, so hopefully he'd know.
12:13m0smithI have been looking at clojure and love it
12:13m0smithThere is something that is bugging me though
12:13tknudsenwhat's that?
12:13The-Kenny_ato: I mean a small one.. I have a big one here, but I never find the command I'm searching for.
12:14The-Kennys/small/compact/
12:14m0smithI want to convert a self-referential class to clojure
12:14m0smithbut I can't seem to figure it out
12:14emitis there a way for me to break up a long string in clojure without explicitly concat'ing fragments? like using \ in makefiles or just " " " "
12:14AWizzArdcemerick: this logging module in Contrib seems to be very uninteresting. It will select by random a logging facility that happens to be in the CP.
12:14fanaticoemit: """
12:15tknudsenm0, how is self-referential different than private class? elementary question, perhaps...
12:15cemerickAWizzArd: hardly at random -- there is a defined order.
12:15emitthanks
12:15AWizzArdcemerick: the one it chose for me is not able to log :trace and :debug levels.
12:15chouseremit: strings can wrap across multiple lines, but the newline will be included
12:15emitoh ok that should be fine as well then. just an sql query
12:15_atofanatico: clojure doesn't have """ does it?
12:15AWizzArdcemerick: yes, first commons - but commons supports 7, and commons will decide which it wants to use. In my case a very lame logger.
12:15tknudsencascade or compojure? Anyone making constructive use of a web framework implemented in clojure?
12:15fanatico_ato: oops, my mistake.
12:15_atofanatico: that's just the same as "" "
12:15AWizzArdNow you have to hardwire your code to exactly that logger, very stupid.
12:16m0smithI am looking for my example
12:16cemerickAWizzArd: what logger are you getting that doesn't support trace and debug?
12:17AWizzArdcemerick: http://commons.apache.org/logging/apidocs/org/apache/commons/logging/impl/Jdk14Logger.html
12:18AWizzArdYes yes, it lists those methods. But when I call .trace or .debug on my logger then nothing happens.
12:18AWizzArdAnd the way how I can set the log level is completely different from how java.util.logging.Logger
12:18AWizzArdis doing it.
12:19cemerickAWizzArd: well, I can't speak to what commons logging is doing. But c.c.logging isn't doing anything particularly special or fancy...I very much doubt it's the one swallowing your logging msgs.
12:19m0smithfor some reason browser is not working
12:20AWizzArdIt seems the Jdk14Logger only supports four levels.
12:20cemerickI do think it would be very reasonable for commons-logging to come *last* in the resolution order, rather than first.
12:20AWizzArdyes
12:20m0smithImagine a Person that referson to mother, father and children, all of which are also Person instances
12:20m0smithrefers
12:20cemerickI keep commons logging far, far away from our new projects. PDFTextStream v2 bundles it, and it's been a constant source of frustration.
12:21m0smithIn Java that is a simple construct, but what about clojure?
12:21AWizzArdcemerick: the problem is that I have it in my CP, cause I am using htmlunit for example which has it as a dependency *sigh*
12:21_atoeven simpler because it's dynamically typed?
12:21_atoor are you talking about gen-class or something?
12:22cemerickAWizzArd: I'd absolutely +1 a patch to change the resolution order :-)
12:22cemerick(not that that means a damn thing, though)
12:22chouserm0smith: are you trying to create a Java class or just represent the same functionality in a more Clojure-oriented way?
12:22AWizzArdcemerick: do you know if the Eclipse Public License lets me take Contribs logging lib, change it, and close source the changed code in my code base with my own license?
12:22m0smithrepresent the same sort of data structure in a more clojure/funtional way. The java class is trivial
12:23_atom0smith: {:type :person, :name "Bob", :family [{:type :mother, :name "Jody"}]} ?
12:23cemerickAWizzArd: You can certainly use contrib in commercial projects without impacting the license your code is distributed under, but you can't change contrib's license itself.
12:24cemerickor, that's my understanding. IANAL, and all that.
12:24_atoor you mean self-referentia as in a cycle?
12:24_atoso Jody would also have a pointer to Bob
12:24m0smithHow do I then get Bob as Jody's child?
12:24_atoyou can't with pure immutable data
12:25_atoeither use refs
12:25_atoor use keys
12:25_atolike
12:25chouserone way is to put all the people in a map indexed by unique id or name or something, then the outbound links can have those uuids or names as their values.
12:25_ato{:type :person, :id :bob, :name "Bob", :family [:jody :phillip]}
12:25_atothis is also quite nice as it's easy to read and write
12:26m0smithso then there is a list that I look through to get :Jody?
12:27chousera map, just look it up.
12:27_atoas in: {:bob {:type :person, :id :bob, :name "Bob", :family [:jody :phillip]}, :jody {:type :mother ...}}
12:27chouser{:bob [:jody :phillip], :jody [:bob :phillip] ...}
12:28m0smithok that makes sense
12:28_atoah yep, that's nicer
12:30m0smithDifferent but related question: Can we build a binary tree in clojure?
12:31_atom0smith: as in sorted-map?
12:31_atoa binary search tree
12:31_atoor just a binary tree
12:31chousersorted-maps are a binary tree, but you could build your own with vectors as nodes for example.
12:31m0smithjust and arbitrary tree
12:31chouser[[[1 2] [3 4]] [[5 6] [7 8]]]
12:32m0smithok
12:32m0smiththanks for the help. I was trying to make it much harder
12:32chousermore efficient ways of doing this are coming. :-)
12:32m0smithI have been programming emacs for a while
12:40ozzileeI've got a question about bindings. Is there a way to bind something for an entire module? The json library in contrib will return keys as keywords if *json-keyword-keys* is true, but that means I have to either wrap every call in a (binding ...), or create a wrapper function around the function in contrib.
12:40chouserm0smith: fwiw, a tree of vectors like that can be navigated using clojure.zip, which can allow you to walk up, down, across sibilings, and make "modifications" as needed
12:44cemerickozzilee: you can manually set a root binding on the var in question, but I'd go with a wrapper fn.
12:44_ato(defn read-jason [& args] (binding [*json-keyword-keys* true] (apply clojure.contrib.json.read/read-json args)))
12:44cemerickto answer your question directly though, no, I don't think so.
12:44_atowith (require 'clojure.contrib.json.read) instead of (use)
12:47ozzileeHrm. Okay, that works, I guess. Is there a better way to do this sort of thing. I'm writing a couchdb library, and I want to be able to set the host and database name in one place instead of passing it to each function call. I could use a connection object and pass that every time, but I'd like to be able to just say, "In this module, the database name is foo".
12:49cemerickozzilee: that's what bindings are for. You *could* set up a couple of atoms for people to set their db properties in, but that will fall over pretty quickly.
12:50_atoozzilee: note that bindings are dynamic not lexical, so if you do (binding [db "somedb"] ... ) in your main function
12:50_atoit'll apply to everything in the program in the main thread
12:50_atounforunately there's not yet a good way to make them propagate across threads
12:50ozzileecemerick: Yeah, I've been using atoms, but that means the properties are set globally. Not really what I want.
12:51ozzilee_ato: Hrm, yeah, that's something to think about.
12:52cemerickfogus_: http://muckandbrass.com/web/display/~cemerick/2009/11/03/Be+mindful+of+Clojure%27s+binding
12:52cemerickfeedback welcome from everyone, of course
12:52ozzileecemerick: So would I be better off to just use a connection object and pass it to every call? I don't want to write wrapper functions in every module that uses the couchdb library.
12:52technomancywasn't clojure's artifactId going to be changed to just "clojure"?
12:52technomancyrather than "clojure-lang"?
12:53cemerickozzilee: using binding is far more idiomatic
12:54cemerickyou can provide a with-couch macro that takes db info, that makes it a little neater so people don't have to remember the name of your library's vars
12:59lisppaste8ozzilee pasted "bindings" at http://paste.lisp.org/display/89736
13:00cemerick#2 gets my vote by a country mile.
13:00ozzileecemerick: I'm not sure I'm clear on exactly what you mean, is that paste pretty much it?
13:01ozzileecemerick: Okay, that's what I thought, that's not going to use bindings though, right?
13:01Chousukeyou can even combine #2 and #1 if you have a default argument for the connection that is some bindable global var.
13:01Chousukerequires an arity overload though
13:01cemerickyeah, #2 is about as straightforward as it gets. You could make get and put support using a connection object for callers that prefer that, too.
13:01cemerickozzilee: no, #2 does use binding
13:01cemerickyou need to write a macro that does the binding.
13:03ozzileecemerick: I don't see why. couch/get would just be a function that does an http GET with the provided connection details. couch/make-connection would return a hashmap of the connection info.
13:04_atocemerick is counting from 1 not 0 :p
13:04cemerickhah
13:04_atomake-connection is #3
13:04technomancyozzilee: have you seen http://github.com/danlarkin/clojure-couchdb ?
13:05lisppaste8ozzilee annotated #89736 "untitled" at http://paste.lisp.org/display/89736#1
13:06ozzileeSorry, the top part was just to clarify that host and db were just strings.
13:06ozzileetechnomancy: No, I hadn't, thanks.
13:07_atohehe :)
13:07cemerickozzilee: you can have #1 and #2 if you'd like, but if you only want either/or, #1 is the way to go.
13:07ozzileecemerick: What's the advantage of that versus just passing the info in? It's awful verbose.
13:08ozzileecemerick: Granted, less verbose if there's multiple calls in a single scope.
13:09cemerickonly offering #2 means that callers have to have a connection object sitting around, or create one on every action.
13:10danlarkinbut when a connection is just a string that is not expensive :)
13:10_atohmm, couchdb is stateless isn't it?
13:10_atoit's over http
13:10The-Kenny_ato: Yes.
13:10cemerickdanlarkin: you're not saying we should be hard-coding db strings, right? ;-)
13:11danlarkin*gasp*!
13:11danlarkinno, but it could certainly go in a config file or something like that
13:12_atoozzilee: I was thinking the usage would be like this: http://gist.github.com/225294
13:12_atobut as it's stateless, there's not much point
13:12The-Kennyhttp://github.com/kunley/clojure-couchdb :)
13:13ozzilee_ato: Yeah, it's a web app, so there will be a bunch of disconnected functions instead of a single entry point.
13:15ozzileeAm I crazy to think that there could/should be some kind of module-scoped binding? Maybe that's not possible or desirable.
13:16cemerickozzilee: the question is, how is it different from normal bindings, and what would the threading semantics be?
13:16cemerickYou can't just assume that your lib has only one caller.
13:16danlarkin<3 non-reentrant code!
13:16ozzileecemerick: Right, that's where atoms fall down, since there are multiple callers.
13:17ozzileedanlarkin: Does clojure-couchdb use your clojure-json?
13:18_atohmmm... you could probably basically achieve it by having a macro that (use)s the library and automatically generates wrappers for all functions
13:19ozzilee_ato: Yeah, that sounds like it would work.
13:19_atoactually
13:19_atoeven better
13:19_atowould be to custom name space it
13:19_atoso
13:20danlarkinozzilee: it does not, it uses contrib's json
13:20_ato(require-with-bindings 'couchdb :as 'shop-db :host "whatever" ...)
13:20_atothen if you wanted to use another db
13:20_atoyou could add
13:21_ato(require-with-bindings 'couchdb :as 'blog-db :host "something else" ...)
13:21cemerick_ato: it hurts just thinking of that, but maybe this is a matter of opinion.
13:21ozzileedanlarkin: Okay. Now to decide if it's worth rewriting stuff so I don't have to maintain my own library :-)
13:21danlarkinhow is this different from bindings?
13:21_atoand use (shop-db/put ...), (blog-db/get ...)
13:21_atodanlarkin: it's module-local and propagates threads
13:21danlarkinozzilee: fork it and patch 'til it's good enough :)
13:22cemerickdanlarkin: it'd use your ns' vars to hold implicit bindings, I think.
13:22danlarkinle gross
13:22ozzileedanlarkin: Oh I'm sure it's good enough, probably better than what I've got.
13:22cemerickI agree.
13:22_atochouser's clojure-jna does something similar
13:23danlarkinozzilee: there's also http://github.com/tashafa/clutch
13:23The-Kennydanlarkin: Is there a reason for not-merging the view-*-functions added by kunley to your repository of clojure-couchdb?
13:24danlarkinThe-Kenny: I started to a couple weeks ago but got distracted and have been too busy since then
13:24ozzileedanlarkin: Ah, a view server too. Nice.
13:24The-Kennydanlarkin: Oh okay.
13:27ozzileeI'm just trying to avoid having to pass the host and db a dozen different times in the module. Sounds like the only practical way around it is to write wrapper functions, or maybe make a macro that writes them for me.
13:28djorkso what are the implications of using Clojure in game development?
13:28djorkLWJGL + Clojure = ...?
13:28cemerickozzilee: seriously, bindings are *the* way to avoid having to thread arguments through various levels of fns.
13:29The-Kennyozzilee: the host is already bound to a variable and isn't an argument. You can easily do the same for the database with few modifications.
13:29djorkwhat about distribution?
13:29ozzileecemerick: Right, it just means I have to wrap every single call with (binding ..). It's more verbose, unless I'm terribly mistaken.
13:29_atodjork: java web start or just one big jar that you can double click to run?
13:30The-Kennydjork: Distributing clojure is easy, just create a .jar and add clojure.jar to the classpath.
13:30djorkyeah I'm more concerned with the ugly details of running it on different platforms
13:30djorkweb start is pretty funky for most users
13:30cemerickozzilee: if the caller knows what he's doing, no more than one binding form is ever necessary
13:31djorkI can assume Java on Macs, but not on Windows or Linux.
13:31cemerick(assuming a single-threaded environment)
13:31ozzileecemerick: Then I'm missing something. Let me paste up an example.
13:31djorkthe minimal JRE isn't too big, is it?
13:32_ato8 mb or so I think
13:32_ato17M jre-1_5_0_21-linux-i586.bin
13:33_atomaybe a bit bigger than I remembered :p
13:33djorknot too big for a larger project
13:33djorkas a percentage of the assets et al
13:33_atoyeah, if you've got 200mb of art or whatever
13:33_atofor smaller stuff you could just have a graphical installer that checks if they've got it and downloads it for them if they haven't
13:34djorkyeah
13:34djorkso now how about architecture?
13:34cemerickozzilee: I'm think here of with-db in clutch, for example
13:34djorkI am imagining many refs being slung about
13:35djorkmaybe I need to re-read some of the clojure presentations
13:35djorkI'm concerned with memory usage when the world state is kept in maps or vectors that might be quite large
13:35djorkdoing lots of disj conj assoc operations, etc.
13:36danlarkindjork: prototype something and measure it
13:36_atoI've been fiddling with a little RPG type thing in Clojure (2d tiles, although they can be stacked so the game actually has 3d world coordinates)
13:36djorkyeah, really that's the best way to go I guess
13:37lisppaste8ozzilee pasted "bindings 2" at http://paste.lisp.org/display/89737
13:37_atoat the moment the tile map is a sorted-map where keys are coordinates and values are game objects (which are wrapped in refs)
13:37_atoso you can update game objects independently
13:38ozzileecemerick: I don't understand how I could do something like that with only one binding form.
13:38_atobut only one thing can change the map at a time
13:38_atoants.clj also has an interesting way of doing it
13:39cemerickozzilee: you wouldn't, but I think it's save to assume that callers aren't going to be setting db info on every db access -- the binding would be set up in the top level of a servlet handler, a JMS receive, etc.
13:39Guest77613hi there. What would be the most idiomatic way to walk a directory and grab the files names and paths ?
13:40Guest77613recursively that is
13:40cemericke.g. not (binding [...] (save ..)) (binding [...] (load ...)), (binding [...] (save ...) (load ...))
13:40djork_ato: sounds pretty reasonable
13:41The-KennyGuest77613: function(doc,req) {
13:41The-Kenny return {
13:41The-Kenny body: \"<div>42</div>\"
13:41The-Kenny };
13:41The-Kenny }
13:41The-Kenny user=> ; The latest field is the id. It's left blank in this example
13:41The-Kenny user=> (show-get "some-db" "test" "forty-two" "")
13:41The-Kenny user=> ("<div>42</div>")
13:41The-Kennyargh sorry.
13:41The-Kennydamn c&p
13:41Guest77613:D
13:41The-KennyGuest77613: (file-seq (java.io.File directory-string))
13:42The-Kennys/File/File./
13:42Guest77613thanks, i thought it looked more like javascript too :)
13:42Guest77613why couldn't i find that in the docs :/ i must be very tired
13:42alexykis clojure dynamically typed, i.e. closer to Ruby than to Scala?
13:42_atoalexyk: yes!
13:43_ato:)
13:43alexykso how are you supposed to do big projects?
13:43alexykcan I supply type annotations throughout?
13:43ozzileecemerick: I don't follow. Are you saying I should be calling the (binding ...) in the client to the module I posted?
13:43alexykcan I insist they're enforced?
13:43_atono
13:43alexyk:(
13:43_atoyou can specify them
13:44_atobut they're for a performance optimisation
13:44_atonot for bondage and discipline :p
13:44cemerickalexyk: clojure is strongly typed -- any type conflicts will result in an error
13:44alexykcemerick: now I'm confused... strongly typed dynamic??
13:44djorkyou can be strong and dynamic
13:44djorklike a CEO
13:45djorkno
13:45_atohaha
13:45alexykso what's dynamic here?
13:45cemerickalexyk: there are 2 axes: strong vs. weak, dynamic vs. static
13:45djorklike Spiderman
13:45Guest77613_ato : If i'm not wrong though , type hints will throw exceptions if you don't use the right types no ?
13:45alexykwhat's an example where something is strongly typed but dynamic, hence different from Java/Scala?
13:46_atodynamic means you don't specify types when eg declaring a local
13:46cemerickalexyk: that is clojure
13:46_atoso like: (let [x 5] ... )
13:46cemerickperl is weakly typed and dynamic
13:46cemerickjava is strongly typed and (sorta) static
13:46alexyk_ato: Scala infers the type. so you don't have to declare it either
13:46cemerickas is scale
13:46cemerickscala*
13:46alexykbut it always knows what it is
13:47alexykthe question is, does clojure know always what a type of x is?
13:47Guest77613no
13:47_atosometimes
13:47cemerickoh goodness
13:47_atoin that case yes
13:47Guest77613well i mean there is boxing right ?
13:47_atobut it doesn't *need* to know
13:47cemerickalexyk: yes, just like any other JVM lang, you can get the type of an object
13:47alexykso say I want always to insist a parameter of a function is Int. Can I enforce that, so you won't pass strings into it?
13:48cemerickalexyk: No, that's the dynamic part.
13:48_atoalexyk: yes, by explicitly checking
13:48_atobut not as in java
13:48alexykcemerick: _ato: make up your minds guys :)
13:48Chousukethey're both right :)
13:48cemerickI think _ato is trying to make the hard sell :-)
13:48Chousukeno, you can't and yes you can.
13:48hiredmancemerick: you can get at type information at runtime, sure
13:49_atohehe
13:49alexyk_ato: do I have to check myself, or can I annotate and make clojure check for me?
13:49cemerickI don't think manual assertions are ever what someone is talking about w.r.t. type enforcement.
13:49hiredmanbut clojure does not always know the type of an object
13:49hiredmanthat is what *warn-on-reflection* is about
13:49alexykhiredman: you're messing around with clojure too?
13:49alexyk:)
13:49_atoalexyk: you originally mentioned Ruby, it's just like that from the type enforcement perspective
13:50alexyk_ato: I'm scared as heck of Ruby. I wonder if I can make annotations work for me.
13:50hiredmanalexyk: I've only ever written a few lines of scala
13:50cemerick_ato: I'm not certain, but Ruby coerces values, so it's far more lax in that regard
13:50lisppaste8ozzilee annotated #89737 "Maybe this is what I want?" at http://paste.lisp.org/display/89737#1
13:51hiredmanalexyk: why is ruby scary?
13:51alexykRuby degenerated into testing frameworks because of the lack of type safety. Hence the whole "agile testing" industry... recreate type system via unit tests.
13:51cemerickalexyk: this is worth a read re: type systems: http://www.pphsg.org/cdsmith/types.html
13:51Guest77613When you type hint a Clojure func, and you provide it with different types arguments
13:51Guest77613it will try to cast them
13:51Guest77613if the cast doesn't work
13:51Guest77613you get a cast exception
13:51Guest77613it's pretty straightforward
13:51alexykso the question is how clear are the casting rules then
13:51ChousukeI recall Rich mentioning that he wouldn't oppose an optional "type system" based on predicates, but I don't think he (or anyone else) has any solid ideas about implementing something like that yet.
13:52hiredmanalexyk: plenty of typed languages use testing frameworks
13:52alexykhiredman: right, yet in Scala you can get by without one, while in Ruby you really have to have one.
13:52Guest77613it's pretty confusing with strings
13:52rfgpfeifferChousuke: datalog is also based on predicates and will always terminate
13:52hiredmanalexyk: I think the divide is less typed/dynamic as functional/imperative
13:52Guest77613because everything in java can be casted to string
13:52Guest77613so if you type hint a func so it only accepts strings
13:52Guest77613it will actually accept anything
13:52ChousukeGuest77613: huh, they can?
13:53hiredmanalexyk: functional code is more transparent and easier to reason about
13:53Chousukewhat happens?
13:53rfgpfeifferweren't there plans for embedding datalog in clojure?
13:53Chousukedo they just get .toString calleD?
13:53Chousukerfgpfeiffer: something like that. or at least some handwawing :)
13:53alexyktoString would be a massive fail
13:53Chousukewaving*
13:53hiredmanrfgpfeiffer: there is something called datalog in contrib
13:53hiredmanGuest77613: I don't think that is true
13:54cemerickGuest77613: that's very not true
13:54_atohmm
13:54cemerick,((fn [#^java.util.ArrayList s] (.floatValue s)) 6)
13:54clojurebot6.0
13:54_ato,((fn [#^String s] s) 5)
13:54clojurebot5
13:54_ato,(type ((fn [#^String s] s) 5))
13:54clojurebotjava.lang.Integer
13:54cemerickThe hint is just that, a hint. No type enforcement at fn boundaries
13:54Guest77613(defn repeat-2 [#^String a]
13:54Guest77613(str a a))
13:55Guest77613#'user/repeat-2
13:55Guest77613user> (repeat-2 "apo") |"apoapo"
13:55Guest77613user>(repeat-2123)
13:55Guest77613|"123123"
13:55Guest77613user> (repeat-2 [1 2 3 4])
13:55Guest77613"[1 2 3 4][1 2 3 4]"
13:55ChousukeGuest77613: it's not being cast to string; the type hint is just ignored.
13:55cemerickright, str is converting your parameters into strings.
13:55Guest77613Chousuke: how can it be ignored ?
13:56ozzileecemerick: Sorry to keep hounding this. Could you take a look at my last paste? Is that at all idiomatic? Or can you point me towards some code that does things idiomatically?
13:56lisppaste8Chouser pasted "Java does not convert non-strings to strings automatically." at http://paste.lisp.org/display/89740
13:57ChousukeGuest77613: because it's just a hint
13:57Guest77613ok got it
13:57ChousukeGuest77613: Clojure uses it to avoid reflection when the type is correct, but will fall back to using reflection if it's not.
13:57_ato,((fn [#^Long s] 5 + s) "foo")
13:57Guest77613did another test function that made more sense ..
13:57clojurebot"foo"
13:57cemerickozzilee: no, bindings only hold within the scope of the binding.
13:57Guest77613ok
13:57_atohmm.. that's weird
13:57Chousuke5 + s?
13:57Guest77613so in theory it would be possible to make clojure throw an exception instead of just using reflection
13:57_atooh wait
13:57_atobrain dead
13:57Chousukeyou mean (+ 5 s) :P
13:58Guest77613when a type hint isnt being respected ?
13:58_atoall this talk of ruby is confusing me :p
13:58_ato,((fn [#^Long s] (+ 5 s)) "foo")
13:58clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
13:58chouserChousuke: no, it doesn't fall back on reflection if the type hint is wrong
13:58alexyk,(+ 5 "4")
13:58clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
13:58cemerickozzilee: you need to let your caller establish the binding themselves. If they're doing things in the right way in general, they'll establish the binding *once*, do all of their couch stuff, and be done.
13:58alexykwell this fails at least
13:58chouserit falls back to reflection if there is no type hint.
13:58_ato,((fn [#^Long s] (+ s 5)) "foo")
13:58clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
13:58_ato,((fn [s] (+ s 5)) "foo")
13:58clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
13:58cemerickalexyk: right, clojure is strongly typed
13:58_atohmm
13:59Guest77613chouser : well then what does it do when there is a type hint, but it's not respected at runtime ?
13:59_atoalexyk: yeah, if that worked, it'd be an example of "weak typing"
13:59Chousuke,((fn [#^Integer s] (.floatValue s)) 5.0)
13:59clojurebotjava.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer
13:59chouserif casting to the hinted type wouldn't help (say when calling a clojure fn rather than a Java method) then no casting is done regardless of whether a type hint was supplied or not
13:59Chousukeah, I see.
13:59cemerickalexyk: you're looking for static typing, which is decidedly not clojure's approach, though it does avoid reflection when you provide it with type hints appropriately.
13:59ozzileecemerick: Bah. Okay, I give up, I'll just do things verbosely. Thanks.
13:59cemerickozzilee: I'm unclear as to what you think is verbose...?
14:00samlhey, did anyone write mp3 encoder purely in clojure?
14:00samlor is there lisp/scheme implementation so that i can easily translate?
14:00alexykinteresting... just gauging stuff... are all Lisps like this?
14:00chousermosts lisps don't run on top of a OO runtime like the JVM
14:00_atoalexyk: most, but there are some that are statically typed
14:01Guest77613alexyk : i think that there is a strong tradition of dynamic typing among lisps
14:01alexyktrue, but in terms of dynamic and strong?
14:01ozzileecemerick: I want to write a library that hides the couchdb access from its clients. Every function in that library has to either pass in or bind the hostname and the database name. I can't just set them in one place.
14:01alexykhow cal clojure be dynamic if Java is not, and JVM is made for Java originally?
14:01alexykcan
14:01_atosaml: why would you want write one instead of using a library? just for fun?
14:01cemerickalexyk: most schemes do not have an object system built-in, so it's less of an issue.
14:01chouseralexyk: When I think I want a static type system it's because I'd like to catch a certain class of errors at compile time. You have a similar desire?
14:02saml_ato, to package into applet or web start instead of doing JNI with lame and including lame for windows,mac,linux....
14:02cemerickalexyk: Java *is* dynamic under the covers, but javac and the Java language don't provide an easy mechanism to access it.
14:02alexykchouser: exactly. I'm am OCaml/Scala addict in terms of long and painful compile cycle, but when stuff compiles, it usually works.
14:02chouseralexyk: as it turns out, the Java language is static as processed by javac, but the JVM is quite dynamic internally.
14:02alexykchouser: interesting
14:03cemerickchouser: hah, beat you this time. :-P ;-)
14:03chousercemerick: :-)
14:03_atosaml: ah fair enough. I can't even find a pure java one, so there'd be no chance there's a pure Clojure one ;)
14:03cemerickalexyk: I used scala for about 8 months before coming to clojure. I don't miss it one bit :-)
14:04alexykso with clojure, is there a similar experience that once stuff compiles it works, or is it Ruby-like, lots of unit testing?
14:04saml_ato, yup :P i was just wondering
14:04Chousukechouser: heh, I read John Rose's post about continuations on the JVM today :P Scary stuff.
14:04_atosaml: looks like there's a pure java vorbis encoder though, if you don't need specifically mp3
14:04Chousuke(old post, but I was looking through the archives)
14:04alexykcemerick: can you summarize your pain/pleasure points for Scala vs clojure?
14:04technomancyJohn Rose is the man.
14:04_atoalexyk: hehe.. I don't find in java that once stuff compiles "it works"
14:04samli found a C implementation. i might port it: http://www.mp3-tech.org/programmer/sources/shine.zip
14:05cemerickalexyk: I'm not at all into the TDD stuff, but judicious testing is invaluable IMO.
14:05chouseralexyk: I have come to believe that required static type systems are an obstacle to a lot of interesting design work. I'm hopeful about the possibility of an optional static type system, but I'm not sure what that would look like.
14:06saml_ato, yah currently, our "reader" client is flash plugin. so it should be mp3 or flv. i found pure java speex encoder. so our "creator" (web start) client can convert to speex, but "reader" client can't read spx directly. it should be flv.
14:06alexykcemerick: true. But what's the largest project in clojure so far? Also, I've just started reading the book... so pardon me for asking, does it have objects? (I don't really need them.)
14:06cemerickalexyk: Scala's type system is incredibly complicated, as is the language. Implicits are scary as hell. The impl. of traits similarly so. The easy mixing of mutable and immutable state makes it easy to turn things into a mash IMO.
14:06chouseralexyk: I would also contend that if the only errors in your program can be caught by a type system, then the program's not doing much of interest.
14:07samlso, i have 2 choices: implement mp3 encoder in "publisher" client. or implement flv encoder on client. or make swf with embedded speex
14:07samlso 3 choices haha
14:07chouseralexyk: conversely, if you write tests that check the logic of your program, they will tend to catch type errors as well, making the effort of correct typing superfluous.
14:07alexykchouser: true. Yet you can't deny the strange experience of forcing a Haskell/OCaml/Scala program to compile and then seeing it work *correctly* the first time it runs.
14:07cemerickalexyk: The largest projects are almost certainly not public at this point. Ours is getting pretty sizable, nearing the scope of our existing Java 'legacy' codebase from the past 5 years.
14:07chouseralexyk: happens to me in clojure all the time ;-)
14:07_atoalexyk: Clojure isn't object-oriented in the java classes sense. You can use and make java classes if you really want to, but you normally would just use data structures and functions instead
14:07samlor forget about fattening "publisher" client.. and convert everything in the server
14:08cemerickalexyk: and yes, "there's objects", but that's really not the interesting question.
14:08alexyk_ato: that's good, I didn't need no stinking objects in OCaml
14:08alexykalthough it was *O*Caml, nobody used the O
14:08alexykso I guess you package functions and their data into... what? closures? :)
14:09chouserthat's one way, though not the most common
14:09alexykwhat's an equivalent of ML/OCaml module?
14:09cemerickalexyk: there's proxy and gen-class currently; this is what's coming down the road, but it might be more than you're ready for yet: https://www.assembla.com/wiki/show/clojure/Datatypes
14:09djorkdata is data, and code is data :)
14:09cemerickalexyk: namespaces are modules, roughly
14:09chouserit's probably more common to group related functions (that possibly operate on similar data collection) into a namespace. Then your data is held in Clojure persistent collection (nested vectors/maps as needed)
14:10alexykchouser: ah ok, makes sense. Those I see in REPL.
14:11chouserthere's real power in using the same core collection types for all or most data
14:12chouservs. each lib having it's own objects with its own fields and methods that can't operate on anyone else's data.
14:13gbtalexyk: I'm not sure how far your clojure goes? (I'm new too) but the common interface to all the datatypes is very cool :)
14:13alexykso, what's the biggest open-source clojure project folks are aware of? I want to see me some githubbin'!
14:14chouserthough as we speak rhickey is hard at work adding the ability to create efficient app-specific data objects with related methods.
14:14alexykgbt: my closure is 1 day old. :) But my Scala is 6 months, and OCaml is a couple years... I also read 1/3 of the Practical Lisp book. :)
14:14hiredmanhttp://github.com/languages/Clojure
14:14chouserprobably contrib. :-P
14:15alexykhiredman: ok, I should say, doing something else but self
14:15cemerickalexyk: yeah, those are all projects *using* clojure
14:16alexykbtw Scala tries to standardize all the fields via traits, it's really complex but seems to work in 2.8
14:16technomancyalexyk: the altlaw project is the biggest open codebase probably.
14:16rhickeychouser: but people *will* be able to use existing code on that app-specific data - it is both app-specific and generic
14:16chouserrhickey: ah, good point.
14:16rhickeyI'm working hard on making the generic use fast
14:16chouseresp. if (:k x) is just as fast as (.k x)
14:17rhickeyand the specific data dynamic
14:17_atoalexyk: altlaw is at: http://github.com/stuartsierra
14:17alexyktechnomancy: _ato: thanks
14:17_atothe actual running version is: http://www.altlaw.org/
14:18alexykrhickey: performance is another thing I wanted to ask, not to start any flames, but to understand JVM better. Is there any reason why Scala or Clojure would be faster or slower due to type system differences?
14:19rhickeyalexyk: yes
14:20alexykrhickey: which way?
14:20Licenseraloa good evening everyone
14:22alexykI mean if JVM is dynamic enough, that shouldn't slow things down, especially if you don't incur casts by designing things carefully, right?
14:23alexyk(also saw something about JVM designed to support dynamic languages better)
14:23rhickeyalexyk: the more type information you have the faster things can be, potentially. Note that you can give Clojure type information. Also, if a system is designed to be dynamic, it will likely be faster at dynamic things then one that wasn't (or you will be rolling your own dynamic things, with perf on your head)
14:23rhickeybut there are no general answers applicable to specific problems, thus the futility of the exercise
14:24alexykrhickey: yeah, I'll play with things like JSON parser/database insertions... I generally parse Twitter JSON stream then mine it.
14:25alexykare there good JDBC and/or Berkeley DB interfaces?
14:25LicenserA question, did someone ever started to put problems from language shootout / benchmarks in clojure code?
14:25technomancywhat do folks think about clojure.test/report's :summary method returning true or false depending on if all the tests passed or not?
14:25technomancythat would also cause run-tests to return a useful value
14:25technomancyeasy 1-liner
14:25Licenseralexyk: someone is developping a nice driver for mongodb, which would allow to store json directly in the database
14:26alexykLicenser: thx for the idea!
14:26LicenserI use it for a pet project of mine, it's still alpha (the driver) but it works stable for me
14:29_atoalexyk: but yes SQL/BDB are easy enough. For BDB: http://github.com/gcv/cupboard
14:29_atothere's a couple of different SQL libraries, there's a simple one in contrib
14:30alexyk_ato: looovely cupboard, thx
14:30LicenserOne thing I noticed while writing clojure, it is damn hard to write functional functions. I nearly always end up having sideeffects - is that a general problem or is it because I work on a web app?
14:31_atoLicenser: if it's a typical database-backed webapp, yes probably because it's a webapp
14:31chouserLicenser: the difficulty varies between different domains. I'd be a bit surprised if web apps were particularly hard, though.
14:31alexykthe clojure book lists contrib under google code, while here it's referred to via git. Which one is current?
14:31chouseralexyk: git
14:32alexykwhy is it called contrib when in fact it's a stdlib? :)
14:32Licenserokay that makes me feel better, I was a bit frustrated that I don't manage to write pure functions, I nearly always end up with either a query, a commit or rendering in the function :/
14:33chouserLicenser: if you think of the input being the http req + the user's state (database, session, etc.) and the output being the page to render + new user state, then your whole app is a function. :-)
14:33alexykLicenser: web it notoriously impure, downright dirty stuff :)
14:33_atoalexyk: there's sort of two "standard libraries" for clojure. There's "core" which comes with the language but is very small
14:33Licenserchouser: it's not about beeing hard to write the app - it's incredible easy I love clojure - I am just wondering if the fact that I don't get pure functions comes from he tasks or my incapability :P
14:33_atoalexyk: and "contrib" which has lots of handy but absolutely necessary stuff
14:33Licenserchouser: I like that vew ^^
14:33_atoerr
14:33_atonot absolutely*
14:34chouserright. only seq-utils and repl-utils are absolutely necessary
14:34chouser:-)
14:34chouseroh, and str-utils2
14:34alexyk_ato: right, that's why my first reaction is, that's how contrib might have started, but if everybody is using it, it should be called something like stdlib, with contrib usually having kinda-nice things you can live without somebody bothered to upload
14:35alexykjust a newbie's feedback, I know you guys got used to it
14:35chouserit's an interesting thought. might be useful to split contrib.
14:35technomancy"experimental contrib" vs "tried-and-true, everyone uses"
14:36LicenserI find some things in contrib very confusing
14:36chouserThe hard line is between core and contrib: rhickey approves every commit to core individually, but not for contrib.
14:36Licensercoming form ruby I'm used to have a huge stdlib with all kind of nifty stuff
14:36chouserLicenser: We're still very early for that.
14:36Licenserchouser: then just rename it from clojure.contrib to clojure.stdlib :P
14:37Licenserchouser: i know I know, but tings like seq-utils really could be in somet kind of stdlib
14:37chouserbut there's definitely experimental stuff in contrib that's not necessarily recommended yet.
14:38LicenserI agree but some things are a defacto standard right?
14:38chouserthere's also a hard line between contrib and non-contrib -- if it requires an external dependency or doesn't fall under the Clojure license or hasn't been approved (at least the broad strokes) by rhickey, then it's not in contrib.
14:38chouserso there may be value in splitting contrib itself, but it might be hard to define the line there. Could get political. :-(
14:39LicenserI don't know I find the whole license stuff a bit radical
14:39_atomm.. I thought the initial idea was stuff would start off in contrib and could be "promoted" to clojure (not necessarily core) if it was tried and true and everybody used it
14:39chouserand I don't think we want any extra structure or policy unless it's needed -- such things generally come with hidden cost
14:40LicenserNot sure if it is because I was looking at licenses the moment I found clojure but I lately got the feeling that OS licenes at time make it harder to provide stuff as open source
14:40chouser_ato: the licensing allows for that
14:41_atochouser: yeah, I was just talking about splitting contrib, not in reference to licenses
14:41chouserLicenser: yes, requiring a CA surely discourages some contributions, but has its benefits as well.
14:42LicenserIt's a broader feeling, like alone choosing a license is a tasks that kind of discurages me from releasing stuff as OS
14:42Licenserif I keep it closed source I just can say: leave me alone
14:42chouserLicenser: ah, I see. yeah, I can certainly see that.
14:43LicenserThat's not even related with clojure
14:43chouserI once took a fair amount of abuse for trying charge for an upgrade to something I originally released as open source. :-P
14:43LicenserI've a ruby project I hope to be OS one day but when I set down to find a fitting license, I got hugely frustrated after a day and decided screw OS for now I keep it closed untill It calls for it :P
14:43Licenserheh
14:44Licenseryes it's horrible, open source is a jungle and event he liceses are hating eachoterh - at least partially
14:44djorkanybody ever written a memory usage macro?
14:44djorklike time, but for memory
14:44Licensercall it mime
14:44djorkI like it
14:45djorkI'm just not sure if it's right
14:45djork(my macro)
14:45_atohow would a memory usage macro work?
14:46_atoit gives you the change in memory usage so you can see if you're leaking memory?
14:47djorkyeah
14:47djorkjust to see how much memory changes while evaluating & exprs
14:48chouserI think so -- you might check the google group. It's hard to be accurate on the JVM though.
14:49_atoit'd be hard to do accurately as the GC may not have collected everything even if you do (System/gc)
14:49_atoyeah
14:51djorkyeah the GC makes it kind of suck
14:51djorkbut it sort of works
14:51jasappthat'd be nice to have something like common lisp's time
14:51jasappone that reported bytes
14:52jasappI don't know if that would make sense in a jvm context though
14:53djorkI think it's pretty accurate right now
14:53djork[] is 8 bytes
14:53djork?
14:53djorkor is that 8 8 byte blocks
14:53djorkno it's bytes
14:55chouserarohner: are you here? just looked at your Scriptjure README -- looks quite useful.
14:55djorkhttp://gist.github.com/225372
14:56djorkit's not too accurate...
14:56chouserarohner: I wondered if you knew you could tweak your js macro to treat ~ and ~@ specially, for example to do what your 'clj' does now.
14:57arsatikiohh
14:57_ato(mime []) => -3256 bytes used
14:57_atohmm
14:57arsatikiscriptjure made my head asplode out of happiness
14:57arsatikibecause it's precisely what I've been looking for
14:58djork_ato: it has to "warm up"
14:58djorkit's certainly not perfect since the VM makes it kind of fuzzy
14:58djorkhence the voodoo 5 System/gc calls :)
14:58_atoyeah (mime (vec (range 1000))) gives something more sensible looking
15:00_atounless clojure is so efficient that each empty vector *reduces* memory usage by 3k. :-P
15:01djorkheh
15:01chouserI think rhickey has wanted something like scriptjure too.
15:02djorkby golly I think it works
15:15alexykLicenser: is this the clojure-mongo thing you mentioned? http://github.com/gilbertl/mongo-clojure-wrapper
15:15Licenseralexyk: nope this one I'm talking about: http://github.com/somnium/congomongo
15:17alexykcool
15:17jasappLicenser: are you using mongodb?
15:17Licenserjasapp: yes
15:17jasapphave you been using it for awhile?
15:18Licenserit has a few issues I see and it kind of seems as the server is still is in a development phase but it's very nice to use
15:18Licenserjasapp: a week or so, no production use just developping with it
15:18Licenserbut it integreates very nicely in clojure
15:18jasappI'm using it for a work related project right now
15:18Licenser(save for the few issues it has :P)
15:18jasappI'm awaiting the addition of the or operator.
15:18Licenserheh
15:19jasappthey say it's supposed be out on November 11th
15:19Licenserupdate is a tricky thing, it isn't yet doing all I want
15:19Licenserjasapp: *nods* they are still in heavy development
15:19Licenserdid you ask the $in question on the mailinglist? ^^
15:19alexykI wonder how much can I stuff into mongodb... I get a Twitter feed, about 2 million tweets/daily. Each tweet is a JSON string with ~20 fields (with a nested user field). Could it handle 100 million such tweets?
15:20duncanmtechnomancy: is your branch of swank-clojure the canonical one now or should i stay with the jochu branch?
15:20jasappalexyk: did you see that nosql benchmark?
15:20alexykjasapp: no, which one?
15:20fanaticoGood question came up on news.yc. Why doesn't memoize use java.lang.ref.SoftReferences?
15:20technomancyduncanm: use the "maven" branch of my fork to be most up-to-date.
15:20jasappI want to say they looked at mongo, couchdb, and tokyo cabinet
15:20jasapplet me see if I can find it
15:20technomancyduncanm: I'm about to release a 1.0, would love to get some more eyes on the latest version. hop on the mailing list if you have any problems.
15:20Licenseralexyk: I use it with 1 million fields at the moeent eats up about 2 GB of hdd but works very fast with good indexes so I think it sould be fine if you've the HW to back that up
15:20duncanmtechnomancy: and if i want to run start a swank server from within another app, do you have a snippet ready for doing that? (I had one before, but I lost it)
15:21duncanmtechnomancy: i used to have a jar file of swank-clojure and i'd launch it from my app, and use M-x slime-connect from emacs to connect to it
15:21technomancyduncanm: I will make sure it gets into the readme before 1.0; in the mean time take a look at drewr's clot project on github; it's a good example
15:21alexykLicenser: yeah, HW is no prob. Berkeley DB eats about as much per 1 mil/twits.
15:21duncanmbut i lost that script ;-(
15:21duncanmtechnomancy: nice, thank you
15:22Licenseralexyk: if you want a word of advice, don't use BDB it does not stand for berkeley but for braking DB in my experience
15:22LicenserI really hate BDB
15:22LicenserI hade huge problems both with near data lass due to some stupid updates without backwards compatibility
15:22alexykLicenser: well, I've managed to stuff it allright from Scala... was pain though
15:22duncanmtechnomancy: http://github.com/drewr/clot/blob/master/src/com/draines/clot/main.clj is it 'swank!' that's the key part there?
15:23technomancyyep
15:23duncanmtechnomancy: and if i have maven installed, and i use your maven branch, mvn install will make me a jar file of swank-clojure?
15:23technomancyduncanm: yeah, that's the idea
15:24alexykLicenser: I had to write Scala classes in a Java way and convert Scala types to Java's so that BDB would know how to store them... Is it the same in clojure?
15:24Licenserno you can store most of clojures objects directly in mongodb
15:24Licenserand retreive them
15:25alexykright, but about BDB -- can you store clojure structs as is in BDB, are they like Java classes for that purpose?
15:25Licenseras long as it are native types (hashmaps, arrays, ints, stirings lists
15:25duncanmtechnomancy: should i be using your version of slime too? right now i have the boinkor.net version checked out
15:26technomancyduncanm: yes, and there's a "from source" install instructions section in the readme
15:26Licenseralexyk: never worked with BDB and never will unless someone places a gun on my head and forces me too and even then I#d have a hard time to make a call
15:27alexykLicenser: well, JE is not that bad, actually
15:27LicenserJE?
15:27drewrduncanm: it doesn't quite work flawlessly
15:27alexykBDB Java Edition
15:27drewrI need to get sldb support in there
15:27Licenserdon't care, I care about the fact that it has a huge design flaw with bacwards incompatibility
15:28Licenserwhich makes it a no go for me
15:28_atoalexyk: yeah, if you use cupboard it'll automatically marshall the clojure data types
15:28duncanmdrewr: ahh
15:28duncanmtechnomancy: i don't see swank-clojure in elpa
15:28technomancyduncanm: look further down in the readme to the "from source" intructions
15:28LicenserI like things that don't have a auto-brake-and-delete-my-data feature
15:28technomancyI'm waiting for more people to give feedback and test before I submit it
15:29hiredmanfanatico: it's come up on irc before
15:29alexyk_ato: the problem is, you don't want to store class info more than once... JE provides for that, wonder if cupboard takes advantage of that.
15:29duncanmahhh
15:29drewrtechnomancy: I'm running the latest, but haven't tried the mvn stuff
15:29alexykdrewr: what is clot? :)
15:29drewralexyk: IRC client
15:29alexykah ok
15:30drewrit's more of a bot though
15:30Licenserlikely the cl(ojure b)ot
15:30technomancyI like clot, but I really don't like the fact that cd ~/src/cl TAB no longer completes to clojure. =(
15:31drewrI haven't been able to do that in quite some time
15:31technomancyheh
15:31drewrclojure-contrib, clj-*, etc.
15:31drewrclabango
15:32technomancydrewr: I meant to ask you, do you know why swank's start-server must be wrapped in a clojure.main/repl call?
15:32alexykoh, another noob's question: is there a jline option for REPL?
15:32technomancy(I should know this, but there are vast swaths of swank that I haven't really dug into yet)
15:32drewrtechnomancy: I can't give you a detailed answer, but I found that swank really wants a repl set up before it can do anything
15:33drewrslime apparently starts a repl, runs swank, and then connects to it
15:33technomancydrewr: it seems like it'd be nice to have it be able to set up one for you. maybe that could be added to swank-clojure if everyone who wants to embed swank is going to need it.
15:33drewrdefinitely
15:34drewrthere's an abstraction there waiting to be codified
15:34technomancyI'll try to sneak that in before 1.0 escapes.
15:34_atoalexyk: apparantly "java -cp jline-0.9.91.jar:clojure.jar jline.ConsoleRunner clojure.lang.Repl" I just use emacs though
15:35alexyk_ato: nice... I also use Emacs but log into a remote box where I find console-level jline useful. If the darn thing could only do C-r. I know about rlwrap, too, and the fact that jline can't search backwards makes me mad at it.
15:36technomancyalexyk: I prefer launching it inside rlwrap
15:38_atoalexyk: if there's no firewall in the way you can start a swank server inside your remote process and use M-x slime-connect in emacs to connect over a tcp socket
15:39spuzQuestion about iteration: Is map the only way to iterate through items in a list? Say I want to print each of the items in a list, I could say (map println mylist) but this would map each item to nil, return a new list and print each item as a side effect which doesn't seem to really fit conceptually with what I'm doing.
15:39alexyk_ato: hah! now I start to understand what swank is :)
15:39_atospuz: (doseq [x mylist] (println x))
15:40spuz_ato: that's much nicer :)
15:40_atoevaluates eagerly (returns nil)
15:41tknudsenhey, are compojure/cascade stable enough for me to rely upon for simple apps? comments appreciated
15:42hiredmanspuz: also, seqs are immutable so mapping print over a seq will make a seq of nils, but not change the source seq
15:43spuzyep, I get that but even so, map is wasting my time if I'm just relying on side effects :p
15:46spuzwasting its time rather*
15:47duncanmException in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 4
15:47duncanmeek
15:47duncanmi can't build swank-clojure
15:51StartsWithKhi
15:52StartsWithKif i want to use xml security from clojure (jsr 105), what is the best lib for that?
15:52LicenserStartsWithK: that is not true StartsWithK starts with S
15:52StartsWithKLicenser: by my name does
15:52StartsWithKcan clojure.xml do that?
15:53_atoKresimirStartsWithK
15:53Licensersneaky person you should raname yourself to Steward then you could use StartsWithS
15:53StartsWithK:)
15:53Licenserand sorry I don't know about clojure.xml
15:54StartsWithKi looked at jdom and clojure.xml, clojure.xml dosn't use standard dom api, so i think that will not work, and jdom has some problems with xml security
15:54StartsWithKis there some other lib?
16:01ordnungswidrigre
16:02duncanmbah
16:03duncanmtechnomancy: util/class_browse.clj doesn't support windows ;-P
16:06duncanmoh, this is a nasty bug
16:15duncanmdum de dum
16:27duncanmdrewr: ping?
16:28drewrduncanm: pong
16:28duncanmdrewr: i'm having problems building swank-clojure because my paths are in Windows style
16:28duncanmCompiling swank.commands.completion to c:\Users\Duncan\git\swank-clojure\target\classes
16:28duncanmand then it dies on \U
16:29duncanmi'm trying to define file.separator to "/", but to no avail
16:29drewrwith "ant -Dfile.sep..." ?
16:29drewrI'm not sure if that should work or not
16:29drewrI haven't looked at the latest swank build
16:29duncanmdrewr: mvn has a -D flag too
16:29drewrI just use it out of src
16:30duncanmand i saw that you can write something like <configuration><file.separator>...</...>
16:30drewrprobably so
16:30duncanmdrewr: yeah, so do i, but right now i wanna embed it inside another app, so i need to give it a jar
16:31drewr( cd src; jar cvf ../swank.jar swank )
16:31duncanmoh
16:31drewr;-)
16:32duncanmdrewr: doesn't that include all the files, and not just the class files?
16:33drewryes, but in this case it's just clj files
16:33duncanmthat's enough?
16:33duncanmthat's great
16:34drewrclojure looks in its classpath for .class or .clj
16:35hiredmanwas there ever a 1.1.0-alpha-SNAPSHOT download available from clojure.org?
16:39chouserI don't think so
16:42chouserhttp://github.com/richhickey/clojure/tarball/9bde10d
16:42duncanmdrewr: beautiful, i got it working, thanks
16:44drewrduncanm: great!
16:46ordnungswidrighow do I test for a function
16:47ordnungswidrigI mean how do I test if a value is a function?
16:47hoeck1ordnungswidrig: ifn? or fn?
16:48ordnungswidrighoeck1: there I go. I search for function?
16:48ordnungswidrighoeck1: what's the difference?
16:49chouser,[(ifn? {}) (fn? {})]
16:49clojurebot[true false]
16:49hoeck1ordnungswidrig: ifn? also returns true for keys, maps symbols and everything that implements IFn
16:49chouser,(juxt {} [ifn? fn?])
16:49clojurebot#<core$juxt__4916$fn__4926 clojure.core$juxt__4916$fn__4926@7e8bd9>
16:49ordnungswidrig,((juxt {} [inf? fn?]))
16:49clojurebotjava.lang.Exception: Unable to resolve symbol: inf? in this context
16:50ordnungswidrig,((juxt {} [ifn? fn?]))
16:50clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap
16:50hiredman
16:50ordnungswidriggive up
16:50hiredman,((juxt ifn? fn?) {})
16:50clojurebot[true false]
16:50chouserhiredman: thanks!
16:51ordnungswidriggood night for now
16:51ordnungswidrigcu all
16:51hoeck1ordnungswidrig: n8
16:52hiredmanjuxt is my new favorite function
16:53chouseris it a superset of partial?
16:53chouserhm, no but has some overlap
16:53hiredmannot really
16:54chouseroh. no -- would if partial allowed a single (fn) arg.
16:54hiredmanit's, uh, sort of map+repeat
16:54hiredmanbut not really
16:55hiredmanupdate-in+vec+repeat
16:55hiredman,(repeat 2 {})
16:55clojurebot({} {})
16:55hiredman,(vec (repeat 2 {}))
16:55clojurebot[{} {}]
16:55hiredman,(update-in (vec (repeat 2 {})) [0] ifn?)
16:55clojurebot[true {}]
16:55hiredman,(update-in (update-in (vec (repeat 2 {})) [0] ifn?) [1] fn?)
16:55clojurebot[true false]
16:56hiredman,((juxt ifn? fn?) {})
16:56clojurebot[true false]
16:57hiredman,(-> {} ((partial repeat 2)) vec (update-in [0] ifn?) (update-in [1] fn?))
16:57clojurebot[true false]
16:57javuccihello
16:57ChousukeI still don't like that ((partial foo bar)) form
16:58javucciplease, an easy way to install clojure with emacs on linux
16:59hiredmanChousuke: I don't mind, obviously
16:59hiredman~emacs
16:59clojurebotemacs is best configured for Clojure with instructions at http://technomancy.us/126
17:03duncanmdrewr: hey, i think there's a little bug in the swank startup script?
17:03duncanmNo value supplied for key: true in 19: swank.commands.basic$eval__1000$load_file__1002.invoke(basic.clj:133)
17:04duncanmdoes it have something to do with this line? (swap! stop (fn [_] true))
17:04duncanmhmm
17:04drewrduncanm: likely, I haven't tested it with any recent swank
17:05drewrthis is the version I'm using with that code you saw: 20090804201540+bfb55c4
17:06The-KennyI really dislike the installation process of swank-clojure... I managed to set up my own environment, but I'm afraid to update swank-clojure because I don't want to break it.
17:08rhickeyok - keyword call sites are in place in new branch
17:12duncanmcool
17:14technomancyThe-Kenny: you dislike M-x clojure-install or the new process from the maven branch?
17:14The-Kennytechnomancy: M-x clojure-install
17:15technomancyThe-Kenny: you'll be happy to hear it's going away... check out the latest on my maven branch.
17:16The-Kennytechnomancy: The best way (in my opinion) would be to just put the emacs-files together with the clojure-files somewhere, load the files in emacs and configure some of the variables (path to clojure.jar etc.)
17:16javucciThe-Kenny, i use debian lenny and package-list-packages doesn't exists
17:16The-Kennyjavucci? I think you want to talk to someone else here :)
17:17javuccihow to make package-list-packages avaiable in emacs?
17:18technomancyjavucci: http://tromey.com/elpa/install.html
17:19javuccithanks technomancy
17:25patricius_are there anyone here using VimClojure?
17:28hiredmanI'm using the static part of vimclojure
17:28patricius_ok
17:28patricius_Well, for one thing, I can't get indenting to work
17:29patricius_it detects the filetype, but when I write "(defn function-name [] <ENTER>" it doesn't indent
17:30patricius_perhaps there is a more suitable channel for this? maybe a forum?
17:30patricius_couldn't find one tho
17:32hiredmanpatricius_: do you have all the thing it recommends setting?
17:32hiredmansyntax on
17:32hiredmanfiletype plugin indent on
17:32hiredmanfrom the README.txt
17:32patricius_let me double check
17:33hiredmanI haven't actually messed with vimclojure since I installed whatever version I am using many months ago
17:36patricius_those options are set as suggested in README.txt. Syntax highlighting seems to work fine.
17:37hiredman*shrug*
17:37hiredmanthe author is in here from time to time
17:38patricius_darn it
17:38hiredmando you have any other indeinting options set?
17:38patricius_but do you use vim for your day to day clojure programming?
17:38hiredmanyes
17:38patricius_I don't think I do
17:39hiredmanfor I think the gvim window on my netbook has tabs with clojure, c, sh, llvm ir, and maybe latex
17:40hiredman:P
17:40patricius_:)
17:40patricius_hiredman: you're thinking about 'lisp' and 'autoindent' options perhaps=
17:40hiredmanpatricius_: no idea
17:40patricius_:)
17:41hiredmanI was just asking without thinking of anything specific
17:41patricius_thought so
17:41patricius_but as I said, I don't think I have any other options set... not from looking at my .vimrc and gvimrc
17:42technomancyhiredman: so when are we going to start up the Seattle Clojure group? =)
17:42hiredmanpatricius_: what does :set filetype say on a clojure file
17:42patricius_filetype=clojure
17:42hiredmantechnomancy: it's more of a duo with just the two of us
17:42patricius_hiredman: syntax hilighting works it seems
17:43technomancyyeah, "group" might be a bit of a stretch
17:43technomancyactually the clojure users' map lists two others
17:43patricius_i talked to two mormon girls from Seattle today... in Denmark (Northern Europe) - aren't you happy to know that?
17:44hiredmanand what would we do? I could give a presentation on why "->" is awesome which will just be a bunch of confusing code wrapped in several layers of parens
17:44technomancywe could work on the Grande Unified Clojure Dependency Mechanism
17:45hiredmanclojurebot: translate to fr: Grand Unified Clojure Dependency Mechanism
17:45clojurebotGrand Unified Clojure dépendance Mécanisme
17:45hiredman:/
17:45technomancycd sa-safe
17:46technomancybah; wrong window
17:46rsynnott_slightly less than impressive
17:46rsynnott_does its 'translate to french' function just entail adding random accents? :)
17:46hiredmanrsynnott_: it uses google translate
17:46hiredmanclojurebot: translate to de: Grand Unified Clojure Dependency Mechanism
17:46clojurebotGrand Unified Clojure Dependency Mechanismus
17:47technomancyrsynnott_: that would be random accents using Markov Chains, thankyouverymuch!
17:47hiredmanclojurebot: translate to de: grand unified Clojure dependency mechanism
17:47clojurebotGrand Unified Clojure Abhängigkeit Mechanismus
17:47hiredmanzounds
17:48hiredmanclojurebot: translate to de: great unified Clojure dependency mechanism
17:48clojurebotgroßen einheitlichen Clojure Abhängigkeit Mechanismus
17:48lpetittranslate from fr to en: bonne nuit
17:48hiredmanGECAM
17:48lpetit:)
17:48lpetitwhoops
17:48lpetitclojurebot: translate from fr to en: bonne nuit
17:48clojurebotto in: good night
17:48rsynnott_heheheh
17:49hiredmanclojurebot: translate from de großen einheitlichen Clojure Abhängigkeit Mechanismus
17:49clojurebotlarge, single Clojure dependent mechanism
17:49hiredmannice
17:51Chousukeclojurebot: translate to fi: great unified Clojure dependency mechanism
17:51clojurebotsuuri yhtenäinen Clojure riippuvuuden mekanismi
17:51Chousukenice try :P
17:52hiredmanclojurebot: translate from fi suuri yhtenäinen Clojure riippuvuuden mekanismi
17:52clojurebothigh dependence on a single mechanism for Clojure
17:52Chousukethat's closer to "Large unified mechanism of Clojure addiction"
17:52hiredmanChousuke: haha
17:52hiredmanperfect
17:52hiredmanSYCRM
17:52Chousukethough even that is fairly liberal
17:54hiredmanLUMOCA
17:54hiredmanLarge Unified Method Of Clojure Addiction
17:54Chousuke"unified dependency handling system" would be something like "Yhtenäinen riippuvuuksienhallintajärjestelmä" which Google translate will no doubt fail to translate because of the huge compound word :P
17:56ChousukeThe method GT uses for translation doesn't map very well between English and Finnish :/
17:56Chousukebecause it isn't capable of breaking compounds into their constituents
17:57hiredmanah
17:57hiredmanthe statistical translation bits
17:57hiredmanclojurebot: translate to kr hello
17:57hiredmanwhoops
17:58hiredmanclojurebot: translate to ko hello
17:58clojurebot안녕하세요
17:58hiredmannice, don't have the right fonts
17:58ChousukeI do, but I can't read korean ;/
17:58hiredmanbut pasted else where that looks about right
17:59Chousukeclojurebot: translate from ko: 요
17:59clojurebotJohn
17:59Chousuke??? :D
17:59hiredmanweird
17:59hiredmanmore like Yo
17:59hiredmanor Yoh
18:00hiredmankorean as a bunch of dirrent yo sounds that I could never tell apart that are always transliterated slightly differently
18:00hiredmanI mean, they all sounds like "yo" to me
18:01ChousukeI don't know much about Korean but I hear it's quite similar to Japanese, structurally at least.
18:01spuzclojurebot: translate from ko: 녕
18:01clojurebotGoodbye
18:02spuzheh, awesome, "Hello" has "Goodbye" encoded within it in Korean
18:02ChousukeI really got a good laugh out of the "John" :P
18:02spuzI can't even see these characters which makes it all the stranger
18:03spuzclojurebot: translate from ko: 하
18:03clojurebotSummer
18:03hiredmanputty shows them as little boxes
18:03spuzclojurebot: translate from ko: 세
18:03clojurebot3
18:03spuzclojurebot: translate from ko: 요
18:03clojurebotJohn
18:04spuzwow, all that just to say Hello :)
18:04Chousukewell, korean writing is phonetic :P
18:04hiredmaneach of those boxes is actually comprised of multilple characters too
18:04hiredmansome combination of consonant and vowel
18:04Chousukeyou have goo in good morning too :)
18:07Chousukethe usual Japanese word of hello is interesting. It's actually an abbreviation of some sentence that probably was something like "Today is a good day" originally.
18:07Chousukebut it's been abbreviated to just "today (is)" and lives as its own word :P
18:09ChousukeI think it might be the only word that has a grammatical particle permanently affixed to it :/
18:18cemerickis anyone else getting this building the new branch: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (PrettyWriter.clj:17)
18:18hiredmancemerick: typically it means you need to rebuild contrib
18:19cemerickhiredman: yeah, I'm clean-building it :-/
18:21cemerickhrm, maybe not. I've got this nifty rebuild-clojure target, but it doesn't specify clean + jar for the contrib subant, only jar.
18:22cemerickyeah, nevermind. Damn stupid operator error.
19:38cemerickoh, no, PersistentStructMap is final now :-/
19:39rhickeycemerick: you weren't deriving from a concrete class, were you?
19:40cemerickrhickey: I was for my über-struct macros.
19:40rhickeyit needn't be final, just a remnant from some perf tweaks... hang on
19:41cemerickrhickey: I wouldn't bother...there's more to it than the final.
19:41cemerickThere was also the constructor, and the makeNew (or whatever it was called) method that allowed for polymorphic assoc, etc.
19:41rhickeylike what?
19:41cemerickconstructors*
19:42cemerickI'm happy enough to rip out all of the über-struct garbage, and see what falls out. It'll make the porting process more interesting :-)
19:43rhickeycemerick: there was that stuff where?
19:44rhickeyI don't think there are any external differences at all
19:44rhickeyother than the final
19:45rhickeyI just made it so the keyslots could be an arraymap
19:46cemerickthere was the protected constructor PersistentStructMap(IPersistentMap meta, Def def, Object[] vals, IPersistentMap ext) and the protected PersistentStructMap makeNew(IPersistentMap meta, Def def, Object[] vals, IPersistentMap ext) method.
19:46cemerickoh, those are still there :-/
19:46rhickeyright
19:46cemerickIt's been a rough couple of days, sorry. :-(
19:47cemerickIn that case, I'll just twiddle it to not be final.
19:47cemerickPardon the interruption.
19:48rhickeyit's fixed
19:49rhickeycemerick: the tweaks I made make a big perf difference - there's still more to do, but I imagine people will move to deftype
19:50cemerickrhickey: Thanks very much. I can totally understand you wanting to make it final, though.
19:51cemerickThat's my second chicken-little-esque moment in an hour, which is a new personal record.
19:52rhickeyno worries - did you try out deftype yet? It screams vs defstruct, 3x as fast as the improved defstruct version that's there in new
19:52cemerickrhickey: I'm in the process now :-)
19:53rhickeykeyword call sites - (:field x) now same speed as (.field x) for deftype
19:53blackdog_i don't see a branch for deftype or is it right in git head?
19:53cemerickblackdog_: it's in the 'new' branch
19:54blackdog_ok, i need to visit github
19:54blackdog_ta
19:56cemerickrhickey: Not sure what you're seeing, but I think there's another tipping point falling. Lots of totally green folks in here lately, and I got my ear chewed off by two completely random programmers who aren't generally language enthusiasts over the weekend about how much they were enjoying *using* the language.
19:57rhickeyyeah, it keeps growing
19:58weissji'm doing euler probs in clojure right now. its fun
19:58weissjit's like i have a power tool in my hands that i know can do just about anything if i just figure out how to use it :)
20:04churibweissj: which problem do you currently work on?
20:04weissjchurib: #14
20:05churibi am on #7
20:05weissjchurib: cool, i just did that one last night, i can help you if you need it
20:05churibit really makes fun!
20:07churibi am currently trying to replace the multiplications by sums
20:08weissjchurib: #7? find the 10001st prime?
20:08churibhm wait :)
20:08churibokay, i am #6
20:08weissjah haven't tried that one
20:08churibbut 7 is already solved :)
20:20weissjchurib: can i see your solution for #7
20:22sraderjust tried out the new deftype :field perf improvement. Wow! Almost the same as .field now.
20:23rhickeysrader: it is the same as field on my tests
20:23rhickeyas .field
20:25sraderI ran my tests individually now and get = perf. Not sure why when running as a batch they were slightly different.
20:25rhickeyalthough every now and then hotspot does less with it than most other times
20:27rhickeysrader: you have to make sure you are getting a non-polymorphic call path, the cache will only fully inline if the call path has only seen one type, once more than one type you get a slight reduction from then on
20:28sraderok, thanks
20:29rhickeyi.e. if you have a fn that reads :a :b and :c of its args, and flow a ton of the same deftype through it, it will be fastest. Then send some structs or arraymaps with :a :b :c keys through the same fn, will be slower (as expected) but going back to the original deftypes will also be slower
20:30hiredmandoes hotspot ever re-inline?
20:30rhickeyhiredman: I don't know why it couldn't, but I didn't see it
20:31rhickeybut that's really a non-use-case of this, since .field isn't polymorphic ever
20:32rhickeyso, in cases where you are defining methods of a protocol for some deftype Foo, that code will only ever see Foos
20:32hiredmanuhhuh
21:00weissjcan i get a hint how to convert '(\2 \1 \3) char seq into the number 213 ?
21:02tomoj,(Integer/parseInt (apply str '(\2 \1 \3)))
21:02clojurebot213
21:02rlbweissj: maybe not the best approach, but (Integer/praseInt (apply str x)) should work
21:02rlbs/praseInt/parseInt/
21:03weissjthx tomoj and rlb for your near simultaneous and identical solutions :)
21:03rlbI just assume there's some awesomely clever clojure solution I don't know about yet...
21:03tomojread-string looks more clojure-ish but can be dangerous I think
21:04tomojI mean if you don't have control over the chars coming in
21:04weissjtomoj - i do - i am trying to basically right-circular shift a number
21:05weissjie 321 -> 132
21:06hiredman,(-> 321 Integer/toString)
21:06clojurebot"321"
21:07hiredman,(-> 321 Integer/toString cycle ((partial take 4)))
21:07clojurebot(\3 \2 \1 \3)
21:07hiredmanrmmm
21:08hiredman,(-> 321 Integer/toString cycle ((partial repeate 2)) ((juxt first (comp reverse second))))
21:08clojurebotjava.lang.Exception: Unable to resolve symbol: repeate in this context
21:08hiredman,(-> 321 Integer/toString cycle ((partial repeat 2)) ((juxt first (comp reverse second))))
21:08hiredmanuh oh
21:08hiredmanclojurebot: ping?
21:09hiredman,(-> 321 Integer/toString ((partial repeat 2)) ((juxt first (comp reverse second))))
21:09hiredmanhmmm
21:09hiredman,(repeat 2 "321")
21:09hiredmanhuh
21:11tomojyou killed him
21:11hiredmanthats just odd
21:12hiredmanuser=> (repeat 2 "321")
21:12hiredman("321" "321")
21:14hiredman,(repeat 2 "321")
21:14clojurebot("321" "321")
21:14hiredman,(-> 321 Integer/toString ((partial repeat 2)))
21:14clojurebot("321" "321")
21:15hiredman,(-> 321 Integer/toString ((partial repeat 2)) ((juxt first (comp reverse second))))
21:15clojurebot["321" (\1 \2 \3)]
21:15hiredman,(-> 321 Integer/toString ((partial repeat 2)) ((juxt first (comp reverse second))) ((partial apply concat)))
21:15clojurebot(\3 \2 \1 \1 \2 \3)
21:16hiredmanhuh, thats not helping
21:16dysingerls
21:16dysingerlol oops - emacs!
21:17tomoj,(+ (* (mod 321 10) (reduce * (take (dec (.length (str 321))) (repeat 10)))) (quot 321 10))
21:17clojurebot132
21:17hiredman((fn [x] (Integer/parseInt (apply str (last x) (butlast x)))) "321")
21:17hiredman,((fn [x] (Integer/parseInt (apply str (last x) (butlast x)))) "321")
21:17clojurebot132
21:18tomojooh nice
21:18hiredmanhmmm
21:19hiredman,(+ 132 9)
21:19clojurebot141
22:14tomojI'm considering writing macros that communicate with an external server when compiled
22:14tomojis this evil
22:14tomoj..seems like it is probably evil
22:20robinkAnyone know of a Gentoo ebuild for Compojure?
22:22dysingerhttp://build.clojure.org :)
22:23danlarkintada!
22:24rhickeycool
22:28dysingeryou can download the latest jar straight from the site
22:28dysingeror you can use it for a maven repo
22:29dysingerrhickey: sign up and I'll admin you
22:30rhickeyI'm in
22:30dysingeryour name ?
22:30dysingerrhickey ?
22:30rhickeyrichhickey
22:30dysinger1 sec
22:31dysingerdone
22:32rhickeythanks
22:33dysingeryou can add yourself to the build notifications at the bottom of the project "configure" screen
22:35rhickeywill it build branches?
22:36dysingerI think so
22:36dysingerthere's a spot to configure branches in there
22:36dysingerwe'll have to fiddle with it
22:37rhickeyfound it
22:38dysingerdo you want */new or just new ?
22:39dysingerI don't know - just curious
22:39rhickeygot me
22:41dysingeroh when you save it changes new to */new
22:41dysingerI put lazy in there too just for kicks
22:41rhickeylazy is over
22:41rhickeyonly master, new and par are active
22:42hiredman:D
22:43hiredmanmy clojure hello world appengine app is up
22:43hiredmannow to figure out the facebook api
22:44dysingerrhickey: http://build.clojure.org/job/clojure/13/ :)
22:45dysingerpar didn't work http://build.clojure.org/job/clojure/14/console
22:45rhickeypar needs support lib
22:46rhickeyhttp://cloud.github.com/downloads/richhickey/clojure/jsr166y.jar
22:46rhickeyand to be built for java 6
22:46rhickeyso, I'm happy with master and new
22:47dysingerthis is ubuntu karmic - I think it only has java6
22:48rhickeythen it just may be matter of having jsr166y.jar next to clojure.jar
22:53rhickeyand in classpath
22:54dysingerrhickey: current bug in hudson https://hudson.dev.java.net/issues/show_bug.cgi?id=4422
22:54dysingerwe'll have to watch for that
22:54dysingerand not go crazy with branches right now
22:56rhickeynew would be the only one I care about, as I'd like people to try it. It builds, tests, and builds contrib + tests before I check it in
22:57dysingerI fixed it - so it's new and master for now
22:57rhickeygreat
22:57rhickeyI wish it showed the branch more prominently in the views
23:01rhickeyThanks again, I don't intend to muck with it
23:02dysingerheh
23:05qedhow does clojure clean up old versions of persistent tree structures?
23:05rhickeyqed: gc
23:08qedrhickey: im having a little trouble wrapping my mind around persistence and the idea of tries-- structural sharing and all of that
23:09qedit just seems sort of...well...impossible
23:09qedhow does the garbage collector know when it can safely prune a version of the tree?
23:10notallamasame way it knows when it can prune anything else
23:10solussdI want an infinite lazy seq of random ints, but this produces "less than random" looking ints: (iterate rand-int 100)
23:10qedhow's that, notallama?
23:11hiredmannew versions of the datastructure don't keep references to the entire previous version, just the parts that it needs
23:11tomojsolussd: think about what iterate does
23:11solussd,(take 10 (iterate rand-int 100))
23:11clojurebot(100 98 49 12 6 0 0 0 0 0)
23:11notallamawhen you make a 'change' to a tree, you're really making a new root, which is an almost-copy of the old root. one of the nodes is another new almost-copy, etc.
23:11solussdoh, i see tomoj
23:11tomojyou're getting s0=(rand-int 100), s1=(rand-int s0), s2=(rand-int s1),...
23:11tomojwhat you want is probably (repeatedly #(rand-int 100))
23:12solussdthanks
23:12tomoj(actually s0=100, and then on from there)
23:12notallamaand the garbage collector can walk from the roots of all the trees (which share nodes). anything that it can't reach can be freed. (it uses tricks so that it doesn't have to walk the trees all the time, though)
23:13tomojI would like to know what the expected length of (take-while (complement zero?) (iterate rand-int n)) is, though
23:13solussdi like this: (take 50 (distinct (repeatedly #(rand-int 100)))) *being able to specify I want an infinite list of distinct items. :)
23:13solussdeven though there are only 100
23:14solussdhangs ... forever?
23:14solussd,(take 101 (distinct (repeatedly #(rand-int 100))))
23:14clojurebotExecution Timed Out
23:14solussdheh
23:25tomojhmm, seems to be about log(x)+1.6 (if you count the first zero as well)
23:34tomojthe answer appears to be about log(n)+0.575
23:36tomojoops, wrong channel
23:38hiredmanhttp://mrepo.happyfern.com/sites/facebook-java-api/facebook-java-api/apidocs/index.html this is horrible
23:40somniumhiredman: it always helps when everything is piled into one package. have you graphed it?
23:40tomojwhat pisses me off is that we can't send messages through the API
23:40tomojonly read them
23:42hiredmanfacebook seems to wnat to make it as hard as possible to write a facebook app in a language other than php
23:42somnium:)
23:47hiredmanI'm still trying to figure out their login model
23:47hiredmanor whatever it would be called
23:47solussdwhat's wrong with this? It's throwing an illegal argument exception: (take 10 (distinct (repeatedly #([(rand-int 100) (rand-int 100)]))))
23:48tomojyou can't put a vector like that in a #()
23:48tomojyou could use vector instead
23:48solussdI want 10 vectors of 2 random ints
23:49tomoj,(take 10 (distinct (repeatedly #(vector (rand-int 100) (rand-int 100)))))
23:49clojurebot([67 79] [85 41] [84 62] [54 26] [90 77] [68 27] [15 93] [14 5] [25 13] [30 33])
23:49solussdah- i was trying to use vec, but that takes a coll
23:49solussdthanks
23:50tomojit's because of what #() is
23:50tomojwhat is it again?
23:50solussdmacro?
23:50tomojah, yeah, #(foo) is (fn [] (foo))
23:51tomojso #([foo]) is (fn [] ([foo])) which is wrong
23:51tomojyou could write (fn [] [foo]) as well
23:51tomojor #(vector foo)
23:59Puzzler?
23:59G0SUBI am not sure if Tim Bray criticised or appreciated Clojure in his blog post http://www.tbray.org/ongoing/When/200x/2009/11/03/Clojure-N00b-Advice