Except in 1.3 it will be a little bit harder to do "throw-away" per-thread
memoizes for vars you do no "own" if their author didn't make their holding
var :dynamic ('cause then you will not be able to rebind them).

This is close to being a problem for paredit.clj (not tested yet), but
hopefully I'll discover that I'm using memoize this way with paredit's own
functions only ...

2011/3/29 Sean Corfield <seancorfi...@gmail.com>

> On Tue, Mar 29, 2011 at 8:31 AM, Benny Tsai <benny.t...@gmail.com> wrote:
> > Just out of curiosity, does "memoize" in 1.3 behave like the current 1.2
> > version or the 1.1 version?
>
> user=> (clojure-version)
> "1.3.0-alpha4"
> user=> (defn f [n]
>   (println "f called with" n)
>  (if (zero? n)
>    0
>    (min (f (dec n))
>         (f (dec n)))))
>
> (def f (memoize f))#'user/f
> user=> user=> (f 2)
> #'user/f
> f called with 2
> f called with 1
> f called with 0
> 0
> user=> (f 2)
> 0
> user=> (f 3)
> f called with 3
> 0
> user=>
>
> (so it works the way you expect)
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
> Railo Technologies, Inc. -- http://www.getrailo.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to