home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!sdd.hp.com!swrinde!cs.utexas.edu!torn!news.ccs.queensu.ca!mast.queensu.ca!dmurdoch
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Subject: Re: Pointer problems...
- Message-ID: <dmurdoch.301.722547756@mast.queensu.ca>
- Lines: 36
- Sender: news@knot.ccs.queensu.ca (Netnews control)
- Organization: Queen's University
- References: <1992Nov21.181025.18275@jupiter.sun.csd.unb.ca> <KIM.92Nov23091623@kim.Software.Mitel.COM>
- Date: Mon, 23 Nov 1992 19:42:36 GMT
-
- In article <KIM.92Nov23091623@kim.Software.Mitel.COM> kim@Software.Mitel.COM (Kim Letkeman) writes:
- >| var
- >| P1 : ^Byte;
- >| P2 : ^Byte;
- >| begin
- >| new(p1);
- >| p2:=p1; { Why is this illegal }
- >
- >Compiles fine for me.
-
- Which compiler are you using? I get compile errors in both TP 6.0 and BP
- 7.0. The problem is that P1 and P2 are being declared to be two different
- types of pointers, and different types of pointers are generally not
- assignment compatible.
-
- The fact that these two types of pointers are constructed in the same way is
- the confusing part. This particular feature of Pascal is designed to catch
- errors like the following:
-
- type
- season = 1..4;
- quarter= 1..4;
- var
- summer : season;
- first : quarter;
- begin
- first := summer;
- end.
-
- The assignment here is disallowed, because even though both season and
- quarter are constructed as the same subrange of the integers, they aren't
- the same type. In the example above, the types are never named, but the
- effect is the same.
-
- Duncan Murdoch
- dmurdoch@mast.queensu.ca
-