#clojure logs

2009-04-09

01:22hiredman~jdoc java.util.LinkedList
01:54scottj_I have some html that is not standards compliant and I would like to use xml-seq with it. It appears that xml-seq needs parse which only works with standards-compliant xml. am I missing something?
02:12spaceman_stuhm. When I launch my compojure site from the repl, it can't find the public directory I set up with images, etc
02:12spaceman_sturather, launch from slime
02:13spaceman_stuit's behaving as though it's not referencing directories from the app's root
02:13spaceman_stuis that a .emacs setting?
02:15scottj_probably referencing it from whatever directory was the working directory when you started slime. C-x C-f will try to open a file in the current working directory I think
02:15hiredmanI think compojure looks for a directory called public in the cwd
02:15spaceman_stucool. So how would I change the cwd?
02:16hiredmanit is where you start clojure
02:17scottj_spaceman_stu: don't really know the best way. you could open a file in the directory you want to be your cwd and then launch slime from there, maybe
02:17scottj_I don't know if ,cd in slime changes the cwd, or whether you need to do that before you load your compojure code
02:20spaceman_stulooks like M-x cd is what I'm looking for. THanks both of you
02:31hiredman~mock objects?
02:31clojurebotYour mock object is a joke; that object is mocking you. For needing it. -- rhickey
03:21AWizzArdMoin moin
03:23AWizzArd~seen rhickey
03:23clojurebotrhickey was last seen quiting IRC, 318 minutes ago
03:24AWizzArd~max people
03:24clojurebotmax people is 164
03:33jdzhmm, is there a function in core that composes functions?
03:33jdzi don't like how #(max (count %)) looks
03:34jdzhmm
03:34jdzthose don't glue together anyway
03:34jdzbut the question still remains
03:36leafwjdz: yes: comp
03:36leafw,(doc comp)
03:36clojurebot"([& fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
03:36jdzok, thanks
03:43hiredman,(pl ((inc � dec) 0))
03:43clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$dec
03:43hiredman,(pl inc � dec)
03:43clojurebot#<core$comp__3753$fn__3755 clojure.core$comp__3753$fn__3755@411379>
03:43hiredman,(pl (inc � dec 0))
03:43clojurebot0
03:44hiredman,(pl (range � inc 3))
03:44clojurebot(0 1 2 3)
05:02AWizzArdhiredman: what is this pl thing?
05:13jdzwhat would be a proper way to iterate over keyvals sequence (like :key1 val1 :key2 val2 etc) without first creating a map with apply?
05:14jdzby properly i mean at each iteration step getting a key/value pair
05:26AWizzArdlike should have a header such as (defn like [[k v] & args] ...)
05:28AWizzArdor just take [& args] and have a (loop [[k v & rest] args, result []] ... (recur rest (conj result [v k])))
05:28jdzhmm...
05:29AWizzArd,(loop [[k v & rest :as all] '(:a 1 :b 2 :c 3), result []](if-not all result (recur rest (conj result [(inc v) k]))))
05:29clojurebot[[2 :a] [3 :b] [4 :c]]
05:31AWizzArdDoes this get you started?
05:31jdztoo bad "for" does not support this kind of destructuring...
05:31jdzyes, thanks
05:32jdzi have written so many loop/recur's that i'm trying to get rid of them
05:32jdzthey have their place in utility functions, but not sprinkled all over the code
05:36AWizzArdThey are as typical as loops are in any language, such as Javas for loop.
05:36AWizzArdIt's everywhere :)
05:36jdzyes but i recently discovered "for" and many things can be written so much more clearly
05:37AWizzArdright
05:37jdzsomething like CL' s iterate would be awesome to have, though
05:37jdzand lazy!
05:47AWizzArdIn principle I see it as a bug that it does not work with (for ..)
05:47AWizzArdThe problem is the use of when-first in the for macro.
05:48jdzyes, i gathered as much
05:49AWizzArdThe for macro needs a correction in my opinion.
05:50AWizzArdCurrently it is hardwired into it that one takes only one element out of the collection.
05:52hosiawak,(doc pl)
05:52clojurebot"([& forms]); replaces a $ b with (a b) walking right to left replaces a � b with (comp a b) left to right ?a with (uncurry a) left to right ?a with (flip a) left to right"
05:59antifuchsso... plyntax?
06:07Chousukejdz: partition might work too
06:08jdzChousuke: yes, thank you.
06:11jdz,(for [[k v] (partition 2 '(:a 1 :b 2 :c 3))] [(inc v) k])
06:11clojurebot([2 :a] [3 :b] [4 :c])
06:11jdzlooks so much better!
06:16AWizzArdjdz: but this is then again already much closer to the apply which you did not want to have
06:17jdzwhat apply?
06:17jdzthe point is that i want function to accept a list of key/value pairs, not a map
06:18jdzlike (defn foo [x y & keyvals] ..) instead of (defn foo [x y keyval-map] ...)
06:19AWizzArdWhy? :)
06:19jdzand creating a map in-between feels worse than going through a sequence by two elements
06:20jdzbecause the first approach looks better at the call site
06:20AWizzArdIt saves two chars: { and }
06:20jdzand many core functions work that way
06:20jdzand it also saves stress on my eyes
06:20AWizzArdSeveral of these core functions work this way to *create* a map.
06:21jdzyes, but they do not ask you to provide a map :)
06:21AWizzArdThis is obviously necessary.
06:21jdzlike assoc; there is a difference between assoc and merge
06:21AWizzArdSure, how could you provide a map if your goal is to create one?
06:22AWizzArd,(conj {:a 1, :b 2} {:c 3})
06:22clojurebot{:c 3, :a 1, :b 2}
06:23AWizzArdThe map is a really good data structure if you need key/value pairs.
06:23jdzi'd prefer (assoc {:a 1, :b 2} :c 3) to conj any time of day
06:24AWizzArdThat's fine. But in that case you must already know what the target is.
06:25jdztarget being?
06:25AWizzArdhashmap
06:25jdzin your context?
06:25AWizzArd,(conj (list 1 2 3) 0)
06:25clojurebot(0 1 2 3)
06:25AWizzArd,(conj (vector 1 2 3) 4)
06:25clojurebot[1 2 3 4]
06:26jdzi'm not getting the drift, sorry
06:26AWizzArdassoc is very good for documenting the code. It tells your readers that you explictly want to work on maps.
06:26AWizzArdBut conj allows for more generic algorithms.
06:26jdzyes, and that is besides the point
06:27AWizzArdalso in your example you will need to apply assoc to your & kv-pairs
06:27AWizzArdif that were a map you could just assoc them
06:27jdzno
06:28AWizzArd,(assoc {:a 10, :b 20} '(:c 30))
06:28clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$assoc
06:28AWizzArd,(apply assoc {:a 10, :b 20} '(:c 30))
06:28clojurebot{:c 30, :a 10, :b 20}
06:28AWizzArdvs
06:28AWizzArd,(assoc {:a 10, :b 20} {:c 30})
06:28clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$assoc
06:28AWizzArdcool
06:28jdzthe point is that i don't want to create a map
06:29jdzi want my function to accept options
06:29AWizzArdTo save the caller side from typing two more chars?
06:29jdzthe caller should not be constructing maps just to please the callee
06:29AWizzArdYes, like keyword args in CL.
06:29jdzall i want is to pass some options
06:29jdzconstructing maps is just a clutter
06:29AWizzArdBut how do you define the defaults?
06:30jdzif the callee wants to construct a map out of the options, it's callee's business
06:30AWizzArdThe idiomatic Clojure design pattern is to pass a map and merge it with the defaults.
06:30jdzin my case i don't have defaults
06:30AWizzArdWhat if you want to add them later?
06:31jdzit would be no problem
06:33jdzwell, it may be my exposure to CL being at work here; i'm sure i'll pick up clojure idioms while writing more code
06:33AWizzArdI also come from CL. And &key args would indeed be nice to have.
06:35AWizzArdIt's just the closest bet we have in Clojure to pass maps. Those you can easily bind in a let with destructuring and merge.
06:35AWizzArd(defn foo [args] (let [{port :port, prot :protocol, url :url} (merge defults args)] ...))
06:36AWizzArd&key args always need to have a default. Without one they don't make sense.
06:37AWizzArdIf you really have no defaults in your case then I don't see why the user has to pass in key/value pairs vs just values.
06:37jdzsometimes they do; like in my case: (node "node" :fontname "Helvetica" :fontsize 16 :fillcolor "white")
06:37AWizzArdWhat if the caller does not specify a :fillcolor?
06:38jdzthen the :fillcolor is not being used.
06:38jdzi mean, is not being used in the output
06:38AWizzArdSo the output will have no color?
06:38jdzi'm generating .dot files here
06:38AWizzArdWhat fontsize will be used?
06:38jdzthe default graphviz font size
06:38AWizzArdYou are implicitly using the defauts of .. yes
06:39jdzyes
06:39jdzand i don't want to create my own defaults and override graphviz's defaults with them
06:39AWizzArdDoes anyone here remember why Clojure does not support key args?
06:40jdzthey don't mesh very well with rest args :)
06:40jdzumm, the optional ones
06:40AWizzArdtrue
06:41AWizzArdI mean, CL has a way to handle that, but maybe Rich thought it would make Clojure too complicated.
07:29NeronusI guess because you can emulate this very well using maps or arraymaps
07:49AWizzArdgenau
08:37hosiawakwhere can I find the def of pl clojurebot knows about ?
08:40AWizzArdYou can ask the bot where its sources reside.
08:54AWizzArdIs there an X that allows me to say (X methodC methodB methodA (get-some-object)) instead of (.methodC (.methodB (.methodA (get-some-object))))? If yes, what is it?
08:54AWizzArdI am aware that I can do (-> (get-some-object) (.methodA) (.methodB) (.methodC)).
08:55gnuvinceAWizzArd: ..?
08:55jdzi curious why would you want that...
08:55gnuvince(doc ..)
08:55clojurebotform => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get "os.name")) expands to: (. (. System (getProperties)) (get "os.name")) but is easier to write, read, and understand.; arglists ([x form] [x form & more])
08:58AWizzArd.. seems to be doing what -> is doing.
08:58gnuvince(.. "Hello" length (equals 5) toString)
08:58gnuvince,(.. "Hello" length (equals 5) toString)
08:58clojurebot"true"
08:58AWizzArdBut for this case it documents better what I want to do. Thanks gnuvince
08:58gnuvincenp
08:58gnuvince,(macroexpand-1 '(.. "Hello" length (equals 5) toString))
08:58clojurebot(.. (. "Hello" length) (equals 5) toString)
08:59AWizzArdI thought I would want to have it as (.. toString (equals 5) length "Hello"), but the other way around it's perhaeps even better.
08:59gnuvince,(macroexpand '(.. "Hello" length (equals 5) toString))
08:59clojurebot(. (. (. "Hello" length) (equals 5)) toString)
09:09AWizzArdjdz: I want that to make it a bit easier for a human reader to parse what it means.
09:09AWizzArdThat is probably the biggest use of ..
09:10jdzwell yes, i was just wondering about the order of invocation (since it seemed that you wanted the opposite of ->)
09:11AWizzArdjdz: Yes, that was indeed my first idea. But now I like the order of .. (or ->) more :)
09:26AWizzArdHi PJ.
09:31ozzileeHey all. I wrote a java class in Clojure that I can compile and call with JSVC. JSVC calls the class's 'start' method...
09:32ozzileeI'd like to be able to run it from an ant task without compiling for development. Can I get clojure.lang.Script to do this?
09:33ozzileeOr do I need to compile, and maybe write another script to start it?
09:41hosiawakclojurebot: def pl
09:43hosiawakclojurebot: def aofjo
09:45AWizzArdclojurebot: where are your sources?
09:45clojurebotI don't understand.
09:45AWizzArdclojurebot: where is your source?
09:45clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
10:01pjstadigAWizzArd: hi
10:21cconstantinebooo! java regex is broken, so I can't do what I want in clojure :(
10:21cconstantineno named captures == broken
10:23gnuvincewhy?
10:23gnuvinceIt's a missing feature for sure, but I wouldn't call it broken
10:23cconstantineI shamelessly thing of Perl's regex as canonical, so if Perl's regex can do it anyone should be able to
10:24cconstantines/thing/think
10:25Carkbasic regex is easy, full blown and optimized is hard
10:25cconstantineyeah, with lookahead/behind and all that
10:26cconstantineeven perl doesn't optimize as much as it could
10:26Carkhave a look to http://www.weitz.de/cl-ppcre/ for a common lisp implementation
10:26Carkwhich is faster on some implementations than perl
10:26cconstantineCark: I've had much luck with that. I was looking to re-write my fancy-grep in clojure based on my CL implementation
10:27gnuvinceI don't see the point of rewriting the regex engine when there's one that works pretty darn well
10:27cconstantineMy CL implementation wasn't very lisp-y anyway
10:27cconstantineno named captures... my fancy-grep is based around that feature
10:27gnuvinceEspecially if you can't use your own with Java libs
10:27Chousernamed capture in perl is pretty new, isn't it?
10:27gnuvinceChouser: 5.10
10:27gnuvincePython had it way before
10:28ChouserI have a whole project written in python because I wanted named capture and neither perl nor ruby had it.
10:28Carkanyways if you need named capture, you might want to look into soime parser library instead ?
10:28cconstantineI know the CL, and o-caml implementations had it over a year ago.
10:28frodwithParser::RecDescent, for instance.
10:30cconstantineeh, I have an implementation of my fancy-grep in python also (used it to learn both CL and python). I was hoping to implement it in clojure as a learning experiance
10:31AWizzArdIs there a way to list all namespaces which Clojure currently knows? (because of using/requiring Clojure libs)
10:32cconstantineChouser: I'd avoid writing whole project in perl... but that's because I've never been able to write a non-trivial perl program/script and maintain it.
10:32AWizzArd,(doc all-ns)
10:32clojurebot"([]); Returns a sequence of all namespaces."
10:33AWizzArdoki
10:36eyerisIf I have a string who's contents name a function, how can I call that function?
10:37pjstadig,(apply (eval "str") 1 2 3)
10:37clojurebotDENIED
10:37pjstadigd'oh
10:39pjstadig(apply (ns-resolve *ns* (symbol "str")) 1 2 3)
10:39pjstadig,(apply (ns-resolve *ns* (symbol "str")) 1 2 3)
10:39clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
10:39pjstadig,(apply (ns-resolve *ns* (symbol "str")) [1 2 3])
10:39clojurebot"123"
10:39pjstadig,((ns-resolve *ns* (symbol "str")) 1 2 3)
10:39clojurebot"123"
10:40eyeris((symbol "str") [1 2 3])
10:40eyeris,((symbol "str") [1 2 3])
10:40clojurebotnil
10:40eyeris,((symbol "str") 1)
10:40clojurebotnil
10:40pjstadigyou would have to resolve the symbol to a var
10:40eyerisOh, right
10:41pjstadig,((resolve (symbol "str")) 1 2 3)
10:41clojurebot"123"
10:41pjstadigif you want to specify a specific ns i guess you'd use the ns-resolve
10:41pjstadig~def resolve
10:42pjstadigresolve is the same thing as (ns-resolve *ns* sym)
10:42pjstadig,(resolve "str")
10:42clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol
10:45eyerisThanks. That worked.
10:45pjstadignp
11:23eyerisHow can I get the length of a Java array?
11:23slashus2.length ?
11:23pjstadig(doc alength)
11:23clojurebotReturns the length of the Java array. Works on arrays of all types.; arglists ([array])
11:24eyerisah!! alength!
11:24pjstadigmost of the array functions start with an 'a' as a prefix
11:24pjstadigso they are conveniently grouped on http://clojure.org/api
11:25Chouserkinda interesting that I've never needed that.
11:25eyerisThis is so annoying. I've spent 3 hours tracking down phantom bugs in my clojure code, only to find out that this java Excel library is broken
11:26pjstadig(.length (to-array [1 2 3])
11:26pjstadig,(.length (to-array [1 2 3])
11:26clojurebotEOF while reading
11:26eyeris,(.length (to-array [1 2 3]))
11:26clojurebotjava.lang.IllegalArgumentException: No matching field found: length for class [Ljava.lang.Object;
11:27eyeris,(count (to-array [1 2 3]))
11:27clojurebot3
11:27eyeris,(acount (to-array [1 2 3]))
11:27clojurebotjava.lang.Exception: Unable to resolve symbol: acount in this context
11:27eyeris,(alength (to-array [1 2 3]))
11:27clojurebot3
11:27slashus2(.length (make-array Integer/Type 10))
11:27slashus2,(.length (make-array Integer/TYPE 10))
11:27clojurebotjava.lang.IllegalArgumentException: No matching field found: length for class [I
11:29eyerisslashus2 .length is a property, not a method
11:29slashus2yeah
11:29slashus2I know
11:29pjstadig(amap (to-array [1 2 3]) i [] inc)
11:29pjstadig,(amap (to-array [1 2 3]) i [] inc)
11:29clojurebotjava.lang.IllegalArgumentException: Argument is not an array
11:29pjstadig,(amap (to-array [1 2 3]) i (to-array []) inc)
11:29clojurebotjava.lang.Exception: Unsupported binding form: (to-array [])
11:30pjstadig,(amap (to-array [1 2 3]) i ret (inc i ret))
11:30clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$fn
11:34hosiawak,(Integer/valueOf "2")
11:34clojurebot2
11:34hosiawak,(map #(Integer/valueOf) '(1 2 3))
11:34clojurebotjava.lang.NoSuchFieldException: valueOf
11:35hosiawakhow to pass Integer/valueOf to map ?
11:35pjstadig,(map Integer/valueOf '(1 2 3))
11:35clojurebotjava.lang.Exception: No such namespace: Integer
11:35Chousuke#(Integer/valueOf %)
11:35Chousukedon't forget the parameter :P
11:36Chousuke,(map #(Integer/valueOf %) '(1 2 3)) ; like this
11:36clojurebot(1 2 3)
11:36Chousukenot very interesting though
11:36hosiawak,(map #(Integer/valueOf %) '("1" "2" "3"))
11:36clojurebot(1 2 3)
11:37hosiawakis there other way to get the integer value of a string ?
11:37Chousukeusing vectors instead of quoted lists for literals is slightly more clojurey :)
11:37ChousukeInteger/parseInt
11:37hosiawakok, thanks
12:19kadaverhow would you implement types in clojure itself? i mean not writing a parser for a new language but jsut add it to clojure itself?
12:20pjstadigusing maps, structs, and multimethods
12:24kadaverok i did it with struct
12:25kadaverso basically you do it like with cons and cdr
12:25kadaveryou jsut implement it as a function
12:26kadaverhttp://hpaste.org/fastcgi/hpaste.fcgi/view?id=3592#a3592
12:26kadaverhaskell Maybe-type ^, is that how you would do it?
12:27kadaverand is there a function or macro for this: if x x y; ? instead do-if x y; so it will return the tested condition without me having to write it again as the then branch?
12:28scottj_Is there a way to use xml-seq with bad html? the parse function is too strict for most webpages.
12:29stuarthallowaykadaver: if-let
12:30kadaver(defn neat-if [a b]
12:30kadaver (if a a b))
12:30kadaveris what i want
12:32Chouserkadaver: or
12:37AWizzArdrhickey: Are you aware of the suggestions in this video? http://www.infoq.com/presentations/click-fast-bytecodes-funny-languages
12:39hiredmanAWizzArd: I am interested to hear what you think the suggestions from the video are
12:41AWizzArdDr. Click explains that he found some ways how Clojures bytecode could be improved to be more efficient. I don't understand in detail what he is talking about. But maybe rhickey does understand it, and perhaps there is new info waiting for him. So, I am just interested if he is aware.
12:42rhickeyAWizzArd: I was there and spent a lot of time with Cliff. At the time, Clojure didn't inline all the ops in his test, it now does, he's seen that, and it's the same as Scala on his benchmark
12:42AWizzArdOki, thanks.
12:48stuarthallowayrhickey: got two compiler questions for you: (1) any reason bytecode would blow up coverage tools? and (2) how would I compile to avoid this warning: "EMMA: package [clojure/contrib] contains classes [test_is__init] without full debug info"?
13:27eyerisCould someone tell me what I am doing wrong that is making Clojure fail to find this Java method? http://pastebin.ca/1387241
13:28stuarthallowayeyeris: getRefersToFormula sounds like the name of a getter method, not a field
13:30eyerisIt is a method.
13:31stuarthallowayI don't see Clojure code in the paste, just a stack trace
13:31eyerisHere it is: http://pastebin.ca/1387245
13:33stuarthallowaycan you try calling bean on the object to see what properties it does expose?
13:36eyerisThe output of bean is appended here: http://pastebin.ca/1387247
13:37eyerisThough isn't the problem that clojure thinks I am accessing a field instead of a method?
13:37stuarthallowayno, the message is a little misleading
13:38stuarthalloway,(.toUpperCase "foo")
13:38clojurebot"FOO"
13:38stuarthalloway,(.toNonexistentPlace "foo")
13:38clojurebotjava.lang.IllegalArgumentException: No matching field found: toNonexistentPlace for class java.lang.String
13:38eyerisOh. Ok.
13:39stuarthallowaythe bean info may be the clue -- it includes deprecated names and does not include the name you want
13:39stuarthallowayold version of the jar?
13:40eyerisDoes getRefersToFormula being defined in an interface, and implemented in the class complicate matters with bean?
13:40eyerisNo, it's the newest jar.
13:40eyerisWhat do you mean by "deprecated" names?
13:41stuarthallowayaccording to http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFName.html, the property "reference" is deprecated
13:41eyerisperhaps that documentation doesn't refer to the latest release, but some in-development realease...
13:43eyerisYep
13:43eyerisThat's it
13:43eyerisI will track that down after lunch :)
13:43eyeristhanks for helping me track that down.
13:43stuarthallowaygood luck
13:47cemerickthe fact that (not= (delay 5) 5) has become a serious inconvenience, especially in the context of map and vector equality
13:48cemerickdoes anyone see any potential issues with the notion of building a c.l.Delay subclass that provides equals and hashcode impls that always force the delay's value and delegate such calls to that value?
13:52Chouseryou want every delay in a key or value of a map forced if you test = on that map?
13:52cemerickin certain circumstances, yeah
13:52cemerickor, actually, in most circumstances, actually
13:53cemerick...maybe that's a sign I'm doing things wrong in a fundamental way....?
13:57Chousercemerick: I couldn't say -- I've not used delay at all.
13:57Chouserpeople have previously asked for other operations to auto-force, such as math operators.
13:57Chouserare you sure you're only going to want hash and = ?
13:58cemerickwell, auto-forcing isn't really appropriate across the board, I don't think (Rich semi-convinced me of that some time ago)
13:58cemerickI think that's all that's necessary in order to get maps and vectors to work properly.
13:59twismclojure question... when (let [kws (keys a-map)] ...) would (last kws) be equal to the last kw in a (doseq [kw kws] ...)?
14:00twismif that makes any sense
14:00twismof course i cold just test it out
14:02twismbut it equality could be true by chance
14:03twismam i making sense or am i being stupid
14:04pjstadigtwism: are you asking about a stable iteration ordering?
14:04lisppaste8cemerick pasted ""transparent" delays" at http://paste.lisp.org/display/78320
14:05cemerickthat feels wrong, somehow....
14:07twismpjstadig: basically are the keywords of maps when returned by the "keys" fn ordered the same?
14:07Chousertwism: every time get a seq for the same map's keys, the seq will have those keys in the same order.
14:08twismChouser: thanks i thought so
14:08Chouseras soon as you add anything or removing anything from the map, I wouldn't rely on the order being at all the same.
14:08twismok
14:08twismgotcha
14:08twismthanks again
14:08Chousercemerick: wrong because it was so easy to implement?
14:09cemerickheh, that's the good part!
14:09cemerickNo, I just know I've planted some pretty difficult-to-track bugs for myself when I start screwing with identity like that.
14:09cemerickin the past, that is
14:17dakrone_hbcan someone give me a hand with some refactoring? I have this code: http://gist.github.com/92640 and I think I need to switch it around to better operate on each line rather than loading the entire thing into memory...
14:22hiredmanif use exec directly you get an outputstream from the process
14:22hiredmanyou can wrap the os with a bufferedreader, then call line-seq on it
14:23Chouserdon't forget to clean up the streams and process when you're done
14:23Neronusbut don't close it before line-seq has seen it all, or you're dead... or something less worse
14:23Neronusless worse
14:24Neronusthat doesn't sound correct to me
14:24Neronusless bad
14:24hiredmanwhich is why you should use a scope
14:24Chouserdakrone_hb: shell-out doesn't let you get at the streams or the process directly precisely because that's a whole lot to worry about for those many cases where getting a single string is sufficient.
14:24Neronusor write your own lineseq
14:24dakrone_hbhiredman, were you talking to me when you said exec?
14:25dakrone_hbso, I need to write something that will let me operate on a single line with a function, without loading *all* the lines into memory?
14:25Neronuswhich uses scoping, so... forget me :)
14:25dakrone_hbor does something already exist in this capacity?
14:26hiredmanRuntime getRuntime exec?
14:28dakrone_hbhiredman, I was using this macro a while back: http://pacific.mpi-cbg.de/wiki/index.php/Clojure_Scripting#Executing_a_command_in_a_shell_and_capturing_its_output then Chouser suggested I use shell-out instead
14:29hiredmanprocessing the output of a shell comand lazily is pretty silly
14:29hiredmanthe ouput is not generated on demand anyway
14:30hiredmanit is just dumped into a buffer so it already exists
14:30Chouserwell, a process will block waiting to write if the output buffer is full, won't it?
14:31hiredmanI have no idea
14:31ChouserI think it does.
14:31hiredmanI guess that depends on how java manages it
14:31dakrone_hbI believe that's what happens
14:32pjstadigi think the point still stands, you're not asking a shell command for its output, it is giving it to you
14:32hiredmandakrone_hb: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html
14:33pjstadigso you process it based on the whim of the shell command, which means you don't really decide to be lazy
14:34dakrone_hbso instead of a line-seq, I'd use something that wasn't lazy, correct?
14:34Chouseryou'll be dealing with lines not chunks of binary data or something?
14:35hiredmandakrone_hb: you are already doing that
14:36dakrone_hbChouser, yes, dealing with another program that doesn't have an api, so I need to call it's executables, and then process each line of output to do different things with them
14:36pjstadigdakrone_hb: i don't think the OOME is coming from your code, but from the shell-out code that is trying to load all of the output at once
14:36Chouserdakrone_hb: in that case, a line-seq is probably appropriate
14:36pjstadigso if you use exec directly and read from the stream incrementally, then you wouldn't error out
14:37Chouserbut shell-out isn't going to help you at all as it stands
14:37dakrone_hbso doing a (read <stream>) only return 1 line at a time?
14:37Chouserdakrone_hb: you're name's not Kyle is it?
14:37hiredmanChouser: it might be nice to have something like ruby's IO.popen
14:38dakrone_hbChouser, no, why do you ask?
14:38hiredmanwell
14:38dakrone_hbyea, a popen is exactly what I need
14:38Chousersomeone named kyle is asking for similar features for shell-out
14:38hiredmanwith readlines.each
14:38dakrone_hboh, well that wasn't me
14:38hiredmanbasically a combination of with-open an shell-out
14:38hiredmanwith-open-proc
14:39Chouserthe reason it doesn't have it already is because it forces the user to mange the closing of streams and the cleaning up of the process
14:39Chouserand there are a lot of simple use cases where getting a String back is fine, so it's nice to not worry about all that.
14:39kadaverwhat do you people prefer with Clojure over Haskell?
14:39hiredman(with-open-proc "echo foo" [stdin stdout stderr] (do stuff))
14:40ChouserI think these more advanced usages warrent a bit more design and thought.
14:41hiredmankadaver: I like lisp and clojure has easy access to all the millions of java libraries
14:42rsynnottbecause haskell is, well, haskell ;)
14:43pjstadigkadaver: i know Clojure, and I do not know Haskell
14:44hiredmanthere was a great quote
14:44dakrone_hbChouser, I look forward to additions to the shell-out library ;) in the meantime I will try to hack something up with my limited knowledge of it
14:45hiredman#clojure.log:2009:Feb:10:16:37:16 ayrnieu : you have to see features like that in the context of Haskell's community, which is something like Perl's community in the garden of Eden: detached from all shame or need to do any work.
14:46Neronuslol
14:46dakrone_hbhiredman, Chouser, pjstadig, thanks for the help :)
14:46pjstadignp
14:47kadaverhiredman: what feature was that?
14:47hiredmanI forget
14:48kadaverI used to use Clojure (got interested in functional programming via Python) and I thought at first Haskell was too facist functional but after some time in Clojure and really grokking functional programming then I loved Haskell the next time I tried it.
14:48hiredmanclojurebot: logs?
14:48clojurebotlogs is http://clojure-log.n01se.net/
14:50hiredmanhttp://clojure-log.n01se.net/date/2009-02-10.html#19:37
14:50hiredmanfor context
14:50hiredmanthe context was infix operators, I believe
14:51hiredman,(pl inc $ inc $ inc $ 0)
14:51clojurebot3
14:51pjstadig?
14:52kadaverif you don't have macros int he lisp-sense then infix-math is nice...
14:52hiredman,(macroexpand `(pl inc $ inc $ inc $ 0))
14:52clojurebot(do (clojure.core/inc (clojure.core/inc (clojure.core/inc 0))))
14:52pjstadig(doc pl)
14:52clojurebotHuh?
14:52hiredman,(doc pl)
14:52clojurebot"([& forms]); replaces a $ b with (a b) walking right to left replaces a � b with (comp a b) left to right ?a with (uncurry a) left to right ?a with (flip a) left to right"
14:52pjstadigoh
14:53hiredmanpl is not in clojure.core so (doc pl) doesn't pick it up
14:53hiredman,(doc uncurry)
14:53clojurebot"([x]); applied to a function it returns a function that will continue partially applying until it is called with no arguments"
14:53pjstadighiredman: is there a way to get clojurebot to show the definition of a non-core function?
14:53hiredman,(((uncurry +) 1) 2)
14:53clojurebot#<sandbox$uncurry__1858$uc__1860 sandbox$uncurry__1858$uc__1860@8443a3>
14:53pjstadig~def parallel.par
14:54hiredmanha ha
14:54pjstadig~def clojure.parallel.par
14:54pjstadig~def clojure.parallel/par
14:55hiredman,(require '[clojure.parallel :as p])
14:55clojurebotjava.io.FileNotFoundException: Could not locate clojure/parallel__init.class or clojure/parallel.clj on classpath:
14:56pjstadigit needs to to be required to post a url?
14:56hiredmanclojure needs to be able to resolve the symbol
14:56hiredmanI don't have the funky jars needed for parallel.clj
14:56pjstadigk
14:57hiredman,((((uncurry +) 1) 2))
14:57clojurebot3
14:57pjstadig~def clojure.set/union
14:57pjstadiggotcha
15:00hiredmanfail whale
15:00hiredmanI think this is my first (shows how 2.0 I am)
15:00pjstadigmy first was just a couple of days ago
15:00hiredmanhttp://twitter.com/boscoh/statuses/1484205898 <-- ouch
15:01pjstadigbut then i only joined twitter like last month
15:02hiredmanyou know, clojurebot has a twitter...
15:02cemerickwhoa, dude's got some rage
15:04pjstadigi like having my brain turned inside out by new ideas....but maybe i'm just weird
15:07hiredmanI just don't get it
15:07hiredmanfunctions are like the simplest thing ever
15:08cemericknot having mature tools can often trip people up pretty easily
15:09pjstadigit's maybe simple once you get it, but it takes people a while to give up their for loops
15:09hiredmanclojurebot: functions?
15:09clojurebotanonymous functions are functions with no names
15:10hiredmanclojurebot: functions is <reply>functions are maps
15:10clojurebotYou don't have to tell me twice.
15:10hiredmanclojurebot: maps?
15:10clojurebotTitim gan �ir� ort.
15:10hiredmanclojurebot: maps is <reply>maps are functions
15:10clojurebotYou don't have to tell me twice.
15:20dhaasare there any particular windowing toolkits that mesh well with clojures way of doing things?
15:21hiredmanthere are some miglayout (swing layout manager) wrappers in contrib
15:21hiredmansome seem to like QT's java bindings, but those have been discontinued
15:23hiredmanI would just swing, just watch out for the event dispatch thread
15:24hiredmanjcip has a short section on concurrent guis, which made me re-think my opinion of swing
15:26durka42for the better or worse?
15:26hiredmanit made me appreciate the need for all the EDT redtape
15:27hiredmanhttp://weblogs.java.net/blog/kgh/archive/2004/10/multithreaded_t.html
15:28hiredmanI still hate writing guis, and avoid it
15:28hiredmanclojurebot: <3
15:28clojurebotHuh?
15:28cemerickhiredman: jcip?
15:29hiredmanclojurebot: jcip?
15:29clojurebotI don't understand.
15:29pjstadigjava concurrency in practice
15:29cemerickah
15:29hiredmanclojurebot: jcip is Java Concurrency in Practice
15:29clojurebotAck. Ack.
15:29cemerickstill haven't read that :-(
15:29Chousukeclojurebot: <3 is <3
15:29clojurebotOk.
15:29Chousukeclojurebot: <3 is also </3
15:29clojurebotIk begrijp
15:29pjstadigclojurebot: <3
15:29hiredman~<3 is also ?
15:29clojurebotRoger.
15:29clojurebot<3 is </3
15:30Chousukehm
15:30pjstadigclojurebot: <3
15:30clojurebot<3 is <3
15:30Chousukeneeds <reply>
15:30hiredmanclojurebot: literal [?] <3
15:30clojurebot3
15:31hiredman~<3 is also <reply>?
15:31clojurebotc'est bon!
15:57bradfordsuppose i have a seq generated by file-seq
15:58bradfordhow would i find all jars?
15:59cp2(filter #(.endsWith "jar" (.getName %)) blah)
15:59cp2i guess
16:00cp2oh oops
16:00Chouser(filter #(.endsWith (str %) ".jar") blah) ?
16:00cp2#(.endsWith (.getName %) ".jar") rather
16:06bradford(def files-and-dirs (file-seq (new File "~/opt/capjure")))
16:06bradford
16:06bradford(filter #(.endsWith (str %) ".jar") files-and-dirs)
16:06bradfordi'm getting an empty seq back
16:06bradfordthought i know there are jars under there
16:07hiredmandecompose and examine intermediate results
16:14dhaasi hate writing GUIs as well, but they are still quite useful :(
16:16bradfordah, i was being dumb. :-) the result of filter is also lazy so i need to force it to see results
16:49dhaasim trying to do an import once im in a namespace
16:49dhaas(in-ns 'foo) ........ (clojure/refer 'clojure)
16:49dhaasbut it doesnt think clojure is a valid ns...?
16:51hiredmanclojure.core
16:54dhaasits having a problem resolving clojure/refer
16:54dhaasjava.lang.Exception: No such var: clojure/refer (NO_SOURCE_FILE:1)
16:55pjstadig,clojure.core/refer
16:55clojurebot#<core$refer__4341 clojure.core$refer__4341@18600d7>
16:56pjstadig,clojure/refer
16:56clojurebotjava.lang.Exception: No such namespace: clojure
16:56dhaasah:)
16:56hiredmandhaas: there is no clojure namespace
16:56dhaasunderstood
16:56dhaas(now)
16:57hiredmannow as of five (six?) months ago
16:59AWizzArd~ def time
17:02kefka,(let [rg (set (range 50000))] (count (set rg)))
17:02clojurebot50000
17:02kefka,(let [rg (set (range 50000))] (time (count (set rg))))
17:02clojurebot50000
17:02clojurebot"Elapsed time: 210.43 msecs"
17:03kefkaIt costs significant time to call set on a large object that's already a set.
17:04pjstadig,(let [rg (set (range 50000))] (count rg))
17:04clojurebot50000
17:04pjstadig,(let [rg (set (range 50000))] (time (count rg)))
17:04clojurebot50000
17:04clojurebot"Elapsed time: 0.04 msecs"
17:04pjstadig~def set
17:05hiredmanset calls seq first
17:05hiredmanoh
17:05hiredmanoops
17:06hiredmanlooking at the wrong def
17:08kefka,(doc set)
17:08clojurebot"([coll]); Returns a set of the distinct elements of coll."
17:08hiredmanwell, someone has to ask
17:08pjstadig~def hash-set
17:08hiredmanwhy call set on a set?
17:08kefkaCalling set on a collection that may be a set.
17:14eyerisUhm, how do I exit the repl?
17:14pjstadig(System/exit 0)
17:14cp2you may not leave :)
17:14hiredmanI usually use control-d
17:15eyerisYeah, ^d doesn't work on Windows. Neither does ^z^z for some reason
17:16hiredmanyet another strike against windows...
17:16pjstadigto exit on window, insert unbuntu cd, go to start=>restart and install
17:17cp2actually its start -> turn off computer -> restart
17:17pjstadigoh you're right....that makes much more sense...
17:18hiredmanstart -> cmd.exe -> figure out the syntax for the shutdown command -> shutdown
17:18cp2that is true hiredman
17:18pjstadigyou mean start -> run "cmd.exe"?
17:18cp2yes
17:18cp2or winkey + r
17:18cp2!
17:18hiredmanah, depends
17:19hiredmanyou might have cmd.exe in your start menu, or have vista with the search thinger
17:19hiredmanso you just type "cmd.exe" and it finds it, and you hit enter
17:25Chouser^Z<enter>
17:31eyerisIs there a clojure api wrapper for Double/parseDouble?
17:32hiredmanwhy would you need one?
17:32hiredman,(Double/parseDouble "1.0")
17:32clojurebot1.0
17:32hiredman~javadoc Double
17:33hiredmanlooks even simpler then Integer/parseInt
17:35duncanmit'd be nice if the api page on clojure.org contains examples, particularly for the macros
17:35eyerisBut (dbl "1.0") would be cooler :)
17:36eyerisduncanm or at least a link at the top of the page to the examples page
17:36Chouser~examples
17:36clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
17:37duncanmi wanted to know how IF-LET looks
17:37duncanm(if-let [x 0] test? then-clause else-clause) ?
17:39slashus2duncanm: You mean having non-trivial examples in the doc strings?
17:40Chousukeduncanm: (if-let [x whatever] whatever-is-true whatever-is-false)
17:40Chouserpeople say that a lot. what is "non-trivial"
17:40duncanmChouser: where's the test, then?
17:40Chousukeit's basically (let [x whatever] (if x ...))
17:41duncanmoh!
17:41slashus2Chouser: I think a concise example that demonstrates the core usage of the api item is good enough.
17:42duncanmit says bindings => binding-form test in the docs
17:42duncanmit's kinda hassle that metadata associated with a list 'l' is not preserved in (rest l)
17:42duncanmit makes sense, but it's a hassle
17:43bradfordif want to go over a seq and call a func with each element of the seq, what is the right way..its like an each in ruby
17:43pjstadig(doc doseq)
17:43clojurebotRepeatedly executes body (presumably for side-effects) with bindings and filtering as provided by "for". Does not retain the head of the sequence. Returns nil.; arglists ([seq-exprs & body])
17:43duncanmbradford: do you want to get a seq back?
17:43duncanmMAP or DOSEQ
17:43bradfordnope, not getting a seq back..its not a map
17:44duncanmthen doseq
17:44pjstadiguse doseq for side effects and map if you are transforming the seq
17:44duncanm(doseq [i '(1 2 3)] (println i))
17:44bradfordyea, its causing side effects
17:44bradfordcool, thx
17:52bradfordok, so if i throw a println in to see that my seq contains what i think in contains, how do is see the resutsl if i do a slime-eval-region?
18:01bradfordi'm such a fool - it all sows up in the repl of course :-)
18:06dakrone_hbare there any already-built libraries for Clojure+Lucene?
18:10Chouserdakrone_hb: stuart sierra's apparently using it, though I don't know exactly what it is: http://groups.google.com/group/clojure/browse_thread/thread/62600c60f5279b8e
18:11bradfordwhat is the best way to concat a string ... file:// /foo/bar/baz -> file:///foo/bar/baz
18:11cp2(str "abc" "def")
18:12dakrone_hbChouser, cool, I'll check it out, thanks
18:17bradfordsuppose i have a filter liek this: (filter #(.endsWith (.getName %) ".jar") files-and-dirs)
18:17bradfordif i now want to extend the predicate to filter .jar and /src dirs, how to i add that?
18:21hiredmanit depends on what files-and-dirs is a seq of
18:22bradford(def src (filter #(.endsWith (.getName %) "src") files-and-dirs)) ... is how I would filter if i defined it seperately
18:22hiredmanit might be easier to half two filters one for jar files and one for directories named "src"
18:22bradfordyea, that is what i have now
18:22hiredmanwell
18:22hiredmanthat is easy
18:22bradfordperhaps i will jsut stick to that
18:22hiredmanjust use or
18:22hiredman#(or (.endsWith (.getName %) "src") (.endsWith (.getName %) ".jar"))
18:23hiredman(def jar-filter (partial filter #(.endsWith (.getName %) ".jar")))
18:23hiredman(def src-dir-filter (partial filter #(.endsWith (.getName %) "src")))
18:24hiredman(-> files-and-dirs jar-filter src-dir-filter)
18:24hiredmanhmm
18:24hiredmanthat wouldn't work
18:25bradfordi was wondering, in your first example using or...might there be another anonymous function to extract to avoid the cuplication?
18:25bradfordthe endswith getname stuff
18:25hiredman*shrug*
18:25bradfordhehe
18:25bradfordi'll jsut leave it as two seperate seqs :-)
18:27Rayneshiredman: Would you still love me if I learned Scala? :)
18:30hiredmanbe sure, I would not love you the less for doing such a thing
18:34SethTisuethere are 12 of us on both #clojure and #scala
19:32bradfordadd-classpath at the repl is not working for me as it did earlier
19:32bradford(add-classpath "file:///home/bradford/opt/capjure/lib/java/hadoop-0.18.1-core.jar")
19:32bradfordthen ... (System/getProperty "java.class.path")
19:33bradfordand that jar is not on the cp
19:33bradfordany ideas?
19:33hiredman(System/getProperty "java.class.path") is never updated
19:34hiredmanclojurebot: add-classpath
19:34clojurebotadd-classpath is bad, avoid it. I mean it!
19:34bradfordok, what shall i use?
19:34hiredmanjava -cp
19:35hiredmanclojurebot: jar directory
19:35clojurebotwith java6(jdk1.6) CLASSPATH can contain a "*" so /jar/dir/* will suck in all the jars in the /jar/dir directory, this also works with swank-clojure-extra-classpaths in emacs, alternatively you can use this shell snippet: find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"
19:36bradfordi ahve been using the swank-clojure-extra-classpaths
19:37bradfordbut i building up a project with many dependencies...and trying to find a nice way to slurp up al the deps in various lib folders (jars) and esatablish deps on .cljs via the src dirs
19:39hiredmanwhy bother connecting jars to individual source files?
19:39bradfordso, sicne add-classpath is not working. what is a good hook for me to use so that I can create a clojure script that generates the list of paths that I want to feed to swank-clojure-extra-classpaths?
19:40hiredmanjust use the find command from above
19:40hiredmanunless you are on windows, in which case find does something completely different
19:40bradfordwell, if i skip the add-classpath garbage, i don't need to collect jars sicne i can just add lib dris with lib/*
19:40hiredmanand the classpath seperator is different
19:40hiredmancorrect
19:44bradfordthe issue is finding dirs containing jars to add lib/* to classpath and then finding dirs such as /src containing other clojure projects to add those paths to classpath to be able to use vars from those projects
19:45bradfordI already have all the manual hackery in the my .emacs and bash scripts and stuff. but this is not really a great setup for maintaining a project aht dependens on many other clojure projects.
19:45hiredmanI would jar up the other clojure projects
19:45bradfordah
19:45hiredmanso you just have a set of jars
19:46bradfordso assume that everything msut be jar'd
19:46hiredmanwell it lets you manage java and clojure in a uniform way
19:46bradfordso then i just bring all projects under one dir my/project/deps ... jar them all up, and then something simpelr like find will be OK
19:46bradfordgood point
19:47durka42i see
19:48bradfordand i should not need to use the find comamnd at all in that case?
19:48bradfordwill the lib/* work recrusively?
19:48hiredmanI dunno
19:48bradfordcool, i'll find out.
19:48bradfordthx
19:54hiredmanthe "*" is not handled by shell globing but by java
21:13redalastorHow can I do a GUI with a data entry zone and a rendering zone (data should asynchronously be rendered as typed).
21:14redalastor I thought of using an agent but I want the current rendering to be thrown out if it's not done and more data is typed. An agent would just queue all the intermediate stages.
21:15arohnerredalastor: have you looked at atoms?
21:16redalastorI read about them but I didn't grok how they work.
21:18arohnerthey are a variable than can be set without race conditions
21:18arohnerthe new value is a function of the old value
21:18arohnerbut thinking about it, that isn't quite what you want
21:19arohneryou sort of want agents, but you want new jobs to cancel in-progress jobs
21:19redalastorExactly
21:20Chouseryour in-progress jobs are going to have to poll to see if they should give up
21:20redalastorSo somewhere in my rendering loop, I have to check if I should continue or not?
21:21ChouserJava doesn't like you cancelling threads from outside the thread, so I think your only option is from within the thread.
21:21redalastorWould there be a way to achieve what I want by storing a future in an agent?
21:22Chouserfutures are for when you want something to block if it's not done computing yet
21:22ChouserI think some kind of reference type (perhaps an atom) to store the most-recent data value as entered by the user.
21:22redalastorYes. But they return instantly so if I call an agent twice it will hapilly replace the first future with the second, right?
21:23Chouseryou can put a watcher on that so that when the value changes it sends off an agent
21:23arohneryou could use an atom or a ref to cancel in-progress rendering jobs
21:23Chouserthat agent runs, occasionally checking its starting value with the current value of the atom
21:24Chouserif they don't match, return out of the agent, allowing the next watcher-sent agent in the queue to start over
21:25redalastorMakes sense. I was hoping there was a way to kill off a thread from outside itself.
21:25Chouseryeah, java doesn't like that
21:26redalastorAccording to Google, Java used to like it but it's deemed unsafe these days.
21:26redalastorhttp://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.html
21:27dreishSounds like STM and immutable data structures would fix these problems.
21:29redalastorThat's what I was thinking.
21:29Chouserfix the problems with halting a thread?
21:29redalastorWith having damaged objects when you do.
21:30Chouserah
21:30dreishI wouldn't trust it without a test running for tens or hundreds of hours, though.
21:30Chouserwell, you could still have issues with exiting without going the finally blocks and such
21:34ChouserI do it every time I press Ctrl-C
21:34dreishgasp!
21:34dreishWouldn't it be simpler to never make mistakes?
21:34Chouserhehe
21:35dreishI hold a code review meeting before hitting return, every time.
21:51hiredmanmust an issue clearing day
23:11hiredman~ticker IDSOX
23:11clojurebotIDSOX; +0.54
23:11hiredman:D
23:21markgunnelsNot sure of the protocol but I have two Clojure questions I was hoping to get answered. I imagine they are rather simple but just non-obvious to a noob like myself.
23:23markgunnelsIf variables in Clojure are by default non mutable, why does this work:
23:23markgunnels(def favorite-books (list "Anathem" "Matter" "I know this much is true"))
23:24markgunnels(def new-favorite-books (cons "The Road" favorite-books))
23:24markgunnelsOops.
23:24markgunnelsI mean (def favorite-books (cons "The Road" favorite-books))
23:24markgunnelsIt seems that I shouldn't be able to reuse the favorite-books variable.
23:24arohnermarkgunnels: vars can be re-defed to make development easier
23:25arohneryou shouldn't do that in production
23:25hiredmanit's usefull for swapping code in a running system
23:25markgunnelsOk. I know Erlang calls me on it.
23:25markgunnelsSo it surprised me when I got away with it.
23:26markgunnelsThanks.
23:26arohnernp
23:27hiredmanjust do anything crazy like re-def'ing in a loop
23:27markgunnelsOk.
23:29Chouserdon't
23:31hiredmangood catch
23:31cp2heh
23:31markgunnels:-) I translated.
23:31hiredman~hiredman
23:31clojurebothiredmans euler.clj is so embarassing
23:39arohneris there a way to find all existing refs?
23:40arohnerwhen unit testing, I was thinking of a macro that would grab all refs, grab their value, execute body and then ref-set all of them back to their original value
23:40hiredmanerm
23:41hiredmanfor why?
23:41Chouserarohner: I highly doubt it
23:41arohnerso I don't have to worry about tests causing side-effects and interfering with each other
23:42Chouserarohner: you could find all vars in a namespace
23:42arohnerfrom there, I could find all vars in all namespaces that are refs
23:42arohnerhmm...
23:43Chouserbut not any local refs
23:43Chouseror any refs only accessible via closures
23:43arohneryeah
23:48slashus2,(^ 5 2)
23:48clojurebotjava.lang.NullPointerException
23:48hiredman,(pow 5 2)
23:48clojurebotjava.lang.Exception: Unable to resolve symbol: pow in this context
23:48hiredman,(.pow 5 2)
23:48clojurebotjava.lang.IllegalArgumentException: No matching method found: pow for class java.lang.Integer
23:49slashus2It is because ^ is a reader macro
23:49slashus2reader syntax
23:49slashus2,(Math/pow 5 2)
23:49clojurebot25.0