home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mcsun!news.funet.fi!network.jyu.fi!sakkinen
- From: sakkinen@jyu.fi (Markku Sakkinen)
- Subject: Re: Member function renaming proposal from the ARM
- Message-ID: <1992Nov17.103735.23693@jyu.fi>
- Organization: University of Jyvaskyla, Finland
- References: <721945900snx@trmphrst.demon.co.uk>
- Date: Tue, 17 Nov 1992 10:37:35 GMT
- Lines: 60
-
- In article <721945900snx@trmphrst.demon.co.uk> nikki@trmphrst.demon.co.uk writes:
- >I have a question about an extension to the language to allow programmers
- >to specify inheriting and optionally renaming functions. The extension is
- >proposed in the ARM 10.11c (pp 236-237).
- >
- >Let us assume two base classes with name clashes ...
- > ...
- >// The suggested extension would allow ...
- >class LotterySimulation : public Lottery, public GraphicalObject {
- > // ...
- > virtual int l_draw() = Lottery::draw;
- > virtual void draw() = GraphicalObject::draw;
- > };
- >
- >It is stated in the ARM that such a language extension is not _necessary_,
- >and is only worthwhile if the need to resolve such name clashes proves
- >common. It strikes me that the workround suggested in the ARM is going to
- >cause some loss of efficiency on most compilers around today.
-
- I will take some ideas from my paper in Computing Systems
- (A critique of the inheritance principles of C++) -- excuse the plug.
- The ARM is actually wrong: some extension like this would be necessary
- in order to _redefine_ the two 'draw' functions separately.
- At least Eiffel has the 'rename' clause for this purpose.
-
- >I see another use for this extension (see ARM also 13.1 pp310-312) ...
- > ...
- >class Derived {
- ^^ : public Base (obviously)
- >public:
- > // ...
- > void set(int) = Base::set(int);
- > void set(double) = Base::set(double);
- > virtual void set(char *s);
- > };
- >
- >This will prevent set(int) and set(double) being hidden by set(char *),
- >without any loss of efficiency in the calling mechanism.
- > ...
-
- I suggested an even more convenient way for inhibiting the obnoxious
- hiding rule in the paper:
- reveal set;
- I.e., none of the overloaded 'set' functions would be hidden.
- Even better if the hiding would not be the default, but could
- be effected when desired by
- hide set;
-
- In both cases, I think that conceptual clarity is a stronger argument
- than efficiency for the proposed language modifications.
-
- ----------------------------------------------------------------------
- Markku Sakkinen (sakkinen@jytko.jyu.fi)
- SAKKINEN@FINJYU.bitnet (alternative network address)
- Department of Computer Science and Information Systems
- University of Jyvaskyla (a's with umlauts)
- PL 35
- SF-40351 Jyvaskyla (umlauts again)
- Finland
- ----------------------------------------------------------------------
-