#clojure logs

2009-08-24

02:09hiredman~ping
02:09clojurebotPONG!
03:02alinphi
04:23liwp~ping
04:23clojurebotPONG!
04:28NeronusAnd clojurebot wins the game
05:30raphinouHI
05:31raphinouI'm still debugging this code: http://paste.lisp.org/display/85858
05:32raphinouhow can I know the type of the arguments passed to an object's method? (it is addListener in the pasted code)
05:36Licenser_morning everyone
05:36raphinouHI Licenser_
05:38Licenser_hi raphinou I would love to help but I'm newer to clojure then you I geuss ;)
05:38raphinou:-)
05:39raphinouno problem Licenser_ , I'm searching further
05:40Licenser_some somart person here told me using (.. is uglish it's better to use (.<function> but I don't know if that is of any relevance for you
05:41raphinouno Licenser_, the code is running actually, but it's the type of arguments passed that seem to cause problem
05:41woodzraphinou: the type function does this for you: (type "foo") --> java.lang.String
05:41raphinouI also had the advice to use (-> ) rather than (.. )
05:42raphinouwoodz: the problem is that it is not a clojure function I try to debug, but a method on a java object
05:42raphinouI'm looking at jswat, but as I'm new to the java platform I'm progressing slowly to put all pieces together
05:42_crcraphinou: A possibly useless suggestion: Can you try type hinting, the second argument to the addListener. I see that EventSignal has two addListener methods with same arity but varying types.
05:43raphinou_crc: yes, good suggestion. I'll try that!
05:43woodzAh, right. You could use Java's reflection API to get a Method object, and call getParameterTypes on that.
05:44_crcI don't know how the clojure compiler resolves overloaded method calls. I guess people that know are asleep right now :)
05:45raphinou:-)
05:45raphinouI'm not sure how I add a type hint on the proxy object. Alls type hint I find are in the definition of a function.
05:47raphinouhmm, just found (cast )
05:50Licenser_I really would love how they handle closures in clojure
05:50Licenser_insert a 'to know' in there :P
05:56tomojLicenser_: what do you mean exactly?
05:57tomoj,((let [a 2 b 3] (fn [] [a b])))
05:57clojurebot[2 3]
05:58Licenser_tomoj: I mean compiler wise
05:58tomojoh, I see. I dunno about the internals
05:58Licenser_because I've trouble with that :P it's a really tricky thing for a compiler/interpreter
06:00raphinou_crc: shouldn't I be able to cast the proxy object to the expected class ?
06:05_crcraphinou: Type hinting didn't solve the issue?
06:06raphinou_crc: can I do type hinting on a method that is defined in the java class?
06:06tomojLicenser_: a naive stack of bindings isn't sufficient?
06:06raphinouall type hinting I've found are in the definition of clojure functions
06:06Licenser_tomoj: I write on a VM/Interpreter/Compiler set since a while and closures are the thing that is most complicated for me / causes the most problems
06:07_crcwell, what i mean is something like this (.. line-edit enterPressed (addListener wapp #^Signal$Listener (proxy [Signal$Listener]....
06:07_crcI am not even sure that works. But worth a try :)
06:08raphinou_crc: I'll try. What I tried without success is (.. line-edit enterPressed (addListener wapp (cast Signal$Listener (proxy [Signal$Listener]..
06:10raphinouseems equivalent to the (cast )
06:11raphinouexact same error
06:13Chousukecast is pretty much a no-op in clojure
06:14Chousukeit just checks whether the object is treatable as whatever you're casting to.
06:15_crcraphinou: Hmm.. are you sure the first argument type is what it expects. I mean, the wapp object.
06:16Chousukehmm
06:17Chousukeyou're using .. there so it's (.addListener (.enterPressed line-edit) wapp ...)
06:17raphinouyes, the wapp is fine as I instanciate it as a WApplication, and it's inheriting from WObject
06:18_crcChousuke: The .. operator doesn't need the (.method..)
06:18raphinouChousuke: lemme check
06:19Chousuke_crc: I know, I just meant that's what it expands to
06:19Chousukeand it looks dubious
06:19Chousukedoes (.enterPressed line-edit) really have an .addListener method?
06:20Chousuke.enterPressed looks like it returns a boolean but I guess it could be returning an event :/
06:20raphinouyes
06:20_crcThe error apparently is "No matching method found: addListener for class eu.webtoolkit.jwt.EventSignal"
06:20raphinouenterpressed returns an SignalEven which such a method
06:21ChousukeClojure REALLY should print the parameter types with that exception ;(
06:22_crcChousuke: I agree.
06:22_crcraphinou: Are you working on trunk?
06:22raphinouI did a checkout last week and compiled it
06:23raphinouI didn't look further which version resulted in compiled form
06:46Licenser_The expetions really give very very little helpfull information
06:46Licenser_It does not even tell you where they occur :/
06:51tomojin slime you get a backtrace
06:52tomojand you can get a backtrace other ways too but I don't know how
06:54Licenser_slime is that emacs thingy?
06:57tomojyeah
07:27ole3test
08:02alinphi
08:02alinpis there a foldr in clojure ?
08:02alinpreduce has foldl functionality, at least this is what I noticed
08:03Neronusalinp: I don't think so, as sequences are possibly infinite
08:04alinpok, in this case it seems ok
08:04ChouserI don't think there's a foldr, though you could use 'reverse;
08:04alinpthanks
08:04alinpthat should do the trick :)
08:04Chouseror if you're working on a vector, maybe rseq
08:06alinprseq is not returning a lazy seq
08:06alinpright ?
08:06alinpat least this is what the doc says
08:06Chouserit probably is, but it's over a non-lazy thing like a vector or map
08:06alinp,(doc rseq)
08:06clojurebot"([rev]); Returns, in constant time, a seq of the items in rev (which can be a vector or sorted-map), in reverse order. If rev is empty returns nil"
08:06alinpyeah, indeed
08:07alinpmy q had no point, sorry :)
08:08Chouserso it's a seq but, right, calling it lazy doesn't mean much even if its true.
08:09rhickeyChouser: which patch files do I need to apply to test chunked for/concat? could you paste the timing code you were running?
08:10Chouserchunked-concat.diff and chunked-for.diff
08:13ChouserTo test the timing I kept the old definition of 'for' as 'for1'
08:18rhickeyChouser: what code had a 2x variance?
08:20Chouserthat's on the other computer. gimme a minute...
08:22rhickeyChouser: don't worry about it - I've got it running now here
08:22rhickeythe 2x diff has to do with whether or not you get a gc during the run I think
08:23Chouserok. the variance was not between the two versions, it was the same version on subsequent runs.
08:23Chouseryeah, ok
08:23tomojis chunking what causes this?:
08:23tomoj,(dorun (take 4 (map println (range 10))))
08:23clojurebot0 1 2 3 4 5 6 7 8 9
08:24tomojseems to go over in increments of 32
08:25rhickeytomoj: ?
08:25tomoj(e.g. if you do that taking 4 and (range 100), it prints 0-31, while if you take 33, it prints 0-63
08:27rhickeytomoj: yes
08:27Chouser(time (into [] (for1 [a (range 1e6) :when (odd? a)] a)))
08:28ChouserI was doing "into []" in an attempt to get a chunked consumer (unlike doall or last)
08:29rhickeyreduce is a chunked consumer too
08:29Chouserah, of course.
08:30tomojso due to chunking is it generally bad to have lazy seqs which cause side-effets on consumption?
08:30Chouseryeah, that's more stable.
08:31Chousertomoj: if your lazy seq isn't chunked, nothing should have changed.
08:32tomojah, but range for example generates a chunked seq, then?
08:32Chousertomoj: the "problem" with your example is having a side effect in 'map', which has never been recommended.
08:32rhickeytomoj: there will be a seq1 (name TBD) which will force non-chunked seqing of a possibly-chunked seq
08:32tomojthat's what I told the person asking about this the other day, I recommended doseq instead
08:32tomojbut then I saw it in ants.clj
08:33Chousertomoj: exactly. doseq also does chunking now, but if you guard a loop with :while then your body will not be called when it shouldn't.
08:33rhickeytomoj: you saw the chunked side effect problem or just map of side-effecting fn?
08:33tomojjust a map of side-effecting fn
08:34tomojno chunking problem I believe
08:34tomojnah, cus the send-off needs to go to all ants anyway
08:38Chousukehmm, why doesn't the clojure dev group have the lambda picture as its logo? :(
08:52lisppaste8raphinou_ annotated #85858 "untitled" at http://paste.lisp.org/display/85858#1
08:52raphinouit seems the wrong addListener method is called (same arity, different signature)
08:53raphinouany idea how I can tell that I want the other one to be run?
09:01lisppaste8Chouser pasted "'for' timings" at http://paste.lisp.org/display/85959
09:02Chouserso I guess the new 'range' cost a bit, but allows for better optimizations down the chain.
09:08Chousukegah.
09:09ChousukeI was wondering why paredit behaved weirdly. then I noticed it was using an old version I had accidentally installed with elpa :P
09:09clojurebothttp://clojure.org/rationale
09:35Chousukehm, neat.
09:36Chousukethe next milestone for my reader was to read core.clj without exceptions. Turns out it already can :P
09:37ChousukeI doubt evaling things is going to go so well, though :/
09:40LauJensenOh my. Did the previous discussion on chunks mean that when I call (take n coll) I cant count on getting n items back ?
09:40ChouserLauJensen: nope, nothing of the sort
09:41LauJensenphew - Got a little scared there for a bit
09:54Chousercould range provide a sort of lazy chunk?
09:55Chouseroverride .nth to do the math on demand rather than allocate an array?
09:56Chousukehm
09:56weissjwhat's the easiest way to iterate thru a list of function symbols, and call each one with the same arg?
09:57weissj,(for [myfn '(inc dec)] (println (myfn 1)))
09:57clojurebot(nil nil)
09:57weissj,(for [myfn '(inc dec)] (myfn 1))
09:57clojurebot(nil nil)
09:57ChousukeI got as far as evaling the first 109 top-level forms of clojure.core
09:57rhickeyChouser: chunk consumers need the chunk size in order to allocate their own chunks
09:57Chouser,(map #((resolve %) 5) '(inc dec))
09:57clojurebot(6 4)
09:57Chousukeit breaks on / :)
09:57ChouserChousuke: not bad!
09:57Chousukewhich is not surprising at all, considering my symbol parsing is rather primitive still.
09:57Chouserrhickey: sure, it would still be Chunks of size 32, but instead of ArrayChunks they'd be RangeChunks
09:59Chousukenow my problem is that the error message is not very helpful :/
09:59rhickeyChouser: ah, so not really about laziness, just 'virtual', sure
09:59Chouserright, just for performance
10:00rhickeyI thought you wanted to solve tomoj's chunked laziness granularity problem
10:00Chouserah, no. that's not a problem. :-)
10:00Chousukeit simply says "Can't refer to qualified var that doesn't exist"
10:00fdaoudhi all
10:00rhickeyactually, it is a problem, and a tricky one, not for side effects but for expensive calculations
10:00Chousukeand while I suspect / is the problem, I'm not sure what's wrong with it
10:01fdaoudhey, there is the Clojure elite here!
10:02Chouserfdaoud: welcome
10:03fdaoudthanks Chouser....congrats rhickey and all for Clojure. I'm reading Stu's book. Very cool stuff.
10:04fdaoudI've been interested in functional programming for years, but Clojure is the first time I see it all come together
10:06ChouserI just wanted macros and libraries, but rhickey foisted all this immutable stuff on me.
10:06rhickey:)
10:07fdaoudNow if I can integrate Clojure with Stripes, I'll be all set :)
10:16Chousukehmm
10:17Chousuke,(map namespace ['foo (symbol "foo")]); curious behaviour
10:17clojurebot(nil nil)
10:17Chousukehuh. I get "" for the second case
10:17Chousukehmm...
10:18Chousukeno wait, got confused
10:19Chousuke,(map namespace ['/ (symbol "/")]); this is when it happens for me :/
10:19clojurebot(nil "")
10:21Chousuke~def symbol
10:22Chouser,(range 1/2 5 1)
10:22clojurebot(1/2 3/2 5/2 7/2 9/2)
10:22Chouser,(range 1/2 5)
10:22clojurebot(1/2 3/2 5/2 7/2 9/2)
10:22Chousukelooks like a bug in Symbol/intern
10:22Chouserhm. In clojure 1.0 the latter gives (0 1 2 3 4)
10:23Chousukeif the name contains a /, it does "return new Symbol(nsname.substring(0, i).intern(), nsname.substring(i + 1).intern()"
10:24Chousukewhich means the namespace will become "" instead of nil
10:45raphinouI'm lost here: I have a java object with the method addListener. Arity of addListener is 2, and it has 2 definitions differing by the type of its arguments. It seems the wrong one is called and I get an IllegalArgumentException....
10:46raphinouis there a way to specify the method to be used?
10:46raphinouthe second argument is a proxy object, which can not be casted to the type expected by the method
10:50Chouserraphinou: I looked at your paste briefly, but didn't see what could be causing your problem.
10:51Chouserproxy self-hints with the class you're extending, Signal$Listener
10:51raphinouChouser: I think the code is fine, but the way the java method to run is chosen is picking the wrong one. Ha, ok for the self-hint. I didn't know that
10:52Chouserfrom your stack frame it lokos like it's found the right class for wapp, jwt.EventSignal
10:53Chouseroh, wait -- where's your WObject?
10:53raphinouit's the wapp
10:53Chouseroh, right ..
10:54Chouserraphinou: I'm shooting in the dark here, but you might try turning on reflection warnings first, and make sure you're getting the call resolved at compile time.
10:54Chouserthat sometimes helps bring out the real issue.
10:55raphinouhmm, I read something about reflection warnings this morning. Will try to find it back. Thx for the hint, I'll try that
10:55Chouser(set! *warn-on-reflection* true)
10:55raphinouha, thx :-)
10:56Chouserinsert that before the top level form that contains your erroring call
10:56Chouserthe re-load or re-eval or re-compile or whatever you're doing
10:56Chouserthen
10:56raphinoucall to addListener can't be resolved!
10:56raphinouyou're righ Chouser
10:56Chouserok, not exactly shocking, but not an error in itself
10:57ChouserI guess try hinting the wobj?
10:57raphinouok, I'll try that
10:57Chouserer, wapp
10:58Chouseris that the only reflection warning, or are there others, like for enterPressed?
10:58Chousuke~def mexpand-all
10:59raphinouChouser: only warning, and type hint or cast do not resolve it
11:00Chousukehmmhm
11:00Chouserdoesn't resolve the warning or the runtime error?
11:01raphinouboth
11:02carkraphinou : you're still stuck at the same point ?
11:02raphinouyes cark
11:02cark=(
11:03Chouserok, so try (addListener #^WObject wapp #^Signal$Listener (proxy ...))
11:04Chouserthe latter hint shouldn't be necessary, so I don't actually expect that to fix it.
11:04Chouserif it doesn't, it might be time to unpack that .. so we can see what's going on.
11:05Chouser(let [sig (.enterPressed line-edit)] (.addListener #^EventSignal sig #^WObject wapp (proxy ...))
11:06Chouserthat let form really should not produce any reflection warnings.
11:06raphinouok
11:07Chouserrhickey: why does IChunk have a reduce? Does it really perform that much better than having the reduce fn do a general loop on each chunk?
11:11raphinousame problem with type hints. chouser, you want me to put the let in the code of the app, that's it?
11:12Chouseryeah, using that 'let' instead of your .. form ought to remove any reflection warning from that line.
11:12Chouseryou're saying it still generates a reflection warning?
11:12Chouserfor addListener?
11:12rhickeyChouser: I don't recall, but I presume so, else I thought many would be writing that same loop over and over, or tempted to call reduce itself in their chunk fns
11:13raphinouboth warning and exception are still there Chouser
11:13Chouseryeah. writing my first IChunk implementation here and I've got a bug in my reduce. :-P
11:14Chouserraphinou: bleh. try the hint on 'proxy' too then? If it still fails I'd start to doubt the javadocs
11:17lisppaste8raphinou_ annotated #85858 "let to remove reflection warning" at http://paste.lisp.org/display/85858#2
11:17raphinouI posted the let as I still get the warning :(
11:18raphinouI hope I'm not doing something stupid and wasting your time....
11:20Chouserdo you have clojure-contrib handy? repl-utils?
11:21Chouser(show EventSignal "addListener")
11:21raphinouclujure-contrib yes
11:22raphinourepl-utils I don't know
11:22Chouserjust try that 'show' at the repl and see if it lists the addListener method you're trying to call
11:22Chouser(use 'clojure.contrib.repl-utils)
11:22raphinouhem, ok, just found out..
11:24lisppaste8raphinou_ annotated #85858 "show EventSignal addListener" at http://paste.lisp.org/display/85858#3
11:24Chouser...and there's the problem
11:24Chouseroh
11:24Chouserwait
11:24Chouserbah
11:24Chouser(show EventSignal 0)
11:26carkmhh i should be using repl-utils more
11:26lisppaste8raphinou_ annotated #85858 "show EventSignal 0" at http://paste.lisp.org/display/85858#4
11:28krumholtcan someone help me understand what happens when i do ('+ 1 2) why does a symbol take arguments?
11:28Chouserok, I'm completely stumped. I don't see how that method can exist and yet your call to it fails to resolve.
11:29raphinou:(
11:29Chouserkrumholt: symbols look themselves up in a map when called.
11:29Chouser,('+ {'foo 1, 'bar 2, '+ 3})
11:29clojurebot3
11:30Chouserjust like keywords do. A second arg is allowed for when the key is not found.
11:30Chouser,('+ {'foo 1, 'bar 2, '+ 3} :default-something)
11:30clojurebot3
11:30Chouser,('+ {'foo 1, 'bar 2} :default-something)
11:30clojurebot:default-something
11:32cgrandraphinou: try putting the proxy in a local and still fully hint the addListener call
11:33raphinouok, trying
11:33krumholtChouser, so the first argument to a symbol is a map to lookup its value and the second is the default value?
11:33Chouserkrumholt: right. if the first arg is not a map, it returns the second arg or nil
11:33Chouser,('+ 5)
11:33clojurebotnil
11:35krumholtChouser, ok thanks. i just stumbled upon this and wanted to understand it.
11:35Chouserkrumholt: keywords act the same, and that pattern is rather more common
11:35raphinoucgrand: I get a class cast exception:
11:35raphinouclojure.proxy.java.lang.Object$Listener cannot be cast to eu.webtoolkit.jwt.Signal$Listener
11:36cgrandpaste?
11:36raphinoucoming
11:37lisppaste8raphinou_ annotated #85858 "class cast exception" at http://paste.lisp.org/display/85858#5
11:38raphinoubut warning has disappeared
11:39cgrandmy guess that the warning was caused by macroexpansion eating the type hint on proxy
11:39clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
11:40Chouserbut the ClassCastException doesn't make any sense, does it?
11:40carklooks like a bug to me
11:41cgrandno :-(
11:42raphinouwould anyone be interested in a tarball with my code and all jars it depends on? It's about 8Mb. I can easily put it online
11:43Chouserraphinou: yeah
11:43raphinouok, it's coming!
11:43carkmaybe proxy doesn't know how to handle nested interfaces ?
11:44Chouserthis is how the Greeks defeated Troy.
11:47Chousercark: I was wondering the same thing, but I guess it's not that simple. This looks ok: (supers (class (proxy [Object javax.swing.text.AttributeSet$ColorAttribute] [])))
11:48Chousukehmm
11:48ChousukeIt looks like my reader can read clojure.core, but there are other problems with it
11:48Chousukeredefining clojure.core on the fly causes slime to barf, for example :P
11:49Chousukeafter it gets to the point where it redefines print-method, something happens and *boom*
11:51raphinouokn the tarball is at http://www.raphinou.com/rb.tar.bz2
11:51raphinouI put a README in it to say how I run it
11:55Chousershould I get that ClassCastException?
11:58raphinouyes Chouser
12:00lisppaste8Chouser annotated #85858 "no error for me?" at http://paste.lisp.org/display/85858#6
12:01raphinouI get the error when requesting page at http://localhost:8080
12:02raphinouit prints my user agent, and the I have the exception printed
12:02Chouserah, ok, I got it.
12:12cgrandcould it be a classloader mess? two Signal$Listener classes loaded by two classloaders? (shooting in the dark)
12:13raphinouthis is beyond my java knowledge, I have no idea
12:13clojurebotthis is not a bug
12:22rhickeyclojure.proxy.java.lang.Object$Listener looks funky
12:23cgrandraphinou: wow, your listener effectively implements Signal1$Listener and not Signal1$Listener: I think proxy caching got confused
12:23cgrand"and not Signal$Listener"
12:23raphinouok
12:23Chousukehmmh
12:24ChouserSignal$Listener inherits only from SignalImpl$Listener
12:24Chousukeapparently it's not possible to redef clojure.core in its entirety by reading and evaling the file. :/
12:24Chouserbut the generated proxy class inherits from #{eu.webtoolkit.jwt.SignalImpl$Listener eu.webtoolkit.jwt.Signal1$Listener clojure.lang.IProxy java.lang.Object}
12:24Chousukethe repl barfs when you redef print-method
12:25rhickeyChousuke: yes, could you please submit an issue for that?
12:26rhickeyChouser: you can go ahead with chunked concat/for
12:27Chousukeokay. I'm using my own reader here though
12:27Chouserwhere do SignalImpl$Listener and Signal1$Listener come from?
12:27Chousukebut I suppose the problem is with eval
12:27Chouserrhickey: ok, thanks.
12:27rhickeyChousuke: try clojure's same prob
12:27cgrandHere is the culprit:
12:27cgrandbe.nsa.server=> (proxy-name Object [Signal$Listener])
12:27cgrand"clojure.proxy.java.lang.Object$Listener"
12:27cgrandbe.nsa.server=> (proxy-name Object [Signal1$Listener])
12:27cgrand"clojure.proxy.java.lang.Object$Listener"
12:27Chousercgrand: ah, nice.
12:28cgrandso the second call to proxy retieves a cached class
12:28raphinouwow, good catch
12:29Chouseris there a limit on class name length? seems like proxy-name should include (and/or hash) the full package name of all implemented interfaces too
12:30Chouserdoes newnew use something similar?
12:30raphinouok, so the problem happens if multiple nested interfaces have the same name?
12:30cgrandand should escape $ too
12:31rhickeycgrand: $ is an ok name component
12:33raphinouif I only define the second listener, and only import Signal$Listener, I still have the same problem
12:33cgrandI meant: if we are going to include full names, we should escape the $ characters in the full names to prevent collisions on pathological worst cases
12:34rhickeyI think we should just use lastIndexOf '.' instead of getSimpleName
12:35NeronusChouser: Class name lenghts have to fit into CONSTANT_Utf8_info in the constant pool. And the maximum length of such an entry is 2^16
12:35NeronusClass names have to fit into that entry, not their lengths
12:36cgrandif one uses two frameworks which each defines a Listener interface, proxy would still confuse them since it wouldn't include the package
12:36rhickeythis is another why '.' as nested class separator is weak, and why the $ is used for the real JVM name
12:37rhickeycgrand: true, but I'd rather append the hash of full names than have a giant name
12:38cgrandrhickey: ok
12:50weissjdoes clojure have a facebook page? (like scala's here http://www.facebook.com/pages/Scala/62722535767?ref=mf )
12:51weissjwould be nice if i could make myself a 'fan of' clojure for my programmer friends to see
12:52drewrthere's a "Finding Clojure" group
12:52drewrand now there's apparently a "Clojure" group
12:52weissjdrewr: yeah i saw that. but groups don't work the same as company/famousperson pages
12:55Chousukerhickey: I created a ticket for the repl issue. I also created one for (namespace (symbol "/")) returning "" instead of nil (with patch)
13:07cgrandraphinou: in the mean time, you could work around by specifying a second useless interface (just to generate another name)
13:17raphinoucgrand: in java you mean?
13:17raphinouis there a ticket for this issue btw, so I can follow it and try again.
13:19cgrandraphinou: eg replace (proxy [Signal$Listener] by (proxy [Signal$Listener Comparable] it should work
13:19raphinouho, I see
13:20raphinoubut how comes the same problem arises when I import and define only the Signal$Listener ?
13:21raphinouit works by specifying a second interface. thx!
13:21raphinouand thx everyone who looked at this problem!
13:22raphinouhmm, it worked when adding the second interface when I had the first listener commented....
13:23cgrandwhich first listener? (proxy [Signal1$Listener] ?
13:24raphinou(.. (WPushButton. "Greet me" root) clicked (addListener....
13:25raphinouhmm, wait, checking I'm working on the right version....
13:30raphinouok, it's working fine now...
13:30raphinouright on time, I need to go. bye!
13:31cgrandrhickey: should I open a ticket for the proxy-name bug?
13:33rhickeycgrand: sure
13:33rhickeythanks
13:43devinusi keep hearing people say that clojure has no objects
13:43devinusbut other people saying that's BS
13:43devinuswhich one is it?
13:43devinusi'm assuming "objects" are just represented entirely different than in your standard OO language
13:43Neronus,(Object.)
13:43clojurebot#<Object java.lang.Object@e62f6>
13:44Neronusthere you go :)
13:44LauJensendevinus: Read "Object Orientation is overrated" http://clojure.org/rationale
13:45NeronusWhile there are objects (everything is a java object, except the primitives), there is no need to think of objects except when doing java interop
13:46fdaoudHi all. Does anyone know how to have a context path in compojure? I can't seem to find the info. The examples I find all have the app deployed under the root path.
13:47Chousukegah.
13:47ChousukeAssembla sent me some mail and apparently it triggers a bug in Mail...
14:00arbschtfdaoud: you can associate servlets to non-root request paths in run-server, if I understand you correctly. also, git HEAD has `with-context', which trims context prefixes from the request
14:00arbschtfdaoud: pop into #compojure to discuss it further if you want :)
14:00fdaoudarbscht: thanks for the info! I didn't realize compojure had its own channel :)
14:18rhickeycgrand: your master still contains Arrays.copyOf calls
14:29jensliHi all!
14:29jensliCan anyone recomand a book? Programming Clojure or The Definitive Guide to Clojure?
14:29jensliMaybe the latter isnt out yet...
14:30cgrand1it should be in print at the end of year
14:31Chouserright now the definitive guide is Programming Clojure. :-)
14:32LauJensenWho's writing 'the definitive guide' ?
14:33ChouserLauJensen: http://www.www.friendsofed.com/book/view/9781430272311
14:34LauJensenLuke Vanderhart, never heard of him
14:34Chouserhe's posted to the group a couple times
14:35LauJensenWhat makes this book 'definity' and programming clojure, not ?
14:35LauJensen(since he's saying its the first)
14:35hiredmanstill haven't finished programming clojure
14:35hiredmanLauJensen: it's bigger?
14:35LauJensenoh thats right, he's american :)
14:36jensliMore pages but less weight!
14:36jensliIn Defeniteve guide
14:36ChouserI guess "a few" is understating it a bit. google say 45 posts.
14:37ChouserHe apparently works with the DC study group
14:37LauJensenI feel a soap coming on "Chouser Chen - Internet stalker"
14:38jensliThis language running amok? Soon someone unheard of is going to release 2.0.
14:41LauJensenjensli: Why do you think so ?
14:41hiredmanwhat?
14:41hiredman~what?
14:41clojurebotdo you ? what is the benefit of lazy sequences
14:43jensliSomeone you havent hear of released the Definitive guide, it might go on in that way...
14:44LauJensenDont worry, Chouser has got it covered
14:45NeronusOr clojure for dummies
14:48jensli*** will that write "A brutal intro to clojure"
14:49jensliHow does dynamic typing affect the possibility of IDE support?
14:49jensliWould it be possible to write a good rename tool for clojure?
14:49jensliFor example...
14:50rhickeyjensli: IntelliJ Clojure plugin does good renaming already
14:52jensliAllright, has to try that, have only played with it in eclipse, it rather spartan.
14:53technomancyit should be doable on top of slime's xref functionality, but afaik nobody's hooked it up
14:55drewrtechnomancy: I finally got swank loaded inside a persistent, non-repl jvm process
14:58drewrhttp://github.com/drewr/clot/commit/902272d69133e88b28147407e089733292511af8#L2L11
14:58technomancydrewr: slick!
14:59drewrswank really wants to be run from a repl, so you have to fake it
14:59drewrthe repl stuff in clojure.main made it very easy -- thanks to whoever did that (scgilardi?)
15:35weissjanyone have any advice on how to get my repl to re-load java classes i'm developing without having to restart the jvm?
15:37Chousergenerally the jvm doesn't allow loading a new definition for an existing class
15:38Chouserclojure lets you redefine any namespace, function, or proxy, though. You really need to reload a named Java class?
15:38weissjChouser: hm ok, i had a feeling that wasn't possible (or easy at least). It's just clojure code that easy to change and debug in the same repl
15:38Chouserthese are classes written in .java?
15:38weissjChouser: yeah, my project here is basically a scripting environment for java classes
15:39weissjthe script i can debug and update in the same repl, but if i have to change a java class,i have to restart the repl
15:39hiredman~google java rebel
15:39clojurebotFirst, out of 174000 results is:
15:39Chouserhttp://www.zeroturnaround.com/javarebel/
15:39clojurebotJavaRebel | ZeroTurnaround.com
15:39clojurebothttp://www.zeroturnaround.com/javarebel/
15:39hiredmannice
15:39Chouseryeah. you could try that, though I've not heard any reports of people using it with clojure
15:40weissjcool, i'm going to try that out
15:41weissjoh. hm, it's not really free
15:53Chouserrhickey: newnew doesn't currently try to create stable classnames, but will that change to support AOT?
15:56Chouserstable nor package qualified.
15:57Licenser__out of couriosity, what is newnew?
15:58ChouserLicenser__: I wrote a little about what it's for here: http://blog.n01se.net/?p=41
15:58Licenser__*reads*
15:59ChouserLicenser__: there's also a link there to rhickey's notes on the subject. There's also a branch "new" in the github repo with the work in progress.
15:59Licenser__ah okay new is a branch :)
16:01Licenser__hmm don't you have the hen egg problem when implementing a language in itself?
16:01Licenser__You will need a working implementation to implement it right?
16:01Chousersure, but we already have one. The hen, probably.
16:01Licenser__But it would mean when somethign changes to change it twice, for the hen and for the egg that gives a new hen :P
16:02Chouseryep. standard compiler procedure.
16:04danleiLicenser__: you could always hand-compile (theoretically)
16:04Licenser__Chouser: hmm didn't knew that :) I'm quite new to compiler building :P
16:05hiredmanwhee
16:05ChouserLicenser__: the "normal" way to build gcc, for example, is to compile a minimal gcc using whatever c compiler you have handy.
16:05Licenser__ah I didn't knew that :)
16:05Licenser__I learn a lot here it seems
16:05hiredmanthe gcc build happens in stages, I believe
16:05Licenser__hmm clojurescript is very interesting too
16:05hiredmanthe last stage is to compile gcc with gcc
16:05ChouserLicenser__: that minimal compiler uses only the most widely supported C features so it's likely to work with your OS vendor's own compiler, or whatever.
16:07Chouseryou go through two or three stages of using the previously built compiler to build a more featureful compiler needed for the next stage.
16:07Licenser__ah
16:07Licenser_I like this idea, it sounds very cool
16:07hiredmanhttp://gcc.gnu.org/wiki/Top-Level_Bootstrap
16:07Licenser_clojure-in-clojure
16:08Chouseryou go through two or three stages of using the previously built compiler to build a more featureful compiler needed for the next stage.
16:08Licenser_You people are smartish :P
16:08Chouserer
16:08Chouseryou go through two or three stages of using the previously built compiler to build a more featureful compiler needed for the next stage.
16:08Licenser_^^
16:08Chouserbah
16:08Licenser_You like to say that don't you?
16:08Chouserby the end you can have a gcc that was built from C source using all of gcc's own extensions and with gcc's most advanced optimizations.
16:08Chousersorry
16:08Licenser_:P just teasing
16:09Licenser_makes kind of sense, oddly enough
16:09Chouseranyway, clojure-in-clojure isn't likely to be quite that extreme. For one, the .class files are already portable to anywhere that has a JVM, so you wouldn't generally need to distribute the original .java
16:10danleifirst lisp was hand-compiled by steve russel, btw
16:10hiredmanwow
16:10hiredmanhand compiled from lisp?
16:10danleiyes
16:11hiredmanI guess it bust have been
16:11hiredmanjeez
16:11Licenser_I like to compile things myself, and I think distributins like gentoo would not be happy to only get .class
16:11Licenser_He had a lot of time and was very boored?
16:11danleihe took mccarthys "universal LISP function" and translated the whole thing by hand
16:11NeronusFWIW "LISP in small pieces" is probably enough to get one started (though I still have to read it :))
16:11technomancylisp was a lot smaller back then. =)
16:11technomancyand he was a grad student
16:11ChouserLicenser_: I'm sure we'll keep the .java version around, and probably not just in the github history
16:11hiredmanjust have a shellscript that emits jvm bytecode
16:11danlei(mccarthy actually didn't even WANT that :)
16:13ChousukeI think it might be good to ship at least one version of Clojure with both the Java bits and the c-in-c bits whenever we get to that stage.
16:14Chousukethen it could be used to bootstrap itself, and the java bits could be dropped from the next version, requiring a previous version to compile.
16:14Licenser_makes sense
16:14Licenser_I like clojure, I really like it i must say =)
16:16hiredmanI was kind if thinking, you could do a stripped down sort of stage one lisp, where the reading and compiler used java.util.* datastructures and then bootstrap clojure with that
16:16Chousukeor the java bits could be kept in, but moved out of the main namespace into clojure.bootstrap or something.
16:17ChousukeBut I think first we need the actual c-in-c compiler :P
16:18Licenser_heh
16:18Licenser_yes that might be tricky
16:19ChousukeI should just get my reader to a state where I can introduce it to people ;(
16:20Chousukestill missing unicode escapes...
16:20danleiChousuke: where is it?
16:20hiredmanthe whole bootstrapping thing makes my head spin when I try to think about it
16:21Chousukealso eval'ing clojure.core hit a roadblock with ns. apparently you can't redef "ns" in any namespace.
16:21hiredmanclojure needs to have it's datastructures availble for clojure code to be read, but if the datastructures are written in clojure…
16:21Chousukehiredman: heh.
16:21hiredman*brain hurt*
16:22danleiChousuke: you have the source of your reader online?
16:22Chousukehiredman: that's why you use an earlier compiler to compile the data structures first, and then recompile with the resulting compiler :P
16:22Chousukedanlei: yeah. http://www2.sandbox.google.com/search?q=clojure-reader
16:23Chousukeoops
16:23Chousukewrong url.
16:23Chousukehttp://github.com/Chousuke/clojure/commits/clojure-reader
16:23danleiChousuke: thanks
16:23Chousukenot documented, optimised or organised in any way :P
16:24danleithat's ok, I'm just interested and wanted to take a look
16:26ChousukeI guess I should put some helper function in there to produce the reader input data structure from a string, for people who want to play with it.
16:26danleigithub is slow as hell for me atm :|
16:30Chousukedanlei: I pushed a helper function in there. should make it easier to play with.
16:32LauJensendanlei: Guess why people are moving to Gitorious
16:33ChousukeThe Github people did blog about the slowness some time ago, didn't they?
16:33Chousukeapparently they're working on it :/
16:33technomancywe should at least have an auto-updating mirror on gitorious for the downtime/slowtime
16:33LauJensenI mailed them about it Chousuke, says they've been working on a fix since april, expect something big to happen "soon"
16:38danleiChousuke: thanks
16:45technomancyI'll set up auto-pushes later: http://gitorious.org/clojure/clojure/trees/master
16:45technomancyfor now it has master, 1.0.x, and new branches
16:52danleihm, there was some feature like CL's * ** *** (result of last evaluations) in clojure, wasn't it?
16:53Chouser*1 *2
16:53danleiaaah, thanks
16:54Chousuketechnomancy: why don't you just push all the branches as they are from github to gitorious? :/
16:55technomancyChousuke: only because I just haven't got a chance to look into automating it yet
16:56ankouhi is there a function which checks if an item is contained in a list?
16:57hiredman,(.contains '(1 2 3) 2)
16:57clojurebottrue
16:57hiredman,((set '(1 2 3)) 2)
16:57clojurebot2
16:57hiredman,((set '(1 2 3)) 4)
16:57clojurebotnil
16:57hiredman~def set
17:00hiredmanhmmm
17:00danleiChousuke: after a first glance, I find it really nice :)
17:01Chousukedanlei: I tried to keep it that way. If it hadn't been fun to write I don't think I would've gotten this far :P
17:01danleiChousuke: but I see you hardcoded the dispatch table, is that subject to change; will you expose the table to allow prefix-dispatch chars definition by the users?
17:02Chouserdanlei: not if he wants rhickey to accept it
17:03danleiI mean, it's all there :) just add a char and define a method on a char
17:03danleiChouser: I see
17:03danleibut it'd be trivial to do so
17:03Chousukeyeah, it would.
17:03danleiI understand rich's sentiments
17:03danleireader macros tend to be ugly
17:04Chouseryes. also pretty simple to open up clojure's current reader to user defined reader macros
17:04danleiand clojure already has a lot of handy reader extensions
17:04ChousukeI just decided to emulate clojure behaviour for now.
17:04Chouserbut once its available to users, it would be very hard to change or take away
17:04danleianyway, nice piece of work, as far as I can tell (not trivial, just my first impression)
17:05danleiChouser: yes, that's right
17:05ChousukeI won't be too disappointed if that reader ends up getting rewritten though.
17:06Chousukeit's still got many pieces that should be useful in any clojure reader implementation.
17:06danleisure, I'll dive in a bit more, when I've got the time to do so
17:06ankouokay and is there another (maybe faster) way to check if there is any element in a list which satisfied a given predicate then just checking the size of the result of filter?
17:07technomancy(doc any?)
17:07clojurebotTitim gan éirí ort.
17:07technomancy,(doc any?)
17:07clojurebotTitim gan éirí ort.
17:07technomancy... =(
17:07hiredman,(doc some)
17:07clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return true if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
17:08Chousukedanlei: just be aware that it's still missing some bits. like unicode escapes :P
17:08danleiChousuke: not a problem.
17:09Chousukeand #! and #_... hmm.
17:09Chousukethose ought to be trivial to implement though
17:09danleiwell, #_ shouldn't be hard, what's #! again?
17:09Chousukeit's basically a comment too.
17:09Chouser#!/bin/clojure
17:09danleiah, ok
17:09danleifor scripting, I see
17:10Chousukethey're so easy I just haven't bothered writing support for them :D
17:10danlei:)
17:10hiredmanbut I don't have a ca in
17:12Chouserhiredman: is that on purpose?
17:12hiredmanno, I just hate mailing stuff
17:12danleiyou're not alone :)
17:15hiredmanI think I have the ca sitting on my desk at home (I definitely did before I cleaned up last weekend)
17:26Chousukehmm.
17:26Chousukenow there is support for #! and #_ (though #_ probably could be smarter)
17:26Chousukeas it is, #_ actually reads the following form and then drops it...
17:28danleiyes, I see, creates an anonymous function without a body and calls it
17:29hiredmaneh?
17:29Chousukeit does have a body, I used the function to avoid holding on to the old rh when consuming the ignored form
17:30Chousuke... though that may not help as my other consume methods are not as careful :)
17:30Chousukebut I intend to fix that.
17:32Chousuke,#_#=(clojure.core/println "foo")
17:32clojurebotEOF while reading
17:32Chousukehm
17:32Chousuke,#_#=(clojure.core/println "foo")'a
17:32clojurebota
17:32clojurebotfoo
17:40danleiah, misread that
17:47ankouthe documentation talks about the read table as an extension system, so how can I access the read table?
17:48hiredmanuh, what?
17:48hiredmanwhich docs?
17:48Chousukeankou: the read table is not accessible to users.
17:48hiredmanrhickey specificly does not allow access to the read table
17:49ankouThe behavior of the reader is driven by a combination of built-in constructs and an extension system called the read table.
17:49Chousukeyeah, but that extension system is only modifiable by the implementors.
17:50Chousukeit's that way because no-one has yet come up with an acceptable solution for conflicting reader macros.
17:51hiredmanankou: there are many threads on the google group that discuss this
17:51ankouokay
17:52ankouis it possible to include clojure as a library in any java program to use clojure as a scripting language for that program?
17:52hiredmansure
17:53hiredmanI don't think there are any frame works to do it, but it should be relatively simple to setup
17:54hiredmanyou just initialize the clojure runtime, and fire it up
17:55ankouis there any documentation how to do that from java?
17:57hiredmanhttp://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java
17:58ankougreat, thanks
18:29danleihow can I access a non-public var from another namespace?
18:30hiredman:/
18:30danleinot at all?
18:30hiredmanthere are ways
18:31danleifor example?
18:31hiredmanI forget
18:31danleiok, but nothing like foo::bar I guess?
18:31hiredmansome kind of mix of various reader macros
18:31danleiok, ty
18:31cemerick#'other.namespace/foo will get you the var, regardless of its :public metadata
18:32hiredman#'clojure.core/throw-if
18:32hiredman,#'clojure.core/throw-if
18:32clojurebot#'clojure.core/throw-if
18:32hiredman,@#'clojure.core/throw-if
18:32clojurebot#<core$throw_if__5764 clojure.core$throw_if__5764@16909e0>
18:33danleithanks!
23:20JAS415I have a question about mapping
23:20hiredmanthe map function?
23:20JAS415it seems that whenever I do a map operation rather than just evaluating the head of the sequence, it will evaluate an arbitrary number off of the head
23:20JAS415yeah
23:21hiredmanuh
23:21JAS415so i'm doing mapcat on a function that does an api request to get a lazy seq of requests
23:21hiredmanah
23:21hiredmanso you are not mapping
23:21hiredmanyou are mapcatting
23:21JAS415it'll do 4 requests, i want 1
23:21JAS415right but i would have expected that to be the same thing
23:21hiredmanmapcat uses concat, and concat is not fully lazy
23:22JAS415oooh
23:22JAS415i didn't realize concat wasn't fully lazy
23:22JAS415that could be the root of many of my problems
23:22hiredman,(doc concat)
23:22clojurebot"([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls."
23:22hiredman,(doc lazy-cat)
23:22clojurebot"([& colls]); Expands to code which yields a lazy sequence of the concatenation of the supplied colls. Each coll expr is not evaluated until it is needed. (lazy-cat xs ys zs) === (concat (lazy-seq xs) (lazy-seq ys) (lazy-seq zs))"
23:23hiredmanlazy-cat is a macro though
23:23JAS415yeah i couldn't use it with an arbitrary number i suppose
23:26JAS415yeah switching to a straight map fixes it
23:27JAS415i'll just rearrange my code to accomodate that
23:27JAS415thanks!
23:29tomojis concat partially lazy? what does that mean?
23:29JAS415well it seems to be chunked or something
23:29JAS415like
23:29JAS415do
23:30JAS415(apply concat (map fn seq))
23:30carki think tha has to do with the multiple parameter lists
23:30JAS415it'll evaluate the first few of the seq from resulting map
23:30carkthough you would see 3 elements realized instead of 4
23:52technomancythe mirror at http://gitorious.org/clojure/clojure should be fully automated now
23:52technomancyclojurebot: gitorious mirror is http://gitorious.org/clojure/clojure
23:52clojurebotIn Ordnung
23:53technomancyfor github's slow days