#clojure logs

2009-11-23

00:57gilbertleunghi
00:58gilbertleungi'm trying to use wall-hack-method, which requires a list of params to be passed in
00:59gilbertleungif the param is of string class, then i just pass in java.lang.String
00:59gilbertleungso... what if the param is of String[] ?
01:00hiredman,(-> "foo" vector into-array .getClass)
01:00clojurebot[Ljava.lang.String;
01:00hiredman,(Class/forname ""[Ljava.lang.String;"")
01:00clojurebotEOF while reading
01:01hiredman,(Class/forName "[Ljava.lang.String;")
01:01clojurebot[Ljava.lang.String;
01:01gilbertleunghmm
01:02hiredmanit is less than ideal, but most things dealing with classes of arrays are
01:04gilbertleunginteresting
01:04gilbertleunghiredman: thx
01:06hiredman,(-> "foo" vector into-array class)
01:06clojurebot[Ljava.lang.String;
02:23mrSpechello
05:41ordnungswidriganybody using leiningen on w32?
05:42Bjeringis there a function to list all my variables so I can run test on those that have :test metadata?
05:45ordnungswidrigBjering: all vairables or all functions?
05:46liwpBjering: you can look up the vars in a namespace I think
05:46Bjeringall variables that holds functions
05:47liwpso you could iterate over all the vars exported by a ns and see if they have :test metadata on them or not
05:47BjeringWhat I am really after the best way to manage my unittests, I have no java legacy its a new project. I am new to Clojure.
05:47Bjeringyes that was my idea
05:47liwpBjering: you should look into the clojure test framwork: clojure.test I think
05:49liwp,(doc clojure.test)
05:49clojurebotjava.lang.ClassNotFoundException: clojure.test
05:49liwpor not...
05:50Bjering,(doc test)
05:50clojurebot"([v]); test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception"
05:50BjeringThats all the doc I find
05:51liwp,(doc clojure.test-is)
05:51clojurebotjava.lang.ClassNotFoundException: clojure.test-is
05:51liwpgrr
05:52Bjeringnow I am reading "the book" now, and it describes the test-is library. I just wanted to go with the core test first, until it was proven to me it wasnt enough. Maybe I already reached that point?
05:53liwpAFAIK clojure.contrib.test-is got moved to clojure.test and it's used e.g. in writing tests for core
05:53liwpI haven't used it myself, but there's an oldish article about it at http://stuartsierra.com/2009/01/18/tests-are-code
05:54liwpseems straight forward enough, i.e. I don't think you need to worry about it being overkill for you needs
05:54Bjeringthank you, I'll read that
06:15cypher23VimClojure question: The keybindings don't seem to work, is there anything I need to do to activate them?
06:57rhickeyheh, potential JDK syntax for function expressions? #() :) http://www.jroller.com/scolebourne/entry/closures_in_jdk_7
06:59_ato`:D
07:53Bjering_I want to rotate a vector, like this:
07:53Bjering_ (reduce conj (subvec v n) (subvec v 0 n)))
07:54Bjering_is there a way todo this O(1) ?
08:02ordnungswidrigBjering_ Rotate by one element? What about concat? (concat (subvec v n) (subvec v 0 n))
08:02ordnungswidrig,(let [v [1 2 3 4] n 3] (concat (subvec v n) (subvec v 0 n)))
08:02clojurebot(4 1 2 3)
08:02ordnungswidrig,(let [v [1 2 3 4] n 1] (concat (subvec v n) (subvec v 0 n)))
08:02clojurebot(2 3 4 1)
08:06Bjering_ornungswidrig: Ah perfect, now it would be great if concat was listed among "related functions" ner vector at http://clojure.org/data_structures
08:07ordnungswidrigBjering_ yes, the api is very large and dynamic typing makes it hard to browser for matching functions.
08:08Bjering_I understand
08:10Bjering_hmm, concat destroys the "vectorness" though, its a lazy-seq
08:10ordnungswidrigBjering_: but is O(1) I suppose :-)
08:11Bjering_As long as I dont want to use it as a vector later.
08:11ordnungswidrigBjering_: you mean random access?
08:11Bjering_yes, such as subvec
08:11Bjering_,(= [1 2 3 4 5 6] (concat [1 2 3] [4 5 6]))
08:11clojurebottrue
08:12Bjering_one is a seq, one is a vec still they are equal?
08:12ordnungswidrigBjering_: you'd better ask somebody who is more familier with clojure's datastructurs. I don't know them very well.
08:16ordnungswidrig,(let [v [1 2 3 4] n 3] (vec (subvec v n) (subvec v 0 n)))
08:16clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$vec
08:17Bjering_Well, I can make my rotate return a vector by using the vec-ctor, sure, but I assume the vec call is O(n)
08:19ordnungswidrigBjering_: basically you need sth. like concat for vectors which is O(1)
08:21Bjering_yes but this doesnt exist?
08:27chouser,(into [1 2 3] [4 5 6])
08:27clojurebot[1 2 3 4 5 6]
08:27chouserThat's roughly O(n) where n is the length of the second vector
08:28rhickeyBjering: there is no constant-time vector rotate in Clojure
08:28Bjering_ok, thats the best possible?
08:28Bjering_ok
08:29rhickeyso, in playing with callsites I've added the ability to more-statically link to defn-ed vars you know won't change (e.g. clojure.core), for significant perf boost in some situations, thinking about how best to expose/express this option
08:30rhickeycould be at the var or lib levels, property of the author or consumer...
08:31chouserhm, fun...
08:32rhickeyseems to give 20% perf boost easily, and can be many times that when a small work unit gets inlined
08:32chouserthat's a bit better than I saw going from vars to letfn in finger tree
08:32rhickeyyou would never need letfn for perf again
08:32chouseryay
08:33rhickeythe tradeoff is, no dynamic rebinding, no redef without reloading deps (not a restart though)
08:34rhickeyI found few cases of dynamic rebinding of fns, one in test itself, some in a mock and trace lib
08:35rhickeyso, this ad hoc capability is costing everyone, even when not used, but can be tricky to determine granularity of expressing static/non
08:36chouserproducer could provide a "hint" and a consumer could still override that, right?
08:37rhickeyit's notthat simple when you think of libs that might dynamically rebind something expecting that to be in effect for called code that statically linked
08:37rhickeythat's a made-up but possible case
08:39chouserah, right. like a trace applied to someone else's code
08:40djorkis there a standard way to create a fully-qualified symbol from a "base" symbol and a namespace?
08:40rhickeyso there are a few division points - this fn was designed to be rebound, this lib is done/static, this code is under dev/dynamic, this lib superimposes dynamism on things it doesn't own
08:40djork,(namespace 'foo/bar)
08:40clojurebot"foo"
08:40djorkshould I just do it with strings
08:41djork,(str "some-ns/" (name 'foo))
08:41clojurebot"some-ns/foo"
08:41rhickeyfor the latter case there could just be a 'turn off direct linking' option, back to old semantics
08:42rhickeybut if on consumer side, :requires in different libs could have conflicting directives re this
08:42durka42,(symbol "foo" "bar")
08:42clojurebotfoo/bar
08:43djorkah, thanks a lot durka42
08:46djorkhmm, can't use private fns in a macro that's used somewhere else...
08:47chouseris it possible to get a warning if you try to rebind something that has direct linking?
08:55Bjering_the seq returned by (seq (vector 1 2 3)) is lazy I presume?
08:59Bjering_this paste-webpage I have seen you use, how do I use it?
09:01rhickeychouser: I guess if it was a property of the var in the first place - I haven't gone there yet, but on the todo is a more varied set of vars, with/without rebind e.g., and 'constant' vars
09:02rhickeybut while linkage could be a global property, it need not be, since it is really a property of each fn how strongly it links to the vars it references
09:07rhickeyone consuming fn could say - I'm happy with the current def indefinitely, another that is wants to see changes
09:08rhickeyof course, #' does the latter right now
09:11chouserBjering_: just go to http://paste.lisp.org/new/clojure and fill out the form
09:11Bjering_chouser: Thank you
09:13lisppaste8Bjering_ pasted "fast-drop" at http://paste.lisp.org/display/90945
09:14rhickeyalso on the table this weekend was putting protocol fn defs right into deftypes, and having protocols auto-generate interfaces. The desire is to hide the interfaces, which really are an implementation detail, but not have deftype + interfaces be more convient than deftype + protocols, and not have there be any code munging required to move an extend impl to an interface-based one
09:14Bjering_Is there a reason (other then deemed unimportant) why this kind of optimization isn't in?
09:14rhickeybut protocols-autogenerate-interfaces has the problems of gen-and-load-interface :(
09:17rhickeyBjering: special handling of particular data structures would bloat all of the standard fns, and how to decide which to special-case? When the standard fns are protocol-based, this kind of optimization will be easy, natural, and extensible
09:18Bjering_rhickey: Where can I learn about "protocol-based"?
09:18rhickeyhttps://www.assembla.com/wiki/show/clojure/Protocols
09:19Bjering_Thank you
09:19chouserBjering_: currently clojure's core fns and datatypes don't use protocols, but there are plans to move in that direction.
09:20mikem`Hi, I have a call to map like this: (map (fn [x] (list (keyword (first x)) (second x))) (some-seq)) -- instead of (fn ...) I tried to use #('((keyword (first %)) (second %))) but that throws java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn. what am I missing?
09:22chousermikem`: #(foo) is (fn [] (foo)) not (fn [] foo)
09:23chousermikem`: so you're trying to eval something like ('(a b))
09:23chouserbut a list is not a function, so you get an error.
09:24mikem`ok. so can I write a function like with #() that returns a list based on the argument it receives?
09:24rhickey(fn [x] (anything x)) ==> #(anything %)
09:25chousermikem`: #(list (keyword (first %)) (second %))
09:26mikem`ok, thanks! it's working.
10:48djorkare there any catches to using defmulti/defmethod across namespaces or files?
10:52chousernot really. a defmulti can be extended by a defmethod in any file or namespace
11:05hamza`~memoize
11:05clojurebotGabh mo leithscéal?
11:05hamza`how did we get the url to source for a function?
11:07jweissbah. paredit. doesn't do what i want in clojure. anyone here gone thru this already? (paredit in emacs)
11:07chouser~def memoize
11:07hamza`ool thanks..
11:07hamza`* cool
11:08liwpjweiss: I have
11:08liwpjweiss: I had problems with {} I think
11:08jweissliwp: ok, for instance, i want the slurp/barf to work within square braces. how do i do that
11:09jweissbtw i love that they named it 'barf'
11:09liwpjweiss: huh? what happens at the moment?
11:09liwpjweiss: slurp / barf are paredit functions?
11:09jweissliwp - that command does nothing if i run it withing square braces
11:09jweissliwp: paredit-forward-slurp-sexp
11:10liwpjweiss: what happens in your case?
11:11liwp~paste
11:11clojurebotlisppaste8, url
11:11lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
11:11jweissliwp - nothing happens. if i have this (let [a b | ] c) where | is the point, and i run that command, i want it to give me (let [a b c]) . but it does nothing.
11:13liwpjweiss: IIRC you have to hack paredit source to understand [] and {}. Let me see if I can figure out what I changed...
11:14jweissliwp: maybe just diff your paredit.el with the orig
11:14jweissor create patch :)
11:14liwpjweiss: have a look in paredit.el:667
11:15liwpjweiss: you should see a bunch of (define-paredit-pair) forms
11:15jweissliwp: yeah
11:15liwpdo you have forms for all these: () [] {} <>?
11:15jweissliwp yes
11:16liwpjweiss: uhh, must have been something else that I changed then...
11:16jweissround, square, curly, angled.
11:16liwpyeah
11:16jweissliwp: just run diff from http://mumble.net/~campbell/emacs/paredit.el to your file
11:18jweissliwp, or better just just pastebin your file and i'll use that :)
11:18jweisss/just just/yet just/
11:18liwpjweiss: yeah, let's try that for starters
11:18the-kennyI fell asleep two times in a row watching "Clojure Data Structures - Part 1". Sorry :(
11:18jweisswe should probably post this somewhere maybe on github for other people
11:19liwpjweiss: I'd love to figure out what I changed first :-)
11:19liwpuhh, "paste too large"
11:19jweissliwp: i'll diff it for ya if you like
11:19jweissliwp: maybe try the non-lisp pastebin
11:20jweisshttp://pastebin.com/
11:21liwpjweiss: apparently my paredit.el is identical to the one on the above url...
11:21liwpthis isn't really helping :-(
11:21jweissliwp. so you didn't change anything?
11:21jweissthat is... odd
11:22liwpjweiss: I distinctly remember changing something. IIRC I wasn't able to type in curly braces with the default paredit.el
11:23jweissliwp, for what it's worth, i CAN slurp in the next item if it's an sexp
11:23liwpjweiss: ahh, I think there's some magic in clojure-mode.el for paredit
11:24liwpjweiss: can you pastebin some code that doesn't work for you
11:24jweissliwp, ok, hm
11:24liwpjweiss: my clojure-mode say this: ./clojure-mode/clojure-mode.el:225: ;; Enable curly braces when paredit is enabled in clojure-mode-hook
11:24jweissliwp: yeah i think i have that too
11:24jweissthis is on the REPL by the way
11:25liwpahh, I don't have paredit enabled on slime repl
11:25jweissliwp: (interpose [|] :a [1 2 3])
11:25jweisswhere the cursor is at the |
11:25jweissi want to slurp in the :a
11:26liwpjweiss: I get this after a slurp: (interpose [| :a] [1 2 3])
11:26liwplet me try that in the repl
11:27jweissliwp: works for me in a clojure file
11:27jweissnot the repl tho
11:27liwpjweiss: yep, works there as well
11:27liwpjweiss: is that a slime repl or the inferior-lisp buffer?
11:27jweissliwp, slime-repl
11:28jweissok i think i have a problem in my .emacs, let me see if i can fix liwp
11:28liwpjweiss: seems to work for me everywhere, sorry I can't help :(
11:32mattreplany active contributors know if it's fine to self-assign an open ticket in assembla?
11:34Chousukemattrepl: I don't think the assigment system is used for anything other than tracking who's working on the issue
11:35mattreplChousuke: thanks
11:35liwpmattrepl: I think so. If you think that you can fix something, go for it. The patch will go through verification before it's applied in any case.
11:38jweissliwp: ok i figured it out. had to enable clojure-mode in the repl, and then enable paredit-mode in the repl.
11:38JorejiHey guys, how can I dispatch a multimethod on a & rest param? (e.g.: (defmethod [:one :two LazySeq] [one two & rest] nil) )
11:38liwpjweiss: good job
11:38jweissliwp: i am not sure how to get this to happen in my .emacs file tho, any suggestion
11:39liwpjweiss: let me see what I do to get slime going...
11:41Jorejijweiss: (add-hook 'slime-repl-mode-hook (lambda()(progn(clojure-mode 1)(paredit-mode 1)))) ?
11:41jweissJoreji: letme try that
11:41liwpjweiss: it seems that I don't have clojure-mode enabled in my slime-repl (I don't know why paredit seems to work for in that case). But I'm sure you can use some mode hook to enable clojure-mode
11:42liwpJoreji: yeah, something like that
11:44jweissJoreji: didn't work, i get a strange message when i run slime:
11:45jweissbah, it won't even paste because it has multibyte chars
11:45jweissJoreji: error in process filter: progn: Wrong number of arguments: #[nil (and then bunch of list items)
11:47liwpjweiss: try it without the progn, i.e.: (add-hook 'slime-repl-mode-hook (lambda () (clojure-mode 1) (paredit-mode 1)))
11:48JorejiHmm strange
11:49jweissliwp: Joreji, nope, same err
11:49JorejiI doubt the problem lies with the top level progn
11:50Jorejithen again, I've just activated clojure-mode inside my repl, and I must say that I don't see the use for it.
11:50JorejiYou can't have the repl-mode and clojure-mode be activated at the same time.
11:51jweissJoreji: hm, i can't get paredit to work right unless i activate clojure-mode
11:51the-kennyjweiss: Just add a hook to slime-repl-mode
11:51jweissthe-kenny: um, i'm an emacs newb, how do i do that
11:52Jorejijweiss: You already tried that.
11:52the-kenny(add-hook 'slime-mode-hook (lambda () paredit-mode +1))
11:52jweissthe-kenny: i don't think that's it. clojure-mode does something to make paredit work right.
11:52the-kennyjweiss: It's working for me.
11:53liwpJoreji: yeah, you're right, enabling clojure-mode disables repl-mode
11:53jweissthe-kenny: in the REPL?
11:53the-kennyjweiss: Yes
11:53the-kennyparedit doesn't have anything to do with paredit
11:53ordnungswidrigwhoohoo. chatting at the train with my g1
11:53the-kennyEw.. I mean clojure-mode
11:53jweissthe-kenny: try this: (interpose [|] :a) where | is the cursor, and hit C-[rightarrow]
11:53jweisssee if it slurps in the :a
11:54jweissthe-kenny: yes it does, i think. clojure-mode's code has some paredit stuff in it
11:55the-kennyjweiss: Hm.. you're right. It adds functionality for {
11:55the-kennyBut that works for me in my REPL without extra changes
11:55jweissthe-kenny: crap
11:56ordnungswidrigthe-kenny paredit doesn't work on { for me.
11:56the-kennyordnungswidrig: Oo strange
11:56jweissi can't seem to surround a list with [] in the repl
11:56the-kennyMaybe it works because I've opened a buffer in clojure-mode *before* I started the repl?
11:57jweissnor slurp the list into empty []
11:57ordnungswidrigwhen i insert a { no } is inserted. the rest works as expected... deleting etc.
11:57jweissordnungswidrig: yeah i don't get any curly brace love on the repl either
11:58jweissthe-kenny: i didn't realize it mattered where you start slime from
11:58jweissit opens a new buffer for me
11:58ordnungswidrigjweiss: in the clojure buffer i do not get it neither
11:59jweissordnungswidrig: oh yea, me neither
11:59liwpyou don't get {} in a clojure buffer?
11:59jweissliwp: no
11:59liwpjweiss: I do
11:59ordnungswidrigliwp: no insert of { after }
12:00liwpIf I type '{' I get '{}' and the point is in between the braces
12:00ordnungswidrigliwsp: tr/{}/}{/
12:00jweissliwp, doesn't work for me
12:00ordnungswidrigstrange stuff
12:00liwpjweiss: I think this is exactly what clojure-mode fixes in paredit.el
12:00jweissliwp: so what's going wrong then
12:01jweissloaded in the wrong order or something?
12:01ordnungswidrigmust i enable paredit by clojure-mode?
12:01liwpI don't think that should make any difference...
12:01ordnungswidrig...let enable...
12:02liwpI autoload paredit first and the require clojure-mode
12:02ordnungswidrighmm. i'm on debian unstable. does the clojure-mode version matter?
12:02liwpordnungswidrig: possibly, I think most people get it directly from github
12:03liwpI gotta run, good luck!
12:03ordnungswidrigiirc I use clojure installed by elpa-cl-swank
12:03ordnungswidrigyes, will keep trying. good to know that it can work fine.
12:04Chousukeelpa should have a recent enough clojure-mode I think
12:05jweissi installed it thru elpa as well
12:05jweissbut if i put (require 'clojure-mode) in my .emacs it won't start correctly
12:06jweissmy clojure mode is udner my ~/.emacs.d/elpa
12:08jweissaha, had to move the elpa stuff to the top of .emacs
12:15Bjering_What is the idiomatic way to check for the empty list? #(= '() %)
12:17stuartsierraBjering_: seq or empty?
12:17Bjering_thank you
12:50jweissif i have a little mini function i want to call a couple times within a defn, but i don't need the mini function anywhere else, is it ok to just define it in a let? or will this waste memory each time the larger function is called? i would hope it's the same as any place you use #()
12:51the-kennyjweiss: Let is fine..
12:51the-kennyI think there is also letfn or so
12:52the-kennyjweiss: You're on the JVM. The JIT does a good job in optimizing such things
12:58stuartsierraEach instance of (fn ...) or #(...) creates a single Java class. A new instance of that class is created each time you evaluate the fn/#() form.
12:59hiredmaneach time you compile
13:00hiredman(which is what eval does, but saying it happens each time you compile the form sounds less threatening)
13:00the-kenny,(time (dotimes (_ 100000) (let [foo (fn [] nil)] (foo))))
13:00clojurebotjava.lang.IllegalArgumentException: dotimes requires a vector for its binding
13:00the-kenny,(time (dotimes [_ 100000] (let [foo (fn [] nil)] (foo))))
13:00clojurebot"Elapsed time: 56.972 msecs"
13:00hiredmanthe-kenny: what will only compile the function once
13:01hiredmanthat
13:01the-kennyhiredman: That compiles only once? Very good :)
13:03bgs100,(map .toUpperCase ["a" "b" "c"])
13:03clojurebotjava.lang.Exception: Unable to resolve symbol: .toUpperCase in this context
13:03hiredmanbgs100: java methods are not first class values
13:03bgs100Oh
13:04hiredman,(map (fn [x] (.toUpperCase x)) ["a" "b" "c"])
13:04clojurebot("A" "B" "C")
13:04the-kenny,(map (memfn toUpperCase) ["a" "b" "c"])
13:04clojurebot("A" "B" "C")
13:04hiredman,(map #(.toUpperCase %) ["a" "b" "c"])
13:04clojurebot("A" "B" "C")
13:19defnhiredman, S. Halloway's book, eh? :)
13:19defnerrr, nvm, didn't notice the-kenny interjected there
13:20defnit should be noted that memfn is less favorable
13:20the-kennydefn: Why is memfn not favorable?
13:20defnIt came from when Clojure didn't have anonymous functions
13:20defnanonymous functions are the preferred way of using Java calls
13:21the-kennyah ok.. got it.
13:49krukowAnyone up for an emacs/slime classpath question?
13:51the-kennykrukow: Just ask. meta-questions are just time consuming
13:51krukowsure: I can use add-classpath to dynamically a to the classpath, yes?
13:51krukowfor example:
13:52the-kennykrukow: You could, but it's discouraged.
13:52krukow(add-classpath "file:////Users/krukow/emacs/enlive/enlive.jar")
13:52krukow(add-classpath "file:////Users/krukow/emacs/enlive/enlive.jar")
13:52krukowyes, just for a repl session
13:53krukowfollowing the enlive tutorial I am adding enlive.jar and tagsoup-1.2.jar
13:53krukowthis works fine. However adding: (add-classpath "file:////Users/krukow/emacs/enlive/src")
13:54krukowdoesn't seem to work for me
13:54krukowat least it can't see a file located in the src directory
13:55krukowit works with java -cp<paths here> clojure.main
13:56KirinDaveEnlive looks nice.
13:56KirinDaveI am glad the culture of sexp->html is not deeply rooted in the clojure community. It's such a tiresome practice to dispel.
13:58krukownoone on the emacs classpath q?
14:00the-kennykrukow: Which question?
14:00krukowI was wondering why seems to be able to see the html file in enlive/src with java -cp<paths here> clojure.main
14:01krukowbut not when using add-classpath file:////Users/krukow/emacs/enlive/src
14:01krukowinside emacs
14:02the-kennyBecause add-classpath is buggy ;)
14:02krukowoh ;-)
14:02hiredman~add-classpath
14:02clojurebotadd-classpath is Fraught with Peril!
14:02krukowwhich is why it is discouraged :-)
14:02the-kennyhiredman: Is ~ a shortcut for ,(doc name)?
14:03hiredman~ is a shortcut for clojurebot:
14:03clojurebotfor is not used enough
14:03hiredmanclojurebot: add-classpath
14:03clojurebotadd-classpath is Fraught with Peril!
14:04michaeljaakahi
14:04michaeljaakaI have question
14:04michaeljaakahttp://gist.github.com/241284
14:05michaeljaakaare these sequences whole consumed?
14:05michaeljaakaor only first element is evaluated
14:05michaeljaakaand removed as filter wants
14:06hiredmanmichaeljaaka: those sequences are not lazy, so it makes no difference
14:06michaeljaakabut if those were lazy?
14:06michaeljaakahow to check this in future
14:06hiredmanonly the first
14:06michaeljaakaI will have sequences from file
14:06hiredmancheck what?
14:06michaeljaakais there any simple way to ensure
14:07michaeljaakathat sequences are not evaluated?
14:07hiredman"sequences from a file" is pretty vague
14:09michaeljaakaif the filter computes after checking only first element from each seq, then it is ok
14:09michaeljaakathanks
14:13Chousukemichaeljaaka: note that functions that transform or consume sequences may consume more than is strictly necessary. first doesn't though, so in this case it's safe.
14:14michaeljaakaok, thanks
14:24esjany way of seq'ing an integer ? Doing an Euler problem where I want to treat a number as seq, and turning it into a string first seems a bit wasteful.
14:25Chousukeyou can devise another method of extracting the digits from an integer I suppose.
14:26rhickeyadd-classpath is not buggy, it just can't make the added classpath visible to all classloaders, thus, not that useful and to be avoided
14:27krukowok, interesting. can you explain why adding a jar seems to work while adding a directory does not?
14:27esjChousuke: sure I could do it numerically or via the string, but seems roundabout
14:29rhickeykrukow: don't use add-classpath, I'm going to remove it at some point. Use regular classpaths
14:30rhickeyI don't see a reason why jars and dirs would be different if the dir has the same structure
14:31krukowok, but it's still a nice feature to dynamically extend a repl session
14:31krukowexcept that it doesnt work of course :-)
14:32rhickeyI wish there was a standard way to extend the root classpath, but there isn't
14:33rhickeyif you are using JDK 6 you can add a wildcard dir to your classpath, then dynamically drop jars there
14:34krukowcool, didn't know that
14:34rhickeymy classpath ends with :/Users/rich/dev/ext/* and everything I put there is visible
14:35the-kennyDoes this really work? I remember problems with that
14:35rhickeyit's quite painless
14:35krukowI think I'll add something similar to my swank-clojure-extra-classpaths
14:36krukowthanks
14:36rhickeythe-kenny: java.ext.dirs can be tricky, but the wildcard isn't afaict
14:37chouserWith some effort I've gotten java.ext.dirs to work pretty consistently. I should probably try the wildcard instead.
14:37the-kennyhm.. so should "java -cp classes/*:lib/*:src/* my.class" work?
14:37chouserthe-kenny: probably "classes:lib/*:src" if you've got a "normal" layout
14:38the-kennyhm... does the order matter?
14:38chouserthe-kenny: if there are two classes with the same name in different places, yes.
14:39rhickeywildcards are for dirs containing jars only
14:39chouserthe-kenny: but I was pointing out that 'classes' and 'src' are usually each the root of a classpath, with dirs named like 'com' and 'org' in them.
14:39chouserwhile 'lib' is usually a directory full of .jar files.
14:39the-kennychouser: Yes, that's my layout.
14:40rhickeyhrm, claspath wildcards are not dynamic, guess I never really needed that
14:41rhickeyat least they keep you from ever-expanding classpath args
14:41rhickeyhttp://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html
14:41the-kennyI just started using `echo lib/*.jar|sed -e 's/ /:/g'` some minutes ago
14:41krukowok
14:42jweisscan someone point me to an example of using callbacks/listeners in clojure? I am trying to implement something like TestNG in clojure. testng is java, and to add a listener to it you implement one of their interfaces, and it calls your listener when certain events happen.
14:43the-kenny,(doc proxy)
14:43clojurebot"([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which creates a instance of a proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, must be first. If not provid
14:44chouserjweiss: 'proxy' is the best way to implement an interface
14:44chouserjweiss: there are examples in contrib and you can probably google for more.
14:44jweissok
14:44hiredmanhttp://clojure.org/jvm_hosted has an actionlistener example
14:45jweissproxy is not what i'm looking for though, i don't need to interact with testng, just do a clojure-only version of it
14:45chouseroh!
14:45chouserthen you just write a high-order function.
14:45chouser'map', for example, essentially calls the "callback" you give it, right?
14:46jweisschouser: yeah i know how to call a single function, but how to group them together like in java's interface?
14:46jweissi suppose i could just make a map
14:46jweissof keywords to fn's
14:47chouserjweiss: ah. In the "new" branch, defprotocol. but yes, a map would be perfectly acceptible.
14:47chouseractually, depending on your use cases a map might be best even if defprotocol were available.
14:47jweissi don't know if i'm ready to mess up my new emacs dev environment with the new branch :) i'll try maps
14:48the-kennyjweiss: "new" is very stable in my opinion.. never had a crash
14:49jweissthe-kenny: yeah i'm more worried about getting it working with swank-clojure
14:49the-kennyjweiss: Works without any problems here.
14:50jweisshm. so i just h ave to replace the jar i build in the swank-clojure emacs.d dir?
14:50the-kenny"git co new; ant clean; ant build" and the same for clojure-contrib was enough :)
14:50the-kennyjweiss: Hm.. Maybe you have to recompile the jar.
14:50jweissthe-kenny: swank-clojure jar?
14:50the-kennyYes
14:51jweissk, i'll give it a shot in a bit
14:51krukowkrukow:~/emacs/clojure/clojure$ git checkout new
14:51krukowerror: pathspec 'new' did not match any file(s) known to git.
14:51the-kennyYeah, you have to add the remote branch.. wait
14:54jweissgit checkout --track -b new origin/new
14:54jweiss?
14:54the-kennyyeah, something like this
14:56krukowgreat :-) really gotta read up on git soon...
15:01kzaryea me too krukow, submitted a patch the other day and it was pretty easy but I want to learn a lot more about it
15:03krukowsame here, I read a bit of theory about it but I don't know many actual commands besides git clone :-)
15:04the-kennygit is really cool :)
15:04chouserhttp://www.newartisans.com/2008/04/git-from-the-bottom-up.html
15:04krukowthx - reading it now
15:04chouserthat helped me a bit. I should probably read it again, actually.
15:04kzaroo thanks I'll read that later too
15:08kzarIs this kind of code OK or is it bad form to redefine stuff like this with let? (let [example "hello", example (take 3 example)] example)
15:08stuartsierrakzar: that's ok
15:09stuartsierraalthough it may be more readable to use different names
15:09chouserkzar: but it's good you're asking. :-)
15:09krukowI would have guessed that would result in an error, but it runs fine
15:09kzarHeh cool, it makes more sense in my actual code but I wanted to make sure it's not a taboo or something heh
15:10krukowwhy is that ok - I would consider it bad style
15:10hiredmanlet performs sequential binds so its like (let [example 1] (let [example 2] example))
15:10krukowah
15:10hiredmangenerally it's kind of icky
15:10hiredmanbut I do it all the time :P
15:10chouserit's no worse than using the same local variable to mean a couple different things in any other language.
15:10rhickeyme too
15:11krukowcan someone give a compelling example?
15:11hiredmanusually it means I mean incrementally mucking with a function
15:11hiredmanI have been
15:11fogus_krukow: I do it when I coerce
15:12chousermm, yes (fn [x] (let [x (int x)] ...))
15:12hiredmanhttp://github.com/hiredman/clojurebot/blob/master/hiredman/clojurebot/code_lookup.clj#L66
15:12hiredmanstarted out as google being the google url
15:13hiredmanthen clojure moved from google svn to github
15:13kzarkrukow: (I'm having a go at changing my tetris to be functional like a few articles I read. So I have signals being passed and I'm setting the signals to be the result of routing the signals, then setting the signals to be the result of routing the input signals. So I could call them signals, signals after processing, input-signals, input-singals-after-processing ... but I rather just keep 'changing' something called
15:13kzar signals)
15:13hiredmanso I wrote a transform to turn the google svn url into a github url
15:13chouserI guess I'd say it's a matter of taste. If you're *realy* rather say (fn [x-obj] (let [x (int xobj)] ...), then go ahead. But it hardly seems clearer.
15:14hiredmancode_lookup is icky anyway
15:14chousernearly all code that actually does anything seems to be icky in the end
15:14krukowLOL
15:15kzarchouser: At least all the code I've received money for has been
15:15krukowcan I quote that? ;-)
15:15chouserthat's one nice thing about projecteuler type problems. You can write tidy little solutions that you can feel good about.
15:15chouserkrukow: :-P sure
15:15hiredmansometimes it has a brutalist beauty
15:16chouserhiredman: that's true. the beauty of a good hack.
15:19esjchouser: you don't mean to tell me that once I've learn't clojure through PE my mercenary coding won't suddenly be beautiful. *crestfallen*
15:20hiredmanhttp://gist.github.com/184831 <-- I still like this
15:21hiredman~ticket search Keyword
15:21clojurebot("#154: (keyword \"a/b\") => ns nil, name a/b; should be ns a, name b" "#154: (keyword \"a/b\") => ns nil, name a/b; should be ns a, name b" "#154: (keyword \"a/b\") => ns nil, name a/b; should be ns a, name b" "#64: GC Issue 61: \t Make Clojure datatype Java Serializable" "#174: Make c.l.Keyword Serializable" "#6: GC Issue 1:\t:validator as keyword arg for ref/atom/agent" "#174: Make c.l.Keyword Serializable" "#200: Exte
15:21stuartsierrayowza
15:22chouserhiredman: I'm pretty sure I wrote zip-filter exactly so I wouldn't have to write code like that. :-P
15:23hiredman~ticket #64
15:23clojurebot{:url http://tinyurl.com/kv5v3t, :summary "GC Issue 61: Make Clojure datatype Java Serializable", :status :new, :priority :low, :created-on "2009-06-17T19:38:52+00:00"}
15:26krukowpeople don't like me at work anymore because of clojure...
15:27tmountainkrukow: why is that?
15:27jweissi'm guessing because clojure is greek to them
15:27krukowbecause I've started programming my Java more functionally, I think
15:27zaphar_pskrukow: yeah we want to know
15:27mauritslamersquestion: is it possible to create arrays of primitives inside clojure for use in calling Java functions?
15:28chouser,(into-array Integer/type [1 2 3 4])
15:28clojurebotjava.lang.Exception: Unable to find static field: type in class java.lang.Integer
15:28chouser,(into-array Integer/TYPE [1 2 3 4])
15:28clojurebot#<int[] [I@1738d88>
15:28tmountainkrukow: when every variable in your class begins with final, you know you've drank the koolaid ;-)
15:28krukowit does, but it's not just that
15:28jweissick, can't imagine trying to force java's square peg into that round hole
15:29stuartsierra,(int-array [1 2 3 4])
15:29clojurebot#<int[] [I@13bb93a>
15:29mauritslamerschouser: when I call my function with that, it returns a ClassCastException
15:29chouserstuartsierra: so much better!
15:29stuartsierrabut I think that creates an array, not convert
15:29stuartsierra,(doc int-array)
15:29clojurebot"([size-or-seq] [size init-val-or-seq]); Creates an array of ints"
15:29mauritslamersstuartsierra: checking out :)
15:29stuartsierranope, it converts to an array too
15:32mauritslamersstuartsierra: it seems to return the correct array, but when I call my function with the result, it still throws an ClassCastException
15:32krukowanyway, I find myself mimicking clojure constructs in the code
15:32chousermauritslamers: are you sure the method you're calling wants an array of primitive int?
15:32mauritslamers public byte[] convertDoubleArrayToByte(double[] incoming){
15:32hiredmanint[] is not double[]
15:32stuartsierraThat's a double array you want, then.
15:32jweisshehe
15:33mauritslamersof course :)
15:33mauritslamers(def heletoonsarray (double-array heletoonsbuffer))
15:33mauritslamersin which heletoonsbuffer is a list of floating point values
15:33krukowit's really quite facinating... I've never tried this with a language before
15:33mauritslamersdoubles to be exact
15:33chouserkrukow: using clojure idioms in Java?
15:34mauritslamerscalling the function with: (.convertDoubleArrayToByte dsp heletoonsbuffer)
15:35chousermauritslamers: you're saying that's what you've been doing and you still get the exception? Can you paste the whole stack trace somewhere?
15:35mauritslamershow do I get the whole stack trace?
15:35mauritslamersthe only message I get is: user=> (.convertDoubleArrayToByte dsp heletoonsbuffer)
15:35mauritslamersjava.lang.ClassCastException (NO_SOURCE_FILE:0)
15:36stuartsierra(.printStackTrace *e)
15:36chouser(.printStackTrace *e) if you're at a plain terminal repl
15:37mauritslamersthe stack trace only contains clojure stuff and sun.reflect et
15:37mauritslamers*Etc
15:37chouseryou can often get a better message too if you type-hint the first arg. (.methodOfFoo #^Foo dsp arg2 etc)
15:37mauritslamerschouser: http://gist.github.com/241351
15:38rhickeyurk, looks like pprint rebinds core fns
15:38hiredman:(
15:38chouserreally!? which ones?
15:38chouserpprint is rather ambitious
15:38hiredmanmauritslamers: can you pastebin your code?
15:39mauritslamershiredman: which code exactly?
15:39rhickeylooks like pr
15:39mauritslamersit is quite a lot :)
15:39krukowchouser: at least thinking much more in terms of identities and values
15:39hiredmanmauritslamers: the code that produces the exception
15:39hiredmanlike a small test case
15:39chousermauritslamers: did you try the type hint?
15:40mauritslamerschouser: when I do: (.convertDoubleArrayToByte #^ml.mesic.dsp.DSP dsp heletoonsbuffer)
15:40mauritslamersjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to [D (NO_SOURCE_FILE:0)
15:40chouserah, now we're getting somewhere.
15:40hiredmanmauritslamers: you are running map or something over the array at some point
15:41hiredmanso it is no longer an array
15:41mauritslamersit shouldn't...
15:41mauritslamersmoment. checking...
15:41mauritslamersah... oops ...
15:41chouser:-)
15:41chouserthe best words in a debugging session
15:41mauritslamers*shame*
15:41chousernaw, that's what debugging is all about
15:42mauritslamersit ain't gonna work if I keep feeding it with the wrong argument ... :\
15:42mauritslamersanyway: thanks a lot :D
15:43chouserI wonder why the error message is different for dynamic method calls
15:43krukowif the bug isn't there it's because it is somewhere else
15:43hiredmanhttp://hsivonen.iki.fi/rdf-competition/
15:44rhickeyso, that's a good example - some lib like pprint wants to redefine something like pr for everyone. Leaving all those hooks open means slowing everyone else down...
15:45rhickeyaargh - (deftest dotrace-on-core ...)
15:53mauritslamersinteresting... my function written in java is much much MUCH faster than the one in clojure...
15:55mauritslamersFor those interested: http://gist.github.com/241366
15:55mauritslamersthe clojure code takes at least half a second
15:57KirinDaveThe JVM is pretty notoriously bad at byte-level manipulation.
15:57mauritslamersbut why is the java code faster than the clojure code :)
15:58stuartsierramauritslamers: The difference in this case comes from the overhead of Clojure's persistent data structures.
15:58stuartsierraEvery call to your float-to-two-bytes creates a persistent vector as an intermediate value.
15:58mauritslamersso for this type of conversions it is better to write stuff in java
15:58mauritslamersand create a clojure wrapper
15:59rhickeyhrm, mocking is in obvious conflict with direct linking...
15:59stuartsierraAlso, Clojure's bit-shifting operations are not well-optimized.
15:59stuartsierramauritslamers: you would get closer to Java performance by writing a single function using loop/recur and Java arrays instead of reduce/mapcat
16:00stuartsierraBut you will probably not be able to match Java performance on bit twiddling (yet).
16:00rhickeyonly failures in clojure and contrib with direct linking are now in the mocking stuff
16:00mauritslamersstuartsierra: which is not really a problem, since I have to do other java stuff anyway :)
16:01mauritslamersI need the bit twiddling to be as fast as possible
16:01mauritslamersthanks!
16:01stuartsierrarhickey: what's this mocking/linking?
16:01mauritslamerstty all later!
16:02KirinDaveIt'd be cool if Clojure had optimized binary pattern matching like erlang. :)
16:02rhickeystuartsierra: I now can do direct-linking of call sites. For code you are not going to be changing at runtime, nor rebinding (e.g. core, etc) you can get much faster perf by limiting dynamism and directly hooking up the callee. The mocking is just the contrib library, the only thing left in contrib that doesn't work with direct linking
16:03stuartsierraI see.
16:03stuartsierraI like.
16:03wtetzner_how do i use the clojure printer from java?
16:03wtetzner_i found the reader in LispReader.class
16:03wtetzner_but i can't find the printer
16:04stuartsierrawtetzner_: You can invoke the clojure.core/print function directly.
16:04stuartsierraRT.var("clojure.core", "print").invoke(...)
16:04wtetzner_oh
16:04wtetzner_cool
16:04wtetzner_thanks
16:04hiredmanprn
16:04hiredmanI imagine you'll want prn
16:04wtetzner_so you can call any clojure functions that way?
16:05rhickeystuartsierra: fyi, test/report was another problem area
16:05wtetzner_hiredman: yeah, actually prn-str
16:05stuartsierraOh, yeah.
16:05rhickeybut now test/report and pr are marked {:dynamic true}
16:05krukowrhickey: why are these problematic?
16:05rhickeyso test and pprint work
16:05stuartsierrarhickey: Ok.
16:05rhickeykrukow: they are being dynamically rebound by design
16:06krukowok so just marking them is fine
16:06stuartsierrarhickey: So does this mean that any var which is dynamically rebound must be declared {:dynamic true}?
16:06rhickeykrukow: I've been testing all of clojure and contrib with direct linking
16:06KirinDaveOr can we enable an optimization by saying {:dynamic false}
16:06krukowwhat kind of speed up are you expecting from direct linking?
16:06rhickeystuartsierra: just vars that are invoked, so not your normal *foo* stuff
16:07stuartsierrarhickey: Ok, that's good.
16:07stuartsierraFunctions, in other words.
16:07rhickeyfunctions
16:07rhickeyright
16:07chouseryou get an error? when?
16:08rhickeykrukow: it can be quite substantial, depending on what the function does, but overall you can see 20% easily, some specific calls might be several times faster
16:09rhickeychouser: what error?
16:10chouserif you try to dynamically bind a static fn
16:10chouserdo you get an error or just the root binding behavior?
16:10rhickeychouser: no error, just won't be dynamic
16:10chouserhm
16:10KirinDaveSo you'd try to rebind it and it'd fail for some calls?
16:11rhickeyas I was saying before, direct linking is a property of the caller, not the callee
16:11rhickeyone caller could directly link and another not
16:11KirinDaveAh
16:11stuartsierraeven better
16:11stuartsierraSo which is declared {:dynamic true}? The caller or the callee?
16:12krukowI guess that could give some strange behaviour with binding core fns
16:12rhickeya directly linked caller will see the original value forever (or until they themselves are re-evaluated)
16:12rhickeykrukow: that's the question - who's binding core fns and why?
16:12rhickeythere was only one case in all of contrib - pprint
16:13rhickeynone in core
16:13rhickeytrivial functions can be 10x faster with direct linking
16:14rhickeyso, it's important, to me at least
16:14krukowI was just thinking of an example on the web:
16:14stuartsierraI assume direct linking allows the JVM to inline the function as well?
16:14rhickeybut the general question is, how do we want to talk about this, at what granularity, with what defaults
16:14rhickeystuartsierra: yep
16:14krukowcant find it right now, but I think it was about using binding to create som AOP like feature
16:15rhickeykrukow: one option could be - I never want direct linking
16:16stuartsierrarhickey: I feel I should mention that it feels like features keep getting added, pushing a 1.1 release farther into the future.
16:16rhickeythat is the simplest story for ad hoc whatever
16:16stuartsierraI mean, they're cool features, no question, but have you thought about where you're going to stop?
16:16hiredmanstuartsierra: 2.0 :P
16:17krukowactually it sounds very cool to me - just immediately trying find an example it would break :-)
16:17rhickeystuartsierra: none of this is going into 1.1. I would love it if someone would come up with a punch list for calling what we've got 1.1, producing some release candidates etc. I've added a new field in the tickets - bug/enhancement - I'd like to see all tickets categorized
16:17stuartsierraWould that include deftype/defprotocol?
16:18rhickeystuartsierra: nothing from new is going in 1.1, so no deftype/defprotocol
16:18spuzIn Clojure, if a variable is not actually variable... then what do we call it?
16:18hiredmanspuz: a binding
16:18rhickeyIt came up the other day that chunked seqs might be controversial - we need the broader community trying master
16:18krukowrhickey: when do you expect deftype/protocol?
16:19spuzhiredman: funny how I could read a whole book about clojure and not get that...
16:19stuartsierraIf it's any help, I've been using master for months without any problem.
16:19rhickeykrukow: soon after 1.1, at least with 1.1 out it can move into master and get more hands on it. But it is still a work in progress
16:20krukowreally looking forward to it, btw :-)
16:20rhickeystuartsierra: right, and yet, I think hiredman and AWizzArd were both troubled by it the other night, as it can change full lazy semantics. And we don't have a seq1 to force dribbling
16:21hiredmanspuz: I was just looking over the chapter on lexical bindings in essentials of programming languages
16:21rhickeyI'd love to know how the community breaks down as far as which release/branch they use
16:21stuartsierrarhickey: Ah, ok, hadn't considered that.
16:22rhickeyso, 1.1. is a matter of - no new enhancements, tidy up anything unfinished, produce release candidates and get broader feedback, cut a release when ready
16:23rhickeythe new branch work will follow 1.1
16:23krukowdiff 1.1 1.0?
16:23rhickeybut I am fully (like 10 hrs a day) occupied with the new branch, so people that want 1.1. have to step up and volunteer
16:24krukowI want the new branch :-)
16:24rhickeykrukow: right, but we want releases of things that are relatively stable, as is master right now
16:24krukowI'm not sure if it is my object oriented mind kicking in but I am missing deftype
16:25krukowsure - I value stability highly
16:25stuartsierrarhickey: I'm volunteering. :)
16:25rhickeybut yes, deftype/protocols fill an important gap
16:25rhickeystuartsierra: great!
16:26stuartsierraI'll start by making a which-release-are-you-using survey
16:26hiredmanclojurebot: stuartsierra is volunteering
16:26clojurebotc'est bon!
16:27stuartsierrarhickey: What do you want to know, besides http://spreadsheets.google.com/viewform?formkey=dFJSd1p4YXh0d0VxV0xjdk42MTU5RkE6MA
16:28chouserwhat's a SNAPSHOT release?
16:28spuzis there a command to reset the state of the REPL?
16:28stuartsierraThe maven repositories take snapshots of master roughly every 24 hours
16:28rhickeyis that from hudson?
16:28chouseris that just some version of master we've chose ourselves, vs. "github master" being continuouly upgrading?
16:28chouserah
16:29the-kennyWhat are chunked sequences? :)
16:29stuartsierrachouser: I was thinking keeping it up to date regularly.
16:30twbrayWondering why if-let only lets you do one binding... I have two or three bindings to do and some forms to run, but only if the first binding is non-nil. Why would that be wrong?
16:31chouserstuartsierra: ok. I recently switch our work code from 1.0 to some a recent 1.1-snap, but probably won't change it again until 1.1.0. wasn't sure which answer I'd pick for that.
16:31rhickeystuartsierra: question 1 is good enough for me. Maybe asking people if they know how to get from github or maven. But if we do release candidates we can make that just a download for everyone
16:32chousertwbray: some people that ask for mutliple if-let bindings only want the "true" case if all the bindings are true. you're asking for something different?
16:32rhickeytwbray: if if-let did multiple bindings, it would be unclear as to which would be involved in the conditional
16:32KirinDavetwbray: It's probably just historical. This is why we have macros and -contrib.
16:33twbrayHmm... I read the docs and assumed it would key off the first binding.
16:33spuzyes, what are chunked sequences? :)
16:33twbraychouser: Yep... I can see the ambiguity.
16:34krukowspuz http://blip.tv/file/2301367
16:34chouserhttp://www.assembla.com/wiki/show/clojure/Chunked_Seqs
16:34chouserhm, that's pretty thin
16:34twbraySo I'm left with (let [x (some complex fun)] (if x (let [bunch of other bindings]. Not terrible I guess.
16:34stuartsierraok, changed the questions a bit: http://spreadsheets.google.com/viewform?formkey=dFJSd1p4YXh0d0VxV0xjdk42MTU5RkE6MA
16:35hiredmantwbray: you can still use if-let
16:36spuzkrukow: thanks, it says "Rich Hickey, inventor of Clojure, talks about the new "chunked seq" architecture which allows first-order Clojure functions such as map to as fast (or faster) than hand-coded loops." why would that be a bad thing? Why ask the question in the questionnaire?
16:36KirinDavetwbray: Why not try and get a macro into contrib? I'm sure people would use it. It sounds useful.
16:36spuz(obviously, I still need to watch the video, but just incase it's not obvious...)
16:36rhickeystuartsierra: I recently made another milestone - Approved backlog - into which we can move things from Next Release that aren't going in, in order to use Next Release as a punch list
16:36stuartsierraok
16:37hiredmanspuz: it can alter the lazy nature of seqs
16:37spuzah I see
16:37hiredmanbecause chunked seqs are processed in 32 item chunks
16:37rhickeyhttp://clojure.googlegroups.com/web/chunks.pdf
16:38twbrayhiredman: Right... (if-let [x (some complex func)] (let [ other bindings] ...
16:38chousertwbray: that's not an uncommon pattern in my code, fwiw.
16:41falkor2hi, why is there clojure.lang.PersistentList$1 ? My question regards the $1, I seem to see it inside macros...
16:41chouserfalkor2: that's normal Java naming for a anonymous inner class
16:42twbraychouser: Thanks, that's the kind of thing a n00b likes to hear.
16:42falkor2yep, I know, but sometimes it is not therre
16:42rhickeylooks like there are a dozen or so patches waiting in backlog, but they should probably wait until after 1.1 unless trivial
16:43falkor2 (println (type '(1)) -gives persistentlist (no $1)
16:44hiredmanfalkor2: some annonymous subtype of plist
16:44falkor2 `(println (type ~lst)) [Note in macro], gets $1
16:44hiredmanimplementation detail
16:44hiredmanignore it
16:44chouser,(class clojure.lang.PersistentList/creator)
16:44clojurebotclojure.lang.PersistentList$1
16:45falkor2The problem is that I am doing type inspection (probably not in the best way...)
16:45chouserPersistentList$1 is a function, not a list
16:45hiredmanfalkor2: don't
16:46chouserfalkor2: lst may not be what you think it is, or may be being misused.
16:46stuartsierrarhickey: any more questions for the survey, before I post it to the group?
16:46falkor2I am doing macros (newbie) and I think I am being bitten by some confusion still lingering in my head...
16:47rhickeystuartsierra: the whole 'reliability' part of it seems a little weird
16:47stuartsierraWhat do you want to know?
16:47stuartsierraI thought that was the point.
16:47chouserfalkor2: seems plausible. maybe paste somewhere your macro that's includes the `(println (type ~lst)) ?
16:48rhickeyI think we get the reliability reports on the group etc, I really want to know if they are using master yet
16:48stuartsierraok, I'll drop that question.
16:48rhickeyi.e. are we close to 1.1. from a community feedback perspective, or have most of them never tried the master code, and we'll be seeing a lot of new reports once we do a release candidate
16:48stuartsierraAnd the "Describe any reliability problems..." question.
16:49stuartsierraok, just 3 questions now
16:49rhickeyit used to be, most people were on trunk, so when the bug reports eased, we were good to go. Now, I'm unsure what the ratios are, and with more, and more conservative, users, we might need a decent beta period
16:50KirinDaveSo where is the right place to get the most current stable clojure?
16:50KirinDaveThe github?
16:50stuartsierraKirinDave: define stable :)
16:50stuartsierraThere is one official release, 1.0.
16:50KirinDavestuartsierra: Well, usable.
16:50KirinDaveyes, but no one seems to use that. :D
16:50KirinDaveThey want the new features.
16:50chouserwell the 'master' features at least, if not the 'new' ones.
16:51falkor2chouser: I think I have to do a bit more self-investigation before I pester you guys ;)
16:51stuartsierraAll the major new features (reify, deftype, defprotocol) are on the "new" branch.
16:51stuartsierraThe "master" branch seems to be quite stable.
16:51KirinDaveSo are people going builds from http://github.com/richhickey/clojure:master?
16:51chouserfalkor2: ok, that's up to you. Don't get too frustrated though before asking.
16:51stuartsierraBut "master" doesn't have any whiz-bang new features.
16:51chouserfalkor2: and if it's about a macro, we have a form to help ask the question well.
16:52chouser~macro help
16:52clojurebotmacro help is http://clojure-log.n01se.net/macro.html
16:52rhickeyit's all usable, that's always been the Clojure way. some of the very latest features are works in progress, but you won't have existting code that a) uses them, or b) will be broken by them
16:52KirinDaveCool, so it's relatively safe to run off new then?
16:52rhickeyif you use the latest features, you are helping me define them with your feedback
16:52chouserstuartsierra: that's just an age thing. master has futures, chunked seqs -- good stuff!
16:52falkor2I have to say, coming from Prolog, that evaluation in lisp is made a bit complex and convuluted
16:52stuartsierrachouser: Oh, I thought futures were in 1.0
16:53rhickeyKirinDave: master is the best choice unless you are really interested in the new features and testing
16:53chouserstuartsierra: hm, I may be thinking of promises
16:53stuartsierrachouser: promises, promises
16:53chouserexactly
16:53rhickeythere are a ton of new things in master, we're all just used to them already
16:53chouserexactly
16:54stuartsierraWe're blase'
16:54rhickeynice
16:54chouseranyone want to bet on survey results?
16:54stuartsierraok, ready to go? http://spreadsheets.google.com/viewform?formkey=dFJSd1p4YXh0d0VxV0xjdk42MTU5RkE6MA
16:54chouserI say <20% of responders on 1.0
16:54rhickeystuartsierra: sure - we'll know more than we do now! Thanks
16:54stuartsierrano problem
16:55rhickeystuartsierra: wanna stick a logo on it?
16:55hiredmanyou should stick a picture of a wallaby on it
16:55chouserif you like it you should stick a ring on it
16:55rhickeyhiredman: because?
16:56chouserum. nevermind.
16:56hiredmanthey're cute
16:56stuartsierrarhickey: don't know how to do that on GDocs.
16:56hiredmanchouser: ha ha
16:56rhickeystuartsierra: ok
16:56stuartsierraand I already emailed it to the lists
16:57chouserthe url doesn't change when you edit the doc
16:57chouseroh, inlined. nevermind
16:58rhickeyit's fine
16:58falkor2There are other ways to get clojure, BTW: I mostly use whatever comes in enclojure....
16:58technomancylike leiningen. =)
16:59chouserstuartsierra: care to share the results url?
16:59chouserso that I can obsessively reload it?
17:00stuartsierratechnomancy: ok, added "IDE/Package manager" as an option.
17:00stuartsierrachouser: yes, hang on
17:00chouserwhile you're fixing things, typo on "the help me"
17:01stuartsierrachouser: thanks, fixed
17:02rhickeylooks like 2 how do you get questions now
17:03stuartsierrayes
17:03stuartsierrafrom the early responses
17:03stuartsierraoops, ok, fixed
17:06stuartsierraResults link: http://spreadsheets.google.com/ccc?key=0AuEMlyQZQkUMdFJSd1p4YXh0d0VxV0xjdk42MTU5RkE&amp;hl=en
17:06chouserstuartsierra: thanks
17:07stuartsierra"Form-> Show summary" gives you pie charts.
17:07zaphar_psone question is shown twice
17:07stuartsierrazaphar_ps: fixed now
17:07stuartsierraOh, in the results? yes, that's a leftover
17:07zaphar_psahh ok
17:08zaphar_psgithub is obviously the most frequent method to get clojure shown so far
17:09chouser"in early results"
17:09zaphar_pswhich probably features the early adopter type crowd
17:09chouserwith less than 2% of precincts reporting...
17:09zaphar_ps:-)
17:09stuartsierraOk, that's my contribution for the day, got to go.
17:09chouserI can't choose the "form" menu
17:10chouser(to see the pie charts)
17:10stuartsierrahuh
17:10zaphar_psme either
17:10stuartsierraAre you logged in with a Google acct?
17:10chouserstuartsierra: don't worry about it. go do what you need to do.
17:10chouseryeah
17:11stuartsierraDon't know how to fix that.
17:13chouserheh. I "made a copy" of the spreadsheet, and there I can choose form->show summary, but it says 0 responses
17:14hiredmanclojurebot: ~logs
17:14clojurebotlogs is http://clojure-log.n01se.net/
17:17falkor2OK, I think a more clever question would be: Is is possible to know, in a macro, the type of an object without executing it? Say, I do (mymacro (1 2 3) (println 3) ) And are able to see the type of both lists, and execute the 2nd?
17:17hiredmanthe type of what?
17:17hiredmanthe datastructure passed to the macro?
17:17falkor2Whatever I pass to the macro...
17:18hiredmanthe type of the result of calling eval on the datastructure?
17:18falkor2so in this case, There are 2 lists
17:18falkor2no, not the result
17:18falkor2but I would like to inspect the objects without executing them
17:18hiredmanwhy are you interested in concrete types?
17:19falkor2mainly in seeing the first element and do a decision on how to proceed
17:19hiredmanfalkor2: have you looked at multimethods?
17:19falkor2I need something a bit more general
17:19hiredman
17:19falkor2let me explain
17:19hiredmanthen you haven't looked at multimethods
17:20hiredmanmultimethods let you define a dispatch function
17:20hiredmanthat is about as general as you can get
17:20funkenblatti think he wants to decide whether to evaluate based on the car of each list
17:20falkor2I have, and I have code with mm on github
17:20falkor2let me explain
17:20hiredmanfunkenblatt: very doable
17:21falkor2I want to be able to do something like this ((new StringBuffer "bla") (add "ble") (add "bli"))
17:21falkor2The result being a SB "blablebli"
17:21the-kennyfalkor2: doto?
17:21falkor2maybe, let me reread doto
17:21hiredman,(doto (StringBuilder.) (.add "a") (.add "b"))
17:21clojurebotjava.lang.IllegalArgumentException: No matching method found: add for class java.lang.StringBuilder
17:22hiredmanbah
17:22hiredman,(doto (StringBuffer.) (.add "a") (.add "b"))
17:22clojurebotjava.lang.IllegalArgumentException: No matching method found: add for class java.lang.StringBuffer
17:22the-kenny,(doto (StringBuilder.) (.append "a") (.append "b"))
17:22clojurebot#<StringBuilder ab>
17:22hiredmanright
17:22the-kenny,(.getString (doto (StringBuilder.) (.append "a") (.append "b")))
17:22clojurebotjava.lang.IllegalArgumentException: No matching field found: getString for class java.lang.StringBuilder
17:22the-kenny...
17:22hiredmanthe-kenny: toString
17:22hiredmanor just str
17:22the-kenny,(.str (doto (StringBuilder.) (.append "a") (.append "b")))
17:22clojurebotjava.lang.IllegalArgumentException: No matching field found: str for class java.lang.StringBuilder
17:22hiredmanthe-kenny: str is not a method
17:23funkenblattwell in any case looks like my interpretation of what he wanted was completely wrong
17:23hiredmanhttp://gist.github.com/222974
17:23the-kennyhm.. I think falkor2 knows what we mean
17:23falkor2I think doto is probably enough. Newbie questions, sorry
17:24falkor2My objective is to be able to create tree like structures in an easy fashion
17:24falkor2(think lots of swing components embedded in one another)
17:25the-kennyMaybe something like clojure.zip?
17:25the-kenny(I'm not sure what you want to do)
17:26hiredmanswing is very imperative
17:26hiredmanI don't you want to use zippers for interacting with it
17:26hiredmandoubt
17:27the-kennyhiredman: I thought about creating and traversing the tree structure with zippers
17:27falkor2Mainly I am trying to construct tree like structure of Java objects in an easy way (think a JFrame which contains a Menubar, which contains menus, and so on and so forth)
17:27falkor2Trying to devise a way with little boillerplate code
17:27hiredmanthe-kenny: zippers are a functional tree editing construct
17:28hiredmanthere would be a significant mismatch for bidirectional swing<->zipper
17:31falkor2I am going to research doto, thanks. My final objective is to have a dynamic way to construct Java tree-like structures easily.
17:32hiredmanyou migh do some kind of batched convert to zipper, edit, update ui
17:34falkor2I am going to have a look, thanks for the tips.
17:42cow-orker,char?
17:42clojurebotjava.lang.Exception: Unable to resolve symbol: char? in this context
17:42cow-orkerwhy is this so....?
17:43hiredmanbecause the function does not exist
17:43the-kennycow-orker: My repl doesn't lnow this function either.
17:43KirinDave1Man I updated lein and broke it
17:43cow-orkersure, but why?
17:43KirinDave1I spend like 5x as much time futzing with lein as I do actually coding.
17:43cow-orker,integer?
17:43clojurebot#<core$integer_QMARK___5623 clojure.core$integer_QMARK___5623@78fac9>
17:43cow-orker,vector?
17:43clojurebot#<core$vector_QMARK___4488 clojure.core$vector_QMARK___4488@346801>
17:43hiredmancow-orker: no one has bothered to write it
17:43cow-orkeretc etc .... but no char?
17:43cow-orkerok, fair enough :)
17:44hiredman(partial instance? Character)
17:44KirinDave1Is "lein new _name_" or "lein help" broken for everyone or just me?
17:45hiredman,((partial instance? Character) \a)
17:45clojurebottrue
17:45hiredman,((partial instance? Character) 1)
17:45clojurebotfalse
17:45technomancyKirinDave1: help is broken due to a Clojure bug if lein has been AOT'd.
17:45KirinDave1technomancy: Same deal for new?
17:45technomancyKirinDave1: not that I know
17:46KirinDave1technomancy: "Could not locate leiningen/new__init.class or leiningen/new.clj on classpath", you know?
17:46cow-orkerhiredman: thanks. Was looking at core.clj and just wondered if there was something special wrt characters. Guess not :)
17:46technomancyKirinDave1: you're on 1.0.0-SNAPSHOT and have updated your bin script?
17:47technomancy(new didn't exist in 0.5.0)
17:47KirinDave1Oh, well
17:47KirinDave1When i pulled from the url in your repo
17:47KirinDave1i got 0.5.0
17:50KirinDave1technomancy: Following the directions in the mailing list seems to work better. :)
17:52Chousuketechnomancy: good work with leiningen btw. It seemed to me to appear out of thin air and now I see mentions of it everywhere :P
17:52technomancyKirinDave1: right; the readme points to with the stable branch
17:52technomancyChousuke: thanks! it's obvious now that it's addressing pain that a lot of people feel.
17:52Chousukenow Clojure itself needs to start using it.
17:53Chousuke:P
17:53technomancychicken, meet egg.
17:56funkenblattdelicious delicious egg
17:56funkenblattman now i'm hungry
17:59KirinDave1Man, I just have no luck with lein.
18:09technomancyKirinDave1: I'm a bit busy right now, but there's a mailing list for leiningen: http://groups.google.com/group/leiningen
18:45ambientclojure-mode from ELPA is telling me that clojure-install is deprecated. what should I use instead?
18:48technomancyambient: M-x slime should download Clojure if swank-clojure is installed.
18:49ambientnvm, i was a bit reading impaired. technomancy.us/swank-clojure seems to be the way
18:50ambienttechnomancy: ok, ty
18:52ambientit installed version 1.0.0 :(
18:53ambientand i dont even know where to
18:53technomancyambient: sounds like you want option 2 then
18:53_ato`ambient: ~/.swank-clojure
18:55_ato`I also had to move swank.jar into ~/.clojure to get M-x swank-clojure-project to work :\
18:59KirinDave1Man, too much time spent trying to get this to work. :\
18:59KirinDave1I am just gonna go back to lein 0.5.0
18:59KirinDave1Good thing I have lots of time today with my 800000 installs of windows.
19:00_ato`KirinDave1: yeah, best to stick with stable version unless you want to hack on lein itself.
19:01KirinDave1_ato: Probably should remove the .jar tho
19:01KirinDave1It seems completely broken.
19:01KirinDave1Referring to a method that does not exist at invocation, etc. etc. :)
19:02_atoyeah, you probably know but they're installed under: ~/.m2/repository/leiningen/leiningen/
19:02KirinDave1Yes.
19:02KirinDave1The 1.0.0-SNAPSHOT invokes main when I think it means to invoke "-main"
19:04technomancyno, it got renamed to "main" in master; that's correct. we're no longer gen-classing.
19:23tomojis there something wrong with "java -cp lib/* clojure.main" in a swank-clojure-project-style project?
19:23qedwow I need to learn Java
19:23tomojoh, yes, of course
19:23tomojneeds to be quoted
19:24qedI've been secretly hoping this whole time learning clojure that I'd be able to completely ignore Java
19:24qedbut it looks like a dirty necessity
19:24tomojyup :/
19:24qedTo what extent seems to be the question
19:24tomojthey taught me java here at school, luckily. but I still haven't forced myself to learn ant or maven or..
19:25_atoKirinDave1: ah.. I just realised what the problem is, technomancy's snapshot is 4 days out of date
19:26tomojpackaging seems to be the dirtiest part to me, maybe new clojure tools will help hide that from us :)
19:27qedit'll get better
19:27technomancy_ato: I guess I should put a note that self-install should not be relied upon for snapshot versions
19:28technomancyit's so easy to get out of sync
19:28_atotechnomancy: yeah, probably a good idea to chuck a check in the lein script as well that spits out a warning if the version ends in snapshot
19:28qedi do all of my clojure/swank/slime setup manually
19:28qedit just seems cleaner that way, no offense technomancy
19:32ambientthis bothers me, to use clojure efficiently there still remains a significant threshold for not-so-smart people
19:33tomojisn't there clojurebox or something?
19:34ambientcertainly. i'm just lamenting that in my view, there's no "perfect" development environment yet, in which i would feel comfortable in, without wanting some random feature or convenience
19:34ambienti could make emacs such, but in my experience, it becomes with a significant burden
19:43chouserI'm hopeful. Lisp was not an acceptable lisp, and then came clojure.
19:43chouseremacs is not an acceptable emacs, but maybe something will come along.
19:44technomancylexical scoping and threading in emacs 24!
19:44chouserhm
19:44chouserreally?
19:44technomancychouser: there's talk of it
19:45chouserwith those, it might make an acceptable clojure compilation target.
19:45technomancypossibly coroutines instead of threads; that's fine w/ me
19:45technomancychouser: I've thought about that, believe me. =)
19:46hiredmanbest to start now
19:46hiredmanclojure subset to elisp compiler
19:46hiredman"translator"
19:46technomancymight be fun to compile directly to elisp bytecode
19:47hiredmanthat would be even better
19:47chouserno point in starting pre-cinc
19:47hiredmanI wasn't aware there was elisp bytecode
19:47hiredmanchouser: not a full clojure port
19:47hiredmanmore like code gen guided by feed in clojure forms
19:47technomancyhiredman: someone ported a destructuring version of let already; it's pretty nice
19:48hiredmanemacs :(
19:48qedgah I get so confused at this Creating & Compiling Java Classes in Clojure section of Stuart's book
19:49_atoqed: with anything in particular?
19:49funkenblatti thought emacs has had destructuring bind in the 'cl package for a while
19:49qedi worked through this section last night _ato -- im going to try my luck again. If i have an issue ill ask though, thanks :)
19:51qedis the (.. class-or-inst form & forms) special form kind of like (->)?
19:51_atoyes
19:52technomancyfunkenblatt: not with hashes
19:52funkenblattah
19:52_atoqed: it came from before the (.foo obj) notation was introduced IIRC. Better to do (-> obj (.foo) (.bar)) rather than (.. obj (foo) (bar)), as you can also use clojure functions with ->
19:53qedok _ato -- here's where I get confused, and this might just be my java ignorance, but the (proxy class-and-interfaces super-cons-args & fns) is scary to me
19:53qedah right _ato that makes sense
19:53_atohehe it is scary!
19:53_atoclass-and-interfaces = classes and interfaces you are subclassing/implementing with proxy
19:54_atosuper-cons-args = arguments to the superclass' constructor, so if you're subclassing class Foo and need to pass in some args like: (Foo. 1 2 3) this is where you'd put them
19:55_atoboth of them should be vectors
19:55qedokay so far so good
19:55_atoand fns is jus the fns you want to override. So if you want do override. (.foo obj 1 2 3), you'd put (foo [x y z] ...) there
20:08qed_ato: i think what is confusing me is...and this might sound ridiculous...but...why?
20:08qedlike...what are we doing essentially by using proxy
20:09tomojqed: are you totally new to java? or you know a bit?
20:09qedI know some Ruby, I took some AP Java in high school, a semester of it
20:10tomojwell in ruby you can make a subclass and override some methods
20:10qedMyController < ApplicationController
20:10qedsomething like that?
20:11tomojyeah, but..
20:11tomojI guess it's sortof like a ruby singleton class maybe
20:11tomojyou just get a single instance of this new class
20:12tomojso like if you want to make a JFrame instance but override some methods, instead of creating a new class MyJFrame and instantiating it, like you would in java, you can just proxy JFrame
20:12tomojyou get an instance of an anonymous subclass with your overridden methods
20:12qedoh okay okay, i think i see where this is going
20:13hiredman(except extending JFrame like every java gui tutorial does is a horrible idea)
20:13qed(def print-element-handler (proxy [DefaultHandler [] (startElement [uri local qname atts] (println (format "Saw element: %s" qname)))))
20:13_atoyeah
20:14qedso we are making an anonymouse instance of DefaultHandler and overriding startElement?
20:14hiredmanyou are missing a ]
20:14qedah yeah, so i am
20:14_atoqed: it's basically because many java libraries force you to subclass one if their types in order to use their API
20:14hiredman_ato: if you are lucky, one of their interfaces
20:15qedso what is [uri local qname atts]
20:15hiredmanthe arguments to the method
20:15_atoit's the arguments passed to .startElement
20:15qeddo they need to be named exactly like the the method names them?
20:15hiredmanproxy generates a class
20:15hiredmanqed: nope
20:15qedso i could just do q1 q2 q3 q4
20:15_atono, it's just like (defn startElement [uri local qname attrs] ...)
20:15_atoyeah
20:16_atoexcept that it creates a java method
20:16_atoinstead of a clojure function
20:16qedsure, okay
20:16_ato(method meaning it's attached to a class instead of being "global" like a function)
20:16hiredmanproxy stubs out the java methods in the generated class, and just passes the arguments off the to clojure fn created from the proxy form
20:16qedthanks guys, im gonna get back to playing with this -- just for fun, does anyone have an easy example of a Java class/method I could use proxy on?
20:16hiredmanACtionListener
20:16qedim gonna try to write a couple of them
20:16hiredmanActionListener
20:17hiredmanFileFilter?
20:19tomojhiredman: got disconnected, was the verdict horrible or not horrible?
20:19qedlike: (def action-performed (proxy [ActionListener] [] (actionPerformed [event] (println (format "Performed %s" event)))))
20:20tomojI think the only time I've ever used proxy was for a KeyListener
20:21hiredmantomoj: verdict on?
20:21tomojwhich overrode keyPressed to call a handler-fn on the event
20:21hiredmanqed: are you familiar with java's anonymous classes?
20:21tomojoh, is proxying swing classes always horrible?
20:21tomojor did you just mean JFrame in particular
20:21qedhiredman: im familiar with Ruby's
20:22hiredmandoes ruby hava anonymous classes?
20:22qedthe "ghost" class, singleton class, eigenclass, uniclass, etc.
20:22tomojruby has anonymous classes?
20:22qedyes
20:22tomojoh, that's sorta like proxying but backwards I think
20:22tomojwhen you proxy you make an anonymous class and then instantiate it once
20:22hiredmanhttp://blog.jayfields.com/2008/02/ruby-creating-anonymous-classes.html
20:23tomojwith the singleton class you've got an instance of some class and then you can stick your overridden methods in for just that instance, so, same effect I guess
20:23hiredmananyway
20:23hiredmanyeah, proxy creates an instance of an anonymous class
20:23tomojin ruby proxy'ing would be unnecessary since we don't have to dance around to satisfy java's type system anyway
20:24hiredmanwell, it creates an anonymous class, and then returns an instance
20:25qedso it creates this anon class, and then an instance of it with my overridden methods, i guess im still struggling to see applicable scenarios not having worked with Java much at all
20:25qedthat's really where im really trying to get clarification, some examples of this in action
20:25tomojwell, for example, swing wants you to give it a KeyListener to listen to key events in the GUI
20:25_atoqed: java doesn't have first class functions
20:25_atoyou can't pass a function to another function in java
20:26tomojI don't want to make a java class which subclasses KeyListener, so I just proxy it
20:26_atoso you basically use anonymous classes or subclasses instead
20:26tomojyeah, in clojure I'd just be able to pass a fn to call on the key event I suppose
20:27tomojRunnable too, eh?
20:27qedCallable/Runnable yeah
20:27qed_ato: when you say fn in java, you mean method, no?
20:28qedwe're essentially creating an anonymous function from some Java method?
20:28_atoyeah, it doesn't have functions and it's methods aren't first class, they don't exist as objects themselves. You can't pass them around. It doesn't even have function pointers. (leaving aside reflection, which doesn't really count)
20:29tomojeh
20:29tomojI think we're essentially doing some little dance to make up for the fact that java can't do that
20:29qedso we're sort of creating an abstract version of a java method
20:29qedso we can use it all over the place in clojure
20:30tomojwhere you would pass a fn in clojure, you instead pass a singleton of some anonymous class
20:31tomojjava code you're interoping with wants some object which extends/implements certain classes/interfaces - it doesn't care that clojure is dynamic
20:31qedis there a way to get the methods for a Java class in my REPL?
20:31tomojso you use proxy to make a one-off subclass/implementation
20:31tomojc.c.repl-utils has show
20:32tomojif you're using slime you should be able to use the slime inspector as well
20:32tomojlike C-c I Math
20:32qedawesome, that's a big help
20:33qedokay okay, this is starting to make real sense now
20:33_atoWhat I find really funny is a lot of java folks have been against adding closures/lambda expressions to java because they're "too complex". So instead you've got to do to this annoying subclass / anonymous class dance which actually turns out to be harder and more complex.
20:34tomojI remember really enjoying learning about anonymous/inner classes because they seemed so esoteric
20:34qedWe're just making some version of a Java method which implements a Class/Interface, so we can fake Java into talking to our version of it which we create with a proxy
20:34_atoqed: exactly
20:34tomojI guess maybe they're much easier to implement in java, though?
20:34qedtomoj: yeah i really enjoyed the ruby metaprogramming stuff
20:34qedvery fun
20:36tomojI had heard rumors about closures coming to java, though
20:37qedokay so I have (def get-month (proxy [Date] [] (getMonth [month] (println (format "The month is %d" month)))))
20:37qedwhat am i doing wrong there?
20:40tomojgetMonth doesn't take a parameter
20:41tomojso "month" is not what you think it is, I think
20:43tomoj,(.getMonth (proxy [Date] [] (getMonth [] (println "foo") 3)))
20:43clojurebotjava.lang.RuntimeException: java.lang.IllegalStateException: Var null/null is unbound.
20:44tomoj,(import 'java.util.Date)
20:44clojurebotjava.util.Date
20:44tomoj,(.getMonth (proxy [Date] [] (getMonth [] (println "foo") 3)))
20:44clojurebotjava.lang.RuntimeException: java.lang.IllegalStateException: Var null/null is unbound.
20:44tomojhuh.
20:44qedthere we go
20:44tomojwell, that works fine for me, prints foo and returns 3
20:44tomojthough that's a pretty strange example :)
20:45qed(def print-crazy-date (proxy [Date] [] (toString [] (str (. (java.util.Random) nextInt)))))
20:45qed(. print-crazy-date toString)
20:45qederr forget a . after Random
20:46qedforgot*
20:46tomojcrazy indeed
20:46qedhehe
20:49qedokay this is making more and more sense.. (.start (Thread. (proxy [Runnable] [] (run [] (println "I ran!")))))
20:50qedThread. wants something that is Runnable, so we're giving it what it wants
20:51tomojyep
20:51hiredmanhttp://groups.google.com/group/clojure/browse_thread/thread/4303a1a0bc4bdfa5?hl=en <-- good question
20:51tomojthough I think agents make all that unnecessary in clojure, luckily
20:51tomojbut maybe if you're interoping with some library that wants Runnables..
20:51hiredmanclojure Fns are Runnable
20:51qed#()
20:52qedand Callable
20:52hiredman,(ancestors (class #()))
20:52clojurebot#{java.lang.Object clojure.lang.IMeta clojure.lang.AFunction clojure.lang.Obj java.io.Serializable clojure.lang.AFn java.util.concurrent.Callable java.lang.Runnable java.util.Comparator clojure.lang.IFn clojure.lang.Fn :clojure.contrib.generic/any clojure.lang.IObj}
20:52tomojwell then I guess all that is unnecessary no matter what
20:52qed(.call #(println "foo"))
20:52qed,(.call #(println "foo"))
20:52clojurebotfoo
20:53tomoj(.start (Thread. #(println "foo"))), nifty
20:53qedyeah definitely
20:53hiredman(future (println "foo"))
20:54qed,(future (println "foo"))
20:54clojurebot#<core$future_call$reify__7719@624159: nil>
20:54qed,(seq (future (println "foo")))
20:54clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$future_call$reify__7719
20:54tomojI still have never used future
20:55qed,(future-call #(println "foo"))
20:55clojurebot#<core$future_call$reify__7719@1937976: :pending>
20:55tomoj,(let [the-future (future (println "foobar"))] [@the-future @the-future])
20:55clojurebot[nil nil]
20:56tomojguess clojurebot doesn't want to print that
20:56qedwhy two calls to @the-future?
20:56tomojbut it only prints once :)
20:56qedit gives me nil twice
20:57tomojbecause it still only prints once
20:57tomojyeah, but only prints once
20:57tomoj(println returns nil)
20:58qed(let [the-future (future (str "foo!"))] [@the-future @the-future])
20:58qed,(let [the-future (future (str "foo!"))] [@the-future @the-future])
20:58clojurebot["foo!" "foo!"]
20:59qed,(let [the-future (future (str "foo!"))] [@the-future the-future])
20:59clojurebot["foo!" #<core$future_call$reify__7719@19c1908: "foo!">]
21:02tomoj,(time (let [the-future (future (Thread/sleep 1000) "foo")] [@the-future @the-future @the-future]))
21:02clojurebot["foo" "foo" "foo"]
21:02clojurebot"Elapsed time: 1030.109 msecs"
22:11arohnerI have on the order of 1000 instances of clojure maps that I scan through, looking up values. If I convert that to a deftype that implements IPersistentMap, will things get faster?
22:12chouserthe clojure maps all have the same keys?
22:12chouserif so, you should see a substantial speedup
22:15arohnerchouser: yes, they all have the same keys, and do no assoc/disassoc
22:15arohnerthanks
22:19chouseryeah, you should get an inlinable java method call instead of the hashmap algorithm implementation
22:35arohneroh, but they don't implement IFN, so I can't do (instance key)
22:36arohneris that planned/ a good idea?
23:01carkarohner : did you try (keyword instance) ?
23:01arohnercark: yes, that works
23:01arohnerbut my existing code uses (instance keyword) everywhere. I was hoping a deftype that implemented IPersistentMap would be a drop in replacement
23:03carkbut wouldn't you loose the performance characteristics if this was done this way ?
23:04carkohwell anyways i don't have this version of clojure installed yet =P
23:05carkoh i see your post
23:07_atocark: (keyword instance) is actually faster for deftypes
23:08_atoit's as fast as a java field access
23:08qedYou know I just realized that all of this channel is logged and my stupidity will forever be cast in stone.l
23:09_atoyeah, isn't it great. In 5 years time when you're an almightly Clojure god you can look back and think... "ah... how I have improved!" :-)
23:10carkmhh but if you include the IPersistentMap interface in your deftype, doesn't it behave like a struct-map ?
23:10qed_ato: haha you are by far the most positive person I've met in here -- I have to say I really appreciate your patience
23:10kzarqed: Yea I asked a question in here the other day, then I googled the problem and found what I said in the results..
23:10qedkzar: ahahaha
23:11kzar"Sweet this guy has the same problem... oh wait"
23:11qedTo the internet: If you come to IRC and ask _ato, you will learn.
23:12_atocark: hmm, you could well be right. I'm not sure, I haven't played with that enough
23:12carklooks like i might have to test it too =)
23:13qedAnd on top of that, _ato is humble, he didn't even take the opportunity to toot his horn.
23:13qedGod damnit, _ato. What are you made of, man?
23:14kzarI bet you are the same person, you just opened up bitchx in a shell and started bigging yourself up
23:14_atohahaha
23:14qedhahahaha
23:14_mstouted!
23:14_mstI'm _ato and so's my wife :P
23:14qedi am really offended you would think I'd use BitchX
23:14qedwtf is it, 1997?
23:15carkhey i'm using mirc !
23:15qedthat's right, get the shame you feel out into the open
23:15qedyou can only learn from this experience
23:15_mstanother one for the IRC logs :)
23:16qedactually something ive taken to showing my future employers -- or at least mentioning in interviews is that if you google me you will find me, at age 13, on the vuln-dev mailing list
23:17qedasking if it is "okay" to extort money from a local ISP for a hole I found in their system
23:17qedthat shit is never going away
23:18qedin fact, they mirrored it...twice
23:18qedand vuln-dev takes precedence over my crappy blog, so my 13 year old extortion scheme still reigns supreme in my google results
23:23_atoheh, if you google my name, which seems to be fairly common you will get: "The father of brainstorming" and "like Jesus, except I'm not dead."
23:25qedthere's another guy in my state who is a drug addict and got arrested for statutory
23:26qedi need to be very clear on my middle initial
23:59KirinDave1I'm writing a program and I feel like I'm doing it wrong.