Path: utzoo!attcan!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!tektronix!percival!qiclab!m2xenix!randy From: randy@m2xenix.UUCP (Randy Bush) Newsgroups: comp.lang.pascal Subject: Re: Control variables in FOR loops Message-ID: <169@m2xenix.UUCP> Date: 18 Dec 88 00:00:45 GMT References: <1439@csuna.UUCP> Reply-To: randy@m2xenix.UUCP (Randy Bush) Organization: Oregon Software, Portland Oregon US Lines: 33 Conjecture and testing aginst particular implementations (other than ours, of course:-) may be amusing, but have little to do with the definition of the language. I recommend the standard itself, accompanied by "Standard Pascal User Reference Manual" by Doug Cooper. The control variable of a FOR loop may not be 'relatively global'. I.e. it must be declared in the variable declaration part of the program, procedure, or function in which it is used. The interesting, and unexpected, restriction is that it may not be threatened by use within an enclosed procedure/function. The following is not legal: PROGRAM foo; (* excuse keyword capitalization. i am a modulan *) PROCEDURE fee; VAR i : INTEGER; PROCEDURE bar; BEGIN i := 42 (* this assignment threatens the control variable *) END; BEGIN (* fee *) FOR i := 0 TO 42 DO END; BEGIN (* foo *) END. A correct Pascal compiler must detect the above error. Yes, that test is in the Pascal Validation Suite. -- { mcvax!uunet!oresoft, tektronix!percival!qiclab } !m2xenix!randy Randy Bush