comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <rm-dash-bau-haus@dash.futureapps.de>
Subject: Re: Renaming vs assignment to constant
Date: Fri, 06 Dec 2013 19:35:12 +0100
Date: 2013-12-06T19:35:13+01:00	[thread overview]
Message-ID: <52a218e1$0$9512$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <lypppaj9jo.fsf@pushface.org>

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.

  parent reply	other threads:[~2013-12-06 18:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06 15:14 Renaming vs assignment to constant Simon Wright
2013-12-06 16:09 ` Jeffrey Carter
2013-12-06 18:03   ` AdaMagica
2013-12-06 18:24     ` Jeffrey Carter
2013-12-06 16:47 ` adambeneschan
2013-12-06 18:06   ` Eryndlia Mavourneen
2013-12-07  0:47   ` Randy Brukardt
2013-12-07  1:55     ` Shark8
2013-12-06 18:35 ` G.B. [this message]
2013-12-06 20:07   ` adambeneschan
2013-12-06 21:59 ` Shark8
2013-12-06 23:48   ` adambeneschan
2013-12-07  1:04     ` Shark8
2013-12-07  1:26       ` adambeneschan
2013-12-07  6:17       ` J-P. Rosen
2013-12-07  6:22         ` J-P. Rosen
2013-12-07  8:57   ` Dmitry A. Kazakov
2013-12-07  9:02     ` Dmitry A. Kazakov
replies disabled

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