From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,4873305131bf4d94 X-Google-Attributes: gid1014db,public X-Google-Thread: 109fba,4873305131bf4d94 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,4873305131bf4d94 X-Google-Attributes: gid103376,public From: Alan E & Carmel J Brain Subject: Re: Porting (was ADA and Pascal etc) Date: 1997/11/01 Message-ID: <345BBECE.6BE0@dynamite.com.au>#1/1 X-Deja-AN: 286335226 References: <34557f2b.1934172@news.mindspring.com> <63bhta$g2e@bgtnsc03.worldnet.att.net> <345AB871.413A@dynamite.com.au> <63d3sm$ap7$3@darla.visi.com> Organization: @home Reply-To: aebrain@dynamite.com.au Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ Date: 1997-11-01T00:00:00+00:00 List-Id: Matt Austern wrote: > The draft C++ standard is quite specific, and not at all random. If > you write > for (int i = 0; i < N; +i) { > // loop body > } > then the scope of the variable i does not extend past the end of the > loop. The same holds for while loops and if statements. > I don't know whether Ada has any constructs where an analogous issue > arises. Both Ada-83 and Ada-95 allow the following: procedure ExampleProcedure is type SomeDiscreteType is new INTEGER range -14..45; type SomeOtherDiscreteType is ( Red,Yellow, Green, Blue); begin for I in SomeDiscreteType loop -- do something -- within this scope, I is of SomeDiscreteType, between -14 and 45 end loop; for I in SomeOtherDiscreteType loop -- do something else -- within this loop, I is of SomeOtherDiscreteType, Red etc end loop; end ExampleProcedure; Thus the scope of I is defined only within the loop. -- aebrain@dynamite.com.au <> <> How doth the little Crocodile | Alan & Carmel Brain| xxxxx Improve his shining tail? | Canberra Australia | xxxxxHxHxxxxxx _MMMMMMMMM_MMMMMMMMM abrain@cs.adfa.oz.au o OO*O^^^^O*OO o oo oo oo oo By pulling MAERKLIN Wagons, in 1/220 Scale