#clojure logs

2009-04-19

01:21ChrisF___i'm kindof curious who's sneaking it into the corporate enviro?
01:22ChrisF___i'll be perfectly honest....unless we have different sufrface syntax on it, its a no go...for everybody
01:22hiredmanuh
01:23hiredmanwell, thats just like, you're opinion, man...
01:23ChrisF___uhh....yeah, we can dick around with as computer geeks, but it will never go for anybody in the corporate enviro
01:23ChrisF___hiredman: dude, nobody will ever do s-expression
01:24dreishhttp://www.mail-archive.com/clojure@googlegroups.com/msg12271.html
01:24ChrisF___it's hard enough to be dynamic...but to do s-expressions is a non-starter
01:24dreishChrisF___: You're babbling.
01:24ChrisF___just aanother geek language
01:25hiredmanhttp://www.flickr.com/photos/gnuvince/2944227285/
01:25ChrisF___ChrisF___: yes, i'll take that as i agree
01:25Carkhaha nice one hiredman
01:25Carkolegs pointer made me laugh
01:25hiredmanit's gnuvince's
01:25ChrisF___have fun dorks, you have no choice in the corporate environemant
01:25hiredmanjust repasting
01:26ChrisF___you're like jrugy
01:26ChrisF___jruby
01:26ChrisF___oops
01:26hiredmanChrisF___, you ever read any discworld books?
01:26ChrisF___hiredman: don't worry, you'll never be a PHB
01:27hiredmanChrisF___, in the mythos of the discworld trolls, it is believed that living creates are actually living backwards through time
01:27ChrisF___so go have fun dicking around with shit that nobody will never use
01:27dreishChrisF___: Good grief, can you even read?
01:27ChrisF___rich probably understands that...he just wants to be able hack himself
01:28ChrisF___he didn't think dweebs would follow
01:28hiredmanChrisF___, it is an interesting idea, and one that would not typically show up in a cultural myth
01:28hiredmanChrisF___, because it is sort of a distinction without a difference
01:28ChrisF___yes, we will get scala
01:28ChrisF___before some idiocy that insisits on s-expressions
01:29hiredmanChrisF___, but I think it is used to sort of engender a feeling of hidden depths in the troll culture
01:29dreishThere's also http://www.mail-archive.com/clojure@googlegroups.com/msg11977.html
01:29ChrisF___ahh, yes....i can't believe you brought up the troll word before this time
01:29dreishTwo substantial production deployments before the language is even at 1.0, before there is even a single book out.
01:29ChrisF___it took you this long? yes, you're just weak and had to weave it in
01:30ChrisF___yes we have many substantial dork deployments of jruby and jpython
01:30hiredmanChrisF___, so you've read the books?
01:30ChrisF___hiredman: why are you losing?
01:31ChrisF___no wonder i never hire java dorks
01:31ChrisF___thank god for a real modern language like C# 3.0
01:32ChrisF___have fun idiots...once you put a python-like surface syntax on your toy, then we can talk
01:35cp2hrmf.
01:35cp2reminds me of this quote:
01:35cp2shut the hell up i aint a no lifer nerd like u...
01:37hiredmanit would be depressing if that became a regular occurrence here
01:45replacaOh looks like I missed some fun
01:46replacaPoor ChrisF___ has to work in a fabric covered box all day
01:46replacaand assumes that everyone shares that aspiration :-)
01:55cp2hm, JNA is so much more appealing than JNI
01:56cp2although they have different purposes i suppose
01:56cp2however, using JNI for what JNA does is what i mean
09:07emacsenpjb3, hey
09:07emacsenping again
09:07pjb3emacsen: hey
09:07emacsenso I saw your mail. You want JSON as the internernal data structure?
09:07emacseninternal that is
09:08pjb3emacsen: No, internally would be clojure data structures
09:08pjb3Just use JSON to define the "tubes"
09:08emacsenokay, we need to all work on a common set of vocabulary
09:08emacsenmaybe we should do that at the mtg
09:09emacsencan you use it in a sentence? ;)
09:10pjb3What Luke has in the file test.tube (haha), I would make test.json
09:12emacsenoh gotcha
09:28emacsendliebke, hi
09:28emacsenare you a member of the study group?
09:34dliebkeemacsen, do you mean the d.c. study group?
09:34emacsenyeah
09:34dliebkeno, I just learned about it a couple days ago
09:35emacsenabout clj or the study group?
09:35dliebkethe study group
09:35emacsenah
09:35emacsenwell do you know clj well?
09:36dliebkeI've been programming with it a lot the last few months
09:36emacsenah cool
09:36emacsenwell, if you'd like to work on a side project, we're starting one :)
09:37dliebkesounds cool, but I've got a side project that has been consuming all my time already :)
09:37emacsenfair nuff
09:38emacsendliebke, so to be a total shill, do you know it's at HacDC? :)
09:40dliebkeemacsen, HacDC?
09:40emacsenhttp://www.washingtonpost.com/wp-dyn/content/article/2009/04/18/AR2009041800112.html
09:40emacsenDC's hackerspace
09:42dliebkevery cool, thanks for the article link
09:42emacsenno problem
09:50emacsenwow another DC person
09:50emacsenI think we need to convince rhickey to move down here
09:51emacsenmarklar, do you know about the DC Clojure study group?
10:09marklaremacsen: yes, it popped up in a google search a few weeks back
10:09marklarI couldn't make the one on the 4th though
10:11emacsenyou know we're doing one today
10:12marklarno I didn't... what is the website again?
10:13marklarnevermind, I found the google group. I won't be able to make it today either, I would like to come to one though
10:14emacsenk
13:59unlinkI 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:05dreishCan't use -cp and -jar together.
14:13unlinkdreish: Oh, heh. You're right. Thanks.
14:16unlinkIs 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:18unlinkjava -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:23arohner_unlink: what a few people do is write a bash script that adds dir/*.jar to the cp
14:23arohner_function load_jars()
14:23arohner_{
14:23arohner_ for file in "$@"; do
14:23arohner_ jars=$jars:$file
14:23arohner_ done
14:23arohner_}
14:23arohner_load_jars jars/*.jar
14:23arohner_java -cp $jars
14:25unlinkHmm, I'm trying to see if I can start the Repl from ant. Doesn't seem especially possible.
14:25arohner_why not?
14:26unlinkBecause it wants to handle all I/O itself
14:27unlinkFirst off every line of output gets prepended with " [java] "
14:28arohner_eww
14:38Lau_of_DKHey guys
14:38unlinkHi Lau_of_DK.
14:39technomancyhello
14:42unlinkIt looks like GAE is swallowing my classpath somehow.
14:42Lau_of_DKGAE?
14:43unlinkGoogle App Engine.
14:44unlinkoh, it wants me to copy all of my jars to WEB-INF/lib.
14:45Lau_of_DKah
14:45unlinkIT WORKS!
14:45unlinkexcellent.
14:46unlinkgoogle app engine summarily ignores any classpath you give java when loading classes.
15:40unlinkIs 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:48unlinkHow 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:51arohner_unlink: the special forms page lists the available destructuring options with for maps
15:51arohner_http://clojure.org/special_forms
15:51arohner_can you give an example of what you want to do with return values to multiple arguments?
15:51arohner_that sort of sounds like another destructuring thing, but I'm not quite sure what you want to do
15:53unlinkI'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:54arohner_oh, are you looking for apply?
15:54arohner_(apply + [1,2,3]) => 6
15:56unlinkWhat I described I want is that.
15:56unlinkI *actually* want somethiing even simpler.
15:58unlinknamely cons
15:58unlinkO:-)
15:59arohner_:-)
15:59gnuvince_What is it you want?
16:11technomancywhy is there a separate function for getting a seq from an enumeration?
16:45cp2technomancy: because seq doesnt 'know how to' make a sequence from an enumeration
17:11dliebketechnomancy: yeah, what cp2 said -- specifically since a java enumeration doesn't implement the Seqable interface and has no seq method
17:12ChousukeIt'd be neat if Java had some way to have interface adaptors kind of like C++ concept maps :/
17:12ChousukeC++0x, that is :P
17:12Chousukeor is it C++1x nowadays
17:13cp2hrmm Chousuke ?
17:13cp2could you link me
17:14rhickey_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:14Chousukecp2: 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:16cp2ah
17:16cp2i see
17:16Chousukecp2: 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:16cp2oh right
17:16cp2neat
17:16cp2rhickey_: makes sense, i didnt consider that
17:50unlinkIs there a shorter form for (if a a b)?
17:50cp2if-let
17:50hiredmanor
17:51cp2o
17:51hiredman(or a b)
17:51cp2yeah
17:51unlinkI've been doing (let [[some-expr] [a]] (if a a b))
17:51unlinkOh, or sounds good. :-)
18:31unlinkI've got a (:gen-class) without a :name arg. How does it know what to call the class?
18:34hiredmanit names it after the namespace
18:39technomancyrhickey_: ah thanks; interesting.
18:39technomancythere'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:40cp2oh yeah
18:40cp2that reminds me
18:40cp2rhickey_: typo in the doc for enumeration-seq
18:40rhickey_technomancy: there are many things you can't make a seq from
18:40rhickey_,(find-doc "enumeration")
18:41rhickey_where's clojurebot?
18:41cp2down
18:41cp2 "Returns a seq on a java.lang.Enumeration"
18:42cp2should be java.util.Enumeration
18:42cp2nothing major
18:42technomancyright; 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:42technomancy*turned into a seq
18:44rhickey_cp2: fixed - thanks
18:58stuhoodhmm, it seems a bit of a wart that (sorted-set) takes values, and (set) takes a collection
19:00stuhoodah... i guess that is because there is a literal for sets
19:01rhickey_no, the comparable of is hash-set
19:01Chouserhash-set is the corollary.
19:01stuhoodgotcha... thanks
19:02cp2np rhickey_
19:55lisppaste8technomancy pasted "extract-jar" at http://paste.lisp.org/display/78858
19:56technomancyis there a more concise way to write the loop at the end of that function?
19:56technomancyI feel like there should be a better way to express that.
20:23hiredman(.close (reduce #(.write % %2) something-else (take-while #(not= -1 %) (repeatedly (.read sometihgn)))))
20:23hiredmanhmmm
20:24hiredmanthe .close is a bad idea, best to use with-open
20:24hiredmanerm
20:25hiredmanthe reduce function should be #(doto % (.write %2))
21:25unlinkWhat is the (:xyz ...) syntax? (with a keyword at the beginning of the parens)
21:26hiredmankeywords look themselves up in maps
21:27hiredmanthere is also an optional second argument
21:27hiredmanwhich is a default value to return
21:28unlinkSo how is (:xyz foo bar) evaluated?
21:29hiredmanuser=> (:a {:a 1 :b 2})
21:29hiredman1
21:29hiredmanuser=> (:a {:b 2} 1)
21:29cp2keys are functions of maps
21:29hiredman1
21:30unlinkSo (:xyz foo bar) is the same as (get foo :xyz bar)?
21:30hiredmanyes
21:30unlinkwhen foo is a map.
21:31unlinkOr are they really equivalent?
21:31hiredmanyes
21:31unlinkoh ok
21:32unlinkso (:import java.io.File) is the same as (get java.io.File :import) ?
21:32hiredmanit would be, except most likely you are seeing that inside the ns macro
21:33unlinkoh
21:33unlinkI am.
21:33hiredmanin that case (:import java.io.File) is (import 'java.io.File)
21:35unlinkI'm not really sure why there is a distinction in the language between symbols and keywords
21:36hiredmanjust a second
21:40hiredmanugh
21:41hiredmannot having my logs to grep through is such a pain
21:42hiredmanunlink, start here http://clojure-log.n01se.net/date/2009-04-15.html#15:36
21:44unlinkIntersting.
21:45hiredmanstops maybe around 15:59
21:47unlinkIs something wrong with me if I find Clojure is more intuitive than Scheme?
21:47unlinks/is //
21:48Raynesunlink: No.
21:48RaynesClojure rocks Scheme's world.
21:48unlinkI've always found Scheme very clumsy for things I want to do on a fairly regular basis.
21:48dreishClojure's design better conforms to the expectations of a programmer steeped in the languages that are popular right now.
21:49dreishI guess it might also be objectively better.
21:49unlinkI never made it past the "which CL implementation should I use?" hurdle so I'm not equipped to opine about CL versus Clojure.
21:52RaynesMy CL experience ended when I installed SBCL.
21:52unlinkIs 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:54Cark(doto (new MyObject) (.method param))
21:54Cark?
21:55unlinkheh. That's almost too good.
21:56Carkthis form will return your first object ... if you expect to get the result of calling the method ... you'd use ->
21:57Cark(-> (new MyObject) (.method param))
21:58hiredmanunlink, I think you scheme is showing in your let
21:59Carkyep there are many brackets there =)
21:59hiredmanyou must want (let [a 1] ...) not (let [[a] [1]] ...)
21:59unlinkwhoa.
22:00hiredmanbut the second form does work, it has needless destructuring
22:01technomancyhiredman: thanks; take-while looks like it could clean things up nicely
22:02technomancyhiredman: I don't understand why you use doto there though
22:03technomancyisn't doto just for when you're calling different methods many times on the same object?
22:03hiredmanbecause reduce needs to return the object you are writing to so you can write to it again
22:03hiredmanI mean, you could use #(do (.write % %2) %)
22:04technomancyoh, of course.
17:40hiredmanI haven't used compojure in some time, you might want to ask compojure specific questions on the compojure google group
17:40unlinkprobably
21:48msingh``is there any doc for using clojure within an existing java project. I would like to call clojure code from java..
21:49cp2http://markmail.org/message/tx23zaxf77b6widh
21:49cp2quick google brought that up
21:50cp2although, i would keep looking around
21:50msingh``thanks!
21:52msingh``the java interop docs work in the oppposite direction
21:52cp2yeah, i know
21:52cp2there was an example somewhere else i remember looking at
21:52cp2dont know where it is though, or what it was
21:56Carkhttp://berlinbrowndev.blogspot.com/2009/03/java-clojure-interoperability-calling.html
21:56cp2there you go msingh``
21:57msingh``sweet cheers :)
22:03msingh``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:04msingh``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:25Lau_of_DKHas anybody here had success emitting specific HTTP headers using Compojure/Ring ?
23:25AWizzArdI would also be interested to know more about this.
23:25AWizzArdBtw, Lau, what headers would you like to send?
23:26Lau_of_DKcontent-type "text/html" and Connection: close
23:26Lau_of_DKRigth now, no headers are being emitted, despite my best efforts, which is causes a cascade of problems
23:26Lau_of_DK(compojure.server.jetty/run-server {:content-type "text/html" :Connection "close"} "/*" myservlet) does not give me anything
23:28Lau_of_DK(GET "/text" [{"Content-Type" "text/plain"} "This is plain text." "And some more text."])
23:28Lau_of_DKWiki says so
23:30AWizzArdHmm, 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:30AWizzArdAh okay, in your GET you are also trying this.