Memoization Question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Memoization Question

philippeback
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
Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

HilaireFernandes
What's wrong with?

myData
 ^ data ifNil: [data := self computeMe]



Le 03/11/2014 16:10, [hidden email] 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
iStoa - http://istoa.drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

philippeback


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

NorbertHartl
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.

Norbert

Am 04.11.2014 um 07:03 schrieb "[hidden email]" <[hidden email]>:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

Damien Pollet-2
In reply to this post by philippeback
mutate a literal array ?  :D

On 3 November 2014 16:10, [hidden email] <[hidden email]> 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 as often as
> they are called.
>
> TIA
> Phil

Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

philippeback
In reply to this post by NorbertHartl
On Tue, Nov 4, 2014 at 9:59 AM, Norbert Hartl <[hidden email]> 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

Gofer it 
        squeaksource: 'MethodWrappers'; 
        package: 'MethodWrappers4'; 
        load. 

It loads.

But no test seems to be fine.


 Inline image 1

What version should I be using?

Phil
 
Norbert

Am 04.11.2014 um 07:03 schrieb "[hidden email]" <[hidden email]>:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

NorbertHartl
I'm not sure. I thought Spy would use them but it does not load in a fresh pharo3 for me. Did you try


?

Norbert

Am 04.11.2014 um 11:53 schrieb [hidden email]:

On Tue, Nov 4, 2014 at 9:59 AM, Norbert Hartl <[hidden email]> 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

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 "[hidden email]" <[hidden email]>:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

philippeback
On Tue, Nov 4, 2014 at 12:06 PM, Norbert Hartl <[hidden email]> 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


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.

Phil

?

Norbert

Am 04.11.2014 um 11:53 schrieb [hidden email]:

On Tue, Nov 4, 2014 at 9:59 AM, Norbert Hartl <[hidden email]> 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

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 "[hidden email]" <[hidden email]>:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>




Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

Marcus Denker-4
In reply to this post by NorbertHartl

On 04 Nov 2014, at 09:59, Norbert Hartl <[hidden email]> 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.


This would be a nice useless for Reflectivity…  one way of describing it is “like method wrappers, but generalized”. e.g. you can put a “wrapper” on any kind of AST node.
After the breakpoints, we could use that as the next client.



Marcus

Norbert

Am 04.11.2014 um 07:03 schrieb "[hidden email]" <[hidden email]>:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

NorbertHartl

Am 04.11.2014 um 13:16 schrieb Marcus Denker <[hidden email]>:


On 04 Nov 2014, at 09:59, Norbert Hartl <[hidden email]> 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.


This would be a nice useless for Reflectivity…  one way of describing it is “like method wrappers, but generalized”. e.g. you can put a “wrapper” on any kind of AST node.
After the breakpoints, we could use that as the next client.


Sure, I forgot. If I would have the need to implement it I would try solving it with meta-links. Basically it does the same as the method wrapper without having the need to exchange the compiled method.

Norbert


Marcus

Norbert

Am 04.11.2014 um 07:03 schrieb "[hidden email]" <[hidden email]>:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

Luc Fabresse
In reply to this post by Marcus Denker-4

2014-11-04 13:16 GMT+01:00 Marcus Denker <[hidden email]>:

On 04 Nov 2014, at 09:59, Norbert Hartl <[hidden email]> 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.


This would be a nice useless for Reflectivity…  one way of describing it is “like method wrappers, but generalized”. e.g. you can put a “wrapper” on any kind of AST node.
After the breakpoints, we could use that as the next client.

yes

Nick's Reflectogram would also be usable for that but it would require a special VM currently. 
Indeed, it would be better to have at the compiler level.

Then, Ghost is also usable for that since Mariano did a MethodWrapper like implementation using Ghost in 5 lines or so.
And Ghost should load in Pharo 3 ;-)

Luc
 



Marcus

Norbert

Am 04.11.2014 um 07:03 schrieb "[hidden email]" <[hidden email]>:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

NorbertHartl
In reply to this post by philippeback

Am 04.11.2014 um 12:47 schrieb [hidden email]:

On Tue, Nov 4, 2014 at 12:06 PM, Norbert Hartl <[hidden email]> 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


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 [hidden email]:

On Tue, Nov 4, 2014 at 9:59 AM, Norbert Hartl <[hidden email]> 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

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 "[hidden email]" <[hidden email]>:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>





Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

Denis Kudriashov
In reply to this post by philippeback

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 пользователь "[hidden email]" <[hidden email]> написал:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

jfabry

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 Reflectivity is working use that.

On Nov 4, 2014, at 1:50 PM, Denis Kudriashov <[hidden email]> wrote:

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 пользователь "[hidden email]" <[hidden email]> написал:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>




---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile

Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

Denis Kudriashov

2014-11-04 16:09 GMT+03:00 Johan Fabry <[hidden email]>:
The language you are thinking of is most probably PHANtom: http://pleiad.cl/phantom

Exactly
Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

philippeback
In reply to this post by jfabry

On Tue, Nov 4, 2014 at 2:09 PM, Johan Fabry <[hidden email]> wrote:

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 Reflectivity is working use that.

On Nov 4, 2014, at 1:50 PM, Denis Kudriashov <[hidden email]> wrote:

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 пользователь "[hidden email]" <[hidden email]> написал:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>




---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile


Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

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: ConfigurationOfGhost load 
Tests are green for me.

No I did not push the config in the right place to have it in the ConfigurationBrowser.

You can find infos+examples on how to achieve Method wrapper in Mariano's PhD (p116) using Proxies for Methods.


and also look at the test case method named #testSimpleForwardingForMethodUsingBecome

Cheers,

Luc

2014-11-04 15:48 GMT+01:00 [hidden email] <[hidden email]>:

On Tue, Nov 4, 2014 at 2:09 PM, Johan Fabry <[hidden email]> wrote:

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 Reflectivity is working use that.

On Nov 4, 2014, at 1:50 PM, Denis Kudriashov <[hidden email]> wrote:

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 пользователь "[hidden email]" <[hidden email]> написал:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>




---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile



Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

philippeback
On Tue, Nov 4, 2014 at 4:56 PM, Luc Fabresse <[hidden email]> 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 Pharo 2.0 ;-)).
Ghost is really small so I've just fixed it

Thanks a lot!
 

Try it: ConfigurationOfGhost load 
Tests are green for me.

I loaded the configuration:

Gofer it
smalltalkhubUser: 'CAR' project: 'Ghost';
package: 'ConfigurationOfGhost';
load.
(#ConfigurationOfGhost asClass project version: #stable) load.

Tests are all green.


No I did not push the config in the right place to have it in the ConfigurationBrowser.

I've put it in the Metarepo for 3.0
 

You can find infos+examples on how to achieve Method wrapper in Mariano's PhD (p116) using Proxies for Methods.


I didn't had that one, thanks! 

and also look at the test case method named #testSimpleForwardingForMethodUsingBecome

Yes, seen that.
 

Cheers,

Much appreciated! Ghost is quite nice and useful. Could do with some more class comments as there is none. I'll try to put in some as I use it.

Phil 

Luc

2014-11-04 15:48 GMT+01:00 [hidden email] <[hidden email]>:

On Tue, Nov 4, 2014 at 2:09 PM, Johan Fabry <[hidden email]> wrote:

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 Reflectivity is working use that.

On Nov 4, 2014, at 1:50 PM, Denis Kudriashov <[hidden email]> wrote:

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 пользователь "[hidden email]" <[hidden email]> написал:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>




---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile




Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

philippeback
In reply to this post by Luc Fabresse
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 <[hidden email]> 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 Pharo 2.0 ;-)).
Ghost is really small so I've just fixed it

Try it: ConfigurationOfGhost load 
Tests are green for me.

No I did not push the config in the right place to have it in the ConfigurationBrowser.

You can find infos+examples on how to achieve Method wrapper in Mariano's PhD (p116) using Proxies for Methods.


and also look at the test case method named #testSimpleForwardingForMethodUsingBecome

Cheers,

Luc

2014-11-04 15:48 GMT+01:00 [hidden email] <[hidden email]>:

On Tue, Nov 4, 2014 at 2:09 PM, Johan Fabry <[hidden email]> wrote:

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 Reflectivity is working use that.

On Nov 4, 2014, at 1:50 PM, Denis Kudriashov <[hidden email]> wrote:

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 пользователь "[hidden email]" <[hidden email]> написал:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>




---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile




Reply | Threaded
Open this post in threaded view
|

Re: Memoization Question

Luc Fabresse

just added you as a contributor.
And yes comments are more than welcome ;-)

#Luc

2014-11-04 18:03 GMT+01:00 [hidden email] <[hidden email]>:
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 <[hidden email]> 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 Pharo 2.0 ;-)).
Ghost is really small so I've just fixed it

Try it: ConfigurationOfGhost load 
Tests are green for me.

No I did not push the config in the right place to have it in the ConfigurationBrowser.

You can find infos+examples on how to achieve Method wrapper in Mariano's PhD (p116) using Proxies for Methods.


and also look at the test case method named #testSimpleForwardingForMethodUsingBecome

Cheers,

Luc

2014-11-04 15:48 GMT+01:00 [hidden email] <[hidden email]>:

On Tue, Nov 4, 2014 at 2:09 PM, Johan Fabry <[hidden email]> wrote:

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 Reflectivity is working use that.

On Nov 4, 2014, at 1:50 PM, Denis Kudriashov <[hidden email]> wrote:

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 пользователь "[hidden email]" <[hidden email]> написал:


Le 3 nov. 2014 22:13, "Hilaire" <[hidden email]> 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, [hidden email] 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
> iStoa - http://istoa.drgeo.eu
>
>
>




---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile