[squeak-dev] Re: The Trunk: Kernel-eem.474.mcz

Levente Uzonyi leves at elte.hu
Fri Jul 23 15:16:57 UTC 2010


On Fri, 23 Jul 2010, Tobias Pape wrote:

>
> Am 2010-07-23 um 07:39 schrieb Andreas Raab:
>>
>> However, I do take Travis' point about compile time expressions. Here the whole point is that you really want the expression to be reevaluated when the defining code changes which is not easily done the above (it's possible but bothersome).
>
> I think its good to point out that it is possible to
> differentiate between one-time-expressions
> and compile-time expressions. I think an expression
> executed once, however, not at compile time can make
> a pretty good lazy initializer in the sense you mentioned.
>  Alas, I must admit that I?m not aware of an example that
> cannot be equally good expressed with the ?ifNil: variant
> as with the [] once  variant.

Seaside 2.8 uses a literal array with a single element for this to cache 
files. It works something like this:

fooFile

 	| array |
 	array := #(nil).
 	^(array at: 1) ifNil: [
 		array at: 1 put: 'alongbase64string' decodeBase64 ]

These selectors are auto-generated. I think #once is (would be) a better 
solution. It could be hardly done with class (instance) variables.


Levente

>
>
> So Long,
> 	-Tobias
>



More information about the Squeak-dev mailing list