From -1382514868801914158
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,d172be9423d7e292
X-Google-Attributes: gidf78e5,public
From: jcoffin@taeus.com (Jerry Coffin)
Subject: Re: virtual versus dynamic
Date: 1999/02/02
Message-ID: <MPG.11204495a7a88e0f989868@news.rmi.net>#1/1
X-Deja-AN: 439714186
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <917861033.740809@saturn.riv.be>
X-Original-Date: Tue, 2 Feb 1999 00:00:33 -0700
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 917955922 12076 128.250.29.16 (2 Feb 1999 11:45:21 GMT)
Organization: TAEUS
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANrblL+EDnX0m9pzZAQHakgF+JqRDdA6GQbydC7TKqFtr/BPbNfRt7S/z zdOkoVn2qrhCHzQXHtFJYBnaSZNXOW5r =qIDG
NNTP-Posting-Date: 2 Feb 1999 11:45:21 GMT
Newsgroups: comp.std.c++

In article <917861033.740809@saturn.riv.be>, cminnoy@starlab.net 
says...
> While I was experimenting with Delphi I noticed a rather remarkable feature
> that C++ doesn't support, namely dynamic methods. Dynamic methods are, just
> like virtual methods, late binded. The difference is size and speed.

[ ... ] 

> Maybe it's worthwhile to explore the possibility to include such a
> feature also in C++. C++ always claims to be efficient with it's
> resources, and this feature seams to increase the resource handling
> capability (speed versus size).

This doesn't require any addition to the language.  You can handle 
such considerations of size vs. speed without any new keywords, etc.

Possibilities include the compiler simply looking at the number of 
functions involved, and the number that are overridden, and making a 
decision based upon that.  A compiler might also do some profiling and 
make decisions about how to handle things based upon how often 
particular functions are used.

Note that these techniques are already well-known in present 
compilers.  I'm not sure whether they use it to decide upon a format 
for the vtable (I kind of doubt it) but the first is _commonly_ used 
in generating code for case statements, and the second is used (e.g. 
by HP's compiler, IIRC) for certain forms of optimization in general.

Right now, the language includes both ``register'' and ``inline'', 
both of which are nearly obsolete for most compilers.  ``inline'' 
means a few other things that compilers can't ignore, but the general 
idea remains: compiler technology is generally fairly quick overtake 
things we add to languages in an attempt to help them out.

I also did a quick bit of looking through programs I have on hand.  On 
average, the vtable seems to consume less than 1% of the programs.  
Even if addition of the keyword could completely eliminate that (which 
is clearly impossible) the best we could hope for from it would be a 
1% reduction in program size and memory usage.  It might be that other 
programs have much larger vtables than mine, but they'd clearly need 
to be a LOT larger before this could possibly make a meaningful 
difference.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



