#clojure log - Feb 10 2010

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:01 somnium: ah, I had to call them something for the multimethod (::A->B->C) would involve a parser

0:01 so I just gave them random letters and put the haskellish types in the comments

0:01 devlinsf: Ah, okay

0:02 somnium: was loosely based on (my incomplete) understanding of the state-monad

0:03 devlinsf: Still, I like the idea of typed fns... sometimes :)

0:03 It would be a good option to have occasionally

0:04 somnium: yeah, when they cause compile failures they suck, but if they can help build things theyre interesting

0:05 devlinsf: I'm more interesting in multimethods/protocols

0:05 I'd like a promise that implementations will behave kind correctly

0:06 Returns a seqable when expected, etc.

0:07 Hmmm... I guess that would require a speed hit in a dynamic language, though

0:07 Oh well

0:11 somnium: with :pre :post, and possibly primitive args and return types, might be inching towards an occasionally static dynamic language

0:12 devlinsf: Yeah, I was thinking about that. Do they work with multimethods? I thought :pre & :post are specific to closures.

0:13 somnium: right now they just expand to (assert ...), so you could put them in the dispatcher

0:13 will be interesting if they eventually get used by the compiler

0:13 devlinsf: Ah. Makes sense

0:20 maxhodak: i'm trying to call a variably named java method using the dot syntax and can't get it to work

0:21 (. impl method-name) keeps giving me "No matching field found: method-name for class"

0:21 and i can't figure out how to quote it properly if that's the right way to do it

0:24 devlinsf: maxhodak: (.method-name impl) is generally considered better form

0:24 maxhodak: Also, try adding type hints. This will fix this error some of the time

0:25 maxhodak: (.method-name impl) gave the same error

0:26 devlinsf: And type hints?

0:26 maxhodak: as in, #^double

0:26 er

0:26 devlinsf: Yeah

0:26 maxhodak: (.#^double method-name impl) ?

0:27 devlinsf: (.method-name #^ImplClass impl #^Double ar1 #^Object arg2)

0:27 maxhodak: oh; i'm using apply and have the args in a list

0:27 devlinsf: Oh

0:28 maxhodak: (let [impl (new ServerImpl)]

0:28 devlinsf: I'm 99% sure you can't do that

0:28 maxhodak: (apply (.method-name impl) args)))

0:28 chouser: that's not going to work

0:28 devlinsf: You need a memfn call

0:28 maxhodak: grr

0:28 googling memfn

0:28 chouser: and memfn won't help

0:28 devlinsf: No?

0:28 clojurebot: da da king of the road

0:29 chouser: devlinsf: no, memfn does nothing the #() can't do better.

0:29 devlinsf: Ah.

0:29 maxhodak: chouser: how would you work around?

0:29 chouser: maxhodak: are there actaully a variable number of args?

0:29 devlinsf: maxhodak: Can you point to the real javadoc?

0:29 maxhodak: chouser: yes, it's a way to access the class methods from the commandline

0:29 chouser: so you don't know what method you're trying to access ahead of time

0:30 chouser: the java method probably accepts an array then, doesn' it?

0:30 maxhodak: devlinsf: i haven't generated javadoc for this

0:30 devlinsf: maxhodak: Oh, okay

0:30 maxhodak: chouser: no, it takes two integers

0:30 chouser: java "varargs" compile to actually accepting an array.

0:30 maxhodak: (the one im trying right now away)

0:30 chouser: "two integers" doesn't sound like a variable number of args. it sounds like 2. -)

0:30 :-)

0:30 maxhodak: chouser: for this method, but there's a bunch in the class

0:31 some are void, some take 1 arg, some take 3

0:31 etc

0:31 and im basically doing

0:31 chouser: do you not know the name of the method ahead of time either?

0:31 maxhodak: java -cp myfoo.jar myfoo.test methodname arg1 arg2

0:32 chouser: ok, for that you probably want either reflection or 'eval'

0:32 these are instance methods or static?

0:32 maxhodak: instance

0:32 though i could probably declare a bunch of them static

0:33 but really instance

0:33 chouser: ok, doesn't really matter. for something like this 'eval' might be easiest.

0:33 maxhodak: ok

0:33 so like

0:33 chouser: in fact, if you're taking different arg types, that is not always strings, you might use the Clojure reader too.

0:33 maxhodak: (eval `(.~method-name impl ~(map ...))

0:34 TheBusby: chouser: in way to get prxml to return the generated string?

0:34 er, _any_ way...

0:34 chouser: yes, but the lone-dot format is better when you're constructing the form like this.

0:35 so (eval '(. impl ~method-name ~(map read-string args-strings)))

0:35 maxhodak: chouser: what's the best way to unroll my args list?

0:35 ok thanks

0:35 chouser: er, but with `

0:36 maxhodak: chouser: what's the big difference between a syntax quote and a quote?

0:36 (i know, i know, basic question)

0:36 chouser: TheBusby: with-out-str might do it

0:36 ,(with-out-str (println "stuff"))

0:36 clojurebot: "stuff\n"

0:36 tomoj: ,`(~foo)

0:36 clojurebot: java.lang.Exception: Unable to resolve symbol: foo in this context

0:36 tomoj: ,'(~foo)

0:36 clojurebot: ((clojure.core/unquote foo))

0:37 tomoj: ,`foo#

0:37 clojurebot: foo__6489__auto__

0:37 tomoj: ,'foo#

0:37 clojurebot: foo#

0:37 maxhodak: so, basically do i need to declare my bindings *inside* the quote?

0:37 it looks like that's the only way to get impl in scope?

0:38 chouser: maxhodak: I wrote a section on that in chapter 1, but not the version that's out yet. :-/

0:38 TheBusby: chouser: thanks! Seems like odd default behaviour for Clojure's default XML generater though...

0:39 chouser: maxhodak: syntax-quote aka ` has a couple differences from quote. here all we're using is the ability to unquote with ~

0:39 tomoj: ,(namespace `foo)

0:39 clojurebot: "sandbox"

0:39 tomoj: ,(namespace 'foo)

0:39 clojurebot: nil

0:39 chouser: maxhodak: no, sorry, my eval example was bad.

0:40 so (eval (list '. impl method-name (map read-string args-strings)))

0:40 there, try that.

0:40 tomoj: don't the args need to be spliced?

0:40 chouser: eh. that's just a slow way to get to reflection. :-/

0:41 tomoj: bleh. yeah.

0:41 (eval (list* '. impl method-name (map read-string args-strings)))

0:41 tomoj: whoa

0:41 awesome

0:41 maxhodak: (eval (list '. impl method-name (map read-string args))) won me "Malformed member expression

0:41 "

0:41 chouser: maxhodak: yeah, sorry. try list* instead

0:42 maxhodak: ok. i appreciate you helping me here.

0:42 chouser: sorry I keep being wrong. :-P

0:42 maxhodak: (the clojure community is one of the best things about it)

0:42 chouser: now I'm thinking eval is just a red herring

0:42 I mean, it should work, but kinda lame

0:42 maxhodak: java.lang.ClassCastException: clojure.lang.ArraySeq

0:42 devlinsf: chouser: Why won't a normal macro cut it?

0:43 chouser: devlinsf: he doesn't know anything about the which method to call or what the args are until runtime.

0:44 devlinsf: But you've got strings... which can easily be turned to symbols.... eh, okay

0:45 chouser: ,(let [method-name "toUpperCase", impl "FooBar", string-args []] (clojure.lang.Reflector/invokeInstanceMember method-name impl (to-array (map read-string string-args))))

0:45 clojurebot: "FOOBAR"

0:46 chouser: ,(let [method-name "lastIndexOf", impl "FooBar", string-args ["\"B\""]] (clojure.lang.Reflector/invokeInstanceMember method-name impl (to-array (map read-string string-args))))

0:46 clojurebot: 3

0:46 devlinsf: maxhodak: Do you have a fixed pool of methods? Is it easy enough to wrap them in normal fns?

0:46 chouser: maxhodak: probably best to just use Reflector like that. That's what eval will do (after a whole lot of mucking about with bytecode) anyway.

0:47 maxhodak: yeah, saw the examples... trying it

0:48 devlinsf: Why not a hashmap of strings->fns ?

0:48 maxhodak: this is totally mystifying

0:48 i kind of want to say screw it and hardcode it to test it

0:49 but i also feel like that won't lead to me learning the intricacies of clojure

0:49 devlinsf: maxhodak: You come from a Java background?

0:50 If so, start at java.lang.Reflect. Then look at Chouser's example

0:50 maxhodak: devlinsf: no; hacking background: i hate java. ocaml, php, c++, python, ruby

0:50 devlinsf: Oh

0:50 maxhodak: unfortunately java is useful since everyone else uses it

0:51 chouser: it's not working?

0:52 maxhodak: no

0:52 chouser: getting an error?

0:52 maxhodak: i'm just going to hardcode it for now and move on

0:52 java.lang.ClassCastException: clojure.lang.ArraySeq

0:53 chouser: I'm happy to keep helping if you're not ready to give up.

0:53 maxhodak: hmm, ok

0:53 chouser: I would (prn string-args) and (prn (map read-string string-args)) ... paste them here to see if they look like what we're expecting.

0:55 maxhodak: so

0:55 i added both of those statements, and got one line printed back

0:55 (("010121" "12121"))

0:55 for

0:55 somnium: the build.xml is gone from contrib?

0:56 maxhodak: java -cp myfoo-standalone.jar myfoo.run mymethod 010121 12121

0:56 chouser: somnium: yeah. read the readme for how to build with maven.

0:57 huh

0:57 maxhodak: i just removed the (prn args) to see which line it corresponded to

0:58 it was (prn args), so (prn (map ...)) did nothing

0:58 chouser: maxhodak: get rid of the prns and try (prn (map read-string (first string-args)))

0:58 the (prn (map ...)) probably threw the same exception you were seeing before

0:59 maxhodak: chouser: it did

0:59 so, that time it printed: (4177 12121)

0:59 (how did it get 4177 from 010121?)

0:59 chouser: haha! octal!

0:59 maxhodak: haha, yes

1:00 very strange

1:00 chouser: so ... if you don't want that, then you don't want to use read-string

1:01 anyway, the problem was that string-args is apparently a list of arrays of strings or something, instead of just an array of string. so try (first string-args) in your Reflector call as well.

1:02 maxhodak: trying (clojure.lang.Reflector/invokeInstanceMember method-name impl (to-array (first args)))

1:02 got: java.lang.IllegalArgumentException: Unexpected param type

1:03 chouser: that's probably because your method doesn't want strings, but that's what you're giving it.

1:04 maxhodak: hmm

1:04 chouser: ,(let [method-name "charAt", impl "FooBar", string-args [["3"]]] (clojure.lang.Reflector/invokeInstanceMember method-name impl (to-array (map read-string (first string-args)))))

1:04 clojurebot: \B

1:04 maxhodak: can i do something like (map (meta double) (to-array (first args))) ?

1:04 er, #^double maps to (:tag double), right?

1:05 chouser: sure. (map #(Double/parseDouble %) (first string-args))

1:05 maxhodak: %s/double/integer

1:05 underdev: arrgh! One last emacs problem... so close...

1:05 (add-hook 'closure-mode-hook (lambda () (paredit-mode +1)))

1:05 maxhodak: what's the purpose of the % in that statemetn?

1:06 chouser: ,(let [method-name "charAt", impl "FooBar", string-args [["3"]]] (clojure.lang.Reflector/invokeInstanceMember method-name impl (to-array (map #(Integer. %) (first string-args)))))

1:06 clojurebot: \B

1:06 chouser: maxhodak: #(Integer. %) is the same as (fn [x] (Integer. x))

1:06 underdev: is 'closure-mode-hook the hook for clojure mode?

1:06 paredit's catching in everything else

1:06 just not clojure mode

1:07 which, of course, is the entire point

1:08 maxhodak: (clojure.lang.Reflector/invokeInstanceMember method-name impl (to-array (map #(#^Integer %) (first args)))) -> java.lang.RuntimeException: java.lang.ClassCastException: java.lang.String

1:09 chouser: #(Integer. %) ...that's a ctor call, not a type hint

1:09 somnium: underdev: usually (add-hook 'clojure-mode-hook 'paredit-mode)

1:09 maxhodak: chouser: ok, will try that

1:11 chouser: finally! that worked.

1:11 wow that was way more work that it should have been

1:11 (clojure.lang.Reflector/invokeInstanceMember method-name impl (to-array (map #(Integer. %) (first args)))) to call a variably named java method

1:11 underdev: somnium, thank you

1:12 somnium: as i was pasting into #emacs, i realized i spelled "closure" and not "clojure"

1:12 chouser: maxhodak: now try it in Java. ;-)

1:12 underdev: durr dee durr

1:12 somnium: :-)

1:13 maxhodak: lol

1:13 chouser: thanks

1:13 chouser: maxhodak: np. sorry for all the pain.

1:24 underdev:

1:24 maxhodak: chouser: hmm, so now i have to run a variably named fxn inside clojure

1:24 at least here i have a fixed arg length

1:24 my naive (filters/'filter-name triples) is failing miserably

1:28 chouser: ,((resolve (symbol "+")) 2 4)

1:28 clojurebot: 6

1:59 slyphon: any vimclojure users at home?

2:44 underdev: Lau, i had first installed clojure box, but being a geek i couldn't stand not knowing what was working and why. So i started from scratch, using a lot of the .emacs you posted on your blog. Thank you.

2:44 also, i didn't want the win32 stuff, so the emacs i know is portable :)

2:45 i thought that .emacs was a screenshot, what did you use for the syntax highlighting?

2:48 LauJensen: Great :)

2:48 maxhodak: how do you set a method's return type to byte[] in gen-class :methods ?

2:58 hoeck: maxhodak: maybe (Class/forName "[B") or bytes, not shure

3:01 maxhodak: hoeck: nope

3:01 hoeck: well, bytes tries to become java.lang.bytes rather than clojure.core.bytes

3:01 but still get a class not found err for clojure.core.bytes

3:12 hoeck: maxhodak: and what about "[B", at least compiles here, but I have no disassembler at hand to check it

3:18 maxhodak: gen-class :methods is basically a macro that's substituting in directly anything you enter

3:18 to java.lang.%

3:18 and byte[] doesn't work

3:18 (byte does, but then i get return value mismatches)

3:21 LauJensen: underdev: Sorry missed your last line, syntax highlighting is done by Clojure-mode, colors are from charcoal-black color theme, conversion to html is htmlize

3:22 hoeck: maxhodak: yes, but it seems that :methods expects classnames as strings

3:22 maxhodak: and "[B" ist the jvm-classname for byte[]

7:12 ordnungswidrig: ping?

7:12 clojurebot: PONG!

7:40 chouser: cemerick: http://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/lazy_xml.clj#LID137

7:41 cemerick: heh

7:41 that's cheating, just a little bit :-)

7:42 oh, wait

7:43 chouser: sorry, I thought you were going from clojure.xml -> strings -> inputsource -> sax

7:44 it's too bad about that .toCharArray call

7:50 chouser: yeah, it's a shame

7:50 but at least it ought to be constant memory usage rather than O(n)

7:51 cemerick: yeah

7:51 chouser: in this case, *out* is simply not appropriate IMO -- if it's a Writer, wonky things will happen if there's a mismatch between the writer's encoding and the encoding output property.

7:51 s/wonky/bad

7:52 the doc can provide the necessary warnings, but it's going to be a beartrap

7:52 chouser: ok. there are other details to be improved as well. for example I think my concept of QName may be wrong for both tags and attrs

7:54 and indentation may not work on Java 1.5: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446

7:55 could emit pick up the encoding setting from *out*?

7:55 cemerick: chouser: yes, qname and localname are only the same if there is no declared namespace

7:56 no, wait, qname and localname are the same if the elt is in the default namespace :-/

7:57 which will always be the case until namespaces are supported in general

7:58 chouser: ok. how clojure.xml will store namespaces is TBD. I've had some thoughts, but none that aren't a bit of a mess.

7:58 cemerick: yeah, that's something that can stew for a while IMO. It's fiendishly hard to get right.

7:59 chouser: OutputStreamWriter is the only one that provides encoding info, and it can be wrapped. So, probably not.

7:59 chouser: is qname like "foo:bar" for localname "bar" and uri "http://blah.blah/foo" ?

8:00 cemerick: almost

8:00 chouser: depending on xmlns delcarations?

8:00 cemerick: right, the prefix is the ns declared name, not the last portion of the url or whatever.

8:00 chouser: right, ok.

8:01 cemerick: except! :-P

8:01 ns declarations can be made in any element

8:01 chouser: anyway, it was everything inside that (.transform ...) call that tortured me all evening.

8:01 yes, I know that. painful.

8:01 cemerick: so foo:bar could turn into blah:bar given a different ancestor for bar.

8:01 chouser: right

8:02 which is why, when parsed, each clojure.xml node should include a complete prefix->namespace map for that level

8:02 cemerick: why the #^void hint on parse?

8:02 chouser: or something.

8:03 cemerick: reify requires hints on everything if you provide hints on anything, and requires hints on parse because there's more than one

8:03 cemerick: ah, right

8:03 fundamentally, you don't want to carry around prefixes at all -- I remember being deep into this when doing a lot of xml in python, and libs like lxml only carry around namespace URI's, never prefixes.

8:04 chouser: all of that is like a magic incantation. for example, that InputSource is never used, but if you don't create it .transform says it can't use the SAXSource

8:04 cemerick: to the point where they can't parse prefixed xml, and then emit it again with the same prefixes.

8:04 chouser: cemerick: and that's good?

8:05 cemerick: I wonder if I can dig up the mailing list thread. Apparently, various XML wizards say it is, that prefixes (or any details of a particular serialization) are inconsequential.

8:06 avarus: hi!

8:07 chouser: ugh. I'd hate to see {tag: :http://foo.bar/a :attrs [:http://foo.bar/href "http://clojure.org"] :content [{:tag :http://foo.bar/b :content ["home"]}]}

8:12 avarus: I need coke

8:12 chouser: "a coke" I hope?

8:12 avarus: don't ever say that at a spanish airport

8:12 like I did

8:13 yes :P

8:13 underdev: a coke, and a smile

8:13 cemerick: chouser: found the "relevant" thread. See http://www.mail-archive.com/python-list@python.org/msg120086.html , but it starts at http://www.mail-archive.com/python-list@python.org/msg119559.html

8:14 It's a very long thread, and I couldn't find the money quote about how prefixes are irrelevant, but the first link points in that direction. And lxml is pretty highly-regarded, last I knew. *shrug*

8:15 So fundamentally, I think whoever adds namespaces to clojure.xml needs to have a sit-down with a dozen XML "experts" from various schools of thought before we make a move there.

8:16 chouser: sounds like a formula for getting nothing done. :-)

8:16 cemerick: heh

8:16 ohpauleez: haha zing

8:17 chouser: "A committee is a life form with six or more legs and no brain." --Lazarus Long

8:17 avarus: :P

8:17 cemerick: insofar as XML is about interop, it seems like we should make sure we're meeting external expectations

8:17 chouser: cemerick: but you're probably right. It'd be easy to do something that any number of them could have told you was wrong on its face.

8:18 Chousuke: in general, the time required to make a decision is proportional to the number of decisionmakers

8:18 cemerick: Chousuke: except that, there should be no decisions here -- only finding out what is acceptable and expected elsewhere

8:19 chouser: Chousuke: that would be one thing, but if only the quality of the decision weren't so often inversely proportional...

8:20 cemerick: chouser: helluva spike, though. I need to float more ideas out there and see who else will do my work for me. ;-)

8:20 chouser: cemerick: hehe

8:21 I'm a known sucker for such things among my friends. They regularly talk loudly about things they wished existed, hoping I'll take the bait. :-/

8:21 cemerick: so are you interested in cleaning that up and submitting a patch for clojure.xml?

8:22 cemerick: sure, I'll take the credit ;-)

8:22 chouser: wfm

8:22 cemerick: Seems that "" should be the namespace until we figure that out.

8:22 wfm?

8:23 chouser: works for me

8:23 cemerick: ah

8:23 chouser: yeah, you're probably right.

8:23 cemerick: chouser: thoughts on *out*, etc?

8:24 chouser: thoughts, sure. solutions, not at all.

8:25 for example, returning strings is inapporpriate when combined with an xml declaration that includes an encoding, right?

8:25 just as bad as printing to an Writer that already has an encoding if the encodings don't match.

8:26 cemerick: right, we have to let the transformer drain to an outputstream-based StreamResult

8:26 I'm inclined to have emit take an OutputStream, and punt on the *out* issue until someone figures out the right wrapper.

8:27 e.g. emit-with-out

8:27 chouser: but does that mean casual use such as at a repl requires building an outputstream chain?

8:28 cemerick: well, I can make emit into emit*, and have emit bind *out*

8:28 so, yes :-)

8:28 chouser: hm. or perhaps add an option to take the outputstream

8:29 cemerick: in the optseq?

8:29 chouser: that's what I was thinking

8:29 seriously, why does the SAX spec use char[] instead of a String? bleh.

8:30 cemerick: because it was designed by a language-agnostic committee and implemented transparently in java

8:30 but yeah, bleh

8:30 having the outputstream in the optseq doesn't seem right. It's decidedly not a peer to :indent or :encoding, etc.

8:31 chouser: ok

8:32 so two fns, one that emit's to *out* (with appropriate warnings about encoding) and one that takes an outputstream?

8:33 cemerick: I think so. Naming? emit and emit-with-out or emit and emit*?

8:33 chouser: emit-to ?

8:33 cemerick: ah

8:33 sure

8:34 chouser: hm

8:34 what about allowing the user to pass in *out*, but printing a warning everytime when they do?

8:35 cemerick: not sure who wins in that scenario

8:35 chouser: ok

8:36 cemerick: I'll have a ticket + patch up later today

8:37 chouser: thanks!

8:37 cemerick: thank you :-D

8:37 chouser: cemerick: cgrand just responded on this subject from yesterday.

8:37 cemerick: where?

8:37 clojurebot: where is your source code

8:38 chouser: http://clj-me.cgrand.net/2010/02/10/why-enlive-templates-return-seqs-of-strings/

8:38 cgrand: on my blog, since "everyone" was asleep

8:38 chouser: :-)

8:39 cemerick: cgrand: how do you manage to get so much done when it's dark out? ;-)

8:39 cgrand: did you catch what chouser put together?

8:46 cgrand: cemerick: I'm just back from lunch, and reading the logs

8:46 I agree: prefixes are a serialization thing and should not be in the tree

8:47 cemerick: heh

8:47 good to have more confirmation on that

8:50 cgrand: we'd have to set up a pipe from the outputstream that chouser's emit writes to an inputstream that could be passed off to ring/compojure, but I wonder what you think of it as a general replacement for enlive's emit?

8:53 cgrand: for enlive it means that each serialization incurs a full traversal of the tree :-(

8:53 cemerick: indeed

8:54 The price we pay for using the stdlib.

8:56 cgrand: I guess one could cache seqs of sax events instead of strings for static nodes

8:57 chouser: ring and definitely a specific environment -- perhaps it makes sense to have different emits for enlive vs. clojure.xml?

8:58 cemerick: cgrand: wouldn't those cached events be roughly the same size as the equivalent clojure.xml tree?

8:59 I'd hate to see this not be generally applicable.

8:59 konr: I'm in a ->> form, and I want it to behave like -> in one step. Is there a more elegant way to do that besides something like (->> 3 (- 10) (#(%1 %2) #(- % 5))) ?

8:59 underdev: LOOK! ITS PERL!

9:00 :)

9:00 konr: haha, almost :)

9:01 cgrand: on chouser's new emit: it's cool and I think there's real value in extracting the clojure.xml tree -> sax events transformer (eg for interop with DOM consuming libs)

9:02 powr-toc: with the ns macro... is there a difference between (:use [foo.bar]) and (:use (foo.bar))?

9:02 chouser: konr: when I'm in such circumstances I generally decide it's not worth using the ->> form anymore.

9:03 rhickey: cgrand: did you have any thoughts on ->/->> flipping and env arg to resolve?

9:03 powr-toc: Or rather... why does (:import (use lists)) and (:use [use vectors)) ?

9:03 cemerick: powr-toc: the latter won't use anything, whereas the former will use foo.bar. The first element in a parenthesized :use is the prefix applied to all other elements in the :use form.

9:03 chouser: it's hard to argue that the transformer-based emit isn't better than what's in clojure.xml and lazy-xml now. Not sure about enlive though.

9:05 cemerick: I'd like to know what could be improved to make it usable by enlive. That's exactly the sort of use case that emit should fill.

9:05 powr-toc: cemerick: not sure I follow...

9:06 cemerick: powr-toc: parens in :use, :require, and :import treat the first symbol as a prefix. e.g. (:use (clojure.contrib def core)) (:import (java.util List ArrayList))

9:07 powr-toc: cemerick: ok, what about vectors, do they have a different behaviour?

9:08 cemerick: powr-toc: yes. See the docs for require and use for more info.

9:08 cgrand: rhickey: yep, I have problem with aliases (and there's the same problem in chouser's patch for -> and ->> destructuring): so I tried to 'resolve the symbol and see if this returns #'-> or #'->> but when the tested symbol is String. or .foo I get an exception. That's why I asked about fixing resolve. (or adding a resolve restricted to vars)

9:08 powr-toc: ahh require... has a lot more docs than the others... I find the namespace docs a bit confusing, and dispersed.

9:09 avarus: how can I check if compojures (params :foo) and (params :bar) contains something != empty in an elegent way?

9:09 cgrand: cemerick: enlive's emit is optimized for _repeated_ serialization

9:09 ordnungswidrig: avarus: (not (empty?) (params :foo))

9:10 avarus: is a number empty?

9:10 avarus: ordnungswidrig: exactly how I am doing it now but how would you check more than one?

9:10 a number is not empty

9:10 ordnungswidrig: avarus: anyway (params :x) returns a string....

9:11 cemerick: cgrand: OK. I guess I would ask why -- at least in the context of ring/compojure, a template's tree is only ever serialized once, no?

9:11 ordnungswidrig: avarus: check a set of parameters?

9:11 avarus: ordnungswidrig: e.g.? :)

9:11 ordnungswidrig: avarus: got me wrong. Do you want to check a set of parameters, say :foo :bar for not emptyness?

9:12 avarus: yes

9:12 rhickey: cgrand: but what you asked about 'fixing' was this.that, not this. or .that

9:12 avarus: but in a short way, ordnungswidrig :)

9:13 rhickey: (resolve 'String.) is broken

9:13 (resolve '.that) is harmless

9:14 I think you can fix the former without doing away with classname correctness checling

9:14 checking

9:14 cgrand: rhickey: true, my fault: I wasn't specific enough (as usual :-/) in defining what I wanted

9:15 rhickey: patch welcome for (resolve 'String.) -> nil

9:15 cgrand: rhickey: ok, I create a ticket, attach a patch and update the patch for ->/->>

9:16 ordnungswidrig: avarus: (every #(-> % params empty? not) [:foo :bar]))

9:16 avarus: ach du scheisse :P

9:16 ok, I'll try it :)

9:16 ordnungswidrig: avarus: this is short for (every #((not (empty? (params %)))) [:foo :bar])

9:17 avarus: "short" in a sense of "short of parens"

9:17 avarus: ok :)

9:18 ordnungswidrig: avarus: i'd probably define some helper (defn param? [n] (-> n params empty? not)) and then (every param? [:foo :bar])

9:18 or like that

9:22 cgrand: cemerick: when you define a template the serialization of its source tree is cached. When you call the template only "dirty" nodes are serialized. See, in my blog post, the difference between "<h1>This is a static title</h1>" and "<h2>" "Replaced dynamic title" "</h2>". Hence static parts are only serialized once: at definition time.

9:25 cemerick: ah, see, I hadn't read your post yet :-/

9:26 avarus: ordnungswidrig: big thanks! I think the example with the helpfer function is the most readable one

9:26 helper*

9:26 at least for me

9:27 cemerick: cgrand: Perhaps I've been using enlive "all wrong" then, but there is virtually no content in my templates -- everything is being injected from other snippets being pulled in from elsewhere, which have no cached serialization.

9:29 Where I'm going with this is, it seems that serialization of relatively small bits of static content is a minor issue, given that most of the serialization going on is over dynamic content.

9:30 cgrand: snippet also performs pre-serialization (because snippet and template noth rely on snippet*: http://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj#L318)

9:30 jcromartie: I wonder how enlive compares (performance-wise) to things like ERB or JSP

9:31 cemerick: cgrand: right, I'd forgotten that.

9:31 jcromartie: templating (regardless of the flavor) is almost always inconsequential to an app's perf

9:31 jcromartie: well yeah, it's rarely a bottleneck

9:31 when my DB might take 200ms to respond

9:32 but I'm looking at some serious scaling in the future

9:33 cemerick: cgrand: won't you have to abandon that approach entirely if enlive is to support different encodings and namespaces?

9:33 jcromartie: heh, and that certainly won't depend on your templating system. :-)

9:33 or your DB perf, for that matter

9:34 cgrand: cemerick: if one can make chouser's emit to work on fragments (I haven't checked yet) then it could be used by enlive without sacrificing the serialization cache.

9:34 on encoding: no, I serialize to Strings not to bytes

9:35 jcromartie: hmm, this is interesting...

9:35 ,(nil)

9:35 clojurebot: java.lang.IllegalArgumentException: Can't call nil

9:35 jcromartie: ,(let [x nil] (x))

9:35 clojurebot: java.lang.NullPointerException

9:37 cgrand: namespaces are a problem but I think I have a solution for serialization. The real pain with namespaces is how to integrate them in the selector syntax.

9:40 jcromartie: http://blog.n01se.net/?p=85 <- these should be made to be defaults

9:40 djpowell: xpath apis generally let you use prefixes in your selectors, but pass a prefix->namespace map for their interpretation

9:43 cemerick: cgrand: by fragments, I presume you mean seqs of strings that when concatenated, would result in a complete element. If emit were to work with such a thing, it would require reparsing the fragment into elements that would be used for the basis of the sax events. Not so great.

9:43 cgrand: no by fragment I mean an XML fragment

9:44 cemerick: cgrand: oh, just a clojure.xml tree?

9:45 cgrand: yes, I have to go

9:54 jcromartie: I'm trying to make a .cljrc.clj or something like that

9:54 what do you all do for such things?

9:56 i.e. a startup script

9:57 devlinsf: jcromartie: I think the convention is to include a user.clj in your classpath

9:57 At least it used to be

9:57 jcromartie: I have seen a dozen different ways

9:57 many of them incomplete or outdated

10:02 I'm just not sure how to mix my startup .clj with clojure.main and running a repl

10:03 as it seems that passing any arguments after clojure.main means that it just runs that script and quits

10:03 chouser: user.clj doesn't work for many of the repl settings you want

10:04 cemerick: jcromartie: are you really running a repl from the command line?

10:04 jcromartie: cemerick: yes I am really running a repl from the command line

10:04 is that surprising?

10:04 I thought people did that

10:04 chouser: the repl-launching script I use does: rlwrap java clojure.main -i ~/.clojure/repl-init.clj

10:05 jcromartie: ah, I see user.clj in here http://clojure.org/getting_started

10:05 cemerick: only hardcore hackers like chouser use a repl on the command line except as a last resort ;-)

10:05 chouser: ...and then either -r or if foo.clj is supplied on the command line, -i foo.clj

10:05 jcromartie: I don't understand what's special about running a repl on the command line

10:05 chouser: I think I'm more "fuddy-duddy oldtimer" than "hard core hacker" :-/

10:06 cemerick: enclojure, inferior-lisp, slime, all provide better tools around the repl

10:06 chouser: jcromartie: everyone else uses IDEs or emacs

10:06 jcromartie: ah yes

10:06 well I am not running emacs on my servers (and yes I run my servers in repls)

10:06 chouser: and then go around posting questions when things break. :-)

10:06 jcromartie: heh

10:06 chouser: where are these -i and -r options documented?

10:07 cemerick: jcromartie: you don't have to run emacs or whatever on your servers -- just a repl-server, which is extraordinarily lightweight.

10:07 jcromartie: repl-server, eh?

10:07 avarus: jcromartie: I'm using emacs with clojure mode but still firing up the repl by hand :)

10:07 chouser: jcromartie: -h

10:07 _fogus_: What about if it someone like me who's too lazy to setup my IDE? Is that l33t also?

10:07 cemerick: jcromartie: in enclojure's case, a 200-line file that opens up a socketserver on a port that you can connect to.

10:07 jcromartie: yeah really I mean rlwrap with tab completion makes for a decent repl

10:08 AWizzArd: And for emacs you can just start the swank-server.

10:08 jcromartie: JLine is awful... it's just completely utterly terrible compared to rlwrap, and I think it has to do with a lot of why people don't like command line repls

10:08 AWizzArd: Then you can connect to it with your external emacs, over a ssh-tunnel for example.

10:08 jcromartie: I wish everybody would stop recommending it

10:08 hmm

10:08 DeusExPikachu: *sighs* snowed in again :)

10:08 jcromartie: DeusExPikachu: you must be in my neighborhood :)

10:09 avarus: I believed textmate was a good editor but it's not (for clojure :))

10:09 * chouser just cleared the driveway again

10:09 jcromartie: OK so still, what about these -i and -r options?

10:09 avarus: snow here, too :(

10:09 DeusExPikachu: jcromartie, just woke up (a bit late) in Baltimore

10:09 avarus: I fucking hate snow (outside the nose)

10:09 jcromartie: not here http://clojure.org/repl_and_main

10:09 DeusExPikachu: I'm down the road in Frederick

10:09 chouser: jcromartie: -h

10:09 _fogus_: My heat pump looked like Han Solo at the end of Empire Strikes Back

10:09 jcromartie: chouser: ah you mean run clojure.main -h

10:10 for help

10:10 chouser: yeah, I figured if I just kept saying the same cryptic thing over and over somebody would eventually get it.

10:10 :-P sorry

10:10 ordnungswidrig: position in collection? (position [:a :b :c] :b) -> 1

10:11 is there sth like that?

10:11 ohpauleez: I too run the repl from the command line

10:11 vim + command line repl

10:11 chouser and I are going to do an entire workshop at the first clojure con

10:11 :)

10:11 chouser: ,(#'clojure.main/help-opt 0 0)

10:11 clojurebot: Usage: java -cp clojure.jar clojure.main [init-opt*] [main-opt] [arg*] With no options or args, runs an interactive Read-Eval-Print Loop init options: -i, --init path Load a file or resource -e, --eval string Evaluate expressions in string; print non-nil values main options: -r, --repl Run a repl path Run a script from from a file or resource - Run a script from standard input -h, -?, --help Print this help message and exi

10:11 avarus: t

10:12 :>

10:12 jcromartie: clj -e '(+ 1 1)'; # yields Exception in thread "main" clojure.lang.LispReader$ReaderException: java.lang.Exception: EOF while reading

10:12 chouser: ohpauleez: what windowmanager do you use?

10:12 jcromartie: not with my clj it doesn't. mine prints 2

10:12 ohpauleez: Right now I'm using OSX with Awesome overtop

10:13 but I usually use Fluxbox or enlightenment

10:13 jcromartie: my clj is very simple

10:13 ohpauleez: I'm really enjoying Awesome though. Awesome + OSX is turning out to be a total productivity enhancer for me

10:13 jcromartie: ohpauleez: does Awesome require X?

10:13 ohpauleez: and I use screen extensively

10:13 yes

10:13 jcromartie: ^

10:14 chouser: ohpauleez: I think when you have a helpful windowmanager (ion3 in my case), it helps simpler tools (like a command-line repl) become a lot more powerful.

10:14 avarus: ohpauleez: are you on snow leopard?

10:14 DeusExPikachu: jcromartie, cool, that's close, I'm at the wyman park area, west of Johns Hopkins Homewood campus, should have a clojure meet one of these days :)

10:14 Chousuke: Awesome would be great but it doesn't help with native OS X apps :/

10:14 avarus: a clojure meet lol :)

10:14 ohpauleez: chouser: I totally agree, ion3 is tiling, like awesome. Awesome allows floating too, so that's why I use it

10:14 avarus: I am

10:15 chouser: ion3 allows floating now too.

10:15 ohpauleez: ohh, rad!

10:15 avarus: ohpauleez: just curious...is it normal that snow leopard takes around 6GB after setup?

10:15 not that I care

10:15 just curious :P

10:15 chouser: I think what I want is tabs and tile-inspired floating. but now I'm way off topic.

10:16 * cemerick put his hands over his ears and started humming to himself once he read "what window manager do you use?" ;-)

10:16 ohpauleez: chouser: take a look into awesome when you have some time. It's like ion3 (as I remember it) + fluxbox

10:16 hahaha

10:17 avarus: I use emacs as window manager *joking

10:17 chouser: I bet cemerick still uses a mouse to move his winodws around.

10:17 ohpauleez: avarus: total zing. But with 500 GB, I don't care so much

10:17 hahaha, nicely done chouser

10:17 cemerick: chouser: screw that man, I wouldn't use a mouse. I use a trackball! So there! :-P

10:17 avarus: zing? :)

10:17 chouser: heh

10:18 ohpauleez: true story, Sometimes RMS stays with me when he's in Philly. And he uses emacs as his window manager, but edits emails in.... VIM

10:18 avarus: lol :)

10:18 cemerick: for me, window managers : OS X :: emacs : <anything else>

10:18 ohpauleez: avarus: it's like saying, "touche". The full phrase is: That's a real zinger

10:19 konr: xmonad is very nice

10:19 devlinsf: Steve Balmer is my Windows Manager

10:19 chouser: xmonad's configuration system strikes me as an indictment of haskell

10:19 jcromartie: chouser: hah

10:20 avarus: ohpauleez: ah thx :)

10:20 ordnungswidrig: hmm, no indexof anywhere?

10:20 DeusExPikachu: maybe someone will make a clojure window manager?

10:20 avarus: there's a perl window manager, so why not :P

10:20 chouser: DeusExPikachu: it's been started, though perhaps I'm not supposed to say that out loud.

10:20 jcromartie: I guess so

10:20 DeusExPikachu: call it xmacro

10:21 ohpauleez: haha

10:21 ordnungswidrig: ,((zipmap [:a :b :c :d] (iterate inc 0)) :b)

10:21 clojurebot: 1

10:21 jcromartie: PROTIP: to doom your project to obscurity, start a window manager and name it after an abstract programming language feature

10:21 ohpauleez: hahaha, this has to be one of the funniest tangential discussions in #clojure ever

10:22 chouser: look at what we started

10:22 * chouser apologizes

10:22 ordnungswidrig: anybody else using xmonad with emacs in viper vi emulation?

10:22 *scnr*

10:22 avarus: lol

10:22 ordnungswidrig: i actually like it.

10:23 konr: ordnungswidrig: Oh god, me too!

10:23 ordnungswidrig: are you using vimpulse, too?

10:24 ordnungswidrig: konr: no, not heared of it :-)

10:24 chouser: for block selection, right?

10:25 konr: ordnungswidrig: it emulates many features of vim... see http://www.emacswiki.org/emacs-fr/vimpulse

10:25 ordnungswidrig: currently reading

10:25 konr: chouser: yes!

10:25 chouser: dabbled with it last time I gave emacs a chance

10:26 ordnungswidrig: blockselection i never use

10:26 visualmode i seldomly use

10:26 jcromartie: BTW, my ~/bin/clj is one line

10:26 rlwrap java -cp src:resources:test:"$HOME/.clojure/*" clojure.main $@

10:26 and -e fails for whatever reason

10:27 (even without rlwrap)

10:27 chouser: hm. try "$@" instead

10:27 jcromartie: hooray!

10:28 I don't understand why, but that worked.

10:28 Lovely.

10:28 chouser: sh is a minefield. I had an expert pick over my clj script.

10:28 konr: There is also viper-in-more-modes, which I'm currently hacking to allow the use of the leader key in clojure (eg " c" instead of "C-cC-c": http://pastebin.com/f32361732

10:28 mattc58: hello everyone. Question: I'm using Leiningen, and I'm trying to use the 1.2.0 versions of clojure and contrib. I'm having a problem when I try to use the clojure.contrib.string library.

10:28 Two Java exceptions. 1 deals with missing class Replacement

10:28 chouser: $@ without quotes was like: java clojure.main (+ 1 2) ...three args instead of one

10:28 mattc58: the other deals with "Unable to pop operand off an empty stack" from string$replace_first_re

10:29 any ideas?

10:30 avarus: bye :)

10:35 _fogus_: ,((comp first rest) [1 2 3])

10:35 clojurebot: 2

10:35 _fogus_: wrong window. :(

10:36 Chousuke: I think that's also known as frest

10:36 :P

10:36 cemerick: _fogus_: don't worry, I can never remember comp's order of application either. :-P

10:36 Chousuke: heh

10:36 drewr: cemerick: +1

10:36 cemerick: Chousuke: that pointfree stuff in the disclojure screencast was scary as hell.

10:37 * cemerick continues a conversation from 2 weeks ago

10:37 _fogus_: cemerick: ;)

10:37 Chousuke: cemerick: yep :P

10:38 ordnungswidrig: cemerick: which screencast do you mean?

10:38 Chousuke: I'm more partial to point-freeness than I used to be, but it still needs to be used small amounts at a time only.

10:39 cemerick: ordnungswidrig: there was a full disclojure screencast that focused on pointfree style, and the more realistic example at the end was crazy.

10:39 Every time I think I'll use partial, it ends up being longer than using #().

10:40 Chousuke: cemerick: yes, but partial makes it look less noisy

10:40 ordnungswidrig: thanks

10:40 DeusExPikachu: cemerick, don't have to mentally parse the #(), you'd know what partial does

10:40 cemerick: yeah, I can see that. I often have to drop the incoming arg into the middle of the parameter list anyway, so...

10:41 DeusExPikachu: *you'd

10:41 cemerick: I disagree *shrug*

10:41 Chousuke: maybe we're blub programmers.

10:42 DeusExPikachu: maybe it is more clear if you keep forgetting which end of the args it adds too

10:43 I forget

10:43 ordnungswidrig: I wonder if there could by a shorter alternative to "partial" like (def ° partial)

10:43 Chousuke: ordnungswidrig: well you can always do that yourself

10:44 cemerick: DeusExPikachu: I'm not *confused* by partial, it's just that it is often longer than using #(), and often is unusable (due to where an argument is going to be placed.

10:44 devlinsf: cemerick: What was scary?

10:44 jcromartie: (oh, and for whoever though I was crazy for running a repl outside of Emacs, the Rails folks think I'm crazy to run my dev server within Emacs!)

10:44 ordnungswidrig: Chousuke: of course by point free code is already hard to read. using individual shortcuts makes it harder

10:44 cemerick: jcromartie: no, that's crazy too :-)

10:44 DeusExPikachu: cemerick, I'm not saying you're confused at all, I'm only talking about readability tradeoffs

10:44 jcromartie: DANG IT

10:44 cemerick: devlinsf: we're hating on pointfree :-)

10:44 DeusExPikachu: you in third person

10:45 ordnungswidrig: DeusExPikachu: and then add flip to it to make pointfree more pointless

10:45 devlinsf: cemerick: Ah. To each their own

10:45 cemerick: yup

10:45 AWizzArd: What is fn* doing?

10:46 devlinsf: cemerick: And yes, I *do* code like that sometimes

10:46 Chousuke: AWizzArd: you don't need to know.

10:46 AWizzArd: fn is the *documented* special form :)

10:46 AWizzArd: Chousuke: one of my macros expands into a fn*

10:47 So to evaluate its correctness (and it has a little problem) I need to understand this part.

10:47 cemerick: devlinsf: I hear it's all the rage with people who do a lot of work with maths. Maybe once I learn a few things about stats, I'll come around. :-)

10:47 Chousuke: AWizzArd: think of it as fn

10:47 AWizzArd: What is the difference then?

10:47 devlinsf: cemerick: I also took WAY too much linear algebra in school

10:47 Chousuke: AWizzArd: fn is a macro implemented on top of fn*, which is implemented in Java.

10:47 cemerick: devlinsf: oh, see, so you're damaged for life anyway ;-)

10:48 _fogus_: devlinsf: There is never too much linear algebra

10:48 Chousuke: AWizzArd: it shouldn't matter to you what fn does differently from fn*, since you're never supposed to directly use fn* (it might even go away someday)

10:48 devlinsf: _fogus_: You sure about that?

10:48 ordnungswidrig: can clojure names be UTF?

10:48 cemerick: yes

10:48 ordnungswidrig: my emacs warns on (def ⋅ comp)

10:48 Chousuke: AWizzArd: I suppose the fn macro handles destructuring and such.

10:49 ordnungswidrig: yes they can

10:49 cemerick: ordnungswidrig: whether your editor, etc are capable or not is another story

10:49 AWizzArd: Chousuke: I am not using fn* directly. It just got expanded into my code ;)

10:49 Chousuke: ordnungswidrig: check SLIME encoding. it's latin1 by default.

10:49 ordnungswidrig: Chousuke: I see

10:49 _fogus_: devlinsf: Absolutely. Never too much linear and never enough stats :(

10:50 cemerick: heh, that's like mysql's collation default being set to swedish.

10:52 devlinsf: _fogus_: Then pay attention the next couple of weeks :)

10:54 * _fogus_ anxiously awaits the next season of Full Disclojure

10:54 ghotli_: so. monads. how did you achieve understanding? by using them? have a good book to suggest?

10:54 jcromartie: is there any work towards something ORM-ish in Clojure?

10:56 tmountain: jcromartie: http://github.com/duelinmarkers/clj-record

10:56 chouser: AWizzArd: try using macroexpand-1 instead of macroexpand

10:56 jcromartie: yay

11:03 I feel like models could be namespaces with attributes and relationships as simple functions.

11:03 like (customer/orders (customer/find-by {:first-name "john"}))

11:04 at least that's where I'm going with my code

11:08 devlinsf: jcromartie: I'd start thinking in terms of protocols. Somebody is gonna release a set of awesome CRUD protocols soon enough...

11:10 jcromartie: can I use protocols in 1.1?

11:10 they're not on clojure.org

11:10 devlinsf: jcromartie: No, they're going to be one of the defining features of 1.2

11:11 jcromartie: so we've got multimethods and protocols

11:11 are multimethods going to be "deprecated" or do they serve a different purpose

11:11 devlinsf: jcromartie: Some of both

11:12 protocols will be a special case of multimethods

11:12 At least conceptually

11:12 ordnungswidrig: devlinsf: for single dispatch will there a differene regarding performance?

11:12 jcromartie: I can see a lot of confusion between all of these different ideas popping up...

11:13 stuartsierra: Protocols are faster than multimethods for single-argument type dispatch.

11:13 devlinsf: ordnungswidrig: My limited experiments has shown them to be much, much faster

11:13 (Thanks stuartsierra)

11:13 ordnungswidrig: devlinsf: protocols are faster.

11:13 ?

11:13 Oh, I see

11:14 jcromartie: where can I read about Protocols?

11:14 http://www.assembla.com/wiki/show/clojure/Protocols

11:14 devlinsf: On the assembla page

11:14 ordnungswidrig: stuartsierra: is this because JVM does single dispatch?

11:14 devlinsf: Also, doc defprotocol has a lot

11:15 There is going to be a lot of work done explaining these concepts when 1.2 comes out

11:15 pdk: is there a release timeline for 1.2, betas etc

11:17 stuartsierra: ordnungswidrig: yes, the JVM is very good at optimizing single dispatch

11:17 jcromartie: yeah really, and examples for where you would use one over another

11:18 would be good

11:18 stuartsierra: I'm working on a book for Apress that will include a chapter on deftype/defprotocol

11:18 cemerick: stuartsierra: is this news, or have I not been paying attention?!

11:19 ordnungswidrig: stuartsierra: for multiple dispatch only on the type of the arguments, can this be reduced to single dispatch in some way to take advantage of this?

11:19 stuartsierra: cemerick: It's been in the works for a while, but i haven't talked about it much b/c the publication date was uncertain

11:19 cemerick: stuartsierra: congrats, then, either way! :-D

11:19 stuartsierra: ordnungswidrig: Yes, I demonstrated a macro to do this.

11:19 cemerick: thanks!

11:19 jcromartie: I hope people don't get caught up on the Java differences between reify and proxy

11:20 stuartsierra: jcromartie: proxy will be deprecated in situations that reify can support

11:20 jcromartie: it seems to me that you can't always use reify where you could use proxy

11:20 ordnungswidrig: stuartsierra: have a ghist / pastie?

11:20 stuartsierra: somewhere...

11:21 ordnungswidrig: stuartsierra: just if you have it at hands, I'll google it else, if it's public

11:21 jcromartie: stuartsierra: like if you have a Java method that takes a subclass instead of just looking for an interface

11:21 stuartsierra: ordnungswidrig: It's on paste.lisp.org somewhere

11:22 Here: http://paste.lisp.org/display/93387

11:22 Corrected version here: http://paste.lisp.org/+2023/2

11:24 ordnungswidrig: oh, thanks

12:01 DeusExPikachu: does anyone have slime-edit-defun working correctly for a remote swank server, (possibly by using a properly configured tramp filename translator)?

12:04 I got slime-load-file to work, but function defs in the lib/ directory are not being found

12:10 cgrand: rhickey: when you say "a version of resolve that takes the environment" you mean something like (resolve sym &env) and (ns-resolve ns sym &env) or a private helper ?

12:14 * ordnungswidrig plays with nixos and likes it

12:16 joshua-choi: What do special-form-anchor and syntax-symbol-anchor do? I just randomly found them in the docs...

12:19 yuuki: any bitc-ers in here?

12:19 cgrand: joshua-choi: they are used to generate the fragment part of the url whe,n you do (doc if) for example

12:19 ,(doc if)

12:19 clojurebot: Gabh mo leithscéal?

12:19 cgrand: ĩf

12:19 ~if

12:19 clojurebot: Pardon?

12:20 joshua-choi: -------------------------

12:20 if

12:20 Special Form

12:20 Please see http://clojure.org/special_forms#if

12:20 I see; that's what it does.

12:20 Why two functions, though?

12:21 cp2: http://www.wreck.devisland.net/ga/ neato

12:21 safe for work, of course

12:21 unless you want your productivity to go down :)

12:22 cgrand: joshua-choi: reading #'doc source I would say that's beacuse they are also used as predicates

12:24 rhickey: cgrand: yes, but sym last

12:24 joshua-choi: I see...it seems to be that special-form-anchor is for those special symbols whose anchors are just their names, while syntax-symbol-anchor is for those symbols whose anchors are different than their names.

12:25 cgrand: rhickey: and &env first or second for ns-resolve?

12:25 rhickey: after ns

12:26 cgrand: ok

12:26 rhickey: thanks!

12:42 replaca: I never cease to be amazed by the civil quality of the discussion in the google group!

12:59 AWizzArd: rhickey: some days ago we mentioned PersistentMultimaps. Do you still have an implementation of them flying around?

13:00 rhickey: AWizzArd: never implemented, as I said, you can build them on maps of keys to sets

13:00 AWizzArd: This is what I currently do, although it is pretty "manual" so far.

13:03 Leafw: AWizzArd: what is a multimap ?

13:03 keys to sets sounds like a normal construct, to me

13:03 AWizzArd: Leafw: A map onto which you can assoc maany objects with the same key

13:04 (assoc mm :a 1, :a 2, :a 3) ==> {:a #{1 2 3}}

13:04 Leafw: AWizzArd: I see, you just want some sugar on it to make it easier, some sort of cummulative assoc

13:04 rhickey: urk, default print-methods for deftype not desired for 'real' types defined with deftype

13:05 AWizzArd: Leafw: so to say

13:05 rhickey: what are "real types" defined with deftype?

13:05 rhickey: I'm coming around to thinking all this default map-like stuff should be stuck in a new defstruct built on deftype

13:05 AWizzArd: I'm working on persistent vectors defined with deftype

13:06 AWizzArd: Oh! Wow, that sounds interesting

13:06 Would be amazing to see them perform about as well as our current Vectors.

13:06 rhickey: should have just automatically printed as vectors, but aren't due to generated print

13:06 AWizzArd: I'm making sure perf is identical as I go

13:07 AWizzArd: Aah, they print as #:Vector{ ... }

13:07 amazing.. I remember that cemerick was very sceptical about the efficiency ;)

13:08 cemerick: AWizzArd: I was?

13:08 AWizzArd: yup :)

13:09 1-2 months ago or so

13:09 cemerick: I doubt that, but whatever :-)

13:14 rhickey: are all deftype classes serializable by default?

13:14 rhickey: cemerick: possibly

13:14 IOW, not thought about yet

13:15 cemerick: ah

13:15 cgrand: rhickey: are you trying to specialize vectors by depth or reimplementing them as in Java?

13:15 cemerick: I mean, they appear to be already.

13:16 rhickey: cgrand: mostly as in Java. I'm not sure differing type by depth is a win, vs just switching to a switch instead of a loop in arrayFor

13:16 cgrand: the target here is - same perf, plus maybe macroizing to gen vectors of primitives

13:17 cgrand: only need a six-way switch, and can unroll the nested derefs

13:20 cemerick: rhickey: having serializable baked in to deftype + reify seems like the right thing to do IMO/FWIW. That's really been driven home for me by having to deal with session storage, etc. again.

13:22 cgrand: rhickey: still not considering having the last and the penult (for even-sized vectors) items as fields? :-)

13:22 rhickey: cgrand: no

13:26 cemerick: well, when AOTed deftype gens stable names

13:26 serializing a reify though...

13:27 cemerick: yeah, we've been down this road a little before

13:33 ericthorsen: how many books do we have in the KLP database now?

13:33 qed: KLP?

13:33 ericthorsen: opps wrong window

13:33 sorry

13:43 qed: do i just have a really old paredit? I don'

13:43 I don't have working {}

13:45 it looks like i have 22 beta

13:56 ordnungswidrig: qed: I don't have them either!

13:56 I have 22 from elpa

13:57 sorry, I have 20 from epla

14:07 qed: hmm -- wish i could figure out how to use this library

14:08 technomancy|away: I'm still getting that pesky json error and this is a complete re-install of OSX 10.6 (im speaking of leiningen (lein autodoc specificall))

14:08 stuartsierra: qed: what's the json-related error?

14:11 qed: stuartsierra: [null] #<CompilerException java.lang.ExceptionInInitializerError (json.clj:15)>

14:12 technomancy seemed puzzled by this and could not recreate it a couple of weeks ago, but the issue still persists so I'm not sure what's the deal there

14:13 stuartsierra: qed: Which json lib is this? The latest clojure.contrib.json?

14:13 qed: 1.1.0 i believe

14:13 stuartsierra: o

14:13 ok

14:14 qed: sorry should have specified that

14:14 jcromartie: what code is throwing that exception?

14:14 qed: im just running lein autodoc from the command line, autodoc is a dev-dependency, but it throws that error

14:15 jcromartie: oh nevermind sorry

14:15 stuartsierra: Ok, that must be something in lein or autodoc; clojure-contrib doesn't contain a file named "json.clj" in 1.1.0

14:15 qed: hmm weird

14:16 jcromartie: what version am I looking at here http://github.com/richhickey/clojure-contrib/tree/master/src/main/clojure/clojure/contrib/

14:16 stuartsierra: jcromartie: current master

14:16 jcromartie: I see

14:17 duh!

14:17 (playing with tags)

14:17 stuartsierra: I think this file is the culprit: http://github.com/richhickey/clojure-contrib/blob/1.1.0/src/clojure/contrib/pprint/examples/json.clj

14:18 Line 15 is the start of the ns declaration; that's usually the source of ExceptionInInitializerErrors.

14:18 qed: nod

14:18 my guess is it is autodoc at fault

14:19 im using autodoc 0.7.0 from clojars

14:21 stuartsierra: does autodoc use/require clojure.contrib.pprint.examples.json ?

14:44 cemerick: sheesh, I never knew refs were IFns

14:45 I presume that's only an implementation detail?

14:45 rhickey: cemerick: it's not a promise yet, but seems to make sense for all reference types

14:45 flow through to contained val

14:45 cemerick: yeah

14:47 rhickey: I'd suggest adding an 'unpack' fn to core once that becomes a promise (e.g. recursively derefing until you're out of turtles)

14:47 rhickey: cemerick: not sure about that

14:48 refs of refs is a bit icky

14:48 AWizzArd: indeed :)

14:48 cemerick: rhickey: right, but sometimes one gets something that acts like an Associative, until you try to assoc on it, and discover it's a ref with a map in it.

14:49 rhickey: ?

14:49 cemerick: I'm talking about a 3rd party lib that, it turns out, returns a ref OR a map from a particular fn.

14:50 rhickey: that's crazy

14:50 mixing values and refs

14:51 cemerick: indeed, but insofar as refs (and other reference types) can act like values in function position, it's going to happen

14:51 AWizzArd: rhickey: do you mean mixing the returned values?

14:52 cemerick: even relatively good unit tests wouldn't catch that if someone was using (object :slot) instead of (:slot object)

14:53 rhickey: cemerick: I'm not going any further down that road

14:54 wow, there's a lot to making a complete data structure for Clojure, even porting pvector is a pain :(

14:56 AWizzArd: was it easier to do in pure Java?

14:56 rhickey: AWizzArd: no

14:57 AWizzArd: Btw, pvector will only be of use with this special extension lib which is still not going to be included in Java 7 yes?

14:57 rhickey: but pvector support 20+ interfaces

14:57 AWizzArd: oh

14:57 rhickey: AWizzArd: different pvector

14:57 p = persistent

14:57 AWizzArd: Ah, oki

14:58 krumholt: programming in clojure is fun! i just read that in stuart sierras book. it's in a book so it must be true

14:58 AWizzArd: Yup :)

14:59 the-kenny: Ohh this reminds me of my newest purchase :) *going to read now*

15:12 LauJensen: Evening team

15:15 AWizzArd: Ah, hi the Lau.

15:17 LauJensen: Moin André

15:37 AWizzArd: Anyone here who has 16+ GB RAM at home?

15:38 esj: not all in one machine...

15:38 DeusExPikachu: is various parts of the internet down for anyone here in the east coast?

15:38 AWizzArd: I mean a single box :)

15:38 DeusExPikachu: for some reason I can still irc, but google is down

15:39 chouser: google's fine here. I'm not on the east coast.

15:39 cemerick: AWizzArd: used to, in a sunfire box. Long since sold it.

15:39 the-kenny: DeusExPikachu: Google has started to morph to skynet

15:39 DeusExPikachu: well, a lot is down, i'm guessing some DNS server

15:42 AWizzArd: cemerick: and today you have 8 GB?

15:42 cemerick: just 4 in my macbook pro

15:42 DeusExPikachu: i'm kinda boxed in internet wise, can someone give me an ip address of google?

15:42 cemerick: heavy lifting gets done in a distributed fashion nowadays

15:46 AWizzArd: cemerick: Google hosts its DB in memory.

15:46 cemerick: I can see that

15:46 krumholt: DeusExPikachu, for me google is at

15:46 cemerick: hard drives take a lot of power

15:47 DeusExPikachu: krumholt, thanks, looks like it is a DNS problem, I can connect

15:52 ordnungswidrig: DeusExPikachu: isn't irc udp based?

15:54 DeusExPikachu: ordnungswidrig, maybe, why?

15:54 chouser: no, irc is tcp

15:56 kotarak: ordnungswidrig: talk was udp based, IIRC

15:56 ordnungswidrig: kotarak, chouser: you're both right

15:58 kotarak: When I first saw the wave video, I though: wow, they've reinvented talk.

16:00 ordnungswidrig: kotarak: hehe talk was fun

16:01 kotarak: ordnungswidrig: it still is. :)

16:31 lancepantz: i see some clojure projects with tests in project/src/test and some in project/test what's the standard there?

16:31 it looks like lein wants them in project/test

16:34 the-kenny: lancepantz: I would recommend project/test

16:35 lancepantz: ty

16:40 jcromartie: how do you all actually run your tests?

16:40 I see clojure has a "main" test script

16:40 (clojure-the-project)

16:53 patrkris: kotarak: can I ask you a stupid question about the implementation of the new ClojureQL frontend? Just looking through the code now.

16:53 kotarak: patrkris: go ahead

16:54 patrkris: kotarak: I'm looking at the function 'where' in frontend.clj (line 193 in the latest commit I pulled.) Where does constraints come from, i.e. where is the identifier constraints bound?

16:55 kotarak: patrkris: easy answer: it's a bug. :]

16:55 patrkris: kotarak: ah... haha, great :)

16:55 thought it was some magic happening :)

16:55 kotarak: patrkris: messed up when changing the argument order.

16:55 patrkris: alright

16:56 kotarak: patrkris: I'm not in favor of such magic.

16:56 patrkris: kotarak: I didn't think so

16:56 rhickey: persistent vector using deftypes (work in progress) http://gist.github.com/300895

16:56 patrkris: kotarak: I'm trying to read about monads (which you may remember I mentioned the other day) and thought clojureql could be a case study

16:57 AWizzArd: oho, definterface

16:57 kotarak: patrkris: it's basically a state monad

16:58 AWizzArd: rhickey: this is indeed very interesting and helpful for me

17:03 patrkris: kotarak: the state is the query representation as it goes through various functions?

17:03 kotarak: patrkris: yes

17:03 patrkris: eg. for SQL we have to collect the values which are finally replaced with ? as we go along.

17:07 StartsWithK: what will happen if my pom.xml is not valid and i push it to clojars? i created it manualy

17:08 i can't break anything? don't want to some one gets mad :)

17:14 seths: I'm struggling with the difference between bound-fn and bound-fn*

17:14 bound-fn* does what I expect

17:14 (expected bound-fn) to do

17:15 it seems like the return value of bound-fn isn't immediately callable?

17:15 Chousuke: (doc bound-fn)

17:15 clojurebot: Gabh mo leithscéal?

17:15 Chousuke: hm :(

17:15 seths: I read the docs

17:16 ,(doc bound-fn)

17:16 clojurebot: Huh?

17:16 kotarak: seths: bound-fn returns a new function, bound-fn* modifies an existing one

17:17 seths: bound-fn is a convenience wrapper around bound-fn* + fn.

17:17 seths: ah

17:18 Chousuke: bound-fn* modifies nothing :P

17:18 kotarak: Chousuke: okok, it wraps an existing function

17:18 chouser: it "modifies" the way everything in clojure is "modified". you need quotes. :-)

17:31 rhickey: yum, pvector of ints

17:31 chouser: pvector?

17:31 rhickey: persistent

17:31 chouser: this isn't in Java I hope?

17:31 rhickey: good ol' vector

17:31 nope

17:31 chouser: yay!!

17:31 ints. cool.

17:32 rhickey: twidling http://gist.github.com/300895

17:32 twiddling

17:32 just seeing what needs to change from object version to primitive

17:32 chouser: oh, *that's* why you were asking about inline bit-shift.

17:32 rhickey: the gist is objects

17:33 and is same speed as java persistentvec

17:33 chouser: beautiful

17:35 so once you have pvec of objects and pvec of ints side by side, you'll write a macro to generate either from a type parameter? Or are they insufficiently similar?

17:36 rhickey: right, very similar

17:36 just a few hints different

17:36 chouser: fantastic

17:37 jcromartie: so MongoDB is fun, right?

17:37 rhickey: replacing ArrayChunk now

17:38 chouser: less design work here than in implementing the compiler in clojure.

17:39 rhickey: chouser: starting small, but the memory pressure of boxed numbers is killing us

17:39 I also want to experiment with the numeric changes I've talked about

17:39 chouser: killing who? where?

17:40 rhickey: a big hassle and ugliness are all of the casts ti int

17:40 chouser: killing anyone who wants perf, or has big data

17:40 chouser: ok

17:40 rhickey: everyone is being affected, but can deal

17:40 chouser: your number changes are about overflow, not literals being unboxed by default, right?

17:41 rhickey: both

17:41 chouser: oh, ok. hadn't heard about unboxed literals.

17:41 rhickey: a problem right now is the semantics of boxed/prim ar edifferent, even without unchecked-*

17:42 so literal 42 can't be treated as primitive

17:42 chouser: ah, yeah. and upgrading a primitive isn't an option, so the path to consistency is overflow always an error.

17:42 rhickey: because that would pull it into primitive semantics

17:42 exactly - overflow is error - you want bigints, you ask for them

17:43 then same semantics boxed/non

17:44 but the vector experiment is interesting, as there are many cases where, for interop with the Object world, the values in a vec of primitives will be boxed on the fly

17:44 chouser: I mourn for _fogus_'s beautiful section on numerics. ;-)

17:44 rhickey: that generates ephemeral garbage

17:45 chouser: sure. what is demanding you enter the Object world?

17:45 danlarkin: faster numerics is relevant to my interests

17:45 rhickey: but avoids the horror show that is a vector of a million numbers being a million 24-byte objects with different addresses

17:45 chouser: yeah

17:45 AWizzArd: oh, why 24-byte objects?

17:45 chouser: oh, the object world of fn args and returns?

17:45 rhickey: chouser: map/filter/seq etc

17:45 chouser: ah

17:45 rhickey: right

17:46 pdk: jvm overhead?

17:46 chouser: AWizzArd: that's what an Integer is.

17:47 AWizzArd: 20 bytes as package around the 4 bytes int

17:47 rhickey: but we are on the threshold of a whole new wave of awesomenes when IReduce becomes a protocol. Then primitive vectors and strings can reduce internally without any boxing, or at least boxing trivially eliminated by escape analysis

17:48 AWizzArd: oho

17:48 chouser: ooh

17:48 doesn't that still require primitive arg/return?

17:49 rhickey: chouser: hotspot could see the object being built, passed, unboxed for use, reboxed, unboxed after return and get rid of all boxes

17:50 chouser: wow. that's "escape analysis"?

17:50 rhickey: at least theoretically

17:50 yes

17:50 but boxed numbers stored in data structures inherently escape - will never be eliminated

17:51 chouser: ok

17:53 abrenk: Is it idiomatic to have (doall (for ...)) if I need to use aset-byte on a Java array?

17:53 chouser: so you're already seeing the reduced memory usage of pvec of ints, even if there's not much speed advantage yet?

17:53 abrenk: you might look at amap

17:54 (doc amap)

17:54 clojurebot: "([a idx ret expr]); Maps an expression across an array a, using an index named idx, and return value named ret, initialized to a clone of a, then setting each element of ret to the evaluation of expr, returning the new array ret."

17:54 rhickey: chouser: yes

17:58 abrenk: chouser: I'll think about if amap fits. Its a pretty complicated sequence comprehension (http://paste.lisp.org/+213K). At least for me. Still learning.

17:59 chouser: abrenk: that's just for speed. you can always start with an array, go through 'for', and dump it back into an array using 'into-array'

18:05 abrenk: sorry, I didn't look at your code. you might try 'doseq'

18:06 and I'm not sure there's any benefit anymore to using aset-byte over just aset

18:07 maxhodak: where is clojure.contrib.stacktrace?

18:07 i can't seem to find it in any obvious place

18:07 abrenk: chouser: Thanks for taking a look. It throws "argument type mismatch" if I drop "-byte". I'll look at 'doseq'

18:07 maxhodak: i keep getting class not found errors, and then i realized that its not even in the obvious place in github: http://github.com/richhickey/clojure-contrib/tree/1.1.x/src/clojure/contrib/

18:08 chouser: abrenk: yeah, you just need (byte (bit-and ...))

18:08 maxhodak: under *any* branch

18:08 chouser: maxhodak: it got moved into clojure. clojure.stacktrace

18:08 mengu: hi. after i build clojure with run

18:09 should i add its path to PATH or CLASSPATH etc?

18:09 abrenk: chouser: Okay, that works.

18:09 maxhodak: chouser: thanks. live doc (http://clojure.org/libraries) is out of date then

18:09 arohner: is there a way to tell whether you're in jar hell? I get the feeling my project is running two different versions of compojure.

18:10 hiredman: arohner: do you have two different version of compojure on your classpath?

18:10 jcromartie: Is http://github.com/somnium/congomongo broken with Clojure 1.1.0?

18:11 somnium: (use 'somnium.congomongo) => java.lang.IllegalAccessError: seqable? is not public (NO_SOURCE_FILE:0)

18:11 arohner: hiredman: I don't think so, but I don't know for sure

18:11 hiredman: arohner: well check

18:11 somnium: jcromartie: are you using lein to get it?

18:12 jcromartie: yeah

18:12 oh wait on

18:12 no

18:12 I built it with lein jar

18:12 abrenk: chouser: 'doseq' it is. That's what I was looking for. Much better than (doall (for ...)) and not using the return value...

18:15 hiredman: my guess is the problem is the rename in contrib

18:15 somnium: jcromartie: better to use lein deps and get it from clojars, the github repo takes a little rearrangement to build right now

18:15 hiredman: http://github.com/richhickey/clojure-contrib/commit/4e7a55d4e7e899d29f725222495d752730584bdd#diff-2

18:16 chouser: abrenk: is that really to put a cycle of bytes into the array?

18:16 or have you simplified it for me?

18:16 abrenk: chouser: To give a little context: I'm re-implementing jBCrypt in Clojure as an exercise.

18:17 chouser: ,(seq (into-array Byte/TYPE (map byte (take (* 4 8) (cycle [24 16 8 0])))))

18:17 clojurebot: (24 16 8 0 24 16 8 0 24 16 8 0 24 16 8 0 24 16 8 0 24 16 8 0 24 16 8 0 24 16 8 0)

18:18 chouser: gotta go.

18:18 abrenk: chouser: I've pasted the Java version http://paste.lisp.org/+213K/3

18:19 chouser: Okay, thanks for your help!

18:21 hiredman: ~clojure

18:21 clojurebot: clojure is the brand

18:22 jcromartie: somnium: ok thanks

18:22 I am doing that

18:23 somnium: now, in MongoDB I have db.people

18:23 but (mongo! :db "db") (fetch :people) doesn't return anything

18:23 there are docs in there

18:23 I see the connection being established

18:23 (fetch-count :people) returns 0

18:23 but from mongo, db.people.find() returns all of the people in my db

18:24 somnium: check (databases) and (collections)

18:24 db name is people and collection is people?

18:24 jcromartie: db name is db

18:24 collection is people

18:25 somnium: what does (collections) return?

18:25 jcromartie: an empty HashSet

18:25 somnium: and (databases)

18:25 jcromartie: (databases) lists my databases though

18:26 #<ArrayList [test, admin, db, local]>

18:26 hmm, using :db "test" works

18:27 ah, db is test in mongo

18:27 I don't quite get it

18:27 somnium: the default db in mongo-shell is test I think

18:28 jcromartie: yeah

18:28 I see that now

18:28 weird

18:28 I was thrown off because I saw a db named db, and I was using db.people.save(...)

18:29 thanks :)

18:29 somnium: np

18:30 jcromartie: I am excited about mongo, is there anything missing from congomongo I should be aware of?

18:30 maybe keep an eye out or improve?

18:31 somnium: jcromartie: purcell added gridfs support, you can use his fork if you need it

18:31 jcromartie: k

18:31 not yet :)

18:31 not for my 5 documents

18:32 somnium: numerous changes scheduled for a merge in some future semi-lost weekend :)

18:38 grammati: anyone know what happened to build.xml from clojure.contrib?

18:38 clojure mode's clojure-install command wants it

18:40 devlinsf: grammati: It's gone

18:40 contrib went to maven a few weeks ago

18:40 Raynes: grammati: Permanently.

18:42 grammati: so I guess I should edit clojure-mode.el then, right?

18:43 it's my first day with emacs, so that should be educational :)

18:43 hiredman: grammati: clojure-install shouldn't be pulling and building contrib anyway

18:44 (not that I know what it does, it just shouldn't do that)

18:45 grammati: what instructions are you following to setup emacs?

18:45 Raynes: grammati: You should be getting clojure-mode from ELPA, and not using clojure-install at all.

18:45 hiredman: http://technomancy.us/126 is the latest and greatest, I believe, and the clojure-install part is crossed out

18:46 Raynes: Leiningen, swank, clojure-mode, and swank-clojure-project (a swank-clojure command) is pretty canonical right now.

18:49 jcromartie: somnium: do regexes work from congomongo?

18:49 it doesn't look like they do

18:53 somnium: jcromartie: they seem to here. (fetch :stuff :where {:content #"^foo.*"})

18:54 jcromartie: the mongo-java driver occasionally patches the java->js conversion, so may be some dark corners

18:55 jcromartie: ah, nevermind, I was botching the case-insensitive flag

18:55 lovely!

19:04 grammati: ok, so I did M-x package-install swank-clojure... now what? M-x slime starts a CL-USER> prompt, no clojure. what do I do next?

19:10 seths: grammati: try M-x swank-clojure-project

19:10 (after killing *inferior-lisp*)

19:12 it will ask for a starting directory... I have only ever given it the root dir of a Leiningen project

19:13 Raynes: He'll need to have his deps in the lib directory of the project folder, including swank-clojure.jar and Clojure itself.

19:14 maxhodak: uh

19:14 why are there a bunch of references to fruit in the clojure.contrib.sql doc?

19:14 db-grade-range Usage: (db-grade-range min max) Print rows describing fruit that are within a grade range

19:14 and so on

19:14 Raynes: Because fruit is good for you.

19:14 maxhodak: (db-read) Read the entire fruit table

19:15 db-read sounds a little general for that

19:15 lol

19:15 hiredman: the docstrings most likely copied and pasted from some example that used fruit

19:16 grammati: so I cant' just use the slime repl without creating some dummy project?

19:16 hiredman: oh

19:16 intersting

19:17 db-read is from the test suite for sql

19:17 maxhodak: so, more srs question: how do you yield a query result out of with-query-results?

19:17 like, (sql/with-connection conn (sql/with-query-results rs [query] (prn rs))

19:17 er, without the prn

19:17 just throws a null pointer exception

19:17 (no parens around the rs at the end)

19:17 hiredman: because the result is lazy

19:17 maxhodak: oh?

19:18 hiredman: and the query is closed outside of the with-query-results scope

19:18 so you need to force it if you want to use it

19:18 ,(doc doall)

19:18 clojurebot: "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."

19:18 maxhodak: so

19:19 technomancy: grammati: you can, but you need to remove your old manual slime configuration first

19:19 maxhodak: (with-query-results rs [query] (doall rs)) ?

19:19 hiredman: yes

19:20 maxhodak: hiredman: got java.lang.ClassCastException: clojure.lang.LazySeq

19:21 for (sql/with-query-results rs [query] (doall rs))

19:21 hiredman: ,(doc with-query-results)

19:21 clojurebot: "clojure.contrib.sql/with-query-results;[[results sql-params & body]]; Executes a query, then evaluates body with results bound to a seq of the results. sql-params is a vector containing a string providing the (optionally parameterized) SQL query followed by values for any parameters."

19:21 maxhodak: oh, wait

19:21 hiredman:

19:21 maxhodak: i think the error is somewhere else, 1 sec

19:22 (where i'm returning the rs to)

19:22 yeah, ok

19:22 hiredman: thanks

19:28 grammati: technomancy: I don't think I have any manual slime configuration. Did I mention it's my first day with emacs? I just did "sudo apt-get install slime". Is that wrong?

19:30 technomancy: grammati: oh, I see. yeah, you want to use either apt-get's version of slime or ELPA's; having both installed will confuse things.

19:30 apt-get's version requires a fair amount of manual config; so I recommend using ELPA's only.

19:31 grammati: ok thanks, I'll try that

19:35 ok, now I've done "apt-get remove slime", rm'ed my .emacs and .emacs.d, reinstalled elpa, then used M-x package-install to get slime, clojure-mode, and swank-clojure

19:35 and still no clojure repl. what am I missing?

19:37 M-x slime gives me: "Searching for program: no such file or directory, lisp"

19:41 technomancy: must be some leftover CL-related slime configuration

19:46 JonSmith: i woah

19:46 so you have your classpath misconfigured

19:46 try m-x clojure-mode

19:46 not classpath

19:52 herdrick: question: is there a way already built to display an Image directly in a swank-clojure REPL?

19:52 i know that graphviz.emacs does this

19:53 sorry, that should be "graphviz-dot-mode"

19:55 technomancy: herdrick: I think it would require some elisp hacking; probably not doable in pure-clojure

19:55 herdrick: technomancy: yeah

19:55 ok, thanks

20:25 jcromartie: clojure's immutable data types have spoiled me

21:52 herdrick: so, if in the swank-clojure REPL I type: javax.imageio.ImageIO/

21:52 then press <tab>

21:52 i get all the static methods for that class

21:52 (maybe other static members, too)

21:53 but how do you get the signatures of those static methods?

21:53 unlike with clojure methods, you don't automatically see the signatures in the minibuffer

21:54 another question about that: is there a way to explore for methods (functions attached to instantiated objects) of Java classes?

21:56 dnolen: herdrick: you can use SLIME to inspect javax.imageio.ImageIO to see all the signatures, not nice as being shown in the minibuffer but works well enough

21:56 herdrick: dnolen: oh? how?

21:58 dnolen: C-c I

21:58 herdrick: ^

21:59 herdrick: oh! nice!

22:01 thanks dnolen, that's perfect

22:02 dnolen: herdrick: np

22:05 herdrick: hmmm... I don't see constructors listed there

22:05 is there a way to see constructors?

22:09 dnolen: herdrick: huh, dunno. If you really want access to all that info conveniently you might be interested in Bill Clementson's post about adding javadoc support to his Emacs. http://bc.tech.coop/blog/081120.html

22:10 herdrick: dnolen: ok, thanks

22:25 cemerick: Man, spending an hour with Java every week makes one really appreciate clojure.

22:26 slyphon: hah

22:29 herdrick: this seems like it should be obvious, but I haven't found it: where is map-tree?

22:29 i.e. (map-tree / [2 3 4 [5 [6]]]) would yield: (1/2 1/3 1/4 (1/5 (1/6)))

22:29 or must i roll my own with a reduce?

22:33 maxhodak: so, i'm trying to debug a client library i didn't write that won't run at all. basically it's using (declare) to intern a symbol

22:33 and then referencing it before binding it to anything

22:33 (declare *with-open-stack*)

22:34 (when (and obj (not (some #{obj} *with-open-stack*))) (set! *with-open-stack* (conj *with-open-stack* obj)))

22:34 it dies on the first *with-open-stack*

22:34 cemerick: herdrick: it exists.....

22:36 herdrick: cemerick: great! i've got my own now... ;)

22:36 what is it?

22:36 what is it called, i mean?

22:40 cemerick: herdrick: I can't find it now, sorry :-/

22:41 my brain's gone to mush tonight

22:47 herdrick: cemerick: quite all right

22:47 thanks anyway! :)

22:47 surely it does exist, eh?

22:48 cemerick: yes, definitely. The fn I'm thinking of maps deeply into most any seqable data structure.

23:11 Mec: is there a (somefunc (range 10)) -> ((0 2 4 6 8) (1 3 5 7 9))?

23:12 somnium: ,(separate even? (range 10))

23:12 clojurebot: [(0 2 4 6 8) (1 3 5 7 9)]

23:13 Mec: anything more general? may not be a seq of numbers

23:14 hiredman: uh

23:14 how could you be more generally than seperate?

23:14 you give it the predicate to use

23:16 Mec: im not sure what predicate would take every other one

23:17 hiredman: so you don't want something "more generally" you want something totally different

23:19 somnium: ,(reduce (fn [acc [x y]] (-> acc (update-in [0] conj x) (update-in [1] conj y))) [[] []] (partition 2 (range 10)))

23:19 clojurebot: [[0 2 4 6 8] [1 3 5 7 9]]

23:20 hiredman:

23:20 somnium: =)

23:20 Mec: well like (partial separate even?) is similar to what i want but that only works on a range of numbers, therefore i need more general?

23:21 somnium: ,(separate (fn [[x]] (even? x)) (indexed (range 10)))

23:21 clojurebot: [([0 0] [2 2] [4 4] [6 6] [8 8]) ([1 1] [3 3] [5 5] [7 7] [9 9])]

23:22 somnium: oh, theres a simple way

23:22 hiredman: Mec: you want to split based on position (every other) seperate splits based on the predicate

23:23 completely different

23:23 somnium: ,(vector (take-nth 2 (range 10)) (take-nth 2 (rest (range 10))))

23:23 clojurebot: [(0 2 4 6 8) (1 3 5 7 9)]

23:25 Mec: that'll work, thanks

23:26 DeusExPikachu: anyone here has arc-mode working with tramp in emacs?

23:42 ivan: has anyone ported Twisted's Deferreds or something similar to Clojure?

23:43 the general goal is composing asynchronous tasks

23:48 I guess I should probably use agents and add-watch before trying crazy stuff

23:49 dnolen: ivan: or promise/deliver.

23:49 ivan: thanks

23:50 DeusExPikachu: ok I give up with making tramp working with a slime!!!! sshfs worked first time with little hassle

Logging service provided by n01se.net