#clojure logs

2009-11-10

00:00_atohmm
00:00_ato,(split-with #{" "} "foo bar")
00:00clojurebot[() (\f \o \o \space \b \a \r)]
00:00_ato,(map str (split-with #{" "} "foo bar"))
00:00clojurebot("clojure.lang.LazySeq@0" "clojure.lang.LazySeq@3f32ee98")
00:01_ato,(map #(apply str) (split-with #{" "} "foo bar"))
00:01clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--5184$fn
00:01hiredman
00:01_ato,(map #(apply str %) (split-with #{" "} "foo bar"))
00:01clojurebot("" "foo bar")
00:01_atonevermind
00:01qedthere are also the str-utils clojure-contrib libs
00:01qedwhich have a re-split in them
00:01hiredman,(doc split-with)
00:01clojurebot"([pred coll]); Returns a vector of [(take-while pred coll) (drop-while pred coll)]"
00:01_atoh right
00:02_atoI was thinking of partition-by
00:02_atowhich wouldn't have worked anyway
00:04sudoerwhat does the . mean here? (. parsedLogFlow start)
00:05hiredman. is the java interop special form
00:05_atosame as: (.start parsedLogFlow)
00:05hiredmanor (parsedLogFlow/start)
00:05_atocall the .start() java emthod on paresedLogFlow object
00:05hiredmanor possibly parsedLogFlow/start
00:06hiredman_ato: could be field access
00:06_atoah yeah true
00:07sudoerI see, what is the point of it then?
00:07sudoeroh, so I can do oop with java?
00:07hiredmanno
00:07hiredmanit is for java interop
00:08hiredman(don't do oop)
00:08wavisdoes assoc return a sorted map when given a sorted map?
00:09_atowavis: yes
00:09waviscool. if it uses a custom comparator, that's also preserved, i presume?
00:09_atoyep
00:09wavisgracias
00:10sudoerwhat does it mean when you say java interop?
00:11_atosudoer: interoperating with code written in java. for example using a java library in a clojure program
00:11hiredman,(Math/sqrt 25)
00:11clojurebot5.0
00:12hiredman,(macroexpand '(Math/sqrt 25))
00:12clojurebot(. Math sqrt 25)
00:12wavis,(.exists (File. "/etc"))
00:12clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: File
00:12wavis,(.exists (java.io.File. "/etc"))
00:12clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission /etc read)
00:13sudoerok, I understand
00:14sudoeram I supposed wrap those calls with dorun? I see java interop cored wrapped in dorun, I read the dorun definition, but I am not sure why I would use it
00:14hiredmanuh
00:14sudoersorry, im a clojure newb, I assume my question made no sense?
00:14hiredmanright
00:15hiredmanhave you read the doc for dorun?
00:15hiredman,(doc dorun)
00:15clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
00:15sudoerI am tryint to understand what this does: (dorun (. parsedLogFlow start) (. parsedLogFlow complete))
00:15sudoertrying to understand why dorun is used there
00:15hiredmansudoer: maybe a typo
00:15hiredmanI would guess they meant to use do
00:16sudoerthe code works
00:16hiredmansure
00:16hiredmanbut that could just be an acident
00:17hiredmanit also looks like either old code, or code by someone not so plugged into the clojue community
00:17sudoerits a clojure newbie
00:17hiredmanbecause of the direct use of the . form
00:17somniumthe source for do run is shorter than its doc string
00:17hiredman:P
00:18qedhow do i keep track of the number of times ive called a function, inside of a function
00:18hiredman
00:18hiredmanseriously?
00:18qedis that a stupid question?
00:19hiredmanI guess it depends, but it kind of seems like it is
00:19qedi mean, here's the deal
00:19qedi have this function: (defn step [n] (if (even? n) (quot n 2) (+ (* 3 n) 1)))
00:20qednow i have another function that continues to call step until we can't go any lower
00:20qederr until we hit 0
00:20hiredmanI know this problem
00:21qedi want to find out which number i input <1000000, that has the most number of steps
00:21hiredmaniterate+filter+sort+count
00:21qedso im trying to determine how many steps something takes
00:21hiredmannot filter. take-whil
00:21hiredmanqed: like I said, I know this problem
00:21qedhey i believe you
00:21qedim just explaining my reasonining
00:21qedreasoning
00:22qedi dont really understand how to write what you're describing
00:23qedhow does sort+count work?
00:23qedin this context
00:24somnium let me check my euler dir
00:24qedsomnium: thanks, not trying to cheat if i can avoid it
00:24qedthat's boring
00:24hiredmanyou sort the results of interate+take-while
00:25hiredmanwhich will give you longest chain
00:25hiredmanand the first thing in the chain will be the number
00:25hiredmanodd, I can't find this in my euler.clj
00:26somniumits the collatz one
00:26qedoogatz
00:27hiredmanclojurebot: hiredman's euler.clj?
00:27clojureboteuler is http://clojure-euler.wikispaces.com/
00:27hiredmanbah
00:27hiredmanclojurebot: hiredman's euler.clj
00:27clojurebothiredman's euler.clj is so embarassing
00:28qedi wont be going there heh
00:28somniumall my solutions were painfully slow :(
00:28somniumbut there's an easy bi... nm
00:28technomancy_ato: yeah, I'm going to make leiningen use build.clojure.org as a default repo before I hit up the release.
00:28sudoerhiredman: so is the dorun useless in that situation?
00:28technomancy_ato: all the functionality is there, it just needs a bit more polish, particularly in the bash script
00:29hiredmansudoer: it's hard to say, if those java methods return lazy-seqs that you want to realize for side effects it would make sense, but not otherwise
00:29hiredmanand I doubt they do
00:29qedim not understanding tak-while
00:29hiredmanI would guess they meant to use do
00:29qed(take-while (> 3) [1 2 3 4 5 6 7 8])
00:30qedhow would i do that?
00:30hiredmanqed: (> 3) is not a function
00:30hiredmanso it would not
00:30qed(take-while (> [1 2 3 4 5 6 7 8] 3)) ?
00:30hiredmanyou need something like (partial > 3) or #(> 3 %) or (fn [x] (> 3 x))
00:30hiredmanqed: no
00:31qedah yes this partial business
00:31somniumqed: (take-while #(> % 1) (iterate (fn [n] (if (even? n) (/ n 2) (inc (* n 3)))) 9))
00:32somniumoops, meant to send that one to the bot
00:32somniumthat gets you a function that returns an expansion, try to take it from there
00:33qedthanks somnium
00:33qedim off for the evening
00:33qedthanks hiredman and all for the help
00:46twbrayWondering if it's evil to use send-off with a placeholder first arg just because I want a long-running operation in its own thread. More idiomatic to just create a new thread?
00:50_msttwbray: `future' provides an easy way of spawning a new thread
00:50_mst,(doc future)
00:50clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."
00:50twbray_mst: Thanks, will check that out.
00:50twbrayI guess I can just do (.start .... as well
00:51wavis,(send-off (agent nil) #(Thread/sleep 9999))
00:51clojurebot#<Agent@1aacdc9: nil>
00:51wavisi was expecting to be locked out of that one
00:51_mstyep, (.start (Thread. #(...)))
00:52_atoah neat, scp uses a really trivial protocol so I can just make it talk to my own code that verifies the uploaded files and if they're okay puts them into the right place in the repo :)
00:52twbraywavis: (send-off (agent nil) makes me uncomfortable....
00:52_atohttp://blogs.sun.com/janp/entry/how_the_scp_protocol_works
00:53_atoand that dispatch on ssh key thing that github does is easy too, you can just add a command=whatever to the end of each line in authorized_keys and it'll run it instead of the user's shell or scp or whatever :)
00:53wavistwbray: i suppose if you're starting with nil and want to immediately start initializing it, it could be practical. it does return the agent after all
00:54_mst_ato: yep, probably a good idea not to let them run whatever command they want ;)
00:54shoovertwbray: I've seen several examples where an agent calls send-off on itself as a loop with a quit check. See the bottom section of http://clojure.googlegroups.com/web/ants.clj
00:55twbrayshoover: thanks
01:00hiredmanapache-mina has some kind of sshd in java
02:07piccolinoLazy sequences don't have to be infinite do they?
02:10hiredmannope
02:10hiredman,(map inc (range 10))
02:10clojurebot(1 2 3 4 5 6 7 8 9 10)
02:10piccolinoI didn't think so.
02:10piccolinoBut then I'm having a hard time understanding what exactly lazy-seq wants. How do you terminate the sequence?
02:11hiredmannil
02:11piccolinoOh, OK.
02:11hiredman,(lazy-seq (cons 1 nil))
02:11clojurebot(1)
02:11piccolinoI thought nil could be a part of a list, so I thought that would be alright.
02:11hiredmanit's not really about what lazy-seq wants, but what cons wants
02:11hiredman,(lazy-seq (cons 1 '()))
02:11clojurebot(1)
02:12hiredmanpiccolino: nil can be part of a list
02:12hiredmanbut the second form in a cons is not an item in a list
02:12hiredmanit is a list (or nil)
02:12piccolinoAh, OK. So you can't use lazy-seq with conj?
02:13hiredmannever seen it done
02:16piccolinoMan, this doc string still makes no sense to me. "yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequence seq calls."
02:17piccolinoHow do I make an indefinitely long sequence that will definitely end at some point?
02:17piccolinoI don't want the same expression called over and over, I need it work through some data.
02:29hiredman,((fn a [n] (when (not (zero? n)) (lazy-seq (cons n (a (dec n)))))) 10)
02:29clojurebot(10 9 8 7 6 5 4 3 2 1)
02:30hiredmanusually you can get by with the various sequence functions with out resorting to lazy-seq
02:30piccolinoYeah, I was looking at iterate, but it says the function must be side-effect free.
02:31hiredman*shurg*
02:31piccolinoI apprecite it, though, that's helpful.
02:31piccolinoI find it confusing just what exactly lazy-seq returns and how it does its thing.
02:32hiredmanlazy-seq returns a lazy seq
02:32piccolinoAlso, it requires recursion on a function?
02:32hiredmanit's generally how it's done
02:33piccolinoYes, a lazy seq, but how exactly that contains my code, is what I mean.
02:34hiredmanessentially you construct a list
02:34piccolinoLike, in the cons in your lazy seq, if you call first on the lazy seq, clearly the cons has to be executed, but the second argument is deferred?
02:34hiredmanthe second are evals to a lazy-seq
02:34hiredmanarg
02:34piccolinoOh, duh.
02:35piccolinoI think I got it.
02:35piccolinoLess magical than I thought.
02:35hiredman:)
02:45piccolinoUrg. cons forces me to build it in backwards order.
02:47piccolinoOh nevermind.
02:48Chousukelazy-seq is kind of cheating :)
02:48Chousuke"here, I'm consing to this sequence that doesn't exist yet"
02:55piccolinoI have no idea how to explain it better, but I sure wasn't gonna understand that just from the docs.
03:01wavisIf I create a function inside of a dosync, and the function references a ref, will the snapshot state of the ref be captured, or will, the function deref again later each time it is called?
03:01tomojcreating a function inside of a dosync sounds like a really bad idea
03:02waviswhy?
03:02tomojwell, ok, not a _really_ bad idea
03:02tomojcompiling the function should have state side effects, it shouldn't need to be in a dosync
03:03tomojtry this
03:03tomoj(let [foo (atom 5)] (defn bar [n] (swap! foo + n)))
03:03tomojthen do (bar 3), (bar 4), whatever
03:04tomojyou don't need a dosync you just need to close over the state
03:05tomojuh, also, s/should/shouldn't/
03:05wavisi hear you. the function doesn't have side effects though. i have to create *a* function inside, but I could create one that references the ref outside, and have the inside function call the outside function
03:06tomojI dunno what you mean
03:07wavisso (let [a (ref nil) fa (fn [] @a)] (dosync (stuff) (fn [] (fa))))
03:09wavisfa gets the state of a
03:09wavisthe function created in the dosync just calls fa
03:09clojurebotfunction is <Chouser> there is one class per fn, one instance of it per closure
03:09tomojwhy do you need fa
03:09tomojI mean, why can't you just put (fn [] @a) inside the dosync
03:10wavisthat's the question. will calling that anonymous function return to the state of the ref inside of the original dosync, or will it deref the new state of the ref
03:11tomojI still think wrapping a dosync around the fn is... strange
03:12wavisi'm altering a ref and setting it to (proxy [stuff] (stuff [])) ... i guess i could create the proxy outside the dosync
03:14tomojI think the answer to your question is that it will be deref'd again and again
03:14tomojcreating the function doesn't store the value anywhere
03:14tomoj,(let [a (ref 3) fa (fn [] @a)] (dosync (alter a + 4) (fa)))
03:14clojurebot7
03:15wavisok i'm going with that. It's what I intuitively expect, but I wasn't sure
03:17wavis,(let [a (ref 3) fa (fn [] @a) fb (dosync (alter a + 4) fa)] (dosync (alter a + 1)) (fb))
03:17clojurebot8
03:18waviser. that actually doesn't do anything different. anyway...
03:19wavis,(let [a (ref 3) fa (fn [] @a) fb (dosync (alter a + 4) (fn [] @a))] (dosync (alter a + 1)) [(fb) (fa)])
03:19clojurebot[8 8]
03:19wavisthere.
03:23tomojyeah I don't understand the point of that at all
03:50osaundersCan you get a reference to the current function?
03:52Chousukeyou can give it a local name as in (fn foo [] ... (foo ...))
03:52osaundersYou can't not give it a name?
03:53osaundersI mean, you can't do it without giving it a name?
03:53Chousukethat's correct
03:53Chousukethere's no "this"
03:53Chousukebut the name is local, so if you need it there's no harm in giving it one.
03:54Chousukeit'll also make stacktraces more readable
03:54osaundersOK.
03:55osaundersYou're only supposed to be able to def once right? If I def foo to 1 I shouldn't be able to def it to 3 again later. I should need set! to do that. Is the REPL an exception to that rule?
03:56Chousukeyou can use def as many times as you want
03:56Chousukeyou only shouldn't :)
03:56osaundersRight, OK.
03:56osaundersBecause I was thinking that would be funny with recursion.
03:56osaundersBecause if you have defs inside your function you'd re-def them each recursion.
03:57Chousukeyeah. and that would be horrible. :P
03:57osaundersIf that wasn't allowed it might be a problem.
03:57osaundersYeah.
03:57Chousukedefs anywhere other than top level are a problem.
03:57sudoercan I have multiple "classes" in a clojure file?
03:57Chousukesudoer: gen-classed ones? not as far as I know.
03:58sudoercan I define java classes in a clojure file?
03:58Chousukewell, every function is a java class, so yes :P
03:58Chousukebut gen-class is for constructing custom classes.
03:58sudoerChousuke: the code I have uses gen class
03:58osaundersChousuke: Thanks for the help.
03:59Chousukebut often it's not needed. You can just use proxy.
03:59yasonosaunders: you can use (binding) to "change" defs within a certain dynamic scope.
03:59sudoerI am totally new to clojure, I am trying to port this to clojure http://code.google.com/p/cascading/wiki/CrawlDataWordCountCascade
03:59osaundersyason: binding?
03:59Chousukeand there are a couple new things upcoming that you will be able to use to create "classes" :)
03:59osaundersYou mean the [foo 1, bar 2] stuff?
04:00osaundersWait, no.
04:00osaundersI really don't know :-P
04:00sudoerso can I just write it as regular java and have that included in my program?
04:00yasonosaunders: it's one of Clojure's special forms
04:00Chousukesudoer: no, not like that :)
04:00sudoerhmm
04:01Chousukesudoer: if you have java code, keep it in a java file :P
04:01sudoeri dont even know how to program java
04:01Chousukebut you don't need to program java for that example.
04:01sudoerthis is going to be tough!
04:01Chousukeyou can implement the PipeAssembly subclasses through proxy
04:02sudoerChousuke: what do you mean proxy?
04:02Chousuke(doc proxy)
04:02clojurebot"([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
04:03sudoerChousuke: ok, I am reading about prozy now, my goal is to get this working today!!
04:04yasonsudoer: check out some of the Swing demo applications for Clojure, they generally use proxy to implement event listeners
04:04sudoerChousuke: have you programmed cascading before?
04:04sudoerso can I instanciate objects with proxy?
04:05yasonsudoer: they look like real objects to Java
04:06sudoercan I declare the fake class though?
04:06sudoeror must they be classes that already exist?
04:07yasonsudoer: you don't have to: just list the interfaces you want your proxy to emulate and implement whatever methods you know you'll need
04:08sudoeryason: how would I implement something like this where there are no methods, just the public interface? http://pastie.textmate.org/691616
04:09sudoercan I use proxy still for this situation?
04:10yasonsudoer: You're eventually going to need an instance of PipeAssembly at some point?
04:10sudoeryason: of ImportLogAssembly, not directly of PipeAssembly
04:11yasonsudoer: that's what you probably should proxy. In Java, you have to subclass something to implement your own stuff; in CLojure you proxy something to do that
04:12yasonsudoer: but ImportLogAssembly is just a subclass of PipeAssembly; I would assume that some Java code actually needs to do something with the PipeAssembly since ImportLogAssembly is clearly an implementation of it
04:13sudoerso can I still proxy in this situation?
04:13yasonsudoer: you generally don't want to replicate how the subclass hierarchy is generally built in the corresponding Java code. You want to narrow down to the essential interfaces/classes that you need in order to plugin to this framework
04:14yasonsudoer: I don't know, I don't know enough about this PipeAssembly thing to know that.
04:14sudoeryason: yes, I will call this later: Pipe importPipe = new ImportLogAssembly( "import pipe" );
04:14sudoeryason: that means I must be really familiar with the underlying java code I guess
04:14yasonsudoer: okay, so where is importPipe used then?
04:15sudoeryason: it gets called later like so: Flow importPagesFlow = new FlowConnector().connect( localPagesSource, importedPages, importPipe );
04:15sudoeryason: I am trying to port this example to clojure since I dont program in java: http://code.google.com/p/cascading/wiki/CrawlDataWordCountCascade
04:15yasonsudoer: connect() method takes a Pipe right?
04:16yasonsudoer: not PipeAssembly?
04:16sudoeryason: it appears so, yes
04:17yasonsudoer: so you probably want to proxy a Pipe so that you can do your own stuff with the pipe object
04:17yasonsudoer: but it seems to me that your example is a really bad one as for porting to clojure
04:18sudoeryason: its not a good fit? why is it bad?
04:18yasonsudoer: it seems to be mostly about how java does things; you would want to know what the hell that mess is _supposed_ to do and implement that in Clojure, in a clean way
04:19yasonsudoer: Java defines lots of classes and instantiates lots of objects because it has to. I almost never do that in Clojure because I write Clojure, not Java. I've only used proxy for Java interoperations and I try to minimize the interop parts of my code
04:19yasonsudoer: so the question is how to solve the same problem that Java code solves, instead of how to write that Java code in Clojure
04:20sudoerhmm, unfortunately there is only one example of cascading and clojure used together and it was written by a clojure newb
04:21sudoerand I'm a newb to both clojure and java
04:21somniumporting java to clojure without being familiar with either sounds like a painful endeavor
04:22yasonsudoer: you could learn the basics of Java first, say I/O and file operations. Then write that in Clojure.
04:22sudoeryeah, haha
04:22sudoeri mean I know basic java, but I really do not enjoy programming in java at all
04:23sudoeri wrote some apps for android a couple of years ago
04:24yasonsudoer: I don't like Java either so I like to keep it to the minimum.
04:24yasonsudoer: well take some very basic java program that only relies on the standard libraries and doesn't come with its own framework or anything, and try to do the same in Clojure
04:24sudoeri dont know any of the idiosyncrasies of java because I dont use it every day, I try to avoid it as much as possible
04:25sudoeryason: yeah, that is probably a good idea
04:25Chousukemost of that code seems to be news anyway
04:25sudoeror I could bite the bullet and write java for now, that would probably be the fastest route
04:27somniumFWIW, thinking of java as garbage-collected C helps me find it more tolerable ;)
04:27Chousukehm.
04:27sudoersomnium: objective c!
04:28somniumhmm, I think I'd rather have objective c if given the choice
04:28Chousukethose extended assembly classes are silly
04:28Chousukethey only have a constructor that calls a super method at the end :/
04:29yasonsudoer: how about just writing clojure and looking up Java as you go, on a need-to-know basis? That's what I practically did.
04:29sudoeryason: I want to write it in clojure
04:30yasonsudoer: so pick a problem that's generic and not in the Java problem space
04:32Chousukelooks like you can replace them with a function like (defn make-import-log-assembly [the-name] (let [p (PipeAssembly.) regex (RegexSplitter. (Fields. "url" "raw")) import-pipe1 (Each. name (Fields. "line"), regex) import-pipe2 (Each. import-pipe1 ...)] (.setTails p result-pipe) p))
04:33Chousukehopefully.
04:33Chousukeif PipeAssembly is abstract... :-(
04:33ChousukeIs proxy capable of defining the constructor?
04:34sudoerChousuke: that is a clojure question, not question about cascading?
04:35somniumChousuke: have you been using the new features?
04:35sudoerChousuke: I think it is abstract : http://www.cascading.org/javadoc/cascading/pipe/SubAssembly.html
04:36somniumI tried gen class, but it was 10x times slower than 100 lines of java
04:36yasonChousuke: I don't know but constructor in a proxy doesn't really make any sense because there's no object for you to construct.
04:38somnium~proxy
04:38clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
04:38Chousukesomnium: gen-class itself is not the problem.
04:38somniumyes, the function lookups and state I guess? at any rate, it will be wonderful if we can get java speed without ever touching java
04:38Chousukesomnium: it creates a plain java class. it's the clojure code that's slower, because it's more dynamic and using primitives is more difficult :)
04:39Chousukeit can be optimised, but it's not very easy to match java speed. not yet, at least.
04:39Chousukedefclass etc. are supposed to help with that
04:46somniumdoes recur compile down to a for-loop? the code I needed just looped along a hashmap subclass, if (x typeof y) PersistentFoo.create() ... but I didn't know how to optimize the clojure version
04:47somnium(using clojure.walk probably didn't help)
04:47Chousukedid you eliminate reflection?
04:49somniumit didn't touch java much, I just used #^hashmap.keyset which had strings and the rest in clojure
04:51Chousukethat would be #^HashMap$KeySet :)
04:51somniumit seemed the java was faster at creating clojure objects than clojure, though its entirely likely my clojure code was poor
04:51somniumyes, I don't actually recall :) just only one direct java call and then condp instance?
04:51somniumI probably used #^Set or something
04:52ChousukeOh well, I need to hurry away now. later.
04:52somniumbye
04:52sudoerChousuke: one question about regular java: importPipe = new Each( importPipe, new Fields( "url" ), new RegexFilter( ".*\\.pdf$", true ) ); <--- isnt that a bad writing style to rewrite teh variable with the same variable?
04:53Chousukesudoer: well, I think it's icky
04:53Chousukecertainly is in clojure, because it doesn't actually overwrite the old reference
04:53Chousukeit just shadows it.
05:28ordnungswidrighi
06:16AWizzArd~seen cemerik
06:16clojurebotno, I have not seen cemerik
06:17AWizzArd~seen AWizzArd
06:17clojurebotAWizzArd was last seen in #clojure, 0 minutes ago saying: ~seen AWizzArd
06:26KjellskiI´ve got a question about the clojure bit-mapped hash tries: When we add one new thing, the path to that thing need
06:26Kjellskis to be created.
06:27KjellskiSo, the pathes to every other thing begfore is just copied from old nodes?
06:27KjellskiI´m talking about these slides: http://clojure.googlegroups.com/web/ClojureConcurrencyTalk.pdf?gda=59CHlkwAAAB9TgGpbzbMg0BCq3i8IqXnCz2xnAVnahGaLFuwC71R5C1I1OtZCnFmn_w8aWW3nzHB8Gzz9WpxuUbp_zNxpCdh_Vpvmo5s1aABVJRO3P3wLQ
06:28KjellskiPage 21
06:28_atoKjellski: what do you mean by "every other thing" just the path to the node you add needs to be copied
06:29KjellskiI know, but the pathes to the old nodes, where do they come from? Do we just copy old path and add one entry to the bottom node?
06:30KjellskiIn other words: Is the copied path to the new node, a "java cloned" path that has all its entries and we´re adding one entry to the last one...?
06:32_atoKjellski: oh right. No the whole path has to be changed, not just cloned... as each copied node in the path will have a different address
06:33KjellskiBut Why? Wouldn´t it be just fine to copy every "not leaf" nodes until we get to the one that needs the new one?
06:35Kjellskichouser: Are you arround? ^^
06:35_atosuppose the path is nodes a b c. suppose our nodes currently look like a = [x b w], b = [c e r], c = [d e f]
06:36_atowe want to add a new value to node c
06:36_atowe create a new node C' with [d e f g]
06:36_atobut Clojure's data structures are immutable
06:36_atoso we can't just change b and a to opint at it, so we need to copy them too
06:37_atoso we make b' = [c' e r] and a' = [x b' w]
06:37_atoa' becomes our new referene to the data structure
06:39KjellskiHuh? a and b never changed. What I mean is just, looking at the picture of page 21 from the slides, our references in your example, to the xw and er and rf nodes, come from the old ones right? Our dashed lines to the shared structure, can be copied from old nodes...
06:40_atoyes, so x w don't change, but a and b need to because there's a new version of c, then there needs to be a new version of b that points at the new c, and thus there needs to be a new a to point the new b
06:41KjellskiOkay... that makes sense... sorry... I think I´ve got it. Thanks!
06:42KjellskiDo you know how "big" the node Objects are?
06:43_atoat most they have 32 entries, but they're only as large as they need to be
06:43_ato(plus wahtever java's normal object overhead is, probably 8 bytes or so)
06:44_atoalso the tree is really shallow, because each node has up to 32 branches
06:44_atoso the paths that get copied are really short
06:47KjellskiI think that is pretty neat. ^^
06:50ol3hello, i am searching for a pathname-type method
06:50_atoyeah, they're pretty amazing.
06:51ol3is there something like that in java?
06:51KjellskiWhat is a pathname-type method?
06:51_atool3: is that a CL thing? what does it do, return the file extensions?
06:52ol3it returns the type of the file, normally the file extension
06:55_atoas far as I know there's nothing built-in to do that
06:55KjellskiAnd in the not normal case?
06:55KjellskiWhy not just split at the last dot of path?
06:55_ato,(last (.split "foo.txt" "\\."))
06:55clojurebot"txt"
06:56_ato,(last (.split "foo.tar.gz" "\\."))
06:56clojurebot"gz"
06:56_ato,(next (.split "foo.tar.gz" "\\."))
06:56clojurebot("tar" "gz")
06:56_atohmm
06:56_atosplitting extensions is hard because of cases like that :(
06:57ol3yes, that will work
06:57ol3,(.substring "foo.bar" (+ (.lastIndexOf "foo.bar" ".") 1))
06:57clojurebot"bar"
06:57ol3but split looks better
06:57ol3,(last (.split "foo.tar.gz" "\\."))
06:57clojurebot"gz"
07:06ol3,(doc file-seq)
07:06clojurebot"([dir]); A tree seq on java.io.Files"
07:06ol3,(file-seq "/")
07:06clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.io.File
07:06ol3,(file-seq (java.io.File. "/"))
07:06clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission / read)
07:06ol3,(file-seq (java.io.File. "./"))
07:07clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission . read)
07:07ol3(take 1 (file-seq (java.io.File. "./")))
07:07ol3,(take 1 (file-seq (java.io.File. "./")))
07:07clojurebotjava.lang.RuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission . read)
07:33stephenj~def let
07:54stephenj~def pmap
07:59stephenj~def split-at
08:07stephenj~def future
08:26Guest35930I'm struggling to get with-out-writer in duck-streams to give me new lines when I (println ). How do I do this?
08:28tomojGuest35930: it should already do that
08:30Guest35930Oh yes, it does! Notepad just isn't showing it. :)
08:30tomojmaybe it's a windows \r\n problem?
08:31tomoje.g. maybe if you did (println "\r") instead it would work? I dunno
08:31Guest35930Quite probable, I'm on an XP machine at the moment. I'll give that a try.
08:37stephenjGuest35930: Does the answer look different if you open it in Wordpad (rather than Notepad)?
08:38stephenjWordpad handles \n and presents it well - whilst Notepad insists on \r\n data
08:39Guest35930stephenj: Wordpad shows the intended output.
08:40stephenjGuest35930: So depending on which tool / environment, the output needs to adapt (or not)
08:41stephenjDepend on what the desired results is...
08:41Guest35930Well I'm planning on feeding this file to a DOS program, so I probably need \r\n?
08:42stephenjprobably
08:42stephenjSorry, must leave now - hope that helped
08:43Guest35930It did indeed, cheers.
08:50Guest35930It did require the \r. Thanks for the help tomoj.
08:53tomojI wonder if there is a good way to automatically add \r
09:49KjellskiIs there any AI - Clojure approaches out there? Some libs?
09:49Kjellski-s
10:10hamza`hey guys, i have two maps, i would like to get a list of common keys right now i am using reduce to iterate map1 check map2 and build a vector? is there a better way to do this?
10:12chouserany nil or false values in either map?
10:12hamza`no they are a list of movies and scores
10:13hamza`* a map of
10:13chouser,(let [m1 '{a 1 b 2 c 3} m2 '{b 2 d 4 c 3}] (filter m1 (keys m2)))
10:13clojurebot(b c)
10:14chouserprobably doing essentially the same work as you described -- walking through one map, looking up each key in the other
10:14hamza`wow, thx thats a lot shorter then reduce..
10:15chouseryw
10:36tomojI feel bad wrapping up and hiding clojure.test/is
10:36tomojbut I don't like it very much either
10:36tomoj:(
10:37chouserwhat do you dislike?
10:37tomojit just feels awkward to me
10:37tomojtrying to translate things like "response.should have_content"
10:38tomoj(is (has-content? response "foo")) works but seems... yeah, awkward
10:38tomojmaybe I'm just not used to it yet
10:39chouserI've got very shallow experience with testing frameworks, so I don't have much opinion.
10:39chouseris "response.should have_content" from an existing framework/language?
10:43cemerickI'm guessing that's ruby
10:43cemerickhas a distinct AppleScript taste to it.
10:43cemerickor, rails, I should say
10:44chouserAssuming 'response' is a application object, having a 'should' method seems a bit odd
10:45ryssmells like rspec to me
10:45cemerickright, I was keying on the 'response' bit -- doesn't rails use rspec?
10:45rysAnd if it is, it's response.should have_content("string") I think
10:46rysAlthough I haven't coded any ruby in an age
10:47rysAh, yes, that's what chouser said upstream
10:48cemerickI'm sure an rspec-esque test framework could be put together. Not sure I'd use it, tho. :-)
10:55tomojyep, it's rspec
10:55tomojrspec puts a should method on everything :/
10:58kefka`Question about clojure.contrib.pprint: is there an easy way to set a left margin?
10:59kefka`,(+ 1 2)
10:59clojurebot3
10:59kefka`(just making sure I'm connected; ERC is acting weird)
10:59kefka`Anyway, I'm looking to set a left-margin in clojure.contrib.pprint
11:07johnyhi
11:07johnywhat's wrong with my installation : http://paste.lisp.org/display/90105 ??
11:07johnythe agent example does not return properly
11:10tomojjohny: nor does mine
11:10chouserjohny: once the agent thread pools are used, clojure.main isn't sure all the work is done yet, so won't quit automatically
11:11chouser(doc shutdown-agents)
11:11clojurebot"([]); Initiates a shutdown of the thread pools that back the agent system. Running actions will complete, but no new actions will be accepted"
11:11AWizzArdcemerick: good that you suggested to continue the fixing in Contribs logging module.
11:13cemerickwell, what's right is right. Some may worry about the fact that the solution would result in a deref call on every log, but I have to think it's worthwhile.
11:14cemerickI suppose we could add an init fn to the ns, but that's just kicking the can down the road.
11:16johnywhen 'i'm using await it also waiting forever if not message was sent
11:16johnyis it a normal behavior ?
11:16rhickeyI am considering protocols on interfaces being specified on a per-method basis, rather than (defprotocol AProtocol :on AnInterface ...)
11:17rhickeythis because: there will often be a name remapping
11:17rhickeyand, if there are extant interfaces, a single protocol might map to more than one
11:17rhickeythe tradeoff is it is more verbose in the 1:1 case
11:19rhickey(defprotocol AProtocol
11:19rhickey "A doc string for AProtocol abstraction"
11:19rhickey (bar [a b] "bar docs" :on AnInterface/barMethod) ...)
11:19chouserjohny: (let [a (agent nil)] (await a)) returns instantly for me
11:21chouserrhickey: renaming will be common because 'bar' will be a namespace-global name of a function while barMethod is an instance method on a specific class?
11:21johny(def node0 (agent 0)) (await node0) does not for me
11:22chouserjohny: at a repl that returns instantly for me as well. What version of Clojure are you using?
11:22AWizzArdcemerick: yup, i absolutely agree and hope this will be fixed.
11:22rhickeychouser: could be for many reasons - you want to say my-fn here and myMethod there, or are mapping to a pre-existing interface with names you don't like
11:23chouserrhickey: will there be protocols on protocols, or is there even any value in that?
11:23johny1.0.0
11:23rhickeychouser: no protocols on protocols, share impls by mixing in method maps
11:24johnycalling it with "java -cp /opt/clojure/clojure.jar clojure.main /tmp/simpleagent.clj"
11:24chouserrhickey: defprotocol doesn't provide any impls anyway, right?
11:25johnyand with java 1.5.0_13 , maybe too old ?
11:25rhickeychouser: I'm still not sure about :on, the multiple interface case might be fabricated, and the name mapping could go in a single map
11:25rhickeychouser: right, no impls in defprotocol
11:25sharvieHi, anyone know how to do the equivalent of ruby's respond_to? in clojure?
11:25chouserrhickey: anyway, so :on would only be needed for interop cases, either consuming or providing a Java interface.
11:26rhickey(defprotocol AProtocol :on AnInterface :mapping {this-fn thatMethod ...} ...)
11:26johnysame pb with 1.6 :s
11:27rhickeychouser: :on is for extension via interfaces - could be a bout mapping to existing, allowing for extension via Java, or just fast-path (since deftypes could implement)
11:27rhickeythe :on interface will be a fastpath
11:27rhickeytested first
11:28chouserrhickey: what about using the top-level :on as default, but allowing per-method :on to for renaming and disambiguation.
11:28cgrandand regular interop will use "implements", right?
11:29chouserI like having each defproto's method named once, rather than having to repeat it for the renaming cases.
11:29rhickeycgrand: maybe (extend AType AArotocol a-method-map BProtocol b-method-map ...)
11:31rhickeychouser: if top-level :on then I don't think per-method could be anything other than name mapping (i.e. not to introduce another interface)
11:32rhickey(a-method [args] "docs" :maps-to aMethod) or something
11:32sharvieexit
11:35cgrandrhickey: most of the time when you write (defprotocol AProtocol :on AnInterface ...) AnInterface will be an interface also written by the protocol author, no? Or are you thinking of retrofitting existing clojure interfaces (eg mapping IPersistentCollection/cons to conj)?
11:37rhickeycgrand: I don't want to decide this one way or the other - I am presuming both will occur with equal frequency (protocol author defines interface, protocol author maps to existing interface to allow for extension via protocols)
11:37cgrandok
11:37rhickeyobviously in the first case you have more control, but still might need mapping just due to Java name limitations
11:39rhickeyso if top-level :on and name inside, need better name for :maps-to (a-method [args] "docs" :maps-to aMethod
11:42chouserI don't understand why top-level :on preclude per-method interfaces if per-method interfaces could ever be an option.
11:44rhickeychouser: because it would be too confusing
11:44chouseroh
11:45rhickeyseeing A Protocol :on AnInterface leads one to believe implementing that interface is sufficient
11:45rhickeywhereas the name mapping is more of an implementation detail, given good names and docs on the interface side
11:47rhickeyI guess :maps-to could just be :on again
11:48chouserallow for a list of interfaces at the top level, and for any conflicting method names require a per-method :on ?
11:49rhickeychouser: I've pretty much talked myself out of mapping to more than one interface, barring a real use case
11:49chouserokey-doke.
11:49rhickeyso, :on in method for name-mapping?
11:50lisppaste8cgrand pasted "grouped by interface" at http://paste.lisp.org/display/90109
11:50chousersure
11:50cgrandforget that then :-)
11:52chouserI could use a way to refer to a clojure ticket in a contrib commit.
11:59qedsigh -- i just re-read the bipolar lisp programmer essay
11:59qedthat is me to a T
12:03tomojqed: sounds like me a bit too
12:06tomojat least the "abject failure" part :)
12:18qedtomoj: haha -- no i can just relate to the boredom, the bad grades feeling surrounded by phonies, etc.
12:26KnekkIntensity: yuck
12:31Knekkyeah, that was #wrong
13:34tomojwow, I got enlive's selectors working with the DOM tree from HtmlUnit
13:34tomojI didn't think it would be this easy :D
13:36hiredmanhtmlunit++
13:36cgrandtomoj: cool! Did you use a custom zipper?
13:37tomojuh, should I have? :/
13:37tomojI just took the dom tree from htmlunit and made xml/element structs out of it
13:38tomojgonna put the dom elements from htmlunit into metadata so that I can use your slick selectors and then take the results and do htmlunit-ish things to them like clicking/form-filling/etc
13:38cgrandno, I don't think that a custom zipper would be enough
13:38tomojwell I don't even have that :O
13:39tomojI admit enlive is still mostly a mystery to me
13:46cemerickrhickey: is the only JVM lang summit video coming out the short stuff on youtube now, with bad audio?
13:54rhickeycemerick: It was recorded by InfoQ, I expect their usual v. good treatment eventually, but it is usually several months between event and release
13:55cemerickah, ok
13:55cemerickI was excited to see *some* video, but figured there had to be something better coming.
14:01chouserSo far this month the most frequent poster to the google group has over four times as many posts as the person in second place.
14:02cemerickchouser: you should post the top ten every month or something. :-
14:02cemerick:-P
14:03rhickeychouser: yes, how do you tell someone nicely that they need not participate in every discussion?
14:03technomancyalong with Clojure's position on the Github languages high-score board. =)
14:03technomancy(which, btw, just surpassed Scheme to take position 20.)
14:05rhickeytechnomancy: do they produce a sorted list anywhere?
14:05technomancyrhickey: no, but I had a script somewhere to build one.
14:06technomancyif you're curious: CL is 19, Scala is 18, and Erlang is 17
14:06danlarkinThe top10 is here: http://github.com/languages
14:07djorkwow that's a very different picture than SourceForge
14:07cemerickI wouldn't have thought github would be attractive to CL folk.
14:08chouserIt seems likely that the impression people have of a community could be influenced proportionally to the volume posted that portray various personalities and attitudes.
14:09rhickeyhrm, richhickey/clojure is the most watched and most forked *Java* project this week/month/overall !?
14:09rhickeyso isn't contributing to Clojure stats I guess
14:10chouserrhickey: I assume that's correct. contrib drives the clojure stats
14:10danlarkinrhickey: http://github.com/richhickey/clojure/graphs/languages
14:10chouserhaha! http://github.com/richhickey/clojure-contrib/graphs/languages
14:11shooverYou could always make core.clj more verbose
14:11rhickeyI guess cinc will fix that
14:11chouserapparently contrib is written mostly in javascript
14:11rhickeyheh
14:11chouserer, largely
14:23replaca_kefka`: are you there still?
15:26MaddasLooks like Github doesn't know about Fortran, Ada, or Cobol :-/
15:27MaddasOh, it does know Fortran.
15:31ChousukeNo Ada? :/
15:31technomancyMaddas: http://p.hagelb.org/github-langs.clj.html
15:32hiredman(ha ha VimL)
15:33Maddastechnomancy: Thanks, I found a list on the site itself too.
15:33technomancyMaddas: you're not the only one! =)
15:36ChousukeIs Arc actually still being developed?
15:36technomancyno
15:40MaddasPaul Graham also forgot about it? =)
15:41hiredmanhttp://groups.google.com/group/unladen-swallow/browse_thread/thread/4edbc406f544643e <-- I wonder if this means google is looking for another dynamic language
15:41hiredmanI imagine they'd end up with rhino though
15:43cemerickrhino is really far behind on AOT compilation, last I knew
15:44rhickeyhmm, I missed this last week: http://fwierzbicki.blogspot.com/2009/11/leaving-sun.html - so JRuby and Jython guys all gone from Sun now? That's really too bad
15:44rhickeycemerick: more likely js than rhino in particular
15:44rhickeygiven V8
15:45cemerickright, I forgot they had their own internal vm
15:46headiusrhickey: I feel for the folks still at Sun, actually
15:46rhickeyheadius: I can imagine it's simply awful, waiting like this
15:46headiuswhen we left in july we didn't like the idea of the axe hanging for a couple more months
15:46chouserI'm under the impression Paul Graham is still using and possibly making improvements to arc.
15:46fogus_technomancy: Paul Graham *does* still work on Arc... he blasted me about implying otherwise. :O
15:46headiusnow it could be year(s) what with the EU objection
15:47rhickeyheadius: yes, amazing
15:47headiusthe oracle/sun deal has probably done more to set back java platform dev than anything in the past decade
15:47hiredman:(
15:47headiusrhickey: btw, I want to try writing a plugin for Duby that adds first-class lang support for clojure refs, collections, and stm
15:48rhickeycool
15:48headiusI'll ping you when I get some time to work on it
15:48cemerickhas anyone played follow-the-money on the EU thing? I doubt there's principled objections involved.
15:48cemerickheadius: that's quite a quote
15:49headiuscemerick: and you can feel free to quote me
15:49headiusbefore this deal I might have said "JavaFX has probably done..." :)
15:49chouserheh
15:56chouserhiredman: VimL's not just there, it's above Emacs Lisp and all the other lisps.
15:57chouserhm. I've got a literal UTF-8 string in a .clj file that when written out to a data file is having it's multibyte characters replaced by question marks.
15:58chouseroh, I bet it's FileWriter's fault.
16:00chouserah, and it worked when run from the command-line because my default encoding there is UTF-8, but when run from cron it must be something else...
16:02hiredmanchouser: :(
16:02hiredmanyegge should do something about vim's scripting language while he is doing something about emacs
16:03chouserhe doesn't believe in vim because the smart people don't use it
16:03hiredmanchasing down all the places where you have to set the checkbox to "UTF-8" is a pain
16:03hiredmanchouser: :(
16:03hiredmancould be true, I guess
16:04fogus_pg uses vim, that must count for something right?
16:04jableyfogus_: beat me to it
16:04chouseroh, does he? I didn't know that.
16:04chouserhe uses etherpad.
16:04fogus_etherwhat?!?
16:05fogus_That's soooo last week
16:05chouserheh
16:06chouserhttp://etherpad.com/ep/pad/slider/foundervisa -- PG using etherpad
16:16hiredmanclojurebot: git fbacc4a5751fa5c15baa599b5a058cd81b05a247
16:16clojurebotAdded bound-fn to define thread-local binding aware functions bound-fn captures the thread-local bindings in effect where the function is defined. Installs these bindings before executing the body. This is useful for helper functions running in a different thread. Excluded with-bindings from clojure/main.clj to prevent name clash. Fixes #170 Signed-off-by: Chouser <chouser@n01se.net>
16:17hiredmanwhee
16:21djpowelldo you think clojure's println and stuff should be respecting platform newlines?
16:22hiredmanwhat do mean?
16:22jbendig\n versus \r\n?
16:23hiredmanbut, how exactly?
16:23djpowellyeah
16:23hiredmanwhat if I want a literal \n on windows?
16:23djpowell(def *nl* (System/getProperty "line.separator"))
16:23chouser(prn-str) should return "\r\n", "\n" or "\r" depending on platform
16:23djpowellwell it shouldn't rewrite \n's
16:23chouser?
16:23djpowellchouseer: yes
16:23djpoweller sry typo
16:24hiredmandjpowell: so, again, "what do you mean?"
16:24djpowellhiredman: println and prn should output a platform specific newline at the end of the line
16:24hiredmanoh
16:24djpowellany literal \n's will remain #x0a
16:24hiredmansimple enough
16:24hiredmanI though it did that
16:25djpowellnot sure - i think it doesn't ?
16:25hiredman~def prn-str
16:25hiredmanfailure to render correctly in firefox
16:26hiredmanah
16:26hiredman~def newline
16:27djpowellactually, make a *line-ending* dynamic var, so you can rebind it if you want unix outputting on windows or whatever
16:28hiredmanyou can dynamically rebind newline to a fn that returns the line.separator property
16:33djpowellhow are you supposed to use *err* btw? rebinding *out* to it?
16:36chouserdjpowell: sure, or just write to it (.write *err* "error text\n")
16:38djpowellyeah, but then you miss out on some stuff like auto-flushing, and er newline handling
16:38djpowelli noticed that clojure.main printlns to *err*, which is making some assumptions about what class *err* is
16:39chouserindeed. won't work if *err* is an integer for example.
16:39djpowellonly PrintWriters support .println, and if you're rebinding, you probably don't want to be using a printwriter, cause they eat exceptions
16:39djpowellho ho
16:39chouser:-) sorry
16:39hiredman,(doc *err*)
16:39clojurebot"; A java.io.Writer object representing standard error for print operations. Defaults to System/err, wrapped in a PrintWriter"
16:50spuzI'm trying to write a paint function that draws on a BufferedImage, however as the paint method is called from Java, it cannot have the image passed into it as a parameter. Also as I don't know the width and height of the image until runtime, I can't define it as a var. How could I use something like dynamic binding to first create the buffered image and then access it in a paint function?
16:51spuzI've tried something like:
16:51spuz(def *img*) (defn draw [] (set! *img* (create image))) (defn paint [graphics] (drawImage graphics *img))
16:52spuzbut apparently, you are not allowed to re-bind a var with set! until it has been initially bound
16:54chouseryou'll implement the paint method using proxy?
16:57_atospuz: use a closure when you make your proxy, like? (let [image whatever] (proxy [whatever] [] (paint [g] (draw g image))))
16:57spuzchouser: yes
16:58_atoif image isn't created at that point, or you need to change it, then make it an atom/ref
17:00_atohmm is it just me or is everyone receiving 7 or 8 copies of each mailing list post? either google groups or my smtp server seems to have gone crazy
17:01_msthm, no weirdness for me
17:02_atohmmm.. it looks like it's google groups, there's different timestamps for the duped messages by their SMTP servers, oh well
17:04shooverspuz: using binding somewhere on the call stack, then you can set! if you want: (def *img*) (defn draw [] (binding [*img* (create-image)] (let [g (create-graphics)] (paint g)))) (defn paint [g] (drawImage g *img*))
17:05spuzshoover: hmm thanks
17:11the-kennyIs there a library like contrib.server-socket, just for client-sockets?
17:14patrkrisCould Clojure get some of the benefits of Erlang if the JVM still supported green threads? I'm thinking for massively concurrent scenarios, where the overhead of context switching would be large.
17:17hiredmanpatrkris: I think it's telling that green threads are not used alot these days
17:18hiredmanmostly because smp with native threads is less complex
17:19patrkrishiredman: yeah, well ... but shouldn't you be able to gain something without the context switching? I'm not suggesting to use only green threads instead of OS threads, but for highly concurrent scenarios, it may be nice to use green threads
17:19patrkrisThe same idea that Stackless Python uses
17:20patrkrisAs far as I know, Stackless Python uses green threads, and it is one of the reasons it is used for Eve Online, which exhibits concurrency on a massive scale
17:20hiredmanwell, python is horrible at concurrency anyway
17:20hiredmanso, uh, any example with python is a deviant case
17:21patrkriswell, yeah there are problems with the global interpreter lock and so on
17:22hiredmanactually, the wikipedia article on green threads says that native threads outperform green threads for context switching on linux
17:22patrkrisreally... i'll check that out
17:22hiredmanpatrkris: as I said, I am aware of python's limitations in that regard, so I don't need you to repeat them to me :P
17:22patrkrissorry
17:24hiredmanand explaining why python is bad at concurrency does not make it less bad
17:24spuzpatrkris: Scala has erlang type concurrency, I'm not sure whether it uses green threads though
17:25patrkrishiredman: i was just mentioning stackless python as an example of a system that uses green threads - not trying to advocate python in particular
17:25hiredmanspuz: it doesn't
17:54hiredmanthe invokedynamic pdf on hackernews uses the word "reified"
17:54hiredmanfirst time I've seen it outisde of #clojure
17:54hiredman:P
17:58djpowellyou hear it a lot with RDF
17:59spuzdjpowell: RDF?
18:00djpowellspuz: http://www.w3.org/RDF/
18:00hiredmanIn the Core Reflection API, the simulation signature 〈as(*),rs(*)〉 is
18:00hiredmanalways 〈Object[], Object〉. JRuby has about 8 simulator signatures,
18:00hiredmanand Clojure has about 21.
18:00hiredmaninteresting
18:01djpowellspuz: a data model for representing information (on the web) as graphs with an xml seralisation and stuff
18:01hiredmanI am subscribed to something called planet rdf
18:02hiredman"In a nutshell,
18:02hiredmanfunction pointers have arrived in the Java virtual machine"
18:03spuzis invokedynamic actually going to appear in 7?
18:04hiredmanyeah
18:05hiredmanit's in, whenever 7 chooses to make an appearance
18:06spuzwell this paper is way too heavy going for me, but maybe someone will write a blog post as to what it actually means :p
18:06hiredmanI suddenly have a feeling that rich's protocol work and invokedynamic are connected
18:06hiredmanspuz: the paper or invokedynamic?
18:06hiredmanthere are a lot of blog posts on invokedynamic
18:06spuzhiredman: both
18:07spuzyeah I've seen a few but I think haven't properly understood the context
18:14replaca_Rich makes no secret of the fact that he is voraciously following other developments in academia, the JVM, etc.
18:15hiredmansure
18:16hiredmanI just hadn't caught onto to protocols+invokedynamic yet
18:17Chousukethat paper is quite interesting.
18:17Chousukehaven't even finished reading page three yet though. But so far it has been :P
18:19hiredmanthe paper is over my head too
18:21hiredmanI like the fact that the paper is java java java λ calculas
18:28_atohehe the java syntax for it is pretty horrible (like the curried greeter example)
18:30_atocould be worse though I guess
18:53hiredmanhttp://scienceblogs.com/goodmath/2009/11/philosophizing_about_programmi.php
19:25lusoryhi, does anybody know whether there are sample codes showing how to pack/unpack data from the network?
19:27duncanmhmm
19:28duncanmi just watched this techtalk on Google's new Go language, it's a bit underwhelming
19:30frooglink?
19:31duncanmfroog: it's on youtube
19:34duncanmaha, it's twbray
19:35twbrayduncanm: G'day
19:36duncanmtwbray: i was gonna leave a comment on your blog (or something); i saw your tweet about having functions with too many arguments from a few weeks ago, i think a judicious use of maps and structs will help with that
19:37twbrayduncanm: Yeah, I eventually poured a bunch of somewhat-related things into a map and passed that around instead. Hey, if some of them were functions would that be O-O?
19:37duncanmtwbray: yeah, it's a well-known technique used by Schemers
19:39duncanmtwbray: the trade off is that dispatch is explicit (which is tedious to implement again and again), the plus side is that there's no distinction between functions and methods (usually just a symbol, ie in Smalltalk)
19:40twbrayduncanm: Don't understand "dispatch is explicit"
19:41duncanmtwbray: you have to remember to pull out the right method from the map when you call, and use it on the right data, on more traditional OO systems, you can't make that mistake
19:43twbrayRight, the O-O flavor is not very strong.
19:51duncanmtwbray: do you also write a lot of JRuby code?
19:52duncanmtwbray: i really like that you can pass blocks in Ruby to make instances of interfaces (like java.io.FilenameFilter)
19:52twbrayduncanm: Not really. I'm usually in MRI
19:52twbrayAlthough the last piece of Ruby code I wrote ended up getting deployed in JRuby/GlassFish, which is not terribly rare these days
20:02twbrayDamn... seem to be stubbing my toe on a nasty little bug. Is Clojure 1.0 very far out of date? Worth updating?
20:08hiredmantwbray: have you seen map destructuring?
20:09twbrayhiredman: nope
20:09clojurebothiredman <3 XeLaTeX
20:09hiredmanhmmmm
20:10hiredmanhard to say, I usually use clojure from git, but the times I have used 1.0 I haven't hit any differences
20:10hiredmanbut my use of 1.0 is limited
20:11twbrayI have a ref to a map that's refusing to deref when accessed in a sub-thread. Blecch. Works perfectly called from REPL.
20:11hiredmanwhat do you mean refusing to deref?
20:12twbrayI do (sort-by last > @unsorted) where @unsorted is a ref to a map and it works fine at top-level, when executed in a thread I get "java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.Ref cannot be cast to java.lang.Number"
20:13hiredmanare you using agents at all?
20:13twbrayOh............. hold on. I'm a moron.
20:13hiredmanI would suggest dropping a call to prn in there
20:13hiredman(the subthread)
20:14twbrayD'oh, the map values are refs to numbers not numbers. The error message is perfectly correct and I'm a dork.
20:14hiredmanif you are using agents at all it is very easy to accidently add layers of refs
20:14hiredman:P
20:14hiredmanprn is your friend
20:33burnyI'm giving a presentation on clojures to my university Programming Language Concepts class tomorrow. We've studied scheme, prolog, and javascript, most of the people are familiar with java and c++. Any suggestions on area's in particular to cover for a general overview of the language in about 15/20 minutes?
20:38arbschtclojurebot: rationale
20:38clojurebotrationale is http://clojure.org/rationale
20:38hiredmanyou might take a look at rich's "clojure for java programmers" and see what he covers
20:39hiredmanclojurebot: blip.tv
20:39clojurebotblip.tv is http://clojure.blip.tv/
20:39burnyyea, I've gone over it a couple times
20:39burnythanks
20:40hiredmanthere are a lot of little neat corners of the language
20:40hiredmancallability as an interface anthing can implement
20:56chouserrhickey: will the next release be called 2.0, since we're now past Clojure's second year?
20:58rhickeychouser: good question, I don't think so
20:59duncanmhiredman: ah, that's a good point
20:59twbrayHAH! Am now keeping 25+ on average of the 32 cores in a Niagara maxed processing the Wide Finder dataset.
21:00rhickeytwbray: cool
21:01twbrayGonna have to get a JVM/Solaris guru to look at this puppy, swings wildly back & forth between high concurrency & occasional single-threadedness, I'm sure there are JVM options & so on to help.
21:02durka42garbage collection?
21:02hiredman~google headius jvm flags
21:02clojurebotFirst, out of 279 results is:
21:02clojurebotHeadius: My Favorite Hotspot JVM Flags
21:02clojurebothttp://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html
21:03twbrayYeah... currently java -d64 -Xmx18000m -XX:+UseParallelGC
21:06rhickeynow with dates - http://pragmaticstudio.com/clojure
21:08twbrayI suppose that a big clojure program is going to generate disposable java objects at a ferocious rate...
21:08rhickeytwbray: yes, lots of ephemeral garbage
21:10twbrayInterestingly, my program had the computer maxed until it hit its max heap (18G) and now the concurrency is varying between 1x and 8x, presumably because it's competing with gc all the time.
21:10headiustwbray: you might want to try +UseConcMarkSweepGC
21:10headiusit should help a bit
21:10headiusparallelGC doesn't actually run concurrently
21:11headiusit just stops the world for less time by using multiple threads to GC
21:11headiusyou must be generating a ton of garbage
21:11headiusI don't know if that's typical for clojure ornot
21:11twbrayWell, it's Wide Finder... it has a ref to an int for each URL (a few thousand of 'em) and it's updating them at many tens of thousands per second.
21:11hiredmanI generate tons of garbage :P
21:12twbrayGosh.... does this mean that immutability isn't free?!? I'm shocked... shocked.
21:12hiredmanthat doesn't sound like it should generate garbage
21:12twbrayWell, every time I do (ref-set some-int (inc @some-int)) the old value is now garbage. Right?
21:13rhickeyhiredman: boxed numbers can yield a lot of garbage
21:13hiredmanoh
21:13hiredmanright
21:13hiredmantwbray: (alter ref inc)
21:13rhickeyyes, please
21:14hiredman,(doc alter)
21:14clojurebot"([ref fun & args]); Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value-of-ref args) and returns the in-transaction-value of ref."
21:14headiusrhickey: we need to get a pool together for fixnums in mlvm
21:14rhickeyheadius: I think it's the #1 problem for dynamic langs on the JVM
21:15rhickeyperf-wise
21:15headiusprobably...and #2 would be lack of closure-conversion during inlining
21:15headiusif we had both of those I'd have far fewer headaches
21:15twbrayWhy would alter generate less garbage?
21:15rhickeytwbray: it doesn't, just more idiomatic
21:16hiredmantwbray: I dunno that it would, but alter is prefered to ref-set
21:16twbrayCrap... 30 minutes into the run, it's now single-threaded :(
21:16twbrayOK, gc research after dinner.
21:16headiustwbray: log some GC stuff to see if that's the problem
21:16hiredmanyou might be ok with commute instead of alter, but I always get confused so I stick to alter
21:17headiusit shouldn't impact you *that* much
21:17clojurebotmuch is permittted
21:17headius-XX:+PrintGCDetails
21:17headiusif you see incremental GC runs streaming by, or lots of full GCs, you'll know it's an issue
21:17twbrayheadius: will do
21:18duncanmoh, this is fun
21:18duncanmtwbray: you're gonna write a blogpost on this debugging session, right? ;-)
21:19twbrayOh yeah. Lotsa fodder here. But I want some good numbers.
21:20twbrayAs in "dramatically faster than the equivalent perl code on a multi-core machine"
21:20duncanmtwbray: the perl code isn't using the multi-core at all, is it?
21:20chouserheadius: what's closure-conversion during inlingin?
21:20twbray"equivalent single-threaded perl code" I mean
21:20duncanmah
21:22headiuschouser: current JVMs will not inline closures all the way back to where they're instantiated, since the method they're passed to ends up being megamorphic
21:22headiusa ruby example: [1,2,3].each {|x| ...}
21:22chousermegamorphic means types with perhaps the same method name but no parent class in common with that method name?
21:23headiusyou'd like "each" and the closure to inline into the caller, but they can't because each gets used for lots of different call paths
21:23chouserah
21:23headiusmegamorphic means they're all of some "closure" type, but there's many different ones
21:23headiusunless each only ever receives one closure, it won't inline it
21:24headiusthat means you can't get most inlining optimizations whenever there's an intermediate call like "each"
21:26headiusjrockit guys said it wouldn't be hard to add, but it's not in any current JVMs
21:29headiusrhickey: more frustrating to me than lack of fixnum support is that the majority of comparison benchmarks on the interwebs are numeric-heavy...so we end up looking sucky
21:31rhickey_headius: exactly, the most trivial things look the worst, too
21:32headiusyes
21:32headiusstupid fi
21:32headiusfib
21:32duncanmheh
21:32headiusif I had time for more projects I might work with maxine guys to hack fixnums in
21:33duncanmoh, i read about maxine, it looks pretty cool
21:33duncanmheadius: do you know what the status is for interface injection?
21:33headiusduncanm: fading quickly...no resources to work on it
21:33headiusat this point I think I might like fixnums more
21:33headiusbut I want it all
21:33duncanmoh, that's too bad, that's one feature that I find very exciting
21:34headiusI find then all exciting
21:34headiusI wish I knew hotspot better to help out :)
21:34headiusbbl
22:45qedoh man im excited for RubyConf
22:45qedS. Halloway has a talk about Clojure
22:45woobywill the vids be up somewhere?
22:46qedyeah eventually
22:47qedactually they will likely be up the same day
22:47woobyawesome
22:48qedi hope clojure sticks around for awhile
22:48JAS415oh jeeze
22:48JAS415me too
22:48qedive really grown to love it, except for the whole JVM thing
22:48qed;)
22:48qedi mean, if i was a java programmer in the first instance, i would be loving clojure
22:49qedbut for me this is more like my first foray into java
22:49qedive avoided it for such a long time
22:49qedi wrote some long long ago in a far away place
22:49woobyqed: what did you work in primarily?
22:50qedwooby: C++ at first, then I got turned on to perl, then to ruby, ruby has lasted me awhile, then i found clojure
22:50qedwell actually i found a lot of languages in between ruby and clojure
22:50qedbut clojure is the only one i thought to be worth learning
22:51qedi played with haskell for awhile, got bored
22:51qedclojure has kept me interested
22:51woobyyeah i tinkered with haskell also
22:51qedi think most of us did
22:52qedclojure is where the haskell rejects go
22:52qed:X lol
22:52woobyfollowed the java -> ruby -> scala trajectory and settled on clojure finally, love it... feels like i won't want or need to learn anything else for a long time
22:52chouserwhere would clojure go if it doesn't stick around for awhile?
22:52qedchouser: i didnt mean anything by that
22:52chouseroh, ok.
22:53qedi guess what im saying is that im praying for a long and healthy prosperous language
22:53chouser:-)
22:53qedi really enjoy clojure and cant wait to see the things people will inevitably build for it
22:53woobyi cant wait to see more clojure jobs ;)
22:53qedoh man
22:53qedif i could get a job writing clojure...
22:54woobyi know
22:54qedthe world would likely explode
22:54woobythat's the ultimate
22:54qedthat's like LAMBDA
22:54woobysecond only to being paid to work on my own toy languages lol
22:54qedhaha
22:54qedhey now -- clojure aint just a toy anymore
22:54qedor at least i dont see it that way
22:54qedit's maturing pretty rapidly
22:54woobyi know but my stuff is ;)
22:55qedchouser: what do you see the 5 year outlook for clojure being?
22:55qedchouser: nothing too serious, just sort of your wishes and hopes
22:57chousera variety of hosts besides JVM -- iphone, jvm, clr, javascript, chickenscheme, maybe C++
22:57qedi didnt even consider that
22:58qedwhat is clr chouser ? ive heard that term passed around a lot.
22:58woobyit's like microsoft's jvm
22:58chouserqed: that's the C# runtime
22:58qedahhh
22:58qedwhat about ruby?
22:58qed:X
22:58_atoparrot
22:58qedis that heresy?
22:58woobychouser: have you looked at nu?
22:58chouseryes, parrot
22:58chouserwooby: I don't think so
22:59qedthe iphone would be really interesting
22:59chousersomeone will have solved the dependency problem well, so you'll declare your deps, and someone can install with a single command that also fetches and installs the dpes.
22:59woobychouser: http://programming.nu/
22:59qedchouser: fwiw i appreciate so much the work youve done on clojure
23:00qedits not said enough
23:00qedthank you
23:00chouserheh. well, thanks. I do hardly anything.
23:00chouserrhickey is the workhorse
23:00qedyou're part of the machine, and you being in here right now answering my questions as you've done for the past month or so
23:00qedhas not gone unnoticed
23:01qedso thanks :)
23:01qedchouser: is there any active documentation project going on?
23:02qedone thing i miss is a really complete set of documentation that includes code samples
23:03chouserwooby: No, I haven't looked at nu before.
23:03st3fannu is interesting
23:03devlinsf@qed It's a work in progress
23:03woobychouser: it's probably only worth a look if you're into obj-c/cocoa at all, but i've found it a really nice way to build things for macs
23:03woobychouser: and the runtime definitely pays the way for clojure-on-cocoa :)
23:03wooby*paves
23:04chouserqed: there are a few efforts related to docs going on. That'll be solved in the next 5 years too. :-)
23:04devlinsf@qed There is some effort going on trying to improve the documentation for contrib. Tom F. is doing a lot to create refernce documentation
23:06danlarkins/someone/technomancy :-D
23:09technomancydanlarkin: ssshhh! I'm not _quite_ ready yet. =)
23:09burnyAny suggestions for my presentation? http://docs.google.com/present/edit?id=0AZJoMk7c8j5uYXd6NWNoY3hjbm1fNjJrazV0N2Jodg&amp;hl=en
23:10woobyburny: looks awesome, sp on pg 3: "Functinonal Languaguage"
23:10woobyreading though
23:10chouserwooby: yeah, any lisp-like syntax with macros is a win, even if it's a thin layer over a host language
23:11_atoburny: slide 5 s/Full/Fully/
23:12burny_ato: wooby: haha oops! thanks
23:13woobyburny: is it for school?
23:14burnywooby: yea, Programming Languages course
23:14durka42if we're into spelling, Breif on slide 2
23:15woobyburny: i like the compojure/incanter examples, cool way to show the power
23:16_atoburny: I'd say something about how the mind-blowing persistent hash maps and vectors are immutable yet still fast and memory efficent (due to state sharing), but it depends on the audience :)
23:17burny_ato: I'm gonna do a run through, if I have some time I'll be sure to add it in, thanks.
23:17chouserburny: should use (doseq ...) instead of (dorun (for ...)) unless you're specifically trying to show 'for'
23:19burnychouser: Thanks, I didn't know that
23:19devlinsfchouser: got a minute to talk about c.c.map-utils?
23:20woobyburny: do you go to RIT by any chance?
23:20qedtechnomancy: now i know why you got turned down for your rubyconf proposal
23:20qedwhat with stuart H. getting his clojure presentation accepted and all
23:22chouserdevlinsf: hm, my name is in that file, isn't it.
23:22chouserI wonder why
23:22timothypratleystupid question, I'm formatting a patch and have gone blank on how to run the tests
23:22chouserah, deep-merge-with.
23:22technomancyqed: yeah, but my talk was actually related to ruby. =\
23:22devlinsfchouser: deep-merge-with
23:22chouserdevlinsf: what's up?
23:23chousertimothypratley: for clojure itself? ant jar test
23:23timothypratleythanks!
23:23devlinsfchouser: I've had a post about two libs on the dev list, c.ctable-utils & c.c.map-utils. I think the table-utils lib needs a little more time, but the map-utils is ready to go
23:24devlinsfchouser: do I need Rich's approval for a patch?
23:24chouserdevlinsf: not for contrib, no.
23:25devlinsfchouser: okay, so an assembla ticket w/ docs, test & code could get applied. Who would do the actual application?
23:25chouserdevlinsf: I see your posts. I had forgotten I was responsible for map-utils. I'll take a look at some point.
23:26devlinsfchosuer: thanks
23:27timothypratleyBUILD FAILED Target "test" does not exist in the project "clojure". <--- should I be worried?
23:28timothypratleyarrrrghhhh!!!! ignore me, I was in a really old snapshot directory for some reason
23:29timothypratley*slinks away*
23:35JAS415does anyone use clojure from a VPS?
23:37JAS415nvm found something about it through google :-)
23:47burnywooby: yes I do
23:49woobyme too
23:50burnyvery cool
23:50burnyse/ce/cs/one of the other hundreds of computing majors?