#clojure logs

2009-01-14

01:16lisppaste8durka annotated #73563 with "trivial: i reinvented a small wheel (number?)" at http://paste.lisp.org/display/73563#2
01:24lisppaste8durka 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
01:25durkaat this point i will cease and desist using lisppaste as a VCS
01:30slevenwithout reader-macros does Clojure really support syntactic abstraction? or "merely" evaluation-control?
02:21burkelibbeyHmm, looks like now I need to go learn Haskell so I can figure out clojure.contrib.monads... :/
02:24burkelibbeyoh cool, I didn't notice the examples directory before.
02:24RaynesLearn Haskell anyways. It rocks.
02:25burkelibbeyIt's definitely on my todo list. I want to get a better grip on clojure first.
02:25burkelibbeyI think haskell is next though
02:26burkelibbeyHow is it? I leafed through it once, but didn't take a very good look
02:26RaynesIt's avery good book.
02:26Raynesa very*
02:27burkelibbeyHmm, maybe I'll order a copy then.
02:28RaynesYou can read it online for free. I don't require a dead tree version.
02:29burkelibbeyOh right, I remember hearing that. Thanks
02:29Raynesbook.realworldhaskell.org/read
02:30burkelibbeyHeh, if only I could just do this stuff instead of my boring Java OO courses :P
03:54AWizzArdMoin
04:06Kerris7yay Clojure book update
04:07Kerris7Morning AWizzArd :)
08:11duck1123It 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"
08:12duck1123That way, burkelibbey could do his assignments in clojure, convert to java, and the teacher would be none the wiser. :)
08:12Chousukehe'd get bad marks for ugly code though.
08:13duck1123If you could keep the generated code clean and logical enough, you could convert, say clojure-contrib, then run javadoc on it
08:21leafwduck1123: does not sound so difficult ... nice weekend project
08:22leafwto 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.
08:23duck1123I 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
08:23rhickeyduck1123: the early Clojure compiler was a CL app that generated Java and C# source.
08:24duck1123that's cool
08:24rhickeyreadability was a non-objective :)
08:24leafwrhickey: one would say that macroexpand-1 inherits from those days, ehem ehem
08:25FibIf 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?
08:25duck1123I 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.
08:25Fibe.g. I have '(+ x 1) and {'x 1} and want to get the result 2.
08:26duck1123rhickey: btw, have you received my CA yet?
08:26duck1123Daniel E. Renfer
08:28Chousuke,(let [mymap {'x 2 'y 3}] (map #(get mymap % %) '(+ 1 x y)))
08:28clojurebot(+ 1 2 3)
08:28ChousukeFib: like that
08:29rhickeyduck1123: no, but I only check the box once a week or so
08:29ChousukeFib: of course, the result will be a list. if you want to compute it, you'll need eval
08:30duck1123ok, my stamps were kinda old, but they said first class. Wasn't sure if they were still good, so I put 2 on.
08:31rhickeyLinj attempted to produce readable Java from a Lisp-like language
08:31rhickeyduck1123: sent when?
08:32duck1123thursday? I dropped it in the outgoing mailbox at work, so I'm conserned about that as well
08:32FibChousuke: 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...
08:32duck1123I'm sure it's there
08:32FibSo I guess I'd have to walk the expression keeping track of rebindings on the way down
08:33AWizzArdWhen 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?
09:14StartsWithKFib: http://is.gd/fQGf
09:15StartsWithKFib: but notice the comment: gross - please don't write code like this!!!
09:18FibHaha, thanks :)
09:40StartsWithKAWizzArd: JFilleChooser works fine for me in standard repl, maybe a slime issue
09:41AWizzArdoki, I will try it from the shell
09:43AWizzArdyes, in the shell it works fine
09:43AWizzArdmust be a slime issue... very strange though
09:44AWizzArdAnyone here who knows Swing as if he wrote it himself? ;-)
09:46asbjxrnI've written some code I know as well as I know swing...
09:47Chouserhehe
09:51AWizzArdDo you see a way to get out of an instance of a JFileChooser the combo box which shows directories (indented and with symbols)?
09:55asbjxrnSorry, I hardly know Swing at all.
09:55mattreplAWizzArd: there are problems with Swing on Windows and Emacs/Slime. don't recall if there was a workaround, may want to search the list
09:58leafwAWizzArd: JFileChooser is likely a Container:just inspect throgh its hierarchy of Containers and Components
10:01AWizzArdleafw: yes, I am doing this right now in the repl. Is there an easier way to do this? Maybe in NetBeans somehow?
10:01asbjxrnhow do you inspect?
10:01AWizzArdI call (.getComponents fc) where fc is a JFileChooser
10:02ChouserI bet you could add a little defmethod to inspector for that, and have a nice graphical explorer of the container tree
10:04asbjxrnI got to learn about the inspector.
10:04AWizzArdI don't understand why Sun does not give users full control to anything in those ready dialogs, with easy access through some methods
10:04asbjxrnThat is one of the things I miss from CL.
10:04AWizzArdasbjxrn: there is no "the inspector"
10:04Chouserclojure.inspector
10:05AWizzArdah ok
10:05AWizzArdasbjxrn: yes, in CL I would (inspect fc)
10:05asbjxrnAWizzArd: That was my reaction about 2 minutes ago :)
10:07asbjxrnAlso, 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:07Chouserhah, sweet, it works. Dunno if it's useful, though.
10:09lisppaste8Chouser pasted "inspect swing tree" at http://paste.lisp.org/display/73577
10:10Chouseroh, I left out the (use 'clojure.inspector)
10:11AWizzArdyes, nice
10:12slevenits not until I really learned Clojure that I saw what a big inelegant mess my Jav,C++ and Python programs were.
10:12Chousersleven: I'm right there with you.
10:14ChousukeWell, 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:15ChousukeI guess that applies to functional programming in general too
10:23lisppaste8asbjxrn pasted "Performance challenge, how much can you improve this" at http://paste.lisp.org/display/73578
10:24asbjxrn(Thought I'd submit this to the performance thread in the clojure group, do anyone see any improvements first.)
10:25asbjxrnThis is one step in this fluid dynamics solver: http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf
10:26asbjxrnIt 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:28Chousukeasbjxrn: I get an exception trying to run that.
10:28ChousukeI wonder if it's slime's fault :/
10:28asbjxrnOops.
10:31asbjxrn(def foo (make-grid)) should be (def foo (ref (make-grid)))
10:32ChousukeI wonder why the classcast exception just says "[F" though
10:32Chousukenot very helpful
10:33asbjxrnI think it's the start of the name of the array, see the return value from the function.
10:34asbjxrnIt tried to cast it to a ref
10:36karmazillaI think [F is the classname for a primitive array of floats. Could be wrong about the floats part though
10:36asbjxrnI think you're right.
10:37Chousukewhy is it a ref though?
10:40asbjxrnA 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:43asbjxrnThe 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:45asbjxrnThe original algorithm avoids that, of course. It allocates two arrays and swaps the pointers to them. I think of refs as pointers, so..
10:47Chousukeas far as I can see, you don't do anything useful with that ref :/
10:52gnuvinceGuys, I'm getting some weird results when reading from urandom from Clojure
10:52gnuvince> (let [buf (reader "/dev/urandom")] (for [_ (range 20)] (.read buf)))
10:52gnuvince(65533 65533 120 16 84 71 60 36 65533 65533 29 72 65533 14 65533 17 64 65533 65533 65533)
10:52gnuvinceIf I try the same code with Haskell or Python, I don't get any 65533
10:54asbjxrnChousuke: This is just part of the algorithm. But a time critical part so any improvements here makes a big difference.
10:55Chousukegnuvince: try with java?
10:55gnuvinceChousuke: I probably should
10:56gnuvinceChousuke: it was just easier with languages where it was a single line and in a REPL
10:56Chousukealso, definline seems broken :/
10:59ChousukeI 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:59Chousukemagnitude*
11:00Chousukeeven though the jvm really should be autoinlining it, it seems like it's not even trying. :p
11:02asbjxrnHmm. Maybe I should check if it's the calculations or the array lookups that take time.
11:03karmazillacalls on interface types are harder to optimize, methinks
11:05ChousukeI wish there were a way to define local inline fns :/
11:05Chousukesort of minimacros
11:06asbjxrnShouldn't a array lookup be pretty fast anyway? Almost like a ref/pointer?
11:07Chousukethe lookup is probably as fast as it can be
11:07ChouserChousuke: I think that's called 'macrolet' and is on Rich's wishlist.
11:08Chouserdefinline is used in core.clj. How broken could it be?
11:09gnuvinceChousuke: found my problem. I switched to a FileInputStream and it fixed the problem.
11:10asbjxrnHmm, 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:10ChousukeChouser: maybe I don't understand how it's used
11:10Chousukeuser=> (definline foo [] (+ 1 1))
11:10Chousukejava.lang.ExceptionInInitializerError (NO_SOURCE_FILE:1)
11:10gnuvince> (let [stream (java.io.FileInputStream. "/dev/urandom")] (for [_ (range 20)] (.read stream)))
11:10gnuvince(168 64 2 210 238 108 10 128 156 41 65 167 79 218 213 10 205 175 169 239)
11:10Chousergnuvince: It was being read as UTF-8.
11:10asbjxrn(sorry, 30%, not 50%)
11:11gnuvinceChouser: yeah, someone explained to me that Streams read bytes and Readers read characters.
11:12StartsWithKwill 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:12StartsWithKis rev1207 'safe', i see there is new stream stuff in there, will that break any old behaviour?
11:13ChouserStartsWithK: you can always got back if the new version breaks something.
11:13Chouserif there's any stream stuff in trunk, it's non-breaking changes.
11:14StartsWithKi know, just asking, i would like to get watcher for refs and condp, they look realy good
11:15karmazillaasbjxrn: the JIT can make your code do nothing a trillion times in no time at all :)
11:19ChouserChousuke: definline works more like a macro
11:20Chouserhm, though I can't get that to work either.
11:21StartsWithKfor what sould unquote be used?
11:21StartsWithKis there any example?
11:22Chousukeit's there for the occasion that you want to assign your own semantics to ~foo
11:22ChouserStartsWithK: http://groups.google.com/group/clojure/msg/62437f3b96835b58
11:23ChouserI think ClojureQL is actually using it for real now.
11:24Chouserusing the definline examples directly from core.clj at my repl still break. How can that be?
11:25Chousermaybe they have to be compiled now?
11:27StartsWithKChouser: thanks, will look in ClojureQL for more examples
11:29ccmtaylorhi 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:30StartsWithKand are there maybe any examples of using watcher for refs to create similar effect to the one in http://is.gd/fRKs
11:31ccmtaylor`(stuff ~@(when conditional-stuff [conditional-stuff]) more-stuff)
11:31ccmtaylorworks, but seems un-pretty. does anyone have a better solution?
11:32Chouserccmtaylor: Off the top of my head, I think that's about as pretty as you're going to get.
11:32StartsWithKccmtaylor: is 'stuff' ok to accept nil for its first argument?
11:32ChouserStartsWithK: the only watcher example I know of is one I wrote for watching agents.
11:33ChouserBut 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:34ccmtaylorStartsWithK: no, it needs to be completely not-there
11:35Chouserccmtaylor: 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:35ccmtaylorok, thanks!
11:36StartsWithKyes, you'll have to have two routes to that `(stuff ...) expansion then
11:36Chouserhm, you could filter the list after you've made it.
11:37Lau_of_DKChouser: Its a shame you dont have enough time to keep up anymore, do you want to tips on some Clojure/SQL implementations?
11:37Chouserccmtaylor: (defn f [x] (remove nil? `(stuff ~(when (odd? x) x) 2 3)))
11:37Chouserseems a bit dangerous though. I think ~@( ... [foo]) is fine
11:38ChouserLau_of_DK: give tips? get tips?
11:38Lau_of_DKs/to/some :)
11:38Lau_of_DKOh, you want more money?
11:38Lau_of_DKfine...
11:39ccmtaylorChouser: 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:39ccmtaylorwon't
11:41Chouseryou could use some other sentinel besides nil
11:41ChouserI'm not really arguing for this, just trying to drum up options.
11:42Chouser(defn f [x] (remove #{:skipit} `(stuff ~(if (odd? x) x :skipit) 2 nil)))
11:59_hrrldRatios 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_hrrld(Math/sin 52163/16604) ;le cry.
12:06Chouser_hrrld: I suppose you'd have to write your own, or try to convert back to a ratio after calling Math/sin
12:24drewrDoes dispatching to defmethods occur in any particular order?
12:25drewrSince methodTable is a PersistentHashMap in MultiFn, I'm guessing not.
12:44Lau_of_DKIs there a clojure-func to upper-case a string?
12:45danlarkinyes
12:45danlarkin(.toUpperCase "foo")
12:45danlarkin:)
12:45danlarkinor, if you prefer, #(.toUpperCase %)
12:47Lau_of_DKGotcha
12:47Lau_of_DKThanks
12:54lisppaste8durka pasted "is there a way to do this without the ~' ugliness?" at http://paste.lisp.org/display/73582
12:57Chouserdurka: are you willing to let the caller pass in the name to be used, instead of always capturing 'get-value'?
12:58durkai'd rather not...
12:58durkathis is related to the RPN thing i was playing with yesterday
12:59durkawhere quasiquote wants to resolve things at macroexpansion time but i'd like it to wait
12:59durka(is it called quasiquote?)
12:59Chouserif you want to capture a name, ~' is the way to do it.
12:59durkaok
13:00Chousukeit serves as a hint that capturing names is ugly :)
13:08durkafair enough
13:49Lau_of_DKAnyone here, whos strong on the SQL statement Alter ?
13:51gnuvinceIs it possible to get the address of an object in clojure? Something like id() in Python
13:52Lau_of_DKFor what purpose would you need that gnuvince ?
13:52gnuvinceLau_of_DK: I would like to show to someone that structures share data and are not copied
13:52gnuvinceBut he's got a Thomas syndrome
13:53Lau_of_DKhmmm
13:54Lau_of_DKhttp://www.velocityreviews.com/forums/t145498-how-to-get-address-of-a-java-object.html
13:54Lau_of_DKgnuvince: Theres a discussion which ends with the conclusion that its not possible
13:55gnuvincehmmm
13:55gnuvinceI could probably use identical? then
13:56Lau_of_DKCouldnt you make a specific example and then refer to the clojure source code?
13:56gnuvinceI think I can manage with identical?
13:56Chousergnuvince: you may be able to use .hashCode
13:58Chouser,(let [a '(3 2 1) b (cons 4 a)] (map #(.hashCode %) [a b (rest b)]))
13:58clojurebot(1800990793 -467838107 1800990793)
13:59gnuvince,(.hashCode "hi")
13:59clojurebot3329
13:59gnuvince,(.hashCode "hi")
13:59clojurebot3329
13:59Lau_of_DKChouser, doesnt your example show that the structure is shared?
14:00ChouserLau_of_DK: that was the idea, wasn't it?
14:00Lau_of_DKI was under the impression that no structure was ever shared, because if you modified one, an entire new collection would be formed
14:01ChouserLau_of_DK: no, a major advantage of immutable collections is that you *can* share structure safely, since none of it can be changed.
14:01karmazillathere's System/identityHashCode - closest thing to python's id() I think
14:02Lau_of_DKChouser: yes of course, youre right
14:02Lau_of_DKI didnt have my thinking cap on :(
14:02Chouserkarmazilla: that appears to be the same as .hashCode
14:03Chouserkarmazilla: no, you're right. identityHashCode is what you want.
14:03karmazillathat depends on the object.. but Object.hashcode calls identityHashCode
14:04gnuvince,(let [x1 (list "one" "two" "three") x2 (conj x1 "zero")] (every? #(apply identical %) (map vector x1 (rest x2)))
14:04clojurebotEval-in-box threw an exception:EOF while reading
14:04Chouser,(let [a {} b (dissoc {:c 1} :c)] (map #(vector (.hashCode %) (System/identityHashCode %)) [a b]))
14:04clojurebot([0 16638032] [0 26336541])
14:04gnuvince,(let [x1 (list "one" "two" "three") x2 (conj x1 "zero")] (every? #(apply identical? %) (map vector x1 (rest x2)))
14:04clojurebotEval-in-box threw an exception:EOF while reading
14:05gnuvincewth?
14:05Chouserone more )
14:05gnuvincedamn
14:05gnuvince,(let [x1 (list "one" "two" "three") x2 (conj x1 "zero")] (every? #(apply identical? %) (map vector x1 (rest x2))))
14:05clojurebottrue
14:05gnuvincethere
14:06gnuvinceWriting Lisp code without paren-match is pretty hard
14:07Lau_of_DKgnuvince: you mean, you dont chat in emacs?
14:07gnuvinceLau_of_DK: irssi
14:07gnuvinceI used to before with rcirc
14:07Lau_of_DKoh.. switch to emacs, then you can enable paredit on irc if you like :)
14:07Lau_of_DK:(
14:07gnuvinceYeah
14:07Lau_of_DKrcirc was really lacking if you ask me. ERC is cool though
14:07gnuvinceThere are some real advantages to using Emacs for IRC
14:07gnuvinceparen matching, auto completion of words other than nicks, searching backwards
14:08gnuvinceI think I lost my ERC config a few years ago
14:08Lau_of_DKYea, and especially, you can send all of Chousers tips straight to the REPL
14:08gnuvinceThat too
14:11ChousukeI'm not that much of a lisper that I would give up irssi
14:13erohtar.
14:13replacaI'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:13erohtardanlarkin: thanks for your time yesterday on helping me with clojure-json
14:13erohtardanlarkin: it was a problem of the incoming json string being escaped twice -
14:14danlarkinerohtar: no problem. good to hear you solved it
14:34Chousernot yet halfway through January, and the group already has twice as many posts as all of September.
14:35danlarkinI can't keep up anymore :-/
14:36Chouserthere have been a couple attempts at summarizing the "important" threads, but I think the volume has overwhelmed those who were attempting it.
14:37rhickeyChouser: it does test the limits of all apps I try to manage it with
14:39Chousergmail is hanging on for me, but I had to change tack a bit today -- we'll see if this holds up.
14:41Lau_of_DKChouser: Tried thunderbird + digests ?
14:41Chousernope
14:41Lau_of_DKI suspects its easier to keep up with, but I still cant keep up
14:42ChouserI really don't think digests would work for me, unless I wanted to stop posting and just read.
14:42ChouserWhich come to think of it might be better for everyone.
14:44rhickeyMail.app is so much better than GMail at letting you walk through what's new - gmail's threaded-only viewing is fail
14:44rhickeyfor me
14:46danlarkinI 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:47ChouserI use vi keybindings in gmail. :-)
14:47danlarkin*mind boggled*
14:47hiredmanhit the escape key alot while trying to write emails in gmail
14:48hiredmanI
14:48Chousukedoes it delete all text? :)
14:48ChouserI edit emails in vim. Esc is ok.
14:48hiredmannope
14:48Lau_of_DKAlso, you can get the mails directly in Emacs if you like
14:48hiredmanit does nothing
14:49hiredmanactually, I hit "<esc>:w<enter>"
14:49ChousukeI have vim keybindings for my browser... really nice. Though some sites suck for keyboard browsing
14:50hiredmanclojurebot: mock?
14:50clojurebotYour mock object is a joke; that object is mocking you. For needing it. -- rhicky
14:50Lau_of_DKname mispelled :)
14:52Lau_of_DKhttp://tech.slashdot.org/article.pl?sid=09/01/14/1312210
14:52Lau_of_DKQt goes LGPL
15:13hiredmanbeing able to roll everything into a jar file and ship it out is so nice
15:34Lau_of_DKKota 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:37rhickeyasbjxrn: http://groups.google.com/group/clojure/msg/967ebe3133aa25ec
15:58red_fishsomeone can explain to me
15:58red_fish(defn add-points [& pts]
15:58red_fish(vec (apply map + pts)))
15:58red_fish(add-points [10 10] [-1 0])
15:59red_fishI don't understand (apply map + pts)
15:59danlarkindo you understand map and apply?
15:59red_fishyep
15:59Lau_of_DKdanlarkin: I dont think he does, no
15:59red_fishwhat is the order of evaluation?
15:59danlarkinred_fish: well then it's just applying map + to pts
16:00kotarak(apply map + pts) <=> (apply map + (list [10 10] [-1 0])) <=> (map + [10 10] [-1 0]) <=> (list (+ 10 -1) (+ 10 0))
16:03red_fishkotarak: (apply #(map + %1 %2) (list [10 10] [-1 0]))
16:03red_fishkotarak: is it the same?
16:03red_fishhow can apply know infer that "map +" is the function?
16:03hiredman,(apply #(map + %1 %2) (list [10 10] [-1 0]))
16:03clojurebot(9 10)
16:04hiredmanmap + is not the function
16:04hiredmanmap is the function
16:04hiredman+ is just another argument
16:04hiredman(that happens to be a function)
16:04kotarakand takes + as argument
16:04kotarakright
16:05kotarak(apply func arg1 ... argn arglist) (where arglist is something seqable)
16:05hiredmanring is a nice, but I think I like compojure's vector -> html stuff better than clj-html's
16:05danlarkinred_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:05red_fishkotarak: is this equivalent (apply map (list + [10 10] [-1 0]))?
16:06kotarakI think so.
16:06hiredman,(apply map (list + [10 10] [-1 0]))
16:06clojurebot(9 10)
16:06red_fish,(apply map (list + [10 10] [-1 0]))
16:06clojurebot(9 10)
16:06red_fishcool
16:06kotarak,(apply map + [10 10] [[-1 0]])
16:06clojurebot(9 10)
16:07red_fishthank you very much
16:07kotaraknp
16:07red_fishI think i wanna see the source of "apply"
16:07Chousukehiredman: clj-html is faster though.
16:07kotaraksrc/clj/clojure/core.clj
16:07hiredmanChousuke: I see
16:07red_fishkotarak: thx
16:09Chouserred_fish: http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/core.clj#367
16:10danlarkinand let me assure you, apply _is_ lazy :-D
16:10hiredmandanlarkin: what?
16:11hiredmanmadness
16:11danlarkin:o
16:18karmazillamadness? this is Clojure!
16:21ChouserI love lazy apply. Another one of those features where my first reaction was simply to assume it was impossible.
16:21Chouser,(apply (fn [a b & r] [a b (take 3 r)]) (iterate inc 0))
16:21clojurebot[0 1 (2 3 4)]
16:25gnuvinceneat<
16:27danlarkinLau_of_DK: I know something I'd really like to see in clojureql: postgres support
16:29kotarakdanlarkin: 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:29Chousukehmm
16:30Chousuke,(apply (fn [a b] (list a b)) (iterate inc 0))
16:30clojurebotjava.lang.OutOfMemoryError: Java heap space
16:30ChousukeI guess the infinite seq goes to a in that case?
16:31red_fish(apply (fn [a b & r] [a b (apply identity (take 3 r))]) (iterate inc 0))
16:32red_fish,(apply (fn [a b & r] [a b (apply identity (take 3 r))]) (iterate inc 0))
16:32clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$identity
16:32red_fish,(apply (fn [a b & r] [a b (apply map identity (take 3 r))]) (iterate inc 0))
16:32clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
16:33ChouserChousuke: odd -- you should have gotten a "Wrong number of args"
16:34red_fish,(apply (fn [a b & r] [a b (take 3 r)]) (iterate inc 0))
16:34clojurebot[0 1 (2 3 4)]
16:35Chouser,(apply (fn [a b & r] [a b (map identity (take 3 r))]) (iterate inc 0)) ; red_fish: looking for this?
16:35clojurebot[0 1 (2 3 4)]
16:35red_fishChouser: yes
16:36Chouserof course since 'map' is also lazy, you can move the 'map' to inside the 'take
16:36red_fish,(apply (fn [a b & r] [a b (appy map identity (take 3 r))]) (iterate inc 0))
16:36clojurebotjava.lang.Exception: Unable to resolve symbol: appy in this context
16:37red_fish,(apply (fn [a b & r] [a b (apply map identity (take 3 r))]) (iterate inc 0))
16:37clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
16:46burkelibbeyDoes 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:46kotarak(doc conj)
16:46clojurebotconj[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:46rhickeyburkelibbey: conj works that way, for all collections
16:47burkelibbeyAh, I thought conj added to the end of a collection, but apparently I was using a vector without really realizing :P. Thanks.
16:48red_fish(doc conj)
16:48clojurebotconj[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:53red_fishcan I use ctags with clojure?
16:54kotarakred_fish: I write a simple cljtags.
16:54red_fishcool
16:54kotarakred_fish: http://bitbucket.org/kotarak/cljtags/ there is only a repo at the moment, but it has download link
17:15gnuvince_Hmmm
17:15gnuvince_Somebody ought to reply to Slava on reddit to point out that Clojure is not like the Lisp he mentions
17:16rhickeylink?
17:16gnuvince_Me again?
17:17gnuvince_http://www.reddit.com/r/programming/comments/7pohw/why_haskell_is_beyond_ready_for_prime_time/c071i7o
17:18rhickeyNot 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:20gnuvince_Really?
17:27NafaiI think Slava has sufficiently demonstrated that he has no interest in the Java language or platform
17:28ChouserI do think there's remarkably little scolding here
17:29albinothey're talking about that thread in #concatenative right now, you could join them and make it real time
17:30rhickeyChouser: yes, I'm extremely pleased with this irc and the google group for general pleasantness, helpfulness and respectfulness
17:30Lau_of_DKFunny argument Slava puts forth, he's not entirely wrong
17:32karmazillasomething is wrong with swing :(
17:35Chouserkarmazilla: seems likely :-)
17:35Nafai:)
17:37karmazillaa 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:46karmazillaohh... a little animal of mythical origin shared with me the arcane secrets of SwingUtilities.invokeLater. I'm a now bewildered by its magic
17:46Chouserkarmazilla: there's a macro for that in textjure.clj
17:48karmazillayeah, that might have been the animal, but I am still prototyping with netbeans and its gui builder from the land of control
17:49karmazillait's the document-switcher-slash-file-opener for textjure that I'm trying to build :)
18:03meredyddHey all. Is there a convention for calling out of a sub-namespace?
18:03meredyddSay I have two components X and Y that each need to send events to the other
18:04meredyddIf 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:04meredyddIs there a conventional way of handling this situation?
18:06hiredmanmeredydd: have them require each other?
18:06meredyddhiredman: That didn't work last time I tried it
18:06meredyddCan't remember the failure mode now - might just be an infinite loop of interpreter-ness
18:10meredyddhiredman: Yeah, there we go. "No such var: com.xxx.x/var"
18:11durkaisn't this was declare is for?
18:11hiredmanmeredydd: a.a requires a.a.a requires a.a.b requires a.a.a
18:11meredydddeclare? Fee fi fo fum, I smell a new keyword.
18:11durka(doc declare)
18:11clojurebotdefs the supplied var names with no bindings, useful for making forward declarations.; arglists ([& names])
18:12Chousukecan you declare vars in other namespaces? :/
18:12hiredmandurka: declare would not work across namespaces I don't think
18:12durkayes
18:12meredyddChousuke: Nope.
18:12hiredman,(declare 'foo/fum)
18:12clojurebotDENIED
18:12Chousukeso your problem is that a.a.b and a.a.a call each other directly.
18:12hiredmanclojurebot: thanks man
18:12clojurebotNo entiendo
18:12Chousukeadd indirection!
18:12durka(binding [*ns* *ns*] (in-ns 'other) (def a b))
18:13meredydddurka: Yep, but then you've got to break up your (ns) and do all your definitions before your use/require/etc statements
18:13durkaseems like there should be a better way to do this
18:13meredydddurka: ...or you've got to do something unpleasant like that.
18:13meredydd(which is what I've been doing so far. But it's frankly ugly.)
18:13durkahow does java handle it?
18:14hiredmanmeredydd: what I said should work
18:14hiredmanI just tried it
18:14meredyddhiredman: Try referring to a var in a.a.a from a.a.b
18:14meredyddand vice versa
18:14meredyddthat'll break it.
18:15meredydddurka: javac copes with mutual references between classes supplied in the same invocation.
18:15meredydddurka: 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:16durkai see
18:17hiredmanmeredydd: what I said works fine here
18:17meredyddWhere's the local pastebin?
18:17hiredmanlisppaste8: url?
18:17meredyddclojurebot: paste
18:17clojurebotNo entiendo
18:17lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
18:18meredyddOh, well - worth a shot :)
18:18hiredmanclojurebot: paste is http://paste.lisp.org/new/clojure
18:18clojurebotIk begrijp
18:18waltersmeredydd: groovy actually has a joint compiler, so it can do that
18:18meredyddwalters: That was a later development, explicitly developed to solve that problem.
18:19waltersmeredydd: http://groovy.codehaus.org/The+groovyc+Ant+Task
18:19meredydd(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:19waltersyeah, it's relatively recent
18:20meredydd(My point was that it requires explicit compiler smarts.)
18:20waltersyeah...ideally there would be a way for a language to plug into javac, so it sees ".clj" -> hand off to clojure.Compiler etc
18:20lisppaste8meredydd pasted "reference problems" at http://paste.lisp.org/display/73606
18:21erohtarhey - does anyone know if dynamic variables set via binding are visible through agents?
18:21meredyddhiredman: That breaks, with the error message I pasted.
18:21waltersthere's some sort of compiler API now, but I don't know whether it helps with this at all
18:22meredydderohtar: Give an example? Generally not - dynamic bindings are thread-local, and agents run in a separate thread.
18:22hiredmanmeredydd: you are correct, I did not have enough references between namespaces to check everything
18:22erohtarmeredydd: ah, i see - makes sense
18:22meredyddhiredman: 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:23erohtarmeredydd: 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:24meredydderohtar: No; the function you send will run in the agent's thread(pool), and won't see the dynamic binding either.
18:24erohtarmeredydd: right - ok... so can i change the dynamic binding within *that* function, then?
18:24meredydderohtar: 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:25meredyddRefs are "this is a value that can change over time"
18:25erohtarmeredydd: well, in my case, im using a dynamic variable to hold database config information, which I want to set at call time
18:26rhickeymeredydd: hm?
18:26meredyddrhickey: How do I cope with mutual references between two namespaces?
18:26meredyddeg, I have com.xxx.x and com.xxx.y and they both want to talk to each other.
18:27meredydd(say, each wants to call a funciton in the other)
18:27rhickeymeredydd: don't do it
18:27meredyddAnd if the answer is "that's the wrong question, you're doing it wrong", what patterns should I be using instead?
18:27meredyddThought that would be the answer :)
18:27meredyddSo what should I be doing instead?
18:28hiredmanmeredydd: 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:28meredyddIt's not easy to write, say, a message queue in the parent namespace that the the two can use to communicate
18:28meredydd(because the (:require) and (:use) clauses of the parent's (ns) macro come before any of the parent's (def)s)
18:29meredyddand 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:35hiredmanI think it may be time to re-examine your purpose in creating such a namespace arrangement
18:39meredyddThat's quite possible; nay, probable.
18:41meredyddI 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:43meredyddIn 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:43meredyddThat said, last time I was convinced I was right and Rich was wrong....well, you can guess the result :)
18:43danlarkinis it too complicated for an summary of what each does?
18:44Chousukeif they're interlocked libraries, is there a reason they aren't in the same namespace?
18:44hiredman^-
18:47meredydddanlarkin: Okay...
18:47meredyddChousuke: Essentially, because they're too big to put the whole hairball in one file; I'd like to destructure it a little.
18:48grosoursHi everybody
18:48meredydddanlarkin: A chat system that falls back to email.
18:48Chousukemeredydd: well, you can put some code in another file and just (load) it, can't you=
18:49meredyddThe webchat system is a hairy MVC beast that definitely wants to live in its own namespace.
18:49Chousukehmm :/
18:49meredyddThe mail system is also moderately hairy, and I don't want to go blending it with anything else.
18:49danlarkinHmmmm
18:50meredyddDepending on whether there's a chat session open (ie internal state of chat system), mails need to be intercepted and diverted to chat
18:50danlarkincan you do something like have a 3rd file with a function like send-chat-or-email ?
18:50meredyddAnd when a chat session times out, unseen messages get dispatched via the email system.
18:51meredydddanlarkin: 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:51danlarkinnah
18:52danlarkinit'd call try-to-send-chat and if that fails it calls try-to-send-email
18:52danlarkinor whatever
18:52danlarkinoh
18:52meredyddOkay. Now, in what namespace is 'try-to-send-chat located?
18:53meredydd(I take it that "oh" was you getting the problem)
18:53danlarkinhaha
18:53danlarkin...maybe :)
18:54meredyddNow, 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:54Chousukemaybe you need to abstract away the message handling somehow
18:55meredyddI'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:55hiredman*shrug*
18:55Chousukemail system receives message, notifies some message center, message center sees chat system is interested, forwards to it
18:55Chousukehmm
18:56meredyddaand 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:57Chousukethe 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:58meredyddyep, and then pass in a handler function for messages of type "mail", and chat does the same thing...
18:58hiredmanyou could leave out the require and have a fourth file that requires all three
18:58meredyddBut 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:58meredyddhiredman: How does that work?
19:00hiredmanactually
19:01hiredmanyou may want a look at the clojurebot code
19:01meredydd?
19:01hiredman(the ns and callback stuff is Chousuke's)
19:02meredyddOh, yes. If you want to do it with callbacks, that's all very well.
19:02hiredmanyeah
19:02hiredmanit is very well
19:02meredyddYou create both halves as libraries with empty callbacks for "send mail" and "intercept-message?"
19:03meredydd(with specific signatures designed to match their one and only implementation...)
19:03hiredmanmeredydd: the control center has a place where message handlers can latch on to
19:03ChouserI find I have to use 'declare' only very rarely in well-organized files.
19:03meredyddthen write a separate NS which just wires them together by plugging one's functions into the other's callbacks
19:04meredyddChouser: Oh, I agree. In fact, in this example, I want to use it all of once. (Maybe twice.)
19:05hiredmanmeredydd: you can have the ns plug themselves into the callbacks
19:05meredyddhiredman: How? By referencing which common component?
19:06hiredmanmeredydd: http://github.com/hiredman/clojurebot/blob/369ceedc238d8fe1539e0bca3b087d89827523ca/hiredman/clojurebot/svn.clj
19:06hiredmanline 85
19:06hiredmanwhen the ns is loaded
19:07hiredmanit calls that function, which hooks it in to the dispatching function in hiredman.clojurebot.core
19:07meredydd(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:08meredyddAha. You're dispatching on regexp there?
19:09hiredmanmeredydd: 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:10Chousukeit's not a very clean solution though. it lacks priorities so the first dispatch that matches gets called :P
19:10hiredman:P
19:11hiredmanI am not suggesting he take it verbatim
19:11hiredmanI am suggesting a similar model could be used
19:11meredyddhiredman: 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:12hiredmanmeredydd: you can do that, just leave out the requires and load the files
19:13meredyddYeah, I guess. I'd just prefer not to have to sacrifice the internal namespace structures of A and B to do this.
19:14meredyddAnyway, you're right here; I think this is a round-in-circles maneuver.
19:15meredyddI 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:53erohtarcan anyone tell me how agents die? i see that the thead count is increasing (under Activity Monitor)...
19:54durkayou mean how to forcibly kill them?
20:03erohtardurka: no, do they (the associated thread) die when the function sent to them is over?
20:04durkai don't think so, not necessarily
20:04Chouseran agent is not a thread. When the action is complete, the thread returns to the pool.
20:05durkaeven with send-off?
20:05ChouserThe agent stays around as long as something is referencing it, after that it can be GC'd
20:05erohtarchouser: ok understood, then why does the thead-count increase?
20:05erohtarchouser: also - is there a limit to the size of the thread-pool?
20:05Chouserdurka: yes, even with send-off.
20:06Chousersend'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:07erohtarchouser: ok thanks
20:08ChouserI don't think the send-off pool should ever have more threads than the maximum number of actions being processed at one time.
20:11Chouser,(.getPoolSize clojure.lang.Agent/pooledExecutor)
20:11clojurebot0
20:11Chouser,(.getPoolSize clojure.lang.Agent/soloExecutor)
20:11clojurebotjava.lang.Exception: No such namespace: clojure.lang.Agent
20:13Chouser,(send (agent 1) inc)
20:13clojurebot#<Agent clojure.lang.Agent@1e881b6>
20:13Chouser,(.getPoolSize clojure.lang.Agent/pooledExecutor)
20:13clojurebot1
20:13Chouserso that's the 'send' thread pool
20:13Chouser,(send (agent 1) inc)
20:13clojurebot#<Agent clojure.lang.Agent@94310b>
20:13Chouser,(.getPoolSize clojure.lang.Agent/pooledExecutor)
20:13clojurebot2
20:14Chouser,(dotimes [_ 100] (send (agent 1) #(do (Thread/sleep 1000)))
20:14clojurebotEval-in-box threw an exception:EOF while reading
20:14Chouser,(dotimes [_ 100] (send (agent 1) #(do (Thread/sleep 1000))))
20:14clojurebotnil
20:14Chouser,(.getPoolSize clojure.lang.Agent/pooledExecutor)
20:14clojurebot3
20:14Chousercapped out at 3
20:15Chouserlooks like the send-off pool is no longer public, so I can't see its thread count anymore
20:24Chouserok, I coulda *sworn* there was a verion of Clojure where I could get at both pools. But i can't find it now.
20:30erohtarwow - i didnt even know about clojurebot
20:30erohtaramazing
20:31erohtarchouser: why was the threadpool capped at 3?
20:42ChouserApparently clojurebot's running on a single-CPU machine. the 'send' pool uses CPU count plus 2.
20:43hiredmanyep
20:45danlarkinleaking implementation details!!!111oneonewon
20:48RSchulzHey, danlarkin! I'm not gone, just otherwise occupied. I upgraded my primary development system to openSUSE 11.1, and there were... complications.
20:48RSchulzAll is well, now, though.
20:48RSchulz345 unread messages in the Clojure list!
20:48hiredmanheh
20:49RSchulzWhat have I missed??
20:49danlarkin:)
20:49hiredmanthe internet is over
20:49hiredmanclojure won
20:49danlarkinglad to see you're still alive
20:49RSchulzThe tubes are terminally clogged?
20:49RSchulz(Couldn't think of a good word beginning with 't')
20:50durkano, it's not that
20:50durkathey caught tuberculosis
20:50RSchulzAh. Good one!
20:50durkathis is unrelated to last year's bout of tubercuilosis
20:51RSchulzAnyway, almost 100% of my old stuff is restored and much is better than it was. Now I can run, among other things, VimClojure.
20:51RSchulzAnd the various Git programs. It seems inevitable...
20:55durkalet's use reflection to break Agent's encapsulation
20:55durka,(.. (agent nil) getClass (getDeclaredField "soloExecutor") (get (agent nil)) getPoolSize)
20:55clojurebot2
20:55durka(send-off (agent 1) inc)
20:55durka,(send-off (agent 1) inc)
20:55clojurebot#<Agent clojure.lang.Agent@130671e>
20:55durka,(.. (agent nil) getClass (getDeclaredField "soloExecutor") (get (agent nil)) getPoolSize)
20:55clojurebot3
20:55hiredmanI 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:56durkareally? what put it there?
20:56RSchulzhiredman: You use Windows?
20:56hiredmannope
20:57durkai don't think nautilus has been ported to windows yet
20:57RSchulzWhich Nautilus are we talking about?
20:57hiredmanI 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:57hiredmanbut I guess it did
20:57RSchulzI think that's more likely the explanation.
20:58hiredmanI poked a lot of places, so I am note sure what did it
20:58RSchulzAnd... What's with using Gnome? ... Real Programmers (TM) use KDE!
20:58hiredmanRSchulz: I will refrain from bring a flame war into to #clojure (but KDE is junk, and I hate it)
20:58hiredmanbringing
20:58RSchulzYou're thinking of KDE 4.x
20:59hiredmanKDE.
20:59RSchulzControl freaks prefer KDE 3.5.
20:59hiredmanwell, thats just like, your opinion man.
21:00RSchulzThe only wrong opinion is "meh. don't care."
21:00RSchulz(I've known that type...)
21:02RSchulzLet's try another tack... Which distro do you use??
21:02hiredmanI don't use linux
21:04RSchulzEh? You use Gnome but not on a Linux or Windows?
21:05RSchulzOSX?
21:05hiredmanfbsd
21:06RSchulzAh. A real minority.
21:06hiredmannot in ##freebsd
21:07albinoheh
21:07RSchulzThe long tail.
21:07albinowe welcome all minorities, don't we?
21:08RSchulzOne would hope.
21:10albinohiredman: what do you like about freebsd? If you don't mind me being curious
21:10hiredmanit is very together
21:11RSchulzWhat's the latest FreeBSD version?
21:11hiredmanuh, the latest release was 7 something
21:11hiredman7.1
21:11albinoI need to try it out sometime
21:11albinomy only expereince with it was when someone else installed it and I was floored that tab completion wasn't there by default
21:12hiredmansomeone recommended it to me, about ten years ago, I tried it, and have not switched back
21:12hiredmanwell, I also use zsh not bash
21:12RSchulzYou dare bash BASH?
21:13albinobut zsh has tab completion by default, doesn't it?
21:13hiredmanyes
21:13RSchulzYou are quite the heretic!
21:13RSchulzCommendible!
21:13albinoall the real smarties use zsh
21:13RSchulzBut where do you you go from zsh? There aren't any more letters...
21:13hiredmanfreebsd 's /bin/sh is not bash and nothing like bash or zsh, if you want those with those features you can install them
21:14RSchulzOoh. Zsh has a new-user configurator / wizard!
21:15RSchulz(I have so run it before)
21:15albinohiredman: so do you hack for a living?
21:16hiredmanno, actaully
21:16RSchulz"Will hack for food."
21:16NafaiI used to run zsh
21:16NafaiBut I never really used the specific features of it
21:16RSchulzhiredman is a Software Engineer. No hacking allowed.
21:16NafaiAnd when I installed my OS on a new machine, I never got around to installing zsh, so I just use bash
21:17hiredmanI am the junior estimator at a commercial painting company
21:18RSchulzWell, that doesn't admit much in the way of bon mots...
21:19albinohiredman: sounds kind of interesting
21:20hiredmannah, just stare at plans all day
21:21RSchulzLots of Excel, I suppose.
21:21hiredmanYes.
21:21albinohiredman: 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:21RSchulzSpreadsheets are pretty cool. A Clojure-oriented spreadsheet could be interesting.
21:22RSchulzHmmm. I mowed lawns, painted houses, shovelled snow and fried donuts when I was young.
21:41drewolsonhow can i get access to command line arguments?
21:42Chouser*command-line-args*
21:42Chouser,*command-line-args*
21:42Chouser,(prn *command-line-args*)
21:42drewolsonthanks :)
21:42clojurebotnil
21:42Chouserheh, sure.
21:43drewolsoni'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:43ChouserI wrote a toy program to draw fractals in clojure.
21:44drewolsondamn you for beating me to it :)
21:44drewolsondo you have the source somewhere?
21:44Chouserhm, I know I posted an older version.
21:45Chouserhttp://blog.n01se.net/?p=35
21:47drewolsonthat looks cool
21:47ChouserI've got a more flexible version somewhere...
21:48Chouser:-) thanks. It proved more difficult for me than I expected.
21:48drewolsonhttp://github.com/drewolson/dragon/tree/master
21:48drewolsonthis is my feeble attempt so far
21:48drewolsontrying to draw the dragon fractal
21:48drewolsoni swear it's right, but the turtle graphics programing isn't working as expected
21:50rhickeyMany patches applied - thanks all! http://code.google.com/p/clojure/source/list
21:53Chouserdrewolson: ah, here's a commented more fleixble version: http://gist.github.com/44584
21:53Chouserthat one is an applet
21:53drewolsonah, thanks
21:54Chouserpage with embedded applet: http://chouser.n01se.net/misc/tree.html
21:54Chouserdurka: it does not :-)
21:55Chouserdurka: 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:57drewolsoni 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:57Chouserit is definitely more dense
21:58ChouserI've heard different people specifically call that out as bad or good.
21:58drewolsonit can't decide if that's a good thing
21:58drewolsoni find myself thinking that my clojure code is "clever" in a somewhat bad way
21:58drewolsonterse but very dense
21:58drewolsoni suppose like anything else it gets better with practice
21:59ChouserI 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:59ChouserBut yes, it takes practice and especially at first a certain amount of persistence to dig in.
22:00drewolsonspecifically concurrency has been a hurdle for me. never really touched it before.
22:00ChouserOne "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:00drewolsonyes, totally agree
22:01ChouserI guess this is especially for the more deeply nested structures.
22:02Chouseroh, 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:02Chouserthat 'branch' macro is -- substantial.
22:03drewolsonIt'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:04drewolsonyou're mapping across a range of ints to start the agent pool, right?
22:05Chouseryes, just to create a batch of agents
22:05drewolsonand then you create another agent to monitor them
22:05drewolson?
22:06Chousereach 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:06Chouseryes, that's just for debugging.
22:06drewolsoni see
22:06Chouserif an agent's action function throws an exception, the agent quits working but you may never know about it.
22:06drewolsonah, i see
22:07Chouserso I made a monitor agent to occasionally check all the other agents for any errors and print them to stdout
22:07Chouserof course if the monitor agent has an error....
22:08drewolsonmetamonitoring? heh
22:08Chouserbut 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:12drewolsoni took a quick look at the agents section on clojure.org, but i'm not groking the reduce in run
22:14Chousersorry, I'm not sure what you're talking about.
22:16drewolsonthere'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:16Chouserah, yeah. talk about dense...
22:18Chouserok, reduce there has 3 args, a fn, an initial value, and a seq
22:18drewolsonsure
22:19drewolsonoh i get it
22:19drewolson:)
22:19drewolsonnext is the last agent
22:19Chouserso the first time the fn is called, it's 'next' is the :report-queue agent and it's 'i' is 0
22:19drewolsonwhich becomes part of the state of the current agent
22:19drewolsonwhich is returned
22:19drewolsonand then used for the next agent
22:19drewolsonand so on
22:19drewolsonyes?
22:19Chouserwell, if you get it, then can I stop trying? :-)
22:19drewolsonhaha
22:20drewolsoni'm still slightly confused how the range is involved
22:20drewolsonis that just providing something to iterate over?
22:20Chouseryes, the value of 'i' isn't used
22:20drewolsongotcha
22:20drewolsonis there an idiom in clojure to use, say _ when a param will not be used?
22:20Chouseryes
22:20drewolsongotcha
22:21Chouserthere, fixed.
22:22drewolsoncool :)
22:23Chousersurely Halloway's examples are easier to follow?
22:23drewolsonwell, they are more gradual
22:23drewolsonhowever i love to ponder these more real examples
22:24drewolsonwhen you finally get them it's quite gratifying
22:24Chouserah, true.
22:27freddy_dhi all
22:27Chouserhello
22:27freddy_danyone using Clojure in the workplace?
22:28Chouserthere was a interesting post to the group recently about a Clojure deployment.
22:28drewrfreddy_d: Almost every day.
22:29freddy_ddrewr: interesting. what kind of applications?
22:29drewolsondrewr: lucky. and nice name.
22:29drewrdrewolson: :-)
22:30drewrfreddy_d: Mostly back-end, data-mining types of things.
22:30freddy_ddrewr: cool.
22:31drewolsonChouser: 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:33drewolsonah, nvm. java.util.concurrent.SynchronousQueue is a blocking queue
22:33drewolsontricky, very tricky
22:33Chousergood eye -- I hadn't spotted that yet.
22:34drewolsonok, this all makes sense now. very interesting example.
22:40drewolsonthanks for the help, night all
23:17danlarkinJEEEEEZ it's cold outside
23:32arohnerdanlarkin: I know! It's like 50 outside!
23:32arohner:-p
23:35pjb3I was just looking through some of the code in contrib/sql and I
23:35pjb3have a question
23:36pjb3in do-commans
23:36pjb3do-commands
23:36pjb3it has this: (with-open [stmt (.createStatement (connection))]
23:36pjb3that means that connection must be a function that is being called, right?
23:36pjb3where does connection come from?
23:37pjb3ah, internal
23:37pjb3nevermind, didn't see that
23:39pjb3I suppose this was written before the introduction of defn- into the language?