home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / pascal / 6705 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  4.2 KB

  1. Path: sparky!uunet!utcsri!skule.ecf!torn!nott!cunews!revcan!software.mitel.com!kim!kim
  2. From: kim@Software.Mitel.COM (Kim Letkeman)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: BP/TP OOP is missing something...
  5. Message-ID: <KIM.92Nov18081057@kim.Software.Mitel.COM>
  6. Date: 18 Nov 92 13:10:57 GMT
  7. References: <KIM.92Nov16125141@kim.Software.Mitel.COM>
  8.     <1992Nov17.153804.21729@news.clarkson.edu>
  9. Sender: kim@Software.Mitel.COM
  10. Organization: MITEL Public Switching, Kanata, Ontario, Canada
  11. Lines: 71
  12. In-reply-to: kooijman@sun.soe.clarkson.edu's message of 17 Nov 92 15:38:04 GMT
  13.  
  14. In article <1992Nov17.153804.21729@news.clarkson.edu> kooijman@sun.soe.clarkson.edu (Harry Kooijman,Peyt314a,3808) writes:
  15.  
  16. | Why is it that TP with objects does not have the capability to call the
  17. | constructors when variables are declared? 
  18. <stuff deleted>
  19. | When you dynamically allocate vectors and matrices this is very useful.
  20. | If I forget to call the constructor or destructor I will be in for nasty
  21. | debug times.
  22.  
  23. This is not as useful as it sounds. Dynamically allocating vectors and
  24. matrices that are efficient requires specifying the size at
  25. constructor time, i.e. the way it is done in TP. If you want
  26. construction at declaration, then you have to grow your vectors and
  27. matrices in real time and you lose all kinds of efficiency.
  28.  
  29. | This is why constructors in C++ have the same name as the objects.
  30. | But what is more is that they allow for *multiple* constructors (and
  31. | the compiler figures out which one to use).
  32.  
  33. Multiple constructors would be nice, and could be implemented in the
  34. existing language, but the rules for handling different parameter sets
  35. and/or optional parameters would destroy the "PASCALness" of TP. I.e.
  36. if you really desire this facility, then use C++.
  37.  
  38. If, on the other hand, you are addicted to the incredible speed of the
  39. TP compilers, then live with the burden of calling the constructors
  40. and destructors yourself (not much of a burden IMO).
  41.  
  42. | It is mentioned that the compiler gets the burden of finding out all
  43. | the details which routine to call when operators are overloaded (and
  44. | also in other cases, such as the automatic generation of
  45. | destructors).  Well, to my opinion its better to do so since the
  46. | compiler does it faster than we can do. Ultimately we might have
  47. | toolboxes full of objects we want add or subtract from eachother. If
  48. | we want to do so its much easier to use the + and - then to call
  49. | specific routines for each combination. If a certain operation can
  50. | be interpreted for more than one (for example matrix * matrix, as
  51. | Duncan pointed out) we have a choice: let the user determine the
  52. | overloading. He can define his/her own version and pick the
  53. | overloading he likes. Or we could pick the most popular overloading
  54. | and put a warning in the manual/documentation!
  55.  
  56. Yes, well, this is one of C++'s strengths and IMO one of its greatest
  57. weaknesses as well. These tool boxes you look forward to using will
  58. have to be engineered by the same person to have any hope of being
  59. reliable when being used together. Overloading introduces all kinds of
  60. potential ambiguities with complex objects and this can take longer to
  61. debug than it would have to call well named functions to do explicit
  62. conversion between objects.
  63.  
  64. | TP with objects is a good product but it's missing some good
  65. | portions of the object way of thinking, isn't it? Don't get me
  66. | wrong: I'll be buying BP7 as well and probably using its OOP, but
  67. | totally happy with it, no I am not. And that's the shame, since I
  68. | regard Pascal higher than C++.
  69.  
  70. How can you argue so passionately for these itty bitty improvements to
  71. a very well thought out OOP extension to TP and then in the next
  72. breath say "probably use its OOP"? It seems to me that you are waiting
  73. for perfection before using a facility that is already excellent. I've
  74. written thousands of lines of code using the existing facilities and
  75. believe me, it works.
  76.  
  77. To me, it has enough of the so-called "object way of thinking" to
  78. allow the writing of completely isolated objects that can be used
  79. without knowing anything about their guts. That's the whole point as
  80. far as I'm concerned. The syntactic sugar you desire would be nice,
  81. but wouldn't shrink most applications by more than a few lines of
  82. code (again, IMO).
  83. --
  84. Kim Letkeman    kim@Software.Mitel.COM
  85.