Chris Muller uploaded a new version of Environments to project The Inbox:
http://source.squeak.org/inbox/Environments-cmm.74.mcz ==================== Summary ==================== Name: Environments-cmm.74 Author: cmm Time: 15 February 2019, 6:04:29.038747 pm UUID: 6caf9737-93e0-4117-9ee0-336dd2991002 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 includesKey: 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). + 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). + #(''declarations'' ''bindings'') do: [ : eachIdDictVar | (each instVarNamed: eachIdDictVar put: ((each instVarNamed: eachIdDictVar) as: Dictionary)) ] ]'! |
On Sat, 16 Feb 2019, [hidden email] wrote:
> Chris Muller uploaded a new version of Environments to project The Inbox: > http://source.squeak.org/inbox/Environments-cmm.74.mcz > > ==================== Summary ==================== > > Name: Environments-cmm.74 > Author: cmm > Time: 15 February 2019, 6:04:29.038747 pm > UUID: 6caf9737-93e0-4117-9ee0-336dd2991002 > 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 includesKey: aString! > - Symbol hasInterned: aString ifTrue: > - [:symbol | > - ^ (declarations at: symbol ifAbsent: [nil]) > - isKindOf: Class]. > - ^ false.! The above change will make Smalltalk hasClassNamed: #Smalltalk return true because the #isKindOf: test was removed. But that is not correct. > > 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). > + 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). > + #(''declarations'' ''bindings'') do: [ : eachIdDictVar | (each instVarNamed: eachIdDictVar put: ((each instVarNamed: eachIdDictVar) as: Dictionary)) ] ]'! Large part of this postscript seems to be the same as what was removed from the preamble. Why was it moved to the postscript? Does it need to be evaluated again? Levente |
Hi Levente,
> > Item was changed: > > ----- Method: Environment>>hasClassNamed: (in category 'classes and traits') ----- > > hasClassNamed: aString > > + ^ declarations includesKey: aString! > > - Symbol hasInterned: aString ifTrue: > > - [:symbol | > > - ^ (declarations at: symbol ifAbsent: [nil]) > > - isKindOf: Class]. > > - ^ false.! > > The above change will make > > Smalltalk hasClassNamed: #Smalltalk > > return true because the #isKindOf: test was removed. But that is not > correct. Woops, not sure how I missed that. Fixed in Environments-cmm.75. > > ... > > 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). > > + 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). > > + #(''declarations'' ''bindings'') do: [ : eachIdDictVar | (each instVarNamed: eachIdDictVar put: ((each instVarNamed: eachIdDictVar) as: Dictionary)) ] ]'! > > Large part of this postscript seems to be the same as what was removed > from the preamble. > Why was it moved to the postscript? Does it need to be evaluated again? This change needs a postscript. I borrowed the code from the preamble and added in the conversion. There was some harmless idempotent code in there from the prior preamble that I should've just cleaned out since it wasn't needed anymore. I did that in the new Environments-cmm.75. Thanks, Chris |
Free forum by Nabble | Edit this page |