From: James Edward Gray II Date: 2006-01-26T23:46:18+09:00 Subject: Re: Rethinking Memoization On Jan 26, 2006, at 7:08 AM, Robert Klemme wrote: > class SillySomething > extend Memoizable > > def initialize() > @a,@b,@c = A.new, B.new, C.new > # or other initialization > end > > def calculate_foo(quirk, quark, quork) > x = @a.foo(quirk) + @b.doit(quark) > if x > 10 > x += @c.doh(quork, @a) > else > x - 2 > end > x > end > > memoize :calculate_foo > end This example runs as written with the module discussed in this thread. It requires multiple changes to work with the current memoize.rb library. > If (i) I don't see the point in having several objects that do > exactly the > same calculation - methods might even be class methods (i.e. singleton > methods of the *single* class instance X). So there is actually no > need > for a cache that covers several instances. > > If (ii) you gain nothing by having a centralized cache because > you'll have > to keep memoized values from different instances separate; in fact > you add > a level of lookup (first object, then method and args - or do it in > one > request with a larger key) and separate instance state from the > instance. > IMHO that's inefficient, memory leaking and error prone. I understand know. You're just against this feature. Fair enough. Thanks for taking the time to explain it to me. James Edward Gray II