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

  1. Xref: sparky comp.lang.c++:11816 comp.std.c++:998
  2. Newsgroups: comp.lang.c++,comp.std.c++
  3. Path: sparky!uunet!sybus.sybus.com!myrddin!tct!chip
  4. From: chip@tct.com (Chip Salzenberg)
  5. Subject: Re: run-time type checking, freezing, and thawing
  6. Message-ID: <2A78457A.561C@tct.com>
  7. Date: Thu, 30 Jul 1992 19:39:37 GMT
  8. References: <BryL9q.K5I@watcgl.waterloo.edu> <2A75837D.8B10@tct.com> <2TJ53BQ@netmbx.netmbx.de>
  9. Organization: TC Telemanagement, Clearwater, FL
  10. Lines: 40
  11.  
  12. According to jrobie@netmbx.netmbx.de (Jonathan Robie):
  13. >chip@tct.com (Chip Salzenberg) writes:
  14. >>But once you've frozen a C++ object into a dead array of bytes, it's
  15. >>no longer a C++ object, so the C++ type system is no longer operative.
  16. >
  17. >RTTI is needed to properly freeze a C++ object into a "dead array of
  18. >bytes" ...
  19.  
  20. Virtual functions are sufficient for freezing.
  21.  
  22. >... and to turn a "dead array of bytes" into a C++ object.
  23.  
  24. RTTI is of zero relevance to thawing.  It doesn't make this code work:
  25.  
  26.     int i;
  27.     char *buf;
  28.     read(fd, &i, sizeof(int));
  29.     buf = new char[i];
  30.     read(fd, buf, i);
  31.     XXX *foo = thaw_arbitrary_object(buf, i);
  32.  
  33. For one thing, what is the XXX type? -- since there is no universal
  34. base class for C++ objects, there is no valid candidate.  For another
  35. thing, how can thaw_arbitrary_object know the complete set of classes
  36. I might have written to the given file? -- it can't.
  37.  
  38. >It is also needed to follow references among objects in RAM.
  39.  
  40. I can do that without RTTI right now.
  41.  
  42. >RTTI and persistence are related enough that all of the major C++
  43. >database systems use precompilers to get at it.
  44.  
  45. The mere fact that RTTI can be used for freezing proves neither (1)
  46. that it is necessary for freezing, nor (2) that it is useful -- much
  47. less necessary -- for thawing.
  48. -- 
  49. Chip Salzenberg at Teltronics/TCT  <chip@tct.com>, <73717.366@compuserve.com>
  50.    "Do Rush place weird subliminal backmasked messages in their songs to
  51.  compel unwilling geeks to commit evil .sig atrocities?"  -- Dean Engelhardt
  52.