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,56131a5c3acc678e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-25 17:16:02 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!elnk-pas-nf1!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: Question about OO programming in Ada References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Wed, 26 Nov 2003 01:16:02 GMT NNTP-Posting-Host: 63.184.9.194 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.pas.earthlink.net 1069809362 63.184.9.194 (Tue, 25 Nov 2003 17:16:02 PST) NNTP-Posting-Date: Tue, 25 Nov 2003 17:16:02 PST Xref: archiver1.google.com comp.lang.ada:2950 Date: 2003-11-26T01:16:02+00:00 List-Id: Ekkehard Morgenstern wrote: > First of all, how do I accomplish returning a reference in Ada? What > is the default behaviour of parameter passing and return in Ada? > Someone said here that if I use an "in" parameter in a procedure or > function definition, the object will be passed by reference. What > about the returing of objects? Are they returned by copy or returned > by reference? Parameter modes (in, in out, out) have NOTHING to do with parameter passing mechanisms. "In" means the subprogram cannot modify the parameter; "in out" that the caller provides a value and the subprogram modifies it; and "out" that the subprogram creates a value in the parameter. Elementary types (scalars and access types) are always passed by copy, regardless of the parameter mode. Limited types and tagged types are always passed by reference, regardless of the parameter mode. Other types are passed by whichever method the compiler determines is best. For the gory details, see ARM 6.2. Like many people from a C/++ background, you're thinking at much too low a level. As a beginner, you should not be using access types unless you're creating dynamic data structures. You should not be worrying about parameter passing mechanisms or how values are returned from a function. Ada takes care of this for you, and generally does a pretty good job. Unless you're doing hard real-time software, you probably don't need to worry about how good a job the compiler is doing. > I will read the Ada book when I receive it! :-) While you're waiting, I suggest you work through one or more of the tutorials, and read one of the books, available online through www.adapower.com or www.adaworld.com. -- Jeff Carter "Sheriff murdered, crops burned, stores looted, people stampeded, and cattle raped." Blazing Saddles 35