#clojure logs

2009-04-07

03:41dysinger~java.lang.Thread/currentThread
03:41clojurebot?
03:42dysinger~(.. java.lang.Thread/currentThread getContextClassLoader)
03:42clojurebot?
03:43dysingerwhy is this happening ?
03:43dysingerClojure
03:43dysingeruser=> java.lang.Thread/currentThread
03:43dysingerjava.lang.Exception: No such namespace: java.lang.Thread (NO_SOURCE_FILE:0)
03:46dysingerstrange
03:46dysingeruser=> Thread/currentThread
03:46dysingerjava.lang.Exception: No such namespace: Thread (NO_SOURCE_FILE:0)
03:46dysingeruser=> Thread
03:46dysingerjava.lang.Thread
03:46dysingeruser=>
03:47AWizzArd,Thread
03:47clojurebotjava.lang.Thread
03:47AWizzArd,java.lang.Thread
03:47clojurebotjava.lang.Thread
03:48AWizzArd,Thread/currentThread
03:48clojurebotjava.lang.Exception: No such namespace: Thread
03:50AWizzArd,(Thread/currentThread)
03:50clojurebot#<Thread Thread[Thread-16,5,main]>
03:50dysingerah my goof
03:50AWizzArddysinger: currentThread is not a public field but instead a method
03:50AWizzArdSo it should be put into parens :)
03:50dysingery I goofed
03:50dysingernoob
04:06alphazerogood morning / hello all
04:06AWizzArdHi alpha.
04:07alphazeroHi there AWizzArd.
04:08alphazeroQuick q: has anyone tried bolting clojure to anything besides couchDB for key value hash dbs?
04:25dysingerhow do I proxy java.util.logging.Formatter ?
04:25dysinger(proxy [Formatter] [] (format [record] ... er wait format is clojure method
04:26dysingereven emacs gets it all mangled
04:26Carkdo you have an error trying to compile this ?
04:26dysingerthe problem is the method to proxf is "format"
04:27dysingernot compiling yet
04:27dysingerjust curious as to what happens - maybe it's fine - other than emacs mangles the formatting
04:27Carkit's working for me
04:27dysingerok
04:27Cark(.format blah) and (format blah) are two different functions
04:28dysingery it's just not .format in the proxy form it's plain "format" which clojure-mode then things is the clojure method
04:28dysingers/things/thinks
04:34dysingersorry for the noob questions
04:35dysingeris there a way to pull an array out of a bean (set) easy? say I want "x" and "y" properties
04:35dysinger{ :x 1 :y 2 :z 3 }
04:36dysingerrepeating [(:x myset) (:y myset)] isn't right I bet
04:44dysingersorry I meant pull out multiple vals from a map
04:44dysingernot set
04:44dysingerI think I want select-keys
04:46dysinger,(select-keys {:one 1 :two 2 :three 3} '(:one :two))
04:46clojurebot{:two 2, :one 1}
04:47dysingerhmm closer but still not there
04:48Chouser,(map {:one 1 :two 2 :three 3} '(:one :two))
04:48clojurebot(1 2)
04:49dysingernice
04:49dysingernow to guarantee order
04:50dysingerjust add sort
04:50Chouserthose will be in the order given in the list
04:50Chouser,(map {:one 1 :two 2 :three 3} [:three :one])
04:50clojurebot(3 1)
04:51dysingerah that's right
04:51dysingerI was thinking of my version above
04:51dysingermap would work off a seq in order
04:51dysingerthanks
04:52Chouserright
05:03dysingerJava 1.4-1.6 has java.util.logging -> is there something like the simple formatter that is clojure friendly? the default java formatter does this "Apr 7, 2009 3:55:57 AM sun.reflect.NativeMethodAccessorImpl invoke0 FINE: testing"
05:03dysingerI quickly scanned contrib and didn't see anything stand out.
05:04dysingerJust want to make sure I am not repeating ground
05:24cemerickdysinger: we've had good results using log4j in conjunction with clojure.
05:24cemericknot sure what you mean by 'clojure friendly' tho...
05:24dysingerI don't want to use commons or log4j
05:25dysingerby clojure friendly I mean the namespace instead of "sun.reflect.NativeMethodAccessorImpl invoke0"
05:26dysingerI guess I could use log4j but what's the point? that was 10 years ago and I am only on java 6
05:27dysingerIt doesn't add anything but extra weight IMO
05:27cemerickwell, java.util.logging is a pale shadow of a kit compared to log4j IMO, but that's emacs v. vi territory.
05:27dysingerthats true
05:28dysingerI just don't need JMS appenders etc
05:28cemerickthe class that is emitted in the log msg should be the one where you invoke the log method, regardless of your kit
05:28cemerickperhaps the log message you pasted was generated by a call from an anonymous fn or somesuch?
05:29cemerickwe don't use any of the fancy appenders, either. We're with log4j primarily because of the formatting flexibility.
05:29dysingeryes you are right - I was using the repl to try it
05:30dysingerbut even from within clojure logging I get "sun.reflect.GeneratedMethodAccessor7 invoke"
05:30dysingerinstead of my Logger's name
05:33dysingerok - I give up - going off to try commons/log4j
05:35dysingerThey practically cut & pasted doug lea's threading library but couldn't see adopting log4j
05:35pjstadigdysinger: does clojure.contrib.javalog not work for you?
05:35dysingerwhoa - didn't see that - thanks
05:35dysingerI don't know contrib well enough yet.
05:35pjstadigjavalog.clj -- convenient access to java.util.logging in Clojure
05:35pjstadig:)
05:35dysingersweetness
05:39dysingerhmm only problem is the big warning "Consider it DEPRECATED."
05:39pjstadig,(doc clojure.contrib.javalog/*logger*)
05:39clojurebotjava.lang.Exception: Unable to resolve var: clojure.contrib.javalog/*logger* in this context
05:39pjstadigoh
05:39pjstadighehe
05:39pjstadigi think something like it might still be useful
05:41pjstadig,(require 'clojure.contrib.javalog)
05:41clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/javalog__init.class or clojure/contrib/javalog.clj on classpath:
05:41pjstadighiredman: i guess clojurebot doesn't have access to clojure.contrib?
05:41Chousernot all of it anyway
05:42dysingermaybe it's "This library will not work on Java 5." in javalog
05:43pjstadig,(System/getProperty "java.specification.version")
05:43clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission java.specification.version read)
05:43pjstadighehe
05:43pjstadigclojurebot: why are you so cagey?
05:43clojurebotwhy not?
05:45danlarkincooked
05:46dysingercommons/log4j api is much cleaner
05:46dysingerI never got the asinine Fine, finer & finest
05:47dysingerI actually complained to Sun when they released 1.4 about logging being so arcane compared to log4j
05:47Chouserand they said "good point, we'll get right on that"?
05:48dysingerheh
05:48dysingerI just wanted to log a complaint
06:06pjstadigclojurebot: what is our mascot?
06:06clojurebotthe official mascot of clojure is a futuristic ninja robot
06:06pjstadigclojurebot: just checking
06:06clojurebotthat's cool
06:07pjstadigclojurebot: futuristic ninja robot?
06:07clojurebotsooo much better than any of the historical ninja robots
06:20Guest31655clojurebot: historical ninja robots?
06:20clojurebothistorical ninja robots are so 1999...
06:21Neronusclojurebot: 1999?
06:21clojurebotGabh mo leithsc�al?
06:21Neronusclojurebot: 1999?
06:21clojurebotExcuse me?
06:21Neronusahh
06:21Neronusclojure: histerical ninja robots?
06:21Neronusclojurebot: histerical ninja robots?
06:21clojurebotExcuse me?
06:21Neronus:-/
06:21Neronusclojurebot: You don't pass the turing test
06:21clojurebotI don't understand.
06:21Neronusclojurebot: yup, thats the problem
06:21clojurebotTitim gan �ir� ort.
06:22Neronusclojurebot: Wanna talk to a lady I know? She's called eliza
06:22clojurebotI don't understand.
06:28pjstadigclojurebot: 1999 is <reply>I'm afraid that was before I was born
06:29clojurebotAlles klar
06:29pjstadig~1999
06:29clojurebotI'm afraid that was before I was born
06:29pjstadigclojurebot: turing test is <reply>the answer is 42
06:29clojurebot'Sea, mhuise.
07:18danlarkinplease don't subject us to that :-/
12:37Carkdef~ c.l.PersistentQueue
12:38Cark~def c.l.PersistentQueue
12:39mihandhello guys. does recur work with lazy sequences?
12:39Chousukewhat do you mean?
12:40mihandi have something like this (lazy-cons x (recur ...
12:40Chousukehmmh
12:40mihandi would expect the recur to happen lazyly
12:40dakrone_hbwhen using an exec macro to execute a program, is there a way to get around the limitation of not being allowed to next #( functions?
12:40kotarakmihand: call the function recursively instead of recur
12:40mihandbut instead it loops forever
12:40ChousukeI think you need to use a recur... yeah.
12:40dakrone_hbs/next/nest/
12:40Cark,(conj (new clojure.lang.PersistentQueue) 1)
12:40clojurebotjava.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.PersistentQueue
12:41dakrone_hbie: http://gist.github.com/91322
12:41mihandcalling it recursivly works
12:41Chousuke,(clojure.lang.PersistentQueue. [1 2])
12:41clojurebotjava.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.PersistentQueue
12:41kotarakdakrone_hb: #() is not a fn replacement. You have to use fn for nesting.
12:41mihandbut i get stack overflows
12:41Chousukeshould you be using lazy-cons anyway
12:41Chousukewasn't it done away with in the new release.
12:42kotarakmihand: you probably want a new release, with lazy-seq
12:42Chousukethough it seems the documentation hasn't been updated yet
12:42dakrone_hbkotarak, how to you use fn to do %1 equivalent, would #(doseq [group %1] (...)) == (fn [group %1] (...))?
12:42dakrone_hbin the example on the gist
12:42kotarakdakrone_hb: (fn [some-seq] (doseq [group some-seq] ...))
12:43dakrone_hbkotarak, okay, I'll give it a try, thanks!
12:43Chousukethere's no mention of the lazy stuff on the clojure.org front page
12:43Cark(conj (clojure.lang.PersistentQueue/EMPTY) :a)
12:43Cark,(conj (clojure.lang.PersistentQueue/EMPTY) :a)
12:43clojurebot(:a)
12:43Chousukeand the docs still talk about lazy-cons
12:44Carkhum is it safe as in futureproof to use persistentqueues ?
12:44ChousukeShould be. :/
12:44dakrone_hbkotarak, that works great, thanks again :)
12:45kotarakdakrone_hb: np :)
12:45danlarkinARGH why does (TimeZone/getDefault) return a sun.util.calendar.ZoneInfo instead of a java.util.TimeZone like it says it will?
12:46dakrone_hbso fn defines a function, and #( is like a lambda?
12:46dakrone_hbI'm still unsure of the main difference between the two
12:46kotarakdakrone_hb: fn is like lambda and #() is for very short lambdas.
12:47kotarakdakrone_hb: #(foo %) is equivalent to (fn [x] (foo x))
12:47Cark,(doc seque)
12:47clojurebot"([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer."
12:47dysingerhow come the clojure api docs say to use (ns foo.bar (:import (java.util Date Timer Random) (java.sql Connection Statement))) I don't see that that works. I have to use (ns foo.bar (import '(java.util Date Timer Random) '(java.sql Connection Statement)))
12:47dakrone_hbkotarak, so, why can you nest fn, but not #90?
12:47dakrone_hb*#()
12:48Cark~def seque
12:48kotarakdakrone_hb: because #() is only for very *short* lambdas. Something like #(instance? SomeClass %).
12:48dakrone_hbkotarak, okay, I'll remember that, thanks for the explaination
12:50pjstadig~function literals?
12:50clojurebotFunction literals are cute, but overused
12:55dysingeranyone have a noob explaination for my question above on (:import vs (import in (ns
12:55dysinger?
12:56Carkhumhum rhickey: that's why I haven't exposed PersistentQueue yet - I'm afraid of people building polling systems on top of refs
12:57Carkwell i'm not polling, i only need a queue !
12:57ChouserCark: yes, I think that's specifically the misuse he's trying to avoid
12:58Chousergo ahead and use the class directly get the empty one, and you're set from there on in.
12:58Carkok well i'm afraid about it disapearing in a future version
12:58kotarakdysinger: the :import for without quoting is correct.
12:58Carki might have to build my own because of this
12:58ChouserCark: I wouldn't worry about that.
12:59ChouserCark: it's more likely to be exposed properly in a future version than it is to go away, I think.
12:59Carkalso there's a little problem with it's interface
12:59Carkwhen you pop from a collection, it should return both the poped value and the new collection
13:00ChouserCark: forcing you to destructure?
13:00Carkas it is you have to do imperative style ugliness
13:00Chouserwhat??
13:01Carkfirst get the value, the return the new queue ...
13:01Carkthen
13:02Carkand yes, forcing destructuring is what you have to do in the absence of multiple return values
13:03Chouserit's no more imperative than working with any other seqable. (first s) ... (next s)
13:03Carkah you're right
13:04Carkok well i'll use it ... if it disapear i'll blame it on you !
13:04Cark=P
13:05Chouserok
13:05ChouserI can handle such blame.
13:06hiredmanCark: if you really want to write non-imperitive code, make your functions pointless
13:06Carkchouser : damn, you're supposed to be terrified at this point...
13:07Carkhiredman, i just don't like to have these (do froms all over the place
13:07Chouserhiredman: a lot of the code I write seems pretty pointless, at least when I look back on it a few days later.
13:07hiredman:P
13:07ChouserCark: yeah, breaking other people's code just doesn't scare me much. ;-)
13:09Cark~chouser is ruthless about breaking other people's code
13:09clojurebotIk begrijp
13:10ChouserI think I can back that up with facts, even.
13:11dysingerkotarak: "dysinger: the :import for without quoting is correct." that appears to be true from the clojure api but it doesn't work for me trying to import commons logging for example. If use (import '(org..... it works
13:12dysingerIt doesn't seem clear and clean to me why not
13:12kotarakdysinger: I'm not sure, what happens, but (ns foo.bar (:import (some.package ClassA ClassB))) definitively works for me. Do you have an example?
13:13dysingery let me pastie one up and make sure I am correct
13:13Carkthere are (were?) somme inconsistencies with the diferrent part of the ns form
13:14Carki found that always using vectors works
13:14Carklike (ns some.package (:use [blah] [troot]) (:import [some.package Blah]))
13:15kotarakWasn't there some change? I think, the () form was the original one. But I vaguely remember Stephen writing about that on the group.
13:16Chouserafaik, no actual change was made.
13:16Carkah could be ... anyways use the vector syntax ...always works !
13:34dysingerkotarak - I was in the wrong ns
13:34dysingersorry
13:34kotaraknp
13:34dysingerhow do you guys define something like a logger that you want to stick around ?
13:35dysingerI don't want to make-log for every debug call
13:35dysingerI was doing this (def log (LogFactory/getLog "x.y.z"))
13:37dysingerseems to work but I want to make sure I am following idiom
13:37dysingeridioms
13:38dysinger(defn log ..... ) would evaluate it every call right ?
13:39Chouserdysinger: yeah, what you've got seems fine.
13:39dysingerk
13:40kotarakIs there some ant magic, that it stops when c.l.Compile blows up?
13:45cemerick~max
13:45clojurebotmax people is 164
13:45cemerickI daresay we've hit a plateau.
13:46cemerickwho's got day-by-day population data for #clojure to make a pretty graph? ;-)
13:46kotarakHmm.. We dettach from the google group. Should be 170 by now.
13:48kotarakWhen I have a src and a class file. The src in the filesystem, the class created from the source, but in a jar... Which one is loaded by Clojure?
13:49cemerickI think it always prefers the classfile.
13:49cemerickWouldn't make sense to do otherwise.
13:49kotarakIt loads the src if it's newer. But is this information available via jar?
13:50cemerickah -- which reminds me -- why does the clojure-slim.jar file produced by the build retain the .clj files?
13:52kotarakThe reason, why I'm asking is: I work on a ivy setup for contrib, which generates a jar per module on which I can depend (I don't want a 2.5MB jar, when I just wanted to use defvar...). But it seems, that the .class files provided in a jar are ignored, when the source is available via the filesystem. (I didn't want to rework the whole layout. So every module sees also the source of the other modules..)
13:55cemerickI'm not clear on why the source is still available, if you've split contrib into one jar per lib...
13:57kotarakcemerick: In contrib there are also dependencies. So, eg. repl-ln depends on def. So it gets provided the freshly built c-c-def.jar, which contains the .class files for c.c.def. But the source is still in the usual src tree. So c/c/def.clj is still in the classpath for c.c.repl-ln. Hence the .class files from c-c-def.jar are ignored and c.c.def is compiled again. Injecting its .class files into the c-c-repl-ln.jar....
13:58cemerickhrm.
13:59cemerickthat's dicey. libs that are dependencies of many other libs (def is a great example) really should just get pushed into core. Who doesn't use defvar-?
13:59cemerickthat's an orthogonal problem, though.
14:00cemerickkotarak: why not compile everything in one shot to one dest dir, and then produce separate artifacts for each lib?
14:02kotarakcemerick: when I solve this problem, I also solved the initial one: I have to decide, which file goes to which jar. (Actually the separate build idea is from ivy. If there is another way... I'm happy to use it)
14:03cemerickThere's absolutely nothing stopping you from compiling all of clojure-contrib in one shot, and then splitting it up into multiple artifacts. You can then define dependency relationships between them in ivy.
14:06kotarakcemerick: the problem is: how do I decide which file belongs where? I have to rely on some naming convention for the source files (and hence class files). Clojure itself doesn't care for such a convention. (eg. genclass.clj)
14:07cemerickthere's N libs in clojure-contrib, each one in clojure.contrib.XXX. Why not one artifact per lib package?
14:09kotarakcemerick: yes. That was roughly my plan (maybe grouping the scattered math stuff). Hmmm... The names in contrib are relatively consistent. I will have a look in the file name heuristic for splitting the jars.
14:11dysingerpulling my hair out - figured out the problem
14:11dysingermy mac's java vm is 6 (set in the prefs panel)
14:11dysingerbut Aquamacs / Slime is loading 5
14:11dysinger:/
14:12dysingeruser=> (System/getProperty "java.vm.version")
14:12dysinger"1.5.0_16-133"
14:12dysingeranyone else have this problem ?
14:14cemericknope
14:15Carkdid you manage to make eclipse work on an x64 computer ?
14:17dysingerEclipse loads with JDK 1.5 on mac but recognizes 1.6 is on the system
14:17dysinger(for me)
14:40durka42kotarak: bah, my repl isn't working anymore
14:40kotarakdurka42: huh?
14:40durka42\sr isn't bound to anything
14:41kotarakhmmm.. which rev are you using?
14:42durka42um, i just did hg pull/hg update bleeding-edge
14:42durka42vimclojure#NailgunClient is correct
14:43kotarakwhat does b:vimclojure_namespace say?
14:43durka42invalid expression
14:43durka42:echo b:vimclojure_namespace
14:43kotarakHave you started the ng-server? (<- stupid questions first)
14:43durka42aah! no i haven't
14:44durka42stupid people first
14:44kotarakJust start the server and do a :a
14:44kotarakI mean :e
14:44kotarakThis should correctly setup the buffer.
14:45durka42you fixed the error conditions then, when there is no server to be found
14:45durka42uh oh
14:45kotarakIt basically just goes on without interactive features.
14:45kotarakStarting the server and doing :e will activate them.
14:46lisppaste8durka42 pasted "untitled" at http://paste.lisp.org/display/78190
14:47kotarakWhat did you do?
14:47durka42i opened the file
14:47durka42that also happened when i did :e
14:47durka42the server is now running
14:47kotarakhmmm... What is gismu?
14:47durka42it is the namespace of the file
14:48durka42and the filename
14:48kotarakYou did no \ef or something=
14:48kotarak?
14:48durka42no
14:48durka42i mean, it's true that it isn't on the classpath
14:49kotarakArg. That gives always problems. You have to work with a proper setup.
14:49kotarakVC looks into the namespace to determine the syntax highlighting of included libs.
14:50kotarakTherefor the namespace must be available.
14:50durka42i can open other files
14:51durka42wait, it should be on the classpath
14:51durka42hmm
14:55durka42strange
14:55durka42the file starting with "(ns org.durka.nytimes.common" is loaded fine
14:55durka42"(ns org.durka.gismu" does not work
14:55kotarakwhat is the complete ns-form of the failing one?
14:56kotarakAh no. Shouldn't of importance.
14:56kotarakVC loads via normal require...
14:58durka42ah, now it works
14:59durka42i restarted a few things after putting it on the classpath
15:00durka42so files with compilation errors do not load
15:00durka42this may or may not be desired behavior
15:01kotarakhmm... It is certainly suboptimal. But as long as VC uses the normal Clojure reader, one has to live with the need for proper source files...
15:01kotarakVC heavily relies on the introspection capas of Clojure.....
15:02durka42right
15:03kotarakHelping it a bit can get you very far. :)
15:08Neronuswahh... namespace dependency hell
15:39eyerisIs (for [a as b bs] [a b]) supposed to generate the same combinations as (for [a as] (for [b bs] [a b]))?
15:39Chousukeprobably.
15:40Chousuke,(for [a [1 2] b [3 4]] [a b])
15:40clojurebot([1 3] [1 4] [2 3] [2 4])
15:40Chouserno, 'for' flattens things out, returns a single seq
15:40eyerisIt will be wrapped in an extra list.
15:40Chouserif you nest the 'for' yourself, you'll get nested seqs
15:40eyerisBut the combinations seem the same when I use numbers
15:41Chousukehm, right.
15:41eyerisHowever I have other code that seems to behave differently.
15:41eyerisbrb
16:01eyerisI'm trying to construct a crosstab from aggregate database results, but I'm having trouble with (for)
16:01eyerishttp://pastebin.ca/1385227
16:01eyerisThat paste shows my code and the problem I am having.
16:03eyerisI am essentially trying to take two lists and generate a list with the same number of elements as the first list, pairing items from the first and second list where a predicate matches and pairing the item from the first list with nil if there is no match.
16:03eyerisWhat I am getting is a list of all combinations of the items in each list.
16:04eyerisDo I just need to replace the second (for) with a searching function?
16:04kotarak(map #(if (pred %1 %2) [%1 %2] [%1 nil]) list-1 list-2) ?
16:05eyeriskotarak (map) requires equal-length lists.
16:06kotarak,(map #(vector %1 %2) [1 2 3] (iterate inc 5))
16:06clojurebot([1 5] [2 6] [3 7])
16:07cads,(zip [1 2 3] [1 2 10])
16:07clojurebotjava.lang.Exception: Unable to resolve symbol: zip in this context
16:08kotarak,(interleave [1 2 3] [1 2 10])
16:08clojurebot(1 1 2 2 3 10)
16:08cads,(interleave [1 2 3] [1 2 10 6 6 6])
16:08clojurebot(1 1 2 2 3 10)
16:09cadsnice!
16:09cadscan we easily map a function over pairs in an interleaved list?
16:09eyeris,(into (1 2 3) (10 11 12))
16:09clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
16:09eyeris,(into [1 2 3] [10 11 12])
16:09clojurebot[1 2 3 10 11 12]
16:10kotarakcads: you mean like partition?
16:10slashus2,(zipmap [1 2 3 4] [4 5 6 7])
16:10clojurebot{4 7, 3 6, 2 5, 1 4}
16:10kotarak(map identity (partition 2 (interleave [1 2 3] [:a :b :c])))
16:10kotarak,(map identity (partition 2 (interleave [1 2 3] [:a :b :c])))
16:10clojurebot((1 :a) (2 :b) (3 :c))
16:11Chouser,(map vector [1 2 3] [:a :b :c])
16:11clojurebot([1 :a] [2 :b] [3 :c])
16:11Chouser,(map list [1 2 3] [:a :b :c])
16:11clojurebot((1 :a) (2 :b) (3 :c))
16:11eyeris,(map vector [1 2 3] [:a :b :c :d])
16:11clojurebot([1 :a] [2 :b] [3 :c])
16:11cads:)
16:11eyeris,(map identity (partition 2 (interleave [1 2 3] [:a :b :c :d])))
16:11clojurebot((1 :a) (2 :b) (3 :c))
16:11kotarakeyeris: seems that map doesn't require equal-length lists ;)
16:12slashus2,(vec (zipmap [1 2 3] [:a :b :c]))
16:12clojurebot[[3 :c] [2 :b] [1 :a]]
16:12eyeriskotarak It doesn't require them to execute, but it only consumes the smaller of the number of entries in each list
16:14cads,(let (zipmap2 #(map %1 (vector %2 %3))) (zipmap2 identity [1 2 3 4] [:dog :cat :bat]))
16:14clojurebotjava.lang.IllegalArgumentException: let requires a vector for its binding
16:15cads,(let [zipmap2 #(map %1 (vector %2 %3))] (zipmap2 identity [1 2 3 4] [:dog :cat :bat])) ; like that?
16:15clojurebot([1 2 3 4] [:dog :cat :bat])
16:16cadshrm, I missed what Chousuke did
16:17eyeriscads: Here's a fleshed out example: http://pastebin.ca/1385227
16:18eyerisI don't even need the items paired, if the mismatches are eliminated.
16:22eevar_is this still true? -- When you ask a sequence on its last element for the rest it returns nil, saying, "there is no more".
16:23slashus2,(rest [3])
16:23clojurebot()
16:23eevar_http://clojure.org/lisps
16:24Chouser,(next [3])
16:24clojurebotnil
16:24slashus2,(next [3])
16:24clojurebotnil
16:25eevar_that whole paragraph seems pre-lazy-patch to me
16:26Chousereevar_: yes it does
16:27eyerisIs there a function in the api like filter, but returning the first match instead of all matches?
16:28eyeris,(first [])
16:28clojurebotnil
16:28slashus2some
16:28slashus2,(some even? [1 3 4])
16:28clojurebottrue
16:29slashus2await.
16:29eyerisThanks
16:30slashus2No, some doesn't do that.
16:30slashus2You could just use first on filter.
16:30eyeris(first (filter even? [1 3 4]))
16:30eyeris,(first (filter even? [1 3 4]))
16:30clojurebot4
16:31eyeris,(first (filter even? [1 3 5]))
16:31clojurebotnil
16:31eyerisPerfect
16:31kotarakIns't there a find-first or seek or something in contrib.seq-utils?
16:31AWizzArdthere is
16:31AWizzArd(find-first even? [1 3 5])
16:31Chousereyeris: (defn left-join [as bs pred] (for [a as] [a (first (filter #(pred a %) bs))]))
16:32eyerisChouser: That is what I was just trying! :)
16:32eyerisYou beat me to it :)
16:32Chouserah, sorry.
16:33eyerisEarlier I sd "Do I just need to replace the second (for) with a searching function?", but I didn't know what that "searching" function was :)
16:33eyerisI knew it had to be simple
16:34Chouserby the time I understood what you were trying to produce, I had the solution
16:34Chousersince you're working with collections of maps and have names like "left-join", you might be interested in clojure.set
16:35eyerisDocs? I don't see it on the libraries page.
16:35slashus2http://clojure.org/api#toc649
16:37Chouserthings named like 'xrel' should be sets of maps
16:37bradfordanyone using clojure-test-mode?
16:39cemerickis there a map fn across associatives? Or is (apply hash-map (mapcat ...)) the best there is?
16:40kotarak(into (empty thing) (map foo thing))?
16:42cemerickyeah, somewhat better.
16:42bradfordre: clojure-test-mode...I am able to run tests, but unsure what buffer the output is being dumped to - any ideas?
16:42cemerickheh, I *always* forget about into
16:42kotarakcemerick: me too. :)
16:43cemerickI think part of is that I intuitively think of setting all of the values in a map being cheaper when "updating" a map that already has all of the keys I want.
16:44cemerick...which is surely wrong in the new clojure world order :-)
16:49Chouserno, I think you're right.
16:50Chouservectors and (array-)maps are created more efficiently when given the full set of values at creation
16:52cemerickwell, in that way, into and (apply hash-map ...) are in the same boat, aren't they (e.g. they're just reducing over the seq of kvs being provided)
16:53slashus2It would be neat if the map constructors could also take in a map.
16:53slashus2(sorted-map map-of-another-kind)
16:54antifuchshow would the resulting sorted map be ordered? (:
16:54slashus2by the keys
16:55Chousercemerick: for hash-map, yes. But (apply array-map ...) can be O(1) instead of O(n)
16:55cemerickslashus2: (into (sorted-map) map-of-another-kind)?
16:56antifuchsmakes as much sense as any other (:
16:56slashus2cemerick: Yes that does work.
16:56slashus2When I first saw (sorted-map) I expected it to take a map as an argument to coerce it.
16:57cemerickChouser: ah. That'd get coerced up to a hash-map pretty quickly, though.
16:57Chouserhm, and in practice you'd have to work pretty hard to make it O(1)
16:57cemerickyeah
16:58cemerickit's possible if your datasets are small, but in that case, you probably don't care about the costs of reducing through your new kvs anyway
16:58slashus2,(. clojure.lang.PersistentTreeMap (create {:b 5 :a 4}))
16:58clojurebot{:a 4, :b 5}
16:58Chousereven a LazilyPersistentVector will clone it's array before handing it to a PersistentArrayMap
16:58slashus2That will do it, but that is not how the constructor is set up.
16:59Chouserslashus2: that's some old-school syntax you've got there. ;-)
16:59Chouser,(clojure.lang.PersistentTreeMap/create {:b 5 :a 4})
16:59clojurebot{:a 4, :b 5}
16:59slashus2Chouser: I copied that out of the core.
16:59Chouserah
16:59slashus2The core has some old school syntax :-P
17:00cemerickheh -- that's probably worth tweaking, so people can pick up "modern" idioms
17:00slashus2Chouser: Is that more efficient than doing into?
17:01slashus2into seems faster.
17:01Chouserboth essentially do 'assoc' on all the values
17:01slashus2hmm
17:02Chouseron all the entries
17:02slashus2No, I was just doing a mini benchmark that doesn't show the variability of the times.
17:02slashus2I guess they are very similar.
17:02pjstadig,(class (into [] '(a b c)))
17:02clojurebotclojure.lang.PersistentVector
17:03pjstadigi thought into was lazy
17:03Chouserno
17:03slashus2Maybe it should have three explanation points on it.
17:04slashus2(into!!! (sorted-map) {:b 5 :a 4})
17:04pjstadig~def into
17:04dakrone_hbfrom: (exec "shellscript.sh" (fn [groups] groups)) I'm getting java.io.IOException: Stream closed, is this because of my syntax, or can I not just get a list of outputed lines like this?
17:04Chouserit produces non-lazy collections. no way for it to be lazy
17:05pjstadigyeah i wasn't sure why i thought that
17:05pjstadigi hadn't thought it all the way through
17:05Chouserdakrone_hb: what's 'exec'?
17:05pjstadigi just thought it was supposed to be efficient
17:05dakrone_hbChouser, http://gist.github.com/91322 very first defmacro
17:07Chouserthat macro looks bad -- it needs to force the lazy line-seq before returning out of with-open
17:07dakrone_hbChouser, unfortunately, I don't completely understand how it works, found it elsewhere and needed something to run other programs
17:07Chouseror I suppose you have to be careful to force as much as you need in your 'pred'
17:07dakrone_hbclojure needs a popen method
17:07Chouserdakrone_hb: you might look at clojure.contrib.shell-out
17:08dakrone_hbChouser, I will take a look at it
17:08kotarakIt doesn't even need to be a macro...
17:09Chousershell-out returns non-lazy things specifically to avoid that kind of problem
17:09dakrone_hbis there a unified place for clojure-contrib documentation, or do I need to go through all the source to understand it?
17:09dakrone_hbthe google-code wiki only has 1 page in it
17:10dakrone_hbor, run (doc <blah>) on everything I guess
17:10dakrone_hbif there is a web-form
17:10Chouserthere's not much -- most of the source files have a line or two in the header comment that describes the purpose of that lib
17:11Chousermost of them also have expamples of usage at the end, in a comment.
17:11dakrone_hbI see, seems like a javadoc equivalent would be nice to have for it
17:12dakrone_hbChouser, thanks for the pointer, I'll check it out
17:22duncanmis there an equivalent to begin0 or prog1 in Clojure?
17:24kotarak(defmacro do1 [form & body] `(let [result# ~form] ~@body result#))
17:26kotarakor: (defn [form & _] form), but the macro is clearer in its intention, doesn't hide the main point (side-effects of _) and doesn't live from assumptions about the evaluation order of function arguments.
17:27kotarakSo although not strictly necessary, I would prefer the macro in this case.
17:28Chouserinteresting
17:28slashus2(defn returning [returnval & body] returnval)
17:29slashus2Does that work?
17:29kotarakyes, but for the above reasons I would not recommend this function.
17:31slashus2yeah
17:33kotarakBut what are my recommendations... YMMV as always.
17:34replacadakrone_hb: I've also been thinking about standarizing the doc on clojure.contrib so that folks kind understand it's capabilities, but I haven't started the discussion yet
17:34dakrone_hbreplaca, that would definitely be helpful
17:34dakrone_hbshould write a javadoc tool to go through and run (doc) on everything and convert it to html for publishing
17:35replacaI think so. We need to discuss and get some consensus on the best location, format, etc.
17:35replacadakrone_hb: yeah, that's one component. Rich already does that for the core API
17:35replacaWe should probably follow him on that for consistency
17:36kotarakThere is already clj-doc, which is supposed to do that, IIRC.
17:36dakrone_hbone thing I'd love to see (as an extreme newbie) is non-trivial examples for all the core API functions in the docs
17:36kotarakMaybe it could serve as a starting point.
17:37replacakotarak: yeah, we just need to automate it and host it
17:37replacadakrone_hb: someone already did some of the in the wikibook. Did you check that out?
17:37kotarakdakrone_hb: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
17:37kotarakclojurebot: examples is also http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
17:37clojurebotIk begrijp
17:38replacakotarak: thanks, saved me the trip!
17:38dakrone_hbkotarak, replaca, awesome! was reading through it and hadn't gotten there yet
17:38replacaas for contrib doc, I'd like to see it get a little richer than just API doc
17:39kotarakNamespaces may also carry docstrings. Some more verbose docs with examples could go there.
17:39replacawhich implies the ability for authors to add their own html, markdown whatever
17:39replacakotarak: so that did happen? I remembered it being discussed, but didn't know if it happened
17:39replacathat's also a great component
17:40slashus2So a "JavaDoc" generator for clojure?
17:40kotarakBut it is currently broken in so far, that the metadata on namespaces is lost when loading from a class file.
17:40kotarakAt least it was the last time I checked.
17:41replacaI'd imagine a home page with a list of contrib namespaces, the namespace doc and a link to the API doc (autogenerated) and also a link to some contributer/user generated doc if it exists
17:41replacamaybe hosted on the main clojure site off the contrib link.
17:42replacakotarak: :-( I'll take a look and see if there's an issue on it
17:42replacawe're realy going to want that for tools like this
17:42kotarakreplaca: I asked rhickey several times, whether I should open an issue, but never got an answer.
17:44replacahmm, maybe we should just go ahead and do it :-) we could try to see if there's an easy patch
17:44replacathe desire for someone to do and maintain this system (which I'm willing to do) could serve as a motivator
17:45replacaI'll write up a post to the group (it's been on my mind anyway)
17:45replacaand see what people think
17:46cp2si there a built in function that returns the version of clojure?
17:46Chousercp2: no
17:46cp2aye
17:47RaynesWrite one.
17:47replacaRaynes: Can you determine it from the jar? I don't think so
17:47slashus2I don't think clojure keeps up with its current version.
17:48cp2Raynes: i wanted to see which version this clojure plugin downloaded
17:48cp2(la clojure for IDEA)
17:48cp2but im just going to build one from svn
17:48replacaIt would have to be part of the compilation
17:48kotarakUp to now I had the impression, that the current version number doesn't keep up with the dev speed of clojure... ;)
17:48replacaI'd like to see a version and build number in there too, though
17:48Raynescp2: I always use an external Clojure with La Clojure and Enclojure.
17:49cp2yeah Raynes, thats what i will be doing
17:49replacamost production systems that I've been involved with stash their svn version or something like it in the output somewhere
17:50Chouserhttp://clojure-log.n01se.net/date/2009-03-20.html#11:05b
17:50cp2heh
17:51cp2darn, revision 1338
17:51cp2i missed rev 1337
17:51replacawe discussed 1337 in here when it went by
17:52replacathat was a moment of high geekiness
18:03dakrone_hbChouser, do you have a moment I could ask you some questions about your shell-out library?
18:07cp2does la clojure have the ability to spawn a repl?
18:08cp2Raynes: do you know ?
18:09cp2ah i see
18:09cp2nevermind
18:15Raynescp2: I'm sorry for not replying sooner. La Clojure doesn't have a way to spawn a standalone REPL, or load files into an REPL, it will be included in the future. If you want to strike an REPL, the easiest way to do so is to create an empty file and then run it as a script and check run in REPL. Little tedious but it works.
18:16cp2yes i noticed :)
18:16RaynesThe way it indents let and if forms, is what keeps me from using it any more than just testing it. I've talked with llya or whatever his name is about it and I guess he's going to include a settings page to fix it, but I'm not sure if we got the messages through to each other very well because of the language differences.
18:17cp2hm
18:17cp2i only just installed it, so i dont know about the way it indents
18:17cp2let me check that out
18:18cp2i see
18:18cp2yeah, i dont prefer my indentation to be like that either
18:18Raynescp2: I think he thinks that is the convention :\
18:18cp2lol
18:19cp2i can tolerate that, but it would be nice to have it configurable
18:19RaynesI'm too picky to tolerate that.
18:44Chouserdakrone_hb: sure
18:44dakrone_hbso I was able to split command output by line with this: (doseq [i (.split (:out (sh "ls" "-l" :return-map true)) "\n")] (println "line:" i)) Is this the right way to do that?
18:44Chousersure
18:46dakrone_hband now I'm trying to write a wrapper or a macro around that so I can do something like (doseq [i (sh-lines "ls" "-l")] (println "line:" i))
18:46dakrone_hbbecause I'm going to be calling a lot of external programs and iterate over the lines of output
18:47Chousersure, a function like that should be pretty easy to write.
18:47dakrone_hbI'm trying to wrap my head around writing it
18:48dakrone_hband I have (defn sh-lines [& body] (.split (:out (sh body :return-map true)) "\n"))
18:48dakrone_hbbut that doesn't work, something with the arguments I believe
18:48dakrone_hbam I on the right track? wrong track?
18:49Chouserlooks pretty close
18:49Chousertry (apply sh :return-map true body)
18:50dakrone_hbChouser, excellent!
18:50dakrone_hbthanks works :)
18:51Chousergreat. you see why you need apply?
18:51dakrone_hbChouser, I *think* so, is it because body is a list of arguments?
18:51Chouserright, body is a list but sh is expecting several args instead of a single list
18:51dakrone_hband apply formats it correctly for the (sh) function?
18:52dakrone_hbhow does apply know how to apply ':return-map true' to 'sh'?
18:52dakrone_hb*know not to
18:52slashus2,(doc apply)
18:52clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
18:52Chouserapply take then fn, then several args (or none), and finally a seq -- the seq is "unrolled" into the args to the fn
18:53dakrone_hbokay, so it applies to the last arg, no matter how many other arguments you have
18:53Chouserright
18:53dakrone_hbI understand now :) thanks
18:53Chouserwhich is why the body arg has to go last
18:53dakrone_hbokay
18:53Chouserfortunately sh doesn't demand that the options come at the end
18:54dakrone_hbif it did, would this not work?
18:54Chouserright, you'd have to do something more complicated
18:54Chouser(apply sh (concat body [:return-map true])) or something
18:55dakrone_hbahh, to add the option only to the end first
18:55dakrone_hbthanks for the shell-out library, much better than the macro I was using :)
18:56Chouseryou're welcome -- I only started it, several others have added on now.
18:58Chouseryou might want to be careful spliting on "\n" if you intend to work on other OS's
18:58dakrone_hbOkay, I'll switch to a separator that'll work with others
18:58dakrone_hbthanks for the heads up
18:59Chousercould be another option, I suppose
18:59dakrone_hbfor 'sh'?
18:59Chouser:out :line-vec
19:00dakrone_hbahh, to split by lines automatically?
19:00Chouserright
19:00dakrone_hbthat would be useful
19:07Chouserwould there be any value to you if it returned a lazy sequence?
19:32hiredmanlisppaste8: url?
19:32lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
19:32lisppaste8hiredman pasted "fast-proxy" at http://paste.lisp.org/display/78214
19:34Carkthe regular proxy is slow ?
19:34lisppaste8hiredman annotated #78214 "usage example" at http://paste.lisp.org/display/78214#1
19:34hiredmanno
19:34hiredmanfast in the writing sense
19:35Carkkk
19:35Chouserthe first arg to the given fn is the name of the method being called?
19:35hiredmanas a keyword
19:36durka42so the only function you give fast-proxy is a dispatch?
19:36hiredmanso you can use it with a multimethod
19:36hiredmanno, it is a function
19:36hiredmanif it is a multimethod it will need it's own dispatch function
19:37hiredmansomething like (comp first list)
19:38hiredman(defn fn->al [func] (fast-proxy ActionListener (fn [_ event] (func event))))
19:50durka42why did you use _SOMEFUNCTION instead of a gensym?
19:50clojurebotwhy not?
19:50durka42good answer
19:51hiredmandifferent symbols got generated
19:51hiredman(let* [fn__688__auto__ (constantly 1)] (clojure.core/proxy [clojure.lang.IDeref] [] (deref [& args] (clojure.core/apply fn__687__auto__ :deref args))))
19:52durka42interesting
19:55Chouserthat's because auto-gensym only works right within a single syntax-quote
19:55Chouseryou'd have to use (gensym) manually
19:56hiredmanin the outer let?
19:57Chousersure, next to 'class'
19:59lisppaste8hiredman annotated #78214 "fixed to use gensym" at http://paste.lisp.org/display/78214#2
20:13lisppaste8hiredman annotated #78214 "filter out methods from ancestors" at http://paste.lisp.org/display/78214#3
20:15durka42is that what getDeclaredMethods does?
20:15hiredmanis it?
20:16hiredman~javadoc java.lang.Class
20:17cp2getDeclaredMethods returns all methods regardless of access flags
20:17cp2whereas getMethods only returns public methods
20:18durka42i mean, do you want this method to filter out superclass methods
20:18durka42this macro, i mean
20:18hiredmanyes
20:19durka42what if you're proxying something that descends from jframe, say
20:19hiredmanI don't want to proxy wait() etc
20:19hiredmanfast-proxy is for simple things
20:19hiredmanat least that is the idea
20:20durka42ok
20:21hiredmanI guess I could just filter out methods from Object
20:22lisppaste8hiredman annotated #78214 "filter out methods from object" at http://paste.lisp.org/display/78214#4
20:29hiredman~ticker IDSOX
20:29clojurebotIDSOX; -0.30
20:29hiredmanmy first day of my first index fund
20:33cp2lol
20:34Cark~google IDSOX
20:34clojurebotFirst, out of 167 results is:
20:34clojurebotIDSOX: Profile for ING DIRECT INDEX PLUS SMALL CAP - Yahoo! Finance
20:34clojurebothttp://finance.yahoo.com/q/pr?s=idsox
20:58jonathanturnernewbie questions... I'm trying to get numbers from 1 to 1000 using this: (filter (partial < 1000) (iterate inc 1)) but that doesn't seem to stop at 1000
20:59hiredmanyou want take-while
20:59durka42(partial < 1000) is #(< 1000 %)
20:59hiredmandurka42: shhh
20:59hiredmanclojurebot: function literals
20:59clojurebotFunction literals are cute, but overused
21:00durka42no, i was giving a hint as to why it didn't work
21:00hiredmanfilter has no way of knowing that sometime after 1000 there isn't something that is less then 1000
21:00durka42that too
21:00hiredmanclojurebot: filter?
21:00clojurebotfilter is not map
21:01durka42clojurebot: map?
21:01clojurebotmap is *LAZY*
21:01hiredmanclojurebot: literal [?]
21:01clojurebot1
21:01durka42clojurebot: lazy?
21:01clojurebotlazy is hard
21:01jonathanturnerhiredman: I thought that too, but then why would it return the values if they didn't meet the requirement?
21:01hiredmanclojurebot: literal [?] filter
21:01clojurebot1
21:01durka42,(take 3 (filter (partial < 1000) (iterate inc 1)))
21:01clojurebot(1001 1002 1003)
21:01hiredmanclojurebot: filter is also <reply>filter doesn't stop
21:01clojurebotc'est bon!
21:01hiredmanjonathanturner: you are using the wrong function
21:02hiredman,(doc <)
21:02clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically increasing order, otherwise false."
21:02hiredman,(< 1000 1)
21:02clojurebotfalse
21:02jonathanturnerhuh, why is that 1001 1002 1003 instead of 1 2 3?
21:02hiredman,(> 1000 1)
21:02clojurebottrue
21:02hiredmanfilter is jumping over 1-1000
21:02jonathanturneraahhh, oops
21:03jonathanturnerI had it in my head that filter was drawing out what you wanted, not removing it
21:03hiredman,(doc take-filter)
21:03clojurebotjava.lang.Exception: Unable to resolve var: take-filter in this context
21:03hiredmaner
21:03hiredman,(doc take-while)
21:03clojurebot"([pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects."
21:03jonathanturner(take-while (partial < 1000) (iterate inc 1)) returns nothing
21:04jonathanturneror () rather
21:05hiredmanwrong function again
21:05hiredman,(take-while (partial > 1000) (iterate inc 0))
21:05clojurebot(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 1
21:06cmvkki this case, i actually think #(< % 1000) is more readable
21:07jonathanturnerhiredman: I'm scratching my head as to why you say greater than instead of less than
21:07cmvkkbecause you're taking anything that 1000 is greater than.
21:07dnolenjonathanturner > is the function you setting it's first argument to 1000
21:07dnolenthe second argument will be the number passed to take-while to test.
21:08jonathanturnerdnolen: ahh, I think too many years of infix has melted my brain
21:08hiredmanjonathanturner: ,(doc >)
21:08hiredman,(doc >)
21:08clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically decreasing order, otherwise false."
21:08cmvkkthis is why #(< % 1000) makes more sense. partial makes it look wrong...
21:09jonathanturnermonotonically decreasing order? heh, glad I didn't look it up first
21:09jonathanturnercmvkk: yeah, I see your point
21:09hiredman,(doc <)
21:09clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically increasing order, otherwise false."
21:10hiredman~def <
21:16jonathanturnerI get it. So I had filter right in my head, it does draw out when things are true. Not that I was using it right, but had the idea
21:16cmvkkyes.
21:17jonathanturnerthough I guess you guys are prob tired of answering questions like that... I bet a decent number of people try the project euler stuff in clojure
21:17slashus2If an agent blocks, do the agents queued after it run?
21:17slashus2while it is blocked.
21:18hiredmandepends
21:18Chouserif you used send-off, yes
21:18hiredman^-
21:18cmvkkif you send-off a function to an agent, nothing gets queued after it though, right?
21:19slashus2I am playing with a socket server, and I have the agent blocking and waiting for imput from the socket client, but the behavior seems to be that both clients have to enter input before the agents return anything.
21:19cmvkkunless it's another function to the same agent, in which case it would not run.
21:19slashus2cmvkk: That is the case that I am playing with.
21:19slashus2I think I just need to use threads.
21:19cmvkkif you send two functions to the same agent, then they won't run at the same time, i don't think...
21:19slashus2cmvkk: I think you are right.
21:19cmvkk(i don't actually know though)
21:19hiredmanthat is correct
21:20slashus2It is an agent queue.
21:20hiredman,(map #(.getName %) (.getMethods (class (agent nil))))
21:20clojurebot("releasePendingSends" "getErrors" "clearErrors" "getQueueCount" "shutdown" "dispatch" "deref" "setValidator" "getValidator" "notifyWatches" "getWatches" "addWatch" "removeWatch" "alterMeta" "resetMeta" "meta" "wait" "wait" "wait" "hashCode" "getClass" "equals" "toString" "notify" "notifyAll")
21:21cmvkkis there a way to use a Ref from java without using a class that implements Callable?
21:22hiredman~def c.l.Ref
21:22durka42fail
21:24cmvkkdosync runs Ref.runInTransaction, with the body as a callable fn, i think
21:24Chouseroh, by "use" you mean "mutate"?
21:24cmvkkyes.
21:25cmvkki think foo.deref() is good enough to read
21:25Chouseryes
21:25cmvkkbut ideally there would be start and stop methods for transactions or something
21:26hiredmanrunInTransaction doesn't seem to be a method on Ref
21:26Chouserwell, it has to be able to restart the transaction
21:26cmvkkoh right, it's in LockingTransaction
21:26cmvkkChouser, oh you're right. that's a good point.
21:26cmvkkso i really do have to encapsulate transaction code in its own class.
21:27Chouserwhy are you writing Java code?
21:27Chousergun to your head?
21:27hiredmanannon inner class
21:27cmvkkto learn java :)
21:28cmvkki don't mind java, as long as I can do stuff that needs to be dynamic in clojure. which i can.
21:28cmvkkbut i'm writing a 2D game engine, and i want it to work without me having to worry about boxing of numbers between function calls, etc
21:29jonathanturnerwhat's lazy-cons in the most recent clojure?
21:29cmvkklazy-seq ?
21:29cp2jonathanturner: cons
21:29jonathanturnerI notice it's still on the website under Sequences but not in the api docs
21:30cp2cons is now lazy, so no more lazy-cons
21:30hiredmancp2: nope
21:30hiredmancons is not lazy
21:30Chouserlazy-cons is gone. use lazy-seq and cons in similar circumstances
21:30cp2oh what
21:30cp2oh right
21:30hiredmanlazy-seq is lazy
21:30cp2Chouser got it right
21:30cp2i was mixed up
21:30cmvkkha ha, someone didn't update the website properly
21:30hiredmanyou wrap cons in lazy-seq
21:31cp2right, listen to them jonathanturner
21:33Chousersee http://clojure.org/lazy
21:36jonathanturnerChouser: thx
21:42cmvkkugh, i can't commute without passing an IFn either
21:43Chouserthere's a reason rhickey created a new language
21:43cmvkkthis stuff should be usable from java though,
21:43cmvkki mean, having something like a Ref is useful in any language.
21:43Chouserit *is* usable, it's just not convenient
21:44cmvkkit just reminds me of some place where he was talking up the fact that the persistent data structures are all easily drop-in usable in java
21:45cmvkkif that's such a boon, then why not the STM?
21:45cmvkkoh well. i can do it this way anyway.
21:45Chouserall you'd need is macros in Java, and STM could be convenient
21:46cmvkkin this case, it's not something that's a restriction of the language, though.
21:46msinghdid anyone find it weird getting used to square parens coming from lisp?
21:46cmvkksee, refs have a set(), which takes a new value and that's all.
21:46cmvkkbut commuting has particular characteristics that are favorable (it's 'more concurrent')
21:47Chousercmvkk: the fn passed to commute gets run twice
21:47cmvkkthat is true...
21:48dnolenmsingh: only a little, have built in reader support for defining vectors [], maps {}, and set #{} is worth the tradeoff, also it makes destructuring bind quite fun!
21:48cmvkkwhich brings up an interesting point. 90% of the time, all i need to do is commute the ref's value. if it were 100%, i could just use an agent or atom.
21:49cmvkkbut 10% of the time, i need to change two refs in reference to each other
21:49cmvkkthere should be a way to commute outside of a transaction. since i don't intend to do anything else inside the transaction but change that one value.
21:50msinghdnolen: humm.. may'be they'll grow on me :)
21:50arohnerif commute were defined as (dosync (_commute ...)), wouldn't that work?
21:51cmvkkyeah. i guess the point was, in that situation, there's no need to run commute twice.
21:51arohnerbecause if you wanted to do stuff in a "real" transaction, you would write (dosync (commute foo) (commute bar))
21:51cmvkkor rather, there's no need for the fn passed to be called twice.
21:52Chouserthat's a very interesting observation
21:53cmvkkit would be like calling swap! on a ref.
21:53Chouserright
21:53cmvkkwell, kind of. maybe more like 'send' but without the new thread.
21:54cmvkkanyway
21:54Chouserhm.
21:56Chouserno, I think it'd be synchronous, like an atom
21:58cmvkkoh yeah, i guess i was thinking that if it was commutable you wouldn't have to retry ever, but really you still would.
22:00ChouserI see in the code that retries can happen when committing commutes, but I think that's different from what I understood previously.
22:00cmvkkwell if two changes are being made to a ref at once, it doesn't matter if they're commutable. only one can go through.
22:02replacaQ: does anyone know how your supposed to add metadata to a namespace (like a doc string)
22:02Chouserbut I thought they queued up and happened without retrying
22:03replacawe were talking about this earlier, but I don't see how to do it
22:03replaca*your => you're!
22:04cmvkkChouser, commutes queue? that would block the tread the commute occurred in though, right?
22:04cmvkkwhich i thought nothing particularly ever blocked.
22:04cmvkkthe reason agents queue is because the code isn't being executed in the calling thread anyway.
22:11replacaoops, never mind - that was obvious
22:13ChouserI thought the commute happened once for the "in-transaction" value, and then queued for the commit value.
22:13cmvkkif you mean it waits until the transaction is committed to run again, then yeah.
22:14cconstantine_has anyone here used enclojure?
22:14cmvkkbut what if, for example, the transaction finishes, then when the commute is running, another transaction happens?
22:15slashus2Since an agent can block the agent queue, send-off wouldn't help on an agent that blocked indefinitely, it would help on an agent that blocked, but not indefinitely.
22:15cmvkksend-off helps for agents that block indefinitely in that they don't hog one of the threads in the pool.
22:16cmvkkother than that, it makes no difference.
22:17cmvkkalso, there's not just 'an agent queue'. every agent has its own queue... at least i think.
22:17cmvkkif you send-off a function that runs forever, to an agent, it won't affect the way any other agent runs.
22:17Chouserif an action is going to be slowed down by anything other than the CPU, it should be done in a send-off
22:18Carki think there's a single queue for all agents
22:18Cark~def c.l.agent
22:18Chousereach agent has a queue of actions. also, the "send" pool has a queue of agent/actions
22:18Carkright
22:19Carkthat's what they just changed in erlang
22:19Carkthey were seeing contention because of this
22:19replacaCark: did you get the pretty printer working OK?
22:19cmvkkwell anything done with a send-off won't block the pool queue, right?
22:19Carkreplaca : yes i did, thanks a lot
22:19Chousercmvkk: not at the java level, right.
22:19replacayou were having problems with it yesterday, weren't you?
22:20Carkwas only a matter of flushing *out* =/
22:20Chousercmvkk: of course both pools are sharing the same hardware, so... :-)
22:20replacacool, glad to hear it. I'll ge tthe upper stream to flush the underlying strem before closing
22:20cmvkkwell right.
22:20replacawhich should make that invisible to you
22:20Carkreplaca : mhh i'm not sure it's the job of your library to do this
22:21Carklibrary which is highely usefull, thanks for it !
22:21replacawell, I'm creating a wrapper stream, if you didn't do it yourself, so I should probably flush on close
22:21Carkso you'll be flushing each time i use pprint ?
22:21replacaif people are doing larger things, they coul dopen a longer term stream
22:22replacayeah, does that seem like a bad idea?
22:22replacaI've been torn on the subject, which is why I hadn't done it
22:22Carkit depends, can you forsee some inefficiencies coming out of this ?
22:22replaca(you're welcome, btw :-) )
22:23Carki think only the user knows when it's best to flush
22:24replacayeah, though there's a workaround: (binding [*out* (PrettyWriter. *out*)] ...) (more or less)
22:24replacathat's why I'm on the fence. The other ide of the story is that you have confusion.
22:25replacawell, maybe we'll see if more people are confused by it
22:25Carkwell i have a feeling that most programs spend a little more time doing output than my little test, the flushing problem then becomes easy to spot
22:26Carkmaybe give a hint about it in the documentation
22:26replacagood idea
22:27replacaQ: anyone ever think about the problem of "find all the namespaces in a jar?"
22:28ChouserI've asked around about "find all the classes in a package"
22:29Chouserbut apparently the closest you can come to that is poking around if the filesystem or .jar files directly.
22:29albinojar -tf ?
22:29mattreplunzip -l
22:30hiredmanmaybe clojure should have it's own equiv of the manifest?
22:30hiredmanor embrace and extend the manifest
22:30Chouserwhat's missing from java's manifest?
22:30mattreplyou can grab all class files from a jar, if that's what you're thinking
22:31Chouseror all the .cljs
22:31mattreplor that
22:31Chouserand look for (ns ...) at the top
22:31hiredmanChouser: a list of the namespaces in the jar
22:31clojurebotChouser might make night
22:32hiredmanclojurebot: bah!
22:32clojurebotI don't understand.
22:32Chouserclojurebot: Chouser is <reply>Who??
22:32clojurebotChouser might make night
22:32Chouserwhat does that even mean?
22:32Cark~chouser?
22:32clojurebotchouser is ruthless about breaking other people's code
22:33Cark=)
22:33hiredmansomeone was thanking you for something, and it was late
22:33Chousermuch better.
22:33Carkcase sensitive
22:33Chouserohhh.
22:36Chouserbut why won't it let me overwrite?
22:36Carkoh is there only one definition per word ?
22:36Cark~foo
22:36clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
22:36hiredmanit thinks lines that end with ? are questions
22:37hiredmanclojurebot: literal [?] Chouser
22:37clojurebot1
22:37hiredmanclojurebot: literal [1] Chouser
22:37clojurebot<reply>Who??
22:37Chouserrace
22:37hiredmanlooks overwitten to me
22:38Chouser~Chouser?
22:38clojurebotWho??
22:38Chouseryep, you gave me the hint I needed, thanks.
22:56replacasorry, I had to go put my boy to bed
22:56slashus2cmvkk: The reason I said that earlier is because I wrote a server thingy it had the following behavior.
22:57replacaI'm thinking there's gotta be a Java API just to read through the jar and then I can load up all the clj files and see what (all-ns) is like at the end
22:58hiredmanoh sure
22:58hiredmanthere is a java api for jars
23:01lisppaste8slashus2 pasted "server thingy" at http://paste.lisp.org/display/78229
23:05cmvkkslashus2, maybe that's socket behavior?
23:05slashus2cmvkk: It works the way I expected when I use the executors.
23:06cmvkki guess i don't see where you're using more than one agent, by the way.
23:06slashus2I am using one agent.
23:06cmvkkso, an agent can only do one thing at a time.
23:06slashus2Right.
23:06cmvkkso that would be why.
23:06slashus2send and send-off have the same behavior in this case?
23:06cmvkkwhat you should be doing is using a separate agent for each connection.
23:06cmvkkyes.
23:07cmvkkthe thread pool can only do n things at once (where n is the number of threads), but
23:07dreish_send-off only promises not to deplete the common agent thread pool.
23:07cmvkkan agent will only take up one thread at any time.
23:07cmvkkwhether that thread is part of the pool or not.
23:08cmvkk(.execute pool ...) is like creating a brand-new agent and using it only once.
23:08slashus2cmvkk: Yeah
23:08cmvkki.e. (send (agent nil) client-handler-agt-fn client-socket)
23:11hiredmanthe is a threadpool (two of them) backing agents, and each agent has it's own queue of actions
23:12cmvkki think it might be useful to think of an agent as its own thread with an attached value, even though at the java level that's not what's going on
23:13hiredmanso send or send-off to a single agent multiple times will block until the previous action completes
23:13slashus2I was confused because it said that send-off should be used in situations with blocking actions.
23:13hiredmansend's go to a bounded threadpool so they may also need to wait for other agents to complete
23:14hiredmansend-off's go to an unbounded threadpool
23:14dreishslashus2: I agree the docs should do a better job of explaining _why_ the distinction between send and send-off exists. Otherwise one can't help but form theories.
23:15cmvkkoh yeah, the docs for send-off are ambiguous in that way.
23:45arohner,(str nil)
23:45clojurebot""