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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable 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 17:08:43 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!proxad.net!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Pass by reference Date: 08 Apr 2004 20:01:37 -0400 Organization: Cuivre, Argent, Or Message-ID: References: <19b0e504.0404080652.4eab9f80@posting.google.com> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: melchior.cuivre.fr.eu.org 1081468909 61041 212.85.156.195 (9 Apr 2004 00:01:49 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Fri, 9 Apr 2004 00:01:49 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: <19b0e504.0404080652.4eab9f80@posting.google.com> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:6870 Date: 2004-04-08T20:01:37-04:00 dan.r.mcleran@seagate.com (Dan McLeran) writes: > I am investigating using Ada for a project at work Excellent choice :). > 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. A 'by-reference type' is simply one that is always passed by reference, never by copy. > 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? The compiler is always free to choose either copy or reference for passing parameters. I'm not clear what you mean by "unspecified type". Hmm, perhaps you are refering to 6.2(11): For parameters of other types, it is unspecified whether the parameter is passed by copy or by reference. Yes, an array of elementary types is an "other type" in this sense; it may be passed either by reference or copy. The compiler will choose whichever mechanism it feels is "best". > 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. Yes. > If so, does this mean that there is no way to pass a tagged type by > value? Yes. > I believe C# works this way without programmer intervention. Don't know. > I am using Aonix's ObjectAda V7.2.2, by the way. I have not tried > GNAT for comparison. Ok. A couple of larger questions; Why do you care whether a type is passed by copy or reference? If you are worried about time or space efficiency, specify the appropriate option to the compiler, and forget about it, until measurements of your final application show a problem. Why would you want to pass a tagged type by copy? You might want to read the Ada Rationale, and the annotated Ada Reference manual, on this topic. See http://www.adaic.com/standards/ada95.html -- -- Stephe