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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,daca227a72518885 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-08 14:48:48 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed1.e.nsc.no!nsc.no!nextra.com!uio.no!newsfeed1.uni2.dk!news.get2net.dk.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Unbounded Strings References: <20031007175516.DC2884C40C8@lovelace.ada-france.org> <_XYgb.3237$dn6.2766@newsread4.news.pas.earthlink.net> From: Mark Lorenzen Message-ID: User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux) Cancel-Lock: sha1:xCh1rjQum3XyI6WyHa3w5/KY5q0= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 09 Oct 2003 01:55:08 +0200 NNTP-Posting-Host: 62.84.221.216 X-Complaints-To: abuse@colt-telecom.dk X-Trace: news.get2net.dk 1065649728 62.84.221.216 (Wed, 08 Oct 2003 23:48:48 CEST) NNTP-Posting-Date: Wed, 08 Oct 2003 23:48:48 CEST Organization: Colt Telecom Kunde Xref: archiver1.google.com comp.lang.ada:499 Date: 2003-10-09T01:55:08+02:00 List-Id: Jeffrey Carter writes: > Andrew Carroll wrote: > [snip] > >> I found myself desingning more and debugging less. There were still >> problems >> of course, such as pass by value or pass by reference; I didn't know what to >> use >> nor did I know if I had to specify it. I found out when I created my first >> graph, >> you have to specify out paramter or in and out for the parameter or you get >> a >> copy instead of the actual "thing". > > This represents a serious misunderstanding of Ada parameter modes. All > elementary types are passed by copy, regardless of the parameter > mode. All tagged and limited types are passed by reference, regardless > of the parameter mode. For all other types, the compiler chooses the > parameter mode best suited to the type. Mode in means the subprogram > receives a value from the caller, and cannot modify it; out means the > subprogram provides a value to the caller, and in out means the caller > provides a value which the subprogram may modify. Parameter modes have > nothing to do with parameter passing mechanisms. See ARM 6.2. > Hint to Andrew: Don't think about _how_ parameters are passed (i.e. by copy or by reference) for "For all other types" as Jeffrey says above. Use "in", "in out" and "out" to express your _intentions_ with the parameters. Don't worry about efficientcy - the compiler will do "the right thing". - Mark