Topic: variant data types

topics > computer science > data > data type > Group: derived data types

casting a variable to a different type
data record
dynamic type checking
enumerated data types
non-exclusive data type
ref_any or Object data type
restricted and extended types
union data type


Variant types are union types which share most of their components. For instance employee records may have male and female variants. Variant fields are identified by a tag component which can be case discriminated. The tag component is an enumerated type. In use, variants are usually fixed once a variable is assigned. In Pascal, a major weakness is uncontrolled assignment to variant fields instead of dynamic type checking or required variant discrimination. (cbb 5/80)
Subtopic: case type and variants up

Quote: for Euclid case types, either a case for every value or an otherwise clause [»barnDT3_1978]
Quote: Euclid allows assignment to a variant only within a discriminating case [»veneT3_1978]

Subtopic: tag field up

QuoteRef: wirtN1_1971 ;;37 record variants by tag field eg alloc ( p[tag])

Subtopic: unchecked tag field up

Quote: Pascal does not check when assigning values to record variants

Subtopic: tag modification up

Quote: Pascal errors caused by changing the tag of a variant record without initializes related fields
Quote: Ada requires a new record value if the discriminant or tag of a variant record is changed [»maclBJ_1987]
QuoteRef: gescCM8_1977 ;;552 "It seems that we hardly ever change the variant of a record once it has been initialized

Related Topics up

Topic: casting a variable to a different type (7 items)
Topic: data record (57 items)
Topic: dynamic type checking (43 items)
Topic: enumerated data types (17 items)
Topic: non-exclusive data type (16 items)
Topic: ref_any or Object data type (9 items)
Topic: restricted and extended types (35 items)
Topic: union data type
(12 items)

Updated barberCB 3/05
Copyright © 2002-2008 by C. Bradford Barber. All rights reserved.
Thesa is a trademark of C. Bradford Barber.