Topic: casting a variable to a different type
Topic: data record
Topic: dynamic type checking
Topic: enumerated data types
Topic: non-exclusive data type
Topic: ref_any or Object data type
Topic: restricted and extended types
Topic: union data type
| |
Summary
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
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
QuoteRef: wirtN1_1971 ;;37 record variants by tag field eg alloc ( p[tag])
| Subtopic: unchecked tag field
Quote: Pascal does not check when assigning values to record variants
| Subtopic: tag modification
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
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)
|