home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!mcsun!news.funet.fi!funic!nntp.hut.fi!nntp!jkorpela
- From: jkorpela@snakemail.hut.fi (Jukka Korpela)
- Subject: Re: Variant records
- In-Reply-To: dmurdoch@mast.queensu.ca's message of Sat, 23 Jan 1993 20:57:06 GMT
- Message-ID: <JKORPELA.93Jan25124537@lk-hp-10.hut.fi>
- Sender: usenet@nntp.hut.fi (Usenet pseudouser id)
- Nntp-Posting-Host: lk-hp-10.hut.fi
- Organization: Helsinki University of Technology, Finland
- References: <1993Jan23.140159.10176@wariat.org> <dmurdoch.334.727822626@mast.queensu.ca>
- Date: 25 Jan 93 10:45:37 GMT
- Lines: 31
-
- In article <dmurdoch.334.727822626@mast.queensu.ca> dmurdoch@mast.queensu.ca (Duncan Murdoch) writes:
-
- I'm not sure if standard Pascal
- forces you to declare a tag field (e.g. "case Choice:Boolean of ..") and
- then makes sure that your references are consistent with the value there,
- but TP certainly doesn't.
-
- I'm sure it doesn't. In the original Wirth's Pascal and in standard Pascal
- and, as far as I know, in all Pascal dialects (if they support variant
- records at all, of course), a variant can be declared with or without
- the tag field identifier.
-
- Even if a variant record is declared with a tag field identifier, there is
- (in general) no guarantee that inconsistent references to fields will be
- trapped. An implementation may or may not provide runtime checks for this,
- just as it may or may not perform runtime checks for array indexes
- (although it is in practise more common to provide index checks than
- variant access checks). The situation may dependent on the settings of
- compile-time switches. The standard only requires that the behaviour of
- an implementation in this respect be documented (e.g. by stating that
- variant access errors are not detected).
-
- Moreover, if a variant record is declared _without_ a tag field identifier,
- an implementation may perform runtime checks against inconsistent references
- (probably by inserting an invisible tag field and implicitly assigning
- suitable values to it when the variant is changed). This, of course,
- is most a theoretical remark.
-
- * Jukka "Yucca" Korpela, Manager of User Support
- * Helsinki University of Technology (HUT) Computing Centre, Finland
- * Internet mail address: Jukka.Korpela@hut.fi
-