'From Squeak3.3alpha of 30 January 2002 [latest update: #4730] on 1 February 2002 at 2:09:21 am'! "Change Set: nameForRef-sw Date: 1 February 2002 Author: Scott Wallace Fixes a bug recently introduced into Object.uniqueNameForReference; thanks to Bob Arning for zeroing in on this"! !Object methodsFor: 'viewer' stamp: 'sw 2/1/2002 02:03'! uniqueNameForReference "Answer a nice name by which the receiver can be referred to by other objects. At present this uses a global References dictionary to hold the database of references, but in due course this will need to acquire some locality" | aName nameSym stem knownClassVars | (aName _ self uniqueNameForReferenceOrNil) ifNotNil: [^ aName]. (stem _ self knownName) ifNil: [stem _ self defaultNameStemForInstances asString]. stem _ stem select: [:ch | ch isLetter or: [ch isDigit]]. stem size == 0 ifTrue: [stem _ 'A']. stem first isLetter ifFalse: [stem _ 'A', stem]. stem _ stem capitalized. knownClassVars _ ScriptingSystem allKnownClassVariableNames. aName _ Utilities keyLike: stem satisfying: [:jinaLake | nameSym _ jinaLake asSymbol. ((References definedNames includesKey: nameSym) not and: [(Module root moduleDefining: nameSym) isNil]) and: [(knownClassVars includes: nameSym) not]]. References defineName: (aName _ aName asSymbol) as: self export: true. ^ aName! ! !Object methodsFor: 'viewer' stamp: 'sw 1/30/2002 10:56'! uniqueNameForReferenceOrNil "If the receiver has a unique name for reference, return it here, else return nil" | nameDict | nameDict _ References definedNames. (nameDict includesIdentity: self) ifTrue: [^ nameDict keyAtValue: self]. ^ Smalltalk keyAtValue: self ifAbsent: [nil]! !