home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!hagbard!loglule!jbn
- From: jbn@lulea.trab.se (Johan Bengtsson)
- Newsgroups: comp.lang.c++
- Subject: Re: static members in derived classes
- Message-ID: <5387@holden.lulea.trab.se>
- Date: 15 Dec 92 20:03:54 GMT
- References: <1992Dec14.215407.21631@microsoft.com>
- Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
- Lines: 56
- X-Newsreader: TIN [version 1.1 + PL8]
-
- Jim Adcock (jimad@microsoft.com) wrote:
- : In article <1992Dec12.175244.17775@taumet.com> steve@taumet.com (Steve Clamage) writes:
- : |"Virtual static" has been proposed from time to time. I don't know of
- : |any technical objections to it. There are lots of good ideas for
- : |extensions to C++. The question is always one of evaluating the costs
- : |and benefits of any proposed extension.
-
- : The technical argument against it is that the same capability can be
- : implementing using virtual functions.
-
- Agreed.
-
- : If the complaint is that virtual
- : functions are too slow to implement "virtual statics" then the counter-
- : reply is that compilers can use a fat table implementation [or other
- : implementation] instead of the common vtable implementation in order
- : to reduce the cost of the virtual function call in these cases.
-
- I'd say it would take a pretty smart compiler to recognize the
- "virtual static idiom", noticing that
-
- virtual void f();
- static void static_f();
-
- in fact is equivalent to the (forbidden) construct:
-
- static virtual void f();
-
- And of course, this doesn't work, since you have to use two different
- names, f() and static_f().
-
- : Going the opposite direction people who propose "virtual static" do so
- : on the basis of an assumed vtable implementation of virtual functions.
- : In which case including "virtual static" begins to dictate one implementation
- : over other potentially faster implementations, which is not a good thing
- : to do. Language should specify language, not dictate implementation.
-
- I like "virtual static", and I do not need the vtbls to back me up.
- It is more a question of orthogonality and removal of an exception
- to language rules.
-
- Even if it was true that "virtual static" must be implemented using vtbls,
- you would only pay for it when you use it. "Virtual static" could
- in principle use a different scheme than other virtual functions.
-
- Also, the equivalence between "static virtual void f()" and two separate
- methods, one static and one virtual, is a direct disproof of your claim
- that "static virtual" dictates a particular implementation (assuming
- you are not also claiming that ordinary virtuals _must_ be implemented
- using vtbls).
-
- --
- --------------------------------------------------------------------------
- | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden |
- | Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490 |
- --------------------------------------------------------------------------
-