home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!usc!cs.utexas.edu!torn!news.ccs.queensu.ca!slip202.telnet1.QueensU.CA!dmurdoch
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Subject: Re: Why doesn't this cause an error?
- Message-ID: <dmurdoch.277.726007849@mast.queensu.ca>
- Lines: 35
- Sender: news@knot.ccs.queensu.ca (Netnews control)
- Organization: Queen's University
- References: <34851@adm.brl.mil>
- Date: Sat, 2 Jan 1993 20:50:50 GMT
-
- In article <34851@adm.brl.mil> stone@hilbert.math.grin.edu (John David Stone) writes:
- > Because the Pascal standard specifies that
- >
- > for v := e1 to e2 do body
- >
- >shall be equivalent to
- >
- > begin
- > temp1 := e1;
- > temp2 := e2;
- > if temp1 <= temp2 then begin
- > v := temp1;
- > body;
- > while v <> temp2 do begin
- > v := succ (v);
- > body
- > end
- > end
- > end
- >
- >where temp1 and temp2 are otherwise unused identifiers of the same type as
- >v (or, if v is a subrange type, of the host type of v's type), with the
- >restriction that no assignments to v are permitted within body.
-
- Here's another difference between Turbo Pascal and the standard: TP
- implements the for as if temp1 and temp2 are of exactly the same type as v.
- For example, if v is of type 1..10, then the standard won't complain about
-
- for v:=1 to 0 do...
-
- but TP will give a range check error, because 0 can't be assigned to the
- 1..10 subrange.
-
- Duncan Murdoch
- dmurdoch@mast.queensu.ca
-