pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.21k stars 355 forks source link

Should remove accesses to `ActiveHand` global #5908

Closed guillep closed 4 years ago

guillep commented 4 years ago

The global assumes there is a single hand, while there may be many of them. And to this to work properly, there is code like this that updates the global in a loop:

self extraWorldList do: [:world |
    ActiveHand := world activeHand.
    world doOneCycle.
].

(self currentWorld isNotNil and: [(self extraWorldList includes: self currentWorld) not]) ifTrue: [
    self currentWorld doOneCycle.
    ActiveHand := self currentWorld activeHand
]

Notice also that the code below may have a bug too, because it may happen that the cycle in the second block executes with a wrong hand. In my image we have 50 users of the class variable. We should study case by case.

Ducasse commented 4 years ago

Yes this code is delicate. To me the architecture is wrong. This is what alain faced when working on Morphic and all the events are strange (bubling) this is why after som years he decided to work on Bloc.