Path: utzoo!attcan!uunet!lll-winken!ames!sun-barr!apple!rutgers!att!westmark!mole-end!mat From: mat@mole-end.UUCP (Mark A Terribile) Newsgroups: comp.lang.c++ Subject: Re: address of virtual function (revisited) Summary: Virtual consts? A syntactic and semantic change ... Message-ID: <182@mole-end.UUCP> Date: 11 May 89 11:23:31 GMT References: <904@garya.Solbourne.COM> <6590118@hplsla.HP.COM> Organization: mole-end--private system. admin: mole-end!newtnews Lines: 39 > > >Again, for OOP to be affordable, these simple, everyday "get" and > > >"put" type functionalities must be handled at minimal cost. > > I get a frustrated by assertions of this kind. By any standard C++ > > is "affordable", ... > Sorry, I meant my comments in the context of the relative cost of > virtual functions, compared to simple lookups as you discuss below: [Virtual function calls when all that's needed is a stored value representing ``sizeof''] > ... Unfortunately, at least when using K&R compilers for the back end, > cfront knows a lot more about the code to be produced than the backend > compiler. So cfront would be the place that a lot of the optimzations > would have to occur. I think that this is wrong. Remember that anywhere the class is visible, a programmer may derive a new class with a replacement function that can't be implemented as a constant lookup. The only way to avoid this is to make the original base class promise that this won't be done, and then to enforce the promise. This means a *declaration* to that effect. What you really want, I think, is a virtual const. I think it's a neat idea and useful for certain purposes, *but* it's a new language feature and implementing every feature that might be composed at the fringe of the language smacks of PL/I. Have we forgotten wher *that* leads? Allowing the constructor to initialize a const member with the sizeof is, all in all, a reasonable idea, except that it only works for the base that owns that member. It has to be written as an assignment, I believe. (Still not too bad, though not quite as safe in the face of program changes.) -- (This man's opinions are his own.) From mole-end Mark Terribile