Chris Muller uploaded a new version of Environments to project The Inbox: http://source.squeak.org/inbox/Environments-cmm.75.mcz
==================== Summary ====================
Name: Environments-cmm.75 Author: cmm Time: 17 February 2019, 8:54:02.934673 pm UUID: 13aceb53-d0e1-4823-a86c-a2abacb6c2d9 Ancestors: Environments-pre.73
Keep and access Classes and Traits by their #name's logical value instead of the physical identity of the String object.
=============== Diff against Environments-pre.73 ===============
Item was removed: - (PackageInfo named: 'Environments') preamble: '"Fix ''Instances'' entry for Smalltalk Environment." - | dict | - dict := (Environment classPool at: ''Instances''). - dict keys - do: [ : eachName | (eachName isSymbol not ) ifTrue: [ dict at: eachName asSymbol put: (dict removeKey: eachName) ] ]. - - "Let Environment names be, consistently, Symbols." - Environment allInstances do: - [ : each | - each info - instVarNamed: ''name'' - put: (each name asSymbol) ]'!
Item was changed: ----- Method: Environment>>allClassesAndTraitsDo: (in category 'classes and traits') ----- allClassesAndTraitsDo: aBlock declarations keysAndValuesDo: [:key :value | + ((value isBehavior) and: [key = value name]) ifTrue: - ((value isBehavior) and: [key == value name]) ifTrue: [aBlock value: value]]!
Item was changed: ----- Method: Environment>>classOrTraitNamed: (in category 'classes and traits') ----- classOrTraitNamed: aString "aString is either a class or trait name or a class or trait name followed by ' class' or 'classTrait' respectively. Answer the class or metaclass it names."
| meta baseName | (aString endsWith: ' class') ifTrue: [meta := true. baseName := aString copyFrom: 1 to: aString size - 6] ifFalse: [ (aString endsWith: ' classTrait') ifTrue: [ meta := true. baseName := aString copyFrom: 1 to: aString size - 11] ifFalse: [ meta := false. baseName := aString]].
+ ^declarations at: baseName ifPresent: - ^declarations at: baseName asSymbol ifPresent: [ :global | global isBehavior ifTrue: [ meta ifFalse: [ global ] ifTrue: [ global classSide ]]]!
Item was changed: ----- Method: Environment>>hasClassNamed: (in category 'classes and traits') ----- + hasClassNamed: aString + ^ declarations + at: aString + ifPresent: [ : global | global isKindOf: Class ] + ifAbsent: [ false ]! - hasClassNamed: aString - Symbol hasInterned: aString ifTrue: - [:symbol | - ^ (declarations at: symbol ifAbsent: [nil]) - isKindOf: Class]. - ^ false.!
Item was changed: ----- Method: Environment>>initialize (in category 'initialize-release') ----- initialize + declarations := Dictionary new. + bindings := Dictionary new. - declarations := IdentityDictionary new. - bindings := IdentityDictionary new. undeclared := WeakIdentityDictionary new. policies := Array new. observers := IdentitySet new.!
Item was changed: ----- Method: Environment>>removeClassNamed: (in category 'classes and traits') ----- removeClassNamed: aString declarations + at: aString - at: aString asSymbol ifPresent: [:class | class removeFromSystem] ifAbsent: [Transcript cr; show: 'Removal of class named ', aString, ' ignored because ', aString, ' does not exist.']!
Item was added: + (PackageInfo named: 'Environments') postscript: '"Fix ''Instances'' entry for Smalltalk Environment." + | dict | + dict := (Environment classPool at: ''Instances''). + Environment classPool at: ''Instances'' put: (dict := dict as: Dictionary). + + "Fix ''delcarations'' and ''bindings'' of existing Environments." + Environment allInstances do: + [ : each | + #(''declarations'' ''bindings'') do: [ : eachIdDictVar | (each instVarNamed: eachIdDictVar put: ((each instVarNamed: eachIdDictVar) as: Dictionary)) ] ]'!