#clojure logs

2010-01-19

00:00defnseen _ato?
00:00defnclojurebot: seen _ato?
00:00clojurebotno, I have not seen _ato
00:00defnon freenode you can do a nickserv info on the nick
00:00derridadefn: well, i can't create one using that swank-project command
00:00defnderrida: create one?
00:00derridadefn: so i just used an existing project i downloaded
00:01derridahttp://sprunge.us/VZMU
00:04defnderrida: get rid of the repositories line in the file, as well as that 2nd :dev-dependencies [[lein-clojars...]] line
00:04defnthat shouldn't be necessary
00:05derridadefn: thats the one you told me to add?
00:05defnno i told you to add the swank-clojure line
00:05defnnot the other one
00:05derridaohhhh
00:06defnchange org.clojure/clojure "1.1.0-alpha-SNAPSHOT" to "1.1.0-master-SNAPSHOT"
00:06defnrun lein deps again
00:06defnrinse, repeat
00:07derridahm
00:07derridastill not working
00:08derridais it a problem that clojure 1.0 is being used with 1.1 contrib?
00:08derridawoah this is the java line starting the repl: java -classpath /home/derrida/.clojure/clojure-1.0.0-SNAPSHOT.jar:/home/derrida/.clojure/clojure-1.2.0-master-SNAPSHOT.jar:/home/derrida/.clojure/clojure-slim-1.0.0-SNAPSHOT.jar:/home/derrida/.clojure/clojure-slim-1.2.0-master-SNAPSHOT.jar:/home/derrida/.clojure/clojure-slim.jar:/home/derrida/.clojure/clojure-sources-1.0.0-SNAPSHOT.jar:/home/derrida/.clojure/clojure-sources-1.2.0-master-SNAPSHOT.jar:/ho
00:13derridadefn: i think i found it
00:16derridanah. same stuff http://pastie.org/784329
00:16derridaoh well, it's been fun
00:26alexyksomnium: I recompiled the heck out of clojure/contrib/leiningen congomongo and can no longer use it :(
00:27alexyksays can't locate somnium/congomongo.clj on the classpath
00:27alexykI see that congomongo.jar has src/clj/congomongo.jar
00:27alexykhow is it being added to classpath as somnium/congomongo.clj?
00:30defnderrida: wish i could be of more help, but im not sure what you're trying to accomplish
00:30derridai want to use clojure tha way i use clozure
00:31defnim not familiar with clozure so you'll need to be more explicit
00:32derridadid you ever use slime prior to clojure?
00:33derridai use it as an integral part of my development process where i'm really interacting with my code (as i code/while i code)
00:33alexykderrida: http://data-sorcery.org/2009/12/20/getting-started/
00:33derridaafaict, this is just a clojure repl inside of emacs?
00:34derridaalexyk: that sounds very promising from the first sentence :>
00:34derridaalexyk: i assumed that had to be the case which is why i'm feeling a bit unraveled by the whole thing
00:35alexykyeah, stick to your current editor or use a careful setup guide
00:35derridadefn: more specifically, i will compile a file (derrida.lisp) [C-c C-k]
00:35derridaalexyk: ? i love emac
00:35derridas
00:35alexykah ok, sry
00:36derridadefn: then, from the slime-repl, i'm able to access the running code
00:37derridadefn: currently, this is not happening and beyond just not happening emacs goes into a state of "constant polling" where it seems to just be endlessly trying to connect to the repl
00:38technomancyderrida: how are you launching slime?
00:38derridawhen i hit [C-c C-k] for .1 second i see it say [Not Connected] in the minibuffer
00:38derridaM-x slime
00:38technomancyderrida: what's the content of ~/.swank-clojure?
00:39derridathe three jars that were installed by elpa (which didn't work) so i tried adding the root folder of swank-clojure in there also and had the same result
00:39derridacurrently looks like this: clojure-1.1.0-master-20091202.150145-1.jar clojure-contrib-1.1.0-master-20091212.205045-1.jar pom.xml README src/ swank-clojure-1.1.0.jar target/
00:40technomancyderrida: are you on an older build of Emacs maybe?
00:40hyp3rvigi1antderrida: i was having the same problem with slime...sometimes it would eventually connect after it polled for a few dozen times, but most of the time it would poll for hundreds of times with no results
00:40derridagit pull
00:40derridatechnomancy: ^^
00:41derrida(about the git pull)
00:41derridahyp3rvigi1ant: i wasn't going to say but i could have sworn it's connected a few times here too :)
00:42derridai just assumed ihad accidentally started clozure instead
00:42technomancyderrida: all your deps seem to be in place, but maybe you could try just rm -rf ~/.swank-clojure and try again?
00:42derridasure
00:42technomancyusing swank-clojure and slime from elpa?
00:42derridayeah, everything from elpa
00:42hyp3rvigi1anti just tried it again now, and it's polled almost 250 times already, with no connection...but when i start swank using lein, and i connect to it from emacs, it works fine
00:42derridai totally wiped emacs to get a clean slate
00:42technomancyhmm... I can't repro
00:43technomancynever heard of that problem before
00:43derridagoogle cropped up some results
00:43derridano answers
00:43derridahyp3rvigi1ant: well, that's very interesting
00:43technomancynot finding clojure.lang.RT means it's a problem with Clojure, not with Swank or Emacs
00:43hyp3rvigi1antI'm on Ubuntu using GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.18.3)
00:43hyp3rvigi1ant of 2009-11-10 on vernadsky, modified by Debian
00:43hyp3rvigi1antUbuntu 9.10
00:44derridahow do you start swank from lein?
00:45derridai have added nothing to my .emacs btw?
00:46alexyksomnium: pinggg
00:46derridatechnomancy: what are you saying?
00:47hyp3rvigi1antderrida: lein swank
00:47hyp3rvigi1antyou need to have [leiningen/lein-swank "1.1.0"] and [swank-clojure "1.1.0"] as dependencies in your project.clj file
00:48derridaso you would do this for each project you were working on?
00:48hyp3rvigi1antthat's what i do...i've been using lein since earlier today, though, lol...not a pro
00:49derrida:)
00:51hyp3rvigi1anti do have swank-clojure jar-path, jar-home, and classpath set in my .emacs file...not sure if i have it set correctly or anything, though
00:52derridatechnomancy: afaict that error is not saying it can't find clojure.lang.RT .. it's saying it can't find the swank class
00:53derridatechnomancy: it's the standard ClassNotFoundException
00:56technomancyderrida: java.lang.NoClassDefFoundError: clojure/lang/RT (swank.clj:0)
00:56derridahttp://java.sun.com/j2se/1.4.2/docs/api/java/lang/NoClassDefFoundError.html
00:56derridais this a different error?
01:03derridahyp3rvigi1ant: would you mind showing me those lines from you .emacs
01:05hyp3rvigi1antderrida: here's what it is currently: http://pastie.org/784366
01:06derridathank you
01:06hyp3rvigi1antnp
01:14alexyktechnomancy: how do I tell lein to start swank on a specific port?
01:22technomancyalbino: it should accept it as a command-line argument
01:22albinookay
01:22defnStreaking
01:23defnlol, oops
01:36woobyhello, i can't seem to get leiningen to recognize the 'swank' task
01:36tomojdid you add lein-swank to the dev-dependencies?
01:37woobyi've added swank-clojure to dev-deps, would anyone happen to know if there's something else i need to do?
01:37woobyaha
01:37tomojyes, see the README.md in lein-swank/ for the details
01:37tomojthough, back when I tried it last (which was a while ago) it didn't work right
01:38tomojwhen I slime-connect'd, the classpath wasn't set up right, so that I couldn't compile with C-c C-k
01:38woobyah
01:38tomojthat may have been a problem with my setup or it may have been fixed since
01:39woobyi had it working at some point myself
01:43woobywee, took some tinkering but it's working now
01:43woobythanks again tomoj
01:46tomojsure
01:46tomojI should try it again sometime
01:46tomojthere is a small probability that I might get to use clojure in the wild for backend processing :D
01:46tomoj(I currently prefer haskell or erlang :/ but those are even smaller probabilities)
01:47replacaQ: how do I get clojure-mode/slime to indent a macro's body form without telling it explicitly? I thought if I sent the macro to the slime buffer that would do it
01:48technomancyreplaca: that's not implemented in the clojure backend currently, only for CL
01:49technomancyreplaca: the correct answer is "name your macro with-*"
01:49technomancy=)
01:49replacatechnomancy: ahh, ok. memories from the old days :-)
01:50replacawith-* would be a bad name for my macro :). It's a variant of for that makes maps
01:50replacasparing me infinite into {}s
01:51replacasuddenly this week (for ...) and (merge-with ...) are my best friends
01:51technomancymerge-with is awesome
01:52replacaindeed. I'm in the midst of gluing multiple two-level maps together into three level maps
01:53replacatrying to figure out what's happening with thousands of our machines after they leave our factory
02:10woobyhm, anyone ever get "java.lang.Error: can't load apple.laf.AquaLookAndFeel" with swing on mac?
02:41defnwooby: sorry no -- someone did a tutorial on swing + mac not too long ago
02:41defncheck disclojure.org -- that's probably your best bet
02:43woobydefn: thanks, i managed to fix it... custom swank stuff conflicting with elpa
02:43woobyelpa's swank that is
02:45defnwooby: ah
02:45woobynow i'm cookin' ;)
02:45woobythanks anyways, and goodnight
03:25LauJensenAnybody putting in work on clojure-android?
03:49quizmeIf i have a string like "{:a 1, :b 2}" how do I read that string as data?
03:49quizmei want to say something like (def x (eval "{:a 1, :b 2}"))
03:51quizmei want that Java string to be converted into a hashmap.
04:00LauJensen,(read-string "{:a 5 :b 10}")
04:00clojurebot{:a 5, :b 10}
04:01unfo-cool! didn't know that
04:01unfo-it's good to hang out here :)
04:01spariev_quizme: also see http://stackoverflow.com/questions/1885448/how-do-you-evaluate-a-string-as-a-clojure-expression
04:01quizmeok thank you
04:03quizmeread-string ... that's what i wanted. thanks
04:05LauJensennp
04:14defnjust a note to anyone who has been dragging their feet: The Joy of Clojure is absolutely the Book to Buy
04:15defnit doesn't try to be "learn clojure in 24 hours", which is sort of how I felt while reading through pragprog's clojure book
04:16defnchouser is undoubtedly the guy to be writing a book on clojure -- absolutely awesome job
04:16esjdefn: agreed its a knockout
04:17esjreally helping me understand the Tao of Clojure
04:18gkoIs Joy of Clojure for 1.0 or pre-1.1 ?
04:19defnnot sure where it's at -- they have about 4 chapters done, and the first four chapters is better than anything ive read
04:20defn100+ pages for 4 chapters, with a TOC that boasts 14 IIRC
04:20defnit's going to be a monster reference
04:22esjwhat am I misunderstanding here:
04:22esj,((set '(1 2 3 4 5)) 3)
04:22clojurebot3
04:22esj,((sorted-set '(1 2 3 4 5)) 3)
04:22clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number
04:22esj:(
04:23esjwhy can a sorted-set not be used as a predicate for its members ?
04:32dnolen,((sorted-set 1 2 3 4 5) 3)
04:32clojurebot3
04:32dnolenesj: ^
04:32esjinteresting ! thanks.
04:33euwyndefn: thanks for the heads up on the joy of closure. was just working through pragprog.
04:33dnolen,((apply sorted-set '(1 2 3 4 5)) 3)
04:33clojurebot3
04:44esj,(class (sorted-set 5 1 4 2 3))
04:44clojurebotclojure.lang.PersistentTreeSet
04:44esj,(class ( sorted-set [5 1 4 2 3]))
04:44clojurebotclojure.lang.PersistentTreeSet
04:45esjso this is a laziness effect in constructing the sorted-set, I guess.
04:54maaclIs there a swank-clojure command to execute tests? I am using swank-clojure-project
04:57technomancymaacl: sure, clojure-test-mode
04:57technomancyit's another library to get from elpa
04:57maaclAh - thanks
04:58technomancyyou might run into a bug installing it; if so just rm -rf ~/.emacs.d/elpa/swank-clojure before installing clojure-test-mode and it will reinstall swank-clojure
04:58technomancyI've fixed the package.el bug, but it hasn't made it out to the repos yet
04:59maacltechnomancy: thanks - it will work from the actual code buffer - or do I have to switch to the buffer that contains the tests?
05:00technomancyit has to be from the test buffer
05:03maacltechnomancy: would be hard to add the capability to swank-clojure-project to run tests in /tests - it think that would be very useful
05:03maacltechnomancy: maybe also autorun tests if anything changes in the src tree
05:06LauJensentechnomancy: Is there a swank-clojure-bleeding-edge which clones, builds and installs ?
05:07technomancyLauJensen: once you have a checkout, lein install should be enough for the java side
05:07technomancybut coordinating the elisp side with the java side is really hard
05:07technomancy*jvm side
05:07LauJensenoh really?
05:08LauJensenI thought all you had to do was issue a command and wait for a return code
05:34derridais it just me or does maven seem ungodly slow a lot of the time? heh
05:35derridahttp://dpaste.com/147356/
05:35harblcatthis is an out-of-the-blue question, but would anyone know of any board-game engines in clojure?
05:40harblcator really, any sort of material at all on the subject? I've looked at something called "Zillions of Games", and the way to make a new game is to use something akin to lisp (specialized s-expressions), so it shouldn't be too hard to do the same in clojure.
05:41LauJensenharblcat: for all things related to gaming I recommend having a look at JMonkeyEngine
05:43harblcatLauJensen: it is a java library?
05:46LauJensen~google jmonkeyengine
05:46clojurebotFirst, out of 6440 results is:
05:46clojurebotjMonkeyEngine.com
05:46clojurebothttp://www.jmonkeyengine.com/
05:46LauJensenYes sir - You need to make some kind of interface, I did one ages ago
05:47LauJensen~sofiaba
05:47clojurebotsofiaba is http://wiki.github.com/Lau-of-DK/sofiaba
05:47LauJensenIts in a state of bitrot, but you'll see how easy it is to initialize a full 3d world with dynamic water, lighting etc
05:47harblcatLauJensen: thanks a lot!
05:48LauJensenah I see the URL has changed http://github.com/LauJensen/sofiaba
05:49LauJensenUnfortunately I no longer had the screenshots - they were gorgeous
05:49LauJensenclojurebot: forget sofiaba
05:49clojurebotI forgot sofiaba
05:51harblcatwoah, grappling hook was made in that engine. I didn't even know..
05:55LauJensenSomebody made a massive 12 (?) part tutorial, showing how to build a capture the flag race-game, a must-read
05:58harblcatI've got a lot of studying to do, I think :)
05:58harblcatthanks again!
06:00LauJensennp
06:00LauJensenBut just to be clear, if what you just need a simple board game ala checkers - Maybe rolling your own isn't a bad idea
06:00LauJensen(I'd hate to waste your time)
06:22lypanovhey rhickey
06:22rhickeylypanov: hi
06:25angermanis it a good idea to span hundrets of agents? or should I better keep an agent pool around the size (e.g. 4 times the system's cores)?
06:25djpowellagents aren't threads - the functions that you dispatch to them run on a thread-pool
06:26rhickeyangerman: depends on what they are doing, if computation, not much reason to have more than ncores
06:26rhickeybut send takes care of that
06:27angermanrhickey: I'm pulling data from a database table, process it, and send it of to some writer-agents, that write the data to the according file
06:27rhickeysend-off will create many, which makes sense if some are blocking, doing nothing
06:27rhickeybest idea if there is some I/O in the mix is to put a knob on it
06:53angermanWell I used to have a dispatch agent, that was set up as watcher over all the worker agents.
06:53angermanand when ever a workeragents state changed, it assigned a new task to the agent, until the task queue was empty
06:56angermanand I was just wondering if it was simpler to just create an agent for each task and wait till all are done
07:00angermanmaybe futures are what I'm looking at?
07:01LauJensenagents carry state, futures launch seperate threads, conceptually they are different
07:02angermanIf I send multiple tasks to an agent, the agents works them down one by one, right?
07:22LauJensenYes
07:26LauJensenAt least thats how I understand http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/Agent.java#L240
07:26angermanLauJensen: I ahve 1300 taks to be completed.
07:27angermanI guess a straight forward approach would be to partition them on size n
07:27angermanand have n agents work down those taks.
07:27LauJensenWhat are the tasks?
07:27angermanThe issue I'm facing though is that the time for each task may vary. And thus in the end I have n-1 agents done and one agent still crunchin away for some time to be
07:28angermanLauJensen: read data from the database according to a query, process the data and send it off to be written out to a file
07:28LauJensenAre we talking 10ms tasks or 10min. tasks?
07:29angerman5-10min
07:29angermanmaybe some are 1 min.
07:31LauJensenrhickey: What did you mean when you advised him to put a knob on it ?
07:32rhickeyLauJensen: make the number of agents used a variable/argument to the process
07:33angermanrhickey, LauJensen: ok, that makes sense so far.
07:33rhickeyangerman: the true answer to irregular task processing times is something like fork/join
07:33angermanI'm still not so certain how to implement a mechanism to chew down a queue in parrallel.
07:33angermanI'm luck though that I don't need the returnvalue.
07:35LauJensenI'm wondering if rhickey approach won't just result in behavior very similar to (pmap #(process-task %) tasks)
07:35angermanLauJensen: I guess I'm looking for a pdoseq
07:36LauJensenangerman: (dorun (pmap)) should do fine then
07:36LauJensenI think if you let 500 agents loose they'll just crater your I/O performance
07:37angermanHm. But pmap does have an synchronization overhead, right?
07:38LauJensen~source pmap
07:39rhickeypmap's sliding window is pretty handy, you might need to partition first in order to create large enough work units
07:40angermanrhickey: so you basically mean glue 3-5 tasks together
07:41rhickeyangerman: it depends on how much work is in one task, no need to do that unless pmap is slower than map
07:41angermanrhickey: each task takes between 1min and 10min
07:42rhickeybut you still have issues with irregular task times, as pmap won't get far ahead of a slow task
07:42rhickeyangerman: oh, then pmap overhead is nothing relative to those times
07:42angermanHm. I'll try pmap
07:42rhickeypmap overhead can be a problem when the job is: +
07:43rhickeyangerman: a problem with pmap for you might be that your jobs are I/O bound, not computation bound, is that correct?
07:43angermanwell. the sql server runs locally. so it's mostly cpu bound
07:44rhickeywell, if I/O bound you can actually benefit from having more threads than cores, to a point
07:44rhickeysubject to your I/O system
07:45angermanI'll try and see how the system-meter looks
07:45LauJensenrhickey: since pmap will wait for a lingering task, perhaps its best just to settle on 4, 8 or 16 threads and feed them tasks as they finish, that way pmap wont just wait
07:45rhickeywhere do the tasks come from?
07:46rhickeyLauJensen: 4/8/16 = knob
07:46djpowell(I have some slow IO from clojure being processed by some java, and dragging stuff through a LinkedBlockingQueue seems to work well for me)
07:47LauJensenangerman: How long do you expect the total processing time to be ?
07:47rhickeydjpowell: yes, I was just about to recommend stuffing work in queue, then having a set of futures each of which loops taking one job from queue until done
07:48rhickeyas long as the jobs come from a known place in advance, vs being the results of other jobs
07:48angermanLauJensen: at least a night
07:49angermanrhickey: no. I know them in advance
07:49LauJensenangerman: If this is an ever growing dataset you're working on, maybe you should consider making it a map-reduce job and running it on Hadoop ? That'll clear any scheduling concerns you might have
07:49angermanLauJensen: It's for now a one-shot
07:50LauJensenAh ok
07:50angermanworking with MicroArray Data is just painful at best
07:51LauJensenThis is where Rich jumps in saying "Pain, does not exist, in this Dojo! DOES IT?" :)
07:51LauJensenAnd Chouser goes "No sensei!" :)
07:52angermanHm. It's not clojure specific.
07:52rhickeyangerman: then you can have one future fill a LBQ http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/LinkedBlockingQueue.html with a fixed capacity, and N other futures looping pulling out a job and doing it
07:53rhickeyworkflow => queue
07:53djpowellI guess you need to put N 'poison' objects into the queue after the data, so that the consumers can shut themselves down
07:53rhickeydjpowell: no, they shutdown when no job to pull
07:53angermanIf I know the size I need in advance, I can just create a queue of that size right?
07:54rhickeyangerman: no, you probably don't want all jobs in memory at once, just use a capacity a bit larger than the number of workers
07:54angermanrhickey: I'm having the jobs in a list already. (?)
07:55rhickeylbq ctor takes a capacity, when the queue reaches that size the producer blocks
07:55rhickeyangerman: if it already fits i nmemrory, then stick into lbq with no bound, that's fine
07:55djpowellrhickey: how will the consumers no that there is no job to pull? won't they just block forever?
07:55angermandjpowell: using poll
07:56djpowells/no/know
07:56rhickeypoll, not take
07:57djpowellwhat if the producer is dead slow though? the consumer might take the last one before the producer has added the next
07:57rhickeydjpowell: that's not angerman's situation
07:58djpowellah ok - sry - wasn't really paying attention
07:58angermandjpowell: using a global flag to indicate the producers state?
07:58rhickeydjpowell: in the general case, non-infinite queues need termination messages, yes
07:59rhickeyangerman: usually you'd try to put something in the queue
08:00angermanyes, that's probably a better idea ...
08:00rhickeythen the protocol is: peek for termination, poll with timeout
08:01rhickeydon't remove termination, leave for others
08:02angermanhmm. how do I block for a seq of futures?
08:02rhickeyangerman: to know when you are done?
08:02rhickeyuse a countdown latch
08:02rhickeyhttp://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/CountDownLatch.html
08:03rhickeyhave launcher set it up with n set to number of workers, each worker counts down when done, launcher blocks on await
08:04angermanthanks
08:04rhickeyjava.util.concurrent's workflow stuff is very good, and works well with Clojure. I didn't wrap it, but should, since few people know about it
08:06djpowellangerman: 'Java Concurrency In Practice' is a good book if you want to learn about it.
08:07djpowellit is a bit overwhelming otherwise, knowing what to use when
08:07angermandjpowell: thanks. I've had abandoned java for years.
08:07angermanSometimes just using it under the hood in Matlab, to plug holes
08:15LauJensenrhickey: I was thinking of wrapping u.concurrent as well, but where in the eco-system does this fit compared to the fork/join stuff from par ?
08:17rhickeyLauJensen: j.u.c is workflow (queues/latches), cache-like collections, and exectutors. Only the latter overlaps with fork/join
08:17LauJensenOk, thanks
08:17rhickeythe big utility of j.u.c. for Clojure users is in the workflow
08:18rhickeyfork/join will be preferable to executors
08:19defnchouser: Your book is fantastic.
08:20LauJensenrhickey: I haven't digged into fork/join yet, but can their executors be combined with the workflow from util.concurrent ?
08:21rhickeyLauJensen: they can, it's all just threads under the hood. But like any thread pool, you have to be concerned about blocking starving the pool
08:21angermanhm. Did the agent logic change in 1.1?
08:24angermanI htink this http://pastie.org/784694 did work previously
08:25LauJensen(send printe....) typo ?
08:26angermanno, those came from typing of from head
08:26LauJensenah, the reader macro ^ is deprecated
08:27angermanbut depricated doesn't mean dead. right?
08:31_fogusdefn: On behalf of chouser, Thanks! :-)
08:55angermanToday is a bad day :(
08:57AWizzArduh oh..
08:57angermanthings just don't work out today for me.
08:58AWizzArdAre those things you have control over? Such as computer programs? ;-)
08:58angermanright now it's mostly clojure errors I'm having serious trouble to understand
08:59angermanDon't know how to create ISeq from: clojure.lang.Keyword in the (ns ... block)
09:00AWizzArdYou could delete everything from the file with the exception of the (ns ...) which is in the beginning. Then compile and see if it works.
09:00AWizzArdIf it does work then paste some parts of the other code back, and try again. And that way put more and more code back into the file.
09:01angermanhttp://pastie.org/784744
09:01AWizzArdIf it does not work then you have indeed an error in the (ns ...) form.
09:01AWizzArdWhy so many uses of :use?
09:01AWizzArdI suggest to have exactly one :use in the ns form
09:04dnolenangerman: that's probably an error in your own library your trying to include right? I removed those use exprs and it worked fine for me.
09:05angermanhm. I'll try to dig some deeper.
09:05AWizzArdyou can comment out all lines and bring them in one by one, seeing at what point the error pops up
09:06angermanAWizzArd: will do the bisection method :D
09:06angermannaj. paredit doesn't want me to comment-out
09:07chouser#_
09:07chouserput that before an expression to make it "disappear"
09:08dnolenangerman: that should only happen on the last expr because of trailing parens, you just need to move those extra parens down
09:10jcromartie#_ is just weird
09:10angermanThanks for all the help, there seems to be some serious issue on my side. I can (use '...) all of the libs with no problem. I'll better restart the repl
09:18angermanSorry. I was editing the wrong file and thus never got any sensible difference
09:19LauJensenDoes anybody know where _ato Alex Osbourne is camping these days?
09:33defnis there anything like nokogiri for clojure?
09:37defnchouser: i've been using #_ after reading your first few chapters
09:38defnchouser: great job on the book again -- it's exactly what I've been looking for
09:41chouserdefn: we mentioned #_ in the first we chapters?
09:41chouserMaybe I should read that book.
09:42esjchouser: yeah, I learnt about #_ from your book
09:43chouserAnyway, glad you're enjoying it. If you ever get a chance to work on a project with _fogus, I'd highly recommend you do. :-)
09:43_foguschouser: It's in the Style section ;-)
09:46esja pat and run ?
09:46chouserdrive-by back-pat
09:47angermando i need any special plumbing to use future?
09:48chouser,(let [x (future 5)] @x)
09:48clojurebot5
09:48cgrandI've been mulling over the idea of using #_(namespaced/symbol yadi yada) as a way for tools (mainly IDEs) to add structured comments and markers. eg #_(tools.annotations/review "this is displayed as a post-it" :author "someone")
09:49chousercgrand: huh!
09:49chouserI have a couple snippets of code with #_"comments like this"
09:49defn#_TODO
09:50angerman,(let [t (for [n (range 5)] (future n))] t)
09:50clojurebot(#<Object$IDeref$Future$2b9be1f9@13b2b95: 0> #<Object$IDeref$Future$2b9be1f9@1aa7618: 1> #<Object$IDeref$Future$2b9be1f9@2f4356: 2> #<Object$IDeref$Future$2b9be1f9@edd295: :pending> #<Object$IDeref$Future$2b9be1f9@19c4d4b: :pending>)
09:50_fogusI love using #_ in these ways which is why I added it to the comments section... but I think I should add a few extra words regarding using it alongs these lines.
09:51defn,(#_let #_[t (for [n (range 5)] (future n))] #_t)
09:51clojurebot()
09:51defn#_ is like a fork lift coming to take away your form
09:52defnmaybe a snow plow
09:52chouserheh. nice. I like fork lift
09:52qbgIt is a bottomless hole with a sign warning about it from the wrong side
09:52_fogus,(let [x (future (do (Thread/sleep 5000) (+ 41 1)))] @x) ; ... 5 seconds later
09:52clojurebot42
09:53angermanI must not mix future and loop?
09:53defnhi _fogus -- nice book
09:54chouserthere's nothing wrong with that.
09:54_fogusdefn: Thanks!
09:57stuarthallowayirc4019
10:01stuarthallowayanybody have a function that takes a lazy seq of input-streamable things and exposes it as a single inputstream?
10:02chouserhow would you close such things?
10:03stuarthallowayeach one closes as it is consumed
10:04stuarthallowaylike contrib read-lines does
10:06stuarthallowaystop me now if I am crazy...
10:07cgrandsomething built on java.io.SequenceInputStream?
10:07chouserthe way read-lines closes things makes me nervous
10:07stuarthallowaythat's where I am headed
10:07stuarthallowayand it has the close semantics I am describing
10:08stuarthallowayfor my use case I think SequenceInputStream will be find
10:08stuarthallowaythe number of seqs to push together is small, but the individual seqs are larg
10:09defnclojurebot: skynet?
10:09clojurebotI will become skynet. Mark my words.
10:10jkdufairsuggestions on why println on other threads does not print on stdout in clojure box on windows?
10:11chouserjkdufair: did you check your inferior-lisp buffer?
10:11defn*print-readably* can technically change between threads right?
10:12defnoops nevermind
10:13chouserwhat's a better name for a clojure-lint tool?
10:14defnhm
10:14defnflint
10:14defnit's functional
10:14defnfunctional lint
10:14chouser:-)
10:14jkdufairchouser: thank you!
10:14chousernot bad
10:15angermanOk, now I'm getting a Rejected Execution Exception
10:15defndid you have a name in mind?
10:15chousernope
10:15ohpauleezchouser: are you making a clojure lint?
10:15chouserohpauleez: mulling it
10:15angerman,(def printer (agent nil :meta {:out *out*}))
10:15clojurebotDENIED
10:16angerman:D
10:16ohpauleezI've wanted one for awhile
10:16datkaA clojure lint would be a great tool
10:16chouserran into a bug in my code yesterday that took way to long to track down.
10:16defnchouser: glint would also be acceptable I think -- fewer google results to compete with also
10:16defngive out or reflect small flashes of light : her glasses were glinting in the firelight.
10:16chouserI'm not sure, but I think a lint-like tool would have helped (if I had thought to run it. :-/ )
10:17datkaClijnt
10:17esjljnt
10:18ohpauleezCKB - Chouser|Clojure Killin' Bugs
10:18defnTijnt
10:18somniumEastwood (clojure -> lint -> clint)
10:19ohpauleezthis is looking like a Notorious BIG song, and less like tizzool :)
10:19angermanclojure 1.1.0 is stable right?
10:19defnaye
10:20chousersomnium: oh, nice.
10:20angermanwhat's the appropriate line for the project.clj?
10:20somniumchouser: in the spirit of Leiningen :) (kind of)
10:20defnangerman: [org.clojure/clojure "1.1.0-master-SNAPSHOT"]
10:21angermandefn: hmm. I'm using that.
10:21stuartsierra1.1.0 is in maven central now
10:21angerman*clojure-version* -> {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "alpha"}
10:21angermandoes that match?
10:21Raynes(defmacro with-thread [& forms] `(.start (Thread. ~@forms))) Weeee, mah first macro.
10:22stuartsierraRaynes: that won't actually work
10:22defnangerman: try "1.1.0"
10:22defnbedtime
10:22defnnight all
10:22ohpauleeznight
10:22angermandefn: contrib as well?
10:22stuartsierraangerman: I'm working on numbered contrib releases, stay tuned
10:23angermanstuartsierra: thanks.
10:24angermanwhat's the supposed *clojure-version* string for 1.1.0?
10:26Raynesstuartsierra: That isn't surprising.
10:26dnolenhow does one type hint types created by deftype ?
10:27angermanhttp://pastie.org/784871
10:27angermanhm
10:27angermanI dont' get why
10:27Raynesdnolen: #^Nameoftype seems to work.
10:31spariev_angerman: do you use emacs+slime ? if so, check the version of lein-swank, should be 1.1.0
10:32angermanspariev_: I found lein to load the old clojure. So I fixed that
10:32angermanStill I cannot use my printer agent
10:32angermanI'm sure it used to work
10:33angermanor is there an issue with my code? (http://pastie.org/784871)
10:35angermanI can't even execute "(pmap #(* % %) (range 0 10))"
10:36spariev_angerman: I was just about to suggest checking that )
10:36spariev_I had the similar exception trying to use pmap in slime, upgrading lein-swank in project.clj fixed my problem
10:37spariev_like, :dev-dependencies [[leiningen/lein-swank "1.1.0"]]
10:37angermanyep, that's exactly how I have it
10:38chouserangerman: looks like you may have already shut down your agent pool?
10:43rhickeyaargh, this fn metadata ended up being a huge deal - now I've got to optimize compiled metadata storage, complete sidetrack
10:46jcromartiehmm, is (decorate ...) broken right now in compojure?
10:46jcromartiejava.lang.IllegalArgumentException: No method in multimethod 'update-response' for dispatch value: class clojure.lang.Var
10:47jcromartiehttp://gist.github.com/281015
10:48stuartsierraWho runs the build server at tapestry.formos.com?
10:48jcromartiehitting any of my routes results in an the exception posted above
10:49jcromartieah wait I think I get it
10:49jcromartie(decorate) is not meant to be used inline like that, right?
10:52stuartsierra~seen dysinger
10:52clojurebotdysinger was last seen quiting IRC, 242 minutes ago
10:53rhickey~seen devlinsf
10:53clojurebotno, I have not seen devlinsf
10:53triddellstuartsierra: probably Howard Lewis Ship, or hlship in irc I believe
10:53triddellstuartsierra: creator of tapestry and clojure fan
10:53stuartsierra~seen hlship
10:53clojurebotno, I have not seen hlship
10:54angermanhmm. seems like leiningen was interfering with the libs form the leiningen checkout
10:54stuartsierratriddell: thx
10:55rhickeysean's latest video, Abstraction Grafting, left me puzzled. All of the multimethods were variadic, but clearly only took one arg
11:08stuartsierrarhickey: just looking at the code, maybe he wants to allow variadic forms like (date 2010 1 19)
11:10rhickeystuartsierra: I don't understand
11:10rhickeywon't that just convert 2010 into a time?
11:11stuartsierraas it's written now, yes
11:11stuartsierraI don't really understand either
11:13AWizzArdWhy does Clojure not use githubs issue system? I am just curious, no criticism or suggestion to use it.
11:14stuartsierraAWizzArd: rhickey liked Assembla, that's all
11:15AWizzArdSo, github is just the store for the central repositories, while assembla is for the project management, issue tracking and so on, while the official homepage is for documentation and collecting all basic information.
11:16stuartsierrapretty much
11:17AWizzArdok
11:18lypanovhey headius
11:19headiuslypanov: hello there
11:22headiuslypanov: oh yeah? likin you some lisp?
11:24lypanovheadius: it was either scala or clojure and rich did a neat devoxx talk, so clojure it is.
11:24lypanov:P
11:25headiuswell, there's certainly less syntax to learn
11:29the-kennyAnyone who can tell me the type of Urlencode which translates + to %252B ? (I think it's a java-thing)
11:31_fogus,(java.net.URLEncoder/encode "+")
11:31clojurebot"%2B"
11:31the-kennyTried that, with every encoding mentioned in the doc
11:32_fogus,(java.net.URLEncoder/encode (java.net.URLEncoder/encode "+"))
11:33clojurebot"%252B"
11:33the-kennyWow
11:33chouseroh dear
11:33the-kennyLooks like Google Wave is recursive
11:33the-kenny:D
11:33_fogusdouble secret encoding. ;)
11:34lypanovmore security! we use ssl twice!
11:35chouser,(take 5 (iterate #(java.net.URLEncoder/encode %) "+"))
11:35clojurebot("+" "%2B" "%252B" "%25252B" "%2525252B")
11:35chouserinfinite security
11:36_fogusLooks more like lazy security to me :p
11:36the-kennylol
11:38jcromartiethat's hilarious
11:38jcromartiep.s. you can include wacky things in a compojure route-param if you URL-encode it
11:38jcromartielike an email address
11:38jcromartieit's ugly as sin but it works
11:49krumholt__hi. how would i define a lazy-seq of all natural numbers with lazy-seq?
11:50chouser(defn incs [i] (lazy-seq (cons i (nums (inc i)))))
11:50chouser(incs 1)
11:51Raynes,(take 5 (lazy-seq (iterate inc 1)))
11:51clojurebot(1 2 3 4 5)
11:51RaynesWas what I came up with.
11:51chouserRaynes: lazy-seq is doing nothing useful there.
11:51RaynesI just noticed that.
11:51chouserBut of course it's better to use iterate than what I did
11:51Raynes,(take 5 (iterate inc 1))
11:51clojurebot(1 2 3 4 5)
11:52krumholt__ok thanks
11:52RaynesThat's what happens when you fail to read the doc string. :>
11:52Raynes(defn incs [i] (iterate inc i)) ; Anyways.
11:53chouserRaynes: right, that's much better.
12:00lpetit,(take 5 (fn incs [i] (lazy-seq (cons i (incs (inc i)))))
12:00clojurebotEOF while reading
12:02lpetitgrr
12:02lpetit,(take 5 ((fn incs [i] (lazy-seq (cons i (incs (inc i))))) 1))
12:02clojurebot(1 2 3 4 5)
12:03lpetitor as devlinfs would say : (defn incs (partial iterate inc) :-)
12:03lpetitargh, must really go to sleep early today
12:04lpetit(def incs (partial iterate inc))
12:04lpetitgo to bed
12:24lypanovLauJensen: man i've lost days on this arch thing :P
12:25LauJensenIts good that you get some practice :)
13:02konrIs there a way to use a regexp to match but then return just part of it? something like (function #"value=\([0-9]*\)" "\1" "<tag value=30>") => 30 ?
13:02stuartsierrakonr: re-groups
13:08the-kennyIf you're parsing xml, I would recommend using a xml-parser :)
13:09alexykI've tried upgrading clojure, contrib and congomongo, and leiningen, and got a mess. E.g., this: java.lang.NoSuchMethodError: clojure.lang.RestFn: method <init>()V not found (coerce.clj:1)
13:09RaynesI thought that said circumcision.
13:10RaynesI parsed XML for the first time yesterday! :D
13:10alexykupon trying to (ns mongol (:use somnium.congomongo))
13:10the-kennyclojurebot: clojure.lang.RestFn
13:10clojurebotant clean and rebuild contrib
13:10alexykwhat's that error? trying 1.1.0 for clojure and 1.1.0-master-SNAPSHOT for c.c.
13:11Raynesalexyk: Last time I got that, it was because my contrib wasn't built against my clojure.
13:11alexykokok
13:11the-kennyalexyk: Are you building clojure and contrib from source?
13:11alexykthe-kenny: used to, but now want leiningen to get the right ones. Which c.c. does go along with clojure 1.1.0?
13:12the-kennyalexyk: Sorry, no idea. But if you're building contrib from source, try "ant clean" before this..
13:12the-kennyWait, I can tell you the lein-entries for one of my projects
13:12alexykok
13:12the-kenny[[org.clojure/clojure "1.1.0-alpha-SNAPSHOT"]
13:12the-kenny [org.clojure/clojure-contrib "1.0-SNAPSHOT"]]
13:13the-kennysorry for bad line-breaks
13:13alexykthe-kenny: I used to use alpha, now it's 1.1.0
13:13the-kennyoh wait, let me try it
13:13alexykthere was a message about versioning of c.c. today on build.clojure.org, but I guess lein looks at clojars
13:15Chousukehmm
13:16Chousukeis there any quick way to use leiningen to run examples for a project? :/
13:16the-kennyclojure 1.1.0 (without snapshot) and c.c "1.0-SNAPSHOT" works for me (at least I can start a repl within emacs)
13:16the-kennyChousuke: Write a plugin!
13:16the-kennyWould be useful
13:17noidihow can I set the value of a field of a java object?
13:18noidi(.field object) works for reading, but the obvious attempt at writing -- (.field object new-value) didn't seem to work :)
13:19Chousuke(set! (.f o) someval) I think
13:20noidiUnable to resolve symbol: set! in this context
13:20Chousukewhat.
13:20Chousuke(doc set!)
13:20clojurebotexcusez-moi
13:21Chousukehm
13:21noidiah, I just checked if the function exists by typing "set!" in the repl :)
13:21Chousukeright
13:21noidishould've known it's a special form
13:21Chousukeit's a special form
13:22noidithanks, that works
13:22Chousukethe syntax is pretty common lispy (in a good way)
13:23noidiif the (.f o someval) syntax worked, one could initialize objects with doto
13:23Chousukethough Clojure has little need for generic-whatever-they-call-them because of the empasis on not mutating things. :)
13:23Chousukeemphasis*
13:23noidiyup, this is for Java interop
13:24hyp3rvigi1ant1is there a lein plugin for searching clojars and/or mvnrepository?
13:28alexykafter upgrading, I can't load congomongo anymore in lein repl, getting: java.io.FileNotFoundException: Could not locate somnium/congomongo__init.class or somnium/congomongo.clj on classpath: (NO_SOURCE_FILE:1). Yet It's a dependency in project.clj. What can be the issue?
13:29alexykthe jar has the structure src/clj/somnium/congomongo.clj
13:29alexykhow does clojure know to read that out of it?
13:29hiredmanyeah, that doesn't look right
13:29alexykit also has that very project.clj in the jar
13:30hiredmansounds like someone jar'ed up the source tree
13:30hiredmaninstead of running lein jar
13:31alexykI get this after lein install or lein jar
13:31alexykwhy would lein be screwed up here?
13:31hiredmanso you are generating the har?
13:31hiredmanjar
13:32alexykI was just doing lein install
13:32alexykand that produced the crooked jar
13:32alexyklein jar does the same src/clj
13:32hiredmanthe jar should not have the project.clj in it
13:34the-kennyI thin lein jar does include the project.clj too
13:34the-kennyI've seen some jars with it
13:37alexykah what a mess. lein repl cannot launch a specified clojure version, jars are effed, pre-cooked one has a different version and exhibits RestFn. I'm itching for a Makefile.
13:37alexykand this is only because I've upgraded lein.
13:38alexykhow can you launch a swank server with lein on a non-standard port?
13:38the-kennyalexyk:hm.. I don't think so
13:38the-kennyBut it should be easy
13:39the-kennyFile a feature request for it :)
13:39alexykmy filing technique is shouting "technomancyyyyy!" :)
13:40the-kennyheh
13:40hiredmanalways makes me think of chrestomanci
13:50hyp3rvigi1ant1alexyk: try: $ lein swank <port>
13:50alexykok
13:51alexykyeah
13:52alexykcan I also specify host? It should bind to the externally visible IP
13:53hyp3rvigi1antdoesn't look like you can specify the host
13:54hyp3rvigi1anthere's the entire lein-swank plugin source code (one function): http://github.com/technomancy/leiningen/blob/master/lein-swank/src/leiningen/swank.clj
13:55alexykwow
13:59the-kennyahhh lein swank has the port argument already?
13:59the-kennydidn't know that
14:02hyp3rvigi1anti didn't either, until i just now looked at the source, and then tried it, lol
14:09stuartsierra~url
14:09clojurebotsomething
14:09stuartsierra~paste url
14:11lisppaste8stuartsierra pasted "N-element tuples with deftype" at http://paste.lisp.org/display/93626
14:13cemerickstuartsierra: sweet. Should go show that to the #scala people. http://scala-tools.org/scaladocs/scala-library/2.7.1/Tuple9.scala.html#Some%2819%29
14:16stuartsierraDon't know much Scala, but that looks weird all right.
14:17alexykcemerick: what did I miss which is better in clojure? :)
14:17stuartsierraI thought about allowing type hints too.
14:17stuartsierraMaybe another day.
14:17stuartsierraalexyk: "N-element tuples with deftype" at http://paste.lisp.org/display/93626
14:18alexyknice
14:19alexykcemerick: referring to 2.7.1 dates you :)
14:20alexykand scala people have real types, for the record :)
14:22cemerickalexyk: the point is, there's one file/implementation for each tuple arity in scala
14:22cemerickthe types have nothing to do with it
14:23chouserstuartsierra: excellent. now add primitive support
14:23alexykcemerick: I think the static-ness of tuples makes it necessary, same in haskell and ocaml; you can't convert to lists either.
14:23cemerickalexyk: see, now you're making my argument for me ;-)
14:24chouserI think you could do something this in template-haskell
14:24alexykI remember a horrible protracted sesion on #ocaml where I'd ask how to convert a tuple to a list, and an FP dogmatic would say, "you shouldn't do that" like 20 times.
14:24cemerickactually, wouldn't template haskell make that possible?
14:24cemerickchouser: damn! ;-)
14:25alexykcemerick: my haskell is very rudimentary. But this is the dynamism vs static-ness.
14:25cemerickstuartsierra: interesting that you capitalized the key bindings.
14:25Chousukehmm, I wonder if the template macro would look any better if done using clojure.template
14:25chouseralexyk: no this is macros vs. not.
14:25cemerickalexyk: ah, I don't think so. Some better metaprogramming facilities in the scala compiler would make this possible.
14:26alexykthe same dogmatic, #ocaml is generally very friendly and a magic way was provided using some special magic.
14:26Chousukeit doesn't look like it has much actual programmatic construction of code.
14:27stuartsierraNo, there's not much code-construction.
14:27stuartsierraMost of the code is the same for tuples of any size.
14:28stuartsierraThe annoying part was ~'quoting all the method names and arguments.
14:28rhickeystuartsierra: awesome!
14:28stuartsierrarhickey: thanks!
14:29Chousukehm. I think the generated case impl prevents from using template
14:30stuartsierraSo if I add type declarations, should it be per-element or one type for the whole tuple?
14:30cemerickper-element, I'd think
14:30chouserstuartsierra: I have the same construction, and for similar reasons, here: http://tinyurl.com/yb8bggv/finger_tree.clj#LID39
14:30stuartsierracemerick: That was my first thought, but at that point you're basically writing deftype again.
14:31chousera macro for making types, calls to make the types, and then a multi-body fn to construct the right kind.
14:31chouserif I add primitive support to the finger-tree digit types, all fields would have the same type.
14:32chousermy digits are rather less featureful than your tuples
14:33stuartsierrachouser: You aren't trying to support all the Vector interfaces.
14:33rhickeystuartsierra: for Clojure, tuples are just specific small vectors. Vectors have uniform element type (only Object right now, but another interesting case of data-structures-as macros is vectors of longs and doubles)
14:33chouserright, just Indexed. ISeq for destructuring.
14:34rhickeyshould use nth, not get for tuples/vectors
14:34chouserplus my tree-specific stuff: DoubleSeq, Measure, Splittable
14:34stuartsierrarhickey: it supports both nth and get, like vectors
14:35stuartsierraBut the examples should probably use nth.
14:35rhickeyright, but I hate to see example code with get
14:35rhickeyheh
14:35rhickeyget on vectors only when supporting associative things more generally
14:36rhickeyI'd like to get rid of the need for those ~'s
14:37stuartsierrarhickey: Some of them are not necessary, but it was easier to leave them all in than figure out which ones.
14:37rhickeyhrm
14:37stuartsierraI can't use auto-gensyms in some cases because I have nested backquote-unquotes
14:38chouserI didn't need ~' for any of the method names
14:38rhickeyso, metadata on fns is ready for public consumption. One issue right now is macro arglist metadata includes the implicit &form and &env args
14:39rhickeyclojure.core/for
14:39rhickey([&form &env seq-exprs body-expr])
14:39rhickeyI need to strip them at some point in the chain
14:39chouseris the fn metadata copied to the var, or... ?
14:40rhickeychouser: right now var to fn
14:40rhickeybig pain having it both places, but breaking change to take off var
14:40chouseryeah
14:40rhickeywith-meta works on fns
14:42chouseroooh
14:43cemerickthat's pretty exciting
14:44cemerickthis includes arities? That's probably the #1 requirement out there.
14:44rhickeywhat are people doing with runtime arity?
14:46rhickeyin any case, it's just the arglists metadata
14:47chouserfor what people are doing with runtime arity?
14:47rhickeyyes
14:48rhickeyor runtime fn metadata in general
14:48cemerickI'm trying to remember what my use case was... :-/
14:48chouserone example someone descibed was a fn that wanted to except either a one- or two-arg predicate.
14:48chouserso var metadata was useless
14:49rhickeychouser: what's a one or two arg predicate?
14:49rhickeyi.e. what do you pass?
14:49cemerickoh, right, I wanted to be able to decorate fns with arities and acceptable type tags so that candidate fns could be selected from a library/population given a set of args
14:49chouserHe wanted both (foo (fn [a] ...)) and (foo (fn [a b] ...)) to work
14:50cemerickI ended up passing around [fn-info-map fn] vectors.
14:50rhickeychouser: I'd have to know the specifics to understand that - if you take one arg you get passed foo and if 2 foo and bar?
14:51rhickeycemerick: so full runtime dispatch
14:52cemerickrhickey: with lots of layers of indirection, backtracking as necessary, etc. But being able to describe the 'surface' of each fn was critical.
14:52rhickeyhmm
14:53cemerick"signature" is too weak of a term for what we were doing, so we came to call the characterization of each function (a 'feature' in bayesian terms) its surface
14:54rhickeycemerick: but you didn't want to package the fn in a descriptive map?
14:54chouserrhickey: I think so, like (fn [a _] ...) would have worked, but is uglier.
14:55cemerickrhickey: that's roughly what we ended up doing, although we kept the description separate.
14:55rhickeychouser: I'm still unclear (and I know its not your thing you're describing) what one or two things would get passed
14:56cemerickrhickey: to be clear, the difference between what your doing and what you *could* do is very small.
14:57cemerickas long as we can decorate fns with metadata, I'm super-happy :-)
14:57rhickeynote that fn equality is still identity based
14:58cemerickwe put all sorts of stuff in our surface descriptions anyway, so leaving the :arities [1, 2, 5, [6 '&]] pair in there is fine for me.
14:58cemerickrhickey: is anything else really possible/
14:58cemerick?
14:59rhickeycemerick: well, it can't be behavior based, but could (but isn't) be based around same type plus equal closed-overs
14:59cemerickrhickey: sounds like a difficult path with little to gain from it
15:00rhickeytwo such fns would give same results given same args, and would isolate metadata
15:00rhickeycemerick: we'll see if people get breakage from fn != same fn + meta
15:01cemerickIMO, if you're comparing fn equality, you're already in rough shape
15:01rhickeythere was never a reason to create another version of the same fn before
15:02rhickeymeh, fns are values, can be map keys etc
15:03cemerickI've always thought about fns as being black boxes, quite unlike other values -- can't be serialized, can't be compared, no notion of equality, etc.
15:08Chousukeequality for functions is defined at least in a theoretical sense. Hmm
15:08cemerickSure, in the f(x) -> y sense, but a real implementation of that is probably intractable.
15:10hiredmanit's the halting problem
15:10hiredmanisn't it?
15:10cemerickto brute-force it, yeah
15:11rhickeycemerick: I agree, in general, but a particular fn is = to itself in any system, yes?
15:11cemerickif you were to do something like aggressively normalize the source of two equivalent fns, you might get them to hash out equally, but I wouldn't bother :-)
15:11rhickeyso, that fn with-meta should still be =, given what with-meta is supposed to do and metadata's relationship to equality
15:12rhickeyat least one could argue that, and I expect someone will
15:12cemerickrhickey: Yeah, it probably should be, but *meh*
15:13arohnerrhickey: one use of fn arity metadata is macros / fns that wrap it
15:13arohnerat one point, I wanted to make a function that took another function, wrapped it, and def'd a new function with the same arity
15:14arohnerand I wanted the old arity to stick it in the doc string of the new fn
15:14cemerickHell, if I didn't know how fns were implemented under the covers, I might expect a meta-altered fn to drift in equality from the original fn anyway due to JIT recompilation.
15:15rhickeycemerick: really?
15:15cemerickrhickey: *if* I didn't know how fns were implemented, etc., but did know that code was being regenerated and replaced all the time.
15:17cemerickrhickey: if you're really worried about it, you could add an :original-fn slot to new meta on fns. :-P
15:17alexykdid str-utils2 remain in c.c. 1.1.0-master-SNAPSHOT?
15:17ambientbtw, anyone else done any musical audio synthesis with clojure? or written a clojure-lib for realtime audio?
15:19alexykI do (:require [clojure.contrib.str-utils2 :as s2]) and it gives me a class not found. Why suddenly?
15:20hiredmanstr-utils2 may have been renamed to str-utils, I forget
15:21the-kennyohh and str-utils is dropped?
15:21hiredmanpossibly
15:22hiredmanI saw some discussion of it, dunno if it actually happened
15:22alexykdarn, I can't find str-utils2/replace
15:23alexykwhat can I replace replace with?!
15:23alexyk(replace string from to)
15:23the-kenny,(doc replace)
15:23clojurebot"([smap coll]); Given a map of replacement pairs and a vector/collection, returns a vector/seq with any elements = a key in smap replaced with the corresponding val in smap"
15:23hiredman,(.replace "foo" "foo" "bar")
15:23clojurebot"bar"
15:23alexykin a string!
15:23the-kennyalexyk: you have to say .replace, not replace :)
15:23the-kennyThere's a difference
15:23hiredman,(.replace "foo" "foo" "bar")
15:23clojurebot"bar"
15:24alexykI used to use str-utils2 tp get rid of the . apparently... hmm
15:24the-kennyoh sorry, I didn't see one of your comments
15:24chouserstr-utils2 replace is a multimethod
15:24stuartsierraas far as I know str-utils2 has NOT replaced str-utils
15:24alexykchouser: which is what ?
15:25alexykall I know that require c.c.str-utils2 used to work and now doesn't
15:25alexykbut, here Javaism will save the day
15:26hiredmanok
15:26hiredmanthen the problem is something else
15:26alexykI've just spent inordinate amount of time to: upgrade leiningen and clojure; determine lein repl won't respect clojure versions; try swank and eff with firewalls, ports, and tunneling; replace lein repl with zsh: var=( lib/**/*.jar ); print ${(j.:.)var}
15:27stuartsierraalexyk: what versions of Clojure/contrib are you using?
15:27alexykstuartsierra: 1.1.0-master-SNAPSHOT on both
15:27alexykas delivered by lein
15:27alexyklein deps
15:27stuartsierraOh, can't help with lein, but I expect that's the problem.
15:28stuartsierraThey're pulling a bad build or something.
15:28alexykstuartsierra: what's the latest correct coupling?
15:28stuartsierraI don't know, I don't use lein.
15:28alexykand is it gettable via build.clojure.org maven repo? I'll use raw maven, forget lein
15:29stuartsierrayes, there are contrib release candidates on build.clojure.org now
15:29stuartsierrasee my announcement on the clojure-dev list
15:29alexykright, from the email this morning, correct? which clojure do they work with?
15:29stuartsierraalexyk: version numbers match; contrib 1.1 => clojure 1.1
15:30rhickeyI'm not sure metadata is the right way to get arity from a fn. Arity is a property of the fn. Arglists meta is for humans
15:30alexykis c.c. supposed to work with variations, e.g. both 1.1.0 and 1.1.0-master-SNAPSHOT?
15:30Raynescontrib 1.1 new snapshot seems to run with clojure 1.2 master snapshot.
15:30RaynesSo, that's what I've been pulling down fro my stuff.
15:31stuartsierraIf you're using snapshots, use matching branches. If you're using releases, use matching release numbers.
15:32lisppaste8stuartsierra annotated #93626 "N-element tuples with type declarations" at http://paste.lisp.org/display/93626#1
15:33alexykso is multimethod is a function with variants by arity?
15:34hiredmannope
15:34hiredmanhttp://clojure.org/multimethods
15:34rhickeyok, fn metadata is up
15:35stuartsierracemerick: tuples with primitives!
15:36chouserstuartsierra: beautiful
15:36cemericknice
15:36stuartsierrathx
15:36rhickeystuartsierra: neato - now onto vectors of primitives? :)
15:36cemerickstuartsierra: you should add comparisons to arrays
15:37rhickeycemerick: that would be wrong
15:37rhickeymutable things should have identity-based equality
15:38cemerickrhickey: I'm just curious about the relative perf
15:38rhickeyoh, make a comparison
15:38Raynesfor* (late correction)
15:38cemerickright
15:38Raynesrhickey: Hah! We used words of the same length to end our sentences!
15:38RaynesYou owe me a coke.
15:38alexykhiredman: thanks, dreaded OO stuff.
15:39alexykBenUncle uncleBen = new UncleBenUncle("Ben")
15:39hiredmanit's polymorphism
15:39rhickeystuartsierra: should switch get to nth
15:39hiredmannot OO
15:39stuartsierrarhickey I thought I did
15:40stuartsierraoh, only in the tests
15:40alexykright, just mention of OO was a flashback. I read through CL CLOS once and forgot it, will see about defmulti
15:42alexykmy repl is finally back, lesson: don't entrust your repl to tools
15:42alexykhand-made vintage repl is in your full control
15:44lisppaste8stuartsierra annotated #93626 "typed tuple comparison with arrays" at http://paste.lisp.org/display/93626#2
15:44stuartsierratuple performance does not quite match arrays, but gets very close
15:44cemerickthat's pretty remarkable
15:45cemerickIf the same margin applies between aset and (assoc tuple n blah), then *whoa*
15:45rhickeystuartsierra: you've got to tweak valAt
15:46stuartsierrarhickey: how so?
15:46rhickeycalling interleave?
15:46chouserthat's at compile time
15:46rhickeyah
15:47stuartsierraIt generates a case expression like (case n 0 e0, 1 e1, 2 e2, ...)
15:47rhickeywell, then you'll need case help - what are the times with condp
15:48stuartsierraLast week with 2-tuples, it was slightly faster with condp
15:48rhickeyright, and will be until case gets an all-integers specialization
15:48RaynesHaha. People actually do the too-hot tutorial stuff. :>
15:48rhickeyfor small n condp still might be faster
15:49stuartsierraThat's what I thought. But it was easier to write with case.
15:49rhickeyright, but this one fn is at the bottom of everything, make as fast as possible
15:49stuartsierratrue
15:49stuartsierraI'll try it
15:50rhickeynow that I'm out of fn metadata nightmare I can look at case
15:50rhickey(meta map)
15:50rhickey,(meta map)
15:50clojurebotnil
15:50rhickeyhrm
15:50chouserclojurebot gets new versions of clojure fairly rarely
15:51chouserhe's on some pre-HEAD version of the "new" branch right now I think.
15:51hiredmanno
15:51hiredmansome lein repl version
15:51chouseroh
15:51hiredmanhmmm
15:51hiredmanunfortunate sideeffect of leinizing
15:52rhickeycemerick: tuples should end up faster than arrays
15:52hiredmanmmmm
15:53hiredmannow we just need a means of stack allocating
15:53cemerickrhickey: object creation is really that fast?
15:54rhickeyyes, and an array is an object, and array access is bounds checked
15:55chouserheh. meta fns just broke what I'm doing.
15:55arohner,(clojure-version)
15:55clojurebot"1.1.0-master-SNAPSHOT"
15:55chouserI should have learned by now not to build code on top of Compiler internals...
15:55rhickeychouser: what broke?
15:56stuartsierrarhickey: plain cond is very slightly faster, still not quite the equal of arrays
15:57chouserno multimethod for dispatch value Compiler$MetaExpr
15:57lisppaste8stuartsierra annotated #93626 "Ever so slightly faster with cond" at http://paste.lisp.org/display/93626#3
16:00stuartsierraBut array performance is more consistent; tuples are harder to benchmark.
16:00rhickeychouser: how are you getting that?
16:01chouserrunning my own multimethod recursively on the results of Compiler/analyze
16:01chouserrhickey: don't worry about it. It's all my own thing.
16:03technomancylein repl is wonky with clojure versions
16:04technomancyI should have it print out a warning when it launches
16:04technomancyor just fix it, I guess
16:08wlrchouser: re your lint name q, howze 'bout "clintj" pronounced "clinch". (Sorry, couldn't resist :)
16:11rhickeyurk - stuart's code is using a macro as a fn
16:12chouserhow?
16:12clojurebotwith style and grace
16:12kotarak,#'and
16:12clojurebot#'clojure.core/and
16:12kotarak,@#'and
16:12rhickey2-arg version calls 3 arg version as if it was a fn
16:12clojurebot#<core$and__4467 clojure.core$and__4467@395626>
16:13chouserohhhh... :-/
16:13wiligtechnomancy: Did the read-line fix work for ya?
16:13rhickeythat will now fail, will be a common error I thimk
16:15Hali_303what are some mature frameworks for persistence?
16:15technomancywilig: yeah, it looks great
16:15Hali_303(I mean high level, not SQL interface)
16:16wiligtechnomancy: Oh good, I'm glad it worked outside of my little environment.
16:16technomancystill doesn't let you call clojure.main/repl from slime-repl, but it's a good move forward
16:18wiligtechnomancy: what should that do?
16:20cemerickit looks like one cannot use var references in clojure.test/are ...
16:21cemerickbah, nevermind
16:22technomancywilig: (require 'clojure.main) (clojure.main/repl) ;; <= should allow the new repl to take over the slime-repl buffer until it exits
16:22wiligah
16:22technomancywilig: I think it comes down to the simple fact that (read) from slime-repl doesn't work
16:23technomancysince it needs a pushback reader
16:23technomancythat might not actually be too tricky to fix now that I think about it
16:24technomancymaybe just proxying clojure.lang.PushbackReader instead of java.io.BufferedReader would work
16:24wilighmm, I agree. changing the proxy to a pushback reader shouldn't be too hard. if I understanding the problem correctly.
16:24wiligexactly
16:26hiredmanclojure's is a linenumberingpushbackreader
16:26hiredmanpushbackreader is in java.io
16:27technomancyoh right
16:34wiligtechnomancy: you gonna have a go, or should I crack it back open?
16:35alexykis there any tracing for the dreaded java.lang.NullPointerException (NO_SOURCE_FILE:0)?
16:36technomancywilig: I'll have a go possibly tonight, but if you beat me to it I'd be happy. =)
16:36alexyktechnomancy: please please add host to lein swank! I need to bind to outfacing IP
16:37tcrayfordal3xyk can't you just use an ssh tunnel?
16:38chousercould make a lein plugin for it even
16:38cemerickalexyk: ctrl-J prints the stack trace from the last exception in enclojure *shrug*
16:39alexyktcrayford: my tunneling is effed up with administrative error or some such
16:39hiredman
16:39alexykcemerick: plain command line repl, how about that?
16:39chouser(.printStackTrace *e)
16:39cemerickalexyk: (.printStackTrace *e)
16:40chouser:-)
16:40hyp3rvigi1antalexyk: when i was working on those patches, i noticed that swank seems to bind to 0.0.0.0 by default, which I think should allow connections from anywhere on any interface (though I haven't made sure of that yet)...i continued writing the patch to give users the option to specify the host in case they don't want it to be accessible on certain ips/interfaces
16:40cemerickchouser: that's 3/3, all less than a second before me! Well done. :-P
16:40chouserheh
16:40chouserI feel so useful
16:41cemericknow if I could just get my wife to be as clairvoyant ;-)
16:41technomancyalexyk: uh... I'll get to it eventually
16:41technomancyif you really want it soon you could implement it yourself. =)
16:41alexykchouser: thx! fast and correct every time!
16:41chousernow if I could just be as clairvoyant with my wife ;-)
16:42alexykso long as the wives are not clairvoyant...
16:42cemerickalexyk: amen to that
16:43alexyknow I appreciate a bit why Scala etc. run away from nulls as heck, and go to such lengths with Option types. Null is nasty.
16:43cemerickare there *any* publicly-known women clojure programmers out there?
16:43alexykYou spend a few days to craft a lovely functional program, and get a null.
16:43alexykcemerick: Clair Voyant is as close to the scent of a woman as you get here.
16:43hiredman~women
16:43clojurebotwomen are just jealous, since lisp has nice curves. -- Chousuke
16:44cemerickYeah. Unfortunate.
16:44alexykthink of Lady Ada Lovelace and her lovely language Ada 2005
16:44rhickeythere you go
16:45wiligtechnomancy: Well the simple change didn't work. No error returned, just nil.
16:45alexykrhickey: I really love Clojure, but I come from OCaml where Option types make it go away, I', all soft and bamm! A null per 200 lines of dense clojure. What to do?
16:45cemerickif we could get a -?>> to go with -?>, I'd really be all set
16:45alexykwhat's -?> ; ?
16:46cemerick-?> is like ->, but short-circuits on nulls, returning null
16:46cemerickit's in clojure.contrib.core
16:46alexyksee? you said "null". :)
16:46hiredmanalexyk: stop producing nils
16:46cemerick,#'clojure.contrib.core/-?>
16:46clojurebotjava.lang.Exception: Unable to resolve var: clojure.contrib.core/-?> in this context
16:47alexykhiredman: now that's managerial! (getting back to debugging nulls)
16:47hiredmanalexyk: how is that managerial?
16:47cemerickhiredman: they're a fact of life given seq, but I'm still not clear on what the problem is
16:47alexykhiredman: a good phrase to tell an underproducing programmer
16:47hiredmanalexyk: well, start producing more
16:48alexyk:)
16:48alexyka null ate my program
16:48RaynesA null killed my father and raped my mother.
16:48stuartsierraYou are likely to be eaten by a null.
16:49rhickeystuartsierra: you were calling a macro as a fn in your def-tuple-type (2 arg called 3 arg) - that's a no-no and new master breaks it
16:50rhickeyshould be ([NAME N] `(def-tuple-type ~NAME ~N 'java.lang.Object))
16:50hiredmannil is a legitimate value, clojure is a dynamic language
16:50hiredmanwhat is the problem?
16:50stuartsierrarhickey: yes, I see, will fix
16:50chouserit's kinda crazy that it worked at all. depends on the fact that def-tuple-type isn't marked as a macro yet when that line is compiled?
16:51rhickeyif there was a man who promised to keep you free from headaches, but only by continuously kicking you in the shin, would you want him to?
16:51rhickeychouser: yeah
16:52alexykrhickey: on a day with a null, I might welcome it; but generally no. The question is, how can null be trapped easily and isolated.
16:52hiredman(when x (do stuff to x))
16:52rhickeyalexyk: you could try preconditions
16:52lisppaste8stuartsierra annotated #93626 "fixed recursive macro self-call" at http://paste.lisp.org/display/93626#4
16:53alexykrhickey: yep, thought of that. One kinda hopes stuff will work by itself :)
16:53Raynes,(+ nil nil)
16:53clojurebotjava.lang.NullPointerException
16:53rhickeystuartsierra: also, your array test is not fair as it doesn't set the array elements to 3 values as does the tuple
16:53alexykRaynes: scary!
16:53RaynesOh noes! I has a null problems!
16:53stuartsierrarhickey: true
16:54alexykwell, now go wrap each operand in an (or..)
16:54alexykI wonder if a macro can be written to magicaly wrap everything in a "must-be-not-null" check
16:54alexykthen it will cry out with specifics
16:55RaynesI had a NullPointerException yesterday. It was really null.
16:55rhickeystuartsierra: when you do that, 3-tuples of doubles beat arrays of doubles, but arrays of objects beat all
16:55stuartsierrarhickey: Calling aset-double kills performance.
16:55rhickeyaset-double is not fast, aset is, with hints, hang on a sec
16:56alexyk,(inc nil)
16:56clojurebotjava.lang.NullPointerException
16:56lisppaste8rhickey annotated #93626 "tuples vs arrays" at http://paste.lisp.org/display/93626#5
16:56hiredmanalexyk: what's the problem?
16:57Chousuke,(inc "foo") makes as much sense as (inc nil)
16:57clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
16:57Chousukeand it's just as likely
16:57alexykhiredman: nothin', just besting Raynes' shortest null-inducement
16:57rhickeystuartsierra: ^^that code is fast for arrays, but double array still requires unboxing
16:57stuartsierraok
16:58stuartsierraA while ago I thought about implementing tuples as Object arrays.
16:59ChousukeAs far as I can tell, even if you had types that can't be null, you could still pass nil to functions because Clojure is dynamic. And if you had no nil, you'd instead have n different objects doing what nil does, each making as much sense as nil to functions that don't expect them.
17:01alexyk,(let [m {:a 1} {a :a} m] a)
17:01clojurebot1
17:02alexyk,(let [m {:a 1} {:keys [a]} m] a)
17:02clojurebot1
17:02alexykdoes the latter mean that :keys prepends : to its list?
17:02alexykmeaning varname a maps to key :a?
17:02stuartsierrayes
17:02hiredmangah
17:03hiredman"prepending :" is some kind of text operation on characters
17:03hiredmanit certianly does not do that
17:03alexykI know, I know. I mean naming convention here
17:03alexykwell somewhere it maps a to :a
17:03alexykit prepends : in the eyes of the higher powers
17:03hiredmanno
17:04hiredmana is a symbol and :a is a keyword, :a is not a a with a : prepended
17:04chouserheh
17:05alexykI meant names
17:05alexykapaprently a naming mapping is implied
17:05chouseryes, a name mapping is implied
17:05alexykand names are text thingies!
17:05chouserthere are :syms and :strs as well
17:06hiredmannames are not text thingies
17:06chouser(name 'symbol)
17:07chouser,(name 'symbol)
17:07clojurebot"symbol"
17:07alexykhiredman: then what are they?
17:07hiredmanalexyk: they are an abstract concept
17:07alexykhiredman: which can be expressed as text thingies :)
17:07hiredmanhttp://en.wikipedia.org/wiki/Lambda_calculus#.CE.B1-conversion
17:08alexykan electronic computer is a machine for manipulating bytes, i.e. text
17:08Chousukethe :keys [a] means the map has a keyword as a key that has the same name as the symbol 'a :)
17:08hiredmanthen please write asm
17:09Chousuke,(= (name :a) (name 'a))
17:09clojurebottrue
17:09Chousukesame name, very different entities.
17:09alexyk,(type (name 'a))
17:09clojurebotjava.lang.String
17:09alexykcase closed
17:09hiredmanno
17:09tcrayfordthat's just because name returns a string
17:09tcrayford,(type 'a)
17:09clojurebotclojure.lang.Symbol
17:10tcrayford,(type :foo)
17:10clojurebotclojure.lang.Keyword
17:10hiredmanthe name function is not the same thing as a name
17:10ChousukeI think you're arguing useless semantics here though.
17:11hiredmanChousuke: since alexyk is always in here asking for help and complaing about NPE's I think a revision of his mental model via an education in semantics might be useful
17:11Raynesalexyk: coolest npe http://gist.github.com/281362
17:11alexykok sorry, I was bitten by a null. I'm not asking for help per se, I love to know the right idioms. :) Now I have to track the null.
17:12ChousukeWell, there's certainly no prepending of : or anything,
17:12hiredmanChousuke: exactly
17:12Chousukealexyk: you said a naming mapping is implied. I think it's rather explicit, as the syntax exists just for that.
17:12alexykok
17:13Chousukebut really, be wary of treating clojure code as text. it's just misleading and someone might feel the need to correct you :)
17:14hiredman<--
17:14Chousukeit has a textual representation yes, but it's still important to treat it as data.
17:15chouserClojure programs have non-textual in-memory representations, but sometimes it's important to treat them as text.
17:15hiredmanto program in language X it is important to have a good mental model of X
17:16Hali_303does anyone use clj-record or clojureql in production? which is better choice for a green field project?
17:17Chousukethe code=data thing kind of changes the terminology a lot though
17:18hiredmanit's even a code=date thing, it is confusing a concrete manipulation with semantic intent
17:18hiredmanit's not even
17:19Chousukeinstead of "let" having syntax consisting of an open bracket and a list of bindings, a closing bracket and a body of expressions, it instead "takes a vector of binding forms" and an arbitrary number of expressions.
17:19hiredmanif I have a function F that produces :a when applied to 'a the intended meaning is a mapping of symbols to keywords
17:20hiredmanconfusing that a possible concrete method for creating that mapping is bad
17:20hiredmanthat with
17:20Chousukeyeah. though I think this was blown out of proportion a bit :P
17:21hiredmanis F a mapping between values or a procedure for pretending :
17:21chouserthe name of a symbol is a string
17:21hiredmanprepending
17:28alexykI have two files: a big one with (ns ...) on top, and a fun I factored out and killed null in. I pasted the big file into repl, then was fixing the factored-out fun and did (load-file "it.clj") until it works. Now If instead of pasting I do (load-file :bigfile.clj") the ns doesn't change and small fun cannot find stuff from it. Pasting just the ns header works. How can I change the bigfile so its ns header is injected into repl as if pasted?
17:30tcrayforduse :reload
17:30tcrayfordmaybe?
17:30qbgWhen you load the file, the namespace will be updated, but your ns won't change
17:30qbgWhy not just switch to that namespace?
17:31tcrayfordvia (in-ns 'new-ns)
17:31alexykqbg: right... How do I switch to it from repl?
17:31alexykah ok
17:31qbg(in-ns 'your-namespace)
17:31alexyklovely
17:31alexykand beautifully, on a defn from a file, a line is printed where null occurs. That solves the Clojure Null problem. :)
17:35riktheviklet's say i have a map (structure) and i do a map (function) on it. what's the best way to assemble that list of vectors back into a map (structure)?
17:35hiredman(into {} ...)
17:35hiredman(apply conj {} ...)
17:37rikthevikah, beautiful. i usually have a good idea of what i want to do, but i have trouble figuring out the exact function i need. thank you
17:40ts00000anyone clueful with compojure that can show me how a javascript should be declared in (html)?
17:42arohnerts00000: you just make your string an attribute in a script element
17:42arohnerts00000: you can also use scriptjure, but that compiles down to a string, and you use it in the same place
17:42ts00000I tried [ :script "test.js" ] but I don't think that does the right thing
17:43hiredmants00000: um
17:43arohnerif you want to include a js file, you can use the include-js function provided by compojure
17:43hiredmants00000: how do you include javascript in html? (hint: it is an exact map to compojure's [:tag] style)
17:43tcrayfordaye
17:44ts00000hiredman: what I want is to do a script src
17:44ts00000but I think arohner might have it
17:45arohnerwhich would be [:script {:type "text/javascript" :src "foo.js"}]
17:45arohnerif you wanted to do it "by hand"
17:45ts00000thanks arohner, I was trying something wrong and forgot about the curlies
17:45ts00000still learning syntax
17:46ts00000programming clojure goes through it so fast it's hard to keep track of :-)
17:47ts00000so I can just use include-js inside the html/
17:47ts00000?
17:48tcrayford(html (include-js "foo.js")) works fine
17:48ts00000finally just found a good example
17:48ts00000thanks folks
17:48tcrayforduser=> (html (include-js "foo"))
17:48tcrayford"<script src=\"foo\" type=\"text/javascript\"></script>"
17:48tcrayford
17:49ts00000http://www.pgcon.org/2009/schedule/attachments/96_visualizing-postgres-2009-05-21.pdf has way more examples than i'd seen so far
18:02the-kennyI love the xkcd comic in the pdf
18:02tcrayfordis there an easy way to get clojure regex to match newlines?
18:03hiredman,(re-find #"\n" "\n")
18:03clojurebot"\n"
18:03tcrayfordsay I have a string "foo\nbar", and I want something like #"^foo.*" to match it
18:03the-kennytcrayford: Take a look at RegexPattern javadocs
18:03hiredmanoh
18:03hiredmanyou have to use a flag
18:03hiredman?s maybe?
18:03tcrayforddoes that mean dropping down to java?
18:03hiredmanno
18:03tcrayfordor just at the start of the pattern
18:04hiredman,(re-find #"(?s)*" "\n")
18:04clojurebotDangling meta character '*' near index 4 (?s)* ^
18:04hiredman,(re-find #"(?s).*" "\n")
18:04clojurebot"\n"
18:04ts00000?s is the flag
18:04ts00000like
18:04hiredman,(re-find #"(?s)foo.*" "foo\nbar")
18:04clojurebot"foo\nbar"
18:04ts00000"(?s).+?(?:\n\n|$)"
18:04hiredman,(re-find #"(?s)foo." "foo\nbar")
18:04clojurebot"foo\n"
18:04hiredman,(re-find #"(?si)foo." "FOO\nbar")
18:04clojurebot"FOO\n"
18:11dabdmethods are supposed to be documented with metadata #^{:doc "...." ?
18:12dabdit would be nice if the defmethod macro also supported documentation strings
18:14hiredmandabd: where do you put the docs?
18:14tcrayfordcheers for that hiredman, problem solved
18:14jcromartiewhat are the implications of putting lots of jars on your classpath?
18:14dabdhiredman: well I put the multimethod doc string in defmulti
18:14jcromartiedoes it really matter if you don't use the libs/classes?
18:14dabdhiredman: but it would be nice to be able to document also the methods
18:15arohnerjcromartie: not really
18:15ts00000how can you get find-doc and repl-utils/source to return private methods?
18:15ts00000or can you?
18:15hiredmandabd: the docstring is not just suspended in space, it is hung on the var
18:15hiredmanwhere would you have it for defmethods?
18:15hiredmanhow would you look it up?
18:15jcromartiehow about (doc multimethod type)
18:16hiredmanjcromartie: that does not solve the "were to put it problem"
18:16tcrayford(defmacro is=
18:16tcrayford ([expr val] `(is= ~expr ~val ""))
18:16tcrayford ([expr val msg] `(is (= ~expr ~val))))
18:16dabdhiredman: I see
18:16tcrayfordwondering if its worth adding that to clojure.test
18:16dabdhiredman: is there any way to add documentation specific to a method?
18:17hiredmandabd: if the behaviour of the multimethod is so out of line with the documentation from the defmulti you might consider making it a seperate function
18:18hiredmanyou can always make comments
18:18jcromartieI think if you have to document each defmulti you should probably break it up.
18:19jcromartieerr
18:19jcromartiedefmethod
18:19dabdhiredman: the specific case is a multimethod that performs queries either in SPARL or SQL so the result set is different in each case and I wanted to document that. However code comments are only useful for developers and they cannot be inspected with the REPL or programmatically
18:19jcromartieI'd just document the two result sets in the defmulti
18:20jcromartiebut if your return values are different between two defmethods for the same defmulti then it doesn't really seem like a good use for multimethods
18:20jcromartieor at least if you can't use the return value in the same way
18:21dabdjcromartie: the return value is a seq over the result set. So I use it as a sequence abstraction
18:39hiredmanclojurebot: git 277f0235c1387ddd6247a72857597814a3e10bc3
18:39clojurebotadd &form and &env implicit args to macros
18:39hiredmanneat
18:40jcromartieare there any problems using symlinks to jars?
18:41wiliganyone know how to call a super method from a proxy?
18:41jcromartielike if I have a directory full of symlinks to the jars I want to use, and I specify them in the classpath with something like "$HOME/.clj/jars/*" I can't seem to use or require any of the libs
18:43jcromartieoh, hmm
18:46hiredmanwilig: proxy-super
18:46jcromartiemaybe I should be using hard links
18:47hiredmanjcromartie: * when expanded by the shell does not work in the classpath
18:47jcromartieI know
18:47jcromartieI think the problem is with my links
18:47jcromartiethey carry the exact path source file path that I specified... not an absolute path to the source file
18:47hiredmanjcromartie: it also only works for java 6+
18:47jcromartieso they are only relative
18:48jcromartieyah I'm on 6
18:48jcromartieit works with hard links or real jras
18:48jcromartiejars
18:48jcromartiebut my symlinks have the wrong source file
18:48hiredmanwell, I've never had problems with symlinks
18:48jcromartieif I do ln -s ./foo/bar bat
18:48jcromartiethen bat is a symlink to *exactly* ./foo/bar
18:49jcromartiemeaning it will still be ./foo/bar wherever I access it from
18:49jcromartieso the full path must be specified
18:55jcromartieI guess hard links are probably better for this than symlinks.
18:55krumholt_i want to traverse and find the first element to fullfill some condition how would i do that?
18:55jcromartieI dunno... you all probably just copy the freaking jars :)
18:56jcromartiekrumholt_: first, filter
18:56jcromartieor some
18:56krumholt_jcromartie, ah ofcourse thanks
18:57jcromartie,(some even? [1 3 5 6 7])
18:57clojurebottrue
18:57hiredman,((comp first filter) even? [1 3 5 6 7])
18:57clojurebot6
18:57jcromartie,(first (filter even? [1 3 5 6]))
18:57clojurebot6
18:57jcromartieooh, fancy with the comp
18:58jcromartiebut you made it bigger :)
19:05jcromartiesome is fun for maps and sets
19:05jcromartie,(some {:foo 1 :bar 2} [:bat :baz :foo])
19:05clojurebot1
19:17zmyrgelhow can I make hash map out of two lists?
19:18zmyrgelI'm trying to make hash map of hex chars, like :11 points to b
19:18Chousukezipmap might help
19:18Chousukemap keys don't have to be keywords either
19:19zmyrgelzipmap was just the thing
19:21zmyrgelI'm trying to learn clojure by converting one of my java projects to it
19:24zmyrgelthis would be easier if I hadn't forgotten my copy of halloway's book at my parents house
19:24Chousukezmyrgel: A good idea, but it's also a double-edged sword. You may end up writing Java in Clojure if you're not careful :)
19:24zmyrgeltrue that
19:25zmyrgelbut I guess it takes time to learn the 'flow' of different language
19:25Chousukethough I suppose that's a good experience as well.
19:25Chousukeyeah
19:25Chousukeespecially since Clojure outright abandons most concepts familiar to Java programmers :P
19:26zmyrgeltrue that
19:27RaynesBleh. More code to change.
19:27zmyrgelI could do my bachelor's thesis about clojure if I can't ooze myself into any real job
19:27RaynesI was doing (apply hash-map (interleave blah blah)). :|
19:27Chousuke~def zipmap
19:28Chousukehmm
19:28Chousukeoff sync it seems
19:52janjanIs there a max-seq or something like that? so I can do (max-seq [1 2 3]) as (max [1 2 3]) doesn't work
19:53jcromartiedo you just want the maximum value in a seq?
19:53janjan,(max [1 2 3])
19:53clojurebot[1 2 3]
19:53janjanjup
19:53jcromartie,(apply max [1 2 3])
19:53clojurebot3
19:53jcromartie,(apply max (range 1 20))
19:53clojurebot19
19:54janjanhmm, guess I'm still thinking too much in Python
19:54janjanthx
19:54jcromartiethere are other ways that are perhaps more traditional
19:55jcromartie,(reduce max [3 4 2 6 7 3])
19:55clojurebot7
19:55janjanI'd say the apply one is more traditional than using reduce :)
19:56jcromartiereally? I see reduce more than apply
19:56jcromartieapply seems to be more of a lisp thing
19:56janjanyea, but reducing with max is not something I'd find intuitive
19:56jcromartieI suppose not
19:57jcromartiebut reduce is usually in the "intro to FP" curriculum if you know what I mean
19:58janjanI know it, but i'm used to use it with the traditional operators like + and *, but it works equally well with max I guess
19:59janjanthough I usually program Python, and there you mostly don't use any of apply, reduce, map, etc.
20:02jcromartieit works great with all sorts of wacky things in clojure
20:03jcromartieyou could use a map or set as a predicate for reduce
20:03jcromartieor any number of things
20:03jcromartieanything callable
20:03konr`I wish I could use github's search engine to find interesting examples
20:04seths,(map (partial nth (seq "abc")) [0 2])
20:04clojurebot(\a \c)
20:04konr`but "(apply " returns all sorts of things
20:04konr`including "this applies to ..."
20:09jcromartieGoogle code search... now if only it had some interesting Clojure code :P
20:12konr`It would be cool to be able to search for code using queries like "(reduce $FN ...) where $FN != +"
20:17janjanFunny, in another (older) part of my code I had had the same problem of 'how do I apply this func to that seq', the func being + in that case. I also didn't think of 'apply', but I did come up with reduce. But with the max case that didn't come up in my mind.
20:23hiredmanI do believe max and + both internally use reduce for more than two args
20:23rhickey_waddya think - is Clojure the borg? http://vintage-digital.com/hefner/misc/lisp-programmers.jpg
20:25jcromartieaw man, that is a riot
20:25jcromartieI love Forth vs Factor
20:25jcromartiethey're all brilliant
20:25konr`hahahaha
20:27jcromartieClojure is *Captain Picard as a Borg*, that's gotta count for something
20:28hiredmanI think it is import to keep in mind that is supposed to represent the view of a common lisp programmer
20:28janjanApparently CLers are afraid of clojure 8-]
20:30hiredmanI think it's http://www.loper-os.org/?p=42 in in picture form
20:31rhickey_hiredman: I thought that was the "zombie-reanimated corpse of a dream" guy
20:31hiredmanyeah
20:31hiredmanwell, what else is a borg?
20:31hiredmanI guess you get the groovy head gear
20:31rhickey_it's very funny in any case
20:38RaynesThe PHP and Haskell ones are hilarious.
20:45wilighiredman: Thanks exactly what I was looking for.
20:46Raynes"You’re looking at it wrong. It’s not meant to be a serious Lisp. It’s only cosmetically descended from McCarthy’s original idea. It’s an attempt to terraform the wasteland of the JVM. It fails, of course, but it does make it at least somewhat less likely that geysers of molten arsenic will pour through your floor at 1AM." Eh.
20:48hiredmankind of poetic
20:51hiredmanthe serious (common) lisp almost killed lisp completely
20:53jcromartieRaynes: is that from that Loper OS guy?
20:53Raynesjcromartie: No.
20:53RaynesIt was from a guy who was trying to defend Clojure, and ended up doing so with misinformation.
20:55jcromartiehah
21:15chouserI look forward to seeing how such arguments get adjusted once clojure starts maturing on other VMs.
21:20jcromartieClojure on LLVM will be a great day.
21:20jcromartieBut this guy has me thinking: how about building a "clojure machine?"
21:20jcromartie"clojure-all-the-way-down"
21:21jcromartiewith the major caveat that Java is OK
21:21jcromartieand the OS that Java runs on
21:22jcromartielet's say Linux and a JVM and then everything else implemented in clojure
21:22jcromartieit's most just UI at that point
21:23jcromartiebut you could start replacing the lower parts of an operating system with clojure code
21:23hiredmanthere are jvms that run without an os
21:23jcromartiewell there we go
21:23hiredman~google maxine java
21:23clojurebotFirst, out of 16000 results is:
21:23clojurebotMaxine VM
21:23clojurebothttps://maxine.dev.java.net/
21:23jcromartieYou could eventually build something like Genera but for Clojure.
21:23hiredman~google guest os java
21:23clojurebotFirst, out of 493000 results is:
21:23clojurebotVirtualbox guest OS networking on WinXP host : Tao&#39;s Sun Blog
21:23clojurebothttp://blogs.sun.com/tao/entry/virtualbox_guest_os_networking_on
21:23hiredmanbah
21:24jcromartieI mean obviously you're never going to have something like a "Lisp machine" that has hardware built to run Lisp.
21:26jcromartieit's too bad practicality and productivity have to get in the way of lofty goals and idealistic outlooks
21:26jcromartie:)
21:26jcromartie(not really)
21:54limuxin the lastest release lein.bat 1.1.0, it required leiningen-1.1.0-SNAPSHOT-standalone.jar, but there is not that file at all, except the leiningen-1.0.1-standalone.jar, why?
21:56devlinsfliebke: Hey, trying to get those fixes in chrono
21:57defn`Are there any HTML/CSS parsers for clojure?
21:57alexykwhat's a good lazy way to write nondecreasing? predicate for a seq?
21:58liebkedevlinsf: Great, I really like your api design (and your screencasts)
21:58defn`im looking for something like nokogiri
21:58devlinsfliebke: thanks. What build tool do you use?
21:58liebkemaven
21:58devlinsfAh
21:58devlinsfOkay, installing
21:59liebkesorry to do that to you :)
21:59defn`i guess the next logical question i have is, if there isnt a good XPath/CSS parser for clojure, what would you recommend in Java?
21:59alexyknothing like maven to get your juices going at night!
21:59devlinsfliebke: Eh, I haven't used it yet. I'll write this one off as a "Learning Experience"
21:59devlinsfliebke: :)
21:59alexykoh, the rage! oh, the evil monstrous energy!
22:00liebkedevlinsf: oh, you're in for a good time :)
22:00devlinsfGreat
22:00liebkedevlinsf: the existing incanter.chrono pom.xml file should work for you, you might not have to do anything
22:00devlinsfWith a little luck
22:04cemerickalexyk: nondecreasing?
22:05alexykcemerick: yeah!
22:05alexyklazy one
22:05alexykI have a reduce-driven one, but aint' lazy
22:05devlinsfalexyk: How about partition, map & some?
22:06cemerickalexyk: I'm not sure what you mean by 'nondecreasing'
22:06devlinsf[1 2 3]
22:06alexykcemerick: ok, simply increasing? will do.
22:06cemerick(iterate inc 0)
22:07alexyknondeacreasing? means for any subsequent x y, x <= y, increasing? means x < y
22:07hiredmanhe somehow wants a predicate to tell him that a seq only has values that increase in order, without actually looki ng at the seq
22:07hiredmanmadness
22:07alexykthe predicate checks an existing seq lazily and at any moment says true or false
22:07alexykbasically it bails once it feels violated
22:07hiredmanthat is not a predicate
22:07alexyk,used and betrayed by the seq
22:07clojurebotjava.lang.Exception: Unable to resolve symbol: used in this context
22:07hiredmanthat is map
22:08hiredman,(let [x [1 2 3 4 0]] (map > x (rest x)))
22:08clojurebot(false false false true)
22:08hiredman,(let [x [1 2 3 4 0]] (map < x (rest x)))
22:08clojurebot(true true true false)
22:08devlinsf,(every? #(apply < %) (partition 2 1 [1 2 3 4 3]))
22:08clojurebotfalse
22:08devlinsfThere you go
22:08defn`anyone have a recommendation on a good xpath/css html parser for clojure? java libs suggestions welcome
22:09cemerickalexyk: there's take-while if you want to consume until a predicate fails, but you have to look at a seq in order determine anything about it.
22:09devlinsfevery? is lazy, is it fails fast
22:10alexykdevlinsf: looks good, hope it's lazy...
22:10devlinsfEvery is eager, but it fails quick
22:10devlinsfAdd a call to Thread/sleep to see
22:10rhickey_devlinsf: I had a question about your latest video - why are all the multimethods variadic?
22:10alexykdevlinsf: easy to check, lemme load 100M twits
22:11devlinsfrhickey_: Ah. Check my work in incater
22:11rhickey_?
22:11devlinsfhttp://groups.google.com/group/incanter/browse_thread/thread/4d678e226b3a1f0a
22:12alexykhiredman: yours is good, but does all seq, while I need to fail asap
22:12devlinsfIt lets you optionally pass stuff, like a keyword to the string parser
22:12hiredmanalexyk: you cannot do that lazily
22:12devlinsfrhickey_ Granted, the multimethod could use some polish
22:13hiredmanyou want something to look at the whole seq, and yet some how not look at the seq
22:13alexykhiredman: well I want to consume the seq lazily and stop doing it once I see it fails the test
22:13rhickey_I still don't understand - to-ms takes and uses only one arg
22:13chouserdefn`: you're looking for a way to query/filter/lookup things in an html document?
22:13devlinsfrhickey_: I'm going to re-implement it as a protocol eventually, I'm too lazy to optimize now.
22:14hiredman,(let [x [1 2 3 4 0]] (take-while true? (map < x (rest x))))
22:14rhickey_devlinsf: I just think it's confusing, a newcomer to multimethods would be baffled
22:14clojurebot(true true true)
22:14defn`chouser: filter out specific xpaths, depending on whether a regex matches the content therein
22:14defn`and compose a new html doc from that information
22:14defn`i was trying to use enlive, but i dont know if it's well suited to my needs
22:14devlinsfEh, yeah, you might be right.
22:14chouserdefn`: enlive and zip-filter are the two most clojury solutions I know of.
22:14defn`im playing with htmlparser right now, but was wondering if anyone had any other suggestions
22:15kmurph79why is there a dot after File in this ex: (.listFiles (File. "."))
22:15devlinsfrhickey_: I was going for power, not easy to understand
22:15defn`im not clear on how to get the HTML of the tagsoup that enlive creates
22:15chouserkmurph79: (Foo. x) is the same as (new Foo x)
22:15kmurph79chouser: thank you
22:16defn`im doing something like (at (html-resource (as-url "http://...&quot;)) [:div#blah :p :b])
22:16rhickey_devlinsf: I don't see the power, you don't ever use the rest args
22:16defn`this returns a big ole mess of tagsoup -- anyone know how to turn that back into HTML?
22:16alexykhiredman: nice, thx!
22:17devlinsfrhickey_: I have another version where the :default uses (into {} params)
22:17devlinsfkeyword input
22:17chouserdefn`: I think there's an "emit" fn there somewhere.
22:18defn`chouser: ill keep playing -- thanks though
22:18chouseryou might be able to use clojure.xml/emit -- sorry, I'm not sure.
22:18rhickey_devlinsf: also to-ms-dispatch, very strange
22:18devlinsfYeah.
22:18devlinsfIt's an early mm
22:19devlinsfHmmm... maybe I shoulda polished it a little more
22:19rhickey_devlinsf: I thought the example was good, but those details make it very confusing
22:19rhickey_especially, people often make mistakes with custom dispatch functions, essentially doing some of the dispatch there, but rendering the multimethod 'closed'
22:20devlinsfTrue. I;m not quite sure how to dispatch on an abstract class
22:20ohpauleezis stuart halloway in here, I forget what he uses for his IRC handle
22:21devlinsfHence I'm looking forward to the protocol version
22:21rhickey_devlinsf: you can use class as your dispatch and the abstract class or interface as the dispatch value - it just works
22:21devlinsfOh
22:21devlinsfWell, that should clean some stuff up.
22:21rhickey_because multimethods use isa matching
22:21devlinsfnot equality?
22:21rhickey_right
22:21devlinsfGood to no
22:21devlinsfknow
22:22devlinsfSounds like I have correction #2 next week
22:22rhickey_devlinsf: the video series is a great idea
22:23devlinsfGlad to help
22:24alexykhiredman: take-while piles on "true"s, I only need one
22:25hiredmanalexyk: uh
22:25alexykevery? on top?
22:25hiredmanno
22:26hiredmanyou need to figure out what you actually want so that you able to clearly explain it. by that time you should be able to write it
22:31chouser,(every? true? (apply map > ((juxt rest seq) [1 3 4 6 7])))
22:31clojurebottrue
22:33alexyknice
22:34alexyknow for strings, is there anything better than replacing < by (< (.compareTo x y) 0)?
22:45chouser(< (compare x y) 0)
22:46chousernot much better. :-P
22:48alexykchouser: but generic for any types, right?
22:49alexykchouser: also, devlinsf has every? <seq>, and you have every? true? <seq> -- same?
22:52chouser'every?' takes two args
22:57alexykah right
23:16defn`hmm, how do i convert from hex to a string
23:17defn`I have the groupings ((\6 \4) (\7 \D) ...)