Tuples
Introduce tuples and tuple-types. A tuple-type is a generic type with one type per element in the tuple (e.g. the tuple (1, 'peter', 1.5)
might have the type Tuple<xsd:integer, xsd:string, xsd:decimal>
).
It would then make sense to define a list as a generalized type of tuple which only consists of elements of the same type. E.g. the type Tuple<xsd:integer, xsd:integer, xsd:integer>
would be a subtype of NEList<xsd:integer>
(both being a valid type for the term (1, 2, 3)
). We would thus reuse the list-syntax for tuples.
The introduction of tuples has several benefits:
-
Tuples can be used to describe objects, e.g. information about the name, age and occupation of a person can be gathered into a tuple
('Peter', 32, 'Student')
. We can then naturally form lists of such persons, e.g.(('Peter', 32, 'Student'), ('Mary', 34, 'Professor'))
. Previously this information would have to be split across several lists. -
FROG-functions can be defined over single elements that are tuples.
-
We can replace argument lists with tuples, and reduce the number of different constructs.
However, the introduction of tuples may also blur the distinction between statements and values, as a tuple may be viewed as a statement. Therefore, we should have a clear description of how and when tuples should be used.