Re: Multimethod or Multiple Arg Lists

2009-10-05 Thread Robert Stehwien
> > > (dosync (dorun (for [key ks] (alter file-seq-cache dissoc key >> > > You might want to write (dorun (for ...)) as (doseq ...). Since you don't > use the resulting sequence using for to generate sequence and then using to > dorun to force it and immediately throw it away is very ugly.

Re: Multimethod or Multiple Arg Lists

2009-10-04 Thread Meikel Brandmeyer
Hi, Am 05.10.2009 um 05:03 schrieb Robert Stehwien: (dosync (dorun (for [key ks] (alter file-seq-cache dissoc key You might want to write (dorun (for ...)) as (doseq ...). Since you don't use the resulting sequence using for to generate sequence and then using to dorun to force i

Re: Multimethod or Multiple Arg Lists

2009-10-04 Thread Robert Stehwien
Thanks Sean and Meikel. I tightened up the function a bit as a single function with multiple arglist: -- (defn clear-cached-files3 ([] (dosync (alter file-seq-cache empty))) ([& ks] (dosync (dorun (for [key ks] (alter file-seq-cache dissoc key @file-seq-cache)) --

Re: Multimethod or Multiple Arg Lists

2009-10-04 Thread Meikel Brandmeyer
Hi. Am 04.10.2009 um 14:29 schrieb Sean Devlin: Very good point Meikel. The only reason I wrote the code that way is I was asking myself "What if I had Rich's Job? How would I write reduce?" I should have been more explicit. (defn reduce ([f coll] (reduce f (first coll) (rest coll))) ([f

Re: Multimethod or Multiple Arg Lists

2009-10-04 Thread Sean Devlin
Very good point Meikel. The only reason I wrote the code that way is I was asking myself "What if I had Rich's Job? How would I write reduce?" I should have been more explicit. On Oct 4, 7:42 am, Meikel Brandmeyer wrote: > Hi, > > I second Sean's view: dispatching a multimethod on argument co

Re: Multimethod or Multiple Arg Lists

2009-10-04 Thread Meikel Brandmeyer
Hi, I second Sean's view: dispatching a multimethod on argument count is possible, but maybe not the clearest use of multimethods. I would also prefer the multiple arglist approach. Am 03.10.2009 um 21:39 schrieb Sean Devlin: (defn reduce ([f coll] (reduce f (first coll) (rest coll))) (

Re: Multimethod or Multiple Arg Lists

2009-10-03 Thread Sean Devlin
I would definitely prefer clear-cached-files2. I usually use multimethods when I need to change behavior on type of arguments, not the argument count. Let's take a look at reduce. I would write the shorter form in terms of the longer one. (defn reduce ([f coll] (reduce f (first coll) (rest c

Multimethod or Multiple Arg Lists

2009-10-03 Thread Robert Stehwien
I'm toying around with a file utility library as part of a vow to do all my "scripting" in clojure so I can learn the language - this is actually my first attempt at writing anything "real" with clojure. I considered using memoize to cache file listing but wanted to be able to selectively clear th