#clojure logs

2009-05-04

00:00hiredman,(let [[a b c] '(1 2 3)] (vec a b c))
00:00clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$vec
00:00cadsverec, I think it would look more elegant as a let binding.. doing the destructing in the argument vector makes it look more messy, I feel
00:00hiredman,(let [[a b c] '(1 2 3)] (vector a b c))
00:00clojurebot[1 2 3]
00:00barkleyI know pattern matching
00:01barkleylike in F#
00:02barkleycan't really do pattern-matching in the channel
00:02barkleybut i understand
00:02barkleythat's why i always liked predicate-dispatch
00:02verec_cads, you can always introduce a "destructuring let" right after the argument, if that's the problem???
00:02barkleycan we meta functions with predicate-dispatch?
00:03cadswhat is predicate dispatch?
00:04barkleycads predicate-dispatch : you decorate a function with x < 10 then you dispatch on that
00:04verec_cads, predicate dispatch is a) not in clojure and b) not relevant to your destructuring problem ....
00:05barkleyprobably right
00:05barkleysorry verec_
00:05cadsverec, heh, I know
00:05barkleypredicate dispatch is cool though...actually cllojure already has it
00:05barkleyin a way....
00:06barkleywith it's built-in multi-dispatch on normal funcs
00:06cadsverec_: I was using destructing let before i moved the destructuring to the argument vector, where it looks messy and doesn't tell us what kind of structure we're working with unless we know the structure's keys
00:06cadsverec_: I think I'll move back to having a separate let, because that's neater
00:07verec_cads, in your ideal world, what would you have wished you had instead?
00:08barkleyverec_: don't you think multi-dispatch is a more natural dispatch then single dispatch?
00:08cadsI can't think of anything I'd want to be the general case for functions called on structs
00:08barkleyverec_: i never got your argument for single tree dispath
00:08danleicads: i don't see the problem ... if you prefer (defun foo [s] (let [bar (:baz s)] ...) to (defun foo [{bar :baz}] ...) just use it ... no?
00:09verec_cads, you wrote: "I've been thinking of using something more powerful than structmaps". What exactly were you thinking of?
00:11verec_barkley: I didn't make any argument in favor of either single or multi-dispatch. Not *me* :D
00:12cadswell I think I'd like to write instead of (defn grav [{a_m :mass a_p :pos} {b_m :mass b_p :pos}] (* a_m b_m (inverse-square a_p b_p))), perhaps something like (defmapfn grav [a b] (* a_m b_m (inverse-square a_p b_p))), where inside the body of the function we have special mappings for things like a_m or b_p, where x_y means (:y x)
00:13danleicads: sounds like symbol-macros
00:14verec_cads, you'd want something that does the "destructuring let" for you invisibly? Is that what you are saying?
00:14cadsyeah, it's duplication of my effort :D
00:15cadsI think danlei's right, I should just write this up as a macro to use in special cases
00:15danleicads: well, you could, for example write a macro which binds implicitly, if you like that kind of thing
00:15cadsbecause there are a lot of cases where I would want to bind things manually
00:16danleicads: but, without symbol macros, it would be the values of (:y x) evaluated, if you really want (:y x), you'd need symbol macros.
00:16cadsare symbol macros different than what we write with defmacro?
00:17danleicads: in your case, no. in cl, they're there if you for example want an expression bound to a symbol, which yould be a setf'able place ...
00:18danleicads: a symbol macro like foo for (:foo x) would be just the same as (:foo x), whereas binding it implicitly in a macro would ... well just bind the value of the form evaluated
00:20cadswell, my macro will need to take a argument vector, it will have to know which arguments are structmaps.
00:23cadsthen it creates a list of symbols by combining a map's parameter name with its key names, in order to create the bindings for the implicit symbols used in the body
00:25verec_cads, how often are you going to use it, since "there are a lot of cases where [you] would want to bind things manually" ?
00:25danleicads: an example of binding implicitly: (defmacro implicitly-bind-foo [[s] & body] `(let [~'x (:x ~s)] ~@body))
00:26danlei(implicitly-bind-foo [{:x 5}] x) => 5
00:27cadsdanlei that's very spiffy :D
00:28danleicads: many people don't like that kind of thing (it's, more or less) how aif, awhen, etc. are implemented
00:28danleicads: but you get the idea
00:30danlei(should have named it implicitly-bind-x)
00:32cadsin my macro, we'd have to tell the macro what kind of struct it's dealing with, or give it a list of keys to auto-bind
00:37cadseeew, I think I know a way... let (defstruct body :mass :pos), then (defmapfn [:body a :body b] (* a_mass b_mass (op a_pos b_pos))
00:37cadserr
00:37cadsthat was a premature enter
00:37cadsthat's never happened to me before, I swear!
00:40cads(defmapfn foo [:body a :body b] (* a_mass b_mass (op a_pos b_pos))) => (def foo (fn [a b] (let [{:pos a_pos :mass a_mass} a {:pos b_pos :mass b_mass} b] (* a_mass b_mass (op a_pos b_pos)))))
00:41cadsI dunno, I don't like the underscores
00:44cadsbut, hey, on the wider question, if I come up with something like I like and it modifies the language and adds some feature or changes some syntax, but it feels comfortable and works for me, should I still feel dirty?
00:57danleicads: does that help you? (defmacro implicitly-bind [[keys-to-bind s] & body] `(let [~@(mapcat (fn [key] (vector key (list (keyword (str key)) s))) keys-to-bind)] ~@body)) ... not really tested, and it's late over here
00:58danleicads: (implicitly-bind [[x y] {:x 5 :y 10 :z 100}] (vector x y)) => [5 10]
01:08cadshello again
01:09cadsI took a walk and came back and wanted to get back working on my project, not learning macros so
01:10cadsback in the editor, I was wondering if anyone knows of a syntax highlighting mode for clojure in gnome's Gedit?
01:10danleicads: you've seen what i last posted (implicitly-bind)?
01:10cadsyeah, that was good
01:11danleicads: you'd just have to make it take several structures, and you're set
01:57rlbhiredman: had to kill the process after about 45 minutes -- not sure if it's my code, java, or clojure, but that's far too long for a simple fs traversal.
01:58rlb(even if it's a decent number of files (~3 million))
02:44kotarak,(nth (iterate rest [1 2 3 4 5 6 6 7 8 9]) 3)
02:44clojurebot(4 5 6 6 7 8 9)
02:44kotarak,(nth-rest 3 [1 2 3 4 5 6 7 8 9])
02:44clojurebotjava.lang.Exception: Unable to resolve symbol: nth-rest in this context
02:44kotarak,(nth-next 3 [1 2 3 4 5 6 7 8 9])
02:44clojurebotjava.lang.Exception: Unable to resolve symbol: nth-next in this context
02:44kotarakhmm..
02:45kotarak,(nthnext 3 [1 2 3 4 5 6 7 8 9])
02:45clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
02:45hoeck,nthnext
02:45clojurebot#<core$nthnext__4400 clojure.core$nthnext__4400@11e51d0>
02:45kotarak,(nthnext [1 2 3 4 5 6 7 8 9] 3)
02:45clojurebot(4 5 6 7 8 9)
02:46kotarakSeems to be what unlink1 looked for .....
03:07danleij lisp
03:08kotarako caml?
03:08danlei=)
03:36AWizzArdMoiners
03:36kotarakMoin Moin
03:47unlink1Can I solicit style feedback on this implementation http://paste.lisp.org/display/79626 ?
03:47unlink1Usage is like: (println (rpn "1 2 3 + - 2 *"))
03:57AWizzArdI find it okay. Only comments are missing, but else the code looks nice.
03:59AWizzArdcomments ==> doc strings
03:59AWizzArdcomments are not needed
04:02unlink1I'd ideally like some more concise way to parse either + or 12 identically
04:03unlink1like (get-clojure-object string)
04:03hoeckunlink: maybe read-string?
04:03unlink1Yeah, but that gives me a symbol for "*", not #<core$_STAR___3341 clojure.core$_STAR___3341@30419d05> or whatever.
04:04unlink1,((read-string "*") 2 3)
04:04clojurebot3
04:05hoeckbut you can resolve that symbol, as you do in your code
04:05unlink1right, but I'd have to special case symbols.
04:05hoeck,(resolve (read-string "*"))
04:05clojurebot#'clojure.core/*
04:06unlink1The idea is to treat numbers and operators identically in parsing
04:08hoeckand what about:
04:08hoeck,(read-string (str "(" "1 2 3 + - 2 * 12 +" ")"))
04:08clojurebot(1 2 3 + - 2 * 12 +)
04:09AWizzArdunlink1: btw, what is that for?
04:10unlink1It's an RPN calculator.
04:11AWizzArdjust for fun?
04:11unlink1Hone my clojure & prepare for interviews.
04:13Carkhello all
04:13Carklittle question : what's a good java decompiler ?
04:14Carkor at least on that works on jvm 1.6
04:14AWizzArdjad
04:14AWizzArdhttp://www.varaneckas.com/jad
04:14Carkthanks AWizzArd
04:16unlink1Although, checking if something is a symbol and conditionally resolving it is much more concise than parsing integers.
04:19kotarakunlink1: btw: you asked yesterday for (nth (iterate rest coll) 3) => (nthnext coll 3)
04:20unlink1oh cool. thanks.
04:30unlink1well I guess it's slightly different.
04:30unlink1nthnext will NPE when coll is too small, but nth (iterate rest coll) won't
04:31kotarak,(nthnext [] 3)
04:31clojurebotnil
04:31kotarak,(nth (iterate rest []) 3)
04:31clojurebot()
04:31unlink1hmmmm
04:31kotarak,(nth (iterate next []) 3)
04:32clojurebotnil
04:32unlink1er. -> nil instead of ()
04:58MikeSethis there a way to run clojure code in restricted environment? e.g. where java interop & symbol access is not allowed (including e.g. core functions)?
04:59unlink1clojurebot might be a good starting point, http://github.com/hiredman/clojurebot/tree/master
04:59kotarakI think clojurebot does this.
04:59AWizzArd,(java.io.File.)
04:59clojurebotjava.lang.IllegalArgumentException: No matching ctor found for class java.io.File
04:59AWizzArd,(java.io.File. "/")
04:59clojurebot#<File />
04:59AWizzArdhmm, some io is allowed ;)
05:00kotarakAWizzArd: File does no IO.
05:00unlink1Well, file creation is allowed.
05:00MikeSethand that's implemented without hacking the host clojure environment?
05:00unlink1java.io.File creation, that is.
05:00kotarak,(java.io.File. "/nonexistant")
05:00clojurebot#<File /nonexistant>
05:00unlink1,(nth (.listFiles (java.io.File. "/")) 0)
05:00clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission / read)
05:00MikeSethTCL is very strong in this respect - you can execute any code in restricted environment where every variable/method access can be intercepted
05:01unlink1there you go
05:01MikeSethnice
05:01MikeSeththanks for the tip - i'll look in the bot's code
05:01unlink1np
05:06Chousukeclojurebot just uses the JVM sandboxing features.
05:17MikeSethdidnt know JVM had sandboxing - im very new to both
06:35AWizzArdrhickey: is it intended that catch inside a (try ...) block will only take a constant as an exception? I noticed that the exception argument can't be parametrized/filled with a variable.
06:38AWizzArdExample: (let [x Exception] (try (catch x e (println "Hi"))))
06:41rhickeyAWizzArd: right it can't be a variable because the exception type must get compiled into the bytecode
06:44AWizzArdok, I wasn't sure about that
07:58Carkwew !
08:11unlink1Is this 1.0?
08:11kotarakIt seems so.
08:13Chousersomeone should do this for contrib as well
08:14AWizzArdIs there a function that takes a hashmap HM and a key K and returns a hashmap {K (HM K)}?
08:16kotarak(apply hash-map (map hm key-list))
08:16kotarakOps
08:16kotarak(apply hash-map (interleave key-list (map hm key-list)))
08:19rhickeyChouser: yes, that would be good
08:21unlink1Is a release announcement planned?
08:29rhickeyunlink1: working on it
08:36aperottehello everyone
09:04rhickeyIt's official: http://groups.google.com/group/clojure/browse_frm/thread/1e661d16bd910ddd
09:05Carkthat's great news =)
09:05Chouserwell, congrats and all that! :-)
09:06duck1123sweet
09:06rhickeythanks to all for your help, especially you Chouser!
09:06Chouserheh, aw shucks...
09:06kotarak\o/
09:08Chouserrhickey: "self-funded
09:08Chousersabbatical" sounds scary to me -- thanks for doing that!
09:09rhickeyChouser: there's no other way things like this get created
09:09ChouserI hope you're payed back, in the end, many-fold in money, quality of life (ie. jobs that hurt less), etc.
09:09unlink1Thanks a lot everyone for everything that went into 1.0.
09:11cgrandrhickey: thanks!
09:12aperottecongratulations!
09:13duck1123does anyone know what java.lang.NoSuchMethodError: clojure.lang.MultiFn.<init>(Ljava/lang/String;Lclojure/lang/IFn;Ljava/lang/Object;Lclojure/lang/IRef;)V means?
09:14kotarakbroken build
09:15duck1123of clojure? or the calling library? I'm getting this when I try to compile compojure against a recent clojure.
09:16kotarakIt depends. Might also be something compojure uses eg. from contrib.
09:16kotarakYou have to consult the stacktrace where this exception is thrown.
09:17duck1123actually, it looks like this one is comming from swank
09:19kotarakAnd this is rather ominuous. I think the string argument was added recently. So this seems to be some new code in combination with an old clojure?
09:22kotarakduck1123_: might it be, that you have some old clojure somewhere? The named constructor is actually the new one. So it seems, that new (compiled) code is used in combination with an old clojure.
09:31duck1123_I my call to swank-clojure, and it compiled. so the problem is there somewhere
09:42rhickeySite documentation error reports for inconsistencies with 1.0 welcome
09:43duck1123_so is the site now updated to 1.0 documentation? (more or less)
09:45rhickeyduck1123_: I haven't done a thorough review, but have fixed things as I see them, the API page is freshly generated, the example for refs improved, some clarifications to the seq language in lisps, but as I said, proofreading help wanted, also retrying all the examples
09:45slavacongrats on 1.0
09:45rhickeyslava: thanks, it's just a start
09:46AWizzArdrhickey: is 1.0 now final?
09:47rhickeyAWizzArd: yup
09:47AWizzArdgrats
09:47rhickeythanks
09:47AWizzArdI will inform Heise then :)
09:47hoeckAWizzArd: :)
09:48kotarak~then there was 1.0 and suddenly...
09:48clojurebotCLABANGO!
09:51AWizzArdrhickey: your email address is like your name here in chat, ending in @clojure.org ?
09:52rhickeyAWizzArd: no, like on the google group
09:52AWizzArdok
09:56slavarhickey: so did you have any idea clojure would take off like it did?
09:57rhickeyslava: none whatsoever
09:58kotarakhehe, the good things always come surprisingly...
10:04tashafacongrats on 1.0... what a ride!
10:06duck1123_I have a feeling that a lot of people will start giving Clojure a fair look now that it is no longer pre-1.0
10:06cemerickrhickey: congratulations! :-D
10:10hiredmanI imagine a contrib jar should be cut
10:11rhickeycemerick: thanks
10:12Raynesrhickey: Congratulations on 1.0 :)
10:27AWizzArdSo, reddit already has the news, heise is informed. Where is slashdot? :)
10:28RaynesAWizzArd: I was browing my reddit RSS feed and shat my pants.
10:32wlrrhickey: (take as-many-as-you-like (iterate identity "congrats on 1.0!"))
10:42hoeckrhickey: congratulations, I have been following and programming clojure since it was first mentioned on reddit and it is now my favourite lisp to program with, big thanks!
11:28eyerisI am trying to follow the "gen-class Examples" section of clojure.org/compilation. I am on Windows. If I run "java -cp deps\clojure.jar clojure.lang.Repl", I get a repl, but if I create a classes directory and then run this command "java -cp classes:deps\clojure.jar clojure.lang.Repl", I get an exception "java.lang.ClassNotFoundException: clojure.lang.Repl"
11:28eyerisWhat am I doing wrong here?
11:29Chouserhis is a shot in the dark, but try a / instead of a \
11:29Chouserthis is
11:31hiredmaneyeris: windows uses ';' as the classpath seperator, not ':'
11:31eyerisAhh!
11:31eyerisThe horrors of trying to be multi-platform :)
11:31cemerickwould it be crazy of me to suggest that deref should be a multimethod (or, that there should be a corollary to seq-on)?
11:32hiredmanYeah
11:32hiredmancemerick: it is crazy
11:32hiredmanderef needs to be as fast a path as possible
11:32cemerickthus my parenthetical secondary option
11:33hiredmanI have no idea what 'seq-on' is
11:33cemerickit's seq, but a multimethod, so you can define how to obtain seqs from things that aren't ISeqs
11:35hiredmanI see
11:35cemerickI find myself creating various kinds of maps where there is a primary value, and the semantics of deref are appropriate.
11:35hiredmanyou can always proxy IDeref
11:35rhickeycemerick: I'm still thinking about how to make more of the core fns extensible with multimethods w/o ruining the fast path
11:36rhickeycemerick: really - maps with deref? are they still values?
11:36hiredmanactually, that kind of sounds like something you could do with metadata too
11:37cemerickrhickey: well, I'm not sure. I'm still feeling out the problem space. Consider a cells impl, where there's a particular Value associated with the map object that tracks cell state.
11:37cemerickhiredman: yeah, that's another option I'm considering.
11:39rhickeycemerick: I think deref should be reserved for reference types, having not value other than they thing to which they refer
11:39rhickeyhaving no value
11:40rhickeyidentity equality and hash
11:40rhickeyare you just looking for the convenience of @?
11:40replacarhickey: let me add my congrats on 1.0: Clojure is an excellent piece of work.
11:40rhickeyreplaca: thanks
11:42replacarhickey: I missed you the other day - how does Tuesday evening after your JavaOne presentations work for you for an SF clojure get-together? Or is another time better?
11:44rhickeyreplaca: could work, just looking at my schedule - there are lots of BOFs in the evenings...
11:45replacarhickey: let me know what day is best for you. I'd like to start getting the word out in the Bay Area pretty soon so we get a great turnout
11:46rhickeyreplaca: what format are you envisioning?
11:47replacarhickey: not clear yet - I was thinking a few short Work-in-progress type presentation (think poster session), but really I'm pretty open
11:47replacaor maybe very open :-)
11:47replacamostly the idea is to build momentum for CLojure here in the Bay Area since you'll be here
11:50replacarhickey: recruiting from the more lisp-y/fp crowd than Java crowd (though they would also be welcome) with a focus slightly above the "look, it's clojure" talk
11:51rhickeyreplaca: well, I'd like to participate, something other than a formal talk might be interesting, if a full talk, Wed. might be better
11:51cemerickrhickey: there are circumstances where I have an object graph that is a heterogenous mix of refs, delays, and various maps that have an 'authoritative' value. I'd like to always use the same fn to access them all (right now I'm using an unpack multimethod that has an IDeref dispatch, and then whatever other dispatches exist for other 'container' objects).
11:51rhickeycemerick: what you are doing right now sounds correct
11:52cemerickI thought that perhaps this is a common use case, and seeing seq-on in contrib made me think that having parallel multimethods for various base fns made sense.
11:52replacarhickey: I wasn't going to put you on the spot for a formal talk since I know you have a busy week, but if you have something you'd like to say to that kind of audience, I'd be happy to provide a forum
11:53rhickeyreplaca: It might be fun to do a town-hall kind of QA session
11:53rhickeysaves me some prep as I can wing it :)
11:54replacarhickey: Sounds cool. I was thinking maybe a mix of that and a few early adopters doing quick demos of what they're using CLojure for
11:54rhickeyreplaca: that sounds great
11:54replacarhickey: I know Amit Rathore is doing some interesting messaging stuff I'd love to hear about
11:55rhickeyreplaca: what time of day are you talking about?
11:55replacarhickey: Would Wed be a good night to lock and load or do you want to wait and see?
11:55clojurebotrhickey is a T-1000 sent from the future
11:55replacaearly eve, right after work
11:55replacamaybe ~5:30 or 6
11:56replacabut again, I'm pretty open. I figured I'd get some feedback from the peninsula crown about when they could get up
11:56replaca*crowd
11:57rhickeyreplaca: Let's shoot for Wed then
11:57rhickey6/3
11:58replacarhickey: It's a plan. I'll put my head together with the other BayArea clojurians and fill in the details
11:58replacarhickey: We'll keep you posted
11:58rhickeyreplaca: great, thanks
11:58replacarhickey: np
12:02djpowellgz on version 1.0!
12:06replacarhickey: On another subject (from response to my posting to the group last night): Could you add a link to the API docs on the clojure.contrib landing page? I think that is beyond my powers. :-)
12:07rhickeyreplaca: http://code.google.com/p/clojure-contrib/wiki/OverviewOfContrib ?
12:07replacarhickey: you got it!
12:09rhickeyhttp://code.google.com/p/clojure-contrib/
12:10replacarhickey: Thanks!
12:11rhickeynp
12:44hiredmanreplaca: clojure-json pukes on the api index
12:44danlarkin*gasp*!!
12:45hiredmandanlarkin: Yeah
12:45danlarkinis it valid json?
12:45hiredmanhow would I know
12:45danlarkin*shrug*
12:45hiredmanare there validators or something?
12:46danlarkinprobably somewhere... could you point me to it? I will try it with simplejson in python
12:46replacahiredman: it was produced by clojure.contrib.json.write
12:46hiredmanhttp://clojure-contrib.googlecode.com/svn/wiki/ApiDocIndex.json
12:46replacait's all one huge line :-)
12:47hiredmanactually google chrome wraps it
12:47replacahiredman: did you cut and paste it or pull it directly?
12:48hiredmanI pulled
12:48replacahiredman: ok, that should be ok. I haven't really inspected it myself. I was more focused on fleshing out the namespace doc for contrib this weekend
12:49danlarkinI believe this json is invalid
12:49replacabut in theory, if json.write can write it, clojure-json should be able to read it
12:49replacadanlarkin: is there a bug in json.wrie
12:49danlarkinnot if json.write produces invalid json, which it seems to
12:49replaca?
12:50hiredman:(
12:50replacadanlarkin: can you see what the error is?
12:50danlarkinI haven't done any testing on contrib's json implementation, but I know clojure-json does a bunch of special-casing of peculiarities that I didn't see the contrib one do
12:52replacadanlarkin: I can convert to clojure-json, but I'd like to make sure that things that are in contrib are correct
12:52replacacause they're the ones noobs are going to grab
12:53danlarkin"arglists": [[coll, x]]
12:53danlarkinthat is wrong, coll and x aren't quoted
12:54replacadanlarkin: OK, I'll file an issue
12:54danlarkinthat's just the first thing that jumps out at me, there might be other stuff
12:54replacahiredman: in the meantime, I'll pick up clojure-json for output
12:55replacadanlarkin: other option is to deprecate json.* and replace with clojure-json
12:55replaca:-)
12:55replacawe'll find out!
12:58bradfordJava integration question...if I do an (:import AMQP$PROTOCOL) and then use it via (AMQP$PROTOCOL/PORT) what is the signifigance of the $ - does that mean that PROTOCOL is a nested strcture (class, enum, whatever) inside the AMQP class?
12:58kotarakYes. $ are nested classes.
12:59bradfordaha, so that is why my imports that tried to get to nested classes via . do no t work, i suppose they must all use $
13:00bradfordyep, works fine now, thanks kotarak
13:00kotaraknp
13:15replacahiredman: OK, just checked in a version using clojure-json. See how that works for you.
13:16replacahiredman, danlarkin: looked good when I eyeballed it. And no longer all on one line :-)
13:16arohnergrr. java.io.File has a deleteOnExit, but not a deleteOnGarbageCollect
13:17replacaarohner: you could simulate with a weak ref
13:17arohnerooh, that would be pretty cool
13:17arohnerif there were a clojure fn that did (weak-ref object on-GC-fn)
13:17danlarkinoops, looks like there's a bug with the indenting though, the arglists are left-justified
13:17arohneri.e. (weak-ref my-file #(.delete %))
13:19danlarkinhttp://www.jsonlint.com/ says the clojure-json produced version is valid, yay :)
13:20replacadanlarkin: I was thinking about doing a JSON formatter based on the pretty printer, it could make a nice extension to clojure-json and simplify your formatting
13:21replacadanlarkin: the big advantage is that the pretty printer has a very smart fill algorithm that can make things go across more than down when appropriate
13:22replacadanlarkin: but I want to build the official extensible dispatch stuff first
13:22replacaarohner: that shouldn't be too hard to write, though it's been a long time since I've done weak ref stuff so my memories of the details are fuzzy
13:23arohnerI think I can figure it out
13:23arohnerthanks for the pointer
13:24replacaarohner: np. I'd like to see what you come up with.
13:28bradfordis this: (def consumerThreads (for [x (range consumerCount)] (new Thread))) the best way to directly approximate this: Thread[] consumerThreads = new Thread[consumerCount];
13:29bradfordI am porting a bit of java and I want to try to port some things directly first, get it working, and then clojureize it. Although Maybe I should just make these agents now.
13:32arohnerbradford: it's hard to tell, without knowing more
13:32arohneragents aren't 1:1 replacable for threads
13:32arohnerthey basically just compute one value and exit
13:35danlarkinreplaca: moving the indenting code out of the core encoding code would simplify the encoder a good deal
13:37AWizzArdWoohoo! All german readers please note: http://www.heise.de/developer/Clojure-1-0-funktionale-Programmiersprache-fuer-die-Java-Virtual-Machine--/news/meldung/137231
13:38AWizzArdMake some nice comments :)
13:38bradfordarohner: I think it is natural in thsi case because I am working with rabbitmq so each agent is an operation that takes something off the queue and does something with it.
13:38bradfordbut maybe there is a better abstraction
13:38Lau_of_DKAWizzArd: How's your compojure trip going?
13:39AWizzArdLau_of_DK: I am trying to figure out how I can read the port number of out a server object, returned by start-server
13:39AWizzArd(.getPort server) doesn't work
13:41Lau_of_DKk :)
13:41danlarkinif only you were rocking madison...
13:42Lau_of_DKif only you were including dependencies :)
13:43Lau_of_DKdanlarkin: If you have surpassed Compojure I'll be happy to start using Clabango instead - As it is right now, Compojure is just really really funky, and webdeveloping has never been remote this fun/productive before
13:45replacadanlarkin: that was my theory. that's what the pretty printer does to earn it's dinner and I'd like to see it work for building all sorts of formatted output, not just s-exps
13:54arohnerpaste
13:54arohnerclojurebot: paste
13:54clojurebotlisppaste8, url
13:54lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
13:55lisppaste8arohner pasted "untitled" at http://paste.lisp.org/display/79644
13:55arohnerthat call to name resolves to clojure.core/name
13:55arohnerrather than my local name
13:56hiredmanarohner: I see no call to name
13:57arohnerthe (.delete ~name)
13:57arohnerresolves to (.delete clojure.core/name)
13:57hiredmanI disbelieve
13:57arohnerrather than the local in the destructuring
13:57arohnerjava.lang.IllegalArgumentException: No matching field found: delete for class clojure.core$name__3618
13:58rhickey_user=> (macroexpand-1 '(with-delete [a b] c))
13:58rhickey_(clojure.core/let [a b] c (.delete a))
13:58hiredmanuser=> (macroexpand-1 '(with-delete [foo bar] baz))
13:58hiredman(clojure.core/let [foo bar] baz (.delete foo))
13:58hiredmanwhoops
13:58hiredmanclojurebot: works on my machine
13:58clojurebothttp://haacked.com/images/haacked_com/WindowsLiveWriter/IConfigMapPathIsInaccessibleDueToItsProt_1446B/works-on-my-machine-starburst.png
14:03arohnerthe image is cute, but not very helpful
14:03hiredmanif you proxyed whatever you are using that on you could close => delete and just use with-open
14:03hiredman:P
14:03hiredmanarohner: I would try in a fresh environment
14:07arohnerhiredman: about proxying. I've wanted variants of with-open before. I was thinking of making a generic with-f, like (with-f #(.delete %) [my-file (File. "foo")] ...)
14:12hiredmanwrap-with
14:13hiredmanhmmm
14:13hiredman~def with-open
14:15hiredmanjust change that (. ~(bindings 0) close) to some arbitrary function call
14:15arohneryup
14:16hiredmanor just wait for rhickey to push scopes
14:16hiredmanand use those
14:17hiredmanthere is always http://github.com/hiredman/clojurebot/blob/9216e6b2f6c5402be06d093d01590a7dd33131c3/hiredman/horizon.clj
14:18tashafaping danlarkin
14:18danlarkintashafa: pong
14:18tashafahey im using your json library..great stuff
14:19danlarkingreat!
14:19tashafahow would you reommend parsing a java date object
14:19tashafai get an Unknown Datastructure exception
14:20arohnerpush scopes?
14:20danlarkinyou mean encoding a Date, right?
14:20tashafayup
14:20Serkanhi
14:20danlarkintashafa: look at the README, it shows an example of adding a custom encoder to handle writing dates
14:20tashafashould I turn it into a javascript Date Object?
14:21tashafaoh ok...thanks
14:21dnolenis test-is working for people? I'm up to date with clojure-contrib and clojure, and it doesn't seem to be working at the moment, an error about clojure.core/if being unbound.
14:21danlarkintashafa: no, you should turn it into a string with appropriate resolution for your needs
14:21SerkanIs asm bundled with clojure sources a modified version or direct copy?
14:22tashafadanlarkin: thanks man
14:23danlarkintashafa: do you see where I mean? also see the docstring for add-encoder in json.clj
14:23tashafayup including the dat-encoder
14:23tashafadate-encoder
14:24danlarkingreat
14:25tashafathanks again.. should have read thru the readme
14:26arohnerdnolen: works for me
14:26clojurebotfor is not a loop
14:26arohnerdnolen: do you have an example of it breaking?
14:27tashafadanlarkin: hmm... does the decoder have the same behaviour?
14:28danlarkintashafa: no, they'll just be read as strings
14:29tashafayeah..i see why
14:29tashafano type info
14:29danlarkinyeah, it's unfortunate, but probably not too hard to encode the logic in your application to handle it
14:29tashafatrue
14:30dnolenarohner: yeah the most basic test.
14:30dcnstrctI just wanted to come say congrats on 1.0, and thank you!!
14:30dnolenarohner: (deftest foobar (is (= 1 2)))
14:31arohnerdnolen: and what's the error?
14:31dnolenexpected: (= 1 2) actual: java.lang.IllegalStateException: Var clojure.core/if is unbound.
14:32arohnerwhat happens if you do (doc if)
14:32arohner?
14:32hiredmanah, I imagine it is because if is a special form again
14:33dnolenI get the expected documentation
14:33hiredmanduring the the lazy-seq transition if was made a macro that depended on the if* special form
14:33hiredmanthat was reverted back a few svn revs ago
14:33dnolenarohner: all I have is the ns the test and (run-tests)
14:35dnolen(is (= 1 2)), throws the error.
14:37arohnerare you running clojure-contrib from source or jar?
14:37dnolenwhat's weird is that if I fully expand the "is" macro it works.
14:38dnolenaroher: I'm running contrib from the .jar
14:40arohneryou said your clojure and contrib are up to date. Did you svn up contrib without recompiling?
14:41dnoleni use the git mirrors, and everything is up to date and recompiled. but let me double check, I'll wipe then out and load them anew.
14:44dnolenarohner: odd that fixed it, oh well :)
14:45arohnerdnolen: good to hear
14:45dnolenarohner: thx for the help.
16:15Lau_of_DKdanlarkin: How far are you with Madison ?
16:16danlarkinHmmm
16:17danlarkinit'd be usable for a small project no doubt, and having someone else use it would help me know what's important to add next :)
16:21Lau_of_DKAha :) Do you have a public roadmap up somewhere?
16:22danlarkinno, no I don't
16:22danlarkinI probably should, though
16:22danlarkinso much to do, so little time
16:33Lau_of_DKWould probably make it easier to get into - You know what there is, and whats coming
16:39danlarkinyeah, for sure
16:39danlarkinany documentation would help I'm sure :)
17:01Chouserwhen is the word "status" preferred over "state"?
17:02danlarkinis this our very own Chouser? http://www.ibm.com/developerworks/edu/os-dw-linuxxwin-i.html
17:03Chouserheh, it is. That's a bit ... old.
17:03rhickey_Chouser: status implies progress/stature/availability, while state merely condition
17:05Chouserhm...
17:06ChouserI've got two external systems that each have a state (status?), and I'm polling info both to decide how and when to update one of them.
17:06hiredman:D
17:06hiredmanXFree86
17:06Chouserhiredman: yeah. back when you had to configure it.
17:06rhickey_Chouser: what's in the polled-for info?
17:07Chouserso I have in my clojure program snapshots of the status (state?) of each, and in at least some fns access to old versions.
17:08Chouserone is phone, so I get the text output of a query, a boolean conclusion about whether the phone is on the hook or not, a flag indicating if that conclusion should be believed.
17:09Chouserit currently also contains config info about how to connect with the phone, but I think that probably belongs in a separate ref, perhaps an atom.
17:09Chouserthe other is jabber status, which contains an id, type, message, and title.
17:10Chouserand I just realized I'm using both the words "state" and "status" in various places, apparently randomly. :-P
17:11rhickey_Chouser: on hook or not smells like status, but queries/messages neither status nor state
17:11Chouserthe jabber api here uses the word "status", and that may be appropriate for all cases in this codebase.
17:13Carkcall state : state machine ... phone state : status onhook ? hum not sure ...then again i'm no native speaker
17:14ChouserI'm collecting all that extra info mainly for diagnostics later. Both these systems are proving to be a bit squirrely, and I'm sure I'm going to get error reports on things I can't reproduce.
17:14hiredmanall the dictionary definitions of status seem to only relate to people and not inanimate objects
17:14Chouser...so i'm hoping to provide an option to turn on a repl and can ask the user to query things like the text output from the phone, etc.
17:16Carki wonder what's your application doing, care to tell us ? or should it be kept a secret ?
17:16Chouserno, it's pretty simple. I've already explained the bulk of it.
17:17Chouserwhen it notices the phone status has changed, it calls a function that can look at the phone and jabber status and decide how to change the jabber status.
17:18Chouserby default, when you pick up the phone the jabber status will change to "Away -- on the phone". When you hang up (if you've changed nothing else), it goes back to whatever it was.
17:18Carkoh i see, nice =)
17:19rhickey_Chouser: that's definitely status then
17:19Chouserit's pretty specific, though -- assumes one particular kind of SIP phone and that you're using libpurple for jabber.
17:19RaynesDid anyone notice that Slava Pestov congratulated Rich in that reddit thread? Also said "Now I need to get Factor 1.0 out this year..."
17:19Chouser...on linux.
17:19Chouserrhickey_: ok, thanks.
17:20Carki had much success using yate as a sip gateway, this one works with any sip phone
17:20Carkjust direct the trafic to it
17:20Carkand get all the signaling
17:20Carkfrom a socket interface
17:21Chouserdirecting the traffic sounds like you'd have to mess with firewall rules or something?
17:22Carkwell that's a carrier grade piece of software, so you get nat traversal and stuff bundled with it
17:23Carkthough the endopoint you're calling will see the name and password from yate
17:23Carkinstead of your p^hone
17:23Chouserinteresting -- I may have to look at that later: could open up a lot more options.
17:25Carkwhat i would love to do, is write a sip stack with clojure
17:25Carkthat would be the killer app =P
17:25ctdeanThis is probably Clojure 101, but how do I do the equivalent of (new java.util.Set<java.lang.String>) ?
17:25ctdeanSo, Java generics
17:25Chouserjust skip the type-arg part
17:26ChouserIt'll Just Work.
17:27Carkchouser : the problem about it is testing, you need real phones and gateways to do proper testing
17:27ctdeanso it does, thanks!
17:27ctdean,(new java.util.HashSet)
17:27clojurebot#<HashSet []>
17:27Carkanyways =P enough dreaming !
17:47opqdonutwhy isn't 1.0 in the topic?-)
17:49Chousernobody knows how to change it
17:49hiredman#clojure generally has very little op presence, there may be no one around who can change the topic
17:58powr-tocDoes slime work with clojure 1.0/
17:58powr-toc?
17:59danlarkinthere's only the one op
17:59danlarkinand I have only ever seen him on once since september
17:59hiredmanyeah
17:59hiredmanvery littel
18:01technomancypowr-toc: it should as long as you've got the latest swank-clojure
18:02powr-toctechnomancy: thanks
18:25cipherhow might I call a C function from within clojure?
18:26sohailcipher, you'd need to use JNI. I think there is a "pure" Java way to do it
18:26sohailJNA?
18:26cipherclojurebot: JNA?
18:26clojurebotIt's greek to me.
18:26sohailcipher, https://jna.dev.java.net/https://jna.dev.java.net/
18:26sohailhttps://jna.dev.java.net/
18:26sohailsorry...
18:27cipherthanks
19:04powr-tocWhich SVN commit is clojure 1.0?
19:05powr-tocrhickey: Which SVN commit is clojure 1.0?
19:12rhickey_powr-toc: 1362
19:13powr-tocrhickey_: was just looking at that... it looks like the github mirror is a few commits behind
19:14powr-tocthough the commits it's missing appear to be solely version number changes
19:14rhickey_is it only grabbing trunk?
19:15powr-tocrhickey_: yeah, looks like it... I'm not sure how it's being mirrored, but I use some unnoficial apache git-svn mirrors, and they correctly grab everything
19:15powr-tocrhickey_: also, is it worth creating a 1.0 tag in the svn tags directory?
19:15rhickey_powr-toc: just looking at that
19:16powr-tocawesome!
19:18powr-tocrhickey_: congratulations on 1.0 btw! Very glad to see it! :-) Though I'm intrigued by post 1.0 development (out of curiosity, not yet necessity)
19:19powr-tocOne thing that crossed my mind, now that clojure has reached 1.0 is there going to be a corresponding release of clojure-contrib? i.e. one that is targetted at the clojure 1.0 release?
19:20rhickey_powr-toc: sounds like a good idea - one of the contribbers needs to organize that
19:21powr-tocis it worth raising the issue as a thread on the group?
19:21rhickey_powr-toc: sure
19:22powr-tocrhickey_: cool... I'll fire something off
19:22chessguy'evening
19:22chessguyhey rhickey_ : congrats on a great milestone today
19:22rhickey_chessguy: thanks
20:35danlei,(doc defn)
20:35clojurebot"([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata"
20:35danleihm
20:36danleiwhy does (defn #^{:foo 'foo} foo []) add the metadata, but (defn foo #^{:foo 'foo} []) not? if i read the docstring correctly, the second one should be right, shouldn't it?
20:37danleis/doc-string/parameter list/
21:02Chouserdanlei: leave off the #^ in the second form
21:02Chouserprovide a plain literal map instead
21:03danleiChouser: aah, thank you!
21:42durka42congrats on the 1.0
22:36eeei wonder if anyone has a pointer or two for an approach/design for a little program that does the 15-puzzle
22:37eeethe puzzle with 16 squares, one is empty and the numbers need to get in order
22:38eeebasically, I don't really have a feel for when it is ok to use def
22:38gnuvince_eee: throw it against the wall :) I hate those puzzles. They're sometimes featured as a mini-game in video games and I need to spend like 2 hours solving it
22:39eeeahhhh
22:39eeewell I know how to solve it quickly
22:39eeeand want to show how using clojure
22:39eeebut I know what you mean
22:39eeeI was thinking there'd be an outer function
22:40eeethat takes an input state, some scrambled version
22:40eeea goal state
22:40eeethe ordered version
22:40eeeand a way to transition
22:41eeethe space would move at most in 4 directions
22:41eeeand a way to score the move
22:41eeethe score is the number of out of place pieces
22:42eeei guess that helped right there L)
22:42eeejust saying it out loud
22:45chessguyis typing considered "out loud"? :)
22:46eeei was too lazy to put the quotes
22:46chessguyhehe
22:46chessguyso, what, you're gonna do an AB search on the tree formed by considering all possible sequences of moves?
22:47chessguys/tree/graph/ sorry
22:47eeea* search to demonstrate usefulness of my heap
22:47chessguyerr, and you definitely don't want AB anyway...
22:47eeemope
22:47eeeonly one player
22:47eeenope, that is
22:47chessguyi think i should stop typing and start sleeping :)
22:48eeeanother question, is anyone for hire to do clojure talks?
22:48chessguyg'night
22:48eeegnight
22:53eeeclojure 'let' is sequential let, right? like let*?
22:53danlei`yes
22:53eeethanks
22:57eeedo all the bindings work that way?
22:57eeelike loop []
23:00danlei`eee: as far as i know, yes
23:00eee"all" was too strong
23:00eeethanks
23:18benatkinIs there a more succinct way to write (map #(or % %2) [9 2 nil 4] [3 4 2 5])? Something like (function-name [9 2 nil 4] [3 4 2 5]) -> [9 2 2 5]), where function-name is the name of a function in the standard clojure api?
23:20Chousera shame 'or' is always a macro
23:20benatkinthat was going to be my other question...if there was some way to get or to pretend to be a function
23:21durka42that's strange...
23:21durka42,(apply #'or [1 2 3])
23:21clojurebot(clojure.core/let [or__3311__auto__ 1] (clojure.core/if or__3311__auto__ or__3311__auto__ (clojure.core/or 2 3)))
23:21ChouserI can't think of anything more succinct than what you've got.
23:21Chouserdurka42: what's strange about that?
23:22durka42oh, i see, that is literally pretending to be a function, and apply didn't know it was supposed to be a macro
23:22Chouserexactly
23:22benatkinjust think, if we'd raised this issue a couple of days ago, Clojure 1.0 would have been delayed :D
23:22Chousernah, it's been raised plenty of times, in one form or another
23:24Chouser,(map #(some identity %&) [1 2 nil 4] [5 6 7 8])
23:24clojurebot(1 2 7 4)
23:25Chouser,(for [[a b] (map list [1 2 nil 4] [5 6 7 8])] (or a b))
23:25clojurebot(1 2 7 4)
23:26durka42he times out
23:26dnolenChouser: wow, always something new to learn, what is %&?
23:26benatkindurka42: of course! that's sweet.
23:26durka42dnolen: like & in the normal parameter list
23:26Chouserdnolen: all the rest of the args to #() in a seq.
23:26benatkinthreading rules!
23:27dnolenahh gotcha, cool!
23:28benatkindoes identity need to be in there?
23:28benatkin,(map #(some %&) [1 2 nil 4] [5 6 7 8])
23:28clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$some
23:28benatkinah...apparently
23:33benatkin,(ffirst [[:ffffound!]])
23:33clojurebot:ffffound!