home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!enterpoop.mit.edu!ira.uka.de!slsvaat!slsveit!dcb
- From: dcb@slsveit (David Binderman (SWP))
- Subject: Re: Compiler should generate virtual destructors
- Message-ID: <1993Jan28.095059.21080@us-es.sel.de>
- Sender: news@us-es.sel.de
- Organization: SEL-Alcatel LTS Dept. US/ES
- X-Newsreader: TIN [version 1.1 PL8]
- References: <lkc2k7INNajv@exodus.Eng.Sun.COM>
- Date: Thu, 28 Jan 93 09:50:59 GMT
- Lines: 63
-
- David Brownell (db@argon.Eng.Sun.COM) wrote:
- : On the other hand, one of the things I'd really like to see changed is
- : how much stuff a C++ compiler does "for me" automagically. It's a rare
-
- Agreed. What the C++ compiler does is a constant source of bugs.
-
- : So, a pair of proposals that I'd be happier to see accepted:
-
- : (1) It is an error for a class to have virtual functions and a
- : nonvirtual destructor.
-
- I'd vote for it being a warning. Then compilers can be graded on their
- user friendliness.
-
- :
- : (2a) C++ compilers don't automagically generate ANYTHING for classes
- : any more: constructors, destructors, assignment and address-of
- : operators, etc. If such routines are used but not declared and
- : defined, that is an error.
-
- Agree 100%. Also, any compiler that implements a warning for a class which
- only declares one or two of the (ctor, dtor, copy ctor) set would get my vote.
-
- The C++ FAQ has other suggestions for a C++ lint to do.
-
- Also, drop all this "struct is a class with different visibility". Our
- programmers here have spent years learning what a C struct is. Don't change
- it. Just make the restriction that any struct which defines a method
- must be converted into a class. It makes life simple: a C++ struct can
- only define data, and the moment it declares a method, then it
- must be a class.
-
- I'd also vote for any compiler which produced a warning for an inline method
- definition
-
- class K {
- void f() { // no !
- };
- ..
- };
-
- And another warning the compiler implementers out there might consider
- is that if a constructor calls new, and the matching destructor does
- not, then I want to see a warning for that destructor.
-
- But hey, all this talk of improving the details of the compiler
- implementation fails to address the real problem: The ARM has been
- publically available for nearly three years now, and I have yet to see
- a compiler which implements the ARM ( less Exceptions and Templates
- obviously). Ok I will be able to use the full functionality of the ARM
- when (if ?) the moment it arrives, but I can't even get a compiler
- for a reasonable language subset.
-
- I'm sure the reason for this is the complexity of the language.
- Me, I'd vote for Typesafe ANSI C with Objects thrown in.
- No inheritance, no virtual functions, no polymorphism. The rest is hard
- for the compilers to implement, hard for the programmers to understand,
- and hard to build reliable systems that work using those features.
-
- Regards
- --
- David C Binderman Dept US/ESI, Bau 60, SEL-Alcatel AG, Lorenz Strasse 10,
- D-7000 Stuttgart 40, Germany dcb@us-es.sel.de Tel: +49 711 821 3841
-