#clojure logs

2009-02-06

00:01hiredmansvn rev 1251
00:01clojurebotsvn rev 1251; [lazy] removed loop from distinct
00:42lisppaste8metaperl pasted "trying to use apply..." at http://paste.lisp.org/display/74963
00:43Carkyou forgot a map somewhere
00:44Carkerr oops forget it
00:44durka42metaperl: can't treat java methods as first-class fns. use #(Integer/parseInt %)
00:45metaperlouch
00:45metaperlwhat does taht % sign do?
00:46metaperlIs it still fn [x]
00:47ayrnieu#(f %) => (fn [x] (f x)), #(f %1 %2 %3) => (fn [x y z] (f x y z))
00:54metaperlthank you. I got it - (map (fn [x] apply #(Integer/parseInt %1 %2) x) number-and-base)
00:55yangsxWhen I try to use (compile 'mylib.example), it says "No such file or directiory: (example.clj:1)", though I have use add-classpath the relevant path. Any hint?
00:55yangsxdirectory*
00:55ayrnieuhint: add the path to CLASSPATH before you start clojure. Don't use add-classpath
00:55hiredmanclojurebot: add-classpath?
00:55clojurebotadd-classpath is bad, avoid it. I mean it!
00:55ayrnieualso, you mean both paths, right?
00:55yangsxayrnieu: I'm using slime.
00:57yangsxayrnieu:Do you mean if I want to use compile, I should not use slime?
00:57metaperl,(. java.lang.String concat "a" "b")
00:57clojurebotjava.lang.IllegalArgumentException: No matching method: concat
00:57ayrnieunot using slime is an option, as is adding the path to CLASSPATH before you start it.
00:58ayrnieubut you've dropped a packet.
00:58ayrnieuyangsx: also, you mean both paths, right?
00:58yangsxayrnieu: sorry, what do you mean by both paths?
00:58durka42metaperl: sorry, had to run. did you get an answer?
00:59metaperldurka42: yes, but now I have another question
00:59metaperl,(. java.lang.String concat "a" "b")
00:59clojurebotjava.lang.IllegalArgumentException: No matching method: concat
00:59metaperlhow to concatenate string?
00:59durka42java.lang.String is a Class
00:59durka42instances of String have the methods
00:59durka42,(.concat "a" "b")
00:59clojurebot"ab"
00:59durka42(. concat "a" "b")
00:59durka42,(. concat "a" "b")
00:59clojurebotjava.lang.IllegalArgumentException: Malformed member expression
00:59durka42just kidding
00:59durka42,(. "a" concat "b")
00:59clojurebot"ab"
00:59ayrnieuyangsx - mylib and *compile-path*
01:00metaperl,. ("a" concat "b" concat "c")
01:00clojurebotjava.lang.Exception: Unable to resolve symbol: . in this context
01:00metaperl,.(. "a" concat "b" concat "c")
01:00clojurebotjava.lang.Exception: Unable to resolve symbol: . in this context
01:00metaperl,.(. "a" concat "b")
01:00clojurebotjava.lang.Exception: Unable to resolve symbol: . in this context
01:00ayrnieu,(-> "a" (.concat "b") (.concat "c"))
01:00clojurebot"abc"
01:00durka42just ,
01:01yangsxayrnieu: I didn't, *compile-path* is just classes.
01:01metaperl,(. "a" concat "b")
01:01clojurebot"ab"
01:01metaperl,(. "a" concat "b" concat "c")
01:01clojurebotjava.lang.IllegalArgumentException: No matching method found: concat for class java.lang.String
01:01ayrnieuyangsx - OK. Does 'classes' exist, and is it in your classpath?
01:01durka42,(.. "a" (concat "b") (concat "c"))
01:01clojurebot"abc"
01:02metaperlhmm
01:02metaperlwhere can I learn about -> and ..
01:03metaperlI kinda remember them from the Java tutorial part 1
01:03hiredmanuh
01:03ayrnieuyou can read their documentation, read their source, look for examples, ask questions about them, read about them in Programming Clojure
01:04yangsxayrnieu: it seems not the case
01:04ayrnieuI think -> and doto are particularly useful. I think .. is hard to read.
01:04hiredmanyes
01:04ayrnieuyangsx - I think that's probably your 'file not found' error, then.
01:05yangsxayrnieu: thanks, I didn't notice *compile-path* thing before this. It's not convenient to order the book, though.
01:19metaperlwhat is 'Programm/join #java
01:25metaperlwouldnt .quote be in java.lang.String even though discussed in java.regex.Pattern - http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#quote(java.lang.String)
01:25metaperl,(. "afdafasdfadsf" quote)
01:25clojurebotjava.lang.IllegalArgumentException: No matching field found: quote for class java.lang.String
01:27yangsxIf I add my paths when starting clojure, compile works as expected. Use add-classpath later seems to not work properly. Just a bit inconvenience to me to use with slime, though.
01:29durka42metaperl: no. as it says on that javadoc page, quote is a static method of Pattern, that takes a String and returns a String.
01:29durka42,(java.util.regex.Pattern/quote "asdfasdfasdf")
01:29clojurebot"\\Qasdfasdfasdf\\E"
01:29metaperlah
01:30durka42are you learning java and clojure concurrently?
01:30metaperl,(java.util.regex.Pattern/quote "hi\r\nthere")
01:30clojurebot"\\Qhi\r\nthere\\E"
01:30metaperldurka42: yes
01:30metaperlsince clojure is a concurrent language, seems like a good idea
01:30durka42:)
01:30metaperli've fooled around with lisps for a long time
01:30metaperlplayed with java in eclipse a few times
01:32durka42i don't know how often learning clojure has been tried without prior knowledge of java
01:32durka42i wish you luck
01:32metaperlreally, I was wondering if there were something like Perl --- where a single quoted string is literal and double-quoted string is not
01:32metaperljava is hardly anything to learn... just knowing libraries
01:32durka42well, no, but there are regex literals
01:32durka42,#"blah"
01:32clojurebot#"blah"
01:32durka42(class #"blah")
01:32durka42,(class #"blah")
01:32clojurebotjava.util.regex.Pattern
01:33durka42,(print #"one\ntwo")
01:33clojurebot#"one\ntwo"
01:33durka42,(print "one\ntwo")
01:33clojurebotone two
01:33durka42(clojurebot chopped the line break)
01:55metaperlreally I just want to create a string which has the result of (- 25 21) in it
01:56metaperlprintf "the result is %d", 25-21
01:57hiredman,(str "the result is " (- 25 21))
01:57clojurebot"the result is 4"
01:57metaperlphew
01:57metaperlthat was much easier
01:59durka42yuck
01:59durka42,(.toString (. (java.util.Formatter.) format "the result is %d" (into-array [(- 25 21)])))
01:59clojurebot"the result is 4"
01:59yangsxMy program can run interactively with slime, but running the compiled program gives No matching ctor found for class java.io.FileWriter at clojure.lang.Reflector.invokeConstructor(Reflector.java:157), what's likey the reason?
02:00yangsxGoogle gives two hits, but not exactly the same with mine. I suspect I missed something.
02:01metaperl,(% 15 6)
02:01clojurebotEval-in-box threw an exception:arg literal not in #()
02:01durka42mod, rem
02:01durka42% is the parameter in lambda fns
02:02metaperlyes, but it would never be at start of parentheses
02:02metaperlhence could be overloaded
02:02metaperl,(mod 15 6)
02:02clojurebot3
02:02metaperl,(rem 15 6)
02:02clojurebot3
02:05tehello ladies and gentlemen
02:06metaperlsup te
02:06metaperldont forget the androgynes
02:06durka42and the bots
02:06metaperllol
02:07metaperlis clojurebot written in clojure?
02:07durka42sometimes they talk to each other when they get bored
02:07durka42yes it is
02:07durka42clojurebot: paste?
02:07clojurebotlisppaste8, url
02:07lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
02:07durka42by hiredman and chousuke
02:07metaperlthat's the lisppaste url
02:08durka42clojurebot: where are you?
02:08clojurebothttp://github.com/hiredman/clojurebot/tree/master
02:08metaperllol
02:09metaperlwell I will chat with you ladies, gentleman, androgynes, and bots later :)
02:09metaperlsorry but I must be going!
02:13teI'm not /too/ far along in Clojure-- but I have been reading... I'm trying to visualize how haskell works (the anatomy of a simple program), as opposed to how say, perl works.
02:13teerr s/haskell/clojure
02:13tesorry it's late
02:14metaperlte look at the screencasts
02:14metaperlthe ones for java programmers were useful to me
02:14metaperli'm converting Simon Cozen's "Beginning Perl to Clojure" - http://github.com/metaperl/begin-clojure/tree/master
02:15metaperlhttp://en.wikibooks.org/wiki/Learning_Clojure#Reader_Macros
02:15metaperlttyl!!!!
02:15durka42unfortunately no user-defined reader macros :(
02:31temetaperl: thanks
02:59boxbeatcan I only interact with the OS through Java?
03:00ayrnieu(println "hi") <-- interacting with the OS.
03:00boxbeatwould anyone be interested in creating a C-version of clojure?
03:00boxbeatayrnieu: yes but doing scripting like in python with subprocess etc
03:01ayrnieu(println "hi") <-- interacting with the OS, like with Python's print "hi"
03:09cgrandbosbeat: see clojure.contrib.shell-out to launch sub-processes
03:10cgrandbeatbox: see clojure.contrib.shell-out to launch sub-processes
03:11ayrnieuoh, somehow I stopped reading before "with subprocess"
03:11beatboxwhy? explaining beats being an asshole
03:16albinoThere is also ProcessBuilder from java land
05:48boxbeatdoes clojure have partial application or currying?
05:50rfgpfeiffer__yes
05:50rfgpfeiffer__,((partial + 3) 4)
05:50clojurebot7
05:52Chousukeit's a bit less common than in haskell though.
05:53Chousukeusually people prefer anonymous functions, like #(> 5 %) over (partial > 5)
05:55boxbeatis partial actually of much use?
05:55boxbeatah i see
05:55rfgpfeiffer__I wrote a macro that lets you define curried functions
05:56rfgpfeiffer__but losing dispatch on number of args is not worth it
06:01karmazillaI find my functions rarely have multiple arities. Might be a style thing
07:27djpowellI just needed a function that takes a sequence, and deals the sequence out to N sequences. Basically, so that I can process the sequence by N java threads. Does one already exist?
07:27djpowellI've wrote one now, but wanted to check I wasn't reinventing the wheel.
07:28Holcxjopartition ?
07:28Holcxjo,(doc partition)
07:28clojurebot"([n coll] [n step coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap."
07:29Holcxjo,(partition 3 (range 10))
07:29clojurebot((0 1 2) (3 4 5) (6 7 8))
07:29Holcxjo,(partition 3 (range 11))
07:29clojurebot((0 1 2) (3 4 5) (6 7 8))
07:29djpowellNo that won't do it
07:29djpowellcause it is a lazy sequence
07:29djpowellI want:
07:29djpowell(deal (iterate inc 0) 3) to return:
07:29djpowell((0 3 6 9 12 ...) (1 4 7 10 13 ...) (2 5 8 11 14 ...))
07:30HolcxjoAh! I see
07:32lisppaste8djpowell pasted "deal" at http://paste.lisp.org/display/74970
07:32jdzanything involving drop function won't work
07:32jdzi think
07:33djpowelloh really? why?
07:33jdzok, nvm
07:37Chousuke,(apply map list (partition 3 [1 2 3 4 5 6]))
07:37clojurebot((1 4) (2 5) (3 6))
07:38Chousuke,(take 4 (first (apply map list (partition 3 (iterate inc 0)))))
07:38Chousukehmm.
07:38Chousukelist is not lazy I guess :(
07:39clojurebotExecution Timed Out
07:40Chousukeah, good timing
07:41Chousuke,(apply map list (partition 3 [1 2 3 4 5 6])) ; rhickey, any idea if it's possible to make this work if the sequence is infinite (producing a seq of infinite seqs). list doesn't seem to be lazy :/
07:41clojurebot((1 4) (2 5) (3 6))
07:41Holcxjo(deal () 3) -> ((nil) (nil) (nil))
07:41Holcxjoshouldn't that be (() () ()) ?
07:42cadshello. I was having a discussion about languages that use the same namespace for functions and variables, and was wondering if reasons for using lisp 2 that are commonly given, mainly that it's easy to shoot yourself in the foot, apply when we're dealing with languages where the variables are immutable or already thought of as functions (clojure/haskell).
07:44cadsSomeone pointed out that the programming issues of mutable variables and immutable functions in the namespace can all be easily avoided, but what the real issue motivating lisp-2 was that macros in lisp-1 can be a royal pain
07:44Chousukethey aren't in clojure though :)
07:45cadsI maintain that in a fully functional language like haskell it's perfectly natural for functions that take arguments to be in the same namespace as those defined identifiers that just contain values
07:45djpowellHolxcjo: yeah. where are the nils coming from I wonder?
07:45Carki think that being functional or not is orthogonal to this issue
07:45Chousukecads: I think there was some macro-hygiene problem that having two namespaces would solve.
07:46Holcxjodjpowell: There is a test for empty list missing -- you only do it on the recursion
07:46cadsbut yes, I remember from a talk where rhickey mentions that macros in clojure take a slightly nonconventional route compared to scheme
07:46rhickeyChousuke: you can get what you want, but you have to flip things around, and right, list makes a concrete, non-infinite, list
07:47Carkcads : if you get a parameter "list" and need to build a list in your function, the problem arises wether you're using a perfectly functional language or not
07:47Holcxjodjpowell: Wrap the whole (let [r...) in a (when xs ...)
07:47Chousukedjpowell already suggested http://paste.lisp.org/display/74970 but there has to be a nicer way :)
07:48cadsCark, are you talking about the macro issue, or the issue of getting functions confused with variables?
07:48Carkthe later
07:49Carkthat's the same problem anyways, only you don't control where your macro is being expanded
07:49Chousukecads: I think clojure's namespace-qualifying syntax-quote is an even better solution. as far as I can tell it helps prevent even more hygiene problems, doesn't sacrifice the elegance of lisp-1, and is capable of everything the CL macro system does without the complex stuff you see in scheme.
07:50Carkchousuke : also clojure won't allow to use symbols as eay as in cl in a macro
07:50ChousukeCark: symbols?
07:50Carkrmember the infamous ~'symbol thing =P
07:50Chousukeah, that
07:50Chousukewell that's easy.
07:50Carkright, but you need to specifically say : i want to capture this symbol
07:50Chousukeeasier than remembering to accidentally *avoid* capturing names :P
07:50Holcxjodjpowell: I am also worried that you basically evaluate every element of the input list n times -- if they are expensive to compute you are wasting a lot of computation
07:51ChousukeCark: that's better than accidentally capturing it :)
07:51Carksure thing =P
07:51Holcxjo(assuming Clojure isn't memoizing, which I assume as it would go againt the immutable objects)
07:51cadsCark: I don't completely understand what you mean. I'm referring to the normal everyday programming problem of accidentally trying to call a function when it's a variable, or overwrite a function. Are you talking about a problem in macro-programming?
07:51ChousukeHolcxjo: seqs are cached.
07:52ChousukeHolcxjo: each value is realised only once.
07:52Carkcads : nope
07:52Chousukefunctions in clojure *are* values
07:52Chousukeso you shouldn't worry about confusing functions with values
07:52cadsCark: I'll ask for an example in a bit, right now my puppy needs to pee! bbiab
07:52Cark(do-something-to-a-list [list] (list (first list)) .... what does that mean ?
07:53ChousukeCark: that's nonsensical.
07:53Chousukelist is a value (a parameter in this case) that's probably not a function.
07:53Carkthat's an everyday problem, in a lisp one you need to (do-something-to-a-list [lst] (list (first lst))
07:53Carknow how is this related to being purely functional ?
07:53Chousukeor name your list a bit better.
07:53Carknot related at all
07:54Carkchousuke : right
07:54Carkwe could make an example in c# ... that's a lisp hum 3 to 20 don't know =P
07:54lisppaste8djpowell annotated #74970 with "fix (nil) problem" at http://paste.lisp.org/display/74970#1
07:54Chousukethat's simple name shadowing... happens in all languages.
07:55Chousukeexcept those that make it a compilation error I suppose..
07:56Carkanyways, i feel that this whole lisp1 vs lisp2 thing is pretty unimportant
07:56Carkdebating it won't make the program run any better
07:56ChousukeI'm not saying lisp-2 doesn't have its advantages, but I feel that those advantages are not worth the lost elegance of not being a lisp1 :)
07:57Carkthat's only cosmetic, there are advantages in both camps ... clojure avoids most pitfalls with a couple simple things, so i guess it's ok
07:57Cark(as it is)
07:57Chousukebeing lisp-2 makes functional code cumbersome though
07:58Chousukesince you need to be funcalling all the time if you want to use higher-order functions.
07:58Carkright
07:58Carkon the other hand, it's sometimes less readable
07:58metaperlwell you have to recur here though right?
07:59Cark(((a b) b) ((z e) k))
07:59Cark=/
07:59metaperlclojure is a lisp-1 but you recurse by the word recur?
07:59Carkmetaperl : unrelated
07:59metaperloh
08:03ChousukeCark: I don't like that kind of code :)
08:04Carkme neither
08:04ChousukeCark: I prefer naming the functions first in a let
08:04Carkwell then you have as much overhead as when using funcall
08:04Carkthough it's still unreadable with funcal
08:05ChousukeCark: not really.
08:05Chousukefor example, when implementing a higher-order function like map, the function you're calling is already named (it's a parameter)
08:06Chousukein that case, you have a function returning a function so (let [foo (a b) bar (z e)] (foo b) (bar k)) is in my opinion more readable.
08:07Carkyes it is
08:08ChousukeI guess you can find examples where either approach looks ugly though :)
08:09Carkanyways, you pick a language, then adapt to it, wether it is a lisp1 or 2 is really not important to me
08:09Holcxjodjpowell: take-nth
08:09Holcxjo,(doc take-nth)
08:09clojurebot"([n coll]); Returns a lazy seq of every nth item in coll."
08:25HolcxjoWhat is the difference between (drop n xs) and (nthrest xs n) ?
08:27HolcxjoLazyness?
08:27Holcxjo,(doc nthrest)
08:27clojurebot"([coll n]); Returns the nth rest of coll, (seq coll) when n is 0."
08:27Holcxjo,(doc drop)
08:27clojurebot"([n coll]); Returns a lazy seq of all but the first n items in coll."
08:31cemerickI think I *might* be overcomplicating things here, but it seems like import should attempt to load the lib corresponding to each class ahead of actually loading the class into the current namespace. Unless I'm missing something, without that, one needs to explicitly load or require each such lib before importing it in other clojure code so that AOT compilation can succeed.
08:33lisppaste8Holcxjo annotated #74970 with "Simplification using take-nth" at http://paste.lisp.org/display/74970#2
08:34cemerickI guess I'm saying that each import should imply a require, so that a given lib/classname doesn't have to be specified twice in the ns form.
08:37rhickeycemerick: the :load-impl-ns gen-class flag allows you to control whether the static initializer for a generated class loads the implementing namespace
08:39cemerickrhickey: if I understand :load-impl-ns properly, that's a runtime consideration -- I'm talking about AOT-compile-time, where no classfiles have been generated yet, but a given lib with a gen-class spec imports a classname of another lib with a gen-class spec
08:39cemerickIn order to resolve that import, it seems like a second reference to that lib/class must be made in a :require
09:01djpowellHolcxjo: ah, missed take-nth
09:02djpowellit probably makes sense to wrap the input to deal with a seque, else slow consumers will cause the remainder of the seq to stay in memory
09:08djpowellHolcxjo: I'm not sure of the difference between drop and nthrest either
09:10djpowellis the multiple list version of map a clojure thing? does haskell have that? i spent ages looking for a zip function at first.
09:12gnuvincedjpowell: it's Clojure specific
09:13gnuvincedjpowell: unless you use type class black magic (as in Printf), you can't do that with Haskell
09:13djpowellah, python has it
09:13gnuvincewhich is why they have zip, zip3, zip4,... zip8
09:13djpowellhttp://docs.python.org/library/functions.html
09:17Holcxjodjpowell: CL has it as well
09:19cadsHey, I'm back.
09:21cadsI read the conversation after I left and before I got disconnected, and especially your example about list, Cark. I agree that it's not to do with functional programming.
09:23cadsMy main point about functional programming is that classically we consider everything to be a function, even what would be called variables in a imperative language.
09:24ayrnieuyou can also take the prolog/erlang/mercury path of capitalizing variables. It's a bit odd, but then so are nam lst rst nxt
09:25cadshmm, I'll admit I've only played with haskell and pen and paper FP, plus my math
09:26cadsI feel most comfortable considering constants as functions which take no arguments
09:28cadsthe "everything is a function" way of thinking means you won't collide names between a constant and a function
09:29cadsso if each thing is a function, it feels silly to put functions with parameters in one namespace, and constants in another
09:30Chouserthat feels silly anyway. ;-)
09:30ayrnieuso how long have you thought this way, and how well do you think it has helped you not name your parameters 'name'?
09:33cadsI never felt a need to name a variable the same name as a function, I don't think
09:33ayrnieuso you can't say that this interpretation has helped you.
09:33Cark=)
09:35cemerickso, given a lib with a gen-class spec, how is one supposed to type-hint using the gen-class' eventual classname (since it looks like the entire file needs to be loaded before classfiles are generated)
09:40cadswell write in math, F = D^(-1)(f)... f can be a constant or f can be a polynomial, and god knows what D is, but I wouldn't call it f if f was defined elsewhere. I guess the question is if this way of thinking has helped me avoid accidentally naming new functions the same name as existing functions accidentally.
09:40cadsif I'm writing f(f), then f is a wierd ass operator
09:42cadsand yeah, I think it's help
09:43cemerickoh, actually my immediate issue is being able to refer to the gen-class' constructors in the various method impls in clojure...
09:43Chousukecads: f could be identity :)
09:43Chousukethough no idea how you would express that mathematically.
09:45cadsId x = x forall x in X, where X is a set powerful enough to have Id in it :D
09:46ayrnieucads, lisp-1 doesn't need a "really, see, variables and functions are both fungible slices of Chewbacca" defense. It's an obvious problem accompanied by obvious benefits and people adjust.
09:48Chousukecads: I guess you could just validly say Id x = x forall x
09:49ayrnieuit's like saying that you can't have n-ary functions in Haskell, and you can't distinguish between the two functions 'foo 1 2' and 'foo 1', but you can't do these things because you get automatic currying. Oh, OK. No need to argue that this or those are fundamentally superior, or that someone used to one will not have to adjust to a language dominated by another.
09:51ChousukeI guess Haskell could have N-ary functions if you extended its metaprogramming capabilities somewhat; do not actually offer N-ary functions, but automatically generate one of specific arity when needed.
09:51Chousukethat might conflict with some other stuff though :/
09:53LordOfTheNoobsChousuke: http://74.125.47.132/search?q=cache:p8uh0NA1AH0J:www.informatik.uni-bonn.de/~ralf/talks/fullcircle.pdf+haskell+printf&amp;hl=en&amp;ct=clnk&amp;cd=8&amp;gl=us
09:54rhickeycemerick: sorry, had to run out before. How would import know which classes were Clojure-generated?
09:57cemerickrhickey: it doesn't, but it can (optionally?) *attempt* to require all of the libs corresponding to the named classes.
09:58rhickeyhmm...
09:58cemerickMy line of thought is: (a) the programmer knows far less than the machine as to which classes are clojure-generated (b) the machine can just do some extra work at load-time to make import imply require, and (c) the alternative of duplicating lib/classnames and otherwise doing the necessary associated bookkeeping is *really* painful
09:59cemerickif you're worried about runtime impact of doing a fail-safe require for each lib corresponding to each class to be imported, a :require-imports key could be added to ns
09:59cemerick(which I'd *always* set to true, but then I could care less about init runtime)
10:00rhickeycemerick: no, I'm just wondering if this is an actual problem. Right now import does classForName, so the class should be loaded by import and load-impl-ns should matter
10:01cemerickrhickey: that's true if you're actually using the code -- if you're just using c.l.Compile (for example), and you pass to it com.bar and com.foo, both of which have genclass specs, and bar imports com.foo, right now bar *must* require com.foo as well.
10:02cemerickI should say, that's true when you're not compiling
10:03rhickeycemerick: but if foo were compiled first you wouldn't - this seems more like a make problem
10:04cemerickrhickey: it seems like resolving the import/lib dependencies of an arbitrary clojure codebase is not a problem that should be solved in ant et al.
10:05rhickeycemerick: I'm not saying it is, but just as javac must do a dependency analysis, so might compile, rather than trigger loads via side effects of imports
10:05cemerickwhat I'm trying to get to is a state where compiling a clojure codebase is as straightforward as compiling a java codebase (thus my comments yesterday about c.l.Compile taking a set of source root dirs, and walking the files in them in order to determine what libs needed to be loaded)
10:06cemerickrhickey: oh, well, that's an implementation detail. Doing rigorous dependency analysis in-flight while loading/importing seems like a big chunk to bite off, compared to doing a fail-safe require of every lib corresponding to each class to be imported.
10:07cemericks/"loading/importing"/compiing
10:07rhickeycemerick: I wonder if anyone other than you is importing gen-classed files yet :), i.e. the vast majority of imports do not have Clojure dependencies
10:07cemericklol
10:07cemerickHey, go big or go home, y'know?
10:08cemerick:-)
10:08cemerickinterestingly, the vast majority of our imports *are* to clojure-generated classes
10:08cemerick(outside of core java libs)
10:10rhickeycemerick: I think that's great, but I'm not sure you are going to get around dependency analysis, nor is it necessarily hard (volunteers welcome)
10:11cemerickwell, you'd know better than I. I'd go do it, but I honestly wouldn't know where to start.
10:12cemerickrhickey: would true dependency analysis solve any problems that wouldn't (functionally) be solved by being dumb about it and doing the fail-safe requires?
10:30valebedev__join #couchdb
10:49Chouserthere's currently no way for a macro from a namespace X to refer to a var X/foo when used in namespace Y unless X/foo is fully public, right?
10:50jbondesonheh, i just ran into that this morning.
10:51WizardofWestmarccan you wrap the macro's code in an in-ns block?
10:51jbondesonyou'd break user code like that
10:51WizardofWestmarchm, good point
10:52ChouserI've run into it before, but the var I've got right now would be particularly bad for users to muck around with.
10:53Chouserwell, in-ns wouldn't work because the expression containing it has to be eval'ed before it take effect (on the following expression)
10:53Chouserbinding+eval would do it, but of course that's lousy
10:54ayrnieudepending on foo , you can embed it into your macroexpansion. (def x (ref 0)) (defmacro on-x [f] `(f @~x))
10:54ayrnieumacroexpands to: (foo/f (clojure.core/deref #<Ref clojure.lang.Ref@9a6cd4>))
10:54Chouserayrnieu: ooh.. hm...
10:55Chouseroh, but that won't 'read'
10:55jbondesonyou wouldn't be able to expand that if the ref were private though, right?
10:56jbondesoneven multiple layers of macros all evaluate at read time of the "caller", right?
10:56Chouseryou get "Can't embed object in code" because you can't print and then read an object reference like that
10:58ChouserIn this case I'd probably be content with a var that was public but not referred by default by 'use'.
11:08cgrandChouser: @#'ns/private-var ?
11:12Chousercgrand: ok! thanks.
11:24cemerickit would be *really* nice if some kind of 'friend'-level access were available.
11:24cemerickProbably more trouble than it's worth, I guess.
11:25Chousereveryone that knows how to @#' is my friend.
11:26jbondesonheh
11:27ayrnieu(lib.chouser/THIS-CODE-WILL-BREAK a) ;;; it's just the lib author's 'scary' name. Stop coming to me about this! --ayr
11:28Chouser:-)
11:31duck1123@#' would allow you dereference a var that is named by the results of a form?
11:35cemerickChouser: indeed, but something that would operate through refer and friends would be pleasant in some circumstances
11:37cemericke.g. right now, I'm making public a variety of fns that were being shared by two gen-classed libs, which are now in separate namespaces -- defining those fns' vars as friendly with just that other lib would be nifty (so I don't have to scatter the @#' line-noise all over the place)
11:42jbondesonok, i'm going to ask a question that may be dumb, but what is the reason that Ref is not considered a Class for use in 'isa?', but you can identify one with (instance? clojure.lang.IRef reference)?
11:43cgrandcemerick: what about putting them in a third namespace and warn users to not use this lib?
11:44cemerickcgrand: yeah, I may do that. Right now, I just want to get all of our stuff ported to post-AOT clojure. Then I'll tidy shop. :-)
11:49Chouser(defn get-friends [] (doseq [s '[var1 var2 var3]] (.refer *ns* s (resolve s))))
11:50ChouserI think that ought to work, but instead I get a busy infinite loop. :-/
11:50Chouserjbondeson: Class is a final class -- no derived classes allowed.
11:51Chouser,(instance? Class clojure.lang.Ref)
11:51clojurebottrue
11:51jbondesonah-ha
11:51jbondesonsee knew it was going to be a dumb question.
11:52Chousernot dumb. The Class class is meta in a direction that's frequently confusing.
11:56Chouserhm, clojure's tiny amount of syntax is biting me
11:57ChouserI want to write a macro foo that allows me to say: {:a 1 :b 2 (foo 3 4)}
11:57hiredmanerm
11:58hiredmanI don't see how that could ever work
11:58hiredmanfunctions/macros result in one value
11:58ayrnieu,(let [foo #(do {%1 %2})] (conj {1 2 3 4} (foo 3 5)))
11:58clojurebot{1 2, 3 5}
11:59hiredmana map needs pairs of key -> value mappings
11:59Chouseryeah, the user will have to wrap the whole {} in something, either conj or the macro call itself.
12:00Chouserhiredman: oh, you're right. it wouldn't even work in a list because I want multiple return forms.
12:00Chouserso its a weakness of macros, not anything to do with Clojure synatx.
12:01hiredman...
12:03ayrnieuCL discards the second value in (defmacro x (a b) (values `(foo ,a) `(bar ,b))) , too. I wonder how robust the idea is.
12:07LordOfTheNoobsChouser: what were you wanting the resulting form to look like?
12:08hiredmanwell, I assume he wanted a valid map
12:08Chouser{:a 1 :b 2 :fookey (+ 3 4)} for example
12:09ayrnieu(defmacro multiple-value-macro [x y] (atom [:fookey `(+ ~x ~y)])), {:a 1 :b 2 (multiple-value-macro 3 4)} => {:a 1 :b 2 :fookey (+ 3 4)} ;; doesn't work, of course.
12:12Chouserayrnieu: if your mvm were made to work, though, *then* we'd have a syntax problem.
12:12ChouserClojure's reader wants an even number of things in {}
12:13ayrnieuthat's an even number of things; (atom [a b]) => a b
12:14Chouserbut not at the read time of {:a 1 :b 2 (multiple-value-macro 3 4)}
12:14ayrnieuin the hypothetical atoms-from-macros-are-treated-specially-world , which is compatible with ours in that macros can't return such things.
12:15ayrnieuhm.
12:17Chouserheh, you can use 'binding' on private vars
12:19hiredmanit's a feature!
12:21Chouserone of those unusual write-only constructs.
12:30technomancyit says here that set! only works on java fields, agents, and refs: http://clojure.org/java_interop#set
12:30technomancybut I'm using it on a thread-local var
12:33zakwilsontechnomancy: Note - you cannot assign to function params or local bindings. Only Java fields, VARS, Refs and Agents are mutable in Clojure. (emphisis added)
12:34technomancyzakwilson: yes... my brain is not turned on.
12:34technomancyI read that as "java field vars"
12:45technomancyso does CL avoid the use of brackets because they wanted to reserve them for M-expressions? http://en.wikipedia.org/wiki/M-expression
12:48technomancyit's really weird to read about how people used to think M-expressions were the future.
12:52jbondesonis there any easier way to deal with gen-class objects than having to do a compile every time you make a change?
12:52gnuvincetechnomancy: in a sense, every other language adopted M-expressions :)
12:52hiredmanI think CL avoids using brackets for religious reasons
12:53hiredmanjbondeson: for changes like adding a method you have to recompile, but for changes to existing methods that don't change their signature, I don't think you need to recompile
12:53Chouserjbondeson: you should only have to recompile if you change the actual args of the gen-class macro
12:53hiredmana compiled class is just stubs that dispatch to clojure functions
12:54jbondesonsweet.
12:54Chouseryou can even add new override fns and stuff to the namespace without recompile
12:54zakwilsonI think CL avoids the use of brackets to make them available to the programmer for arbitrary purposes.
12:55BigTomHi technomancy
12:55technomancyzakwilson: purposes including adopting m-expressions, no doubt. =)
12:55technomancyBigTom: hello
12:55BigTomtechnomancy: I am afraid I didn't use your Slime script in the end
12:55technomancyo rly?
12:55BigTomtechnomancy: I have put Slime on the backburner until I am better at emacs
12:56zakwilsonI doubt it, technomancy. I think by the time CL came out, hardly anybody was seriously considering using M-expressions.
12:56technomancywere you running into problems?
12:56jbondesoni suppose i could also test with a proxy if i want to play in the repl
12:57technomancyzakwilson: yeah, but they have this thing about leaving peoples' options open. I dunno; mostly joking though.
12:57zakwilsonLisps in general aim to leave options open - Clojure included.
12:57BigTomThere is just friction everwhere (mostly me not knowing my way round)
12:58BigTomso I'll stick with inferior lisp until I am comfortable with emacs
12:58BigTomThen I'll have another go
12:58BigTomjust wanted to say thanks for the patient help over the last few days
12:58zakwilsonI've seen brackets used in CL for delimiting sexps that were translated by a macro in to SQL statements (CLSQL), for array literals and for Arc-style function literal shorthand.
12:59technomancyBigTom: no problem. do you know about the Emacs PeepCode?
12:59BigTomnope
13:00technomancyit's a screencast you can buy for learning Emacs: http://peepcode.com/products/meet-emacs
13:00BigTomtechnomancy: Emacs is this vast uncharted continent of obscure functionality ;-)
13:00BigTomtechnomancy: ah, I'll have a look
13:00jbondesonit's not obscure, it just wasn't *meant* for you! ;)
13:00Kerris7"It's not you, it's just Emacs"
13:01technomancyBigTom: people have told me they find it helpful. =)
13:01BigTomfunny thing was that I had no trouble with Emacs and erlang, I think its a serious case of running before I can walk
13:01technomancywell Emacs and Erlang have had more time to get to know each other I suppose.
13:02zakwilsonI think Emacs suffers from some dated conventions and could use a more modern replacement... but I'm not holding by breath for that. I expect to be using Emacs in ten years.
13:02jbondesonnever used the erlang mode, but it could have to do with how much the mode alters emacs
13:02technomancyzakwilson: a lot of the cruft is going to be targeted in the next release: adding lexical scope and coroutines
13:02jbondesonmost of the lisp-emacs modes embrace emacs
13:03zakwilsonLexical scope? Finally? Yay!
13:04technomancyzakwilson: optional lexical scope of course; can't go around breaking all extant code. but it's a step in the right direction.
13:04technomancyand it makes threading possible
13:04BigTomI have to admit my Java side is very excited that the intellij guys are taking over the clojure plugin
13:04BigTomIntellij is a very impressive piece of kit
13:04duck1123I hate doing something intensive in emacs, only to have it mess up my ERC buffers
13:04zakwilsonIsn't somebody working on a Clojure IDE in Clojure?
13:05hiredmanclojurebot: textjure?
13:05clojurebotNo entiendo
13:05zakwilsonYes, that name sounds familiar.
13:05jbondesonbeat the bot until it remembers.
13:06technomancyzakwilson: it's more than an IDE though, it's a structure editor
13:06technomancyso you're operating directly on data structures rather than editing the textual representation of the code.
13:06technomancythat's what they tell me anyway.
13:06BigTomIf you like that sort of thing
13:06BigTomWhich I do
13:07zakwilsonNow I have to go download the bloody thing and see what it's all about.
13:07BigTomWhat would be cool would be a clojure equivalent of Pythons IDLE
13:07duck1123I wonder if you could convert clojure code to xml, edit it in a xml structure editor, then transform it back into clj code
13:07Chousukeyes :P
13:08Chousukethe question is, how easily
13:08jbondesonnot really, because technically with macros you can modify to be less s-exp-y
13:08technomancyyou could compile it to X#: http://xsharp.org =)
13:08duck1123the trick would be to have enough structure to capture everything, without it getting in the way of the code editing
13:09duck1123I haven't looked into X# too much, but XMLProc is a pretty cool spec, I used to work with it's precursor XPL quite a bit
13:10technomancyX# is hilarious
13:10jbondesonno, no it's not...
13:10jbondesonyou shouldn't encourage them.
13:10technomancyit's like someone interpreted Greenspun's Tenth Law as Best Practices
13:11duck1123"hmm... implement half of lisp? sure, I'll give it a try"
13:11danm__I'm not sure why anyone would want something like X#
13:11jbondesonI can just see how the thought process went for those people
13:11danm__but I suppose differences between people make the world work
13:12WizardofWestmarcungh, X#
13:12WizardofWestmarcI hoped it was a joke when I originally heard about it
13:12jbondeson"I don't understand XSL, so how do I make a different XML language that has all the downsides of being in XML, and non of the upsides of XSL?"
13:13WizardofWestmarcthere are upsides to xslt besides not being compiled?
13:13jbondesonnow now
13:13duck1123xslt is actually a quite powerful language. (if you're using XPath 2.0)
13:14duck1123it's no lisp, but not far from it
13:14jbondesonXSL 2.0 is fine, but people, and by people I mean CRUD developers, couldn't understand it, so they came up with XQuery, and now this bastardization X#
13:14technomancyif only you could write xslt using M-expressions.
13:17cemerickrhickey_: do you have any issues applying patches emitted by git-svn?
13:27hiredmanah
13:27hiredmanthis is also an issue with old swank and new clojure
13:27hiredmanbasically the field became private
13:27hiredmanand the solution is somewhere in the irc logs
13:28Chousercemerick: that's how i generate all my patches
13:28Chousercemerick: either "git diff" or "git show"
13:29Chousertextjure's not set up to compile -- just run it as a script
13:29Chouserand it's super pre-beta, but if you want to actually try to use it, you'll want karmazilla's version
13:31cemerickChouser: OK, thanks. I was worried about the svn rev #'s.
13:32Chouserit's just a raw diff file, right? so git or svn rev numbers aren't really involved.
13:32beatboxif you want to do image analysis in clojure, which libs?
13:33beatboxcolt for linear algebra, jung for graphs, but what for manipulating and parsing images?
13:34ayrnieuI'm not an experienced java programmer, so I'd ask in ##java if I didn't like the hits from 'java image analysis' (ImageJ, etc.) You can easily use these in clojure.
13:36albinoI thought the conclusion was jai
13:47leafwbeatbox: Fiji at http://pacific.mpi-cbg.de
13:51zakwilsontextjure has an interesting ability to recurse through every subdirectory and open every file when given a directory to switch to.
13:52zakwilsonFortunately, it seems to have the ability to handle hundreds of open files without complaint or slowdown.
14:26Chousukezakwilson: I remember kotarak complaining about it lacking the ability to *close* files, but that may have been fixed.
14:36zakwilsonChousuke: It can close files, but the help doesn't mention a quit command (and Ctrl-Q doesn't do it)
14:37hiredmanAlt-F4
14:37zakwilsonNor does closing the window terminate the JVM.
14:37hiredmanCtrl-C
14:38zakwilsonHmm... that time it did terminate.
14:39zakwilsonMaybe it was taking its time due to my hundreds of open files.
14:39Carkmhh did i hear textjure ?
14:39zakwilsonYes. I was trying it out.
14:40Carkdid they make any progress on it ?
14:40zakwilsonI cannot answer your question; I do not have a reference point for defining what progress means.
14:41Carki've been relentlessly pestering chouser with stupid java interop questions in order to prevent any progress on that front
14:42gnuvincehahaha
14:44zakwilsonCark: I can't tell you if it's worked. I have only used one version of textjure and have not followed its history. It appears to have a working editor and REPL, and it appears to be fairly unfinish.d
14:49cemerickrhickey_: do you have any AOT-related changes coming down the pike that would bring down the size on disk of the generated classfiles?
14:51lpetitHello
14:53danlarkinlpetit: hi
14:53lpetitrhickey_: sorry for cross posting here what I've already done in the group, but I have a close window to work on clojuredev this weekend, and I would like to know if it is worth of me to create a patch for clojure.lang.Compiler.writeClassFile(), as explained in the e-mail
14:54lpetitI wanted to say a short window, of course ... please excuse my english
15:08gnuvinceTo convert a signed byte to a short (so that I can have the unsigned value if Java supported that), do I use (bit-and x (short 0xff)) or is there a better way?
15:15zakwilsongnuvince: that appears to return a java.lang.Integer. I think what you want is (short (bit-and x 0xff))
15:15gnuvince,(class (bit-and (byte 128) (short 0xff)))
15:15clojurebotjava.lang.Integer
15:15gnuvincehmmm
15:15zakwilsonThe bitwise functions don't (currently) work with primitives.
15:16gnuvince,(short (bit-and (byte 128) 0xff))
15:16clojurebot128
15:16gnuvincecool
15:16gnuvincethanks zakwilson
15:16zakwilsonNo problem.
15:19gnuvinceToo bad that Java doesn't have signed/unsigned though :-/
15:20gnuvinceThat would've saved me some trouble
15:42jbondesonok, swing events are just dumb.
15:43hiredmaneh?
15:44jbondesonjust trying to do some watching of changes in a text field, and it took me way to long to figure that out. JTextField.getDocument().addDocumentListener(...)
15:44jbondesonaddActionListener only fires when you press Enter, which is just crazy
15:44hiredmanoh, well, that is just Java for you
15:45jbondesonmakes it tough to make a uniform event listening library when you have to addActionListener isn't actually what you want
15:46karmazillaSwing is like an unwanted child
15:46jbondesonin what world does [Enter] triggering an event make sense? the only event anyone cares about with a text field is TEXT CHANGED!
15:46WizardofWestmarcthat's mother drank heavily while carrying it to term
15:46hiredmanand yet awt shows no love, so swing it is
15:47WizardofWestmarcwhenever I get around to UI stuff I'm probably going to go down the QT road
15:47ayrnieujbondeson, have you ever logged into a web page by typing 'username', hitting tab, typing 'password', and then hitting enter?
15:47WizardofWestmarclast time I used swing I thought I was going to lose my mind
15:47mofmogi'm writing a little program that does A* search and although not necessarily to do with clojure i was wondering you guys could help...
15:47waltersayrnieu: we should make the firefox patch to remove it from javascript for his computer and see if he changes his mind about an activation signal =)
15:47jbondesonayrnieu: i would expect the [Enter] to trigger a button...
15:48karmazillabut input focus is on the textfield
15:48technomancyenter triggers on input elements. textareas are not inputs, but text fields are
15:48jbondesonyes but in most sane environments you have have forms that have key preview...
15:49mofmogit's a* for essentially the travelling salesman problem on a grid, and i had a heuristic that used the minimum spanning tree, but it turns out it's not a consistent heuristic. for some reason, replacing the manhattan distance function used to find the edge cost between edges with a function that calculates euclidean distance makes it consistent
15:49mofmogi dont know if that's necessarily true.. hrm
15:50mofmogit should be at least admissible since euclidean distances are less than or equal to the equivalent Manhattan distance
15:53jbondesonmofmog: a quick look at manhattan distance looks like it's not monotonically decreasing.
15:53mofmogyeah exactly
15:53jbondesonthat's one of the requirements for A*
15:54mofmogwell for a graph search at least
15:54mofmogthat's exactly my problem, it isn't consistent, but euclidean distances makes it consistent, even though the search space is on a grid
15:54mofmognot "makes" but "makes it seem"
15:55jbondesonWhat are you seeing with the A* algorithm with manhattan?
15:56jbondesonyou said it isn't "consistent", what exactly do you mean by that?
15:56mofmogit's not monotonic
15:56jbondesonit's evaluating nodes that should be disqualified?
15:56mofmoggoing off of norvig's terminology
15:56mofmogno i'm saying that f(n) = g(n) + h(n) is not monotonic
15:56mofmogg(n) always grows by one, so essentially h(n')-h(n) is not <= 1
16:12scottjShould (rational? 0.5) return true?
16:13ayrnieu(rationalp 0.5) evaluates to nil in CL, too.
16:13gnuvincescottj: 0.5 is not a rational, it's a double. 1/2 is a rational
16:13gnuvince,(rational? 1/2)
16:13clojurebottrue
16:14scottjgnuvince: I think that's what ratio? is for
16:15ayrnieu,[(ratio? 1/1) (rational? 1/1)]
16:15clojurebot[false true]
16:17scottjrational? "returns true if n is a rational number." 0.5 is a rational number.
16:17jbondeson,(rationalize 0.5)
16:17clojurebot1/2
16:18ayrnieuIt is a rational number with one set of terms. It is not (or integer? ratio?), in the relevant set.
16:18gnuvince(doc ratio?)
16:18clojurebotReturns true if n is a Ratio; arglists ([n])
16:18gnuvince(doc rational?)
16:19hiredmanhuh
16:20hiredmanclojurebot NPE'ed on that
16:20hiredman,(doc rational?)
16:20clojurebot"([n]); "
16:20hiredmanNice
16:20scottjit's messed up in the repl also
16:20durka42it has no doc
16:21scottjit looks like it does in the source
16:22durka42yeah, it does
16:22scottjanyway, I think that doc string should be changed if it's going to test something other than what's normally meant by "rational number"
16:23ayrnieu,(.setMeta #'rational? (assoc (meta #'rational? :doc "(or (integer? n) (ratio? n) (decimal? n))"))
16:23clojurebotEval-in-box threw an exception:EOF while reading
16:23ayrnieu,(.setMeta #'rational? (assoc (meta #'rational?) :doc "(or (integer? n) (ratio? n) (decimal? n))"))
16:23clojurebotnil
16:23ayrnieuit doesn't have documentation in the source. It has a string that is thrown away.
16:23jbondesonexcept for one problem scott, EVERY floating point number is a rational number.
16:23ayrnieuscottj, computer types are metaphorical.
16:23durka42oh, hey
16:24durka42yeah, what ayrnieu said
16:24jbondeson,(double 1/3)
16:24clojurebot0.3333333333333333
16:24jbondesonyou can rationalize any floating point number, because by definition they terminate
16:24durka42that seems like it should be on the issues page
16:24jbondesonthey are of fixed precision.
16:24durka42since it's such a trivial problem
16:24ayrnieuoh oh, that's a rational number. That's 3333333333333333/1000000000000000
16:24jbondesonyes, exactly the point
16:25ayrnieu(it's a rational number anyway, because it's repeating)
16:25mofmog,(double 234213/2343)
16:25clojurebot99.9628681177977
16:25jbondesontrue, but you can also do it with irrational numbers
16:25mofmog,pi
16:25clojurebotjava.lang.Exception: Unable to resolve symbol: pi in this context
16:25jbondesonit's just impossible to show =P
16:26durka42,Math/PI
16:26clojurebot3.141592653589793
16:26durka42,(rationalize Math/PI)
16:26clojurebot3141592653589793/1000000000000000
16:26mofmogoh there it is
16:26durka42man we have been trying to do that for how many thousand years?
16:26jbondesonpythagoras would be proud
16:26ayrnieuscottj - there's some thought in http://www.lispworks.com/documentation/HyperSpec/Body/c_number.htm
16:26durka42clojurebot just one-upped everyone
16:27mofmogpythagoras didn't have thinking machines
16:27hiredmanthen he should have built some
16:27mofmogand jump start the inevitable war on thinking machines by >2000 years? I think not
16:29jbondesondoes clojure bot have access to contrib?
16:30hiredmanuh, yes
16:30hiredmanaccidently
16:30jbondeson,(clojure.contrib.math/sqrt 2)
16:30clojurebotjava.lang.ClassNotFoundException: clojure.contrib.math
16:30hiredmanhmmm
16:30WizardofWestmarcyou probably need to import it first
16:30Chouser,(use clojure.contrib.math)
16:30clojurebotjava.lang.ClassNotFoundException: clojure.contrib.math
16:30hiredmanI thought he did
16:30ayrnieu,(use 'clojure.contrib.math)
16:30clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/math__init.class or clojure/contrib/math.clj on classpath:
16:31jbondesonclojurebot: you are a failure!
16:31clojurebotExcuse me?
16:31ayrnieu,(Math/sqrt 2)
16:31clojurebot1.4142135623730951
16:31jbondesoncheating
16:32hiredman/home/hiredman/.jars/clojure-contrib.jar <-- from clojurebot's classpath
16:32hiredmanI think that is just whatever clojure-contrib ships with ring
16:32jbondeson,(rationalize (Math/sqrt 2))
16:32clojurebot14142135623730951/10000000000000000
16:32technomancyclojurebot uses ring?
16:33technomancyor that's just where you got your copy from?
16:33hiredmanno
16:33hiredmanI dump jars in .jars
16:33technomancyright, sure
16:33ayrnieu,(filter #(.contains % "clojure") (.split (System/getProperty "java.class.path") ":"))
16:33clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission java.class.path read)
16:33hiredmanso I took all the jars that came with ring and dumped them in there
16:34hiredman("/home/hiredman/.jars/clojure.jar" "/home/hiredman/.jars/clojure-contrib.jar" "/home/hiredman/.jars/clojureql.jar" "/home/hiredman/.jars/clojure-json.jar" "./clojurebot/")
16:34hiredmanclojurebot does use clojure-json
16:34hiredmanwell
16:35hiredmanthe google search and translate modules/plugins/whathaveyou do
16:35RaynesWell. Don't you just hate it when you write a function only to look like an idiot 2 days later when someone throws the same (but improved) version in your face :|
16:35danlarkinRaynes: I love it!
16:36RaynesRight out of the standard library.
16:36jbondesonoh, heh, that's slightly different
16:36Raynes:|
16:36jbondesoni've rewritten my fair share of the core api
17:19Lau_of_DKGood evening all
17:21WizardofWestmarcheya Lau
17:22danlarkinHi Lau!
17:41RaynesGood evening Lau_of_DK. Sorry for the extremely delayed reply.
17:42gnuvince_Hi all
17:42c|phey
17:43Rayneshi gnuvince
17:43Lau_of_DKNo worries Raynes, its late :) here...
17:43Lau_of_DKSo, anyone brewing something interesting in Clojure for the weekend ?
17:43RaynesIt's 4:43, pm here. :D
17:44Lau_of_DKoh... its 17 minz to midnight here
17:46Lau_of_DKAnyone using this streams branch regularily ?
17:47ChouserI think I'll have my condition/restart thing ready for people to try out tonight.
17:47Chousercalled error-kit for now, because I'm just flat out lousy with names
17:47Lau_of_DKCool
17:47Lau_of_DKIs it on Github yet ?
17:48jbondesonChouser: that based off the main branch?
17:48Chouserno, it'll go straight into contrib
17:48Lau_of_DKOk
17:48Chouseryes, I'm still using svn trunk HEAD.
17:48ChouserI think its got nil punning in there, but I'm not sure. :-)
17:49Lau_of_DKIve got to hit the sack, its been a looong day, but I'll look forward to seeing your code when I wake up Chris - Good night to you all
17:49Lau_of_DK(oh and danlarkin, could you hurry and wrap 'barkin larkin' up soon?)
17:51danlarkinAw he's gone
17:51danlarkinI'm working on it now, Lau!
17:51jbondesonwish there was a way to do multi-method despatches on available methods...
17:51jbondesoncourse that would be slow as dirt
17:52durka42eh?
17:53jbondesonThe presense of a certain method signature to determine the defmethod to use.
17:53jbondesonswing does have an interface for addActionListener
17:53jbondesonunless i'm crazy (totally possible)
17:58jbondesondoes -> doesn't
17:58jbondesoni have no idea why i love leaving off the end of contractions...
18:04lpetitHi Chouser
18:04Chouserlpetit: hi
18:05lpetitSorry for cross posting here what I've already done in the group, but I don't have a lot of time to spend (alas!) on clojuredev this weekend, and I would like to know if you think there is a chance that the patch for clojure.lang.Compiler.writeClassFile(), as explained in the e-mail, will be accepted
18:05lpetitIf yes, then I'll take time to work on it. If no, then I'll do something else :-(
18:06ChouserI'm afraid I'm no position to make such judgements, even on issues I'm pretty familiar with.
18:07ChouserI understand that it can sometimes be frustrating when a project seems to be blocked waiting for a decision from Rich and no decision appears to be forthcoming.
18:07ChouserAll I can recommend is to adjust your project to allow you to move forward until a judgement has been made.
18:09lpetitDo you think there's something I could do better myself clearer ? Maybe my e-mails are too long, maybe the tone of my e-mails is not appropriate ... ?
18:10lpetitOh, the project is not blocked. I've currently hacked the embedded clojure in clojuredev. Works like a charm.
18:10lpetitBut it's not satisfying in the long run, of course.
18:16ChouserMainly I'd recommend patience.
18:17ChouserGive it a week or so, and if you still haven't heard anything, bring it up again.
18:21lpetitChouser: Yeah, you're right. thanks
18:27drewolsonanyone out there using gorilla>
18:28durka42i am
18:29drewolsondurka42: i recently started getting an error where gorilla is looking for gatekeeper.vim
18:29drewolsonwhich i don't seem to have. any idea what this is?
18:30durka42really
18:30durka42i don't know
18:30durka42did you switch branches?
18:30durka42i know kotarak is working on some new stuff in the nails branch
18:31drewolsondurka42: i don't believe so. i'm pulling from the standard bitbucked branch
18:31drewolsoni completely crashes vim for me at this point, can't use it
18:31durka42is this it?
18:31durka42http://www.mail-archive.com/vim_dev@googlegroups.com/msg02823.html
18:31durka42doesn't sound connected to gorilla, though
18:32c|pcan anyone recommend a book in which the main point of focus is relative to functional programming styles/techniques/etc?
18:32c|pim heading up to new jersey tomorrow and could use something to read
18:32drewolsondurka42: all i know is if i add gorilla.vim , vim crashes. if i run it with -V20, i see that the errors are related to attempting to use gatekeeper
18:32drewolsonnot sure why
18:33durka42yeah, i'm not sure, sorry
18:33durka42i'm rather new to vim too
18:34waltersc|p: perhaps http://www.pragprog.com/titles/shcloj/programming-clojure
18:35technomancyc|p: I don't know if there's anything that targets lisp. I'm sure you could find something on haskell or erlang, but you'd have to wade through a lot of unrelated content
18:35c|pwalters is that mostly clojure specifically? i would like something more generalized...sort of just concept related
18:35c|ptechnomancy, yeah, im looking about on google
18:35c|ponly found haskell related books so far
18:36c|pah, thank you google http://books.google.com/books?ei=xciMSaquBIG4twf89uiGCw&amp;ct=title&amp;rview=1&amp;q=functional+programming&amp;btnG=Search+Books
18:36BigTomclp: Okasaki. Purely Functional Data Structures?
18:37technomancyc|p: this looks like fun: http://learnyouahaskell.com/ =)
18:37BigTomclp: Haskel I think
18:37drewolsonclp: real world haskell was very good
18:37c|pBigTom im just more curious about concepts. i'll tell you right now i favor lisps over haskell ;)
18:37c|pim just not very used to functional programming
18:38c|palthough, i might go with the book walters suggested
18:39c|pbut im not too sure if its worth it, clojure seems to be "evolving" quite rapidly
18:39BigTomHow about the ML family?
18:39ChrononautOn Lisp is good for understanding macros (the pdf is free as well)
18:39BigTomThere is "The Little MLer"
18:39technomancyc|p: if you haven't read the book on clojure, that's the obvious place to start
18:39technomancyit's quite good
18:39c|prighto
18:39technomancyc|p: also: reading code can be just as instructive as reading prose, so browse the contrib library
18:40c|pjust wanted some recommendations
18:40c|paye technomancy
18:40BigTomStu Halloway's book is good and it has a functional chapter now
18:40c|pim going to drop by barne's and noble to check out what they have
18:40c|p(in the morning)
18:40BigTomoops, I see technomancy beat me to it
18:41hiredmanugh
18:41technomancyc|p: I doubt you'll find anything there
18:41c|pPub. Date: April 28, 2009
18:41c|pheh, looks like they wont have it
18:41technomancypossibly erlang if you're lucky
18:41c|ptechnomancy: yeah, im not expecting much
18:42hiredmanthe local barnes and noble used have a "computer science" shelf, it was full of "excel for dummies" books
18:42c|pheh
18:42c|pwell, mine is a bit better than that
18:42hiredmanlike the label on the top of the shelf was "Computer Science"
18:42c|pi might get lucky and they could have something useful
18:43hiredmanthe books where all MS-Office related
18:43hiredmanI saw real world haskell on the programming shelf at b&n the other day
18:43hiredmanthey had three copies
18:43technomancywow; nice
18:43hiredmantechnomancy: the one at the northgate mall
18:44technomancyhiredman: wonder how long before Programming Clojure shows up there. =)
18:44hiredman:)
18:44c|pright well
18:44c|pto all of you that gave me some info, thanks
18:44c|pback to idling
18:46hiredmanI was surprised, java has one shelf
18:46hiredmanthat is it
18:46technomancyPowell's Tech in Portland is phenomenal. They had like five copies of the Little Schemer
18:46hiredmanout of four six foot (I guess) sets of bookshelves
18:46technomancythree shelves of ruby
18:47hiredmanyeah
18:47technomancyand a little "History of Computing" museum in the back.
18:47walterswell, the web is really dominant in computing now, and dynamic languages make more sense for web frontends. Java is probably going to drop more towards the C++ domain
18:49hiredmanthe goodwill has a number of (outdated) java books
18:50BigTomare there any in-date Java books?
18:51c|phead first java is 3rd edition now
18:51technomancyhiredman: it's hilarious what kind of stuff you can find at used bookstores... high-priced assembly manuals for 70s-era mainframes always give me a kick.
18:51c|pi tihkn
18:51c|pnot sure
18:51c|p2nd edition was pretty much 5.0
18:52BigTomThe problem with a lot of Java is that it isn't easy to knock out small stuff so the books are all about frameworks and big stuff
18:52BigTomwhich doesn't sell in bookshops
18:53technomancy"Java in a Nutshell" is pretty huge.
18:53technomancystart to wonder what kind of nuts they use as reference
18:53hiredmantechnomancy: I got a UNIX System V manual the other day
18:53technomancynice
18:53BigTomJava in a coconut shell :=)
18:53technomancyhiredman: I'm holding out for a PDP manual
18:53BigTomI got Hoare's CSP book
18:54lpetitConcerning java, there's not a lot of book I would recommend. For quick starters, any book will do. For more in-depth, then I'd recommend "Effective Java 2d edition" from Josch Bloch
18:54hiredmanand a bunch of intel ia32 instruction set books
18:54c|pi have a new-ish condition windows 98 manual, anyone want it :)
18:54c|pill even throw in the disk!
18:54Spreadsheetme
18:54c|poh, that reminds me
18:54c|pi have an apple ii in the attic as well
18:54technomancynice
18:54SpreadsheetChousuke: hello!
18:55Spreadsheetc|p: can you IRC on it?
18:55c|pi dont know, it is my dads
18:55c|pi havent ever really used it
18:55Spreadsheetoh
18:55c|phe got one around the time it came out
18:55lpetitAnd concerning some higher level book on object orientation, not too tied to a language implementation, I would recommend trying to get the foundational book for Eiffel by Bertrand Meyer
18:56hiredmansomeone happened to paste a link to a webpage version of java concurrency in practice on some chinese or japanese website to the google group a while back :P
18:57lpetitObject-Oriented Software Construction ( http://en.wikipedia.org/wiki/Object-Oriented_Software_Construction ). Takes time to explain the reasons that lead to object orientation (we should really say class orientation, when we speak of java).
18:59lpetitI found this book very interesting. Very easy to understand, not too deep in the technical aspects of a specific language.
18:59lpetitI wonder if there is the same think for the "functional" approach. The Little Schemer was interesting, but very very "hands on" ...
19:00canderaIs it possible to "rebind" a java method? I'd like to be able to either add methods to a class or redirect existing methods to my own code. I.e. make (. o foobar) wind up in my Clojure implementation of foobar, for an existing Java type.
19:01canderaI'm guessing the answer is "no", but Clojure often surprises...
19:02Chouserif you used genclass to create the Java class, you can swap in new method implementations
19:02hiredmanmaybe subclass the Java class?
19:03ayrnieuBut you can't do this in general. You can't subclass String, for instance.
19:03erohtardoes anyone know how i can find the filepath of a loaded clojure script?
19:04canderaOK, so I guess I need to study genclass to understand that approach better (subclassing is not really an option), but really what I'm looking for is a way to implement something like Ruby's open classes, where I can rip off existing methods and replace them with my own, or add totally new ones. Obviously it wouldn't survive the trip across the interop barrier, but I'm fine with that.
19:05technomancyerohtar: should be *file*
19:05ayrnieuerohtar - a #! /usr/bin/env clj script will have the path in (first *command-lineargs*)
19:05technomancy~*file*
19:05clojurebotHuh?
19:06erohtarthanks!
19:06ayrnieurelative in (first *command-line-args*), absolute (but not necessarily 'clean') in *file*
19:11lpetitbye folks
19:15canderaSo, having read the gen-class docs and a few other Google hits, it's not clear to me that I could use it to do what I'm asking about. As you say, it would work in the case where I've created the class, but I'm after being able to replace methods on (e.g) java.io.File.
19:50bakkdoorhi
19:51bakkdooris there any wrapper for swing in clojure? or something similar, like a library to do gui stuff "the clojure way"?
19:51bakkdoor(whatever that even means)
19:54bakkdooror if not, is there any interest in something like this?
20:09Chouserbakkdoor: there's clojure.contrib.miglayout
20:10Chouserbakkdoor: there are a couple mentions of swing on http://clojure.org/libraries
20:20danlarkin,(keyword 1)
20:20clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
20:20danlarkinthat seem silly to me
20:20Chouser,(keyword "1")
20:20clojurebot:1
20:21ayrnieu,(-> 1 str keyword)
20:21clojurebot:1
20:21danlarkinbut then I have to call str on my input in addition to calling keyword on it
20:21danlarkinoh well, I guess it's not the end of the world
20:22Chouseryeah, it could call str on both args
20:22ayrnieu,(keyword (ref 0))
20:22clojurebotjava.lang.ClassCastException: clojure.lang.Ref cannot be cast to java.lang.String
20:22Chouserexcept that I'd like keyword to take a Symbol as well
20:22ayrnieuaw, more work?
20:23Chouser(keyword 'foo/bar) should produce :foo/bar
20:23ayrnieuwell, (keyword (name sym)) helps by reminding you that 'name' was a poor choice of parameter.
20:23bakkdoorChouser: hm miglayout isn't really what i want, but alright. thanks :)
20:23danlarkinit should take any Named I guess?
20:23Chouserbakkdoor: never used it, just mentioning what I'd heard of.
20:24Chouserand I wish Vars were Named
20:24ayrnieuthe language actually isn't a carpet that you can sweep complexity under without cost.
20:24Chouser...while we're listing trivial changes...
20:28ayrnieu,(-> #'+ meta :name name keyword)
20:28clojurebot:+
20:28Chouser,(-> #'+ meta :ns str keyword)
20:28clojurebot:clojure.core
20:29ayrnieu,(-> "+" symbol resolve meta :name name keyword)
20:29clojurebot:+
20:30Chouser,((fn [v] (apply symbol (map #(str (% ^(resolve v))) [:ns :name]))) 'filter)
20:30clojurebotclojure.core/filter
20:31Chouser,((fn [v] (apply keyword (map #(str (% ^(resolve v))) [:ns :name]))) 'filter)
20:31clojurebot:clojure.core/filter
20:34ryszard_szopais there a way of recognizing through destructuring whether something has returned [something AString] or just AString?
20:34ryszard_szopaIf I do (let [[new new-context] (some-fn context)] ...) and some-fn
20:34ryszard_szopareturns a string as the only value, then Clojure will destructurize
20:34ryszard_szopathe string, and new will be equal to the first element of that string.
20:35gnuvince_ryszard_szopa: no, destrcuturing binding is not pattern matching.
20:35ryszard_szopaIn Common Lisp I would just make some-fn return multiple values and use multiple-value-bind
20:36ryszard_szopado you think there's some clean way of achieving a similar effect?
20:37gnuvince_checking if you are returned a vector or not maybe?
20:37ayrnieuYou could always return a vector with one or two strings. You could tag your results Erlang-style: [:ok s], [:multi s1 s2]
20:39Chouser(let [z (some-fn) [x y] (if (vector? z) z [z])] ...)
20:39Chouser:-/
20:40ryszard_szopaChouser: hm, that seems quite clean... but I cannot say it is *very* clean :/
20:40ryszard_szopasome-fun should get some context and return a string and the changed context
20:41ayrnieu(let [ret1 (ref nil) ret2 (ref nil)] (some-fn ret1 ret2) ...)
20:41ryszard_szopaI wanted some-fun to be able return just the string if it doesn't change the context... This would allow me to pass :keywords as some-funs...
20:42Chouserthere's a snippet of code somewhere that implements CL-style multiple-value return
20:43ayrnieuryszard, if you have a number of possible mutations of the context, write a macro to string the context through the calls.
20:43ryszard_szopaayrnieu: string the context through the calls? what do you mean by that?
20:44SimonAdameitGood evening
20:45SimonAdameitWhy is -> a macro and not a function?
20:45ayrnieufunction arguments get evaluated before their results can be passed to the function.
20:45ayrnieu,(-> "hi" (.contains "i"))
20:45clojurebottrue
20:45ayrnieu,(.contains "i") ;; can't evaluate this ahead of time
20:45clojurebotjava.lang.IllegalArgumentException: No matching field found: contains for class java.lang.String
20:45SimonAdameitIt means (-> #(take 2 %) .....) does not work
20:46SimonAdameitayrnieu: I'd rather have -> be a function and use currying for shortness :)
20:46ayrnieuthere are trade-offs. Some has gone to the trouble of extending -> so that (-> (take 2 _) ...) will do that.
20:46ayrnieusimon - you're a haskell-addled fool.
20:47SimonAdameithaha :)
20:47SimonAdameitno, I dont know Haskell, but I'm interested in it.
20:47SimonAdameitayrnieu: actually I come from Common Lisp
20:48ayrnieuthen you should know better! >:(
20:50Chouser,((-> [a] #(* 2 a)) 3)
20:50clojurebot6
20:52Chouser,(-> [x [1 2 3]] (for (+ x 2)))
20:52clojurebot(3 4 5)
20:53ayrnieuryszard, you could have something like -> that also destructures your meaningful results and has a bit of flow-control. How useful this would be depends on what you're doing.
20:54SimonAdameit,(-> 3 repeat #(take 2 %))
20:54clojurebotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentVector
21:03ryszard_szopaayrnieu: this was a one time thing... and I wanted the keywords mostly for debug purposes. I think I should just accept that destructuring =/= pattern matching and I won't be able to write my clj functions the way I would write eg Prolog predicates.
21:03ryszard_szopa;)
21:09humanzeeping
21:11Chouserclojure.contrib.error-kit is up: http://groups.google.com/group/clojure/browse_thread/thread/2d1d91693887a45b
21:14Chouserfeedback very welcome.
21:15ryszard_szopaChouser: I like the general idea... Thanks...
21:16ryszard_szopahowever, it is not very clear for me how the intermediate continues work
21:16durka42Chouser: did you just post error-kit?
21:16Chouserdurka42: yeah
21:17durka42can i see?
21:18durka42it's not in the log yet
21:18Chouserdurka42: description posted to the group, linnk above
21:19ryszard_szopaChouser: and if you are in Santa Klaus mood, then you could also consider implementing something like Ruby's `retry'
21:19Chouserdurka42: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/error_kit.clj
21:20durka42thanks
21:21Chouserryszard_szopa: continues are a little tricky. I guess they need a more complete doc.
21:22ryszard_szopaI guess they don't work like restarts, allowing the operator to choose what to do?
21:23ryszard_szopawith-handler is something like CL's handler-case... What about handler-bind?
21:24Chouserwith-handler can have handle forms, which is like handler-case, and bind-continue which is like handler-bind
21:26ChouserI have no clue how to even begin trying to implement ruby's retry. :-)
21:30ryszard_szopaChouser: this may be naive, but you could try putting all the forms in with-handler into a lambda... and retry would just call it.
21:31ryszard_szopa*lambda -> fn
21:31Chouserruby's retry starts a loop over from the beginning, doesn't it?
21:31Chousermaybe I misread that
21:31ryszard_szopaI don't know, I just heard of it and was always jealous ;-)
21:32Chouser"The redo statement causes a loop to repeat the current iteration. Sometimes, though, you need to wind the loop right back to the very beginning. The retry statement is just the ticket."
21:38ryszard_szopaChouser: yeah, that's right. And "If retry appears in the iterator, the block, or the body of the for expression, restarts the invocation of the iterator call.". But I've always thought it would be really useful in handler-{case|bind} situations.
21:41ryszard_szopaIn CL it was quite common for me to wrap everything I wanted to be handled in a 0-argument function, which I would just call in handler-*. Then in some situations I would call it once again in the handling code. If I had a name to refer to that function my life would probably be a bit easier
21:59danlarkinChouser: I'm liking how error-kit looks
21:59Chouserdanlarkin: great!
22:00Chouserryszard_szopa: I think I'd have to see an example.
22:07ryszard_szopaChouser: http://common-lisp.net/cgi-bin/darcsweb/darcsweb.cgi?r=submarine-submarine;a=headblob;f=/db.lisp#l122
22:11gnuvince_Chouser: nice work
22:12ryszard_szopaChouser: hm, now that I think about it this is not the best example... I don't retry it in the handling code, but leave it for later treatment... Maybe I should stop bugging you and just write a macro when I need it :-)
22:14Chouserryszard_szopa: you do that. :-) ...and then show me your macro, maybe it'll fit right in.
22:28RaynesRich quits a lot doesn't he :o.
22:33ryszard_szopagah! is there something like `break' in Clojure?
22:33ayrnieu,(java.util.Date. (long (* 1000 1234567890)))
22:33clojurebot#<Date Fri Feb 13 15:31:30 PST 2009>
22:33ryszard_szopaor, to rephrase my question: what is your debugging strategy?
22:33ayrnieuryszard - throw
22:34Chouserryszard_szopa: rpn
22:34Chouserum, prn
22:34ayrnieuoh, you mean *break*.
22:34ryszard_szopabreak like in CL
22:35ryszard_szopa(I forgot that in Java break is something completely different)
22:35ChouserYou can use the java debugger if you want
22:35ryszard_szopaayrnieu: as for throw, it doesn't allow me to continue the execution of the function
22:36ryszard_szopaChouser: hm... do you maybe know how to configure it to work with Slime and Emacs?
22:36Chousersorry, i don't use either.
22:37ChouserI try to use small functional functions, and sprinkle with prn.
22:37ayrnieuryszard, the most advanced debugging I've done has been to set Refs from within agents.
22:39ryszard_szopaayrnieu: sounds scary
22:51gnuvince_*sigh*
22:51gnuvince_Man, I can't believe how slow my program has gotten to make it right
23:12gnuvince_Is it possible to use a local with the . macro? Something like: (let [meth 'indexOf] (. "hello" (meth (int \e))))
23:15drewr(let [meth #(.indexOf %)] ... )
23:16drewror
23:16drewr(let [meth #(.indexOf %1 %2)] ... )
23:16drewr(-> "hello" (meth ... ))
23:17Chousergnuvince_: you can either do it with a macro or via reflection
23:17gnuvince_Chouser: the macro, that's what I'm looking for.
23:18gnuvince_`(let [meth# indexOf] (. "hello" (meth# (int \e)))) ?
23:20drewrthis works with no macro: (let [meth #(.indexOf %1 %2)] (-> "hello" (meth (int \e))))
23:20Chouserbut gnuvince_ wants to pass in the name of the method?
23:21Chouseroh, a macro won't do it if the name is being given at runtime
23:21drewrI've been down this road before
23:21drewrclojure makes this unreasonably difficult
23:22drewrneeds something like ruby's send or python's getattr
23:22Chouserthere was a thread on the group recently that included a macro that used eval to do it.
23:22gnuvince_drewr: I have about 80 million calls
23:22gnuvince_drewr: when I used memfn, it took so long that I wouldn't let the program finish running
23:24gnuvince_I think I want to do something for which Clojure is absolutely not suited.
23:24Chouser,(clojure.lang.Reflector/invokeInstanceMember "indexOf" "hello" (to-array ["l"]))
23:24clojurebot2
23:24Chouser(clojure.lang.Reflector/invokeInstanceMember "indexOf" "hello" (to-array ["l"]))
23:25Chousergnuvince_: you're calling lots of different methods on the same object?
23:25Chouserlots of different object/methodname pairs?
23:25gnuvince_Chouser: the same three
23:25gnuvince_Byte calls get, Short calls getShort and Integer calls getInt
23:26Chousercan you use three closures?
23:26gnuvince_Too slow
23:26Chouserwhat!?
23:26gnuvince_I had three memfns before
23:26gnuvince_They didn't cut it.
23:26drewrdoesn't sound like raw Java would be any better either
23:27Chouserwere they using reflection?
23:27Chouserif you're having performance issues, the very first thing to do is turn on *warn-on-reflection*
23:28Chouseronce you've removed all reflection your inner loops, then you can look into boxing issues, primitive math and stuff.
23:36replacaChouser: that error-kit stuff looks super-cool!
23:36gnuvince_I have no inner loop really
23:37gnuvince_It's all byte reading stuff
23:37gnuvince_Trying to get a profile
23:37gnuvince_But it takes over 10 minutes
23:37Chouser:-(
23:37gnuvince_So progress is ultra slow
23:37gnuvince_And I did what drewr suggested
23:37gnuvince_I am *very* surprised that it actually increased performance
23:38gnuvince_I distinctly recall switching away from functions to macros
23:38gnuvince_In any case, all the better, I prefer functions to macros
23:38drewrany way to break up your problem into smaller sets of calls?
23:38drewrfor quicker feedback
23:39gnuvince_drewr: If I run code in slime, it takes about 4-5 seconds to decode a file
23:39gnuvince_But because I expect to need to decode hundreds if not thousands of files, I really need to find why I cannot get the same performance as my Python version
23:40Chousergnuvince_: is it small enough code to paste?
23:40gnuvince_No
23:40gnuvince_I have a git repos
23:40gnuvince_I'll link in a few seconds
23:40gnuvince_Just need to push some changes
23:40Chouserreplaca: ah, thanks! I hope someone actually uses it -- I'm afraid I don't have much need.
23:42replacaChouser: I think it's good if it just starts discussion about better errors/conditions for clojure. It feels like java exceptions (by themselves) don't really fit
23:43replacaChouser: cause of the checked exceptions
23:43Chousersomeone was in here recently wishing for checked exceptions in Clojure.
23:44drewrwow
23:45gnuvince_Chouser: http://github.com/gnuvince/clj-starcraft/tree/master
23:46gnuvince_Chouser: if you wish to try it, you'll need to download a Starcraft replay file (you can go to http://teamliquid.net to get one)
23:46Chouserwhich .clj file is the main culprit?
23:47drewrChouser: http://github.com/gnuvince/clj-starcraft/commit/926bf7211c497478b609def912a579646bd186b4
23:48gnuvince_Chouser: in starcraft.replay.unpack, decode-commands and decode-command-block are the big ones
23:48gnuvince_decoding the headers is fast because it's so tiny.
23:48gnuvince_(the actions are in actions.clj)
23:53Chouseryeah, I think a few more type hints will help you
23:53gnuvince_I agree
23:54gnuvince_After 17 minutes, -Xrunhprof finally finished
23:54gnuvince_Here are the first three lines:
23:54gnuvince_ 1 8.43% 8.43% 13163743 304691 java.lang.reflect.Method.copy
23:54gnuvince_ 2 8.18% 16.61% 13163743 304690 java.lang.reflect.Method.<init>
23:54gnuvince_ 3 8.16% 24.77% 13163743 304692 java.lang.reflect.ReflectAccess.copyMethod
23:54gnuvince_the next two are also about reflection
23:55Chouseryup, they hurt.
23:55gnuvince_that's like 40% in reflection.
23:55gnuvince_Now, I need to find it :-/
23:55Chouserand the three lines that *warn-* mentions are the three you were already touching with the macro/fn switch
23:57gnuvince_Do I need to use defn to use type hints?
23:57gnuvince_Cause I changed it to (fn [#^ByteBuffer buf] (...)) and I still get a warning
23:58gnuvince_...
23:58gnuvince_It looks faster when there are no type hints?
23:58gnuvince_That's abnormal...
23:58Chouserthat's not trickling through to the %
23:59Chouseryou need something like Integer #(long (bit-and (.getInt #^ByteBuffer %) 0xffffffff))} type)
23:59Chouserbut that's not sufficient for the two previous lines. I can't quite figure them out.