From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: renames usage Date: Sat, 2 Jan 2021 21:19:49 -0600 Organization: JSA Research & Innovation Message-ID: References: <5fedba8b$0$6186$426a74cc@news.free.fr> <5fedf478$0$21621$426a74cc@news.free.fr> <5fef180c$0$19476$426a74cc@news.free.fr> Injection-Date: Sun, 3 Jan 2021 03:19:50 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="18439"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:61016 List-Id: "Jeffrey R. Carter" wrote in message news:rsnckg$h6v$1@dont-email.me... > On 1/1/21 1:39 PM, DrPi wrote: >> >> Reading all the answers, I understand that : >> X : Float renames Random (Seed); >> is equivalent to : >> X : constant Float := Random (Seed); > > Technically, the renames gives a name to the anonymous temporary object > returned by the function. The constant declaration makes a constant copy > of it. So they're equivalent, but not identical. > > However, the compiler is free to optimize the copy away, and I'd be > surprised if there are any compilers that don't (except GNAT with -O0). In this case (a scalar return), the "copy" is a register, and it would be hard (and pointless) to eliminate that. It's more interesting for a function that returns a composite object, and in that case your answer is correct. Note that you can tell if a copy is made if there is a controlled component in the object. One thing we've learned in language design is that nothing is ever exactly equivalent to something else. There's always subtle differences. Typical programmers can ignore such stuff, but not language designers. Randy.