#clojure logs

2009-06-08

01:59tbatchelli1anyone knows if there is already a way how to convert a clojure map into a java map (for example a HashMap)?
02:04hiredman,(import java.util.HashMap)
02:04clojurebotjava.util.HashMap
02:04hiredman,(import 'java.util.HashMap)
02:04clojurebotjava.util.HashMap
02:04hiredman,(HashMap.)
02:04clojurebot#<HashMap {}>
02:04hiredman,(HashMap.{:a 1 :b 2})
02:04clojurebot#<HashMap {:b=2, :a=1}>
02:05hiredman,(ancestors {})
02:05clojurebotnil
02:05hiredman,(ancestors (class {}))
02:05clojurebot#{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}
02:09tbatchelli1hiredman: thanks. does that mean that I can call (. doSomethingWithMap javaObject (HashMap. {a:1 b:2})
02:11hiredmanclojure maps are java Maps
02:12hiredmanclojure maps are java Maps, they just throw an exception if you try to mutate them
02:14tbatchelli1that'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
02:20tbatchelli1hiredman: thanks! I figured the error in my code... :)
08:38chouser(defn searcher-path [#^IndexSearcher searcher]
08:38chouser (let [#^FSDirectory fsdir (.. searcher getIndexReader directory)
08:38chouser #^String path (.. fsdir getFile getPath)]
08:38chouseroh, dear
08:38chousersorry.
09:17ivananyone know where terraclojure went? github project seems to be deleted.
09:18ivanoh, maybe that was old
10:22rhickeyChouser: nice!: http://groups.google.com/group/clojure/browse_thread/thread/9d3215ed863f1586/0cb4cf7abf269740?show_docid=0cb4cf7abf269740
10:22chouser:-) thanks
10:22chouserit'll have to do until c-in-c is done.
10:23rhickeyI'll have to look at the type-hint-of-host-call logic, if any
10:27drewrUgh. I'm seeing more and more :use without :only. We need a PEP 8 for Clojure.
10:27rhickeyPEP 8?
10:28drewrIt's a style guide for Python that the community has rallied around.
10:28rhickeylink?
10:28drewrhttp://www.python.org/dev/peps/pep-0008/
10:29drewrHowever, he doesn't seem to address "from foo import *" in that document.
10:30drewrIt's strictly syntactical.
10:31drewrHe does talk about writing confusing code, which :use could fall under.
10:32rhickeyChouser: 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:32chouserI now use :use exclusively, and mix in :as and :only [] as needed to get the results I want.
10:33stuartsierraI use (:require ... :as ...) exclusively. Should I be using :use/:as instead?
10:34drewrYou guys are missing my point. It's the naked use of :use that I'm complaining about.
10:34rhickeyassigning to a typed local forces the cast, but isn't an option for a free expression
10:34drewrSymbols get imported into the local namespace that you have no idea where they came from.
10:34chouserrhickey: 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:34stuartsierradrewr: I agree.
10:35rhickeyChouser: I need to think about it
10:35chouserdrewr: yes, I know, I just thought I'd mention my usage while we're in the vicinity of the topic. :-)
10:35drewrstuartsierra: Compojure does it like it has an addiction. I noticed this morning that incanter does too.
10:35drewrchouser: Ah, thanks. :-)
10:35chouserdrewr: and I absolutely agree. naked :use is Not Good.
10:37chouserstuartsierra: :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:39chouserlike the second example here: http://groups.google.com/group/clojure/msg/67f26c65bb1e2127
10:39drewrSo 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:39drewrchouser: I remember that. Is that now in 1.0?
10:39chouserno, nothing was ever done
10:39drewrAh, well I'm +1 I think.
10:40chouserthere were a couple alternatives suggestioned in that thread with various amounts of backward-incompatibility
10:40rhickeyA 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:41danlarkinhear hear!
10:42rhickeyI volunteer to kibitz :)
10:42chousermaybe 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:44rhickeythat seems a bit draconian
10:44chouser:-)
10:45drewr:-)
10:45chouserIt's a bargaining position. Make me an offer!
10:45rhickeyI offer a wiki page for you guys to provide your best advice
10:46drewrI'll gladly contribute.
10:47chouserrhickey: but, but ... you didn't move! Are you sure you know how to bargain?
10:47drewrDo you have to be a project member to do so?
10:47drewrAnd does the autogeneration of the docs interfere with manually edited pages?
10:47drewrDoesn't look like it.
10:48rhickeydrewr: you do need to be a member
11:17chouserwow
11:17chouserif you try to return nil from a proxy method has a primitive return type, you get a NullPointerException
11:18chouserI suppose that should have been obvious, but I just spent longer than I'd like to admit tracking that NPE down.
11:19cemerickyeah, i hit that one once before, too. Not sure what else it could do, though.
11:19chouserright
11:22cemericknaked :use absolutely has its uses, when you know what you're doing.
11:22chousercemerick: it's not a problem for *you*. It's a problem for *me* when I try to read your code.
11:23cemerickchouser: 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:24chousercemerick: control and know intimitely
11:24drewrcemerick: I'm not in favor of banning it outright, but for anything intended to be use by others it really should be avoided.
11:24drewrAnd by "others" I mean you after you've slept. :-)
11:24chouserBut even I wasn't suggesting banning it ... you'd still be able to say :exclude () if you really wanted to.
11:25drewrchouser: Ah, just a little added effort to make it explicit?
11:25chouserright, rather than the most succinct default.
11:30cemerickdidn't the assert form used to take an optional string describing what was being asserted?
11:31stuartsierracemerick: I don't think so. It was requested once.
11:52chouser(.schedule timer #(do-thing) 1000)
11:53chouseroops, TimerTask is a Runnable, but Runnable is not a TimerTask
11:53chouser(.schedule timer (proxy [TimerTask] [] (run [] (do-thing))) (long 1000))
11:53chouser*sigh*
11:54hiredmanscheduledthreadpoolexecutor
11:54chouserhm
12:02chousergah. I guess it's better.
12:03chouserit takes both Runnable and Callable, so I have to hint the closure.
12:03chouser(.schedule #^ScheduledThreadPoolExecutor e #^Runnable #(prn :hi) (long 500) TimeUnit/MILLISECONDS)
12:04hiredmancorrect
12:04rhickeydo you need to hint e?
12:05chouseractually, 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:05rhickeyright
12:05chouserIf I hint e, I get a compile-time error unless I also hint #()
12:06chouserthis is fast-path -- I'd rather hint.
12:07chouserthis code base is making me wish for centrally-hinted struct-maps (or something similar)
12:10cemerickI 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:11rhickeycemerick: we'll see what, if anything, struct-map needs post 'instance'
12:11cemerickthat's something I plan on implementing eventually, if no one else gets to it before me :-)
12:11cemerickI missed almost all of the irc chatter about 'instance', so I'm in the dark. Good luck searching the logs for 'instance', too :-)
12:12rhickeyWhy Clojure over Scala?
12:12rhickeyI was asked
12:12stuartsierraDynamic types, if that's your thing.
12:12hiredmanclojurebot: what of scala?
12:12clojurebot"you can usually accomplish a lot by laboriously enumerating type arguments everywhere." -- seen in #scala
12:13technomancybecause "it's better than Java" is not aiming high enough.
12:13cemericktechnomancy: +1
12:13technomancyactually that's more like Groovy
12:13cemerickI was going to say, because onerous complexity is bad?
12:13rhickeyhere's what I have so far:
12:13rhickeyClojure 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:14stuartsierragood statr
12:15rhickeylooking for anything missing from the perspective of people who've switched/ used both
12:15hiredmanfor scala being mixed paradigm, the community seems to be obsessed with complex type manipulation, like with haskell, clojure neatly side steps that
12:16cemerickrhickey: I'd amend "It is dynamic, but delivers java-native performance."
12:16rhickeycemerick: that's covered in another part of the interview
12:16kotarakwhich will be questioned immediately
12:17cemerickkotarak: 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:19ChousukeI 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:19rhickeyChousuke: I think Scala fans think the same of Scala
12:20hiredmanyeah, again, in #scala they gripe about the compiler and the emitted bytecode all the time
12:20gnuvincecemerick: I'd replace "delivers" with "sometimes delivers" or "may deliver"
12:20ChousukeWith Clojure, you just get a neat java library for building your own languages. :)
12:21kotarakcemerick: 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:21kotarakI like Clojure's consistency. (swap! an-atom-with-a-map update-in [:foo :bar] conj some-thing)
12:22cemerickrhickey: 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:25technomancyit 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:25technomancythat's not true of very many languages
12:26stuartsierratrue
12:26hiredmancemerick: do the scala collections interop with the java collections easily?
12:28cemerickof 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:28cemerickhiredman: 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:29cemerickpresumably, they've fixed that in a year's time.
12:29stuartsierracemerick: that's true of Clojure too, isn't it?
12:30cemerickstuartsierra: 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:30cemericks/extend/extent
12:31gnuvinceI think he was talking about the generics part
12:31stuartsierrayes
12:36technomancystuartsierra: have you seen this? http://github.com/technomancy/clojure-http-client/tree/master
12:36stuartsierrano
12:37technomancymy fault for not announcing it on the mailing list, but I'm afraid we may have duplicated some effort.
12:38stuartsierraNo harm, really.
12:39stuartsierraI'm aiming in a slightly different direction. I want to make a completely asynchronous client, with all response information mediated through an API.
12:40stuartsierraAnd, eventually, a servlet-wrapper that uses the same API.
12:40technomancyyeah, I guess that's not quite the same thing.
12:43stuartsierraI'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:43technomancyI could probably adapt my synchronous client to use your connection lib if it's any easier.
12:44technomancyoh, you mean build a synchronous client on top of the agent one?
12:44stuartsierraThat was my thought.
12:44stuartsierraOr on top of the low-level lib, it doesn't really matter.
12:46technomancywell if you want some help with that just let me know.
12:46stuartsierrasure, 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:48stuartsierraI like your url-encode and cookie fns, might borrow those. :-D
12:48technomancyno problem.
12:55technomancyman... apt-get and java really do not mix, do they...
12:57stuartsierraUbuntu isn't too bad with Java 6
12:58technomancystuartsierra: right, for Java itself it's not bad, but for java libraries it gets wacky
12:58stuartsierraoh, yeah, I never use it for that :)
12:58technomancyservices that don't start automatically, no shell scripts get installed. not a lot of fun to try to guess how it works.
13:01technomancyfirst 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:02stuartsierraOr the packaged binaries. Solr's not that hard to configure, but it won't run out-of-the-box.
13:02technomancynot even the admin interface? hmm; maybe the instructions I have were out of date.
13:03stuartsierraI think you can run the "example" JAR, but nothing else.
13:04stuartsierrayou can't load new docs without changing the schema.xml
13:04technomancy"Severe errors" makes me think it's not just a "you haven't set it up to do anything yet" kind of problem.
13:04technomancybut what do I know...
13:05stuartsierraIt's probably just missing paths for the index, "solr.home", schema, etc.
13:06technomancyguess I'm used to debian providing sane defaults for that, but clearly their java packaging is of a different calibre
13:16technomancyit was missing a dependency in its listing. rock. on.
13:17stuartsierrahuh
13:22rhickeyslides from lightning talk I gave on chunked seqs: http://groups.google.com/group/clojure/web/chunks.pdf
13:23chouserrhickey: 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:23rhickeyChouser: probably not, even if true :)
13:24rhickeyI'll write up some prose on chunked seqs and move the diagrams to a page on the site
13:25chouseralso, 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:27chouserContrast with scala's implicit conversions, for example, which can lure you into creating implicit magic hidden throughout your code
13:27rhickeyChouser: yeah, but tough to convey until you see them in action - for now subsumed by "simpler"
13:28rhickeyactually I didn't even say simpler, just that Clojure was simple
13:29chouserok
13:30chouserI 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:31rhickeyI'm taking the Clojure over Scala and Clojure over Erlang questions as opportunities to highlight Clojure's strengths rather than direct comparisons
13:31chouserI 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:32chouserrhickey: heh, always the high road, eh?
13:32rhickeyChouser: It has served us well, IMO
13:32Carkchunked seqs : kind of like cdr-coding isn't it ?
13:33rhickeyCark: not too much
13:33rhickeythe structure is sitting there already in the vectors and maps
13:33Carki only see the pdf, do yo mean that one can access the underlying structure from client code ?
13:33rhickeyits much more about seqs on them than it is about gaming lists
13:33technomancybeing 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:34hiredmantechnomancy: some kind of concurrent fistfight
13:35rhickeyCark: yes, seqs on vectors can leverage the indexed structure they already have
13:36rhickeysearch for Clojure in: http://blog.objectmentor.com/articles/2009/06/05/bay-area-scala-enthusiasts-base-meeting-whats-new-in-scala-2-8
13:36rhickeyBeyond 2.8
13:37chousernice. gotta love open source.
13:38chouserBagwell's containers aren't Persistent, though, are they?
13:38rhickeyno
13:41chousercgrand: fantastic. re: http://clj-me.blogspot.com/2009/06/linear-interpolation-and-sorted-map.html
13:42rhickeysomeone finally used subseq!
13:48cgrandchouser: thanks
13:57Chousukeheh, I had forgotten subseq exists.
13:57Chousukejudging from its docstring, it's pretty old.
13:57Chousuke(test (.. sc comparator (compare ek key)) 0) --- ???
13:58Chousukewouldn't that be (sc ek key) nowadays :/
14:00Chousukewait, I forgot the actual test. hmm.
14:29cemerickI keep meaning to apply that sorted-set-by patch to my local clojure -- then subseq would be *very* useful.
14:42cgrandcemerick: +1
14:42mrsololittle schemer, is it a good book?
14:42technomancymrsolo: yes!
14:43technomancyvery good.
14:43mrsolook
14:43mrsolois it only for beginners?
14:43hoeckcemerick: +1, waiting for (official) sortet-set-by to
14:43technomancymrsolo: not at all
14:43technomancyunless you define "beginner" as "haven't implemented a language yet" =)
14:43hoeckr/to/too
14:43mrsologreat
14:43mrsolo*buy* :-)
14:44cemerickhoeck: there's a patch out there already. I haven't looked at it, but regardless, it's not a complicated change at all.
14:44mrsolohow but the next two in the series?
14:44gnuvincemrsolo: it starts easy, but then at the end you're into CPS
14:44gnuvinceDitto
14:44gnuvinceI have *way* too many books on my shelf
14:45mrsolonice... CPS is that oftenly used at all? it got mentioned from time to time
14:45gnuvinceI 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:47Hunthe problem with cps is that you cannot use it in just part of your system
15:00lisppaste8cemerick pasted "key-paths -- is this available anywhere else already? I (unfortunately) implemented it before looking..." at http://paste.lisp.org/display/81548
15:07hiredman~scala is also<reply>"we are completely screwed on ==." -- seen in #scala
15:07clojurebotAlles klar
15:08cemerickheh, was that recent?
15:08hiredmanminutes ago
15:08cemerickI've long since stopped lurking on #scala
15:09mib_dgk9yuycIs 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:15mib_dgk9yuycOk, here's an easier one - is there a better way to invert a predicate than #(not (pred %1))?
15:16stuartsierra(complement pred)
15:16mib_dgk9yuycthanks. I was searching for "inverse".
15:17mib_dgk9yuycI'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:18stuartsierracheck clojure.contrib.seq-utils.
15:18tgevaertyou could use (first (filter pred seq))
15:19lisppaste8cemerick pasted "is-one-of? impl e.g. (is-one-of? String Integer Object) => true" at http://paste.lisp.org/display/81550
15:19tgevaertoops. that wouldn't return the index. nvm
15:19mib_dgk9yuycok, I'll look at contrib. I've been trying to learn the built-in stuff first, to avoid overloading my brain
15:20hiredmanthat would need a linear search anyway
15:20chouserI avoid using indexes whenever possible.
15:20mib_dgk9yuycyeah, I get the feeling that looking for an index is a remenant of a non-functional mindset
15:21kotarakGetting rid of loops iterating through the index most of the time also gets rid of the index itself...
15:21mib_dgk9yuycwhat I really want is to split into (part-before-the-match, matching-item, part-after-the-match), given a seqence and a predicate
15:22stuartsierraAh, you want a slightly modified "partition".
15:22mib_dgk9yuycPython's str.partition is my mental model for what I want
15:23chouser,(split-with #(not= % 5) (range 10))
15:23clojurebot[(0 1 2 3 4) (5 6 7 8 9)]
15:23chouseralmost but not quite...
15:23hiredmanhe seems to want vectors
15:23stuartsierraTry c.c.seq-utils/partition-by
15:29stuartsierra,(clojure.contrib.seq-utils/partition-by #(not= 5 %) (range 10))
15:29clojurebotjava.lang.ClassNotFoundException: clojure.contrib.seq-utils
15:29stuartsierra,(require 'clojure.contrib.seq-utils)
15:29clojurebotnil
15:29stuartsierra,(clojure.contrib.seq-utils/partition-by #(not= 5 %) (range 10))
15:29clojurebot((0 1 2 3 4) (5) (6 7 8 9))
15:30lisppaste8kotarak pasted "py-partition w/ loop, some better way?" at http://paste.lisp.org/display/81551
15:30kotarakstuartsierra: what happens with two 5's?
15:31kotarakis that desired?
15:31chousercemerick: I'm pretty sure you don't need lazy-seq in your key-paths. mapcat's already sufficiently lazy.
15:31stuartsierra,(clojure.contrib.seq-utils/partition-by #(not= 5 %) [1 2 3 5 5 7 8 9 5 9 10])
15:31clojurebot((1 2 3) (5 5) (7 8 9) (5) (9 10))
15:31cemerickchouser: good point, thanks :-)
15:31kotarakmib_dgk9yuyc: How the above case defined?
15:32tundeHello #clojure!
15:34Hunhello world!
15:34chousercemerick: 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:35chouser...short of a new zip type, which I think would end up being clumsy compared to what you've got.
15:35hiredmanhuh
15:36chouser"bunch" meaning: clojure.zip, tree-seq, contrib.walk
15:36cemerickyeah, I mucked with tree-seq for a bit before tossing off key-paths
15:37cemerickI think I could have made it work, but it probably would have required a two-step process.
15:44chouser(map first (tree-seq #(map? (% 1)) #(for [[k v] (% 1)] [(conj (% 0) k) v]) [[] m]))
15:45chousercemerick: so tree-seq can do it, but that doesn't mean it's better than what you've already got
15:46cemerickah, I didn't think of doing it that way
15:48mib_dgk9yuycis colojure-contrib only available through svn? there is nothing on the downloads page.
15:50technomancymib_dgk9yuyc: yeah, you'll need to get it from source. there hasn't been an official release.
15:51mib_dgk9yuycok, so everyone works on the bleeding edge, I see - there are no tags, no stable version...?
15:51chouserit doesn't bleed very much
15:51mib_dgk9yuycmaybe you're not stabbing hard enough
15:51mib_dgk9yuyc:)
15:51chouserwe "ought" to have a release that works with clojure 1.0.0, but nobody's done ityet.
15:52asdfasfeis clojure 1.0 out yet?
15:52dnolenyes
15:52technomancymib_dgk9yuyc: that's part of the design of contrib; it's much looser than Clojure itself in terms of what goes in.
15:52technomancybut I agree that releasing a Contrib 1.0 would be wise
15:53ajuchello, I have stupid question
15:53ajucclojure is my first lisp so don't kill me
15:53ajucwhy this doesn't print anything : http://pastebin.com/m6a7a4bed
15:54hiredmanI think you want when not while
15:54gnuvinceajuc: defn defines a function. You need to call it.
15:54chouserajuc: It's probably just not flushing stdout
15:54technomancyajuc: standard out doesn't flush unless a newline gets printed or you call flush
15:54hiredmanchouser: oh
15:54chouserajuc: try 'println' instead of 'pr'
15:55ajucah :)
15:55ajucok, thanks
15:55chouseror 'prn' if you actually mean to be printing objects and not just strings.
15:55ajucit's only test
15:55ajucbut I've thought I don't understand something fundamental
15:56hiredman(doc while)
15:56clojurebot"([test & body]); Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become false/nil. Returns nil"
15:57hiredmanso that code as the equiv of a while(true){} loop in it
15:57ajucyes, I wanted that to test some threading
15:58ajucnow it works
16:11mib_dgk9yuyc,(first [1 2 3])
16:11clojurebot1
16:11mib_dgk9yuyccool
16:11mib_dgk9yuycjust testing
16:11mib_dgk9yuycclojurebot really is a bot
16:12hiredmanclojurebot: are you a bot?
16:12clojurebotNo entiendo
16:12technomancyyeah, hiredman hasn't added in the turing test module yet
16:12hiredmanclojurebot: are you a computer program?
16:12clojurebotNo entiendo
16:12hiredmanhmmm
16:13tgevaerthow does it avoid running infinite loops?
16:13hiredmanwith style and grace
16:13mib_dgk9yuycwhy does clojurebot respond to ",(" instead of "~(" - this ain't common lisp!
16:13technomancy~ is used for something else IIRC
16:13clojurebotfor is not a loop
16:14kotarakmib_dgk9yuyc: clojure is not common lisp...
16:15hiredmanmib_dgk9yuyc: , is whitespace, so it is nice for copy&paste stuff around
16:18chouser,,,,,,,,5
16:18clojurebot5
16:24dnoleninteresting, 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:32stuhoodhm... sounds like a threadpool
16:33chouserbut outside the application? I wonder if there are security implications.
16:34chouser"simple extension to C" ...sigh.
16:34technomancytee hee
16:37chouserhuh. Doesn't look like they address state management at all. I wonder how it can help you avoid locks.
16:37stuhoodbeing able to schedule based on io/timers looks handy though
16:38chouserI guess if any given piece of state is only changed via one particular queue, that can help.
16:39chouseroh, 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:42stuhoodah... yea, so the private queue is kindof like an agent
16:49Chousukegcd sounds neat. Having the system manage a global thread pool for applications does sound simpler than each program managing its own threads.
16:51Chousukeat least, from the application's point of view :P
16:56mib_dgk9yuycIs there some trick to using clojure-contrib that I should know about? (require 'clojure.contrib.seq-utils) doesn't work (FileNotFoundException)
16:56mib_dgk9yuycI added clojure-contrib.jar to my classpath
16:56mib_dgk9yuycand C:/clojure-contrib/src too
16:59Chousukethat ought to work.
16:59technomancymib_dgk9yuyc: you didn't use add-classpath, did you?
17:00mib_dgk9yuycno, didn't know about add-classpath
17:00kotarakmib_dgk9yuyc: then forget it again, as fast as you can. ;)
17:00mib_dgk9yuycforget what? ;)
17:00technomancymib_dgk9yuyc: so you restarted your JVM after changing the classpath?
17:00duck1123exactly
17:01mib_dgk9yuycyes
17:01mib_dgk9yuycshould I be putting clojure-contrib.jar on the classpath, or the src directory, or both?
17:02Chousukeshould work with either. :/
17:02technomancymib_dgk9yuyc: the jar is probably better
17:02technomancymib_dgk9yuyc: maybe if you spelled out your exact steps?
17:05mib_dgk9yuycC:\clojure>set CLASSPATH=C:\clojure-contrib\clojure-contrib.jar;%CLASSPATH%
17:05mib_dgk9yuycC:\clojure>java -jar clojure-1.0.0.jar
17:05mib_dgk9yuycuser=> (require 'clojure.contrib.seq-utils)
17:05technomancymib_dgk9yuyc: oh, if you use the -jar option, it ignores your CLASSPATH
17:05kotarak*meep* -jar
17:05technomancywoo! yay JVM!
17:06mib_dgk9yuycoh, ok. so how do I run the repl?
17:06technomancymib_dgk9yuyc: just put clojure.jar on the classpath and call: java clojure.main
17:06technomancythe JVM has a lot going for it, but I've yet to see a platform with a worse command-line interface.
17:07mib_dgk9yuycvictory!
17:07mib_dgk9yuycthanks
17:07chousermib_dgk9yuyc: now go find who told you to use -jar and give them a stern talking-to.
17:08mib_dgk9yuycone more noob question: is (System/exit 0) the normal way to get out of the repl?
17:08chousermib_dgk9yuyc: try Ctrl-Z <Enter>
17:08technomancychouser: then find the guys who implemented it and smack them around too for good measure!
17:08chousertechnomancy: you must not be on Windows.
17:09technomancyoh, yes. that would be true.
17:09duck1123doesn't C-c also work?
17:10kotarakC-c is so hard and unfriendly to the process....
17:11duck1123ahh... so C-d shuts things down properly?
17:11Chousukeit just closes the input stream :p
17:11kotarakduck1123: C-d means "end of input".
17:11Chousukemost programs quit at that point :)
17:11kotarakyeah
17:11Chousukebut it might hang if you have a thread running.
17:12kotarakC-c is more like being thrown of the bus by the driver pointing a gun at you at the terminal station.
17:12duck1123actually, I've been using "mvn jetty:run" lately to start my server, so I have no choice but use C-c
17:22duck1123so is there a way to make it so that the return values in the slime repl are pretty printed?
17:27replacaduck1123: I think there is, but I've never really tried to do it
17:28replacaduck1123: you should be able to set your repl's print function to pprint
17:28replacaduck1123: it's hard for me to do, since I'm often debugging the pretty printer :-)
17:29replacaoh, yeah, now that I think of it, slime may add a layer of indirection that would mess you up/help you
17:30duck1123I'm pretty sure it does
17:30duck1123the slime repl isn't an actual clojure repl AFAIK
17:30replacadnolen added the stuff that let macroexpansion pretty print, maybe he knows
17:32dnolen_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:33replacaI just always type (pp) to the repl, but that is not wholly satisfying
17:35duck1123cool, I didn't know about (pp) that'll be good enough I guess
17:36dnolen_(pprint some-expr), after you've run (use 'clojure.contrib.pprint)
17:38duck1123that'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:38technomancythe main advantage of vimclojure over slime is that its author still uses it. =)
17:38kotaraktechnomancy: hehe :)
17:39kotarakSLIME is certainly more advanced for Lisp in general, but VC does a good job for Clojure too. :)
17:41duck1123is there an easy way to convert a hash-map into a struct? (assuming I already have the struct set up)
17:41kotarak... considering Vim's interprocess limitations, anyway.
17:42kotarak(into (struct-map foo) my-hash-map) ?
17:46duck1123what 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:47replaca(pp) is really just (pprint *1) for the typing impaired (like me!)
17:47duck1123I would rather just get the structs back from the mysql server directly, but this is what clj-record gives mme
17:49duck1123ok, i got it working no
17:57technomancyoh man. contrib's prxml is a lot nicer than clojure.xml.
17:59duck1123I'm still waiting for a good namespace-aware xml lib for clojure
18:00technomancynobody uses namespaces anyway
18:00clojurebotnamespaces 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:01technomancyoh, I'm sorry, I misspelled understands.
18:02duck1123there are some times when you absolutely need ns-support
18:02technomancyyeah, I'm just kidding.
18:02technomancylife's a lot nicer if you don't though. =)
18:06mrsolois there another way to do this? (apply (partial format "%s%s") (map identity '("one" "two")))
18:07mrsoloidentity is not real function of course.. so is list one, two...
18:08kotarak(apply format "%s%s" (map f [1 2 3]))
18:08kotarakoops.
18:08kotarak-3
18:41mrsolois there a fucntion that does this? :foo -> "foo"?
18:41dreish,(name :foo)
18:41clojurebot"foo"
18:41mrsoloty
18:52mib_t2h1qb,(dorun (repeat 1))
18:52clojurebotExecution Timed Out
20:58emacsenIs the JavaOne video available anywhere?
20:58emacsen(was there video?)
22:06duck1123I so wish I could have gone to JavaOne
22:23mrsolois there a fucntion that does this? (foo println) => "println"
22:24Cark,(name 'println)
22:24clojurebot"println"
22:24Carkwould that do ?
22:24mrsolono quote
22:25Carkyou might want to use a macro then
23:09slavamy copy of programming clojure arrived today :)
23:10cataskaslava: great !!