From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9d0b383ee17c13af X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: One type for all Date: 1999/07/19 Message-ID: #1/1 X-Deja-AN: 502751069 Sender: bobduff@world.std.com (Robert A Duff) References: <3783E0D2.5D74243@boeing.com> <3786741C.E73F1124@hso.link.com> <7mdobd$fu$1@nnrp1.deja.com> <1999Jul12.193436.1@eisner> <7mqueq$k7e$1@nnrp1.deja.com> <7mttci$edv$1@nnrp1.deja.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1999-07-19T00:00:00+00:00 List-Id: Robert Dewar writes: > In article , > Keith Thompson wrote: > > ] Two types are said to be _compatible_ if any of the > > following four conditions is true. > > ] > > ] (a) They are the same type. > > ] (b) One is a subrange of the other, or both are > subranges of the > > ] same host type. > > ] (c) Both are set types, their base types are compatible, > and either > > ] both are packed or neither is packed. > > ] (d) Both are string types with the same number of > components. > > So thanks, it is indeed the case that Pascal does NOT have > structural type equivalence, which is what I remembered (any > other conclusion would have been a big surprise!) > > OK, so those are VERY restictive cases. (a) and (b) correspond > closely to the Ada rules, and (c) and (d) are very special > cases, similar in spirit indeed to the restricted Ada rules. In the case of scalars, the rules are not at all like Ada -- in Pascal, all integers may be freely intermixed (except in certain special cases like passing a component of a packed array as a VAR parameter). That is, there is nothing in Pascal equivalent to Ada's "type T is range 1..10;". Pascal only has the equivalent of "subtype S is Integer range 1..10;". For records, you're right -- Pascal uses by-name equivalence. I'm confused about pointers: I thought in: type T = ^Integer; var X: ^Integer; Y: ^Integer; X and Y could be freely assigned to each other, and passed to a parameter of type T. No? Also, note that Keith quoted from a book that came out after the Pascal standard. The original Jensen and Wirth book was rather unclear about type equivalence / compatibility / etc, and was roundly criticized at the time for it. And of course compiler writers did what they liked; the Pascal culture never developed a great deal of respect for standards and compatibility. (I even once used a Pascal compiler in which identifiers were case sensitive! The authors were C programmers, and they did it the way they thought it ought to be done.) - Bob -- Change robert to bob to get my real email address. Sorry.