Article View: gnu.g++
Article #432Re: address of virtual function (revisited)
From: grunwald
Date: Wed, 10 May 1989 02:32
Date: Wed, 10 May 1989 02:32
46 lines
2083 bytes
2083 bytes
furthermore, remember that other optimizations are allowed, depending on
the knowledge of the type.
E.g., if you are using an instance of the function, and not a pointer
to the function, you can inline the virtual.
There are some possible language extensions that would allow you to do
load/stores a little cheaper. Examples can be found by looking at CLU.
Not using their syntax, the basic idea would be to automatically
declare functions for variables. Given this, and knowledge about the
size of the object and the semantics, you could generate simple
loads & stores. You'd need to introduce a keyword, e.g., ``mutable''
and/or ``immutable'' to distinguish read members from read/write members.
e.g.,
class Foo {
immutable int frob;
mutable double bar;
};
Foo foo;
is a class with 2 data variables & two functions: frob is read only, bar
is writable. Users could specify ``foo -> bar(10)'' or whatever syntax
you desire.
If I subclassd Foo, and hide the definition of variable `bar' with another
variable `bar', I'd still be able to generate the code via:
load foo,a0
add #4,a0
load @a0,d0
(optimize it for you machine).
But what does all this buy you? How often do you need to return data values
without additional work? If you don't have additioanl work to do, why are
they virtual data items?
I think I'm missing the range of applicability of the feature, although
it's simple to add.
--
Dirk Grunwald
Univ. of Illinois
grunwald@flute.cs.uiuc.edu
Technical Details
Message-ID:
<GRUNWALD.89May9213201@flute.cs.uiuc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc!garcon!garcon.cso.uiuc.edu!grunwaldReferences:
<6590118@hplsla.HP.COM> <8905100026.AA27112@yahi.stanford.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc!garcon!garcon.cso.uiuc.edu!grunwald From: grunwald@flute.cs.uiuc.edu Newsgroups: gnu.g++ Subject: Re: address of virtual function (revisited) Message-ID: <GRUNWALD.89May9213201@flute.cs.uiuc.edu> Date: 10 May 89 02:32:01 GMT References: <6590118@hplsla.HP.COM> <8905100026.AA27112@yahi.stanford.edu> Sender: news@garcon.cso.uiuc.edu Distribution: gnu Organization: University of Illinois, Urbana-Champaign Lines: 46 In-reply-to: tiemann@YAHI.STANFORD.EDU's message of 10 May 89 00:26:08 GMT