system category bungle

Dan Ingalls Dan at SqueakLand.org
Mon Apr 21 19:50:16 UTC 2003


>PS...

>It is fairly simple to recover missing elements if that becomes important (essentially by enumerating classes and classifying them as, eg, 'Unclassified' if they are not found in the SystemOrganization.  If anyone is feeling bored out there, it would be useful to write a method that verifies consistency of the SO in this manner, and offers to perform this recovery if necessary.

The following method performs the kind of verification and repair I have in mind, with sample invocation in quotes.  Someone with discipline might want to remove the halt and cast this into the form of a proper unit test.

Derek:  You might want to file this in and see if the first test runs without a halt in your system.

	- Dan
-------------------------------------
'From Squeak3.4 of 1 March 2003 [latest update: #5170] on 21 April 2003 at 12:35:15 pm'!

!ClassOrganizer methodsFor: 'private' stamp: 'di 4/21/2003 12:31'!
verifyElements: elems
	"SystemOrganization verifyElements: (Smalltalk allClasses collect: [:c | c name])."
	"Smalltalk allClassesDo: [:c | c organization verifyElements: c selectors]."
	| elements |
	elements _ elems asSet.
	self elementArray asSet = elements ifFalse:
		[self halt.
		(self elementArray copyWithoutAll: elements) do:
			[:excess | self removeElement: excess].
		(elements copyWithoutAll: self elementArray) do:
			[:missing | self classify: missing under: self class default]].
! !



More information about the Squeak-dev mailing list