|
![]() |
||||||||||||||
Record TutorialRecord Type CheckingIf R1 is a record type: Record[<el1>:<type1>, <el2>:<type2>, ..., <eln>:<typen>], and R2 is a record type with some of R1 elements, and with no other elements, then we say that R1 is subtype of R2. In Wafl, if a function is defined for argument of a record type, then it is applicable to subtypes of that type, too. That same rule is used with selectors. If a function or any other context allows a record type, or its subtype, the type is usually annotated as: Record[name:type]['2], where '2 represents an optional record extension. In the following example, a function sums elements a and b of a given record. The function is applicable to subtypes, too. It is only required that the argument is a record with elements a and b of a same value type.
|
|
||||||||||||||
© 2006 Saša Malkov | |||||||||||||||