Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!psuvax1!schwartz From: schwartz@cs.psu.edu (Scott Schwartz) Newsgroups: comp.lang.misc Subject: Re: Use of scope Message-ID: Date: 11 Feb 90 07:25:31 GMT References: <14226@lambda.UUCP> <760@enea.se> Organization: Penn State University Computer Science Lines: 15 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. > >The nightmare is standard Pascal where you must declare the variables >before internal functions and procedures. My favorite is "Stroustrup's revenge": in C++ you can write for (int i = 0; ... ; ... ) { ... } but the variable has scope outside the loop. -- Scott Schwartz schwartz@cs.psu.edu "the same idea is applied today in the use of slide rules." -- Don Knuth