J7M7@UNB.CA (J7M7000) (07/27/89)
As I have not been reading my mail all week (I awoke this morning to some 113 pieces of mail) so this posting may be appear a little "behind the times." In reference to the discussion on types I would like to present to you from Ravi Sethi's "PROGRAMMING LANGUAGES: Concepts and Constructions" --or as it is better known 'The Teddy Bear Book'-- the following paraphrase and excerpts discussing the topic. According to Sethi, "Modula-2 defines two types to be compatible if C1. they are the same name, or C2. they are s and t, and s=t is a type declaration, or C3. one is a subrange of the other, or C4. both are subranges of the same base type.(**) Furthermore, two types are assignment compatible if they are compatible, or if one is cardinal or a subrange of cardinal and the other is integer or a subrange of integer. (**)" (**) --although not explicitly stated, the author demonstrates the assumption that such subranges are required to overlap. This 'double'-compatible definition can lead to variations in interpretation, which is displayed in the two different compilers we available to me. Examining the following declarations x,y : integer; z : integer; c : cardinal; we find that x and y have the same type because they are declared toget- her, but z does not; type c is obviously different. However, all three are assignment compatable (NOTE that any assignments from an object of types x, y, and z to an object of type c must fall in the positive integer range; therefore subranges of integer types starting at (0)+ are assignment compatible with cardinal types. This definition leaves much more ambiguity than is normally desired in a language (C being left unscathed). It is a "Half-committment to both structural type equivalence and name equivalence (as found in the 'Jolly Green Giant' --Ada). As mentioned before I have one compiler which "conforms" (thus far) to this deinition and one which does not (a public domain type job that appears to be written by a C die-hard with ample time on his hands. Any further comments (or corrections) may be directed to me <j7m7@UNB.CA> or posted on the board. I'll summarise those that I receive personally and post the result to the board. Roy Nicholl