Path: utzoo!attcan!uunet!samsung!usc!snorkelwacker!bu.edu!xylogics!transfer!crackers!m2c!umvlsi!dime!dime.cs.umass.edu!moss From: moss@cs.umass.edu (Eliot Moss) Newsgroups: comp.lang.modula2 Subject: Re: FOR loops Message-ID: Date: 5 Jul 90 13:08:26 GMT References: Sender: news@dime.cs.umass.edu Reply-To: moss@cs.umass.edu Organization: Dept of Comp and Info Sci, Univ of Mass (Amherst) Lines: 17 In-reply-to: ROSS@UCF1VM.BITNET's message of 3 Jul 90 20:54:15 GMT Just for fun, I note that Modula-3 (and Ada for that matter) make the index variable of a FOR loop a *new* variable, defined only between the DO and END. This makes it even more clear that the optimization can be performed and that the value after the cannot be depended upon. If you need the last value after the loop, you must explicitly assign it to a variable defined in the broader scope. This seems to me to be the best way to design a looping construct; CLU's iterators generalize what you can loop over, but the index variable's scope is as for Modula-3 and Ada. CLU's usage predates those other languages, but I am not sure where this style of definition first arose. -- J. Eliot B. Moss, Assistant Professor Department of Computer and Information Science Lederle Graduate Research Center University of Massachusetts Amherst, MA 01003 (413) 545-4206; Moss@cs.umass.edu