[squeak-dev] The Trunk: Tools-mt.1074.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Sat Nov 27 20:46:35 UTC 2021


Hi Marcel,


crazy hack, but it bites with the fact that storing underscore variables in a Workspace is a legal operation. I only need to print "_fileDirectory" in a workspace and the menu will break. Could we please just use a separate dictionary for the properties? :-)


Furthermore, how many different properties can actually be stored in a Workspace? So far I only counted 3 different keys - does this really justify the use of the Variable State pattern?


Best,

Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Donnerstag, 25. November 2021 11:44:04
An: squeak-dev at lists.squeakfoundation.org; packages at lists.squeakfoundation.org
Betreff: [squeak-dev] The Trunk: Tools-mt.1074.mcz

Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-mt.1074.mcz

==================== Summary ====================

Name: Tools-mt.1074
Author: mt
Time: 25 November 2021, 11:44:01.944354 am
UUID: 39954290-b416-f242-a5b0-c7aea0e3c6a6
Ancestors: Tools-mt.1073

Adds a property protocol to Workspace to avoid having to go through #containingWindow to store extra stuff, which does not even work for MVC, just for morphs (i.e., SystemWindow, not StandardSystemView). Reuses a workspace's "bindings" with each property being prefixed with a "_" to not interfere with regular bindings.

Note that such extra properties have already been added to #containingWindow in the past.

=============== Diff against Tools-mt.1073 ===============

Item was added:
+ ----- Method: Workspace>>hasProperty: (in category 'binding - properties') -----
+ hasProperty: aSymbol
+
+        | propertyValue |
+        propertyValue := self valueOfProperty: aSymbol.
+        propertyValue ifNil: [^ false].
+        propertyValue == false ifTrue: [^ false].
+        ^ true!

Item was changed:
  ----- Method: Workspace>>initialize (in category 'initialize-release') -----
  initialize

         super initialize.
+        bindings := Dictionary new.
-        self initializeBindings.
         acceptDroppedMorphs := false.
         mustDeclareVariables := self class declareVariablesAutomatically not.
         environment := Environment current!

Item was removed:
- ----- Method: Workspace>>initializeBindings (in category 'binding') -----
- initializeBindings
-
-        bindings := Dictionary new!

Item was added:
+ ----- Method: Workspace>>removeProperty: (in category 'binding - properties') -----
+ removeProperty: aSymbol
+
+        bindings removeKey: ('_', aSymbol) asSymbol ifAbsent: [].!

Item was added:
+ ----- Method: Workspace>>resetBindings (in category 'binding') -----
+ resetBindings
+        "Remove all bindings that are not prefixed with an $_. See #setProperty:toValue:."
+
+        bindings keysAndValuesRemove: [:key :value | key first ~= $_]!

Item was added:
+ ----- Method: Workspace>>setProperty:toValue: (in category 'binding - properties') -----
+ setProperty: aSymbol toValue: anObject
+
+        anObject ifNil: [^ self removeProperty: aSymbol].
+        bindings at: ('_', aSymbol) asSymbol put: anObject.!

Item was added:
+ ----- Method: Workspace>>valueOfProperty: (in category 'binding - properties') -----
+ valueOfProperty: aSymbol
+
+        ^ self valueOfProperty: aSymbol ifAbsent: nil!

Item was added:
+ ----- Method: Workspace>>valueOfProperty:ifAbsent: (in category 'binding - properties') -----
+ valueOfProperty: aSymbol ifAbsent: aBlock
+
+        ^ bindings at: ('_', aSymbol) asSymbol ifAbsent: aBlock!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211127/430d5362/attachment.html>


More information about the Squeak-dev mailing list