#clojure logs

2010-09-24

00:07technomancygrrr... using ant as a library is like building a castle out of sand
00:07ninjuddtell me about it
00:08technomancyapparently it just plain ignores the spawn option on the subprocess launching
00:08ninjuddwhich task? Javac.
00:08technomancy"Look ant, I need you to fork a subprocess that outlasts the parent." / "Cool story bro. Listen, I'm gonna do my own thing over here..."
00:08technomancyjust plain Java
00:10ninjuddhmm
00:11ninjuddisn't that what you use to fork your project jvm?
00:11technomancywell normally I don't want the forked process to outlast the parent
00:12technomancybut I realized it wouldn't be hard to have it start a background server
00:12technomancyerr--it wouldn't be hard if ant behaved as advertised
00:12ninjuddare you writing a persistent jvm.
00:13technomancyI'm expanding the repl server to work in the background
00:13technomancyI guess so?
00:13ninjuddyou have fork=true and spawn=true, right?
00:13technomancyright
00:13technomancybut the parent JVM just quits and takes the child with it
00:14ninjuddand you aren't using any of the other opts that aren't compatible with spawn?
00:15technomancyright; I had failOnError set, but I turned that off when it complained
00:16ninjuddi could swear I got that working before I decided to launch both jvms from ruby
00:17technomancymaybe it's fixed in a newer ant
00:17BahmanHi all!
00:17ninjuddperhaps. docs say it doesn't work with input, output, error, result and timeout...
00:21ninjuddcould you use Runtime.exec directly?
00:22technomancyaccording to the ant mailing list they had to work around a hell of a lot of edge cases in Runtime.exec
00:23technomancyof course, apparently they missed at least one
00:23ninjuddhehe
00:24ninjuddI use ant 1.8.1. you may want to try that
00:27technomancyoh, I thought 1.7.1 was the latest... will try that
00:28ninjuddI think there is 1.8.2
00:28ninjuddnot sure why I'm not using it though
00:34TheBusbyI've actually had a lot of trouble with Java process spawning recently. Final solution ended up being using JNI.
00:56technomancyat least with smalltalk you could forgive it for pretending like Unix didn't exist because it was so old
00:57technomancythat excuse really doesn't work for the JVM
01:04sandGorgonhi guys... wanted to prototype a document store like functionality in clojure. basically a clojure server would be running on a remote machine, I request for a (guaranteed) unique filename and it returns a one-time URL that I can retrieve the files from. Later I'm gonna bolt on authentication and all that stuff
01:04sandGorgonI'm confused on the first step - to build the clojure "server" would I have to use a web framework like compojure ?
01:06amalloysandGorgon: i'm not an expert here (so don't take my advice!), but you certainly don't have to. if you wanted, you could instantiate the java.net.ServerSocket yourself
01:07sandGorgonamalloy, true - I was kinda hoping one layer of abstraction above it. my first thought was compojure, then I thought of ring, now I'm thinking of something using Aleph/Netty. But wanted to get idead
01:07sandGorgons/idead/ideas/
01:07sexpbot<sandGorgon> amalloy, true - I was kinda hoping one layer of abstraction above it. my first thought was compojure, then I thought of ring, now I'm thinking of something using Aleph/Netty. But wanted to get ideas
01:09amalloysomewhere around here i have a copy of my first clojure program, which was a simple chat server. compojure or ring or something is almost certainly better, but i don't have experience with any of them
01:09TheBusbytechnomancy: I fought with the JVM's processing spawning for quite a bit before going JNI. The worst part is what works for one platform doesn't work for another, hence the JNI route...
01:10technomancyTheBusby: yeah... honestly I only bothered because it looked like it would be really easy
01:11technomancyI'm not sure it's worth the hassle at this point just to be able to do TDD outside swank
01:11sandGorgonamalloy, actually the reason why it might be a bit different is that it might well be a multi-gigabyte file. So you dont want to drop down to socket level and have to deal with fillng up of posix buffers and all that.
01:11technomancymaybe someone who doesn't use swank could implement it. =)
01:13TheBusbyI think it took me about 20 minutes to implement what I needed, but I had some skeleton code (using fork and execvp) to work with.
01:15amalloygithub gist
01:15amalloyargh. wrong window :P
01:18amalloysandGorgon: anyway http://gist.github.com/594895 if you want to use it as a comparison vs ring or some other tool
01:19sandGorgonamalloy, hey thanks!!
01:20technomancy(re-pattern (format "(?:^|/)%s/" pat)) <= what's all that punctuation about?
01:23amalloytechnomancy: ^ indicates start of line, and / is a literal. they're separated by |, which is OR; those are wrapped in (?:) to get proper grouping - the ?: prevents it from stomping on your capturing groups
01:24technomancyamalloy: ah, thanks. I hadn't seen ?: before; handy.
01:24amalloyso it looks to be matching "foo/" or "anything/foo", but not "myfoo"
01:25nroot7clojure documentation mentions many functions to be side effect free. How does the compiler verify that ? Is it just a convention ?
01:25amalloytechnomancy: http://www.regular-expressions.info/tutorial.html is a superb resource for learning both basics and nuances, if you're getting into a lot of regexes
01:25amalloynroot7: just convention. the compiler has no idea
01:25sandGorgonamalloy, ah.. I was thinking that the ? was for a non-greedy match
01:27amalloyheh. ? means about a hundred things depending on where in the regex it is
02:07BahmanHi all!
03:07LauJensenGood morning all
03:10amalloysilly europeans, claiming it's morning
03:12LauJensenclojurebot: UGT?
03:12clojurebotugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html
03:12LauJensensilly uneducated americans, thinking I was referring to time
03:14nlogaxalso, there's no timezone exclusive to europe
03:24RaynesIt's morning in the USA.
03:24RaynesAt least, my clock says AM.
05:18fliebelmorning
05:18mrBlissmorning fliebel
05:19fliebelWhat is the usual path to follow when lein deps is missing something?
05:19fliebel(junit 4.7 in this case I believe)
05:20mrBlissmake sure your dependency vector is correct: http://jarvana.com/jarvana/archive-details/junit/junit/4.7/junit-4.7.jar
05:22fliebelIt's not exactly my vector, rather the Overtone one. And even then, it is a dependency of a dependency, because Overtone itself does not depend on junit.
05:23mrBlissfliebel: good luck :)
05:24fliebelmrBliss: Thanks :( I guess I'll just ask on the Overtone mailing list, after I tried some more.
05:59fliebelmrBliss: Deleting .m2 fixed it for some reason :-|
06:11HoornetHello
06:12RaynesHi.
06:14esjwotcha
06:21esjwas it something I said ? :(
07:53LauJensenAnybody here living in London ?
07:58mccraigLauJensen: i work there
08:08esjI live up the way in Cambridge
08:13LauJensenesj: Im in priv with mccraig trying to extract some information :)
08:13esjAll you need to know is that London is big and smell :)
08:14LauJensenI don't remember any specific smell, just that its huge and difficult to get around in
08:18esjyes, I served a two year term there, happily I am now paroled.
08:25bobo_is there any good tutorial on testing your java code with clojure? setting up the project and so on?
09:11fliebelHey, what are naming conventions in Clojure? I figured out dashed-style is preferred and question-mark? is used for booleans, but how about *stars and -dashes?
09:12esjfliebel: I think *ear-muffs* are often for dynamic vars, and -dashes for private functions
09:13fliebelesj: -main has a dash, and in java that's public static void main IIRC.
09:13chousernever seen a leading star. trailing star is like a "prime tick" in math -- foo is something, foo* is related but different. sometimes a macro vs. a function that does something similar
09:13fliebelchouser: Yea, I meant things like fn*
09:13chouseryes, *ear-muffs* are for vars -- things that are meant to be rebound using (binding ...)
09:14chouserleading dash is for functions that are acting as methods for genclass. Note (defn- foo ...) is for a private foo which is different than (defn -foo ...) which is likely a public method of a class.
09:15chouserfliebel: yeah fn* is the real special operator, related to fn which is a macro
09:16fliebelokay… so, recap: *changable-var* low-level-stuff* -java-method bollean?
09:16esj-dashes.... yes I'm confusing myself with defn-. Apologies.
09:17AndChat-.
09:17esjor rather: predicate?
09:17fliebelesj: Yea, nicer word :)
09:17chouserI use ? for boolean locals too. I think that's ok.
09:18chouseras in (let [inside? (< low x high)] ... (if inside? ...))
09:18fliebelTalking about private functions, why would you want to do that? Except for keeping the ns clean and for "setters"
09:19esjchouser: cool.
09:21chouserfliebel: I think "ns clean" is too dismissive. A public API carries weight -- it should be clean yes but also documented, slow to change, conceptually aligned with how users are supposed to think about the problem space, free of implementation-specific details, etc.
09:21chouserprivate functions don't need to meet any of those criteria, so it's worth being clear about which is which.
09:22fliebelchouser: Right… I'll think about making my bad ass macro a bit more friendly.
09:22chousernote they're not even as private as Java private methods -- you can always get at a private var from another ns if you know its name.
09:22chouseractually, you can discover it's name easily too.
09:23fliebelchouser: I did that to Ring the other day… I needed something in their lower levels.
09:23chouserfliebel: right, good, and you're aware of the risks involved.
09:23fliebelchouser: Probably not… Only thing I can think of is that they change it becasue it's private anyway.
09:24chouserfliebel: right, that's it.
09:24chouserit's behavior, name, interface may change without notice
09:25chouserif you think your use of it is legit I'd recommend asking for it to be made public.
09:25fliebelI'm not using it anymore
09:26fliebelMy use was completely unrelated to Ring, it just happend to contain the exact thing I needed.
09:28fliebelHuh, am I allowed to do this? (defn a [] (defn b []))
09:29fliebelThat'd mean I don't need to make a macro at all to define some crazy function.
09:30fliebelI'm trying to do this badd ass macro in a proper way: http://github.com/pepijndevos/utterson/blob/develop/src/utterson/compile.clj#L55
09:34lpetitfliebel: I really don't understand your problem with (defn a [] (defn b [])) which could be solved by a macro.
09:34lpetitcan you repeat slowly for me please ? :-)
09:34chouserdef-anything inside a fn is generally not a "proper way"
09:34fliebellpetit: The point is that I though one wa supposed to use a macro for this, but evaluating that just yieald b
09:35fliebelchouser: Right...
09:35chouserfliebel: you won't be able to give the name of 'b' from an argument of 'a'
09:35lpetitI can't see why (defn a [] (defn b [])) could be useful at all
09:35fliebelchouser: I also realized that...
09:35chouseryou could try using intern, though.
09:36fliebelI'll just do it the normal way and break it up in fns and a macro for defining it.
09:36chouser(defn a [tname] (intern *ns* tname (fn ...)))
09:37chouserbut .. looking at your defgen I doubt that'll work for you either.
09:39fliebelchouser: So what do you suggest, if anything?
09:43fliebelI think I'll split it up in 3 functions and one macro
09:44chouseryeah, I'd try to have the macro emit as little code as possible.
09:45pjstadig,36r16
09:45clojurebot42
09:45chouserlooks like it'll need markdown# to redefine your template# a couple times
09:45pjstadig1r2
09:45pjstadig,1r2
09:45clojurebotRadix out of range
09:45pjstadig,3r16
09:45clojurebotFor input string: "16"
09:45pjstadig:-(
09:46pjstadig,2r1
09:46clojurebot1
09:46fliebelchouser: Yea, I need to come up with a decent plan to spread the data to the right places across those fns
09:46chouserand maybe put your template of ~@others in a local fn.
09:46pjstadighmm i guess the radix comes first?
09:47pjstadig,3r12
09:47clojurebot5
09:47chouserso then the body of the let you emit can just be (gen* markdown# template# othersfn#)
09:56fliebelchouser: Would it be good style to define some fo those functions in a lot, so they can access common data?
09:56fliebel*let
09:57chouserfliebel: not sure exactly what you mean, but it doesn't sound bad. :-)
09:57fliebelchouser (let [common data] (defn a []) (defn b[]))
09:58chouserthat'll only work if common data is entirely global
09:58fliebeltrue
10:15chouserwould it be dumb to have a pom.xml editor? perhaps an emacs mode or a little command-line utility that wraps up common configurations?
10:15technomancylein includes a sexp->pom.xml translator, in essence
10:16chouseryeah, I guess I'm thinking something two-way
10:16hugodit would be great not to maintain seperate project.clj and pom files
10:16chouserin case you use an IDE to adjust the pom.xml or something.
10:16technomancyhugod: if you need something in pom.xml that project.clj currently doesn't support it should be easy to add
10:17technomancyI've been thinking about adding a maven plugins section so you can do "lein pom && mvn myplugin:action" easily
10:17chouserlein is happy to depend on projects that provide pom.xml but not project.clj, right?
10:17technomancychouser: definitely
10:18technomancyonce something is on clojars, project.clj is not even taken into account; the pom is the only thing that matters
10:18hugodtechnomancy: there is rather a lot I fear http://github.com/hugoduncan/pallet/blob/master/pom.xml
10:18technomancyhugod: eh; it wouldn't be too much work to add
10:19hugodtechnomancy: good to hear :)
10:19technomancyprofiles, plugins, and developer lists; it's all just a matter of adding the appropriate .addProfile etc. calls to the maven java API
10:19RaynesMy eyes!
10:20technomancythough I'm really not sure of the purpose of the latter
10:20chouserbtw, lein cake and maven all feel less superfluous to me since I've started thinking of them as classpath management tools rather than "build" tools
10:21hugodtechnomancy: I tend to agree with you on that
10:21chousersuperfluous isn't quite the right word
10:22shooverchouser: I'm curious how you manage dependencies without those tools. Do you download jars the old fashioned way and stash them somewhere?
10:23shooverOr write everything from scratch depending only on clojure.jar? ;)
10:23chousershoover: essentially yes. Well, I've got two different "systems", neither very impressive.
10:23technomancychouser: indeed; "building" a jar is the trivial part
10:23technomancyclasspath management is the #1 faq for newbies coming in
10:24chouserfor work we already have an extensive build system using cmake (do not recommend), so I plugged clojure into that. The generated makefiles fetch dependencies and then we have a shell script that sets up the classpath and launches the appropriate Java class.
10:24raekhttp://clojure.github.com/clojure/ <-- what happened to clojure.test and friends?
10:25chouserfor my own hacking around, I had started working up a system of jar directories, one per clojure major version plus a "common" one. So to start using a jar I'd just download it into the appropriate dir, launch the appropriate clojure repl version, and go.
10:26chouserof course this is both too complex and too simplistic.
10:26Rayneschouser: Insanity.
10:26shooverchouser: I see
10:27chousershoover: but you're right -- I tend to depend on few libs in practice. java core, clojure core, and contrib covers 90% of what I play with.
10:27chouserdabbling with ring was painful with my setup. I definitely need to use one of these dep management things.
10:27anonymouse89j git
10:27anonymouse89oops
10:27shooverchouser: oh yeah, lots of little jars in the http world
10:28chouserso maybe after finger trees...
10:29chouserbut see after that I'm likely to be messing around with clojure-in-clojure stuff, and then maybe clojurescript, etc. None of these have deps outside of clojure.
10:29technomancychouser: so right after I give my lein talk at the conj then? nice timing =)
10:29chousertechnomancy: yep. and maybe I'll look at eclipse right after lpetit is done talking...
10:29chouserclojure-conj fascilitates my laziness
10:30AWizzArdWhen I have a :gen-class'ed namespace, and :state s, and want somewhere in that file/NS to access .s then I get a reflection warning. Exists there a way to type-hint it?
10:30chouserAWizzArd: sure, just hint it to the class you're gen'ing
10:31shooverchouser: I can't imagine doing anything not involving a couch and a tv after writing a book
10:31AWizzArdchouser: that would be the NS itself.
10:31chouserAWizzArd: no, the namespace is not a class
10:32chouserthough they are generally named similarly, yes.
10:32AWizzArdchouser: to AOT that class I used a (:gen-class ...) in the (ns my-ns) form.
10:35AWizzArdchouser: one sec, I will post an example
10:36cemerickman, there was a nasty little locals-clearing bug in 1.1.0 :-/
10:37AWizzArdhttp://paste.lisp.org/display/114852
10:37AWizzArdWhen I try to compile this I get a ClassNotFoundException: bar.Foos
10:37AWizzArdwithout the type hint I get two reflection warnings
10:40chouserAWizzArd: you have to compile for :gen-class to work
10:41chouseralso, why are you using gen-class to implement intefraces instead of deftype or reify?
10:41chouserinterfaces
10:41AWizzArdThis is just a demo
10:41chouserok
10:41chouserso yeah, you have to use compile. when I (compile 'bar.Foos) it works fine
10:41chousergiving only a reflection warning for the .s you didn't hint.
10:44AWizzArdokay good
10:44AWizzArdI was confused because I got those warnings in Emacs, when loading this NS.
10:45chouseryes, I understand emacs can be confusing.
10:45chousersorry, couldn't resist. bad chouser!
10:46AWizzArdchouser: *g*
10:47rfgpfeiffer_can a deftype type have static methods?
10:49chouserrfgpfeiffer: no, just use regular clojure functions for that
10:58technomancyhmmm... might be time to drop test-is support in the next leiningen release. =)
10:58fliebelGiven the fact that Clojure-in-Clojure is possible, it is thus possible to define lazy seqs. Would it also be possible to define a lazy seq where the 0th element is actually in the middle of an infinite lazy seq extending in both ways? so like (iterate inc) with negative number included :)
10:59technomancyyou can't rebind a dynamically-referenced var, can you?
10:59technomancyI mean, without evaling a binding call
11:00chouserfliebel: ISeq only provides an API for walking forwards. You'd need a different interface for walking the other direction.
11:02fliebelchouser: Hrm :( that means I'll be unable to use with with existing functions, right?
11:04chouserfliebel: well, what existing function do you intend to call to get item before 'first'?
11:04fliebelchouser: Dunno… I mean, if I'm not using ISeq, I can;t even use first, right?
11:05chouserwell, your theoretical bidirectional lazy seq could implement ISeq for going forward
11:05fliebelchouser: Oh wait, Java, so I can implement ISeq and add my own interface and fns for going the other way.
11:07fliebelchouser: How about this… you define a lazy seq like iterate but with 2 fns, for going in either direction. then you call spin on it to change which direction you're seqing over :)
11:08fliebelso spin = reverse for lazy seqs
11:08chouserhm, interesting.
11:09chouserI don't see why not.
11:09fliebelchouser: So, what Clojure bits do I need to implement that?
11:10chousera deftype and ... a function?
11:10fliebel*looks up deftype*
11:17chouseractually, just a deftype would do, though it's not quite as pretty.
11:17fliebelchouser: I don't think I get it.
11:18chouser(rseq (rest (drop 10 (IterBi. 0 inc dec)))) ;=> (5 4 3 2 1 0 -1 -2 -3 -4 -5 ...)
11:18anonymouse89I'm having trouble with this:
11:18anonymouse89,(let [add '(+)] (apply (first add) (range 10)))
11:18clojurebotjava.lang.IllegalArgumentException: Wrong number of args (10) passed to: Symbol
11:18anonymouse89I would like it to be equivalent to (apply + (range 10))
11:18chouseranonymouse89: try (list +) instead of '(+)
11:19anonymouse89chouser: nice
11:19chouser,(class (first '(+)))
11:19clojurebotclojure.lang.Symbol
11:19chouser,(fn? (first '(+)))
11:19clojurebotfalse
11:19chouser,(fn? (first (list +)))
11:19clojurebottrue
11:20anonymouse89I thought '(0 1 2) could be thought of as an unevaluated sequence not as a symbol
11:20chouserit is an unevaluated sequence, but the contents are unevaluated as well
11:20chouserso + in that case is just a symbol.
11:21anonymouse89chouser: that makes sense, thanks
11:21chouserif you want to look up what function + refers to, you have to evaluate the symbol
11:22chouserfliebel: so that's what you wanted, right? intersting idea.
11:22fliebelchouser: I understand how I can do without the fn, but I don't understand deftype.
11:22chouseractually, you don't need deftype either. you could use reify or proxy if you prefer, and a normal function.
11:23fliebelchouser: I never worked with those 1.2 things before. So it's going to be a lot of learning… :)
11:24chouserfliebel: so... how shall we proceed? You want to see my code or should I try to drop hints or ask leading questions?
11:24fliebelthe later one :) extended with my guessing and reading
11:25fliebelchouser: So I basically need to look up the ISeq interface and overwrite a few methods?
11:25chouserok, so how would you use deftype or reify to implement an ISeq that just repeats the same value over and over
11:25chouser?
11:26fliebelWhere can I find the ISeq interface?
11:26chouserI do (show clojure.lang.ISeq)
11:26fliebelUnable to resolve symbol: show in this context
11:26edwI'm a longtime Emacs user and Scheme programmer and I'm trying to get Emacs set up to play nice with Clojure (1.2) and I the best guide I can find is a mailing list message from Constantine Vetoshev and I get an error when following along with that. Is there a definitive SLIME/Clojure guide out there somewhere?
11:26chouserfliebel: :-( rhickey took my 'source' fn, but not my 'show'
11:27chouserfliebel: show is clojure.contrib.repl-utils/show
11:27fliebelchouser: Ah, I use source quite often, but that doesn't work on Java stuff I guess.
11:27dnolenedw: http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Emacs
11:27edwdnolen: Thank you!
11:28chouserfliebel: http://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ISeq.java
11:28edwOh gawd, it uses ELPA?! I didn't have good luck with that!
11:28dnolenedw: the trick is that you only need to install swank-clojure
11:29RaynesELPA is the standard way of setting this stuff up to work for Clojure. It's all tested and known to work.
11:29dnolenedw: the main trouble you might run into is if you have existing Lisp configurations
11:29edwdnolen: Ah. I was getting all sorts of dependency errors when installing slime using it. Should I clean out any existing SLIME installations?
11:30dnolenedw: I would. Don't bother installing anything but swank-clojure, ignore slime, slime-repl, clojure-mode. There's a bug in the install process. installing swank-clojure will grab everything you need.
11:31fliebelchouser: I guess it'd be (reify clojure.lang.ISeq (first [this] 1)) but that fails
11:31dnolenedw: you will need to wipe anything clojure related from your .emacs.d/elpa before installing swank-clojure
11:31fliebelah wait
11:31edwdnolen: Thanks again. Cleaning out my .emacs (and .emacs.d) right now.
11:32fliebelchouser: Do I need to implement all of them? Or can I just use a concrete subclass of ISeq?
11:33dnolenedw: np
11:33chouserfliebel: just implment the ones you need for now. What happens when you call 'first' on your reify there?
11:33chouserThen when happens when you call 'next'?
11:34fliebelchouser: I get java.lang.AbstractMethodError when defining it, because ISeq is an abstract interface.
11:34fliebel(i think)
11:34chouserfliebel: are you sure that's why?
11:34chouserdid you try (first (reify ...)) ?
11:35fliebelchouser: Hm, that works, but just defining it fails.
11:35fliebelchouser: Ah, repl evaluates
11:36chouseryep, and after E is P
11:36fliebel?
11:36chouserREPL
11:36fliebelah
11:36chouserand printing a seq means walking it an printing each of the items. we're not ready for that.
11:37fliebelI see
11:37chouserso, (first ...) works. what about (next ...)?
11:37fliebellet me try..
11:39fliebel(next [this] this)
11:39fliebelOkay, but I have no idea what more and cons are about.
11:40chouserfliebel: ignore them for now.
11:40chouserso, (first ...) and (first (next ...)) work now, right?
11:40fliebelyea, but not doing second on it still gives me the error.
11:41chouserit's a shame it doesn't tell you the specific method it's trying to call that fails.
11:41chouseryou can discover it by looking up the line of source code it mentions and seeing what method it's calling.
11:42fliebelIt doesn't even give a line or file:
11:42fliebeljava.lang.AbstractMethodError
11:42fliebel(
11:42fliebelthat's all
11:42chouseryeah
11:42chouseroh, (.printStackTrace *e) or (pst) on clojure 1.3.0 alpha 1 will show you more
11:42chouserbut not enough.
11:42fliebelI'm not on the alpha
11:43chouserright, so use (.printStackTrace *e)
11:43chouserso I'll just tell you -- the REPL calls your .seq method during printing.
11:44chouserseq must return an ISeq ... can implement that?
11:44fliebelBut seq isn't in ISeq, or is that up in IPersistentCollection?
11:44chouserfliebel: IPersistentCollection
11:45fliebelNo, Sequential I guess
11:45chouserbut you can put it under ISeq in your reify
11:46fliebelI know, but I need to know it's… how do you call that...
11:47chouserhttp://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Seqable.java#L16
11:47fliebelright… Now I made it return a list. It prints that and *then* gives the same error.
11:48chouseryeah. so that final error is it calling equiv. not sure why
11:49fliebelhm…. Do we need to fix that?
11:49chouserprobably not
11:49chouserso, what do you have so far?
11:49fliebelA ISeq that returns 1s
11:50fliebel(reify clojure.lang.ISeq (first [this] 1) (next [this] this) (seq [this] (list 1 2 3)))
11:50fliebelMaybe I could make seq return a cons of first and rest, but then I'd need to define that as well
11:50chouser,(reify clojure.lang.ISeq (first [this] 1) (next [this] this) (seq [this] (list 1 2 3)))
11:50clojurebot(1 2 3)
11:50technomancythere's no zeroconf stack for the JVM, is there?
11:51technomancythat would be great for conj shenanigans...
11:51chouserfliebel: do you have an ISeq handy already for your 'seq' to return?
11:52fliebelthis?
11:52clojurebotthis is not a bug
11:52chouserfliebel: what happens when you try it?
11:53fliebelI guess it'll get stuck
11:53mrBlissthere's (quote ..) for ', what's the function for `?
11:53chousermrBliss: doesn't exist. ` is implemented differently
11:54fliebelchouser: It does get stuck, but doing take 10 gives java.lang.AbstractMethodError again
11:54chouser,(read-string "1(foo)")
11:54clojurebot1
11:54mrBlisschouser: too bad, now I have to wrap it in (fn [] ..)
11:54chouser,(read-string "`(foo)")
11:54clojurebot(clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/foo))))
11:55jashmennhey, one more question to add to the mix: if i compile and import a gen-class from the repl, is there a way to reload the gen'd class without restarting the jvm?
11:55chouserfliebel: you're in a plain REPL or in slime or what?
11:55jashmenn(my code: http://gist.github.com/595569)
11:55fliebelcake
11:55chouserfliebel: cake and a terminal?
11:56fliebelokay, just the terminal prints a lot of 1 :)
11:56chousergood job!
11:56fliebelbut take 10 doesn't work yet
11:56chousertake is calling your (unimplemented) rest method
11:57chouserer, 'more', rather
11:57fliebelI keep forgetting the difference between next and rest...
11:57fliebeland I don't know more at all :P
11:57ubiilooking to get back into clojure after a 9 month hiatus and have the following questions
11:58fliebelchouser: There arn't any docstrings on ISeq :(
11:58ubii1) I am still very much a newbie and am wondering if I should stick with 1.2 or go ahead and check out 1.3
11:58chouserthe difference between more (called by clojure.core/rest) and next only matters when being very careful about nearly vs. complete laziness.
11:58ohpauleezfliebel: new rest is almost always what you want, except when you don't
11:59chouserthat is, we don't really care much. So what happens if youre 'more' is the same as your 'next'?
11:59esjubii: i'd stick with 1.2, its still pretty new :)
11:59andyfingerhutubil: You'll likely have less confusion with 1.2. More tested with other add-ons
11:59fliebelchouser: Works :)
11:59ubii2) should I install clojure via the zip files, source(github), or use Leiningen?
12:00chouserfliebel: congrats!
12:00mrBlissubii: leiningen or cake
12:00ohpauleezubii: I agree with 1.2, but if you want to play with some of the new stuff, and can deal with some exceptions now and then, 1.3 has been fine for me
12:00mrBlissubii: or cljr for a standalone repl to play with
12:00fliebelchouser: I know how to reverse it :D
12:00ohpauleezubii: what mrBliss said
12:00chouserfliebel: :-{
12:00chouserfliebel: :-P
12:01chouserfliebel: ok, but you want to apply a function instead of just repeating, right? how would you do that?
12:02fliebelchouser: Hey, my ISeq doesn't implement clojure.lang.Reversible
12:02chouserfliebel: hm, what are going to do about that?
12:02ubii3) which editor (emacs, vi) or IDE do most of you use and what would you recommend?
12:03RaynesEmacs is the most used, followed by vi and the IDE plugins.
12:03RaynesI did a poll a while back, which was further confirmed by cemerick's poll not too long ago.
12:03fliebelchouser: I don't think reify allows me to define multiple ancestors :(
12:03chouserthere are about as many emacs users as non-emacs users
12:03chouserfliebel: I would not have led you astray
12:04fliebelchouser: Can I nest reifies? :P
12:04RaynesWasn't it like 62% of Clojurians using Emacs?
12:04chouserfliebel: yes, but that's not what you want here.
12:04fliebelNope :(
12:05chouserfliebel: according to the deftype docs, "Each spec consists of..."?
12:05andyfingerhutEmacs is free as in beer, free as in libre, but if you are new to it, it costs some time :-) It was new for me a long time ago...
12:05fliebelah...
12:06chouserRaynes: oh, you're right. 70%
12:08andyfingerhutchouser: So did you understand Haskell somewhat well before reading the published paper on finger trees?
12:08fliebelchouser: I added clojure.lang.Reversible (rev [this] this) but it still says Can't define method not in interfaces: rev
12:09fliebelhuh…. I need to define rseq, but rseq calls rev
12:09fliebel,(source rseq)
12:09clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
12:10fliebelno. wait...
12:10chouserfliebel: yeah, I did that first too.
12:11fliebelchouser: (. rev (rseq)) what is this?
12:11fliebelWhy the parens abround rseq?
12:12chouserfliebel: ancient syntax. the same as (.rseq rev)
12:12fliebellol
12:12fliebelOkay, so now for the real thing :)
12:15fliebelchouser: Can we go somewhat more down the inheritacne tree to find something that covers the basics? Or do we need everything customized anyway?
12:19chouserfliebel: reify doesn't let you inherit from anything but pure methods.
12:22anonymouse89,(quote (first '(0 1 2)))
12:22clojurebot(first (quote (0 1 2)))
12:22fliebelyou mean interfaces?
12:23anonymouse89why does this happen?
12:24fliebelchouser: So what is next?
12:24andyfingerhutanonymous89: If you mean "why does the ' change to (quote ...)?" it is because that is what ' is defined to mean.
12:25anonymouse89andyfingerhut: oh, duh the repl is just taking the outside quote off
12:29mrBlissI've written a lazy-let macro which doesn't evaluate any of its bindings until they are needed, handy when you're dealing with many conditional bindings. http://gist.github.com/595634
12:30mrBlisss/written/hacked together ;-)
12:30chouserfliebel: sorry, distracted.
12:30fliebelnvm
12:31ohpauleezmrBliss: I like that substitute
12:32fliebelchouser: Did you mean present or past?
12:33chouserfliebel: I'm on the phone at work.
12:33fliebelwork? oh right… timezones, I'm sorry
12:34stuartsierra1.3.0-alpha1 artifacts deployed... let the carping commence!
12:35ohpauleezstuartsierra: haha
12:35ohpauleezstuartsierra: btw, really loving lazytest stuff
12:35stuartsierraawesome
12:35stuartsierraSpeaking of Lazytest
12:35stuartsierraI'm thinking of releasing 1.0.0 final today.
12:35ohpauleezyes!
12:35ohpauleezplease do
12:36stuartsierraAnybody have any bug reports before that goes out?
12:36andyfingerhutcarping: Why wasn't this ready when Rich asked us to try out 1.3? Why is it alpha1? Why am I losing my hair?
12:36stuartsierraandyfingerhut: What?
12:37technomancyconsult your healthcare provider if you experience hair loss in conjunction with upgrading to Clojure 1.3
12:37andyfingerhutSorry, just wanted to commence the carping in a silly fashion. Should have added :-)
12:37stuartsierraAs I understand from Stu Halloway & Rich, the plan is to release more frequent alphas to get more people to test out new features without having to depend on SNAPSHOT versions.
12:37esjstuartsierra: quick question - is there any intent to add a test coverage tool ?
12:37stuartsierraesj: Sure, want to write one? :)
12:38technomancyesj: do you know about radagast?
12:38ubiithx for the answers
12:38esjstuartsierra: would love to - unsure you would though. Care to supervise ?
12:38esjtechnomancy: googling.
12:38ubiisorry, got tied up with dealing with a client request
12:39esjtechnomancy: now I do ! I'll go play with it, thanks.
12:39stuartsierraesj: It doesn't interest me a great deal. I think doing it "properly" would require instrumenting the JVM.
12:40ubiiregarding Emacs, which is the preferred method for installing/configuring clojure-mode, slime, and swank-clojure?
12:40technomancystuartsierra: radagast offers coarse-grained test coverage, but for branch-level you'd have to hack the compiler
12:40andyfingerhutIf you haven't done it before, ELPA
12:40stuartsierraubii: Sacrifices of fattened animals generally help.
12:40esjubii: ELPA, as per technomancy's guide.
12:40stuartsierratechnomancy: Yeah, that's what I meant.
12:41esjtechnomancy: 35 lines...
12:41stuartsierraIt would be an interesting dive into the Clojure compiler, but I think the effort would far outweigh the reward.
12:41technomancystuartsierra: especially when coarse-grained coverage is trivial to implement
12:41stuartsierrayeah
12:42stuartsierraSo if anybody wants to play with integrating radagast with Lazytest, I'll try to help out.
12:42ohpauleezstuartsierra: I might be into that
12:42stuartsierracool
12:42ohpauleezIf I get anywhere, I'll ping you
12:43stuartsierraok
12:43fliebelchouser: I need to prepare dinner. I'll talk to you about reify later. Thanks for helping me. I'm now struggling with where to keep state and how to modify things withouy an endless recursion.
12:43chouserfliebel: yep. hint: fn args are state
12:44ubiihttp://technomancy.us/126 - is this the correct url to the guide?
12:44technomancyubii: try "getting started with Emacs" on the official Assembla wiki
12:45ubiicool, thx all
12:49andyfingerhutAre there "inner deftypes" that are analogous to Java inner classes?
12:49stuartsierraAck!
12:50chouserandyfingerhut: there's reify
12:51andyfingerhutchouser: I ask because I was thinking of how one could modify your finger trees without having a meter-obj in every deftype'd object in a whole tree.
12:51chouserandyfingerhut: yeah, I mentioned an alternative in a recent email
12:52chouser...passing in the meter as an arg to methods that use it, and relying on some outter context to provide the correct one every time.
12:52chouserI didn't have outer contexts before, but my most recent commit adds a couple examples
12:54andyfingerhutok. It is just that so many of the methods need it. I'm not advocating for inner deftypes, but they look like they would kinda-sorta help in this kind of case. I'm sure there are other ways.
12:55chouserit would still have to be stored somewhere that all the node methods could find it, wouldn't it?
12:55andyfingerhutYes. So you make all the node deftypes inside the main one.
12:56andyfingerhutMaybe a crazy idea, and maybe problems with it I haven't thought of. But if the feature were there, I would have been crazy enough to try it out :-)
12:57chouser:-)
12:57chousergotta go. bbl.
12:57stuartsierraEven nested classes aren't really contained in Java.
12:57stuartsierraIt's just a namespacing convenience.
12:57stuartsierraWith some funny rules about public/private visibility.
12:58andyfingerhutInner classes do not get access to per-instance fields of the class in which they are nested?
12:58stuartsierraI can never remember the rules.
12:58andyfingerhutThat's OK. Some rules, only the writer of the rules can keep in their head at one time.
13:02amalloyinner classes have access to instance fields of the outer class. the one that always gets me is method-local classes
13:12proyalhowdy! question: i have two seq's, one of fn's, the other of values. in order, i want to map each item of my value seq with the corresponding (nth-wise) fn from my seq of fn's. is there a handy way to do that?
13:12stuartsierra(map (fn [f v] (f v)) fns values)
13:13chouseror #(%1 %2)
13:13proyalstuartsierra: ah, awesome. docs weren't clear that's how it worked
13:13stuartsierrawhat chouser said
13:13proyali tried 'for', but that gave me a cartesian product
13:13ohpauleezproyal: I'd do what chouser said, typically
13:14proyalyah, anon-fn's preferred indeed. worked like a charm, thanks gents!
13:16amalloychouser: wow, i didn't know that worked. i sorta assumed #() needed something it could resolve at the call site
13:17ohpauleezamalloy: the beauty of first-class of functions
13:17amalloyyeah. when i look at the expansion of #() into (fn []) it's clear that there's no reason the latter should work but not the former; but the first one just looks mind-boggling
13:18dnolensomebody who is able want to open up a ticket for even? in 1.3.0-alpha1 (I really need to send in my CA :P) http://groups.google.com/group/clojure/browse_thread/thread/f46fc7389ecdf1f8#
13:21birdspiderhi, anyone familiar with penumbra(clj wrapper for lwjgl)? can't get the examples to work
13:24dnolenbirdspider: what's the problem?
13:27birdspiderdnolen, well first I'd like to know if the examples are bundled in the penubra.jar ? or if I have to pull them seperatly
13:28dnolenbirdspider: the jar? did you d/l the git repo?
13:29birdspiderdnolen, nope I just downloaded the clojar via lein deps
13:29dnolenbirdspider: that won't work I think as you need something to set the classpath to the native libs.
13:30dnolenbirdspider: it's simpler to just checkout the repo, and run 'lein repl' and run the examples from the REPL
13:30birdspiderdnolen, well yes, my current status is that I downloaded a single example and tried to (require) it
13:30birdspiderdnolen, native libs via native-deps in place afaik
13:31birdspiderdnolen, which I link via -Djava.library.path=pathToSo
13:31dnolenbirdspider: do you have a paste somewhere of the error?
13:31birdspiderbut it gives me java.lang.ClassNotFoundException: org.lwjgl.opengl.GL11 (core.clj:9)
13:31birdspiderdnolen, do I have to link each *.so specifically
13:32birdspiderdnolen, or just the path
13:32dnolenbirdspider: no, what do you set the library path to?
13:32birdspiderdnolen, -Djava.library.path=native/linux/x86/
13:32birdspiderdnolen, which contains: libjinput-linux.so liblwjgl.so libopenal.so
13:34cemerickI'd like to invoke a fn a no-arg function within the context of comp or ->, but for the life of me, I don't see a clean way to do so.
13:34cemerick,(-> str .invoke count)
13:34clojurebot0
13:34cemerickis the best I've come up with, which sucks.
13:34cemerickSomeone tell me I'm nuts.
13:35dnolenbirdspider: hmm that should work yes... and yr classpath is set as well I assume? You do need to include each jar individually.
13:36birdspiderdnolen, well there is a bunch of stuff in lib, but i tried: java -cp lib/clojure-contrib-1.2.0-20100813.160219-142.jar:lib/clojure-1.2.0-master-20100813.160144-94.jar:lib/penumbra-0.6.0-20100502.112537-3.jar:src/ -Djava.library.path=native/linux/x86/liblwjgl.so clojure.main
13:36birdspiderdnolen, clojure, clojure-contrib, and penumbra
13:36birdspiderdnolen, ah
13:36birdspiderdnolen, there are the lwjgl jars
13:36birdspiderdnolen, :)
13:36stuartsierracemerick: You're nuts (-> (str) count)
13:36dnolenbirdspider: yup
13:37dnolenbirdspider: those get unpacked by native-deps so it's a bit weird
13:37cemerickstuartsierra: right, but assume the fn I want to invoke is the result of a prior invocation in -> or comp
13:37birdspiderdnolen, thats what I got wrong, I looked there after calling deps
13:37birdspiderdnolen, ok thx for now
13:37dnolenbirdspider: np
13:38stuartsierracemerick: with comp, easy, just wrap in #()
13:38stuartsierraWith ->, you're still nuts :)
13:38hiredman,(str (apply nil) count)
13:38clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$apply
13:38stuartsierrawell, not #() but (fn [_] foo...)
13:38hiredman,(-> str (apply nil) count)
13:38clojurebot0
13:39cemerickMy real trouble is that I"m actually using comp and partial with equal frequency as -> and #() these days.
13:39momosHello :-)
13:45andyfingerhutWith 1.3.0, is someone already planning a web page or something similar that people can go to in order to assist in upgrading their code base from 1.2.0? As a minor example, I had some calls to re-gsub that worked on 1.2.0, but the name changed so it took some time to find in 1.3
13:45stuartsierrare-gsub was already deprecated in 1.3
13:45stuartsierraI mean 1.2
13:53andyfingerhutIs there a way to enable warnings of using deprecated things in 1.2?
14:09duncanmanyone working on incanter here?
14:09duncanmis there a reason why the API page is broken? it only shows the package names, but none of the functions
14:09fliebelchouser: I have a full stomach now. Do you have time to explain me a few key things about reify? I'm thinking in circles now. :(
14:10duncanmhmm, liebke is not around
14:13ohpauleez~seen liebke
14:13clojurebotliebke was last seen quiting IRC, 2561 minutes ago
14:17fliebel~seen chouser
14:17clojurebotchouser was last seen in #clojure, 64 minutes ago saying: or #(%1 %2)
14:47chouserfliebel: back in a sec
14:48fliebelsure :) I nearly got it working :)
14:50chouserok, back. That's great. what have you got?
14:50fliebelhttp://gist.github.com/595835
14:51chousernice!
14:52fliebelthanks :) You're a good teacher :)
14:52chouserI think that's the same as what I have. but you said "nearly"?
14:52fliebelThe problem I had was that first was defined as the first of this, but I couldn't do (first this) of course.
14:53fliebelThe same goes for next, that should return this with first replaced, but I can't just do (assoc this)
14:53fliebelSo then I figured I needed the fn.
14:54chouserif you want to "check" your answer: http://gist.github.com/595663
14:54fliebelthis is your version?
14:54chouseryep
14:56fliebelvery close :) Only you have equiv defined and next uses more. Does it matter if you use .more(method call) or rest?
14:57chousernot really. yours is probably faster
14:57chouserbut duplicates half a line of code. :-)
14:57fliebelyea… :(
14:57chouserso take your pick. what you've got is good.
14:58chouserbetter arg names than mine
14:58fliebelOne problem I have is that drop 5 returns a lazy seq which I can't reverse.
14:58chouseryeah, you see how I work around that in my example?
14:59fliebelrest, I used seq to do the job
14:59chouseroh! smart!
14:59chouserinteresting -- I hadn't considered that, and wouldn't have been sure it would work. nicely done.
14:59fliebelOne thing I haven't figured out yet is how to make a seq that goes 1 2 3 4 5 4 3 2 1, so changes direction in the middle.
15:00fliebelchouser: I wasn;t sure it would work, but seq is magic you know..
15:02chouser(let [[prefix the-rest] (split-at 5 (iter-bi 0 inc dec))] (concat prefix (rseq (seq the-rest))))
15:04fliebelyea, so much trickery… :(
15:05chouserhm
15:05fliebelIt'd be awesome if there was a clean way to do that as an infinit seq.
15:06fliebelI've been thinking about reduce and recur, but immutable stuff makes it hard t say "hay, rseq the rest" in the middle of a loop.
15:07chouserfliebel: right, the problem is applying a different function partway through a seq. split-at is one way to do that. reduce and loop/recur would be others, but aren't lazy.
15:09fogus_I am perplexed by the contrib modules.
15:12chouserfliebel: ((fn f [s] (lazy-seq (cons (first s) (f (rest (if (zero? (rem (first s) 5)) (rseq (seq s)) s)))))) (iter-bi 1 inc dec))
15:14fliebelchouser: I'm going to try and understand :)
15:15fliebelit works, but I'm not yet sure how :P
15:17chouserBTW, I wanted to call attention to my comment on rseq. I think we're abusing it here and probably ought to define a new protocol instead. (defprotocol Spinnable (spin [_])) or something.
15:19fliebelOkay… you use defprotocol for that?
15:19chouseryep
15:20chouserhmm...
15:22fliebelSo now in reify I replace reversible with spinnable?
15:24chouseroh, wait -- does reify not work on protocols?
15:24chousernm, dumb mistake
15:25chouserthere, now you don't have to call seq manually on lazy-seqs: http://gist.github.com/595663
15:26briancarperIs anyone here actually able to pull 1.3.0-alpha1 contrib via Maven or Lein?
15:27raekanyone know why the clojure.github.org/clojure docs for 1.2 seems to have been reverted to 1.1-ish?
15:27fliebelchouser: What? You can just add behavior to existing types? Am I in #ruby?
15:27raekall the clojure.java.* and clojure.test namespaces are gone
15:28chouserfliebel: nope. in clojure we do it without monkey patching or adapter classes. :-)
15:28AWizzArdwhy was it named clojure.java?
15:28chouserfliebel: I mean "nope" you're not in #ruby. Of course you can write new functions that take existing classes as args that then do their own thing with them.
15:28AWizzArdIt could have been more platform neutral, instead of clojure.dotnet/java
15:29raekprobably because those are very host-specific
15:29AWizzArdyou find?
15:30raekfeels like those are mostly wrapper libs for certain java feauters
15:30AWizzArdthose libs are also present in .net
15:30fliebelchouser: But you just added extra behavior to LazySeq, right?
15:30raekok, maybe they are more similar than I thought
15:30AWizzArdit means that if I want to use typical IO stuff, we will have funny java names in my .net code
15:31raekdoes .net have input/ouput streams and readers/writers in the same way java does
15:31dnolenfliebel: it's a properly namespaced extension tho. It's not visible to other namespaces.
15:31chouserfliebel: it certainly looks like I did. In this case we could have written spin like: (defn spin [x] (if (instance? LazySeq x) ...))) right?
15:32fliebelI think so...
15:32chouserit's our function, we just defined it with defprotocol which allows us to add new cases on the fly
15:32fliebelyay
15:32replacaHas anyone else seen a stack overflow out of clojure.lang.Keyword?
15:32replacain the intern method
15:32chouseressentially. Except then rhickey sprinkled it with magic dust to make it very fast.
15:33fliebel:)
15:33chouserfliebel: it's good to know not everyone knows about this yet -- it's my topic at Strange Loop
15:33bhenryfrom the moustache docs:
15:33bhenry(app ["foo" name] my-handler)
15:33bhenry; will route requests to "/foo/", "/foo/bar" to my-handler and bind @name@ (a local) to the matched segment (eg "" or "bar")
15:33bhenryhow do i access the name where (= name "bar")
15:33fliebeloh, I feel special now :)
15:34chouserfliebel: good I'm glad! But... why?
15:34dnolenbhenryy: you need to create a handler fn, 'name' will be visible to it - (fn [req] (my-handler name)), moustache also has a delegate fn to make this less tedious
15:35fliebelBecause I know something not everyone knows ;)
15:35chouserah, good!
15:36bhenrydnolen: i had that and it didsn't work
15:36fliebelExcept that I'm not o sure yet what exactly you just said. Only that it's magic and fast. Two things I like especially.
15:36bhenry*gisting*
15:39chouserfliebel: not coming to Strang Loop I suppose? Or Clojure-Conj?
15:40fliebelI'm located in the Netherlands, so I'm afraid not :( :(
15:41fliebelI'd love to though
15:42chouserfliebel: Here are the basics: http://clojure.org/datatypes
15:42chouseror perhaps "raw details" is a better description.
15:42fliebelchouser: I tried to read that this morning, but maybe with my new knowledge I can understand it.
15:43chouser"Joy of Clojure" and "Practical Clojure" I believe both cover protocols and reify.
15:43fliebelI never read programming books, except when I did Java.
15:44chouserI do sparingly. Learned Pascal and Lisp from books, but not perl or ruby
15:46chouserin both cases the paradigm shift from what I knew to what I was trying to learn warranted the kind of wholistic coverage a book does better than random web postings.
15:46chouserand official docs
15:47fliebelThat would have been true when I started with Clojure, but now I'd get bored by the stuff I already know, and lose myself in side projects based on hte book.
15:48ohpauleezJoy of Clojure has an awesome section on proxy, reify, defprotocol, and defrecord
15:48ohpauleezI reference it often to judge if I'm abusing something
15:48fliebelMan, I turned 100-bootles-of-beer-song-generators from a book into webapps and such, to find out they'd do that a couple of chapters later.
15:49fliebelYea, maybe I should get a book anyway…
15:49ohpauleezfliebel: At the point you're at in Clojure (based on what I follow in here), you'd get a lot of mileage out of it
15:50chouserohpauleez: thanks. didn't want to say it myself. :-)
15:50ohpauleezvery well organized and telling you when and why, instead of how and a little why
15:50ohpauleezchouser: :) it's all good
15:51ohpauleezchouser: real talk, it's one of the best books I've read. Works great as a story, examples are intelligent and easy to follow, but advanced enough to be adapted, Easy to use a reference.
15:52fliebelohpauleez: I think I agree with you.
15:52ohpauleezand the biggest problem I had in clojure was deciding, "when"
15:52fliebelohpauleez: ?
15:52ohpauleezit helped me a lot with that
15:52fliebelwhen?
15:52ohpauleezfliebel: In clojure, you have this whole array of functionality. Take concurrency
15:52ohpauleezwe all have that little chart burned in our brains by now
15:53ohpauleezwe know vars and atoms and agents
15:53ohpauleezbut when should I be using promises over futures, or when am I abusing a future and should really be using an agent
15:53ohpauleezwhen should I use protocols and not some other small hack
15:53fliebelright… I have that problem a lot indeed
15:54chouserohpauleez: that's very encourging, thanks.
15:54ohpauleezJoy of Clojure is structured by answering when, and for me, that pulled it all together
15:55ohpauleezchouser: np, thank you!
15:55fliebelmuhahaha, under 10 there is a whole set of "when to use … "
15:56bhenrydnolen: can you give an example of delegate?
15:57ohpauleezchouser: Out of curiosity, how did you and fogus assemble the book
15:57dnolenbhenry: lemme look
15:57ohpauleezLaTeX?
15:57fliebelohpauleez: How comes you have already read it when it's not out yet? You do the MeAP ebook thing?
15:57chouserohpauleez: heh. you don't want to know.
15:57chouserohpauleez: sausage-making and all that.
15:57ohpauleezchouser: haha, fair enough
15:58chouserohpauleez: nah, I kid. We wrote it in markdown, augmented with our own various extensions.
15:58ohpauleezfliebel: Yeah, I got the MEAP when the first chapter was finished, and read the chapters as they were released
15:58chouserohpauleez: then wrote tools to generate Manning's docbook-like XML from that, which they use to generate PDFs, etc.
15:59ohpauleezahh, cool
15:59fliebelnice
15:59dnolenbhenry: http://github.com/cgrand/moustache/blob/master/src/net/cgrand/moustache.clj#L159
16:00dnolenbhenry: (delegate foo name) -> (fn [req] (foo req name))
16:00fliebelchouser: Is there a release date, or is it a "don't ask, it's read when it's ready" thing?
16:01chouserfliebel: fogus_ and I are essentially done, as far as I understand. It's going through final editing revisions now and should be on dead trees by Nov or Dec.
16:02fliebelCool :) I prefer a real book over an electronic one, except for searching :)
16:02bhenrydnolen, i had just read that and gotten it to work when you posted. thanks for the help.
16:02ohpauleezfliebel: I don't know if you can still do it, but you can get a package deal
16:03ohpauleezebook and physical one, for a great price
16:03fliebel"MEAP + Print book (includes Ebook) when available"
16:03ohpauleezright, you get the ebook now
16:03ohpauleezand the print book is shipped
16:03fliebelnice :)
16:04dnolenanybody know who the intro is written by yet?
16:04ohpauleezdnolen: The Stu's
16:04chouserfliebel: there are often coupon codes listed at joyofclojure.com
16:04ohpauleezdnolen: nah, I'm just making it up
16:05chouserdnolen: not yet announced, afaik. :-)
16:05dnolenarg
16:06fliebelchouser: ?
16:06fliebelWhere do I look for?
16:06chouserfliebel: we're very excited about who we've got to write the foreward for us, but for some reason are keeping it a secret for now.
16:06chouseroh, what are you asking?
16:07fogus_chouser: BTW, got an email. Things are back on track WRT to the foreword. :-)
16:07chouserfogus_: ah, great news. I wasn't really worried.
16:07fliebelchouser: I was asking about the coupon codes. What do you mean by listed?
16:07fogus_yeah really.
16:07chouserfogus_: not as if this person has shown difficulty producing large amounts of text in the past.
16:08chouserfliebel: oh, sorry. It would be right by the "Buy it" link if there were one running right now.
16:08fliebelchouser: Ah, okay, I'll keep any eye on it, or probably not actually, but anyway.
16:08lpetithello all
16:09chouserfliebel: if you use twitter you can follow fogus or me -- we generally tweet when we hear about coupon codes.
16:09chouserlpetit: hi!
16:10fliebelchouser: I was about to do that anyway :) My Twitter is becomming full of awesome Clojure people :)
16:10lpetitchouser: you lose. I need somebody's help, you answered to me, you're the one ! :)
16:11lpetitchouser: more seriously, is it a time where I can talk about a problem, do you have enough bandwidth currently ?
16:12alpheusHow do you specify that a Var is bound in a function's :pre condition?
16:13fogus_The Clojure Maven repos are busted. Should be fixed... eventually.
16:13wwmorgan1alpheus: can you call the java method isBound on it?
16:13chouserlpetit: hm, it's nearly time for TF2, so perhaps not.
16:14lpetitI have questions related to clojure and its use of classloaders. We're trying, with cgrand, to see what could be done better in our way to embed in OSGi.
16:14alpheusI think I'm really just asking what is the argument for bound? supposed to be?
16:14lpetitWhat's TF2 ?
16:14ohpauleezTeamFortress 2, I'm guessing
16:14chouserlpetit: way off topic. ohpauleez is correct.
16:16alpheusI would have thought (bound? 'foo) but clojure.lang.Symbol cannot be cast to clojure.lang.Var
16:16lpetitFirst question: is there a way for me to initiate the Clojure environment, or very quickly after its initialization, with a parent classloader of my own. So that clojure always tries to find a classpath resource (bytecode on disk, clojure file on disk) via my classloader before "giving up" ?
16:16MayDanielalpheus: (bound #'foo)
16:16MayDanielbound?*
16:17lpetit>(doc bound?)
16:17lpetit,(doc bound?)
16:17clojurebot"([& vars]); Returns true if all of the vars provided as arguments have any bound value, root or thread-local. Implies that deref'ing the provided vars will succeed. Returns true if no vars are provided."
16:17ninjuddlpetit: not sure i am qualified to answer, but i spent many hours a few months back trying to do something similar
16:17alpheus(bound? #'foo) raises Unable to resolve var: foo in this context
16:18hiredman-Djava.system.class.loader
16:18lpetitninjudd: interesting. If you have a clearer "vision" of how things work
16:18hiredmanbut if the classloader you specify references clojure clojure will be loaded
16:18wwmorgan1alpheus: do (declare foo) first. then bound? on #'foo will return false
16:19lpetithiredman: I can not tweak things at this level. I cannot force every user of ccw to tweak its loading script for eclipse
16:19MayDanielalpheus: What are you trying to do? Are you sure bound? is what you need?
16:19hiredmanso you need to either write the classloader in java or use ASM to generate byte code that doesn't reference clojure
16:19hiredmanlpetit: *shrug*
16:19ninjuddlpetit: my solution was to use setContextClassLoader, but i ran into what i think is a bug in how clojure handles *use-context-classloader*
16:20ninjuddlpetit: my travails are detailed in this thread: http://groups.google.com/group/clojure-dev/browse_thread/thread/f61b550abf7f9c52/da25ba7e31b9431c
16:20lpetitninjudd: you tried your tests for which kind of environment ? OSGi ? WebApp ?
16:20stuartsierraBwahaha, I broke Contrib.
16:20stuartsierraTrying to fix now.
16:20lpetitninjudd: thx I'll consult it
16:22alpheusI am not sure bound? is what I need. I am writing a function that relies on something that I expect will be set up by def/defvar or in a binding form and I wanted to assert that in the pre part of a condition-map for the function. Please feel free to tell me I'm going about that all wrong and point me toward the right documentation.
16:22lpetithiredman: no problem. I can write the classloader in java. But I can not "insert it" in the classloader hierarchy in the classical way. It's "constrained" by OSGi. Rather, I would like to create my own classloader, which will leverage the OSGi classloader as its parent one, and then inject mine (which will have some goodies such as being able to consult all classloaders of all bundles that...
16:22lpetit...depend on the clojure bundle) as the "reference" classloader for clojure
16:22lpetithiredman: at this particular moment, I don't even know if what I just described makes sense
16:23lpetitninjudd: before even reading your post, reacting to your explanation: my fear is that I do not have control over the context class loader in the long run. I'm thinking about entering by the backdoor room :)
16:24wwmorgan1alpheus: I think that what you want to know is whether the namespace has the symbol you need. In this case you want ns-resolve
16:24hiredmanlpetit: that is a complex issue
16:24hiredmanand surprisingly oracle or ibm have some patents related to it
16:24hiredman(ugh)
16:24lpetithiredman: oooh yes ! took us awake veeerry late yesterday !
16:24lpetitpatents ?
16:25hiredmanninjudd: I haven't look at clojure's use of classloaders much, but the use of dynamic classloaders the way they are may be what allows the redefinition of records at a repl
16:25hiredmanlpetit: I know right? crazy
16:25lpetithiredman: probably not an issue, everybody knows those people work for science, not profit ;-)
16:26hiredmanfiltering classloaders and such
16:26hiredmanhttp://www.faqs.org/patents/app/20080271002
16:27duncanmla la la
16:27lpetithiredman: it really is totally crazy to place patterns on such trivial "thoughts" !
16:28lpetitand even more crazy to accept those as patterns !
16:29lpetithiredman: I haven't played with records that much. There's still a restriction on their redefinition ? Due to the fact that a real class is generated, right ?
16:30ninjuddhiredman: my change didn't affect the repl. it still had DynamicClassLoader as the parent of NativeClassLoader. plus i only change the classloader temporarily in my import-native method
16:31lpetithiredman, ninjudd: reading ninjudd's link and others related to OSGi/context class loader. Will come back to you within 15 minutes
16:32ninjuddhiredman: but i'm past NativeClassloader anyway. cake handles native libs perfectly without having to muck with the classloader
16:32ninjuddmy point was just that i think there is still a bug in how clojure handles *use-context-classloader*
16:33hiredmanas I said, I have not really looked at it, but classloading is very complicated, and is definitely tricky in the case of redefining classes
16:36ninjuddhiredman: agreed, it is very complicated. which is probably why cemerick was the only person brave enough to respond to my message
16:37cemerickwhich message was that?
16:37ninjuddthat classloader message from way back when
16:42ninjuddhiredman: the complexity is also likely why nobody wanted to touch a patch from some kid they'd never heard of to fix a bug that nobody else had noticed ;-)
16:42ninjuddbut that doesn't mean it isn't a bug
16:44hiredmanI will with hold judgement on bugness until it's been reviewed elsewhere
16:45ninjuddhiredman: probably won't ever happen. it's over four months old.
16:46hiredman*shrug*
16:46ninjuddunless someone with more clout has the same problem. then i shall be vindicated!
16:47cemerickninjudd: is there a bug opened on assembla?
16:48ninjuddgood question
16:48ninjuddlooks like i never opened one. i think this was back before i had access
16:49dnolenninjudd: do it!
16:50lpetitninjudd, cemerick, hiredman: just read an article or two on the subject of OSGi and its affinities with context class path. It's just a no man's land in the spec. Every container has its own way to use it. Some expose every exported package by every bundle in this classloader, some do not guarantee that it is set, some by the use of proxies at bundle boundaries try hard to always set it...
16:50lpetit...correctly (but I guess that you need to always use OSGi services then, not directly call classes exported by another bundle ...
16:51ninjuddyou scared him off
16:54ninjuddlpetit: sounds painful
16:55lpetitninjudd: ooh yes. That's why I somehow give up on trying to cheat with OSGi, and now I'm trying to cheat with clojure :-). I can even consider hacking it a little bit in the corners. But right now I just need to understand how it works.
16:57ninjuddso how do you plan to cheat with clojure? replace DynamicClassloader?
17:00lpetitninjudd: first step = find a summary of how the parts that use classloaders work, or someone with the ability to do this summary "live" for me. Then I'll see if this "DynamicClassloader" should be extended, composed, replaced, etc. (I don't even know exactly what I'm talking about, concerning Clojure and classloaders. And this kind of subject does not suffer to be imprecise)
17:02ninjuddlpetit: i would start by trying to write your own classloader that users DynamicClassLoader as it's parent, which means that resources that are not found by your classloader will be loaded using dynamic classloader.
17:02ninjudds/users/uses/
17:02sexpbot<ninjudd> lpetit: i would start by trying to write your own classloader that uses DynamicClassLoader as it's parent, which means that resources that are not found by your classloader will be loaded using dynamic classloader.
17:03ninjuddlpetit: then you can use setContextClassLoader to change clojure to use your classloader instead of DynamicClassLoader.
17:04ninjuddlpetit: what you are doing sounds very similar to what i was doing. NativeClassLoader and my import-native function are good examples
17:04lpetitninjudd: it's more that I don't know in which ways I can direct clojure to use my classloader. I remember vaguely having seen various places where a modif can be made (some *use-context-classloader*, some CLASS_LOADER static attributes of RT / Compiler, BASE_CLASSLOADER, etc). I'm lost between those "alternatives"
17:06lpetitninjudd: but *when* to call setContextClassLoader() ? I cannot do this once and for all, or I'll not play well with OSGi (that's what I understand). By doing so I may expose to few or to many things to all other following users of the thread. And I have no guarantee that it will not be changed by somebody else in the future.
17:06lpetitInstead of telling clojure "use the context classloader", I would rather have a way to tell him: please also try to always use as a last resort this classloader I'm handing you
17:06lpetitonce and for all
17:09ninjuddwell, clojure does that with the parent of DynamicClassLoader, which should be whichever classloader loaded clojure.lang.Compiler
17:09lpetitOh and I also just thought about this one: the context classloader, by definition, is for one thread. I'm not sure at all in OSGi that I have any guarantee that it will always be this thread that will be used when accessing e.g. RT ?
17:09ninjuddIIRC
17:09ninjuddlpetit: good point
17:13ninjuddlpetit: this part of clojure seems like a total mess to me. if you can convince someone (i.e. stuarthalloway) to clean it up, that would be a very good thing
17:15lpetitninjudd: a real world example of the problem. An AOT class is declared in a bundle A, via the plugin.xml. At some point the eclipse frameworks wants to load the class. I don't know when, I have no control, the class will automatically call clojure in another bundle to initialize its implementation namespace. I have no way to take control in this workflow by superimposing my "classloader-which-will
17:15lpetit-call-back-to-the-calling-bundle-loader" so that clojure will even be able to find the implementation namespace's ".clj" resource
17:16lpetitninjudd: I'll try, as soon as I seem to know what I'm talking about :)
17:16ninjuddhttp://books.google.com/books?id=CvvdZtzxnAEC&amp;lpg=PP1&amp;ots=3G5cW4y2NJ&amp;dq=stuart%20halloway%20Component%20Development%20java&amp;pg=PA11#v=onepage&amp;q&amp;f=false
17:17ninjuddwritten by stuarthalloway
17:19ninjuddlpetit: yeah, i think changing the classloader used by clojure can't be done without a patch
17:19ninjuddunless you can control which classloader is used to load clojure.lang.Compile
17:20lpetitninjudd: I can live with such a (probably) tiny patch for the needs of ccw.
17:20ninjuddlpetit: but then every user of ccw must use a forked version of clojure
17:22AWizzArdninjudd: were you the guy who implemented a Set that keeps the order of insertion?
17:22lpetitninjudd: no we thought about 2 scenarios with cgrand: one where we totally bypass OSGi and indeed create and wire "on the fly" clojure environments. In this scenario we control which classloader is used to load clojure.lang.Compile. But this scenario does not play well with OSGi when you add AOT compiled classes to the dance. They just never will be able to get a the proper clojure classes,since t
17:22lpetithey are isolated from OSGi.
17:22ninjuddAWizzArd: yes
17:22lpetitninjudd: thanks god no.
17:23lpetitninjudd: it's been months (if not years) since ccw does not mistake its own clojure environment with each of the user's projects environments :)
17:23ninjuddi see. like lein and cake
17:23AWizzArdninjudd: please look into your priv messages
17:24lpetitninjudd: but it's fair to say that users whose job is writing Eclipse plugins could benefit from this new approach (and the patched clojure) if they want the greater repl experience in their own development cycle
17:24lpetitninjudd: yes, they now do like ccw :-p
17:53erikcw15
17:54amalloyerikcw1: 11
17:55erikcw1I have a string that contains some html. I'm trying to process it with enlive, but I can't figure out how to get started. Any ideas?
17:58raekI suspect that you could pass an instance of java.io.StringReader ot html-resource (note: I have not tested this)
17:58erikcw1raek: thanks -- I'll try that. I still have a heck of a lot more Python in my head than Java
17:59raekhrm, maybe you need to pass an java.io.StringInputStream instead...
18:01raekhere's the multimethod that handles how a resource is made from the argument: http://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj#L49
18:01erikcw1I was just looking at that, looks like it takes both a java.io.Read and an InputStream
18:02raekah, didn't see the Reader part...
18:02erikcw1what's the difference between a Reader and a Stream?
18:02raekusing a Reader would be preferred
18:02lpetitbest resource on the subject I've found: http://www.infoq.com/articles/code-generation-with-osgi
18:02raekthey do characters and bytes, respectively
18:03raekstrings are character-based, so using a reader avoid any redundant encoding to and decoding from bytes
18:03erikcw1ok, makes sense
18:04erikcw1you wouldn't happen to know off the top of your head how to render the enlive object back into a string after it has been processed would you?
18:05raekI have barely begun using elive :-)
18:05erikcw1:)
18:05raekiirc, it makes lazy sequences so that the whole document doesn't need to be in memory at once
18:08erikcw1raek: (apply str (html/emit* ENLIVE_OBJECT)) does the trick
18:12raekok, neat
18:13raekI think Ring accepts sequences of strings as reponse bodys
18:14raek(in case you were coding web with some Ring-based framework)
18:20erikcw1not using Ring yet. thanks for the info though
18:22amalloyraek, erikcw1: Ring does indeed accept seqs of strings. i was reading through the APIs just last night to get my feet wet
18:24duncanmi want (contains? [10 20 30 40 50] 50) to return true, which call should i be using instead?
18:25raekhrm, I think that new fn was added recently
18:25raekit scanned the sequence for the element in linear time
18:26raekanyway, using sets are often a better solution
18:26raek,(contains? #{10 20 30 40 50} 50)
18:26clojurebottrue
18:26scottjit was discussed or possibly temporarily introduced but I don't think it made it
18:27iGNOSaurusHi!
18:27raek,(some #{50} [10 20 30 40 50])
18:27clojurebot50
18:27iGNOSaurusHow do I turn a seq of characters into a string? Sorry for being a noob!
18:27raek,(some #(= % 50) [10 20 30 40 50]) ; if you really need a bool
18:27clojurebottrue
18:28duncanmiGNOSaurus: (apply str s)
18:28raekiGNOSaurus: not very obvious, but (apply str [\f \o \o])
18:28iGNOSaurusduncanm: Thanks!
18:29iGNOSaurusIt makes a lot of sense if you know how stuff works. :)
18:29wwmorgan1,(clojure.contrib.seq-utils/includes? [10 20 30 40 50] 50)
18:29clojurebottrue
18:33amalloyduncanm: you probably don't want true anyway, just something non-false; in which case raek's first two examples are perfect depending on whether you can store your stuff as a set or not
18:54lpetit,(some #{false true} false)
18:54clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Boolean
18:54lpetit,(some #{false true} [false])
18:54clojurebotnil
18:55lpetitI love this one :)
18:55amalloy,(some false? [false])
18:55clojurebottrue
18:56lpetitof course. But for example cannot be used in a generic way (not controlling the set :-))
19:02abedradoes anyone know how to read a raw device from java?
19:02abedrai'm trying to capture input from /dev/input/js0
19:02abedrawhich I know is spitting out information
19:02abedrabecause I can cat /dev/input/js0
19:04alsocaseyI was wondering whether anyone could offer some insight concerning this aquamacs/SLIME/swank-clojure setup issue I'm struggling with over here?
19:05alsocaseyspecifically, while I can run a standalone REPL just fine, initiating a swank session and connecting to it in Aquamacs leads the REPL to freeze on any but the simplest inputs
19:09scottjdoes it work in normal emacs?
19:11alsocaseyHaven't tried with standard emacs yet - I was hoping someone might have experienced similar and could provide a quick solution
19:12amalloyabedra: it's the same as reading any file, isn't it?
19:12iGNOSaurusIs there a really simple way to add a list of characters to a set? That is, the individual characters. :) Thanks again!
19:13amalloy(,into #{\a \b} [\n \6])
19:13iGNOSaurusI've been watching 5 hours of video, and it seems so simple when other people are doing it. When I type myself most things fail miserably.
19:13amalloy,(into #{\a \b} [\n \6])
19:13clojurebot#{\a \b \n \6}
19:14iGNOSaurus,(into #{\a \b} '(\n \6))
19:14clojurebot#{\a \b \n \6}
19:14iGNOSaurusThanks! OMG. That is simple. :)
19:14amalloyit always is, eventually :)
19:14iGNOSaurusYeah. :)
19:18amalloy(use 'clojure.java.io)
19:18amalloy(->> (file "/dev/urandom") reader line-seq (take 2))
19:18amalloyabedra: ^^
19:21technomancyalsocasey: aquamacs is not very well supported since it's not cross-platform
19:21alsocaseyI suppose I'll try again with regular emacs
19:22abedraamalloy: i guess it is
19:23technomancyalsocasey: could also be an issue with clojure 1.3 if you're using that; swank hasn't been updated for it yet
19:23ninjuddalsocasey: i know lancepantz uses aquamacs with swank all the time with no problem.
19:23ninjuddbut he talks about switching off aquamacs all the time
19:23alsocaseytechnomancy: no, this is using clojure 1.2
19:24alsocaseyninjajudd: yes I figured it was something I was missing since Aquamacs seems to be used by others without problems - also "switching off"?
19:25ninjuddto plain-old-emacs
19:25alsocaseyah - well I'll try that then
19:31iGNOSaurusLike, dudes. I'm amazed, my first program. :) Thanks for the help.
19:35amalloywhat's it do, iGNOSaurus?
19:41iGNOSaurusNot much. It reads in a Norwegian dictionary from file, and it picks out the words that uses "allowed" letters.
19:41iGNOSaurusA friend of mine, who's a teacher for young children, wanted it. They only know four letters, and she wants to know which words they can learn to spell. :)
19:44alsocaseytechnomancy: sure enough it works fine under regular emacs
19:46lpetitif somebody can explain how RT.USE_CONTEXT_CLASSLOADER works, please explain
19:46ninjuddnot very well ;-)
19:48lpetitseems convoluted, and I don't fully grasp why so
19:48ninjudd,(clojure.lang.RT/baseLoader)
19:48clojurebot#<DynamicClassLoader clojure.lang.DynamicClassLoader@1fd523d>
19:48ninjudd,(.getParent (clojure.lang.RT/baseLoader))
19:48clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
19:48ninjuddmeh
19:49ninjudd,(println "#<DynamicClassLoader clojure.lang.DynamicClassLoader@169c6f2>")
19:49clojurebot#<DynamicClassLoader clojure.lang.DynamicClassLoader@169c6f2>
19:49ninjuddthat's better ;)
19:49ninjuddtry it for yourself. the baseLoader is a dynamic classloader, as is it's parent
19:50ninjuddwhich is not right
19:51lpetitno, its parent is a FactoryURLClassLoader for me, with cljr and
19:51lpetit...
19:52lpetitsome probably not so old (.getParent (clojure.lang.RT/baseLoader))
19:52iGNOSaurusWhat's the best framework for doing web with Clojure?
19:52lpetit1.2.0-master-SNAPSHOT
19:53ninjuddhmm, running clojure from the jar directly i get: DynamicClassLoader -> DynamicClassLoader -> AppClassLoader
19:53ninjuddiGNOSaurus: i'm fond of compojure
19:53iGNOSaurusCool, thanks. I'll look at it.
19:54ninjuddnot quite a framework though. you'll still need a few more pieces for html, javascript, ORM?
19:54lpetitanyway, I want to interpose something between DynamicClassLoader and AppClassLoader. If I could make it "generic" or "pluggable", it *could* be an acceptable patch
19:55ninjuddlpetit: here is my patch to RT to fix *use-context-classloader*: http://github.com/ninjudd/clojure/commit/4dac03fb2b47a33c77704c00fc9086f4c9b9dc3a
19:55ninjuddthat's how i think it should work
19:56lpetitninjudd: I' look at it. Please not that I absolutely want to avoid using *use-context-classloader*, though :). Is this "var" intended to be used from outside clojure core ?
19:56lpetit(ok I must really read your post)
19:58ninjuddi assume so, but at one point they changed the root binding from false to true to fix a bug. now it is kind of pointless. i believe the right fix would have been changing baseLoader as i have done
20:01ninjuddhttp://github.com/clojure/clojure/commit/b045a379215d1f48e6a2e6cedcdb41526cd5bb25
20:01ninjuddi believe that change was prompted by the netbeans problem cemerick mentioned in the thread
20:15amalloyiGNOSaurus: http://gist.github.com/596278 is my go at it. probably not as legible as yours, but you might get some neat ideas from it about how expressive clojure is
20:25lpetitninjudd: all this *use-context-classloader* remains opaque to me. Looks like a hack,
20:25lpetits/remains/stuff remains/
20:25sexpbot<lpetit> ninjudd: all this *use-context-classloader* stuff remains opaque to me. Looks like a hack,
20:26lpetitninjudd: in your patch, shouldn't you try to position it to true from within the main.clj ?
20:26ninjuddlpetit: agreed seems that it would be better to have a *classloader* var that you can modify the root of
20:28ninjuddlpetit: not sure what you mean about main.clj
20:29ninjuddoh, you mean to wrap the call to setContextClassLoader with a binding of *use-context-classloader*?
20:30lpetitninjudd: in the changeset of Rich you pointed, there was a conjunction of several changes: on in main.clj to try hard to set the context classloader to a meaningful value, and one to change the value of *u-c-c* so that what has been done in main.clj has a chance to be used
20:30lpetitno
20:30lpetitI mean, in main.clj, set the value of *use-context-classloader* to true, for the REPL thread
20:31ninjuddlpetit: that's what i meant when i said "wrap the call to setContextClassloader"
20:31ninjuddi wasn't all that clear. should have qualified it with: in the repl function
20:32lpetitninjudd: sorry I dindn't understand that. I thought you hoped that just calling binding for the duration of the setContextClassloader() method call
20:33ninjuddoh, right. you would have to bind it for longer than that. good point
20:34ninjuddlpetit: i don't think the setContextClassLoader is necessary with the the fix to baseLoader. that is what is causing the double-parent problem i pointed out
20:35ninjudd(which may be why you didn't see it in cljr)
20:35lpetitguess we'll have to block rich hickey in some corner at the clojure conj to know the final word about all this :)
20:36ninjuddhehe. and stuarthalloway since he "wrote the chapter" on classloaders ;-)
20:37lpetithuh ?
20:37ninjuddi sent the link before
20:37ninjuddhttp://books.google.com/books?id=CvvdZtzxnAEC&amp;lpg=PP1&amp;ots=3G5cW4y2NJ&amp;dq=stuart%20halloway%20Component%20Development%20java&amp;pg=PA11#v=onepage&amp;q&amp;f=false
20:39lpetitoh ok ;)
20:40ninjuddlpetit: yep. cljr does its own classloader magic: http://github.com/liebke/cljr/blob/master/src/main/resources/cljr/main.clj#L95
20:42lpetitninjudd: why does he store previous-classloader but not use it ?
20:43lpetitAgain an example of use of the context class loader as if it were in full control of the whole world :-(
20:44lpetitworks for the REPL, from a Request thread in a webapp, but, again, not in an OSGi context :-( :-(
20:44lpetitanyway thanks for the link !
20:51ninjuddlpetit: no problem
20:52ninjuddlpetit: for your case, would *classloader* be sufficient? assuming you could alter the root to be your modified classloader
20:53lpetitI guess so
20:55lpetitI am in control of the first invocation of a clojure class. e.g. I call Class.forName("clojure.lang.RT"). If just after that I set the root of *classloader* to be my own, then it's ok
20:57lpetitbut isn't this a problem that for its core initialization, clojure would have used as its root a "temporary" classloader. I should ensure that the "old" *classloader* of clojure is the root classloader of my own, right ?
21:00lpetitninjudd: if we don't want to break anything, we must keep it in place, though
21:00lpetitok, must go to bed (3am here !)
21:00lpetitcu later !
22:25nroot7In my program I represent each user as a agent maintaining its own state. This works fine w.r.t. to concurrency but what if I want to persist this state in a non-volatile way. Is this a common pattern in clojure world ? How is it implemented ?
22:30technomancynroot7: if 100% absolute consistency is not a requirement, you can have a watcher on your agent that serializes to disk
22:31nroot7technomancy: thanks
23:36bhenryhow can i make this happen?
23:36bhenry[:option {:value "123"} "Item" ] => [:option {:value "123" :selected true} "Item" ]
23:38wwmorgan1,(assoc-in [:option {:value "123"} "Item" ] [1 :selected] true) ;If you can guarantee that your data structure will be a vector
23:38clojurebot[:option {:selected true, :value "123"} "Item"]
23:40bhenryoh duh. i was looking right at assoc-in and forgot the key didn't already have to exist.
23:41wwmorgan1,(assoc-in {} [:a :b] :c) ; :-) You can do multiple levels of nesting too
23:41clojurebot{:a {:b :c}}
23:47technomancyit looks like in some situations clojure.walk treats MapEntries as distinct items, while sometimes it doesn't
23:47technomancyI don't suppose that's intentional?