#clojure log - Jan 14 2009

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

1:16 lisppaste8: durka annotated #73563 with "trivial: i reinvented a small wheel (number?)" at http://paste.lisp.org/display/73563#2

1:24 durka annotated #73563 with "use peek in rpn-repl so that stack can truly be any type of seq" at http://paste.lisp.org/display/73563#3

1:25 durka: at this point i will cease and desist using lisppaste as a VCS

1:30 sleven: without reader-macros does Clojure really support syntactic abstraction? or "merely" evaluation-control?

2:21 burkelibbey: Hmm, looks like now I need to go learn Haskell so I can figure out clojure.contrib.monads... :/

2:24 oh cool, I didn't notice the examples directory before.

2:24 Raynes: Learn Haskell anyways. It rocks.

2:25 burkelibbey: It's definitely on my todo list. I want to get a better grip on clojure first.

2:25 I think haskell is next though

2:25 * Raynes notes he is learning Haskell right now. Reading Real World Haskell.

2:26 burkelibbey: How is it? I leafed through it once, but didn't take a very good look

2:26 Raynes: It's avery good book.

2:26 a very*

2:27 burkelibbey: Hmm, maybe I'll order a copy then.

2:28 Raynes: You can read it online for free. I don't require a dead tree version.

2:29 burkelibbey: Oh right, I remember hearing that. Thanks

2:29 Raynes: book.realworldhaskell.org/read

2:30 burkelibbey: Heh, if only I could just do this stuff instead of my boring Java OO courses :P

3:54 AWizzArd: Moin

4:06 Kerris7: yay Clojure book update

4:07 Morning AWizzArd :)

8:11 duck1123: It would be fun to have a program that could "compile" clojure forms into java source files. The generated code would be ugly as hell, but it would be cool to play with "because you can"

8:12 That way, burkelibbey could do his assignments in clojure, convert to java, and the teacher would be none the wiser. :)

8:12 Chousuke: he'd get bad marks for ugly code though.

8:13 duck1123: If you could keep the generated code clean and logical enough, you could convert, say clojure-contrib, then run javadoc on it

8:21 leafw: duck1123: does not sound so difficult ... nice weekend project

8:22 to render the code reasable, one would have to handle gensym-generated forms a bit better, checking for local overlaps within the java file, if any.

8:23 duck1123: I have a feeling it would prove to be more difficult than it sounds, but you would probably find something in the core code that makes it that much easier

8:23 rhickey: duck1123: the early Clojure compiler was a CL app that generated Java and C# source.

8:24 duck1123: that's cool

8:24 rhickey: readability was a non-objective :)

8:24 leafw: rhickey: one would say that macroexpand-1 inherits from those days, ehem ehem

8:25 Fib: If I have an s-expression containing arbitrary symbols and a map of symbols to values, can I evaluate that expression in a contaxt that will resolve those symbols to values in the map? Do I need to write my own eval?

8:25 duck1123: I bet it would be an interesting way to debug a tricky bit of code. Compile it to java, look through it, see what the compiler is doing and see what you need to change.

8:25 Fib: e.g. I have '(+ x 1) and {'x 1} and want to get the result 2.

8:26 duck1123: rhickey: btw, have you received my CA yet?

8:26 Daniel E. Renfer

8:28 Chousuke: ,(let [mymap {'x 2 'y 3}] (map #(get mymap % %) '(+ 1 x y)))

8:28 clojurebot: (+ 1 2 3)

8:28 Chousuke: Fib: like that

8:29 rhickey: duck1123: no, but I only check the box once a week or so

8:29 Chousuke: Fib: of course, the result will be a list. if you want to compute it, you'll need eval

8:30 duck1123: ok, my stamps were kinda old, but they said first class. Wasn't sure if they were still good, so I put 2 on.

8:31 rhickey: Linj attempted to produce readable Java from a Lisp-like language

8:31 duck1123: sent when?

8:32 duck1123: thursday? I dropped it in the outgoing mailbox at work, so I'm conserned about that as well

8:32 Fib: Chousuke: hm, okay. That doesn't handle nested s-expressions though, and if it's modified to do so it will still miss let-bound symbols...

8:32 duck1123: I'm sure it's there

8:32 Fib: So I guess I'd have to walk the expression keeping track of rebindings on the way down

8:33 AWizzArd: When I start a fresh repl in slime and type (def fc (new javax.swing.JFileChooser)) then my Clojure hangs. As if the thread would be busy with something. Does that work for you?

9:14 StartsWithK: Fib: http://is.gd/fQGf

9:15 Fib: but notice the comment: gross - please don't write code like this!!!

9:18 Fib: Haha, thanks :)

9:40 StartsWithK: AWizzArd: JFilleChooser works fine for me in standard repl, maybe a slime issue

9:41 AWizzArd: oki, I will try it from the shell

9:43 yes, in the shell it works fine

9:43 must be a slime issue... very strange though

9:44 Anyone here who knows Swing as if he wrote it himself? ;-)

9:46 asbjxrn: I've written some code I know as well as I know swing...

9:47 Chouser: hehe

9:51 AWizzArd: Do you see a way to get out of an instance of a JFileChooser the combo box which shows directories (indented and with symbols)?

9:55 asbjxrn: Sorry, I hardly know Swing at all.

9:55 mattrepl: AWizzArd: there are problems with Swing on Windows and Emacs/Slime. don't recall if there was a workaround, may want to search the list

9:58 leafw: AWizzArd: JFileChooser is likely a Container:just inspect throgh its hierarchy of Containers and Components

10:01 AWizzArd: leafw: yes, I am doing this right now in the repl. Is there an easier way to do this? Maybe in NetBeans somehow?

10:01 asbjxrn: how do you inspect?

10:01 AWizzArd: I call (.getComponents fc) where fc is a JFileChooser

10:02 Chouser: I bet you could add a little defmethod to inspector for that, and have a nice graphical explorer of the container tree

10:04 asbjxrn: I got to learn about the inspector.

10:04 AWizzArd: I don't understand why Sun does not give users full control to anything in those ready dialogs, with easy access through some methods

10:04 asbjxrn: That is one of the things I miss from CL.

10:04 AWizzArd: asbjxrn: there is no "the inspector"

10:04 Chouser: clojure.inspector

10:05 AWizzArd: ah ok

10:05 asbjxrn: yes, in CL I would (inspect fc)

10:05 asbjxrn: AWizzArd: That was my reaction about 2 minutes ago :)

10:07 Also, being able to expand the backtrace when a condition happen to see local variables etc. is nice. Clojure exceptions makes me feel lost compared to that.

10:07 Chouser: hah, sweet, it works. Dunno if it's useful, though.

10:09 lisppaste8: Chouser pasted "inspect swing tree" at http://paste.lisp.org/display/73577

10:10 Chouser: oh, I left out the (use 'clojure.inspector)

10:11 AWizzArd: yes, nice

10:12 sleven: its not until I really learned Clojure that I saw what a big inelegant mess my Jav,C++ and Python programs were.

10:12 Chouser: sleven: I'm right there with you.

10:14 Chousuke: Well, as the saying goes, even if you never use it for real, learning lisp makes you a better programmer for the rest of your days.

10:15 I guess that applies to functional programming in general too

10:23 lisppaste8: asbjxrn pasted "Performance challenge, how much can you improve this" at http://paste.lisp.org/display/73578

10:24 asbjxrn: (Thought I'd submit this to the performance thread in the clojure group, do anyone see any improvements first.)

10:25 This is one step in this fluid dynamics solver: http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf

10:26 It gets called 3 times for each frame, and is presented as if it is to be used for games, so I suspect they need a reasonable framerate.

10:28 Chousuke: asbjxrn: I get an exception trying to run that.

10:28 I wonder if it's slime's fault :/

10:28 asbjxrn: Oops.

10:31 (def foo (make-grid)) should be (def foo (ref (make-grid)))

10:32 Chousuke: I wonder why the classcast exception just says "[F" though

10:32 not very helpful

10:33 asbjxrn: I think it's the start of the name of the array, see the return value from the function.

10:34 It tried to cast it to a ref

10:36 karmazilla: I think [F is the classname for a primitive array of floats. Could be wrong about the floats part though

10:36 asbjxrn: I think you're right.

10:37 Chousuke: why is it a ref though?

10:40 asbjxrn: A little bit cleaner I thought. After the diffusion is done, the result needs to be copied into the grid array again. It was either using a ref of looping through an copy.

10:43 The ref is only dereferenced once, so the overhead is minimal. I was a bit worried about creating a new array for each time the function is called as well. But that seems quick as well.

10:45 The original algorithm avoids that, of course. It allocates two arrays and swaps the pointers to them. I think of refs as pointers, so..

10:47 Chousuke: as far as I can see, you don't do anything useful with that ref :/

10:52 gnuvince: Guys, I'm getting some weird results when reading from urandom from Clojure

10:52 > (let [buf (reader "/dev/urandom")] (for [_ (range 20)] (.read buf)))

10:52 (65533 65533 120 16 84 71 60 36 65533 65533 29 72 65533 14 65533 17 64 65533 65533 65533)

10:52 If I try the same code with Haskell or Python, I don't get any 65533

10:54 asbjxrn: Chousuke: This is just part of the algorithm. But a time critical part so any improvements here makes a big difference.

10:55 Chousuke: gnuvince: try with java?

10:55 gnuvince: Chousuke: I probably should

10:56 Chousuke: it was just easier with languages where it was a single line and in a REPL

10:56 Chousuke: also, definline seems broken :/

10:59 I wanted to make a gget helper to get rid of the (aget diffused-grid ...) repetition but making a local fn raises the execution time by an order of magnitute

10:59 magnitude*

11:00 even though the jvm really should be autoinlining it, it seems like it's not even trying. :p

11:02 asbjxrn: Hmm. Maybe I should check if it's the calculations or the array lookups that take time.

11:03 karmazilla: calls on interface types are harder to optimize, methinks

11:05 Chousuke: I wish there were a way to define local inline fns :/

11:05 sort of minimacros

11:06 asbjxrn: Shouldn't a array lookup be pretty fast anyway? Almost like a ref/pointer?

11:07 Chousuke: the lookup is probably as fast as it can be

11:07 Chouser: Chousuke: I think that's called 'macrolet' and is on Rich's wishlist.

11:08 definline is used in core.clj. How broken could it be?

11:09 gnuvince: Chousuke: found my problem. I switched to a FileInputStream and it fixed the problem.

11:10 asbjxrn: Hmm, 50% of the time is in the aset, it seems. But then, maybe the JIT optimizes more if the value isn't used for anything.

11:10 Chousuke: Chouser: maybe I don't understand how it's used

11:10 user=> (definline foo [] (+ 1 1))

11:10 java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:1)

11:10 gnuvince: > (let [stream (java.io.FileInputStream. "/dev/urandom")] (for [_ (range 20)] (.read stream)))

11:10 (168 64 2 210 238 108 10 128 156 41 65 167 79 218 213 10 205 175 169 239)

11:10 Chouser: gnuvince: It was being read as UTF-8.

11:10 asbjxrn: (sorry, 30%, not 50%)

11:11 gnuvince: Chouser: yeah, someone explained to me that Streams read bytes and Readers read characters.

11:12 StartsWithK: will something brake if i move from rev1132 to rev1194 or rev1207? I looked but didn't find anything that looks like it will break code that worked with rev1132

11:12 is rev1207 'safe', i see there is new stream stuff in there, will that break any old behaviour?

11:13 Chouser: StartsWithK: you can always got back if the new version breaks something.

11:13 if there's any stream stuff in trunk, it's non-breaking changes.

11:14 StartsWithK: i know, just asking, i would like to get watcher for refs and condp, they look realy good

11:15 karmazilla: asbjxrn: the JIT can make your code do nothing a trillion times in no time at all :)

11:19 Chouser: Chousuke: definline works more like a macro

11:20 hm, though I can't get that to work either.

11:21 StartsWithK: for what sould unquote be used?

11:21 is there any example?

11:22 Chousuke: it's there for the occasion that you want to assign your own semantics to ~foo

11:22 Chouser: StartsWithK: http://groups.google.com/group/clojure/msg/62437f3b96835b58

11:23 I think ClojureQL is actually using it for real now.

11:24 using the definline examples directly from core.clj at my repl still break. How can that be?

11:25 maybe they have to be compiled now?

11:27 StartsWithK: Chouser: thanks, will look in ClojureQL for more examples

11:29 ccmtaylor: hi all, quick newbie question: i'm writing a macro and want to conditionally include some stuff in a form, if it's non-nil...

11:30 StartsWithK: and are there maybe any examples of using watcher for refs to create similar effect to the one in http://is.gd/fRKs

11:31 ccmtaylor: `(stuff ~@(when conditional-stuff [conditional-stuff]) more-stuff)

11:31 works, but seems un-pretty. does anyone have a better solution?

11:32 Chouser: ccmtaylor: Off the top of my head, I think that's about as pretty as you're going to get.

11:32 StartsWithK: ccmtaylor: is 'stuff' ok to accept nil for its first argument?

11:32 Chouser: StartsWithK: the only watcher example I know of is one I wrote for watching agents.

11:33 But I know a much smaller percentage of what's going on in the Clojure world than I used to. ...getting hard to keep up.

11:34 ccmtaylor: StartsWithK: no, it needs to be completely not-there

11:35 Chouser: ccmtaylor: I think the only other route is to cons up the form, which is not likely to be prettier than what you've got.

11:35 ccmtaylor: ok, thanks!

11:36 StartsWithK: yes, you'll have to have two routes to that `(stuff ...) expansion then

11:36 Chouser: hm, you could filter the list after you've made it.

11:37 Lau_of_DK: Chouser: Its a shame you dont have enough time to keep up anymore, do you want to tips on some Clojure/SQL implementations?

11:37 Chouser: ccmtaylor: (defn f [x] (remove nil? `(stuff ~(when (odd? x) x) 2 3)))

11:37 seems a bit dangerous though. I think ~@( ... [foo]) is fine

11:38 Lau_of_DK: give tips? get tips?

11:38 Lau_of_DK: s/to/some :)

11:38 Oh, you want more money?

11:38 fine...

11:39 ccmtaylor: Chouser: nice idea, but it won;t work in my case since there might be more nils in the form. Guess, i'll leave it like it is.

11:39 won't

11:41 Chouser: you could use some other sentinel besides nil

11:41 I'm not really arguing for this, just trying to drum up options.

11:42 (defn f [x] (remove #{:skipit} `(stuff ~(if (odd? x) x :skipit) 2 nil)))

11:59 _hrrld: Ratios are so awesome, and Java floats are so lame in comparison. It's really paining me calling Math/sin and Math/toRadians on my beautiful ratios. Is there any way to preserve ratios while calculating sine/cosine?

12:01 (Math/sin 52163/16604) ;le cry.

12:06 Chouser: _hrrld: I suppose you'd have to write your own, or try to convert back to a ratio after calling Math/sin

12:24 drewr: Does dispatching to defmethods occur in any particular order?

12:25 Since methodTable is a PersistentHashMap in MultiFn, I'm guessing not.

12:44 Lau_of_DK: Is there a clojure-func to upper-case a string?

12:45 danlarkin: yes

12:45 (.toUpperCase "foo")

12:45 :)

12:45 or, if you prefer, #(.toUpperCase %)

12:47 Lau_of_DK: Gotcha

12:47 Thanks

12:54 lisppaste8: durka pasted "is there a way to do this without the ~' ugliness?" at http://paste.lisp.org/display/73582

12:57 Chouser: durka: are you willing to let the caller pass in the name to be used, instead of always capturing 'get-value'?

12:58 durka: i'd rather not...

12:58 this is related to the RPN thing i was playing with yesterday

12:59 where quasiquote wants to resolve things at macroexpansion time but i'd like it to wait

12:59 (is it called quasiquote?)

12:59 Chouser: if you want to capture a name, ~' is the way to do it.

12:59 durka: ok

13:00 Chousuke: it serves as a hint that capturing names is ugly :)

13:08 durka: fair enough

13:49 Lau_of_DK: Anyone here, whos strong on the SQL statement Alter ?

13:51 gnuvince: Is it possible to get the address of an object in clojure? Something like id() in Python

13:52 Lau_of_DK: For what purpose would you need that gnuvince ?

13:52 gnuvince: Lau_of_DK: I would like to show to someone that structures share data and are not copied

13:52 But he's got a Thomas syndrome

13:53 Lau_of_DK: hmmm

13:54 http://www.velocityreviews.com/forums/t145498-how-to-get-address-of-a-java-object.html

13:54 gnuvince: Theres a discussion which ends with the conclusion that its not possible

13:55 gnuvince: hmmm

13:55 I could probably use identical? then

13:56 Lau_of_DK: Couldnt you make a specific example and then refer to the clojure source code?

13:56 gnuvince: I think I can manage with identical?

13:56 Chouser: gnuvince: you may be able to use .hashCode

13:58 ,(let [a '(3 2 1) b (cons 4 a)] (map #(.hashCode %) [a b (rest b)]))

13:58 clojurebot: (1800990793 -467838107 1800990793)

13:59 gnuvince: ,(.hashCode "hi")

13:59 clojurebot: 3329

13:59 gnuvince: ,(.hashCode "hi")

13:59 clojurebot: 3329

13:59 Lau_of_DK: Chouser, doesnt your example show that the structure is shared?

14:00 Chouser: Lau_of_DK: that was the idea, wasn't it?

14:00 Lau_of_DK: I was under the impression that no structure was ever shared, because if you modified one, an entire new collection would be formed

14:01 Chouser: Lau_of_DK: no, a major advantage of immutable collections is that you *can* share structure safely, since none of it can be changed.

14:01 karmazilla: there's System/identityHashCode - closest thing to python's id() I think

14:02 Lau_of_DK: Chouser: yes of course, youre right

14:02 I didnt have my thinking cap on :(

14:02 Chouser: karmazilla: that appears to be the same as .hashCode

14:03 karmazilla: no, you're right. identityHashCode is what you want.

14:03 karmazilla: that depends on the object.. but Object.hashcode calls identityHashCode

14:04 gnuvince: ,(let [x1 (list "one" "two" "three") x2 (conj x1 "zero")] (every? #(apply identical %) (map vector x1 (rest x2)))

14:04 clojurebot: Eval-in-box threw an exception:EOF while reading

14:04 Chouser: ,(let [a {} b (dissoc {:c 1} :c)] (map #(vector (.hashCode %) (System/identityHashCode %)) [a b]))

14:04 clojurebot: ([0 16638032] [0 26336541])

14:04 gnuvince: ,(let [x1 (list "one" "two" "three") x2 (conj x1 "zero")] (every? #(apply identical? %) (map vector x1 (rest x2)))

14:04 clojurebot: Eval-in-box threw an exception:EOF while reading

14:05 gnuvince: wth?

14:05 Chouser: one more )

14:05 gnuvince: damn

14:05 ,(let [x1 (list "one" "two" "three") x2 (conj x1 "zero")] (every? #(apply identical? %) (map vector x1 (rest x2))))

14:05 clojurebot: true

14:05 gnuvince: there

14:06 Writing Lisp code without paren-match is pretty hard

14:07 Lau_of_DK: gnuvince: you mean, you dont chat in emacs?

14:07 gnuvince: Lau_of_DK: irssi

14:07 I used to before with rcirc

14:07 Lau_of_DK: oh.. switch to emacs, then you can enable paredit on irc if you like :)

14:07 :(

14:07 gnuvince: Yeah

14:07 Lau_of_DK: rcirc was really lacking if you ask me. ERC is cool though

14:07 gnuvince: There are some real advantages to using Emacs for IRC

14:07 paren matching, auto completion of words other than nicks, searching backwards

14:08 I think I lost my ERC config a few years ago

14:08 Lau_of_DK: Yea, and especially, you can send all of Chousers tips straight to the REPL

14:08 gnuvince: That too

14:11 Chousuke: I'm not that much of a lisper that I would give up irssi

14:13 erohtar: .

14:13 replaca: I've become kind of addicted to irssi + screen. I can lurk from wherever I sit down (I've even had conversations on the subway)

14:13 erohtar: danlarkin: thanks for your time yesterday on helping me with clojure-json

14:13 danlarkin: it was a problem of the incoming json string being escaped twice -

14:14 danlarkin: erohtar: no problem. good to hear you solved it

14:34 Chouser: not yet halfway through January, and the group already has twice as many posts as all of September.

14:35 danlarkin: I can't keep up anymore :-/

14:36 Chouser: there have been a couple attempts at summarizing the "important" threads, but I think the volume has overwhelmed those who were attempting it.

14:37 rhickey: Chouser: it does test the limits of all apps I try to manage it with

14:39 Chouser: gmail is hanging on for me, but I had to change tack a bit today -- we'll see if this holds up.

14:41 * danlarkin uses Mail.app

14:41 Lau_of_DK: Chouser: Tried thunderbird + digests ?

14:41 Chouser: nope

14:41 Lau_of_DK: I suspects its easier to keep up with, but I still cant keep up

14:42 Chouser: I really don't think digests would work for me, unless I wanted to stop posting and just read.

14:42 Which come to think of it might be better for everyone.

14:44 rhickey: Mail.app is so much better than GMail at letting you walk through what's new - gmail's threaded-only viewing is fail

14:44 for me

14:46 danlarkin: I appreciate that I can navigate with the keyboard only. Expand a thread with the right arrow, View next message with up arrow, close the thread with left, etc

14:47 Chouser: I use vi keybindings in gmail. :-)

14:47 danlarkin: *mind boggled*

14:47 hiredman: hit the escape key alot while trying to write emails in gmail

14:48 I

14:48 Chousuke: does it delete all text? :)

14:48 Chouser: I edit emails in vim. Esc is ok.

14:48 hiredman: nope

14:48 Lau_of_DK: Also, you can get the mails directly in Emacs if you like

14:48 hiredman: it does nothing

14:49 actually, I hit "<esc>:w<enter>"

14:49 Chousuke: I have vim keybindings for my browser... really nice. Though some sites suck for keyboard browsing

14:50 hiredman: clojurebot: mock?

14:50 clojurebot: Your mock object is a joke; that object is mocking you. For needing it. -- rhicky

14:50 Lau_of_DK: name mispelled :)

14:52 http://tech.slashdot.org/article.pl?sid=09/01/14/1312210

14:52 Qt goes LGPL

15:13 hiredman: being able to roll everything into a jar file and ship it out is so nice

15:34 Lau_of_DK: Kota and I had planned to have an RC at January 15, and it looks like we're very close. If some of you who are knowledable in SQL could have a look through http://github.com/Lau-of-DK/clojureql/tree/master I'd be very grateful for your feedback. Especially if you find features missing that we havent yet implemented, but you badly want.

15:36 * danlarkin wishes there were more hours in the day :)

15:37 rhickey: asbjxrn: http://groups.google.com/group/clojure/msg/967ebe3133aa25ec

15:58 red_fish: someone can explain to me

15:58 (defn add-points [& pts]

15:58 (vec (apply map + pts)))

15:58 (add-points [10 10] [-1 0])

15:59 I don't understand (apply map + pts)

15:59 danlarkin: do you understand map and apply?

15:59 red_fish: yep

15:59 Lau_of_DK: danlarkin: I dont think he does, no

15:59 red_fish: what is the order of evaluation?

15:59 danlarkin: red_fish: well then it's just applying map + to pts

16:00 kotarak: (apply map + pts) <=> (apply map + (list [10 10] [-1 0])) <=> (map + [10 10] [-1 0]) <=> (list (+ 10 -1) (+ 10 0))

16:03 red_fish: kotarak: (apply #(map + %1 %2) (list [10 10] [-1 0]))

16:03 kotarak: is it the same?

16:03 how can apply know infer that "map +" is the function?

16:03 hiredman: ,(apply #(map + %1 %2) (list [10 10] [-1 0]))

16:03 clojurebot: (9 10)

16:04 hiredman: map + is not the function

16:04 map is the function

16:04 + is just another argument

16:04 (that happens to be a function)

16:04 kotarak: and takes + as argument

16:04 right

16:05 (apply func arg1 ... argn arglist) (where arglist is something seqable)

16:05 hiredman: ring is a nice, but I think I like compojure's vector -> html stuff better than clj-html's

16:05 danlarkin: red_fish: sorry if what I said confused you. I guess I should have said it's applying map to pts, where map is also taking + as an arg

16:05 red_fish: kotarak: is this equivalent (apply map (list + [10 10] [-1 0]))?

16:06 kotarak: I think so.

16:06 hiredman: ,(apply map (list + [10 10] [-1 0]))

16:06 clojurebot: (9 10)

16:06 red_fish: ,(apply map (list + [10 10] [-1 0]))

16:06 clojurebot: (9 10)

16:06 red_fish: cool

16:06 kotarak: ,(apply map + [10 10] [[-1 0]])

16:06 clojurebot: (9 10)

16:07 red_fish: thank you very much

16:07 kotarak: np

16:07 red_fish: I think i wanna see the source of "apply"

16:07 Chousuke: hiredman: clj-html is faster though.

16:07 kotarak: src/clj/clojure/core.clj

16:07 hiredman: Chousuke: I see

16:07 red_fish: kotarak: thx

16:09 Chouser: red_fish: http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/core.clj#367

16:10 danlarkin: and let me assure you, apply _is_ lazy :-D

16:10 hiredman: danlarkin: what?

16:11 madness

16:11 danlarkin: :o

16:18 karmazilla: madness? this is Clojure!

16:21 Chouser: I love lazy apply. Another one of those features where my first reaction was simply to assume it was impossible.

16:21 ,(apply (fn [a b & r] [a b (take 3 r)]) (iterate inc 0))

16:21 clojurebot: [0 1 (2 3 4)]

16:25 gnuvince: neat<

16:27 danlarkin: Lau_of_DK: I know something I'd really like to see in clojureql: postgres support

16:29 kotarak: danlarkin: Ideally you just load the postgres JDBC driver and it "should work". For some definition of should and work. I have no experience with the different databases, but MySQL and SQLite work at the moment.

16:29 Chousuke: hmm

16:30 ,(apply (fn [a b] (list a b)) (iterate inc 0))

16:30 clojurebot: java.lang.OutOfMemoryError: Java heap space

16:30 Chousuke: I guess the infinite seq goes to a in that case?

16:31 red_fish: (apply (fn [a b & r] [a b (apply identity (take 3 r))]) (iterate inc 0))

16:32 ,(apply (fn [a b & r] [a b (apply identity (take 3 r))]) (iterate inc 0))

16:32 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$identity

16:32 red_fish: ,(apply (fn [a b & r] [a b (apply map identity (take 3 r))]) (iterate inc 0))

16:32 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer

16:33 Chouser: Chousuke: odd -- you should have gotten a "Wrong number of args"

16:34 red_fish: ,(apply (fn [a b & r] [a b (take 3 r)]) (iterate inc 0))

16:34 clojurebot: [0 1 (2 3 4)]

16:35 Chouser: ,(apply (fn [a b & r] [a b (map identity (take 3 r))]) (iterate inc 0)) ; red_fish: looking for this?

16:35 clojurebot: [0 1 (2 3 4)]

16:35 red_fish: Chouser: yes

16:36 Chouser: of course since 'map' is also lazy, you can move the 'map' to inside the 'take

16:36 red_fish: ,(apply (fn [a b & r] [a b (appy map identity (take 3 r))]) (iterate inc 0))

16:36 clojurebot: java.lang.Exception: Unable to resolve symbol: appy in this context

16:37 red_fish: ,(apply (fn [a b & r] [a b (apply map identity (take 3 r))]) (iterate inc 0))

16:37 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer

16:46 burkelibbey: Does clojure have a function like cons, but with a reversed signature? Is (defn revcons [coll x] (cons x coll)) the best way to do it?

16:46 kotarak: (doc conj)

16:46 clojurebot: conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type.; arglists ([coll x] [coll x & xs])

16:46 rhickey: burkelibbey: conj works that way, for all collections

16:47 burkelibbey: Ah, I thought conj added to the end of a collection, but apparently I was using a vector without really realizing :P. Thanks.

16:48 red_fish: (doc conj)

16:48 clojurebot: conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type.; arglists ([coll x] [coll x & xs])

16:53 red_fish: can I use ctags with clojure?

16:54 kotarak: red_fish: I write a simple cljtags.

16:54 red_fish: cool

16:54 kotarak: red_fish: http://bitbucket.org/kotarak/cljtags/ there is only a repo at the moment, but it has download link

17:15 gnuvince_: Hmmm

17:15 Somebody ought to reply to Slava on reddit to point out that Clojure is not like the Lisp he mentions

17:15 * danlarkin points at gnuvince_

17:16 * Chouser seconds the motion

17:16 rhickey: link?

17:16 gnuvince_: Me again?

17:17 http://www.reddit.com/r/programming/comments/7pohw/why_haskell_is_beyond_ready_for_prime_time/c071i7o

17:18 rhickey: Not sure there's a point to arguing with Slava about this, he doesn't think it benefits Clojure much to have access to Java libs

17:20 gnuvince_: Really?

17:27 Nafai: I think Slava has sufficiently demonstrated that he has no interest in the Java language or platform

17:28 Chouser: I do think there's remarkably little scolding here

17:29 albino: they're talking about that thread in #concatenative right now, you could join them and make it real time

17:30 rhickey: Chouser: yes, I'm extremely pleased with this irc and the google group for general pleasantness, helpfulness and respectfulness

17:30 Lau_of_DK: Funny argument Slava puts forth, he's not entirely wrong

17:32 karmazilla: something is wrong with swing :(

17:35 Chouser: karmazilla: seems likely :-)

17:35 Nafai: :)

17:35 * Nafai can vouch for that

17:37 karmazilla: a JList and a TextField... KeyEvents to the text field will modify the ListModel for the jlist, but the damn thing only figures out that it needs to redraw after I make a second event happen, so the contents of the displayed list is always one keystroke behind... who the hell thought that up?

17:46 ohh... a little animal of mythical origin shared with me the arcane secrets of SwingUtilities.invokeLater. I'm a now bewildered by its magic

17:46 Chouser: karmazilla: there's a macro for that in textjure.clj

17:48 karmazilla: yeah, that might have been the animal, but I am still prototyping with netbeans and its gui builder from the land of control

17:49 it's the document-switcher-slash-file-opener for textjure that I'm trying to build :)

18:03 meredydd: Hey all. Is there a convention for calling out of a sub-namespace?

18:03 Say I have two components X and Y that each need to send events to the other

18:04 If I define them as 'com.xxx.X and 'com.xxx.Y, then (:require) them both from 'com.xxx, I have a forward-definitions problem.

18:04 Is there a conventional way of handling this situation?

18:06 hiredman: meredydd: have them require each other?

18:06 meredydd: hiredman: That didn't work last time I tried it

18:06 Can't remember the failure mode now - might just be an infinite loop of interpreter-ness

18:10 hiredman: Yeah, there we go. "No such var: com.xxx.x/var"

18:11 durka: isn't this was declare is for?

18:11 hiredman: meredydd: a.a requires a.a.a requires a.a.b requires a.a.a

18:11 meredydd: declare? Fee fi fo fum, I smell a new keyword.

18:11 durka: (doc declare)

18:11 clojurebot: defs the supplied var names with no bindings, useful for making forward declarations.; arglists ([& names])

18:12 Chousuke: can you declare vars in other namespaces? :/

18:12 hiredman: durka: declare would not work across namespaces I don't think

18:12 durka: yes

18:12 meredydd: Chousuke: Nope.

18:12 hiredman: ,(declare 'foo/fum)

18:12 clojurebot: DENIED

18:12 Chousuke: so your problem is that a.a.b and a.a.a call each other directly.

18:12 hiredman: clojurebot: thanks man

18:12 clojurebot: No entiendo

18:12 Chousuke: add indirection!

18:12 durka: (binding [*ns* *ns*] (in-ns 'other) (def a b))

18:13 meredydd: durka: Yep, but then you've got to break up your (ns) and do all your definitions before your use/require/etc statements

18:13 durka: seems like there should be a better way to do this

18:13 meredydd: durka: ...or you've got to do something unpleasant like that.

18:13 (which is what I've been doing so far. But it's frankly ugly.)

18:13 durka: how does java handle it?

18:14 hiredman: meredydd: what I said should work

18:14 I just tried it

18:14 meredydd: hiredman: Try referring to a var in a.a.a from a.a.b

18:14 and vice versa

18:14 that'll break it.

18:15 durka: javac copes with mutual references between classes supplied in the same invocation.

18:15 durka: It's a regular problem when spanning different languages (eg one class in Groovy, one in Java - there's no simple way of having each of them refer to the other)

18:16 durka: i see

18:17 hiredman: meredydd: what I said works fine here

18:17 meredydd: Where's the local pastebin?

18:17 hiredman: lisppaste8: url?

18:17 meredydd: clojurebot: paste

18:17 clojurebot: No entiendo

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

18:18 meredydd: Oh, well - worth a shot :)

18:18 hiredman: clojurebot: paste is http://paste.lisp.org/new/clojure

18:18 clojurebot: Ik begrijp

18:18 walters: meredydd: groovy actually has a joint compiler, so it can do that

18:18 meredydd: walters: That was a later development, explicitly developed to solve that problem.

18:19 walters: meredydd: http://groovy.codehaus.org/The+groovyc+Ant+Task

18:19 meredydd: (I first tried Groovy before that was introduced, when it was still a publicised "gotcha", and haven't gone back to it since; my apologies for being out of date)

18:19 walters: yeah, it's relatively recent

18:20 meredydd: (My point was that it requires explicit compiler smarts.)

18:20 walters: yeah...ideally there would be a way for a language to plug into javac, so it sees ".clj" -> hand off to clojure.Compiler etc

18:20 lisppaste8: meredydd pasted "reference problems" at http://paste.lisp.org/display/73606

18:21 erohtar: hey - does anyone know if dynamic variables set via binding are visible through agents?

18:21 meredydd: hiredman: That breaks, with the error message I pasted.

18:21 walters: there's some sort of compiler API now, but I don't know whether it helps with this at all

18:22 meredydd: erohtar: Give an example? Generally not - dynamic bindings are thread-local, and agents run in a separate thread.

18:22 hiredman: meredydd: you are correct, I did not have enough references between namespaces to check everything

18:22 erohtar: meredydd: ah, i see - makes sense

18:22 meredydd: hiredman: That's why I said "[23:17:19] <meredydd> hiredman: Try referring to a var in a.a.a from a.a.b, and vice versa"

18:23 erohtar: meredydd: so if I need to do something from an agent that involves changing a dynamic variable, i should do it from the function i use in the send?

18:24 meredydd: erohtar: No; the function you send will run in the agent's thread(pool), and won't see the dynamic binding either.

18:24 erohtar: meredydd: right - ok... so can i change the dynamic binding within *that* function, then?

18:24 meredydd: erohtar: Generally speaking, if it's a value you want to change, you should be using Refs. Think of (binding)s as "temporarily set this variable to this value"

18:25 Refs are "this is a value that can change over time"

18:25 erohtar: meredydd: well, in my case, im using a dynamic variable to hold database config information, which I want to set at call time

18:25 * meredydd pokes rhickey

18:26 rhickey: meredydd: hm?

18:26 meredydd: rhickey: How do I cope with mutual references between two namespaces?

18:26 eg, I have com.xxx.x and com.xxx.y and they both want to talk to each other.

18:27 (say, each wants to call a funciton in the other)

18:27 rhickey: meredydd: don't do it

18:27 meredydd: And if the answer is "that's the wrong question, you're doing it wrong", what patterns should I be using instead?

18:27 Thought that would be the answer :)

18:27 So what should I be doing instead?

18:28 hiredman: meredydd: if they are subname spaces of another name space, maybe they a can just assume they are both there and leave out the require

18:28 meredydd: It's not easy to write, say, a message queue in the parent namespace that the the two can use to communicate

18:28 (because the (:require) and (:use) clauses of the parent's (ns) macro come before any of the parent's (def)s)

18:29 and by "not easy" I don't mean "insurmountably hard", I mean "it's breaking the expected usage of the (ns) macro, therefore probably isn't the right way to be going about things"

18:33 * meredydd invokes rhickey's name again

18:35 hiredman: I think it may be time to re-examine your purpose in creating such a namespace arrangement

18:39 meredydd: That's quite possible; nay, probable.

18:41 I have a suspicion that there is such a thing as a legitimate need for two components to talk to one another, rather than forcing one to be effectively a library called by the other

18:43 In this particular case, there are ways I can make one a library of the other, and pass in function pointers for the callouts, but I still feel slightly unpleasant.

18:43 That said, last time I was convinced I was right and Rich was wrong....well, you can guess the result :)

18:43 danlarkin: is it too complicated for an summary of what each does?

18:44 Chousuke: if they're interlocked libraries, is there a reason they aren't in the same namespace?

18:44 hiredman: ^-

18:47 meredydd: danlarkin: Okay...

18:47 Chousuke: Essentially, because they're too big to put the whole hairball in one file; I'd like to destructure it a little.

18:48 grosours: Hi everybody

18:48 meredydd: danlarkin: A chat system that falls back to email.

18:48 Chousuke: meredydd: well, you can put some code in another file and just (load) it, can't you=

18:49 meredydd: The webchat system is a hairy MVC beast that definitely wants to live in its own namespace.

18:49 Chousuke: hmm :/

18:49 meredydd: The mail system is also moderately hairy, and I don't want to go blending it with anything else.

18:49 danlarkin: Hmmmm

18:50 meredydd: Depending on whether there's a chat session open (ie internal state of chat system), mails need to be intercepted and diverted to chat

18:50 danlarkin: can you do something like have a 3rd file with a function like send-chat-or-email ?

18:50 meredydd: And when a chat session times out, unseen messages get dispatched via the email system.

18:51 danlarkin: How would that work? That function sounds like it would want to refer to functions in both the chat and email systems...and yet both the chat and email systems would want to refer to it.

18:51 danlarkin: nah

18:52 it'd call try-to-send-chat and if that fails it calls try-to-send-email

18:52 or whatever

18:52 oh

18:52 meredydd: Okay. Now, in what namespace is 'try-to-send-chat located?

18:53 (I take it that "oh" was you getting the problem)

18:53 danlarkin: haha

18:53 ...maybe :)

18:54 meredydd: Now, this kind of thing happens all the time at the within-namespace level, and we solve the problem with forward declarations (empty (def)s, or nowadays the (declare) macro)

18:54 Chousuke: maybe you need to abstract away the message handling somehow

18:55 meredydd: I'm just curious as to why rhickey is so certain that such a thing is illegitimate between two namespaces when it's legitimate between two functions

18:55 hiredman: *shrug*

18:55 Chousuke: mail system receives message, notifies some message center, message center sees chat system is interested, forwards to it

18:55 hmm

18:56 meredydd: aand once again, we have the mail system needing to refer to the message center, but the message center needing to refer to the mail system, and...

18:57 Chousuke: the message center doesn't need to directly know about the mail system. the mail system could just tell the message center that it produces messages of type "mail"

18:58 meredydd: yep, and then pass in a handler function for messages of type "mail", and chat does the same thing...

18:58 hiredman: you could leave out the require and have a fourth file that requires all three

18:58 meredydd: But now we're reinventing something that smells distinctly like Enterprise Java, just to try to dance around the fact that we have a circular reference. (Which we still do, because the string "mail" will be hard-coded into the chat system)

18:58 hiredman: How does that work?

19:00 hiredman: actually

19:01 you may want a look at the clojurebot code

19:01 meredydd: ?

19:01 hiredman: (the ns and callback stuff is Chousuke's)

19:02 meredydd: Oh, yes. If you want to do it with callbacks, that's all very well.

19:02 hiredman: yeah

19:02 it is very well

19:02 meredydd: You create both halves as libraries with empty callbacks for "send mail" and "intercept-message?"

19:03 (with specific signatures designed to match their one and only implementation...)

19:03 hiredman: meredydd: the control center has a place where message handlers can latch on to

19:03 Chouser: I find I have to use 'declare' only very rarely in well-organized files.

19:03 meredydd: then write a separate NS which just wires them together by plugging one's functions into the other's callbacks

19:04 Chouser: Oh, I agree. In fact, in this example, I want to use it all of once. (Maybe twice.)

19:05 hiredman: meredydd: you can have the ns plug themselves into the callbacks

19:05 meredydd: hiredman: How? By referencing which common component?

19:06 hiredman: meredydd: http://github.com/hiredman/clojurebot/blob/369ceedc238d8fe1539e0bca3b087d89827523ca/hiredman/clojurebot/svn.clj

19:06 line 85

19:06 when the ns is loaded

19:07 it calls that function, which hooks it in to the dispatching function in hiredman.clojurebot.core

19:07 meredydd: (And if this common component is anything like the "message center" referred to earlier, which dispatches to functions or handlers based on strings, we've just "solved" the syntactic issue by implementing exactly the same dependency, at great length, in a value domain less suited for the job (identifying functions with strings rather than function pointers))

19:08 Aha. You're dispatching on regexp there?

19:09 hiredman: meredydd: you big long message there does not make sense to me, so we must be talking across each other, so maybe I should stop talking if it is just noise

19:10 Chousuke: it's not a very clean solution though. it lacks priorities so the first dispatch that matches gets called :P

19:10 hiredman: :P

19:11 I am not suggesting he take it verbatim

19:11 I am suggesting a similar model could be used

19:11 meredydd: hiredman: I guess all I was trying to say was that building a full dispatch mechanism is overkill when all I ever want to do here is have component A call component B, and B call A.

19:12 hiredman: meredydd: you can do that, just leave out the requires and load the files

19:13 meredydd: Yeah, I guess. I'd just prefer not to have to sacrifice the internal namespace structures of A and B to do this.

19:14 Anyway, you're right here; I think this is a round-in-circles maneuver.

19:15 I guess I'll do it the hacky way, with forward declarations, and if one day someone clever comes along and shows me how I should have done this more simply then I'll change it.

19:53 erohtar: can anyone tell me how agents die? i see that the thead count is increasing (under Activity Monitor)...

19:54 durka: you mean how to forcibly kill them?

20:03 erohtar: durka: no, do they (the associated thread) die when the function sent to them is over?

20:04 durka: i don't think so, not necessarily

20:04 Chouser: an agent is not a thread. When the action is complete, the thread returns to the pool.

20:05 durka: even with send-off?

20:05 Chouser: The agent stays around as long as something is referencing it, after that it can be GC'd

20:05 erohtar: chouser: ok understood, then why does the thead-count increase?

20:05 chouser: also - is there a limit to the size of the thread-pool?

20:05 Chouser: durka: yes, even with send-off.

20:06 send's use a pool that's capped based on the number of CPUs. send-off's pool will grow as needed, but when the action is done the thread can hang around for a later send-off to another (or the same) agent.

20:07 erohtar: chouser: ok thanks

20:08 Chouser: I don't think the send-off pool should ever have more threads than the maximum number of actions being processed at one time.

20:11 ,(.getPoolSize clojure.lang.Agent/pooledExecutor)

20:11 clojurebot: 0

20:11 Chouser: ,(.getPoolSize clojure.lang.Agent/soloExecutor)

20:11 clojurebot: java.lang.Exception: No such namespace: clojure.lang.Agent

20:13 Chouser: ,(send (agent 1) inc)

20:13 clojurebot: #<Agent clojure.lang.Agent@1e881b6>

20:13 Chouser: ,(.getPoolSize clojure.lang.Agent/pooledExecutor)

20:13 clojurebot: 1

20:13 Chouser: so that's the 'send' thread pool

20:13 ,(send (agent 1) inc)

20:13 clojurebot: #<Agent clojure.lang.Agent@94310b>

20:13 Chouser: ,(.getPoolSize clojure.lang.Agent/pooledExecutor)

20:13 clojurebot: 2

20:14 Chouser: ,(dotimes [_ 100] (send (agent 1) #(do (Thread/sleep 1000)))

20:14 clojurebot: Eval-in-box threw an exception:EOF while reading

20:14 Chouser: ,(dotimes [_ 100] (send (agent 1) #(do (Thread/sleep 1000))))

20:14 clojurebot: nil

20:14 Chouser: ,(.getPoolSize clojure.lang.Agent/pooledExecutor)

20:14 clojurebot: 3

20:14 Chouser: capped out at 3

20:15 looks like the send-off pool is no longer public, so I can't see its thread count anymore

20:24 ok, I coulda *sworn* there was a verion of Clojure where I could get at both pools. But i can't find it now.

20:30 erohtar: wow - i didnt even know about clojurebot

20:30 amazing

20:31 chouser: why was the threadpool capped at 3?

20:42 Chouser: Apparently clojurebot's running on a single-CPU machine. the 'send' pool uses CPU count plus 2.

20:43 hiredman: yep

20:45 danlarkin: leaking implementation details!!!111oneonewon

20:47 * danlarkin misses RSchulz

20:48 RSchulz: Hey, danlarkin! I'm not gone, just otherwise occupied. I upgraded my primary development system to openSUSE 11.1, and there were... complications.

20:48 All is well, now, though.

20:48 345 unread messages in the Clojure list!

20:48 hiredman: heh

20:49 RSchulz: What have I missed??

20:49 danlarkin: :)

20:49 hiredman: the internet is over

20:49 clojure won

20:49 danlarkin: glad to see you're still alive

20:49 RSchulz: The tubes are terminally clogged?

20:49 (Couldn't think of a good word beginning with 't')

20:50 durka: no, it's not that

20:50 they caught tuberculosis

20:50 RSchulz: Ah. Good one!

20:50 durka: this is unrelated to last year's bout of tubercuilosis

20:51 RSchulz: Anyway, almost 100% of my old stuff is restored and much is better than it was. Now I can run, among other things, VimClojure.

20:51 And the various Git programs. It seems inevitable...

20:55 durka: let's use reflection to break Agent's encapsulation

20:55 ,(.. (agent nil) getClass (getDeclaredField "soloExecutor") (get (agent nil)) getPoolSize)

20:55 clojurebot: 2

20:55 durka: (send-off (agent 1) inc)

20:55 ,(send-off (agent 1) inc)

20:55 clojurebot: #<Agent clojure.lang.Agent@130671e>

20:55 durka: ,(.. (agent nil) getClass (getDeclaredField "soloExecutor") (get (agent nil)) getPoolSize)

20:55 clojurebot: 3

20:55 hiredman: I was poking around nautilus a few days ago, and last night when I turned on my laptop, all my *.clj files had the clojure icon

20:56 durka: really? what put it there?

20:56 RSchulz: hiredman: You use Windows?

20:56 hiredman: nope

20:57 durka: i don't think nautilus has been ported to windows yet

20:57 RSchulz: Which Nautilus are we talking about?

20:57 hiredman: I was messing with gnome's mimetype database trying to get the clojure icon has the icon for clojure files, but it did not seem to work

20:57 but I guess it did

20:57 RSchulz: I think that's more likely the explanation.

20:58 hiredman: I poked a lot of places, so I am note sure what did it

20:58 RSchulz: And... What's with using Gnome? ... Real Programmers (TM) use KDE!

20:58 hiredman: RSchulz: I will refrain from bring a flame war into to #clojure (but KDE is junk, and I hate it)

20:58 bringing

20:58 RSchulz: You're thinking of KDE 4.x

20:59 hiredman: KDE.

20:59 RSchulz: Control freaks prefer KDE 3.5.

20:59 hiredman: well, thats just like, your opinion man.

21:00 RSchulz: The only wrong opinion is "meh. don't care."

21:00 (I've known that type...)

21:02 Let's try another tack... Which distro do you use??

21:02 hiredman: I don't use linux

21:04 RSchulz: Eh? You use Gnome but not on a Linux or Windows?

21:05 OSX?

21:05 hiredman: fbsd

21:06 RSchulz: Ah. A real minority.

21:06 hiredman: not in ##freebsd

21:07 albino: heh

21:07 RSchulz: The long tail.

21:07 albino: we welcome all minorities, don't we?

21:08 RSchulz: One would hope.

21:10 albino: hiredman: what do you like about freebsd? If you don't mind me being curious

21:10 hiredman: it is very together

21:11 RSchulz: What's the latest FreeBSD version?

21:11 hiredman: uh, the latest release was 7 something

21:11 7.1

21:11 albino: I need to try it out sometime

21:11 my only expereince with it was when someone else installed it and I was floored that tab completion wasn't there by default

21:12 hiredman: someone recommended it to me, about ten years ago, I tried it, and have not switched back

21:12 well, I also use zsh not bash

21:12 RSchulz: You dare bash BASH?

21:13 albino: but zsh has tab completion by default, doesn't it?

21:13 hiredman: yes

21:13 RSchulz: You are quite the heretic!

21:13 Commendible!

21:13 albino: all the real smarties use zsh

21:13 RSchulz: But where do you you go from zsh? There aren't any more letters...

21:13 hiredman: freebsd 's /bin/sh is not bash and nothing like bash or zsh, if you want those with those features you can install them

21:14 RSchulz: Ooh. Zsh has a new-user configurator / wizard!

21:15 (I have so run it before)

21:15 albino: hiredman: so do you hack for a living?

21:16 hiredman: no, actaully

21:16 RSchulz: "Will hack for food."

21:16 Nafai: I used to run zsh

21:16 But I never really used the specific features of it

21:16 RSchulz: hiredman is a Software Engineer. No hacking allowed.

21:16 Nafai: And when I installed my OS on a new machine, I never got around to installing zsh, so I just use bash

21:17 hiredman: I am the junior estimator at a commercial painting company

21:18 RSchulz: Well, that doesn't admit much in the way of bon mots...

21:19 albino: hiredman: sounds kind of interesting

21:20 hiredman: nah, just stare at plans all day

21:21 RSchulz: Lots of Excel, I suppose.

21:21 hiredman: Yes.

21:21 albino: hiredman: well it's kind of interesting that you hack on clojure stuff on the side, I would expect most people here aren't in painting businesses

21:21 RSchulz: Spreadsheets are pretty cool. A Clojure-oriented spreadsheet could be interesting.

21:22 Hmmm. I mowed lawns, painted houses, shovelled snow and fried donuts when I was young.

21:41 drewolson: how can i get access to command line arguments?

21:42 Chouser: *command-line-args*

21:42 ,*command-line-args*

21:42 ,(prn *command-line-args*)

21:42 drewolson: thanks :)

21:42 clojurebot: nil

21:42 Chouser: heh, sure.

21:43 drewolson: i've been messing with a toy program to create fractals with clojure...but i can't seem to find a java turtle graphics lib that _works_

21:43 Chouser: I wrote a toy program to draw fractals in clojure.

21:44 drewolson: damn you for beating me to it :)

21:44 do you have the source somewhere?

21:44 Chouser: hm, I know I posted an older version.

21:45 http://blog.n01se.net/?p=35

21:47 drewolson: that looks cool

21:47 Chouser: I've got a more flexible version somewhere...

21:48 :-) thanks. It proved more difficult for me than I expected.

21:48 drewolson: http://github.com/drewolson/dragon/tree/master

21:48 this is my feeble attempt so far

21:48 trying to draw the dragon fractal

21:48 i swear it's right, but the turtle graphics programing isn't working as expected

21:50 rhickey: Many patches applied - thanks all! http://code.google.com/p/clojure/source/list

21:53 Chouser: drewolson: ah, here's a commented more fleixble version: http://gist.github.com/44584

21:53 that one is an applet

21:53 drewolson: ah, thanks

21:54 * durka wonders if applets work on os x

21:54 Chouser: page with embedded applet: http://chouser.n01se.net/misc/tree.html

21:54 durka: it does not :-)

21:55 durka: but the last version I asked you to try was, I thought, compiled using java 1.5, and I now think it wasn't.

21:57 drewolson: i think it's probably because i'm still getting used to it, but it takes me much longer to read clojure code than, say ruby. it feels much more "dense"...not it a bad way. just lots of info per line

21:57 Chouser: it is definitely more dense

21:58 I've heard different people specifically call that out as bad or good.

21:58 drewolson: it can't decide if that's a good thing

21:58 i find myself thinking that my clojure code is "clever" in a somewhat bad way

21:58 terse but very dense

21:58 i suppose like anything else it gets better with practice

21:59 Chouser: I guess I come down on the side of it being good. Why would I want to spend more space, more lines, more words, saying the same thing?

21:59 But yes, it takes practice and especially at first a certain amount of persistence to dig in.

22:00 drewolson: specifically concurrency has been a hurdle for me. never really touched it before.

22:00 Chouser: One "trick" I tend to forget and have to rediscover occasionally is that if a block I'm reading is just too impenetrable, to try reading it from the inside out.

22:00 drewolson: yes, totally agree

22:01 Chouser: I guess this is especially for the more deeply nested structures.

22:02 oh, you're trying to read the Tree code, aren't you. I'm afraid there's a couple things in there that kinda obfuscate what's going on.

22:02 that 'branch' macro is -- substantial.

22:03 drewolson: It's interesting though, worth looking at. I'm going to have to scurry off and figure out what's going on with the agents

22:04 you're mapping across a range of ints to start the agent pool, right?

22:05 Chouser: yes, just to create a batch of agents

22:05 drewolson: and then you create another agent to monitor them

22:05 ?

22:06 Chouser: each agent just computes a random point in fractal, draws it, and then loops around to do it again. The agents are completely independent of each other.

22:06 yes, that's just for debugging.

22:06 drewolson: i see

22:06 Chouser: if an agent's action function throws an exception, the agent quits working but you may never know about it.

22:06 drewolson: ah, i see

22:07 Chouser: so I made a monitor agent to occasionally check all the other agents for any errors and print them to stdout

22:07 of course if the monitor agent has an error....

22:08 drewolson: metamonitoring? heh

22:08 Chouser: but it was the code for the other agents I was changing a lot, experimenting with different shapes and such, so that's where errors were likely to occur.

22:11 * drewolson starts reading the concurrency chapter of programming clojure

22:12 drewolson: i took a quick look at the agents section on clojure.org, but i'm not groking the reduce in run

22:14 Chouser: sorry, I'm not sure what you're talking about.

22:16 drewolson: there's some example code on clojure.org under the agents section. in the run function, there is a reduce function called to build the ring of agents. i can't quite parse it.

22:16 Chouser: ah, yeah. talk about dense...

22:18 ok, reduce there has 3 args, a fn, an initial value, and a seq

22:18 drewolson: sure

22:19 oh i get it

22:19 :)

22:19 next is the last agent

22:19 Chouser: so the first time the fn is called, it's 'next' is the :report-queue agent and it's 'i' is 0

22:19 drewolson: which becomes part of the state of the current agent

22:19 which is returned

22:19 and then used for the next agent

22:19 and so on

22:19 yes?

22:19 Chouser: well, if you get it, then can I stop trying? :-)

22:19 drewolson: haha

22:20 i'm still slightly confused how the range is involved

22:20 is that just providing something to iterate over?

22:20 Chouser: yes, the value of 'i' isn't used

22:20 drewolson: gotcha

22:20 is there an idiom in clojure to use, say _ when a param will not be used?

22:20 Chouser: yes

22:20 drewolson: gotcha

22:21 Chouser: there, fixed.

22:22 drewolson: cool :)

22:23 Chouser: surely Halloway's examples are easier to follow?

22:23 drewolson: well, they are more gradual

22:23 however i love to ponder these more real examples

22:24 when you finally get them it's quite gratifying

22:24 Chouser: ah, true.

22:27 freddy_d: hi all

22:27 Chouser: hello

22:27 freddy_d: anyone using Clojure in the workplace?

22:28 Chouser: there was a interesting post to the group recently about a Clojure deployment.

22:28 drewr: freddy_d: Almost every day.

22:29 freddy_d: drewr: interesting. what kind of applications?

22:29 drewolson: drewr: lucky. and nice name.

22:29 drewr: drewolson: :-)

22:30 freddy_d: Mostly back-end, data-mining types of things.

22:30 freddy_d: drewr: cool.

22:31 drewolson: Chouser: in the given agent example, how can we bet sure that all messages have reached the final agent. we aren't blocking anywhere waiting for them, correct?

22:33 ah, nvm. java.util.concurrent.SynchronousQueue is a blocking queue

22:33 tricky, very tricky

22:33 Chouser: good eye -- I hadn't spotted that yet.

22:34 drewolson: ok, this all makes sense now. very interesting example.

22:40 thanks for the help, night all

23:17 danlarkin: JEEEEEZ it's cold outside

23:32 arohner: danlarkin: I know! It's like 50 outside!

23:32 :-p

23:33 * danlarkin scowls

23:33 * arohner is in austin

23:33 * danlarkin is in new york

23:35 pjb3: I was just looking through some of the code in contrib/sql and I

23:35 have a question

23:36 in do-commans

23:36 do-commands

23:36 it has this: (with-open [stmt (.createStatement (connection))]

23:36 that means that connection must be a function that is being called, right?

23:36 where does connection come from?

23:37 ah, internal

23:37 nevermind, didn't see that

23:39 I suppose this was written before the introduction of defn- into the language?

Logging service provided by n01se.net