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