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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8b8f4ad9d302b143 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-30 09:01:54 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.litech.org!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!wanadoo.fr!proxad.net!proxad.net!news-hub.cableinet.net!blueyonder!internal-news-hub.cableinet.net!news-binary.blueyonder.co.uk.POSTED!53ab2750!not-for-mail User-Agent: Microsoft-Entourage/10.1.1.2418 Subject: Re: ada loops From: Bill Findlay Newsgroups: comp.lang.ada Message-ID: References: Mime-version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Date: Fri, 30 May 2003 17:00:53 +0100 NNTP-Posting-Host: 80.195.75.181 X-Complaints-To: abuse@blueyonder.co.uk X-Trace: news-binary.blueyonder.co.uk 1054310513 80.195.75.181 (Fri, 30 May 2003 16:01:53 GMT) NNTP-Posting-Date: Fri, 30 May 2003 16:01:53 GMT Organization: blueyonder (post doesn't reflect views of blueyonder) Xref: archiver1.google.com comp.lang.ada:38110 Date: 2003-05-30T17:00:53+01:00 List-Id: On 30/5/03 16:44, in article d3ba4d4c.0305300744.520de992@posting.google.com, "Roman V. Isaev" wrote: > I've got bitten by this (code was translated from pascal by p2ada, so > please don't bash using goto): > > for Ijk in 1 .. 40 loop > Sss:=Fnmis-Si(Ijk); > if Sss<0.0 then > goto Label_1; > end if; > end loop; -- IJK > <> null; > > Before the loop Ijk is 0, after the loop Ijk is still 0. Huh? Why? I > replaced Ijk with temp variable and put Ijk := temp before goto and > it solved the problem, but why we can't have final value when we break > out of the loop? What's the logic behind this language behaviour? P2Ada has mis-translated your Pascal program. In Pascal, the Ijk variable was used and updated by the Pascal for loop. In Ada, loop-controlled "variables" are actually local constants of the loop body. Thus your (mis-)translated code has TWO objects called Ijk: the one appearing outside the loop, and declared by you; and the one appearing inside the loop and declared by the loop command. -- Bill-Findlay chez blue-yonder.co.uk ("-" => "")