From: Adam Beneschan <adam@irvine.com>
Subject: Re: Will "renames" increase program size?
Date: Thu, 16 Jun 2011 08:40:41 -0700 (PDT)
Date: 2011-06-16T08:40:41-07:00 [thread overview]
Message-ID: <2e8222df-9b82-497f-9dc4-5cb0d5653550@f31g2000pri.googlegroups.com> (raw)
In-Reply-To: gykghxms6uix.4o3teocknpfl$.dlg@40tude.net
On Jun 16, 1:59 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
>
> > That's not correct. A renaming does not copy nor somehow create new
> > entities, it only creates new names for the same thing. Since
> > visibility is via names, you arrive at unresolvability issues.
>
> No. First, sometimes it certainly copies, e.g. when the function's result
> is renamed, the result (temporary object) is copied. The compiler might
> optimize the temporary object away, or even mandated to do so for limited
> results, but *semantically* it is a copy.
I don't think that's right. The test would be:
type T1 is new Ada.Finalization.Controlled with record
F1 : Integer;
end record;
overriding
procedure Adjust (Obj : in out T1);
function Func (N : Integer) return T1 is
begin
return Ret : T1 do
T1.F1 := N;
end return;
end Func;
procedure Proc is
R : T1 renames Func(3);
begin
...
end Proc;
In this example, I believe that the renaming declaration cannot
legally cause Adjust to be called. (This is in contrast with
R : T1 := Func(3);
in which case the semantics specify that Adjust should be called, but
I think there are implementation permissions that would allow the
compiler to optimize the Adjust away.)
In the renaming case, as I read the RM, the extended return creates a
return object, the function call denotes a constant view of the return
object, and the renaming denotes a new view of the return object.
There's no copying or assignment involved. (Of course, the compiler
could generate some sort of block-copy to implement this, but I think
we're talking about Ada semantics. I don't think our compiler
generates a block copy.)
-- Adam
next prev parent reply other threads:[~2011-06-16 15:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-15 2:10 Will "renames" increase program size? Adrian Hoe
2011-06-15 5:37 ` Randy Brukardt
2011-06-15 9:11 ` AdaMagica
2011-06-15 11:26 ` Yannick Duchêne (Hibou57)
2011-06-15 11:24 ` Yannick Duchêne (Hibou57)
2011-06-15 13:15 ` Dmitry A. Kazakov
2011-06-16 6:59 ` AdaMagica
2011-06-16 8:59 ` Dmitry A. Kazakov
2011-06-16 10:18 ` AdaMagica
2011-06-16 12:15 ` Dmitry A. Kazakov
2011-06-16 23:22 ` Randy Brukardt
2011-06-16 15:40 ` Adam Beneschan [this message]
2011-06-16 16:33 ` Dmitry A. Kazakov
2011-06-16 17:42 ` Adam Beneschan
2011-06-16 18:53 ` Dmitry A. Kazakov
2011-06-16 23:39 ` Randy Brukardt
2011-06-17 6:53 ` Dmitry A. Kazakov
2011-06-18 0:02 ` Randy Brukardt
2011-06-18 7:54 ` Dmitry A. Kazakov
2011-06-18 8:58 ` Yannick Duchêne (Hibou57)
2011-06-18 10:05 ` Dmitry A. Kazakov
2011-06-18 12:49 ` Yannick Duchêne (Hibou57)
2011-06-18 22:44 ` Randy Brukardt
2011-06-22 0:56 ` Shark8
2011-06-15 22:21 ` anon
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox