#clojure logs

2010-03-22

01:02MecIs there anything in java to see what the current relative path is?
01:17psykotic(System/getProperty "user.dir") i think
01:26arkrostHi! Can someone explain me how to create global var?
01:31Mecpsykotic: that does seem to be it, thanks
01:53psykotichaha, programming with promises from the repl is ridiculously annoying. the print function for IDerefs automatically derefs anything you try to print, even in a debug context like the repl.
01:53psykoticwhich means... it will block. it's very easy to do it by accident.
01:54psykoticpromises should probably have a custom print function that prints <undelivered> when a promise is not ready, so it's nonblocking
01:56psykoticit already does that for futures, from looking at core_print.clj, but not for promises
02:15psykoticfixed it, sent my code to the list
03:54LauJensenMorning team
03:56defnMorning Lau
03:56defnWhat's new?
03:58LauJensenCells are pretty new, so I'm looking forward to getting acquainted with them
03:59defnyeah i have been stuck in the past waiting for the full 1.2 release
04:00LauJensenHave you put cells to good use already?
04:00defnnot yet, no
04:01defnive been watching with great interest, though :)
04:01LauJensenyeah, the mapx, filterx implementations look very very promising
04:02vegaiwhat are cells?
04:02underdevits where they keep me after i get arrested.
04:02tomojI can't wait for someone to explain it to the laity
04:02LauJensenvegai: http://www.assembla.com/wiki/show/clojure/Cells
04:03tomojI tried for a bit to decipher that but gave up
04:03LauJensenvegai: Its a low-level mutable construct which uses locks in some clever way, so that its safe and as fast as java, so that you can implement map and filter in clojure without speed loss
04:03LauJensen(as far as I understood, might be wrong/dillusional)
04:03tomojwe have speed loss on map and filter?
04:04LauJensenIf not, I dont see why Rich would start out by implementing them
04:04tomojI guess that means multithreaded map and filter?
04:04tomojlike pmap?
04:04LauJensenNo I dont think so
04:04defnme likey pmap
04:05vegaisort of STM?
04:05vegaior did clojure already have STM elsewhere
04:05LauJensenBut there's already a lot of those standard functions implemented for parallel use in the par branch
04:05LauJensenvegai: Not like STM
04:05hircusLauJensen: just followed your "Approaching Productivity" guide, and the Emacs color theme looks fine on GTK+ but when using "emacs -nw" I get a green background, odd
04:05Chousuketomoj: the speed loss comes from all the thunks you need.
04:05vegaiLauJensen: dataflows?
04:06vegaireactive programming?
04:06Chousukecells are not dataflows either.
04:06underdevlol
04:06Chousukethey're basically a reference type for managing "dangerous" things.
04:06Chousukesuch as java objects or transients
04:06defnah-ha!
04:06defnthat makes sense to me
04:07tomojso this lets you do pmap on arrays?
04:07defnhircus: your terminal doesn't support 256 colors
04:07LauJensentomoj: You can already do that
04:07tomojoh, hmm
04:07LauJensenBut yea, one important thing which I heard, was that cells should replace transients in 1.2
04:08defnwhat of chunked seqs?
04:08defni thought chouser said something about chunked seqs -> cells
04:08Chousukeremember though that this is still all speculative :P
04:08defn:)
04:08LauJensenI think that sequence parsing usings cells will make them obsolete, because cells are faster than regular chunked seqs
04:08LauJensenDue to less allocation
04:08LauJensenAnd when thinking about it, I think that was the motivation for the mapx and filterx functions
04:09LauJensenhttp://gist.github.com/311542
04:09defnyeah i think that makes a bit of sense
04:09defnbut like Chousuke said -- no way to be sure
04:09defnwell there is a way to be sure
04:09defnyou need to be rich
04:09Chousukethe performance improvement supposedly comes from being able to have a "virtual" seq. ie. the cell represents the seq and as long as the user does not actually request the seq itself, the cell will never even create it.
04:09hircusdefn: that's probably it, some of the default color themes are displayed odd too
04:10defnhircus: yeah you gotta hack your terminal up a bit
04:10defnget the proper TERMINFO and TERM vars setup
04:10defnyou might need to compile a terminfo file
04:11defnhircus: i beleive the emacs wiki has stuff about using emacs from the terminal, some of it is very helpful
04:11LauJensenChousuke: That sounds like a minor improvement over chunks
04:11LauJensenAlthough, I would like to reclaim the lazyness, chunks make modelling something like Mersenne impossible
04:11LauJensenMersenne Primes that is
04:11hircusdefn: thanks, will look it up. I don't recall having this problem at home, but the work computers have an odd Linux setup
04:11ChousukeLauJensen: apparently it's a lot faster
04:11LauJensenoh
04:13ChousukeLauJensen: I think the idea is that a cell-based seq can be transient, and if a transient-seq-aware function uses it, the seq can stay virtual. ie. it can just be a stream of values, with no caching.
04:13ChousukeI hope I understand it right though :P
04:15hircusdefn: export TERM=xterm-256color -- heh :)
04:15defnhircus: did that do the trick for you?
04:15defnsometimes that's all it takes
04:15LauJensenChousuke: No caching, as in reuse equals recomputation ?
04:16defni run rxvt-unicode so i have a bit more of a pain
04:16hircusdefn: yup, that's all. Wonder why that's not the default
04:16hircusdefn: gnome-terminal here
04:16defni suggest rxvt-unicode :) it'
04:16defnit's faster -- i use it with xmonad and run it as a daemon
04:16defnso i can spawn terminals like mad
04:18ChousukeLauJensen: you're not supposed to reuse it
04:18ChousukeLauJensen: the point is that it goes through a pipeline and gets fully consumed somewhere (or maybe finally transformed into a real seq, I guess)
04:19LauJensenOk, but thats a feature loss compared to present day seqs
04:19ChousukeI don't see how
04:19Chousukeyou don't care about the intermediate seqs in (reduce (map ... (filter ... (foo blah)))
04:19Chousukeor whatever
04:20LauJensenIm trying to think of an example where I do
04:20Chousukewell, in those cases you just need to make the transient seq a real one.
04:21LauJensenTrue
05:18underdevhi! when using lein project & swank-clojure-project, there is some :dev-dependency that needs to be added to the the project.clj file, but i can't remember what it is. google isn't helping. does anyone know what it is off hand?
05:19LauJensenunderdev: skip google and go directly to www.bestinclass.dk
05:19LauJensen :dev-dependencies [[swank-clojure "1.1.0"]])
05:19underdevLauJensen: the pittsburgh (pennslyvania, usa) clojure users group just discovered your blog
05:20LauJensenunderdev: from Reddit Clone in 91 lines, which covers deployment as well
05:20underdevookay, thanks
05:20LauJensenunderdev: great :)
06:28jeffmessis it possible to do graph animations over time with Incanter?
06:35esjjeffmess: yes. directly using the Processing interface. if using the jfreechart you'll have to bung by redrawing each frame (I think).
06:37jeffmessesj: awesome, are there any tutorials showing this being done?
06:38esjAs far as processing goes I think the Incanter tests / examples document it (I remember a bouncy ball example of some sort). Processing itself is documented in its own right.
06:38jeffmessesj: thx
06:39esjgood luck, I've been planning a similar thing myself for a while, but still working on the plumbing of 'what lies beneath'
08:17Licenserdefn: greetings to you :) I'm playing a bit more with walkon if you don't mind?
08:33powr-tocIs anyone here running compojure? I'm wondering how you can restart the jetty server at the REPL with a new app or set of routes?
08:33tomojyou often don't need to
08:33tomojer, are you an emacs/slime user?
08:33powr-tocyeah
08:34powr-tocre-evaling didn't seem to cause the definitions to update
08:34tomojif you started the jetty server in the slime repl, recompiling the file that defines the routes works for me
08:34powr-tochmm... I'll try again
08:34tomojpowr-toc: https://gist.github.com/3e4088d23fcc1e316dde
08:34tomojI do that
08:35tomojthen if I'm at a repl I just do (start-server) to start it up
08:35tomojrecompiling that file or a handler usually makes the update live
08:36tomojmaybe you have to recompile the dependent files, then recompile the files that require them, etc..
08:36tomojI think the :reload tags can help, not sure really yet
08:37powr-toctomoj: hmm.. I'm using compojure 0.4 and ring 0.2-snapshot... I use run-jetty to start the server, is there a difference between that and jetty-server ?
08:38tomojI'm not sure, really
08:38tomojdunno what run-jetty is
08:38powr-tocwhat namespace is jetty-server from?
08:38tomojI don't think I've been using 0.4
08:38tomojhttps://gist.github.com/355412ea5c68d123eedc
08:38powr-tocwell 0.4 is pretty bleeding edge
08:39tomojthat is the relevant part of my ns decl
08:39tomojI think this is 0.3.2
08:40powr-tocyeah, I think 0.4 uses ring for starting jetty etc...
08:40tomojdunno anything about that :(
08:46chousercemerick: do you use polyglot maven?
08:47chouseractually, does anyone here?
08:47cemerickchouser: no, just the regular clojure-maven-plugin (which might sit underneath the clojure polyglot stuff, actually)
08:47chouserI think it can, yeah.
08:48cemerickI (unsurprisingly) don't think much of the fever to have sexprs everywhere, no matter the consequences. *shrug*
08:49chouserwhat intruiged me most was having clojure logic in the pom instead of ... what, xml logic. :-/
08:49cemerickwell, poms are entirely declarative, so there's no logic, per se.
08:51cemerickBesides, the tough bits of any nontrivial build aren't the "logic" or general process, it's tying together all the disparate pieces that go into making the build work. The glue is the commodity, not the stuff you're gluing together.
08:57chouserperhaps it would be the ability to write maven plugins in clojure that would be the killer feature for me, not writing poms in clojure.
08:58cemerickwell, you can do that today
08:58chouserI suspected as much
09:00cemerickmaven's architecture has a lot going for it, but the real value is in the ecosystem. Being able to hook in any of 100's of plugins that take care of otherwise horrendously-complicated build tasks is glorious. The concrete stuff -- XML, local repo formats, whatever -- are entirely inconsequential IMO.
09:00chouserI'm just mulling a swan-dive off the maven cliff. Trying to get an eye on the bracken I'm likely to hit on the way down.
09:02cemerickYou'll feel yourself drawn to the big-3 IDEs -- their maven tooling is pretty spectacular these days. Really learning about how lifecycles and phases work is foundational, and shouldn't be skipped. Profiles are ingenious, and *will* save your bacon. In an organizational setting, deploy nexus, and only pull deps through that (ensures that external network issues don't hinder your builds).
09:03AWizzArdcemerick: :-)
09:03AWizzArdThank you for thinking about my network issues *g*
09:04cemerickAWizzArd: well, you're an outlier in that area. I was thinking more along the lines of "the cable's out for the afternoon" or "maven central is down", etc.
09:05AWizzArdcemerick: is it possible and worth to think about moving maven functionality into Leiningen?
09:06cemerickAWizzArd: I don't know that that's a comprehensible notion.
09:08cemericklein uses maven's dependency mechanisms. In general, it offers a subset of maven's capabilities (given the latter's plugin ecosystem). The sexpr syntax is the big draw AFAICT, which I personally don't think should be a relevant factor when choosing a build system (but if you do, the nascent polyglot maven project(s) await).
09:10chousercemerick: I actually think it's the percieved simplcity of setup -- the friend FAQ, the clojure-specific help, etc.
09:11chouserbah, can't type: simplicity, friendly
09:11chousercemerick: nobody wants to think about the build system, they just want to get on with the code.
09:11ericthorsenchouser: I'm just about finished moving all the enclojure builds to maven. I was hesitant on the xml and was intrigued by lei sexpr support but in the end I was looking for simplicity. The IDE support has been great and once you get your head around what maven it taking care of for you, the xml part was not much of a bother.
09:11cemerickMight have to get that quick-start clojure-maven-plugin blog post up today.
09:12cemerickchouser: right, until they actually get build requirement #2, and start reimplementing javac invocation. :-x
09:12AWizzArdI would also think that it could be an interesting psychological “trick” if it were possible to do all/most of the build stuff in Clojure. The complexity will stay about the same, but people like I would perceive it as easier to use.
09:12LauJensenericthorsen: I heard a report recently that on a large software project "maven related activity" accounted for 1500+ hours, which gave me the clear impression that its a dinosaur which needs to be avoided?
09:13chousercemerick: that kind of quick-start guide could be really key to pulling people that way, I think.
09:13chouserericthorsen: interesting thanks.
09:14chouserfwiw, talk of IDE pull does not attract me. I'm willing to overlook it in the hopes that such integration is not necessary. :-)
09:14cemerickLauJensen: I saw that piece. Quite a bit of puffery, IMO. Let's do a tally of hours spent twiddling ant files, or reimplementing stuff for lein, or monkeypatching stuff in rake scripts.
09:14chousersounds too much like "Java is a fine language as long as you have sufficient IDE support" ... to generate code, refactor, etc. I'd rather have a good language.
09:14chouserI'll just assume that doesn't apply the same way to maven. :-)
09:14ericthorsenLauJensen: I cannot speak to what it is like for very large projects as mine is only a few. It solves a complex problem and has a large eco-system which is what attracted me to it.
09:15cemerickchouser: By no means necessary. However, when you see "code" completion on artifact revisions, etc., it's hard to not be impressed.
09:15LauJensencemerick: ericthorsen ok
09:15LauJensenMaybe the main attraction of Clojuresque and Lein is that they're both so young nobody has really been burned by them on bigger builds :)
09:16chouserour project at work does not live mainly in the Java ecosystem, so I'm still pretty hesistent about using maven there. But for clojure-only projects, if maven is better than lein, we should also make it easier and more popular. :-)
09:16cemerickchouser: a good language does nearly nothing for you w.r.t. builds IMO. This is why I could care less what the chrome is on the build system.
09:16chouserno offence to technomancy|away
09:17ericthorsenLauJensen: possibly...I am also using to build an IDE plugin :) Once people start using maven projects for the myriad of different java project types, getting the dependancies and having a REPL with a properly setup classpath is much simpler
09:17chousercemerick: i'm not speaking of maven's language in that analogy, just the sense that "it's easy to use if your IDE has integration"
09:17LauJensenericthorsen: Yea I was very happy to actually try out Enclojure, its come a long way :)
09:18Licenserdefn: http://playground.licenser.net:3000/walton.html if you want to have a look
09:19LauJensenLicenser: dead link
09:19LicenserLauJensen: not for me o.O
09:19chouserIDEs scare me. I assume this is a personal problem. :-/
09:19LauJensenchouser: It is :)
09:20ericthorsenLauJensen: Thanks...it will be easier to extend as well being part of maven world since contrib is there. Simpler to pull is known versions, etc.
09:20ericthorsenchouser: They are much scarier from the inside :)
09:20chouserLauJensen: what are you grinning at? emacs is not an IDE.
09:20LauJensenchouser: ehm... yes it is, among other things
09:21AWizzArdWhen I want to work with directories, is then java.io.File the best class to use?
09:21Chousukechouser: emacs is not. CEDET is :P
09:22Chousukeor actually, CEDET is the foundation of multiple IDEs as far as I understand
09:22chouserericthorsen: yeah, I wrote a patch for enclojure early on. But I won't hold what I learned against NetBeans. :-)
09:22LauJensenAWizzArd: Yea I think so
09:23AWizzArdLauJensen: and do you know a better way of (File. (str my-file "/next-dir/")) if I want I want to cd into another dir?
09:23LauJensenDo you actually need to change the working directory, or do you need to recursively consume files?
09:23AWizzArdchanging the working directory
09:24cemerickAWizzArd: you cannot change the working directory of a java process.
09:24LauJensenAWizzArd: true what cemerick said, but File can construct with 2 args right?
09:25AWizzArdI don't want to change the wd of the process. I just have a str representing a path to a dir, and another str representing a subdir
09:26LauJensenSo how did wd changing come into this?
09:31AWizzArdbut as I don't know if my code runs on Linux I can not simply (str dir "/" subdir) as dir may already end in a slash, or even a backslash
09:31AWizzArdfirst making dir a File, then getting the canonical path allows me to add a File/separator and then concat it with subdir, which first should be freed of slashes/backslashes
09:32cemerickAWizzArd: if you're worried about being cross-platform, then it's a bad idea to go around glomming strings together. Use the File api that you have available to you, which will account for platform-specific details.
09:33LauJensenAWizzArd: http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#File(java.io.File, java.lang.String)
09:33chouserAWizzArd: File ctor can take two string args: base dir string and then relative path string.
09:33LauJensenchouser: keep up now, thats what the Emacs guy just linked to :)
09:34AWizzArdok, that sounds good
09:34AWizzArdthanks you three
09:55licoressewith (map #(.getWidth %) (seq (. @c getComponents))) I get a list of the widths of some components, how can I use reduce to compute the total width ?
09:56LauJensenreduce + ?
09:56hiredmanI would use appply, and you don't need that call to seq there
09:56LauJensenhiredman: Why apply ?
09:56LauJensenOr is appply something special, like pl ?
09:56licoressehow would reduce know that I am interested in the getWidth method of component?
09:57hiredmanLauJensen: + is var arg and uses reduce interally
09:57LauJensen(->> (.getComponents @c) (map #(.getWidth %)) (reduce +))
09:57hiredmanlicoresse: it doesn't, but you already have the map
09:57hiredmanapply +
09:57licoresseLauJensen: ah, great
09:57licoressethanks
09:58LauJensenhiredman: Im not sure its that simple, I remember cgrand arguing quite heavily for reduce in all cases but apply str
09:58LauJensennp licoresse
10:26spariev,(reduce conj (map (fn [k] { k (name k)} ) [:a :b :c]))
10:26clojurebot{:c "c", :b "b", :a "a"}
10:28sparievis it ok to process big vectors this way ?
10:28chousersure
10:29chouserthough I guess I'd suggest using 'into'
10:30chouser,(into {} (map (fn [k] [k (name k)]) [:a :b :c]))
10:30clojurebot{:a "a", :b "b", :c "c"}
10:32sparievI'm worried about performance of this snippet on big vectors - shouldn't I somehow use transients there ?
10:34chouserinto uses transients. :-)
10:35chouserand map on a vector uses chunked seqs, so you really should be good-to-go.
10:35sparievcool, so into version will be faster/allocate less memory that reduce ?
10:35chousershould be faster and less GC churn, yes.
10:36chouserthough of course you should measure your actual use case and see if it's acceptible and if not where the real problem lies.
10:36sparievgood to know, thanks chouser
10:36chousernp
10:37chouseralso shorter, which is how you know you're using a good language and api: the shorter code is more correct. :-)
10:47foguschouser: So J and APL are flawless? :p
10:47chouserhmph
10:49Licenserwhgat is J and APL?
10:49chouserlanguages. succinct ones.
10:49Chousukegoodness is a function of comprehensibility and expressiveness, both of which are functions of length :P
10:50esjJ is succinct in the way that Tyson is tough.
10:50chouserRequiring custom printers and type-ball heads may be too high a price for succinctness, but J is indeed intruiging.
10:50esjChousuke: and that function is, in turn, a function of the user.
10:51fogusAgreed. I would love to dive into J one day
10:51chouserbut actually I meant within a given language or api -- if the correct code consistently requires more code, something is wrong.
10:52chouserI'm thinking of prohibitions against default copy constructors in C++ for example.
10:52sparievI have method setFacetSpecs() in java class, which is a setter for _facetSpecMap.
10:52sparievThen I do (.setFacetSpecs specs) I get exception java.lang.IllegalArgumentException: No matching field found: FacetSpec for class ...
10:53spariev at clojure.lang.Reflector.getInstanceField(Reflector.java:245)
10:53sparievhow can I tell clojure to look for method, not instance field ?
10:53chouserthat's weird.
10:54chouserspariev: setFacetSpecs takes no parameters?
10:55sparievchouser: oh, sorry, missed one arg, it takes one parameter, something like (.setFacetSpecs browse-request specs)
10:56chouserthat looks nothing like a field lookup or field 'set!' -- you're sure that's the line causing the error?
10:56chouseryou might try hinting the first arg -- you can sometimes get clearer error messages.
10:56chouser(.setFacetSpect #^BrowseRequestThingy browse-request specs)
10:57sparievthanks, I'll try
11:11sparievfigured this one out, was a typo in ctor call, sorry for the noise
11:14powr-tocI took a look at labrepl today... but I still can't quite figure out how it's supposed to be used... what workflow/benefits does it give over just having some HTML tutorial and a standard clojure REPL?
11:19chouseroh dear.
11:19chouserI just spent much too long on what turned out to be a misplaced close-paren.
11:20chouserIf I had requested this block of code be re-intented, I would have seen the problem immediately. :-/
11:22chouser(let [y z] (if-let [x (foo)] (bar x)) (log-error))
11:22chouser(let [y z] (if-let [x (foo)] (bar x) (log-error)))
11:22chouser*sigh*
11:23hiredmanrainbow parens!
11:23chouserI doubt I would have noticed the minor difference in colors. :-/
11:24hiredmanit's not really minor
11:24tomojanyone know if there are clojure jcloud docs around?
11:30Chousukewith paredit you wouldn't have been able to type that wrong ;P
11:30dnolenchouser: that's one advantage of paredit. If you have a misplaced paren it flips out and you can basically no longer type. Annoying but in a good way.
11:30chouserheh
11:32chouserChousuke: do you now use arrow keys to navigate a clojure source file? Or hjkl?
11:33Chousukechouser: mostly regexp search, actually
11:33Chousukebut arrow keys, yes.
11:33chouserno more viper?
11:33zmilain the dvorak keyboard layout the hjkl are placed not so nice as in qwerty :)
11:33Chousukehaven't been using it for a long while
11:34chouserChousuke: ok
11:34chouserzmila: yeah
11:34esjzmila: I know your pain
11:34arohnertomoj: AFAIK, just the docstrings
11:34arohnertomoj: I read all of the clj source as well
11:35tomojarohner: yeah, getting help in #jclouds
11:35tomojthe source indeed
11:35arohnerspeaking of
11:35arohnerbah, technomancy is away
11:35arohnerI was going to ask him what his plans are on the clojure API
11:35tomojhe's working on it?
11:36tomojthat is good to know
11:36arohnerhe's a jcloud committer
11:36arohnerand I saw a few emails from the maintainers asking him to make changes to the clj API
11:37arohnerthe current API is not very clojure-y, and I've been writing my own bindings to accomplish what I want
11:37tomojbindings over the java?
11:37tomojor just over the clojure stuff?
11:38arohnerI'm mainly calling the java directly
11:38cemerickchouser: eh, someone beat me to it: http://learnclojure.blogspot.com/2010/03/clojure-maven-emacs-eternal-golden.html
11:38cemerickI'll probably post anyway, to provide a version without the emacs and command-line dross.
11:38chouserheh. I just nested my closures too deeply: java.io.IOException: File name too long from clojure.lang.Compiler.writeClassFile
11:39hiredmannice
11:41RaynesI wish Ioke had multimethods. :(
11:42chousercemerick: nice, thanks for that link.
11:43chouserhm, is it true that a lib built using maven is easier to add to a project that uses lein than the other way around?
11:43chouseroh, I guess you don't usually build dependent libs from source either way, so perhaps it doesn't matter?
11:44Chousukeisn't lein built on maven? :/
11:44chouserChousuke: that was my understanding as well, but I've been corrected.
11:46Chousukeone thing I like about lein is that I can get it to start a clojure repl anywhere
11:47Chousukemaven apprently requires a pom.xml for that to work, at least by default. :/
11:48sparievwith lein install you can install your lib in maven's local repository, so there is no difference IMO
11:49cemerickChousuke: IIUC, lein only uses maven's dependency mechanisms
11:50cemerickchouser: are you asking about multi-module projects?
11:51Chousukehm, my .m2 dir is 50MB
11:51Chousukethat's a lot, considering it has the dependencies for maybe two projects besides clojure and contrib :P
11:52Chousukeokay, three
11:52chousercemerick: no, about clojure libs that want to make themselves as easy to depend on as possible.
11:53cemerickchouser: Ah. I have no idea how lein does deployments. `mvn deploy` is how it's done in maven-land.
11:59phfis there fix to null pointer exception when doing slime-edit-definition while connected to a jar'ed clojure program?
12:01tomojhmm
12:01tomojit works for me
12:01tomojelpa clojure-mode and swank-clojure?
12:02tomojand, how are you starting clojure?
12:10cemerickThe inability to scope methods to particular namespaces is growing into a bit of a problem.
12:10tomojhmm?
12:11tomojhmm, I think I understand what you mean
12:11tomojyou get one hook into the multimethod, and that's it
12:11tomojeveryone shares that hook
12:11cemerickright
12:11tomojmaybe you could define a dispatch function which can scope to namespaces?
12:12tomojthen a macro or two to use it easily?
12:12cemericktomoj: well, in this case, the multimethod is defined by third-party code.
12:13tomojoh, yeah, so they define the dispatch function already
12:13tomojlame indeed
12:13tomojhow do haskell's typeclasses handle this?
12:13cemerickNo idea.
12:13chousercemerick: I don't understand -- you can have a defmulti by the same name in a different namespace
12:14tomojthen you have to redefine all the methods in the third-party code, though, don't you?
12:14chouser...and you can have methods dispatching on keywords with the same name but different namespaces resulting in different defmethods being called.
12:14Chousukeif you're using a multimethod you need to accept the fact that anyone can define a method on it.
12:15cemerickchouser: except I have no control over the dispatching fn
12:15chouseroh, you want to "inherit" some defmethods but the have different ones added in different namespaces for the same keywords?
12:16cemerickso in this case, I'm wrapping the multi with (if (some-predicate-here) (do-special-thing) (call-existing-multi ...args...)))
12:16cemerick"inherit" is a decidedly bad term in this case
12:16Chousukeisn't it possible to get all the methods on a multimethod?
12:16Chousukethere's some Java method for it.
12:17Chousuke... too many diffrent methods in these sentences. :P
12:17chouseryou want multiple dispatch functions that are somehow automatically composed based on namespace? I clearly have no idea what you're talking about. :-)
12:17cemerickChousuke: yes, but I'm not sure what that'd get me.
12:18Chousukecemerick: you could create a new multifn and take existing methods from another :P
12:18Chousukepossibly. I haven't tried
12:18cemerickChousuke: except the dispatch fn is opaque.
12:18AWizzArdHello performance Gurus. Problem: I have 1-1000 substrings sub1 to sub1000 that I want all to replace by string S inside a big text string T. Example: subs1-subs3 are ["clojure lisp", "the clojure programming language", "clj"] and I want them all to be replaced by "Clojure" (my S in this example).
12:18AWizzArdNow the thing is: I have not only one set of sub1 to subN and one String S, but I have 1700 of those. What is a very performant way to take a text T and replace all my 1700 sub1-subNs by S1-S1700 in T? Ideas?
12:19AWizzArdDo I want 1700 regexps of form #"(sub1|sub2|sub3|...subN)" and do a (.replaceAll T r S) 1700 times? Is using JavaCC better for this? Are there other existing solutions? Bake something myself?
12:21chouserI would indeed be tempted to try #"(sub1|sub2|sub3|...subN)"
12:26AWizzArdI thought about traversing the T once, collecting all substrings that need a replacement and look those up in a hashmap off 1700x 1-1000 entries and then build a new string out of that.
12:27AWizzArd... collecting all start/end positions of substrings ...
12:45TalkingHeadNew to clojure, and have been looking at the Geonames Java API
12:45TalkingHeadWondering what the clj equivalent of would be: ToponymSearchResult searchResult = WebService.search(searchCriteria)
12:46TalkingHead(ToponymSearchResult. (WebService/search tsc)
12:46TalkingHeaddoesn't seem quite right
12:46TalkingHeadwith tsc being:
12:46TalkingHeadtsc (doto (ToponymSearchCriteria. )
12:46TalkingHead (.setQ (str loc ", " country)))
12:48hiredmanTalkingHead: (ToponymSearchCriteria. ) is new ToponymSearchCriteria()
12:49hiredman(which doesn't apear in the java code)
12:49notallamai just did something somewhat useful with my monad library: http://github.com/hclarke/clojure_combinators/blob/master/src/examples/parser.clj
12:49notallamastill not sufficiently magical, but it's getting there.
12:49TalkingHeadgotcha
12:49hiredmanso in order to translate to clojure you first need to understand what is happening in the java
12:50ipostelnikTalkingHead, you want to do something along the lines of (let [result (WebService/search tsc)] ... your code to use result ...)
12:50hiredmanstuff on the left of an = can generally be ignored
12:51ipostelnikTalkingHead, result will be bound to the return value of the web service inside let
12:53TalkingHeadthanks - makes sense
13:18Licenser_greetings my lispy friends!
13:21tomojsalutations
14:05arkrostHi! Explain please how can I use set! and var-set
14:18dnolenarkrost: there's documentation for set! on the clojure website in the special forms section. var-set can only be used with thread-locally bound vars. what are you trying to do?
14:56dcnstrcthow do you specify that a regex should be case insensitive in clojure ? Ruby also has regex literals and to do what I'm talking about would like like this: puts "match" if "Ninjas are cool" =~ /ninjas/i
14:57dcnstrctthe case insensitivity specifier thingy is built into the language's regex syntax.. is it the same in clojure ?
14:58drewr,(re-find #"(?i)ninjas" "NiNJaS")
14:58clojurebot"NiNJaS"
14:58dcnstrctneat
14:58dcnstrctare there a bunch of other flags you can use in (?) ?
14:58dcnstrctI
14:59dcnstrctI'll google it. thanks
15:00drewrin http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html, look for "special constructs"
15:45edbondwhat does :: means? like ::result
15:45rhickey,::foo
15:45clojurebot:sandbox/foo
15:46rhickey,*ns*
15:46clojurebot#<Namespace sandbox>
15:46zaphar_psedbond: it automatically qualifies the symbol with the the namespace it's in
15:46zaphar_psit's handy for DIY types
15:47edbonddidn't symbols global?
15:47edbondsorry, I thought about keywords
15:48edbond:result
15:48chouseralso handy for adding keys to maps that may be used by multiple namespaces, like metadata on objects that are getting passed around.
15:51drewredbond: the namespacing is just syntactic
15:55Crowb4rIt's a shame clojure did not do GSoC, I would really use a job. :p
16:00vegaiis clojurebot's source available?
16:01LauJensenclojurebot: where are you?
16:01clojurebothttp://github.com/hiredman/clojurebot/tree/master
16:01vegaioh, he answered to "source" privately, I just saw :)
16:01vegaicheers
16:02vegaidoes its evaluator have some sort of sandboxing?
16:03chouseryes
16:03chouser,(java.io.File. "/")
16:03clojurebot#<File />
16:03vegaiah, it implements its own
16:03chouser,(file-seq (java.io.File. "/"))
16:03clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission / read)
16:03chouser,(def five 5)
16:03clojurebotDENIED
16:03vegai:)
16:04Raynesvegai: Check out http://github.com/Licenser/clj-sandbox
16:04vegaiRaynes: that looks nice
16:04Raynesvegai: Me and Licenser_ have been doing some hardcore testing and such on it over the last few days. It's in good working order. ;)
16:05Licenser_vegai: yap thanks to Raynes it might actualy be usefull for people aside of me :P
16:05_invisHi all
16:05RaynesLicenser_: You're too kind. <3
16:06_invisGuys could you tell me how I can multiply LazySeq with Number ?
16:06Licenser_nah, it's very important
16:07Licenser_(reduce * (range 10))
16:07Licenser_,(reduce * (range 10))
16:07clojurebot0
16:07Licenser_,(reduce * (range 1 11))
16:07clojurebot3628800
16:07Licenser_there we go
16:07_invisemm
16:07_invis(def Fi (range 0 60 1)) for example
16:07_inviswith 150 for example :)
16:08kotarak,(map #(* 150 %) (range 0 6 1))
16:08clojurebot(0 150 300 450 600 750)
16:08_invisI should take Seq with for each Fi*150
16:08_inviswow
16:08_invisThank you :0
16:08_invis*:)
16:08kotaraknp
16:08_invisWhat # does ?
16:08Licenser_ah :)
16:09_invis^^
16:09kotarak_invis: #(foo %) is equivalent to (fn [x] (foo x))
16:09_invisI am from java :)
16:09_invisok
16:09_invisty
17:02RaynesCan you use Clojure on JavaME?
17:03programblelawl
17:03programbleknew you were going to ask
17:03programbleright, afk
17:18seangroveAnyone in here used opengl with clojure?
17:18seangroveI'm having a hard time loading a texture and referencing it later on
17:20LauJensenseangrove: Read this (all of it) http://ideolalia.com/
17:20seangroveOh, looks good
17:21LauJensenYea, Zach is very inspirational
17:21seangrove Damnit
17:21seangroveI've built all this up on cloggle, now there's a better lib, heh
17:22LauJensen:(
17:22LauJensenpenumbra is here to stay
17:23LauJensenseangrove: I did an automaton which ran at about 300 ms per iteration of a 160x160 board, cgrand optimized it, so it ran at something like 2 msecs per iteration, then Tellman put it on the GPU using Penumbra, and it still ran at about 1.6 msecs per iteration, but now on a 2000x2000 board
17:23seangrovewow, crazy
17:24LauJensenThats the word
17:24rfgseangrove: I'm using LWJGL.
17:25rfgAnd loading textures.
17:25seangroveYeah, I guess I should have used jwgl instead of jogl
17:25seangroveI have a slightly more general clojure-java interop question
17:25rfgIn fact I'm using lwjgl and jogl.
17:26seangroveIf I use a proxy class in clojure, and then I have an error in the code (or what would be an error in java land), I don't get any error output at all, it just silently fails
17:26seangroveI have to litter my class with output to find out where it's stopping its execution
17:26seangroveI lost hours and hours finding this out because I wrote .getGl instead of .getGL
17:27seangroveDoes that seem normal?
17:27rfgseangrove: try looking at *inferior-lisp*, assuming you are using slime.
17:27seangroveI am using slime - would that have given me some error output?
17:27rfgQuite possibly.
17:30seangroveI'll definitely keep that in mind
17:30seangroveThe jogl issue I'm having is loading a texture into memory without a gl context
17:31seangroveHere's what I have so far - progressively building up the examples: http://pastie.org/881700
17:32seangroveBut the one I'm concerned about is the texture-window
17:32seangroveIt *works*, in the sense that it displays the texture on the quad, but it does it by loading the texture into memory everytime display is called, which obviously is not right
17:33seangroveBut I can't load the texture before the proxy class (which would be my preferred way of doing it)
17:33seangroveI thought perhaps I should load all of the textures and store their int-ids in some global variable?
17:34lpetithello
17:36rfgseangrove: What I do is, with a GL context already available I load in the textures I'm going to use and save the glGenTextures numbers in a ref.
17:37seangroverfg: Do you have an example?
17:42rfgseangrove: this is my texture.clj: http://pastie.org/881721
17:43seangroveHeh, I like the " ;; Massively side-affecting
17:43rfg:)
17:43rfgI like to write down when things have side effects.
17:46rfgThen I have this function to store the ids in a ref: http://pastie.org/881725
17:47rfgThe function alters textures which should really be called *textures*.
17:48clojurebotfunction is <Chouser> there is one class per fn, one instance of it per closure
17:48seangroveI assume that clojurebot was not referring to your code, rfg?
17:49rfgI should think not.
17:49seangroveI haven't used dosync or alter at all yet, just looking up those
17:49seangroveOk, I think I understand this
17:50seangroveBut you can only call this while you have an opengl context, right?
17:50rfgIndeed.
17:50rfgI open the window first.
17:51seangroveAlright, it's all coming together slowly in my head
17:51rfgMy texture.clj was just a translation of an example from the lwjgl website, I think.
17:51seangroveI haven't used opengl before, so it's been a bit of a tough learning curve
17:52seangroveBeen fun though, have an opengl rss reader working, and onto texture mapping
17:52clojurebotFunction literals are cute, but overused
17:52rfgseangrove: Here's what it looks like: http://img715.imageshack.us/img715/7810/64460624.png
17:53seangroveThat's the lwjgl example?
17:53rfgNo that's my clojure.
17:54seangroveWell, certainly looks nice in any case
17:57seangrovePenumbra looks pretty amazing though
17:58rfgYeah, I've not tried it yet.
17:59dnolenseangrove: rfg: it's excellent. very idiomatic, http://github.com/swannodette/clj-nehe/blob/master/src/clj_nehe/tutorial11.clj
18:00seangroveSeems to be, yes
18:10seangrovednolen: So you've used penumbra?
18:15Licenser_hey defn_ you're around?
18:51seangroveI'm curious about the meaning of nested arglists to defn
18:51seangrovewhat is (defn example [[x y] z]) ?
18:51Raynesseangrove: It's destructuring.
18:53kotarak((fn [[x y] z] [x y z]) [[1 2] 3])
18:53kotarak,((fn [[x y] z] [x y z]) [[1 2] 3])
18:53clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--7214$fn
18:53kotaraknot my day...
18:53kotarak,((fn [[x y] z] [x y z]) [1 2] 3)
18:53clojurebot[1 2 3]
18:54seangroveI see, so if you're being passed a series of arguments in a manner you don't really like, you can use that to remap it?
18:55kotarakseangrove: I wouldn't put it like that. You should only use destructuring in arglists if it's part of the contract.
18:56seangroveI think I understand
18:57seangrove,((fn [x y] [(first x) (second x) y]) [1 2] 3)
18:57clojurebot[1 2 3]
18:57seangroveOk, yeah, got it
18:57seangroveThat's much nicer
18:57seangroveOk, and also _
18:58programble_ means you dont care
18:58programblea name for a variable you are not going to use
18:58seangroveAh, ok
18:59seangroveThank you!
18:59seangroveStruggling, but enjoying my tiem in clojure
19:12seangrove,(doc ->)
19:12clojurebot"([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
19:13seangroveWhat a strange function :P
19:13kotarak,(-> 1 (+ 2) dec (* 5))
19:13clojurebot10
19:13kotarakseangrove: actually a macro
19:13kotarak,(macroexpand-1 '(-> 1 (+ 2) dec (* 5)))
19:13clojurebot(clojure.core/-> (clojure.core/-> 1 (+ 2)) dec (* 5))
19:14seangroveHrm...
19:14seangroveThat looks the same?
19:14dnolenseangrove: yes, I use Penumbra, I'm working through the nehe tutorials, I'm swannodette on github.
19:14kotarakseangrove: note the recursion
19:14kotarak,(macroexpand '(-> 1 (+ 2)))
19:14clojurebot(+ 1 2)
19:15kotarak,(macroexpand '(-> (+ 1 2) dec (* 5)))
19:15clojurebot(* (clojure.core/-> (+ 1 2) dec) 5)
19:15seangroveI see
19:17seangroveOk, looking at its use, it seems for readability?
19:18seangroveInstead of nested parens?
19:19kotarakseangrove: yes. eg. for chaining method calls. Instead of Java: foo.bar().baz(5).frobnicate() you say (-> foo .bar (.baz 5) .frobnicate)
19:19kotarakseangrove: just as one example
19:20seangroveGreat, looks good
19:20Chousukenote: less parens than java :P
19:20kotarakhehe :)
19:20Chousukefewer, even
19:22Chousukekotarak: if syntax were irrelevant, people would not discuss it :)
19:22seangroveHeh, sorry if I made a faux pas, I was simply wondering about it in this source file here
19:23kotarakChousuke: syntax is relevant, but discussions of the style my brackets are faster than your parens are useless. I hate in particular this moronic "not used to X" argument.
19:23kotarakChousuke: If that was valid, I would still use C64 Basic. ;P
19:24kotarakseangrove: no, no, no problem :)
19:24Chousukeright.
19:25ChousukeThough in lisp dialects the simple syntax is a necessity for macros to work as well as they do.
19:25kotarakseangrove: it's just a usual argument against Lisp: "Uh the many parens. The average John Doe programmer is not used to them. It's soooo scary!". That's just so stupid. "Uh the pointers in C. The average John Doe programmer is not used to them..." "Uh those classes in Java. the average John Doe is not used to them..."
19:26programblehm
19:26Chousukeif the syntax were any more complicated, you couldn't have neat things like syntax-quote :)
19:26seangroveI'm coming from scheme land, and clojure seems to have a somewhat complicated syntax to me
19:26kotarakChousuke: well, you can them, cf. camlp4 of OCaml. But that is rather something for masochists. I'm not in SM. ;)
19:27seangroveBut considerably nicer than cl, I think
19:27Chousukeseangrove: it has more syntax elements. I actually appreciate that.
19:27seangroveIn any case, mostly everything I've used in clojure has turned out to be quite convenient in short order, so I'm not too worried about that
19:27Chousukeseangrove: in scheme and CL you need to use lists to represent all structure in your code. in Clojure you have vectors and maps of code too.
19:28Chousuke.. and sets, but no-one uses sets of code :P
19:29seangroveHeh, I'm sure I'll use them at some point in time
19:30seangroveOnce I get more comfortable with thinking in clojure
19:32ChousukeSure you'll use them for storing your data, but I mean actual clojure code represented by vectors and maps in the syntax of a particular macro. the defn macro for example takes an argument vector instead of a list, and the macro really sees it as a vector.
19:50dnolenis there a version of clojure-contrib on clojars that's up-to-date, like a nightly or something?
19:51Licenser_night people
19:53powr-tocI'm hosting a Clojure workshop tomorrow evening in Dundee (Scotland)... The attendees are all experienced coders, but don't have much experience with FP, Lisp or Clojure... they all know Clojure's hot-shit... any ideas about what I should show them?
19:53powr-tocIt'll hopefully be the first of many events
19:54powr-tocI'm looking for nice code snippets to disect etc...
19:54programblepowr-toc: tool on rosetta-code
19:56birdspiderhi, trying to compile clojure to *.class and getting "java.lang.IllegalArgumentException: Wrong number of args passed to: Test$-mytest", anyone interested ? :)
19:59powr-tocprogramble: nice idea... these guys are all OOP heavy... primarily c# background... any of those jump out at you?
19:59chouserbirdspider: the first arg for every defclass fn is the "this" arg
19:59birdspiderchouser, wow that was simple :)
20:00birdspiderchouser, thanks, it sure looks like I need to do more reading :)
20:00programblepowr-toc: how about some good ol' factorial, quicksort, binary search, etc
20:01powr-tocprogramble: I was thinking that... I might sneak a few in... I have quite a bit about sequences already, but I'd quite like to decimate some design patterns too....
20:02programblepowr-toc: must show them macros!
20:03powr-tocprogramble: yeah I know =) though I think that's worthy of a session of its own
20:03Chousukepowr-toc: write an instance of a design pattern, then show them an invocation of a macro that expands to said design pattern :P
20:04chouserhow long do you have? 1 hour?
20:04powr-tocchouser: maybe 2
20:04powr-tocI'd like to keep it pretty interactive... i.e. I want them to be hacking code at their laptops where possible
21:09seangrovewhat is this %2 and %1 doing here? (reduce #(%2 ball %1) (:v state) ....
21:11seangroveAh, I think I found it.. pre-expr and post-expr?
21:15seangroveNot quite...I think they refer to arguments whenever using #() to define a funciton without arguments list
21:21shalesWhat is the proper was to set *stack-trace-depth* from clojure.test and other similar earmuffed vars?
21:55sattvikshales: I could be wrong, but I think it's generally done with (binding [*muffed* val] ... )
21:57shalesso with unit tests I'd used a fixture to set *stack-trace-depth*? What about for *load-tests*?
21:58JonSmithyou can also use set
21:58JonSmithoh wait
21:58JonSmithmaybe that is depricated
21:58JonSmithit was set!
22:00shalesTried set! but got exception "Can't change/establish root binding of: *load-tests* with set"
22:01gfodoris there any API function or contrib function that does this: (map #(apply f %) coll))
22:01gfodorits useful if you want to use destructuring w/ an anonymous function for map
22:01JonSmithfor set! it needs to be within a thread
22:02gfodor Clojure=> (map-apply (fn [a b] (identity b)) [[1 2] [3 4]]) => (2 4)
22:04JonSmithso you'd do like (spawn-thread (fn [] (set! *var* something) (rest-of-code)) )
22:05hiredman,((comp (partial apply map) (juxt (partial apply apply) idenity) + [[1 2]])
22:05clojurebotEOF while reading
22:05hiredmanpffft
22:05hiredman,((comp (partial apply map) (juxt (partial apply apply) idenity)) + [[1 2]])
22:05clojurebotjava.lang.Exception: Unable to resolve symbol: idenity in this context
22:05hiredman,((comp (partial apply map) (juxt (partial apply apply) identity)) + [[1 2]])
22:05clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$identity
22:05hiredmanbah
22:06JonSmithhm
22:07JonSmithwhy do you need identity of b
22:08JonSmith(map second [[1 2] [3 4]])
22:08JonSmith,(map second [[1 2] [3 4]])
22:08clojurebot(2 4)
22:08JonSmithmine's shorter :-P
22:09gfodorhah, well, that's just an exampl
22:09gfodori didn't see anything that does map-apply idiomatically
22:09JonSmithright
22:09hiredmanJonSmith: but your's has nothing to do with map-apply
22:09gfodorbasically if you have a sequence of lists of arguments
22:09JonSmithright
22:09hiredmanso how short it is does not count
22:09JonSmithahh
22:10JonSmithso you are looking for like common lisp maplists or whatever that thing is called
22:10gfodoryeah I don't know CL, I just didnt' know if there is a more idiomatic way than defn'ing my own map-apply
22:10shalesJonSmith: I see what you're saying, but I'm running unit tests using "lein test". Plus it seems like the value of *load-tests* should be changed globally and not just local to one thread.
22:10RaynesHow can I get rid of paredit's newline-after-comment behavior?
22:11gfodortho i guess a better name is "mapply" :)
22:13JonSmithgfodor: i think your implementation is pretty clear
22:14hiredman,((partial map apply) (repeat +) '((1 2) (3 4)))
22:14clojurebot(3 7)
22:25rpenguinhiredman: how do you keep clojure bot from getting stuck in infinite loops? do you kill off a thread after a certain time?
22:28hiredmanrpenguin: yes
22:31rpenguinwas thinking about this beacuse i typed (recur) a couple times in a repl and was wondering why my mbp battery was draining so quickly
23:16Mecis there a way to combine 2 calls to swap! ?
23:17danlarkinMec: do
23:17Mecis that safe tho?
23:17danlarkinyes
23:18danlarkinswap does a compare-and-set
23:18Mecok, i thought i might have to end up using refs after all
23:18danlarkinso whatever fn you give to swap is safe
23:19danlarkinyou just can't make two calls to swap! and assume it's safe
23:19Mecthats what im doing
23:19Meci have 2 functions that each call swap! and want to do both in a 3rd function
23:19hiredmanuh
23:20danlarkinnah you can't do that
23:25Mecso am i just stuck duplicating code so that theres only 1 swap! call?
23:25danlarkinyou want to use refs
23:25danlarkinsounds like
23:26Meci figured i'd be safe with an atom since im only tracking 1 map
23:27danlarkinwell it just depends on what your application logic requires
23:27danlarkinif you're just associng on or something and you don't care about the order then use an atom
23:32Mecya basically each function is changing out a different key and then i need to combine then to change 2 keys
23:38danlarkinThen you either want to do a bunch of work in the fn you send to swap! or use a ref
23:38Meceven if they're both just using assoc?
23:39danlarkindo you not understand the logic of a compare and swap?
23:40danlarkinif you're running in a single thread then it doesn't matter
23:40danlarkinbut if not, you're going to see inconsistent values (most likely)
23:41Mecill just stop being lazy and read up on refs
23:56technomancydanlarkin: hey... does leiningen master hang when it's done for you too?
23:57technomancy(this is what I get for accepting patches late at night when I'm too tired to test them fully.)