From -7582120789561802102
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,ccbfcafab96cf493
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-11-25 18:00:05 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Edward Diener <eldiener@earthlink.net>
Newsgroups: comp.std.c++
Subject: Re: Proposol to increase robustness of programs
Date: Mon, 26 Nov 2001 01:59:06 GMT
Organization: EarthLink Inc. -- http://www.EarthLink.net
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <3C006716.4070201@earthlink.net>
References: <3BFE97B3.91430FB1@wanadoo.fr>
Reply-To: eldiener@earthlink.net
X-Trace: mail2news.demon.co.uk 1006739952 mail2news:29404 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2
X-Accept-Language: en-us
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
NNTP-Posting-Date: Sat, 24 Nov 2001 19:31:09 PST
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by mulga.cs.mu.OZ.AU id MAA26069
Lines: 81
Xref: archiver1.google.com comp.std.c++:8294

Lo=EFc Joly wrote:

> Hello everybody,
> This is my first post on this group, so I hope I am on-topic...
>=20
> I would like to make a proposal for an addition to the C++ standard.
> It pertains with virtual function that we want to be sure exist in the
> base class.
>=20
> Motivation :
> struct A
> {
>   virtual void f(char *s);
> };
>=20
> struct B : A
> {
>   virtual void f(char *s);
> };
>=20
> int main ()
> {
>   A* a =3D new B;
>   a->f();
> }
>=20
> This works just fine, but now, suppose someone in charge of maintaining
> the A class discovers that the declaration of f should have been :
> virtual void f(char const *s);
> He makes the change, but somehow forget to change class B. The compiler
> will compile silently, but the program will not do the expected thing.
> This is a real-world example that has already bitten me several times,
> and is difficult to debug.
>=20
>=20
> Proposal :
> Add something that will prevent compilation if a virtual function does
> not have a function to override in the base class.
> Some notation (with comments) may be :
>=20
> struct B : A
> {
>   override virtual void f(char *s);
> };
>=20
> This syntax seems rather clear to me, but requires a new keyword, and
> thus may break old programs (maybe we should give to 'static' yet
> another signification ;)).
> The good point is that is is very easy to compile this code on old (i.e.
> current) compilers (just #define away the override keyword).
>=20
> struct B : A
> {
>   virtual void f(char *s) =3D 1;
> }
>=20
> This syntax is not so clear, more difficult to #define away, but does
> not require any new keyword. It also has the advantage of giving more
> consistance to the existing virtual =3D0 syntax ;).
>=20
>=20
>=20
>=20
> I would like to know what do you think of this proposal; and if there i=
s
> something I can do to make it accepted in the next standard, I would
> like to have some advise about it.


I do not like your proposal for the reason that you are attempting to=20
add a feature to the language merely to prevent a programming error,=20
rather than justifying some new functionality in C++ or making the=20
syntax clearer in a much needed way. Additions to C++ merely to prevent=20
programming errors is, to me, not in the spirit of the language.

---
[ 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://www.research.att.com/~austern/csc/faq.html                ]



