Article View: comp.lang.objective-c
Article #203Re: method inheritance in NeXT ObjC classes
From: Hartmut Benz
Date: Tue, 13 Oct 1992 11:38
Date: Tue, 13 Oct 1992 11:38
41 lines
1979 bytes
1979 bytes
Andy Belk writes
> Hi all.
> Just as an aside, this (List->Stack) is a fairly good example of
> when subclassing is not necessarily what is really desired.
>
> A Stack usually has push and pop operations, and in this case also a display
> method, but one can argue that doing List operations on a stack may cause
> problems. For example, one can do things that mess up the LIFO idea of a
> stack:
>
> Stack s;
> Integer i = 5;
> [s init];
> [s push: i--];
> [s push: i--];
> [s push: i--];
> [s push: i--];
> [s push: i--];
> [s removeObjectAt: 5]; // Ok, you can do it, but should you be able to ?
> [[s pop] display];
>
> etc.
[rest deleted]
An excerpt from Object.rtf from the NextDocumentation:
.... For example, an Object subclass might renounce the copy method by reimplementing it to include an error: message as follows:
- copy
{
[self error:" %s objects should not be sent '%s' messages\n",
[[self class] name], sel_getName(_cmd)];
}
This code prevents instances of the subclass from recognizing or forwarding copy messageslthough the respondsTo: method will still report that the receiver has access to a copy method. .....
--
Tschoe'wa
_______________________________________
Hartmut Benz | benz@infko.uni-koblenz.de
D-5400 Koblenz, Germany | (NeXTmail ok)
Technical Details
Message-ID:
<1992Oct13.113844.9127@infko.uucp>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!infko!newsReferences:
<1992Oct12.105651.17220@dxcern.cern.ch>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.objective-c Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!infko!news From: benz@infko.uni-koblenz.de (Hartmut Benz) Subject: Re: method inheritance in NeXT ObjC classes Message-ID: <1992Oct13.113844.9127@infko.uucp> Sender: news@infko.uucp (that is the account for news) Nntp-Posting-Host: nestor.uni-koblenz.de Organization: Universitaet Koblenz (FB Informatik) References: <1992Oct12.105651.17220@dxcern.cern.ch> Date: Tue, 13 Oct 1992 11:38:44 GMT Lines: 41