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

Marcel Taeumel marcel.taeumel at hpi.de
Wed Dec 9 10:30:43 UTC 2020


> Might be less efficient (I haven't measured it) but provides better readability. :-)

Mine is actually faster than yours. ;o) 

> Imagine a morph that changes its fill style regularly while stepping, and that should be displayed with a different border style while a dialog window is open.

You want to optimize for the functional style around "DialogWindow >> getUserResponse"? I wouldn't do that. Most of Morphic is state-based. Maybe we find a better way for showing dialogs as well. It is tricky to support [CMD]+[Dot] along with nested UI loops.

Best,
Marcel
Am 08.12.2020 14:19:34 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
Hi Marcel,

> Preferences does not expose the dictionary. It is rather an implementation detail.

Yes, but #setPreference:toValue:during: *could* reuse #at:put:during: instead of reinventing this - though small - wheel. :-)

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

Isn't this a completely domain-specific design decision? I think we should look at this at a different level of abstraction.

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

But the semantics of an execution-around method do not need to be timeless as mentioned earlier. Imagine a morph that changes its fill style regularly while stepping, and that should be displayed with a different border style while a dialog window is open. In this example, forbidding the manipulation of extensions during aBlock would rule out the use of #at:put:during: ...
[http://www.hpi.de/]

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

Might be less efficient (I haven't measured it) but provides better readability. :-)

Best,
Christoph
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel
Gesendet: Dienstag, 8. Dezember 2020 13:34:33
An: squeak-dev
Betreff: Re: [squeak-dev] The Inbox: Collections-ct.922.mcz
 
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/20201209/fae379d6/attachment.html>


More information about the Squeak-dev mailing list