comp.lang.ada
 help / color / mirror / Atom feed
From: Thomas <fantome.forums.tDeContes@free.fr.invalid>
Subject: Re: RegEx / rename of a function result
Date: Mon, 11 Jul 2022 19:45:53 +0200	[thread overview]
Message-ID: <62cc61d1$0$22254$426a34cc@news.free.fr> (raw)
In-Reply-To: ta5a8t$5vnn$1@dont-email.me

In article <ta5a8t$5vnn$1@dont-email.me>,
 "Randy Brukardt" <randy@rrsoftware.com> wrote:

> "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); 

> >
> > 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

yes, i remember that i had to use a renames with a limited type :-)



> I believe there also are some 
> accessibility differences that might matter in unusual cases.

> it is a matter of preference which to pick. (I 
> usually use "constant" unless avoiding a copy is necessary.)

(i don't know if that's the case of "some accessibility differences": )

i don't like that constant keyword is forbidden in a renames.


i find it less readable when the pointed object is constant,
since it is not remembered at the point of the renames, and one could 
think that it can be changed.
in other words, at the review time we have to check at the source of the 
renames to know if it is constant or not.


moreover, when the pointed object is variable,
constant keyword in a renames could mean that the variable could not be 
modified when used with the "constant renames" identifier.

i understand that it conflicts with the rule: "the constant keyword 
means that the value never changes"

i suppose that some people already thought about that ...

but i don't understant what kind of pb there can be with the 1st case,
so i would find nice to have the constant keyword when the pointed 
object is one, even if it stay forbidden in the other case.



(sorry for my english, I did not sleep well)

-- 
RAPID maintainer
http://savannah.nongnu.org/projects/rapid/

  reply	other threads:[~2022-07-11 17:45 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
2022-07-11 17:45           ` Thomas [this message]
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