🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #191

Who Has The Right Type?

#191
From: J7M7000
Date: Thu, 27 Jul 1989 00:33
50 lines
2808 bytes
    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
Technical Details
Message-ID: <ID9993.D890726.T213341.J7M7@UNB.CA>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!att!ucbvax!UNB.CA!J7M7

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!att!ucbvax!UNB.CA!J7M7
From: J7M7@UNB.CA (J7M7000)
Newsgroups: comp.lang.modula2
Subject: Who Has The Right Type?
Message-ID: <ID9993.D890726.T213341.J7M7@UNB.CA>
Date: 27 Jul 89 00:33:41 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: Modula2 List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu>
Organization: The Internet
Lines: 50