Re: language design implications for variant records in a pascal-like language

Marco van de Voort <marcov@turtle.stack.nl>
Thu, 30 Dec 2010 17:14:41 +0000 (UTC)

          From comp.compilers

Related articles
[8 earlier articles]
Re: language design implications for variant records in a pascal-like noitalmost@cox.net (noitalmost) (2010-12-27)
Re: language design implications for variant records in a pascal-like cr88192@hotmail.com (BGB) (2010-12-27)
Re: language design implications for variant records in a pascal-like bobduff@shell01.TheWorld.com (Robert A Duff) (2010-12-28)
Re: language design implications for variant records in a pascal-like mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2010-12-29)
Re: language design implications for variant records in a pascal-like bc@freeuk.com (BartC) (2010-12-29)
Re: language design implications for variant records in a pascal-like DrDiettrich1@aol.com (Hans-Peter Diettrich) (2010-12-29)
Re: language design implications for variant records in a pascal-like marcov@turtle.stack.nl (Marco van de Voort) (2010-12-30)
Re: language design implications for variant records in a pascal-like gneuner2@comcast.net (George Neuner) (2010-12-30)
Re: language design implications for variant records in a pascal-like gneuner2@comcast.net (George Neuner) (2010-12-30)
Re: language design implications for variant records in a pascal-like gneuner2@comcast.net (George Neuner) (2010-12-30)
Re: language design implications for variant records in a pascal-like bobduff@shell01.TheWorld.com (Robert A Duff) (2010-12-31)
Re: language design implications for variant records in a pascal-like bobduff@shell01.TheWorld.com (Robert A Duff) (2010-12-31)
Re: language design implications for variant records in a pascal-like fw@deneb.enyo.de (Florian Weimer) (2010-12-31)
[41 later articles]
| List of all articles for this month |

From: Marco van de Voort <marcov@turtle.stack.nl>
Newsgroups: comp.compilers
Date: Thu, 30 Dec 2010 17:14:41 +0000 (UTC)
Organization: Stack Usenet News Service
References: 10-12-040 10-12-052 10-12-059
Keywords: design, storage
Posted-Date: 30 Dec 2010 23:01:30 EST

On 2010-12-29, Hans-Peter Diettrich <DrDiettrich1@aol.com> wrote:
>> I suppose I have an initial prejudice against variant records. They seem to me
>> to be a potential source of hard to find bugs (for the user programmer, I mean,
>> not the compiler designer). Am I wrong about this? Is it possible for the
>> compiler to always know which type is active in the variant, like say through
>> a hidden compiler-generated variable in the record?
>
> Most (Wirthian) variant records have an (optional) Tag field, but most
> implementations don't use it for the selection of one variant at
> runtime, most probably for compiler simplicity and performance issues.
> Ada may be more strict here (dunno).
>
> At least there must exist rules for what happens when the Tag field is
> changed. IMO the variant part should be cleared then - otherwise the Tag
> if of no real value for the compiler and coder.


In Delphi it doesn't make sense, but what I remember from reading ISO
Pascal sites (Scott Moore's, GPC) it made sense there, because in ISO Pascal
it is possible to dynamically allocate memory for different cases of the
variant record. And the allocated sizes of the cases could differ.


The tag field(s) were used to select the correct variant (and thus size)
using special new syntax like new(x,tag1[,tagn]);



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.