#clojure log - Apr 19 2009

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

1:21 ChrisF___: i'm kindof curious who's sneaking it into the corporate enviro?

1:22 i'll be perfectly honest....unless we have different sufrface syntax on it, its a no go...for everybody

1:22 hiredman: uh

1:23 well, thats just like, you're opinion, man...

1:23 ChrisF___: uhh....yeah, we can dick around with as computer geeks, but it will never go for anybody in the corporate enviro

1:23 hiredman: dude, nobody will ever do s-expression

1:24 dreish: http://www.mail-archive.com/clojure@googlegroups.com/msg12271.html

1:24 ChrisF___: it's hard enough to be dynamic...but to do s-expressions is a non-starter

1:24 dreish: ChrisF___: You're babbling.

1:24 ChrisF___: just aanother geek language

1:25 hiredman: http://www.flickr.com/photos/gnuvince/2944227285/

1:25 ChrisF___: ChrisF___: yes, i'll take that as i agree

1:25 Cark: haha nice one hiredman

1:25 olegs pointer made me laugh

1:25 hiredman: it's gnuvince's

1:25 ChrisF___: have fun dorks, you have no choice in the corporate environemant

1:25 hiredman: just repasting

1:26 ChrisF___: you're like jrugy

1:26 jruby

1:26 oops

1:26 hiredman: ChrisF___, you ever read any discworld books?

1:26 ChrisF___: hiredman: don't worry, you'll never be a PHB

1:27 hiredman: ChrisF___, in the mythos of the discworld trolls, it is believed that living creates are actually living backwards through time

1:27 ChrisF___: so go have fun dicking around with shit that nobody will never use

1:27 dreish: ChrisF___: Good grief, can you even read?

1:27 ChrisF___: rich probably understands that...he just wants to be able hack himself

1:28 he didn't think dweebs would follow

1:28 hiredman: ChrisF___, it is an interesting idea, and one that would not typically show up in a cultural myth

1:28 ChrisF___, because it is sort of a distinction without a difference

1:28 ChrisF___: yes, we will get scala

1:28 before some idiocy that insisits on s-expressions

1:29 hiredman: ChrisF___, but I think it is used to sort of engender a feeling of hidden depths in the troll culture

1:29 dreish: There's also http://www.mail-archive.com/clojure@googlegroups.com/msg11977.html

1:29 ChrisF___: ahh, yes....i can't believe you brought up the troll word before this time

1:29 dreish: Two substantial production deployments before the language is even at 1.0, before there is even a single book out.

1:29 ChrisF___: it took you this long? yes, you're just weak and had to weave it in

1:30 yes we have many substantial dork deployments of jruby and jpython

1:30 hiredman: ChrisF___, so you've read the books?

1:30 ChrisF___: hiredman: why are you losing?

1:31 no wonder i never hire java dorks

1:31 thank god for a real modern language like C# 3.0

1:32 have fun idiots...once you put a python-like surface syntax on your toy, then we can talk

1:35 cp2: hrmf.

1:35 reminds me of this quote:

1:35 shut the hell up i aint a no lifer nerd like u...

1:37 hiredman: it would be depressing if that became a regular occurrence here

1:45 replaca: Oh looks like I missed some fun

1:46 Poor ChrisF___ has to work in a fabric covered box all day

1:46 and assumes that everyone shares that aspiration :-)

1:55 cp2: hm, JNA is so much more appealing than JNI

1:56 although they have different purposes i suppose

1:56 however, using JNI for what JNA does is what i mean

9:07 emacsen: pjb3, hey

9:07 ping again

9:07 pjb3: emacsen: hey

9:07 emacsen: so I saw your mail. You want JSON as the internernal data structure?

9:07 internal that is

9:08 pjb3: emacsen: No, internally would be clojure data structures

9:08 Just use JSON to define the "tubes"

9:08 emacsen: okay, we need to all work on a common set of vocabulary

9:08 maybe we should do that at the mtg

9:09 can you use it in a sentence? ;)

9:10 pjb3: What Luke has in the file test.tube (haha), I would make test.json

9:12 emacsen: oh gotcha

9:28 dliebke, hi

9:28 are you a member of the study group?

9:34 dliebke: emacsen, do you mean the d.c. study group?

9:34 emacsen: yeah

9:34 dliebke: no, I just learned about it a couple days ago

9:35 emacsen: about clj or the study group?

9:35 dliebke: the study group

9:35 emacsen: ah

9:35 well do you know clj well?

9:36 dliebke: I've been programming with it a lot the last few months

9:36 emacsen: ah cool

9:36 well, if you'd like to work on a side project, we're starting one :)

9:37 dliebke: sounds cool, but I've got a side project that has been consuming all my time already :)

9:37 emacsen: fair nuff

9:38 dliebke, so to be a total shill, do you know it's at HacDC? :)

9:40 dliebke: emacsen, HacDC?

9:40 emacsen: http://www.washingtonpost.com/wp-dyn/content/article/2009/04/18/AR2009041800112.html

9:40 DC's hackerspace

9:42 dliebke: very cool, thanks for the article link

9:42 emacsen: no problem

9:50 wow another DC person

9:50 I think we need to convince rhickey to move down here

9:51 marklar, do you know about the DC Clojure study group?

10:09 marklar: emacsen: yes, it popped up in a google search a few weeks back

10:09 I couldn't make the one on the 4th though

10:11 emacsen: you know we're doing one today

10:12 marklar: no I didn't... what is the website again?

10:13 nevermind, I found the google group. I won't be able to make it today either, I would like to come to one though

10:14 emacsen: k

13:59 unlink: I put /usr/share/java/commons-codec.jar on my classpath via "java -cp /usr/share/java/commons-codec.jar -jar clojure.jar", yet I am unable to (:import org.apache.commons.codec.binary.Base64). What might be the problem?

14:05 dreish: Can't use -cp and -jar together.

14:13 unlink: dreish: Oh, heh. You're right. Thanks.

14:16 Is there a smarter way of starting clojure than manually spelling out all the classpath elements (which are jars located in a couple choice directories)?

14:18 java -cp /usr/share/java/foo.jar:/usr/share/java/bar.jar:/home/unlink/Lib/clojure.jar:/home/unlink/clojure-contrib.jar clojure.lang.Script asdf.clj

14:23 arohner_: unlink: what a few people do is write a bash script that adds dir/*.jar to the cp

14:23 function load_jars()

14:23 {

14:23 for file in "$@"; do

14:23 jars=$jars:$file

14:23 done

14:23 }

14:23 load_jars jars/*.jar

14:23 java -cp $jars

14:25 unlink: Hmm, I'm trying to see if I can start the Repl from ant. Doesn't seem especially possible.

14:25 arohner_: why not?

14:26 unlink: Because it wants to handle all I/O itself

14:27 First off every line of output gets prepended with " [java] "

14:28 arohner_: eww

14:38 Lau_of_DK: Hey guys

14:38 unlink: Hi Lau_of_DK.

14:39 technomancy: hello

14:42 unlink: It looks like GAE is swallowing my classpath somehow.

14:42 Lau_of_DK: GAE?

14:43 unlink: Google App Engine.

14:44 oh, it wants me to copy all of my jars to WEB-INF/lib.

14:45 Lau_of_DK: ah

14:45 unlink: IT WORKS!

14:45 excellent.

14:46 google app engine summarily ignores any classpath you give java when loading classes.

15:40 Is there anything like & for map bindings? Like "bind this parameter from the map to a and bind the rest of the map to other

15:48 How do I expand a vector return value to multiple arguments to a function? sort of like fn(*(lambda: 1,2,3,4...)()) in python. The key being that I don't know how many elements there are in the returned vector

15:51 arohner_: unlink: the special forms page lists the available destructuring options with for maps

15:51 http://clojure.org/special_forms

15:51 can you give an example of what you want to do with return values to multiple arguments?

15:51 that sort of sounds like another destructuring thing, but I'm not quite sure what you want to do

15:53 unlink: I'm writing a function which produces an HTML document and accepts two parameters, a function which returns a vector of elements that go in the body and a map of context variables that are used in rendering the body. You can think of the method as a sort of "base template".

15:54 arohner_: oh, are you looking for apply?

15:54 (apply + [1,2,3]) => 6

15:56 unlink: What I described I want is that.

15:56 I *actually* want somethiing even simpler.

15:58 namely cons

15:58 O:-)

15:59 arohner_: :-)

15:59 gnuvince_: What is it you want?

16:11 technomancy: why is there a separate function for getting a seq from an enumeration?

16:45 cp2: technomancy: because seq doesnt 'know how to' make a sequence from an enumeration

17:11 dliebke: technomancy: yeah, what cp2 said -- specifically since a java enumeration doesn't implement the Seqable interface and has no seq method

17:12 Chousuke: It'd be neat if Java had some way to have interface adaptors kind of like C++ concept maps :/

17:12 C++0x, that is :P

17:12 or is it C++1x nowadays

17:13 cp2: hrmm Chousuke ?

17:13 could you link me

17:14 rhickey_: technomancy: because seq is called often (automatically) in various functions, but creating 2 seqs on the same enumeration would be trouble, thus you have to do it explicitly

17:14 Chousuke: cp2: I'll just summarise. There's a new templating mechanism to require template parameters to implement a certain interface (== 'concept'), and concept maps allow you to write code and "show" how to implement a concept with some type that doesn't have 1:1 the same interface

17:16 cp2: ah

17:16 i see

17:16 Chousuke: cp2: so for example, if your concept requires the ability to use a ">" operator, but your type has only a greater_than() method available, a concept map can be used to "implement" the > interface with greater_than()

17:16 cp2: oh right

17:16 neat

17:16 rhickey_: makes sense, i didnt consider that

17:50 unlink: Is there a shorter form for (if a a b)?

17:50 cp2: if-let

17:50 hiredman: or

17:51 cp2: o

17:51 hiredman: (or a b)

17:51 cp2: yeah

17:51 unlink: I've been doing (let [[some-expr] [a]] (if a a b))

17:51 Oh, or sounds good. :-)

18:31 I've got a (:gen-class) without a :name arg. How does it know what to call the class?

18:34 hiredman: it names it after the namespace

18:39 technomancy: rhickey_: ah thanks; interesting.

18:39 there's no way the "don't know how to make a seq from $FOO" exception could be changed to mention enumerable-seq, is there?

18:40 cp2: oh yeah

18:40 that reminds me

18:40 rhickey_: typo in the doc for enumeration-seq

18:40 rhickey_: technomancy: there are many things you can't make a seq from

18:40 ,(find-doc "enumeration")

18:41 where's clojurebot?

18:41 cp2: down

18:41 "Returns a seq on a java.lang.Enumeration"

18:42 should be java.util.Enumeration

18:42 nothing major

18:42 technomancy: right; so the exception message isn't predicated on the type that's trying to be turned into an enumeration. that's what I was wondering.

18:42 *turned into a seq

18:44 rhickey_: cp2: fixed - thanks

18:58 stuhood: hmm, it seems a bit of a wart that (sorted-set) takes values, and (set) takes a collection

19:00 ah... i guess that is because there is a literal for sets

19:01 rhickey_: no, the comparable of is hash-set

19:01 Chouser: hash-set is the corollary.

19:01 * Chouser curses his need to double-check the spelling of "corollary"

19:01 stuhood: gotcha... thanks

19:02 cp2: np rhickey_

19:54 * technomancy loves putting temporary functions in let bindings.

19:55 lisppaste8: technomancy pasted "extract-jar" at http://paste.lisp.org/display/78858

19:56 technomancy: is there a more concise way to write the loop at the end of that function?

19:56 I feel like there should be a better way to express that.

20:23 hiredman: (.close (reduce #(.write % %2) something-else (take-while #(not= -1 %) (repeatedly (.read sometihgn)))))

20:23 hmmm

20:24 the .close is a bad idea, best to use with-open

20:24 erm

20:25 the reduce function should be #(doto % (.write %2))

21:25 unlink: What is the (:xyz ...) syntax? (with a keyword at the beginning of the parens)

21:26 hiredman: keywords look themselves up in maps

21:27 there is also an optional second argument

21:27 which is a default value to return

21:28 unlink: So how is (:xyz foo bar) evaluated?

21:29 hiredman: user=> (:a {:a 1 :b 2})

21:29 1

21:29 user=> (:a {:b 2} 1)

21:29 cp2: keys are functions of maps

21:29 hiredman: 1

21:30 unlink: So (:xyz foo bar) is the same as (get foo :xyz bar)?

21:30 hiredman: yes

21:30 unlink: when foo is a map.

21:31 Or are they really equivalent?

21:31 hiredman: yes

21:31 unlink: oh ok

21:32 so (:import java.io.File) is the same as (get java.io.File :import) ?

21:32 hiredman: it would be, except most likely you are seeing that inside the ns macro

21:33 unlink: oh

21:33 I am.

21:33 hiredman: in that case (:import java.io.File) is (import 'java.io.File)

21:35 unlink: I'm not really sure why there is a distinction in the language between symbols and keywords

21:36 hiredman: just a second

21:40 ugh

21:41 not having my logs to grep through is such a pain

21:42 unlink, start here http://clojure-log.n01se.net/date/2009-04-15.html#15:36

21:44 unlink: Intersting.

21:45 hiredman: stops maybe around 15:59

21:47 unlink: Is something wrong with me if I find Clojure is more intuitive than Scheme?

21:47 s/is //

21:48 Raynes: unlink: No.

21:48 Clojure rocks Scheme's world.

21:48 unlink: I've always found Scheme very clumsy for things I want to do on a fairly regular basis.

21:48 dreish: Clojure's design better conforms to the expectations of a programmer steeped in the languages that are popular right now.

21:49 I guess it might also be objectively better.

21:49 unlink: I never made it past the "which CL implementation should I use?" hurdle so I'm not equipped to opine about CL versus Clojure.

21:52 Raynes: My CL experience ended when I installed SBCL.

21:52 unlink: Is there a shorthand for something of this form? (let [[a] [1]] (let [[b] [(+ a 1)]] b)) -- here 1 means some java constructor invocation and (+ a 1) means a method on that object

21:54 Cark: (doto (new MyObject) (.method param))

21:54 ?

21:55 unlink: heh. That's almost too good.

21:56 Cark: this form will return your first object ... if you expect to get the result of calling the method ... you'd use ->

21:57 (-> (new MyObject) (.method param))

21:58 hiredman: unlink, I think you scheme is showing in your let

21:59 Cark: yep there are many brackets there =)

21:59 hiredman: you must want (let [a 1] ...) not (let [[a] [1]] ...)

21:59 unlink: whoa.

22:00 hiredman: but the second form does work, it has needless destructuring

22:01 technomancy: hiredman: thanks; take-while looks like it could clean things up nicely

22:02 hiredman: I don't understand why you use doto there though

22:03 isn't doto just for when you're calling different methods many times on the same object?

22:03 hiredman: because reduce needs to return the object you are writing to so you can write to it again

22:03 I mean, you could use #(do (.write % %2) %)

22:04 technomancy: oh, of course.

17:40 hiredman: I haven't used compojure in some time, you might want to ask compojure specific questions on the compojure google group

17:40 unlink: probably

21:48 msingh``: is there any doc for using clojure within an existing java project. I would like to call clojure code from java..

21:49 cp2: http://markmail.org/message/tx23zaxf77b6widh

21:49 quick google brought that up

21:50 although, i would keep looking around

21:50 msingh``: thanks!

21:52 the java interop docs work in the oppposite direction

21:52 cp2: yeah, i know

21:52 there was an example somewhere else i remember looking at

21:52 dont know where it is though, or what it was

21:56 Cark: http://berlinbrowndev.blogspot.com/2009/03/java-clojure-interoperability-calling.html

21:56 cp2: there you go msingh``

21:57 msingh``: sweet cheers :)

22:03 i dont think i'll use this approach.. the amount of boilerplate needed exceeds the small amount of clojure code i was going to use

22:04 i wanted to adapt the sparkline generator from http://jonathanwatmough.com/2008/02/simple-sparkline-generator-in-clojure/ to render some data from a running java app

23:25 Lau_of_DK: Has anybody here had success emitting specific HTTP headers using Compojure/Ring ?

23:25 AWizzArd: I would also be interested to know more about this.

23:25 Btw, Lau, what headers would you like to send?

23:26 Lau_of_DK: content-type "text/html" and Connection: close

23:26 Rigth now, no headers are being emitted, despite my best efforts, which is causes a cascade of problems

23:26 (compojure.server.jetty/run-server {:content-type "text/html" :Connection "close"} "/*" myservlet) does not give me anything

23:28 (GET "/text" [{"Content-Type" "text/plain"} "This is plain text." "And some more text."])

23:28 Wiki says so

23:30 AWizzArd: Hmm, I would hope for being able to return the headers (if I want to) with each request, and not specifying them as an arg to run-server.

23:30 Ah okay, in your GET you are also trying this.

Logging service provided by n01se.net