Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!apple!atncpc!bruce From: bruce@atncpc.UUCP (Bruce Henderson) Newsgroups: comp.sys.next Subject: Re: probate Summary: easy fix Message-ID: <346@atncpc.UUCP> Date: 16 Oct 90 16:24:39 GMT References: <3861@network.ucsd.edu> Organization: Ashton Tate NCPC, San Jose, CA. Lines: 52 In article <3861@network.ucsd.edu>, pbiron@weber.ucsd.edu (Paul Biron) writes: > > I'm trying to figure out an "elegent" way to keep a sub-class > from inheriting methods from its super-class. In this case, > I'm making a Stack class out of the List class. Since a > Stack should specifically deny "random" access to its elements, > I need a way to keep it from inheriting ObjectAt:, etc. > > So far, all I've done is defined these kinds of methods like: > > - ObjectAt:(int)num > { > fputs ("Stack does not recognize selector ObjectAt:\n", stderr) ; > kill (getpid (), SIGIO) ; > } > > In other words, just give the same kind of message that the > Obj-C runtime mechanism gives when you send an unknown message > to an object. > > Is there a "better" way? Is there anything in the specs for > Obj-C which say how this should be handled (I couldn't find > it, if it is there). > > Paul Biron pbiron@ucsd.edu (619) 534-5758 > Central University Library, Mail Code C-075-R > Social Sciences DataBase Project > University of California, San Diego, La Jolla, Ca. 92093 Yes, as a matter of fact there is! You just override ObjectAt: to do nothing! (ie, just return self) And that will remove the functionallity. Actually, returning self in this case is innapropriate. You should probably return an NULL and hope that whoever calls this method checks for null like a good potato. Just as an opinion, it's never polite to kill the process, just because NeXTStep 1.0 sometimes does it doesn't mean it doesn't annoy the hell out of the rest of us 8-) It would llok like : - ObjectAt:(int)num { return NULL; } ta da! a call to ObjectAt: now does nothing! Bruce Henderson Ashton Potato Never a dull moment.....