[squeak-dev] preamble

Eliot Miranda eliot.miranda at gmail.com
Thu Oct 17 19:02:21 UTC 2019


Hi Jakob,

On Thu, Oct 17, 2019 at 11:41 AM Jakob Reschke <forums.jakob at resfarm.de>
wrote:

> Is it really wise to remove the previous scripts?
>
> Suppose I have versions 1, 2, and 3 and object state needs to be migrated
> differently between each of them. If one image still has 1 loaded and is
> updated directly to 3, it will miss the object state updates from 1 to 2,
> or it not even be able to perform an adequate update from 2 to 3.
>
> Shouldn't the scripts rather be idempotent? If they must run again, but
> the code is the same, you could add a comment explaining the reason...
>

I agree; idempotency is a strong approach. And if one wants to keep old
versions around for documentation purposes it's easy to turn each one into
a block; the block will be compiled but not implemented.  And of course any
textual change triggers evaluation of the script.  So one can add a comment
saying "Adding this comment to ensure script is run next time...".

Of course you can draw a line by declaring particular earlier versions as
> "unsupported".
>

But one can't.  What one can do is add guards before the "business" part of
the expression so that it is only evaluated in the correct context.  This
is part of writing idempotent scripts. One thing that would hep is more
informative comments in the empty script, and ensuring that an empty script
is always displayed with a helpful comment.  Right now IIRC once3 you edit
a script the helpful default comment is lost.



>
>
> Am Mo., 14. Okt. 2019 um 22:01 Uhr schrieb karl ramberg <
> karlramberg at gmail.com>:
>
>> So the comment on top of the preamble and post script could be something
>> like code below. Could we make this comment show even in a previous made
>> preamble/ post script so it is there as a reminder ?
>>
>> 'From Squeak5.3alpha of 14 October 2019 [latest update: #19114] on 14
>> October 2019 at 9:53:39 pm'!
>>
>> !PackageInfo methodsFor: 'preamble/postscript' stamp: 'kfr 10/14/2019
>> 21:52'!
>> postscriptDefault
>> ^  '"Below, add code to be run after the loading of this package.
>> Postscript is only evaluated when it is different than previous version.
>> That is why it is always best practice to remove its previous contents when
>> editing it."'
>> ! !
>>
>> !PackageInfo methodsFor: 'preamble/postscript' stamp: 'kfr 10/14/2019
>> 21:49'!
>> preambleDefault
>> ^ '"Below, add code to be run before the loading of this package.
>> Preamble is only evaluated when it is
>> different than previous version. That is why it is always best practice
>> to remove its previous contents when editing it."'
>> ! !
>>
>>
>> On Mon, Oct 14, 2019 at 9:31 PM Levente Uzonyi <leves at caesar.elte.hu>
>> wrote:
>>
>>> These scripts, preamble and postscript are only evaluated when they are
>>> different than their previous versions. That is why I always suggest
>>> removing their contents when changing them.
>>>
>>> Levente
>>>
>>> On Mon, 14 Oct 2019, Marcel Taeumel wrote:
>>>
>>> > Well, it seems to be that a "preamble" in a package is not evaluated
>>> when updating the image. Is this a bug?
>>> > ChangeSet preambles also don't seem to be prepared to store a script.
>>> Just a documentation string. Why is that? :-)
>>> >
>>> > Best,
>>> > Marcel
>>> >
>>> >
>>>
>>>
>>
>

-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191017/d5aec4a8/attachment.html>


More information about the Squeak-dev mailing list