#clojure logs

2009-01-20

00:04apage43technomancy: for text-adventury stuffs i usually represent everything as instances of a single object type, that can have a parent, sibling, and child, including players
00:05apage43so to give an item to a player you just attach it to a different node in the tree
00:06hiredmanbonus points because with trees you can use zippers
00:07technomancyapage43: huh; interesting. I'm keeping items and players in a different map on the room.
00:07apage43this is roughly how inform/infocom games work
00:09apage43this is the class, from an old text adventure sort of "engine" i threw together in java waay back
00:09apage43http://pastebin.com/m65d7b8e2
00:10durka42hiredman: is there an introduction to zippers somewhere?
00:10Carkthese mutual references might not be a best fit for clojure though
00:10apage43possibly not
00:10apage43but a similar datastructure perhaps
00:12technomancyI suppose I can see why you'd want a uniform interface for putting something in your inventory as you would putting a person in a room, but... I'm not sure it makes a big difference.
00:12technomancyin the clojure case it's all just altering refs anyway
00:12apage43yeah
00:12apage43in java it was really nice to be able to just be
00:13apage43object.moveTo(player);
00:13apage43and player.children(); worked to get the player's immediate inventory, and you could list the contents of containers with the same function
00:14apage43really useful when you don't have nice things like multimethods
00:20hiredmandurka42: zip.clj is pretty good :P
00:21technomancyhrm... I wonder how I can perform cleanup when a player disconnects
00:22technomancyprobably just need to catch the right exceptions from my main loop
00:22technomancywhich means I should read up on Java exceptions
00:24technomancydo you get a SocketException when you try to read from a stream that's connected to a socket which the client closed?
00:25apage43that or an ioexception..
00:29technomancyactually it looks like read-line might just return nil
00:29hiredmanon zippers? I looked at both and ended up with zip.clj
00:29hiredmanmainly because I don't speak haskell
00:30durka42i don't either
00:30durka42having tried and given up
00:31danlarkintechnomancy: regarding clean up: you can wait until rich's "scope" function lands in core :)
00:31technomancydanlarkin: how long is that going to be? =)
00:32danlarkinTBD
00:32danlarkin:)
00:32technomancydanlarkin: I don't see a thread on it yet
00:33danlarkintechnomancy: he brought it up on IRC earlier today (or was it yesterday... *sigh* you know it's bad when the days start to blend together)
00:33technomancysounds pretty bleeding-edge
00:33hiredmanlisppaste8: url?
00:33hiredmanhmmm
00:33hiredmanclojurebot: paste?
00:33clojurebotpaste is http://paste.lisp.org/new/clojure
00:34danlarkinhttp://paste.lisp.org/display/73838
00:34danlarkinthat's the url, although paste.lisp isn't responding for me
00:35durka42seems to be dead
00:35technomancyodd; it's usually pretty solid
00:37danlarkinany time a lisp site is having trouble my mind always goes back to that big post the reddit guys wrote up when they moved from whatever amalgam of lisp code they were running to web.py
00:41technomancyis there a "retry" for exception handling?
00:43durka42no, by the time the exception is caught the stack is unwinding and the context of the original throw is gone
00:43durka42so you can't go back to the place where the exception was thrown
00:44technomancyyou can't even go back to the place of the original "try" invocation?
00:44technomancyI know it's not like CL conditions, but you don't need the stack to pull that off.
00:44hiredman(fn a [] (try do some stuff (catch Ex e (a))))
00:45technomancyyou mean defn?
00:45hiredmandunno if that actually works
00:45hiredmanI am pretty sure I meant fn
00:46technomancyoh, you can refer to fns with an internal name?
00:46technomancywithout the y-combinator? =)
00:46hiredmanyeah
00:46hiredmanthat is what the "a" after fn is
00:46technomancyhandy!
00:46hiredman:)
00:46technomancyonly problem is... how will the CS students of the future learn how the y-combinator works then?
00:47technomancyrhickey is making this way too easy
00:47hiredmanthey will read it off that guy's tattoo
00:49technomancyoh snap! got bit by the map-is-lazy thing again.
00:49hiredmanclojurebot: map?
00:49clojurebotmap is *LAZY*
00:49technomancywhat's the way to force that? do-???
00:49technomancydoall?
00:49hiredmanthere are two ways
00:49hiredmandoall and dorun
00:49hiredmandepending if you want to keep the results
00:50technomancyah, so dorun doesn't keep head; yeah that's what I want
00:50technomancyit'd be nice if the docstrings of doall and dorun refered to each other
00:51technomancywoot; that did the trick
00:51technomancyhiredman: how many times a day do you think you ask clojurebot about map for the benefit of clueless folk like me? =)
00:52technomancyI think this is the second time you've done it for me alone.
00:54technomancyCark: your stuff gets dropped when you disconnect now, so the bunny will not disappear.
00:54technomancynow I need to add combat! but not tonight.
00:54hiredmantechnomancy: I just do it because I like the stars
00:54Carkah i was a bit concerned with the bunny i must confess =)
00:55technomancythe wildlife conservation league can rest easy
00:55Carkuntil you add combat i guess
00:56technomancydoh!
01:01danlarkinclojurebot: map?
01:01clojurebotmap is *LAZY*
01:01danlarkinyum
01:01danlarkinclojurebot: botsnack
01:01clojurebotthanks; that was delicious. (nom nom nom)
01:03technomancyis there any "pick a random element from this sequence" function?
01:03danlarkinAH GOD parser combinators I don't understand them!!
01:03danlarkinwhy can't they just be easier :)
01:03danlarkinor why can't joshua choi just come to my apartment and give me a little lesson
01:04hiredmanjava.util.Collections/shuffle
01:04hiredmantakes a List
01:04technomancybut not a seq?
01:04hiredman,(java.util.Collections/shuffle (java.util.List. [1 2 3 4]))
01:04clojurebotjava.lang.IllegalArgumentException: No matching ctor found
01:05hiredman,(java.util.Collections/shuffle (java.util.List. (seq [1 2 3 4])))
01:05clojurebotjava.lang.IllegalArgumentException: No matching ctor found
01:05hiredmanare you kidding me
01:05technomancy(my-vector (rand-int (count my-vector))) is ok too
01:05technomancybut (pick-rand my-vector) would be best
01:05technomancy(while we're being picky)
01:06hiredmanI had this written
01:06technomancyeven if shuffle worked, you'd still have to call first on it
01:06technomancywhich is only one call less than the above
01:07hiredman,(java.util.Collections/shuffle (java.util.LinkedList. [1 2 3 4]))
01:07clojurebotnil
01:08hiredmanoh, and it shuffles the linkedlist, it does not return a new shuffled list
01:08hiredmanhttp://github.com/hiredman/clojurebot/commit/f4a50054eff413f080ab2d1c164374a6a0697c1d
01:08technomancyhrm... I need to head off; battery is low.
01:08technomancythanks for the help
01:08hiredman1d6
01:08clojurebot3
01:08technomancylater!
01:09Cark,(let [l (java.util.ArrayList. (seq [1 2 3 4]))] (java.util.Collections/shuffle l) l)
01:09clojurebot#<ArrayList [2, 1, 4, 3]>
01:09hiredman^-
01:09Carkwould be better to make a clojure function i think
01:10hiredmanthere are where a few functional shuffles on the google group
01:10hiredmanbut I think Collections/shuffle out performs them
01:11Carkah could be
01:11Carkwas there a randomized merge-sort in th elot ?
01:12Cark*the lot
01:12hiredmannot sure, I did not pay that close attention because at the time I did not need shuffle
02:48Lau_of_DKMorning gents
03:04lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
03:39ecretanyone know when clojure-dev(eclipse plugin) will be released?
04:41erohtarhi - this is another newbie question
04:41erohtarwhat is the best way to bind vars to a value when sending to an agent?
04:42cgrandyou have to capture them before sending and rebind them inside the action fn
04:43erohtarcgrand you mean pass them as a parameter into the action fn?
04:44cgrandjust to be sure: by vars, you really mean Vars?
04:44cgrand(and not locals?)
04:44erohtaryes, Vars
04:47cgrandthen, yes, pass their current value as a parameter and rebind the var inside the fn or use a closure
04:47erohtarthanks a lot, that helped - 2 hours of aggravation just now
04:48erohtarbtw - is there some elegant way of doing this?
04:49lisppaste8cgrand pasted "vars capture with a closure" at http://paste.lisp.org/display/73911
04:50cgrandyou can turn this sample code into a macro
04:50erohtarcgrand: thank you so much
05:00lisppaste8cgrand annotated #73911 with "capture-and-send" at http://paste.lisp.org/display/73911#1
05:01lisppaste8cgrand annotated #73911 with "example" at http://paste.lisp.org/display/73911#2
07:06javehello
07:06cgrandhello
07:06Rayneshello
07:07javeI'm thinking about web development with clojure. has someone made bindings for tapestry or wicket?
07:07javeor cocoon?
07:15clowsi don't think so ... but there's a clojure webframework that someone's working on i think
07:15clowsor a few actually
07:15RaynesMy function is better than your function.
07:19clowsthough wicket bindings should be rather easy
08:37rhickeyChouser: nice blog entry
08:40rhickeyhttp://blog.n01se.net/?p=37
09:14Chouserrhickey: thanks
09:15FibIs On Lisp readable for someone with only a little knowledge of macros and none of Common Lisp?
09:16ChouserFib: yes
09:16FibCool, I'll check it out then :)
09:16rhickeyChouser: we didn't get to discuss scope/when-scope before, I didn't know how to interpret your 'wow', - wow that's cool or wow that's too much?
09:16Hunprepare to have your mind boggled
09:17cgrandchouser: I concur with rhickey: nice post. It's funny you experimented with Rhino too.
09:18Chouser"wow that's cool." I don't yet have a grasp on how/when the LFE stuff will be useful, but I can understand scope, and it looks good.
09:19rhickeyChouser: given scope (and safe streams, more on them soon), I find LFE hard to justify
09:20Chouserah, ok.
09:20Chouserback in a bit.
09:37gnuvinceChouser: nice post, though some details of your initial impressions of Clojure would've been nice.
09:38Lau_of_DKon n01se?
09:38gnuvinceyeah
09:39Lau_of_DKdanlarkin: Im eating my words :)
09:39danlarkinLau_of_DK: :-D
09:40gnuvinceChouser also seems more certain about dynamic and static typing than I am
09:40Lau_of_DKIf you check out ClojureQL, you'll see that we decided to move the compilation of statements into the backend, to accomodate some of the subtle, but significant differences in the various dbms
09:43Chousergnuvince: I don't know that I remember my initial impressions
09:43gnuvinceOK
09:47drewrChouser: "...because of it's clean object..." should be "its"
09:47ChouserI supppose I do remember my reaction to the sequences talk -- *so* excited.
09:47Chouserdrewr: indeed, thanks.
09:55gnuvinceMy big moment was "Holy shmoly, you can call *any* Java class with that thing?!"
09:55gnuvinceAnd like that, Clojure was the most practical Lisp ever built
10:02clojurebotsvn rev 1217; don't clear local closed over in catch/finally
10:11mco_hello everybody, I bought the clojure book and wanted to try the compojure example but it won't work. I've seen several posts about that issue but I'm not sure about the status of the code: should the current distribution work ?
10:18Chousermco_: I'm afraid I've not done anything with Compojure yet, so I don't know.
10:18ChouserBut I haven't heard anyone mention recently that it's broken or anything.
10:19ChouserIt's possible that a recent change to Compojure has made the example from the book outdated, I suppose.
10:24clowsI think there's a link to the clojure / clojure-contrib version he used in the book (somewhere in the introduction or so) that one should work
10:24mco_thanks for your answers !
10:24mco_but I downloaded a single package in which al the jars are present
10:25mco_okay maybe I missed a step
10:45danlei`what is the minimum java version to run clojure on? 1.5, right?
10:45Chouserdanlei`: I think that's right, yes.
10:45danlei`ok, thanks
10:47Chousukehm
10:47Chousukeshouldn't server_socket.clj in contrib close the socket if the server fn throws an exception? :/
11:49philscottedI'm trying to invoke a Clojure function from Java, and have so far been successful passing a StringReader with "my-fun-name" to Compile and casting to IFn. However, is there a better way to do this? I can find the class of the compiled function, but I'm not sure how to obtain an instance of it. Any ideas?
11:50philscottedI have the fields const_0,...,const_5 and applyToHelper in the function's class.
11:53cgrandphilscotted: in clojure.lang.RT use the static method var(String, String)
11:53Chouserare you trying to call into a Clojure namespace that has :gen-class and is already compiled? Or just trying to invoke functions in an uncompiled .clj file?
11:54philscottedI've compiled but haven't used gen-class. I need to check the documentation for that.
11:55Chouserwell, if you're trying to get transparent calling from Java, you'll have to go the gen-class route. But it's easier to just do as cgrand said, in which case you don't even need to compile the Clojure code.
11:56philscottedCool. I'll try that. Cheers guys.
11:59ppjtHi all
11:59ppjtCan anyone help confirm some odd behavior w/ pmap?
11:59ppjtTry (pmap inc (range 1000000))
12:00ppjtOut of Memory error?
12:11Chousukeindeed :/
12:21ppjtThanks, Chousuke. I get same with collections one item, too -- (pmap inc [0])
12:21ppjt(collections *of* one)
12:31technomancyif I def a var in the global root, is binding the only way to give it a thread-local value?
12:32danlarkin(doc with-local-vars)
12:32clojurebotvarbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to vars with per-thread bindings to the init-exprs. The symbols refer to the var objects themselves, and must be accessed with var-get and var-set; arglists ([name-vals-vec & body])
12:34technomancyok, for some reason I thought using set! would make a new thread-local binding, but that's obviously not the case
12:34technomancyseems intuitive, but I suppose that could cause some tough-to-catch errors? using binding is fine.
12:59stuarthallowayHi all. Is there a count-if equivalent in Clojure or contrib somewhere?
13:00StartsWithK(count (filter pred coll))
13:00stuarthallowayright, and trivial to compose (comp count filter)
13:01stuarthallowayjust didn't know if was actually composed and named anywhere
13:01StartsWithKi don't think it is
13:04ajustinjohnsonI have a LazyCons called data of PersistentStructMaps and want to create a PersistentArrayMap from that LazyCons that contains :key1 :key2 :key1 :key2... extracted from each PersistentStructMap.
13:05ajustinjohnsonI can't figure out how to do it though. I can do this...
13:05hiredmanwhy so concerned about the type of the hash?
13:05ajustinjohnson(map (fn [psm] [(:key1 psm) (:key2 psm)]) data)
13:05ajustinjohnsonbut that isn't quite what I want.
13:06hiredmanI'd look at for
13:06hiredman,(doc for)
13:06clojurebot"([seq-exprs expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by an optional filtering :when/:while expression (:when test or :while test), and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. (take 100 (for [x (range 100000000
13:06ajustinjohnsonhiredman: I'm getting db results using clojure-contrib and trying to convert the results to the correct form the dejcartes expects
13:07ajustinjohnsondejcartes is a wrapper around JFreeChart
13:07hiredmanand dejcartes needs those exact java types?
13:08ajustinjohnsonMaybe not exact types, but it expects a list of [string, num, string, num, string, num]
13:08ajustinjohnsonAnd I have db results stored in a list of structs
13:08hiredmanyou could use reduce
13:09hiredman,(reduce #(conj % (first %2) (second %2)) [] {:a 1 :b 2})
13:09clojurebot[:a 1 :b 2]
13:10ajustinjohnsonbeautiful
13:10ajustinjohnsonThat is what I needed
13:10ajustinjohnsonThank you
13:11hiredmannp
13:12jliIf I understand correctly, Clojure is composed of a bunch of Java code that implements all the data structures and the Lisp primitives, and then a bunch of Clojure code that implements the rest of Clojure?
13:15djkthxwhats the equivalent for MEMBER or FIND in clojure?
13:15djkthxtrying to find an element in a list
13:15drewrjli: Essentially, yes.
13:15drewrSome of bootstrapping is still just calls to Java though.
13:17technomancydjkthx: you can use first + filter since it's lazy
13:17gnuvinceyou could use some probably?
13:17gnuvince,(some #(= 'a %) '(b a c))
13:18clojurebottrue
13:19jliaww, what a cute bot.
13:22cgrand,(some #{'a} '(b a c))
13:22clojurebota
13:23Chouser,(apply concat {:a 1 :b 2})
13:23clojurebot(:a 1 :b 2)
13:23gnuvincecgrand: thanks
13:24gnuvinceI always forget the idioms with sets
13:25technomancysets are underrated
13:25cooldude127what's the clojure way to convert a string to an int?
13:25Chouser,(Integer. "123")
13:25clojurebot123
13:26Chouserthe clojure way is the java way. :-)
13:26cooldude127alright
13:26cooldude127i was hoping that wasn't the case
13:26ChouserWhy's that?
13:26cooldude127it feels dirty for some reason
13:26cooldude127i would have expected (int "123") to do it
13:27ChouserIt's okay to call into Java when it does what you want.
13:27ChouserNo need to feel dirty.
13:27cooldude127yeah i suppose
13:27technomancyI don't mind hitting Java when the API is relatively sane like that
13:27cooldude127lol
13:27technomancycooldude127: you can't complain till you try to do Date stuff. =)
13:27cooldude127lol
13:27clowsswing *cough*
13:28technomancy,(str (java.util.Date 2009 01 20))
13:28clojurebotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
13:28technomancy,(str (java.util.Date. 2009 01 20))
13:28clojurebot"Sat Feb 20 00:00:00 PST 3909"
13:28technomancycan you believe that?
13:28cooldude127does that say 3909 ?
13:28cooldude127WTF?
13:28technomancyyes.
13:28drewrRead the documentation.
13:29drewrOffset from the year 1900.
13:29technomancydrewr: I know how it works; I'm just using it as an example.
13:29drewrSorry, didn't read above.
13:29drewrYes, it's retarded.
13:29cooldude127that violates whatever principle that says do what i expect you to do
13:30technomancycooldude127: also months are offset from zero, but days are from one.
13:30cooldude127wtf java?
13:30technomancyin other words: don't use java.util.Date.
13:30cooldude127lol
13:30cooldude127is there a clojure date library?
13:30danlarkinwtf, that's exactly like the javascript date functions
13:30technomancycooldude127: if I end up needing it I may write something up and submit to clojure-contrib, but nobody has done that so far iirc
13:30karmazillaJava 7... :)
13:31technomancydanlarkin: apparently they took "make it look like Java" a bit too far. =\
13:31cooldude127lol
13:31cooldude127technomancy: i might write it just to give me something to do
13:31cooldude127i have no cool project to work on
13:33technomancythere's an alternate library called Joda Time that's supposed to be very good, but that's another jar you need to depend on; something that important belongs in contrib
13:33lisppaste8technomancy pasted "my simple date wrapper" at http://paste.lisp.org/display/73931
13:33technomancythat's what I've used so far
13:34cooldude127technomancy: what about using a simple map for dates along with a nice set of functions
13:35cooldude127say {:year 2009 :day 20 :month 1} for today
13:35cooldude127along with whatever other information
13:35cooldude127seems like the clojure way
13:35Hunfor saving stuff that's ok. for calculating it's bad
13:36Hundate management is hard
13:36cooldude127Hun: care to explain? my plan was to still rely on java's date stuff, but simply wrap it up and cover up all the awfulness
13:37Hunthat's ok. but don't try to do conversion and especially math with it yourself
13:37cooldude127Hun: yeah that doesn't sound fun. i'll delegate that stuff
13:37technomancyright; leap years (not to mention leap seconds) will drive you mad
13:38cooldude127technomancy: so i'll still use java dates to calculate, but the user of this library will only see friendly clojure structures and functions
13:38cooldude127that is my plan
13:38technomancysounds reasonable
13:39drewrWeird, stuff that shouldn't work actually does..
13:39drewr(make-date 2009 12 32)
13:39drewr#<Date Fri Jan 01 00:00:00 CST 2010>
13:39cooldude127lol
13:39technomancyyeah, it wraps around
13:39technomancynot sure what I think about that
13:39technomancyit makes stuff like next-date easy, but it could really drive you crazy.
13:40drewrThat was first thought. I thought you had a bug until I tried it.
13:40technomancyheh
13:41cooldude127omg haven't programmed clojure in awhile
13:42danlarkincooldude127: want to write a parser for me using joshua choi's fnparse? that's a nice project for you :)
13:42cooldude127danlarkin: maybe a bit much for me right now :)
13:42Chousertechnomancy: that lib is worth it for the docstrings alone
13:42cooldude127we'll see how this date library goes
13:43technomancyChouser: thanks. I had fun with it.
13:44technomancyit's my passive-aggressive way of fighting back.
13:46Chousukeany emacs gurus here? how can I bind a key so that it is equivalent to pressing esc? I know of global-set-key but I have no idea what "command" corresponds to esc :/
13:46cooldude127Chousuke: (kbd "ESC") should work
13:46cooldude127so do (global-set-key (kbd "ESC") 'my-fn)
13:47technomancyChousuke: yeah, ESC isn't a command
13:47technomancysounds like what you want is another meta key
13:47ChousukeI don't want to bind esc into a command. I want to make another key to behave as if it were esc.
13:47cooldude127 oh
13:47technomancyyou might need to do that in X (or whatever platform you're on)
13:48Chousukehmm :/
13:48technomancyChousuke: http://www.emacswiki.org/emacs/MovingTheMetaKey
13:48cooldude127ok date library: preferred order for year month day arguments?
13:49karmazillaISO
13:49technomancycooldude127: year month date is pretty hard to argue with. (order of decreasing significance)
13:49cooldude127is that the best one? increasing specificity?
13:49cooldude127k
13:49Chousuketechnomancy: Unfortunately that doesn't help as I run OS X
13:49cooldude127Chousuke: which emacs are you running?
13:49ChousukeAquamacs
13:50cooldude127Chousuke: check the docs for aquamacs, i know there is a way
13:50technomancyChousuke: maybe you can do it in System Preferences?
13:50technomancyare you trying to make caps-lock into meta?
13:50Chousukenah, I want ctrl-� (next to l in my layout) to be an additional esc
13:50cooldude127oh shit that might be too much
13:50ChousukeI have caps lock as ctrl
13:51cooldude127Chousuke: same here
13:51technomancyok good. =)
13:51technomancyyou'll go crazy without that
13:52gnuvinceI took advice from somebody who suggested I take a small performance penalty hit by using two hands to perform key chords
13:52gnuvinceby using the Ctrl key on the opposite end of the keyboard of the key I want to hit
13:53Chousukehmm... I thought about moving esc, but instead I guess I could somehow hack viper to change its mode when I hit ctrl-� instead
13:53technomancyso *that*'s what right-control is for. =)
13:53technomancyChousuke: that's pretty involved; might have better luck in #emacs
13:53cooldude127yeah they tend to be helpful
13:58jomaembedding code into html vs embedding html in code?
13:58Chouserneither! :-)
13:59jomathen what do you have?
13:59technomancyjoma: I really like the syntax compojure provides
13:59cooldude127i like a lot about compojure
13:59jomabut isnt that embedding html into code?
14:00cooldude127kind of
14:00Chouseressentially, yes, though it looks a little better than straight html
14:01Chouserjoma: here's another option: http://clj-me.blogspot.com/2009/01/enlive-yet-another-html-templating.html
14:01ChouserI haven't used that yet.
14:01technomancyI think my problem with compojure was that the first app I tried to build was too ambitious.
14:01technomancywill have to go back to that after I wrap up my MUD
14:01cooldude127technomancy: what does MUD stand for?
14:01technomancymulti-user dungeon; basically a multiplayer text adventure.
14:02cooldude127oh got it
14:02cooldude127awesome
14:02cooldude127cuz i think i saw your repo on github
14:02technomancyit's pretty silly, but it's a really simple app that still has some interesting concurrency opportunities.
14:02cooldude127true true
14:03cooldude127technomancy: benefit of using a map for dates: no need for functions for year, day, and month
14:03technomancyquite
14:04technomancyis clojure-contrib still on SVN?
14:05technomancylooks like it; hrm.
14:05Chouserno, the latest is on google code
14:05Chouseroh, sorry, yes, SVN
14:05technomancyhas that been working out OK?
14:05cooldude127oh shit, i just realized the date api from java that technomancy and i are using is deprecated since java 1.1
14:05cooldude127ew
14:06technomancyI guess SVN makes sense for core, but for contrib it seems like there'd be more benefit to using a DVCS.
14:06technomancycooldude127: oh yeah... and the one you're supposed to use takes an integer or something useless like that?
14:06karmazillacooldude127: the replacement is called Calendar, and it is also terrible
14:06cooldude127technomancy: or you use the damn calendar api
14:06Chousertechnomancy: I haven't noticed any problems
14:06technomancycooldude127: it's like a cherry on top.
14:07cooldude127i must investigate this bucket of yuck called Calendar
14:07Chousukehm
14:07technomancyChouser: well in a situation like that, "problems" generally amount to a lower level of community contributions, which would be hard to notice...
14:07ChousukeI found out viper actually has a configuration variable for this.
14:08Chousertechnomancy: ah, I see. yes, Rich was wondering aloud about that.
14:08Chousukebut apparently \C-� is not a valid escape...
14:08Chouserrecently
14:08technomancyChouser: encouraging that he's considering it.
14:09technomancyI know personally I'm much more likely to contribute in small ways if I can just fork and have at it rather than having to maintain a series of personal patches in "my space" and not be able to check in.
14:09cooldude127this calendar junk is awful, is there a REALLY compelling reason not to use the Date api even tho it's deprecated?
14:09technomancyof course I just end up using git-svn or the github mirror anyway, but it'd be nice if that were officially sanctioned.
14:09Chousertechnomancy: that's exactly what I do for my patches against clojure core.
14:10technomancycool
14:10Chousertechnomancy: I don't expect to get commit privs on clojure.core ever
14:11technomancyChouser: doesn't it make you a tiny bit nervous that rhickey is the only one with the keys? like if he got hit by a bus or something?
14:11technomancyI mean, it's fine for now, but in the long run I wonder about the sustainability.
14:11Chousertechnomancy: well, I'm nervous about rhickey getting hit by a bus, but not because of repo commit privs
14:11cooldude127lol
14:11technomancygood point. =)
14:12Chouserbut seriously, if he were to lose interest or the ability to work on clojure, the real loss would be the leadership and direction.
14:12technomancyright, but if that leadership were shared, the odds of survival would improve.
14:13technomancybut the bar for something like that is very, very high.
14:13Chouserit expect it would take less than a week for some sufficiently respected set of clojure community members to band together, put up a new "official" fork, web site, etc.
14:13Chousers/it expect/I expect/
14:13technomancyright. I just don't know of any other languages with a single committer.
14:13ChouserI'm not at all worried about that at the moment.
14:13technomancybut I guess it's not a big deal.
14:14technomancyI just don't think it will stay that way forever is all.
14:15technomancyhas anyone used the new server-socket lib? I'm wondering if it wouldn't be better if it bound *in* and *out* before handing off control in accept-fn?
14:16technomancyI guess it's technically more flexible to make the caller bind them, but it seems like that's definitely the most common case.
14:17gnuvinceIn Java, are the size of integer classes the same on all platforms and and operating systems?
14:18durka42there are 32-bit and 64-bit JVMs
14:18durka42i don't know if Integer changes...
14:18gnuvinceThat's what I'd like to know. Can I assume that Byte/SIZE will always return 8, no matter which platform?
14:18waltersInteger the class probably will, since pointers underlying it will increase to 64 bi
14:18cooldude127ok the Calendar api, despite being slightly strange in not using constructors much, is much saner than Date
14:18ChouserThe amount of memory the boxed objects consume is different, I believe, but I don't know about the range of values supported.
14:18technomancyman, if Byte changes size, you're screwed.
14:18waltersbut the *range* of int/Integer is always 32
14:19cemerickprimitives (including int/Integer) are constant, regardless of the jvm: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html
14:19durka42http://stackoverflow.com/questions/400477/on-a-64-bit-machine-is-the-size-of-an-int-in-java-32-bits-or-64-bits
14:20gnuvinceGreat
14:20gnuvinceThanks
14:31cooldude127well damn, time zones are gonna totally unpretty this date library
14:32technomancyI don't think there's a language out there that has pretty timezone handling.
14:32technomancyespecially when you start to think about... daylight savings</shudder>
14:32cooldude127technomancy: i don't think i can hide the timezone objects from java world in any decent way, so i guess it's best to just use them
14:33hiredman,(bean (Date.))
14:33clojurebot{:hours 11, :time 1232480118568, :minutes 35, :class java.util.Date, :timezoneOffset 480, :year 109, :day 2, :date 20, :month 0, :seconds 18}
14:34technomancy(doc bean)
14:34clojurebotTakes a Java object and returns a read-only implementation of the map abstraction based upon its JavaBean properties.; arglists ([x])
14:34hiredmancute, yes?
14:34technomancyhuh; nice
14:34cooldude127NO WAY
14:34cooldude127except i'm using calendars now, and they are not that pretty
14:36cooldude127but for the moment, i'm gonna do (bean) on timezone objects
14:38cooldude127on second thought, no i'm not, i'll just use IDs for timezones, they are readable and can be used to get the actual instance if necessary
14:40StartsWithKcooldude127: Have you tried http://joda-time.sourceforge.net/
14:41StartsWithKi haven't used it myself but it seen in mentioned couple of times
14:41cooldude127StartsWithK: i was writing this for the clojure-contrib, so i was trying not to rely on external java libs, unless that isn't a problem
14:41technomancyStartsWithK: this is something that would go in contrib, so it has to be based on stuff that ships with the JVM
14:42technomancyStartsWithK: also: your nick is a lie.
14:42cooldude127haha
14:42StartsWithKwhy repeat functionality of existing lib?
14:42StartsWithK:)
14:42technomancyStartsWithK: because people want to be able to work with dates without introducing another dependency
14:42cooldude127exactly
14:42StartsWithKhmm
14:43StartsWithKclojure contrib in another dependency
14:43StartsWithKalso mig layout has external dependency
14:43StartsWithKand it is in contrib
14:43technomancyright, but the assumption is that there's enough other stuff in contrib that folks would already be using it.
14:43technomancyfrom what I've read automated dependency management is still pretty lousy with clojure; it's maven or nothing.
14:44technomancyand for me, nothing wins; no contest. =)
14:44StartsWithKi use ivy, works without any trouble
14:44StartsWithKfor maven and custom ivy repositories
14:44technomancyhuh; will have to read up on that
14:45StartsWithKit works even for direct url dependencies
14:45StartsWithKit can be bootstraped inside ant build, so you dont need to include ivy.jar with your app
14:45technomancyoh; heh. you have to write XML? no thanks.
14:45hiredmanclojurebot: ties?
14:45clojurebotties is http://www.bitbucket.org/achimpassen/clojure-ties/wiki/Home
14:46technomancyties could be promising
14:46StartsWithKlike ties ivy can be used from your own app
14:46technomancyhasn't had any activity in a couple months though.
14:46StartsWithKbut why tie distribution of your app with your build system
14:58jomaanyone have a somewhat complicated webpage programmed in compojure they''d like to show?
14:58technomancyjoma: does it count if it doesn't work? =)
14:59technomancyjoma: you mean a full web app, or just some HTML generation?
15:00jomahtml-generation? just to see how to do some nice stuff with different columns
15:00jomaand get post
15:00technomancyjoma: the lisppaste bot seems to be down: http://paste.lisp.org/display/73936
15:01technomancyI think the lack of good example code is the biggest problem with compojure at this point.
15:01jomathanks ill have a look later
15:01hiredmanjoma: there is a series of blog posts http://ericlavigne.wordpress.com/2008/12/28/using-postgresql-with-compojure/
15:01technomancyluckily the mailing list is pretty responsive
15:01hiredmanwhere, uh, I think the guy builds a blog
15:01hiredmanI have not read them all, but they might be what you are looking for
15:02technomancythe time-honored Hello World of web apps. =)
15:08Lau_of_DKWhat are our tools of choice when it comes to producing graphs from Clojure?
15:08ChouserDejcartes was just announced
15:08hiredmanclojurebot: sicp is also http://web.mit.edu/alexmv/6.001/sicp.pdf
15:08clojurebotYou don't have to tell me twice.
15:09hiredmangoogle charts?
15:09technomancyooh; a PDF
15:09StartsWithKLau_of_DK: prefuse, visual library?
15:09technomancyprobably nicer than reading it with info; heh
15:10Lau_of_DKLooks of good hints, thanks guys
15:11Lau_of_DKOk, next question, anyone has some experience with this? http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html#nativeSQL(java.lang.String)
15:16technomancyhow long has github known how to highlight clojure source?
15:17hiredmanmonths?
15:26danlarkinit's not github per se, but pygments
15:26danlarkinthe highlighting library they use
15:27cooldude`for my date library, is it better to use keyword (:sunday :monday ...) or integers to represent days of the week?
15:28hiredmanintegers
15:28cooldude`hiredman: if so, starting from 1 or 0?
15:28Chousermy gut feeling is keywords.
15:29Chouseryou hardly ever do math with day-of-the-week, though you do it all the time with day-of-the-month
15:29cooldude`i started out with keywords, now i'm wondering if it's right
15:29hiredman0, of course
15:29durka42but then, which day do you start with
15:29hiredmanmonday
15:29Chouserthe mere existence of these questions is an indication of the answer, seems to me.
15:29Chousercooldude`: what made you wonder?
15:30cooldude`the java calendar library starts with sunday and indexes from 1 to 7
15:30cooldude`Chouser: the fact that i was writing maps to convert between what java uses and keywords
15:30cooldude`thought i'd wait and see if that was the right way to go
15:32cooldude`i think keywords are right, just because when i get a number from that, i don't have a clue what it means off-hand
15:33cooldude`I like that the expression (day-of-week (date)) evaluates to :tuesday
15:33gnuvinceIf I use a GPL3 lib in an application, must I put my work under the GPL3 as well or can I choose a more liberal license (e.g. MIT)
15:37danlarkingnuvince: depends on how you distribute
15:37danlarkingnuvince: it's not about use, it's about distribution
15:39gnuvincedanlarkin: not sure yet, but I'll want to open source it.
15:40danlarkinwell you can choose a more liberal license, but you can't distribute a GPL library with it, you'll have to require a separate install
15:41danlarkinthat is, require the user to install the GPL library themselves
15:42gnuvinceok
15:44cooldude`ok i'm ready for critiques of what i've got so far: http://gist.github.com/49656
15:54durka42should figure out how to test for zune-type bugs
15:54Lau_of_DKIs the author of dejcartes in here?
16:00Lau_of_DKIs there an idiomatic way of say (let [smallest-seq (smallest col1 col2)]) where smallest-seq would contains that of col1 and col2 where (count %) was the lowest value ?
16:02gnuvinceLau_of_DK: no, but least, least-by, greatest and greatest-by functions would be very helpful IMO considering that max and min work only with numbers.
16:05Lau_of_DKk, I'll cook something up
16:07Lau_of_DKuser> (<< [1 2 3] [1 2 3 4 5])
16:07Lau_of_DK[1 2 3]
16:07Lau_of_DKThat type of thing might come in handy
16:08ChouserI like the idea of least-by and greatest-by
16:08Chouser(least-by count [[1 2 3] [4 5]]) ==> [4 5]
16:08Lau_of_DKYou do ?
16:08erohtarhi there - does anyone know of a way to wait for all running agents (without access to the agent objects themselves) ?
16:09Chouserlike sort-by, but faster because it can be O(n)
16:09Lau_of_DKI still think << and >> as names are cool, then they could overload on arity to take an fn as optional
16:09Chousererohtar: 'await' works for agents launched by the current thread.
16:10Lau_of_DK(<< count [1 2 3] [4 5 6 7]) ?
16:10gnuvinceI strongly dislike << and >> for this purpose.
16:10Lau_of_DKgnuvince: Why?
16:10erohtarchouser: thanks! is there a way to get at the agents launched by the current thread?
16:10gnuvinceFirst because it's strongly associated in the Java world with bit shifting, but mostly because it doesn't convey what it does.
16:11gnuvinceleast-by is extremely "communicative"
16:11Lau_of_DKTrue - I get the bit-shifting bit, thats actually what I intuitively would think it did
16:12danlarkin-1 for << and >>
16:12Chousererohtar: I think I said that incorrectly, or at least it was wrong in my head. 'await' must be given the agents to wait for, and then it waits for the actions to those agents sent from the current thread.
16:12danlarkinbad names
16:13Chousererohtar: but no, I don't know of any way to get a list of all agents, expect to build such a list as you create them.
16:13erohtarchouser: ok - i understand. Unfortutely i dont have access to the agents themselves - they are launched from elsewhere in the computation
16:13erohtarchouser: ok, i will build the list of agents then
16:15ChouserUsually what I've done is to have some kind of semaphore that the main thread is blocking on, and when the last agent it done it releases that shared semaphore.
16:15Chouserrhickey seemed to suggest that's not a great way to do thing, but I don't think I understood his preferred solution.
16:20technomancydang; github mentioned my MUD on twitter, got a bunch of watchers. good thing I got it working this morning. =)
16:21gnuvincehehe
16:23shooverdoes anyone else wish the throw special form would also accept a string and just wrap it in an exception?
16:23technomancythat would be very nice.
16:23danlarkintechnomancy: github guys excited about clojure :)
16:23technomancydanlarkin: yeah; just noticed the compojure blog post. very nice.
16:24technomancyespecially considering it's only the 23rd-most-popular language on the site.
16:26technomancyheh; compojure is the most-forked clojure project with a grand total of ... 8
16:28technomancyso is lancet a project designed for real use, or is it for instructional purposes only?
16:30cooldude`what is lancet?
16:30technomancyit's the main example project from the book
16:30cooldude`oh
16:31technomancya build system layered on top of ant
16:31cooldude`http://github.com/stuarthalloway/lancet/tree/master
16:31cooldude`found it :)
16:31technomancyclojurebot: lancet
16:31clojurebotExcuse me?
16:32technomancyclojurebot: lancet is a build system that works with ant written as an example for the Programming Clojure book.
16:32clojurebotOk.
16:32stuarthallowaycooldude: it ain't ready for real world use, but if you want to make it so I will cheer you on
16:32cooldude`looks super cool
16:32technomancystuarthalloway: but it's designed to be more than just example code then?
16:32stuarthallowaytechnomancy: I don't think it has any crippling flaws...
16:32stuarthallowayit just isn't done yet
16:33stuarthallowayto be ready for prime time it would need a command line interface
16:33cooldude` i would be willing to work on that
16:33stuarthallowayand some way to get at Ant's sub-task-abstractions like paths
16:33cooldude`this sounds fun
16:33technomancygood to know. I'm in favour of anything that reduces amount of executable XML in the world.
16:33cooldude`lol agreed
16:33gnuvince:)
16:34stuarthallowayweavejester and I discussed it and he thought it had hit the point where purposeful wrappers for specific Ant bits was a better way forward than continuing to be totally general and reflective
16:34gnuvinceXML: Reinventing sexps since 1993
16:34stuarthallowaygnuvince: but bigger! Enterprise sexps! :-)
16:34technomancyI do feel like command-line interfaces are usually the weakest point of clojure projects.
16:34gnuvincewoohoo!
16:35technomancyI've given up and just said "launch it through slime" for my own stuff for the time being.
16:40danlarkinI'd like to see someone working with hashdot
16:40cooldude`stuarthalloway: it wouldn't even be a real problem to invoke from the repl except at the moment tasks can't be run more than once
16:40stuarthallowaycooldude: you can reset them
16:40cooldude`ok
16:40cooldude`good to know
16:41technomancydanlarkin: it's on my todo list, but I think for it to really get steam it requires .rpms and .debs and such, which require more C knowledge than I'm comfortable with.
16:43danlarkintechnomancy: it's chicken an egg :) no one will make packages unless people want them, and no one will make them unless people want them
16:44technomancysad but true.
16:45technomancyI sat down with the intention of creating a .deb file at one point, but the hoops you have to jump through are pretty daunting.
16:45technomancyespecially for a program that doesn't use autoconf or have a configure script =\
16:46danlarkingack
16:46danlarkinwell if it's simple enough not to need autotools then just write a 2 line Makefile
16:47technomancyI don't know... all the packaging tutorials have a lot of assumptions; as soon as you step outside them I'm lost.
16:47danlarkinmmhmm
16:47danlarkinI wouldn't fret too much over no packages
16:48danlarkinthere are no packages for clojure either
16:48technomancyright; submitting a hashdot profile for clojure would be useful regardless
16:51hiredmanxD
16:52hiredmanjava.util.BitSet
16:55technomancydanlarkin: if hashdot were to launch java with a classpath that referred to clojure-contrib even though clojure-contrib.jar didn't exist, would it cause problems?
16:55technomancyor are non-existent entries ignored?
16:57danlarkinjava -cp /does/not/exist.jar:clojure/src/clojure/trunk/clojure.jar clojure.lang.Repl
16:57danlarkinClojure
16:57danlarkinuser=>
16:57danlarkinanswer: ignored
16:57technomancycool
16:57danlarkindidn't know the answer myself :)
16:58technomancyI wonder if hashdot has the # character hardcoded as the comment marker
16:59technomancythat would be a shame
16:59danlarkinwell it's supposed to look like a shell script, I think is the idea
17:06technomancycertain CL implementations will actually let you start your file with # and treat it as a comment just to allow for shebang lines
17:06technomancyit's ugly, but it's nice to have the option.
17:07Chouser#! is a comment in clojure
17:07technomancyaha; nice to know!
17:07technomancywill have to teach clojure-mode.el about that. =) thanks for the heads up.
17:07Chousernp
17:13technomancywhat's the difference between the jvm's -cp argument and -Xbootclasspath?
17:15dudleyftechnomancy: Classes in the bootclasspath don't go through the jvm's bytecode verifier
17:15technomancyso don't use it unless there's a good reason?
17:15dudleyfSo it cuts down on startup time
17:16technomancyaha. would it be advantageous to use it for clojure.jar?
17:16technomancyit wouldn't make a difference for pure-clojure jars then
17:16Chousukeclojure.jar is probably not that big
17:16dudleyftechnomancy: Maybe, but yeah, I think you can run into some weird classloader problems
17:21Chousergnuvince_: thanks for subjecting my blog post to the reddit commenters. ;-)
17:23technomancyChouser: I just had to laugh at the last comment on your "My path to Clojure" post
17:23technomancy"really, the compiler is trying to help you. you ungrateful wretch."
17:23Chouserheh
17:24Chouserwell, he's perfectly correct, at least in theory. And I think I would have agreed with him before my Scala adventures.
17:25pjb3FYI: Clojure talk in Portland, OR JUG 9:30 EST streaming live tonight http://bit.ly/pjuglive
17:27danlarkinpjb3: cool!
17:27gnuvince_Chouser: happy to :)
17:28gnuvince_The static typing thing was the only part I disagreed with you, but I thought that it was very interesting nonetheless
17:28technomancythe compiler is great at helping you avoid a certain class of error, the problem is that you never make those kinds of mistakes in the first place. =)
17:28gnuvince_And if Jonathan "My book on Catalyst sucks" Rockway thinks it's fanoiery, then let him
17:29gnuvince_technomancy: not really true, but I don't think we want to go into a static vs dynamic flamewar
17:29ChouserI don't mind disagreement at all, and I'm trying very hard not to mind the "user error" and "fanboy" comments. I'll succeed, don't worry.
17:29technomancygnuvince: perhaps you and I make different kinds of mistakes. =)
17:30gnuvince_technomancy: perhaps we're familiar with different types of static typing too.
17:30gnuvince_I would agree that static typing in C or Java is much more an annoyance than an advantage
17:33technomancyyeah, one of these years I'll give haskell or OCaml a shot
17:34keithbHi, I'm trying to create an object with metadata. Can you tell me what I'm doing wrong?: http://pastie.org/366164
17:34stuarthallowaytechnomancy: I have really enjoyed working through Real World Haskell online
17:34gnuvince_Real World Haskell is a good starter
17:34gnuvince_And they don't just use the type system to be in your way
17:34Chouserkeithb: Strings don't support metadata
17:35gnuvince_They encode logic about the problem in the type system, thus making sure some invariants are enforced at compile time.
17:35Chouserkeithb: Clojure strings are just Java strings, so no special features like metadata
17:36keithbSo only an object that I can reasonably believe *not* to map to a plain Java object would support metadata?
17:36Chouserkeithb: try this instead, and it should work fine: (def k {:name "Keith"})
17:37Chousukeyou can attach metadata to the var itself too I guess.
17:37Chouseronly objects that implement clojure.lang.IMeta support metadata
17:37Chouser,(instance? clojure.lang.IMeta [])
17:37clojurebottrue
17:38Chousukebut that kind of use for metadata seems wrong.
17:38Chouser,(instance? clojure.lang.IMeta "")
17:38clojurebotfalse
17:38keithbYes, that worked. Is :name a special case that always resolves to the significant value (semantic value? or the value used to test equals) of any object, or is it just strings?
17:38Chousukekeith's sex is obviously data about keith, not data about keith's name :)
17:38Chouserkeithb: there's nothing special about :name, it's just a keyword like any other
17:39Chouserand probably equality-relevent data too, depending on your political views I suppose.
17:39keithbbut why is it that when I have repl evaluate k or k4, it returns "Keith"? Does it always return the first metadata value?
17:40Chousukeit returns the actual value.
17:40Chousukethe metadata is not shown unless you ask for it.
17:40Chouserif you do (def k {:name "Keith"}), then after that typing just k at the repl should print {:name "Keith"}
17:40keithbBut when I did: (def k { :name "Keith" }), "Keith" was considered the actual value. ???
17:41Chousukekeithb: the value of k in that case would be {:name "Keith"}
17:41Chousukekeithb: with no metadata
17:41gnuvince_user=> (def k (with-meta {:name "Keith"} {:source "REPL"}))
17:41gnuvince_#'user/k
17:41gnuvince_user=> k
17:41gnuvince_{:name "Keith"}
17:41gnuvince_user=> ^k
17:41gnuvince_{:source "REPL"}
17:42keithbYes, I'm sorry you're right. so is k then a map containing a single key/value pair?
17:42Chousukeyes.
17:42gnuvince_yes
17:43gnuvince_and the meta data of k is also a map with one key/value pair
17:43keithbGot it. Thanks, all.
17:43keithbThis IRC thing is great. I'm sitting in a bookstore cafe in Panama. ;)
17:44gnuvince_IRC is the best application of the Internet
17:44Chousergnuvince_: wow. just, wow. :-)
17:46gnuvince_Email, shemail (some words don't work with that expression...): I'd rather choose a channel with many people interacting live and talking about a specific subject any day of the week and twice on weekends
17:46keithbI think it would be "shmemail". ;)
17:48gnuvince_keithb: yes, you're right: http://en.wikipedia.org/wiki/Shm-reduplication
17:53AzmodanHow can I do modulo in Clojure?
17:53danlarkinAzmodan: rem
17:53AzmodanThanks
17:57AzmodanI'm trying to eliminate all non-multiples of 3 from a range. I figured I have to use filter. I know my predicate will use rem. I found partial. And I'm kinda stuck.
18:00Chouser,(interleave (range 1 30 3) (range 2 30 3))
18:00AzmodanIs "On Lisp" a good book to read to get into Clojure? And what should I keep in mind while reading it?
18:00clojurebot(1 2 4 5 7 8 10 11 13 14 16 17 19 20 22 23 25 26 28 29)
18:01clows,(filter #(zero? (rem % 3)) (range 1 30))
18:01clojurebot(3 6 9 12 15 18 21 24 27)
18:03ChousukeAzmodan: you should at least remember that things in clojure are supposed to be immutable. :)
18:04AzmodanOtherwise, are the idioms similar?
18:04Chousukethe macro system also looks almost identical to common lisp's, but the namespace qualifying behaviour of syntax-quote is an important difference.
18:05technomancydanlarkin: does this look like a reasonable setting for hashdot? java.class.path = .:../jars/clojure.jar:../jars/clojure-contrib.jar
18:05technomancy(not that you're a hashdot pro, but I just know next to nothing about the classpath)
18:05ChouserI found "on lisp" to be mostly useful in justifying s-expresions over c-like syntax, and for demonstrating the power of macros.
18:06technomancyAzmodan: On Lisp is mostly about macros... there's a lot more to Clojure than macros.
18:06technomancythough macros have the potential to be very confusing.
18:06danlarkintechnomancy: I've never even used hashdot, I just like the idea :) what's the deal with ../jars/ -- is that standard?
18:06technomancyanyway, it doesn't strike me as a good place to start unless you've already read through Programming Clojure and have put together a few sample apps.
18:06AzmodanWhat do you suggest I read then?
18:06technomancydanlarkin: well, I don't want to hardcode the full path
18:07hiredmanproject euler is a good starting point
18:07technomancydanlarkin: but even if I do, it breaks: HASHDOT ERROR: [2]: No such file or directory: /home/phil/src/mire/src:/home/phil/src/mire/jars/clojure.jar
18:07technomancydanlarkin: I guess it's probably hashdot making assumptions that the classpath will only be a single entry?
18:07AzmodanI completed my first Project Euler problem with Clojure :)
18:07hiredmanto just start writing code
18:08AzmodanThat went way faster than with Haskell :)
18:08danlei``azmodan: a few good free (common-)lisp books: successful lisp, gentle introduction to symbolic computation, practical common lisp
18:09danlarkintechnomancy: I hope it doesn't... that would be pretty lame... maybe it checks for .jars or something...
18:09technomancydanlarkin: ok, I'll check in with the author
18:09danlarkintechnomancy: .jar ending each path on the classpath I mean, *shrug*
18:09hiredmanman, if clojure was a real functional language, the complement of my base64 encode function would decode base64
18:10technomancyhiredman: maybe you should use a simpler encoding, like perhaps rot13. =)
18:10technomancydanlarkin: I think I've almost got it, as long as he's OK with my change to allow ; as a comment syntax
18:12AzmodanThanks for the advices. See you soon.
18:25technomancyis . on the classpath by default?
18:27technomancyis there a way to get the path of the file currently being eval'd?
18:37Chouserno
18:37Chouser*file*
18:39technomancyah; should have guessed that. thanks.
18:40technomancyhow about getting a directory from a filename?
18:40hiredman,(str *file*)
18:40clojurebot""
18:50clojurebotsvn rev 1218; added overloads for Atom.swap fix RT.nth for Lists to use count only for RandomAccess
18:51hiredmanclojurebot: botsnack
18:51clojurebotthanks; that was delicious. (nom nom nom)
18:52hiredmanjust keep it up
19:03technomancydanlarkin: sounds like it'll work fine once hashdot gets variable comment syntax, which is planned for Real Soon Now
19:08gnuvince_Wow
19:08gnuvince_Mega retard in the thread about Chouser's blog post
19:08gnuvince_http://www.reddit.com/r/programming/comments/7r2zu/my_path_to_clojure/c0762zp
19:11danlarkintechnomancy: hurrah!
19:13technomancywill be nice to be able to launch things without slime. =)
19:13technomancyand also to have reasonable ps output
19:30clojurebotsvn rev 1219; added methods/prefers for multimethod reflection
19:53joha1I have an application where one agent is setting up an XmlRpc server, while the rest of the program has a GUI. When I select close from the GUI I want to kill the XmlRpc agent, but it is stuck in a server.start() call which will never return. How can I kill this agent/thread?
19:55Chouserthe server.start() is waiting on a socket?
19:55Chouserblocking?
19:56joha1yes
19:57joha1it is a call to a Java library (redstone XmlRpc) so I don't control this call. I just want to kill the thread
19:58Chouseris there any way to give it a timeout, so that its thread can check the status of the GUI and loop around to wait some more?
19:58joha1will have to check the API docs
19:59joha1but the general question is if I can kill agents in Clojure
20:00technomancyonly Neo can kill agents.
20:00cooldude127lol
20:00technomancysorry
20:00cooldude127that was perfect
20:01joha1:)
20:01Chouserjoha1: when an agent is running, it's just using a regular java thread. My (admitedly weak) understanding is that Java discourages killing threads.
20:02joha1sometimes you have no choice - but I will see if I can work around my problem somehow
20:02Chouserhttp://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.html
20:06joha1it seems that the method I want is thread.interrupt(). Now, how to get the agent to send interrupt to its thread...
20:12meredyddIs there a reason you can't let System.exit() take care of things for you, joha1?
20:13joha1it kills the repl :(
20:13meredydd(or, equally, is there a reason you're not using Apache XML-RPC, which doesn't have this problem?)
20:15joha1apache xmlrpc is using reflection to bind xmlrpc tags to callback methods in an object. Demanding an object to declare callback functions doesn't seem to fit with FP. With redstone xmlrpc I can declare my own dispatch function instead
20:16joha1besides, I don't think it solves the problem. You still have a start method which blocks forever
20:16meredyddThe Apache libs don't require reflection; they just provide it as the default handler.
20:16meredyddclojurebot: pastebin
20:16clojurebotI don't understand.
20:16meredydddrat it. Where's the pastebin round here?
20:17Chouserlisppaste8: url
20:17lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
20:17Chouserour bots ignore each other
20:17joha1ok, you know better than me. Do you have the method names, or an example?
20:17lisppaste8meredydd pasted "apache xml-rpc wrapper" at http://paste.lisp.org/display/73958
20:18meredyddThat's the code I use to wrap Apache's XML-RPC implementation
20:18Chouserouch
20:18meredyddYeah, they really brought the ugly for v3.
20:18joha1great. ugly indeed, but thanks
20:19meredyddI can just picture it: "We inherited this wildly-popular project from its original developers, and it works just fine. But you know what it really needs? More abstract factories."
20:20meredydd(I wrap it as a servlet, so I can throw it to Jetty, as I'm writing Compojure apps. Using a real webserver is generally more scalable anyway, so I'd recommend keeping it that way, but if you really wanted to you could probably chuck that handler at the default WebServer)
20:21meredyddRemember, by the way, that XML-RPC structs coming in arrive as java Maps, and if you return a Clojure persistent hashmap it won't understand you
20:21meredyddso you'll want some kind of fixup on return
20:22joha1Yes, I've noticed that problem already
20:25lisppaste8meredydd annotated #73958 with "jmap" at http://paste.lisp.org/display/73958#1
20:25meredyddThat's the function I use.
20:25meredyddIt's not lazy, but in this case there's no point in making it lazy, so I didn't bother.
20:27meredydd(eurrgh. I'm rereading that code, and I was *crap* when I wrote it. Explicit loops rather than (doseq)? Ouch.)
20:29joha1hi there
20:30joha1I don't have time to do more now, but I'll keep the code for reference. thanks for the help
20:30meredyddjust making sure you'd seen the new annotation; save you rewriting that function too :)
20:30meredyddVery welcome. Should really think about submitting that to clojure-contrib, but I keep getting distracted.
20:31joha1no need to duplicate the effort. and i think submitting a good xmlrpc solution to contrib is a great idea
21:11clojurebotsvn rev 1220; Streams in progress - safe stream model
21:28AzmodanHow do I turn ratios into doubles?
21:28Chouser(float 1/2)
21:28Chouser,(double 2/3)
21:28clojurebot0.6666666666666666
21:29Chouseror use a float or double as any of the operands
21:29Chouser,(/ 2 3.0)
21:29clojurebot0.6666666666666666
21:30AzmodanNeat. Does it works as nicely for all type conversion? I was using Integer.parseInt and related for all my conversions.
21:31ChouserI think all Java primitive types have matching coersion functions
21:31Chouser,(char 33)
21:31clojurebot\!
21:31cooldude127but doesn't work for strings
21:31cooldude127,(int "5")
21:31clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character
21:32AzmodanI just found str, it seems very useful.
21:32danlarkinhttp://www.mogulus.com/pjug is on
21:33danlarkinclojure presentation
21:33Carkthere's no image !
21:34danlarkinI think he's still setting up
21:34danlarkinthere was image just earlier
21:35Chouserkilled my browser
21:36danlarkinyeah this is a cpu hog like nothing else
21:36danlarkinfans running full speed
21:37danlarkinoh, they're doing intros around the room I guess
21:49danlarkinHm. well the presentation has started, but the screen is still blank
21:49danlarkinoh spoke too soon!
21:49danlarkinvideo is on
21:53Carkhum is there any way to prevent the advertising showing up ?
22:01danlarkinI'm just listening
22:01danlarkinnot watching
22:01danlarkinbut when I was trying to watch they were _extremely_ annoying
22:02Carkyes =/
22:07danlarkinuh oh, the presenter's in trouble!
22:08danlarkinhe doesn't know the answer :)
22:08Carkhum there are locks though
22:20jlifor a project, I came up with a general design with distinct "pieces" manipulating data and passing data amongst themselves. I intended to implement this is Erlang, because the model seemed to fit very well. Could it be done just as well in Clojure, though?
22:21danlarkinthis presenter is giving out some misinformation...
22:22drewrdanlarkin: Do tell...
22:22Carkjli : clojure is not erlang, but you can go pretty darn close to it using agents
22:23jliCark, okay, thank you - I'll look into that :)
22:24jliI would just love to be able to use a Lisp. And I believe I'll have to use a Java library or two, so Clojure would be great
22:26Carkjli : clojure is great fun and very well integrated in the jvm, interacting with libraries is sometimes even easier using clojure than java, you will love it !
22:26jlieven if I end up using Erlang, I definitely intend on learning Clojure
22:27Carkclojure is still a bit of a moving target though
22:27Carkversion 1 not out yet
22:29Carki guess you can't beat erlang maturity that fast
22:29danleisome moving targets are worth aiming at :)
22:30Carkright, i just don't want to oversell it
22:40blbrownIs there a way to pass flags (like CASE_INSENITIVE) to the regex call if I use (re-pattern s)
22:41blbrownguess I could just create an instance of Pattern
22:42Carkthe re- functions are a thin wraper around the java regex stuff
22:42Carkso that's pretty much the same thing
22:45drewrblbrown: You can also do #"(?i)...." as your pattern.
22:46drewrThat flags it (at some performance cost, apparently).
22:47drewr,(re-seq #"(?i)(foo)" "fOo foo fOO f0o")
22:47clojurebot(["fOo" "fOo"] ["foo" "foo"] ["fOO" "fOO"])
22:47drewr,(re-find #"(?i)(foo)" "fOo foo fOO f0o")
22:47clojurebot["fOo" "fOo"]
22:48dreishNo need for the second pair of parens.
22:48dreish,(re-seq #"(?i)foo" "fOo foo fOO f0o")
22:48clojurebot("fOo" "foo" "fOO")
23:18ecretanyone know when clojure-dev(eclipse plugin) will be released?