If I execute the following code:
Smalltalk at: #TestGlobalForRemoval put: 5. Smalltalk removeGlobalNamed: #TestGlobalForRemoval I get a walkback - is this the correct way to remove a global (its a public method, and #remove: has been overwritten).? Tim |
Tim,
> I get a walkback - is this the correct way to remove a global (its a public > method, and #remove: has been overwritten).? What walkback do you get?. Your code works without error for me unless I try to remove the global twice, which does cause a not found walkback. FWIW, I would usually use .... Smalltalk at: #TestGlobalForRemoval put: 5. Smalltalk removeKey: #TestGlobalForRemoval ifAbsent: [] I have to admit a complete ignorance about the existence of #removeGlobalNamed: though :-) Ian |
> What walkback do you get?. Your code works without error for me unless I
> try to remove the global twice, which does cause a not found walkback. Hmmm your right - in a clean image its ok. My semi clean image gives a 'VariableBinding does not understand #asSymbol' and it opens an inspector on the symbol. It looks like something is registered for #onGlobalRemoved and what it gets is an association rather than just a key. I wonder what I have done to cause this? Tim 20:13:32, 04 November 2005: 'VariableBinding does not understand #asSymbol' VariableBinding(Object)>>doesNotUnderstand: SystemDictionary>>at:ifAbsent: SystemDictionary(Dictionary)>>at: StsManager>>onSystemGlobalRemoved: EventMessageSend>>forwardTo:withArguments: EventMessageSend(MessageSendAbstract)>>valueWithArguments: [] in MessageSequenceAbstract>>valueWithArguments: EventMessageSequence>>messagesDo: EventMessageSequence(MessageSequenceAbstract)>>valueWithArguments: EventsCollection>>triggerEvent:with: RefactoringSmalltalkSystem(Object)>>trigger:with: RefactoringSmalltalkSystem(SmalltalkSystem)>>onGlobalRemoved: EventMessageSend>>forwardTo:withArguments: EventMessageSend(MessageSendAbstract)>>valueWithArguments: [] in MessageSequenceAbstract>>valueWithArguments: EventMessageSequence>>messagesDo: EventMessageSequence(MessageSequenceAbstract)>>valueWithArguments: EventsCollection>>triggerEvent:with: SystemDictionary(Object)>>trigger:with: SystemDictionary>>removeKey:ifAbsent: SystemDictionary(Dictionary)>>removeKey: SystemDictionary>>removeGlobalNamed: UndefinedObject>>{unbound}doIt CompiledExpression>>value: SmalltalkWorkspace>>evaluateRange:ifFail:debug: SmalltalkWorkspace>>evaluateItIfFail:debug: SmalltalkWorkspace>>evaluateItIfFail: SmalltalkWorkspace>>evaluateIt Symbol>>forwardTo: CommandDescription>>performAgainst: [] in Command>>value BlockClosure>>ifCurtailed: BlockClosure>>ensure: Command>>value ShellView>>performCommand: IdeaSpaceShell(Shell)>>performCommand: CommandQuery>>perform DelegatingCommandPolicy(CommandPolicy)>>route: [] in ShellView(View)>>onCommand: BlockClosure>>ifCurtailed: BlockClosure>>ensure: Cursor>>showWhile: ShellView(View)>>onCommand: ShellView(View)>>wmCommand:wParam:lParam: ShellView(View)>>dispatchMessage:wParam:lParam: [] in InputState>>wndProc:message:wParam:lParam:cookie: BlockClosure>>ifCurtailed: ProcessorScheduler>>callback:evaluate: InputState>>wndProc:message:wParam:lParam:cookie: ShellView>>translateAccelerator: |
Tim,
> It looks like something is registered for #onGlobalRemoved and what it gets > is an association rather than just a key. The walkback occurs when you have STS running in the image. It happens because the argument Dolphin sends with the #onGlobalRemoved: event is an Association containing the key and value that are being removed. The StsManager registers for this message but expects the argument to be the key, not the key and value, of the global being removed. Another problem is that the event is sent _after_ the global has been removed so the method, as it stands, won't work anyway. Changing it to the following seems to work. StsManager>>onSystemGlobalRemoved: globalName | global | ((global := globalName value) isKindOf: Class) ifTrue: [classEditions isNil ifFalse: [classEditions removeKey: global name ifAbsent: []]] Ian NB <disclaimer> I know the above method can be written in a more compact way, I was just changing the minimum amount needed to get it to work. |
Ahh so it wasn't me then... Do we need to log this one?
Agreed on minimal changes. tim "Ian Bartholomew" <[hidden email]> wrote in message news:[hidden email]... > Tim, > >> It looks like something is registered for #onGlobalRemoved and what it >> gets is an association rather than just a key. > > The walkback occurs when you have STS running in the image. It happens > because the argument Dolphin sends with the #onGlobalRemoved: event is an > Association containing the key and value that are being removed. The > StsManager registers for this message but expects the argument to be the > key, not the key and value, of the global being removed. > > Another problem is that the event is sent _after_ the global has been > removed so the method, as it stands, won't work anyway. Changing it to > the following seems to work. > > StsManager>>onSystemGlobalRemoved: globalName > | global | > ((global := globalName value) isKindOf: Class) > ifTrue: [classEditions isNil ifFalse: [classEditions removeKey: global > name ifAbsent: []]] > > Ian > > NB <disclaimer> I know the above method can be written in a more compact > way, I was just changing the minimum amount needed to get it to work. |
> Ahh so it wasn't me then... Do we need to log this one?
I'll log it anyway as it gives OA some tracability. |
Tim,
> I'll log it anyway as it gives OA some tracability. Thank you Ian |
Free forum by Nabble | Edit this page |