#clojure logs

2010-08-12

02:18vIkSiThi all
02:18vIkSiTusing 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
02:18vIkSiT(I currently have a :use [clojure.contrib.duck-streams :only [slurp spit]])
02:19vIkSiTbut I cant figure out what the overriding package is
02:21ecyrbin 1.2.0-RC1 at least (and probably 1.2.0-beta1), spit and slurp are in clojure.core
02:21ecyrb(so you don't need to "use" them)
02:21zmila(:refer-clojure :exclude [spit]) inside (ns
02:24vIkSiTaah
02:24vIkSiTzmila, ecyrb - thanks so much :)
02:25vIkSiTi had totally forgotten about :refer-clojure
02:26ecyrbsorry - didn't realize duck-streams spit and slurp were different
02:34zmila:) i never know it, just see in some example
02:36LauJensenGood morning all
02:37raek,(doc seq1)
02:37clojurebotNo entiendo
03:58cobol_expertis 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
03:59arbscht,(str [:foo])
03:59clojurebot"[:foo]"
04:00cobol_expertha, that was easy.. I thought that was just used for concatenating strings :)
04:00cobol_expertthx
04:01zmilause print-dup
04:01zmilaanswer of MM: http://stackoverflow.com/questions/3301439/clojure-data-structure-serialization
04:08cobol_expertokay, researching this now...
04:08cobol_expertone thing I'd like to do is deref any refs in the structure
04:08cobol_expert,(str {:hi (ref "hi")})
04:08clojurebot"{:hi #<Ref@aa7acb: \"hi\">}"
04:09cobol_experti probably need to walk the tree and do that myself first...
04:11hoeckcobol_expert: maybe the functions in clojure.walk will help you with this
04:16cobol_expertyeah, 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
04:19hoeckcobol_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})})
04:25raekcobol_expert: pr-str is good when you want a string that can be read from
04:26raek,[(str [123 "foo" :bar (lazy-seq [1 2 3])]) (pr-str [123 "foo" :bar (lazy-seq [1 2 3])]))
04:26clojurebotUnmatched delimiter: )
04:27raek,[(str [123 "foo" :bar (lazy-seq [1 2 3])]) (pr-str [123 "foo" :bar (lazy-seq [1 2 3])])]
04:27clojurebot["[123 \"foo\" :bar (1 2 3)]" "[123 \"foo\" :bar (1 2 3)]"]
04:27raek,(str (lazy-seq [1 2 3]))
04:27clojurebot"clojure.lang.LazySeq@7861"
04:27raek,(pr-str (lazy-seq [1 2 3]))
04:27clojurebot"(1 2 3)"
04:28raekthere's a bunch of variations of that fn, look for everything that starts with "pr" in the api
05:25LauJensenAnybody familiar with a deployment tool which allows for multiple projects to run on a single JVM instance?
05:43bsteuberhow can I generate static fields/constants with gen-class? like MyColors/BLACK
06:21cschreinerhello, why can't I do this? (doseq [e '(for list)] (doc (symbol e)))
06:23cschreinerwhat would be the correct way to process the above?
06:27hoeckcschreiner: because doc is a macro, not a function
06:28cschreinerhoeck: I know. But how can I make doc eat my e?
06:28clojurebotdeft is http://gist.github.com/128259
06:28hoeckcschreiner: use print-doc instead
06:29hoeck,(doseq [e '(for list)] (print-doc (resolve e)))
06:29clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args (3) passed to: core$for
06:30cschreinerhoeck: but, for the sake of this example, is it possible to use doc?
06:31LauJensencschreiner: Not that I know of
06:31hoeckno, because the doc macro expands at compiletime to: (doseq [e ...] (print-doc (var (symbol e)))
06:31cschreinerok, important for me to know this.
06:32LauJensen,(let [e 'for] (prn (macroexpand-1 '(doc e))))
06:32clojurebot(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
06:32LauJensenSo, it doesnt get any more clear than that...
06:34hoeckcschreiner: the only thing you can do is to write a macro which expands to multiple doc calls
06:34hoecklike (defmacro docs [& syms] `(do ~@(for [e syms] `(doc ~e))))
06:35cschreinerhoeck: Right, tried that. Thanks
06:35old_sound_hi
06:36LauJensenHi old_sound_
06:36hoeckold_sound_: hi
06:37old_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
06:38old_sound_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
07:40edbondold_sound_: take a look at redis-clojure: http://github.com/ragnard/redis-clojure
07:41edbondold_sound_: and http://github.com/shughes/clojure-memcached
08:00old_sound_edbond: redis clojure is just a library to access redis no?
08:01old_sound_edbond: I want to implement the server, not the client
09:39limux1972hi, raek, http://tiny.cc/3cmrx is good
10:07raeklimux1972: does the problem go away if you add that?
10:07limux1972yes
10:10limux1972i made two test, one with wrap!, another no use
10:11raeknice to have that pinpointed...
10:11limux1972and look their source individually
10:12limux1972their meta line is exactly same
10:14raekand those give different results in the browser?
10:14limux1972even include the case sensitive of each word
10:14limux1972yes
10:16limux1972one with ???, another with 你好
10:17limux1972how to paste them?
10:18raekput it in http://gist.github.com/ and post the URL you get here
10:21limux1972http://gist.github.com/521037
10:26cemerickDoes RC3 fix #422 or no?
10:26limux1972if i use wrap! with iso8859-1, the ??? is come
10:26raeklimux1972: which browser are you using? could you test a thing in Firefox?
10:27raeklimux1972: you should not use iso8859-1, since the string is by default encoded in UTF-8 by Ring
10:27raekalso, ISO 8859-1 cannot store chinese characters at all
10:28limux1972the browser of chrome and firefox have same result
10:29limux1972i thank it's compojure who caused it
10:30raekin firefox, click on Tools -> Page Info
10:30raekin the table, there should be a row with "content-type" on the left and "text/html <something>" on the right
10:31raekcould you try what <somethings> is when 1) wrap! is not used 2) wrap! is used with UTF-8
10:32limux1972it's very clearly the encoding is iso-8859-1 with no use wrap!
10:33raekok
10:33raekanyway
10:33limux1972compojure use iso8859 as it's default encoding
10:33raekyou should always have a :content-type key in your response
10:33raekit shouldn't
10:33limux1972even the lastest 0.4.1
10:33raekwell, hrm
10:35raekwhen you do a response, do something like {:headers {"Content-Type" "text/html; charset=UTF-8"}, :body <html goes here>, :code 200}
10:35raekthe content type should always be specified in a way or another
10:35raekyou can use middleware for that
10:35limux1972but what i see is one is iso8859 and utf8 another with utf8 and utf8
10:36apgwozi don't see any place where compojure is changing the encoding or setting a charset in the Content-Type header...
10:36raekthe "text/html; charset=iso8859-1" content type is added because you didn't choose a content type yourself
10:36BrianForester,(try (prn 1) (finally (prn 2) (throw (Exception.))))
10:36clojurebotBrianForester: I don't understand.
10:37raekprobably this is done by the servlet container or something
10:37apgwozraek: yeah, it would seem that way. or jetty defaults it to that or something
10:37apgwozwhich.. would be the servelet container as you said
10:37raekthe problem is that if the encoding is specified in the content-type, then that overrides the meta tags and everything
10:38raekso, solution: always provide the content type yourself
10:38raektext/html should be sufficient
10:38BrianForestercemerick: I just tested this on RC3, doesn't look like 422 was fixed this release.
10:38limux1972and 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:38cemerickBrianForester: the commit referenced that ticket, so I was unclear.
10:39raeklimux1972: the browser doesn't care about the meta if it sees a "charset=..." in the content-type
10:39BrianForestercemerick: same here.
10:39apgwozraek: but compojure already supplies the content-type if you don't set it in the response.
10:39raekdoes it?
10:39raekhrm
10:39apgwozaccording to the source
10:39raekto what?
10:39apgwozcompojure
10:40apgwozhttp://github.com/weavejester/compojure/blob/0.4.1/src/compojure/response.clj
10:40raek*sigh*
10:40raekthen jetty adds a coding attribute
10:40apgwozunless i'm misunderstanding how this is working, but i don't *think* that's the case
10:40raekthat's bad...
10:40limux1972apgwoz, i use emacs convert the source to utf8,
10:41limux1972but it no use
10:41raeklimux1972: could you give me the link to the tutorial?
10:41apgwozlimux1972: 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:42apgwozwhich is why you'd be seeing an issue
10:43raeklimux1972: 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:43BrianForestercemerick: I'm pretty sure that someone has already supplied a patch, so you could apply it by hand if needed.
10:43raekjetty: grrrr
10:44apgwozso, you're handler for compojure should be returning {:status 200 :headers {"Content-Type" "text/html; charset=utf-8"} :body <insert your html here>}
10:44apgwozwhich is quite inconvenient mind you.
10:45raekoh, :status was the correct keyword... disregard my previous example
10:45limux1972as you say, raek, just a moment, i remove all the metas and reserve the wrap, how about it?
10:45raeklimux1972: the meta should be there
10:46raekalways
10:46limux1972i know
10:46limux1972i just want to try
10:46raekok, go ahead :)
10:46limux1972yeah
10:47raekthen the browser will probably guess the enconding (if neither meta nor the charset content-type attribute is there)
10:47limux1972there is no those annoying ???
10:47raekenconding in html is a mess...
10:47raeklimux1972: probably since the browser guessed the right encoding
10:48limux1972yeah, firefox tell us the right encoding utf, but nothing about page info
10:50limux1972anthow word, compojure didn't use the meta's charset, it's for browser
10:52raekboth are for the browser
10:52raekcompojurer does not care about any of them
10:53limux1972browser use which encoding meta tell it to render the html, even since the really encoding is not
10:55limux1972if compojure does care it as you say, i have to not only provide meta
10:56edbondfunny, but enlive doesnt works with utf-8 too
10:56limux1972and must provide encoding info somewhere
10:57limux1972which compojure can use, where
10:57limux1972where?
10:57clojurebotwhere is your source code
10:59limux1972wrap! is a nice solution, what is the best?
11:00raekhaving a Contet-Type in the header, which can be done either manually or with middleware
11:01raekhrm, yes tagsoup (which enlive uses) does not do encoding detection...
11:02cemerick~max
11:02clojurebotmaxine is http://research.sun.com/projects/maxine/
11:02cemerickheh, ok
11:02raeksomeone should take mozilla's encoding detection code and integrate it into tagsoup
11:02cemerickhiredman: clojurebot's brain is still out of commission?
11:03limux1972http://gist.github.com/521100
11:04raek"If you need an autodetector of character sets, consider trying to adapt the Mozilla one; if you succeed, let me know."
11:04raekI take that as a challenge, Cowan!
11:05limux1972my core.clj
11:09limux1972http://gist.github.com/521114, the mostly original core.clj
11:10limux1972all work well with wrap
11:11raekthat looks perfectly fine
11:11raekI recommend using wrap
11:11limux1972badly without wrap
11:12limux1972yes, wrap is a nice way
11:12limux1972i wonder the nicer
11:14limux1972middleware is a good idea, but this issue should not use middleware, personal view
11:16edbondno need for charset detector, utf-8 as a default is good start
11:26limux1972i add a prn in wrap! to see the response at begin and end, but the console has noting to display
11:29BrianForestercemerick: I was wrong, RC3 does fix #422. I had an old copy of the clojure jar in my classpath.
11:34edbondhow to make lein swank to run with utf-8 encoding?
11:36limux1972raek, I have seen the response, a map, the ring and rack's style, it's :headers is {"Content-Type" "text/html"}
11:36limux1972no charset
12:02pdk(doc ->)
12:02clojurebot"([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:02pdk(doc get-in)
12:02clojurebot"([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:03pdk,(get-in {1 {2 3} 4 {5 6}} '(1 2))
12:03clojurebot3
12:03pdk,(get-in {1 {2 3} 4 {5 6}} '(1 3))
12:03clojurebotnil
12:03pdk(doc interpose)
12:03clojurebot"([sep coll]); Returns a lazy seq of the elements of coll separated by sep"
12:03maxpn,(a b)
12:03clojurebotjava.lang.Exception: Unable to resolve symbol: a in this context
12:04maxpn,('a 'b)
12:04clojurebotnil
12:04maxpn, (1 2 3)
12:04clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
12:04pdkif you need the literal list use '(a b)
12:04pdk,'(a b)
12:04clojurebot(a b)
12:04pdkor quote, list etc
12:04maxpn, (quote 1 2 3)
12:04clojurebot1
12:05maxpn, '(1 2)
12:05clojurebot(1 2)
12:06pdk(doc quote)
12:06clojurebotexcusez-moi
12:06pdk'x is shorthand for (quote x)
12:06pdk,(quote (1 2 3))
12:06clojurebot(1 2 3)
12:06pdktheres what you wanted
12:08limux1972raek, bye
12:09pdk,(list 1 2 3)
12:09clojurebot(1 2 3)
12:10pdkcf. '(1 2 3)
12:37edbondany links for java/clojure utf-8 reading?
12:37edbondclj-env-dir doesn't shows utf-8 chars, cake repl shows.
12:52raekedbond: clojure io with UTF-8 is pretty simple
12:53raekbut note that JLine (used by lein repl) does not have support for UTF-8
12:53raekswank does, but you have to configure it to use it
12:53raeklein swank localhost 4005 ':encoding' '"UTF-8"'
12:54raekthen you have to add a setting in your .emacs
12:55raek(custom-set-variables '(slime-net-coding-system (quote utf-8-unix)))
12:55raekthen you have UTF-8 in slime+swank!
12:55raekas for io (files, sockets, etc):
12:55raekcheck out http://richhickey.github.com/clojure/clojure.java.io-api.html
12:57raekUTF-8 is the default encoding for IO in clojure
12:57raekfor example, open a BufferedReader with:
12:57raek(require '[clojure.java.io :as io])
12:58raek(io/reader "filename")
12:58raekthat will read UTF-8 characters from the file
12:58raek(io/input-stream "filename") ; will read bytes
12:59raek(io/reader "filename" :encoding "ISO-5591-1") ; other encodings can be specified too (default so UTF-8)
12:59raeks/5591/8859/
13:01raekalso, if you want to display and write UTF-8 encoded characters through the terminal, the terminal must of course be correctly set up
13:08raekyou can then use the usual java.io.Reader methods, such as .readLine
13:09bmhI'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:09bmhsure I could just make each case a structmap, but it seems like a clunky approach.
13:10raekdoes that make a new type? I have never programmed haskell...
13:11bmhraek: Yes. The snippet creates a type 'Tree' that is parameterized by alpha.
13:11raekinteresting...
13:12raekwell, clojure is not much about types
13:12raekI guess you would just put data in 2-vectors
13:12bmhraek: I want to avoid unstructured programming.
13:13raekyou could perhaps use defrecord if you need them to have their own type
13:13dnolenbmh: also there's an ADT library in contrib
13:14bmhdnolen: I'll check it out.
13:14raekbmh: clojure does not provide the formalness that haskell does
13:14raekat least not in the way of a type system
13:15bmhraek: Sure, it's closer to Scheme than Haskell or ML
13:16dnolenbmh: http://www.mail-archive.com/clojure@googlegroups.com/msg09441.html
13:16raekI'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:16bmhdnolen: Heh, I just found that page on GOOG
13:17raekhrm, repace "no exact way" with "no idemoatic way"
13:17bmhIs equality testing still by identity rather than value?
13:17raekidentity for ref/atom/agent/var, value for data structures and scalars
13:18bmhraek: I meant with regards to the ADT lib. The author mentions a caveat that equality is by identity
13:18raek,(= (hash-set 1 2 3) (sorted-set 1 2 3))
13:18clojurebottrue
13:18raekoh
13:18dnolenbmh: you should read the whole thread
13:18raeksorry
13:18bmhdnolen: will do
13:21metagovDoes 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:24metagovI checked math, set and a few other likely suspects but I didn't see anything.
13:28dnolenmetagov: incanter might have something, http://wiki.github.com/liebke/incanter/matrices
13:32notsonerdysunnyhow can I do something like "import javax.media.* " in clojure?
13:33chousernotsonerdysunny: that's explicitly unsupported
13:33metagovdnolen: nifty. Incanter is a whole lot more than I was looking for but very nice. Thanks
13:33ninjudddnolen: the new version of cake lets you run clojrue shell scripts with just #!/usr/bin/env cake
13:33chousernotsonerdysunny: but you can (import (javax.media Foo Bar Baz))
13:34dnolenninjudd: sweet!
13:34dnolenninjudd: so can I get the raw arguments via a bound var as well?
13:34ninjudddnolen: if the first argument has a / in it, it assumes the task is 'run'
13:35ninjudddnolen: sure, i could just bind, *command-line-args*
13:36dnolenninjudd: how about just bake/*args* ? :)
13:37ninjuddeither is fine with me. *command-line-args* would possibly allow existing code to work as-is
13:38ninjuddbut there may be some value in leaving that to the args from when the jvm was started
13:39dnolenninjudd: good call. I'm okay with *command-line-args*
13:44tastapodcan someone help me with a n00b vimclojure problem?
13:46kencauseytastapod: it's best to just state the problem right out
13:47tastapodI've got nailgun running, and ng is on my path (I'm running ubuntu 10.4), but vim complains about ng classpath problems
13:47ninjudddnolen: just added it to 0.3.13-SNAPSHOT
13:47tastapodsorry kencausey - been a while since I was on irc :)
13:47kencauseyPATH and CLASSPATH are not the same thing
13:47kencauseybut I'm no vim user so I could be way off-base
13:48tastapodI know - so I have clojure.jar, clojure-contrib.jar and vimclojure.jar on my CLASSPATH, and it's exported
13:48clojurebotvimclojure is state-of-the-art
13:48tastapodI run ng on the command line and it works ok
13:52dnolenninjudd:great, thx!
13:52dakronetastapod: do you have anything exported in CLOJURE_EXT?
13:52tastapodnope - what does that do?
13:59dakroneit tells nailgun which paths you want in your classpath
14:00dakronefor example, mine is: export CLOJURE_EXT=/Users/hinmanm/.vimclojure:/Users/hinmanm/.cljr/lib:./lib:./classes:./src:.
14:00arkhis 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:00arkhand the form assigned to c is really more complex than that
14:03qbgAs long as the names are descriptive, I don't see why not
14:04arkhcool. And they are in what I'm writing.
14:04tastapodthere's an error message that flashes up briefly as I start vim
14:05tastapodwhich says: Could not determine the Namespace of the file.
14:08kencauseytastapod: sounds like google fodder to me
14:09dakroneyea, I would check google and send an email to the mailing list tastapod
14:09dakroneI would help more but I'm being overwhelmed at work
14:11arkhdakrone: anything cool? :)
14:12tastapodkencausey: yup, I've googled it - no joy :( thought it would be a noob question!
14:12dakronearkh: a major power outage that knocked out our lab :P
14:12arkhdakrone: bummer
14:21kencauseytastapod: 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:23dakronetastapod: sent you a pm, lemme know
14:37anonymouse89dakrone: 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:39dakroneanonymouse89: the most similar thing would be the treebank-parser that's in clojure-opennlp
14:40dakronedepending on what info you need out of the parse, it may work for you :)
14:42dakroneanonymouse89: the wrapper has tagging and parsing, but lacks coref, typed dependencies and training (amongst other things)
14:49dakroneanonymouse89: 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:37arkhwhat 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:38chouseryou're using send-off incorrectly
15:38chouseryou want something more like (send-off udp-sender send-packet message)
15:39arkhoh - thank you
15:39chouserthen send-packet needs to take two args, [agent-previous-value text]
15:39chousersimilarly receive-packet would have to take an arg for the old agent value
15:40arkhagent-previous-value ?
15:40arkhI'll look at docs, too
15:40chouserwell ... it looks like you're pretty much ignoring the values held by the agents
15:41arkhtrue :( I'm still in the process of making the udp stuff more functional or clojure-ish
15:41chouserwhich is sometimes a hint that agents themselves are not the right construct to use.
15:41arkhI need different threads to share data so I went with agents
15:41arkhand the Thread/sleep stuff is hackery until I have something proper
15:41chousersure, but there are other thread abstractions besides agents
15:42chouser'future' comes to mind.
15:42raekwould it be considered ideomatic to use agents when one does not care about any state, but want the function queue features?
15:42chouserraek: I think so. The alternatives I can think of (Executor + blocking queue for example) are much messier
15:43raekyeah
15:43arkhI have a vague notion of futures - I'll check their fit for this, too
15:45arkhchouser: , raek: thank you for the feedback
15:46chouserarkh: it is possible you'll be wanting queuing behavior for your listener and sender, in which case agents may indeed be justified
15:49arkhchouser: 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:49raekchouser: you always seem to find the that wording I'm looking for...
15:49raek:)
15:51chouserraek: I could tell it was what you were driving at. :-)
16:07Nikelandjelojava.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:14lancepantzheh, github lists clojure jobs under "Futuristic Stuff"
16:16RaynesAppropriately.
16:25chouser,(import 'java.awt.Color)
16:25clojurebotjava.awt.Color
16:26chouser,(->> Color .getFields (map (juxt #(.getName %) #(.get % Color))) (filter (fn [[name color]] (and (= name (.toUpperCase name)) (instance? Color color)))) (into {}))
16:26clojurebot{"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:26chouserNikelandjelo: how's that?
16:29Nikelandjelochouser: Cool! :) juxt - funny function, I've never seen it before :) Thanks
16:41pdk(doc ->>)
16:41clojurebot"([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:41pdk(doc ->)
16:41clojurebot"([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:55vmindAny 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:04mabes,(byte \a)
18:04clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number
18:05mabes^ what am I missing? How would I coerce a char into a byte?
18:07mabeslooking 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:09lancepantz,(byte (Character/getNumericValue \a))
18:09clojurebot10
18:14mabeslancepantz: great, thanks! I thought \a was the primitive char at first
18:14spewn\a is the primitive char.
18:15spewngetNumericValue doesn't do the same as casting to a number
18:15spewn,[(int \a) (Character/getNumericValue \a)]
18:15clojurebot[97 10]
18:15mabes,(class \a)
18:15clojurebotjava.lang.Character
18:16spewnOh, sorry. /That/ primitive
18:16mabes:)
18:29spewn,(class 5)
18:29clojurebotjava.lang.Integer
18:29spewnIs anything in Clojure a Java primitive?
18:31dnolenspewn: Clojure has support for primitive types and arrays of primitive types
18:31dnolen,(int-array [1 2 3])
18:31clojurebot#<int[] [I@533180>
18:32dnolen,(+ (double 5.0) (double 3.33))
18:32clojurebot8.33
18:32dnolenprimitive math
18:40spewn,(class (double 1.1))
18:40clojurebotjava.lang.Double
18:40spewnIt's automatically casting to the object?
18:46tomojclass is a function
18:46tomojso even if you pass a primitive it gets boxed
19:30chouserspewn: locals, record fields, array members, and vector members can be primitives.
19:30chouserfunction arguments are currently always boxed
19:31spewnI see.
19:31spewnchouser, tomoj, dnolen: Thanks.
19:33chouser,(use '[clojure.contrib.repl-utils :only [expression-info]])
19:33clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath:
19:33chouseroh. well, if you have contrib you can compare for example:
19:34chouser(expression-info '(let [i (int 5)] (+ i (int 10)))) ;=> {:class int, :primitive? true}
19:34chouser(expression-info '(let [i (int 5)] (+ i 10))) ;=> {:class int, :primitive? true}
19:34spewnchouser: Typo? I get {:class java.lang.Number, :primitive? false} for the 2nd one.
19:35chouserhm, you shouldn't. you're pasting it just as I wrote it?
19:35spewnYes
19:35chouserwhat about just: (expression-info '(int 5))
19:36spewn{:class int, :primitive? true}
19:36chouserinteresting. so that's right.
19:36chouseroh
19:36spewnBoxing is contagious?
19:36chouserno, you're right. I mis-pasted
19:36chouserthat second one should have been Number, as you said.
19:36dnolen_spewn: unless your on equiv branch, + returns boxed numbers.
19:36chouserboxing is essentially contagious
19:37chouserdnolen_: no
19:37chouserspewn: because if Clojure can't be sure at compile time which primitive type it's dealing with, it'll fall back to Objects.
19:37chouserdnolen_: + is an :inline, so in some cases can return a primitive
19:38dnolen_chouser: + is declared static in the equiv branch and can always return primitives I thought
19:38dnolen_chouser: hmm, interesting I've never gotten good performance from + unless I wrapped all return values in primitive cats.
19:39dnolen_s/cats/casts
19:39technomancyno, I liked primitive cats better
19:39technomancythough there's always http://spl.smugmug.com/Humor/Lambdacats/13227630_eKt46#960526161_yXhEz
19:39dnolen_technomancy: yes, I was thinking that my self ;)
19:40chouserdnolen_: I'm not sure about the equiv branch, but + can in some cases return primtives since at least 1.1 I think
19:40spewnI'm seeing it return a primitive on 1.1.0
19:41dnolen_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:42dnolen_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:45spewndnolen_: equiv? And sick as in good or bad?
19:45dnolen_spewn: heh, good.
19:47dnolen_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:47spewnCool
19:49ceptorialhttp://cacti.ve.box.net/cacti/graph.php?action=view&amp;local_graph_id=985&amp;rra_id=all awesome
19:49ceptorialoops wrong room :) sorry guys
20:43mmarczykhttp://www.marketwatch.com/story/oracle-sues-google-for-patent-infringement-2010-08-12?reflink=MW_news_stmp <- is this for real?
20:47RaynesOh wow.
20:48mmarczykhi Raynes :-)
20:48mmarczykif you're referring to the link above -- my sentiment exactly ;-)
20:48RaynesI was.
20:48RaynesAnd hi. :D
20:48mmarczykhow's USPS doing?
20:48RaynesIt isn't here yet.
20:49mmarczykah. *hurry up guys!* ...I mean, let's be patient.
20:49Raynes:p
20:50RaynesI 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:51mmarczykcool :-)
20:51mmarczykbtw, quotar's a nice name
20:51mmarczykdoes it mean something?
20:51RaynesIt 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:52RaynesOf quotar is a good name, it's purely accidental.
20:52Raynes;)
20:52Raynesif*
20:52mmarczykgood enough etymology for me ;-)
20:53RaynesDo you follow me on Github, or were you just stalking?
20:54mmarczyk:-P
20:54RaynesI think I'm getting technomancy syndrome. Too many projects. :-)
20:54mmarczykI tend to follow projects
20:55mmarczykoccasionally I check if people whose projects I'm following happen to have started new projects ;-)
20:55mmarczykmy 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:57mmarczykthen 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:57Raynesquotar 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:59Raynesmmarczyk: 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:59mmarczykahh, cool!
21:06brweber2hey all, has work begun on an implementation of clojure in javascript yet?
21:06RaynesThe usual response to that is "bug chouser", isn't it?
21:06chouserbrweber2: an older version of clojure was done enough to demo, but it's out of date now
21:07brweber2chouser is it on github? are there plans to do an impl once 1.2 is stable?
21:07chouserhttp://clojurescript.n01se.net (works ok unless you're on a mac)
21:07chouserbrweber2: I'm not going to put more effort into it untile clojure-in-clojure is further along.
21:08brweber2chouser what's the status of clojure in clojure? Has real work begun now that the defprotocol/type/record stuff is in place?
21:09chouserdefprotocl/type/record *is* work on cinc. :-)
21:10brweber2chouser right, that is the groundwork but are there more fundamental changes needed or is everything in place now?
21:10chouserI actually just found a proj/clojure-compiler/compiler.clj on my laptop with some 850 lines that I have no recollection of writing.
21:11chouserbrweber2: there's plenty yet to do -- bootstrapping issues to resolve, intermediate format decisions to make, etc.
21:12chouserI 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:12chousermaybe put my shoulder to finger trees finally again.
21:13brweber2chouser if you get back to it and would like help, let me know, I'd be interested
21:14mmarczykchouser: you mean handing JoC off to production?
21:14mmarczykchouser: congratulations! :-)
21:25chousermmarczyk: yes, thanks!
21:26chouserbrweber2: 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:27chouserif everyone important (read: rhickey) can sign off on the format of that record tree, then several other things can proceed simultaneously
21:27chousersuch as a JVM bytecode emitter, a JS emitter, and an analyzer written in Clojure.
21:28brweber2I 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:28chousera couple people have already written readers in clojure
21:28hiredman*cough*
21:28chouserlook, there's one now!
21:28brweber2yeah, I wrote an alternate reader (allows you to create a new language in no time) ... you get the compiler for free
21:29brweber2fantastic for prototyping new language syntax quickly to see what works and what doesn't
21:29chouserah, interesting
21:30brweber2but I'm studying Compiler now to see what it would take (cic)
21:30hiredmanhttp://github.com/hiredman/Arkham
21:30chouserI'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:31hiredmanbleh
21:31chousersuch 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:31brweber2as 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:32brweber2but 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:33hiredmanI 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:34brweber2the one time I miss scala is when I want parser combinators. they work really well in scala.
21:34hiredmanthere are a number of clojure parser libraries, have you looked at any?
21:35brweber2hiredman actual eval? why didn't you just create the data structures with RT.<list> and compile them?
21:35hiredmanfnparse is always under going a major rewrite
21:35chouserheh
21:35hiredmanbrweber2: that's what eval does
21:35brweber2hiredman 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:35hiredmanby "eval it" I mean: passed it to clojure.core/eval
21:35hiredmanugh, really? commercial for real use
21:36brweber2hiredman ah ok, that makes more sense. I thought you were writing out source as string... not sure what I was thinking there...
21:37hiredmanthe clj-peg was relicensed to the epl earlier this year
21:38brweber2hiredman that looks nicer than what I remember, I doubt that it was clj-peg :)
21:38hiredmanI am mulling over using Arkham for clojurebot's eval
21:39brweber2hiredman just cuz or for any particular reason?
21:39hiredmaneasier to sandbox
21:40hiredmanthe draw back is it won't match clojure in all cases
21:41hiredmaninstead of running clojure, clojurebot will simulate it
21:42brweber2hiredman I suppose it comes down to how different it would be... if people could live with it
21:42brweber2what do people use it for? mostly experimentation or mostly explaining code to others?
21:42hiredmanright
21:44brweber2personally 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:44brweber2but I have no idea how the rest of the community uses it
21:44brweber2or if I'm over simplifying things
21:46brweber2chouser 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:47brweber2chouser hiredman this would allow for certain refactoring to be less painful, do you think that has any value?
21:48brweber2chouser hiredman it is sort of like a patch, but is not source code aware, it is namespace/var aware
21:49chouserlpetit has been working on refactoring tools
21:49brweber2chouser what sort of tools?
21:50brweber2counterclockwise?
21:50clojurebotCounterclockwise aka ccw at http://code.google.com/p/counterclockwise/
21:50chouserthings he's plugging into that I believe, yes.
21:51brweber2I'll have to try to ping him later
23:56notsonerdysunnywhat 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:57lancepantzany lein task will start a jvm with your project's lib and src in the class path
23:58notsonerdysunnyso it is not importing or requiring the dependencies?
23:58lancepantzso lein swank starts a jvm as such and loads a socket server
23:58lancepantzwell, you have to import and refer your dependencies in whatever namespaces your working on
23:59lancepantzinorder to use those classes and functions
23:59lancepantzthats not specific to swank however