Looking at LRUCache tests, I've found this: testFibonacci "After an idea by Jan Vrany. Recursively enter the cache and its access protection" | fibCache | fibCache := self newCache. fibCache maximumWeight: 32; beThreadSafe; factory: [ :key | key < 2 ifTrue: [ key ] ifFalse: [ (fibCache at: key - 1) + (fibCache at: key - 2) ] ]. self assert: (fibCache at: 40) equals: 102334155 the factory thing basically solves the problem. Is there more docs about the caching somewhere? I read the code, comments, and unit tests but still, will value an explanation. Keying by object works, but with symbols, it isn't behaving. I think I miss something here. Is the cache size set at a given limit? I see keyIndex is Dictionary new. What if I do have a lot of keys? Is the dictionary being copied over and over to get to the right size? Phil Phil Phil On Tue, Nov 11, 2014 at 7:52 PM, phil@highoctane.be <phil@highoctane.be> wrote:
I should ask more questions :-).
Now, this still doesn't answer the question on how to use this to memoize object methods.
I think that what is closest to what I am looking for is this:
http://wiki.tcl.tk/10779 http://wiki.tcl.tk/10981
I am use we can do something like that in Pharo, with some memoize method in Object playing around with thisContext.
SomeClass>>someMethodWith: aSomething and: aSomethingElse
Like self haltIf: aSymbol will break if aSymbol is in the call stack.
Any guru having a way to do that?
Phil
On Tue, Nov 11, 2014 at 7:21 PM, Torsten Bergmann <astares@gmx.de> wrote:
Werner Kassens wrote:
Hi, now this a nice idea, especially the memoizedUsing:cache idea. i would really appreciate it, if that would be MIT licenced. werner
It already is, thanks to the permission of author John Cromartie who answered us today. Both methods are in a slice already:
Details in https://pharo.fogbugz.com/f/cases/14458
Thx T.