home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!caen!hellgate.utah.edu!fcom.cc.utah.edu!swillden
- From: swillden@news.ccutah.edu (Shawn Willden)
- Subject: Re: Member function renaming proposal from the ARM
- Message-ID: <1992Nov17.031938.10774@fcom.cc.utah.edu>
- Sender: news@fcom.cc.utah.edu
- Organization: University of Utah Computer Center
- X-Newsreader: Tin 1.1 PL3
- References: <721945900snx@trmphrst.demon.co.uk>
- Date: Tue, 17 Nov 92 03:19:38 GMT
- Lines: 48
-
- nikki@trmphrst.demon.co.uk (Nikki Locke) 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).
- :
-
- [ proposal and ARM's reason for dismissal deleted ]
-
- : I see another use for this extension (see ARM also 13.1 pp310-312) ...
- :
- : class Base {
- : public:
- : // ...
- : virtual void set(int i);
- : virtual void set(double d);
- : virtual void set(char *s);
- : };
- :
- : class Derived {
- : 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.
- :
- : Now I realise that there is no chance of including this in the current
- : standard (lets concentrate on getting it finished), but is it a sensible
- : enhancement to the language for some future date ? Or is there an existing
- : construct which will do the job without any run-time efficiency penalty ?
-
- The standard trick of defining Derived::set(int) and Derived::set(double)
- as inline forwarding functions should work without any run-time penalty
- if the compiler is smart. All it has to do is recognize what is happening
- and put the addresses of the Base methods in the Derived vtable. Given
- that this is such an easy optimization I don't think we need a language
- extension for it (and another bit of syntax to learn).
-
- : --
- : Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
- : trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
-
- --
- Shawn Willden
- swillden@icarus.weber.edu
-