home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 17978 < prev    next >
Encoding:
Text File  |  1992-12-15  |  2.9 KB  |  77 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Give me safe C++
  5. Message-ID: <1992Dec15.134713.2561@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <WARSAW.92Dec11124441@anthem.nlm.nih.gov> <1992Dec12.145403.26483@ucc.su.OZ.AU> <WARSAW.92Dec12174137@anthem.nlm.nih.gov>
  10. Date: Tue, 15 Dec 1992 13:47:13 GMT
  11. Lines: 64
  12.  
  13. In article <WARSAW.92Dec12174137@anthem.nlm.nih.gov> warsaw@nlm.nih.gov (Barry A. Warsaw) writes:
  14. >
  15. >>>>>> "John" == John MAX Skaller <maxtal@extro.ucc.su.OZ.AU> writes:
  16. >
  17. >    John>     While tending to support your liking of the C++ 'hybrid'
  18. >    John> approach, I'm not so sure about 'seamlessly', are you?
  19. >
  20. >I think it is rather seamless in the sense that I can solve problems
  21. >(or typically, subproblems of a larger, integrated system) using a
  22. >functional, ADT, and/or OOP approach, and I can develop all these
  23. >parts in a single language.  Everything doesn't have to be a class in
  24. >C++ and not all classes have to use inheritance and polymorphism. My
  25. >only point was that I don't have to jump through hoops to solve a
  26. >problem using these different abstraction levels.  Maybe we're talking
  27. >about different things when we say "seamless"?
  28.  
  29.     No, I agree in principle and practice with you. 
  30. But there continue to be annoying problems. An example:
  31. I want an abstract base class X with an operation f that returns
  32. an X, so I can provide some implementation
  33.  
  34.     class Y : X { .. Y f(); .. }
  35.  
  36. where f is virtual. But I cant.
  37. How do I declare X::f? If I use
  38.  
  39.     X X::f()
  40.  
  41. it is illegal, due to different return types. If I use a reference
  42.  
  43.     X& X::f();
  44.     X& Y::f();
  45.  
  46. it is fine syntactically, but C++ has no garbage collection,
  47. so if in Y::f is have
  48.  
  49.     .. return new Y;
  50.  
  51. then the object gets lost in an expression and cant be deleted.
  52. This problem doesnt arise in Eiffel, *because* it has garbage
  53. collection.
  54.  
  55. In C++ you can sort of work around this, but only be introducing
  56. another layer of classes that act as references to the real objects.
  57. But thats not seamless integration, I have to rework ALL my code
  58. to accommodate this design change.
  59.  
  60. This explains why good vendor libraries that do this sort of
  61. work for you are incompatible, (and are thus also 'bad')
  62. they use different techniques
  63. for repressenting classes .. because the base language itself
  64. is not adequate.
  65.  
  66. (Adding GC solves some of these problems, but many remain.
  67. There is probably no general solution, of course.
  68. At least on smaller projects these issues tend not to arise,
  69. however. Large scale integration is a different class of
  70. problem I think.)
  71.  
  72. -- 
  73. ;----------------------------------------------------------------------
  74.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  75.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  76. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  77.