#clojure logs

2009-10-21

00:15CalamitousI have a newb question if anybody has a moment :)
00:16CalamitousI have a list of data [1 2 3]-- I'd like to send the elements of the list as params for a method (defn foo [& a] ... so that it comes out as though calling (foo 1 2 3)
00:16Calamitousbut the method only acts as those I'm passing a single param (foo [1 2 3])
00:17CalamitousIs there a way to pass the list elements in as individual params?
00:17Calamitousor am I completely barking up the wrong tree?
00:19mikehincheyapply
00:20mikehinchey,(apply + [1 2 3])
00:20clojurebot6
00:20Calamitousoh i gotcha
00:21Calamitouskewl, thanx! :D
01:05tomojis there an idiomatic way to "loop" through a seq with indices?
01:12slashus2tomoj: I guess you could use doseq and use range. What are you trying to do?
01:13tomojI don't see how doseq would do it
01:13cgrandtomoj: there's indexed somewher in contrib. But iterating over a seq with indices isn't idiomatic.
01:13tomojright
01:13hiredman(map (fn [v i]) some-seq (iterate inc 0))
01:13tomojsometimes I've needed to do it, though
01:13tomojhiredman: ah, yes :)
01:14cgrandtomoj: agreed, sometimes you need it, often for interop
01:16slashus2What do you all think of these macros? http://paste.lisp.org/display/89023
01:16tomojnow I can't remember why I wanted it before
01:17slashus2I have been pondering over the second macro.
01:18slashus2Maybe it is my bad habits, but I sometimes find that I need to do side-effects inside transactions. This seems to do the trick. I would like to add the option to specify whether you want to do a send or send-off.
01:20slashus2The first one I found useful for replacements of the while (n = something > 5) { interop thing
01:20tomojaren't transactions exactly where you want to be doing side-effects?
01:20tomojoh, you mean like printing stuff
01:20slashus2You shouldn't do side effects in transactions because it may repeat.
01:20slashus2But the transactions only sends to agents when the transaction is complete.
01:20slashus2send*
01:21tomojI count mutating state as a side effect. is it not?
01:21hiredmanit is
01:21cgrandslashus2: Why do you introduce a pred# and use resolve?
01:21hiredmanbut you don't do that in a transaction
01:21tomojyou don't mutate state in a transaction?
01:22tomojI thought that's what transactions were for?
01:22hiredmanyou take a an immutable value, produce a new immutable value, and when the transaction succeeds the new value is swapped in for the old
01:22slashus2cgrand: Because I am not very good at writing macros... :-P It is when you actually take the pred argument as data. It needs to be resolved as a function. I think at least.
01:22tomojyes.. that sounds like mutating state to me
01:22hiredmanno
01:23slashus2It is actually an atomic operation of pointing to a new object with potentially shared components.
01:23cgrandYou shouldn't do *unmanaged* side effects in transactions because it may repeat. (managed side effects being send/send-off and anything that change refs)
01:23tomojso it's atomic and the values are immutable, you're still changing the state, right?
01:23hiredmannot within the transaction
01:23tomojoh, I see
01:24slashus2cgrand: Do you see where the when-commit macro could be useful? It even allows you to specify your own agent when needed.
01:26cgrandslashus2: haven't looked at it yet
01:26slashus2okay
01:27technomancytomoj: I've wanted doseq + counter like three times in the last week
01:28technomancyconsidering a patch to add it
01:28technomancyI'm using indexed right now, but adding it as another keyword arg to doseq/for would reflect intentions much more clearly.
01:30tomojlike (for [x aseq :index i] ...)?
01:30slashus2Have you all ran into the case that my when-let macro solves a lot?
01:30cgrandslashus2: http://paste.lisp.org/display/89023#1
01:31slashus2Can't believe I missed that. Sometimes destructed binding skips my mind.
01:33slashus2cgrand: Looks wonderful. Thank you.
01:36slashus2cgrand: I don't think your second macro down there works properly.
01:36slashus2neither one
01:43slashus2cgrand: http://paste.lisp.org/display/89023#2 I think this fixes it.
01:44slashus2Or you could do without the apply and your version would work.
01:45cgrandslashus2: right, apply here is plain wrong
01:46cgrandbut I can't spot what you changed
01:46cgrandwithout apply http://paste.lisp.org/display/89023#3
01:46slashus2Instead of ~@, I did '~
01:46slashus2Meaning it still was in the list form
01:46slashus2so apply could work on its contents.
01:47slashus2Is the when-let macro well constructed?
01:47slashus2I mean
01:47slashus2when-commit
01:51slashus2I am going to try to get Clojure working on a SR4 robot tomorrow. Need to figure out how to get clojure on the robot's module loader classpath.
01:52hiredmanclojurebot: how can slashus2 get clojure on to the robot's classpath?
01:52cgrandah ok, don't do that ('~) :-) and remove apply instead. '~ (and the induced resolve you had earlier) wouldn't behave like you expect: try with your last while-let: (while-let [x 0 > (+ 0 0)] (println "hello"))
01:52clojurebotclojure is a language to use if you want to up your game
01:52hiredmanhmmmmm
01:53hiredmanthat was an awful lot of cpu time for that
01:53slashus2cgrand: That is true....
01:54slashus2hiredman: Yes. I have to extend some DefaultModule class to be able to initialize the module. It sends the kernel's module loader to it.
01:55slashus2Thought it would be cool to write a module using clojure.
01:57hiredmanlisp is the language of ai
01:58hiredmansomething in clojurebot's fuzzy lookup logic is burning more cycles than I would like
01:58cgrandslashus2: http://paste.lisp.org/display/89023#4 you tend to do at runtime (in the expansion) things you can do better at compile-time
01:58slashus2It is for my AI class. We are using XLISP in our class. I should have tried to convince the professor to use clojure.
01:59hiredmannice
01:59slashus2cgrand: I see that now.
02:00hiredmanI want to get pleo, and wire a gumstix to the debug port, then run clojure on it
02:01hiredmanbut that is well over my toy budget
02:01slashus2These robots run a stripped down version of debian on ARM11 processors.
02:02slashus2They have sonar, wifi, temperature gauges, etc.
02:03hiredmanI google it :P
02:03hiredmanlooks like a beast
02:03hiredmanman sonar
02:03hiredmanwow
02:03slashus2Looks sort of like R2D2
02:05slashus2I wish it had arms that could grab things.
02:10slashus2hiredman: I mean I was able to start a clojure repl inside the robot's OS. I guess that was pretty cool.
02:11slashus2Unfortunately, I couldn't control any of the robot's modules successfully during the time I tried.
02:12hiredman:(
02:13hiredmanneed a clojure <-> xlisp bridge
02:14slashus2No, the robot runs java.
02:14slashus2I was just commenting that we use xlisp for some of the smaller applications in the class.
02:15hiredmanoh
02:17slashus2hiredman: I tried to use :gen-class to make its main module, but, like I said before, I couldn't get clojure on the classpath.
02:19slashus2Thought maybe there was a slight chance I could write my robot project in clojure.
02:21hiredmanyou might try writing a java class that creates your own classloader and use that to try and load clojure
02:22slashus2Is that very difficult?
02:22hiredmanhttp://java.sun.com/javase/6/docs/api/java/net/URLClassLoader.html
02:22hiredmanI dunno
02:22hiredmanURLClaassLoader looks simple enough
02:23slashus2I will look into that.
03:55AWizzArd~seen kotarak
03:55clojurebotno, I have not seen kotarak
06:53AWizzArd~max people
06:53clojurebotmax people is 187
06:53AWizzArdcemerick: last was 185 :)
06:53licoressethe daily max people routine ;-)
06:54cemerickit's good, it's good
06:54cemerickI *still* wouldn't worry about it, tho. :-)
06:55cemerickI think the tipping point of (at least moderate) longevity is long since past.
06:56AWizzArdAs long Rich is healthy and interested.
06:59licoresse:D
06:59licoresseplenty of brilliant people here
07:08ambientare there any ready-made macros for fast array processing? so i wouldn't have manually to aset aget everything?
07:09ambientlike array-let and (set-array [a b c] my-array)
07:39cgrandambient: apart from amap and areduce (which are not what you want), I don't know
07:39cgrandwhat are you trying to do?
08:04ambientcgrand a lot of stuff with arrays of doubles. audio digital signal processing, real time
08:09AWizzArdcgrand: in PersistentHashMap.java I see that count is of type int. Does that mean that hashmaps are limited to contain 4 milliard elements only?
08:11cgrandAWizzArd: on a 32 bit CPU it's a safe bet. Java collections have that limit too.
08:11cgrandambient: ok, thx
08:15AWizzArdI see. So it is something for Java 8 or so, when it will be typical for business machines to have 0.5 TB RAM.
08:22cgrandAWizzArd: and int is signed so 2^31-1 items max
08:30AWizzArdcgrand: yes true, so it's even less
08:30AWizzArdfortunately we have no need for 2 milliard k/v pairs right now in one single map ;-)
09:12dom1410hello i need some help.
09:12dom1410i try to write a funktion which initializes a java object from a java class
09:12dom1410like this
09:13dom1410http://pastebin.com/m6871a4b8 but there is a java.lang.Exception
09:14chouserbla?
09:14The-Kennydom1410: Are you sure the problem is this line? I don't see the symbol "bla"
09:14dom1410^^ i try to call the funktion like this "(new-model bla)"
09:14chouserah
09:15dom1410sorry..
09:15The-Kennydom1410: Use a macro. the repl tries to evalue bla before calling the function.
09:15chouser'def' does not evaluate its first arg
09:15dom1410ah ok..
09:16chouserit always takes the symbol you give it as the literal name of the Var to create.
09:17dom1410ok i so it's better to use a makro?
09:17chouserdom1410: also, it's generally discouraged to create new named Vars on the fly at runtime.
09:17chouserare you sure it's what you want to be doing?
09:18dom1410hm.. we want to make our GUI programm running with a console using a repl
09:19chouseryou might consider something like (def DGEModels (ref {}))
09:20chouserthen new-model can store your DGEModel instances there with appropriate concurrency behavior.
09:20chouserand no need for macros. :-)
09:21tmountainhey guys, I have a general question regarding Java interop
09:21dom1410that sounds nice... i will try..;)
09:21dom1410thank you very much
09:22tmountainwhat's the typical approach in Clojure when working with Java classes that have side effects or aren't designed in a thread-safe fashion?
09:27AWizzArdtmountain: you should make sure to not use those classes in parallel then.
09:28tmountainAWizzArd: it's a hypothetical question really. I generally write almost everything side-effect free in Clojure, but some co-workers are interested in Clojure and probing into the theoretical what-ifs
09:30chousertmountain: One general approach that is sometimes appropriate is to only mutute the object via a particular agent, to serialize access to it. (though that won't prevent reading it in a possibly invalid state)
09:31tmountaineven when using a thread-safe class in Java, there are instances where you might have a conditional - if (!someVar.isSet()) { someVar.set(val); }
09:31chousertmountain: but in my experience so far the biggest problem isn't accidental mutation of the object so much as keeping the stateful approach from leaking out into the rest of your program.
09:31tmountainand wrap that in a synchronized block from outside to make sure the whole operation is atomic
09:32tmountainchouser: when you say serialize access to it, are you referring to using a blocking-queue type mechanism to ensure that everything happens in sequence or something completely different?
09:32chousertmountain: you can use 'locking'
09:33chousertmountain: yes, what you said.
09:33chouser(def out (agent output-stream)) (send-off out #(.write % "hello world"))
09:33tmountainso, if you're stuck in that situation, you should basically develop some policies to avoid an ad-hoc spaghetti threading nightmare
09:34chousertmountain: yes. or use a different java lib. :-)
09:34tmountainchouser: preferrably, yes ;-)
09:34tmountainso in the conditional example I posted above, you would use a lock, or the same agent approach?
09:35chouserI guess it would depend on the object and/or your desired usage.
09:36tmountainif you were to use a lock, what locking mechanism does Clojure provide?
09:36chouser'locking'
09:37tmountainahh, aptly named
09:38tmountainthanks for all the help guys. I've convinced at least one co-worker to use Clojure for his senior project and more are gaining interest, so that's a good thing
09:39snowwhite07tmountain, Wow! thats really good
09:39tmountainsnowwhite07: early adopters over here. I work at a startup with a lot of young people, so that helps
09:40snowwhite07tmountain, nice
10:13AWizzArdWill contribs sql lib by default return cursers, so that doing a select that will return huge amount of data won't be a problem?
10:15AWizzArduh, cursor :)
11:22Licenserhmm with the enclojure plugin for netbeans, is there a way to let it automatically add the second half of brackets? like typing ( and it adds ) after the cursor?
11:23RomanRoeLicenser: Wouldnt this be annoying when you want to wrap an existing form?
11:24LicenserRomanRoe: hmm I am used to it from TextMate, if I want to do it I just select what I want to wrap and then type ( so it autowraps it too
11:24Chousukenow you wish you had paredit.el :)
11:25RomanRoeLicenser: or the editor could be smart and only insert the ) when no character is behind the cursor
11:25Chousukesilly editors, thinking only in terms of characters... ;P
11:25LicenserChousuke: I wish TM would work nicely with Clojure :P
11:25RomanRoeChousuke: lol
11:26The-KennyM-x mark-sexp ftw :)
11:26LicenserSex?
11:26arsatikiyeaah
11:26arsatikimark-sexp is The Thing missing from the TM plugin
11:27Chousukeemacs+paredit is so good that even though I can't use emacs at all I think I'm stuck with it forever for lisp editing.
11:27The-KennyLicenser: No, sexp. from one ( to the corresponding ).
11:27Licenseroh okay
11:27Chousukethough even with paredit I can only use barf, slurp and kill-sexp
11:27Chousukebut it's still better than any other editor :P
11:28LicenserI want a good TM plugin :(
11:28LicenserWell for the start I
11:28Licenserd
11:28arsatikiOh wow, there is a select enclosing brackets in TM \:D/
11:28Licenser argh
11:29Licenserarsatiki: which plugin do you use, it seems that all I tried are broken or even more broken
11:32arsatikiLicenser: This one, I believe: http://github.com/stephenroller/clojure-tmbundle
11:33The-Kennyhm.. I never understand what's so cool about textmate.
11:33arsatikiHonestly, neither do I anymore.
11:33Chousukeit's sleek and maclike I guess.
11:33arsatikiPlz some1 rewrite emacs with clojure-lisp :-P
11:34Chousukethat would be fun
11:34Chousuketoo bad emacs is basically core + eleventy billion libraries
11:34The-KennyJust write a elisp-interpretet in clojure :p
11:35The-Kenny*an elisp-interpreter
11:35The-Kennysorry, typing in bed isn't very easy.
11:35Chousukeand while rewriting the core is probably not too bad, it's the libraries that make emacs useful :P
11:35The-KennyI remember someone has wrote an elisp-interpreter in common lisp and got it working.
11:36LicenserNothing is really cool about textmate, it just integrates very nicely on OS X which is a big + in my eyes. It feels native to use and often the TM bundels are damn good
11:36Chousukebut if you write just an elisp interpreter, that won't help. /:
11:36Chousukeit'll still be elisp
11:36arsatikiI recently retried emacs after a 5+ year break
11:36Licenserwrite a elisp -> clojure compiler
11:36samlhey wanna teach me clojure over irc?
11:36The-KennyLicenser: That's what I miss in aquamacs.. a better integration.
11:37The-Kenny(It doesn't support services, for example)
11:37arsatikiIt's scary how well your fingers remember all the commands after all this time
11:37LicenserI admit I never got used to EMACS
11:38LicenserAnd at least for Ruby I didn't found a better editor yet
11:38Licenser(then TextMate)
11:38Licenserwhile there are a few things that horribly annoy me :P
11:38stuartsierraSome people tried to re-implement Emacs in Common Lisp. They never finished.
11:40MaddasOne doesn't even finish such a task :-)
11:41LicenserI tell you a elisp -> clojure compiler is the way to go >P
11:41tmountainconsidering the current version is 23.1, there'd be a lot of ground to cover
11:41Licenserlet it work a few days and you've emojure or how you want to call it
11:41arsatikiemacj
11:41tmountainI'm one of the heretics that writes Lisp code in Vim
11:41The-Kennyclomacs.
11:42Maddastmountain: I use viper-mode (VI emulation), that works for me. Just don't mention it on #emacs. Or #vim.
11:43Chousukeheh
11:43chouserI've been disappointed by viper mode.
11:43The-Kennytmountain: I tried that too.. it just didn't work for me.
11:43RaynesI am disappoint.
11:43chouserSo I started my own repl+editor. It's disappointing me as well.
11:43MaddasOh, chouser and Chousuke are two different people :-(
11:44chouserso true...
11:44kunleyHi.
11:45chouserkunley: welcome.
11:45kunleyHow to make Ctrl-c break current operation in a repl instead of leaving?
11:45tmountainprobably have to trap SIGINT somehow
11:45Licenser okay time for me to eat see you later people
11:46Chousukehmm, there's a java IDE for emacs
11:46Chousukeusing CEDET
11:46Chousukethe plain java mode is a bit too plain...
11:47rhickey_any proposals for a different name for 'implement' in protocols given :implements in datatypes is about interfaces?
11:47The-KennyChousuke: Just use slime and clojure :)
11:47Chousukeadopt?
11:47chouserkunley: there's a thing in repl-utils to do that
11:47ChousukeThe-Kenny: I'm about to hack src/clj/clojure/lang/Compiler.java :P
11:48The-KennyChousuke: Heh, ok.
11:48kunleychouser: thx, will check.
11:49arsatikirhickey: :follow or :follows, perhaps.
11:51LicenserI like follows that makes sense for a protocol
11:52chouserprotocol should use :implement because it means the same as the Java word?
11:52rhickey_we're looking for a word to go first here: (_____ AProtocol AClass ...)
11:53Licenserwhat about :supports
11:53Maddas:satisfies, perhaps?
11:54rhickey_chouser: could be same/similar (AType :implements [AnInterface] ...), (implement AProtocol AClass ...) - too confusing?
11:54arsatikiIf the name of the protocol does not actually contain the word "protocol", then :protocol might work. But it does seem odd that it is not a verb.
11:54danlarkinfulfill?
11:54rhickey_arsatiki et al - not looking for a keyword here, but a function name
11:54arsatikioh
11:54chouserwill protocols sometimes have the same name as a matching Java interface?
11:55rhickey_chouser: I hope not, but ns issues have to be clarified for both datatypes and protocols
11:56rhickey_(___ Seqable String (seq [s] ...))
11:57Licenserextend
11:57rhickey_Licenser: extend has the same relationship to Java extends that implement has to Java implements
11:58LicenserOh didn't knew java stole that word already :P my java is horribl. It just sounded good there
11:58danlarkintechnomancy repeated this quote to me yesterday, "There are only two hard problems in computer science, naming and cache expiry."
11:58rhickey_and implement is probably more correct
11:58Licenservery odd idea >P
11:58Licenserteach
11:58arsatikiI like danlarkin's "fulfill" after looking at the example
11:59Licenser(teach Sequable String (seq [s] ...))
12:01chouserapply
12:01rhickey_I guess a primary question is, is :implements/implement too confusing. If not, then that's it
12:01chouser:-P
12:02danlarkinyeah I think they're too similar
12:02liebkeI don't think :implements/implement is to confusing
12:02LicenserI am confused what would be confusing, but likely because I'm not sure what to confuse them with
12:02Licenserand I
12:02Licenserm hungry, so see you later peopel
12:03cgrandrename :implements to :interfaces?
12:03rhickey_conform
12:03arsatikiconform-to
12:03chouserimplement/:implement is less confusing that map/map
12:04arsatikiPersonally I don't think I'd be confused by implement
12:04kunleychouser: yeah, add-break-thread! does the trick. Your responsiveness is awesome btw
12:04rhickey_cgrand: interfaces are a host thing, if people ask, how do I implement an interface and you say :implements, no surprises
12:05chouserkunley: glad it'll work for you.
12:05arsatikiToo bad implement-protocol is probably too long.
12:05chouserhm. with-protocol
12:06kunleyThe-Kenny: I left comments on your clojure-couchdb commits. Basically I was wondering if vi & emacs clojure modes give different indents, or just it was coincidence that we had them different
12:06rhickey_chouser: mismatch given general (with-this do that)
12:06cgrandrhickey: true and the interface concept may not exist on the host (eg javascript)
12:06chouserusing-protocol
12:06chouserapply-protocol
12:07danlarkinfulfill-protocol :)
12:08The-Kennykunley: I've seen the comments and added some comments too. I don't know if there's a difference... The only thing I could do is telling my emacs to not use tabs for indent :)
12:08arsatikiThesaurus suggested "effectuate" =)
12:10chouserrealize
12:22rhickey_unlike interfaces, you will be able to 'unimplement' a protocol, might help in thinking about it. When implementing a protocol you are both saying how to do it, and adapting/extending the dispatch to the new type. 'include' et al then come to mind
12:23cgrandspecify
12:23rhickey_cgrand: the defprotocol itself seems more like the spec
12:28LuytHello Rich, I've seen a few of your clojure talks videos, I like the way you *don't* say "eh...." dozens of times in every sentence, like so many people do ;-)
12:29arsatikiHaskell uses the term "instance declaration", but I can't get anything useful out of that
12:29arsatiki(except declare, but...)
12:30rhickey_Luyt: :)
12:32rhickey_adapt?
12:33LuytYes, and I'm now reading Stuarts book. I dabbled a bit with CL but I think clojure is more worthwhile learning - although I havent used it yet in any serious app
12:34LuytBTW, the java interop works nicely, it's easy to call java objects from Clojure, but does it work the other way round too?
12:42chouserLuyt: you can create classes and interfaces in Clojure that can be used in Java without the Java user even knowing they're implemented in Clojure.
12:42Luytchouser: Excellent. Thanks.
12:43LuytAll thanks to the JVM, I suppose?
12:43tmountainLuyt: you can also invoke Clojure from Java - http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java
12:43chouserwell that certainly helps. :-) To make it transparent to Java users, you do have to do a bit of work in Clojure that you otherwise wouldn't bother with (gen-class and gen-interface to be specific)
12:44chousertmountain: right, that's the other way to do it -- specify nothing special in the clojure code and require Java users to make foreign-looking calls.
12:46tmountainchouser: yeah, probably not the best way
12:47tmountainbut I suppose it's nice to have options at least
12:54enowhere can I find explanation of the '->' macro?
12:55enoi don't quite understand (doc ->)
12:55The-Kennyeno: It's really simple. Just play around with it a bit. You could also look in the source
12:59tmountain(-> 1 inc inc inc) would give you 4
12:59tmountainjust feeds the result of the last function in the the next
13:01enotmountain: thx for the example
13:02enoso the parameters after the 1st one should all be functions, right?
13:05enokinda like comp, just different order
13:06technomancycomp returns a function without calling its function arguments; this actually calls the functions
13:07enoright
13:10cgrandeno: parameteres after the 1st one they can be function + trailing args
13:10cgrand,(-> 1 (+ 1) (+ 1) (+ 1))
13:10clojurebot4
13:11cgrand,(-> [] (conj 1) (conj 2) (conj 3))
13:11clojurebot[1 2 3]
13:12enoso (+ 1) is like a partially applied function, except that it is only a form, not a function
13:13enogood to know this idiom
13:13Chousukeit's most useful with java interop I think
13:13cgrandyeah and that only the first arg is missing
13:13cgranduseful with nested data structures too
13:14Chousuke,(-> "foobar" (subs 3) .toUpperCase); can intermix java methods and clojure functions, unlike ..
13:14clojurebot"BAR"
13:14cgrand,(-> {:a {:b {:c 42}}} :a :b :c)
13:14clojurebot42
13:15enocool
13:15Chousukethere's also ->> which is a variant of this :)
13:15chouser,(->> (range 20) (remove #(< 5 15)) (filter even?))
13:15clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--4434$fn
13:15chouser,(->> (range 20) (remove #(< 5 % 15)) (filter even?))
13:15clojurebot(0 2 4 16 18)
13:15Chousukeit's fairly recent though.
13:16cgrand,(-> "hello" java.io.StringReader. java.io.BufferedReader.)
13:16clojurebot#<BufferedReader java.io.BufferedReader@14ec8d6>
13:16Chousukewhat fun. I'm trying to compile emacs and it fails with a bus error...
13:43konrHow do the clojure XML libraries work? Do they offer something similar to Xpath?
13:47cgrandkonr: they turn the XML into a tree, tree which can be traversed using clojure.zip. zip-filter (in contrib) is XPath-like
13:48jasappSomeone just was working on xpath, weren't they?
13:48jasapphttp://github.com/kyleburton/clj-xpath
13:49cgrandand (shameless plug) if your XML isn't namespace heavy enlive can allow you to query it with CSS-like selectors
13:58Licenserso how will it be called?
14:47lpetitrhickey: still searching a new name for implementation .
14:47lpetit?
14:50rhickey_lpetit: got one?
14:51lpetitrhickey_: not brilliant ideas, but thought I ought to share them now, and not complain later :) : defimpl, or defimplementation (but too long this last I guess)
14:51lpetitrhickey_: as defmulti / defmethod
14:52rhickey_others have pointed out defmethod probably shouldn't be def- becasue it doesn't introduce any names, same with implement
14:53lpetitrhickey_ : I remember, but defmethod defines a method for the protocol, and has already opened the can of worms :-p
14:53rhickey_time to close it
14:54lpetitrhickey_: want to rename defmethod ?
14:54lpetitrhickey_: ok. At least I tried :)
14:55rhickey_also, I've reconsidered the array and field equality stuff from yesterday. Today I think default should just be = (so identity for arrays), when you want anything else, define equals
14:55cemerickwas there another alternative?
14:55lpetitrhickey_: I myself am not to annoyed by :implements / 'implementation . After all, for people not dealing with host code, it's almost not an issue. And for people dealing with host code, it will just resemble the cascading extension capabilities of interfaces
14:57rhickey_cemerick: lpetit had a neat suggestion for per-field flags - see bottom of: https://www.assembla.com/wiki/show/clojure/Datatypes
14:58lpetitrhickey_: I don't want to misunderstand you : it's just a change concerning array fields, or do you want to go back to a simple implementation with =, and specific equals for anything else (thus throwing away :equals metadata) ?
14:59rhickey_in the end I think anything that encourages people away from compatibility with = and maps is something they have to take on themselves
14:59rhickey_lpetit: right, no more :equals metadata
14:59rhickey_I slept on it and it didn't survive the night
14:59cemerickGood idea -- seems like something a macro could take care of on top of deftype
15:00mikehincheyrhickey_: however, defmethod does modify the application code like other defs, rather than being function or state-changing, so defmethod seems consistent to me
15:00lpetitrhickey_ : grmlml :-)
15:00mikehincheyrhickey_: function -> functional
15:01liebkerhickey_: I don't think :implements/implement is too confusing, but what about bind, bind-protocol, or bind-impl?
15:02rhickey_liebke: if it weren't for existing bind, maybe
15:02liebkefair enough
15:03rhickey_I agree :implements/implement is probably not too bad, I wondered over lunch if people might try to stick protocols in the :implements list
15:03rhickey_and if that would be wrong or not
15:04liebkeinteresting, that might make sense
15:54danlarkinI have a question about nested atoms:
15:54danlarkinis this safe? (swap! (@state account) assoc folder {})
15:55danlarkinstate is an atom for a map keyed on account, and the value is another atom keyed on folder
15:55hiredmanyou are interacting with two atoms there
15:56danlarkinright
15:56hiredmanatoms are uncoordinated
15:57danlarkinI'm asking if I've done that wrong, I guess
15:57lpetitdanlarkin: why ask if it's safe ?
15:57hiredmanI think you meant to use refs :P
15:57danlarkinoh perhaps you're right about that
16:00danlarkinyes, you're right, I just have my nested maps in a ref and then all operations will be in a transaction and I don't have to worry aboot it
16:00danlarkinabout it, that is
16:02chouserright, otherwise you might swap the outer atom while still retrying the inner one -- when the inner one succeeds its value would have already been lost
16:03danlarkinthanks for the brain-check guys :)
16:04danlarkinsometimes I think about what an awful mess this would make in another language
16:25mikehincheyWith clojure.test, is there a way to make it stop testing? If my database is down, I don't want tons of repeated errors, just 1 error from a :once fixture.
16:26technomancyperform the check in your fixture?
16:26stuartsierramikehinchey: you could (System/exit 1) in the fixture
16:27stuartsierrayeah
16:27technomancyjust conditionally execute the argument to your fixture
16:27stuartsierraYeah, that would work.
16:28mikehincheythe fixture is throwing the connection exception
16:29mikehincheywait, that doesn't sound right, let me check more closely
16:32mikehincheyyou're right, my connection isn't really happening until later, so I need a check in the fixture. thanks.
16:37Licenserhrm after working a bit with clojure in netbeans i get the feeling it tries to foce people into the java way of doing stuff, I already have like 3 packages and all that o.O meh
16:40chouserrhickey: so no per-field :equals flag in deftype? will always use = which is 'identical?' for arrays?
16:42solussdwhy does something like (range 100000) cause a outofmemory exception?
16:43chouser,(last (range 100000))
16:43clojurebot99999
16:43chousersolussd: ?
16:43chouser,(reduce + (range 1e6))
16:43clojurebot499999500000
16:43mwoelker,(range 1000000)
16:43clojurebotEval-in-box threw an exception:java.lang.OutOfMemoryError: Java heap space
16:44mwoelkerdon't use the whole seq at once i guess
16:44chouserwell, you didn't want all those values printed anyway, I bet. :-)
16:44solussdseems to only throw the OutOfMemoryError when it is printed
16:44mwoelkerprobably not ;-)
16:45chouserset *print-length* or restrict the output in some other way.
16:45Chousukesolussd: that's because printing it holds the entire sequence in memory.
16:45solussdbut I did... :) b/c I'm playing
16:45mwoelkerit gets boring after the first three pages
16:45technomancymwoelker: sssh; no spoilers
16:45solussdshutup! I'm looking for the pattern in the output of range
16:45mwoelkerit was the butler...
16:47solussdthe python interpreter will print ridiculously long lists generated by range for me. :) Maybe clojure is trying to stop me from wasting my time.
16:47chouserwell, you can try starting your JVM with a bigger heap
16:48chouser,(pr-str (range 1e5))
16:48clojurebot"(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 1
16:48chouserI actually don't get an exception here.
16:49solussdtry 1e6
16:49solussdi think the clojurebot has a bit more heap than i do
16:49chouserbah. takes 10 times longer. ;-)
16:49solussd,(pr-str (range 1e6))
16:50chouserclojurebot: ping?
16:50clojurebotPONG!
16:51chouserI guess he didn't want to do your pr-str for you.
16:53cemerickAside from immutable data structures being preferable in general, is there any reason why putting mutable stuff in an agent is a Bad Thing?
17:22arohnerIf I want to read from multiple refs at the same time, and I want them to be consistent, will derefing them in a dosync do what I want?
17:23arohneri.e. (dosync [@foo @bar])
17:26enoarohner: isn't it writer's responsibility to make sure the refs are consistent?
17:27enoas long as all writers dosync, reader does not need to worry about consistency?
17:27arohnerhrm. In my case, the refs are two different views of essentially the same data
17:28enothen when will it be inconsistent?
17:28arohnereach ref is consistent, but I want to read them both at at point when they are consistent with each other
17:28arohnerif I do [@foo @bar] without a dosync, a transaction could run between the @foo and the @bar
17:29arohnermaybe my data model is wrong.
17:29enoif there is one single ref
17:30enoholding a container of the two
17:31arohneryeah, I may have to do that
17:31arohnerpreviously I didn't need to look at both of them at the same time
17:31hiredmanarohner: you should get consistent information from (dosync [@a @b])
17:32arohnerhiredman: thanks
17:33hiredmanhttp://clojure.org/refs
17:35konrIs there a function that prints a tree with indentation, or represents it visually, so I can get a clue on what it is?
17:37enohiredman: thx, "a consistent snapshot ..."
17:42dnolenkonr: you mean like pretty print?
19:14gregoryg /leave
19:22regularfryEvening all... anyone got clojure-project working on emacs-snapshot-gtk on jaunty? It's not working for me, and I'm a little stumped
19:23technomancyregularfry: what are you seeing?
19:24regularfrytechnomancy: Exception in thread "main" java.lang.NoClassDefFoundError: clojure/main in *inferior-lisp*
19:24regularfryclojure-src-root is correctly set
19:25regularfryand M-x slime works. Just not M-x clojure-project.
19:25technomancyregularfry: clojure-project is meant to work with self-contained projects
19:25technomancyso all the dependencies should exist in the project root
19:25technomancyeither as jars in lib/ or unpacked in target/dependency
19:26regularfryAh, maybe I've misunderstood something then - I thought it created/copied/managed that process.
19:26technomancythat should be better-documented I suppose... I forget that a lot of people don't use dependency management. =(
19:27regularfryNo worries. I think I just assumed that since all the *other* tools manage everything for me, that must as well :-)
19:28technomancyyeah, doing M-x slime without a project is mostly for exploration etc. and for hacking on clojure/contrib itself
19:29regularfryThat's what I figured. It just seemed odd that one worked but not the other. As long as it's not a weird version-interop problem (and I haven't screwed anything major up) then I'm happy as larry
19:29technomancygreat. (assuming larry is happy)
19:55Licenserhrm the API documentation is a horror :/
20:01Licensertechnomancy: well you could put it that way
20:01LicenserI get the feeling you
20:01Licenser... you've to know what you are looking for to find help in the API
20:02dnolen__Licenser: yeah, fortunately there's not much to know. Have you looked at the cheat sheet? It's much more helpful
20:02technomancys/to find help in the API//
20:03Licenserthey are great to refresh ones memory but I find the documents often very unhelpful if you want to figure out what function to use especiually when function parameters have so very expressive names like m s re i or something like that
20:03ataggartdoes something like this (admittedly trivial) fn exist?
20:03ataggart(defn assocf [map key f]
20:03ataggart (assoc map key (f (map key))))
20:04technomancyataggart: maybe update-in?
20:04ataggartI *knew* it had to be there
20:04ataggartthx, I'm blind today
20:14ataggart(doseq [s (.split "hello world" " ")] (println s))
20:14ataggartor use re-split from contrib
20:23Licenserataggart: yes that works great if you have 1 rule, it gets quite complicated if you've more then 1 rule
20:24Licenserthere isn't a scanner feature, at least I didn't find one
20:25ataggarttoo complicated for a regex?
20:26LicenserI want to tokenize sourcecode
20:26Licenserdoing that in one single regexp is suicide
20:26LicenserTried it, is the wrong way :P
20:27chousermost tokenizers use a regex for each token, don't they?
20:29Licenserchouser: yes but not one for all tokens
20:31chouseroh, I see.
20:34Licenserthere we go, re-scis born!
20:35Licenserugly uygly hack but it works
20:51Licenserhah it's working!
21:06Licenserhmm any hints about how I make a regexp multiline in clojure/
21:23Licenserah tricky found it
21:42regularfrytechnomancy: I'm not much cop at emacs lisp (yet... hopefully) but this does what I expect: http://gist.github.com/215647. Don't know if it'd be handy, consider it available equally for taking or ignoring
22:58jlillyhow do you guys manage your jars? Do you guys all use that sort of run script I've seen about?
23:03hiredmanjdk1.6 and beyond lets you put wildcards in the classpath
23:03hiredmanso I just put jars in ~/.jars/ and set my CLASSPATH to "$HOME/.jars/*"
23:11jlillyI think that's my issue. looks to be v1.5
23:15wlrhiredman: would putting symlinks in ~/.jars/ pointing to actual installed locations be a workable alternative?
23:20jlillyanyone know if openjdk6 translates into jdk1.6?
23:44yangsxwlr: it's workable (I'm using Linux system).
23:47wlryangsx: thanks. i might give it a try.
23:58jlillyhaving some classpath issues. hoping someone might be able to give me a hand. http://dpaste.de/Eu3R/
23:59jlillythat's a traceback showing my CLASSPATH, and the commands I'm attempting.