[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In type definitions:
record type identifier = record field identifier: type definition ... field identifier: type definition end; |
or, with a variant part,
record type identifier = record field identifier: type definition ... field identifier: type definition case bar: variant type of selector: (field declarations); selector: (field declarations); ... end; |
or, without a variant selector field,
record type identifier = record field identifier: type definition ... field identifier: type definition case variant type of selector: (field declarations); selector: (field declarations); ... end; |
The reserved word `record' starts the definition of a new record type.
Records can be `packed' to save memory usage at the expense of speed.
The variants of a variant record may -- but are not required to -- share one location in memory (inside the record).
Sometimes variant records are used to emulate type casting in ISO-7185 Pascal. This is in fact a violation of the standard and not portable. There is intentionally no possibility in ISO-7185 Pascal to emulate type casting.
The reserved word `record' and record types are defined in ISO-7185 Pascal.
According to ISO Pascal, the variant type must be an identifier. GNU Pascal, like UCSD and Borland Pascal, also allows a subrange here.
Subranges in the variant fields, e.g. case Integer of 2 .. 5
,
are a GPC extension.
program RecordDemo; |
section 9.188 packed, section 8.1.7.4 case Statement
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |