home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!haven.umd.edu!wam.umd.edu!krc
- From: krc@wam.umd.edu (Kevin R. Coombes)
- Subject: Re: static members in derived classes
- Message-ID: <1992Dec15.150612.28264@wam.umd.edu>
- Sender: usenet@wam.umd.edu (USENET News system)
- Nntp-Posting-Host: rac1.wam.umd.edu
- Organization: University of Maryland, College Park
- References: <1992Dec11.145205.29761@wam.umd.edu> <1992Dec12.175244.17775@taumet.com> <1992Dec14.215407.21631@microsoft.com>
- Date: Tue, 15 Dec 1992 15:06:12 GMT
- Lines: 46
-
- In article <1992Dec14.215407.21631@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
- >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. 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.
- >
- The article to which Steve Clamage replied (and I wrote) pointed out that
- the same capability could be achieved using virtual functions. I did not
- object to the speed; I objected to the fact that this approach was
- tedious and error-prone. In each derived class where I wanted to add
- a different "virtual static" member, I had to add a new static member
- and add the virtual functions to manipulate it. And besides, it looks
- ugly.
-
- Is it really the case that the only objection is that it can already be
- achieved using existing techniques?
-
- >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 don't see how it follows that allowing "virtual static" data dictates
- a particular implementation. Certainly, language definitions should not
- restrict implementations unnecessarily. However, I think of "virtual
- static" data as completing the following picture: Member functions belong
- to the class; data members belong to individual objects. Things that
- belong to the class can be delegated to derived classes by calling them
- "virtual". Things that belong to individual objects don't need to be
- made virtual, because they can have their own values anywhere you need
- them. Static data members, on the other hand, are neither here nor there.
- They belong to the class, but you cannot vary them in derived classes.
-
- Kevin Coombes <krc@math.umd.edu>
-
-
-