comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: RegEx / rename of a function result
Date: Wed, 6 Jul 2022 19:44:11 -0500	[thread overview]
Message-ID: <ta5a8t$5vnn$1@dont-email.me> (raw)
In-Reply-To: 62c5b5e9$0$22251$426a34cc@news.free.fr

"Thomas" <fantome.forums.tDeContes@free.fr.invalid> wrote in message 
news:62c5b5e9$0$22251$426a34cc@news.free.fr...
> In article <a6e2e912-8aa6-4ecf-9118-9dd29a967734n@googlegroups.com>,
> Shark8 <onewingedshark@gmail.com> 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.


  parent reply	other threads:[~2022-07-07  0:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 19:31 deferred constants Matt Borchers
2021-07-07 20:40 ` Jeffrey R. Carter
2021-07-07 20:41 ` Stephen Leake
2021-07-07 20:44 ` Shark8
2021-07-07 23:15   ` Matt Borchers
2021-07-07 23:37     ` Shark8
2022-07-06 16:18       ` RegEx / rename of a function result Thomas
2022-07-06 17:56         ` J-P. Rosen
2022-07-06 19:11           ` Jeffrey R.Carter
2022-07-07  5:51             ` RegEx / rename of a function resultRig J-P. Rosen
2022-07-11 17:49           ` RegEx / rename of a function result Thomas
2022-07-12  5:13             ` J-P. Rosen
2022-07-12 14:45               ` G.B.
2022-07-07  0:44         ` Randy Brukardt [this message]
2022-07-11 17:45           ` Thomas
2022-07-12  6:54             ` Randy Brukardt
2021-07-08  1:21     ` deferred constants Stephen Leake
2021-07-08 14:18       ` Maxim Reznik
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox