home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11453 < prev    next >
Encoding:
Text File  |  1992-07-23  |  5.6 KB  |  142 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: Covariant Types in Derived Classes
  5. Message-ID: <1992Jul23.205820.24559@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: <92A5AID@netmbx.netmbx.de> <1992Jul21.183932.1541@ucc.su.OZ.AU> <P6C5COF@netmbx.netmbx.de>
  10. Date: Thu, 23 Jul 1992 20:58:20 GMT
  11. Lines: 129
  12.  
  13. In article <P6C5COF@netmbx.netmbx.de> jrobie@netmbx.netmbx.de (Jonathan Robie) writes:
  14. >maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  15. >
  16. >>In article <92A5AID@netmbx.netmbx.de> jrobie@netmbx.netmbx.de (Jonathan Robie) writes:
  17. >>>maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  18. >
  19. >>>Then you
  20. >>>need to find out how many members you have in each class and how to
  21. >>>access them.....
  22. >
  23. >>    I dont understand.
  24. >
  25. >If I want a generic print function that can handle all types as though they
  26. >were basic types, then this print function must know the location and type
  27. >of each member, and also the name if the function is to be particularly
  28. >useful.
  29.  
  30.     Such a utility function would be useful for debugging only.
  31. Yes, to do it you would need RTTI.
  32.  
  33.     To make proper output *requires* programmer definition,
  34. when I need this I just have a virtual print in all relevant classes.
  35. Of course, then I have to *write* the definitions, which is a pain.
  36. >
  37. >>but NOT to streams. I use Windows, there are NO streams
  38. >>(well, there are: disk files I personally open).
  39. >>    So you see immediately there is a problem here.
  40. >
  41. >But if Windows provides you with general tools like the ones
  42. >I am describing then there is no such problem.  To do so they
  43. >need the run time type information.
  44.  
  45.     It would be the compiler's library that would have to
  46. support conversion from RTTI to say an object browser Window.
  47. Yes, this would need RTTI.
  48. >
  49. >>What concerns me is that, for example, if you can say
  50. >>get a description of the details of a class,
  51. >>then you can 'cheat' the system, and fiddle with details
  52. >>that were supposed to be hidden.
  53. >
  54. >You can do this with pointers also.  
  55.  
  56.     Yes, every 'cast' is a cheat.
  57.  
  58. >What concerns me is that
  59. >people are already writing precompilers for C++ simply because
  60. >they need this run time identification for such bread and butter
  61. >applications as object oriented databases.  That is OK if only
  62. >one of the tools you use needs a precompiler, but when you need
  63. >two tools which each need a precompiler this can lead to problems.
  64.  
  65.     OK, so you want a standard way of doing it. I cant
  66. disagree that where you need RTTI for foreign interfacing
  67. it would be better provided as standard.
  68.  
  69. >
  70. >Similarly, if every tool you use defines an Object type from which
  71. >all of your classes must be derived then you start having problems
  72. >when you want to use several tools simultaneously.
  73.  
  74.     Why would you do something so stupid as derive everything
  75. from Object? That is a totally out of date idea IMHO. Thats
  76. what MI is for: so you don't have to do this sort of Smalltalk
  77. emulation: it may be OK in Smalltalk, but it is totally wrong
  78. to make heirarchies in C++ when you should have DAGs.
  79.  
  80. [Above is pitched a bit extremely, no flame intended. And
  81. here's my definition of object:
  82.  
  83.     class object { public: virtual ~object(){} };
  84.  
  85. ]
  86. >
  87. >>Of course, in an OO database you might want to do exactly that:
  88. >>how else can the user define a new object?
  89. >
  90. >>But then you are writting in C++ a new system, and an interpreter
  91. >>aided by the C++ run-time system: I don't know what you
  92. >>call this class of programs, but for this class of programs
  93. >>you need run-time support---LOTS of it. No argument.
  94. >
  95. >No, I am not aware of any OO database which uses an interpreter
  96. >to build class methods.  Typically, a standard C++ constructor
  97. >is used to create a new object.  But the database maintains a
  98. >class dictionary to keep track of data members.
  99.  
  100.     Oh, you mean that the database does NOT actually define new 
  101. objects, the user has to write a program to create them?
  102. (To supply the constructor, which must be compiled C++ code)
  103. Then the OODB just stores the stuff, and has to retrieve
  104. it and convert it back to an object, which is a bit
  105. of a problem even WITH RTTI (because the object doesn't yet
  106. exist, so the RTTI is useless).
  107.  
  108. >Object oriented databases are a very typical tool for use with
  109. >C++, as are user interface tools, CASE tools, communications
  110. >packages, etc.   The C++ community is better off if these tools
  111. >are easily available.  You do not need a fully reflective system
  112. >to provide these tools, and you would not need precompilers if
  113. >the run time identification were available.
  114.  
  115.     Fair enough.
  116. >
  117. >>Why not use Smalltalk or Lisp: they already have the 
  118. >>properties you need. C++ with only run-time support
  119. >>added will STILL be almost unworkable for a system
  120. >>like an OO database that really requires reflexivity.
  121. >
  122. >Type safe systems are essential.  Neither Smalltalk nor Lisp are
  123. >type safe.  
  124.  
  125.     Yes. 'tis why I am concerned that RTTI will be used
  126. to do downcasting, which, although not invalidating type safety,
  127. invalidates the open/closed principle.
  128.  
  129.     The problems you want to solve (me too, and many others :-)
  130. are way out of te scope of a traditional language which
  131. works only with memory resources. THAT is the problem, really.
  132.  
  133.     Wouldn't you rather just say 'persistent' and have the object
  134. just exist in the 'persistent'  database totally automatically :-)
  135.  
  136.     
  137. -- 
  138. ;----------------------------------------------------------------------
  139.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  140.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  141. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  142.