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-08 18:27:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!newsfeed.news2me.com!newsfeed2.earthlink.net!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3E45BC6E.6000701@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, 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> <0th1a.41024$zF6.2804045@bgtnsc04-news.ops.worldnet.att.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 09 Feb 2003 02:25:45 GMT NNTP-Posting-Host: 63.184.17.141 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1044757545 63.184.17.141 (Sat, 08 Feb 2003 18:25:45 PST) NNTP-Posting-Date: Sat, 08 Feb 2003 18:25:45 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:33924 Date: 2003-02-09T02:25:45+00:00 List-Id: James S. Rogers wrote: > > 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. An OUT or IN OUT parameter can be passed > by value or by reference. The language provides no rules about this. > The difference between the two in Ada is that an OUT parameter > has no reliable initial value, while an IN OUT parameter does. > In fact compiler writers are quite reasonable about their chosen > passing mechanisms. In general, any value larger than a register > is passed by reference. All other values may be passed by copy > or by reference. This is not entirely correct. In Ada, all elementary types are passed by copy, regardless of the parameter mode. Elementary types are all numeric types, all enumeration types, and all access types. All limited types and all tagged types are passed by reference, regardless of the parameter mode. The parameter passing mechanism for all other types is not defined by the language. Most compilers do a good job of choosing a parameter passing mechanism for such types. Finally, the rules for out-mode parameters provide for many cases in which a reliable initial value does exist and the parameter effectively has mode in out. This includes all record types that have a component with a default initial value. -- Jeff Carter "Death awaits you all, with nasty, big, pointy teeth!" Monty Python & the Holy Grail