#clojure log - Jun 08 2009

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

1:59 tbatchelli1: anyone knows if there is already a way how to convert a clojure map into a java map (for example a HashMap)?

2:04 hiredman: ,(import java.util.HashMap)

2:04 clojurebot: java.util.HashMap

2:04 hiredman: ,(import 'java.util.HashMap)

2:04 clojurebot: java.util.HashMap

2:04 hiredman: ,(HashMap.)

2:04 clojurebot: #<HashMap {}>

2:04 hiredman: ,(HashMap.{:a 1 :b 2})

2:04 clojurebot: #<HashMap {:b=2, :a=1}>

2:05 hiredman: ,(ancestors {})

2:05 clojurebot: nil

2:05 hiredman: ,(ancestors (class {}))

2:05 clojurebot: #{clojure.lang.Obj clojure.lang.Seqable java.util.Map clojure.lang.IPersistentMap clojure.lang.Associative java.io.Serializable clojure.lang.AFn clojure.lang.IMeta clojure.lang.Counted clojure.lang.IPersistentCollection clojure.lang.IObj java.util.concurrent.Callable java.lang.Iterable java.lang.Object clojure.lang.APersistentMap java.lang.Runnable clojure.lang.IFn}

2:09 tbatchelli1: hiredman: thanks. does that mean that I can call (. doSomethingWithMap javaObject (HashMap. {a:1 b:2})

2:11 hiredman: clojure maps are java Maps

2:12 clojure maps are java Maps, they just throw an exception if you try to mutate them

2:14 tbatchelli1: that's what I thought, but I can't seem to be able to pass a map as a parameter to a java method that expects one.... I'll try to figure out what's wrong with my code

2:20 hiredman: thanks! I figured the error in my code... :)

8:38 chouser: (defn searcher-path [#^IndexSearcher searcher]

8:38 (let [#^FSDirectory fsdir (.. searcher getIndexReader directory)

8:38 #^String path (.. fsdir getFile getPath)]

8:38 oh, dear

8:38 sorry.

9:17 ivan: anyone know where terraclojure went? github project seems to be deleted.

9:18 oh, maybe that was old

10:22 rhickey: Chouser: nice!: http://groups.google.com/group/clojure/browse_thread/thread/9d3215ed863f1586/0cb4cf7abf269740?show_docid=0cb4cf7abf269740

10:22 chouser: :-) thanks

10:22 it'll have to do until c-in-c is done.

10:23 rhickey: I'll have to look at the type-hint-of-host-call logic, if any

10:27 drewr: Ugh. I'm seeing more and more :use without :only. We need a PEP 8 for Clojure.

10:27 rhickey: PEP 8?

10:28 drewr: It's a style guide for Python that the community has rallied around.

10:28 rhickey: link?

10:28 drewr: http://www.python.org/dev/peps/pep-0008/

10:29 However, he doesn't seem to address "from foo import *" in that document.

10:30 It's strictly syntactical.

10:31 He does talk about writing confusing code, which :use could fall under.

10:32 rhickey: Chouser: so, it looks like there is no type hinting of host calls, nor perhaps should there be. They have defined return types. It seems to be a job for cast, just as in Java, but there is no way to convey the type from cast without compiler support, I think

10:32 chouser: I now use :use exclusively, and mix in :as and :only [] as needed to get the results I want.

10:33 stuartsierra: I use (:require ... :as ...) exclusively. Should I be using :use/:as instead?

10:34 drewr: You guys are missing my point. It's the naked use of :use that I'm complaining about.

10:34 rhickey: assigning to a typed local forces the cast, but isn't an option for a free expression

10:34 drewr: Symbols get imported into the local namespace that you have no idea where they came from.

10:34 chouser: rhickey: ok. It's a bit surprising for the type hint to be simply ignored in some cases... any chance we could have a warning when that happens?

10:34 stuartsierra: drewr: I agree.

10:35 rhickey: Chouser: I need to think about it

10:35 chouser: drewr: yes, I know, I just thought I'd mention my usage while we're in the vicinity of the topic. :-)

10:35 drewr: stuartsierra: Compojure does it like it has an addiction. I noticed this morning that incanter does too.

10:35 chouser: Ah, thanks. :-)

10:35 chouser: drewr: and I absolutely agree. naked :use is Not Good.

10:37 stuartsierra: :require doesn't let you do :only, which sometimes is a nice feature. And rather than have to shuffle forms between :require and :use as I adjust my usage, I just have one big ol' :us block

10:39 like the second example here: http://groups.google.com/group/clojure/msg/67f26c65bb1e2127

10:39 drewr: So perhaps something as detailed and pedantic as PEP8 isn't necessary, but maybe a short canonical reference that we can point to as "official" would help.

10:39 chouser: I remember that. Is that now in 1.0?

10:39 chouser: no, nothing was ever done

10:39 drewr: Ah, well I'm +1 I think.

10:40 chouser: there were a couple alternatives suggestioned in that thread with various amounts of backward-incompatibility

10:40 rhickey: A pep-8-like guide might make a nice page in the contrib wiki, authored by you more experienced folks, and hopefully resulting in at least consistency in contrib

10:41 danlarkin: hear hear!

10:42 rhickey: I volunteer to kibitz :)

10:42 chouser: maybe now that we're post-1.0 we can ditch :require and make :use disallow naked use (have to give an :as, :only, or I suppose :exclude)

10:44 rhickey: that seems a bit draconian

10:44 chouser: :-)

10:44 * rhickey says, having disallowed import *

10:45 drewr: :-)

10:45 chouser: It's a bargaining position. Make me an offer!

10:45 rhickey: I offer a wiki page for you guys to provide your best advice

10:46 drewr: I'll gladly contribute.

10:47 chouser: rhickey: but, but ... you didn't move! Are you sure you know how to bargain?

10:47 drewr: Do you have to be a project member to do so?

10:47 And does the autogeneration of the docs interfere with manually edited pages?

10:47 Doesn't look like it.

10:48 rhickey: drewr: you do need to be a member

11:17 chouser: wow

11:17 if you try to return nil from a proxy method has a primitive return type, you get a NullPointerException

11:18 I suppose that should have been obvious, but I just spent longer than I'd like to admit tracking that NPE down.

11:19 cemerick: yeah, i hit that one once before, too. Not sure what else it could do, though.

11:19 chouser: right

11:22 cemerick: naked :use absolutely has its uses, when you know what you're doing.

11:22 * chouser changes the double to a Double

11:22 chouser: cemerick: it's not a problem for *you*. It's a problem for *me* when I try to read your code.

11:23 cemerick: chouser: well see, that's my point -- I'd never use a naked :use in any ns I'd expose. However, when you control the codebase you're roping in, it's extraordinarily convenient.

11:24 chouser: cemerick: control and know intimitely

11:24 drewr: cemerick: I'm not in favor of banning it outright, but for anything intended to be use by others it really should be avoided.

11:24 And by "others" I mean you after you've slept. :-)

11:24 chouser: But even I wasn't suggesting banning it ... you'd still be able to say :exclude () if you really wanted to.

11:25 drewr: chouser: Ah, just a little added effort to make it explicit?

11:25 chouser: right, rather than the most succinct default.

11:30 cemerick: didn't the assert form used to take an optional string describing what was being asserted?

11:31 stuartsierra: cemerick: I don't think so. It was requested once.

11:52 chouser: (.schedule timer #(do-thing) 1000)

11:53 oops, TimerTask is a Runnable, but Runnable is not a TimerTask

11:53 (.schedule timer (proxy [TimerTask] [] (run [] (do-thing))) (long 1000))

11:53 *sigh*

11:54 hiredman: scheduledthreadpoolexecutor

11:54 chouser: hm

12:02 gah. I guess it's better.

12:03 it takes both Runnable and Callable, so I have to hint the closure.

12:03 (.schedule #^ScheduledThreadPoolExecutor e #^Runnable #(prn :hi) (long 500) TimeUnit/MILLISECONDS)

12:04 hiredman: correct

12:04 rhickey: do you need to hint e?

12:05 chouser: actually, that's interesting. If I don't hint e and also don't hint #(), I get a reflection warning but it works at runtime.

12:05 rhickey: right

12:05 chouser: If I hint e, I get a compile-time error unless I also hint #()

12:06 this is fast-path -- I'd rather hint.

12:07 this code base is making me wish for centrally-hinted struct-maps (or something similar)

12:10 cemerick: I remember rhickey speculating about a struct-map impl that generated a class that implemented APM, but stored the struct vals as raw java fields. Lots faster for those struct slots, and it'd have a distinct type.

12:11 rhickey: cemerick: we'll see what, if anything, struct-map needs post 'instance'

12:11 cemerick: that's something I plan on implementing eventually, if no one else gets to it before me :-)

12:11 I missed almost all of the irc chatter about 'instance', so I'm in the dark. Good luck searching the logs for 'instance', too :-)

12:11 * cemerick is looking forward to seeing it, tho

12:12 rhickey: Why Clojure over Scala?

12:12 I was asked

12:12 stuartsierra: Dynamic types, if that's your thing.

12:12 hiredman: clojurebot: what of scala?

12:12 clojurebot: "you can usually accomplish a lot by laboriously enumerating type arguments everywhere." -- seen in #scala

12:13 technomancy: because "it's better than Java" is not aiming high enough.

12:13 cemerick: technomancy: +1

12:13 technomancy: actually that's more like Groovy

12:13 cemerick: I was going to say, because onerous complexity is bad?

12:13 rhickey: here's what I have so far:

12:13 Clojure is really quite simple. It is dynamic. Having fewer paradigms to support, it is more focused on being functional. Being a Lisp, it has a regular syntax, and syntactic extensions are very consistent.

12:14 stuartsierra: good statr

12:15 rhickey: looking for anything missing from the perspective of people who've switched/ used both

12:15 hiredman: for scala being mixed paradigm, the community seems to be obsessed with complex type manipulation, like with haskell, clojure neatly side steps that

12:16 cemerick: rhickey: I'd amend "It is dynamic, but delivers java-native performance."

12:16 rhickey: cemerick: that's covered in another part of the interview

12:16 kotarak: which will be questioned immediately

12:17 * rhickey is being interviewed via email by Michael Swaine, one of my heroes from the DDJ days, for a new magazine

12:17 cemerick: kotarak: I think that's spot-on. I don't think scala has any unchecked math support at all (or, last I looked), so that's a clear differentiator. Besides that, they're likely on par.

12:19 Chousuke: I think syntactic abstraction is important. the "true" core language is very small, and the tools that are used to build the rest of Clojure are available to programmers as well, not just the language implementers.

12:19 rhickey: Chousuke: I think Scala fans think the same of Scala

12:20 hiredman: yeah, again, in #scala they gripe about the compiler and the emitted bytecode all the time

12:20 gnuvince: cemerick: I'd replace "delivers" with "sometimes delivers" or "may deliver"

12:20 Chousuke: With Clojure, you just get a neat java library for building your own languages. :)

12:21 kotarak: cemerick: ignore me ;) I'm just fed up by all the "perfomance issue" posts. "I have here this ugly, imperative micro-benchmark testing the wrong thing, Why is it too slow?"

12:21 I like Clojure's consistency. (swap! an-atom-with-a-map update-in [:foo :bar] conj some-thing)

12:22 cemerick: rhickey: I used scala semi-exclusively for 8 months or so prior to moving to clojure (almost a year ago!). Scala is simply too complex for me, and its core datastructures are (were?) bug-prone and difficult to extend.

12:22 * kotarak plays spot the pattern

12:25 technomancy: it might be worth mentioning that you can read through all of core.clj just a few months after learning Clojure without really getting too confused.

12:25 that's not true of very many languages

12:26 stuartsierra: true

12:26 hiredman: cemerick: do the scala collections interop with the java collections easily?

12:28 cemerick: of course, none of this matters. Scala or groovy will likely grow significantly, simply due to people writing Java in (Scala|Groovy), and enjoying the marginally-better compilers.

12:28 hiredman: yes, but last I knew, scala generics don't interop with java generics, so List[Foo] ends up just being List<Object> in java.

12:29 presumably, they've fixed that in a year's time.

12:29 stuartsierra: cemerick: that's true of Clojure too, isn't it?

12:30 cemerick: stuartsierra: to a far lesser extend, I suspect. Parens are enough of a distraction to dissuade people long enough to settle for what's comfortable, advantages be damned.

12:30 s/extend/extent

12:31 gnuvince: I think he was talking about the generics part

12:31 stuartsierra: yes

12:36 technomancy: stuartsierra: have you seen this? http://github.com/technomancy/clojure-http-client/tree/master

12:36 stuartsierra: no

12:37 technomancy: my fault for not announcing it on the mailing list, but I'm afraid we may have duplicated some effort.

12:38 stuartsierra: No harm, really.

12:39 I'm aiming in a slightly different direction. I want to make a completely asynchronous client, with all response information mediated through an API.

12:40 And, eventually, a servlet-wrapper that uses the same API.

12:40 technomancy: yeah, I guess that's not quite the same thing.

12:43 stuartsierra: I'm hoping to build several layers that can be used independently. http/connection.clj is the low-level client API, http/agent.clj is a higher level, then build a synchronous client on top of that.

12:43 technomancy: I could probably adapt my synchronous client to use your connection lib if it's any easier.

12:44 oh, you mean build a synchronous client on top of the agent one?

12:44 stuartsierra: That was my thought.

12:44 Or on top of the low-level lib, it doesn't really matter.

12:46 technomancy: well if you want some help with that just let me know.

12:46 stuartsierra: sure, will do. I just wanted to throw it out there so people could see what I was up to, it may be a couple of weeks before I have time to finish it.

12:48 * chillitom is in love with Clojure

12:48 stuartsierra: I like your url-encode and cookie fns, might borrow those. :-D

12:48 technomancy: no problem.

12:55 man... apt-get and java really do not mix, do they...

12:57 stuartsierra: Ubuntu isn't too bad with Java 6

12:58 technomancy: stuartsierra: right, for Java itself it's not bad, but for java libraries it gets wacky

12:58 stuartsierra: oh, yeah, I never use it for that :)

12:58 technomancy: services that don't start automatically, no shell scripts get installed. not a lot of fun to try to guess how it works.

13:01 first thing I see out of the box: "HTTP Status 500 - Severe errors in solr configuration"... yeah, I guess it's time to install from source.

13:02 stuartsierra: Or the packaged binaries. Solr's not that hard to configure, but it won't run out-of-the-box.

13:02 technomancy: not even the admin interface? hmm; maybe the instructions I have were out of date.

13:03 stuartsierra: I think you can run the "example" JAR, but nothing else.

13:04 you can't load new docs without changing the schema.xml

13:04 technomancy: "Severe errors" makes me think it's not just a "you haven't set it up to do anything yet" kind of problem.

13:04 but what do I know...

13:05 stuartsierra: It's probably just missing paths for the index, "solr.home", schema, etc.

13:06 technomancy: guess I'm used to debian providing sane defaults for that, but clearly their java packaging is of a different calibre

13:16 it was missing a dependency in its listing. rock. on.

13:17 stuartsierra: huh

13:22 rhickey: slides from lightning talk I gave on chunked seqs: http://groups.google.com/group/clojure/web/chunks.pdf

13:23 chouser: rhickey: re: scala -- I don't know if it's fair to mention, but #clojure is a much friendlier place to ask dumb questions than #scala

13:23 rhickey: Chouser: probably not, even if true :)

13:24 I'll write up some prose on chunked seqs and move the diagrams to a page on the site

13:25 chouser: also, much more of the "magic" in Clojure is contained. Refs seem magical, but only within dosync blocks; Persistent containers are magical in the properties they provide, but have simple clear behavior.

13:27 Contrast with scala's implicit conversions, for example, which can lure you into creating implicit magic hidden throughout your code

13:27 rhickey: Chouser: yeah, but tough to convey until you see them in action - for now subsumed by "simpler"

13:28 actually I didn't even say simpler, just that Clojure was simple

13:29 chouser: ok

13:30 I guess if someone gets into scala far enough that the thought occurs to them, "there must be a simpler way..." perhaps that will lead them here.

13:31 rhickey: I'm taking the Clojure over Scala and Clojure over Erlang questions as opportunities to highlight Clojure's strengths rather than direct comparisons

13:31 chouser: I wonder if I could find the comment that brought me here. I think it was by Rich on some blog or other. I think I had Clojure and Qi pages open side-by-side for a while, trying to decide which to dive into next.

13:32 rhickey: heh, always the high road, eh?

13:32 rhickey: Chouser: It has served us well, IMO

13:32 Cark: chunked seqs : kind of like cdr-coding isn't it ?

13:33 rhickey: Cark: not too much

13:33 the structure is sitting there already in the vectors and maps

13:33 Cark: i only see the pdf, do yo mean that one can access the underlying structure from client code ?

13:33 rhickey: its much more about seqs on them than it is about gaming lists

13:33 technomancy: being nice doesn't drive page hits quite as well as a good conflict though, so maybe after this we could set up a fistfight between Rich and Odersky?

13:34 hiredman: technomancy: some kind of concurrent fistfight

13:35 rhickey: Cark: yes, seqs on vectors can leverage the indexed structure they already have

13:36 search for Clojure in: http://blog.objectmentor.com/articles/2009/06/05/bay-area-scala-enthusiasts-base-meeting-whats-new-in-scala-2-8

13:36 Beyond 2.8

13:37 chouser: nice. gotta love open source.

13:38 Bagwell's containers aren't Persistent, though, are they?

13:38 rhickey: no

13:41 chouser: cgrand: fantastic. re: http://clj-me.blogspot.com/2009/06/linear-interpolation-and-sorted-map.html

13:42 rhickey: someone finally used subseq!

13:48 cgrand: chouser: thanks

13:57 Chousuke: heh, I had forgotten subseq exists.

13:57 judging from its docstring, it's pretty old.

13:57 (test (.. sc comparator (compare ek key)) 0) --- ???

13:58 wouldn't that be (sc ek key) nowadays :/

14:00 wait, I forgot the actual test. hmm.

14:29 cemerick: I keep meaning to apply that sorted-set-by patch to my local clojure -- then subseq would be *very* useful.

14:42 cgrand: cemerick: +1

14:42 mrsolo: little schemer, is it a good book?

14:42 technomancy: mrsolo: yes!

14:43 very good.

14:43 mrsolo: ok

14:43 is it only for beginners?

14:43 hoeck: cemerick: +1, waiting for (official) sortet-set-by to

14:43 technomancy: mrsolo: not at all

14:43 unless you define "beginner" as "haven't implemented a language yet" =)

14:43 hoeck: r/to/too

14:43 mrsolo: great

14:43 *buy* :-)

14:44 cemerick: hoeck: there's a patch out there already. I haven't looked at it, but regardless, it's not a complicated change at all.

14:44 mrsolo: how but the next two in the series?

14:44 gnuvince: mrsolo: it starts easy, but then at the end you're into CPS

14:44 * technomancy has the Seasoned, but hasn't started it yet

14:44 gnuvince: Ditto

14:44 I have *way* too many books on my shelf

14:45 mrsolo: nice... CPS is that oftenly used at all? it got mentioned from time to time

14:45 gnuvince: I haven't seen it used very often, but I don't know if that's because programmers don't know about it or because there are better alternatives.

14:47 Hun: the problem with cps is that you cannot use it in just part of your system

15:00 lisppaste8: cemerick pasted "key-paths -- is this available anywhere else already? I (unfortunately) implemented it before looking..." at http://paste.lisp.org/display/81548

15:07 hiredman: ~scala is also<reply>"we are completely screwed on ==." -- seen in #scala

15:07 clojurebot: Alles klar

15:08 cemerick: heh, was that recent?

15:08 hiredman: minutes ago

15:08 cemerick: I've long since stopped lurking on #scala

15:09 mib_dgk9yuyc: Is there a function to split a vector on the last item that matches a predicate? eg: (x [1 6 3 7 2] #(> 5 %1)) -> ([1 6 3] 7 [2])

15:15 Ok, here's an easier one - is there a better way to invert a predicate than #(not (pred %1))?

15:16 stuartsierra: (complement pred)

15:16 mib_dgk9yuyc: thanks. I was searching for "inverse".

15:17 I'm also looking for something like "index-of" - the index of an item in a vector that matches a predicate. Is there a built in function for that?

15:18 stuartsierra: check clojure.contrib.seq-utils.

15:18 tgevaert: you could use (first (filter pred seq))

15:19 lisppaste8: cemerick pasted "is-one-of? impl e.g. (is-one-of? String Integer Object) => true" at http://paste.lisp.org/display/81550

15:19 tgevaert: oops. that wouldn't return the index. nvm

15:19 mib_dgk9yuyc: ok, I'll look at contrib. I've been trying to learn the built-in stuff first, to avoid overloading my brain

15:20 hiredman: that would need a linear search anyway

15:20 chouser: I avoid using indexes whenever possible.

15:20 mib_dgk9yuyc: yeah, I get the feeling that looking for an index is a remenant of a non-functional mindset

15:21 kotarak: Getting rid of loops iterating through the index most of the time also gets rid of the index itself...

15:21 mib_dgk9yuyc: what I really want is to split into (part-before-the-match, matching-item, part-after-the-match), given a seqence and a predicate

15:22 stuartsierra: Ah, you want a slightly modified "partition".

15:22 mib_dgk9yuyc: Python's str.partition is my mental model for what I want

15:23 chouser: ,(split-with #(not= % 5) (range 10))

15:23 clojurebot: [(0 1 2 3 4) (5 6 7 8 9)]

15:23 chouser: almost but not quite...

15:23 hiredman: he seems to want vectors

15:23 stuartsierra: Try c.c.seq-utils/partition-by

15:29 ,(clojure.contrib.seq-utils/partition-by #(not= 5 %) (range 10))

15:29 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.seq-utils

15:29 stuartsierra: ,(require 'clojure.contrib.seq-utils)

15:29 clojurebot: nil

15:29 stuartsierra: ,(clojure.contrib.seq-utils/partition-by #(not= 5 %) (range 10))

15:29 clojurebot: ((0 1 2 3 4) (5) (6 7 8 9))

15:30 lisppaste8: kotarak pasted "py-partition w/ loop, some better way?" at http://paste.lisp.org/display/81551

15:30 kotarak: stuartsierra: what happens with two 5's?

15:31 is that desired?

15:31 chouser: cemerick: I'm pretty sure you don't need lazy-seq in your key-paths. mapcat's already sufficiently lazy.

15:31 stuartsierra: ,(clojure.contrib.seq-utils/partition-by #(not= 5 %) [1 2 3 5 5 7 8 9 5 9 10])

15:31 clojurebot: ((1 2 3) (5 5) (7 8 9) (5) (9 10))

15:31 cemerick: chouser: good point, thanks :-)

15:31 kotarak: mib_dgk9yuyc: How the above case defined?

15:32 tunde: Hello #clojure!

15:34 Hun: hello world!

15:34 chouser: cemerick: there's a bunch of tree stuff I hardly ever use, but I don't think any of it can do what you're doing.

15:35 ...short of a new zip type, which I think would end up being clumsy compared to what you've got.

15:35 hiredman: huh

15:36 chouser: "bunch" meaning: clojure.zip, tree-seq, contrib.walk

15:36 cemerick: yeah, I mucked with tree-seq for a bit before tossing off key-paths

15:37 I think I could have made it work, but it probably would have required a two-step process.

15:44 chouser: (map first (tree-seq #(map? (% 1)) #(for [[k v] (% 1)] [(conj (% 0) k) v]) [[] m]))

15:45 cemerick: so tree-seq can do it, but that doesn't mean it's better than what you've already got

15:46 cemerick: ah, I didn't think of doing it that way

15:48 mib_dgk9yuyc: is colojure-contrib only available through svn? there is nothing on the downloads page.

15:50 technomancy: mib_dgk9yuyc: yeah, you'll need to get it from source. there hasn't been an official release.

15:51 mib_dgk9yuyc: ok, so everyone works on the bleeding edge, I see - there are no tags, no stable version...?

15:51 chouser: it doesn't bleed very much

15:51 mib_dgk9yuyc: maybe you're not stabbing hard enough

15:51 :)

15:51 chouser: we "ought" to have a release that works with clojure 1.0.0, but nobody's done ityet.

15:52 asdfasfe: is clojure 1.0 out yet?

15:52 dnolen: yes

15:52 technomancy: mib_dgk9yuyc: that's part of the design of contrib; it's much looser than Clojure itself in terms of what goes in.

15:52 but I agree that releasing a Contrib 1.0 would be wise

15:53 ajuc: hello, I have stupid question

15:53 clojure is my first lisp so don't kill me

15:53 why this doesn't print anything : http://pastebin.com/m6a7a4bed

15:54 hiredman: I think you want when not while

15:54 gnuvince: ajuc: defn defines a function. You need to call it.

15:54 chouser: ajuc: It's probably just not flushing stdout

15:54 technomancy: ajuc: standard out doesn't flush unless a newline gets printed or you call flush

15:54 hiredman: chouser: oh

15:54 chouser: ajuc: try 'println' instead of 'pr'

15:55 ajuc: ah :)

15:55 ok, thanks

15:55 chouser: or 'prn' if you actually mean to be printing objects and not just strings.

15:55 ajuc: it's only test

15:55 but I've thought I don't understand something fundamental

15:56 hiredman: (doc while)

15:56 clojurebot: "([test & body]); Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become false/nil. Returns nil"

15:57 hiredman: so that code as the equiv of a while(true){} loop in it

15:57 ajuc: yes, I wanted that to test some threading

15:58 now it works

16:11 mib_dgk9yuyc: ,(first [1 2 3])

16:11 clojurebot: 1

16:11 mib_dgk9yuyc: cool

16:11 just testing

16:11 clojurebot really is a bot

16:12 hiredman: clojurebot: are you a bot?

16:12 clojurebot: No entiendo

16:12 technomancy: yeah, hiredman hasn't added in the turing test module yet

16:12 hiredman: clojurebot: are you a computer program?

16:12 clojurebot: No entiendo

16:12 hiredman: hmmm

16:13 tgevaert: how does it avoid running infinite loops?

16:13 hiredman: with style and grace

16:13 mib_dgk9yuyc: why does clojurebot respond to ",(" instead of "~(" - this ain't common lisp!

16:13 technomancy: ~ is used for something else IIRC

16:13 clojurebot: for is not a loop

16:14 kotarak: mib_dgk9yuyc: clojure is not common lisp...

16:15 hiredman: mib_dgk9yuyc: , is whitespace, so it is nice for copy&paste stuff around

16:18 chouser: ,,,,,,,,5

16:18 clojurebot: 5

16:24 dnolen: interesting, Grand Central Dispatch in the next version of OS X reminds me of agents (Objective-C/C++/C on OS X will support anonymous functions and closures), http://images.apple.com/macosx/technology/docs/GrandCentral_TB_brief_20090608.pdf, curious to see what the concurrency Clojure gurus think of this. it's a slightly different approach to a lockless design than Clojure.

16:32 stuhood: hm... sounds like a threadpool

16:33 chouser: but outside the application? I wonder if there are security implications.

16:34 "simple extension to C" ...sigh.

16:34 technomancy: tee hee

16:37 chouser: huh. Doesn't look like they address state management at all. I wonder how it can help you avoid locks.

16:37 stuhood: being able to schedule based on io/timers looks handy though

16:38 chouser: I guess if any given piece of state is only changed via one particular queue, that can help.

16:39 oh, I guess they say that in "private queues" Not sure how that's easier than a lock, and it doesn't adderss the "hard" problems that clojure refs do.

16:42 stuhood: ah... yea, so the private queue is kindof like an agent

16:49 Chousuke: gcd sounds neat. Having the system manage a global thread pool for applications does sound simpler than each program managing its own threads.

16:51 at least, from the application's point of view :P

16:56 mib_dgk9yuyc: Is there some trick to using clojure-contrib that I should know about? (require 'clojure.contrib.seq-utils) doesn't work (FileNotFoundException)

16:56 I added clojure-contrib.jar to my classpath

16:56 and C:/clojure-contrib/src too

16:59 Chousuke: that ought to work.

16:59 technomancy: mib_dgk9yuyc: you didn't use add-classpath, did you?

17:00 mib_dgk9yuyc: no, didn't know about add-classpath

17:00 kotarak: mib_dgk9yuyc: then forget it again, as fast as you can. ;)

17:00 mib_dgk9yuyc: forget what? ;)

17:00 technomancy: mib_dgk9yuyc: so you restarted your JVM after changing the classpath?

17:00 duck1123: exactly

17:01 mib_dgk9yuyc: yes

17:01 should I be putting clojure-contrib.jar on the classpath, or the src directory, or both?

17:02 Chousuke: should work with either. :/

17:02 technomancy: mib_dgk9yuyc: the jar is probably better

17:02 mib_dgk9yuyc: maybe if you spelled out your exact steps?

17:05 mib_dgk9yuyc: C:\clojure>set CLASSPATH=C:\clojure-contrib\clojure-contrib.jar;%CLASSPATH%

17:05 C:\clojure>java -jar clojure-1.0.0.jar

17:05 user=> (require 'clojure.contrib.seq-utils)

17:05 technomancy: mib_dgk9yuyc: oh, if you use the -jar option, it ignores your CLASSPATH

17:05 kotarak: *meep* -jar

17:05 technomancy: woo! yay JVM!

17:06 mib_dgk9yuyc: oh, ok. so how do I run the repl?

17:06 technomancy: mib_dgk9yuyc: just put clojure.jar on the classpath and call: java clojure.main

17:06 the JVM has a lot going for it, but I've yet to see a platform with a worse command-line interface.

17:07 mib_dgk9yuyc: victory!

17:07 thanks

17:07 chouser: mib_dgk9yuyc: now go find who told you to use -jar and give them a stern talking-to.

17:08 mib_dgk9yuyc: one more noob question: is (System/exit 0) the normal way to get out of the repl?

17:08 chouser: mib_dgk9yuyc: try Ctrl-Z <Enter>

17:08 technomancy: chouser: then find the guys who implemented it and smack them around too for good measure!

17:08 * technomancy uses ctrl-d

17:08 chouser: technomancy: you must not be on Windows.

17:09 technomancy: oh, yes. that would be true.

17:09 duck1123: doesn't C-c also work?

17:09 * duck1123 always runs under slime, so it's not an issue

17:10 * chouser uses ^D as well.

17:10 kotarak: C-c is so hard and unfriendly to the process....

17:11 duck1123: ahh... so C-d shuts things down properly?

17:11 Chousuke: it just closes the input stream :p

17:11 kotarak: duck1123: C-d means "end of input".

17:11 Chousuke: most programs quit at that point :)

17:11 kotarak: yeah

17:11 Chousuke: but it might hang if you have a thread running.

17:12 kotarak: C-c is more like being thrown of the bus by the driver pointing a gun at you at the terminal station.

17:12 duck1123: actually, I've been using "mvn jetty:run" lately to start my server, so I have no choice but use C-c

17:22 so is there a way to make it so that the return values in the slime repl are pretty printed?

17:27 replaca: duck1123: I think there is, but I've never really tried to do it

17:28 duck1123: you should be able to set your repl's print function to pprint

17:28 duck1123: it's hard for me to do, since I'm often debugging the pretty printer :-)

17:29 * kotarak throws in (set! de.kotka.vimclojure.repl/*print-pretty* true) for VimClojure users.

17:29 replaca: oh, yeah, now that I think of it, slime may add a layer of indirection that would mess you up/help you

17:30 duck1123: I'm pretty sure it does

17:30 the slime repl isn't an actual clojure repl AFAIK

17:30 replaca: dnolen added the stuff that let macroexpansion pretty print, maybe he knows

17:32 dnolen_: heh, I just wanted slime to macroexpand properly, I never bothered with pretty printing repl output, and i'm no slime expert beyond how to use it ;)

17:33 replaca: I just always type (pp) to the repl, but that is not wholly satisfying

17:35 duck1123: cool, I didn't know about (pp) that'll be good enough I guess

17:36 dnolen_: (pprint some-expr), after you've run (use 'clojure.contrib.pprint)

17:38 duck1123: that's what I had been doing, and actually (pp) works fine. I don't want all of my output pretty printed, just the ones that are hard to read

17:38 technomancy: the main advantage of vimclojure over slime is that its author still uses it. =)

17:38 kotarak: technomancy: hehe :)

17:39 SLIME is certainly more advanced for Lisp in general, but VC does a good job for Clojure too. :)

17:41 duck1123: is there an easy way to convert a hash-map into a struct? (assuming I already have the struct set up)

17:41 kotarak: ... considering Vim's interprocess limitations, anyway.

17:42 (into (struct-map foo) my-hash-map) ?

17:46 duck1123: what I have is a vec of hash-maps that I'm turning into a vec of structs. Your code will return a struct of the first value, but if I try to do it in a map, I get an error

17:47 replaca: (pp) is really just (pprint *1) for the typing impaired (like me!)

17:47 duck1123: I would rather just get the structs back from the mysql server directly, but this is what clj-record gives mme

17:49 ok, i got it working no

17:57 technomancy: oh man. contrib's prxml is a lot nicer than clojure.xml.

17:59 duck1123: I'm still waiting for a good namespace-aware xml lib for clojure

18:00 technomancy: nobody uses namespaces anyway

18:00 clojurebot: namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it

18:01 technomancy: oh, I'm sorry, I misspelled understands.

18:02 duck1123: there are some times when you absolutely need ns-support

18:02 technomancy: yeah, I'm just kidding.

18:02 life's a lot nicer if you don't though. =)

18:06 mrsolo: is there another way to do this? (apply (partial format "%s%s") (map identity '("one" "two")))

18:07 identity is not real function of course.. so is list one, two...

18:08 kotarak: (apply format "%s%s" (map f [1 2 3]))

18:08 oops.

18:08 -3

18:41 mrsolo: is there a fucntion that does this? :foo -> "foo"?

18:41 dreish: ,(name :foo)

18:41 clojurebot: "foo"

18:41 mrsolo: ty

18:52 mib_t2h1qb: ,(dorun (repeat 1))

18:52 clojurebot: Execution Timed Out

20:58 emacsen: Is the JavaOne video available anywhere?

20:58 (was there video?)

22:06 duck1123: I so wish I could have gone to JavaOne

22:23 mrsolo: is there a fucntion that does this? (foo println) => "println"

22:24 Cark: ,(name 'println)

22:24 clojurebot: "println"

22:24 Cark: would that do ?

22:24 mrsolo: no quote

22:25 Cark: you might want to use a macro then

23:09 slava: my copy of programming clojure arrived today :)

23:10 cataska: slava: great !!

Logging service provided by n01se.net