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=-0.9 required=3.0 tests=BAYES_00,XPRIO autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Question on in/out parameters Date: Mon, 2 May 2022 16:35:29 -0500 Organization: A noiseless patient Spider Message-ID: References: <85d12db3-e308-46bc-9be6-20b48ebe4fd2n@googlegroups.com> Injection-Date: Mon, 2 May 2022 21:35:30 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="dffbaacecbf208fb9cb9f079fd8667ba"; logging-data="17006"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fPJpID/+fEvnr2s13k4P662drSwoiObc=" Cancel-Lock: sha1:rDTdsvNP4K5lpKhqyI9jTJUxgPo= X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 X-RFC2646: Format=Flowed; Original X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-Priority: 3 X-MSMail-Priority: Normal Xref: reader02.eternal-september.org comp.lang.ada:63798 List-Id: "reinert" wrote in message news:85d12db3-e308-46bc-9be6-20b48ebe4fd2n@googlegroups.com... >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? It depends on the data type; there is a complex series of rules about what is passed in for an out parameter. The basic idea is that stuff like bounds and discriminants are passed in, while other things may or may not be passed in. Probably it is best to think of the distinction between in out and out parameters as being for the programmer, as noted by Jean-Pierre. When you say "out", you are asserting that you do not care what is passed in -- it could be in any state or even uninitialized. When you say "in out", you expect a value that you can use in the subprogram, so it has to meet the constraints and other requirements. For instance, "out" parameters are checked as little as possible on the way in, while an "in out" parameter has all of the checking one might expect. Of course, if you are working with a well-designed ADT (as in the case of the containers), the difference between an unchecked item and a fully checked item is minimal. If you were working with an elementary type like an integer or access type, the input value may not be initialized at all. Hope this helps. Randy.