From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!newsfeed.fsmpi.rwth-aachen.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Fri, 06 Dec 2013 19:35:12 +0100 From: "G.B." User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Renaming vs assignment to constant References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <52a218e1$0$9512$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 06 Dec 2013 19:35:13 CET NNTP-Posting-Host: 060208d3.newsspool1.arcor-online.net X-Trace: DXC=1:mf;EP6RQHAa;:RKVJ>LEic==]BZ:afN4Fo<]lROoRAnkgeX?EC@@@V59:cPRXS:Fnc\616M64>JLh>_cHTX3jMfI=SO;oMCBJ X-Complaints-To: usenet-abuse@arcor.de Xref: news.eternal-september.org comp.lang.ada:17876 Date: 2013-12-06T19:35:13+01:00 List-Id: On 06.12.13 16:14, Simon Wright wrote: > A poster on Stack Overflow wrote > > Now : Time renames Clock; > > (using Ada.Calendar) which made me blink until I realised that it is the > equivalent of > > Now : constant Time := Clock; > > GNAT generates the same code for these two forms. Is there a difference? > Which form is preferred? Generated code is (or was) more efficient for arrays because the array object renamed isn't (or wasn't) copied into the constant. FTR, with limited types returned by reference (Ada 95), a difference between renaming and a constant declaration is that the former is possible. type Id is range 1 .. 3; type LT is limited private; function Choose (Choice : Id) return LT; X : LT renames Choose (2); Some_Op (Choose (1)); Today, returning an *existing* limited object requires the use of a pointer, IINM.