#clojure logs

2009-08-28

00:01technomancy`heh... now I've switched it back and can't repro.
00:01technomancy`should have checked it in I guess
00:02technomancy`or at least stashed
00:02cark=)
00:04technomancy`http://github.com/technomancy/sketchbook/tree/master <= if you're curious
00:04technomancy`having some fun with Processing
00:04technomancy`even if the language itself is crap, calling it from Clojure is pretty nice.
00:05krumholt__can someone tell me why (java.nio.IntBuffer/wrap (into-array [1 2 3 4 5])) is not working?
00:06krumholt__ah i allready know
00:06cark,(int-array [1 2 3 4])
00:06clojurebot#<int[] [I@172bab9>
00:06krumholt__yes that its
00:06krumholt__thank you very much
00:06cark,(into-array Integer/TYPE [1 2 3 4])
00:06clojurebot#<int[] [I@26b12d>
03:46AWizzArdhiredman: ping
03:58eevar2anyone here with commit rights to sourceforge's clojure-contrib?
04:00eevar2i think someone should make a commit cleaning out all the files, like on google code. but maybe get rid of the license files as well; don't really need 3-4 different licenses to go along with your text file explaining that the project has moved
04:03vIkSiThi all
04:03vIkSiTanyone around?
04:03vIkSiTI'm getting a compilation error on def.clj in clojure-contrib at line 106
04:04vIkSiT[java] java.lang.Exception: Unable to resolve symbol: next in this context (def.clj:106)
04:04vIkSiTany ideas?
04:05eevar2sure you use compatible versions of clojure and the contrib source? i.e. both from master, or both from an 1.0-branch on github?
04:09vIkSiTeevar2, hmm I think I have, although let me refresh to make sure
04:12vIkSiTeevar2, I guess I could use both versions from master?
04:13AWizzArdsounds good
04:14eevar2yes, master and the 1.0 branches aren't compatible
04:15eevar2trying to build (master) here now. just in case ;)
04:15vIkSiTcuriously - vimclojure vs emacs-slime as mode of choice?
04:15opqdonutemacs
04:15eevar2enclojure :p
04:16vIkSiTdoes anyone here use vimclojure at all? :)
04:16eevar2if you're already damaged, you might as well stick with emacs
04:16vIkSiThehe eevar2 - except, moved to using vim after that because of ssh and not liking emacs -nw - and now like it better
04:17vIkSiThehe
04:19eevar2my build of clojure, contrib & compojure, current master branch, went ok
04:24AWizzArdvIkSiT: I use emacs+slime. The author of VimClojure is often here (but not right now). Has many happy users.
04:25vIkSiTah
04:25AWizzArdLast time I checked VimClojure had unique features. For example it can autocomplete the names of static methods.
04:37vIkSiTah I see
04:37vIkSiTalrighty, thanks all
06:44G0SUBHow do I access the values of a Java HashMap?
06:45G0SUB(mymap "key") throws an error. says it can't be cast into an IFn
06:45G0SUBkeys are strings, by the way
06:45AWizzArdUse the method get
06:45AWizzArd(.get mymap "key")
06:46G0SUBAWizzArd: any way to convert that HashMap to an IFn?
06:46jdzi think into works, like (into {} mymap)
06:46AWizzArdYes, use into
06:46G0SUBjdz: interesting. thanks.
06:47AWizzArdG0SUB: if your Map is very big then this operation is maybe not required.
06:48AWizzArdyou could leave it as a j.u.HM
06:48G0SUBAWizzArd: makes sense
06:49AWizzArdEspecially if it is a read-only object. When there are no writers, then read access is thread-safe
06:57ole3Hello, I have to syncronize access to a struct.
06:57ole3Is it better to put the whole struct into a reference or let the slot be references?
07:06ole3ok
07:14AWizzArdin most cases it would make sense to put a whole struct instance into a ref.
07:14AWizzArdBut, it can also make sense to have refs in refs, if you need to keep identity of objects in a collection which itself is in a ref.
07:17ole3well in my struct is a stack and i have to push and pop elements from it.
07:18ole3it is easy if that stack is in a ref.
07:48Fossiole3: that sounds as if the stack should be one ref
07:57Licenserhmmm I wanted to write a few macros that make some things in compojure easyer (namely adding restfull resources) I'm not getting far sadly :/. I wonder if someone could be so nice and take a look and help me out? http://gist.github.com/176928 (as a warning I'm a beginner)
07:58Fossimight be totally unrelated, but the appengine has a deadline after 30 seconds and it's the second time that it fails while starting up in Keyword.intern/ConcurrentHashMap.putIfAbsent
08:02ole3Fossi & AWizzArd: thanks for the response, the stack is now the ref.
08:10ChousukeLicenser: what do you seek to accomplish with that let in the resource macro?
08:11Chousukeoh, I see now. that won't work.
08:11Licenserthat the 'inner macros' like list_items know how the resource is named
08:11LicenserI noticed that
08:11Chousuke,(list `foo# `foo#)
08:11clojurebot(foo__2476__auto__ foo__2477__auto__)
08:11Chousukeautogensyms in different syntax quotes are never the same.
08:11LicenserI fear it's even 'bad style' since the macros like list_items would not be how is it clled, a function of it's values
08:12Licenser*nods*
08:12Licenserokay again something learned
08:12Chousukeyou should instead make those macros use some globally bound *resource-name*
08:12Licensero.o
08:12Licenserisn't that very badish?
08:12Chousukethen do (binding [*resource-name* whatever] (some-macros-here) (some-more-here))
08:12Licenserah okay binding localizes it?
08:13Chousukedynamic global bindings are very common in lisps, and in clojure.
08:13Fossiwho would be responsible for the Keywork.java code? rhickey?
08:13LicenserI love the (doc thing)
08:13Chousukethere are no global (uncontrolled) *variables* in clojure so it's all fine.
08:13LicenserOkay
08:14Chousukealso, don't use underscores
08:15Chousukelist-items, get-item, etc. are better.
08:15AWizzArdFossi: yes
08:15LicenserOkay, thanks for the advice
08:15FossiAWizzArd: k, i'll ask him later then
08:15Licenserwow something is working!
08:17Licenserokay it compiles, now just to get it working too ^^
08:18ChousukeLicenser: also instead of all those nths you could do `(let [~p [(params :id)]] ...) or `(let [~p [(params :id) params]] ...)
08:19Chousukeeg. use destructuring.
08:19Licenserhmm sneaky
08:19Chousukeeh, not eg; ie. ;(
08:19Licenserthanks
08:19Fossidestructuring is the shit.
08:20AWizzArd??
08:20AWizzArdWieso dasn?
08:20Fossi*the* shit. ask google :)
08:25ChousukeLicenser: http://gist.github.com/176962 this should work
08:25Licenserso *
08:26Licenser*looks at it*
08:26Chousukeyour (do ~@body)'s were superfluous so I removed the dos
08:26Licenserhmm why ~'*resource-name* in the one macro?
08:26Licenserokay I had that from the macro documentation ^^
08:26Chousukebecause otherwise it would become qualified.
08:27Chousukeand you can't bind to qualified names I think
08:27Licenserah it would resolve to the value you mean
08:27Chousukeno, I mean
08:27Chousuke,`*warn-on-reflection*
08:27clojurebotclojure.core/*warn-on-reflection*
08:27Chousuke,`~'*warn-on-reflection*
08:27clojurebot*warn-on-reflection*
08:28Chousukemaybe it's possible to use binding with qualified names though.
08:28Chousukebut with let it fails :)
08:28Chousuke(it helps people to not shoot themselves in the foot with macros)
08:28Licenseryes with let it did, I tried something like that :P
08:29Chouserbinding is on vars, so it gets qualified either manually or automatically.
08:29LicenserI wanted to shoot myelf in the foot, or nearly did
08:29G0SUBIs it possible to create private defmulti & defmethods ? like defn- ?
08:29Chousuke(defmulti #^{:private true} foo)
08:29G0SUBChousuke: Thanks. What about the defmethods?
08:29Chousukethey can't be private I think.
08:30Chouseryou don't call them directly anyway -- they are reachable through the multi, so if that's private you're safe.
08:31Licenserhmmm
08:31G0SUBcool
08:31G0SUBChousuke: I put the same metadata after the defmethod. it compiled fine.
08:31Licenserwhen a function takes arguments like (function a1 b1 a2 b2) can I pass it a list too?
08:31Licenserit will destruct it right?
08:32ChouserG0SUB: that metadata is probably being ignored.
08:32G0SUBChouser: right.
08:32FossiLicenser: you can use apply the list
08:32Fossitoday no english me
08:32Licenserhmm hmm
08:33AWizzArd,(re-find #".* \(" "foo (bar)")
08:33clojurebot"foo ("
08:33AWizzArdbut I want only "foo"
08:33G0SUBWhat is the best way to figure out if the arg to a defmethod is a HashMap? I am using (identical? (type arg) (type {}))
08:34ChousukeAWizzArd: use capturing groups and take the first group? :/
08:34G0SUB,(re-find #"(.*) \(" "foo (bar)")
08:34clojurebot["foo (" "foo"]
08:34G0SUB,(re-find #"(.*) \(" "foo (bar)")[1]
08:34clojurebot["foo (" "foo"]
08:34Chouser,(re-find #".*(?= \()" "foo (bar)")
08:34clojurebot"foo"
08:35AWizzArdG0SUB: you can use instance? for the check
08:35Chousukeoh, right. :)
08:35Chouserpositive zero-length lookahead assertion
08:35AWizzArd,(instance? java.util.HashMap (java.util.HashMap.))
08:35clojurebottrue
08:35Chouser,(map? {})
08:35clojurebottrue
08:36AWizzArd,(map? (java.util.HashMap.))
08:36clojurebotfalse
08:36AWizzArdso I check in my programs for being java.util.Map
08:36AWizzArdbecause I need to capture all those cases
08:36AWizzArd,(doc map?)
08:36clojurebot"([x]); Return true if x implements IPersistentMap"
08:36Chouserah
08:37AWizzArdChouser: are you in for a very hard regex again? ;-)
08:37AWizzArdI think it is so hard that noone here can solve it.
08:37Chouserheh. well, statements like that are a good way to get me interested
08:38AWizzArdI got some funny file format that someone invented and I parse it with a function now. But I think a regex may be able to do it too.
08:38AWizzArdI have a string, similar to .csv, in which columns are separated either by , or ;
08:38AWizzArd"15,hello;30;4"
08:38AWizzArdbut...
08:39AWizzArdit also contains strings in which , or ; may show up. Those should not be splitting. These strings are marked by the entries BEGIN;now some,,;;string is here;; with no\n splitting.;ENDTEXT;
08:41AWizzArd"93257,1257 ;1;341;NULL;BEGINTEXT,[zzz] MR813.txt[2009-04-21 14:44];ENDTEXT;BEGINTEXT;>> \r\n>> Hello, it is good; but not now. \"It\" is.\r\n>> Ok;ENDTEXT;BEGINTEXT;NULL,ENDTEXT;BEGINTEXT,NULL;ENDTEXT"
08:41AWizzArdThis is an example input
08:41Chouserwow. so pretty.
08:42AWizzArdand it should split into "93256" "1257 " "1" "341" "NULL" "[zzz] MR813.txt[2009-04-21 14:44]" ">> \r\n>> Hello, it is good; but not now. \"It\" is.\r\n>> Ok" "NULL" "NULL
08:42jdzand nobody ever puts BEGINTEXT etc in those fields?
08:42jdz:)
08:42AWizzArdI hope. I don't know who invented it *sigh*
08:43AWizzArdBut I assume that it does not happen.
08:43AWizzArdSo, the [,;] should split only when not inside a BEGIN END block.
08:43AWizzArdAnd the BEGINs and ENDs need to be eliminated from the result.
08:43ChouserI assume the \" are just for Clojure, not in the file itself?
08:44jdzi think i'd create a filter that would escape those separators inside begin/end
08:44AWizzArdChouser: right
08:44jdzard remove begin/end themselves
08:45AWizzArdjdz: yes, I am doing it in a similar way, in a function. But they are important markers, because the [,;] inbetween must not split.
08:45jdzactually, i think using regular expressions here is more trouble than they help
08:45AWizzArdI was just curious weather this can be expressed with a regex.
08:45AWizzArdjdz: yup
08:46AWizzArdI think noone here can solve that
08:46jdzi'm not gonna trip on that one
08:46jdzi have my own devices to tinker with :)
08:47AWizzArdYes. I think most people will just give up on it after a few tries. It is really complex, and easily solved in an ordinary function.
08:48AWizzArdFossi: the BDFL arrived (Keyword.java).
08:48FossiAWizzArd: ah, excellent :) super assistent ;)
08:53Fossirhickey: (Keyword.java:25) if i read the javadoc right, putIfAbsent returns the old key if it already exists, so the check in :26 is unnecessary
08:54Fossirhickey: that being said we have a strange problem on the app engine where we time out in initializing. it happened to be twice in that line, so could it be some concurrency issue?
08:55ChouserAWizzArd: (map #(or (% 1) (% 2)) (re-seq #"(?s)(?:^|[,;])(?:BEGINTEXT[,;](.*?)[,;]ENDTEXT|(?!BEGINTEXT)([^,;]+))" x))
08:55Fossi("it" happened: the timeout)
08:55Chousernow, who couldn't love a solution like that? :-P
08:58ole3hello, how do i check if a process is still running? (.exitValue process) ?
08:58Fossibrb
09:03jdzole3: solutions to Java related issues can also be tried in #java
09:03jdz(i hope)
09:03ole3jdz: good idea, thank you.
09:04AWizzArdChouser: let me test, one sec
09:05ChouserAWizzArd: (re-seq #"(?s)(?<=BEGINTEXT[,;]).*?(?=[,;]ENDTEXT)|(?<=^|,|;)(?!BEGINTEXT)[^,;]+" x)
09:05Chouserthere, without the map.
09:05bstephensonhello, have a quick question for the clojure experts, if I could
09:06bstephensonI have a vector of hours (e.g. [0 1 2 0 4 3]) and a map of that holds the totals hours in each day used already (e.g., {:day1 0 :day2 2 :day3 3 :day4 7 :day5 6}. Is there a straightforward way (or any way, really) to add the vector values to the map values such that the nth vector value gets added to the value of "day-nth" in the map? The map and vector counts will always be the same.
09:07jdzbstephenson: hardcoding day names in your map keys seems to be a bad idea (to me)
09:08bstephensonhow would you approach it?
09:08AWizzArdChouser: looks good. You were the first who made that. I gave that puzzle to some friends so far and they gave up.
09:09jdzbstephenson: but anyway, you can have a separate map which will give you vector indices when given day names
09:09jdzbstephenson: well, why not use vectors of hours or maps in both cases?
09:10bstephensonwell, I was using the map to use the assoc function to update the value, but I think now that you are probably correct, two vectors will work better than a vec and a map, they will always have the same index.
09:11bstephensonjdz: thx
09:28rhickeyFossi: how is the check unnecessary? If the key was there I need to return the old one, if not the new one. I can't just return the result of putIfAbsent as it will be null if it wasn't there
09:30rhickeyFossi: do you get a stack trace when you timeout?
10:08liwpChouser: I think you need to add ENDTEXT to the negative lookahead as well
10:08liwp,(re-seq #"(?s)(?<=BEGINTEXT[,;]).*?(?=[,;]ENDTEXT)|(?<=^|,|;)(?!BEGINTEXT|ENDTEXT)[^,;]+" "BEGINTEXT;foo;ENDTEXT")
10:08clojurebot("foo")
10:09liwpChouser: and thanks for all the effort you're putting into these regexp challenges, I'm learning a lot here
10:11Chouser,(re-seq #"(?s)(?<=BEGINTEXT[,;]).*?(?=[,;]ENDTEXT)|(?=^|,|;)(?!BEGINTEXT)[^,;]+" "BEGINTEXT;foo;ENDTEXT")
10:11clojurebot("foo")
10:11liwpmaybe I messed up my copy pasting...
10:11Chouseroh, no, I think I did.
10:11liwp,(re-seq #"(?s)(?<=BEGINTEXT[,;]).*?(?=[,;]ENDTEXT)|(?<=^|,|;)(?!BEGINTEXT)[^,;]+" "BEGINTEXT;foo;ENDTEXT")
10:11clojurebot("foo" "ENDTEXT")
10:12liwpthat's what I got earlier
10:12AWizzArdhmm
10:12Chouserthe one I just pasted above is not right. please ignore it
10:13AWizzArdwhat is this (?s) thing with which it starts?
10:13liwpwho knows ;-)
10:14Chouserliwp: yes, you're right. I had this in my command history, but somehow pasted the wrong one instead. I think this is right (and essentially the same as you have):
10:14Chouser(re-seq #"(?s)(?<=BEGINTEXT[,;]).*?(?=[,;]ENDTEXT)|(?<=^|,|;)(?!BEGINTEXT)(?!ENDTEXT)[^,;]+" "BEGINTEXT;foo;ENDTEXT;bar")
10:14Chouserthe (?s) at the beginning says that . should also match \n for the rest of the regex
10:15liwpThe other question mark stuff is related to lookaround: http://www.regular-expressions.info/lookaround.html
10:16liwpfor those of us who didn't know how it all worked
10:17Chouserand if you ever think regex can't do something or other, keep this in mind: http://blog.n01se.net/?p=12
10:18liwpurgh, some people have too much time on their hands
10:19AWizzArdThere is this programming language Malbolge ( http://en.wikipedia.org/wiki/Malbolge ) in which only "Hello World" was the only program ever written. And this hello world program was not written by a human, but by a Lisp program :)
10:20AWizzArdIf people really have a lot of time...
11:06Fossirhickey: ah, ok, the documentation says it's equal to a if !contains, put else get, which would return the old one, so i didn't care to read the actual return documentation
11:06Fossia little inconsisten there
11:08Fossirhickey: is it ok if i pm you the stacktrace?
11:10Fossi(as a paste link of course)
11:18lpetit_hello
11:18lpetit_I can't seem to get rid of reflection warning here, missing something trivial I think :(let [to-name-fn #(-> #^File %
11:18lpetit_ .getPath
11:18lpetit_ (str2/drop (inc (-> *builds-dir*
11:18lpetit_ .getPath
11:18lpetit_ .length)))
11:18lpetit_ (.replace "/" "."))]
11:19lpetit_The last call to .replace generates a "call to replace can't be resolved."
11:20lpetit_.replace works on a String, and takes CharSequences as arguments. How can I indicate the "mutation" of the threaded argument ?
11:27jdzlpetit_: i'd try macroexpanding that form and look what's there
11:30lpetit_,(macroexpand '#(-> #^File % .getPath (.replace "/" ".")))
11:30clojurebot(fn* [p1__2529] (-> p1__2529 .getPath (.replace "/" ".")))
11:31jdzseems to me that the type tag is lost
11:31jdzor maybe not
11:32jdz,(macroexpand '(-> p1__2529 .getPath (.replace "/" ".")))
11:32clojurebot(. (clojure.core/-> p1__2529 .getPath) replace "/" ".")
11:34carkstr2/drop must be returning an Object
11:34carkso you could #^String (str2/drop ...
11:34lpetit_I'll try, thanks (was working on the wrong s-exp :-( )
11:36lpetit_weird, I tried it but still same warning
11:36carkmhh
11:37cark*builds-dir* is untyped too
11:38lpetit_Reflection warning, /home/lpetit/*******_tests.clj:28 - call to replace can't be resolved.
11:41carkand when you run it you have no errors ?
11:42carkcould you paste your current code ?
11:42lpetit_currently trying to cut it down to the minimum
11:43lpetit_no error when running
11:43Chouser-> builds a new list for each step past the first
11:44Chouser,(binding [*print-meta* true] (prn (macroexpand '(-> a #^Integer (b)))))
11:44clojurebot(b a)
11:44lpetit_now that's interesting:
11:44lpetit_1:41 engine-tests=> #(.replace "/" ".")
11:44lpetit_Reflection warning, NO_SOURCE_PATH:41 - call to replace can't be resolved.
11:44lpetit_#<engine_tests$eval__250$fn__252 engine_tests$eval__250$fn__252@15d616e>
11:45carkmhh i know i resolved type warning within ->
11:45lpetit_I also remember this demonstrated on the ml
11:46lpetit_(note : working with clojure-1.0)
11:46Chouser-> could be patched to copy metadata from the given form to the produced one.
11:46lpetit_don't misinterpret : it's not working with clojure-1.0, I'm using clojure-1.0
11:47lpetit_,(binding [*print-meta* true] (prn (macroexpand '(-> a (#^Integer b)))))
11:47clojurebot(#^Integer b a)
11:48lpetit_beh
11:49lpetit_Maybe we're not focusing on the right problem, see:
11:49lpetit_1:43 engine-tests=> (fn [] (.replace "/" "."))
11:49lpetit_Reflection warning, NO_SOURCE_PATH:43 - call to replace can't be resolved.
11:49lpetit_#<engine_tests$eval__262$fn__264 engine_tests$eval__262$fn__264@c5aa00>
11:49Chouser.replace needs 3 args
11:50Chouseronly 2 within ->
11:50lpetit_oh yes sorry
11:50carkchouser : indeed it's not working
11:50lpetit_so the goes back to the -> , of course
11:51carkanyways you could insert a str call juste before the (.replace
11:51lpetit_within -> it's normal the first is the threaded argument
11:52lpetit_so in my original example with ->, there are 3 arguments to .replace
11:53Chousertry (#^String str2/drop ...)
11:56lpetit_that's it !
11:58lpetit_I could also tackle it directly in clojure-contrib/str-utils2 : changing defs like (defn drop [#^String s n] into (defn #^String drop [#^String s n]
11:58Chouserstr2 could use some hints splinkled around.
11:58Chouseryeah
11:58lpetit_post collision :)
11:58lpetit_ok I'll do it
11:59lpetit_around the beginning of next week, it 6pm here in France, by guys
11:59lpetit_and thx for all
12:00hiredmanAWizzArd: pong
12:51stuartsierracommit 4b4f6ab5bcab58c4219eb50395bd366daea3ecc3: str_utils2.clj: added type hints for String return values; fixes #27
12:58fsodomkahi all!
12:58fsodomkacouple days ago I saw discussion about new possible multimaps and their syntax... some time ago I played with Rebol, so I wanted to point out its syntax if anyone wants to get inspired...
12:58fsodomkaValues: http://rebol.com/docs/core23/rebolcore-3.html#section-2
12:58fsodomkaEvaluating Simple Values: http://rebol.com/docs/core23/rebolcore-4.html#section-4.2
12:58fsodomkaand their use: Conditional Blocks: http://rebol.com/docs/core23/rebolcore-4.html#section-6.1
12:58fsodomka... not sure if that helps...
13:54Chouserrathore: nice job posting! Sounds interesting.
14:01carka sample executable jar build process using ant : http://github.com/cark/clj-exe-jar/tree/master
14:02cark~executable jar?
14:02clojurebotPardon?
14:03cark~executable jar is a sample executable jar build using ant : http://github.com/cark/clj-exe-jar/tree/master
14:04carkhum
14:04hiredman:(
14:04ababoHi there, please help me to figure out why casting to an interface is not working!
14:04carkclojurebot: don't do thhis to me !
14:04clojurebotPardon?
14:04ababo,(cast javax.script.Invocable (.getEngineByName (javax.script.ScriptEngineManager.) "js"))
14:04clojurebotnil
14:05ababoThat returns ScriptEngineManager instead of Invocable
14:05stuartsierraClojure is dynamic, no need to cast anything.
14:05ababoWhen I try to call a method of the interface it fails.
14:07Chouser,(doc cast)
14:07clojurebot"([c x]); Throws a ClassCastException if x is not a c, else returns x."
14:08ababoAha, got it, thanks!
14:08carkis there some good soul that would provide me with the equivalent linux clojure startup script for the sample project i just linked ?
14:08stuartsierraScriptEngine isn't required to implement the Invocable interface.
14:09carkequivalent to run-clojure.bat
14:09stuartsierracark: there are sample launch scripts in contrib
14:10Chousercark: line 2 looks like it would work as-is -- what does line 1 do?
14:10carki'm at home and don't have a linux handy. I wouldn't want to screw an example
14:11carkchouser : line 1 changes current directory to the .bat file's directory
14:11dmixanyone recognize whats causing this error? http://gist.github.com/177119 I can't decipher it
14:13carkdmix : maybe show us the code that produces the error ?
14:16hiredman~executable jar is a sample executable jar build using ant : http://github.com/cark/clj-exe-jar/tree/master
14:16clojurebotOk.
14:16hiredman~executable jar
14:16clojurebotexecutable jar is a sample executable jar build using ant : http://github.com/cark/clj-exe-jar/tree/master
14:16carkhiredman : thanks !
14:16ababoMy bad, method name is .invokeFunction but the example code has .invoke
14:16ababoThanks for the input!
14:20Chouser#!/bin/bash
14:20Chousercd "$(dirname $0)"
14:20Chousercark: Those two lines instead of your first should do it.
14:20carkchouser : ok and the filename should be run-clojure.sh ?
14:21Chouseryou could leave of the .sh, but sure.
14:21carki'm a linux ignoramus
14:21carkok thanks
14:21hiredman:(
14:22hiredman#!/bin/sh
14:22hiredman#!/bin/bash is horrible
14:26hoeck1cark: and split paths on the java -cp line with a colon instead of a semicolon
14:26Chouserhiredman: oh? what OS do you use?
14:26carkah yes indeed !
14:26Chouserhoeck1: oh, good catch -- I missed that.
14:26Chouserhiredman: $() is a bash thing anyway -- /bin/sh wants me to use backquotes or something.
14:27hiredmanChouser: $() is a sh thing
14:27hiredmanI use an OS that does not come with bash, and addon software doesn't get installed in /
14:28Chouserhiredman: so... not linux. :-)
14:28carki think any linux user picky enough to want one or the other should be able to make the change
14:29hiredmancark: #!/bin/sh
14:30carkhaha looks like i have to make a vm to test this anyways =/
14:31hiredmantwo characters, and suddenly your shell script will run on any unix
14:39rsynnottand you'll want the permissions to be right
16:03kotarakChouser: thanks for for!
16:21hiredmanhttp://www.scala-lang.org/node/3069 "He found that it is, on average, 30% faster to comprehend algorithms that use for-comprehensions and maps, as in Scala, rather than those with the iterative while-loops of Java."
16:23ankouhi, I just read the chapter about lazy sequences in Programming Clojure and I am surprised that lazy sequences use normal recursion instead of tail-recursion but seam to work with large numbers as well? why? or is this a missunderstanding?
16:24hiredmanankou: sort of
16:24hiredmanlazy-seqs sort of recur
16:25hiredmanbut the recursion and stack depth are controled by sequence consumption
16:25kotarakankou: when the recursive call happens the original call, where the recursion was "started" already returned. So there is no build up of stack frames
16:25hiredmanso if you consume the sequence, but throw away the parts you have already seen, you don't consume space
16:25kotarakyou can still blow the stack by piling eg. map on map on map on map ...
16:27kotarakAnd - man - cl-format sure is on steroids...
16:34Chouserkotarak: I didn't write 'for', it's all I can do to understand it just enough to tweak a bit here and there.
16:34Chouserbut you're welcome for the chunked version. It was hard!
16:38ChouserThis has gotten a bit interesting recently: http://github.com/richhickey/clojure/graphs/impact
16:40kotarakgithub doesn't like me. :( The network graph for contrib seems frozen for days now. :(
16:41kotarakThe small fixes could use some turbo. :|
16:43rhickeyChouser: neat, I'd never seen that view
16:44Chouserrhickey: btw, the finger tree paper does define deque ops, tail-l and tail-r. I just missed them somehow.
16:45rhickeyoh, good
16:46Chouserso split is only useful or needed for annotated (measure/reduce) tree.
16:46rhickeyokasaki famously left out delete from his example red black tree
16:46Chouserheh
16:48Chousersomeone asked me last night why you didn't do finger trees in the first place. I had some guesses, but didn't know.
16:48Chouserinstead of vectors, I suppose.
16:48rhickeyso I wonder - how important are the annotated versions?
16:48rhickeyfinger tress are unlikely to touch the perf of the vectors
16:50Chouserannotations can give you random-access, priority queues, ordered sequences...
16:51Chouseralso I suspect some clever application-specific uses. For testing I'm using the str fn for both measure and reduce, so I always have a correctly-ordered string representation of the whole collection.
16:51rhickeyneat
16:52rhickeyreigy working ok for you?
16:52rhickeyreify
16:52Chousernot there yet.
16:52Chouserprobably start trying to use it this weekend.
16:53Chouserthe transition from haskell-ish to clojure is big enough by itself. I wanted to get a taste of that before I tried to figure out the right way to use reify.
16:54rhickeymakes sense
16:54Chouserdo you have a gut feeling about whether a node of 2 to 4 items should be an array of 4, an array of needed size, or 4 separate fields?
16:55Chouseroops, gotta go. I'll read the history later...
16:56rhickeyChouser: do the node of different N have different behavior? If you look at the different Clojure data structures you'll see a lot of Node polymorphism
17:03lpetitstuartsierra: hi, I saw you were quicker than me to add missing type hints on c.c.str-utils2 :)
17:03lpetitwould you mind applying them on the compat branch, also ? (I didn't check, maybe already done ?)
17:13stuartsierralpetit: ok
17:17stuartsierraok, done
17:18Chouserrhickey: ah, I hadn't thought of that. I'll have to look again to see how transients are done now.
17:18lpetitstuartsierra: thanks a lot!
17:19rhickeyChouser: not just for transients, see e.g. PersistentTreeMap
17:20rhickeyOkasaki's pattern matches turned into polymorphic dispatch
17:23lpetitstuartsierra: did not see the commit yet
17:24lpetitstuartsierra: did you make "clojure-contrib behaviour breaking changes" on the clojure-1.0-compatible branch ? (templating system, etc.)
17:27lpetitstuartsierra: I thought clojure-compatible was not only compatible with also clojure-1.0, but also just a maintenance branch of clojure-contrib, so that people know they have a "1.0 with no breaking changes clojure/clojure-contrib" duo ?
17:29lpetitstuartsierra: note that importing new functionality does no harm, but sometimes it has side effects as importing newer (incompatible ?) versions of some other dependencies ...
17:31stuartsierraWait, did I just break the git repo?
17:32stuartsierralpetit: no, I did not (intentionally) make any behavior-breaking changes
17:33lpetitstuartsierra: ok, glad to have been able to catch it, then.
17:36lpetitstuartsierra: woops, you pushed 110 commits from master to compat branch
17:36stuartsierraDamn.
17:36stuartsierraHow the heck did that happen?
17:37lpetitstuartsierra: you did some sort of merge instead of a cherry pick
17:37lpetitstuartsierra: probably
17:37stuartsierraGreat. Now I have to figure out how to fix that.
17:38lpetitstuartsierra: let's think about it together
17:38stuartsierraAnybody know how to fix this
17:40lpetitok I'm pretty sure you did a merge (not a rebase) from what I can see from gitk
17:40lpetitso it will be very easy to do the reverse change
17:40stuartsierraok, just cloned a new copy of clojure-contrib
17:42lpetitit's just a matter of making the compat label point to the rev with comment "repl-utils: Fix init state for...", that is rev e0080e640a2d9b79
17:42lpetitnow we must find the appropriate command :)
17:44stuartsierrayeah
17:45lpetitthe simpler could be to do a git reset ...(options to determine) and if you have commit rights, to push it. It will definitely delete the wrong commit.
17:45stuartsierraI think it was an older commit, though.
17:45lpetitIf nobody tried to checkout or fetch compat in the time interval, nobody will be harmed
17:46stuartsierralet's go with that assumption
17:47lpetitok, so enter git reset --hard e0080e640a2d9b79 in your clone
17:47stuartsierraThey seem to diverge on "build.xml: run compile-clojure in headless..." 3073f0dc0614cb8c95f2debd0b7e6a75c1736ece
17:51stuartsierraok, did: git checkout origin/clojure-1.0-compatible
17:51lpetitno, chouser ported a correction in commit e0080e640a2d9b79
17:52lpetitno, don't do that !
17:52stuartsierraok, clearly I don't understand git as well as I thought I did
17:53lpetitI'm not 100% sure, but pretty sure it's a bad thing : it is intended as being a mirror of what is on the remote
17:53lpetitI also have git repos for Counterclockwise, and work only on private trees that I push from time to time
17:54lpetiton your fresh clone, switch to your local branch for compat, maybe you have named it compat, maybe something else, so type git branch to see all your branches, and once you've localised it, git checkout <theRightName>
17:55lpetitthen issue the command I stated previously : git reset --hard e0080e640a2d9b79
17:55lpetitthen try to push. If this does not work, there are some things in the configuration I don't master yet.
17:56lpetityou'll finish in the spam black list of everybody :-p
17:57drewrare you guys trying to push to the public repo after a local git reset --hard?
17:57lpetit:-$
17:58lpetitoups, caught
17:58stuartsierraWe're trying to erase a bunch of commits that I accidentally merged into the clojure-1.0-compatible branch.
17:58drewryou would have gotten away with it if it weren't for a couple of commits that just came in from others :-/
17:58stuartsierradamn
17:58stuartsierranow what?
17:59lpetitdrewr: no the problem is on the compat branch of clojure-contrib
17:59drewrgit rebase origin/master :-)
17:59stuartsierraNo, master is fine. It's only the clojure-1.0-compatible branch that I messed up.
17:59drewrat this point it's probably best to just leave it alone
18:00lpetitcompat branch has just the last merge commit wrong.
18:00drewrthe history will be a little dirty, but that's ok
18:00lpetitSeriously, for the compat branch, no big deal to quickly correct this ?
18:00stuartsierraAssuming we can figure out how.
18:01lpetit(is it me that is saying that)
18:01lpetitstuart, did you try my "instructions" ?
18:01drewrmaybe the couple of msgs I saw were from you guys
18:01stuartsierralpetit: not yet, hang on
18:02drewras long as no one else has committed, you can "git reset --hard COMMIT_YOU_WANT && git push -f origin/clojure-1.0-compatible"
18:02lpetitI'll reproduce it locally too.
18:02stuartsierraOk, starting fresh.
18:03stuartsierragit clone git@github.com:richhickey/clojure-contrib.git
18:03stuartsierracd clojure-contrib
18:03lpetitgit branch -r ; copy the name origin/clojure...compatible ...
18:04stuartsierragit checkout -b compat origin/clojure-1.0-compatible
18:04lpetitgit checkout -b compat origin/clojure... ; compat will be the name of your branch
18:04lpetitok
18:05stuartsierragit reset --hard e0080e640a2d9b79
18:05lpetitnow, the hard reset git reset --hard e0080e640a2d9b79
18:05lpetitok !
18:05lpetitand the command from drew (thanks!)
18:05stuartsierraNow what do I push to?
18:05stuartsierra"git push origin/clojure-1.0-compatible" ?
18:06stuartsierraOr just "git push"?
18:06lpetitlet's try that
18:06lpetitthe fully specified first
18:06drewryou'll likely have to push -f
18:07drewrbecause the histories don't agree
18:07stuartsierra"error: src refspec clojure-1.0-compatible does not match any."
18:07lpetittrue
18:08lpetitwould -f help ?
18:08drewrnot for that error
18:08stuartsierrasame error
18:08drewrlet me update and look aroudn
18:08lpetitbased on the criteria of "shooting yourself on the feet", I would say git is way powerful than clojure :)
18:09lpetitstuart : and just git push -f
18:09lpetitif you still are in the compat branch, of course
18:09drewrstuartsierra: remove the slash
18:09drewrit should be "origin cloj..."
18:09stuartsierradid that
18:10stuartsierralispaste: url
18:10stuartsierralisppaste: url
18:10lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
18:10drewryou could do "git push origin :clojure-1.0-compatible && git push origin clojure-1.0-compatible"
18:11drewrthat'll delete the branch and recreate it
18:11lpetitseems dangerous
18:11stuartsierraBut git seems to be telling me that the branch doesn't exist in the first place
18:11lisppaste8stuartsierra pasted "Trying to push to github" at http://paste.lisp.org/display/86203
18:11drewrstuartsierra: what does "git branch -a" tell you?
18:12lisppaste8stuartsierra annotated #86203 "git branch -a" at http://paste.lisp.org/display/86203#1
18:12lpetitit may be because there are some implicit conventions, and since you did not give the same name to your local branch and the remote one, some more typing may be involved
18:12drewrahh
18:12stuartsierraah, pes
18:12stuartsierrayes
18:12Chousukeyou should not use -f to push
18:12drewrso you would do...
18:13drewrsince your local branch is a different name
18:13stuartsierrastuart@wsgrhl700c3:/tmp/clojure-contrib$ git push -f origin compat:clojure-1.0-compatible
18:13stuartsierraTotal 0 (delta 0), reused 0 (delta 0)
18:13stuartsierraTo git@github.com:richhickey/clojure-contrib.git
18:13stuartsierra + 69f810b...e0080e6 compat -> clojure-1.0-compatible (forced update)
18:13Chousukeif you use -f and push a branch that is not a descendant of the branch you're pushing to, you'll screw up other people's repos
18:14drewrChousuke: that's what they're trying to do
18:14stuartsierraChousuke: I know, normally I would not push -f, but in this case I already screwed up the repo and I'm trying to fix it.
18:14Chousukeah, okay :)
18:14drewrstuartsierra: ok, so you got it?
18:14stuartsierraI think that did it. Look at http://github.com/richhickey/clojure-contrib/commits/clojure-1.0-compatible
18:15lpetitbetter, I'll do a fetch and see locally :)
18:15drewrlooks good here
18:16lpetityeah
18:16lpetitfiouu
18:16stuartsierraok, phew
18:16drewrgit log -1 --pretty=oneline
18:16drewre0080e640a2d9b79564a3fb6eb7ee36be1882901 repl-utils: Fix init state for add-break-thread!
18:16lpetitoh sorry phew is fiouu in french :)
18:16lpetityes that's what we wanted
18:16stuartsierrafiouu is a better spelling, anyway :)
18:17lpetitso now, stuart, please man git-checkout :-)
18:17lpetitno, man git-cherry-pick
18:17lpetit
18:17lpetit;-)
18:17stuartsierrayeah, I still don't understand it. I did cherry-pick then push, what could be simpler?
18:18lpetitoh
18:18stuartsierraWait, I know.
18:18stuartsierraI did "git checkout -b compat" without specifying which branch to track, so I got the master branch.
18:18stuartsierraThen pushed it back.
18:19lpetityes, but how come it was then checked in the compat branch ?
18:19lpetitdo you stil have the history of the commands?
18:19Chousukehmm, yeah, master is still a descendant of the compat branch, is it?
18:20lpetitno, Chouser commited something on July
18:20lpetitstuart, it work, the reverse spamming has begun :)
18:20lpetitit works
18:21stuartsierrayay
18:22lpetitso now, let's try the cherrypick ? :-) git checkout compat && git cherry-pick -x 4b4f6ab5bcab58c4219e
18:23stuartsierrano, I'm going home. I'll try the cherry-pick when I'm more awake
18:23lpetitif it's possible to do this as a patch I can do it and then attach it to the issue
18:23lpetitat your convenience
18:24Chousukewell you can always do the cherrypick yourself and then use git format-patch
18:24Chousukethe end result will be the same.
18:24stuartsierraThat won't help, will it? I (or someone) still have to push to the right branch.
18:24stuartsierraI just have to get good with git.
18:25lpetitok, so we'll let this as an exercise for the reader :)
18:25stuartsierrayeah, g'night folks
18:25LicenserI think it is great to have those videos
18:25lpetitg'night
18:26Licensernight lpetit
18:31drewrwhenever I'm about to venture into uncharted territory with git I always create a test repository, clone it, try whatever on the clone, and then push
18:32drewryou can do that in /tmp in 5 min
18:32drewrand they're both gone
18:32drewr(lpetit and stuartsierra that is)
19:53JAS415is there a way to match and replace a string without java doing the regex machinations?
19:58Chouserwhat's wrong with Java doing it? I like contrib str-utils2/replace
20:01dmiles_afkare some you guy s masters at understanding verify errors?
20:01dmiles_afkjavaclassloader verify errors that is
20:02dmiles_afkdoes clojure use invokeinterface ? or just invokevirtuals?
20:03dmiles_afk(thats eigther only invokevirtuals vs both)
20:10dmiles_afkah it uses a private copy of ASM whichmakes it more transparent
21:39lowlycoderis there a macro for scheme-like define in clojure? one that acts more like letfn than defn? (i.e. define the function in the local lexical environment~ not the global one)
21:42cemericklowlycoder: I *think* so. I remember someone asking something very similar, and there was either something in place, or perhaps in contrib?
21:43lowlycodernot finding it grepping for "define " in clojure-contrib
21:43JAS415hmm
21:43JAS415how do i replace a $ with an escaped $ in a string?
21:43lowlycoderthen again~ i'm running clojure 1.0.0 with the relevant clojure-contrib
21:43JAS415with a regex
21:44JAS415you could just use letfn all over
21:44lowlycoderno; i have the indenting
21:44lowlycoders/have/hate
21:45JAS415oh, indenting
21:45JAS415you could make a macro
21:46tomojlowlycoder: didn't we already talk about this?
21:46lowlycoderyes; we concluded that clojure and scheme are different
21:47tomojalso that a macro for the inner defines alone wouldn't help
21:47tomojyou'd need to use a macro for the toplevel form
21:47lowlycoderof course not
21:47lowlycoderright
21:47lowlycoderthis looks like a messy job
21:47lowlycoderand also screws up debugging support
21:47lowlycoder(like mismatching of source code lines)
21:48lowlycoderso i'm hoping someone else has handled this already
21:48tomojmacros mismatch source code lines?
21:48carklowlycoder : are you looking for letfn ?
21:49lowlycoderno~ i'm looking for a macro that ends up writing letfn
21:49JAS415um
21:49lowlycoders/writing/calling
21:49carkwhat's the local envioronment you're talking about ?
21:50JAS415i forget how define in scheme works
21:50tomojI think you would need to macroexpand all the forms in the body, take the initial segment that start with def, and then turn those into a letfn that you wrap around the rest of the body
21:50tomojor if you use "define" in the inner defines as well, it would be even easier
21:50JAS415upi cam
21:50carkoh i see now
21:50JAS415you can't just use let
21:50lowlycodercark: it's hard to explain unless you use scheme; it's obvious if you do
21:50JAS415?
21:51carki got it now
21:51JAS415let = define..
21:51JAS415we're talking about lexical scope?
21:51lowlycoderyes
21:51carki don't think you can access the environement from a macro in clojure
21:52tomojsure you can
21:52tomojjust have the macro produce a letfn
21:52carkright but he wants to have the "define" valid after it is err ... defined
21:53tomojthat's why you need a macro
21:53lowlycodercark: there we go :-)
21:53tomojit needs to convert those into a proper letfn
21:53JAS415have the define valid after is define
21:53carkbut how would your macro know what are the next forms
21:53JAS415hum
21:53tomojit's just the rest of the body
21:54tomojall the forms in the body besides the initial segment which start with "define"
21:54JAS415hmm
21:54JAS415well idunno
21:54JAS415it sounds like a lot of work to reimplement scheme :-P
21:54carkthat's what he wants (def bleh [] (define somefunc (fn [] (println "hello")) (somefunc))
21:55tomojcark: no, the new macro goes at the top level
21:55tomoj(define bleh [] (define somefunc (fn [] ...)) (somefunc))
21:56tomojin that case the toplevel define can take the initial segment of forms starting with "define" it its body and convert them into a letfn, then wrap that around the rest of the body
21:56carkah in this case the define macro could walk the code and do it, yes
21:56tomojyou're right, seems impossible to add inner defines to defn
21:57carkbut i don't like it, because the semantic of the outer define is not the same as the inside one
21:57tomojwell you could name it whatever
21:57carkmhh no scratch that
21:58carkit would be ok as the outer lexical scope is the namespace
21:58tomojto really get this working like scheme you would have to define new versions of fn, let, letfn, defn
21:58lowlycoderwhere is richhickey?
21:58tomojsince inner defines can be used in all the scheme equivalents
21:58lowlycoderi want to hear his reasons for changing this
21:59tomojchanging it?
21:59carkwell i want to hear your reasons to have it your way =P
21:59tomojdid clojure support inner defines at one time?
21:59lowlycoderyeah~ for making the semantics of defn clojure != scheme define
21:59tomojclojure did not derive from scheme...
21:59lowlycoderall languages derive from scheme
21:59tomojhah
21:59JAS415no
21:59carkhehe
22:00JAS415all languagse derive from fortran
22:00JAS415:-(
22:00JAS415fortran and algol
22:00lowlycoderall langauges derive from waving a magnet over a harddrive
22:00JAS415:-( :-(
22:00tomojI mean it's not like he took scheme and then said for each feature, "hmm.. should we keep this feature or change it?"
22:01JAS415how do i replace a $ in a string with an escaped $?
22:01JAS415i've got this far
22:01JAS415(.replaceAll "$324" "\\$" "\$")
22:02JAS415(.replaceAll "$324" "\\$" "\\$")
22:03JAS415this far
22:03Chouser,(.replaceAll "$324" "\\$" "\\$")
22:03hiredmanoops
22:03JAS415it returns $324
22:03tomoj,(.replace "$324" "$" "\\$")
22:03clojurebot"\\$324"
22:03JAS415but i'm guessing i want \$324
22:03JAS415so i try to escape it
22:04hiredmanyou have to \\\\
22:04hiredman,(.replace "$324" "\\$" "\\$")
22:04clojurebot"$324"
22:04hiredman,(.replace "$324" "\\\\$" "\\$")
22:04clojurebot"$324"
22:04hiredman,(.replace "$324" "\\\\$" "\\\\$")
22:04clojurebot"$324"
22:04JAS415,(.replaceAll "$324" "\\$" "\\\\$")
22:04clojurebotjava.lang.StringIndexOutOfBoundsException: String index out of range: 3
22:04JAS415oh i need 5
22:04JAS415okay
22:04JAS415i was trying 4
22:04tomojI must not understand what you're trying to do..
22:05tomojyou want to replace "$" in a string with "\\$" ?
22:05JAS415well i got this string, which i'm going to use in a regular expression...
22:05JAS415which i pulled from an 'unknown source'
22:05JAS415so the internets
22:06JAS415and it comes back something like "Blahblah $60,000"
22:06hiredman,(.replace "$324" "$" "\\$")
22:06clojurebot"\\$324"
22:06hiredmanlike that?
22:06JAS415wow
22:06JAS415exactly like that
22:06JAS415there's a plain old replace?
22:06JAS415nice
22:06tomojdas hab ich auch gesagt..
22:06Chouseroh, use \Q
22:06Chouser,(re-seq #"\Q$1" "$1")
22:06clojurebot("$1")
22:09wtetzner_is there a function to check if a value is contained in a sequence?
22:09wtetzner_i know there is contains?, but that checks if a key exists in something associative
22:09JAS415nice (.replace works perfectly
22:09Chouserif you can use a set instead of a sequence, your life will be easier
22:09JAS415i'll have to look up \Q
22:10wtetzner_oh, that should be ok
22:10wtetzner_thanks
22:10hiredmancalling .contains is much faster than creating a set and testing for set membership
22:11hiredmanfyi
22:11cemerickso, I've got this lib whose most significant hotspot is isa? and friends
22:12cemerickI did a bunch of profiling, and supers (and to a much lesser extent, bases) is the fundamental culprit
22:12wtetzner_oh, thanks hiredman
22:12wtetzner_so is .contains part of the collection interface, but doesn't have a corresponding clojure function?
22:12cemerickI memoized supers, and got a very large factor speed improvement -- perhaps up to an order of magnitude, but I haven't taken a precise measurement
22:13cemerick(memoizing bases helped a little more, but was far less impactful)
22:13cemerickDoes it seem like memoizing supers (+ bases, perhaps) is a good idea in general?
22:14cemerickI'm thinking that using a WeakHashMap would be more correct, so as to allow dead classes to go away, etc.
22:14hiredmancemerick: if your hierarchs are not java classes, it seems like they can be mutated
22:14cemerickhiredman: bases and supers are only concerned with classes and interfaces
22:14hiredmanoh
22:14hiredmanof course
22:15cemerickso, I'm thinking that this might be a safe optimization to apply, but I'm unsure of any impact on touchy module systems
22:15cemerick...and any other things I'm not thinking of.
22:15cemerickOne way or the other, the perf improvement is very significant.
22:16cemerickanyway, I'm going to write some results up for a msg to the group, but I wanted to see if anyone had any immediate reasons why this would be a bad idea
22:17hiredmanI wonder how good Class's .hashCode is
22:18cemerickhiredman: it doesn't override it
22:19cemerickwhich I *think* is good in this case
22:19cemericke.g. if a new version of a class with the same name as another comes into supers/bases, it'll get its bases/supers recalculated
22:19cemerickthat might actually be what saves me with the module systems
22:19carkthe usage of isa? that needs to be optimzed, is it in a loop under your control ?
22:20cemerickcark: yes, but the size of the dataset isn't
22:21carkyou could (binding [super (memoize super)] ...] ...) around your loops maybe ?
22:21carkor whatever function
22:21cemerickheh, that's sneaky :-)
22:21cemerickbut, if this is safe, I'd like to see it made available to everyone's code
22:22carkmhh i don't think it is safe, i wouldn't want that a default in clojure
22:22carksome classes might be unloaded
22:23cemerickcark: that's why a weakhashmap would be more appropriate
22:23Chouserclasses don't go away unless they're loaded by a classloader that goes away
22:23carkright
22:24carkthis is a pretty obvious optimization, don't you think the java people would have done that already if it was a good idea ?
22:24cemerickcark: the point is, using a weakhashmap would allow those unloaded classes to get collected as they would be otherwise
22:25Chouserthe supers of a class can't change, can they?
22:25cemericknope. (JDK 7 majick aside)
22:25Chouseruntil we get interface injection, or whatever it's called.
22:25cemerickright
22:26carkhum if there's one exception, that's it, you can't do it anymore
22:26cemerickOK, quick numbers. Before memoization, 17165ms. After memoizing, 2749ms
22:26cemerickme likey :-)
22:28cemerickcark: exception? Like java.lang.Exception?
22:28carknope i mean like "an exception to the rule that you can do it"
22:28carklike say jdk 7 =)
22:29cemerickoh, sure. If it's not safe, then that's it.
22:29Chouserwell, you just need to know when to invalidate your cache
22:29cemerickjdk 7 is an externality until it actually exists in a meaningful way :-)
22:30cemerickChouser: yeah, I'd assume interface injection would come with some kind of notification mechanism we could hook into
22:31Chouseractually didn't they say you had to do the injection before doing anything else with the class?
22:31cemerickI don't know...
22:31cemerickdoesn't that defeat the point?
22:32carkare they trying to do something like c# extention methods ?
22:34Chouserok, I remembered that wrong. Here's what I was thinking of: "For any given class and injectable interface, the injector method is called the first time the question arises whether the class implements the interface. (This could be an invokeinterface, an instanceof, or a reflective operation.) Just before the decision, the class is called an injection candidate."
22:34cemerickah
22:34cemerickafter injection, does a new class get consed up and swapped in for the old?
22:41hiredmanI hope not