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=-1.9 required=3.0 tests=BAYES_00,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: RegEx / rename of a function result Date: Wed, 6 Jul 2022 19:44:11 -0500 Organization: A noiseless patient Spider Message-ID: References: <5db8eeb4-f3fc-49a7-b588-6a4b25bdbafcn@googlegroups.com> <2e09faca-1f9a-43d3-99cb-6ae0e27a741cn@googlegroups.com> <4333d2e6-a4f6-46a8-a5df-78bb4e0d915en@googlegroups.com> <62c5b5e9$0$22251$426a34cc@news.free.fr> Injection-Date: Thu, 7 Jul 2022 00:44:13 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="ceee2e7e5de0cef646c7637fea4c8611"; logging-data="196343"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sb+TbjAnWWNXnwww9Sr4tlMmz4WZ++00=" Cancel-Lock: sha1:8JaARDx0OvJbCU0xF9wra3/N1Y4= X-Priority: 3 X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 X-RFC2646: Format=Flowed; Original X-MSMail-Priority: Normal Xref: reader01.eternal-september.org comp.lang.ada:64083 List-Id: "Thomas" wrote in message news:62c5b5e9$0$22251$426a34cc@news.free.fr... > In article , > Shark8 wrote: >> > The RENAME is interesting as I have not seen that before. Is it a >> > rename of >> > the function call (invokes the function upon reference) or a rename of >> > the >> > function result? >> That form of RENAMES is the function result. >> I've found it an excellent alternative to CONSTANT, as it signals my >> intent >> to have an alias for some result inside DECLARE blocks and certain >> internal >> objects. (eg Default_Map : Map renames Internal_Map_Generation(P1, P2); >> ... >> and then I can use "Default_Map" instead of calling the >> generation-function >> at each point and possibly messing things up should the parameters >> change.) > > why renames is better than constant in this case ? > could you explicit the difference between them, please? In theory, a renames captures the function result object, so for a composite type, you avoid copying it. That can be especially significant for controlled types, where you avoid an extra Finalization (and that might be critical if you are implementing Finalize). I believe there also are some accessibility differences that might matter in unusual cases. In most cases, however, they are essentially the same, generating essentially the same code. So it is a matter of preference which to pick. (I usually use "constant" unless avoiding a copy is necessary.) Randy.