home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / std / cplus / 2131 < prev    next >
Encoding:
Text File  |  1993-01-28  |  3.0 KB  |  76 lines

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