Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!ukc!reading!cf-cm!andrew From: andrew@computing-maths.cardiff.ac.uk (Andrew Jones) Newsgroups: comp.lang.smalltalk Subject: Re: super super ? Message-ID: <1123@cf-cm.UUCP> Date: 30 Nov 89 13:34:17 GMT References: <2160@cs-spool.calgary.UUCP> Reply-To: andrew@computing-maths.cardiff.ac.uk (Andrew Jones) Organization: University of Wales College of Cardiff, Cardiff, WALES, UK. Lines: 48 In article <2160@cs-spool.calgary.UUCP> sharp@ksi.cpsc.ucalgary.ca (Maurice Sharp) writes: > > Does anyone know the solution to the following problem. Assume >that there are 3 classes each of which implements a message called >foo. Call the classes Class1, Class2 and Class3, where each is a >subclass of the other ... > >The message 'foo' is defined in all three classes ... THE PROBLEM: > > I want Class3 to call the foo of Class1 NOT Class2. Is there a >way to do this ? > Ralph Johnson states: >Strictly speaking, if Class2 overrides a method defined in its superclass, >Class1, then there is no way that its subclass, Class3, can access the >definition in Class1. However, this is not a big problem in practice. And provides the standard work-around using the example of basicAt: and at: for collections. This is the way I have always circumvented the problem. However, if you have a Smalltalk-80 system containing the extension for multiple inheritance (you will find the class MetaclassForMultipleInheritance in category Kernel-Classes) then you might like to try defining the following method in Class3: foo ^self Class1.foo The compiler will complain that Class1.foo is a new message. Tell it to proceed at this point. This method will then kind-of use the method of Class1 for foo. The problem is, multiple inheritance in Smalltalk-80 is not bug-free, so you might suddenly find that things go wrong! One certain problem is that if Class1>>foo sends a message to super, then Class3>>foo will send the message to Class2, NOT Object. So if you're braver than I am, you're welcome to try it! Hope this helps. Andrew Jones, University of Wales College of Cardiff Department of Computing Maths. Maths. Institute Senghennydd Road Cardiff CF2 4AG UK