2014-11-04 13:16 GMT+01:00 Marcus Denker <marcus.denker@inria.fr>:

On 04 Nov 2014, at 09:59, Norbert Hartl <norbert@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.


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 "phil@highoctane.be" <phil@highoctane.be>:


Le 3 nov. 2014 22:13, "Hilaire" <hilaire@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, phil@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
> iStoa - http://istoa.drgeo.eu
>
>
>