[Seaside] Importing halo's from Monticello

Avi Bryant avi.bryant at gmail.com
Sat Jun 4 01:34:31 CEST 2005

On 6/4/05, John Pierce <john.raymond.pierce at gmail.com> wrote:

> > 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?

It's not about how temps work, it's about how literals work.  When an
expression like #(nil) is compiled, a new Array object is created and
stored in the CompiledMethod object.  Every time you invoke the
method, that same instance gets used.  This is different from {nil},
which creates a new Array every time, or [nil], which creates a new
BlockContext every time.

So effectively the cache is inside the CompiledMethod object itself;
if you change the source and recompile, the cache will get wiped out
(which is exactly what you want).

My original version of that method was even nastier, in that it relied
on the fact that the compiler collapses literals that are #= (and
thus, "#(nil) == #(nil)" will evaluate to true).  It was this:

^ #(nil) first ifNil: [#(nil) at: 1 put: .....]


More information about the Seaside mailing list