[squeak-dev] The Inbox: Collections-ct.922.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Tue Dec 8 12:34:33 UTC 2020


Hmm... Preferences does not expose the dictionary. It is rather an implementation detail. See:

Preferences class >> #setPreference:toValue:

Preferences class >> #setPreference:toValue:during:

Hmm... there are implementations of #at:put: where a "nil" value deletes the key. See:

Morph >> #setProperty:toValue:

Hmm... I am not sure about the returned value. Shouldn't it be the object? Should it the block's last result? Depends on the purpose, I suppose.

Hmm... I would rather not support modifying the dictionary during "aBlock". Similar to #do: etc. in a collection.

What about this implementation? Seems to so "low level":

| hasKey oldValue |
self at: key ifPresent: [:v | oldValue := v. hasKey := true].
self at: key put: anObject.
^ aBlock ensure: [
hasKey == true
ifTrue: [self at: key put: oldValue]
ifFalse: [self removeKey: key]]

Best,
Marcel
Am 07.12.2020 19:14:30 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
I wanted to provide it as a general functionality - you could use this in many situations, for example for adding a process variable temporarily, changing a morphic extension temporarily, or maybe even to adjust a preference temporarily ... Where temporary, just for example, might mean for the duration of a test execution (which, of course, might be debugged, so is not necessarily run as an atomic operation). In all these situations, the entire system needs to be kept running without introducing any unintended sandbox effects. :-)
[http://www.hpi.de/]

Best,
Christoph
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von tim Rowledge <tim at rowledge.org>
Gesendet: Montag, 7. Dezember 2020 19:10:11
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] The Inbox: Collections-ct.922.mcz
 


> On 2020-12-07, at 10:05 AM, Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:
>
> IIUYC this would make it impossible to keep other changes to the dictionary after leaving the execution around method?
Absolutely. Depends on what your deeper purpose is.


tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim [http://www.rowledge.org/tim]
Strange OpCodes: LAG: Load and Garble



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201208/2ba56470/attachment.html>


More information about the Squeak-dev mailing list