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

Levente Uzonyi leves at elte.hu
Fri Jul 23 20:33:32 UTC 2010


On Fri, 23 Jul 2010, Nicolas Cellier wrote:

> 2010/7/23 Levente Uzonyi <leves at elte.hu>:
>> 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
>>
>
> Hmm I did same trick long time ago...
> How do they have it working in VW with immutable literals ?

IIRC they send #beMutable to the array. So the first line is like:
array := #(nil) beMutable.


Levente

>
> Nicolas
>
>>>
>>>
>>> So Long,
>>>        -Tobias
>>>
>>
>>
>
>


More information about the Squeak-dev mailing list