Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!lll-winken!decwrl!shelby!csli!poser From: poser@csli.Stanford.EDU (Bill Poser) Newsgroups: comp.lang.misc Subject: Re: Use of scope Summary: Narrow scope of for loop index is not clearly a feature. Message-ID: <12200@csli.Stanford.EDU> Date: 11 Feb 90 04:26:19 GMT References: <14226@lambda.UUCP> <760@enea.se> Sender: poser@csli.Stanford.EDU (Bill Poser) Organization: Center for the Study of Language and Information, Stanford U. Lines: 12 In article <760@enea.se> sommar@enea.se (Erland Sommarskog) writes: >Ada is really nice here. You declare the index variable with the FOR >loop, so that you can only refer to it within the loop. This is true of some other languages as well, but I'm not sure if it is a feature. When writing C I find that it is often very convenient to have access to the loop index. Sometimes testing it is an easy way to detect an unusual loop exit that requires special handling, and sometimes I want to process part of an array in the first loop, exit at a point that may be data dependent, then resume processing in a second loop that needs to know where to start. (And often a for loop is more convenient than a while loop.)