#clojure logs

2010-10-02

01:28BahmanHi all!
01:29TeXnomancyallo
01:29TeXnomancysalut
01:30TeXnomancysunt eu, un haiduc 𝅘𝅥𝅮
01:31amalloybuenas mañana
02:13bobo_hm, cake autotest doesnt seem to always get the latest file when running tests?
02:14bobo_it detects my save, but says the error is still there
02:14bobo_lein doesnt agree
02:14bobo_and restarting autotest and it says no errors
02:14bobo_anyone else seen this? or is it just me
02:16TeXnomancybobo_: probably getting slimed?
02:16TeXnomancygot some leftover state
02:16TeXnomancylein test is meant for a sanity check, which is why it always starts a new JVM
02:16TeXnomancyit's pretty common for persistent JVMs like swank or cake to get leftover state that confuses things
02:17bobo_i dont like it :-/
02:17bobo_almost faster to run lein aswell
02:18TeXnomancyyou should always run tests with a fresh JVM before you check in
02:18TeXnomancybut there's totally a need for in-JVM tests too; that's what I use clojure-test-mode for
02:19bobo_yeh, its kinda pointless if it doesnt work =)
02:20bobo_il give clojure-test-mode a try
02:22TeXnomancythe sweet thing about clojure-test-mode is that it highlights the failures inside the test buffer
02:23TeXnomancynice instant-feedback
02:23TeXnomancybut restarting your cake JVM would probably un-wedge it too
02:25bobo_yeh, but it happens about 20% of every save
02:44tomojanyone know how many attendees the jvm language summit gets?
03:31amalloyi need to split a bunch of objects into sets, and would like it to be easy/fast to (a) see what objects are in a set, and (b) what set an object is in. it seems like immutability makes this easy task pretty hard; is there something i'm missing?
03:58quizmewhat's the version of clojure we should be using these days?
03:58quizmeclojure-1.2.0 ?
03:59quizmei'm reading a tutorial that references clojure-1.2.0-beta1
03:59tomoj1.2.0 is good
04:00tomoj1.3.0-alpha1 is out
04:00quizmeso 1.2.0 is "production ready" whatever that means ?
04:01quizmeanyway thanks i'll go with 1.2.0
04:01tomojit's stable and kinda new
04:24amalloyquizme: i'm using 1.2.0 and i'm happy with it
04:24quizmeamalloy thanks
04:25quizmei'm doing the ring tutorial
04:25quizmehttp://pastie.org/1194970
04:25quizmebut i'm getting : java.lang.Exception: Unable to resolve symbol: header in this context (core.clj:15)
04:25quizmecuz i'm trying to use the header function
04:25quizmein ring.util.response
04:26quizmehow can i use that function ?
04:26quizmei tried ring.util.reponse/header but that didn't work: java.lang.Exception: No such var: ring.util.response/header (core.clj:15)
04:28quizmeand when I do "lein repl" now, it says it's listening on localhost:X where X is an integer. It didn't do that before.
04:29quizmeso i can telnet to it now. what's the advantage of that ?
04:37raekquizme: first, have you added ring to you project.clj?
04:37quizmeraek yes
04:38quizmehttp://pastie.org/1194993
04:38quizmeraek: http://pastie.org/1194993
04:40raektry with the 0.3.1 version
04:40quizmeraek: ok.
04:43quizmeraek: http://pastie.org/1194995
04:43quizmeraek: i did lein clean; lein deps; lein repl; and got that
04:44raekstrange
04:44raekdo you have any files in classes/?
04:44raekif so, delete them
04:44raekquizme: 'header' was not in the example, but in the docs, right?
04:44quizmeraek: it's empty
04:45raekcheck that the lib/ dir is empty too
04:45quizmeraek: yeah, it wasn't in the tutorial. I added it becaue I want to modify the headers.
04:45quizmeraek: lib is full of stuff
04:45raekso, it was probably added after 0.2.0
04:45raekok, delete all that
04:45quizmeraek: ok.... so it's not my syntax i guess
04:45raekno, just lib versions, I think
04:46quizmeok i removed the stuff from my lib/*
04:46quizmenow doing lein deps
04:46raeknothing strange with your code
04:46raekstrange, I thought lein clean should clear the lib/ dir
04:46quizmeraek ok good thanks
04:47quizmei upgraded from an older lein version
04:47quizmei'm on lein 1.3.1 i think
04:47quizmehttp://pastie.org/1194997
04:48quizmeso i did lein deps
04:48quizmeand it seems to be copying cached versions of the jars
04:48quizmeto lib/
04:48amalloyquizme: blow away ~/.m2?
04:48amalloythat's where it keeps the cache
04:48raekbut the different versions are separate jars
04:48raekI think you had both versions in lib/ before
04:48quizmeraek yeah
04:49quizmeamalloy: i blew them away last night, so they're pretty fresh
04:49quizmeraek: ok hope so let's try...
04:49quizmei'm getting that big long stack trace again
04:50quizmemaybe i did something funky with my classpath ?
04:50quizmehttp://pastie.org/1195002 <-- the stack trace
04:51quizmei thought lein handles the classpath issues for you
04:52raekyes, it does
04:52raekthis is some weird errors with strange jars
04:52raekwhich java version do you run?
04:52raekjava -version
04:54quizmejava version "1.6.0_20"
04:54quizmeJava(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
04:54quizmeJava HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)
04:54raekyoulc you paste your current project.clj?
04:54raeklooks good
04:54raekthese kind of errors can be the result of using conflicting versions of libs
04:55quizmehttp://www.pastie.org/1195006
04:55raekfor example clojure 1.2 with contrib 1.1
04:55raekhrm, use clojure 1.20 instead
04:55quizmeok
04:55raek*1.2.0
04:56raekthat *should* work since I used the same libs last night...
04:56quizmei did lein clean
04:56quizmebut it's not removing the contents of lib/
04:56raekbad lein...
04:56raekdelete all lib/*
04:57quizmeok
04:57quizmerepl started
04:57quizmeit says listening on localhost:46962
04:57quizmedoes that mean i should telnet to it?
04:57quizmeor should i just use it at the prompt
04:57raekyou dont' have to
04:57raekyou can use both
04:58raekthe repl server is just an extra
04:58quizmei did this
04:58raekhaven't used it myself
04:58quizme(use 'ring-tutorial.core)
04:58quizmebut it's just hanging there.
04:58quizmeit says
04:58quizmenil
04:58quizmethen hangs
04:58quizmei can hit enter
04:58raektry evaluating 1
04:58quizmebut i'm not getting the user=> prompt
04:58quizmeoh yeah
04:58quizmeit evaluated
04:58raeksometimes, I have seen that the prompt doesn't appear after the ifrst command
04:58quizme^^;
04:59quizmeok
04:59raekthought that was a temporary bug...
04:59quizmeseems to be ok
04:59quizmelemme try to boot
04:59raekI mostly use slime
04:59quizmebooted
04:59quizmethanks
04:59raekI should probably create a ticket for thay
04:59quizmelet's see if the header was modified
04:59raeknp
05:01quizmeraek thanks a lot for your help. I think i got it from here. Cheers!
05:01quizmei'm out...
05:41ldhanson2I have a sorted-set (of vectors, which appears to sort by the first element of each vector, which is what I want). I do a 'replace' on it, but I get back a LazySeq which is no longer sorted. how do I retain the sorted-ness of this set across a 'replace'?
05:43amalloy,(into (sorted-set) (map inc (range 5)))
05:43clojurebot#{1 2 3 4 5}
05:43amalloyldhanson2: ^^
05:44amalloynot exactly elegant, but it works :P
05:45amalloybut i'm off to bed now, so someone else will have to tell you a better way
05:46hoeck,(-> (sorted-set [3 2] [1 2 3] [4]) (disj [3 2]) (conj [3 2 1 0]))
05:46clojurebot#{[4] [1 2 3] [3 2 1 0]}
05:46hoeckldhanson2: to me it appears vectors in a sorted set are sorted by their length
05:47hoeckldhanson2: using disj and conj on a sorted set will maintain its sortedness
05:48ldhanson2great, i'll try that
05:48hoeck,(sorted-set-by #(< (first %1) (first %2)) [3 2] [1 2 3] [4])
05:48clojurebot#{[1 2 3] [3 2] [4]}
05:49hoeckldhanson2: ^ is a set sorted by the first element of the contained vectors
05:50ldhanson2perfect. the behavior i was seeing must have been coincidental
05:50hoeck,(sorted-set-by #(< (nth %1 0 0) (nth %2 0 0)) [3 2] [] [4])
05:50clojurebot#{[] [3 2] [4]}
05:51hoeckldhanson2: ^ that one is actually better as it also handles [] and nil
05:52ldhanson2excellent
05:55ldhanson2related question: i'm writing a unit test to demonstrate my assumption about a set's sort order. how can i assert that the ordering of two sets is the same?
06:08hoeckldhanson2: you could check wether they have the same comparator
06:09hoeckor do sth. like http://gist.github.com/607516
06:12hoeckmaybe additionally check each set being (sorted? s)
06:20raekI think it simply keeps them sorted lexigraphically (like words of letters are sorted: if prefix is the same, sort by next letter. empty string is sorted before any other letter)
06:23raekdisregard that... I found an counterexample:
06:23raek,(sorted-set [2 1] [3])
06:23clojurebot#{[3] [2 1]}
07:13opqdonutis clojure useable on Android?
07:14opqdonutoh, there's clj-android, sweet
07:16octeif i have one namespace with a (def foo "foo") in it
07:16octeand in another namespace do
07:17octe(ns lol (:require [first.ns :as first]))
07:17octeshouldn't i be able to access foo as first/foo?
07:18hoeckocte: right, you should
07:18hoeckmaybe a typo, does first.ns/foo work?
07:22octenope, it does not
07:26hoeckno such var exception or a class not found ex. ?
07:27octeno such var
07:27octecould it be because there's a circular dependency?
07:29hoecknot shure but I think you get a different error, unknown namespace error or so
07:29octeslime can complete symbols in the namespace
07:30hoeckand when you do a (require 'first.ns :reload) ?
07:30octeo such var
07:30octe:(
07:33octei refactored it instead
07:35hoeckocte: then it was that circular dep :)
07:36octeyeah
08:38AWizzArd~seen rhickey
08:38clojurebotrhickey was last seen quiting IRC, 2029 minutes ago
08:38AWizzArd,(/ 2029 60.0)
08:38clojurebot33.81666666666667
08:38AWizzArd,*1
08:38clojurebotjava.lang.IllegalStateException: Var clojure.core/*1 is unbound.
09:51webushi to all
09:52webuswhat do you think about literate programming ?
11:26TeXnoman`raek: the prompt flushing bug was fixed just last night
11:27TeXnoman`octe: there's a patch in to detect circular dependencies with a better error message: http://www.assembla.com/spaces/clojure/tickets/8-gc-issue-3-%09re-enable-detection-of-circular-loads
13:42LauJensenHas anybody had problems with (with-session) in converting a Jetty app to a Tomcat servlet?
13:54AWizzArdMy Clojure serialization lib is using recursing to serialize nested objects. This can possibly run into stack overflows. How often do you work in practice with objects that have more than a few ten thousand levels of nesting, and then want to save such things?
13:57LauJensenNever...
13:58kzarSo it's been a while since I played with Clojure, I'm trying to install the latest versions of everything and get it working with Emacs again. Last time I set it all up I used ELPA and it worked really well but this time I'm having problems, is ELPA still the way to go?
13:58AWizzArdLauJensen: yes, i also don't have that
13:58mrBlisskzar: yes
14:00kzarmrBliss: Which guide is the best to follow? I've tried a few and I haven't had swank working. I was hoping to get to the point where M-x slime launches it all and M-x slime connect lets me connect to one that's already running
14:01LauJensenkzar: Im having some trouble with clojure 1.3, so make sure you stay away from that while experimenting
14:02AWizzArdLauJensen: what kind of trouble?
14:02LauJensenAWizzArd: The kind where lein swank wont even start
14:02kzarLauJensen: OK, I was trying to get it working with 1.2
14:02mrBlisskzar: don't know any recent ones: but I usually install clojure-mode, slime and slime-repl from ELPA
14:02AWizzArdI found a new number bug in it, I should update an issue about it
14:02mrBlisskzar: If you want to use M-x slime, maybe you should try installing only swank-clojure
14:03mrBlisskzar: I've heard that it installs slime etc for you (haven't tried it myself)
14:03kzarI get "java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1)" when I do M-x slime and slime keeps trying to connect until I do a M-x slime-abort-connection
14:08LauJensenprogn? Are you on Emacs 21 or something?
14:09mrBlisskzar: you're trying to execute Elisp code in Clojure
14:12kzarmrBliss: Hmm I don't get how, I just typed M-x slime
14:12kzarLauJensen: No 23
14:13LauJensenok. mrBliss is right, you're calling elisp in java. Im so numb to stacktraces now I apparantly dont even see them anymore :)
14:14mrBlisskzar: What did you install?
14:14kzarOh here's something: (progn (load "/home/kzar/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.5733" :coding-system "iso-latin-1-unix")) that's at the start of the *inferior-lisp* buffer
14:16kzarmrBliss: I deleted ~/.emacs.d/ and then I installed elpa and using that clojure-mode and swank-clojure I think
14:17kzarwhat's your inferior-lisp-program set to?
14:18mrBlisskzar: can you check if slime and slime-repl were automatically installed? I stopped using swank-clojure from ELPA a while ago, so my inferior-lisp-program is actually "lisp"
14:20kzarok inside ~/.emacs.d/elpa/ I see archive-contents, builtin-packages, clojure-mode-1.7.1, slime-20100404 package.el, slime-repl-20100404
14:20mrBlisskzar: looks fine. I use cljr (playing with clojure) or lein (doing a project), so I never use M-x slime, always M-x slime-connect. Actually I have some elisp that does this for me (M-x lein-swank and M-x cljr-swank)
14:23kzarmrBliss: Good idea, although if I use M-x slime-connect I'm not sure how to start the server because lein swank doesn't work anymore
14:24mrBlisskzar: make sure you have [swank-clojure "1.2.1"] listed under :dev-dependencies and do a 'lein deps' in the project folder
14:33LauJensenmrBliss: Do you use swank-clojure 1.2.1 with clojure-1.3.0-master-sNAPSHOT?
14:33kzarbrb
14:35mrBlissLauJensen: no, I haven't tried the 1.3 snapshots yet, still using 1.2 until beta1
14:36LauJensenk
14:38mrBlissI'd like to see a new release of swank-clojure though, I've seen many improvements in my github notifications since 1.2.1.
14:38kzarOK M-x slime-connect is working now, thanks for the help. In the end I made a project called scratch and just use that to launch lein swank. In a way it's a shame you have to make a project to do that. I made a script to load that project but for some reason even though I've set inferior-lisp-program to run it and port 4005 is opened slime never manages to connect. But at least running the script from a shell and the
14:38kzarn doing slime-connect isn't too bad
14:40LauJensenkzar: some people actually prefer that
14:40mrBlisskzar: I open a file of the project, M-x lein-swank and voila a REPL for my project. http://github.com/mrBliss/dotfiles/blob/master/.emacs.d/clojure.el#L79 The same for cljr-swank, because cljr actually is a leiningen project.
14:40kzarLauJensen: Yea, me too sometimes but it's crap to be forced into it
14:41LauJensenah nice mrBliss, love your elisp-fu
14:41kzarmrBliss: Cool thanks for sharing
14:42mrBlissI can't take credit for everything, there was some copy-pasting involved ;-)
14:43LauJensenmrBliss: There always is
14:48raekkzar: cljr is just that... a global scratch project
14:52kzarraek: heh yea, I guess that's the problem / appeal heh
14:56mrBliss(gonna see a movie now bbl)
14:56kzarcya thanks for the help
15:07kzarIf you want to add a dependency to a lein project but you have no idea which version of the dependency to use what would you do?
15:08LauJensenUse the latest
15:10LauJensenHow does the Ring Session Middleware work with Tomcat ?
15:14raekkzar: check its project.clj at github/other hosting
15:24LauJensenIs the memory-store not compatible with Tomcats container model ?
15:34tomojhmm, why wouldn't it be?
15:34tomojjust an atom
15:35LauJensenIt is. My problem has something to do with Moustaches middle-ware strategy
15:35tomoj(I'm actually asking, not trying to answer your question.. I dunno shit about tomcat)
15:35tomojisn't moustaches middleware strategy the same as anything else's?
15:35LauJensentomoj: AFAIK its the only one which has true nesting of routes and middle-wares
15:36LauJensen(app ["app2"] (app ["app3"] (app middleware1 "handler1-app3")....
15:36tomojmoustache dsl got be all confused for a while
15:36tomojs/be/me
15:36LauJensenoh?
15:36tomoje.g. the syntax file seems to suggest you can return a raw response map
15:37tomojbut this doesn't seem to be possible
15:37tomojwell, not from directly in app I mean
15:37LauJensenYou can
15:37LauJensenI mean, handlers are functions, but those functions can returns maps
15:37LauJensen[""] (constantly {:body "Hello"})
15:37tomojI guess constantly would work
15:37tomojheh, yeah
15:38tomojI always ended up separating out into named functions which bugged me
15:38LauJensenOh, I like that
15:38LauJensenOnly for very small apps do you want to keep it inline
15:38LauJensenimo
15:38LauJensenline
15:38LauJensen[""] render-front-page
15:38LauJensen["login"] render-login-page
15:38LauJensenand so on
15:38LauJensenlooks nice
15:41tomojhave you abstracted away from a standard set of "REST-ful" endpoints yet?
15:42LauJensenNo - Which standard sets are you thinking of ?
15:43tomojwhichever one you happen to use
15:43tomoje.g. we use GET /resource, GET /resource/id, POST /resource, PUT /resource/id, ....
15:44tomojI was using compojure, but didn't really see any good opportunities for abstraction even though I still felt like I was writing boilerplate
15:44LauJensenI didn't abstract from a standard set, but I did mold it into something which made sense for the app
15:45raektomoj: [""] [{:body "Hello"}]
15:46tomojraek: huh
15:46raeknote the extra square brackets
15:46tomojcool
15:46raekotherwise, it's a method dispatch map
15:46tomojwhat do the square brackets mean there?
15:46raeknested app
15:46tomojI see
15:46raekraw response maps cannot be the RHS of a route
15:47tomojright
15:47tomojhttp://moustache.cgrand.net/syntax.html says differently though
15:47tomojafaik
15:48tomojwell
15:48raekhandler-main can be a sequence of route + shorthand-or-handler
15:48raekor a literal response map
15:48tomojI guess if that's EBNF the parse with a literal response will just be ambiguous?
15:48raekshorthand-or-handler can be a method dispatch map
15:48tomojand the actual implementation always chooses method-dispatch
15:49raekwell, no. at the shorthand-or-handler position, maps always mean method dispatch
15:49tomojoh
15:49tomojso I just misread the grammar
15:49raekit's tricky to read...
15:49arohneris there a way to tell maven to download and install a single file, from the command line?
15:50raekit utilizes maps and vectors in any way possible
15:50tomojhow do we tell the difference between a method-dispatch and a literal response map at handler-main?
15:50raeka method dispatch map will always be preceded by a route
15:50tomojraek: successfully, you think? or does it just get confusing? maybe I just didn't stick with it long enough
15:51tomojoh, method-dispatch isn't a map, I see
15:51tomojjust the innards of the map
15:51tomojthanks!
15:52raekoh, I misread the synatx too... (in another way) :-)
15:53LauJensenmispelled it as well :)
15:54raekah, no. it seems that my useage of method dispatch was correct after all in my case: "Besides when the right-hand form is a method dispatch without middlewares you can write the form as a map"
15:54tomojLauJensen: you find app forms to be easy to read and write?
15:55raekhandler-main -> method-dispatch | (route shorthand-or-handler)+ | ...
15:55raekshorthand-or-handler -> {method-dispatch} | ...
15:56raekso both [""] [:get ...] and [""] {:get ...} are allowed...
15:57tomojcool
15:58raekthe routing syntax of moustache migth be complex, but at least it has a formal definition
15:59raekLauJensen: sorry, "might"
16:04tomojhttps://gist.github.com/655c34875e3aef2afd9c O_o
16:04tomojthis is like the stuff in the recent "clojure faster than machine code?" post
16:04LauJensentomoj: Yea. For both Moustache and Enlive the experience was the same: Took a little time to understand the system, but once you get it you dont want to change a thing
16:05LauJensen(well, there is a couple of things)
16:05LauJensenBut they are really brilliantly put together and easy/intuitive to use once you understand them
16:08tomojLauJensen: ok
16:08tomojI will try it again sometime
16:13amalloytomoj: where did that gist come from? it's absurd
16:14tomojamalloy: it's from a minecraft 3d cave explorer called minecraft-xray
16:14LauJensentomoj: man thats horrible lisp code
16:15tomojI think it's doing something like this http://www.learningclojure.com/2010/09/clojure-faster-than-machine-code.html
16:15tomojI don't really understand that post yet
16:16tomojI feel like I have created a similar monster
16:17LauJensentomoj: You should ask Christophe what he thinks about pre-mature optimization if you ever get the chance :)
16:17tomojhttps://gist.github.com/bfe2264c4e44b164a3c5
16:17LauJensenhehe
16:17tomojthe macro parser unrolls the dsl into a giant case statement with the entire code for parsing each packet type unrolled
16:18tomojso I've got all these ~'data-in everywhere
16:18ninjuddbobo_: cake test -r will force a restart
16:18LauJensentomoj: You writing a game ?
16:18tomojbecause the parse code for each packet type is just stored as a literal map
16:18tomojno...
16:18tomojthe game already exists (minecraft)
16:18tomojI am just trying to interoperate
16:19bobo_ninjudd: but i want autotest
16:19LauJensenoh ok
16:19tomojit's this binary format where the first byte you read specifies the packet type, and each packet type has basically a list of java types to read out of a datainput stream
16:20tomojbut sometimes the length of one field will depend on the value of a previous field
16:20ninjuddbobo_: working on integrating lazytest which should fix the problem
16:20bobo_ninjudd: ah, nice
16:20tomojso I had to unroll the field parsing to let statements
16:21tomojhttps://gist.github.com/fba67c111138cb9e938b here's the macros
16:21tomojcan you tell it's a monster just by looking at it?
16:22tomojI have a feeling there is a much simpler and more effective way to do this, I just stumbled through making this until I found something that worked
16:24bobo_ninjudd: btw, when does it start a new vm? when i use cake from another terminal? i noticed earlier i suddenly had 5 jvm's running. and my computer was out of ram :-)
16:26amalloybobo_: it searches up the path looking for project.clj files; if the associated project has a jvm it uses that, otherwise it starts a new one
16:26amalloy(if it doesn't find one it uses ~/.cake)
16:26tomojwhat if the jvm from the first command in the one terminal hasn't finished starting up yet?
16:26bobo_it was the same project.clj in all of them
16:28LauJensentomoj: Aren't you the guy who owes me a screencast?
16:28tomojLauJensen: yes
16:28LauJensen[======== ] 80% ?
16:28tomojLauJensen: like I said, don't hold your breath
16:28amalloybobo_: i just tested it by opening two ssh sessions to my clojure machine and starting cake repl in the same directory from each of them; it didn't start a new vm the second time?
16:28tomojI haven't quite achieved enough paredit mojo to do the screencast
16:29LauJensenk
16:29tomojone of these days soon I will sit down and transcribe all of my paredit knowledge so I can figure out how to make the screencast
16:29bobo_i notices railscasts the other day, 233 screencasts on rails. someone should make that for clojure =)
16:29amalloywhat is tomoj supposed to be screencasting for us?
16:29bobo_amalloy: the different terminal thing was a question, it has just happend once, and i have no clue what i did.
16:30LauJensenamalloy: He's the guy who'll convince me that paredit isn't training wheels for Emacs kids
16:30amalloyLauJensen: well...i like paredit...but i'm an emacs kid, so not a great argument there
16:30LauJensentrue
16:33LauJensenamalloy: But in all honesty, there are veterans who use it as well
16:33amalloyyep, i know. otherwise i'd try to learn not to use it
16:44tomojLauJensen: what was your issue again? nice while writing, painful while going back and refactoring/editing code?
16:44LauJensenyep
16:48amalloyi've actually found it really useful for editing. eg just the simple M-s and C-( for wrapping and unwrapping sexps save me a bunch of paren-hunting
16:49bobo_you simple have to make one screencast each to show your points :-)
16:49LauJensenOdd, I never go paren-hunting
16:50tomojLauJensen: sorry, what resolution again do you recommend?
16:50tomojI will write it down this time
16:51LauJensentomoj: np. I think I told you the last time that I usually go for 800x600, but I dont think its optimal. Camtasia and iMovie go for something like 1180x10xx ? Im not sure
16:51LauJensentomoj: I think Vimeo has an entire page on formats you can read through
16:52ninjuddtomoj: if the jvm hasn't opened the port yet, it kills it
16:52tomojah
16:58LauJensenDoes anybody here have some experience with having Tomcat serve static files ?
17:14jjido,(flatten {:a 33 :b 55 :c 11})
17:14clojurebot()
17:16LauJensen,(sequential? {:a 33 :b 55 :c 11})
17:16clojurebotfalse
17:21jjido,(into [] {:a 33 :b 55 :c 11})
17:21clojurebot[[:a 33] [:b 55] [:c 11]]
17:21jjido,(flatten (into [] {:a 33 :b 55 :c 11}))
17:21clojurebot(:a 33 :b 55 :c 11)
17:21jjidowow :)
17:22jjido,(flatten (into nil {:a 33 :b 55 :c 11}))
17:22clojurebot(:c 11 :b 55 :a 33)
17:23jjido,(apply ident {:a 33 :b 55 :c 11})
17:23clojurebotjava.lang.Exception: Unable to resolve symbol: ident in this context
17:23jjido,(apply identity {:a 33 :b 55 :c 11})
17:23clojurebotjava.lang.IllegalArgumentException: Wrong number of args (3) passed to: core$identity
17:24jjido,(apply concat {:a 33 :b 55 :c 11})
17:24clojurebot(:a 33 :b 55 :c 11)
17:27jjidoI am not there yet... I used (fn [a & {:as amap}] ...) and I want to call it having a map in hand. I don't like doing (apply myfunction a (apply concat mymap))
17:43scottjdon't quite follow, maybe replace {:as amap} with just amap
17:44tomojjjido: that's the problem with [& {:as amap}]
17:44tomojwhy not just use [a amap] ?
17:45jjidotomoj: the interface of the function is nicer with &{:as amap}
17:46jjidoI could change it to & alist
17:46Chousukeor you could write a kwapply function
17:47Chousukethat works like apply but takes a map and expands it into keyword args
17:51Guest97534I have a question, is there a way to get a sequence of visited terminals, while walking through a form? clojure.walk seems to ONLY do find/replace ops... (basically, I want to count the occurances of a symbol in certain forms)
17:51hiredmanhave a look at clojure.zip
17:52hiredmanor even tree-seq
17:53Guest97534Is there a way to make a zipper from a form given to a macro?
17:55Guest97534These seem geared towards node functions... I'm not sure how they would work in a macro context
18:00Guest97534OK: thanks for the tips, it doesn't seem that hard to use them in a macro-context like so : (tree-seq list? identity '(+ (3 4) 3))
18:01Guest97534That gives a traversal of the form, I believe.
18:43jjidoChousuke: do I need to test it receives the right kind of data?
18:43jjidoChousuke: (defn kwapply [function & args] (apply function (apply concat (butlast args) (last args))))
18:44Chousukewhy are you doing it like that?
18:44jjidoChousuke: I felt clever doing it that way ;) What is a good way of doing it?
18:47amalloyjjido: it sounds like i joined in the middle of an interesting discussion. what's the "wrong" way?
18:48jjidoamalloy: (defn kwapply [function & args] (apply function (apply concat (butlast args) (last args))))
18:49jjidoamalloy: that is like apply, but it takes a key-value map and expands it into :key value...
18:51Chousukejjido: I was just thinking of a simplle (kwapply f map) but I suppose that works too.
18:52Chousukeexcept for infinite arg sequences :P
18:52jjidoChousuke: would be pervert to call apply with infinite aruments?
18:52jjido*g
18:53Chousukeapply with infinite arguments is just fine
18:53Chousukeas long as the function works with infinite arguments.
18:54ossarehvery happy to be a clojure hacker today :) (having just returned from the realm of javascript)
18:54Chousuke,(take 10 (apply concat (partition 2 (range))))
18:54clojurebot(0 1 2 3 4 5 6 7 8 9)
18:55jjidoChousuke: you didn't
18:55amalloyjjido: i guess i see what kwapply does, but why do you want to do it? there aren't really that many functions that want a list of k/v pairs, are there?
18:55Chousukehmm
18:56jjidoamalloy: I wrote one. It initialises a record by copying the bindings provided in the argument list.
18:58Chousuke,(take 2 (apply apply concat (partition 2 (range))))
18:58clojurebotjava.lang.StackOverflowError
18:58jjidoChousuke: looks like you did it :)
18:59amalloyjjido: i made a macro for doing something similar that you might find interesting: http://gist.github.com/608075
19:00jjidoamalloy: I am not good with macros (ie., looking at your code makes my head ache)
19:03amalloyjjido: updated the gist with an example usage
19:04jjidoamalloy: yeah that is similar to my code then
19:05amalloywell, but mine takes a map instead of & kvs, so you wouldn't need kwapply
19:06amalloy(also the performance is way worse than calling the actual constructor, so don't do this in anything where speed matters)
19:09jjidoamalloy: is it an advantage that it takes a map? I like having one set of { }s less
19:09jjidoamalloy: I copied my code here: http://gist.github.com/608085
19:12amalloyjjido: but you have just as many {}s, don't you? (kwapply myfunc arg1 arg2 {:opt1 10 :opt2 "test"})
19:13jjidoamalloy: no I do not use kwapply for that, I use it in the function that passes key-values to another function
20:11jjido,(~:count)
20:11clojurebotjava.lang.IllegalStateException: Var clojure.core/unquote is unbound.
20:46amalloy,`(~:count)
20:46clojurebot(:count)
20:46amalloyjjido: ^^
20:47jjidoamalloy: I was looking at the wrong thing :P I wanted
20:47jjido,(keyword 'count)
20:47clojurebot:count
20:48jjidois it possible to get rid of the ' ? Are function arguments always evaluated?
20:49amalloyfunction arguments are always evaluated. if you need them to not get evaluated, that's what macros are for
20:49jjidoamalloy: ok I need a macro then
20:49ataggartalternately you can use delay
20:50ataggartthough probably not what you want
20:50jjidoWould be nice if I could write (call* y head) instead of (call* y 'head)
20:51amalloyjjido: i can't def things in #irc, but try: (defmacro kw [name] `(keyword '~name)) (kw count)
20:52amalloyit delays the evaluation of count until it's had a chance to put a ' in front of it
20:54jjidoamalloy: and if I want one of the args of my macro to be evaluated? (because it is used twice in the macro body)
20:55jjidodo I do a (let) before ` ?
20:55amalloy(defmacro [eval-me] `(let [val# ~eval-me] [val# val#]))
20:55amalloyyou can do a let before the `, but it won't be able to evaluate eval-me - that's happening at compile time, and it won't have a value yet
20:56jjidooh I see
20:56amalloyeg, eval-me will be (+ 1 2) instead of 3
20:58jjidoamalloy: are there special rules for varargs macros?
20:59amalloynope. macros are just like functions, except that their arguments aren't evaluated, and their return value is expanded inline
20:59jjidoie. can the additional arguments be inserted without apply?
21:00amalloyyou mean like: (defmacro make-list [& elts] `[~@elts])? i think that works
21:01amalloyyeah, it does
21:03jjidocool :)
21:03amalloywell. this isn't a cure-all to avoid apply, though
21:04jjidoamalloy: I was writing a macro anyway :)
21:04amalloyeg, this won't work: (let [elts [1 2 3 4]] (make-list elts))
21:04jjido(defmacro call* [obj, getter & args] `(let [var# ~obj] (((keyword '~getter) (class* var#)) var# ~@args)))
21:04jjidoamalloy: doesn't it create a single-element list?
21:05amalloyyes, it creates the list [[1 2 3 4]]
21:05jjidothen it works ;)
21:05amalloyheh, okay
21:06amalloyjjido: hm, neat
21:07KirinDaveIn Let Over Lambda they detail some very cool macro hacks to do eval-once macros.
21:07coldheadalso that book is abbreviated LOL
21:07coldheadit even says LOL on the cover
21:08KirinDaveYup.
21:08amalloyKirinDave: but we barely need those in clojure. the gensyms are forced on us and un-painful, so it's only the initial let that could be made easier
21:09KirinDaveamalloy: The single-evaluation part would be smart to port in.
21:09KirinDaveThe other stuff is basically to give you what clojure already has with sym#.
21:10amalloyKirinDave: but you'd have to leave the current feature present; it's hard to generalize what kind of eval-once functionality people want
21:12KirinDaveIt's not hard at all.
21:12KirinDaveMaybe I'll put it in the book.
21:12KirinDaveIt's a very useful macro.
21:14amalloyi haven't read LOL, though i saw an eval-once macro in PCL or some similar book online, and it's not clear to me what the feature would even look like in clojure. what do you envision the ideal use-case being?
21:14KirinDaveFacilitating single-evaluation.
21:16KirinDaveIt's very useful in macros. Most of the time in clojure people sidestep the issue by using (fn ...), in my experience.
21:16KirinDaveSince clojure is so functional, you can sneak around.
21:17amalloyKirinDave: i mean, a concrete example. i'm a dev who wants to write a macro with your eval-once feature, what should my code look like?
21:17KirinDaveIt'd just be like sym#
21:17KirinDaveYou'd say, maybe sym@
21:18KirinDaveWhich means that the sym@ params passed to the macro will be (let [sym@ form] ...) before further macro processing.
21:19KirinDaveAs for why you'd want to use it...
21:19amalloyKirinDave: i see. you imagine them being evaluated once, immediately before being used?
21:19KirinDaveYes.
21:20KirinDaveLet's say one of your macros takes a function param and splices that in.
21:20jjidoKirinDave: why not allow sym# in the arg list?
21:20KirinDaveIf you dont' single-eval it, the function gets redefined.
21:20KirinDavejjido: sym@
21:20KirinDavejjido: Becuase that's the only place it makes sense and that the macro can act.
21:20amalloyi was trying to sort out the order in which they're evaluated if there are more than one of them, but i guess if you don't let until they're used it's likely to be right most of the time
21:20KirinDaveYou only care about collapsing evaluation for injected forms.
21:21KirinDaveBecause those are the only ones where you don't know what the implications of multiple evaluation are.
21:21KirinDaveamalloy: Convention is to go left-to-right on the args list.
21:21KirinDaveLet over lambda is an insanely good book, even if you want to just do clojure.
21:22KirinDaveA lot of chapters you can and will just skip
21:22KirinDaveBut a lot of it is printed gold.
21:22amalloyKirinDave: damn it, don't make me order books while there are already some in the mail
21:23KirinDaveLOL is a better book even that the MOP book.
21:26jjidolike that? (defmacro example [x y@] (if (> ~y 0.5) (+ ~x (* 2.0 ~y)) (+ ~x 1.0)))
21:27jjidoI like better: (defmacro example [x y#] (if (> y# 0.5) (+ ~x (* 2.0 y#)) (+ ~x 1.0)))
21:27amalloyseriously though: (cond false param@, :else param@), vs (cond false param@, false param@). how can your gensym function be smart enough to get both of these right in the case where param has side effects?
21:28amalloyin the first case it needs to wrap the cond with a let; in the second it needs to wrap each param with a let
21:29jjidoamalloy: if you use that, you should expect a single let shouldn't you?
21:30amalloydamn it, i guess i'm wrong there too; in the first case it can still just wrap each param. but there are places where you have to wrap a containing form, and in the second example you need to wrap each param@ to prevent them being evaluated if the conds fail
21:31jjidoit can get pretty hairy
21:31KirinDaveamalloy: The thing@ semantics are "it will be evaluated once and the result used everywhere"
21:31KirinDaveThat's important with things that might be expensive or need identity.
21:32jjidoKirinDave: like memoization?
21:32KirinDaveUm, sure. But at a lexical level
21:32amalloyKirinDave: sure, i understand. are you saying that it will be evaluated regardless of what's in the macro body? i thought the idea was to not eval them unless their code is executed, in which case eval them exactly once
21:32KirinDaveNo, @ means you'd always evaluate.
21:32KirinDaveCode tracing is too much work.
21:32KirinDaveBut clojure has laziness and promises, so it's no big deal
21:33KirinDaveMake the form a future and bam
21:33hiredmanyou'd want delays
21:33hiredmanfuture's are always run
21:33hiredmanon another thread
21:33amalloyi see. that's not too hard then, and i guess saves some code
21:34hiredmanif you bind the name to a delay then replace the name in the code with a force of the delay it will only be eval'ed once
21:34KirinDaveSure.
21:34KirinDaveHeck
21:34hiredmanKirinDave: are you modeling the webmachine graph via just function calls?
21:35KirinDaveyes, for now
21:35KirinDaveTeh stack depth only can hit 25 in the worst case scenario.
21:35KirinDaveSo I think it's okay
21:35hiredmanhave you thought of using some kind of stream processing library like, say, conduit?
21:36KirinDaveNo.
21:36KirinDaveWould that be valuable?
21:37hiredmanit would be neat
21:37KirinDaveWhy?
21:37clojurebotwhy not?
21:37hiredmanit's very graphy
21:38KirinDaveWanna see what I have now?
21:38KirinDaveit'll be open source soon, so I don't mind showing you what's in the pipe.
21:38hiredmanhttp://gist.github.com/608171 is an example of what the first column might look like
21:40hiredmanI am curious, but I don't know if I am that curious
21:43jjidohiredman: is a-comp / pass-through a macro?
21:45hiredmanno
21:45hiredmanthey are all functions
21:46KirinDaveWeird
21:46KirinDaveYou'd think they'd be part of a macro for a compiler.
21:46KirinDaveThat could do things like detect where function boundaries Must be.
21:46hiredmanwhy??
21:47hiredmanconduit is based on an arrows implementation in clojure that models arrows as maps
21:47KirinDaveI do't know if I fully understand that arrows thing.
21:48hiredman*shrug* I don't claim to either but it hasn't stoppped me from writing a lot of conduit code
21:48anonymouse89I'm trying to find an equivalent clojure statement to the Java: Foo[] foos = bar.toArray(new Foo[bar.size()]);
21:48KirinDaveSo what's the value add of conduit over what I am doing, now that you've seen it?
21:48anonymouse89but do not know how to do the "new Foo[bar.size()]" portion
21:49KirinDave,(doc make-array)
21:49clojurebot"([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
21:49hiredmanKirinDave: you don't need to write big macros
21:50KirinDavehiredman: Is my macro hard to read?
21:50anonymouse89sorry for the silly question
21:50hiredmanI dunno, it just seems a lot more complicated
21:51hiredmanI'm not familiar with webmachine so I could be missing something
21:51KirinDavehiredman: Please elaborate. I'm a common lisp guy, so I tend to approach things syntactically.
21:51amalloyanonymouse89: is there a reason you need to use java arrays? if so KirinDave's answer is definitely right, but if you can stick with clojure data types you'll probably be happier
21:51hiredmanhttp://gist.github.com/608183 you can do nodes like this
21:52KirinDaveWell the rub is that some of the states will not be simple test nodes.
21:52KirinDaveSome of them actually have logic.
21:52KirinDaveWhich is where has-body? comes in.
21:52clojurebotgroup? is http://groups.google.com/group/clojure
21:54hiredmanthe graph is transitions based on true/false are you not implementing the graph?
21:54KirinDaveUp to where I have the graph implemented it's simple true-false.
21:54KirinDaveSome of the deeper nodes have more to do.
21:54hiredmanI am looking at the image of the graph
21:54KirinDaveyeah
21:54hiredmaneverything is true/false red/green
21:54KirinDaveSo an example is the node I am up to.
21:54KirinDaveOPTIONS
21:54KirinDaveThat's gotta prepare a response.
21:55KirinDaveAnd there are a few ways I could do that.
21:56hiredman(a-if options? two-oh-oh-ok c3), would take an input, apply the options? predicate, and if the result is true, pass the input on to two-oh-oh-ok and if false to c3
21:57KirinDaveHow does that library solve the forwards invocation problem?
21:57KirinDaveDoes it just not?
21:57hiredmanforwards invocation?
21:57KirinDaveRight now I'm doing (ns-resolve ...)
21:57KirinDaveSo that you don't have to define the graph in reverse order.
21:58hiredmanyou can solve it the same way you do with functions
21:58hiredmanusing declare
21:58KirinDaveI hope that, at least, is something people do with a macro.
21:58hiredmanbut I would just do it in reverse
21:59hiredmansince that seems more natural
21:59KirinDaveTo go from finish to start?
21:59hiredmanno
21:59hiredmanto build up
21:59hiredmanfrom basic nodes to nodes that depend on those nodes
22:02KirinDaveI may keep it as functions permanently, either way
22:02KirinDavebecause I can just annotate the functions with metadata.
22:02hiredman*shrug*
22:02KirinDaveBut thanks for mentioning conduit. It's interesting.
22:03hiredmansure
22:05hiredmanthere isn't an http transport for conduit atm but I know jim is interested in getting one and I have been thinking about what that might end up looking like
22:06anonymouse89amalloy: yeah, unfortunately I'm having to deal with Java libraries directly
22:18KirinDavehiredman: Are you involved with the conduit project?
22:24hiredmanKirinDave: I work with jim at sonian and did a conduit transport for hornetq
22:25KirinDaveAh.
22:25KirinDaveI didn't know you were also @ sonian.
22:25hiredmandid? doing? as far as I know it's working but I have yet to use the hornetq transport anywhere
22:25KirinDaveI was interviewing with them.
22:26hiredmanright I think tim mentioned