#clojure logs

2008-11-14

00:31rzezeskiExcuse me if this is a newb question, but is the only diff between recur, and using the function symbol itself, the fact that recur won't consume the stack?
02:40bradbev_I've written a little viewer app, in much the same style as the ants demo. I listen on a socket inside an agent (started with send-off) and process messages in a loop. Another send-off agent calls repaint & then sleeps. However, my repaint function is not actually getting called :(
02:41bradbev_is the swing thread getting choked?
03:19jtoycan android apps be written in clojure yet?
03:30tWipin theory I guess
03:31tWipYou can create classes with AOT which the android tools would turn into its own format
06:27polliHi, I've got a silly noob question. How would you write something like this "(let [m someFunction] (. someInstance m))"?
06:28polliThat is call (. someInstance someFunction)
06:28pollido you follow? :)
07:29hoeckpolli: still here?
07:29polliyeah
07:30hoeckpolli: http://paste.lisp.org/display/67182
07:31hoeckyou can use this to call a java method dynamically using reflection
07:34polliah! I get it. Hmmm..
07:36Chousukeisn't the annotation there a reimplementation of memfn?
07:44hoeckchousuke: yes looks a bit like memfn
07:48ChouserI bet both memfn and that annotation would frequently require runtime reflection anyway, to pick the right method based on object type and arg types.
09:05fyuryurzezeski: that's correct. Another thing is: you can't recur into other functions
09:20PupenoHello.
09:20leafwbored?
09:21Pupenome? no.
09:22fandahello! looking for some comments on new syntax for tests:
09:22fandahttp://groups.google.com/group/clojure/browse_thread/thread/697d59883a273795#
09:22fandajust one person replied
09:22fandabad? good? have better one?
09:23fandai would like to start writing some tests
09:23fandai can learn that way and help too :-)
09:25PupenoI have a jar with a file a/b/c.clj that has (in-ns 'a.b.c) (defn d ...). In another jar I have a function that calls (a.b.c/d) and both jars are in the classpath. It doesn't work (java.lang.ClassNotFoundException: a.b.c), what am I doing wrong?
09:25Chouserfanda: did you see the existing test effort in contrib?
09:25fandayes, I saw it
09:26rhickeyPupeno: does the other file use/require a.b.c ?
09:26ChouserPupeno: you need (require 'a.b.c)
09:26fandaChouser: it seems unnecessarily verbose to me
09:27Chouserfanda: ah, ok. Personally, I'd try to reach a concensus with the people already working on tests.
09:28ChouserIt seems more important to me that all the tests use the same format than that it's the ideal format. Bring them 'round to your point of view and you get the best of both.
09:29fandayes, I guess, I should talk directly with Stephen C. Gilardi
09:30fandait seems he wrote the tests
09:31fandaStephen, are you here?
09:32Chouserhe's infrequently here, but he generally responds quicly on the google group.
09:33fandaI will write him an email
09:33fandasomehow testing seems fun to me (I am all about quality :-) )
09:33Chousergreat!
09:33PupenoThanks rhickey, Chouser. So now it is failing because a.b.c.c doesn't exists, this is something that recently change, right?
09:36rhickeyPupeno: you have to do one thing or the other - pre-change your file should have been in a/b/c/c.clj - post change in a/b/c.clj, do whatever matches the code revision you want to use
09:37Pupenorhickey: just checking if I understood your mail correctly; since I don't want to be stuck in the past, I'll upgrade. Thanks.
09:38rhickeysure
09:51danleiwhen you think that i
09:52danleioops
10:07PupenoIs there a way to find out, from the REPL, which svn revision was used when compiling clojure?
10:10rhickeyPupeno: this comes up occasionally and the answer is the same as "when did you stop feeding your dog?"
10:10rhickeyi.e. the question contains a presumption
10:11PupenoA false presumption I suppose.
10:11rhickeymaybe
10:11PupenoWhich one is it?
10:11duck1123 so, I can't find the answer from the Repl because I don't have a dog?
10:12rhickeyor you didn't build from a set of sources matching an svn revision
10:14Pupenorhickey: yes, I understand that part, it may sometimes give false information, but right now, it would be useful for me.
10:15ChouserIt's such a mess to solve even to 80% correctness. I've seen shell scripts that try to produce a string like "1080" for a clean revision or "1080+" if local changes are detected.
10:15rhickeyPupeno: there's an svn command for that
10:15duck1123Pupeno: there have been several threads on this subject, many options were given, but none of them stood out as the best way to do it
10:16Pupenook then.
10:16duck1123does sourceforge allow you to set up svn hooks?
10:16ChouserBut the ones I've seen would use hash-codes for hg and git, which is unhelpful. You'd want to track back to the SVN rev number, if that's even possible.
10:16duck1123I've never run a sourceforge project
10:17ChouserAnd of course you'd need all this to work not just on Linux, but Mac and Windows as well.
10:17Chouserall of which makes typing "svn info" seem pretty nice.
10:18leafwChouser: a hack would be to checksum the contents of the jar and check that against every revision with a shell script ... could take some time
10:18duck1123the ant task inserting the number seems the best option, possibly with a fallback to read from a file for the case of downloaded releases
10:19rhickeysvn info, like Chouser said
10:19leafwagreed.
10:20ChouserNow once we have a real version number and a "release culture", it might be worth a bit of effort to get that version number into the runtime environment somehow.
10:20Chouserbut that wouldn't be VCS based.
10:20PupenoThere's an assumption for svn info, and that is that you have the matching repository intact. My problem is "Where did that clojure.jar come from?", not "What is my current revision for this tree?".
10:24PupenoWhat does (all-ns) return post 1094?
10:24cemerickfwiw, we maintain a local authoritative (for us) build of clojure that is tagged with a revision number in ivy, and has that revision number set in a properties file in the clojure.jar we produce
10:26rhickeycemerick: a properties file with $Rev$ and a touch in the build script would work maybe?
10:26jtoygit
10:29cemerickrhickey: maybe -- ours is a bit heavier of a process -- using the svn/status task to set an ant property to the current svn rev #, and then propertyfile to update the properties file
10:30cemerickI don't really trust $Rev$ and such. I actually thought such things were frowned upon in svn (though provided for those who long for cvs)?
10:33rhickeycould be
10:34Chousercemerick: I'm not sure they're frowned on in SVN, but they're completely unavailable in git.
10:35Chousuke(automatic) revision numbers don't really make any sense in git anyway
10:35Chousukemostly because git is rather nonlinear, unlike SVN :/
10:35rhickeyChousuke: right - see "feeding dog" above
10:36cemerickChouser: turns out I'm wrong -- the red bean book describes svn keywords (like $Rev$) without any cautionary notes. I thought I read something discouraging keyword usage, but I suppose I could have imagined it.
10:37rhickeyI think if you are going to save off a jar before moving ahead, you should give it a meaningful name
10:37Chouserrhickey: have you had specific requests for PersistentHashMap for some other language?
10:38rhickeyseems like there should be a relationship between the most recent modified datetime and the svn rev
10:38rhickeyChouser: has been ported to Factor and Scala
10:38cemerickI'm probably being dense, as I'm not getting the dog feeding metaphor, but having some notion of a "version" of clojure that can be determined at runtime will eventually be pretty important. We've just been updating our entire codebase each time we upgrade the clojure we use, but eventually, that will become impractical, so some version-aware conditional execution forms will be necessary.
10:40rhickeycemerick: again, that comes to meaningful names - release versions will have meaningful names
10:40cemerickSure. I'm just blathering over here. :-)
10:41rhickeyand I'm all for an automated solution - no one's come up with one
10:42cemerickrhickey: it's a pretty simple thing in svn-land, if you want it; but do we need to support git and hg as well?
10:43rhickeycemerick: that was the complaint at the end of: http://groups.google.com/group/clojure/browse_frm/thread/9fa07b00c88280fc/e982ad5b869eb11b
10:43duck1123I am perfectly okay if I don't get proper build numbers if I use a non-standart repository
10:44cemerickyeah, seriously -- do we need to support perforce and pvcs and vss, too?
10:45duck1123I would like a solution that supports any scm, but I'd rather just have a solution
10:46rhickeyso much time, so little accomplished
10:46cemerickrhickey: don't let the jets and the sharks knock you off course. Rule with an iron fist. ;-)
10:47rhickeyI'm concerned for everyone's productivity - these vcs discussions always go nowhere
10:48jtoyelection projection systems,machine listening systems
10:48jtoylistening right now
10:52dudleyfvcs discussions are almost as productive as licensing discussions ;-)
10:58cemerickdudleyf: I'd swap them in that comparison, but sure :-)
11:01albinocouldn't you just version every release, and make that part of the version that shows up at runtime?
11:04leafwalbino: just do it yourself and submit a patch.
11:04leafwi.e. create the system, if you want it.
11:06albinoleafw: heh
11:06albinoI just realized python actually does display that (the svn rev number) in its repl. I didn't even know that and I've been using it for years.
11:07triddellIn the tutorial at http://riddell.us/clojure I document using the startup script located at git://github.com/jochu/clojure-extra.git. Using this you just call "clojure" on the command line and it starts a REPL, adds all the jars in .clojure to the classpath, etc. Slime also refers to this script in the tutorial. After the update to the latest version I can start clojure with "java -cp clojure.jar clojure.lang.Repl" but the "clojure" script fails with a "Fil
11:07cemerickthere's already a patch for that functionality on the google group. If Rich wants it, he'll pick it up.
11:08Chousertriddell: you got cut off at: fails with a...
11:08triddellfails with a "FileNotFoundException: Could not locate utils.class or utils.clj on classpath" Any ideas? Is anyone else using this script?
11:10CraigAnyone else having problems with slime on the latest bits? I keep getting "Evaluation aborted" in the minibuffer, although I can still run commands in the REPL no problem.
11:14dudleyftriddell: I doubt that script's been updated for a while
11:17triddelldudleyf: right, but it seems pretty basic and I'm just wondering why it would be broken now... all it really tries to do execute java with the classpath options... guess I just need to simplify it even more and see if I can tell what it breaking
11:18dudleyftriddell: The AOT stuff changed where Clojure looks for namespaces
11:19dudleyffrom path/to/name/name.clj to path/to/name.clj
11:19dudleyfIf I'm not mistaken
11:21duck1123What are your opinions? In Compojure, should the request and response objects be made available thread-locally, or no?
11:22duck1123I'm kinda for it mostly because many of the libraries I'm using expect me to have it, but I also see the author's point
11:22Chouserduck1123: I haven't spoken up on the list because I have zero experience with compojure. Having said that, I'm leaning against it.
11:23triddelldudleyf: I think I just fixed it... it looks to optionally run an additional script when starting the REPL... this may have been reseting the working directory and then not allowing the main clojure classes to be found I guess
11:23ChouserHaving "global" access to the request in rails makes it very difficult to tell what data any particular method is relying on.
11:24ChouserYou can look at a method and think you know what it needs, but it may call a helper function that depends on some other request field.
11:24duck1123it seems to me like having a hash of data, and then pulling all that data out for every function
11:25Chouserduck1123: sure, essentially the same thing. What might be better is to isolate the request data right at the handler, and pass in specific arguments that are needed.
11:26canderaI get java.lang.ExceptionInInitializerError when trying to evaluate '() on the latest bits.
11:26ChouserThe idea of using multiple threads on a single request further pushes in the direction avoid a thread-global.
11:26duck1123I hate filling up the handler macro with code that really should go elsewhere
11:27candera(list) evaluates fine. (quote ()) also blows up.
11:28duck1123I think I'll just drop it and continue doing what I have been doing
11:28Chouserduck1123: well, you could pass the request one level in to a function that unpacks the request or whatever, and passes the specific args on down.
11:29duck1123that's essentially what I have been doing
11:29Chouserduck1123: I'm by no means convinced, but I'm giving you the reasons I've come up with for one side of the argument.
11:30ChouserI think the usual trade off is between making it easy to make changes (global request means you can easily add a new arg without changing all the functions between the handler and the one that needs the data)
11:30duck1123I have a template that needs access to the session, so that means I need the session to be available to every "page-view" function
11:31Chouserbetween that and easy of understanding (being able to see at each point exactly what data may be used, and what will be modified/returned)
11:32Chouserhm. Well, you could add it as your own thread-global if you want, couldn't you?
11:32drewrI'm now confused about this ns/in-ns conversation on the list.
11:33drewrIf I use (in-ns 'foo) from a different file from where (ns foo) resides, none of the symbols is available in the in-ns file.
11:33duck1123I suppose I could. Although I'm not sure where the best place to do that would be if not in the compojure.http ns
11:34drewrEven a refer doesn't make them available.
11:34duck1123drewr: wouldn't you need to require 'foo?
11:36drewrI can (clojure.core/require 'foo).
11:36drewrHow come that then makes clojure.core symbols available? Because of the ns?
11:36drewrI suppose that makes sense.
11:36rhickeyI see a request being more of a context, so prefer the var approach, you can bind that var in any launched threads
11:36Chousukehmmh
11:37Chouserrhickey: as in, pass the request to the new thread and using (binding ...) again there?
11:37drewrNow I get Reflection warnings in calls to .toUpperCase.
11:38drewrAll this just magically worked with ns. :-)
11:38rhickeyChouser: yeah
11:39ChousukeI'm trying to precompile clojure.core but it fails with a rather cryptic error: java.lang.NoClassDefFoundError: clojure/core$str__2721$fn__2725 (core.clj:325) ... on that line in core.clj there's the definition of 'symbol?
11:40ChouserChousuke: you have the "classes" dir in your classpath?
11:40Chousukehmm, no. duh :P
11:43Chousukewell, now it compiles
11:44Chouserrhickey: isn't relying on that kind of implicit context one of the things Tarpit warns against, in favor of more functional and explicit passing of data?
11:45Chousukeif I remove the classes dir though, the compilation works a bit weird: I have to run clojure, (compile 'clojure.core), it fails, but after restarting clojure it can now use the classes in the classpath and compilation will succeed.
11:46rhickeyChouser: yes, you have to use it wisely. OTOH, *out* would have to be threaded through the entire world...
11:47rhickeythat's a different problem - lack of encapsulation, tainting the call path
11:49Chousukehm
11:49Chousukenow this behaviour is rather interesting.
11:49Chouseryeah, ok. feels like a judgement call, and anyone who trusts my judgement over yours is undoubtedly asking for trouble. But *out* is one thing, as is *err* and *in*. the request is n things, the number and names of which can change just by adjusting the request URL.
11:49duck1123for reference, here's my current controller file: http://github.com/duck1123/mycyclopedia/tree/master/app/controller/controller.clj
11:50duck1123pre-AOT
11:54drewrClass cast bug? http://pastie.org/314946
11:54drewrEr, not casting.. type hint.
11:55ChouserI think you type-hinted a list
11:55drewrI get Reflection warnings if I don't.
11:56Chouser(when true #^String %)
11:56drewrhttp://pastie.org/314949.txt
11:56drewrOK.
11:58drewrIs this a consequence of AOT that I have to type hint everywhere now?
11:59Chouserduck1123: yeah, I can see what you mean. It's very interesting to me, though, that returning the output looks very natural, even without an *out*-like global.
12:00Chouserdrewr: I don't think so. You're getting more reflection warnings now than you used to?
12:00Chousukehere: http://paste.lisp.org/display/70388
12:00Chousukethat might be intended behaviour, but it sure is confusing.
12:01drewrChouser: Yes, this worked fine before. http://pastie.org/314953.txt
12:02ChouserChousuke: what happens if you have an empty classes directory before you start?
12:03Chousukeah. it works.
12:05ChouserChousuke: I think java may be essentially eliminating "classes" from your classpath when the dir doesn't exist.
12:06Chouserdrewr: are you sure? I don't see how it could have. "size" could legally be either an int or a java.util.Collection
12:07drewrAll I know is that I didn't get any warnings before.
12:07drewrI don't mind type hinting, but I don't understand why the compiler now cares.
12:08ChouserYou don't have to type hint -- it'll just use reflection at runtime.
12:08drewrSo what is the warning telling me then?
12:08ChouserI just rebuild clojure SVN 1088, and this generates a warning:
12:08Chouser(set! *warn-on-reflection* true)
12:08Chouser(defn m [size] (java.util.concurrent.LinkedBlockingQueue. m))
12:09ChouserThe warning is simply saying that that call will use reflection at runtime rather than being able to resolve the call perfectly at compile time.
12:09Chouserit's essentially a performance warning.
12:10Chouserrhickey has generally recommended using type hints only when you know you need the performance.
12:11drewrYeah, it's ugly.
12:11Chouseryep
12:12drewrMaybe it's that I started using in-ns again.
12:12drewrI don't know why they would be related though.
12:12Chousukehmm
12:12ChouserIf *warn-on-reflection* is false, you shouldn't get any of those warnings.
12:13ChouserIt certainly used to always default to false, and I think it still does.
12:13drewrIt's set to true (in SLIME), but it's been that way for months of usage.
12:13ChousukeI can't compile clojure.inspector on OS X without causing a clojure.lang.Repl process showing up in the dock. I suppose that's because of the Swing-related imports.
12:14ChousukeI suppose it's harmless. :)
12:14drewrChousuke: Except that CMD-Q causes it to kill your JVM.
12:15Chousukewell, yeah
12:15drewrSometimes I forget about that.
12:24cemerickrhickey: I often get "java.lang.Exception: Accessor/struct mismatch" when developing in the repl -- presumably, the ordering of a struct's def has changed, and some client code is trying to use an old def to access a newer version of a struct. In virtually every circumstance, I've not actually changed the keys in a struct. So, shouldn't struct defs be compared with .equals (instead of !=) in PersistentStructMap?
12:24cemerickOf course, Def would have to gain a proper equals impl.
12:25cemericks/the ordering of a struct's def as changed/
12:35fandarhickey: In the latest SVN, there are both core-proxy.clj and proxy.clj files in src\clj\clojure
12:35fandais this intentional?
12:44danlei(/ 1 0)
12:44danlei... well ... no debugger in irc ;)
13:13Drakesonis there a better (lazy) way of doing (seq (.split (slurp file-name) "\n"))
13:14Drakesonsomething that could be called slurp-lines
13:17fandasee this
13:17fandahttp://groups.google.com/group/clojure/browse_thread/thread/380fdd164a5c5b7a/6c2ce06780ce5ddf?lnk=gst&q=line-seq#
13:17fandafor line-seq
13:17Drakesonfanda: thanks
13:18fandano problem
13:20DrakesonHow would you read into a variable what you have prn'ed into a file?
13:20drewrDrakeson: (doc read)
13:20Drakesonthanks
13:21drewrOr read-string I suppose if you've already read the file.
13:23ChousukeCan a jar Manifest file contain multiple classpaths? I'm trying to include precompiled .class files in a jar but I'd like to have them all under a /precompiled directory; however, it seems that clojure doesn't use the .class files if I have them like that. If I put them in the same dir with the .clj counterparts it works though.
13:25ChouserChousuke: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4295946
13:26Drakesonwhat's wrong with this: (with-open [f "test.dat"] (read f))
13:27hiredmanmany many things
13:27hiredmanwell, I am not sure what the latest with-open does
13:28Chouserdrewr: read wants a PushbackReader, not a filename
13:28Chouser^^ Drakeson
13:28Chouserdrewr: sorry. :-)
13:28hiredmanand strings don't have a close method
13:28ChouserDrakeson: do you have clojure.contrib?
13:30Drakesonis `f' in (with-open [f "test.dat"] (read f)) a filename or a stream?
13:30DrakesonI guess I have contrib ...
13:30drewrDrakeson: It's anything that can be .close()d.
13:30Chouserwith-open is somewhat poorly named. It doesn't actually open anything, just closes whatever you bind at the end of the block.
13:31Chouser(with-open [f (java.io.PushbackReader. (java.io.FileReader. (java.io.File. "test.dat")))] (read f))
13:31Drakesonoh!
13:32Drakesonthere should be a macro/function for that
13:32Chouserduck-streams
13:32Drakeson(with-open-file [bindings] do-things)
13:33DrakesonChouser: what is in contrib for that?
13:33Chouser(require '[clojure.contrib.duck-streams :as ds])
13:33Chouser(with-open [f (java.io.PushbackReader. (ds/reader "obj.clj"))] (read f))
13:33drewrhttp://github.com/kevinoneill/clojure-contrib/tree/master/src/clojure/contrib/duck_streams.clj#L20
13:34canderaIs anyone else having trouble evaluating '() on 1099? I get ExceptionInInitializerError.
13:35candera(quote ()) also blows up, but (list) does not.
13:35drewrDoesn't work for me either.
13:35rhickeycandera: fixing now, hang tight
13:35Chouserhuh. () works though
13:35canderarhickey: roger. Thanks.
13:39ChousukeI fixed it so that the manifest has only one Class-Path attribute but it still doesn't work :/
13:40hiredmanis the path with the .clj files first in the class path?
13:40Chousukeno, it's last.
13:41Chousukecurrently it looks like "./precompiled/ ."
13:41rhickeycandera: print-dup on '() fixed. Now please start using () instead of '() :)
13:42ChousukeI wonder if it's causing problems that precompiled/ is a subdir of the second classpath element :/
13:42danlei'(
13:42danleidoesn't work for me either
13:43rhickeydanlei: what doesn't?
13:43danleievaluating '() throws an exception
13:44Chouserdanlei: time to upgrade :-)
13:44danleihm
13:44rhickeydanlei: you have rev 1100?
13:44danleijust built it an hour ago :)
13:44canderarhickey: thanks!
13:44Chouserit's been fixed for 3 minutes now!
13:44danleity
13:45rhickeyI am serious though, please don't write '() - quoted lists are ugly
13:45danleidepends
13:45danleiactually, it's a common ideom
13:45rhickeynot in Clojure
13:45danleican't argue that
13:45danleiin cl, it is
13:45rhickey() is the empty list, if you want literal tuples use vectors
13:45ChousukeI really can't figure out why clojure appears not to be finding the .class files from the jar classpath. :/
13:47Chousukethough I could probably use a more accurate method for determining that than running a hello world script and looking at how long it takes.
13:47hiredman...
13:48Chousukethe difference is pretty noticeable though.
13:48danleiapropos vectors: how relates [] to (vector ...)? one can't write (defn (vector ...) ...) as it seems
13:48ChouserChousuke: you could try removing the .clj classpath entry entirely
13:48ChousukeI suppose.
13:49danleitypo: (defn foo (vector ..) ..
13:49Chouserdanlei: defn doesn't evaluate it's arguments -- if it did (defn foo [a b] ...) would complain that a and b are not yet defined.
13:49hiredmandefn is a macro, yes? so it just sees the (vector ...) function call, not a vector
13:50danleiso its like (quote (vector ..)), ok. thanks. same relation like '( and list.
13:50Chouserdanlei: not quite -- when [] is evaluated, all of its values are evaluated, unlike if it is quoted
13:50rhickeydanlei: not really - vector literals are evaluated
13:51rhickeywhat he said :)
13:51danleiok, got it.
13:54danleioh, no dotted lists
13:55Chousernope. use a vector
13:55danleii see
13:55Chouserwell, or a list or whatever.
13:57ChouserThere's a Cons class, but although the first thing can be any Object, the second thing must implement ISeq
13:57rhickeyif you were doing (x . y) in CL, please switch to [x y]
13:58rhickeyfor 2-tuples
13:59danleiok, thanks rhicky. is there some kind of tutorial, which compares clojure with cl? there is a little table at wikipedia, any tips above that?
13:59danlei+e
14:00rhickeyStuart Sierra posted a patch for precompiling Clojure's core libs into the jar, doubles the size and halves the startup. I'm for it, any objections?
14:00gnuvincedanlei: not a tutorial per-se, but this highlight many differences: http://clojure.org/lisps
14:01danleignuvince: thank you
14:01rhickeya useful exercise - try avoiding using lists except when writing macros, question every time you use reverse etc
14:02rhickeywill get you up to speed on seqs, vectors and maps
14:04Chousukerhickey: I was trying to do that myself (mostly as an excercise though :))
14:04rhickeyChousuke: I did it as a proof of concept of AOT, but Stuart did the ant side
14:05rhickeyworks great
14:05ChousukeIn my version I got it working but it's pretty ugly, as the .jar file clojure/ dir will be full of .class files :p
14:05danlarkin+1 for precompiling clojure.jar
14:05ChousukeI tried to figure out how to move them outside the main clojure/ dir but that didn't seem to work no matter what I did.
14:05AWizzArdrhickey: many clojure functions return what looks like a list... are those really always lists?
14:06rhickeyChousuke: um, aren't jars supposed to be full of class files?
14:06rhickeyAWizzArd: rarely
14:06danlarkinAWizzArd: run (class ...) on it
14:06Chousukerhickey: I kind of wanted to separate the precompiled stuff from the .clj stuff, but that's just me :)
14:06rhickeyAWizzArd: almost never actually lists
14:06AWizzArdAh oki, so it's just the printed representation, good
14:06rhickeyChousuke: the .cljs are not in the jar
14:07AWizzArdClojures vectors don't leave very much room for the usefullness of lists
14:07rhickeyAWizzArd: how so?
14:07danleiah, there are transcriptions of pcl chapters in clojure. nice ...
14:07rhickeyoh I see what you meant
14:08fandadanlei: another comparison CL-Clojure
14:08fandahttp://en.wikibooks.org/wiki/Clojure_Programming#Clojure_for_Common_Lisp_Programmers
14:08Chousukerhickey: in my version of the .jar builder I left them in. Now that I think of it, it seems rather pointless.
14:09danleifanda: thanks that's fond that one already
14:09danleifanda: thanks excuse my english ;)
14:09fanda:-)
14:10fandai am not a native speaker either :-)
14:11fandasee? :-)
14:11danleiyes, but normally, i can at least parse my own sentences .. =)
14:11gnuvinceQuite the multi-cultural community we have here
14:11danlei. o O (that's fond that one already)
14:12rhickeygnuvince: yes, it's great
14:15fandawatch for typos or I say that you are not a native speaker (n)either :-)
14:15fanda:-)
14:17fanda(just having fun :-) )
14:18ChousukeMany times I've seen native speakers use worse English on IRC than non-natives :P
14:19fandaas long as both sides understand, it's just fine
14:19ChousukeYeah.
14:19ChousukeNo prizes for literary excellence.
14:19danlarkinwhat?!
14:20danlarkinbut that's what I'm gunning for :'(
14:22fandarhickey: I remember discussion about #+ and #- macros from CL. They gonna eventually make it into Clojure in some way. Has that happened already or not? (Just curious, no pushing).
14:22Chouserfanda: those haven't happened yet.
14:22gnuvinceWhat are #+ and #-?
14:22rhickeycemerick: struct equality test would be a lot of overhead on every access
14:22rhickeycould do some hash thing I guess
14:24cemerickrhickey: it gets tricky otherwise -- you've been knocking around in the repl for an hour, and then all of a sudden a pile of structs that are being held somewhere (or in many places) are rendered "stale", so you have to go around and reconstitute them, which isn't always possible.
14:25fandagnuvince: they are reader macros
14:25fanda#+ symbol include-this
14:25fandaif symbol exists, include-this gets put in the place of the whole thing
14:25cemerickmaybe Defs could be interned? I wouldn't think there'd be many Defs in any particular app/library.
14:25fandaor should I say - if symbol is bound to something true
14:26rhickeyfanda: on todo list
14:26fandarhickey: oh, ok
14:27fandai was first confused, if it isn't #= macro
14:28rhickeycemerick: I don't want to tease you, but in doing aot, I realized (again) that structmaps don't serialize well due to their relationship to the def. I'm thinking now that maybe structmaps should do some codegen and have a real class as basis - would also give you named fields on Java side
14:30cemerickrhickey: that's exactly how I was hoping I could reimplement genbean, once AOT is ready for me
14:30cemerickI'd prefer methods on the Java side, though (:foo structmap) in clojure => structmap.foo() in Java.
14:31rhickeycemerick: really, why?
14:31cemerickMy latest genbean impl also adds "setters" for those slots, so structmap.foo(newFoo) => updated-structmap-with-newFoo
14:31rhickeyah
14:31rhickeycute
14:32rhickeylast call - precompiled clojure.jar 10, 9, 8 ...
14:32cemerickexposing methods instead of fields also allows for emergency subclassing down the line
14:33rhickeycemerick: :(
14:34cemerickrhickey: yeah, I know. That's more of a symptom of it not being straightforward to "subclass" a genbean specification at this point.
14:34cemerickIn my defense, I've only done it twice so far.
14:44rhickeysvn 1101 - Clojure ant script now precompiles .cljs into jar
14:45Chouserbeautiful. it Just Works.
14:51fandado you see any usefulness in keeping 2 different build scripts? one for .clj, second for .class?
14:52Chouser-Xverify:none seems to reduce startup time slightly
14:52Chouseras does -client
14:53AWizzArdChouser: but do you usually run java in a -server for programming Clojure?
14:53rhickeyChouser: I think the JRuby guys tout -Xbootclasspath as being a big boost
14:54ChouserAWizzArd: I do usually use -server
14:57rhickey-Xbootclasspath/a:clojure.jar
14:59rhickeydoesn't seem to make a big difference for me, but I'm just over a second here
15:00AWizzArdi will see if i can test this inside vmware later, with my mobile processor on just 50%
15:00Lau_of_DKAbout this AOT business - Im completely blank on the uses of this, where do I go read ?
15:03Chouserrhickey: with your bootclasspath option and -client, -Xverify:none doesn't seem to help. But I'm down to 0.448s
15:04rhickeyChouser: bootclasspath subsumes verify:none
15:04dudleyfClasses added to the bootclasspath bypass the verifier, so -Xverify:none shouldn't do anything
15:05ChouserI assumed it was something like that.
15:07dudleyfI vaguely remember JRuby having some problems using bootclasspath
15:08Lau_of_DKAbout this AOT business - Im completely blank on the uses of this, where do I go read ?
15:09rhickeyLau_of_DK: http://groups.google.com/group/clojure/msg/58e3f8e5dfb876c9
15:09rhickey"This can be used to save startup time, deliver
15:09rhickeyapplications without source, interop with bytecode-based tools etc. "
15:10rhickeyIf you don't need it, you can ignore it
15:10Lau_of_DKthanks rhickey
15:10rhickeyLau_of_DK: don't ignore the code changes though, just ignore compile
15:11Lau_of_DKk
15:11Lau_of_DKAre the interrim SVN changed completed now?
15:12rhickeyLau_of_DK: I think the experience on HEAD is back to normal
15:12Lau_of_DKk
15:12Chouserclojure.contrib isn't quite all caught up yet.
15:14rhickeyChouser: what's left?
15:16ChouserI've got that squirrely gen-interface thing.
15:16rhickeyah, yes, I didn't get to look at that last night
15:16rhickeyIt happens when manual loading and compiling in same session>
15:16rhickey?
15:17Chouseroh, Stuart S. moved lazy-xml and command-line for me. I guess everything should load ok now.
15:17rhickeycool
15:17Chouserrhickey: yes, that's the only time I've seen it.
15:18rhickeyyou guys are awesome to have switched over so quickly
15:19ChouserBut like I said, I can follow the directions I posted and *not* see an error.
15:25Lau_of_DKAre there currently any other languages available which can offer the concurrency guanrantees that Clojure does?
15:25rhickeyLau_of_DK: Haskell
15:25Lau_of_DKk
15:25rhickeyErlang
15:26gnuvinceIs there a method to know if a number is negative, positive or zero?
15:26Lau_of_DKpos?
15:26Lau_of_DKzero?
15:26Lau_of_DKneg?
15:26Lau_of_DKrhickey, thanks
15:26gnuvinceLau_of_DK: all in one, like signum in Haskell IIRC.
15:27Chousergnuvince: #(compare % 0)
15:28Lau_of_DKBut rhickey, unless I misunderstood Clojure, you say that even in race-conditions, no locks are used? Erlang suffers from deadlock situations according to your (very excellent) 'state' article
15:29rhickeyLau_of_DK: no, clojure's STM uses locks quite a bit - there are no user locks and no deadlock
15:29Lau_of_DKoh ok . I must have missed that
15:29rhickeyErlang leaves it to you to avoid deadlocks
15:30rhickeyusing timeouts etc
15:30rhickeybut Erlang has a distributed concurrency model, so is a different thing altogether
15:30rhickeyIf that's what you need there's no substitute right now
15:31Lau_of_DKYes I get that. But I understood that the STM creates snapshots for all readers coming in, so that you get a consitent view of the data. And when writing is atomic, because youre only changings refs. Where does locks occur in that?
15:32rhickeyLau_of_DK: you don't have to lock, I do in the implementation of STM, which is, shall we say, tricky
15:33rhickeyprobably the only part of Clojure Chouser hasn't yet gotten around to
15:33Lau_of_DKhaha
15:33Lau_of_DKrhickey, STM is purely your brain-child?
15:34rhickeySTM is a well known idea - there are many implementations
15:35Lau_of_DKok, but you wrote your own I mean, its not a copy of PostReSql or something like that? I seem to remember you mentioning it in a screencast somewhere
15:35Chouserheh. ClojureScript doesn't even have Refs yet, let alone ones that would work if JS had threads.
15:35rhickeyLau_of_DK: Clojure's STM is unique to Clojure
15:35Lau_of_DKrhickey, cool, thats what I wanted to know
15:35AWizzArdrhickey: what about F# for concurrency?
15:38rhickeyAWizzArd: AFAIK F#'s refs don't have any transactional semantics, just the regular ML ones. It's a mixed paradigm language like Scala - you can write in a functional subset, or not
15:38AWizzArdI see
16:16Lau_of_DK(/s/and/at)
16:16Chousersohail: oh, stop it.
16:17sohailChouser, time to make a FAQ methinks
16:18Chouseryeah, perhaps. but that question needs more than a pat answer.
16:18Chouserit needs a blog post that I can't seem to write. or something.
16:19AWizzArdWould clojure run also under this open java? What about Kawa?
16:20Chousersohail: did you solve yours to your satisfaction?
16:21hiredmanI know the repl at least starts on openjdk7
16:21waltersAWizzArd: under OpenJDK? if so yes, OpenJDK has all the important code from the proprietary JDK
16:21AWizzArdnice
16:27sohailChouser, no
16:27sohailproblem was I wanted CL-like dispatching and I was too arsed to do it properly
16:37astorcan someone explain to me how I use defmulti/defmethod to implement a function that dispatches on say a vector of 3 elements where I want some of the elements in the vector to be what in CLOS would be 't - that is "don't care"?
16:37polliAre there people here using aquamacs and clojure-mode/swank-clojure?
16:37astorpolli: I am
16:38polliastor: when I do M-x slime it gives me an exception. Ever had that problem?
16:39kotarakastor: (defmulti foo (fn [[x _ _]] x)) (defmethod foo :x [x] :xxx) (foo [:x :y :z]) (foo [:x 1 2])
16:39polliastor: "java.io.FileNotFoundException: Could not locate Clojure resource on classpath: swank/swank.clj"
16:41polliwhen I look in swank-clojure there's a swank.clj, but none in swank-clojure/swank
16:42astorkotarak: I mean something like (defmulti foo (fn [x] [(:a x) (:b x) (:c x)])) (defmethod foo [:x _ _] :xxx) (defmethod [_ :y :z] :asdf) ...
16:43astorkotarak: where the _s in defmethod mean don't care.
16:43astorpolli: have you set swank-clojure-jar-path?
16:45astorpolli: erm.. have you done (add-to-list 'load-path "/Users/foo/path/to/swank-clojure/")?
16:45AWizzArdnice, nearly 900 users in the GG.. and nearly 90 people here in #Clojure
16:45AWizzArdand maybe something like v0.9 ;-)
16:46polliyes, add-to-list-thing is in
16:46polliI tested with the swank-clojure-jar-path now, but it did not fix it :/
16:48polliastor: I followed some screencast setting up aquamacs with clojure-mode, I checked it twice but was not able to spot any differences
16:48kotarakastor: you could probably do something like (derive ::Foo ::Bottom) (derive ::Bar ::Bottom) (derive ::Baz ::Bottom) (defmulti foo (fn [x] [(:a x) (:b x)])) (defmethod foo [::Foo ::Bottom ::Bottom] :xxx) (defmethod foo [::Bottom ::Bar ::Baz] :yyy) (foo [:a ::Foo :b ::Bar :c ::Foo]) (foo [:a ::Baz :b ::Bar :c ::Baz]) (not tested, though)
16:57kotarakastor: ok. doesn't work obviously. Although (isa? ::Foo ::Bottom) returns true, you has to define a dedicated multimethod.
17:05astorpolli: I seem to remember that there is some ordering magic in .emacs for swank and slime. swank-clojure sets up some functions to be called after slime is loaded, so you might get in trouble if you have slime pre-loaded.
17:06polliastor: aha!
17:07polliastor: I'll test that to disable the pre-loaded
17:09astorkotarak: my problem is that I have an unlimited number of ::Foo and ::Bar values, so the derive stuff isn't trivial. what happens when one dispatches on a map. do all elements have to match?
17:11kotarakastor: it seems so
17:13astorif there was a designated name for the supertype of everything, then that could be dispatched on, but that doesn't seem to be possible to specify using the derive interface.
17:14kotarakYou can, but you have to provide a multimethod anyway for all possible types. (derive ::Foo ::Bottom) and (defmethod foo ::Bottom ...) still complain, that there is not multimethod defined for ::Foo.
17:19astorkotarak: it shouldn't be like that if I understand the example in http://groups.google.com/group/clojure/msg/64e14b845a5e8905 correctly. there (derive java.util.Collection ::collection) implies that (defmethod foo ::collection [c] :a-collection) gets called for (foo [])
17:24kotarakastor: hmm.. you are right. There must have been something messed up. With a fresh Repl it works now. So I can derive everything from ::Bottom and can use ::Bottom as a wildcard.
17:25astorkotarak: the problem is that I have no way of saying "derive everything from ::Bottom"
17:28astorI guess hierarchies could have a list of parents that everything derives from so that isa? simply returns true whenever the second argument is in that list.
17:31danlei404 for me
17:31danleioops
17:31Chousukesome kind of an always-match value might indeed be useful for multimethods :/ Are there any arguments against having one?
17:32astorchousuke: i see that underive semantics might change slightly. are you allowed to underive from a always-match parent?
17:33rhickeyChousuke: I might bake in everything isa? Object, still thinking about it
17:36astorrhickey: my original question was how to implement something like (defmulti foo (fn [data] [(:a data) (:b data)]) (defmethod foo [:x _] :xxx) (defmethod foo [_ :y] :yyy) where _ is don't care. Basically to specify 't as in a CLOS method.
17:37rhickeyastor: I understand, and with what I am proposing you could say Object where you have _
17:37astorbut I would love to see some smart default logic when dispatching on maps. the above would be really elegant if I could express the map properties I wanted directly.
17:37astorrhickey: yes I see..
17:40Chousukehmm.
17:40ChouserI suppose allowing an pluggable alternative to "isa?" would be one step too meta?
17:43rhickeyChouser: it's tricky, as to make multimethods fast they have to have a cache, and that cache has to track changes to the hierarchy, plugging in isa? doesn't solve the cache problem
17:44Chousukemaybe it'd make sense to consider a map dispatch-val as matching if it's a subset of the map passed as a parameter. Or is that already doable? :/
17:44Chouserrhickey: ah, good point.
17:44astorcouldn't my example be solved by adding some sort of destructuring support when matching arguments to each defmethod?
17:45astoryou require that the destructuring have no "nils" for the method to be called.
17:45astordestructuring seems to be cacheable to me.
17:46astor..or maybe not.
17:46rhickeyI think the current multimethod capabilities have barely been exercised, so not inclined to enhance yet
17:48jeweldo you cache at call sites?
17:50kotarakI find it difficult to come up with a suitable dispatch method. And how to design the overall structure with derive and friends. Maybe someone can enhance the wiki with a real-world example? Or write a blog post? *hinthint* ;)
17:52rhickeyjewel: no, on the methods
17:52ChouserI need an simple concrete example of a objects with more than one "type" worth dispatching on.
17:53jewelwouldn't call site caches be more effective? is the space penalty too large?
17:54ChouserSo far my best is vehical class (car, van, truck) and vehical make (Ford, GM, Toyota)
17:54Chouserbut that's pretty lame.
17:57Lau_of_DKFunny, if I type (drop<tab>) SLIME throws a "Stack overflow exception for regex"
17:59astorrhickey: I think there needs to be a way to dispatch on Object as you mention. In CLOS, adding random aux arguments that you don't necessarily want to specify a hierarchy for is common, and you can just say 't for those in your method. another thing I haven't figured out is how to disambiguate multiple methods that can be applied. In one screencast, I hear you say that this is possible, but I haven't seen how. Something like CLOS (left-to-right) is what I
18:00Chouserastor: did you see (doc prefer-method)
18:00astorChouser: no. I will!
18:06Lau_of_DKQuestion. lets say I have a loooooong string "xyzxyzxyzxyzxyzxyz % abcabc" where I want to drop everything before % in an efficient concise way, how do I do ?
18:06danlarkinLau_of_DK: split on %
18:07kotarakLau_of_DK: hi lau, obvious idea (drop-while #(not= \% %) str)
18:07Lau_of_DKthere might be others
18:07Lau_of_DKkotarak, doesnt that just drop everything thats not % ?
18:08kotarakLau_of_DK: it drops until it encounters %
18:09Chousukethe problem is that it doesn't return a string
18:09kotarakLau_of_DK: what you mean is filter
18:09Lau_of_DKI confused remove and drop-while Mr. Kota
18:09Lau_of_DKYou were right
18:10kotarakChousuke is right however. You get a seq back, not a string.
18:10danlarkinapply str result
18:10danlarkinlook ma, no parens!
18:10Chousukeyou can perhaps use some java method to find the first occurrence of %, then make a substring.
18:11Lau_of_DKdrop-while worked like a charm, exactly what I needed
18:11Lau_of_DKThanks both of you for the inspiration
18:12kotarakLau_of_DK: eulering again?
18:12Lau_of_DKActually, I wanted to run through the Python Challenge in Clojure, just for the fun of it :)
18:14astorChouser: I don't see prefer-method as being very powerful. Thinking in CLOS-style MOP, there should be a multimethod that gets *called* when clojure gets confused and that function should disambiguate. then clojure could cache the result of that call. prefer-method seems to imply that one knows beforehand all possible argument combinations to the method, but something like left-to-right is an *algorithm* to disambiguate.
18:14kotarakLau_of_DK: Show 'em the power of Clojure. :) Have fun.
18:14Lau_of_DKThank you Mr. Kota, and thank you for all your wonderful contributions to both the wiki and clojure-euler.wiki - Its good stuff all of it
18:15kotarakLau_of_DK: thanks
18:15hiredmanthere is a clojure euler wiki?
18:16kotarakclojure-euler.wikispaces.com (out of my memory)
18:16Lau_of_DKhttp://clojure-euler.wikispaces.com
18:16hiredmannice
18:53mrsolo_how fast is clojure
18:53mrsolo_?
18:53hiredmanhow fast is the color blue?
18:54mrsolo_does it run as fast as java native code most of the time?
18:54duck1123_299792458 m/s
18:54mrsolo_without hinting?
18:54mrsolo_or 1/2 fast?
18:55ChousukeI don't lnow, what kind of code?
18:55Chousukeknow*
18:56mrsolo_any kind... just it is just a bit of generalization but i just want a ball part figure
18:56mrsolo_web has some clojure performance comparision on fib function that is about it
18:57hiredmanyou need something to compare it to
18:57hiredmansome context
18:59mrsolo_say compares to java native
18:59duck1123_Clojure is just as fast as Java except for the times when it is faster or slower
18:59mrsolo_say..ranking in greatest language shootout? <duck>
18:59hiredmanyou came to the perfect place to answer that question
19:00hiredmanobviously clojure is #1
19:00mrsolo_scala number is somewhat close to java native.. i assume clojure number is somewhat similar?
19:07duck1123_I think I remember hearing Rich saying in one of the screencasts that Clojure is almost as fast as native Java
19:07duck1123_who knows what it's like now with AOT
19:07barn_I have never pushed clojure, but speed of execution isn't the main goal for most people.
19:08duck1123_really the only diffeerence should be what you're doing
19:08kotarakCliff C from Azul posted some numbers on the group.
19:08barn_Lol
19:08barn_I don't think id being using the Azul numbers
19:08mrsolo_it is general langauge characteristic that i like to know
19:08barn_Mortals can't own those machines
19:09mrsolo_execution speed, memory footprint etc
19:10barn_It completely depends on your balance of HLL code vs java libraries
19:10barn_I code most everything still in Jython, and the code is 80-95% the speed of java
19:10barn_since all the heavy lifting is in libraries
19:11barn_But I can write code 4 - 8x faster
19:12barn_2hrs vs 8hrs, gives my computer 6 more hours of execution time
19:12barn_:)
19:12hiredmanand computer time is cheaper then people time
19:12barn_By leaps and bounds
19:12barn_I wish my mobo had 40 dimm slots
19:13barn_Side note, but I will share anyway since your captive
19:13barn_lol
19:13hiredmanmy blackberry idles all day doing nothing, and it can run some kind of stripped down java
19:14barn_I worked on a system that cost the client over 100k per instance, and I was tasked with making sure we could munge gigabytes of data in a program that had a hard limit of 512MB
19:14barn_It made absolutely no sense, we charged the client 100K for this software and we could not assume, nor mandate that they had at least 2GB of ram to work with? We could have delivered buckets of ram for no extra charge
19:15hiredmanheh
19:15barn_I had to write code using JDBM to spool intermediate results to disk and do external sorts like I was using tapes
19:15barn_It still pains me to think about it
19:16gnuvince_Do you guys have any finished projects that you wish you could do again (with Clojure possibly)?
19:17barn_I can't use clojure on a commercial project until I am productive as jython
19:19AWizzArdis there already something like apropos?
19:20billcAWizzArd: find-doc isn't the same; however, it's similar
19:22gnuvince_barn_: we're talking "wishing" :)
19:22gnuvince_When I first joined the company I work with, it was to help on a network daemon program written in PHP (yes, PHP)
19:22gnuvince_I wish I could use Clojure for that now
19:23barn_90% of the java projects I was on could have been done in Jython, and so to in Clojure
19:24barn_I tried using some of the other schemes but they didn't integrate with java well enough
19:24Chousukehm
19:24barn_Clojure is awesome in this regard
19:25ChousukeI posted a reply to a question on the group but it didn't appear immediately. Is it normal behaviour for google groups?
19:26gnuvince_barn_: yeah. I'm writing a tutorial, and it's amazing to be able to use Java libs natively
19:26AWizzArdChousuke: yes, it can appear within seconds or take one day
19:26Chousuke:/
19:26AWizzArdoften it's fast
19:27AWizzArdbut a few times I had to wait for hours
19:27AWizzArdis there a way to find out in which Clojure version I am? Like (lisp-implementation-version) or (lisp-implementation-name)?
19:28ChousukeI posted an answer to the collection containing itself -question; you can emulate with trickery: (def foo [1 2 3 #'foo])
19:59ReplRathas anybody been having trouble with swank-clojure over the last day or so? i'm trying to install it and i wonder whether it is tripping over recent Clojure check-ins. when i do (require (quote swank)) i get Unable to resolve symbol: require in this context.
20:02Chousukedo you have the most recent versions of both clojure and swank-clojure?
20:02ReplRatyeah.
20:02ReplRatis there a way to check my clojure version from the repl?
20:02Chousukeno.
20:03ChousukeThis really is a FAQ. :)
20:03ReplRati'm not great with svn but i did svn update and a new build so i'm pretty sure its new.
20:03ReplRatwhere's the FAQ?
20:04Chousukeno, I meant, your Question is a FAQ (a frequently asked question) :p
20:04ReplRatsorry
20:04ChousukeI suppose we could use a FAQ list somewhere.
20:05Chousukebut I can't say what's wrong with that. it looks like namespace trouble, but if you have the most recent revisions of everything then it should work :/
20:08Chousukeyou're trying to setup slime and clojure? or just doing something else with clojure-swank?
20:13ReplRatChousuke: just trying to set up slime and clojure.
20:13ReplRatclojure doesn't seem to know how to (require)
20:13ReplRatATM i'm trying to verify that i have the latest clojure.
20:14Chousukeyou don't need to (require 'swank) in clojure
20:14Chousukethis is what you need in your .emacs: http://en.wikibooks.org/wiki/Clojure_Programming#Emacs_.2F_Slime_Integration
20:14ReplRatit looks like that's what slime is doing though; after a (add-classpath)
20:15ReplRatok i'll read that
21:01barn_gnuvince_: I would be interested in proof reading your tutorial
21:01barn_What is it on?
21:01barn_Collections classes by chance?
21:15gnuvince_barn_: the first part is online at http://gnuvince.net
21:15gnuvince_barn_: the draft of the second part is half completed
21:16ReplRat_Chousuke: I'm pretty sure my Clojure checkout was old. Everything is OK now. Thanks for the help.
21:17barn_gnuvince_: reading it now
22:17duck1123Does anyone know what the easiest way to get the current time as an xsd:DateTime
22:18duck1123it's looking like I need to specify each segment, which leads me to believe there is an easier way