#clojure log - Aug 12 2010

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

2:18 vIkSiT: hi all

2:18 using 1.2.0-beta1 - how do you recommend resolving this error: error: java.lang.IllegalStateException: spit already refers to: #'clojure.contrib.duck-streams/spit in namespace

2:18 (I currently have a :use [clojure.contrib.duck-streams :only [slurp spit]])

2:19 but I cant figure out what the overriding package is

2:21 ecyrb: in 1.2.0-RC1 at least (and probably 1.2.0-beta1), spit and slurp are in clojure.core

2:21 (so you don't need to "use" them)

2:21 zmila: (:refer-clojure :exclude [spit]) inside (ns

2:24 vIkSiT: aah

2:24 zmila, ecyrb - thanks so much :)

2:25 i had totally forgotten about :refer-clojure

2:26 ecyrb: sorry - didn't realize duck-streams spit and slurp were different

2:34 zmila: :) i never know it, just see in some example

2:36 LauJensen: Good morning all

2:37 raek: ,(doc seq1)

2:37 clojurebot: No entiendo

3:58 cobol_expert: is there an opposite to 'read-string'? It's probably obvious, but eluding me at the moment, something to convert a clojure data structure to its string representation

3:59 arbscht: ,(str [:foo])

3:59 clojurebot: "[:foo]"

4:00 cobol_expert: ha, that was easy.. I thought that was just used for concatenating strings :)

4:00 thx

4:01 zmila: use print-dup

4:01 answer of MM: http://stackoverflow.com/questions/3301439/clojure-data-structure-serialization

4:08 cobol_expert: okay, researching this now...

4:08 one thing I'd like to do is deref any refs in the structure

4:08 ,(str {:hi (ref "hi")})

4:08 clojurebot: "{:hi #<Ref@aa7acb: \"hi\">}"

4:09 cobol_expert: i probably need to walk the tree and do that myself first...

4:11 hoeck: cobol_expert: maybe the functions in clojure.walk will help you with this

4:16 cobol_expert: yeah, i've been playing with that package.. though now I'm questioning why I'm using refs if I'm going to persist to disk anyway

4:19 hoeck: cobol_expert: sorry, couldn't resist: (clojure.walk/postwalk (fn this [x] (if (instance? clojure.lang.IDeref x) (clojure.walk/postwalk this (deref x)) x)) {:a (ref {:a :b})})

4:25 raek: cobol_expert: pr-str is good when you want a string that can be read from

4:26 ,[(str [123 "foo" :bar (lazy-seq [1 2 3])]) (pr-str [123 "foo" :bar (lazy-seq [1 2 3])]))

4:26 clojurebot: Unmatched delimiter: )

4:27 raek: ,[(str [123 "foo" :bar (lazy-seq [1 2 3])]) (pr-str [123 "foo" :bar (lazy-seq [1 2 3])])]

4:27 clojurebot: ["[123 \"foo\" :bar (1 2 3)]" "[123 \"foo\" :bar (1 2 3)]"]

4:27 raek: ,(str (lazy-seq [1 2 3]))

4:27 clojurebot: "clojure.lang.LazySeq@7861"

4:27 raek: ,(pr-str (lazy-seq [1 2 3]))

4:27 clojurebot: "(1 2 3)"

4:28 raek: there's a bunch of variations of that fn, look for everything that starts with "pr" in the api

5:25 LauJensen: Anybody familiar with a deployment tool which allows for multiple projects to run on a single JVM instance?

5:43 bsteuber: how can I generate static fields/constants with gen-class? like MyColors/BLACK

6:21 cschreiner: hello, why can't I do this? (doseq [e '(for list)] (doc (symbol e)))

6:23 what would be the correct way to process the above?

6:27 hoeck: cschreiner: because doc is a macro, not a function

6:28 cschreiner: hoeck: I know. But how can I make doc eat my e?

6:28 clojurebot: deft is http://gist.github.com/128259

6:28 hoeck: cschreiner: use print-doc instead

6:29 ,(doseq [e '(for list)] (print-doc (resolve e)))

6:29 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args (3) passed to: core$for

6:30 cschreiner: hoeck: but, for the sake of this example, is it possible to use doc?

6:31 LauJensen: cschreiner: Not that I know of

6:31 hoeck: no, because the doc macro expands at compiletime to: (doseq [e ...] (print-doc (var (symbol e)))

6:31 cschreiner: ok, important for me to know this.

6:32 LauJensen: ,(let [e 'for] (prn (macroexpand-1 '(doc e))))

6:32 clojurebot: (clojure.core/let [m__1855__auto__ (clojure.core/meta (clojure.core/resolve (quote e))) al__1856__auto__ (:arglists m__1855__auto__) docstring__1857__auto__ (:doc m__1855__auto__)] (if m__1855__auto__ (.replaceAll (clojure.core/str al__1856__auto__ "; " docstring__1857__auto__) "\\s+" " ") (clojure.core/-> hiredman.clojurebot.code-lookup/contrib :vars ((clojure.core/partial clojure.core/filter (clojure.core/fn [a__1858__au

6:32 LauJensen: So, it doesnt get any more clear than that...

6:34 hoeck: cschreiner: the only thing you can do is to write a macro which expands to multiple doc calls

6:34 like (defmacro docs [& syms] `(do ~@(for [e syms] `(doc ~e))))

6:35 cschreiner: hoeck: Right, tried that. Thanks

6:35 old_sound_: hi

6:36 LauJensen: Hi old_sound_

6:36 hoeck: old_sound_: hi

6:37 old_sound_: simple question, any of you guys know of an implementation of a memcache like server in clojure. We are looking at exposing some services using a text like protocol similar to redis or memcached

6:38 so It will be nice if there's a tcp project already, where I can plug al the protocol dispatching to my functions. or some tips where I can read more about that

7:40 edbond: old_sound_: take a look at redis-clojure: http://github.com/ragnard/redis-clojure

7:41 old_sound_: and http://github.com/shughes/clojure-memcached

8:00 old_sound_: edbond: redis clojure is just a library to access redis no?

8:01 edbond: I want to implement the server, not the client

9:39 limux1972: hi, raek, http://tiny.cc/3cmrx is good

10:07 raek: limux1972: does the problem go away if you add that?

10:07 limux1972: yes

10:10 i made two test, one with wrap!, another no use

10:11 raek: nice to have that pinpointed...

10:11 limux1972: and look their source individually

10:12 their meta line is exactly same

10:14 raek: and those give different results in the browser?

10:14 limux1972: even include the case sensitive of each word

10:14 yes

10:16 one with ???, another with 你好

10:17 how to paste them?

10:18 raek: put it in http://gist.github.com/ and post the URL you get here

10:21 limux1972: http://gist.github.com/521037

10:26 cemerick: Does RC3 fix #422 or no?

10:26 limux1972: if i use wrap! with iso8859-1, the ??? is come

10:26 raek: limux1972: which browser are you using? could you test a thing in Firefox?

10:27 limux1972: you should not use iso8859-1, since the string is by default encoded in UTF-8 by Ring

10:27 also, ISO 8859-1 cannot store chinese characters at all

10:28 limux1972: the browser of chrome and firefox have same result

10:29 i thank it's compojure who caused it

10:30 raek: in firefox, click on Tools -> Page Info

10:30 in the table, there should be a row with "content-type" on the left and "text/html <something>" on the right

10:31 could you try what <somethings> is when 1) wrap! is not used 2) wrap! is used with UTF-8

10:32 limux1972: it's very clearly the encoding is iso-8859-1 with no use wrap!

10:33 raek: ok

10:33 anyway

10:33 limux1972: compojure use iso8859 as it's default encoding

10:33 raek: you should always have a :content-type key in your response

10:33 it shouldn't

10:33 limux1972: even the lastest 0.4.1

10:33 raek: well, hrm

10:35 when you do a response, do something like {:headers {"Content-Type" "text/html; charset=UTF-8"}, :body <html goes here>, :code 200}

10:35 the content type should always be specified in a way or another

10:35 you can use middleware for that

10:35 limux1972: but what i see is one is iso8859 and utf8 another with utf8 and utf8

10:36 apgwoz: i don't see any place where compojure is changing the encoding or setting a charset in the Content-Type header...

10:36 raek: the "text/html; charset=iso8859-1" content type is added because you didn't choose a content type yourself

10:36 BrianForester: ,(try (prn 1) (finally (prn 2) (throw (Exception.))))

10:36 clojurebot: BrianForester: I don't understand.

10:37 raek: probably this is done by the servlet container or something

10:37 apgwoz: raek: yeah, it would seem that way. or jetty defaults it to that or something

10:37 which.. would be the servelet container as you said

10:37 raek: the problem is that if the encoding is specified in the content-type, then that overrides the meta tags and everything

10:38 so, solution: always provide the content type yourself

10:38 text/html should be sufficient

10:38 BrianForester: cemerick: I just tested this on RC3, doesn't look like 422 was fixed this release.

10:38 limux1972: and only difference between that two tests is one with wrap and another no use it, all of them take the meta of charset "utf8"

10:38 cemerick: BrianForester: the commit referenced that ticket, so I was unclear.

10:39 raek: limux1972: the browser doesn't care about the meta if it sees a "charset=..." in the content-type

10:39 BrianForester: cemerick: same here.

10:39 apgwoz: raek: but compojure already supplies the content-type if you don't set it in the response.

10:39 raek: does it?

10:39 hrm

10:39 apgwoz: according to the source

10:39 raek: to what?

10:39 apgwoz: compojure

10:40 http://github.com/weavejester/compojure/blob/0.4.1/src/compojure/response.clj

10:40 raek: *sigh*

10:40 then jetty adds a coding attribute

10:40 apgwoz: unless i'm misunderstanding how this is working, but i don't *think* that's the case

10:40 raek: that's bad...

10:40 limux1972: apgwoz, i use emacs convert the source to utf8,

10:41 but it no use

10:41 raek: limux1972: could you give me the link to the tutorial?

10:41 apgwoz: limux1972: what we're saying is that if you don't explicitly set the content-type with a charset, we *think* jetty will set the charset to ISO-whatever

10:42 which is why you'd be seeing an issue

10:43 raek: limux1972: you can work around this by using the wrap! thing, or add :headers {"Content-Type" "text/html; charset=UTF-8"} to the response map

10:43 BrianForester: cemerick: I'm pretty sure that someone has already supplied a patch, so you could apply it by hand if needed.

10:43 raek: jetty: grrrr

10:44 apgwoz: so, you're handler for compojure should be returning {:status 200 :headers {"Content-Type" "text/html; charset=utf-8"} :body <insert your html here>}

10:44 which is quite inconvenient mind you.

10:45 raek: oh, :status was the correct keyword... disregard my previous example

10:45 limux1972: as you say, raek, just a moment, i remove all the metas and reserve the wrap, how about it?

10:45 raek: limux1972: the meta should be there

10:46 always

10:46 limux1972: i know

10:46 i just want to try

10:46 raek: ok, go ahead :)

10:46 limux1972: yeah

10:47 raek: then the browser will probably guess the enconding (if neither meta nor the charset content-type attribute is there)

10:47 limux1972: there is no those annoying ???

10:47 raek: enconding in html is a mess...

10:47 limux1972: probably since the browser guessed the right encoding

10:48 limux1972: yeah, firefox tell us the right encoding utf, but nothing about page info

10:50 anthow word, compojure didn't use the meta's charset, it's for browser

10:52 raek: both are for the browser

10:52 compojurer does not care about any of them

10:53 limux1972: browser use which encoding meta tell it to render the html, even since the really encoding is not

10:55 if compojure does care it as you say, i have to not only provide meta

10:56 edbond: funny, but enlive doesnt works with utf-8 too

10:56 limux1972: and must provide encoding info somewhere

10:57 which compojure can use, where

10:57 where?

10:57 clojurebot: where is your source code

10:59 limux1972: wrap! is a nice solution, what is the best?

11:00 raek: having a Contet-Type in the header, which can be done either manually or with middleware

11:01 hrm, yes tagsoup (which enlive uses) does not do encoding detection...

11:02 cemerick: ~max

11:02 clojurebot: maxine is http://research.sun.com/projects/maxine/

11:02 cemerick: heh, ok

11:02 raek: someone should take mozilla's encoding detection code and integrate it into tagsoup

11:02 cemerick: hiredman: clojurebot's brain is still out of commission?

11:03 limux1972: http://gist.github.com/521100

11:04 raek: "If you need an autodetector of character sets, consider trying to adapt the Mozilla one; if you succeed, let me know."

11:04 I take that as a challenge, Cowan!

11:05 limux1972: my core.clj

11:09 http://gist.github.com/521114, the mostly original core.clj

11:10 all work well with wrap

11:11 raek: that looks perfectly fine

11:11 I recommend using wrap

11:11 limux1972: badly without wrap

11:12 yes, wrap is a nice way

11:12 i wonder the nicer

11:14 middleware is a good idea, but this issue should not use middleware, personal view

11:16 edbond: no need for charset detector, utf-8 as a default is good start

11:26 limux1972: i add a prn in wrap! to see the response at begin and end, but the console has noting to display

11:29 BrianForester: cemerick: I was wrong, RC3 does fix #422. I had an old copy of the clojure jar in my classpath.

11:34 edbond: how to make lein swank to run with utf-8 encoding?

11:36 limux1972: raek, I have seen the response, a map, the ring and rack's style, it's :headers is {"Content-Type" "text/html"}

11:36 no charset

12:02 pdk: (doc ->)

12:02 clojurebot: "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."

12:02 pdk: (doc get-in)

12:02 clojurebot: "([m ks] [m ks not-found]); Returns the value in a nested associative structure, where ks is a sequence of ke(ys. Returns nil if the key is not present, or the not-found value if supplied."

12:03 pdk: ,(get-in {1 {2 3} 4 {5 6}} '(1 2))

12:03 clojurebot: 3

12:03 pdk: ,(get-in {1 {2 3} 4 {5 6}} '(1 3))

12:03 clojurebot: nil

12:03 pdk: (doc interpose)

12:03 clojurebot: "([sep coll]); Returns a lazy seq of the elements of coll separated by sep"

12:03 maxpn: ,(a b)

12:03 clojurebot: java.lang.Exception: Unable to resolve symbol: a in this context

12:04 maxpn: ,('a 'b)

12:04 clojurebot: nil

12:04 maxpn: , (1 2 3)

12:04 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

12:04 pdk: if you need the literal list use '(a b)

12:04 ,'(a b)

12:04 clojurebot: (a b)

12:04 * patrickdlogan will be biab

12:04 pdk: or quote, list etc

12:04 maxpn: , (quote 1 2 3)

12:04 clojurebot: 1

12:05 maxpn: , '(1 2)

12:05 clojurebot: (1 2)

12:06 pdk: (doc quote)

12:06 clojurebot: excusez-moi

12:06 pdk: 'x is shorthand for (quote x)

12:06 ,(quote (1 2 3))

12:06 clojurebot: (1 2 3)

12:06 pdk: theres what you wanted

12:08 limux1972: raek, bye

12:09 pdk: ,(list 1 2 3)

12:09 clojurebot: (1 2 3)

12:10 pdk: cf. '(1 2 3)

12:37 edbond: any links for java/clojure utf-8 reading?

12:37 clj-env-dir doesn't shows utf-8 chars, cake repl shows.

12:52 raek: edbond: clojure io with UTF-8 is pretty simple

12:53 but note that JLine (used by lein repl) does not have support for UTF-8

12:53 swank does, but you have to configure it to use it

12:53 lein swank localhost 4005 ':encoding' '"UTF-8"'

12:54 then you have to add a setting in your .emacs

12:55 (custom-set-variables '(slime-net-coding-system (quote utf-8-unix)))

12:55 then you have UTF-8 in slime+swank!

12:55 as for io (files, sockets, etc):

12:55 check out http://richhickey.github.com/clojure/clojure.java.io-api.html

12:57 UTF-8 is the default encoding for IO in clojure

12:57 for example, open a BufferedReader with:

12:57 (require '[clojure.java.io :as io])

12:58 (io/reader "filename")

12:58 that will read UTF-8 characters from the file

12:58 (io/input-stream "filename") ; will read bytes

12:59 (io/reader "filename" :encoding "ISO-5591-1") ; other encodings can be specified too (default so UTF-8)

12:59 s/5591/8859/

13:01 also, if you want to display and write UTF-8 encoded characters through the terminal, the terminal must of course be correctly set up

13:08 you can then use the usual java.io.Reader methods, such as .readLine

13:09 bmh: I'm coming to Clojure from Haskell and was wondering what the clojure equivalent of the following would look like: data Tree a = Branch (Tree a) (Tree a) | Leaf a

13:09 sure I could just make each case a structmap, but it seems like a clunky approach.

13:10 raek: does that make a new type? I have never programmed haskell...

13:11 bmh: raek: Yes. The snippet creates a type 'Tree' that is parameterized by alpha.

13:11 raek: interesting...

13:12 well, clojure is not much about types

13:12 I guess you would just put data in 2-vectors

13:12 bmh: raek: I want to avoid unstructured programming.

13:13 raek: you could perhaps use defrecord if you need them to have their own type

13:13 dnolen: bmh: also there's an ADT library in contrib

13:14 bmh: dnolen: I'll check it out.

13:14 raek: bmh: clojure does not provide the formalness that haskell does

13:14 at least not in the way of a type system

13:15 bmh: raek: Sure, it's closer to Scheme than Haskell or ML

13:16 dnolen: bmh: http://www.mail-archive.com/clojure@googlegroups.com/msg09441.html

13:16 raek: I'm afraid I can't give you a better answer to your "what is the clojure equivalent" question than that there is not exact way of doing it the way haskell does it

13:16 bmh: dnolen: Heh, I just found that page on GOOG

13:17 raek: hrm, repace "no exact way" with "no idemoatic way"

13:17 bmh: Is equality testing still by identity rather than value?

13:17 raek: identity for ref/atom/agent/var, value for data structures and scalars

13:18 bmh: raek: I meant with regards to the ADT lib. The author mentions a caveat that equality is by identity

13:18 raek: ,(= (hash-set 1 2 3) (sorted-set 1 2 3))

13:18 clojurebot: true

13:18 raek: oh

13:18 dnolen: bmh: you should read the whole thread

13:18 raek: sorry

13:18 bmh: dnolen: will do

13:21 metagov: Does clojure.contrib have a library that supports matrix operations? Functions like multiply, transpose, dot-product, inverse, etc that work on (I'm guessing) vectors?

13:24 I checked math, set and a few other likely suspects but I didn't see anything.

13:28 dnolen: metagov: incanter might have something, http://wiki.github.com/liebke/incanter/matrices

13:32 notsonerdysunny: how can I do something like "import javax.media.* " in clojure?

13:33 chouser: notsonerdysunny: that's explicitly unsupported

13:33 metagov: dnolen: nifty. Incanter is a whole lot more than I was looking for but very nice. Thanks

13:33 ninjudd: dnolen: the new version of cake lets you run clojrue shell scripts with just #!/usr/bin/env cake

13:33 chouser: notsonerdysunny: but you can (import (javax.media Foo Bar Baz))

13:34 dnolen: ninjudd: sweet!

13:34 ninjudd: so can I get the raw arguments via a bound var as well?

13:34 ninjudd: dnolen: if the first argument has a / in it, it assumes the task is 'run'

13:35 dnolen: sure, i could just bind, *command-line-args*

13:36 dnolen: ninjudd: how about just bake/*args* ? :)

13:37 ninjudd: either is fine with me. *command-line-args* would possibly allow existing code to work as-is

13:38 but there may be some value in leaving that to the args from when the jvm was started

13:39 dnolen: ninjudd: good call. I'm okay with *command-line-args*

13:44 tastapod: can someone help me with a n00b vimclojure problem?

13:46 kencausey: tastapod: it's best to just state the problem right out

13:47 tastapod: I've got nailgun running, and ng is on my path (I'm running ubuntu 10.4), but vim complains about ng classpath problems

13:47 ninjudd: dnolen: just added it to 0.3.13-SNAPSHOT

13:47 tastapod: sorry kencausey - been a while since I was on irc :)

13:47 kencausey: PATH and CLASSPATH are not the same thing

13:47 but I'm no vim user so I could be way off-base

13:48 tastapod: I know - so I have clojure.jar, clojure-contrib.jar and vimclojure.jar on my CLASSPATH, and it's exported

13:48 clojurebot: vimclojure is state-of-the-art

13:48 tastapod: I run ng on the command line and it works ok

13:52 dnolen: ninjudd:great, thx!

13:52 dakrone: tastapod: do you have anything exported in CLOJURE_EXT?

13:52 tastapod: nope - what does that do?

13:59 dakrone: it tells nailgun which paths you want in your classpath

14:00 for example, mine is: export CLOJURE_EXT=/Users/hinmanm/.vimclojure:/Users/hinmanm/.cljr/lib:./lib:./classes:./src:.

14:00 arkh: is it idiomatic to say (let [a 10 b 20 c (+ a b)] ... ) so long as the symbols 'a' and 'b' do something useful like label an otherwise "magic number", etc. ?

14:00 and the form assigned to c is really more complex than that

14:03 qbg: As long as the names are descriptive, I don't see why not

14:04 arkh: cool. And they are in what I'm writing.

14:04 tastapod: there's an error message that flashes up briefly as I start vim

14:05 which says: Could not determine the Namespace of the file.

14:08 kencausey: tastapod: sounds like google fodder to me

14:09 dakrone: yea, I would check google and send an email to the mailing list tastapod

14:09 I would help more but I'm being overwhelmed at work

14:11 arkh: dakrone: anything cool? :)

14:12 tastapod: kencausey: yup, I've googled it - no joy :( thought it would be a noob question!

14:12 dakrone: arkh: a major power outage that knocked out our lab :P

14:12 arkh: dakrone: bummer

14:21 kencausey: tastapod: Might be, the trick is finding the right niche community perhaps, too many in this space right now to immediately connect with the right one.

14:23 dakrone: tastapod: sent you a pm, lemme know

14:37 anonymouse89: dakrone: I'm doing an NLP project and encountered your opennlp wrapper. I haven't yet used it, but I want to send a big thank you in advance. Also, I'm wondering if you know of a wraper for the stanford parser (shouldn't be too hard to do myself, but if it's already been done...)

14:39 dakrone: anonymouse89: the most similar thing would be the treebank-parser that's in clojure-opennlp

14:40 depending on what info you need out of the parse, it may work for you :)

14:42 anonymouse89: the wrapper has tagging and parsing, but lacks coref, typed dependencies and training (amongst other things)

14:49 anonymouse89: I'm out for lunch, but I'm keen to hear any feedback you have, send me an email/pm if you have any :)

15:37 arkh: what could cause clojure to block on a call to (send-off) ? I'm working with some DatagramSocket proof of concept code here: http://gist.github.com/521574

15:38 chouser: you're using send-off incorrectly

15:38 you want something more like (send-off udp-sender send-packet message)

15:39 arkh: oh - thank you

15:39 chouser: then send-packet needs to take two args, [agent-previous-value text]

15:39 similarly receive-packet would have to take an arg for the old agent value

15:40 arkh: agent-previous-value ?

15:40 I'll look at docs, too

15:40 chouser: well ... it looks like you're pretty much ignoring the values held by the agents

15:41 arkh: true :( I'm still in the process of making the udp stuff more functional or clojure-ish

15:41 chouser: which is sometimes a hint that agents themselves are not the right construct to use.

15:41 arkh: I need different threads to share data so I went with agents

15:41 and the Thread/sleep stuff is hackery until I have something proper

15:41 chouser: sure, but there are other thread abstractions besides agents

15:42 'future' comes to mind.

15:42 raek: would it be considered ideomatic to use agents when one does not care about any state, but want the function queue features?

15:42 chouser: raek: I think so. The alternatives I can think of (Executor + blocking queue for example) are much messier

15:43 raek: yeah

15:43 arkh: I have a vague notion of futures - I'll check their fit for this, too

15:45 chouser: , raek: thank you for the feedback

15:46 chouser: arkh: it is possible you'll be wanting queuing behavior for your listener and sender, in which case agents may indeed be justified

15:49 arkh: chouser: what I eventually want is something that maintains order of what comes in and what comes out, fifo, so the natural queuing of agents will probably help. That may change as I get into it further and/or look at futures etc.

15:49 raek: chouser: you always seem to find the that wording I'm looking for...

15:49 :)

15:51 chouser: raek: I could tell it was what you were driving at. :-)

16:07 Nikelandjelo: java.awt.Color contains static constants for different colors. I need to make map where key is the color name and value is the color. I have following variant http://gist.github.com/521623 But maybe somebody can show simpler variant?

16:14 lancepantz: heh, github lists clojure jobs under "Futuristic Stuff"

16:16 Raynes: Appropriately.

16:25 chouser: ,(import 'java.awt.Color)

16:25 clojurebot: java.awt.Color

16:26 chouser: ,(->> Color .getFields (map (juxt #(.getName %) #(.get % Color))) (filter (fn [[name color]] (and (= name (.toUpperCase name)) (instance? Color color)))) (into {}))

16:26 clojurebot: {"GRAY" #<Color java.awt.Color[r=128,g=128,b=128]>, "GREEN" #<Color java.awt.Color[r=0,g=255,b=0]>, "CYAN" #<Color java.awt.Color[r=0,g=255,b=255]>, "WHITE" #<Color java.awt.Color[r=255,g=255,b=255]>, "MAGENTA" #<Color java.awt.Color[r=255,g=0,b=255]>, "LIGHT_GRAY" #<Color java.awt.Color[r=192,g=192,b=192]>, "DARK_GRAY" #<Color java.awt.Color[r=64,g=64,b=64]>, "ORANGE" #<Color java.awt.Color[r=255,g=200,b=0]>, "RED" #<Colo

16:26 chouser: Nikelandjelo: how's that?

16:29 Nikelandjelo: chouser: Cool! :) juxt - funny function, I've never seen it before :) Thanks

16:41 pdk: (doc ->>)

16:41 clojurebot: "([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."

16:41 pdk: (doc ->)

16:41 clojurebot: "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."

16:55 vmind: Any help on whether this compilation error with deftype/mutable/locking http://gist.github.com/521695 is a more complex case of http://www.assembla.com/spaces/clojure/tickets/274 or different, before I file a bug?

18:04 mabes: ,(byte \a)

18:04 clojurebot: java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number

18:05 mabes: ^ what am I missing? How would I coerce a char into a byte?

18:07 looking at the source it is clear that (byte) is only intended to coerce Numbers... I just expected it be able to cast a char as well I gues..

18:09 lancepantz: ,(byte (Character/getNumericValue \a))

18:09 clojurebot: 10

18:14 mabes: lancepantz: great, thanks! I thought \a was the primitive char at first

18:14 spewn: \a is the primitive char.

18:15 getNumericValue doesn't do the same as casting to a number

18:15 ,[(int \a) (Character/getNumericValue \a)]

18:15 clojurebot: [97 10]

18:15 mabes: ,(class \a)

18:15 clojurebot: java.lang.Character

18:16 spewn: Oh, sorry. /That/ primitive

18:16 mabes: :)

18:29 spewn: ,(class 5)

18:29 clojurebot: java.lang.Integer

18:29 spewn: Is anything in Clojure a Java primitive?

18:31 dnolen: spewn: Clojure has support for primitive types and arrays of primitive types

18:31 ,(int-array [1 2 3])

18:31 clojurebot: #<int[] [I@533180>

18:32 dnolen: ,(+ (double 5.0) (double 3.33))

18:32 clojurebot: 8.33

18:32 dnolen: primitive math

18:40 spewn: ,(class (double 1.1))

18:40 clojurebot: java.lang.Double

18:40 spewn: It's automatically casting to the object?

18:46 tomoj: class is a function

18:46 so even if you pass a primitive it gets boxed

19:30 chouser: spewn: locals, record fields, array members, and vector members can be primitives.

19:30 function arguments are currently always boxed

19:31 spewn: I see.

19:31 chouser, tomoj, dnolen: Thanks.

19:33 chouser: ,(use '[clojure.contrib.repl-utils :only [expression-info]])

19:33 clojurebot: java.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath:

19:33 chouser: oh. well, if you have contrib you can compare for example:

19:34 (expression-info '(let [i (int 5)] (+ i (int 10)))) ;=> {:class int, :primitive? true}

19:34 (expression-info '(let [i (int 5)] (+ i 10))) ;=> {:class int, :primitive? true}

19:34 spewn: chouser: Typo? I get {:class java.lang.Number, :primitive? false} for the 2nd one.

19:35 chouser: hm, you shouldn't. you're pasting it just as I wrote it?

19:35 spewn: Yes

19:35 chouser: what about just: (expression-info '(int 5))

19:36 spewn: {:class int, :primitive? true}

19:36 chouser: interesting. so that's right.

19:36 oh

19:36 spewn: Boxing is contagious?

19:36 chouser: no, you're right. I mis-pasted

19:36 that second one should have been Number, as you said.

19:36 dnolen_: spewn: unless your on equiv branch, + returns boxed numbers.

19:36 chouser: boxing is essentially contagious

19:37 dnolen_: no

19:37 spewn: because if Clojure can't be sure at compile time which primitive type it's dealing with, it'll fall back to Objects.

19:37 dnolen_: + is an :inline, so in some cases can return a primitive

19:38 dnolen_: chouser: + is declared static in the equiv branch and can always return primitives I thought

19:38 chouser: hmm, interesting I've never gotten good performance from + unless I wrapped all return values in primitive cats.

19:39 s/cats/casts

19:39 technomancy: no, I liked primitive cats better

19:39 though there's always http://spl.smugmug.com/Humor/Lambdacats/13227630_eKt46#960526161_yXhEz

19:39 dnolen_: technomancy: yes, I was thinking that my self ;)

19:40 chouser: dnolen_: I'm not sure about the equiv branch, but + can in some cases return primtives since at least 1.1 I think

19:40 spewn: I'm seeing it return a primitive on 1.1.0

19:41 dnolen_: chouser: I remember hearing some reports from ztellman that 1.2 numeric performance had greatly degraded w/o explicit casts. I haven't used 1.1 in so long, I don't have any recollection of how well it performed.

19:42 spewn: in anycase, the perf of 1.2 equiv branch is sick. if you want all primitive cats, you'll get all primitive cats.

19:45 spewn: dnolen_: equiv? And sick as in good or bad?

19:45 dnolen_: spewn: heh, good.

19:47 spewn: you can easily get above 1e9 arithmetic ops in well under a second on a decent new laptop, basically about same perf you'd expect from pure Java.

19:47 spewn: Cool

19:49 ceptorial: http://cacti.ve.box.net/cacti/graph.php?action=view&local_graph_id=985&rra_id=all awesome

19:49 oops wrong room :) sorry guys

20:43 mmarczyk: http://www.marketwatch.com/story/oracle-sues-google-for-patent-infringement-2010-08-12?reflink=MW_news_stmp <- is this for real?

20:47 Raynes: Oh wow.

20:48 mmarczyk: hi Raynes :-)

20:48 if you're referring to the link above -- my sentiment exactly ;-)

20:48 Raynes: I was.

20:48 And hi. :D

20:48 mmarczyk: how's USPS doing?

20:48 Raynes: It isn't here yet.

20:49 mmarczyk: ah. *hurry up guys!* ...I mean, let's be patient.

20:49 Raynes: :p

20:50 I check the mail daily (because I'm waiting for some packages from Amazon as well), so I'll let you know when it arrives.

20:51 mmarczyk: cool :-)

20:51 btw, quotar's a nice name

20:51 does it mean something?

20:51 Raynes: It was status-quo at first. quotar means I had been awake for too long and didn't want to actually have to think of a decent one-word name.

20:52 Of quotar is a good name, it's purely accidental.

20:52 ;)

20:52 if*

20:52 mmarczyk: good enough etymology for me ;-)

20:53 Raynes: Do you follow me on Github, or were you just stalking?

20:54 mmarczyk: :-P

20:54 Raynes: I think I'm getting technomancy syndrome. Too many projects. :-)

20:54 mmarczyk: I tend to follow projects

20:55 occasionally I check if people whose projects I'm following happen to have started new projects ;-)

20:55 my GitHub dashboard is so full I hardly look at it anyway -- I mostly follow repos so as to have all the interesting GitHub links in one place

20:57 then occasionally I wonder if there's a smarter way to do things... maybe actually making the "event stream" useful? hmmmm... </end-random-musings> :-P

20:57 Raynes: quotar is my new unimportant sandboxy web project. tryclojure is too serious and important to really experiment with, so quotar is my little learning enviroment/hopefully something I can make useful.

20:59 mmarczyk: Oh yeah, there was a little bit more to the name. I was thinking about sexpbot's "quote" system thingy, and how quotar, when finished, could be used for that.

20:59 mmarczyk: ahh, cool!

21:06 brweber2: hey all, has work begun on an implementation of clojure in javascript yet?

21:06 Raynes: The usual response to that is "bug chouser", isn't it?

21:06 chouser: brweber2: an older version of clojure was done enough to demo, but it's out of date now

21:07 brweber2: chouser is it on github? are there plans to do an impl once 1.2 is stable?

21:07 chouser: http://clojurescript.n01se.net (works ok unless you're on a mac)

21:07 brweber2: I'm not going to put more effort into it untile clojure-in-clojure is further along.

21:08 brweber2: chouser what's the status of clojure in clojure? Has real work begun now that the defprotocol/type/record stuff is in place?

21:09 chouser: defprotocl/type/record *is* work on cinc. :-)

21:10 brweber2: chouser right, that is the groundwork but are there more fundamental changes needed or is everything in place now?

21:10 chouser: I actually just found a proj/clojure-compiler/compiler.clj on my laptop with some 850 lines that I have no recollection of writing.

21:11 brweber2: there's plenty yet to do -- bootstrapping issues to resolve, intermediate format decisions to make, etc.

21:12 I haven't been working on it as much as I'd like because of the book, but tomorrow we're handing that off to production, so I think it'll be taking rather less time for a while.

21:12 maybe put my shoulder to finger trees finally again.

21:13 brweber2: chouser if you get back to it and would like help, let me know, I'd be interested

21:14 mmarczyk: chouser: you mean handing JoC off to production?

21:14 chouser: congratulations! :-)

21:25 chouser: mmarczyk: yes, thanks!

21:26 brweber2: I think my first step will be a tool to convert the tree of pojos that Compiler.java currently produces in its analyze step into a tree of Clojure records

21:27 if everyone important (read: rhickey) can sign off on the format of that record tree, then several other things can proceed simultaneously

21:27 such as a JVM bytecode emitter, a JS emitter, and an analyzer written in Clojure.

21:28 brweber2: I wouldn't mind seeing the Reader be pluggable (not related to this) and the IParsers on the Expr's in Compiler be extracted as well

21:28 chouser: a couple people have already written readers in clojure

21:28 hiredman: *cough*

21:28 chouser: look, there's one now!

21:28 brweber2: yeah, I wrote an alternate reader (allows you to create a new language in no time) ... you get the compiler for free

21:29 fantastic for prototyping new language syntax quickly to see what works and what doesn't

21:29 chouser: ah, interesting

21:30 brweber2: but I'm studying Compiler now to see what it would take (cic)

21:30 hiredman: http://github.com/hiredman/Arkham

21:30 chouser: I'm curious if it would be possible to create a C-like syntax that could be converted to clojure code and back with absolutely no loss of data, whitespace, indentation, or anything.

21:31 hiredman: bleh

21:31 chouser: such that it would be safe to convert code in that format to real clojure, edit it, test it, etc. and then convert it back to C-like syntax without danger of any spurious diffs

21:31 brweber2: as long as it is c-like I would think it wouldn't be too bad, I ended up with more do/let's than I cared for

21:32 but c-LIKE is the key, if you have to meet an actual language syntax ... it would be too much work, if you have the freedom to change syntax were it makes sense, I would think it wouldn't be too bad

21:33 hiredman: I started using fnparse to parse the langauge used in EoP, but instead of writing an interpreter for it, I ended up just using fnparse's semantic hooks to transform it in to valid clojure and then eval it

21:34 brweber2: the one time I miss scala is when I want parser combinators. they work really well in scala.

21:34 hiredman: there are a number of clojure parser libraries, have you looked at any?

21:35 brweber2: hiredman actual eval? why didn't you just create the data structures with RT.<list> and compile them?

21:35 hiredman: fnparse is always under going a major rewrite

21:35 chouser: heh

21:35 hiredman: brweber2: that's what eval does

21:35 brweber2: hiredman I looked at a peg one that was commercial for real use, it seemed ok, but not as nice as what I was used to

21:35 hiredman: by "eval it" I mean: passed it to clojure.core/eval

21:35 ugh, really? commercial for real use

21:36 brweber2: hiredman ah ok, that makes more sense. I thought you were writing out source as string... not sure what I was thinking there...

21:37 hiredman: the clj-peg was relicensed to the epl earlier this year

21:38 brweber2: hiredman that looks nicer than what I remember, I doubt that it was clj-peg :)

21:38 hiredman: I am mulling over using Arkham for clojurebot's eval

21:39 brweber2: hiredman just cuz or for any particular reason?

21:39 hiredman: easier to sandbox

21:40 the draw back is it won't match clojure in all cases

21:41 instead of running clojure, clojurebot will simulate it

21:42 brweber2: hiredman I suppose it comes down to how different it would be... if people could live with it

21:42 what do people use it for? mostly experimentation or mostly explaining code to others?

21:42 hiredman: right

21:44 brweber2: personally I wouldn't use clojure bot for experimentation ... I'd use a local repl which means that it would be fine to swap it out (1 vote cast)

21:44 but I have no idea how the rest of the community uses it

21:44 or if I'm over simplifying things

21:46 chouser hiredman so I have this crazy (not really) idea of providing an "upgrade" file with each release of a library which users of the library could "apply" to automagically update their code with changes from the library

21:47 chouser hiredman this would allow for certain refactoring to be less painful, do you think that has any value?

21:48 chouser hiredman it is sort of like a patch, but is not source code aware, it is namespace/var aware

21:49 chouser: lpetit has been working on refactoring tools

21:49 brweber2: chouser what sort of tools?

21:50 counterclockwise?

21:50 clojurebot: Counterclockwise aka ccw at http://code.google.com/p/counterclockwise/

21:50 chouser: things he's plugging into that I believe, yes.

21:51 brweber2: I'll have to try to ping him later

23:56 notsonerdysunny: what is "lein swank" actually doing? is it just starting a clojure server or is it automatically loading all the clj files in the current project?

23:57 lancepantz: any lein task will start a jvm with your project's lib and src in the class path

23:58 notsonerdysunny: so it is not importing or requiring the dependencies?

23:58 lancepantz: so lein swank starts a jvm as such and loads a socket server

23:58 well, you have to import and refer your dependencies in whatever namespaces your working on

23:59 inorder to use those classes and functions

23:59 thats not specific to swank however

Logging service provided by n01se.net