home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7765 < prev    next >
Encoding:
Text File  |  1992-12-31  |  2.1 KB  |  44 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!spool.mu.edu!torn!news.ccs.queensu.ca!slip203.telnet1.QueensU.CA!dmurdoch
  3. From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
  4. Subject: Re: TVision : BUG in my head or in TV?
  5. Message-ID: <dmurdoch.272.725808448@mast.queensu.ca>
  6. Lines: 31
  7. Sender: news@knot.ccs.queensu.ca (Netnews control)
  8. Organization: Queen's University
  9. References: <30DEC92.02825818.0033@music.mus.polymtl.ca> <dmurdoch.262.725736007@mast.queensu.ca> <C03wrE.MH@mentor.cc.purdue.edu>
  10. Distribution: comp.lang.pascal
  11. Date: Thu, 31 Dec 1992 13:27:29 GMT
  12.  
  13. In article <C03wrE.MH@mentor.cc.purdue.edu> pf@bilbo.bio.purdue.edu (Paul Furbacher) writes:
  14. > Duncan Murdoch wrote in response:
  15. >> This is a nasty surprise designed into TurboVision.  TObject.Init zeroes out 
  16. >> all fields of any descendant.  It's not done that way in OWL, and shouldn't 
  17. >> be in TurboVision, but Borland won't change it now because they're afraid of 
  18. >> breaking existing code.
  19. >
  20. >I'm sometimes slow to pick up on why some things are 
  21. >problems.  There are pieces of advice here and there in 
  22. >the manual that the fields are set to zero, and that one
  23. >should not set any field before calling the ancestor's 
  24. >Init() method.  As long as one follows that prescription,
  25. >no problems are encountered.  
  26.  
  27. Sure, I've got no argument with that.  The reason I think this is a bad 
  28. design is that it breaks the usual rule that an ancestor can only see and 
  29. modify the fields that are defined for the ancestor.  As far as I can 
  30. recall, this is the only place in all of TV where an ancestor messes around 
  31. with descendant fields; the design would be cleaner if there were *no* 
  32. places where that happened.
  33.  
  34. One place it causes bugs is if you port code to OWL or another object 
  35. hierarchy that respects the ownership of fields.  OWL won't initialize 
  36. everything to 0, so your code may break.  (Mine did.)
  37.  
  38. BTW, to answer the question (not yours) about how this is possible:  
  39. SizeOf(Self) will return the size of the actual type, not the declared type.
  40. So FillChar(Self,SizeOf(Self),0) will zero out all the fields.
  41.  
  42. Duncan Murdoch
  43. dmurdoch@mast.queensu.ca
  44.