On Jul 22, 2010, at 7:39 43PM, Eliot Miranda wrote:

> 
> 
> 2010/7/22 Sudhakar Krishnamachari <[email protected]>
> And of course the extensibility it gives:
> 
> [ 1->'asd'. 2->'asd'. 3->'dsd' ] asDictionary
> 
> I think Travis Griggs' once is much much nicer:
> 
>     [{ 1->'asd'. 2->'asd'. 3->'dsd' } asDictionary] once
> 
> when once is sent to a BlockClosure it becomes itself into a 
> CachedBlockClosure that remembers and answers the evaluated value.
> You could add selectors to this such as
>     onceEachSession - destroy the cached value on image startup
> 
> It doesn't require any special compiler machinery (unlike ##(...)) and so 
> there are no problems with browsing references or senders within compile-time 
> evaluated forms.  It is easily extensible to different life-times.  It is 
> portable.
> 
> my 2¢
> 
> Eliot

I like once as well, after using it in VisualWorks.
For my tastes, it's uses just the right amount of magickery to both be able to 
easily understand how it works, and provide useful functionality. 

F.ex. I wrote a tool where I tagged (time-expensive) methods I suspected of 
being invariants during a large analysis, the tool then ran those methods 
wrapped in a once block, and told me which did not affect the end results. 
Much faster than a manual verification of whether they were really invariants, 
and provided an ok speedup for the amount of (brain) effort required :D

Only problem I've encountered in VW (7.7 at least), is the debugger raising an 
mnu  if you try to step into the once call of a CachedBlockClosure.

Cheers,
Henry


_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to