home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / pascal / 7843 < prev    next >
Encoding:
Text File  |  1993-01-04  |  4.0 KB  |  86 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!usc!howland.reston.ans.net!paladin.american.edu!gatech!taco!csemail.cropsci.ncsu.edu!samodena
  3. From: samodena@csemail.cropsci.ncsu.edu (S. A. Modena)
  4. Subject: Re: TVision : BUG in my head or in TV?
  5. Message-ID: <1993Jan4.203255.2366@ncsu.edu>
  6. Sender: news@ncsu.edu (USENET News System)
  7. Organization: Crop Science Dept., NCSU, Raleigh, NC 27695-7620
  8. References: <30DEC92.02825818.0033@music.mus.polymtl.ca> <dmurdoch.262.725736007@mast.queensu.ca> <30DEC92.14039571.0035@music.mus.polymtl.ca>
  9. Date: Mon, 4 Jan 1993 20:32:55 GMT
  10. Lines: 74
  11.  
  12. In article <30DEC92.14039571.0035@music.mus.polymtl.ca> CT80@music.mus.polymtl.ca (Steph) writes:
  13. >In article <dmurdoch.262.725736007@mast.queensu.ca> dmurdoch@mast.queensu.ca (Duncan Murdoch) writes:
  14. >>In article <30DEC92.02825818.0033@music.mus.polymtl.ca> CT80@music.mus.polymtl.ca (Steph) writes:
  15. >>>What happens is this : I found out (after many bugs with this), that
  16. >>>EndOfStatic (my before-adding-spaces-to-AText-length) is set to 0
  17. >>>after the call to TStaticText.Init!  Why is this so?
  18. >>
  19. >>This is a nasty surprise designed into TurboVision.  TObject.Init zeroes out
  20. >>all fields of any descendant.  It's not done that way in OWL, and shouldn't
  21. >>be in TurboVision, but Borland won't change it now because they're afraid of
  22. >>breaking existing code.
  23. >>
  24. >>Duncan Murdoch
  25. >>dmurdoch@mast.queensu.ca
  26. >>.
  27. >>.
  28. >
  29. >Well, at least I'm not crazy!  Hmmm, how can TObject.Init zero out
  30. >fields of descendant fields?  How can it know what its descendant
  31. >fields will be?  Oh well.  Thanks a lot, I guess I'll have to build
  32. >around it then!
  33. >
  34. >Steph.
  35.  
  36. Well, the answer resides in looking at the OBJECTS.PAS unit code.
  37.  
  38. I'm paraphrasing now: 
  39.  
  40. INIT TObject portion of the new object.  Then get the quantity of
  41. bytes for the "rest" of the new object SizeOf(TNewObject)-SizeOf(TObject),
  42. Use FillChar() to put #$00 for the correct distance right *after* the
  43. end of TObject in memory.
  44.  
  45. This harkens back to a rather ANCIENT debate as to whether a program
  46. or operating system should PRE-initialize the memory image to ZEROs
  47. or leave whatever garbage values were in memory at the instance of
  48. "loading."   Bugs due to UNinitialized memory variables SET TO ZERO or
  49. NIL (for pointers) are easier to diagnose and are more CONSISTANT in
  50. behavior than are  UNinitialized memory variable with RANDOM garbage
  51. values that "work" sometimes and don't "work" other times.
  52.  
  53. NOTE: MASM and TASM have directives for allocating either memory INITIALIZED
  54. to $00 or to be left in garbage state.
  55.  
  56. Therefore, Borland made a design decision.  Contrary to Duncans assertion,
  57. it is not a "mistake."  It is a design decision.  Though I do not know
  58. the intimate details of Protected Mode programming and Windows programming,
  59. I do know that there is a significant difference from DOS programming
  60. and MEMORY MANAGEMENT.  Therefore, without first hearing a pro- or con-
  61. debate on the merits of memory zeroing--or not--in a particular situation,
  62. I'd hesitate to criticize TObject memory zeroing.
  63.  
  64. As far as Steph needing to learn to "build" around it (memory zeroing in
  65. DOS TV), I'd put forth that I use it to *advantage* and am quite glad
  66. it is done.  :^)
  67.  
  68. Of course, anyone who bought BP7 also got TV source code and therefore
  69. can easily comment out the couple of lines that do the memory
  70. zeroing...and find out whether your code generation life is happier and
  71. easier!  :^)
  72.  
  73. Steve
  74. ---
  75. +------------------------------------------------------------------+
  76. |     In person:  Steve Modena     AB4EL                           |
  77. |     On phone:   (919) 515-5328                                   |
  78. |     At e-mail:  nmodena@unity.ncsu.edu                           | 
  79. |                 samodena@csemail.cropsci.ncsu.edu                |
  80. |                 [ either email address is read each day ]        |
  81. |     By snail:   Crop Sci Dept, Box 7620, NCSU, Raleigh, NC 27695 |
  82. +------------------------------------------------------------------+
  83.          Lighten UP!  It's just a computer doing that to you.    (c)
  84. OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
  85.          
  86.