Re: apply for macros?

2009-10-04 Thread Meikel Brandmeyer
Hi, Am 04.10.2009 um 00:50 schrieb b2m: What macros do y'all have that you want to apply things to? A sure code smell, IMO. It most likely is based on a misunderstanding what macros are capable to do. I am using structs and functions for workings with these structs. Just some very

Re: RFC: laziness-safe, semi-dynamic environment Var(Lite)

2009-10-04 Thread Timothy Pratley
I'm more interested in the compiler being able to detect obvious (to it, not me) errors. Example 1: user= (await1 (binding [*warn-on-reflection* true ] (send (agent 0) # (if *warn-on-reflection* (inc %) (dec %) #ag...@238a47: -1 user= (await1 (send (agent 0) #(binding

Re: apply for macros?

2009-10-04 Thread b2m
Hi, On 4 Okt., 08:31, Meikel Brandmeyer m...@kotka.de wrote: The functions themselves can be easily made independent from the   number of keys. Just save the keys in a constant. (defn process-department    [department-struct]    (- +payment-levels+      (map #(* (fee %) (department-struct

Re: Memory Characteristics of Persistent Datastructures

2009-10-04 Thread Christophe Grand
Hi, Are you sure you aren't leaking memory? (by keeping a reference to an ever growing state -- do you use memoize?) Christophe On Sat, Oct 3, 2009 at 10:22 PM, Elliott Slaughter elliottslaugh...@gmail.com wrote: Thanks. JVisualVM shows the initial memory usage is a couple hundred MB,

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-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 m...@kotka.de wrote: Hi, I second Sean's view: dispatching a multimethod on

Re: apply for macros?

2009-10-04 Thread John Harrop
On Sat, Oct 3, 2009 at 6:50 PM, b2m b2monl...@googlemail.com wrote: What macros do y'all have that you want to apply things to? (defn init-funs [name levels] (do (apply-macro create-department-struct name levels) (apply-macro create-process-department name levels) nil)) A

VimClojure: redefine *test-out* just like *out*

2009-10-04 Thread Mike Mazur
Hi, I noticed that output from clojure.test's (run-tests) is not displayed in the VimClojure REPL (launched with LocalLeadersr). I guessed it's because clojure.test/*test-out* is not redefined appropriately (to print to the vim buffer) like *out* is. So I tried the following at the VimClojure

Re: apply for macros?

2009-10-04 Thread b2m
Hi, On 4 Okt., 04:40, John Harrop jharrop...@gmail.com wrote: If you need to be creating these things dynamically, with information only available at runtime, defstruct is probably the wrong tool for the job, or the only struct member should be :name, and the levels at least should just be

Re: VimClojure: redefine *test-out* just like *out*

2009-10-04 Thread Meikel Brandmeyer
Hi, Am 04.10.2009 um 11:11 schrieb Mike Mazur: Clojure= (binding [*test-out* *out*] (run-tests)) Is the mechanism that configures the *out* stream exposed somehow? Can I tell it to process *test-out* as well? Well. This is exactly the mechanism to process the *test-out*. In the

Re: refs implement IFn, atoms and agents do not?

2009-10-04 Thread Stephen C. Gilardi
On Oct 3, 2009, at 1:50 PM, Stuart Halloway wrote: Is there a principled reason for this? I have written some code that (unintentionally) limits itself to refs because it assumes that all reference types can sit in function position. This discussion:

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

On

2009-10-04 Thread samppi
I want to do this: (defn a ...) (cache a) ; or (cache #'a) or (cache 'a); it doesn't matter to me ...instead of this: (def a (memoize (fn ...))) That way, it separates the concern of what a does from the optimization I'm doing on it. Now, I'm kind of stuck; how should I do it? (defn

On redefining the global binding of a variable in a function

2009-10-04 Thread talk
Oops; I didn't finish this thread's subject title. On Oct 4, 1:41 pm, samppi rbysam...@gmail.com wrote: I want to do this:   (defn a ...)   (cache a) ; or (cache #'a) or (cache 'a); it doesn't matter to me ...instead of this:   (def a (memoize (fn ...))) That way, it separates the

Re: refs implement IFn, atoms and agents do not?

2009-10-04 Thread Stephen C. Gilardi
On Oct 4, 2009, at 5:04 PM, Mark Volkmann wrote: Minor technicality ... Vars are a reference type, but deref and @ don't work with them. I'm guessing you're thinking of an interaction like this: user= (def a 3) #'user/a user= @a java.lang.ClassCastException:

Re: refs implement IFn, atoms and agents do not?

2009-10-04 Thread Mark Volkmann
On Sun, Oct 4, 2009 at 4:26 PM, Stephen C. Gilardi squee...@mac.com wrote: On Oct 4, 2009, at 5:04 PM, Mark Volkmann wrote: Minor technicality ... Vars are a reference type, but deref and @ don't work with them. I'm guessing you're thinking of an interaction like this:        user= (def

Re: On redefining the global binding of a variable in a function

2009-10-04 Thread Meikel Brandmeyer
Hi, Am 04.10.2009 um 22:47 schrieb talk: (defn cache Replaces the function that the given variable refers to with a memoizing version of it. [fn-var] (??? fn-var (memoize @fn-var))) Macros to the rescue: (defmacro cache Replaces the function that the given name refers to

Re: On redefining the global binding of a variable in a function

2009-10-04 Thread talk
What a lifesaver! Thanks a lot! On Oct 4, 2:58 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 04.10.2009 um 22:47 schrieb talk:   (defn cache     Replaces the function that the given variable refers to     with a memoizing version of it.     [fn-var]     (??? fn-var (memoize

Agent send-off: ~20k/s

2009-10-04 Thread MarkSwanson
I recently integrated Clojure with two async messaging systems. I wound up doing send operations through a Clojure agent. I was curious how many agents I could spawn per second and found I could spawn about 20K agents / second. Code for testing: (def t (agent true)) (defn tt [_ num] (try

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 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

Re: Memory Characteristics of Persistent Datastructures

2009-10-04 Thread Elliott Slaughter
On Oct 4, 4:01 am, Christophe Grand christo...@cgrand.net wrote: Are you sure you aren't leaking memory? (by keeping a reference to an ever growing state -- do you use memoize?) You're right, it was a memory leak, although it took me hours to find. Clojure's lazy lists were responsible for the