Maurice Lombardi wrote:
This was not sent to the list, but it was intended to ... I realized while reading the last message of Franck on the subject
-------- Message d'origine -------- Objet: Re: Bug? Identifier Integer sometimes fails Date: Fri, 20 Dec 2002 19:23:13 +0100 De: Maurice Lombardi Maurice.Lombardi@ujf-grenoble.fr A: cbfalconer@worldnet.att.net Références: 3E018128.27241.258BB6@localhost 3E01B718.1040507@ujf-grenoble.fr 3E01CF33.32301.1072E43@localhost 200212192052.VAA26157@goedel.fjf.gnu.de 3E032F09.9080500@ujf-grenoble.fr 3E0338E3.E2F21BFE@yahoo.com
CBFalconer a écrit:
Maurice Lombardi wrote:
... snip ...
The only problem I see is the restriction by pascal to only one case variant in a record. I suppose C has no restriction on the number of union inside a struct. This can be solved only by some extra types.
Is this really so? There is the requirement that fixed components precede variant components, but AFAIK there is no limitation on nesting.
Isn't the following legal?
TYPE
... snip fouled declaration ...
The names have to be distinct, and the compiler must be able to infer a fixed offset for any component name.
This does not work. But nested record are possible to solve this problem. In fact the proper equivalent of
Herewith a corrected and compilable version of that RECORD
CONST maxindex = 5;
TYPE fubar = real; bar = 1 .. maxindex; foo = ARRAY[bar] OF integer;
x = RECORD a : integer; CASE b : char OF 'B': ( b1 : fubar); 'C': ( CASE c1 : char OF 'c': (c2 : foo) ); (* end CASE c1 *) 'D': ( CASE d1 : char OF 'd': (d2 : bar); ); (* end CASE d1 *) (* end CASE b *) (* e : integer; WOULD BE ILLEGAL here *) END; (* RECORD x *)
It compiles with both PascalP and gpc --standard-pascal.