home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11215 < prev    next >
Encoding:
Text File  |  1992-07-21  |  3.2 KB  |  87 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!netmbx!jrobie
  3. From: jrobie@netmbx.netmbx.de (Jonathan Robie)
  4. Subject: Re: Covariant Types in Derived Classes
  5. Organization: netmbx, Berlin, Germany
  6. Date: Tue, 21 Jul 1992 10:19:15 GMT
  7. Message-ID: <92A5AID@netmbx.netmbx.de>
  8. References: <1992Jul15.143126.905@cadsun.corp.mot.com> <1992Jul16.124016.5775@ucc.su.OZ.AU> <5W0422J@netmbx.netmbx.de> <1992Jul20.154835.9269@ucc.su.OZ.AU>
  9. Lines: 76
  10.  
  11. maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  12.  
  13. >    OO database: don't know.
  14.  
  15. You have an arbitrary object.  It needs to be stored.  If your database
  16. has a sensible interface then its references should automatically be
  17. resolved to the right types and stored.  When you load an object from
  18. the database you need to find its complete inheritence tree and load
  19. it correctly, building the vtables, etc.  I don't know how to do this
  20. without run time type identification.
  21.  
  22. >    Comms package: not sure.
  23.  
  24. If it is exchanging objects, then the same arguments apply as for
  25. an OO database.
  26.  
  27. >>
  28. >>Think of stream I/O.  Don't you feel stupid coding an << operator for
  29. >>each type you want to be able to print?  
  30.  
  31. >    No. I never use stream IO. I hate it. It is not well
  32. >designed. Too complicated. Tries to do everything at once.
  33. >And in Windows, there is no console anyhow.
  34. >Personally, I use Gets or like for input, and puts for output in
  35. >textfiles.
  36.  
  37. >>An intelligent stream facility
  38. >>would be able to print any object with a sensible default format which
  39. >>could optionally include the name and type of each field.  Try to code
  40. >>this without run time information.  Since the I/O stream is coded first
  41. >>and can impose no restrictions on user objects I do not know of any way
  42. >>to solve this without adding my own precompiler.
  43.  
  44. >    I dont understand. I define string->stream. Once.
  45.  
  46. >    Now all my objects have a 'print' command that outputs
  47. >a string. I can print anything. No run-time type info required.
  48. >Just a virtual function. (And the output can be used in the
  49. >string package to do other things---much better than stream IO.)
  50.  
  51. >    Even better, use a mixin:
  52.  
  53. >    class printable { public: virtual string print()const=0; }
  54.  
  55. >    class anyclass : public virtual printable, ... {
  56.  
  57. Anybody who follows *your* conventions can then use *your* objects
  58. in this way.  I assume that you define not only string->stream,
  59. but also a stream conversion for every single base type.  Then you
  60. need to find out how many members you have in each class and how to
  61. access them.....
  62.  
  63. Unfortunately, everybody else has *their* conventions.  How many
  64. class libraries implement an Object type?  What if they are not
  65. compatible?  Now do you expect the class libraries you buy to
  66. follow *your* conventions?  If not, maybe the language specification
  67. should make this information available to everybody in a uniform
  68. way.
  69.  
  70.  
  71. Jonathan
  72.  
  73. ===========================================================================
  74.  
  75. Jonathan Robie        jrobie@netmbx.UUCP
  76. Arnold-Zweig-Str. 44    jrobie@netmbx.in-berlin.de
  77. O-1100 Berlin        
  78. Deutschland        Phone:  +37 (2) 472 04 19  (Home, East Berlin)
  79.                 +49 (30) 342 30 66 (Work, West Berlin)
  80.  
  81.  
  82. -- 
  83. Jonathan
  84.  
  85. ===========================================================================
  86.  
  87.