[Cuis-dev] Behavior hierarchy methods --- comment problems, other nits

Andres Valloud ten at smallinteger.com
Sat Aug 24 18:28:34 PDT 2019


These changes homogenize the implementation of withAllSuperclasses and 
withAllSubclasses, and fix a few other comment issues.

Andres.
-------------- next part --------------
'From Cuis 4.2 of 25 July 2013 [latest update: #2595] on 24 August 2019 at 6:21:11.068329 pm'!

!Behavior methodsFor: 'accessing class hierarchy' stamp: 'sqr 8/24/2019 18:19'!
allSuperclasses
	"Answer an OrderedCollection of the receiver's and the receiver's  
	ancestor's superclasses. The first element is the receiver's immediate  
	superclass, followed by its superclass and subsequent superclasses,
	and proceeding as long as there is a non-nil superclass."

	| answer pivot |
	answer := OrderedCollection new.
	pivot := superclass.
	[pivot == nil] whileFalse:
		[
			answer add: pivot.
			pivot := pivot superclass
		].
	^answer! !
-------------- next part --------------
'From Cuis 4.2 of 25 July 2013 [latest update: #2595] on 24 August 2019 at 6:25:11.636653 pm'!

!Behavior methodsFor: 'accessing class hierarchy' stamp: 'sqr 8/24/2019 18:25'!
subclasses
	"slow implementation since Behavior does not keep track of subclasses"
	
	^ self class allInstances  select: [:each | each superclass = self ]! !
-------------- next part --------------
'From Cuis 4.2 of 25 July 2013 [latest update: #2595] on 24 August 2019 at 6:26:50.509852 pm'!

!Behavior methodsFor: 'accessing class hierarchy' stamp: 'sqr 8/24/2019 18:26'!
withAllSubclasses
	"Answer an OrderedCollection with the receiver, the receiver's descendents, and the  
	receiver's descendents' subclasses."

	^self allSubclasses add: self; yourself! !
-------------- next part --------------
'From Cuis 4.2 of 25 July 2013 [latest update: #2595] on 24 August 2019 at 6:21:06.156 pm'!

!Behavior methodsFor: 'accessing class hierarchy' stamp: 'sqr 8/24/2019 18:21'!
withAllSuperclasses
	"Answer an OrderedCollection of the receiver and the receiver's 
	superclasses. See also #allSuperclasses."

	^self allSuperclasses addFirst: self; yourself! !


More information about the Cuis-dev mailing list