2011/4/1 Ken Wesson <kwess...@gmail.com>

> On Thu, Mar 31, 2011 at 3:24 PM, Laurent PETIT <laurent.pe...@gmail.com>
> wrote:
> > 2011/3/31 Ken Wesson <kwess...@gmail.com>
> >>
> >> On Wed, Mar 30, 2011 at 12:02 PM, Laurent PETIT <
> laurent.pe...@gmail.com>
> >> wrote:
> >> > 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 ...
> >>
> >> You'll still be able to use
> >>
> >> (ns foo.core
> >>  (use (somens.baz :exclude quux)))
> >>
> >> (def quux (memoize somens.baz/quux))
> >>
> >> (code that
> >>  (uses quux
> >>    (goes here)))
> >
> > Indeed but that's not what I meant to express. I was talking about a more
> > "volatile" memoization, one which does not stay around until the
> > foo.core/quux root's value is explicitly replaced (and hopefully garbage
> > collected).
>
> Well, there's always
>
> (ns foo,.core
>  (use ...))
>
> (some code
>  (let [quux (memoize quux)]
>    (more code)))
>
> when you want the memoized version locally, and don't mind creating it
> anew (with no memory) each time a particular code path is called.
>

Well, of course, but then it's lexically scoped, and you'll have to pass it
around to every function which may need it (or who calls a function which
may need it).
Not so with a carefully rebound var.

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