Restricting super calls to inherited method

Jon Hylands jon at huv.com
Sat May 19 15:06:02 UTC 2001


On Sat, 19 May 2001 10:26:05 -0400, Paul Fernhout
<pdfernhout at kurtz-fernhout.com> wrote:

> Can anyone point to a non-contrived, non-legacy situation
> where requiring the full "super" behavior could not be easily worked
> around using just "inherited"?

(off the top of my head)

OrderedCollection subclass: #SomeSpecializedOrderedCollection

SomeSpecializedOrderedCollection class methodsFor: 'instance creation'

new: size
	self error: 'It is not appropriate to send #new: to this class, use
#new instead'.

new
	^(super new: 100) doSomeSpecializedInitialization

If you're building a class hierarchy from scratch, or if you are free to
modify the superclass behavior, then it is easy to not do this. But
especially in a case like this, involving a heavily used base system class,
I would much rather do this than have to come up with some convtrived way
of dealing with restricting the inherited behavior.

Later,
Jon

--------------------------------------------------------------
   Jon Hylands      Jon at huv.com      http://www.huv.com/jon

  Project: Micro Seeker (Micro Autonomous Underwater Vehicle)
           http://www.huv.com





More information about the Squeak-dev mailing list