Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site decwrl.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!joel From: joel@decwrl.UUCP (Joel McCormack) Newsgroups: net.lang.mod2 Subject: Re: FOR i := 1 TO 0 Message-ID: <360@decwrl.UUCP> Date: Mon, 28-Jan-85 18:35:38 EST Article-I.D.: decwrl.360 Posted: Mon Jan 28 18:35:38 1985 Date-Received: Wed, 30-Jan-85 08:26:25 EST Organization: DEC Western Software Lab, Los Altos, CA Lines: 25 Wirth is not particularly clear, but no, FOR i := 1 TO 0 does not execute the loop body. He did not DEFINE the FOR loop in terms of REPEAT, but showed how (what would be) a very common case of REPEAT is more appropriately expressed with a FOR loop. The examples for minimum and sort would not work for very small arrays if the FOR loop body always executed. The report in the back of the book is somewhat clearer, when it says that "A+nC is the last term not exceeding B". This implies to me that if A > B, the loop body is not executed. Incidentally, it used to be that VAR i: 1..10; made it illegal to do FOR i := 1 TO 0, because of the limits were supposed to be assignment compatible with the control variable. This has been relaxed to merely compatible. This change should be in the 3rd edition of the book. -- - Joel McCormack {ihnp4|decvax|ucbvax|allegra|sequent|utcsrgv}!decwrl!joel