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,6a0391eb7e0327d5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-09 16:13:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed1.swip.net!swipnet!nntpserver.swip.net!not-for-mail From: Leif Holmgren X-Mailer: Mozilla 4.75 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada style of passing 'in' parameters considered dangerous? References: <86isvuzabx.fsf@hoastest1-8c.hoasnet.inet.fi> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 213.101.93.117 X-Complaints-To: news-abuse@swip.net X-Trace: nntpserver.swip.net 1044836008 213.101.93.117 (Mon, 10 Feb 2003 01:13:28 MET DST) NNTP-Posting-Date: Mon, 10 Feb 2003 01:13:28 MET DST Organization: A Customer of Tele2 X-Sender: s-219882@d213-101-93-117.swipnet.se Date: Mon, 10 Feb 2003 01:13:30 +0100 Xref: archiver1.google.com comp.lang.ada:33942 Date: 2003-02-10T01:13:30+01:00 List-Id: Antti Sykari wrote: > > Hello, Hi! > - Have you encountered a non-trivial real-life case where the > programmer has shot himself in the foot in the form of > implementation-defined behavior because of the error mentioned > above? Yes. Not exactly due to aliasing but due to exceptions. Consider the following: ... procedure Calc_Routine(X : in out integer) is begin X:=X+3; ... raise Calculation_error; end Local; ... Z:=6; declare Calc_Routine(Z); exception when Calculation_Error => null; end; -- Try guessing what X is. Actually this was a bad example, and not what appeared in our code. In reality the procedure did some things with a file whose file handle was the input parameter. Then closed it, and finally did some other processing. The last calculations caused an exception. After this the calling code crashed since it believed that the file was still open. > - If there are such cases, could it have been prevented by having > different policy in the language? Do you think it would've been > better to force the programmer to specify the parameter passing > mechanism, for example? Yes and no. We had not done our homework properly. The ARM states that you cannot know how parameters are passed. With this knowledge you wont do this kind of mistaktes. The solution of this would however have been easier if we could have added something like %ref like in the good old vax-fortran days. Now we had to do a lot of restructuring and searching for similar code fragments (non found). /Leif