From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: Question on in/out parameters Date: Sat, 30 Apr 2022 11:38:06 +0200 Organization: A noiseless patient Spider Message-ID: References: <85d12db3-e308-46bc-9be6-20b48ebe4fd2n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 30 Apr 2022 09:38:06 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="aeef42cce4c4d709da74e3fa66e7b2aa"; logging-data="13944"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/S4dH5g3oAws/TSnnS2RdUWexRajS4CYA=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Cancel-Lock: sha1:ulvfsIOa/jFeldOy18hOt2j5TCU= In-Reply-To: <85d12db3-e308-46bc-9be6-20b48ebe4fd2n@googlegroups.com> Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63787 List-Id: On 2022-04-30 10:57, reinert wrote: > > I expected an "out" parameter in a procedure to be like declaring the parameter "from scratch" (with actual initial default value). For my compiler (GNAT Community Edition, May 2021) it seems like the out parameters brings in content from the calling procedure. Should it be like this? Parameters in Ada are either passed by copy or passed by reference, regardless of parameter mode. The rules are * Scalar types are always passed by copy * Tagged types are always passed by reference * Limited types are always passed by reference * All other types are decided by the compiler For the types that are passed by reference, "in out" and "out" mode are identical. Vector is a tagged type, so this applies to it. One can argue that an out-mode parameter of a by-reference type should be "reinitialized" before use, but the Ada-9X revision decided not to require this. -- Jeff Carter "Hello! Smelly English K...niggets." Monty Python & the Holy Grail 08