[comp.lang.smalltalk] ST V/286 bl... globals

MUHRTH@DB0TUI11.BITNET (Thomas Muhr) (12/01/89)

How can I recover from a system state which I have produced by
mistakenly creating a Smalltalk at:xxxx variable which formerly pointed
to a Class!. Not that I am in much need of this class, but I can no longer
remove it via the ClassBrowser. 'RemoveSubclass' seems to do something,
but does not  remove its entry from the class-listpane.
Any idea is very much appreciated.
Thanks very much -
Thomas

cooper@netcom.UUCP (Ken Cooper) (12/02/89)

In article <453@DB0TUI11.BITNET> MUHRTH@DB0TUI11.BITNET (Thomas Muhr) writes:
>How can I recover from a system state which I have produced by
>mistakenly creating a Smalltalk at:xxxx variable which formerly pointed
>to a Class!.

One way of accomplishing this is to get ahold of the class, reinstall it in
Smalltalk, then remove it with a ClassHierarchyBrowser.  The only trick is
getting ahold of the class.

One way to do so is to get it out of a global array called TableOfClasses, 
which is an *ugly* data structure containing both classes and integer values
(the integers are pointers to the next free slot in the array).  Here's a
bit of code that will do what you want:

	TableOfClasses do: [ :class |
		((class isKindOf: Behavior) and: [ class name = 'Junk' ])
		        ifTrue: [
	        	    Smalltalk at: #Junk put: class.
			].
	]

This works on both Smalltalk/V 286 and Smalltalk/V Mac.

Hope this helps,

Ken

=============================================================================
Ken Cooper                                         USENET: cooper@netcom.uucp
Acumen Software                                Compu$erve: 71571,407
=============================================================================

chouc@mist.cs.orst.edu (Chou Chung-Di) (12/02/89)

 
In <Article 1225 of comp.lang.smalltalk> Thomas Muhrth (MUHRTH@DB0TUI11.BITNET)
wrote:
 
>How can I recover from a system state which I have produced by
>mistakenly creating a Smalltalk at:xxxx variable which formerly pointed
>to a Class!. Not that I am in much need of this class, but I can no longer
>remove it via the ClassBrowser. 'RemoveSubclass' seems to do something,
>but does not  remove its entry from the class-listpane.
>....
 
The simplest way to get rid of anything which is globally defined is to use 
the following method: (maybe you have already tried out this)
 
 
        Smalltalk removeFromSystem: #TheVariableToBeDeleted
 
This should remove either a class or a global variable from the System 
Dictionary.  I think you could also do it by expressing the following 
statement and go to the appropriate entry to do the deletion:
 
        Smalltalk inspect.
 
If this is not what you want...
Something I encountered before was similar to the described situation.  But 
Smalltakl/V 286 only gave me a menu label something like: 'non-existent class'.
I didn't have time to figure out where to get rid of it. (must be in 
ClassHierarchyBrowser some where....?)  Could someone share the info if they 
ever solved this problem? 
 
----------------------------------
Chung-Di Chou
Department of Industrial 
   and Manufacturing Engineering
Oregon State University
Corvallis, OR 97331
----------------------------------
 

baumeist@exunido.uucp (Hubert Baumeister) (12/05/89)

In article <4807@netcom.UUCP> cooper@netcom.UUCP (Ken Cooper) writes:
>In article <453@DB0TUI11.BITNET> MUHRTH@DB0TUI11.BITNET (Thomas Muhr) writes:
>>How can I recover from a system state which I have produced by
>>mistakenly creating a Smalltalk at:xxxx variable which formerly pointed
>>to a Class!.
>
>One way of accomplishing this is to get ahold of the class, reinstall it in
>Smalltalk, then remove it with a ClassHierarchyBrowser.  The only trick is
>getting ahold of the class.
 ... rest of article deleted ...

A class knows of its subclasses. 
Therefore open an inspector on the superclass of your lost class
and inspect the subclasses field, then inspect the entry that holds your 
class. In this inspector evaluate:
 Smalltalk at: xxxx put: self
and your class should appear in the ClassHierarchyBrowser.

Hubert Baumeister
(baumeist@exunido.uucp)