--- Adam Turoff <[EMAIL PROTECTED]> wrote: > On Mon, Dec 09, 2002 at 08:36:20PM -0000, Smylers wrote: > > Perhaps there are only some edge cases which require calculation; > > or the function is liable to be called with many invalid input > > values, which can quickly be determined yield C<undef> and so > > which don't need caching; or there is a pattern as to which sets > > of input parameters are > > likely to be passed multiple times so the function only bother > > caching those. > > It doesn't matter whether some of the values are cheap lookups > while other values are "complex calculations". Once a cached sub > is called with a set of parameter values, the return value will > always be a cheap lookup in the memoized sub's cache.
You may get some disagreement from those for whom memory is neither virtual nor free. > > Anybody else like this, or are we better off leaving things as they > > were? > > I think you're trying to overoptimize something here. I can't see > a benefit to caching only sometimes. If there is, then you probably > want to implement a more sophisticated cache management strategy > for your sub, not warp the language for a special case. Ahh. This is better. How does one implement a more sophisticated cache management strategy? That is, what is the mechanism for manipulating the run-time system behavior of subs? sub days_in_month is cached(&other_cache_function) ? Or what? And, by the way, what happens when I change it in midstream? Obviously the new cache begins empty, but does my old cache behave like a closure, hanging about until the sub dies? =Austin