Re: [Pharo-users] Memoization Question

2014-11-12 Thread Sven Van Caekenberghe
Hi Phil, > On 12 Nov 2014, at 12:54, p...@highoctane.be wrote: > > 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. > fibCac

Re: [Pharo-users] Memoization Question

2014-11-12 Thread p...@highoctane.be
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 |

Re: [Pharo-users] Memoization Question

2014-11-11 Thread Werner Kassens
hi Torsten, thank you for making that possible and thanks to John Cromartie and Sven van Caekenberghe werner

Re: [Pharo-users] Memoization Question

2014-11-11 Thread p...@highoctane.be
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

[Pharo-users] Memoization Question

2014-11-11 Thread Torsten Bergmann
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

Re: [Pharo-users] Memoization Question

2014-11-11 Thread Werner Kassens
Hi, now this a nice idea, especially the memoizedUsing:cache idea. i would really appreciate it, if that would be MIT licenced. werner

Re: [Pharo-users] Memoization Question

2014-11-11 Thread Sven Van Caekenberghe
This is cool indeed. I find an unlimited cache a bit coarse, would not really work in practice. What about memoizedUsing: cache ^ [ :x | cache at: x ifAbsentPut: [ self value: x ] ] then you could pass in a tuned LRUCache instance, among others. Sven > On 11 Nov 2014, at 16:24, Torsten Berg

Re: [Pharo-users] Memoization Question

2014-11-11 Thread Torsten Bergmann
Phil wrote: >thanks for the pointer. >Now, how do I use that? First: create a method BlockClosure>>#memoized in your Pharo image (see https://gist.github.com/jcromartie/2705526) memoized "returns memoized version of an unary function" | cache | cache := Dictionary new. ^ [ :x | cache at: x ifAb

[Pharo-users] Memoization Question

2014-11-10 Thread Torsten Bergmann
Phil wrote: >How can I do memoization in Pharo?   See here   https://gist.github.com/jcromartie/2705526

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Luc Fabresse
just added you as a contributor. And yes comments are more than welcome ;-) #Luc 2014-11-04 18:03 GMT+01:00 p...@highoctane.be : > Luc, > > Can you add me to the repo so that I can send updates? > > Phil > > On Tue, Nov 4, 2014 at 4:56 PM, Luc Fabresse > wrote: > >> Hi Phil, >> >> Ok I missed t

Re: [Pharo-users] Memoization Question

2014-11-04 Thread p...@highoctane.be
Luc, Can you add me to the repo so that I can send updates? Phil On Tue, Nov 4, 2014 at 4:56 PM, Luc Fabresse wrote: > Hi Phil, > > Ok I missed the details so I've just refreshed my mind. > > yes the latest repository is this one: > http://www.smalltalkhub.com/#!/~CAR/Ghost/ > I've just tried

Re: [Pharo-users] Memoization Question

2014-11-04 Thread p...@highoctane.be
On Tue, Nov 4, 2014 at 4:56 PM, Luc Fabresse wrote: > Hi Phil, > > Ok I missed the details so I've just refreshed my mind. > > yes the latest repository is this one: > http://www.smalltalkhub.com/#!/~CAR/Ghost/ > I've just tried in Pharo 3.0 and it works now (yes oups I forgot that it > was for P

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Luc Fabresse
Hi Phil, Ok I missed the details so I've just refreshed my mind. yes the latest repository is this one: http://www.smalltalkhub.com/#!/~CAR/Ghost/ I've just tried in Pharo 3.0 and it works now (yes oups I forgot that it was for Pharo 2.0 ;-)). Ghost is really small so I've just fixed it Try it:

Re: [Pharo-users] Memoization Question

2014-11-04 Thread p...@highoctane.be
I have been reading on Ghost: http://esug.org/data/ESUG2011/IWST/PRESENTATIONS/23.Mariano_Peck-Ghost-ESUG2011.pdf http://www.slideshare.net/esug/ghost-9095241 http://rmod.lille.inria.fr/archives/workshops/Mart11a-IWST11-Ghost.pdf This link is dead BTW: http://rmod.inria.fr/web/pier/software/Marea

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Denis Kudriashov
2014-11-04 16:09 GMT+03:00 Johan Fabry : > The language you are thinking of is most probably PHANtom: > http://pleiad.cl/phantom > Exactly

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Johan Fabry
The language you are thinking of is most probably PHANtom: http://pleiad.cl/phantom But (as author of the language) I think it is overkill to use it for just a memoization cache. Idem for AspectS (I don’t know if it works on Pharo though). Right now, I would use MethodWrappers instead, and when

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Denis Kudriashov
Hi There is AspectS package at old squeaksource site. I not know is it working in Pharo. And there was presentation at Esug few years ago about another implementation of aspects in Pharo ( i not remember project name) 04 нояб. 2014 г. 9:04 пользователь "p...@highoctane.be" написал: > > Le 3 nov.

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Norbert Hartl
> Am 04.11.2014 um 12:47 schrieb p...@highoctane.be: > > On Tue, Nov 4, 2014 at 12:06 PM, Norbert Hartl > 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/ObjectsAsMethods

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Luc Fabresse
2014-11-04 13:16 GMT+01:00 Marcus Denker : > > On 04 Nov 2014, at 09:59, Norbert Hartl 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,

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Norbert Hartl
> Am 04.11.2014 um 13:16 schrieb Marcus Denker : > > >> On 04 Nov 2014, at 09:59, Norbert Hartl > > 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

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Marcus Denker
> On 04 Nov 2014, at 09:59, Norbert Hartl 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 pra

Re: [Pharo-users] Memoization Question

2014-11-04 Thread p...@highoctane.be
On Tue, Nov 4, 2014 at 12:06 PM, Norbert Hartl 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/ > This one loads and tests are green once the "_"s are replaced with ":="s Thx fo

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Norbert Hartl
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/ ? Norbert > Am 04.11.2014 um 11:53 schrieb p...@highoctane.be: > > On Tue, Nov 4, 2014 a

Re: [Pharo-users] Memoization Question

2014-11-04 Thread p...@highoctane.be
On Tue, Nov 4, 2014 at 9:59 AM, Norbert Hartl 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 pragm

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Damien Pollet
mutate a literal array ? :D On 3 November 2014 16:10, p...@highoctane.be wrote: > 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

Re: [Pharo-users] Memoization Question

2014-11-04 Thread Norbert Hartl
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 pa

Re: [Pharo-users] Memoization Question

2014-11-03 Thread p...@highoctane.be
Le 3 nov. 2014 22:13, "Hilaire" 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 removab

Re: [Pharo-users] Memoization Question

2014-11-03 Thread Hilaire
What's wrong with? myData ^ data ifNil: [data := self computeMe] Le 03/11/2014 16:10, 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 th

[Pharo-users] Memoization Question

2014-11-03 Thread p...@highoctane.be
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