Modula-2 input/output procedure using polymorphic and open-ended data type extensions (abstract only)
Thomas R. Leap · 1987
The Modula-2 language does not include special statements or standard procedures for handling input and output as in other languages. By extending Modula-2 to include a polymorphic structure, called a variant data type(1), and allowing open-ended structures, it is possible to define procedures that have a function and syntax similar to the I/O statements and procedures of other languages. The variant data type consists of a tag field followed by several options, each containing only one field (unless a structure definition is used). In an assignment operation, the tag field is implicitly adjusted to indicate the data type of the item assigned to the variant typed object. A variable of variant type is considered to be assignment compatible with another value if either both are exactly the same type or if one of the options of the variant type is compatible with the value being assigned to it. For open-ended data structures, the concept of an open array is generalized to allow stack and dynamically allocated open arrays to be defined which allows them to be sized at run-time. The open array concept is extended to procedures allowing them to have open parameter lists which can accept a variable number of arguments when called. These concepts can further be used to eliminate the need for several other standard procedures in the language definition.