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,FREEMAIL_FROM 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-11 00:39:55 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: gautier_niouzes@hotmail.com (Gautier) Newsgroups: comp.lang.ada Subject: Re: Ada style of passing 'in' parameters considered dangerous? Date: 11 Feb 2003 00:39:54 -0800 Organization: http://groups.google.com/ Message-ID: <17cd177c.0302110039.7f2df760@posting.google.com> References: <86isvuzabx.fsf@hoastest1-8c.hoasnet.inet.fi> <0th1a.41024$zF6.2804045@bgtnsc04-news.ops.worldnet.att.net> NNTP-Posting-Host: 213.173.163.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1044952795 26921 127.0.0.1 (11 Feb 2003 08:39:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 11 Feb 2003 08:39:55 GMT Xref: archiver1.google.com comp.lang.ada:33982 Date: 2003-02-11T08:39:55+00:00 List-Id: James S. Rogers > In Ada an IN parameter is treated as a constant within the subprogram > it is passed to. This eliminates the ability to shoot yourself in the foot > with an IN parameter. As Robert metioned, you can: an IN parameter and an IN OUT may reference the same object. In this situation, ypeee: you believe that your IN parameter is like a rock-solid, unalterable constant, but in fact it is being peacefully modified in the procedure itself! > I have never seen a case where Ada parameter modes have > shot the programmer in the foot. I have seen a case of translation (from Modula) where a lot of procedures were behaving wrong because of the above problem. Passed-by-copy parameters were translated into "in" parameters, so their eventual direct modifications were detected at compile-time, and an explicit copy was added (e.g. procedure P(a:T) is aa:T:= a; ...). But there were cases with "Q(a,b:T; c:in out T);" and calls like "Q(a,b,a)". :-) Not a warning from any compiler! ________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!