#clojure logs

2009-06-19

00:08replacarhickey_: are you around?
02:40Xcaliborgreetings
02:41Xcalibori was wondering... is there any benefit in using :key instead of "key" in a hash-map?
02:57hoeckXcalibor: it's more :lispy?
02:58hoeckXcalibor: If i understand the jvm and clojure correctly, both :key and "key" should be interned, so small strings are effectively the same as keywords
02:59hoeckXcalibor: but keywords implement IFn, they are functions of maps/sets
03:00hoeck,(:a {:a 1, :b 2})
03:00clojurebot1
03:00hoeck,(:c #{:a :b :c})
03:00clojurebot:c
04:02frodefgen-class/interface is really a hassle for smallish things. I think I'll rather proxy clojure.lang.IFn.
04:42samuelsdoes clojure check the type hints at compile time?
04:44jdzno, it does not generate all possible programs to test whether the type hints hold for all of them
04:47samuelsjdz: that's not necessary for checking at compile time
04:48jdzwell, what is necessary then?
04:48mapreducesamuels: I just said that in #scala. Are you an elaborate proxy bot? :)
04:48samuelshehe
04:48samuelsmapreduce: i just didnt' know what to say in reply, so i posted your one instead :)
04:48mapreduceAll you need for compile time checking is some algorithm to follow. You don't need to generate all possible programs.
04:49mapreduceThough you might reject some programs that will never fail, like (if true 5 <type-error-here>)
04:49jdzimplementation details! :)
04:50mapreduceImplementation details are often a language user's business even if they don't want them to be.
04:56tsdhHi. I need to create an ImageIcon in my GUI. The clojure file is in the same directory as the images, so I've thought "image.png" would be ok, but it isn't. The ImageIcon docs say the file should be relative to the class the constructor is invoked...
04:56tsdhAbsolute paths work, but of course that's no solution...
04:57dibblegorelative to System.getProperty("user.dir")
04:57samuelsmapreduce: i think you won thatone
04:57mapreducesamuels: I was not competing.
05:00tsdhdibblego: Ah, I didn't look at the JavaDoc example. Thanks
05:23ryshooray, Clojure book has arrived!
05:27tsdhHm, still no luck with the ImageIcon. The problem is that (ClassLoader/getSystemResource ".") points the the clojure git directory and not to my file...
06:14frodefwhen java code says "foo.class.getResource(bar);" is there a clojure equivalent (to the class member or whatever that is)?
06:15AWizzArdgetResource is a static method in your example?
06:16frodefAWizzArd: I don't know what it is to be honest..
06:18AWizzArdfrodef: if getResource is a static method then you would do this in Clojure: (foo.class/getResource bar)
06:20Lau_of_DKHas contrib changed in some way ? I just updated and now (import '(clojure.contrib.str-utils)) returns nil, but nothing is imported....
06:20frodefjava.lang.ClassNotFoundException: foo.class
06:20AWizzArdfrodef: then getResource is not a static method. Maybe you can try: (.getResource (.class foo) bar) ?
06:21AWizzArdhmm no, I think that will also not work
06:21rhickeyfrodef: what are you trying to do?
06:22frodefrhickey: creating an icon for may swing app.. :)
06:22frodefseems I have to getResource, which is a method on java.lang.Class..
06:23frodef..and so I have to do "(class-of foo)" it seems to me?
06:23rhickey(.getResource TheClass ...)
06:24rhickeyif you know the name of the class, else (.getResource (class an-instance) ...)
06:24frodefrhickey: ah, so clojure "class" is CL "class-of"? thanks!
06:26frodefsorry to ask silly questions, I just get quite confused trying to navigate the perimeter between clojure and java.
06:27rhickeynp
06:39frodefis there something like an implicit class that the code lives in?
06:40frodef"the code" being my code in a foo.clj..
06:40rhickeyfrodef: every fn is an instance of a different class, but there is no class corresponding to a file, since files aren't proper entities in Clojure
06:41rhickey,(class rest)
06:41clojurebotclojure.core$rest__3736
06:41frodefok
06:48frodefhm.. I guess this java resource stuff doesn't mesh so well with dynamic programming.
06:53AWizzArdfrodef: you can program dynamically typed in Java too. Declare everything as type Object :-)
06:54cheddarAnyone know why ants.clj now seems to hang when I send-off all the ants? If I (send-off (nth ants 1) behave) that ant moves around. But when I (map #(send-off % behave) ants) the whole thing freezes. Is it the new version of clojure? Or something to do with JVM settings? It used to work.
06:54frodefprogramming interactively isn't going to be so easy I guess.
07:02cheddarstrange, when I increase the sleep delays by 10 times, it works
07:02cheddarbut it used to work without that change
07:02cheddarand CPU usage is not above 20%
07:03cheddaris there a way to make behaviour degrade more gracefully?
07:03frodefcheddar: sounds race-conditiony, no?
07:04cheddaryeah, but that's strange isn't it?
07:05cheddarisn't ants.clj written using agents and refs in order to avoid race conditions?
07:05cheddari'm not sure now that it's a race condition - at least it's not locking up
07:05cheddarinspecting the ants in the repl, i see their coordinates are still changing
07:06cheddarbut the display isn't updating
07:09cheddarhmmm, it seems maybe it works better when the JVM doesn't have the -server option
07:09cheddardoes that make sense?
07:13rhickeycheddar: I can reproduce - looking now
07:20cheddarit seems the ants are still moving around, but the screen redraws aren't occurring
07:20cheddaractually it happens without -server as well
07:24jgracinhi! how do I dispatch on Java primitive byte array? I mean, my dispatch function is class and I'd like to add method for byte arrays.
07:29rhickeycheddar: fixed in master
07:40cheddarthanks!
07:49hoeckjgracin: I don't know whether clojure has array class-literals, but (defmethod foo (type (make-array Byte/TYPE 0)) [& args] ..) should work
07:55jgracinhoeck: thanks, I'll try that.
07:57rhickeyjgracin: (Class/forName "[B")
07:58rhickeyhttp://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getName()
08:27jgracinrhickey: thanks.
09:06mtdI have to manipulate and plot not-too-small data series (mostly priceA and priceB on the Y, time on the X) stored in an oracle db and I'd like to graph them. On the verrry off chance, is there any Clojure-REPL-hotness that I could play with?
09:07ChouserI have no idea how it handles large data sets, but I found this easy to use: http://www.markmfredrickson.com/code/
09:08liebkeincanter should work, http://incanter.org
09:09mtdChouser, liebke: thank you very much
09:09Chouseras for pulling the data out of oracle, I haven't done any of that yet. There are a couple sql apis you could look at.
09:10Chouserclojure.contrib.sql
09:10Chouserhttp://github.com/Lau-of-DK/clojureql/tree/master
10:36stuarthallowayis there a separate irc node for clojure-dev conversation, or is that all happening here? I have the day free to work on clojure, but don't want to clutter this form with dev talk if that is inappropriate
10:37rhickeystuarthalloway: here is fine
10:37stuarthallowaycool!
10:37stuarthalloway(1) just sent email to clojure-dev proposing the "simple way" to move clojure's tests into clojure
10:38stuarthallowaybut I can imagine reasons that the simple way might cause problems, so willing to pursue some harder way if necessary
10:40stuarthallowayif that is the most substantial problem we can probably reach an accomodation
10:40Chouserit was noted here recently that test-is has dependencies on several other contrib pieces.
10:40rhickeyis there consensus around test-is? Is everyone in contrib using it for their tests? I'm fine with moving to clojure, but should be part of a broader plan to move some contrib bits to clojure, including pprint
10:40rhickeyright, and sorting out deps
10:40stuarthallowaythose are both bigger problems
10:41rhickeythis would be a good clojure-dev topic
10:41rhickeystuarthalloway: bigger how?
10:42stuarthallowaythe dependencies issue could lead to weeks of conversation going in circles
10:43stuarthallowayand, while important, is less important than making testing simple
10:43stuarthallowayI would even prefer the temporary expedient of a private subset of contrib buried in clojure for testing purposes only
10:43stuarthallowayto give the community time to consider dependencies at leisure
10:44rhickeystuarthalloway: well, someone should scope it so we're not speculating, I'm for test and pprint
10:44Chouser2 versions of code, one in core and one in contrib, sounds a bit scary
10:44stuarthallowayChouser: didn't say it was good
10:45Chouser:-)
10:45stuarthallowaybut freezing (and endorsing) a testing library is a separate step from wanting to test core
10:45ChouserAre there problems now that would be solved by having the clojure tests in clojure instead contrib?
10:45Chouserinstead of
10:46stuarthallowayYES!
10:46rhickeyI think the number one issue is not being able to submit a patch with both code and test
10:47stuarthallowayhaving to coordinate patches in two different repos is a big hurdle to community contribution
10:47stuarthallowayrhickey: by "scope it out" do you expect (1) a writeup of what it would look like, or (2) a fork so you can see the ideas develop in code?
10:48rhickeystuarthalloway: a list of deps would be a start
10:48stuarthallowayrhickey: seems like the easiest way would be to try--I will do it
10:49rhickeyChouser: I mentioned yesterday I saw the #1 use case for pulls versus patches ong-running contrib project, like pprint, brought into clojure
10:49rhickeylong-running
10:50stuarthallowayrhickey: the "git way" is for me to just fork and go -- "fork" not having the negative connotations it does with other SCMS
10:51stuarthallowayso my plan is to fork Clojure, move contrib bits in, and get tests to run -- understanding that this may be throwaway work
10:51stuarthallowaythen we can take a look, argue about names of things, etc.
10:51stuarthallowaythat sound good?
10:51rhickeythis will trash test-is history?
10:52stuarthallowaytest-is history will be unavailable in the clojure repos
10:52rhickeyI think everyone can presume pulling the bits in can be made to work
10:53stuarthallowaybut still available in the contrib repos if needed
10:53eevar2you can merge git repos while preserving history
10:53stuarthallowayeevar2: this isn't a fully merge, though -- just grabbing piece until things work to sort dependencies
10:54rhickeystuarthalloway: I want it to end up one place or another, so Stuart can continue to work on it, so it is unlikely your fork will be merged unless it deal with these details
10:54eevar2yes. still, you'd filter out the paths you don't want beforehand, then merge/rename whatever pieces of contrib you want to add to core
10:55eevar2hmm.. filtering out paths may ruin some of the history in what you're merging in, and might be a bad idea
10:55eevar2*of what you're..
10:55stuarthallowayeevar2: I don't care (much) about the history in this case.
10:56drewr`Is there a way, possibly through meta info, to access information about a fn's caller?
10:56stuarthallowayStuart Sierra is the primary (only) developer, and he knows where to find the history if he needs it
10:56eevar2okies. just letting you know it can be done
10:57drewrI guess what I'm looking for is something like elisp's defadvice.
10:57rhickeylooks like just template/walk/stacktrace as deps
10:58AWizzArdAnd anyway: how often is the history older than a few weeks *really* needed? How often does rhickey look at what he did at revision 631?
10:58stuarthallowayrhickey: the cool thing about git is the ease of showing you my ideas, vs. just discussing them. I think the fork will spur a conversation. If it never gets merged, then that is fine
10:58drewrI want to say (defn #^{:deprecated true} foo [& args] ...) and throw an exception if foo is called anywhere.
10:59rhickeystuarthalloway: of course there's no harm, but I'm not seeing too much benefit either, a 2 minute perusal of the source shows 3 deps
11:00Chouserdrewr: You can use a java exception (does not need to be thrown) to examine the stack
11:00stuarthallowaydrewr: why not a macro that implements (deprecated foo)?
11:00Chouserdrewr: but I don't think you'll be able to get from the java stack to the fn or var metadata.
11:00Chouserat least not easily
11:01Chouserdrewr: why not just replace the body of foo with (throw (Exception. ...))?
11:02stuarthallowayrhickey: we'll see. I am a big believer in the difference between "could" and "did"
11:03drewrChouser: That's what I originally did, then I got into thinking about what was possible in capturing fn invocation.
11:04Chouserdrewr: I guess I don't see the benefit of doing it via metadata. Is there some use case where just calling (throw ...) is less desirable?
11:05drewrI went from that to just putting (deprecated!) as the first line in the fn where deprecated! does whatever I need at the time.
11:05Chouseryou could also use (binding [foo (fn [& x] (throw ...))] ...) to only check certain call chains.
11:06drewrAh, that's a good idea.
11:06Chouseror alter-var-root to change it after-the-fact
11:06drewrI'm not quite sure which fns will be called though.
11:21Chouserbah.
11:22Chouserrhickey: would it be terribly difficult to change my clojure-dev member address from n01se.net to gmail.com?
11:22Chousermy mail client (gmail!) is insufficiently powerful to handle the permission requirements well on my end.
11:25Chouseror add my gmail.com address as well, I suppose.
11:27rhickeyChouser: sure, just apply to the group using your other identity, I don't manage emails, just users from google's perspective
11:28Chouseroh, ok.
11:28j-dotChouser: I was able to change my email address on the "Edit my membership" page ... try here:
11:28j-dothttp://groups.google.com/group/clojure-dev/subscribe
11:29Chouserj-dot: than what? I don't see any way to change my email address there.
11:37j-dotChouser: Hmmm ... I have a "Which address do you want to use for this group" option
11:38j-dotperhaps that's because I've registered multiple email accounts in my Gmail settings
11:38Chouserj-dot: ah, ok. thanks.
11:38j-dotnp
11:45eevarstuarthalloway: +1 for moving clojure-core tests into the clojure repo, btw
12:57dhazacan anyone point me towards information on jars and packaging in java?
12:57dhazaim coming at clojure from a lisp background and the entire jar process is pretty opaque to me
12:58j-dotI don't have any URLs, but a jar is just a zip file with your code/classes
12:58slashus2Jars are just zip archives as far as I understand it.
12:58Chouserjars can also have a specially-named file with a bit of extra info in it
12:59DougCjava packages are similar to namespaces in Clojure.
13:00DougCThe class java.lang.String is in the package java.lang and the source is in a file called String.java
13:00DougCIn the file system this would be in a directory structure as java/lang/String.java
13:01dhazayou need to jar the compiled files to have the code loaded?
13:01dhazaor does it read the source upon load?
13:01DougCWhen you compile a java source file the bytecode ends up in a .class file
13:01clojurebotthe unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation
13:01Chouserfor Clojure, compiling is independent of bundling into a .jar
13:02Chousera .jar can have .clj or .class files and still work fine.
13:02DougCSo java.lang.String would compile into a file in the filesystem as java/lang/String.class
13:03dhazai get it
13:03DougCThe CLASSPATH tells the jvm where to look for classes and it can contain path elements which are either directories or .jar files.
13:04DougCIf a path element is a directory then it defines the directory in which those relative paths live. So one element of the classpath might be ~/classes and in there you would find java/lang/String.class
13:05DougCFor jar files, as other have said, they're just zip files where the class directory structures are all zipped up (there are other conventions for things but they're not important for this discusssion)
13:09dhazaokay, so if my package name is 'org.foo.blah.MyClass', it would be in the jar under org/foo/blah/MyClass.class
13:09Chouserexactly
13:10Chouserand your .clj file for that would usually be in some element of the classpath at org/foo/blah/MyClass.clj
13:11Chouserthough it's fine to have it in a different element of the classpath, and therefore not in the same directory as MyClass.class
13:12ChouserFor any given project I like to have a 'src' and a 'classes' directory, with both in my classpath. That way I can blow away the contents of 'classes' anytime I want to be sure I'm getting a clean build.
13:12Chouser...and I don't have to look at .class files littering up up 'src' dirs.
13:13Chouserthen if I make a .jar for that, I can pick either just the class files, just the clj files, or both.
13:13mattreplstuarthalloway: Cluje, eh? =)
13:14stuarthallowayI think I liked "Frak" best
13:15ChouserI like verily!
13:15Chouser(verily (= (foo) 1)))
13:18hiredmanis it name game again?
13:18hiredmantime
13:20stuarthallowayverily, I say unto thee all: I am stepping away for 30 minutes to do a video interview with @coreyhaines
13:21stuarthallowayif thou wouldst agree on a name for thy core testing framework while I am going, I will implement it, and submit the fork to our glorious emperor
13:28j-dothaha, I like verily ... but if I was that confident, why would I bother testing?
14:17r2q2Hello
14:18ChouserHi
14:21kefka,(inc (Long/MAX_VALUE))
14:21clojurebotjava.lang.ArithmeticException: integer overflow
14:21stuarthallowayrhickey: I will rename clojure.contrib.test-is to clojure.test
14:22stuarthallowaywhat about the dependencies: stacktrace, template, and walk?
14:22kefkaIs this a bug, or should we explicitly not use inc / dec if we want integer promoption?
14:22stuarthallowayeach in their own namespace under clojure?
14:22kefka,(inc 12345678901234567890123)
14:22clojurebot12345678901234567890124
14:22stuarthallowayor maybe put walk into core?
14:22stuarthalloway(walk is way cool and I end up using it on every project)
14:23ChouserLong/MAX_VALUE is a primitive
14:23Chouser,(inc (Long. Long/MAX_VALUE))
14:23clojurebot9223372036854775808
14:25r2q2I was wondering if there is a plan for clojure to use the new java 7 features that allow for dynamic languages?
14:26r2q2http://openjdk.java.net/projects/mlvm/
14:27hiredmanr2q2: mlvm is not java 7
14:28hiredmanmlvm is an experimental vm
14:28hiredmanclojure targets java 5, because that is everywhere
14:28brett_hDoes anyone have a link to an explanation on what it means for something to be "composable", I'm specifically referring to the "locks don't compose, but STMs do" here: http://www.slideshare.net/jboner/state-youre-doing-it-wrong-javaone-2009
14:29r2q2hiredman: Yea thats what I thought.
14:29r2q2hiredman: I meant JSR 292 but yea I was guessing its too far out there to support.
14:30rhickey,(inc (num (Long/MAX_VALUE)))
14:30clojurebot9223372036854775808
14:32stuhoodbrett_h: Mark Volkmann's Clojure article contains "The Bank Example": http://java.ociweb.com/mark/clojure/article.html#Refs
14:32hiredmanbrett_h: if you have a locking strategy for A and a locking strategy for B, just mashing those two locking strategies together doesn't work
14:32dhazabrett_h, composable is similar to nestable, you can nest STM transactions, you cant nest locks
14:33dhazawell, i said that wrong
14:33dhazayou can nest locks, but not arbitrarily
14:33brett_hhiredman: you mean it doesn't always work, where transactions do? like you don't have to think about it?
14:33brett_hdhaza: yeah, arbitrarily is what I was thinking
14:33brett_hok that helps
14:33brett_hstuhood: thanks I'll check it out
14:34stuhoodbrett_h: no problem... not really an explanation, but a great example
14:34brett_hoh yeah, I've read that
14:35brett_hI was kind of hoping for a "see, locks fail here because they aren't composable" but I think I get what dhaza means
14:35brett_hyou can't arbitrarily combine things that lock and expect them to work
14:36stuhoodbrett_h: right, so in that example the withdrawals and deposits need to be atomic, so they would have to be protected with locks traditionally. but if you want to transfer money, you need another lock around the first two.. which means there is deadlock potential unless you start thinking about lock ordering
14:36brett_hright, thanks
14:38rhickeysearch for compose in: http://en.wikipedia.org/wiki/Software_transactional_memory
14:38brett_hrhickey: perfect, thanks
14:42stuarthallowayrhickey: I have renamed clojure.contrib.test-is to clojure.test on the fork: http://github.com/stuarthalloway/clojure/tree/c718835af09f238f8f9d57c330951e1a8e906475
14:43stuarthallowayremaining todo:
14:43stuarthalloway(1) rename the dependencies from clojure.contrib to ????
14:43stuarthalloway(2) fix contrib to match
14:45rhickeystuarthalloway: you can use one of the assembla wiki pages for this kind of punchlist
14:46stuarthallowayrhickey: ok doke
14:46stuarthallowayif you are ok with the renaming, I could just be done in another 30 mins or so
14:47stuarthallowaypackages in question are stacktrace, template, and walk
14:47rhickeyputting the issues in a single place will help me make a decision and others to chime in on any missing pieces or things you haven't thought of
14:48stuarthallowayshould I create a ticket too, and link out to the wiki page?
14:48rhickeysure
14:52rhickeyI'm not sure how I feel about template, stacktrace and walk seem fairly straightforward
14:52rhickeyI'm talking about the contents, not the names
14:52stuarthallowayagreed!
14:52stuarthallowayI was about to move template into test
14:52stuarthallowayclojure.test.template
14:53stuarthallowayas a way of marking it to be internal detail
14:53stuarthallowaycould also make the bits private to clojure.test
14:53stuarthallowaywhich would be a stronger statement of same
14:53stuarthallowayTicket is at http://www.assembla.com/spaces/clojure/tickets/131-Move-Clojure-tests-from-contrib-into-Clojure
14:54stuarthallowaywiki page at http://www.assembla.com/wiki/show/clojure/Getting_Tests_Into_Clojure
14:54rhickeyiirc Stuart said he needed template for 'are'?
14:54stuarthallowayyep
14:55rhickeyare there other consumers of template?
14:56stuarthallowaychecking...
14:57stuarthallowayonly contrib.condt
15:04stuarthallowayok, everything is renamed into clojure except template
15:04stuarthallowaygonna fork contrib and pull out the items added to clojure, and make sure *that* works
15:23r2q2,{:a 1,,,,,,,,,,,,, :b 2,,,,,,,,,,,}
15:23clojurebot{:a 1, :b 2}
15:24Lau_of_DKCompojurefreaks - Anybody worked out, how one can benefit from the (with-session) macro ?
15:40rzoomwhat does max-key do if there are multiple keys with the max value?
15:41hiredman(doc max-key)
15:41clojurebot"([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest."
15:41rzoomseems to take the last key
15:41shooverthere is a lot of forking going on here
15:42gnuvincehere where?
15:42shooverthis room, clojure in general
15:43Chouserso far nobody has forked with the intention to do anything other than either merge back into clojure, or throw it away. So no need to worry.
15:44shooverunderstood, it's interesting to see all the activity
15:44hiredmandid we ever get that flag to stop read from evaling stuff?
15:54Chouserhiredman: looks like it: https://www.assembla.com/spaces/clojure/tickets/38
15:54Chouser,*read-eval*
15:54clojurebottrue
15:54Chouser,(doc *read-eval*)
15:54clojurebot"; When set to logical false, the EvalReader (#=(...)) is disabled in the read/load in the thread-local binding. Example: (binding [*read-eval* false] (read-string \"#=(eval (def x 3))\")) Defaults to true"
16:12rhickeysaw some tweets re: test-is inclusion implying the end of testing frameworks, thoughts?
16:13ChouserI have no alegience, but the current clojure regression tests use test-is. That's a bit inescapable.
16:13stuarthallowayruby having test::unit didn't stop rspec, shoulda, and micronaut...
16:14Chouserit can't be worth re-writing the tests to use something else.
16:14dhazafind/replace
16:15stuarthallowayalso, the testing library used to test clojure needs to be (relatively) minimal compared to frameworks people might create to test clojure application code
16:15ChouserI suppose the core version of test-is could be made private, but that seems a bit dumb since it will be used and maintained.
16:15rhickeyChouser: no, but there may be other ways to organize things without seeming to bless one
16:15stuarthallowayI don't think it is a problem
16:16Chousernamespace doc string that says, "there are many clojure testing frameworks -- one of the others may fit your needs better than this one"?
16:16stuarthalloway+!
16:16hiredman~ticket 38
16:16clojurebotGabh mo leithscéal?
16:16hiredmanclojurebot: why?
16:16clojurebotwhy not?
16:16Chouser~ticket #38
16:16hiredman~ticket #38
16:16clojurebot{:url http://tinyurl.com/mngulq, :summary "GC Issue 34: A Lisp reader without access to EvalReader()", :status :fixed, :priority :low, :created-on "2009-06-17T19:11:53+00:00"}
16:16clojurebot{:url http://tinyurl.com/mngulq, :summary "GC Issue 34: A Lisp reader without access to EvalReader()", :status :fixed, :priority :low, :created-on "2009-06-17T19:11:53+00:00"}
16:16Chouserwhee!
16:16dhazaclojurebot, Trej buil listileace misceal
16:21sureshhello all.. am new to clojure.. can anyone help me understand these lines..
16:21suresh(defmacro #^{:private true} -?>
16:21suresh ([form] form)
16:21suresh ([form next-form & forms]
16:21suresh `(when-let [x# ~form] (-?> (-> x# ~next-form) ~@forms))))
16:21r2q2suresh: What are the lines supposed to do?
16:22sureshthose lines are from Ring.. i'm curious what the macro does
16:24slashus2It only chains while the forms are true?
16:25sureshslashus2: can you help me understand by deconstructing those lines?
16:26hiredmansuresh: it is a short circuiting version of →
16:26r2q2suresh: What is the name of the macro? It seems to be missing that?
16:26hiredman"->"
16:26hiredmanr2q2: -?>
16:27r2q2Oh
16:27hiredmanit's in contrib these days
16:27clojurebotcontrib is http://code.google.com/p/clojure-contrib/
16:27hiredman(doc -?>)
16:27clojurebot"clojure.contrib.core/-?>;[[x form] [x form & forms]]; Same as clojure.core/-> but returns nil as soon as the threaded value is nil itself (thus short-circuiting any pending computation). Examples : (-?> \"foo\" .toUpperCase (.substring 1)) returns \"OO\" (-?> nil .toUpperCase (.substring 1)) returns nil "
16:28sureshah.. didnt know it was part of contrib
16:28dnoleni think it would look better if it was ->? or ?-> to preserve the arrow. -?> looks to much like line noise.
16:28hiredmanit is now, it is possible that ring started using before it was in contrib
16:29r2q2(doc ->)
16:29clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
16:35rhickeytechnomancy: you had some reservations about assembla the other day?
16:36technomancyrhickey: no, I don't think so. unless it was about the volume of email, which is pretty solvable.
16:36rhickeyah, ok
16:37technomancyrhickey: any further suggestions for CS papers? I got my Kindle yesterday and just finished Out of the Tarpit.
16:37technomancygreat stuff.
16:39technomancyhah
16:39technomancyls ~/documents/papers | lisppaste
16:39rhickeyunfortunately they are almost universally badly named
16:40technomancyheh, right.
16:40technomancywell I've got enough to keep busy for the time being.
16:41technomancyspent twenty minutes yesterday just clicking madly on download links at feedbooks.com for classics.
16:45rhickey43 on STM, 257 on functional programming, 20 on persistent data structures, 54 on purely functional something, 111 on the cochlea ...
16:46rhickey49 on RDF, 256 on concurrency...
16:47rhickey69 on datalog, 169 on locks, 379 on lisp
16:48rhickeyetc
16:48stuarthallowayhow many on FP in dynamic languages?
16:48rhickey100 on erlang
16:49Chouserwhat percentage of these have you read?
16:49stuarthallowaytechnomancy: not cs, but read Daniel Suarez's Daemon if you haven't already
16:49rhickeyall
16:49rhickeyI read them as I get them
16:49rhickeythese go back to 2003 on this machine
16:49technomancystuarthalloway: will check it out; thanks
16:50rhickeya lot of technical papers are only 12 pages
16:50technomancyoh, it's only available as a DRM'd ebook. =(
16:51rhickeybut I've also read, e.g. Joe Armstrong's PhD thesis, quite good
16:52rhickeyobviously some of those numbers overlap, just doing a raw search
16:54rhickeyunfortunately there aren't many like Out of the Tarpit, research papers tend to be very narrowly focused, and in order to read one you almost always have to read one or more of the papers it references etc
16:55stuarthallowaytechnomancy: *loving* emacs-starter-kit, thank you!
16:55technomancystuarthalloway: awesome.
16:55rhickeyI should put together a list of at least the ones that mattered most in the end
16:55dysinger_stuarthalloway - for those of us on clojure 1.0 and depending on clojure-contrib for test-is and other things - If you refactor it out - then we have to freeze clojure-contrib for a while ......
16:55stuarthallowaystill undecided about paredit-mode -- do most Clojurians use it?
16:55dysinger_no more march straight onward
16:55hiredmandysinger_: or cut a release
16:55dysinger_y
16:56technomancystuarthalloway: it takes some getting used to, but I will never voluntarily go back.
16:56dysinger_technomancy showed me paredit-mode - I am hooked
16:56dysinger_wouldn't code without it now
16:56rhickeyyes please, a contrib release corresponding to 1.0 would be hugely useful
16:57technomancystuarthalloway: the big hurdle is there's no way to just explore it; a lot of its features are hidden until you just look through the list of keybindings it provides
16:57technomancymaybe I should do a short focused screencast on paredit... hrm.
16:57technomancyit's one of those things that's far easier to learn by example
16:57stuarthallowaytechnomancy: that would be a *great* screencast
16:57stuarthallowayesp. since people keep whining about IDE support
16:58dysinger_they'll never be happy :)
16:58stuarthallowaywould be nice to see the benefits of coding in sexprs
16:58dysinger_y it's really cool
16:58technomancyyeah, most of the other features you see ported to IDEs, but I've never seen paredit duplicated.
16:58dysinger_you don't have to track down your paren ending out of ))))))))) anymore - just cut/paste/move etc
16:58stuarthallowayit would be lot harder to write a structural edit mode for a language with ... more structures
16:59rhickeydoes it understand [] and {}?
16:59technomancyrhickey: recent versions do
17:00stuarthallowayand it uses the close versions ] } ) to mean different things
17:00stuarthalloway...regardless of what form you are closing
17:00r2q2rhickey: yes.
17:00dysinger_I love that they call it barfage and slurpage
17:01r2q2rhickey: Documentation is sort of lacking the cheatsheet or the comments in paredit.el are your best bet in understanding what it does.
17:01dysinger_It's easy when someone shows you it in action. Technomancy showed it to me and I was like "ah" and mimicked like a monkey in 5 minutes
17:02technomancyyeah, sounds like a screencast is in order. =)
17:02r2q2rhickey: Actually it doesn't understand {} but it does understand []
17:02dysinger_the editing and the cut and paste without worrying about () {} [] is awesome
17:03dysinger_ah - haven't tried with {} yet
17:03r2q2Hrm oops I'm running an older version
17:04dhazawhy cant the editor call into clojure to get help with the parse tree and how to indent?
17:04technomancydhaza: totally possible. emacs does that with CL, but nobody's hooked up the wiring to do it w/ clojure yet.
17:04clojurebotemacs is best configured for Clojure with instructions at http://technomancy.us/126
17:05technomancydhaza: it's preferable to have static indentation rules imho though since if you auto-indent in Emacs (where it understands those rules) and someone else on the project uses a different editor, you won't be able to achieve consistency.
17:05dhazacool. because reader macros are groovy o_o
17:06wlrparedit dwim re: () {} [] "" for me at least
17:06technomancyoops. I bundled an older version of paredit in the starter kit so it doesn't auto-insert balancing {} chars.
17:07technomancyit understands them when enforcing sexp validity, but it just doesn't insert closing ones for you. will update.
17:10wlrwrapping n exprs with M-n ( or M-n [ or M-{ or M-" as appropriate is really handy
17:12technomancyr2q2: you need paredit 21 or higher
17:13r2q2I self installed v21
17:13r2q2I even evaluated and loaded paredit 21
17:14technomancyoh... clojure-mode is expecting paredit to be loaded before it loads, which is not always the case.
17:15r2q2Oh yea thats probably the problem. I was manually enabling paredit as a minor mode.
17:16technomancylooks like it needs to be enabled in a hook
17:16r2q2(add-hook 'clojure-mode-hook (lambda () (paredit-mode +1)))
17:16technomancywhich is what it says in the docs at the top, but it's easy to miss.
17:17r2q2If you have questions about paredit riastradh is on #scheme.
17:18dysinger_I had to add a clojure-mode hook for paredit too
17:18dysinger_and I installed paredit with elpa
17:18r2q2As long as that is evaluated before clojure-mode that mode hook should work.
17:20dysinger_I have autoload for clojure based on file extension and then the paredit clojure-mode hook after
17:20r2q2Well
17:20dysinger_which I think accomplishes the same
17:20dysinger_anyway it works
17:21r2q2Yea thats fine I was probably doing something funny. Nevermind
17:26r2q2Anyone use redshank ?
17:27technomancyr2q2: I think redshank is pretty cl-specific
17:27lisppaste8dysinger pasted "my el init" at http://paste.lisp.org/display/82154
17:28dysingerkool lisppaste is nice
17:28dysingerr2q2 there's my el init (based on emacs-starter-kit) (as tim.el)
17:32r2q2technomancy: Yea I know some of it is. The mouse copy function was usable in scheme.
17:32r2q2technomancy: It was the only feature that was actually useful.
17:32technomancywhat's it for?
17:33r2q2Well
17:34r2q2It allows you to write a lisp expression and insert it at an arbitrary point
17:36r2q2It copies an sexpr from the point that you click at to the point of your cursor
17:37r2q2I'm doing a horrible version of actually telling you what it does. http://lispm.dyndns.org/news?ID=NEWS-2007-11-18-1 is much better
18:08rhickeyClojure bookshelf: http://www.amazon.com/Clojure-Bookshelf/lm/R3LG3ZBZS4GCTH/ref=cm_lm_byauthor_title_full
18:09technomancyrhickey: nice; thanks!
18:10liebkerhickey: great list!
18:10arohner_rhickey: that is really cool
18:10arohner_I only have 1/7th of that list...
18:12rhickeyI'm not sure I got the latest edition of every book in the links
18:13technomancyDylan, huh? wouldn't have guessed that.
18:14mrsolothats a lot of books
18:15technomancya good portion of them you can find as PDFs
18:15mrsololisp in small pieces is one expensive book
18:16technomancymrsolo: there was a mistake on amazon.ca that had it being sold for $4 for a while
18:16mrsolomissed that heh
18:16technomancythey didn't deliver, but they sent a coupon to everyone who ordered it. =)
18:16technomancyn
18:16mrsolopurely functional data structures was way over my head firt time i read it
18:23ataggartrhickey: do you have a personal site, where you stick links like the one to the bookshelf?
18:23rhickeyataggart: no
18:29r2q2I'm probably being nitpicky but the semantics of (identical? "foo" "foo") has changed since the video Clojure Data Structures has been made. At the time of the video was made (identical? "foo" "foo") => false , while in clojure 1.0 (identical? "foo" "foo") => true . The time that this occurs is at 32:00.
18:31dreishMy guess would be that the difference is strings passed to eval are all getting interned now.
18:31dreishMore of an eval change than an identical? change.
18:32rhickeyr2q2: it wasn't guaranteed then (string literal interning), it is now
18:33r2q2Oh okay.
18:34rhickey,(identical? (str "str" "ing") "string")
18:34clojurebotfalse
18:46mrsolowhy is clojure designed in the way so that (+ nil) doesn't raise NPE?
18:47mrsolo,(:a nil)
18:47clojurebotnil
18:47mrsolo,(nil :a)
18:47clojurebotjava.lang.IllegalArgumentException: Can't call nil
18:47mrsolo,(+ nil 3)
18:47clojurebotjava.lang.NullPointerException
19:13banisterhey what's the diff bw multimethods and functional overloading
19:14ataggartthe former uses an arbitrary dispatch function, and the latter is based on arity (if I understand your meaning of "functional overloading")
19:15banisteroverload
19:16banisterthanks
19:16banisterhey can type hints be used to check for type correctness
19:16Chouserno
19:17banisterhmm ok
19:17hiredman~deft
19:17clojurebotdeft is http://gist.github.com/128259
19:17banisterwhy not?
19:17hiredmanbecause no one has written something to do it yet
19:17Chouserwell, it will catch some circumstances, but not all.
19:18banisterdo you think they will ? cos it seems the only major criticism I hear about clojure to date
19:18ChouserI wrote up an example once showing a case where it doesn't catch the type difference. I wonder where i put it.
19:19Chouserbanister: are you talking about runtime or compile time type checking?
19:19banistercompile time
19:20banistercan't you just take the system from scala?
19:21technomancyopen source doesn't work like that. =)
19:21ataggartsounds like an IDE feature waiting to be written
19:22banisterbut I mean both scala and clojure blatantly take from erlang why doesn't clojure take this one thing from scala?
19:22r2q2You can't just blindly import a system from an opensource language and plop it to another. You would have to rewrite it.
19:22hiredmanbanister: deft does very simple compile time type checking
19:23hiredman(and completely ignores types at runtime)
19:23drewrWhat has clojure "blatantly" taken from erlang?
19:23Chousertechnomancy: I think it's more of languages not working that way than open source.
19:24technomancyChouser: yeah, it was a joke.
19:24technomancysort of.
19:24Chouserbanister: I expect clojure will evenutally have a system for making assertions about the code at compile time.
19:24ataggartcan someone remind me how odl clojure is again?
19:24ataggart*old
19:25Chouserbanister: I imagine it will not be based solely around Java classes
19:25technomancybanister: that's the joy of young languages; you get to be involved in writing that kind of stuff. =)
19:25hiredmanyounger than the mountains, older than the trees
19:25mrsolodrewr: function dispatch based on arity very handy
19:25Chousermrsolo: also very fast on the JVM.
19:25mrsolosorta..although erlang does a lot more
19:25hiredmanmrsolo: hardly exclusive to erlang
19:25mrsolohardly
19:26mrsoloinspired i guess
19:26hiredmaneven java can do that
19:26ataggart"even" lol
19:26technomancy"even my grandma can do that"
19:26technomancy"... and she's been dead for seven years"
19:26mrsoloonly rick can answer what language inspired that part <shrug>
19:27hiredmanI think C++ can do that too
19:27Chouserataggart: I think Nov. '98 was 1 year since it was first "released"
19:27hiredmanbut my c++ is shakey
19:27mrsoloerlang is listed in the book list.. clojure must have taken something out of that langauge
19:28mrsolomay be distrubted programming in the future release? :-)
19:28Chouserataggart: I believe rhickey was working on it for 1.5 to 2 years or before that initial "release"
19:28ataggartchouser: 1998?!
19:28Chouserheh
19:28Chouser2008
19:28Chousersorry
19:28ataggartahh ok
19:36mrsolo,(/ 1)
19:36clojurebot1
19:36mrsolo,(/ nil)
19:36clojurebotjava.lang.NullPointerException
19:37mrsolo,(* nil)
19:37clojurebotnil
19:41ataggartthe one-arg arithmetic ops seem to have alternate behavior
19:41r2q2Yea
19:41r2q2I was going to say that
19:41r2q2,(*)
19:41clojurebot1
19:41ataggart(-)
19:41r2q2,(+)
19:41clojurebot0
19:41r2q2,(-)
19:41clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$-
19:41r2q2,(/)
19:41clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$-SLASH-
19:42r2q2Hrm + and * like being called without anything.
19:42ataggartas (+ 5 1) =>6 and (- 5 1) =>4, I would expect (+ 5) and (- 5) to both => 5
19:42ataggart,(- 5)
19:43clojurebot-5
19:43r2q2,(+ 1)
19:43ataggartso it's more like operator overloading
19:43clojurebot1
19:43banisterdo you guys think of scala as the enemy
19:43ataggartit's a language
19:43r2q2I have no opinion of scala. I know its a language I know it has static typing.
19:44hiredman~scala
19:44clojurebotUnfortunately the standard idiom of consuming an infinite/unbounded resource as a stream can be problematic unless you're really careful -- seen in #scala
19:44drewrI find Scala less interesting than Clojure, but that's mostly out of ignorance.
19:44hiredman#scala is a scary place
19:44banistercompeting with scala clojure for the functional concurrency crowd on jvm?
19:44Chouserbanister: not at all. It's got pretty different goals around dynamism, type systems, metaprogramming, etc.
19:45technomancybanister: they target very different audiences. to appreciate scala you have to think that on some level, Java (the language) is almost a good idea.
19:45drewrI know that I have questions about a functional language whose programming tome has mutable state in its first code example. :-)
19:45hiredmanbanister: I cannot concieve of competition between clojure and scala, in my mind there is no competition
19:45mrsolouse both of them <shrug>
19:45banisterI own the programming scala book but it's size scares me
19:45hiredmanI hang in #scala too, and my impression is that the scala language is a train wreck
19:46mrsolohiredman: is it? hmm
19:46mrsoloi went through scala book and tutorial. thats about it
19:46hiredmanmrsolo: that is just my impression from the irc channel
19:47mrsoloi didn't find any major flaw other than the toolchain was a bit buggy
19:47ataggartcount me among the cadre that has no opinion of scala
19:47hiredmanclojure is just so much more elegant and simpler
19:47r2q2Is lazy-seqs prefered now to lazy-cons?
19:47ChouserI did a couple dozen projecteuler problems in scala before learning clojure.
19:47Chouserr2q2: lazy-cons is gone
19:47ataggartr2q2: it replaces it
19:47r2q2Yea thats what I thought.
19:48technomancyI read through a lift tutorial, but I got turned off by the fact that there was more XML than scala code in the first chapter.
19:48hiredman~literal [0] scala
19:48clojurebotalso<reply>"we are completely screwed on ==." -- seen in #scala
19:48hiredmanbah
19:48r2q2Because the website says that it is the prerelease in SVN trunk
19:48r2q2The video says to use lazy-cons.
19:48ataggartold video is old
19:48hiredmansvn is old
19:48technomancytoo bad you can't patch videos like you can code. =\
19:48hiredman~literal [1] scala
19:48clojurebot<reply>Unfortunately the standard idiom of consuming an infinite/unbounded resource as a stream can be problematic unless you're really careful -- seen in #scala
19:49Chouserhiredman: is that one not true in Clojure as well?
19:49hiredman~literal [2] scala
19:49clojurebot2 is out of range
19:49hiredmanChouser: well clojue nulls locals for you
19:49hiredmanclojure
19:49hiredmanscala does not
19:49Chouserhiredman: oh, they're not just talking about trying to consume the whole thing?
19:50Chouseroh. my.
19:50r2q2How should I learn clojure other than using the website or the videos?
19:50hiredmanr2q2: the videos are fine, just old
19:50ataggartwrite some
19:50hiredmaneuler it up some
19:50technomancyr2q2: read some. then write some more.
19:51technomancy~mire
19:51clojurebotmire is http://github.com/technomancy/mire/tree/master
19:51technomancy^an example project that might be helpful
19:52hiredmannah, you should make clojurebot less of sprawling disaster
19:52hiredman:)
19:52ataggartd'oh
19:53ataggart,(< 5)
19:53clojurebottrue
19:53ataggart,(> 5)
19:53clojurebottrue
19:53ataggartit's a miracle
19:53hiredman,(doc >)
19:53clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically decreasing order, otherwise false."
19:53slashus25 is greater and less than
19:54hiredman"5" is in monotonically decreasing order
19:54hiredmanand increasing too
19:54ataggart,(<)
19:54clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$-LT-
19:54Chouser,(< 2 5 9)
19:54clojurebottrue
19:54ataggartsemms like zero- and one-args should behave the same
19:54mrsolo,(< nil)
19:54clojurebottrue
19:55hiredmanok
19:55hiredmanthats cute
19:55hiredman~def <
19:55hiredmanmust be a fast path
19:55ataggart([x] true)
19:55slashus2fast path?
19:56hiredmanslashus2: fastest path is the shortest
19:56hiredmanone arg to < is always true
19:56hiredmanso one arg gets the shorest bit of code possible to always return true
19:56ataggartI can't think of a case where you'd care about having one-arg work, but not care about zero args working
19:57technomancyI can't think of a case where you'd care about having one-arg work, period
19:57technomancyseems like an implementation detail to allow for a more concise definition
19:57hiredmantechnomancy: apply?
19:57hiredman,(apply > '(5))
19:57clojurebottrue
19:58ataggart,(apply > '())
19:58technomancyhiredman: would need a little more context than that.
19:58clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$-GT-
19:58mrsoloi like the behavor around nil a bit consistent.. i mean this is very nice suprise
19:58mrsolo,(-> {:1 {:a 3}} :2 :b)
19:58clojurebotnil
19:58hiredmantechnomancy: if you want to check if a list of numbers is ordered
19:59technomancyI guess so... but I don't think that's the intention behind the implementation.
20:00technomancyhmm... actually that doesn't seem to be the case; never mind.
20:00technomancythe >1 arities don't call the 1-arity body
20:01ataggartah good catch
20:03hiredmanthat would be very silly
20:04technomancyyeah, doesn't make sense now that I look at the code.
20:05hiredmanthe fast path is there for no reason but to make (> 5) fast
20:07slashus2Why does < put (first more) and (next more) in symbols... they use them so often.
20:08ataggarts/does/doesn't ?
20:08hiredmanhopefully first and next are fast
20:08slashus2It seems increases the performance when that is done, but it isn't very much unless you are comparing 10000000 numbers.
20:09slashus2900 msecs compared to 660 msecs or so.
20:09slashus2I ran them each 10 times.
20:11slashus2Tested with (dotimes [_ 10] (time (apply < (range 10000000))))
20:13slashus2Am I right? :-(
20:14rhickeyslashus2: this kind of microbenchmarking really isn't productive at this stage. If you make any decisions based upon it they could be completely blown in the future
20:15slashus2rhickey: I know, I was just making sure my observation was correct. I wasn't suggest that we change anything. Premature optimization is not the current goal.
20:17slashus2sorry :-(
20:19rhickeynp, I always wonder about such uses of apply
20:24rhickeydiff much small for me, jdk 6 os x: 760 vs 620
20:25slashus2I just did (let [next-more (next more) first-more (first more) ... and used those throughout the bottom part.
20:25slashus2I am running jdk 6 on os x too.
20:25rhickeywith chunks, 612 vs 513
20:25ataggartdoes let have any more overhead than declaring local variables in java?
20:26slashus2:-D
20:26rhickeyataggart: not unless you do destructuring, then there's some logic too
20:27rhickeybetter to spend time writing interesting software...
20:31ataggartagreed, more curiosity than anything else. plus its good to know when someone asks later on.
22:22holmak_In a (dosync ...) expression, does the expression block until the transaction completes?
22:25holmak_so, if i "(dosync (alter some-ref inc)) @some-ref", am i guaranteed to get the incremented value of some-ref when i dereference it?
22:33Chouserholmak_: inside dosync, things may block, but also the whole transaction may be retried.
22:34holmak_Okay... so my question is, when you leave the (dosync ) block, does that mean the change has gone through successfully?
22:34Chouseryes
22:35Chouserof course it may have been changed by something else in the mean time
22:35holmak_Awesome, thanks
22:35holmak_Yeah, but only one thing changes this -- i'm using the ref to pass a value back across an async Swing call
22:36Chouserif you're only ever changing one value at a time in a dosync, you might want to look at 'atom'
22:36holmak_does swap! have the same kind of guarantee?
22:36Chouseryes
22:37holmak_I know the concurrency stuff guarantees consistency and all that, but I wasn't sure if it just acknowledged the transaction and would keep working at it while your code continues
22:37holmak_Thanks for the clarification
22:37Chouserthis is synchronous behavior -- some of the concurrency is synch, other is asynch.
22:38Chouseragents, for example, are async. (send-off my-agent inc) @my-agent ... at the deref, the inc may not have happened yet.
22:38clojurebotfor is not a loop
22:38holmak_I had also considered using an agent, since i knew i could 'send' then 'await', but async wasn't the behavior i needed here
22:39holmak_I'm pretty okay with the concurrency stuff, its quite neat. There are just a lot of nuances to concurrency guarantees...
22:41Chouserindeed
22:41holmak_Good times though, that's why I love playing with Clojure. Doing locks correctly is certainly beyond me. :D
22:55samuelshey
23:20samuelsChouser: do you have a link to your clojure snakes program
23:22Chousersamuels: wow. not sure...
23:23Chouserhey look at that, it's on github
23:24Chouserhttp://github.com/Chouser/programming-clojure/blob/02485e760de2cbfa5c58d9f97f4f8205c15f1286/examples/snake.clj
23:26samuelsthanks!
23:27ChouserI haven't touched it for ages -- dunno if it even works anymore.
23:28samuelsdoes your version have much mutable state?
23:30Chousersamuels: I really don't remember, but looking at it I see very little.
23:31Chouserthere are two 'dosyncs', both changing a single game-state reference
23:35samuelsthanks
23:40durka42~logs
23:40clojurebotlogs is http://clojure-log.n01se.net/