#clojure logs

2009-05-21

00:17cemerickwhat is this org.infolace.format ClassNotFound exception about?
00:19cemerickthe stack trace points at the compiler, but I'm sure that's not where the root reference is. The exception is thrown when attempting to print something to stdout...
00:20cemerickoh, it's cl-format stuff....which I somehow inherited a dependency on? :-/
00:21danlarkinmuhahaha! can't keep them out
00:22hiredman:(
00:31cemerickgrrr, a full grep reveals no com.infolace at all
00:31cemerickcom.infolace occurrences, I should say
00:32replacacemerick: oops, infolace is me - just joining - what's up?
00:33cemerickI'm not sure. I was upgrading our enclojure REPL library, and now I'm getting classnotfound exceptions sporadically when using it, but I can't for the life of me find any infolace references in the source.
00:33cemerickI'm pretty tired though, so this may straighten itself out in the morning.
00:33replacaoh, the macroexpand might be pretty printing
00:34replacacl-format and pprint were originally on github & named with my domain com.infolace.cl-format
00:34replacabut now they've moved (a few months ago) into clojure.contrib.pprint
00:34cemerickit's actually reporting classnotfound for com.infolace.format
00:34replacathat's just an error?
00:35replacathere was never any such namespace
00:35replacait was com.infolace.cl-format
00:35cemerick"FileNotFoundException: Could not locate com/infolace/format__init.class or com/infolace/format.clj" *shrug*
00:36replacainteresting, let me take a quick look at git history
00:38replacaapologies, the namespace was com.infolace.format & the function was cl-format
00:38replacaso you must have code that points at the old pretty print or cl-format routines
00:39cemericknot me, I'm just a bystander ;-)
00:39replacaif you can find out what code it is, you should be able to just point it at c.c.pprint and go on your way
00:39replacacemerick: yeah, I understand
00:39replacamaybe you need an ant clean somewhere?
00:40cemericktried that, but I'm sure I'll try that again
00:40cemerickis there a way to make lib loading verbose, so I can trace the dependencies?
00:40replacaI've nver looked at enclojure, so that's probably as much light as I can shed on it
00:41cemerickreplaca: sure, thanks for trying :-)
00:41replacadunno, it would be useful
00:41danlarkincemerick: there is, it isn't springing to mind at the moment though
00:41danlarkinI think you can pass :verbose to require maybe?
00:42cemerickdanlarkin: yeah, I just found it... (require :verbose 'blah)
00:42danlarkintada
00:43replacaahh, that's a good trick to know
00:46cemerickit only works for the requires or uses in a particular file though -- it's not like a binding, so you have to run around attaching it to the various files that are being loaded.
00:48danlarkinisn't it just a front end option for *loading-verbosely*?
00:50cemerickdanlarkin: dunno. It didn't carry through to verbosely loading my dependencies, tho
00:51danlarkinyeah, even when binding *loading-verbosely* to true I don't get the output without using :verbose
00:51danlarkinoh well, it's late, I'm off
00:52cemerickreplaca: I found the bum reference, BTW.
00:53cemerickenclojure ships with a custom build of cl-format, apparently
00:57replacacemerick: argh! the problem with open source :-)
00:58cemerickheh, indeed. It doesn't seem necessary, at least for the REPL library part of it. Pretty heavy dependency for the context, IMO.
00:59replacawell, I could see why folks want it (after all that's why I wrote it)
01:00replacait would be nice if we could make the version of contrib work for them though
01:00replacawho does enclojure?
01:01cemerickEric Thorsen and co. I'm sure they're aware of clojure.contrib.*. There's likely very good reasons for it, etc.
01:02replacayeah, but I could possibly adapt changes. if they started from the version on github, they're using old code
01:02replacacl-format hasn't changed too much (though it's a lot faster now) but pprint has changed a lot
01:03replacabut who knows, maybe he's doing crazy different things
01:07gcvIs Clojure 1.0.0 not compatible with swank-clojure? I get java.lang.NoSuchMethodError: clojure.lang.Namespace.importClass(Ljava/lang/Class;)Ljava/lang/Class; (pprint.clj:0) in my *inferior-lisp* buffer.
01:08replacagcv: you need to compile/recompile contrib
01:09replacagcv: swank wants the gen-class'ed pretty printer for macroexpansion
01:10gcvreplaca: thank you
01:11replacagcv: no prob. enjoy your pretty macroexpansions :-)
04:33alrex021I have setup Aquamac on my Mac with clojure-mode. Now I have tried adding Clojure Slime support and I get "not connected" when doing C-c C-z
04:34alrex021Any ideas as to when one would get the "not connected" story? in my customization.el I have a (server-start)
04:58yangsx,(defn my-zipmap [keys vals] (loop [my-map {} my-keys (seq keys) my-vals (seq vals)] (if (and my-keys my-vals) (recur (assoc my-map (first my-keys) (first my-vals)) (rest my-keys) (rest my-vals)) my-map)))
04:58clojurebotDENIED
04:59yangsx,(my-zipmap [:a :b :c] [1 2 3])
04:59clojurebotjava.lang.Exception: Unable to resolve symbol: my-zipmap in this context
05:01yangsx,((fn [keys vals] (loop [my-map {} my-keys (seq keys) my-vals (seq vals)] (if (and my-keys my-vals) (recur (assoc my-map (first my-keys) (first my-vals)) (rest my-keys) (rest my-vals)) my-map))) [:a :b :c] [1 2 3])
05:01clojurebotExecution Timed Out
05:03yangsxhi, anybody know why the example at the end of http://clojure.org/functional_programming cited above does not produce a result? I guess it might be a bug. Can anybody confirm that?
05:06Chousukeyangsx: looks like a bug; the rest calls should be nexts instead
05:08Chousukelikely a remnant from the not-so-lazy times when rest returned nil instead of ()
05:36yangsxChousuke: I see the problem now. The example at the web page should be fixed then. Hopefully jhickey will notice this.
07:05manytalksanyone going thru the programming-clojure book?
09:03Chouserit'd be neat if 'apply' could indicate that it returns the same type as its first arg does, without manual hinting.
09:37cgrandChouser: reduce too... would the Qi stuff -- that Rich mentioned -- help to do that?
09:38Chouseryeah, I wonder. it does seem a bit like you'd need a language (datalog?) to descibe the rules.
10:53digash,((fn [fn] (list fn (list (quote quote) fn))) (quote (fn [fn] (list fn (list (quote quote) fn)))))
10:53clojurebot((fn [fn] (list fn (list (quote quote) fn))) (quote (fn [fn] (list fn (list (quote quote) fn)))))
10:56porpoisei'm trying to write a macro that defn's a function, but am getting "can't use qualified name as parameter"
10:56durka42nice quine :)
10:56durka42porpoise: paste it?
10:57porpoisefor example (defmacro make-mult [name mult] `(def ~name [x] (* x ~mult)))
10:58porpoiseer make that
10:58porpoisefor example (defmacro make-mult [name mult] `(defn ~name [x] (* x ~mult)))
10:58digashthat is the shortest I could come up with.
10:59durka42right so the ` is resolving everything inside it to a namespace
10:59durka42so it comes up with user/x and defn doesn't like that
10:59durka42(do a macroexpand to see what i mean)
10:59digashyep
10:59porpoiseyup
10:59durka42to prevent it use ~'x
11:00durka42digash: looks very similar to http://www.nyx.net/~gthompso/quine.htm
11:00porpoisethanks! works
11:01porpoisenow i just need to understand what happened
11:01porpoise` causes everything in the form to resolve to a namespace?
11:02porpoise~ binds to the macro parameters, and ' prevents resolving to the namespace?
11:02clojurebotTitim gan �ir� ort.
11:02durka42the first about ` is right
11:02digashdurka42: i started with another one from Peter Norvig's paper http://portal.acm.org/citation.cfm?id=121989.121990
11:02Chousukehm
11:03durka42~ is unquote, it "breaks out" of ` and forces evaluation of the form after it
11:03clojurebotI don't understand.
11:03durka42,(let [a 3] `(a ~a (inc a) ~(inc a)))
11:03clojurebot(sandbox/a 3 (clojure.core/inc sandbox/a) 4)
11:04durka42' always quotes things so ~'a evaluates 'a, which is just a, not namespace/a
11:04Chouserof course it'd be better to use x# unless you specifically intend to capture x
11:04Chousukeright.
11:04Chousukewas just about to say that ;)
11:06Chousuke(defmacro whatever [name thing] `(defn ~name [x#] (stuff x# ~thing)))
11:08Chousukein general, ~'foo is rarely needed; it's usually simply wrong unless your macro is *intended* to introduce names that are not passed as a parameter to the macro
11:12Chousukein the above example, the user wouldn't care about what the function parameter is called, so using ~'x would be wrong
11:13rhickey_please use x#
11:14rhickey_that's why it's there, to prevent capture, ~' is for intentional capture, rare
11:19gnuvincerhickey_: for a second there, I thought you were recommending we use X Sharp (http://www.xsharp.org/)
11:20Chouserha!
11:20cemerickX# is code and code is poetry, ? X# is poetry!
11:20rhickey_yikes
11:21cemerickEither that, or X# is a big yellow kool-aid man.
11:24ChouserI've got a clojure lib that uses agents internally. It will generally be called from .java code. Currently the java app hangs, presumably waiting on the agent pools.
11:24clojurebotclojure is a language to use if you want to up your game
11:25ChouserI guess the only solution is for the java app to indicate somehow that it's done, so the agent pools can be shut down.
11:26ChouserShould I have it call Agent.shutdown() directly, or provide my own method that does the same thing?
11:27replacarhickey_: just wanted to let you know that everything is set up for the Bay Area Clojure meetup on June 3rd
11:29porpoiseis it possible for me to write a macro for scheme-y nested function defines, (nestdfn (((f a) b) c) (g a b c)) ?
11:30porpoisei'll try hacking away at it... it should be doable
11:30porpoiseright?
11:31replacaporpoise: did you look at letfn?
11:32porpoiselooking at it now
11:32porpoisethanks
11:33rhickey_replaca: where will it be?
11:34RaynesI'm going to take a wild guess and say the bay area.
11:34Raynes:D
11:34rhickey_Chouser: probably best not to expose Clojure internals to consumer apps
11:35porpoiseactually, maybe the scheme-y nested function defines, like (define ((((f x) y) z) w) (g x y z w)) isn't necessary because partial is a nice way of currying things
11:36replacaporpoise: does nesting enable currying? Is that what that's expressing?
11:37porpoiseyep, what it expresses is that (f x) returns a function that takes y which returns a function that takes w
11:37porpoiseand returns (g x y z w)
11:38porpoisei'm reading a physics book that uses scheme to express its ideas, and it uses that style a lot
11:38replacarhickey_: it's going to be at my office (unless we get a better location) -> about three blocks from Moscone
11:40replacaporpoise: I see. I like the haskell thing that *all* funcs are curryable at any arity. (partial) does kind of the same thing
11:40rhickey_replaca: sounds good - can you send me an email with the details (time/address)? Also, if other Clojurians are in town for JavaOne, I presume they'll be welcome as well?
11:40porpoisereplaca: yep, but if you're doing a lot of currying, you'll type "partial" a lot
11:42replacarhickey_: Yeah, I'll get you all the deets and I'm going for the biggest possible clojure crowd, so I'll post to the list, give you info that you can give to other interested folks at JavaOne and also invite the bayfp folks
11:42porpoisebut i can always give it another name if I use it that much, and if not, then "partial" is an easy to understand name
11:43replacaporpoise: yeah, the *really* nice thing in haskell is thet auto currying based on arity. Unfortunately, that kind of conflicts with multiple and arbitrary arities.
11:44replacaI know hiredman has done a bunch of stuff to support a more point-free style concisely
11:44porpoisereplaca: I like haskell a lot too. It's an interesting trade off that they went for.
11:45porpoiseI actually took up scala before clojure because i thought it might be more haskell like. But I ended up using it in a Java-ish way. Maybe I was using it wrong. I'm programming a lot more functionally in clojure, and the same program is half the length.
11:45replacaporpoise: I *really* don't like the idea (which seems to be in both scheme andd scala) that the writer of the function determines how it can be curried
11:46porpoiseright
11:46replacaporpoise: I've just been learning scala the last week or so, mostly so I can do some compare and contrast exercises
11:46porpoisein scheme and scala you need to check the function definition to make sure you're currying correctly
11:47replacaChouser: is it awesome? I went to a presentation by the author a year or so ago at bayfp and was very impressed. But I don't want to disappear back into Haskell right now
11:47replacaporpoise: yeah, that's just wrong
11:48Chouserit's informative. I now know now enough to make it a little further through the finger trees paper than I could before.
11:48Chouserit's easy to read, and doesn't shy from mentioning potential drawbacks in Haskell design decisions, which is a good way to earn my respect.
11:48aravindhi
11:49ChouserI'm reading the online web version, which has reader comment on almost every paragraph -- an interesting way to read technical material, for sure.
11:49Chouseraravind: hi
11:50replacaChouser: sounds like it might be a little distracting. RWH is on my reading list for sure, but not right this sec
11:50replacahaskell and clojure are both like bad drug addictions for me and I can't support being a double junkie right now :-)
11:50Chouserthe comments are collapsed by default, but if a paragraph is confusing, controversial, etc. you can tap the link and expand the discussion
11:51aravindI am new to clojure, and trying to write a LDAP connection library. I am using the novell jldap library and wanted to setup some sort of a connection object that runs a search, gets the results and disconnects. I was looking at the sql.clj source for ideas and it looks like they use with-open a lot.
11:51ChouserI don't expect Haskell to lure me away, but I feel like I need to be able to at least read Haskell code and should understand its type system.
11:52replacaChouser: haskell is really mind-bending when you get into it, but I'm sure you know that already
11:52Chouseraravind: all that with-open does is bind a local name and then call .close on it at the end of the block.
11:52replacaChouser: plus it makes you feel purer, like a buddhist monk or something
11:52porpoiseYeah, monads are purifying
11:53porpoisetaoist, perhaps?
11:53aravindit appears that with-open depends on the class having a .close method to terminate the connection, but jldap doesn't have that menthod. Am I looking at the right thing here, should I be extending the jldap classes?
11:53replacaporpoise: :-)
11:53replacaaravind: do you need a shutdown there at the end?
11:53aravindChouser: right, what should I do if the class I am using doesn't have a close method?
11:53Chouseraravind: does it need to be closed via a method of some other name?
11:54aravindreplaca: well.. jldap uses a disconnect. It would be nice if with-open took a method name as an optional argument or something.
11:54aravindclows: right.
11:54replacaaravind: you can just use (try ... (finally )) to accomplish the same thing
11:54Chouseraravind: or write a with-disconnect macro
11:54replacaaravind: or you can write an equivalent macro in about 2 lines of code
11:54replaca~def with-open
11:55replacaaravind: just look there and you'll see how simple with-open is
11:55Chouserha! 3 lines no more
11:56aravindokay. I guess, my question was more along the lines of "am I even looking in the right direction" and I guess I wanted to stick to what was already defined and is known to work, than invent my own thing...
11:56Chouserthat does sort of suggest a more general (with-finally close [...] ...) macro or something.
11:56aravindbut I guess writing my own is the way to go here?
11:59aravindI was also thinking if I should just extend the class with some sort of proxy that adds a close method, that then calls the disconnect method in the original class.
12:00replacaaravind: I'd go with writing your own
12:01aravindokay. thanks for the pointers.
12:01replacaThe problem with generalizing this is that you get awfully close to the try/finally form pretty fast
12:02replacaaravind: sure, glad to help
12:11replacarhickey_: question about metadata on namespaces?
12:12replacarhickey_: right now it seems to get lost in gen-class'ing, which means no ns doc for compiled classes.
12:12replacarhickey: should we have an issue on this?
12:52triddell,(dissoc {:a "a" :b "b" :c "c"} (first '(:a :b)))
12:52clojurebot{:b "b", :c "c"}
12:53triddellanyone know how I can remove the (first) above and dissoc both keys in the list? I know I could pass them literally in this example but the list comes in through a function parameter.
12:54technomancytriddell: apply?
12:55technomancy,(apply dissoc {:a "a" :b "b" :c "c"} [:a :b])
12:55clojurebot{:c "c"}
12:56triddelltechnomancy: thanks!
12:59twismdanlarkin: ping
12:59danlarkintwism: pong
12:59twismdid you ever get to run the test
12:59twism?
12:59danlarkinwhich test?
13:02cp2hello guys
13:04danlarkinhello
13:27noidiis there a standard way of stripping the namespace prefix off a symbol?
13:27noidi'foobar/baz --> baz
13:27Chouser,(name 'foo/bar)
13:27clojurebot"bar"
13:27Chouser,(symbol (name 'foo/bar))
13:27clojurebotbar
13:27noidithanks!
13:28Chousersure
14:13duncanmwhat's the status of streams in Clojure right now?
14:13rhickey_duncanm: waiting for my better idea (coming soon)
14:17sopelwhat's the clojure way to do python: [f(x) for f in collection]?
14:18cp2,(doc map)
14:18clojurebot"([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
14:18danlarkin(map f collection)
14:18cp2,(map #(+ 2 %) [1 2 3 4 5 6])
14:18clojurebot(3 4 5 6 7 8)
14:18Chouser,(for [x [2 3 4]] (* x x))
14:18clojurebot(4 9 16)
14:18Chousereither way
14:19hlshipIs clojurebot really a bot or just someone obessive w/ a clever name ? :-)
14:19sopelChouser is someone obsessive w/a clever neme, clojurebot is a bot
14:19sopel:)
14:19sopelthey both know everything though hehe
14:19Chouser:-P
14:20hiredmanclojurebot: how much do you know?
14:20clojurebotI know 300 things
14:20hlshipnow that's just freaky
14:21danlarkinChouser: how much do you know?
14:21hiredmansounds like everything to me
14:21ChouserI know nothing
14:21danlarkinborked! restart chouser
14:21sopel,(shutdown)
14:21clojurebotjava.lang.Exception: Unable to resolve symbol: shutdown in this context
14:21danlarkinChouser: now how much do you know?
14:22ChouserI know what you did last summer.
14:22sopelhehe
14:22danlarkin:-o
14:25hiredmanI wonder if wolfram has an ajax search api
14:26twismthey do have an api
14:29duncanmhmm
14:34durka42You can access the API via a web service from technologies such as AJAX and Flash, or from applications written in any programming or scripting language.
14:34durka42http://www.wolframalpha.com/developers.html
14:40sopelhm, what do i do if i want to have a global thread safe counter?
14:40sopelwhich i can increment.
14:41cp2(def *counter* (ref 0))
14:41cp2(dosync (alter *counter* ....))
14:41hiredmanor an atom
14:41hiredmanor an agent
14:41cp2yeah
14:41technomancyan atom sounds best, since inc is never going to block
14:41technomancykeeping it in a transaction is overkill
14:42cp2i suppose
14:42hiredmanwhat about agent vs. atom
14:43sopelok i was reading about atoms and it wasn't that obvious
14:43hiredmanChouser: where is the handy chart?
14:44hiredmanhttp://clojure.googlegroups.com/web/clojure-conc.png
14:45technomancyhiredman: if you were doing more calculation then an agent would make sense, but if all you're going to do is increment it, you don't need it to be async
14:46Chouserif you want to be able to get a new value from the counter in your current thread, an agent is a poor fit.
14:46Chouserif the value of the counter ever has to be synchronized with any other mutable state, use a ref
14:46Chouserif not, atom.
14:47sopelit's just an in-memory sequence (like a db sequence)
14:47sopelproviding consecutive numbers to threads.
14:50hiredmanyou could have a producer thread that just keeps counting upwards and puts each number in a bounded blockingqueue, then have your other threads read from the queue
14:50Chouserooh.
14:50Chouserseque
14:50Chouserhm
14:51Chousernevermind, that wouldn't work.
14:51hiredmanI dunno that seque would work
14:54Chouserbut still, that's an extra thread and the readers would still have to queue up to pull ids out. might as well use an atom.
14:54hiredman:P
14:55hiredmandepending on the amount of readers, the size of the queue, and how fast you can fill it
14:55sopelyea, and if i want thread pools then i use the java thread pools?
14:57Chouser,(_def id (atom 5))
14:57Chouser,(_defn get-id [] (swap! id inc))
14:57clojurebot#'sandbox/id
14:57Chouser,[(get-id) (get-id)]
14:57clojurebot#'sandbox/get-id
14:57clojurebot[6 7]
14:58Chouser,(get-id)
14:58clojurebot8
14:58Chousersopel: yep, or use agents, in which case they'll use their own thread pools.
14:58Chouser,(clear-temps)
14:58clojurebotnil
14:58Chouser,(get-id)
14:58clojurebotjava.lang.Exception: Unable to resolve symbol: get-id in this context
15:23ataggartjust to aid my understanding, how would the memoize fail if you replaced the map-holding atom with just a map?
15:24ataggartin the example at the bottom of http://clojure.org/atoms
15:24duncanmis there a call in the built-in libraries that'll take '((a) (b) (c)) into '(a b c) ?
15:24duncanmflatten?
15:24hiredmanataggart: how would you add new things?
15:24duncanmi thought (into '() '((a) (b) (c))) would work, but that's not it
15:24Chouser,(apply concat '((a) (b) (c)))
15:24clojurebot(a b c)
15:24hiredmanso memoize works by saying for input A the output is B
15:24duncanmoh, concat
15:25ataggartin the example, replace (let [mem (atom {})] with (let [mem {}], and (swap! mem assoc args ret) with (assoc mem args ret)
15:25hiredmanataggart: maps are immutable
15:25Chouser,(into [] (map first '((a) (b) (c))))
15:25clojurebot[a b c]
15:25hiredmanassoc does not add things to a map
15:26hiredmanit creates a new map with those things and the things from the old map
15:26ataggartbut isn't that what happens inside the atom anyway?
15:26hiredman,(let [a {:a 1}] (assoc a :b 2) a)
15:26clojurebot{:a 1}
15:26duncanmChouser: aha
15:26hiredmanataggart: in the atom, the old map is replaced with the new map
15:26duncanmright
15:26clojurebotmap is *LAZY*
15:26duncanmconcat is nice
15:27Chouserduncanm: concat is also lazy
15:27hiredman,(let [a (atom {:a 1})] (swap! a assoc :b 2) a)
15:27clojurebot#<Atom@1e9b67e: {:b 2, :a 1}>
15:27hiredman,(let [a (atom {:a 1})] (swap! a assoc :b 2) @a)
15:27clojurebot{:b 2, :a 1}
15:29ataggartwith regard to (let [a {:a 1}] (assoc a :b 2) a)
15:30ataggartif a is a varable accessed by the closure, then it does refect the changes
15:30Chouserlocals are also immutable
15:30ataggartat least that's what it loks like when I run the un-atomed version of memoize
15:31ataggarthm ok
15:31hiredmanataggart: it cannot reflect the change
15:32hiredmanif it apears to then you are doing something different
15:32ataggartah wait, ok, because assoc is returngin a new map, not changing the passed in map
15:32Chouserif you have code that you think shows a local or a clojure collection changing, feel free to paste it so we can help
15:32Chouseryes
15:32hiredman~paste
15:32clojurebotlisppaste8, url
15:32lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
15:34ataggartaha, I was basing this off of lack of difference between the execution time of the memoized fib, and my version. But I wasn't actually running the right code.
15:34ataggartI see it now
15:34ataggartnot using the atom takes just as long as not "memoizing" at all
15:34ataggartexcellent
15:54lisppaste8marklar pasted "Executing jar error" at http://paste.lisp.org/display/80618
15:54QvintvsI can't seem to get clojure working with jline. Running the command that the getting started page provides gives me a class not found error for clojure.lang.Repl (running clojure without jline as per the command provided on the getting started page works fine). Anyone have any suggestions?
15:54marklarI'm trying to package an app in a jar, but when I run it I am getting this error. Has anyone run across this? Or know of a resource that explains how to distribute clojure app?
16:00arbschtQvintvs: is your jline jar in the classpath?
16:01liebkeQvintvs: are you invoking the REPL with something like this: java -cp $LIBDIR/clojure.jar:$LIBDIR/jline-0.9.94.jar jline.ConsoleRunner clojure.lang.Repl
16:02Qvintvsliebke: yes
16:03Qvintvsoh, well the two jars were in two different dirs. does the jline jar need to be in the clojure jar's directory?
16:03liebkethey shouldn't have to be
16:03liebkeif they are both on your classpath, I have no idea what the problem is :(
16:43Chousershuting down self-sending agents is hard
16:44Chouseryou can send-off before shutdown-agents, and then still get an exception.
16:46Chouseryou can send-off a non-self-sending action to stop the looping, await on that, then call shutdown-agents, and (if one other action got queued behind you) still get an exception
16:47technomancyfunction composition makes me happy.
16:47technomancy(defmulti create-foo (comp class :content))
16:47ataggart,(doc comp)
16:47clojurebot"([& fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
16:48ChouserI'm staring to wonder if self-sending agents are really that great an idea after all.
16:48Chouserstarting
16:49mrsolowhat is self sending agent?
16:50ataggartan agent whose action function does a (send *agent* ...)
16:50ataggartI think
16:52Chouseryeah
16:52Chouseras demonstrated in the venerable "ants" code
16:59technomancyataggart: (comp class :content) is a less-punctuated version of #(class (:content %1))
17:02replacaI noticed this morning that clojure.xml/parse and clojure.contrib.prxml/prxml work on completely different clojure data structures. This seems wrong.
17:06Chouserthere's no way to empty out an agent's queue, is ther?
17:08durka42what does releasePendingSends do?
17:09Chouserit allows sends that aren't queued yet (because you're in an agent action or transaction) to go ahead and get queued.
17:09triddellany compojure users here? if I post JSON to compojure, how can I get a string of the entire request? normally a post has named parameters, etc... but I want the entire JSON string
17:12durka42what happened to c.c.repl-utils/source?
17:12Chouseryou tell me
17:12durka42or, i should say, why do all my vars have metadata :line 0
17:12durka42,(meta (var +))
17:12clojurebot{:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 569, :arglists ([] [x] [x y] [x y & more]), :inline-arities #{2}, :inline #<core$fn__3327 clojure.core$fn__3327@199182a>, :doc "Returns the sum of nums. (+) returns 0."}
17:13durka42clojurebot's are intact
17:13Chouseryou're on svn-something?
17:13durka42yeah
17:13durka42the latest, 1371 of core and 839 of contrib
17:14Chouserhm, I'm indescriminately switching off between 1.0 and 1364 or so.
17:17Chouseryep, looks like a regression. :line 0 here too
17:19durka42but it worked in 1364?
17:19Chouserworks with 1368
17:22Chouser1370 appears to have broken it
17:27Chouserrhickey: you want an Issue for that, a note on the group, or... ?
17:38durka42Chouser: commenting out Compiler.java:4964 (form = macroexpand(form)) fixes it, but i'm not sure what else that screws up
17:42ChouserI think that would partially or perhaps completely remove the purpose of that commit.
17:42durka42yes
17:49Chouserbut perhaps it could throw away the old value of form only in the 'then' case, not the 'else'?
18:12mozinatorhi guys, today I hacked a little with Clojure and JMusic to create a JMusic instrument, see it at: http://www.reddit.com/r/Clojure/comments/8mahz/using_jmusic_with_clojure_part2/
18:20technomancymozinator: looks cool. two suggestions: state your dependencies clearly, and use syntax-highlighting.
18:21technomancywhere does JMusic come from?
18:21mozinatortechnomancy, haven't found a Clojure syntax highlighting system for wordpress
18:21technomancymozinator: you could probably export HTML from your editor
18:22technomancythat's what I do anyway
18:22mozinatorQueensland University of Technology
18:22technomancymozinator: what I mean is that if people want to follow along, they'll want links to where they can download the jars they need to run your code
18:22mozinatortechnomancy, good idea, going to have a look how to do it with emacs
18:22technomancymozinator: search for htmlize.el on the emacswiki
18:22technomancyit's very nice
18:23mozinatortechnomancy, good advice :)
18:24mozinatormy ultimate goal is to make something like ipromptu http://www.google.nl/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fimpromptu.moso.com.au%2F&amp;ei=yNMVSpfROJPLjAf2xb3fDA&amp;usg=AFQjCNEGANbWR_xbxHqEroHdX9rhGMxPiA&amp;sig2=milUfOs55hMGZ9AIp4Lc1g
18:24mozinatoroops
18:24mozinatorhttp://impromptu.moso.com.au/
18:25technomancythat looks cool
18:25technomancytoo bad it's platform-specific
18:25mozinatortechnomancy, hence, the use of JMusic :)
18:26technomancygood deal
18:27mrsolobeside compile, what are some ways to reduce clojure startup time?
18:28technomancymrsolo: if you're on a 32-bit machine, make sure you're running the "client" jvm
18:28mrsolook
18:28mrsolowill switching jvm help?
18:28mrsoloi am using run of the mill sun one
18:29technomancymrsolo: the sun one has two modes, client and server
18:29technomancyserver performs better over time, but starts slowly and IIRC uses more memory
18:30technomancynot totally sure how to check which one you're running though
18:30mrsolooh ya.. just tried it out.. 2x as fast in client mode on startup time
18:31technomancyyups
18:31mrsolostill.. substaintally slower compares to perl/ruby/python..sure hurting its ability to do scripting :-<
18:32hiredman(System/getProperty "java.vm.name")
18:32technomancyclojurebot: what is nailgun?
18:32clojurebotI don't understand.
18:32hiredman~google nailgun
18:32clojurebotFirst, out of 829000 results is:
18:32clojurebotnailgun*
18:32clojurebothttp://www.nailgun.tv/
18:32hiredman:(
18:32hiredman~google nailgun java
18:32clojurebotFirst, out of 7390 results is:
18:32clojurebotNailgun: Insanely Fast Java
18:32clojurebothttp://martiansoftware.com/nailgun/index.html
18:33mrsolonice
18:35mozinatortechnomancy, htmlize works beautifully, thanks for the tip
18:35mozinatortechnomancy, I also put some background info to the post
18:36technomancyvery nice
18:43hlshipI got my evaluation thing working
18:43hlshiphttp://paste.lisp.org/display/80624
18:43hlshipI wonder if it could be simpler
18:43hlshipThe trick was to defer the evaluation of the forms until in the correct namespace
18:43hlshipso I needed an extra (eval) to pull it off
18:44hiredmanugh
18:46hiredmanwhat are you using this for?
18:46hiredmandefining functions in another namespace?
18:51hlshipyes, defining functions in another namespace
18:52hlshipI working on a templating system
18:52hlshiptemplates are XML
18:52hlshipinside the XML are Clojure expressions
18:52hlshipthe template is turned into a function
18:52hlshipthe Clojure expressions are also functions
18:52hiredmanhttp://paste.lisp.org/display/80624#1
18:53hlshipI.e. <span color="${(env :span-color)}">alert</span>
18:53hiredmanlike I told you yesterday, use intern
18:54hlshipthanks for the example, I can see if that fits my needs
18:55hiredmanand don't use in-ns
18:55hiredmanit is fine for switching namespaces in the repl
18:55technomancyI hate to say it, but that looks like it's coming dangerously close to blurring the view/logic barrier.
18:55hiredmanbut really you should do something like (binding [*ns* (create-ns 'some-name-space)] stuff here)
19:00hlshipThe docs are really specific on not using anything but (in-ns) or (ns) to change *ns*, but I can try the binding option if that helps.
19:01hlshipThe concept is based on Tapestry; it's a hierarchical pull MVC model.
19:01hiredmanwhich docs? where?
19:01hiredmanah
19:01hiredmanclojure.org/namespaces
19:02hlshipThe current namespace, *ns* can and should be set only with a call to in-ns or the ns macro, both of which create the namespace if it doesn't exist.
19:03hlshipanyway, any Clojure expressions embedded in a template should be evaluated in the same namespace as the template, with access to namespace private vars (such as functions)
19:03hiredmanin that case, binding is the way to go
19:06mrsolook nailgun works..sorta...
19:09mrsoloclojure.lang.Script bars on Stream closed exception ... Repl exits too fast before output is finished..heh
19:09hiredmanmrsolo: use clojure.main
19:10hiredmanScript and Repl are depricated
19:17mrsoloallright..very nice :-)
19:17mrsolothx
20:14mrsoloemacs c-c c-k seems to be broken ...
21:09emacsenOkay, I'm banging my head against Java. I have a jar on my classpath but I can't import the classes. I don't quite know how to start figuring out what's wrong. Anyone have a guide like "Java for Clojure people"?
21:09clojurebotclasspath is (System/getProperty "java.class.path")
21:32chessguyok, so i've got a clojure architectural question. i want to implement a protocol called winboard, which is basically a text protocol for communicating with engines. so the idea would be that the client of my library could simply define an engine that knows how to play, and my code would provide the UI wrapper for it
21:34chessguybut i'm really not sure how, overall, to architect such a thing in clojure
21:34emacsencommunicating with engines?
21:35chessguyi'm wondering if i want to provide a defmulti in my library, and let the client define new independent functions for it
21:35emacsenchessguy, your question seems really vague
21:36chessguyemacsen, yeah as in, how specifically do you say "here's a position, what move do you want to make?"
21:36emacsenOkay, do you realize you never even said this was for a game of chess?
21:37chessguyoh boy
21:37chessguysorry
21:37chessguyhaha
21:37chessguyyes, that must have sounded veryy strange
21:38chessguyi was trying to figure out how to summarize a lot at once into a succinct question, and i didn't do a very good job
21:39emacsenI'm personally hoping someone can answer my question about, basically seeing what I can import... I guess if there's a way to ask for the tree of defined namespaces (?)
21:41emacsenas for your UI wrapping code, I'm going to assume that your code simply communicates over this protocol...
21:41emacsenso somewhere in the protocol you specify which "engine" you want to use?
21:41emacsenwhy do you need a defmulti? Why can't you just specify the engine over the wire?
21:42chessguywell, there's a program called winboard too, for example. the program takes, as a parameter, the name of a chess engine executable. it starts that engine, and then communicates with it, via the winboard protocol, on stdin and stdout
21:43chessguyi want to write the code that communicates with the program once, and potentially have a number of different actual engines
21:44emacsenwell without seeing it in more detail I can't say anything, but it sounds like defmulti isn't really necessary here
21:45chessguyok
21:45emacsenmaybe I'm wrong. Maybe you do want to dispatch, but I don't think so
21:45emacsenbecause it sounds (to me) like you're just talking over the wire
21:45emacsenbut I don't know your problem set
21:45chessguyover stdin and stdout, yes
21:46emacsenisn't winboard the thing that the GPL fight was over? :)
21:46chessguyhm, i haven't heard that one
21:46chessguybasically, i want to be able to write a chess engine by just saying (def engine ....); (def main (runwinboard engine))
21:47emacsenIChessU
21:47emacsenthat was the one
21:47emacsenchessguy, okay, so here's a naieve answer... why not just try it?
21:48chessguytry what? i'm telling you, i don't know how to go about an overall architecture
21:48emacsenwell that's how we learn :)
21:48emacsenby doing
21:48emacsenand it doesn't have to be right the first time
21:48chessguyi'm not worried about getting it wrong. i literally don't know what to do
21:49emacsenstart from the bottom
21:49emacsenand work your way up
21:49chessguythe only thing i can think of would be to have engine be a function that, when run, produces a map from symbols to functions
21:50emacsenyou're all over the place
21:50chessguyi'm new to lisps
21:50emacsenwell, what languages do you know?
21:50chessguyi have functional programming experience in haskell, but i'm a little weirded out by the complete lack of type system in lisp
21:51p_lchessguy: what lisp? cause there are ones which use static typing and ones that don't :)
21:51emacsenYou just seem to be obsessed with the overall design and not thinking about the individual parts
21:51p_l*which
21:51chessguyp_l, uh...clojure?
21:52emacsenCan you write something to talk to winboard over the wire manually?
21:52emacsenor via stdin/stdout or whatever
21:52p_lclojure afaik conforms to Java's static typing, didn't it?
21:52chessguyemacsen, what do you mean?
21:52emacsenI'm saying... do the low level stuff first
21:52emacsenDo the grunt work
21:53chessguyi guess i'm too SICP-struck
21:53chessguywith their top-down approach
21:53ataggartemacsen: you still having a problem importing?
21:53emacsenand then once you can do that, think about the way your lower level pieces will fit together. I think you're suffering from too much top-down thinking
21:53emacsenataggart, I don't know where my problem lies. I don't understand this Java stuff :)
21:53ataggartwhat are you trying to do?
21:54hiredmanemacsen: are you sure it's in your classpath?
21:54emacsenataggart, There's a java library I want to use. I have the jar in my classpath
21:54hiredmanare you sure?
21:54p_lchessguy: funny how most of what I have seen in lisp world is bottom-up :D With top-down usually having the form of "I type (myapp) in repl, then I fix the bugs it caused" :)
21:54emacsenit prints out the jarfile when I ask clj for my classpath
21:54hiredmangood
21:54gnuvince_Has anyone been having problems with Slime lately?
21:54chessguyp_l, the art of wishful thinking :)
21:54hiredmanhow are you trying to import it?
21:55emacsengnuvince, it's completely broken for me. I've gone back to inferior-lisp
21:55emacsen(:import javax.mail)
21:55ataggartok, then (ns my-ns (:import [some.package] [some.other.package ItsClass]))
21:56emacsenI have to declare a namespace to import the library?
21:56hiredmanemacsen: is javax.mail a class?
21:56hiredmanemacsen: no
21:56emacsenhiredman, no... But I want to see the classes inside it. I don't know how to ask it for that
21:56hiredman(import '(javax.mail someclass))
21:56p_lchessguy: it works quite well, I heard :D
21:56hiredmanemacsen: there is not import * in clojure
21:56p_lchessguy: at least in CL
21:57emacsenhiredman, okay but can I ask java.mailx for its classes?
21:57ataggartnot really
21:57hiredmanI believe you cannot
21:57hiredman~jdoc java.lang.Class
21:57ataggartthats what javadoc is for
21:58hiredmanactually
21:58emacsenoh
21:58emacsenI have no experience with Java. This has proven a hinderance with learning clj
21:58hiredmanwell, just learn to read javadocs
22:00emacsenhiredman, yeah... I was trying to go off examples: http://javamaildir.sourceforge.net/examples/ but these seem to pollute the namespace in ways I can't tell where the classes are being called from
22:00emacseneg "Where the heck is Session? In javax.mail or javax.mail.internet?", etc.
22:01hiredmanemacsen: javadocs will tell you
22:01hiredmanmost javadocs java an index of classes
22:01emacsenokay, I'll have to learn that
22:03ataggarthttp://java.sun.com/products/javamail/javadocs/index.html
22:03emacsenyeah I'm reading them. It's just not clear to me as I read it how the parts fit together
22:04ataggartusually that's listed in the package docs
22:04ataggarte.g., http://java.sun.com/products/javamail/javadocs/javax/mail/package-summary.html
22:04ataggartscroll down
22:05emacsenuser=> (import '(javax.mail Properties))
22:05emacsenjava.lang.ClassNotFoundException: javax.mail.Properties (NO_SOURCE_FILE:0
22:05emacsenso, I can't tell... is that me failing to call it right or not in classpath?
22:05ataggartClassNotFound
22:05ataggartit;s not in the classpath
22:07emacsenataggart, do you mind if I msg you directly my classpath?
22:07ataggartgo for it
22:28mrsolothank got for M-x clojure-install... geez
23:52durka42Chouser: i think i fixed the problem with 1370 without removing the point of the commit
23:52durka42clojure.lang.Compiler/macroexpand throws away the metadata somehow
23:53lisppaste8durka42 pasted "clojure/lang/Compiler.java" at http://paste.lisp.org/display/80629
23:55durka42note that clojure.core/macroexpand does not throw away metadata