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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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 23:16:12 PST Path: archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Pass by reference Date: Thu, 08 Apr 2004 20:21:03 +0200 Organization: AdaCL Message-ID: <54077117.Uc4Ikxz6le@linux1.krischik.com> References: <19b0e504.0404080652.4eab9f80@posting.google.com> Reply-To: krischik@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1081491259 05 19813 qllIGKrv3yLYL9P 040409 06:14:19 X-Complaints-To: usenet-abuse@t-online.de X-ID: r2h7NuZroelOozRq+zc+UNmGmwLteNWmXigULU8SbYDxgOznF5d7Eq User-Agent: KNode/0.7.7 Xref: archiver1.google.com comp.lang.ada:6883 Date: 2004-04-08T20:21:03+02: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? Good Ada compiler will do what is best. So "array (1 .. 2) of Character" is likely to be passed by value while "array (1 .. 10_000) of Integer" is probably passed by reference. And some Ada compilers might even use pass by register. This might sound strange to a C, C++ or C# programmer. Like giving up control. There are things humans can do better then computers but there are also things computers can do better then humans - and counting is is among those. The compiler knows much better how many registers are available, how large the type is, how long it takes to copy and so on. You say what you need (in, out, in out) and the compiler will choose the optimal way to fullfill you which. > 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. They are in deed allways passed by reference. That's done to enable dispaching. Rermember: all native procedures of a tagged type are "virtual". Two ways around that behavior: 1st: for any tagged type X there is indefinite type X'Class. X'Class is an indefinite but untagged type so RM 6.2 does not apply here. 2nt: RM 6.2 does not apply to a non native procedure. That is a procedure in another package. With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com