[new to smalltalk] what does this error want to tell me?

Dan Ingalls Dan at SqueakLand.org
Wed Dec 8 14:45:57 UTC 2004


>Hello folks,
>
>during refactoring I lost a clss GelaendeLinie. I filed it back in and
>a previously working method crashes.
>
>The curious thing is that the underlined line in the debugger yields
>anObsoleteGelaendelinie which I never defined.
>
>Tried recompiling, but it didn't help.
>
>What do I need to understand here??

Hello Herbert -

When a class gets removed, it actually gets transmuted to a stub named AnObsoleteNameIUsedToBe, so that if there are existing instances, they will still be proper objects with a proper class.

[System Maintainers: This used to be, and should be, simply ObsoleteNameIUsedToBe.  If anyone is bored, this should be fixed.  Right now instances print as "an AnObsoleteNameIUsedToBe" which is a little tacky]

Recompiling will fix the code references to the class, but will not fix the obsolete instances.

If you don't care about those instances, then just figure out a way to get rid of them (ie delete the structure that is holding onto them).

If you care about them, then what you need to do is...

AnObsoleteGelaendeLinie allInstances elementsExchangeIdentityWith:
	(AnObsoleteGelaendeLinie allInstances collect: [:x | x as: GelaendeLinie])

...but the name AnObsoleteGelaendeLinie is not registered as a global.  So you need to get in a context (such as a debugger) where you have a reference to one of the actual obsolete instances, and refer to its class.  Let us assume you do this, and the variable "zork" refers to one of these old instances.  In this context you should be able to execute...

zork class allInstances elementsExchangeIdentityWith:
	(zork class allInstances collect: [:x | x as: GelaendeLinie])

...and everything should miraculously start working again (if there aren;t other such problems ;-).

You say you are a newbie, so here's what is going on here:

	"zork class allInstances" rounds up all the obsolete instances in an array
	"x as: GelaendeLinie" makes up a new GelaendeLinie copied from x
		(ie with each corresponding instvar copied), and
	"elementsExchangeIdentityWith" um, er, well it magically replaces every
		reference in the system which used to point to one of the
		receiver's elements (an obsolete instance) with a reference
		instead to the corresponding element from the second
		array (which contains the newly created GelaendeLinies)

Hope this helps and, more specifically, I hope it works for you.

Welcome to Squeak ;-)

	- Dan



More information about the Squeak-dev mailing list