[Seaside] Importing halo's from Monticello

stephane ducasse stephane.ducasse at free.fr
Sat Jun 4 10:02:39 CEST 2005

Hi avi

This hack is really a hack and a bad one. :)
I would just implement a lazy accessor instead than relying on the  
way compiled method
manage literal frame.
So I'm quite sure that this is not I would advertise.


>>> 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: .....]
> Cheers,
> Avi
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/listinfo/seaside

More information about the Seaside mailing list