[squeak-dev] The Trunk: Environments-cmm.53.mcz
Levente Uzonyi
leves at elte.hu
Mon Jan 19 03:13:41 UTC 2015
On Sun, 18 Jan 2015, commits at source.squeak.org wrote:
> Chris Muller uploaded a new version of Environments to project The Trunk:
> http://source.squeak.org/trunk/Environments-cmm.53.mcz
>
> ==================== Summary ====================
>
> Name: Environments-cmm.53
> Author: cmm
> Time: 16 January 2015, 2:54:24.767 pm
> UUID: 69b32fc7-98f1-4c19-9976-a38106a9ee63
> Ancestors: Environments-cmm.52
>
> - Only change key when it is NOT in the 'bindings' Dictionary, otherwise it would be in a state inconsistent with its new hash.
>
> =============== Diff against Environments-cmm.51 ===============
>
> Item was changed:
> ----- Method: Environment>>renameClass:from:to: (in category 'classes and traits') -----
> renameClass: aClass from: oldName to: newName
> "Rename the class, aClass, to have the title newName."
>
> | binding category |
> category := self organization categoryOfElement: oldName.
> self organization classify: newName under: category suppressIfDefault: true.
> self organization removeElement: oldName.
>
> + binding := self associationAt: oldName.
> - binding := self declarationOf: oldName.
The Dictionary API shouldn't be used from new code, especially not from
the Environments code itself.
What was wrong with #declarationOf:? As I see the only difference is that
it'll return nil instead of raising an error (#associationAt:). But that's
not a problem, because the next line will raise an error anyway.
> declarations removeKey: oldName.
> + bindings removeKey: oldName.
> + " self binding: binding removedFrom: self."
> - self binding: binding removedFrom: self.
>
> + binding key: newName.
> + declarations add: binding.
> + bindings add: binding.
> + " self binding: binding addedTo: self."
> - binding := newName => aClass.
> - declarations add: binding.
> - self binding: binding addedTo: self.
I suspect that the removal of the #binding:removedFrom: and the
#binding:addedTo: sends will break Environments, because another
environment which imports this environment will not be notified about
changes which happen here.
This problem is shadowed in case of Smalltalk - which imports itself - by
the direct manipulation of the bindings dictionary.
Levente
>
> Smalltalk renamedClass: aClass from: oldName to: newName.
> SystemChangeNotifier uniqueInstance
> classRenamed: aClass
> from: oldName
> to: newName
> inCategory: category!
>
>
>
More information about the Squeak-dev
mailing list
|