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,9f3d09bde7b33b5d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-08 18:15:01 PST Path: archiver1.google.com!news1.google.com!news.glorb.com!wn52feed!worldnet.att.net!207.217.77.102!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Pass by reference References: <19b0e504.0404080652.4eab9f80@posting.google.com> In-Reply-To: <19b0e504.0404080652.4eab9f80@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 09 Apr 2004 01:15:01 GMT NNTP-Posting-Host: 63.184.33.195 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.pas.earthlink.net 1081473301 63.184.33.195 (Thu, 08 Apr 2004 18:15:01 PDT) NNTP-Posting-Date: Thu, 08 Apr 2004 18:15:01 PDT Xref: archiver1.google.com comp.lang.ada:6874 Date: 2004-04-09T01:15:01+00:00 List-Id: Dan McLeran wrote: > I am investigating using Ada for a project at work and I have a > question I hope someone can answer. If I am interpreting the RM > section 6.2 correctly, an array of elementary types does not meet the > criteria of a by-reference type. But, when looking at the disassembly, > it seems that passing an array of elementary types to a function as an > in-mode parameter is passing by reference. Does this mean that an > array of elementary types is an unspecfied type? > > A 2nd part to my question is: Does Ada automatically pass tagged types > by reference no matter what mode the parameter is specfied (in, in > out, or out)? The language RM 6.2 seems to suggest this is so. If so, > does this mean that there is no way to pass a tagged type by value? I > believe C# works this way without programmer intervention. The Ada rules, simple version, for parameter passing mechanisms, are: Elementary types are always passed by copy. Tagged and private types are always passed by reference. Other types have the mechanism chosen by the compiler. The parameter mode (in, in out, and out) is completely unrelated to the parameter passing mechanism. Generally, compilers do a good job of choosing the mechanism for "other types". It might be informative to check the mechanism used for type T is array (1 .. Integer'Size) of Boolean; pragma Pack (T); -- Jeff Carter "Sons of a silly person." Monty Python & the Holy Grail 02