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.0 required=3.0 tests=BAYES_20,T_SCC_BODY_TEXT_LINE, XPRIO autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: About procedures and functions in Ada Pure packages. Thanks! Date: Wed, 17 Aug 2022 20:12:20 -0500 Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Thu, 18 Aug 2022 01:12:22 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="2622ec0c9258f639e76de0fc1eae5c69"; logging-data="704668"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1946jcpfxhF0SpAtzPEUQy9tVQvx+dEfHw=" Cancel-Lock: sha1:3uASthn5PNmVGCc2pQrLEzDXwaE= X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 X-Priority: 3 X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MSMail-Priority: Normal X-RFC2646: Format=Flowed; Original Xref: reader01.eternal-september.org comp.lang.ada:64204 List-Id: "Daniel Norte Moraes" wrote in message news:e1f43654-dba6-46d7-bcd9-4aa79ed82f74n@googlegroups.com... > Hi! and Very Very Very Thanks! > > I building and change some packages and I have some doubts > about procedures and functions in Ada Pure packages. > I'm asking mainly the Ada Language Lawers. the Ada version is Ada2012. > > fact 1: Ada allow the compiler substitute a function with > the result of this function. > > ?This is valid to functions with 'in out' or 'out' parameters ? > ?This is valid to functions with 'not null access' parameters ? > ?This is valid to procedures with 'in out' or 'out' parameters ? > ?This is valid to procedures with 'not null access' parameters ? Yes, but there is a requirement that the input *values* are the same on both calls, and in the case of access types, everything reachable is the same on both calls. See 10.2.1(18/3) -- http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-10-2-1.html#p18 Practically, compilers will exclude some or all of these cases. > ?If they are replaced (on the second call onwards) by the result, > will the 'in' 'in out' and 'not null access' parameters be updated > if they are changed within the function or procedure? If the "in out" parameters are changed, then the values don't match on the second call, and the optimization isn't allowed. If the values are changed to the *same* value as original, the optimization would be allowed, but you couldn't tell whether or not the values were changed, so I think the question is moot in that case. Again, I doubt that an actual compiler would try to optimize in such cases (too hard to prove that they're OK). Randy.