[Seaside] Importing halo's from Monticello

Bert Freudenberg bert at impara.de
Sat Jun 4 01:37:05 CEST 2005


Am 04.06.2005 um 01:21 schrieb John Pierce:

> One thing I notice about the InstanceEncoder is that it doesn't cache
> the objects after decoding them.  This could be done in a literal
> inside the method - something like this:
>
> myObject
> |cache|
> cache := #(nil).
> ^ cache first ifNil: [cache at: 1 put: '..............'  
> reconsituteObject]
>
> Okay, so I think I've forgotten how temps work. Why doesn't cache  
> just get garbage collected after each call to #myObject?

You're confusing names (variables) with references (objects). "cache"  
is indeed only a temp, but it is bound to the literal array #(nil)  
when entering #myObject. That literal is stored in the method itself,  
so it won't get garbage collected unless you delete the method. And  
the contents of the array is modified lazily.

Just for the record: it's a not-so-clean hack to modify literals. If  
you would decompile the method after executing it, you'ld not see # 
(nil) but #(an Object). But hey, it works! ;-)

- Bert -



More information about the Seaside mailing list