From: Robert A Duff <bobduff@world.std.com>
Subject: Re: One type for all
Date: 1999/07/19
Date: 1999-07-19T00:00:00+00:00 [thread overview]
Message-ID: <wcciu7gej7r.fsf@world.std.com> (raw)
In-Reply-To: 7mttci$edv$1@nnrp1.deja.com
Robert Dewar <robert_dewar@my-deja.com> writes:
> In article <yeciu7hg0oo.fsf@king.cts.com>,
> Keith Thompson <kst@cts.com> 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.
next prev parent reply other threads:[~1999-07-19 0:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3783E0D2.5D74243@boeing.com>
1999-07-08 0:00 ` One type for all czgrr
1999-07-09 0:00 ` Samuel T. Harris
1999-07-10 0:00 ` Ehud Lamm
1999-07-12 0:00 ` Samuel T. Harris
1999-07-12 0:00 ` Robert Dewar
1999-07-12 0:00 ` Samuel T. Harris
1999-07-12 0:00 ` Larry Kilgallen
1999-07-17 0:00 ` Robert Dewar
1999-07-18 0:00 ` Keith Thompson
1999-07-19 0:00 ` Robert Dewar
1999-07-18 0:00 ` Keith Thompson
1999-07-19 0:00 ` Robert A Duff [this message]
1999-07-20 0:00 ` Robert Dewar
1999-07-19 0:00 ` Tucker Taft
1999-07-20 0:00 ` Bill Findlay
1999-07-18 0:00 ` Samuel T. Harris
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox