gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] variant records and repeated names


From: Gaius Mulley
Subject: Re: [Gm2] variant records and repeated names
Date: Wed, 16 Dec 2009 16:26:07 +0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Martin Kalbfuß <address@hidden> writes:

> A small example:
>
> TYPE testType = (variant1, variant2, variant3);
>
>      test = RECORD;
>         shared : INTEGER;
>       CASE type : testType OF
>         variant1:
>            a : INTEGER;
>            b : INTEGER |
>         variant2:
>            b : INTEGER;
>            c : INTEGER |
>         variant3:
>            a : INTEGER;
>            c : INTEGER;
>         END;
>      END;
>
> compiler reports an error because the names a, b and c are present
> multiple times inside the record. But they are in different variants. So
> I assume this should be OK.

Hi Martin,

I don't think this is allowed, all the examples I've seen in the
PIM[234] and ISO standard use differing field names.  In PIM Wirth
says that Variant records are dangerous as you can alter the wrong
variant - so my understanding is that all fields are accessible.
Implying that the field names must be distinct.

regards,
Gaius




reply via email to

[Prev in Thread] Current Thread [Next in Thread]