[fpc-pascal] variant part of a record

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Sep 20 14:28:08 CEST 2006

On 20 sep 2006, at 14:19, Пётр Косаревский wrote:

>> It's on my todo list to implement such checks (when enabled by a
>> command line switch, of course). It's not that easy as it may look at
>> first sight though.
>> Jonas
> It's great news!
> However, in the case of such checks, ability to explicitly place  
> tag variable in the record structure or to place something after  
> the variant part (assuming it has the size of the biggest branch)  
> would be great too.

To place something after the variant part, simply use nested records:

   tr1 = record
     a, b: longint;
     case d: byte of
       1: (s: string);
       2: (c: char);

   tr2 = record
     l: longint;
     r: tr1;
     l2: longint;

Hacking the parser to support this directly is a waste of time imho  
(not to mention that it would break the code's compatibility with  
every other Pascal compiler out there afaik).

> Implementing "else" seems very logical (does modula-2 perform this  
> checks?).

That would be more easily doable than the above, though again it  
would break compatibility with other Pascal compilers afaik.


More information about the fpc-pascal mailing list