comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Renaming vs assignment to constant
Date: Fri, 6 Dec 2013 17:04:18 -0800 (PST)
Date: 2013-12-06T17:04:18-08:00	[thread overview]
Message-ID: <b5d99976-3c25-481c-9d76-9ce642fa89c4@googlegroups.com> (raw)
In-Reply-To: <030e719b-05ec-43ef-9d01-d2c473350704@googlegroups.com>

On Friday, December 6, 2013 4:48:41 PM UTC-7, adambe...@gmail.com wrote:
> 
> > I think the big difference happens when the result has subcomponents:
> >     ch   : constant Character:= 'X';             -- Character X.
> >     temp : String  renames Character'Image(ch);  -- Its image: 'X'.
> >     ch2  : Character renames temp(2);            -- The unquoted character.

Size of Ch:    Assuming 8.
Size of temp:  24 + Bounds(assuming 64).
Size of Ch2:   None, it's a reference-to/alias-of Temp(2).

Total 96 bits.

> What is the big difference between that and
>     ch   : constant Character:= 'X';                -- Character X.
>     temp : constant String := Character'Image(ch);  -- Its image: 'X'.
>     ch2  : constant Character := temp(2);           -- The unquoted character.

Size of Ch:    Assuming 8.
Size of temp:  24 + Bounds(assuming 64).
Size of Ch:    Assuming 8.

Total 104 bits.


Obviously this will really only make a real difference performance-wise when the renamed object's type is large, but there're other reasons to use renames, like component selection of deeply composed objects... but that's a different topic.

  reply	other threads:[~2013-12-07  1:04 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.
2013-12-06 20:07   ` adambeneschan
2013-12-06 21:59 ` Shark8
2013-12-06 23:48   ` adambeneschan
2013-12-07  1:04     ` Shark8 [this message]
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