#clojure log - Apr 07 2009

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

3:41 dysinger: ~java.lang.Thread/currentThread

3:41 clojurebot: ?

3:42 dysinger: ~(.. java.lang.Thread/currentThread getContextClassLoader)

3:42 clojurebot: ?

3:43 dysinger: why is this happening ?

3:43 Clojure

3:43 user=> java.lang.Thread/currentThread

3:43 java.lang.Exception: No such namespace: java.lang.Thread (NO_SOURCE_FILE:0)

3:46 strange

3:46 user=> Thread/currentThread

3:46 java.lang.Exception: No such namespace: Thread (NO_SOURCE_FILE:0)

3:46 user=> Thread

3:46 java.lang.Thread

3:46 user=>

3:47 AWizzArd: ,Thread

3:47 clojurebot: java.lang.Thread

3:47 AWizzArd: ,java.lang.Thread

3:47 clojurebot: java.lang.Thread

3:48 AWizzArd: ,Thread/currentThread

3:48 clojurebot: java.lang.Exception: No such namespace: Thread

3:50 AWizzArd: ,(Thread/currentThread)

3:50 clojurebot: #<Thread Thread[Thread-16,5,main]>

3:50 dysinger: ah my goof

3:50 AWizzArd: dysinger: currentThread is not a public field but instead a method

3:50 So it should be put into parens :)

3:50 dysinger: y I goofed

3:50 noob

4:06 alphazero: good morning / hello all

4:06 AWizzArd: Hi alpha.

4:07 alphazero: Hi there AWizzArd.

4:08 Quick q: has anyone tried bolting clojure to anything besides couchDB for key value hash dbs?

4:25 dysinger: how do I proxy java.util.logging.Formatter ?

4:25 (proxy [Formatter] [] (format [record] ... er wait format is clojure method

4:26 even emacs gets it all mangled

4:26 Cark: do you have an error trying to compile this ?

4:26 dysinger: the problem is the method to proxf is "format"

4:27 not compiling yet

4:27 just curious as to what happens - maybe it's fine - other than emacs mangles the formatting

4:27 Cark: it's working for me

4:27 dysinger: ok

4:27 Cark: (.format blah) and (format blah) are two different functions

4:28 dysinger: y it's just not .format in the proxy form it's plain "format" which clojure-mode then things is the clojure method

4:28 s/things/thinks

4:34 sorry for the noob questions

4:35 is there a way to pull an array out of a bean (set) easy? say I want "x" and "y" properties

4:35 { :x 1 :y 2 :z 3 }

4:36 repeating [(:x myset) (:y myset)] isn't right I bet

4:44 sorry I meant pull out multiple vals from a map

4:44 not set

4:44 I think I want select-keys

4:46 ,(select-keys {:one 1 :two 2 :three 3} '(:one :two))

4:46 clojurebot: {:two 2, :one 1}

4:47 dysinger: hmm closer but still not there

4:48 Chouser: ,(map {:one 1 :two 2 :three 3} '(:one :two))

4:48 clojurebot: (1 2)

4:49 dysinger: nice

4:49 now to guarantee order

4:50 just add sort

4:50 Chouser: those will be in the order given in the list

4:50 ,(map {:one 1 :two 2 :three 3} [:three :one])

4:50 clojurebot: (3 1)

4:51 dysinger: ah that's right

4:51 I was thinking of my version above

4:51 map would work off a seq in order

4:51 thanks

4:52 Chouser: right

5:03 dysinger: Java 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"

5:03 I quickly scanned contrib and didn't see anything stand out.

5:04 Just want to make sure I am not repeating ground

5:24 cemerick: dysinger: we've had good results using log4j in conjunction with clojure.

5:24 not sure what you mean by 'clojure friendly' tho...

5:24 dysinger: I don't want to use commons or log4j

5:25 by clojure friendly I mean the namespace instead of "sun.reflect.NativeMethodAccessorImpl invoke0"

5:26 I guess I could use log4j but what's the point? that was 10 years ago and I am only on java 6

5:27 It doesn't add anything but extra weight IMO

5:27 cemerick: well, java.util.logging is a pale shadow of a kit compared to log4j IMO, but that's emacs v. vi territory.

5:27 dysinger: thats true

5:28 I just don't need JMS appenders etc

5:28 cemerick: the class that is emitted in the log msg should be the one where you invoke the log method, regardless of your kit

5:28 perhaps the log message you pasted was generated by a call from an anonymous fn or somesuch?

5:29 we don't use any of the fancy appenders, either. We're with log4j primarily because of the formatting flexibility.

5:29 dysinger: yes you are right - I was using the repl to try it

5:30 but even from within clojure logging I get "sun.reflect.GeneratedMethodAccessor7 invoke"

5:30 instead of my Logger's name

5:33 ok - I give up - going off to try commons/log4j

5:34 * dysinger has always wondered why Sun did the NIH move on java.util.logging when everyone was already using log4j

5:35 dysinger: They practically cut & pasted doug lea's threading library but couldn't see adopting log4j

5:35 pjstadig: dysinger: does clojure.contrib.javalog not work for you?

5:35 dysinger: whoa - didn't see that - thanks

5:35 I don't know contrib well enough yet.

5:35 pjstadig: javalog.clj -- convenient access to java.util.logging in Clojure

5:35 :)

5:35 dysinger: sweetness

5:39 hmm only problem is the big warning "Consider it DEPRECATED."

5:39 pjstadig: ,(doc clojure.contrib.javalog/*logger*)

5:39 clojurebot: java.lang.Exception: Unable to resolve var: clojure.contrib.javalog/*logger* in this context

5:39 pjstadig: oh

5:39 hehe

5:39 i think something like it might still be useful

5:41 ,(require 'clojure.contrib.javalog)

5:41 clojurebot: java.io.FileNotFoundException: Could not locate clojure/contrib/javalog__init.class or clojure/contrib/javalog.clj on classpath:

5:41 pjstadig: hiredman: i guess clojurebot doesn't have access to clojure.contrib?

5:41 Chouser: not all of it anyway

5:42 dysinger: maybe it's "This library will not work on Java 5." in javalog

5:43 pjstadig: ,(System/getProperty "java.specification.version")

5:43 clojurebot: java.security.AccessControlException: access denied (java.util.PropertyPermission java.specification.version read)

5:43 pjstadig: hehe

5:43 clojurebot: why are you so cagey?

5:43 clojurebot: why not?

5:45 danlarkin: cooked

5:46 dysinger: commons/log4j api is much cleaner

5:46 I never got the asinine Fine, finer & finest

5:47 I actually complained to Sun when they released 1.4 about logging being so arcane compared to log4j

5:47 Chouser: and they said "good point, we'll get right on that"?

5:48 dysinger: heh

5:48 I just wanted to log a complaint

6:06 pjstadig: clojurebot: what is our mascot?

6:06 clojurebot: the official mascot of clojure is a futuristic ninja robot

6:06 pjstadig: clojurebot: just checking

6:06 clojurebot: that's cool

6:07 pjstadig: clojurebot: futuristic ninja robot?

6:07 clojurebot: sooo much better than any of the historical ninja robots

6:20 Guest31655: clojurebot: historical ninja robots?

6:20 clojurebot: historical ninja robots are so 1999...

6:21 Neronus: clojurebot: 1999?

6:21 clojurebot: Gabh mo leithsc�al?

6:21 Neronus: clojurebot: 1999?

6:21 clojurebot: Excuse me?

6:21 Neronus: ahh

6:21 clojure: histerical ninja robots?

6:21 clojurebot: histerical ninja robots?

6:21 clojurebot: Excuse me?

6:21 Neronus: :-/

6:21 clojurebot: You don't pass the turing test

6:21 clojurebot: I don't understand.

6:21 Neronus: clojurebot: yup, thats the problem

6:21 clojurebot: Titim gan �ir� ort.

6:22 Neronus: clojurebot: Wanna talk to a lady I know? She's called eliza

6:22 clojurebot: I don't understand.

6:28 pjstadig: clojurebot: 1999 is <reply>I'm afraid that was before I was born

6:29 clojurebot: Alles klar

6:29 pjstadig: ~1999

6:29 clojurebot: I'm afraid that was before I was born

6:29 pjstadig: clojurebot: turing test is <reply>the answer is 42

6:29 clojurebot: 'Sea, mhuise.

7:16 * hotcore[A] is now away - Reason : Auto-Away after 20 minutes

7:18 danlarkin: please don't subject us to that :-/

12:37 Cark: def~ c.l.PersistentQueue

12:38 ~def c.l.PersistentQueue

12:39 mihand: hello guys. does recur work with lazy sequences?

12:39 Chousuke: what do you mean?

12:40 mihand: i have something like this (lazy-cons x (recur ...

12:40 Chousuke: hmmh

12:40 mihand: i would expect the recur to happen lazyly

12:40 dakrone_hb: when 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:40 kotarak: mihand: call the function recursively instead of recur

12:40 mihand: but instead it loops forever

12:40 Chousuke: I think you need to use a recur... yeah.

12:40 dakrone_hb: s/next/nest/

12:40 Cark: ,(conj (new clojure.lang.PersistentQueue) 1)

12:40 clojurebot: java.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.PersistentQueue

12:41 dakrone_hb: ie: http://gist.github.com/91322

12:41 mihand: calling it recursivly works

12:41 Chousuke: ,(clojure.lang.PersistentQueue. [1 2])

12:41 clojurebot: java.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.PersistentQueue

12:41 kotarak: dakrone_hb: #() is not a fn replacement. You have to use fn for nesting.

12:41 mihand: but i get stack overflows

12:41 Chousuke: should you be using lazy-cons anyway

12:41 wasn't it done away with in the new release.

12:42 kotarak: mihand: you probably want a new release, with lazy-seq

12:42 Chousuke: though it seems the documentation hasn't been updated yet

12:42 dakrone_hb: kotarak, how to you use fn to do %1 equivalent, would #(doseq [group %1] (...)) == (fn [group %1] (...))?

12:42 in the example on the gist

12:42 kotarak: dakrone_hb: (fn [some-seq] (doseq [group some-seq] ...))

12:43 dakrone_hb: kotarak, okay, I'll give it a try, thanks!

12:43 Chousuke: there's no mention of the lazy stuff on the clojure.org front page

12:43 Cark: (conj (clojure.lang.PersistentQueue/EMPTY) :a)

12:43 ,(conj (clojure.lang.PersistentQueue/EMPTY) :a)

12:43 clojurebot: (:a)

12:43 Chousuke: and the docs still talk about lazy-cons

12:44 Cark: hum is it safe as in futureproof to use persistentqueues ?

12:44 Chousuke: Should be. :/

12:44 dakrone_hb: kotarak, that works great, thanks again :)

12:45 kotarak: dakrone_hb: np :)

12:45 danlarkin: ARGH why does (TimeZone/getDefault) return a sun.util.calendar.ZoneInfo instead of a java.util.TimeZone like it says it will?

12:46 dakrone_hb: so fn defines a function, and #( is like a lambda?

12:46 I'm still unsure of the main difference between the two

12:46 kotarak: dakrone_hb: fn is like lambda and #() is for very short lambdas.

12:47 dakrone_hb: #(foo %) is equivalent to (fn [x] (foo x))

12:47 Cark: ,(doc seque)

12:47 clojurebot: "([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:47 dysinger: how 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:47 dakrone_hb: kotarak, so, why can you nest fn, but not #90?

12:47 *#()

12:48 Cark: ~def seque

12:48 kotarak: dakrone_hb: because #() is only for very *short* lambdas. Something like #(instance? SomeClass %).

12:48 dakrone_hb: kotarak, okay, I'll remember that, thanks for the explaination

12:50 pjstadig: ~function literals?

12:50 clojurebot: Function literals are cute, but overused

12:55 dysinger: anyone have a noob explaination for my question above on (:import vs (import in (ns

12:55 ?

12:56 Cark: humhum rhickey: that's why I haven't exposed PersistentQueue yet - I'm afraid of people building polling systems on top of refs

12:57 well i'm not polling, i only need a queue !

12:57 Chouser: Cark: yes, I think that's specifically the misuse he's trying to avoid

12:58 go ahead and use the class directly get the empty one, and you're set from there on in.

12:58 Cark: ok well i'm afraid about it disapearing in a future version

12:58 kotarak: dysinger: the :import for without quoting is correct.

12:58 Cark: i might have to build my own because of this

12:58 Chouser: Cark: I wouldn't worry about that.

12:59 Cark: it's more likely to be exposed properly in a future version than it is to go away, I think.

12:59 Cark: also there's a little problem with it's interface

12:59 when you pop from a collection, it should return both the poped value and the new collection

13:00 Chouser: Cark: forcing you to destructure?

13:00 Cark: as it is you have to do imperative style ugliness

13:00 Chouser: what??

13:01 Cark: first get the value, the return the new queue ...

13:01 then

13:02 and yes, forcing destructuring is what you have to do in the absence of multiple return values

13:03 Chouser: it's no more imperative than working with any other seqable. (first s) ... (next s)

13:03 Cark: ah you're right

13:04 ok well i'll use it ... if it disapear i'll blame it on you !

13:04 =P

13:05 Chouser: ok

13:05 I can handle such blame.

13:06 hiredman: Cark: if you really want to write non-imperitive code, make your functions pointless

13:06 Cark: chouser : damn, you're supposed to be terrified at this point...

13:07 hiredman, i just don't like to have these (do froms all over the place

13:07 Chouser: hiredman: a lot of the code I write seems pretty pointless, at least when I look back on it a few days later.

13:07 hiredman: :P

13:07 Chouser: Cark: yeah, breaking other people's code just doesn't scare me much. ;-)

13:09 Cark: ~chouser is ruthless about breaking other people's code

13:09 clojurebot: Ik begrijp

13:10 Chouser: I think I can back that up with facts, even.

13:11 dysinger: kotarak: "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:12 It doesn't seem clear and clean to me why not

13:12 kotarak: dysinger: 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:13 dysinger: y let me pastie one up and make sure I am correct

13:13 Cark: there are (were?) somme inconsistencies with the diferrent part of the ns form

13:14 i found that always using vectors works

13:14 like (ns some.package (:use [blah] [troot]) (:import [some.package Blah]))

13:15 kotarak: Wasn't there some change? I think, the () form was the original one. But I vaguely remember Stephen writing about that on the group.

13:16 Chouser: afaik, no actual change was made.

13:16 Cark: ah could be ... anyways use the vector syntax ...always works !

13:34 dysinger: kotarak - I was in the wrong ns

13:34 sorry

13:34 kotarak: np

13:34 dysinger: how do you guys define something like a logger that you want to stick around ?

13:35 I don't want to make-log for every debug call

13:35 I was doing this (def log (LogFactory/getLog "x.y.z"))

13:37 seems to work but I want to make sure I am following idiom

13:37 idioms

13:38 (defn log ..... ) would evaluate it every call right ?

13:39 Chouser: dysinger: yeah, what you've got seems fine.

13:39 dysinger: k

13:40 kotarak: Is there some ant magic, that it stops when c.l.Compile blows up?

13:45 cemerick: ~max

13:45 clojurebot: max people is 164

13:45 cemerick: I daresay we've hit a plateau.

13:46 who's got day-by-day population data for #clojure to make a pretty graph? ;-)

13:46 kotarak: Hmm.. We dettach from the google group. Should be 170 by now.

13:48 When 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:49 cemerick: I think it always prefers the classfile.

13:49 Wouldn't make sense to do otherwise.

13:49 kotarak: It loads the src if it's newer. But is this information available via jar?

13:50 cemerick: ah -- which reminds me -- why does the clojure-slim.jar file produced by the build retain the .clj files?

13:52 kotarak: The 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:55 cemerick: I'm not clear on why the source is still available, if you've split contrib into one jar per lib...

13:57 kotarak: cemerick: 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:58 cemerick: hrm.

13:59 that'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:59 that's an orthogonal problem, though.

14:00 kotarak: why not compile everything in one shot to one dest dir, and then produce separate artifacts for each lib?

14:02 kotarak: cemerick: 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:03 cemerick: There'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:06 kotarak: cemerick: 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:07 cemerick: there's N libs in clojure-contrib, each one in clojure.contrib.XXX. Why not one artifact per lib package?

14:09 kotarak: cemerick: 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:11 dysinger: pulling my hair out - figured out the problem

14:11 my mac's java vm is 6 (set in the prefs panel)

14:11 but Aquamacs / Slime is loading 5

14:11 :/

14:12 user=> (System/getProperty "java.vm.version")

14:12 "1.5.0_16-133"

14:12 anyone else have this problem ?

14:14 cemerick: nope

14:14 * cemerick uses enclojure ;-)

14:15 Cark: did you manage to make eclipse work on an x64 computer ?

14:17 dysinger: Eclipse loads with JDK 1.5 on mac but recognizes 1.6 is on the system

14:17 (for me)

14:40 durka42: kotarak: bah, my repl isn't working anymore

14:40 kotarak: durka42: huh?

14:40 durka42: \sr isn't bound to anything

14:41 kotarak: hmmm.. which rev are you using?

14:42 durka42: um, i just did hg pull/hg update bleeding-edge

14:42 vimclojure#NailgunClient is correct

14:43 kotarak: what does b:vimclojure_namespace say?

14:43 durka42: invalid expression

14:43 :echo b:vimclojure_namespace

14:43 kotarak: Have you started the ng-server? (<- stupid questions first)

14:43 durka42: aah! no i haven't

14:44 stupid people first

14:44 kotarak: Just start the server and do a :a

14:44 I mean :e

14:44 This should correctly setup the buffer.

14:45 durka42: you fixed the error conditions then, when there is no server to be found

14:45 uh oh

14:45 kotarak: It basically just goes on without interactive features.

14:45 Starting the server and doing :e will activate them.

14:46 lisppaste8: durka42 pasted "untitled" at http://paste.lisp.org/display/78190

14:47 kotarak: What did you do?

14:47 durka42: i opened the file

14:47 that also happened when i did :e

14:47 the server is now running

14:47 kotarak: hmmm... What is gismu?

14:47 durka42: it is the namespace of the file

14:48 and the filename

14:48 kotarak: You did no \ef or something=

14:48 ?

14:48 durka42: no

14:48 i mean, it's true that it isn't on the classpath

14:49 kotarak: Arg. That gives always problems. You have to work with a proper setup.

14:49 VC looks into the namespace to determine the syntax highlighting of included libs.

14:50 Therefor the namespace must be available.

14:50 durka42: i can open other files

14:51 wait, it should be on the classpath

14:51 hmm

14:55 strange

14:55 the file starting with "(ns org.durka.nytimes.common" is loaded fine

14:55 "(ns org.durka.gismu" does not work

14:55 kotarak: what is the complete ns-form of the failing one?

14:56 Ah no. Shouldn't of importance.

14:56 VC loads via normal require...

14:58 durka42: ah, now it works

14:59 i restarted a few things after putting it on the classpath

15:00 so files with compilation errors do not load

15:00 this may or may not be desired behavior

15:01 kotarak: hmm... 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:01 VC heavily relies on the introspection capas of Clojure.....

15:02 durka42: right

15:03 kotarak: Helping it a bit can get you very far. :)

15:08 Neronus: wahh... namespace dependency hell

15:39 eyeris: Is (for [a as b bs] [a b]) supposed to generate the same combinations as (for [a as] (for [b bs] [a b]))?

15:39 Chousuke: probably.

15:40 ,(for [a [1 2] b [3 4]] [a b])

15:40 clojurebot: ([1 3] [1 4] [2 3] [2 4])

15:40 Chouser: no, 'for' flattens things out, returns a single seq

15:40 eyeris: It will be wrapped in an extra list.

15:40 Chouser: if you nest the 'for' yourself, you'll get nested seqs

15:40 eyeris: But the combinations seem the same when I use numbers

15:41 Chousuke: hm, right.

15:41 eyeris: However I have other code that seems to behave differently.

15:41 brb

16:01 I'm trying to construct a crosstab from aggregate database results, but I'm having trouble with (for)

16:01 http://pastebin.ca/1385227

16:01 That paste shows my code and the problem I am having.

16:03 I 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:03 What I am getting is a list of all combinations of the items in each list.

16:04 Do I just need to replace the second (for) with a searching function?

16:04 kotarak: (map #(if (pred %1 %2) [%1 %2] [%1 nil]) list-1 list-2) ?

16:05 eyeris: kotarak (map) requires equal-length lists.

16:06 kotarak: ,(map #(vector %1 %2) [1 2 3] (iterate inc 5))

16:06 clojurebot: ([1 5] [2 6] [3 7])

16:07 cads: ,(zip [1 2 3] [1 2 10])

16:07 clojurebot: java.lang.Exception: Unable to resolve symbol: zip in this context

16:08 kotarak: ,(interleave [1 2 3] [1 2 10])

16:08 clojurebot: (1 1 2 2 3 10)

16:08 cads: ,(interleave [1 2 3] [1 2 10 6 6 6])

16:08 clojurebot: (1 1 2 2 3 10)

16:09 cads: nice!

16:09 can we easily map a function over pairs in an interleaved list?

16:09 eyeris: ,(into (1 2 3) (10 11 12))

16:09 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

16:09 eyeris: ,(into [1 2 3] [10 11 12])

16:09 clojurebot: [1 2 3 10 11 12]

16:10 kotarak: cads: you mean like partition?

16:10 slashus2: ,(zipmap [1 2 3 4] [4 5 6 7])

16:10 clojurebot: {4 7, 3 6, 2 5, 1 4}

16:10 kotarak: (map identity (partition 2 (interleave [1 2 3] [:a :b :c])))

16:10 ,(map identity (partition 2 (interleave [1 2 3] [:a :b :c])))

16:10 clojurebot: ((1 :a) (2 :b) (3 :c))

16:11 Chouser: ,(map vector [1 2 3] [:a :b :c])

16:11 clojurebot: ([1 :a] [2 :b] [3 :c])

16:11 Chouser: ,(map list [1 2 3] [:a :b :c])

16:11 clojurebot: ((1 :a) (2 :b) (3 :c))

16:11 eyeris: ,(map vector [1 2 3] [:a :b :c :d])

16:11 clojurebot: ([1 :a] [2 :b] [3 :c])

16:11 cads: :)

16:11 eyeris: ,(map identity (partition 2 (interleave [1 2 3] [:a :b :c :d])))

16:11 clojurebot: ((1 :a) (2 :b) (3 :c))

16:11 kotarak: eyeris: seems that map doesn't require equal-length lists ;)

16:12 slashus2: ,(vec (zipmap [1 2 3] [:a :b :c]))

16:12 clojurebot: [[3 :c] [2 :b] [1 :a]]

16:12 eyeris: kotarak It doesn't require them to execute, but it only consumes the smaller of the number of entries in each list

16:14 cads: ,(let (zipmap2 #(map %1 (vector %2 %3))) (zipmap2 identity [1 2 3 4] [:dog :cat :bat]))

16:14 clojurebot: java.lang.IllegalArgumentException: let requires a vector for its binding

16:15 cads: ,(let [zipmap2 #(map %1 (vector %2 %3))] (zipmap2 identity [1 2 3 4] [:dog :cat :bat])) ; like that?

16:15 clojurebot: ([1 2 3 4] [:dog :cat :bat])

16:16 cads: hrm, I missed what Chousuke did

16:17 eyeris: cads: Here's a fleshed out example: http://pastebin.ca/1385227

16:18 I don't even need the items paired, if the mismatches are eliminated.

16:22 eevar_: 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:23 slashus2: ,(rest [3])

16:23 clojurebot: ()

16:23 eevar_: http://clojure.org/lisps

16:24 Chouser: ,(next [3])

16:24 clojurebot: nil

16:24 slashus2: ,(next [3])

16:24 clojurebot: nil

16:25 eevar_: that whole paragraph seems pre-lazy-patch to me

16:26 Chouser: eevar_: yes it does

16:27 eyeris: Is there a function in the api like filter, but returning the first match instead of all matches?

16:28 ,(first [])

16:28 clojurebot: nil

16:28 slashus2: some

16:28 ,(some even? [1 3 4])

16:28 clojurebot: true

16:29 slashus2: await.

16:29 eyeris: Thanks

16:30 slashus2: No, some doesn't do that.

16:30 You could just use first on filter.

16:30 eyeris: (first (filter even? [1 3 4]))

16:30 ,(first (filter even? [1 3 4]))

16:30 clojurebot: 4

16:31 eyeris: ,(first (filter even? [1 3 5]))

16:31 clojurebot: nil

16:31 eyeris: Perfect

16:31 kotarak: Ins't there a find-first or seek or something in contrib.seq-utils?

16:31 AWizzArd: there is

16:31 (find-first even? [1 3 5])

16:31 Chouser: eyeris: (defn left-join [as bs pred] (for [a as] [a (first (filter #(pred a %) bs))]))

16:32 eyeris: Chouser: That is what I was just trying! :)

16:32 You beat me to it :)

16:32 Chouser: ah, sorry.

16:33 eyeris: Earlier 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:33 I knew it had to be simple

16:34 Chouser: by the time I understood what you were trying to produce, I had the solution

16:34 since you're working with collections of maps and have names like "left-join", you might be interested in clojure.set

16:35 eyeris: Docs? I don't see it on the libraries page.

16:35 slashus2: http://clojure.org/api#toc649

16:37 Chouser: things named like 'xrel' should be sets of maps

16:37 bradford: anyone using clojure-test-mode?

16:39 cemerick: is there a map fn across associatives? Or is (apply hash-map (mapcat ...)) the best there is?

16:40 kotarak: (into (empty thing) (map foo thing))?

16:42 cemerick: yeah, somewhat better.

16:42 bradford: re: clojure-test-mode...I am able to run tests, but unsure what buffer the output is being dumped to - any ideas?

16:42 cemerick: heh, I *always* forget about into

16:42 kotarak: cemerick: me too. :)

16:43 cemerick: I 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:44 ...which is surely wrong in the new clojure world order :-)

16:49 Chouser: no, I think you're right.

16:50 vectors and (array-)maps are created more efficiently when given the full set of values at creation

16:52 cemerick: well, 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:53 slashus2: It would be neat if the map constructors could also take in a map.

16:53 (sorted-map map-of-another-kind)

16:54 antifuchs: how would the resulting sorted map be ordered? (:

16:54 slashus2: by the keys

16:55 Chouser: cemerick: for hash-map, yes. But (apply array-map ...) can be O(1) instead of O(n)

16:55 cemerick: slashus2: (into (sorted-map) map-of-another-kind)?

16:56 antifuchs: makes as much sense as any other (:

16:56 slashus2: cemerick: Yes that does work.

16:56 When I first saw (sorted-map) I expected it to take a map as an argument to coerce it.

16:57 cemerick: Chouser: ah. That'd get coerced up to a hash-map pretty quickly, though.

16:57 Chouser: hm, and in practice you'd have to work pretty hard to make it O(1)

16:57 cemerick: yeah

16:58 it'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:58 slashus2: ,(. clojure.lang.PersistentTreeMap (create {:b 5 :a 4}))

16:58 clojurebot: {:a 4, :b 5}

16:58 Chouser: even a LazilyPersistentVector will clone it's array before handing it to a PersistentArrayMap

16:58 slashus2: That will do it, but that is not how the constructor is set up.

16:59 Chouser: slashus2: that's some old-school syntax you've got there. ;-)

16:59 ,(clojure.lang.PersistentTreeMap/create {:b 5 :a 4})

16:59 clojurebot: {:a 4, :b 5}

16:59 slashus2: Chouser: I copied that out of the core.

16:59 Chouser: ah

16:59 slashus2: The core has some old school syntax :-P

17:00 cemerick: heh -- that's probably worth tweaking, so people can pick up "modern" idioms

17:00 slashus2: Chouser: Is that more efficient than doing into?

17:01 into seems faster.

17:01 Chouser: both essentially do 'assoc' on all the values

17:01 slashus2: hmm

17:02 Chouser: on all the entries

17:02 slashus2: No, I was just doing a mini benchmark that doesn't show the variability of the times.

17:02 I guess they are very similar.

17:02 pjstadig: ,(class (into [] '(a b c)))

17:02 clojurebot: clojure.lang.PersistentVector

17:03 pjstadig: i thought into was lazy

17:03 Chouser: no

17:03 slashus2: Maybe it should have three explanation points on it.

17:04 (into!!! (sorted-map) {:b 5 :a 4})

17:04 pjstadig: ~def into

17:04 dakrone_hb: from: (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:04 Chouser: it produces non-lazy collections. no way for it to be lazy

17:05 pjstadig: yeah i wasn't sure why i thought that

17:05 i hadn't thought it all the way through

17:05 Chouser: dakrone_hb: what's 'exec'?

17:05 pjstadig: i just thought it was supposed to be efficient

17:05 dakrone_hb: Chouser, http://gist.github.com/91322 very first defmacro

17:07 Chouser: that macro looks bad -- it needs to force the lazy line-seq before returning out of with-open

17:07 dakrone_hb: Chouser, unfortunately, I don't completely understand how it works, found it elsewhere and needed something to run other programs

17:07 Chouser: or I suppose you have to be careful to force as much as you need in your 'pred'

17:07 dakrone_hb: clojure needs a popen method

17:07 Chouser: dakrone_hb: you might look at clojure.contrib.shell-out

17:08 dakrone_hb: Chouser, I will take a look at it

17:08 kotarak: It doesn't even need to be a macro...

17:09 Chouser: shell-out returns non-lazy things specifically to avoid that kind of problem

17:09 dakrone_hb: is there a unified place for clojure-contrib documentation, or do I need to go through all the source to understand it?

17:09 the google-code wiki only has 1 page in it

17:10 or, run (doc <blah>) on everything I guess

17:10 if there is a web-form

17:10 Chouser: there'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:11 most of them also have expamples of usage at the end, in a comment.

17:11 dakrone_hb: I see, seems like a javadoc equivalent would be nice to have for it

17:12 Chouser, thanks for the pointer, I'll check it out

17:22 duncanm: is there an equivalent to begin0 or prog1 in Clojure?

17:24 kotarak: (defmacro do1 [form & body] `(let [result# ~form] ~@body result#))

17:26 or: (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:27 So although not strictly necessary, I would prefer the macro in this case.

17:28 Chouser: interesting

17:28 slashus2: (defn returning [returnval & body] returnval)

17:29 Does that work?

17:29 kotarak: yes, but for the above reasons I would not recommend this function.

17:31 slashus2: yeah

17:33 kotarak: But what are my recommendations... YMMV as always.

17:34 replaca: dakrone_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:34 dakrone_hb: replaca, that would definitely be helpful

17:34 should write a javadoc tool to go through and run (doc) on everything and convert it to html for publishing

17:35 replaca: I think so. We need to discuss and get some consensus on the best location, format, etc.

17:35 dakrone_hb: yeah, that's one component. Rich already does that for the core API

17:35 We should probably follow him on that for consistency

17:36 kotarak: There is already clj-doc, which is supposed to do that, IIRC.

17:36 dakrone_hb: one thing I'd love to see (as an extreme newbie) is non-trivial examples for all the core API functions in the docs

17:36 kotarak: Maybe it could serve as a starting point.

17:37 replaca: kotarak: yeah, we just need to automate it and host it

17:37 dakrone_hb: someone already did some of the in the wikibook. Did you check that out?

17:37 kotarak: dakrone_hb: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

17:37 clojurebot: examples is also http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

17:37 clojurebot: Ik begrijp

17:38 replaca: kotarak: thanks, saved me the trip!

17:38 dakrone_hb: kotarak, replaca, awesome! was reading through it and hadn't gotten there yet

17:38 replaca: as for contrib doc, I'd like to see it get a little richer than just API doc

17:39 kotarak: Namespaces may also carry docstrings. Some more verbose docs with examples could go there.

17:39 replaca: which implies the ability for authors to add their own html, markdown whatever

17:39 kotarak: so that did happen? I remembered it being discussed, but didn't know if it happened

17:39 that's also a great component

17:40 slashus2: So a "JavaDoc" generator for clojure?

17:40 kotarak: But it is currently broken in so far, that the metadata on namespaces is lost when loading from a class file.

17:40 At least it was the last time I checked.

17:41 replaca: I'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:41 maybe hosted on the main clojure site off the contrib link.

17:42 kotarak: :-( I'll take a look and see if there's an issue on it

17:42 we're realy going to want that for tools like this

17:42 kotarak: replaca: I asked rhickey several times, whether I should open an issue, but never got an answer.

17:44 replaca: hmm, maybe we should just go ahead and do it :-) we could try to see if there's an easy patch

17:44 the desire for someone to do and maintain this system (which I'm willing to do) could serve as a motivator

17:45 I'll write up a post to the group (it's been on my mind anyway)

17:45 and see what people think

17:46 cp2: si there a built in function that returns the version of clojure?

17:46 Chouser: cp2: no

17:46 cp2: aye

17:47 Raynes: Write one.

17:47 replaca: Raynes: Can you determine it from the jar? I don't think so

17:47 slashus2: I don't think clojure keeps up with its current version.

17:48 cp2: Raynes: i wanted to see which version this clojure plugin downloaded

17:48 (la clojure for IDEA)

17:48 but im just going to build one from svn

17:48 replaca: It would have to be part of the compilation

17:48 kotarak: Up to now I had the impression, that the current version number doesn't keep up with the dev speed of clojure... ;)

17:48 replaca: I'd like to see a version and build number in there too, though

17:48 Raynes: cp2: I always use an external Clojure with La Clojure and Enclojure.

17:49 cp2: yeah Raynes, thats what i will be doing

17:49 replaca: most production systems that I've been involved with stash their svn version or something like it in the output somewhere

17:50 Chouser: http://clojure-log.n01se.net/date/2009-03-20.html#11:05b

17:50 cp2: heh

17:50 * Raynes hugs Chouser

17:51 cp2: darn, revision 1338

17:51 i missed rev 1337

17:51 replaca: we discussed 1337 in here when it went by

17:52 that was a moment of high geekiness

18:03 dakrone_hb: Chouser, do you have a moment I could ask you some questions about your shell-out library?

18:07 cp2: does la clojure have the ability to spawn a repl?

18:08 Raynes: do you know ?

18:09 ah i see

18:09 nevermind

18:15 Raynes: cp2: 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:16 cp2: yes i noticed :)

18:16 Raynes: The 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:17 cp2: hm

18:17 i only just installed it, so i dont know about the way it indents

18:17 let me check that out

18:18 i see

18:18 yeah, i dont prefer my indentation to be like that either

18:18 Raynes: cp2: I think he thinks that is the convention :\

18:18 cp2: lol

18:19 i can tolerate that, but it would be nice to have it configurable

18:19 Raynes: I'm too picky to tolerate that.

18:44 Chouser: dakrone_hb: sure

18:44 dakrone_hb: so 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:44 Chouser: sure

18:46 dakrone_hb: and 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:46 because I'm going to be calling a lot of external programs and iterate over the lines of output

18:47 Chouser: sure, a function like that should be pretty easy to write.

18:47 dakrone_hb: I'm trying to wrap my head around writing it

18:48 and I have (defn sh-lines [& body] (.split (:out (sh body :return-map true)) "\n"))

18:48 but that doesn't work, something with the arguments I believe

18:48 am I on the right track? wrong track?

18:49 Chouser: looks pretty close

18:49 try (apply sh :return-map true body)

18:50 dakrone_hb: Chouser, excellent!

18:50 thanks works :)

18:51 Chouser: great. you see why you need apply?

18:51 * Chouser is a Socratic failure.

18:51 dakrone_hb: Chouser, I *think* so, is it because body is a list of arguments?

18:51 Chouser: right, body is a list but sh is expecting several args instead of a single list

18:51 dakrone_hb: and apply formats it correctly for the (sh) function?

18:52 how does apply know how to apply ':return-map true' to 'sh'?

18:52 *know not to

18:52 slashus2: ,(doc apply)

18:52 clojurebot: "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."

18:52 Chouser: apply take then fn, then several args (or none), and finally a seq -- the seq is "unrolled" into the args to the fn

18:53 dakrone_hb: okay, so it applies to the last arg, no matter how many other arguments you have

18:53 Chouser: right

18:53 dakrone_hb: I understand now :) thanks

18:53 Chouser: which is why the body arg has to go last

18:53 dakrone_hb: okay

18:53 Chouser: fortunately sh doesn't demand that the options come at the end

18:54 dakrone_hb: if it did, would this not work?

18:54 Chouser: right, you'd have to do something more complicated

18:54 (apply sh (concat body [:return-map true])) or something

18:55 dakrone_hb: ahh, to add the option only to the end first

18:55 thanks for the shell-out library, much better than the macro I was using :)

18:56 Chouser: you're welcome -- I only started it, several others have added on now.

18:58 you might want to be careful spliting on "\n" if you intend to work on other OS's

18:58 dakrone_hb: Okay, I'll switch to a separator that'll work with others

18:58 thanks for the heads up

18:59 Chouser: could be another option, I suppose

18:59 dakrone_hb: for 'sh'?

18:59 Chouser: :out :line-vec

19:00 dakrone_hb: ahh, to split by lines automatically?

19:00 Chouser: right

19:00 dakrone_hb: that would be useful

19:07 Chouser: would there be any value to you if it returned a lazy sequence?

19:32 hiredman: lisppaste8: url?

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

19:32 hiredman pasted "fast-proxy" at http://paste.lisp.org/display/78214

19:34 Cark: the regular proxy is slow ?

19:34 lisppaste8: hiredman annotated #78214 "usage example" at http://paste.lisp.org/display/78214#1

19:34 hiredman: no

19:34 fast in the writing sense

19:35 Cark: kk

19:35 Chouser: the first arg to the given fn is the name of the method being called?

19:35 hiredman: as a keyword

19:36 durka42: so the only function you give fast-proxy is a dispatch?

19:36 hiredman: so you can use it with a multimethod

19:36 no, it is a function

19:36 if it is a multimethod it will need it's own dispatch function

19:37 something like (comp first list)

19:38 (defn fn->al [func] (fast-proxy ActionListener (fn [_ event] (func event))))

19:50 durka42: why did you use _SOMEFUNCTION instead of a gensym?

19:50 clojurebot: why not?

19:50 durka42: good answer

19:51 hiredman: different symbols got generated

19:51 (let* [fn__688__auto__ (constantly 1)] (clojure.core/proxy [clojure.lang.IDeref] [] (deref [& args] (clojure.core/apply fn__687__auto__ :deref args))))

19:52 durka42: interesting

19:55 Chouser: that's because auto-gensym only works right within a single syntax-quote

19:55 you'd have to use (gensym) manually

19:56 hiredman: in the outer let?

19:57 Chouser: sure, next to 'class'

19:59 lisppaste8: hiredman annotated #78214 "fixed to use gensym" at http://paste.lisp.org/display/78214#2

20:13 hiredman annotated #78214 "filter out methods from ancestors" at http://paste.lisp.org/display/78214#3

20:15 durka42: is that what getDeclaredMethods does?

20:15 hiredman: is it?

20:16 ~javadoc java.lang.Class

20:17 cp2: getDeclaredMethods returns all methods regardless of access flags

20:17 whereas getMethods only returns public methods

20:18 durka42: i mean, do you want this method to filter out superclass methods

20:18 this macro, i mean

20:18 hiredman: yes

20:19 durka42: what if you're proxying something that descends from jframe, say

20:19 hiredman: I don't want to proxy wait() etc

20:19 fast-proxy is for simple things

20:19 at least that is the idea

20:20 durka42: ok

20:21 hiredman: I guess I could just filter out methods from Object

20:22 lisppaste8: hiredman annotated #78214 "filter out methods from object" at http://paste.lisp.org/display/78214#4

20:29 hiredman: ~ticker IDSOX

20:29 clojurebot: IDSOX; -0.30

20:29 hiredman: my first day of my first index fund

20:33 cp2: lol

20:34 Cark: ~google IDSOX

20:34 clojurebot: First, out of 167 results is:

20:34 IDSOX: Profile for ING DIRECT INDEX PLUS SMALL CAP - Yahoo! Finance

20:34 http://finance.yahoo.com/q/pr?s=idsox

20:58 jonathanturner: newbie 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:59 hiredman: you want take-while

20:59 durka42: (partial < 1000) is #(< 1000 %)

20:59 hiredman: durka42: shhh

20:59 clojurebot: function literals

20:59 clojurebot: Function literals are cute, but overused

21:00 durka42: no, i was giving a hint as to why it didn't work

21:00 hiredman: filter has no way of knowing that sometime after 1000 there isn't something that is less then 1000

21:00 durka42: that too

21:00 hiredman: clojurebot: filter?

21:00 clojurebot: filter is not map

21:01 durka42: clojurebot: map?

21:01 clojurebot: map is *LAZY*

21:01 hiredman: clojurebot: literal [?]

21:01 clojurebot: 1

21:01 durka42: clojurebot: lazy?

21:01 clojurebot: lazy is hard

21:01 jonathanturner: hiredman: I thought that too, but then why would it return the values if they didn't meet the requirement?

21:01 hiredman: clojurebot: literal [?] filter

21:01 clojurebot: 1

21:01 durka42: ,(take 3 (filter (partial < 1000) (iterate inc 1)))

21:01 clojurebot: (1001 1002 1003)

21:01 hiredman: clojurebot: filter is also <reply>filter doesn't stop

21:01 clojurebot: c'est bon!

21:01 hiredman: jonathanturner: you are using the wrong function

21:02 ,(doc <)

21:02 clojurebot: "([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically increasing order, otherwise false."

21:02 hiredman: ,(< 1000 1)

21:02 clojurebot: false

21:02 jonathanturner: huh, why is that 1001 1002 1003 instead of 1 2 3?

21:02 hiredman: ,(> 1000 1)

21:02 clojurebot: true

21:02 hiredman: filter is jumping over 1-1000

21:02 jonathanturner: aahhh, oops

21:03 I had it in my head that filter was drawing out what you wanted, not removing it

21:03 hiredman: ,(doc take-filter)

21:03 clojurebot: java.lang.Exception: Unable to resolve var: take-filter in this context

21:03 hiredman: er

21:03 ,(doc take-while)

21:03 clojurebot: "([pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects."

21:03 jonathanturner: (take-while (partial < 1000) (iterate inc 1)) returns nothing

21:04 or () rather

21:05 hiredman: wrong function again

21:05 ,(take-while (partial > 1000) (iterate inc 0))

21:05 clojurebot: (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:06 cmvkk: i this case, i actually think #(< % 1000) is more readable

21:07 jonathanturner: hiredman: I'm scratching my head as to why you say greater than instead of less than

21:07 cmvkk: because you're taking anything that 1000 is greater than.

21:07 dnolen: jonathanturner > is the function you setting it's first argument to 1000

21:07 the second argument will be the number passed to take-while to test.

21:08 jonathanturner: dnolen: ahh, I think too many years of infix has melted my brain

21:08 hiredman: jonathanturner: ,(doc >)

21:08 ,(doc >)

21:08 clojurebot: "([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically decreasing order, otherwise false."

21:08 cmvkk: this is why #(< % 1000) makes more sense. partial makes it look wrong...

21:09 jonathanturner: monotonically decreasing order? heh, glad I didn't look it up first

21:09 cmvkk: yeah, I see your point

21:09 hiredman: ,(doc <)

21:09 clojurebot: "([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically increasing order, otherwise false."

21:10 hiredman: ~def <

21:16 jonathanturner: I 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:16 cmvkk: yes.

21:17 jonathanturner: though 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:17 slashus2: If an agent blocks, do the agents queued after it run?

21:17 while it is blocked.

21:18 hiredman: depends

21:18 Chouser: if you used send-off, yes

21:18 hiredman: ^-

21:18 cmvkk: if you send-off a function to an agent, nothing gets queued after it though, right?

21:19 slashus2: I 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:19 cmvkk: unless it's another function to the same agent, in which case it would not run.

21:19 slashus2: cmvkk: That is the case that I am playing with.

21:19 I think I just need to use threads.

21:19 cmvkk: if you send two functions to the same agent, then they won't run at the same time, i don't think...

21:19 slashus2: cmvkk: I think you are right.

21:19 cmvkk: (i don't actually know though)

21:19 hiredman: that is correct

21:20 slashus2: It is an agent queue.

21:20 hiredman: ,(map #(.getName %) (.getMethods (class (agent nil))))

21:20 clojurebot: ("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:21 cmvkk: is there a way to use a Ref from java without using a class that implements Callable?

21:22 hiredman: ~def c.l.Ref

21:22 durka42: fail

21:24 cmvkk: dosync runs Ref.runInTransaction, with the body as a callable fn, i think

21:24 Chouser: oh, by "use" you mean "mutate"?

21:24 cmvkk: yes.

21:25 i think foo.deref() is good enough to read

21:25 Chouser: yes

21:25 cmvkk: but ideally there would be start and stop methods for transactions or something

21:26 hiredman: runInTransaction doesn't seem to be a method on Ref

21:26 Chouser: well, it has to be able to restart the transaction

21:26 cmvkk: oh right, it's in LockingTransaction

21:26 Chouser, oh you're right. that's a good point.

21:26 so i really do have to encapsulate transaction code in its own class.

21:27 Chouser: why are you writing Java code?

21:27 gun to your head?

21:27 hiredman: annon inner class

21:27 cmvkk: to learn java :)

21:28 i don't mind java, as long as I can do stuff that needs to be dynamic in clojure. which i can.

21:28 but 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:29 jonathanturner: what's lazy-cons in the most recent clojure?

21:29 cmvkk: lazy-seq ?

21:29 cp2: jonathanturner: cons

21:29 jonathanturner: I notice it's still on the website under Sequences but not in the api docs

21:30 cp2: cons is now lazy, so no more lazy-cons

21:30 hiredman: cp2: nope

21:30 cons is not lazy

21:30 Chouser: lazy-cons is gone. use lazy-seq and cons in similar circumstances

21:30 cp2: oh what

21:30 oh right

21:30 hiredman: lazy-seq is lazy

21:30 cp2: Chouser got it right

21:30 i was mixed up

21:30 cmvkk: ha ha, someone didn't update the website properly

21:30 hiredman: you wrap cons in lazy-seq

21:31 cp2: right, listen to them jonathanturner

21:33 Chouser: see http://clojure.org/lazy

21:36 jonathanturner: Chouser: thx

21:42 cmvkk: ugh, i can't commute without passing an IFn either

21:43 Chouser: there's a reason rhickey created a new language

21:43 cmvkk: this stuff should be usable from java though,

21:43 i mean, having something like a Ref is useful in any language.

21:43 Chouser: it *is* usable, it's just not convenient

21:44 cmvkk: it 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:45 if that's such a boon, then why not the STM?

21:45 oh well. i can do it this way anyway.

21:45 Chouser: all you'd need is macros in Java, and STM could be convenient

21:46 cmvkk: in this case, it's not something that's a restriction of the language, though.

21:46 msingh: did anyone find it weird getting used to square parens coming from lisp?

21:46 cmvkk: see, refs have a set(), which takes a new value and that's all.

21:46 but commuting has particular characteristics that are favorable (it's 'more concurrent')

21:47 Chouser: cmvkk: the fn passed to commute gets run twice

21:47 cmvkk: that is true...

21:48 dnolen: msingh: 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:48 cmvkk: which 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:49 but 10% of the time, i need to change two refs in reference to each other

21:49 there 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:50 msingh: dnolen: humm.. may'be they'll grow on me :)

21:50 arohner: if commute were defined as (dosync (_commute ...)), wouldn't that work?

21:51 cmvkk: yeah. i guess the point was, in that situation, there's no need to run commute twice.

21:51 arohner: because if you wanted to do stuff in a "real" transaction, you would write (dosync (commute foo) (commute bar))

21:51 cmvkk: or rather, there's no need for the fn passed to be called twice.

21:52 Chouser: that's a very interesting observation

21:53 cmvkk: it would be like calling swap! on a ref.

21:53 Chouser: right

21:53 cmvkk: well, kind of. maybe more like 'send' but without the new thread.

21:54 anyway

21:54 Chouser: hm.

21:56 no, I think it'd be synchronous, like an atom

21:58 cmvkk: oh yeah, i guess i was thinking that if it was commutable you wouldn't have to retry ever, but really you still would.

22:00 Chouser: I see in the code that retries can happen when committing commutes, but I think that's different from what I understood previously.

22:00 cmvkk: well 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:02 replaca: Q: does anyone know how your supposed to add metadata to a namespace (like a doc string)

22:02 Chouser: but I thought they queued up and happened without retrying

22:03 replaca: we were talking about this earlier, but I don't see how to do it

22:03 *your => you're!

22:04 cmvkk: Chouser, commutes queue? that would block the tread the commute occurred in though, right?

22:04 which i thought nothing particularly ever blocked.

22:04 the reason agents queue is because the code isn't being executed in the calling thread anyway.

22:11 replaca: oops, never mind - that was obvious

22:13 Chouser: I thought the commute happened once for the "in-transaction" value, and then queued for the commit value.

22:13 cmvkk: if you mean it waits until the transaction is committed to run again, then yeah.

22:14 cconstantine_: has anyone here used enclojure?

22:14 cmvkk: but what if, for example, the transaction finishes, then when the commute is running, another transaction happens?

22:15 slashus2: Since 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:15 cmvkk: send-off helps for agents that block indefinitely in that they don't hog one of the threads in the pool.

22:16 other than that, it makes no difference.

22:17 also, there's not just 'an agent queue'. every agent has its own queue... at least i think.

22:17 if you send-off a function that runs forever, to an agent, it won't affect the way any other agent runs.

22:17 Chouser: if an action is going to be slowed down by anything other than the CPU, it should be done in a send-off

22:18 Cark: i think there's a single queue for all agents

22:18 ~def c.l.agent

22:18 Chouser: each agent has a queue of actions. also, the "send" pool has a queue of agent/actions

22:18 Cark: right

22:19 that's what they just changed in erlang

22:19 they were seeing contention because of this

22:19 replaca: Cark: did you get the pretty printer working OK?

22:19 cmvkk: well anything done with a send-off won't block the pool queue, right?

22:19 Cark: replaca : yes i did, thanks a lot

22:19 Chouser: cmvkk: not at the java level, right.

22:19 replaca: you were having problems with it yesterday, weren't you?

22:20 Cark: was only a matter of flushing *out* =/

22:20 Chouser: cmvkk: of course both pools are sharing the same hardware, so... :-)

22:20 replaca: cool, glad to hear it. I'll ge tthe upper stream to flush the underlying strem before closing

22:20 cmvkk: well right.

22:20 replaca: which should make that invisible to you

22:20 Cark: replaca : mhh i'm not sure it's the job of your library to do this

22:21 library which is highely usefull, thanks for it !

22:21 replaca: well, I'm creating a wrapper stream, if you didn't do it yourself, so I should probably flush on close

22:21 Cark: so you'll be flushing each time i use pprint ?

22:21 replaca: if people are doing larger things, they coul dopen a longer term stream

22:22 yeah, does that seem like a bad idea?

22:22 I've been torn on the subject, which is why I hadn't done it

22:22 Cark: it depends, can you forsee some inefficiencies coming out of this ?

22:22 replaca: (you're welcome, btw :-) )

22:23 Cark: i think only the user knows when it's best to flush

22:24 replaca: yeah, though there's a workaround: (binding [*out* (PrettyWriter. *out*)] ...) (more or less)

22:24 that's why I'm on the fence. The other ide of the story is that you have confusion.

22:25 well, maybe we'll see if more people are confused by it

22:25 Cark: well 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:26 maybe give a hint about it in the documentation

22:26 replaca: good idea

22:27 Q: anyone ever think about the problem of "find all the namespaces in a jar?"

22:28 Chouser: I've asked around about "find all the classes in a package"

22:29 but apparently the closest you can come to that is poking around if the filesystem or .jar files directly.

22:29 albino: jar -tf ?

22:29 mattrepl: unzip -l

22:30 hiredman: maybe clojure should have it's own equiv of the manifest?

22:30 or embrace and extend the manifest

22:30 Chouser: what's missing from java's manifest?

22:30 mattrepl: you can grab all class files from a jar, if that's what you're thinking

22:31 Chouser: or all the .cljs

22:31 mattrepl: or that

22:31 Chouser: and look for (ns ...) at the top

22:31 hiredman: Chouser: a list of the namespaces in the jar

22:31 clojurebot: Chouser might make night

22:32 hiredman: clojurebot: bah!

22:32 clojurebot: I don't understand.

22:32 Chouser: clojurebot: Chouser is <reply>Who??

22:32 clojurebot: Chouser might make night

22:32 Chouser: what does that even mean?

22:32 Cark: ~chouser?

22:32 clojurebot: chouser is ruthless about breaking other people's code

22:33 Cark: =)

22:33 hiredman: someone was thanking you for something, and it was late

22:33 Chouser: much better.

22:33 Cark: case sensitive

22:33 Chouser: ohhh.

22:36 but why won't it let me overwrite?

22:36 Cark: oh is there only one definition per word ?

22:36 ~foo

22:36 clojurebot: namespaces 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:36 hiredman: it thinks lines that end with ? are questions

22:37 clojurebot: literal [?] Chouser

22:37 clojurebot: 1

22:37 hiredman: clojurebot: literal [1] Chouser

22:37 clojurebot: <reply>Who??

22:37 Chouser: race

22:37 hiredman: looks overwitten to me

22:38 Chouser: ~Chouser?

22:38 clojurebot: Who??

22:38 Chouser: yep, you gave me the hint I needed, thanks.

22:56 replaca: sorry, I had to go put my boy to bed

22:56 slashus2: cmvkk: The reason I said that earlier is because I wrote a server thingy it had the following behavior.

22:57 replaca: I'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:58 hiredman: oh sure

22:58 there is a java api for jars

23:01 lisppaste8: slashus2 pasted "server thingy" at http://paste.lisp.org/display/78229

23:05 cmvkk: slashus2, maybe that's socket behavior?

23:05 slashus2: cmvkk: It works the way I expected when I use the executors.

23:06 cmvkk: i guess i don't see where you're using more than one agent, by the way.

23:06 slashus2: I am using one agent.

23:06 cmvkk: so, an agent can only do one thing at a time.

23:06 slashus2: Right.

23:06 cmvkk: so that would be why.

23:06 slashus2: send and send-off have the same behavior in this case?

23:06 cmvkk: what you should be doing is using a separate agent for each connection.

23:06 yes.

23:07 the thread pool can only do n things at once (where n is the number of threads), but

23:07 dreish_: send-off only promises not to deplete the common agent thread pool.

23:07 cmvkk: an agent will only take up one thread at any time.

23:07 whether that thread is part of the pool or not.

23:08 (.execute pool ...) is like creating a brand-new agent and using it only once.

23:08 slashus2: cmvkk: Yeah

23:08 cmvkk: i.e. (send (agent nil) client-handler-agt-fn client-socket)

23:11 hiredman: the is a threadpool (two of them) backing agents, and each agent has it's own queue of actions

23:12 cmvkk: i 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:13 hiredman: so send or send-off to a single agent multiple times will block until the previous action completes

23:13 slashus2: I was confused because it said that send-off should be used in situations with blocking actions.

23:13 hiredman: send's go to a bounded threadpool so they may also need to wait for other agents to complete

23:14 send-off's go to an unbounded threadpool

23:14 dreish: slashus2: 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:15 cmvkk: oh yeah, the docs for send-off are ambiguous in that way.

23:45 arohner: ,(str nil)

23:45 clojurebot: ""

Logging service provided by n01se.net