#clojure logs

2011-02-22

00:00brehautaha
00:05brehautamalloy: huh i had something terrible in my scrollback buffer in the (use…) in my repl
01:48rhebusI'd like to get the first item in a sequence which matches a predicate. (some pred coll) almost does this, but it returns (pred x) where I just want x. Is there a neat way to do this?
01:50talios(first (filter ..)) maybe>
01:50talios?
01:51rhebusyeah that makes sense
01:51brehauttalios: that looks right
01:52brehaut,(first (filter even? [1 3 4 5 6 8]))
01:52clojurebot4
01:52rhebusworks a treat
01:52rhebusthanks very much
01:52rhebusnot used to thinking in terms of lazy yet
01:52rhebusi had ruled out filter because it filters an entire sequence when i just want the first bit
01:54taliosthere may be a better way but that works ;) I really need to get myself back into some clojure myself
01:59rhebuscan't see how it could be improved much
02:09clizzinhow does nth interact with java classes that implement the List interface? it looks like first and second work just fine, but nth doesn't for some reason.
02:11taliosfrom memory - try (nth (seq your-list) 5)
02:12taliosor are those params the other way around. use (seq) to turn your list into a seq
02:14clizzintalios: hmm okay, so i guess nth only works on ISeq, but not on lists?
02:14clizzinLists* as in the java interface
02:17talios,(nth (Arrays/asList 4) 1)
02:17clojurebotjava.lang.Exception: No such namespace: Arrays
02:17talios,(nth (java.util.Arrays/asList 4) 1)
02:17clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to [Ljava.lang.Object;
02:17talios,(nth 1 (java.util.Arrays/asList 4))
02:17clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to [Ljava.lang.Object;
02:17talios,(nth 1 (java.util.Arrays/asList "4"))
02:17clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
02:18talios,(nth (java.util.Arrays/asList "4") 1)
02:18clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
02:18taliosbah
02:18talios,(nth (java.util.Arrays/asList ["4"]) 1)
02:18clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to [Ljava.lang.Object;
02:19taliosI *think* nth should work on lists mm
02:19brehaut,(nth 2 (java.util.Arrays/asList (object-array 4)))
02:19clojurebotjava.lang.ClassCastException: java.util.Arrays$ArrayList cannot be cast to java.lang.Number
02:19brehaut,(nth 2 (seq (java.util.Arrays/asList (object-array 4)))
02:19clojurebotEOF while reading
02:20brehaut,(nth 2 (seq (java.util.Arrays/asList (object-array 4))))
02:20clojurebotjava.lang.ClassCastException: clojure.lang.IteratorSeq cannot be cast to java.lang.Number
02:20talios,(nth (java.util.Arrays/asList (object-array 4)) 2)
02:20clojurebotnil
02:20brehautthats correct
02:20brehautthough difficult to tell if its meaningful ;)
02:21taliosheh
02:22brehaut,((juxt #(nth % 2) type) (into-array [1 2 3 4]))
02:22clojurebot[3 [Ljava.lang.Integer;]
02:22brehautthere you go
02:23brehauthah almost
02:24brehaut,((juxt #(nth % 2) type) (java.util.Arrays/asList (into-array [1 2 3 4])))
02:24clojurebot[3 java.util.Arrays$ArrayList]
02:25brehautso yes, nth does work on an arraylist
02:50clizzintalios, brehaut: oh i see, it only works on arraylists. that makes sense.
02:50clizzinthanks for the info
02:50ossareh(inc brehaut)
02:50sexpbot⟹ 3
02:50brehautwhat was that for?
02:50taliosdoes it? I would assume it works on all lists - creating an ArrayList was just easier
02:50ossarehbrehaut: you got a thanks :)
02:51brehautoh right. thanks ;)
02:51brehautwhats another list type/
02:51ossarehalso.. they're free.
02:51brehautheh they are
02:56brehautdoes doc metadata preceed or follow the symbol name in a def ?
02:59ossareh(doc def)
02:59clojurebotDENIED
02:59brehautbefore
02:59brehauthttp://clojure.org/special_forms
03:00brehautive written some extremely ugly code today. i think ive used 200% more loop / recur's that ive used in a few years of clojure
03:57clizzinanyone with experience with incanter know how i can make a histogram of string values? it seems like the histogram function only takes a seq of values as an argument
04:04clizzinwell, i achieved what i wanted with the bar-chart, but i'm still not sure why histogram doesn't allow one to count non-number values, unless i'm somehow missing the meaning of a histogram
05:37clgvis there some way to include external information into leiningen? I want to add the name of my git branch automatically to the name of the uberjar if that is possible
05:56fliebelclgv: Found an answer yet? I think it is possible in Cake, using a custom uberjar task.
05:57fliebelHm, I see room for a nice git integration in Cake :) That would give it a definite edge over Leiningen.
06:21clgvfliebel: no answer yet. but one insight maybe: project.clj seems to be "normal" clojure code. so maybe I can put a query in there
06:24fliebelclgv: That is certainly true. I always wondered why one does not need to (require 'lein)
06:24fliebelSo it might be that it is parsed, but not executed.
06:25clgvhumm that would be bad for me ;)
06:27fliebelhttp://clojure.github.com/clojure/clojure.core-api.html#clojure.core/read
06:28fliebelclgv: Is cake an option for you? I'm sure it's possible with custom tasks.
06:28clgvfliebel: I don't know cake at all
06:29fliebelclgv: For the basics, you can substitute lein for cake. Only in things like plugins and tasks, they differ.
06:30clgvI just tried. lein evaluates the statements in the project.clj
06:31fliebelgood for you :)
06:38clgvalmost there. now I just need a clojure api function to allow me a system call^^
06:42fliebelclgv: You mean like c.c.sh-utils?
06:42clgvmaybe. I have to check that one
06:43fliebelclgv: http://clojure.github.com/clojure-contrib/shell-out-api.html
06:59clgvfliebel: found a way to display the git branch on command prompt :D
06:59fliebelyay
07:02clgvyou can define a function like that: function parse_git_branch { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } in your .bash_profile or .bashrc and add a call to it to your PS1 string with \$(parse_git_branch)
07:41edoloughlin,(clojure.contrib.prxml/prxml [:email_addr nil "x@x.x"])
07:41clojurebotjava.lang.ClassNotFoundException: clojure.contrib.prxml
07:41edoloughlin[sorry]
07:41edoloughlinCan I rely on clojure.contrib.prxml ignoring nils?
07:42clgv&(doc clojure.contrib.prxml/prxml)
07:42sexpbotjava.lang.Exception: Unable to resolve var: clojure.contrib.prxml/prxml in this context
07:44edoloughlinThe docs don't say explicitly what it should to. It suits me at the moment that they are ignored, but if this changes...
07:44edoloughlins/should to/should do/
07:44sexpbot<edoloughlin> The docs don't say explicitly what it should do. It suits me at the moment that they are ignored, but if this changes...
07:45simardcan someone explain to me how this can be so fast ? http://pastebin.com/UfjWpmnY
07:45simardwhat part of it makes it lazy ?
07:46DespiteItAllisn't that just a single calculation?
07:46opqdonuterr it's just some arithmetic
07:47ejacksonyup
07:47DespiteItAllTo explain it, we'll have to start with the and gate ...
07:48simardreally, try to execute the (inc ) part
07:48simardwithout the mod
07:48simarderr..
07:49opqdonutoh, the arguments are _that_ way around
07:49simard?
07:49clgvbit-shift-left seems to be lazy
07:50clgv,(doc bit-shift-left)
07:50clojurebot"([x n]); Bitwise shift left"
07:50simardlol
07:51simardDespiteItAll: a single calculation that takes more than 2,357,207 digits
07:51simardin decimal notation..
07:51clgv,(let [res (time (bit-shift-left 2 7830))] (time (println res)))
07:51clojurebot"Elapsed time: 0.152 msecs"
07:51clojurebot2322180878515618467227753412562314309284874158963514658990419680703090047433767329645678945457651316808130685891008617227656964655976736171725333342949155665795039199339390...
07:52DespiteItAllAh, I made the same mistake as opqdonut, I thought you were shifting 7830456 2 places, rather than vice versa
07:52simard,(let [res (time (bit-shift-left 2 7830))] (println res))
07:52clojurebot"Elapsed time: 0.121 msecs"
07:52clojurebot2322180878515618467227753412562314309284874158963514658990419680703090047433767329645678945457651316808130685891008617227656964655976736171725333342949155665795039199339390...
07:52simard,(let [res (time (bit-shift-left 2 7830456))] (println res))
07:52simardmuhahahahaha
07:52clgv,(let [res (time (bit-shift-left 2 7830)) s (time (str res))] res))
07:52clojurebot"Elapsed time: 0.121 msecs"
07:52clojurebot"Elapsed time: 5.13 msecs"
07:52clojurebot232218087851561846722775341256231430928487415896351465899041968070309004743376732964567894545765131680813068589100861722765696465597673617172533...
07:53clojurebotExecution Timed Out
07:53simard:)
07:53simardthere you go
07:53simardclojurebot: I know, I know
07:53clgv,(let [res (time (bit-shift-left 2 78300)) s (time (str res))] res))
07:53clojurebotPardon?
07:53clojurebot"Elapsed time: 0.125 msecs"
07:53clojurebot"Elapsed time: 521.3 msecs"
07:53opqdonutprinting the number takes time
07:53clojurebot89061598438411090916318627017045455133984151351210558738733007166540398817989858004057107529611021945023100752825293692502273699551641224071379...
07:53clgvnope evaluating the number takes the time as my example shows
07:53Chousukewhat are you doing :P
07:53opqdonut"(do (inc (* 28433 (bit-shift-left 2 7830456))) 1)" is fast
07:54opqdonutand that shouldn't be lazy
07:54simardindeed
07:54clgvyou care to look at the source? ;)
07:55opqdonuthmm?
07:56clgvhmm it's just an adapter for the java implementation in Numbers
07:56opqdonuthmm, weird
07:56simardopqdonut: there you go
07:56simard:)
07:56opqdonutanyway, (def a (atom nil)) (do (swap! a (constantly (inc (* 28433 (bit-shift-left 2 7830456))))) 1) is also fast
07:56opqdonutno chance of laziness there
07:56opqdonutit's just the printing.
07:57simardopqdonut: sounds correct
07:57clgvhm well its getting pretty long indeed ;)
07:59simardit makes sense because after the mod is applied, there is only 10 digits to output, not 2,300,000. well I was pretty impressed at the speed of this calculation, and I thought perhaps that mod function could have a deeper meaning, but it doesn'T
08:00simardthe first way I did the calculation was by applying modulo at each step, and I was considering perhaps mod was some clever macro that did a similar trick
08:00clgvbut you should consider if your formula does allow to apply the mod earlier to speed up calculation
08:00simardclgv: I did that
08:00jcromartiehey LauJensen looks like on http://clojureql.org/examples.html the "Distinct" example code is wrong
08:00jcromartieshould be (defn distinct [table] (modify table :distinct)) no?
08:00clgvsimard: you can provide both timings?
08:01simardclgv: gimme a moment, I recall it was slower though.. perhaps I shouldn't apply mod at EVERY step
08:02simard(I was doing it by hand, let me try with modPow from bigint)
08:09clgvfliebel: got leining to use git branch and date in the name of the jars :D
08:09fliebelnice :)
08:10simardclgv: http://pastebin.com/z4y4KwBS
08:10simardthere you go
08:10simardmuch faster with a modPow
08:11clgvdefinitely^^
08:11simard:)
08:11simardas one would expect..
08:11clgvwell I guess you could be faster without using bigint at all ;)
08:12clgvbut the question is if it is worth the effort
08:14simardwell I'm doing this for fun anyway
08:14simardso.. maybe ;)
08:15simardwhat I would find interesting is a mod macro that takes normal math operations and makes the mod automatically
08:16clgvsounds fun. ;)
09:34TimMcdevn: I am successfully using emacs!
09:52dmiles_afk,(def (mod a b) (- a (* (/ a b) b)))
09:52clojurebotDENIED
09:52dmiles_afkthats correct syntax though right?
09:53dmiles_afk,(def (mymod a b) (- a (* (/ a b) b)))
09:53clojurebotDENIED
09:53opqdonutno
09:53opqdonut(defn mymod [a b] (- a (* (/ a b) b)))
09:53opqdonutif you want a function
09:56Kjellskiping?
09:56clojurebotPONG!
09:57jonkratzpastie: hi!
09:57jonkratzping?
09:57clojurebotPONG!
10:01SgeoI'm not bothering to learn Clojure, but I do have a quick question
10:01SgeoIn Racket, I can do (send* someobject (onemethod) (anothermethod) (yetanothermethod))
10:01SgeoI think
10:02SgeoIs there something similar in Clojure>
10:05jolymaybe doto would fit?
10:05joly,(doc doto)
10:05clojurebot"([x & forms]); Evaluates x then calls all of the methods and functions with the value of x supplied at the front of the given arguments. The forms are evaluated in order. Returns x. (doto (new java....
10:05cemerickor ->, depending on the semantics of send*
10:05clgvor ->
10:08shanmuHi, is there any example on using ring jetty adapter with a custom jetty xml file?
10:09shanmuor is it meant to be passed in via :configurator?
10:12clgvfliebel: as a resultat of exchanging the hash-map I used with the double array, I got a speedup of 0.2 seconds thats approx. 25%
10:12fliebelclgv: ?
10:12clgvfliebel: the performance tuning I was talking about here the last weeks ;)
10:13fliebelah :)
10:20shanmuI think I got the answer to my q. http://communitymapbuilder.org/display/JETTY/Embedding+Jetty gives a java example of how to do it - and it needs to be passed in as the configuration to run-jetty
10:57sritchie_hey all -- does any notion exist in clojure, or some other language, of an invertible function?
10:57sritchie_meaning -- could I define (defn add5 [x] (+ 5 x)), and run it backwards, without having to explicitly define the inverse?
11:00spewnsritchie_: J has this: http://jsoftware.com/help/dictionary/intro11.htm
11:00spewnI imagine the entire APL/J/K family does; not sure of any other languages that do.
11:01sritchie_spewn: hey, very cool
11:11jcromartieso can I use ClojureQL as a "data store?"
11:12jcromartielike, say, (def *users* (table :users))
11:12jcromartiethen I can conj! and disj!
11:12jcromartienice
11:27fliebeldnolen: I wrote a macro that lets you define full-adder-o for any base :)
11:50shanmuhi, this may be a basic question, but how would I get to use a java instance mehtod as a clojure function (to pass as an argument to a another clojure function)?
11:50clgvyou'll have to build a wrapper afaik
11:51raekshanmu: you need to make a clojure function like this: #(.method %)
11:51shanmuraek: ah, thanks!
11:52raekin java, methods are not objects so you need something like this
11:52shanmuyes... that's where I hit the wall
11:52shanmu#() ensures that it does not get evaluated
11:53cemerickshanmu: #() is an anonymous function literal
11:53raekyes, it's syntactic sugar for (fn [obj] (.method obj))
11:53naeuSo what's the current way of creating an executable jar with cake? I declared a :main namespace in the project.clj and inserted (:gen-class) in the namespace declaration. I then did a cake uberjar, and when I try and run it it can't find the class I specified as my main class...
11:54shanmucemerick: yes, thanks! I just thought aloud the place where I got stuck without using the anon function :)
11:54naeuI'm happy to be pointed to some relevant documentation....
11:54shanmuthis is all connected to passing a custom jetty config to ring jetty adapter
12:10shanmuIs there any documentation on integrating jaas with a ring webapp - I need to pass the jetty-web.xml to get access to the principal from within the webapp..is there any way to do it using ring?
12:15fliebeldnolen: ping
12:20bsteuberuser> (class (int 42))
12:20bsteuberjava.lang.Long
12:20bsteubershouldn't this be int?
12:21Chousukebsteuber: it gets boxed and promoted in the process I guess.
12:21bsteuberseems very weird to me
12:22fliebelbsteuber: Which version do you use?
12:22bsteuber1.3-alpha-4
12:22bsteuberso if it changes before 1.3 is't ok :)
12:23fliebelbsteuber: In 1.3, you should use ##(class (Integer. 23))
12:23sexpbot⟹ java.lang.Integer
12:23bsteuberthe thing is, I have an int value from java and want to give it back to java
12:23bsteuberand now I get problems because it's suddenly a long
12:25fliebelbsteuber: What are you doing to with in Clojure space? AS Chousuke said, numbers get promoted to long in 1.3.
12:25bsteuberbasically nothing, I'm just wrapping a java library and don't want to write Label/CONTENT_XHTML etc
12:26fliebelweird...
12:26bsteuberbut ok, I will write (def xhtml (Integer. Label/CONTENT_XHTML))
12:27bsteuberjust felt so strange to me :)
12:27bsteuberthanks
12:27timvisherhi all
12:30timvisheri'm looking for an hour long sales pitch for why anyone should care about Functional Programming. Something that would back up M. Halloway's assertion that Functional Decomposition is generally supperior to Object Oriented Decomposition with mutable state
12:31Adamant1. parallelism
12:31Adamant2. (potential) security
12:31Adamant3. reliability
12:32Adamant4. more mathematical tools being applicable
12:32Adamant(OOD with mutable state is hard to mathematically model)
12:33Adamantwhen in doubt, emphasize our multicore future
12:34apgwozwhat's the recommended parsing tool for when sexps aren't appropriate? fnparse?
12:35chouser"when sexps aren't appropriate"!? heresy!
12:35apgwozchouser: i know, i know. there should be no other language!
12:35chouser:-)
12:36chouserI still haven't tried anything except ANTLR (which I wouldn't generally recommend), but there's also cgrand's parsely
12:38raektimvisher: a purely functional progam never has problems with action-at-distance. mutable state is the new everything in global variables
12:38apgwozchouser: i'll have to look more closely at parsely. thanks for the tip
12:38timvisherAdamant: I'm not actally trying to sell Clojure. It's for a Functional Programming Lunch Study group. Last time we basically came to the conclusion that while we all 'sense' that FP is awesome, but none of us can really articulate why
12:39timvisherWe're all long time OO people so it's a big jump for us
12:39Adamanttimvisher: those apply to more than just Clojure
12:39Adamantthey're a general property of most full scale FP languages
12:39timvisherI know
12:39Adamantah, just looking for general resources?
12:39timvisherBut the Multicore doesn't necessarily, except that non-mutable state is freely shareable
12:39Adamantyou could try mining The Simon's
12:39Adamantof Haskell fame
12:39Adamantlots of papers on the advantages and disadvantages there
12:40Adamant(Simon Marlow And Simon Peyton-Jones)
12:40timvisherraek: agreed, I'd just love to be able to find a paper, blog, or video where someone in a language agnostic way, defines why FP is 'better' than OO in certain (many?) contexts
12:41timvisherAdamant: I could look into them. Any recommendation on where to start?
12:42Adamanttheir websites and early "FP is awesome, pay attention" papers
12:42AdamantIIRC both of them are out of MS Research currently
12:42bsteubertimvisher: to me, the main point seems to be composability
12:43bsteuberthat is similar on large and small scales
12:43timvisherbsteuber: That's definitely a huge point that all of us see and none of us seem to understand
12:43raekhttp://www.cse.chalmers.se/~rjmh/Papers/whyfp.pdf
12:43raek"Why Functional Programming Matters"
12:44timvisherraek: thanks, that looks very interesting
12:45dnolenfliebel: pong. Cool about the full-adder-o for any base!
12:47technomancyclojurebot: google out of the tarpit
12:47clojurebotFirst, out of 21200 results is:
12:47clojurebotOut of the Tar Pit
12:47clojurebothttp://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.93.8928&amp;rep=rep1&amp;type=pdf
12:47technomancytimvisher: I recommend the above
12:48timvishertechnomancy: thought that was for me. ;)
12:49timvisheralright, i should start paying attention to this Ruby presentation again. Thanks for the pointers, everyone!
12:52amalloysritchie_: prolog has inverse-ish stuff, iirc
12:54sritchie_amalloy: interesting, I've been meaning to look at prolog. I'm using cascalog, and it'd be nice to understand the basis for some of the cascalog decisions
12:58ejacksonthe world seems to be getting in logic programming - why is this ?
13:00fliebelejackson: The whole world, as in other people than you, me and dnolen?
13:00ejacksonnot me ! I just dabbled to try figure out what was going on.
13:00ejacksonbut it was too hard for me :)
13:00fliebelejackson: I thought you read TRS...
13:00amalloyejackson: if it makes you feel better i'm just repeating what i vaguely remember from senior year :P
13:01Cozey$findfn ['(:a 2) '(:b 5)] {:a 2 :b 5}
13:01sexpbot[]
13:01amalloyCozey: ##(into {} [[:a 2] [:b 5]])
13:01sexpbot⟹ {:a 2, :b 5}
13:01danbell'(doc hash-map)
13:01danbell,(doc hash-map)
13:01clojurebot"([] [& keyvals]); keyval => key val Returns a new hash map with supplied mappings."
13:01amalloynote that the pairs have to be vectors, not lists: vectors are special
13:02amalloyor do it danbell's way: ##(apply hash-map (apply concat ['(:a 2) '(:b 5)]))
13:02sexpbot⟹ {:a 2, :b 5}
13:03Cozeymm I did apply array-map (mapcat ...
13:03danbelli like amalloy's way better
13:03Cozeyinto is nice
13:04amalloy(into {} ...) is so common it really should have its own name
13:04CozeyI never used it but instantly see so many places asking to change into into
13:04fliebeldnolen: In adder-o, they check for (== '(1) n), which is fine for binary, but doesn't work for decimal. I think I can replace 1 with a fresh variable. Does that sound correct? And, is Logos trampolining somewhere, or do I need to avoid stack overflows myself?
13:05amalloyheh
13:10danbell,(doc into)
13:10clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
13:23dnolenfliebel: I'm not sure about the arithmetic stuff, I only browsed that part of the book. And no, you don't need to worry about stack overflow w/ recursive miniKanren programs if that's what you're asking.
13:24fliebelokay, I'll just try and test.
13:31fliebeldnolen: Does a vector unify with a list?
13:32fliebelapparently: (run* [q] (== '() q) (== [] q)) => (())
13:34dnolenfliebel: you're unifying an empty list w/ an empty vector, so you're going to get back and empty list.
13:34dnolenfliebel: I think order matters in this case, try the reverse unify a vector w/ an empty list
13:35fliebeldnolen: A list of empty lists. (run* [q] (== '(1) q) (== [1] q)) => ((1)), (run* [q] (== [1] q) (== '(1) q)) => ([1])
13:36dnolenfliebel: yeah that's what I'd expect.
13:36fliebelso yea, the result is different, but I can use vectors in place of this ufly quoting.
13:36fliebel*ugly
13:38fliebelhm, is `(,a . ,x) the same as (lcons a x)?
13:41dnolenfliebel: no. Clojure doesn't support pairs.
13:41fliebeldnolen: So what do I do with them?
13:41dnolenfliebel: er, I mean yes, that is the correct translation.
13:42fliebelright :) *holds breath*
13:42dnolenfliebel: also see llist. (llist 'a 'b 'c x), where x is a logic var.
13:42fliebeldnolen: Is that like (a b c . d)?
13:42dnolenfliebel: yes.
13:43fliebelI did a nested lcons for that so far. will replace
13:47fliebeluh-oh, something isn't right… (run* [q] (adder-o 0 [1] [1 0 1] q)) => ((0 0 1) (0 1 1)) decimal is even more broken :(
13:48LauJensenjcromartie: Thanks for the heads up
13:49jcromartieyup
13:49dnolenfliebel: whenever you think you've found another bug, create an issue with the code and the actual output vs the expected output.
13:50jcromartieLauJensen: I am really "getting" ClojureQL now... treating tables and queries as something to be dereferenced
13:50fliebeldnolen: I'll trace my own logic first. I might have brokens something while converting.
13:50LauJensenjcromartie: liking it ?
13:50jcromartieyes
13:50jcromartieseems like a very pure way to interact with SQL
13:50LauJensenGreat, thanks for the feedback
13:50ejacksoni'll second the motion, ClojureQL rocks out.
13:50LauJensen:D
13:50jcromartiestrikes me as very close to relvars from "Tar Pit"
13:51jcromartiebut still in the "accidental" realm :P
13:51fliebeldnolen: I think it's the fresh var I added. I'll check that.
14:06dmiles_afkCan ClojureCLR register event handlers?
14:08fliebelMan, decimal is so much easier to reason about...
14:12brehautwhats the syntax to get opening and closing square bracket chacters into a regexp character class?
14:15LauJensenbrehaut: the syntax is: dont use regex
14:16brehautLauJensen: that was my solution too
14:16brehautive been asked to rewrite the code with them
14:16mids,(re-find #"\[xyz\]" "abc[xyz]t")
14:16clojurebot"[xyz]"
14:16midslike that?
14:16fliebeldnolen: This appears to work! https://github.com/pepijndevos/logos/commit/d844d245655a14579ead376b244053b08d2d479c
14:17brehaut,(re-find #"[\[\]]" "[")
14:17clojurebot"["
14:17brehauthuh
14:17brehauti was using too many \'s
14:18dnolenfliebel: cool! look forward to checking that out :)
14:19fliebeldnolen: I'll implement devision and multiplication another day, as well as a way to switch between bases, and some tests.
14:19fliebeldnolen: I welcome any comments :)
14:21fliebelMy feeling is that binary is faster than decimal, because decimal has 200 cond-e clauses, but I'll have to test that. ;)
14:21dnolenfliebel: looks pretty good to me. I've been reading through pattern-matcher miniKanren paper, hoping to work those ideas in the next couple sweeks. miniKanren programs become much more concise .
14:21dnolenfliebel: ha
14:22fliebeldnolen: What does the pattern matcher do?
14:24dnolenfliebel: think Clojure destructuring - but more sophisticated, it automatically creates vars and does unification.
14:24fliebeloh!
14:24dnolenvars -> logic vars I mean.
14:25fliebeldnolen: Any examples yet?
14:28dnolenfliebel: the first part of adder-o would look something like this, https://gist.github.com/839192
14:28zanes
14:29fliebeldnolen: That hurts, and rocks!
14:30ouncehi
14:30amalloybrehaut: java's regex engine isn't entirely perl-compatible. [][] is supposed to match open or close square brackets, but it doesn't
14:31fliebeldnolen: After second thought, it just rocks.
14:32fliebeldnolen: This is the stuff that is in prolog.clj, right?
14:33dnolenfliebel: that's not working code, just sketches on a reasonable Clojure syntax.
14:33fliebelI know
14:37brehautamalloy: just another facet of the delightful world of regexp
14:41amalloybrehaut: c'mon, [][] is pure gold
14:41brehautamalloy: no doubt
14:43brehautwhat is the idiomatic way of testing a string for emptyness?
14:43brehaut(seq "")
14:43brehaut?
14:44mrBlissbrehaut: I usually use (empty? "")
14:45brehautsorry, i got myself backwards. non-emptyness
14:46amalloybrehaut: i use seq
14:46amalloyeg ##(filter seq ["test" "" "empty"])
14:46sexpbot⟹ ("test" "empty")
14:47fliebel&(zero? (.length ""))
14:47sexpbot⟹ true
14:47dnoleni wouldn't use seq on string unless you know you're not going to test empty-ness non-emptyness often. It's like 25X slower than just checking (.length s)
14:48brehautdnolen: ok thanks
14:49dnolenbrehaut: clojure.string/blank?
14:49dnolen(doc clojure.string/blank?)
14:49amalloybrehaut: time to go point-free with (comp pos? (memfn length))?
14:49clojurebotI don't understand.
14:49dnolen,(doc clojure.string/blank?)
14:49clojurebotI don't understand.
14:49dnolenerg
14:49amalloydnolen: clojure.string isn't loaded, so the doc macro results in a read error
14:50amalloy,(require 'clojure.string)
14:50clojurebotnil
14:50amalloy(doc clojure.string/blank?)
14:50clojurebot"([s]); True if s is nil, empty, or contains only whitespace."
14:51brehautim just going to use (> (.length s) 0)
14:51brehauti need to trim the string anyway
14:52amalloyboo
14:54brehautamalloy: ive already been asked to revise my code to make it simplier and shorter, im not going to go complicating it with point free ;)
14:56Draniksorry I was disconnected
14:56Dranikso once again: how to compile leiningen project?
14:56jweisscan someone recommend a way to do list comprehension and also have access to the index of the list item you're on?
14:57jweissi suppose loop with nth is one way, but that seems ugly
14:58brehaut(for [[x i] (map vec s (range))] [x i]) ?
14:58noidior you can use clojure.contrib.seq/indexed
14:58noidi(for [[i x] (indexed [:a :b :c])] [i x])
15:00brehautor (for [[i x] (map-indexed vector [:a :b :c])] [i x])
15:02jweissbrehaut: thanks, map-indexed is pretty handy
15:08amacanyone familiar with aleph know how to pull POST data out of a request?
15:09fliebelamac: Aleph is just Ring, right?
15:10amacI'm pretty sure it uses ring, yeah
15:10fliebelamac: It's :query-string I guess: https://github.com/mmcgrana/ring/blob/master/SPEC
15:10amacthat pulls get data only :(
15:11amacpost data seems to be locked in the :body as a bytebuffer... can't seem to get the data out though, nor am I even sure that's actually the post data
15:13raekamac: I think wrap-params handle this: http://clojuredocs.org/ring/ring.middleware.params/wrap-params
15:14raekif the post data is url-encoded (e.g. from a html form) then I think the data ends up in :form-params and :params
15:21amacraek: that looks like the ticket, specifically assoc-form-params in that middleware shows how they pull the data out. Thanks! :D
15:31clizzinlet's say that when my program gets an http request, i want it to spawn a long-running thread and immediately send back an http response without waiting for the thread to finish. what's the most idiomatic way to do this in clojure? a future that's never dereferenced? a plain old java thread? something else?
15:32chousera future that's never dereferenced is pretty common
15:32jweisshrm. appears that i cannot use a macro to generate defn forms that have metadata on the symbol. will using def let me throw in (with-meta)?
15:33jweissi mean, my macro will let me use the reader macro ^, but that only lets me put hardcoded metadata in there, instead of being able to pass it to my macro.
15:35brehautjweiss: (with-meta value meta-dict)
15:36brehautoh, you mentioend taht already; my bad
15:36jweissbrehaut: can't do that, try (defn (with-meta mysym {}) [] (println "hi"))
15:36jweisssays first arg to def must be a symbol.
15:36raekjweiss: (defmacro defstuff [name foo bar] `(defn ~(with-meta name ...) ...))
15:36brehautactually
15:36brehautwhat raek said
15:37raekjweiss: what does your macro look like?
15:37amalloywhy do you want meta on the symbol instead of the var?
15:38jweissamalloy: um, when you use the reader macro, it goes on the symbol, no?
15:39amalloyjweiss: not as far as i can tell
15:39amalloy(defn ^{:private true} testfn []),,,,(meta #'testfn)
15:40jweissamalloy: what do you think that does
15:40jweissi thought it places the meta on the next symbol
15:40jweisswhich is testfn
15:40amalloyjweiss: your point is that the meta is attached to testfn before the form is evaluated, and that defn copies it from the symbol to the var?
15:41jweissamalloy: i guess so, hadn't really thought about that :)
15:41amalloyneither had i
15:41jweissis there a way to put it on the var directly?
15:42jweissraek, i want my generated defn's meta to include meta from another fn, which i pass in.
15:42jweissi don't think i can get to that at compile time, so i have to create code that evaluates at runtime... i think :)
15:43amalloyjweiss: actually attaching it to the symbol seems to work too
15:43amalloy(defmacro def-private [name & body] `(defn ~(with-meta name {:private true}) ~@body))
15:43jweissyeah, if you use defn and the reader macro
15:43jweissamalloy: but that only works with data that's available at compile time
15:44jweissi don't know that the meta of my argument is available then
15:44jweissi
15:44clizzinchouser: thanks!
15:44jweissam pretty sure it isn't.
15:44amalloyjweiss: what is the point of defn'ing a var that you don't know about at compile time? nobody will ever access it by name then
15:44raek,(doc defn)
15:44clojurebot"([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any do...
15:44jweissamalloy: well, it's known at compile time, i just don't know how to get it :)
15:45raekthe map at the attr-map place will also be merged into the metadata
15:45amalloyi suggest that you address that issue then, instead of trying to declare functions at runtime :P
15:46jweissamalloy: ok so if i pass my macro a symbol that's an existing function, how do i copy the meta of that function to the one i'm generating :)
15:46amalloydon't do it that way. you want to define N functions that all have the same meta, right?
15:46jweissamalloy: no, the meta is different for each one.
15:47amalloythen...you don't want to copy meta. what do you want to do?
15:48jweissamalloy: i was just trying to simplify the problem for you. i want to merge the meta with a bit more data (let's say if i'm generating 10 defns, the index of it, 0,1...10)
15:49amalloyso you want something like (def-indexed (^:private foo [n] body) (^{:arglists []} bar [] body))
15:50amalloyessentially, instead of calling your magic macro ten times, have your macro wrap ten defns
15:50amalloythen it can do the counting itself
15:58jweissamalloy: that's what i was doing. the problem is taking the symbol i pass in and getting the meta from it, kept getting nil
15:59jweissoh... hm. i might see why that was happening
15:59amalloyjweiss: i just wrote it. gisting momentarily
16:00amalloyjweiss: https://gist.github.com/3d5d85f19505295c9a32
16:01raekjweiss: do you want metadata from an already defined var? in that case, you need (meta #'foo) or (meta (resolve 'foo))
16:02jweissraek: aha, yes, i need that
16:02jweissamalloy: nice hint with vary-meta
16:02jweissi think between those two suggestions i'll get it
16:04raekthe fact that 'def' copies metadata from the symbol to the new var might make the matter confusing here. the symbol 'foo and the var #'foo are not the same thing.
16:05jweissraek: yeah, until amalloy mentioned it, i never thought about how it got from one place to the other.
16:19_schulte_Adding slime support for common lisp, totally broke slime-connect for connecting to a lein swank session, does anyone have this working (i.e. clj and cl) who can suggest a workaround?
16:35joegalloIf I send-off and then immediately await on an agent, and the sent-off function throws an exception, then my program appears to hang on the await. Even though the agent ends up failed after the sent-off function is executed -- my await snuck in beforehand. Am I doing it wrong?
16:38amalloy&(let [a (agent 0)] (send-off a #(throw (Exception. "test"))) (Thread/sleep 1000) (await a))
16:38sexpbotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: sandbox6385$eval13022$fn
16:39amalloyjoegallo: hm. that is weird behavior, and i can reproduce it. i think there's an option you can set on your agent, somewhere
16:41Despite1I think the await docs say that will happen
16:41amalloyDespite1: they do, but it doesn't seem to happen if you don't await until after the exception has been thrown
16:41jcromartie"Will block on failed agents."
16:42amalloyjcromartie: (await a), when a is an agent that has already failed, throws an exception
16:43amalloyif a is an agent that hasn't failed, but will, it blocks
16:43Despite1oh interesting
16:43Despite1Makes a bit of sense
16:46joegallookay, i see. that makes lots of sense.
16:47joegalloat least, in terms of the docs...
16:48technomancy_schulte_: I don't know, but if you figure it out I would love to get a patch documenting that.
17:08TimMc,^{:single}[]
17:08clojurebotjava.lang.ArrayIndexOutOfBoundsException: 1
17:09TimMc,{:single}
17:09clojurebotjava.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
17:09TimMcInteresting that those throw array index exceptions. I would expect something more informative. :-/
17:11amalloy,(hash-map :a)
17:11clojurebotjava.lang.IllegalArgumentException: No value supplied for key: :a
17:12LauJensenTimMc: You expected an informative error message? You must be new here, welcome to #clojure :)
17:57dnolenhuh, anybody use dynamic binding for flow-control? like (binding [*some-continuation* (fn ...)] ...)
18:00rata_hi
18:01rata_how do I really force cake to recompile and install a jar of my project?
18:01rata_I've tried with "cake compile force; cake install" but it doesn't work
18:01amalloyrata_: cake clean && cake install?
18:01rata_amalloy: doesn't work
18:03amalloyrm -f *.jar && cake install :P
18:06rata_amalloy: doesn't work either
18:07rata_do I need to do something special at the project that's using this other project?
18:08rata_(beside "cake kill && cake swank")
18:09amalloyrata_: cake deps
18:10amalloypossibly cake deps force; the deps stuff never made any sense to me
18:11rata_ok, I'll try that
18:12rata_is there a way to tell cake just refetch one dep?
18:14rata_amalloy: thanks a lot! cake deps force is what I was missing
18:14dnolenhmm was there ever any talk around scopes concerning preserving bindings for lazy computations ?
18:14rata_it'd be nice if project-local jars were just links to the maven repo
18:15amalloydnolen: there was certainly talk about it
18:15amalloyi didn't pay much attention, but i think the general opinion was it was a bad idea
18:15dnolenamalloy: link to relevant irc or ML conversation?
18:16amalloydnolen: fraid not. your google will be as good as mine for this one
18:16amalloyit was on ml though, not irc
18:16dnolenamalloy: any recollection on why people thought it was a bad idea?
18:19amalloyummmm, not really. i'm not even sure that was the eventual decision; i might be getting it confused with keeping resources open in scopes
18:20amalloydnolen: aha, i think it's http://groups.google.com/group/clojure-dev/browse_thread/thread/627b2aaa59329d04
18:24rata_amalloy: do you know if there's a way to tell cake to refetch just one dep?
18:24amalloyi don't think there is, but i'm not a cake dev
18:27dnolenamalloy: thx for the link, there's nothing there about it being a bad idea tho, in fact stuartsierra's saying scopes could possibly solve it.
18:27stuartsierraeh, what/
18:27stuartsierra?
18:28dnolenstuartsierra: http://groups.google.com/group/clojure-dev/browse_thread/thread/627b2aaa59329d04
18:31stuartsierraoh, that
18:46dnolenhmm can only vars installed by the runtime be changed with set! ?
18:47rata_dnolen: iirc just binding'ed vars
18:48dnolenrata_: so things like *warn-on-reflection* and *unchecked-math* are exceptions?
18:48rata_dnolen: I don't know
18:49rata_just something I read in clojure.org (iirc, again)
18:56amalloydnolen: http://clojure.org/Vars#Vars%20and%20the%20Global%20Environment--%28set!%20var-symbol%20expr%29
18:57amalloywhat i get from that is that you have to give the var a root value before you can set! it thread-locally
18:58amalloybut that there are no "exceptions" for certain vars
19:02dnolenamalloy: this doesnt seem to work (do (def ^:dynamic *some-flag* nil) (set! *some-flag* true))
19:05amalloydnolen: (binding [*some-flag* nil] (set! *some-flag* true) *some-flag*)
19:06amalloynot really sure why this works, but it does
19:06dnolenamalloy: but you don't need to do what with *warn-on-reflection*, I suppose the compiler does something behind the scenes.
19:07amalloyi suspect that *w-o-r* works because the repl establishes a binding for it
19:07amalloy(not necessarily the compiler)
19:08dnolenrelated, now that you have binding conveyance, is it not possible to fork a thread with a binding, and compute a lazy sequence in that thread?
19:08dnolenthus avoiding the lazy-sequence can't see the binding?
19:08dnolenor rather the binding goes out of scope I mean.
19:13gfrlogIs http.async.client the thing to use for doing that?
19:17dnolenhmm, lazy-sequences are always computed on the main-thread ...
19:17dnolen,(let [t (future (repeatedly #(.getId (Thread/currentThread))))] (println "id:" (.getId (Thread/currentThread))) (println (take 1 @t)))
19:17clojurebotid: 616
19:17clojurebot(616)
20:00danbellis there a way to have swank-clojure execute the (ns (:use), etc.) statement of the .clj file you're editing in emacs?
20:03amalloydanbell: C-c C-k loads the whole file, including ns stuff. to change the namespace the prompt is "in", C-c M-p
20:05danbellamalloy: oh hey, it worked! Thanks!
20:35david` /whois redinger
20:35david`haha
20:57TimMc$findfn [4 6 2 3] 6 1
20:58spewnTimMc: sexpbot timed out about 4 hours ago
20:58TimMchrmf
21:01TimMcIf (get-in {:a [4 5]} [:a 1]) => 5, is there a (foo {:a [4 5]} 5) => [:a 1] ?
21:04SgeoI take it there will never be tail-call optimization in Clojure?
21:05TimMcSgeo: Depends on what happens with the JVM.
21:06SgeoGiven that I'm not at all tied to the JVM, what reasons are there to use Clojure instead of, say, Racket?
21:07dnolenSgeo: in the mean time there are solid tools to write tail-call style code, and it performs at least as well as Racket (which isn't slow) as far I can tell.
21:08joegalloSgeo: the java libraries that come along for the ride are pretty nice to have IMO
21:08dnolenSgeo: data structures are the central part of any program. The design of the data structures in Clojure are much more thought out, and the interface are available to extend, reimplement.
21:09spewnSgeo: With regard to data structures, you might want to read http://programming-puzzler.blogspot.com/2010/08/racket-vs-clojure.html
21:09Sgeospewn, that's pretty much the only reason I'm looking at Clojure, despite the objection of some of my friends'
21:10SgeoAlthough at least some of their objections seem to be more about the community >.>
21:10dnolenSgeo: which isn't to say you shouldn't use/learn Racket. I spend a good deal of time using Racket these days.
21:10SgeoIt looks like Racket is less of a language and more of a ... JVM/.NET competitor
21:10dnolenSgeo: people w/ strong opinions about the various good Lisp dialect are suspect (aka don't know what their talking about).
21:11dnolenSgeo: huh? No. Racket is performant Scheme, w/ a boatload of many many useful extensions.
21:12Sgeodnolen, I guess I'm thinking since it's somewhat easy to define one's own language that interoperates with others...
21:12Sgeo(Not that I've tried it)
21:14SgeoI must admit I do kind of wish Clojure just came with an IDE >.>. I'm lazy >.>
21:15dnolenSgeo: even if it did, it wouldn't beat the Racket IDE any time soon, a good 15 years of work has gone into it.
21:19TimMcDrScheme is pretty fly.
21:19TimMcExcuse me, DrRacket.
21:25SgeoI guess it's not obvious to me how DrRacket's interesting functionality is more than REPL on bottom that gets executed in the environment of running the code on top
21:25SgeoIs at least that much for Clojure difficult?
21:27Sgeo(binding [x 2 y 3]
21:27Sgeo (+ x y))
21:27SgeoI just know that Racket would write it like:
21:27Sgeo(binding ([x 2] [y 3])
21:27Sgeo (+ x y))
21:27SgeoComing from a non-Lisp background, guess which is easier on my mind?
21:28dnolenSgeo: it has good paren matching, syntax highlighting, macro stepper, debugger, tabs, integration with Planet, REPL history, integrated docs, etc. etc. etc.
21:28SgeoLet's implement Clojure in Racket!
21:30dnolenSgeo: don't see much point in that. Clojure gets numerous non-trivial performance benefits from the JVM.
21:30SgeoAccording to Wikipedia, Clojure has an emphasis on recursion. How?
21:31TimMcIt's a lisp?
21:31TimMc:-P
21:31SgeoI meant, considering the lack of TCO
21:31TimMcRecursion has to handled a little differently in Clojure. I wouldn't say there's an "emphasis".
21:32dnolenSgeo: http://dosync.posterous.com/continuation-passing-style-in-clojure
21:33dnolenlazy-sequences, trampoline, recur explicitly get you what Scheme does automatically (which I admit is nice).
21:36SgeoHow much Java do I have to understand to have a good grasp of Clojure?
21:36SgeoI mean, I do know C#, which is like Java but somewhat decent >.>, so...
21:37Sgeo[So says the hypocrite, who yells at Java for lacking lambdas but likes Python]
21:37greghfamiliarity with the java libraries is helpful if you want to do useful stuff with clojure
21:38dnolenSgeo: I prefer to focus on the Lispy elements of Clojure and it's quite easy to live there. But if you want build production apps, you're probably gonna want to pull in some Java libs.
21:42dnolen,(let [t (future (repeatedly #(.getId (Thread/currentThread))))] (println "id:" (.getId (Thread/currentThread))) (future (println (take 1 @t))))
21:42clojurebotid: 618
21:42amalloyTimMc: .indexOf will do what you want for vectors, but anytime you touch an index you should seriously rethink why you're doing that
21:42clojurebot#<core$future_call$reify__5500@168db68: :pending>
21:42dnolen(let [t (future (repeatedly #(.getId (Thread/currentThread))))] (println "id:" (.getId (Thread/currentThread))) @(future (println (take 1 @t))))
21:42dnolen,(let [t (future (repeatedly #(.getId (Thread/currentThread))))] (println "id:" (.getId (Thread/currentThread))) @(future (println (take 1 @t))))
21:42clojurebotid: 621
21:43amalloyalso, i guess Raynes isn't around, so i'll see if i can get sexpbot going again
21:43dnolenbinding conveyance in 1.3.0. is really nice, no more future-out silliness.
21:44TimMcamalloy: I have a vector of control points for a higher order Bézier curve. The user is dragging one vertex. I identify the vertex in the first place by scanning the vector for the first Point2D under the mouse's coordinates.
21:45TimMcCurrently I replace the element with a new Point2D every time the user drags the vertex. I do this with (map #(if (identical? % old) new %) verts). Seems like using an index might be better.
21:46amalloyTimMc: ##(doc replace)
21:46sexpbot⟹ "([smap coll]); Given a map of replacement pairs and a vector/collection, returns a vector/seq with any elements = a key in smap replaced with the corresponding val in smap"
21:46TimMchmmm
21:47amalloyalso, ##(.indexOf [1 2 5 6 8] 6) ; hopefully works? :P
21:47sexpbot⟹ 3
21:48TimMcIs = going to be fast and accurate for comparing two Point2D$Double objects, compared to identical? ?
21:48amalloyprobably not
21:48TimMcIn this case, I know I have a pointer to the same object that I want to replace.
21:49amalloybut indexes do seem like a more appropriate choice for this problem
21:49TimMcI mean, map does *work*.
21:50TimMcI'm just trying to get a sense of whether this optimization is worth the fragility it might add.
21:50Sgeolet is for lexical scoping, binding for dynamic scoping?
21:50amalloySgeo: yes
21:50SgeoWhy does it feel weird that I first learned about dynamic scoping from Factor?
21:51TimMcreplace has to be the worst-named function I've seen so far.
21:52TimMcRather, the behavior with vectors doesn't make sense.
21:52amalloy&(replace {1 2} (vec (range 10)))
21:52sexpbot⟹ [0 2 2 3 4 5 6 7 8 9]
21:52amalloyTimMc: what's the problem?
21:53TimMc&(replace [10 11 12 13] [0 3])
21:53sexpbot⟹ [10 13]
21:54amalloyTimMc: vectors are maps of their indices
21:54TimMc&(replace [10 11 12 13] [0 3 15])
21:54sexpbot⟹ [10 13 15]
21:54TimMchrm
21:54TimMcIt feels icky.
21:56SgeoWhy the discrepency between some and not-any?
22:00amalloySgeo: hard to answer unless you say what the discrepancy is
22:01SgeoI meant in terms of names. Why not any and not-any?
22:06Sgeo(get popsicle-map :green)
22:06Sgeo(popsicle-map :green)
22:06SgeoWould I be able to make my own values that can be called as functions?
22:06SgeoThat aren't merely functions/
22:07mattdwSgeo: I assume you'd just have to implement the IFn interface
22:07amalloyindeed that is the case
22:08SgeoI'm nowhere near reading about that yet
22:08amalloySgeo: some is different from any. filter is functionally the opposite of not-any?, if you want
22:11amalloyor perhaps (comp seq filter)
22:12Sgeo-?> reminds me of the Maybe monad...
22:18Sgeodefmulti is like Factor's GENERIC: and defmethod is like Factor's M:
22:18SgeoAs far as I can tell
22:19SgeoClojure's defmulti seems to be a bit more flexible
22:22spewn,(doc -?>)
22:22clojurebotNo entiendo
22:22spewnSgeo: What is that?
22:23Sgeo"There is also a -?> macro in the clojure.contrib.core namespace that stops and returns nil if any function in the chain returns nil. This avoids getting a NullPointerException."
22:24spewnAh, in c.c. Thanks.
22:24Sgeo-> feels backwards, as does comp
22:25SgeoThen agian, I haven't actually tried it
22:26SgeoHuh.
22:26SgeoPython just got something like memoize
22:28illuminati1113Anyone use Clojure on Android?
22:28sattvikilluminati1113: I do.
22:29spewnsattvik: That was your app I tried on my phone... Very slow, but cool!
22:29illuminati1113sattvik: I'm trying to instantiate a SurfaceViewwith gen-class.
22:30illuminati1113Can this be done?
22:31sattvikspewn: Thanks. Unfortunately, to get dynamic compilation working it has to use the disk, which is very slow. I hope to be able to do in-memory compilation someday.
22:32sattvikilluminati1113: Hmm.. I think so. Depending on the context, it may be easier to use proxy.
22:33DespiteItAllHow do I unload a namespace after accidentally "use"ing it
22:33illuminati1113I can't use proxy because it needs to use a a protected method.
22:33illuminati1113Proxy can't access those I don't think.
22:34sattvikilluminati1113: They can, so long as they're not final, I believe.
22:34spewn,(doc remove-ns)
22:34clojurebot"([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace."
22:34illuminati1113Do you need to use reflexion for that?
22:35DespiteItAllThanks, that seems to be what I need
22:36sattvikIn what sense? There is nothing special you need to do in your Clojure code with the proxy. Whether or not Clojure uses reflection internally, I am not sure.
22:37illuminati1113"Note that while method fns can be provided to override protected methods, they have no other access to protected members, nor to super, as these capabilities cannot be proxied."
22:38illuminati1113The problem is that the proxy function is defined within the proxy namespace.
22:38amalloyilluminati1113: override the protected method as public, then call it
22:38amalloyoh right, but super
22:38illuminati1113amalloy: I did that using gen-class.
22:39illuminati1113But I still get an error and don't know why.
22:42sattvikilluminati1113: Ah, yes, you're correct about the proxy. With gen-class, have you tried exposes-super?
22:42illuminati1113,(doc exposes-super)
22:42clojurebotIt's greek to me.
22:42sattvik,(doc gen-class)
22:42clojurebot"([& options]); When compiling, generates compiled bytecode for a class with the given package-qualified :name (which, as all names in these parameters, can be a string or symbol), and writes the .cl...
22:43sattvikWell, there's an option to provide a map for :exposes-super in gen-class.
22:43illuminati1113do you mean exposes-method?
22:43sattvikYes, that's right.
22:43amalloy&(doc gen-class)
22:43sexpbot⟹ "Macro ([& options]); When compiling, generates compiled bytecode for a class with the given package-qualified :name (which, as all names in these parameters, can be a string or symbol), and writes the .class file to the *compile-path* directory. When not compiling, ... http://gist.github.com/839968
22:43illuminati1113That's what I'm using.
22:43amalloyfor docs that don't truncate :P
22:44sattvikHave you tried not using exposes-method, and just calling (.protectedMethod this ...)?
22:45illuminati1113Yes.
22:45illuminati1113It's the same error either way.
22:47illuminati1113https://gist.github.com/839973
22:47illuminati1113Is my current code.
22:55illuminati1113sattvik: I'm going to just extend this class in Java and call it from Clojure. I know that works. Thanks.
22:55illuminati1113BTW, I've been reading your articles on Clojure on Android. I've been finding them useful; keep them up.
22:55sattvikilluminati1113: Alright... I'll look at it a bit more since it's something I think I've run into before with AsyncTask.
22:56sattvikThanks. I am glad they have been useful.
22:58SgeoHow is Clojure-in-Clojure doing?
23:05sattvikilluminati1113: I think you ran into the exact same bug I did. There is no access to protected *fields*, but there should be access to protected *methods*. The problem you ran into is that, like me, you tried to use a protected final method. I believe that's a bug.
23:08illuminati1113sattvik: Is this an Android or Clojure bug?
23:09sattvikilluminati1113: It's a Clojure bug (CLJ-744). I think that gen-class/proxy try to do some filtering as to what methods should be exposed, and protected final methods don't seem to be making the cut.
23:11illuminati1113sattvik: I see. Thanks, that means there's some hope for seeing it fixed!
23:12illuminati1113I'll look at myself at least.
23:19SgeoYay, got Clojure REPL working
23:19SgeoAww, it doesn't do automatic indenting/
23:39technomancySgeo: the bare clojure repl is pretty sorry; most people opt for more integrated tools.
23:57amalloySgeo: emacs, vim, textmate, and eclipse all have lovely integrated clojure repls
23:57amalloyand lein/cake both provide a smarter command-line repl
23:59SgeoDoes (recurse) work with (fn)?