> Am 04.11.2014 um 12:47 schrieb p...@highoctane.be:
> 
> On Tue, Nov 4, 2014 at 12:06 PM, Norbert Hartl <norb...@hartl.name 
> <mailto:norb...@hartl.name>> wrote:
> I'm not sure. I thought Spy would use them but it does not load in a fresh 
> pharo3 for me. Did you try
> 
> http://www.squeaksource.com/ObjectsAsMethodsWrap/ 
> <http://www.squeaksource.com/ObjectsAsMethodsWrap/>
> 
> This one loads and tests are green once the "_"s are replaced with ":="s 
> 
> Thx for the pointer. I'll see how I can hook a TTLCache into this.
> 
I don't know your exact use case. But if you need one cache for your package 
with TTLCache then this could be done in one pass. You can have an installer 
that scans your package for methods containing a special pragma. Then you 
exchange every compiled method (installing the wrapper) with the wrapper that 
accesses its value from the same TTLCache having the compiled method as key. So 
you would have exchanged a lot of methods that share a single cache. As the 
TTLCache gives the hit rate on printString you get back an effectivity number 
for free.

Norbert

> Phil
> 
> ?
> 
> Norbert
> 
>> Am 04.11.2014 um 11:53 schrieb p...@highoctane.be 
>> <mailto:p...@highoctane.be>:
>> 
>> On Tue, Nov 4, 2014 at 9:59 AM, Norbert Hartl <norb...@hartl.name 
>> <mailto:norb...@hartl.name>> wrote:
>> Ghost won't be a big help here. Slots would be a good solution but not if it 
>> needs to be removable on runtime. So it seems MethodWrappers is your best 
>> bet. I'd try create a caching MethodWrapper, mark all the needed methods 
>> with a pragma and then install the MethodWrapper on these. Could be a 
>> package wide install/uninstall if you need that.
>> 
>> I loaded MethodWrappers in 3.0 as I saw in 
>> http://forum.world.st/MethodWrappers-td3829576.html#a4601624 
>> <http://forum.world.st/MethodWrappers-td3829576.html#a4601624>
>> 
>> Gofer it 
>>         squeaksource: 'MethodWrappers'; 
>>         package: 'MethodWrappers4'; 
>>         load. 
>> 
>> It loads.
>> 
>> But no test seems to be fine.
>> 
>> 
>>  <image.png>
>> 
>> What version should I be using?
>> 
>> Phil
>>  
>> Norbert
>> 
>> Am 04.11.2014 um 07:03 schrieb "p...@highoctane.be 
>> <mailto:p...@highoctane.be>" <p...@highoctane.be 
>> <mailto:p...@highoctane.be>>:
>> 
>>> 
>>> Le 3 nov. 2014 22:13, "Hilaire" <hila...@drgeo.eu 
>>> <mailto:hila...@drgeo.eu>> a écrit :
>>> >
>>> > What's wrong with?
>>> >
>>> > myData
>>> >  ^ data ifNil: [data := self computeMe]
>>> 
>>> That I do have a lot of places like this and do not want these data 
>>> littering the code.
>>> 
>>> Aspects would solve this but we do not have that.
>>> 
>>> Also I need the mechanism to be removable.
>>> 
>>> So, I read something about MethodWrapper, ghost, slots... Can't one use any 
>>> of these things to do this memoization cleanly?
>>> 
>>> Phil
>>> 
>>> >
>>> >
>>> >
>>> > Le 03/11/2014 16:10, p...@highoctane.be <mailto:p...@highoctane.be> a 
>>> > écrit :
>>> > > How can I do memoization in Pharo?
>>> > >
>>> > > I mean, a generic mechanism that will help me wrap the caching around
>>> > > the method invocations / messages.
>>> > >
>>> > > I have expensive calls that do not have to refresh their results as
>>> > > often as they are called.
>>> > >
>>> > > TIA
>>> > > Phil
>>> >
>>> >
>>> > --
>>> > Dr. Geo - http://drgeo.eu <http://drgeo.eu/>
>>> > iStoa - http://istoa.drgeo.eu <http://istoa.drgeo.eu/>
>>> >
>>> >
>>> >
>> 
> 
> 

Reply via email to